public static void main(String[] args) {
// Setup the panel
final RealtimeChart01 realtimeChart01 = new RealtimeChart01();
final XChartPanel chartPanel = realtimeChart01.buildPanel();
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Create and set up the window.
JFrame frame = new JFrame("XChart");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(chartPanel);
// Display the window.
frame.pack();
frame.setVisible(true);
}
});
// Simulate a data feed
TimerTask chartUpdaterTask = new TimerTask() {
@Override
public void run() {
realtimeChart01.updateData();
chartPanel.updateSeries(SERIES_NAME, realtimeChart01.getyData());
}
};
Timer timer = new Timer();