Help !!!!

Thread is closed for posting
2 posts, 0 answers
  1. Ketan
    Ketan avatar
    1 posts
    Member since:
    Jan 2012

    Posted 04 Jan 2012 Link to this post

    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;
     

             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();
     

    please help me as soon as possible.
    Thanks.
  2. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 05 Jan 2012 Link to this post

    Ketan:

    The "error.png" shows an exception based on the selection of a Stacked Line chart, correct? There is a RadChart hide empty values forum thread that provides (at the bottom) some insights on a workaround which might help you here.

    But, what is the error or the problem that occurs when you select the Pie Chart rendering option? Please provide more insight so that I can attempt to assist you.

    See the Creating RadChart Programmatically and the Creating RadChart Programmatically - more complex example documentation page for insights.

    Although they don't go over exactly how to create a pie chart you simply have to set the type of the series like this example:

    protected void testButton_Click(object sender, EventArgs e)
    {
        ChartSeries mySeries = new ChartSeries();
        ChartSeriesItem myItem = new ChartSeriesItem();
     
        myItem.YValue = 10;
        mySeries.AddItem(myItem); 
        mySeries.Type = ChartSeriesType.Pie;
        RadChart1.Series.Add(mySeries);
        RadChart1.DataBind();
    }


    Hope this helps!

    Regards,
Back to Top