LineChartStreaming.java
资源名称:OA.rar [点击查看]
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:1k
源码类别:
OA系统
开发平台:
Java
- 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
- }
- }
- }
- }