0
我有我的foreach循環添加到圖表作爲跟隨和分配dtMonth數據行,以圖表的x軸一個數據表,這是一個月名稱:Telerik的radChart x軸的DataColumn沒有顯示
foreach (DataRow dr in dtMD.Rows)
{
DataTable dtMDByName = ocw.GetMDByName(Convert.ToDateTime(txtStartDate.Text), Convert.ToDateTime(txtEndDate.Text), dr["MD"].ToString());
if (dtMDByName.Rows.Count > 0)
{
ChartSeries MDChartSeries = new ChartSeries();
MDChartSeries.Name = dtMDByName.Rows[0][1].ToString();
MDChartSeries.Type = ChartSeriesType.Line;
foreach (DataRow drByName in dtMDByName.Rows)
{
MDChartSeries.AddItem(Convert.ToDouble(drByName["T"]));
radMD.PlotArea.XAxis.DataLabelsColumn = drByName["dtMonth"].ToString();
}
radMD.ChartTitle.TextBlock.Text = "MDs";
radMD.PlotArea.XAxis.AutoScale = true;
radMD.Series.Add(MDChartSeries);
}
}
但仍顯示爲在xaxis中的數字,任何即時通訊在上面的代碼中做錯了?
即使我做了第二循環外即下面的代碼仍然不表明月份名稱:
radMD.PlotArea.XAxis.DataLabelsColumn = "dtMonth";
感謝
我有同樣的問題,我已經嘗試過你的解決方案,現在它工作得很好,現在它給我空引用異常我不知道爲什麼是這樣嗎? :/ – 2014-03-12 10:52:24
在爲行中的空值/計數分配XAxis文本塊檢查之前。 – Zaki 2014-03-12 10:56:52
對不起,它的索引超出範圍異常:/ – 2014-03-12 10:58:20