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>