gillius / jfxutils

JavaFX Utilities - Zoom and Pan Charts and Pane Scaling
Apache License 2.0
68 stars 22 forks source link

X-Axis DateFormat displays incorrect value #13

Closed manozz91 closed 6 years ago

manozz91 commented 6 years ago

I am using the example code taken from below url,

https://github.com/gillius/jfxutils/blob/master/jfxutils-examples/src/main/java/org/gillius/jfxutils/examples/Charting.java

@FXML
void addSample() {
       series.getData().add( new XYChart.Data<Number, Number>( System.currentTimeMillis() - startTime,
                              valueSlider.getValue() ) );
}

It works like a charm and no issues . but if i change from the above snippet

System.currentTimeMillis() **-** startTime to System.currentTimeMillis() **+** startTime. The x-axis dates get all messed up and chart didnt plot correctly.

In addSample method i added a sysout, //format is HH:mm:ss System.out.println("X is : " + format.format(System.currentTimeMillis() + startTime) + " : " + "Y is : " + valueSlider.getValue());

and the displayed value is : X is : 23:11:39 : Y is : 65.96194503171247 and so on.. The Y value is displayed properly.

manozz91 commented 6 years ago

Solved by adding ((StableTicksAxis)chart.getXAxis()).setForceZeroInRange(false);