This is a migrated thread and some comments may be shown as answers.

multiple pie chart display in rad chart

1 Answer 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
mukul
Top achievements
Rank 1
mukul asked on 03 May 2015, 07:23 AM

hi

i want to display multiple value in single pie chart but it gives  multiple pie chart so how to resolve it.

following pei chart and code

  private void BindColorPieChart()
        {
            //DataTable dt = null;
            DataController dc = new DataController();
            DataTable dt = dc.GetUsageDetailsOne(Convert.ToDateTime(txtTodate.Text.Trim()), Convert.ToDateTime(txtFromdate.Text.Trim()));
            if (dt.Rows.Count == 0)
            {
                ColorPieChart.HttpHandlerUrl = ResolveUrl("ChartImage.axd");
                ColorPieChart.Visible = false;
                lblMessage.Text = "No data found";
            }
            else
            {

                ColorPieChart.HttpHandlerUrl = ResolveUrl("ChartImage.axd");
                ColorPieChart.ChartTitle.TextBlock.Text = "Usage Details";
                ColorPieChart.Legend.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopRight;

                ColorPieChart.PlotArea.XAxis.AxisLabel.Visible = true;
                ColorPieChart.PlotArea.YAxis.AxisLabel.Visible = true;
                ColorPieChart.AutoLayout = true;
                ColorPieChart.Legend.TextBlock.Visible = true;
              
                
                ChartSeries series = new ChartSeries();
                series.Type = ChartSeriesType.Pie;
                series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
                series.DataYColumn = "TotalCost";
                //series.Name = "Total Cost";
     
               series.DataLabelsColumn = "TotalCost";
                series.Appearance.ShowLabelConnectors = true;


             
                ColorPieChart.Series.Add(series);
                ColorPieChart.DataSource = dt;
               

                ColorPieChart.DataBind();
            }
        }
        protected void lnkToDate_Click(object sender, EventArgs e)
        {
            CalToDate.Visible = !CalToDate.Visible;
        }
        protected void lnkFromDate_Click(object sender, EventArgs e)
        {
            CalFromDate.Visible = !CalFromDate.Visible;
        }
        protected void CalToDate_SelectionChanged(object sender, EventArgs e)
        {
            //set date in MM/dd/yyyy format in textbox
            txtTodate.Text = CalToDate.SelectedDate.ToString("MM/dd/yyyy");
            if (txtTodate.Text != string.Empty)
                CalToDate.Visible = false;
        }
        protected void CalFromDate_SelectionChanged(object sender, EventArgs e)
        {
            //set date in MM/dd/yyyy format in textbox
            txtFromdate.Text = CalFromDate.SelectedDate.ToString("MM/dd/yyyy");
            if (txtFromdate.Text != string.Empty)
                CalFromDate.Visible = false;
        }
        protected void btnGo_Click(object sender, EventArgs e)
        {
            ColorPieChart.Visible = true;
            BindColorPieChart();
        }
        protected void RadChart1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
        {
            e.SeriesItem.Name = e.SeriesItem.Name = (e.DataItem as DataRowView).Row["TotalCost"].ToString();
        }
    }

UI part aspx

<telerik:RadChart ID="ColorPieChart" runat="server" Height="600px" Width="700px" DefaultType="Pie">
        <ChartTitle>
            <TextBlock Text="">
            </TextBlock>
        </ChartTitle>
    </telerik:RadChart>

 

 

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 06 May 2015, 12:17 PM
Hi Mukul,

The provided code snippet illustrates settings of Telerik UI for AJAX RadChart control. Based on the Telerik UI for AJAX: Multiple Series in one Pie-Chart forum thread, I believe you are adding twice the pie series to the chart's Series collection.


If you need further help, please post your question in the corresponding product's forum.

Regards,
Stef
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
General Discussions
Asked by
mukul
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or