We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Pie Chart Data Points

Hello,
I have downloaded the trial version of your product. My question is about Essential Chart.

My code snippet is as follow:
ChartSeries series = this.ChartWebControl1.Model.NewSeries("Series Name", ChartSeriesType.Pie);


series.Points.Add(0, 1);

series.Points.Add(1, 3);

series.Points.Add(2, 4);
series.Points.Add(3, 4);

how can add labels for each data point? I mean I wanna put these labels (1,3,4,4....) on a pie chart slices.

5 Replies

SG Senthil Ganesh K Syncfusion Team March 2, 2010 03:07 PM UTC

Hi,

Thanks for showing interest on syncfusion products.

We suggest you the below code snippet to show the datapoint labels.

Code Snippet:

this.ChartWebControl1.Series[0].Style.DisplayText = true;


Please let me know if this helps.

Regards,
Senthil Ganesh K.


EE erdem eralsan March 17, 2010 11:48 AM UTC

Thank you for your reply. Your code snippet did not work for may case.
I really wonder if is really too difficult to show labels on data points?
My code is like below:

ChartSeries series1 = this.ChartWebControl1.Model.NewSeries("Costs",ChartSeriesType.Pie);

this.ChartWebControl1.Series3D = true;

series1.Points.Add(0, double.Parse(GridView1.FooterRow.Cells[2].Text));
series1.Points.Add(1, double.Parse(GridView1.FooterRow.Cells[3].Text));


this.ChartWebControl1.Series[0].Style.DisplayText = true;
this.ChartWebControl1.Series[0].Style.TextColor = System.Drawing.Color.LightSlateGray;

this.ChartWebControl1.Series.Add(series1);


this.ChartWebControl1.Series[0].ConfigItems.PieItem.LabelStyle = ChartAccumulationLabelStyle.Inside;






EE erdem eralsan March 17, 2010 11:58 AM UTC

I have tried everything which inside your online documentation.. But I could not put a basic point label text into grapgh data points!!


EE erdem eralsan March 17, 2010 02:27 PM UTC

Hello Again,
Finally I am very closer to the solution. I have modified my code as follow:
Now, the only issue is the put gridview column headers to the chart legend items..
Any idea?

private void SetGraphFeature()
{

ChartSeries series1 = this.ChartWebControl1.Model.NewSeries("İlave Maliyetler",ChartSeriesType.Pie);

this.ChartWebControl1.Text= "İlave Maliyetler";

this.ChartWebControl1.Series3D = true;

series1.Points.Add(0, double.Parse(GridView1.FooterRow.Cells[2].Text));
series1.Points.Add(1, double.Parse(GridView1.FooterRow.Cells[3].Text));
series1.Points.Add(2, double.Parse(GridView1.FooterRow.Cells[4].Text));
series1.Points.Add(3, double.Parse(GridView1.FooterRow.Cells[5].Text));
series1.Points.Add(4, double.Parse(GridView1.FooterRow.Cells[6].Text));
series1.Points.Add(5, double.Parse(GridView1.FooterRow.Cells[7].Text));
series1.Points.Add(6, double.Parse(GridView1.FooterRow.Cells[8].Text));
series1.Points.Add(7, double.Parse(GridView1.FooterRow.Cells[9].Text));
series1.Points.Add(8, double.Parse(GridView1.FooterRow.Cells[10].Text));



this.ChartWebControl1.Series[0].Style.TextColor = System.Drawing.Color.LightSlateGray;




this.ChartWebControl1.Series.Add(series1);
this.ChartWebControl1.Series[0].Style.DisplayText = true;

this.ChartWebControl1.Series[0].Styles[0].Text = GridView1.FooterRow.Cells[2].Text;
this.ChartWebControl1.Series[0].Styles[1].Text = GridView1.FooterRow.Cells[3].Text;
this.ChartWebControl1.Series[0].Styles[2].Text = GridView1.FooterRow.Cells[4].Text;
this.ChartWebControl1.Series[0].Styles[3].Text = GridView1.FooterRow.Cells[5].Text;
this.ChartWebControl1.Series[0].Styles[4].Text = GridView1.FooterRow.Cells[6].Text;
this.ChartWebControl1.Series[0].Styles[5].Text = GridView1.FooterRow.Cells[7].Text;
this.ChartWebControl1.Series[0].Styles[6].Text = GridView1.FooterRow.Cells[8].Text;
this.ChartWebControl1.Series[0].Styles[7].Text = GridView1.FooterRow.Cells[9].Text;
this.ChartWebControl1.Series[0].Styles[8].Text = GridView1.FooterRow.Cells[10].Text;



// Adding some custom items into the 2nd custom Legend

}



screen_983af9be.rar


JB Jaffersathick B Syncfusion Team March 19, 2010 06:09 AM UTC

Hi Erdem,


Thank you for your interest in Syncfusion products.


We suggest you to use Legend filter items event to set the legend text. We suggest you to get the Grid Column header and set that value in the legend event.

Please refer the below code snippet:

[CS]
//Event
this.chartControl1.Legend.FilterItems += new Syncfusion.Windows.Forms.Chart.LegendFilterItemsEventHandler(this.chartControl1_Legend_FilterItems);
//Event definition
private void chartControl1_Legend_FilterItems(object sender, ChartLegendFilterItemsEventArgs e)
{
ChartSeries series = this.chartControl1.Series[0];
if (series.Type == ChartSeriesType.Pie)
{
// Setting Custom text.
for (int i = 0; i < series.Points.Count; i++)
e.Items[i].Text = "Custom text";
}
}



Please Let me know if you have any other concerns.


Regards,
Jaffer.B

Loader.
Live Chat Icon For mobile
Up arrow icon