226 final Node bar = item.getNode();
227
228 if (bar != null) {
229 bar.focusTraversableProperty().unbind();
230 }
231
232 if (shouldAnimate()) {
233 XYValueMap.clear();
234 dataRemoveTimeline = createDataRemoveTimeline(item, bar, series);
235 dataRemoveTimeline.setOnFinished(event -> {
236 item.setSeries(null);
237 removeDataItemFromDisplay(series, item);
238 });
239 dataRemoveTimeline.play();
240 } else {
241 processDataRemove(series, item);
242 removeDataItemFromDisplay(series, item);
243 }
244 }
245
246 /** @inheritDoc */
247 @Override protected void dataItemChanged(Data<X, Y> item) {
248 double barVal;
249 double currentVal;
250 if (orientation == Orientation.VERTICAL) {
251 barVal = ((Number)item.getYValue()).doubleValue();
252 currentVal = ((Number)item.getCurrentY()).doubleValue();
253 } else {
254 barVal = ((Number)item.getXValue()).doubleValue();
255 currentVal = ((Number)item.getCurrentX()).doubleValue();
256 }
257 if (currentVal > 0 && barVal < 0) { // going from positive to negative
258 // add style class negative
259 item.getNode().getStyleClass().add(NEGATIVE_STYLE);
260 } else if (currentVal < 0 && barVal > 0) { // going from negative to positive
261 // remove style class negative
262 // RT-21164 upside down bars: was adding NEGATIVE_STYLE styleclass
263 // instead of removing it; when going from negative to positive
264 item.getNode().getStyleClass().remove(NEGATIVE_STYLE);
265 }
266 }
326 // fade out last series
327 FadeTransition ft = new FadeTransition(Duration.millis(700),bar);
328 ft.setFromValue(1);
329 ft.setToValue(0);
330 ft.setOnFinished(actionEvent -> {
331 processDataRemove(series, d);
332 bar.setOpacity(1.0);
333 });
334 pt.getChildren().add(ft);
335 }
336 }
337 pt.play();
338 } else {
339 for (Data<X,Y> d : series.getData()) {
340 processDataRemove(series, d);
341 }
342 removeSeriesFromDisplay(series);
343 }
344 }
345
346 /** @inheritDoc */
347 @Override protected void layoutPlotChildren() {
348 double catSpace = categoryAxis.getCategorySpacing();
349 // calculate bar spacing
350 final double availableBarSpace = catSpace - (getCategoryGap() + getBarGap());
351 double barWidth = (availableBarSpace / getSeriesSize()) - getBarGap();
352 final double barOffset = -((catSpace - getCategoryGap()) / 2);
353 final double zeroPos = (valueAxis.getLowerBound() > 0) ?
354 valueAxis.getDisplayPosition(valueAxis.getLowerBound()) : valueAxis.getZeroPosition();
355 // RT-24813 : if the data in a series gets too large, barWidth can get negative.
356 if (barWidth <= 0) barWidth = 1;
357 // update bar positions and sizes
358 int catIndex = 0;
359 for (String category : categoryAxis.getCategories()) {
360 int index = 0;
361 for (Iterator<Series<X, Y>> sit = getDisplayedSeriesIterator(); sit.hasNext(); ) {
362 Series<X, Y> series = sit.next();
363 final Data<X,Y> item = getDataItem(series, index, catIndex, category);
364 if (item != null) {
365 final Node bar = item.getNode();
366 final double categoryPos;
|
226 final Node bar = item.getNode();
227
228 if (bar != null) {
229 bar.focusTraversableProperty().unbind();
230 }
231
232 if (shouldAnimate()) {
233 XYValueMap.clear();
234 dataRemoveTimeline = createDataRemoveTimeline(item, bar, series);
235 dataRemoveTimeline.setOnFinished(event -> {
236 item.setSeries(null);
237 removeDataItemFromDisplay(series, item);
238 });
239 dataRemoveTimeline.play();
240 } else {
241 processDataRemove(series, item);
242 removeDataItemFromDisplay(series, item);
243 }
244 }
245
246 /** {@inheritDoc} */
247 @Override protected void dataItemChanged(Data<X, Y> item) {
248 double barVal;
249 double currentVal;
250 if (orientation == Orientation.VERTICAL) {
251 barVal = ((Number)item.getYValue()).doubleValue();
252 currentVal = ((Number)item.getCurrentY()).doubleValue();
253 } else {
254 barVal = ((Number)item.getXValue()).doubleValue();
255 currentVal = ((Number)item.getCurrentX()).doubleValue();
256 }
257 if (currentVal > 0 && barVal < 0) { // going from positive to negative
258 // add style class negative
259 item.getNode().getStyleClass().add(NEGATIVE_STYLE);
260 } else if (currentVal < 0 && barVal > 0) { // going from negative to positive
261 // remove style class negative
262 // RT-21164 upside down bars: was adding NEGATIVE_STYLE styleclass
263 // instead of removing it; when going from negative to positive
264 item.getNode().getStyleClass().remove(NEGATIVE_STYLE);
265 }
266 }
326 // fade out last series
327 FadeTransition ft = new FadeTransition(Duration.millis(700),bar);
328 ft.setFromValue(1);
329 ft.setToValue(0);
330 ft.setOnFinished(actionEvent -> {
331 processDataRemove(series, d);
332 bar.setOpacity(1.0);
333 });
334 pt.getChildren().add(ft);
335 }
336 }
337 pt.play();
338 } else {
339 for (Data<X,Y> d : series.getData()) {
340 processDataRemove(series, d);
341 }
342 removeSeriesFromDisplay(series);
343 }
344 }
345
346 /** {@inheritDoc} */
347 @Override protected void layoutPlotChildren() {
348 double catSpace = categoryAxis.getCategorySpacing();
349 // calculate bar spacing
350 final double availableBarSpace = catSpace - (getCategoryGap() + getBarGap());
351 double barWidth = (availableBarSpace / getSeriesSize()) - getBarGap();
352 final double barOffset = -((catSpace - getCategoryGap()) / 2);
353 final double zeroPos = (valueAxis.getLowerBound() > 0) ?
354 valueAxis.getDisplayPosition(valueAxis.getLowerBound()) : valueAxis.getZeroPosition();
355 // RT-24813 : if the data in a series gets too large, barWidth can get negative.
356 if (barWidth <= 0) barWidth = 1;
357 // update bar positions and sizes
358 int catIndex = 0;
359 for (String category : categoryAxis.getCategories()) {
360 int index = 0;
361 for (Iterator<Series<X, Y>> sit = getDisplayedSeriesIterator(); sit.hasNext(); ) {
362 Series<X, Y> series = sit.next();
363 final Data<X,Y> item = getDataItem(series, index, catIndex, category);
364 if (item != null) {
365 final Node bar = item.getNode();
366 final double categoryPos;
|