-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating line-chart produces weird result #68
Comments
It's actually a bug in JavaFX charts: I made a repro and submitted a bug report. import javafx.application.Application;
import javafx.collections.FXCollections;
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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class LineChartRepro extends Application {
public void start(Stage stage) throws Exception {
LineChart<Number, Number> chart = new LineChart<>(new NumberAxis(), new NumberAxis());
XYChart.Series<Number, Number> series = new XYChart.Series<>();
series.setData(FXCollections.observableList(Arrays.asList(
new XYChart.Data<>(0,0),
new XYChart.Data<>(1,1))));
chart.getData().setAll(Collections.singletonList(series));
Button addChartData = new Button("Add Chart data");
addChartData.setOnAction(e -> {
ArrayList<XYChart.Data<Number, Number>> newList = new ArrayList<>(series.getData());
newList.add(new XYChart.Data<>(newList.size(), newList.size()));
series.setData(FXCollections.observableList(newList));
});
stage.setScene(new Scene(new VBox(chart, addChartData)));
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
} Bug report: JDK-9064593 (supposedly will be visible once they screen it) |
Ok, thanks for submitting it. It worked ok with the pie-chart. |
Update: screened bug report is here: JDK-8243128. |
Is there a workaround for this? As it seems like from their perspective this is intended behaviour. |
A workaround is described here. |
Very cool. That looks quite workable. Thank you very much for this. |
It can be easily solved by disabling the chart animations with chart.setAnimated(false); |
I get this result when trying to update a line-chart:
using this code:
The text was updated successfully, but these errors were encountered: