Hello team,
We are using telerik charting .We have used below code for generating chart.When we are using below code we get error in stack area and stack line chart.
please find attached screen shot for error.
how can i use below code for pie chart because i am not able to generate pie chart using below code.we have two columns for pie chart x-axis and category.
Code:
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ChartconnectionString"].ConnectionString);
cn.Open();
SqlCommand cmd = new SqlCommand(query, cn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataTable data = new DataTable();
sda.Fill(data);
RadChart1.DataSource = data;
cn.Open();
SqlCommand cmd = new SqlCommand(query, cn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataTable data = new DataTable();
sda.Fill(data);
RadChart1.DataSource = data;
RadChart1.DataManager.ValuesYColumns = new string[] { rcbyaxis.SelectedItem.Text };//Y-axis column
RadChart1.PlotArea.XAxis.DataLabelsColumn = rcbxaxis.SelectedItem.Text;//X-axis column
RadChart1.DataGroupColumn = rcbCategory.SelectedItem.Text;//Category column for stack chart
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300;
RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color =
System.Drawing.Color.BlueViolet;
RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom =
Telerik.Charting.Styles.Unit.Percentage(30);
switch (rcbChartType.SelectedValue)
{
case "BAR":
RadChart1.Chart.DefaultType = ChartSeriesType.Bar;
break;
case "Line":
RadChart1.Chart.DefaultType = ChartSeriesType.Line;
break;
case "Area":
RadChart1.Chart.DefaultType = ChartSeriesType.Area;
break;
case "Stacked Bar":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedBar;
break;
case "Stacked Line":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedLine;
break;
case "Stacked Area":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedArea;
break;
case "Stacked Bar 100%":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedBar100;
break;
case "Stacked Area 100%":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedArea100;
break;
case "Pie":
RadChart1.Chart.DefaultType = ChartSeriesType.Pie;
break;
}
// bind to the datasource
RadChart1.DataBind();
RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color =
System.Drawing.Color.BlueViolet;
RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom =
Telerik.Charting.Styles.Unit.Percentage(30);
switch (rcbChartType.SelectedValue)
{
case "BAR":
RadChart1.Chart.DefaultType = ChartSeriesType.Bar;
break;
case "Line":
RadChart1.Chart.DefaultType = ChartSeriesType.Line;
break;
case "Area":
RadChart1.Chart.DefaultType = ChartSeriesType.Area;
break;
case "Stacked Bar":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedBar;
break;
case "Stacked Line":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedLine;
break;
case "Stacked Area":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedArea;
break;
case "Stacked Bar 100%":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedBar100;
break;
case "Stacked Area 100%":
RadChart1.Chart.DefaultType = ChartSeriesType.StackedArea100;
break;
case "Pie":
RadChart1.Chart.DefaultType = ChartSeriesType.Pie;
break;
}
// bind to the datasource
RadChart1.DataBind();
please help me as soon as possible.
Thanks.