JDK-8097501 : LineChart axis does not show all its tick labels when it's manually ranged
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-05-06
  • Updated: 2016-08-23
  • Resolved: 2014-05-15
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
8u20Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
I have a chart that manually sets the bounds of its NumberAxis classes. This has been working fine until some change in 8u20. Now the y axis will often only render 2 of the 10 tick labels that it should.

To reproduce run the provided test class and you will observe that the y axis does not show all of its tick labels. If you change the code to auto range by taking out the manual bounds in the constructor then all labels are shown.

****************************************** Test Class *******************************************************
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class ChartTest extends Application { 

   @Override public void start(final Stage primaryStage) throws Exception { 

      primaryStage.centerOnScreen(); 
      primaryStage.setHeight(350); 
      primaryStage.setWidth(500); 
      
      NumberAxis xAxis = new NumberAxis(3.5, 9.5, 1);
      NumberAxis yAxis = new NumberAxis(1.505, 1.653, (1.653 - 1.505) / 10d );
      
      LineChart<Number, Number> chart = new LineChart<>(xAxis, yAxis);
      Series<Number, Number> series = new Series<>();
      series.getData().add(new Data<Number, Number>(4, 1.515));
      series.getData().add(new Data<Number, Number>(9, 1.643));
      chart.getData().add( series );
      
      primaryStage.setScene( new Scene( new StackPane(chart)) );

      primaryStage.show(); 

   } 

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

}
Comments
Changeset: http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/cc419fb66f71 Unit test: NumberAxisTest#testAxisWithFractionalBoundsTickUnitFractional
15-05-2014

The new patch works well with the charts in our application. No missing labels and no double labels. Thanks.
13-05-2014

Updated the review: http://cr.openjdk.java.net/~msladecek/rt-36998/webrev.01/ Now in Axis, labels are skipped based on their size and position rather than relying on the fact that they are approximately equally sized and evenly positioned.
13-05-2014

I don't see 2 labels with upper bounds of 1.653. But I do see it with new NumberAxis(1.505, 1.654, (1.653 - 1.505) / 10d ), but not new NumberAxis(1.505, 1.654, (1.654 - 1.505) / 10d ); This is because the tick units will result in a tick very close to (but not equal to) the upper bound. Will update the patch so that the label is not shown in such case.
12-05-2014

Thanks for confirming. I'll leave Martin to respond (although his timezone is such that you probably won't hear from him for ~12 hours).
07-05-2014

Yes I did. This morning I pull from the 8u-dev repo before applying the patch. If you change the y axis construction so the upper bound is off by 0.001 you can see there are 2 labels for the top bound. eg. NumberAxis yAxis = new NumberAxis(1.505, 1.654, (1.653 - 1.505) / 10d ); but I'm also quite positive there are 2 labels on top of each other when the upper bound is 1.653 too.
07-05-2014

Martin: +1 Charles: Did you apply this patch against the latest 8u20 code?
07-05-2014

When I applied this patch and tested it with the above test case all the labels render but it looks to me like the last label on the yAxis is darker perhaps because it is being doubled up? I see the same in my application using this patch.
07-05-2014

Please review: http://cr.openjdk.java.net/~msladecek/rt-36998/webrev.00/ The changes in RT-23093 are applicable only for integral tickUnits. Other tickUnits should be used from the lowerBound itself.
07-05-2014