问题描述
- 为什么我的chart控件曲线显示只有中间一条竖直线?横纵坐标该怎么赋值呢?刚接触求大神指教
-
string[] time = new string[ds.Tables[0].Rows.Count];
string[] index1 = new string[ds.Tables[0].Rows.Count];
string[] index2 = new string[ds.Tables[0].Rows.Count];
string[] index3 = new string[ds.Tables[0].Rows.Count];
string[] index4 = new string[ds.Tables[0].Rows.Count];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
time[i] = ds.Tables[0].Rows[i][0].ToString();
index1[i] = ds.Tables[0].Rows[i][1].ToString();
index2[i] = ds.Tables[0].Rows[i][2].ToString();
index3[i] = ds.Tables[0].Rows[i][3].ToString();
index4[i] = ds.Tables[0].Rows[i][4].ToString();
}
string strXdata = string.Empty;
foreach (string strData in time)
{
strXdata += strData + "t";
}
string strYdata1 = string.Empty;
string strYdata2 = string.Empty;
string strYdata3 = string.Empty;
string strYdata4 = string.Empty;
foreach (string strValue in index1)
{
strYdata1 += strValue + "t";
}
foreach (string strValue in index2)
{
strYdata2 += strValue + "t";
}
foreach (string strValue in index3)
{
strYdata3 += strValue + "t";
}
foreach (string strValue in index4)
{
strYdata4 += strValue + "t";
}
#endregion
chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 0;
chart1.ChartAreas["ChartArea1"].AxisX.Maximum = 20;
chart1.Series["Index1"].Points.AddXY(strXdata, strYdata1);
chart2.Series["Index2"].Points.AddXY(strXdata, strYdata2);
chart3.Series["Index3"].Points.AddXY(strXdata, strYdata3);
chart4.Series["Index4"].Points.AddXY(strXdata, strYdata4);
解决方案
http://blog.csdn.net/chentaihan/article/details/5996022
时间: 2024-11-01 14:23:04