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

Y axis is too wide under some conditions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • 8u60
    • 8u40
    • javafx
    • JavaFX 8u40, JDK 8u40 64bit, Windows 7 64bit, NetBeans 8.0.2

    Description

      Under some conditions, the Y axis of XYChart instances is taking too much horizontal space.

      package test;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.chart.LineChart;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class Test_ChartYAxis extends Application {
          
          @Override
          public void start(Stage primaryStage) {
              final NumberAxis xAxis = new NumberAxis(0, 10, 1);
              final NumberAxis yAxis = new NumberAxis(0, 2.2, 0.2);
              yAxis.setStyle("-fx-border-color: green;");
              final LineChart chart = new LineChart(xAxis, yAxis);
              final StackPane root = new StackPane();
              root.getChildren().add(chart);
              final Scene scene = new Scene(root, 500, 3000);
              primaryStage.setTitle("Test");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

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

      In JDK8u40, the Y axis on this test chart is 105 pixels wide. This leaves a huge blank space on the left side of the chart.

      If instead you use a Y axis definition such as :

      final NumberAxis yAxis = new NumberAxis(0, 10, 1);

      Then the axis is only 22 pixels wide instead.

      It looks like, when pre-calculating its width, the axis class is producing tmp labels, texts or strings that contains non-rounded floating points values so they are way longer than the ones that end up being generated on screen. This is probably why the Y axis' width is way too large under some conditions.

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            fbouyajfx Fabrice Bouyé (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: