JDK-8139850 : CategoryAxis rotates improperly as yAxis
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u51
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-10-09
  • Updated: 2017-08-09
  • Resolved: 2016-02-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u152Fixed 9Fixed
Description
FULL PRODUCT VERSION :
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
XYCharts with a CategoryAxis set as the yAxis rotate improperly when vertical space decreases. 

Here is a gif showing the issue:
https://drive.google.com/file/d/0B71GjZGQBItSVmxkTHhiSXVaMXM/view?usp=sharing

Here's a stack overflow question about it:
http://stackoverflow.com/questions/32979001/javafx-charting-categoryaixis-resize-issue

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an XYChart (Area, Bar, Line, etc...) and set its yAxis to be a CategoryAxis with several categories. 

Resize the chart reducing its height until there is insufficient space to properly show all of the category labels. You will see that the labels rotate to 90 degrees, and only one or two display. As the chart re-grows the labels never rotate back to 90 degrees.

You can see this by running the provided source code and vertically resizing the window until it is small enough.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The labels shouldn't rotate since they already have the optimal layout rotation. I would PREFER to have the labels stack on top of each other, but I would EXPECT to have every other label disappear or something like that.
ACTUAL -
Labels turn vertical and nearly all labels hide. 

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
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.stage.Stage;

public class HorizontalBarExample extends Application {
    @Override
    public void start(Stage stage)  {
        NumberAxis xAxis = new NumberAxis();
        CategoryAxis yAxis = new CategoryAxis();
        BarChart<Number, String> bc = new BarChart<Number, String>(xAxis, yAxis);
        bc.setBarGap(0d);
        bc.setCategoryGap(0);

        xAxis.setTickLabelRotation(90);
        yAxis.tickLabelRotationProperty().set(0d);

        XYChart.Series<Number, String> series1 = new XYChart.Series<>();
        series1.setName("example");

        for (int i = 0; i < 10; i++)
            series1.getData().add(new XYChart.Data<Number, String>(Math.random() * 5000, "long data label number" + i));

        bc.getData().add(series1);

        Scene scene = new Scene(bc, 800, 600);
        stage.setScene(scene);
        stage.show();
    }

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


Comments
Is it fixed in 9? If so, which build?
09-08-2017

Approved to push to 8u-dev for 8u152.
02-06-2017

Requesting approval for backport to 8udev. The committed patch for 9dev applies cleanly to 8udev. Unit tests are running fine with these changes.
02-06-2017

Changeset: 1d63ed6d5ed4 Author: vadim Date: 2016-02-11 09:28 +0300 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/1d63ed6d5ed4
11-02-2016

+1
10-02-2016

Jonathan, Could you please review the fix: http://cr.openjdk.java.net/~vadim/8139850/webrev.00/
05-02-2016