[英]JavaFX real-time LineChart with time axis
我正在嘗試使用時間軸繪制實時圖形,但我發現LineChart
構造函數只有簽名。
LineChart(Axis<X> xAxis, Axis<Y> yAxis)
我認為在javafx中嵌入jfree圖表不是一個合適的解決方案。
我想在javafx LineChart
使用一些jfree功能,這可能嗎?
從http://www.oracle.com/technetwork/java/javafx/samples/index.html下載Ensemble示例
動態圖表中有幾個例子,例如“高級股票線圖”。 您可以直接在應用程序中查看其源代碼。
要在軸上顯示時間,可以使用string和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));
}
org.jfree.chart.demo.TimeSeriesChartDemo1
類包含在發行版中。 它在演示中描繪,其源代碼說明了工廠方法ChartFactory.createTimeSeriesChart()
。 有一個相關的例子在這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.