日期:2014-05-20 浏览次数:20861 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SetChart();
timer1.Interval = 1000;
timer1.Start();
}
private Random rand = new Random();
public void SetChart()
{
ChartArea cha = new ChartArea("ChartArea1");
cha.Area3DStyle.Enable3D = true;
chart1.ChartAreas.Add(cha);
Legend lgY = new Legend("Legend1");
lgY.IsTextAutoFit = true;
lgY.Docking = Docking.Bottom;
chart1.Legends.Add(lgY);
Series SerY = new Series("Series1");
SerY.ChartArea = "ChartArea1";
SerY.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
SerY.IsVisibleInLegend = true;
SerY.Legend = "Legend1";
SerY.LegendText = "Yvalue";
SerY.YValueMembers = "Yvalue";
chart1.Series.Add(SerY);
chart1.Series[0].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
//chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss" + "yy/MM/dd";