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

CategoryAxis rotates improperly as yAxis

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u51
    • Fix Version/s: 9
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Backports

        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 ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  vadim Vadim Pakhnushev
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: