JavaFX real time linechart with timeline

I tried to draw a real-time graph with a timeline, but I found that the linechart constructor only has a signature

LineChart(Axis<X> xAxis,Axis<Y> yAxis)

I don't think embedding jfree diagrams in JavaFX is the right solution

I want several jfree functions in a JavaFX linechart. Is this possible?

Solution

From http://www.oracle.com/technetwork/java/javafx/samples/index.html Download assemble sample

There are several examples of dynamic charts, such as "advanced stock chart" You can view their source code directly in the application

To display the time on the axis, you can use string and dateformatter:

BarChart<String,Number> chart = new BarChart<>(new CategoryAxis(),new NumberAxis());

    final XYChart.Series<String,Number> series1 = new XYChart.Series<>();
    chart.getData().addAll(series1);

    SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
    Date date = new Date();
    for (int i = 0; i <= 10; i += 1) {
        date.setTime(date.getTime() + i * 11111);
        series1.getData().add(new XYChart.Data(dateFormat.format(date),Math.random() * 500));
    }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>