/**
 * Copyright 2015-2016 Knowm Inc. (http://knowm.org) and contributors.
 * Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.knowm.xchart.standalone;

import org.knowm.xchart.QuickChart;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.XYChart;

/**
 * Creates a simple real-time Chart using QuickChart
 */
public class SimpleRealTime {

  public static void main(String[] args) throws Exception {

    final double[] yData = new double[] { 2.0, 1.0, 0.0 };

    // Create Chart
    XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", null, yData);

    // Show it
    final SwingWrapper<XYChart> sw = new SwingWrapper(chart);

    sw.displayChart();

    for (int i = 0; i < 1000; i++) {

      Thread.sleep(100);
      yData[0]++;
      yData[1]++;
      yData[2]++;

      javax.swing.SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {

          sw.getXChartPanel().updateXYSeries("y(x)", null, yData, null);
        }
      });
    }

  }
}

@@ -1007,34 +1007,29 @@
     
-final double%5B%5D yData = new
+double phase = 0;%0A   
  dou
@@ -1037,26 +1037,40 @@
 le%5B%5D
- %7B 2.0, 1.0, 0.0 %7D
+%5B%5D initdata = getSineData(phase)
 ;%0A%0A 
@@ -1162,27 +1162,40 @@
 %22y(x)%22, 
-null, yData
+initdata%5B0%5D, initdata%5B1%5D
 );%0A%0A    
@@ -1320,16 +1320,17 @@
 i %3C 1000
+0
 ; i++) %7B
@@ -1327,24 +1327,64 @@
 00; i++) %7B%0A%0A
+      phase += Math.PI * 2 + 1 / 50.0;%0A%0A
       Thread
@@ -1396,64 +1396,60 @@
 p(10
-0
 );%0A
+%0A
       
-yData%5B0%5D++;%0A      yData%5B1%5D++;%0A      yData%5B2%5D++
+final double%5B%5D%5B%5D data = getSineData(phase)
 ;%0A%0A 
@@ -1614,54 +1614,442 @@
 )%22, 
-null, yData, null);%0A        %7D%0A      %7D);%0A    %7D%0A
+data%5B0%5D, data%5B1%5D, null);%0A        %7D%0A      %7D);%0A    %7D%0A%0A  %7D%0A%0A  private static double%5B%5D%5B%5D getSineData(double phase) %7B%0A%0A    double%5B%5D xData = new double%5B100%5D;%0A    double%5B%5D yData = new double%5B100%5D;%0A    for (int i = 0; i %3C xData.length; i++) %7B%0A      double radians = phase + (Math.PI / (xData.length / 2) * i);%0A      xData%5Bi%5D = phase + i - xData.length / 2;%0A      yData%5Bi%5D = Math.sin(radians);%0A    %7D%0A    return new double%5B%5D%5B%5D %7B xData, yData %7D;
 %0A  %7D

change to sine curve