linechartstreaming.java
来自「一个完整的」· Java 代码 · 共 38 行
JAVA
38 行
package cn.com.fcsoft.chart.examples;
import cn.com.fcsoft.chart.*;
import java.awt.*;
import java.awt.event.*;
/**
* This example shows how to use streaming data with the linechart.
* @author meiqi.
*/
public class LineChartStreaming {
public static void main(String[] argv) {
// create the chart
LineChart chart = new LineChart();
chart.setSampleCount(50);
// display the chart
NonFlickerPanel p = new NonFlickerPanel(new BorderLayout());
p.add("Center", chart);
Frame f = new Frame();
f.add("Center", p);
f.setSize(400,200);
f.show();
// continously add data
while (true) {
try {
Thread.sleep(100);
double value = Math.random()*100;
chart.appendSampleValue(0, value, false);
} catch (InterruptedException e) {
// do nothing
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?