0
如何設置使用radChart因爲我收到IndexOutOfRange例外,我沒有什麼behaind這個原因,X軸標籤設置radChart值的Y軸標籤。如何使用列表<string>
public void setchart()
{
radChart.Clear();
radChart.BringToFront();
radChart.ChartTitle.TextBlock.Text = "Total Number Of Units Per Rack";
this.Controls.Add(radChart);
radChart.Dock =DockStyle.Fill;
radChart.PlotArea.Appearance.Dimensions.Height = 500;
radChart.PlotArea.XAxis.AxisLabel.Visible = true;
radChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "UnitProcessDetailType";
radChart.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red;
radChart.PlotArea.XAxis.Appearance.Width = 1;
radChart.PlotArea.XAxis.Appearance.Color = System.Drawing.Color.Red;
radChart.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 45;
radChart.PlotArea.YAxis.AxisLabel.Visible = true;
radChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Number Of Units";
radChart.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red;
radChart.PlotArea.YAxis.Appearance.Width = 1;
radChart.PlotArea.YAxis.Appearance.Color = System.Drawing.Color.Red;
radChart.Chart.Skin = "Sunset";
Telerik.Charting.ChartSeries chartSeries = new Telerik.Charting.ChartSeries();
chartSeries.Name = "Number Of Units Per Type";
chartSeries.Type = Telerik.Charting.ChartSeriesType.Bar;
chartSeries.Appearance.BarWidthPercent = 70;
radChart.PlotArea.XAxis.AutoScale = false;
ReportGrid.Controls.Add(radChart);
List<string> xaxisLabel = new List<string>();
List<string> yaxislabel = new List<string>();
if (masterTab1.HeaderGrid.CurrentRow.Cells[0].Value.ToString() == "Sales Quotes by Quote Status")
{
DataTable table = new DataTable();
table = Adapter.SalesQuotesbyQuoteStatus(GroupList.SelectedText.ToString(), TimePeriodList.SelectedText.ToString());
int number = table.Rows.Count;
int column = table.Columns.Count;
radChart.PlotArea.XAxis.AddRange(1, number, 1);
radChart.PlotArea.YAxis.AddRange(1 , 1 , 1);
foreach (DataRow dr in table.Rows)
{
xaxisLabel.Add(dr["X_Axis"].ToString());
yaxislabel.Add(dr["Y_Axis"].ToString());
}
for (int i = 0; i < table.Rows.Count; i++)
{
chartSeries.AddItem(Convert.ToDouble(yaxislabel[i]), xaxisLabel[i]);
}
for (int xaxis = 0; xaxis < xaxisLabel.Count; xaxis++)
{
radChart.PlotArea.XAxis[xaxis].TextBlock.Text = xaxisLabel[xaxis];
}
for (int yaxis = 0; yaxis < yaxislabel.Count; yaxis++)
{
radChart.PlotArea.YAxis[yaxis].TextBlock.Text = yaxislabel[yaxis];
}
radChart.Series.Add(chartSeries);
}
}
列表中也含有因爲我已經檢查一遍值又一遍,現在我不知道什麼是真正的問題?