C#画曲线图这么方便。
namespace testchat
{
public partial class Form1 : Form
{
int[] yValue = new int[5] { 0, 0, 0, 0, 0 };
Series series1;
Series series2;
Series series3;
Series series4;
Random y = new Random();
public Form1()
{
InitializeComponent();
ShowLine();
}
void ShowLine()
{
this.chart0.Series.Clear();
series1 = new Series("Spline");
series1.ChartType = SeriesChartType.Column; //Spline
series1.BorderWidth = 3;
series1.ShadowOffset = 2;
//this.chart_bar.Series[0].
series1.Points.DataBindY(yValue);
this.chart0.Series.Add(series1);
this.chart0.Series[0].Label = "#VAL";
this.chart1.Series.Clear();
series2 = new Series("Spline");
series2.ChartType = SeriesChartType.Spline; //Spline
series2.BorderWidth = 3;
series2.ShadowOffset = 2;
//this.chart_bar.Series[0].
series2.Points.DataBindY(yValue);
this.chart1.Series.Add(series2);
this.chart1.Series[0].Label = "#VAL";
this.chart2.Series.Clear();
series3 = new Series("Spline");
series3.ChartType = SeriesChartType.Pie; //Spline
series3.BorderWidth = 3;
series3.ShadowOffset = 2;
//this.chart_bar.Series[0].
series3.Points.DataBindY(yValue);
this.chart2.Series.Add(series3);
this.chart2.Series[0].Label = "#VAL";
this.chart3.Series.Clear();
series4 = new Series("Spline");
series4.ChartType = SeriesChartType.Radar; //Spline
series4.BorderWidth = 3;
series4.ShadowOffset = 2;
//this.chart_bar.Series[0].
series4.Points.DataBindY(yValue);
this.chart3.Series.Add(series4);
this.chart3.Series[0].Label = "#VAL";
//this.chart_bar.ChartAreas[0].AxisX.IsStartedFromZero = true;
}
//定时器
private void timer1_Tick(object sender, EventArgs e)
{
for(int i =1;i<5;i++){
yValue[i-1] = yValue[i];
}
yValue[4] = y.Next()%100;
series1.Points.DataBindY(yValue);
series2.Points.DataBindY(yValue);
series3.Points.DataBindY(yValue);
series4.Points.DataBindY(yValue);
}
}
}