I am trying to improve the performance of LineChart in JavaFX, but without much success. I also found that this was apparently a common problem that some programmers discovered when trying to display big data (here a lot of data is 10,000). For example, such data is quite common in science and technology, and it would be great if we could figure out how to speed up the work of LineChart in JavaFX.
Well, I found two entries here in stackoverflow with a similar question. Performance problem with JavaFX LineChart with 65000 data points and JavaFX LineChart - draw an array . Topic The performance problem with JavaFX LineChart with 65,000 data points gives a proposal (from Adam) to use the Ramer-Douglas-Puker algorithm ! to reduce the number of data points in LineChart for acceleration.
However, in scientific and technical data we usually need to see the shape of the plot, and then zoom in to see the details in certain parts of the plot. Therefore, if we use the Ramer-Douglas-Puker algorithm, we will need to redraw the LineChart each time the user zooms in / out, which I think will cost a lot of processing.
So I would like to know if anyone has any tips on speeding LineChart in JavaFX. Here is a sample code containing what I have learned so far.
import java.util.ArrayList; import java.util.List; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.chart.LineChart; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class TestingLineChart extends Application { @Override public void start(Stage primaryStage) { long startTime, endTime; startTime = System.nanoTime(); StackPane root = new StackPane(); NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); LineChart<Number, Number> lineChartPlot = new LineChart<>(xAxis, yAxis);
As you can see if you are running this code, the greatest cost is in rendering, which I could not capture with these timings. Then, in my opinion, the improvement should be concentrated there, but I do not know how to do it.
Thanks.
java performance javafx javafx-8
Hugo Fernando Maia Milan
source share