-
Bug
-
Resolution: Fixed
-
P4
-
8u73
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Microsoft Windows [Version 10.0.10586.104]
A DESCRIPTION OF THE PROBLEM :
When clearing and repopulating a series that is displayed on a LineChart, the LineChart still displays some points that should have been cleared. This only seems to occur when setCreateSymbols(false) is called on the series.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a new LineChart with NumberAxis.
2. setCreateSymbols(false) on the LineChart
3. Create a new XYChart.Series object.
4. Add the series to the chart.
5. Add XYChart.Data objects to the series.getData().
6. Call clear() on the series.getData()
7. Add new XYChart.Data objects to the series.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The new points in the series to display correctly in the LineChart.
ACTUAL -
Not all points are displayed on the series and some points from the old XYChart.Data objects are still displayed
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package chartissue;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ChartIssue extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("Line Chart Issue - Removing Last Data Point in Series");
//defining the axes
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Number of Month");
//creating the chart
final LineChart<Number, Number> lineChart
= new LineChart<>(xAxis, yAxis);
lineChart.setTitle("Stock Monitoring, 2010");
//Set create symbols to false
lineChart.setCreateSymbols(false);
//defining a series
XYChart.Series<Number, Number> series = new XYChart.Series<>();
series.setName("My portfolio");
//populating the series with data
series.getData().add(new XYChart.Data<>(1, 23));
series.getData().add(new XYChart.Data<>(2, 14));
series.getData().add(new XYChart.Data<>(3, 15));
series.getData().add(new XYChart.Data<>(4, 24));
series.getData().add(new XYChart.Data<>(5, 34));
series.getData().add(new XYChart.Data<>(6, 36));
series.getData().add(new XYChart.Data<>(7, 22));
series.getData().add(new XYChart.Data<>(8, 45));
series.getData().add(new XYChart.Data<>(9, 43));
series.getData().add(new XYChart.Data<>(10, 17));
series.getData().add(new XYChart.Data<>(11, 29));
series.getData().add(new XYChart.Data<>(12, 25));
lineChart.getData().add(series);
VBox vbox = new VBox();
Button button = new Button("Repopulate series");
button.setOnAction((ActionEvent e) -> {
System.out.println("Clearing series");
series.getData().clear();
System.out.println("series.getData().size(): "+ series.getData().size());
for (int i = 0; i < 12; i++) {
XYChart.Data<Number, Number> data = new XYChart.Data<>(2 * i, 5 * i);
System.out.println("Adding point X: "+data.getXValue()+" Y: "+data.getYValue());
series.getData().add(data);
}
System.out.println();
System.out.println("XYChart.Data in series:");
for (XYChart.Data<Number, Number> data: series.getData()) {
System.out.println("X: "+data.getXValue()+" Y: "+data.getYValue());
}
});
vbox.setSpacing(20);
vbox.setAlignment(Pos.CENTER);
vbox.getChildren().addAll(lineChart, button);
Scene scene = new Scene(vbox, 800, 600);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not use setCreateSymobls(false) on the LineChart.
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Microsoft Windows [Version 10.0.10586.104]
A DESCRIPTION OF THE PROBLEM :
When clearing and repopulating a series that is displayed on a LineChart, the LineChart still displays some points that should have been cleared. This only seems to occur when setCreateSymbols(false) is called on the series.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a new LineChart with NumberAxis.
2. setCreateSymbols(false) on the LineChart
3. Create a new XYChart.Series object.
4. Add the series to the chart.
5. Add XYChart.Data objects to the series.getData().
6. Call clear() on the series.getData()
7. Add new XYChart.Data objects to the series.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The new points in the series to display correctly in the LineChart.
ACTUAL -
Not all points are displayed on the series and some points from the old XYChart.Data objects are still displayed
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package chartissue;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ChartIssue extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("Line Chart Issue - Removing Last Data Point in Series");
//defining the axes
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Number of Month");
//creating the chart
final LineChart<Number, Number> lineChart
= new LineChart<>(xAxis, yAxis);
lineChart.setTitle("Stock Monitoring, 2010");
//Set create symbols to false
lineChart.setCreateSymbols(false);
//defining a series
XYChart.Series<Number, Number> series = new XYChart.Series<>();
series.setName("My portfolio");
//populating the series with data
series.getData().add(new XYChart.Data<>(1, 23));
series.getData().add(new XYChart.Data<>(2, 14));
series.getData().add(new XYChart.Data<>(3, 15));
series.getData().add(new XYChart.Data<>(4, 24));
series.getData().add(new XYChart.Data<>(5, 34));
series.getData().add(new XYChart.Data<>(6, 36));
series.getData().add(new XYChart.Data<>(7, 22));
series.getData().add(new XYChart.Data<>(8, 45));
series.getData().add(new XYChart.Data<>(9, 43));
series.getData().add(new XYChart.Data<>(10, 17));
series.getData().add(new XYChart.Data<>(11, 29));
series.getData().add(new XYChart.Data<>(12, 25));
lineChart.getData().add(series);
VBox vbox = new VBox();
Button button = new Button("Repopulate series");
button.setOnAction((ActionEvent e) -> {
System.out.println("Clearing series");
series.getData().clear();
System.out.println("series.getData().size(): "+ series.getData().size());
for (int i = 0; i < 12; i++) {
XYChart.Data<Number, Number> data = new XYChart.Data<>(2 * i, 5 * i);
System.out.println("Adding point X: "+data.getXValue()+" Y: "+data.getYValue());
series.getData().add(data);
}
System.out.println();
System.out.println("XYChart.Data in series:");
for (XYChart.Data<Number, Number> data: series.getData()) {
System.out.println("X: "+data.getXValue()+" Y: "+data.getYValue());
}
});
vbox.setSpacing(20);
vbox.setAlignment(Pos.CENTER);
vbox.getChildren().addAll(lineChart, button);
Scene scene = new Scene(vbox, 800, 600);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not use setCreateSymobls(false) on the LineChart.
- relates to
-
JDK-8096994 LineChart.getData.clear() method exception
-
- Resolved
-