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

[LineChart] Calling setAutoRanging on LineChart with false and then true doesn't work

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      Mac OS X Yosemite

      Description

      Run sample program. Chart starts out in auto ranging mode. Click the '1-5' button. The y axis changes to show custom parameters. Click the 'auto' button. The y axis doesn't draw itself correctly. The range should go back to 0 - 5.5 but instead it is 0 - 5.0. The chart itself is correct but the axis is drawn incorrectly. If you resize the window, the axis is then redrawn correctly.

      Sample program:

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.chart.LineChart;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.XYChart;
      import javafx.scene.control.Button;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class ChartTest extends Application {
      public void start(Stage primaryStage) throws Exception {
      ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList();
      data.add(new XYChart.Data<>(1, 1));
      data.add(new XYChart.Data<>(2, 2));
      data.add(new XYChart.Data<>(3, 3));
      data.add(new XYChart.Data<>(4, 4));
      data.add(new XYChart.Data<>(5, 5));

      ObservableList<XYChart.Series<Number, Number>> series = FXCollections.observableArrayList();
      series.add(new XYChart.Series<>("One", data));

      NumberAxis xAxis = new NumberAxis("X", 0, 10, 1);
      NumberAxis yAxis = new NumberAxis("Y", 0, 10, 1);
      xAxis.setAutoRanging(true);
      yAxis.setAutoRanging(true);
      LineChart chart = new LineChart<>(xAxis, yAxis, series);

      Button autoButton = new Button("Auto");
      Button customButton = new Button("1-5");
      HBox buttonBox = new HBox(10, autoButton, customButton);

      BorderPane bp = new BorderPane(chart);
      bp.setTop(buttonBox);

      autoButton.setOnAction(e -> yAxis.setAutoRanging(true));
      customButton.setOnAction(e -> {
      yAxis.setAutoRanging(false);
      yAxis.setLowerBound(0);
      yAxis.setUpperBound(5);
      yAxis.setTickUnit(1);
      yAxis.setMinorTickCount(5);
      });
      Scene scene = new Scene(bp);
      primaryStage.setScene(scene);
      primaryStage.show();
      }
      }

        Attachments

          Activity

            People

            • Assignee:
              msladecek Martin Sládeček
              Reporter:
              cstanford Curtis Stanford
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: