I have a line chart in my scene that shows several Series in it.each second one or two data is added to the series and is shown on chart. the problem is after a while that the program is running the data are being more and more and chart becomes almost useless.I want to show only last 50 data in the chart and older now shown anymore. The approach I had was to disable "Force Zero in the range" for XAxis and remove index-50 data from series in each data insertion .but I face with ConcurrentModificationException and indexOutofBoundaryException. Is there a better way for this problem? This is my code for chart and series and data insertion.
gxSeries = new XYChart.Series<Number, Number>();
gySeries = new XYChart.Series<Number, Number>();
gzSeries = new XYChart.Series<Number, Number>();
gxSeries.setName("p(Rad/s)");
gySeries.setName("q(Rad/s)");
gzSeries.setName("r(Rad/s)");
gSeriesChart.getData().add(gxSeries);
gSeriesChart.getData().add(gySeries);
gSeriesChart.getData().add(gzSeries);
gSeriesChart.setCreateSymbols(false);
gSeriesChart.getStyleClass().add("thick-chart");
gSeriesX.setForceZeroInRange(false);
gxSeries,... are Series gSeriesChart is the lineChart gSeriesX is the xAxis
gxSeries.getData().add(new XYChart.Data<Number, Number>(tele.missionTime/1000.0, tele.gx));
gySeries.getData().add(new XYChart.Data<Number, Number>(tele.missionTime/1000.0, tele.gy));
gzSeries.getData().add(new XYChart.Data<Number, Number>(tele.missionTime/1000.0, tele.gz));