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

Y axis is too wide under some conditions


    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u40
    • Fix Version/s: 8u60
    • Component/s: javafx
    • Labels:
    • Environment:

      JavaFX 8u40, JDK 8u40 64bit, Windows 7 64bit, NetBeans 8.0.2


      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 {
          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();
              final Scene scene = new Scene(root, 500, 3000);

          public static void main(String[] 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.




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


              • Created: