We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
You can test my code below ,after run maybe 5 mins data still run but the ui shutdown.
import javafx.application.Application; import javafx.scene.Scene; import javafx.stage.Stage; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.fx.ChartViewer; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; import org.jfree.data.time.*; import org.jfree.data.xy.XYDataset; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; /** * A demo showing the display of JFreeChart within a JavaFX application. * * The ChartCanvas code is based on: * http://dlemmermann.wordpress.com/2014/04/10/javafx-tip-1-resizable-canvas/ * */ public class DynamicTimeSeriesChartFXDemo2 extends Application { /** * Creates a chart. * * * @return A chart. */ private static JFreeChart createChart() { final TimeSeriesCollection dataset1 = new TimeSeriesCollection(series1); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(series2); final JFreeChart chart = ChartFactory.createTimeSeriesChart( "Dynamic Data Demo 2", "Time", "Value", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds plot.setDataset(1, dataset2); final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(1, new DefaultXYItemRenderer()); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); return chart; } /** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset. */ private static TimeSeries series1; private static TimeSeries series2; private static double lastValue1 = 100.0; private static double lastValue2 = 500.0; private static void createDataset() { series1 = new TimeSeries("Random 1");//, Millisecond.class series2 = new TimeSeries("Random 2");//, Millisecond.class } private Timer timer; private static final int FAST = 500; @Override public void start(Stage stage) throws Exception { createDataset(); JFreeChart chart = createChart(); ChartViewer viewer = new ChartViewer(chart); timer = new Timer(FAST, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double factor = 0.90 + 0.2 * Math.random(); lastValue1 = lastValue1 * factor; Millisecond now = new Millisecond(); System.out.println("Now = " + now.toString()); series1.add(new Millisecond(), lastValue1); factor = 0.90 + 0.2 * Math.random(); lastValue2 = lastValue2 * factor; now = new Millisecond(); System.out.println("Now = " + now.toString()); series2.add(new Millisecond(), lastValue2); } }); stage.setScene(new Scene(viewer)); stage.setTitle("JFreeChart: TimeSeriesFXDemo1.java"); stage.setWidth(700); stage.setHeight(390); stage.show(); timer.start(); } /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
You can test my code below ,after run maybe 5 mins data still run but the ui shutdown.
The text was updated successfully, but these errors were encountered: