Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8125896

BarChart replaces the style classes for existing bar nodes.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 7u9
    • javafx
    • Windows 7
      java version "1.7.0_09"
      Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

      In the BarChart.createBar(Series, int, Data, int) method, the bar.getStyleClass.setAll(...) method is used to set the bar node's style classes, which removes any existing style classes before adding the additional style classes. The following test demonstrates the problem:

      {code:java}
      CategoryAxis xAxis = new CategoryAxis();
      NumberAxis yAxis = new NumberAxis();
      BarChart<String, Number> myChart = new BarChart<>(xAxis, yAxis);

      XYChart.Series<String, Number> series = new XYChart.Series<>();
      ObservableList<Data<String, Number>> seriesData = series.getData();

      String xValue = "A";
      Number yValue = Integer.valueOf(20);

      Data<String, Number> item = new XYChart.Data<>(xValue, yValue);

      Node bar = item.getNode();
      if (bar == null) {
          bar = new StackPane();
      }

      String myStyleClass = "my-style";
      bar.getStyleClass().add(myStyleClass);

      item.setNode(bar);
      seriesData.add(item);

      myChart.getData().add(series);

      assert bar.getStyleClass().contains(myStyleClass);
      {code}

      Using bar.getStyleClass.addAll(...) would allow style classes to be set at the time of item creation.

            psomashe Parvathi Somashekar (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: