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

[Charts, CategoryAxis] x labels remain vertical after resize

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8u20
    • 8
    • javafx
    • None

      1) Run BarChartSample_RT35076
      2) Ensure that the x labels are horizontal (if not edit code to increase stage width and rerun)
      3) Resize the stage horizontally to be smaller (x labels should resize vertically)
      4) Resize the stage horizontally to be wide again (BUG: x labels remain vertical after resize)
      5) The button can be used to force the x labels to be horizontal again

      package bugs;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.chart.BarChart;
      import javafx.scene.chart.CategoryAxis;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.XYChart;
      import javafx.scene.control.Button;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class BarChartSample_RT35076 extends Application {
          final static String austria = "Austria";
          final static String brazil = "Brazil";
          final static String france = "France";
          final static String italy = "Italy";
          final static String usa = "USA";
          final static String india = "India";
          final static String singapore = "Singapore";

          @Override
          public void start(Stage stage) {
              stage.setTitle("Bar Chart Sample");
              final CategoryAxis xAxis = new CategoryAxis();
              final NumberAxis yAxis = new NumberAxis();
              final BarChart<String,Number> bc =
                  new BarChart<String,Number>(xAxis,yAxis);
              bc.setTitle("Country Summary");
              xAxis.setLabel("Country");
              yAxis.setLabel("Value");

              XYChart.Series series1 = new XYChart.Series();
              series1.setName("2003");
              series1.getData().add(new XYChart.Data(austria, 25601.34));
              series1.getData().add(new XYChart.Data(brazil, 20148.82));
              series1.getData().add(new XYChart.Data(france, 10000));
              series1.getData().add(new XYChart.Data(italy, 35407.15));
              series1.getData().add(new XYChart.Data(usa, 12000));
              series1.getData().add(new XYChart.Data(india, 11000));
              series1.getData().add(new XYChart.Data(singapore, 8000));

              Button button = new Button ("Resize first, then use setTickLabelRotation(0) to force horizontal reset");
              button.setOnAction((e) -> {
                  System.out.println("OLD ROTATION=" + xAxis.getTickLabelRotation());
                  xAxis.setTickLabelRotation(0);
                  System.out.println("NEW ROTATION=" + xAxis.getTickLabelRotation());
              });
              VBox box = new VBox();
              box.getChildren().addAll(bc, button);
              
              Scene scene = new Scene(box,600,600);
              bc.getData().addAll(series1);
              stage.setScene(scene);
              stage.show();
              
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }

            msladecek Martin Sládeček
            snorthov Steve Northover (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: