2 qq 34431685 qq_34431685 于 2016.03.26 09:18 提问

为什么我的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);

1个回答

caozhy
caozhy   Ds   Rxr 2016.03.26 22:53
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!