如何使用一个.csv文件绘制四个图形

时间:2017-03-02 11:44:47

标签: c# winforms csv graph mschart

我想使用一个.CSV文件在C#中的一个窗体中绘制四个图形 绑定.CSV文件的数据后,如何实现我的代码来为X轴和y轴赋值 有2轴y轴电压(y1轴)电流(y2轴),日期是get x轴。

请帮我解决这个问题 我的代码如下。但是这段代码没有得到正确的数据。

chart1.DataSource = ObservingData;
chart1.Series["Voltage"].XValueMember = "Date";

chart1.Series["Voltage"].YValueMembers = "AvE1";
chart1.Series["Current"].XValueMember = "Date";
chart1.Series["Current"].YValueMembers = "AvI1";
this.chart1.Titles.Add("Channel 1");   // Set the chart title
chart1.Series["Voltage"].ChartType = SeriesChartType.Line;  // Set chart type 
chart1.Series["Current"].ChartType = SeriesChartType.Line;  // Set chart type 

chart2.DataSource = ObservingData;
chart2.Series["Voltage"].XValueMember = "Date";
chart2.Series["Voltage"].YValueMembers = "AvE2";
chart2.Series["Current"].XValueMember = "Date";
chart2.Series["Current"].YValueMembers = "AvI1";
this.chart2.Titles.Add("Channel 2");   // Set the chart title
chart2.Series["Voltage"].ChartType = SeriesChartType.Line;  // Set chart type 
chart2.Series["Current"].ChartType = SeriesChartType.Line;

chart3.DataSource = ObservingData;
chart3.Series["Voltage"].XValueMember = "Date";
chart3.Series["Voltage"].YValueMembers = "Av3";
chart3.Series["Current"].XValueMember = "Date";
chart3.Series["Current"].YValueMembers = "AvI1";
this.chart3.Titles.Add("Channel 3");   // Set the chart title
chart3.Series["Voltage"].ChartType = SeriesChartType.Line;  // Set chart type 
chart3.Series["Current"].ChartType = SeriesChartType.Line;

chart4.DataSource = ObservingData;
chart4.Series["Voltage"].XValueMember = "Date";
chart4.Series["Voltage"].YValueMembers = "AvE4";
chart4.Series["Current"].XValueMember = "Date";
chart4.Series["Current"].YValueMembers = "AvI1";
this.chart1.Titles.Add("Channel 4");   // Set the chart title
chart4.Series["Voltage"].ChartType = SeriesChartType.Line;  // Set chart type 
chart4.Series["Current"].ChartType = SeriesChartType.Line;

0 个答案:

没有答案