changeset 1441:6c543a637228

fix RT-21164 BarChart: Adding several bars in a row produces upside down bars.
author Paru Somashekar <paru.somashekar@oracle.com>
date Thu, 12 Jul 2012 15:56:15 -0700
parents 74b5a4b24935
children 231378f0f928
files javafx-ui-charts/src/javafx/scene/chart/BarChart.java
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-charts/src/javafx/scene/chart/BarChart.java	Thu Jul 12 15:54:27 2012 -0700
+++ b/javafx-ui-charts/src/javafx/scene/chart/BarChart.java	Thu Jul 12 15:56:15 2012 -0700
@@ -256,7 +256,9 @@
              item.getNode().getStyleClass().add("negative");
          } else if (currentVal < 0 && barVal > 0) { // going from negative to positive
              // remove style class negative
-             item.getNode().getStyleClass().add("negative");
+             // RT-21164 upside down bars: was adding "negative" styleclass
+             // instead of removing it; when going from negative to positive
+             item.getNode().getStyleClass().remove("negative");
          }
     }
     
@@ -314,6 +316,12 @@
             if (shouldAnimate()) {
                 animateDataAdd(item, bar);
             } else {
+                // RT-21164 check if bar value is negative to add "negative" style class 
+                double barVal = (orientation == Orientation.VERTICAL) ? ((Number)item.getYValue()).doubleValue() :
+                        ((Number)item.getXValue()).doubleValue();
+                if (barVal < 0) {
+                    bar.getStyleClass().add("negative");
+                }
                 getPlotChildren().add(bar);
             }
         }