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

Pie Chart with % value displayed

5 Answers 196 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Quan Nguyen
Top achievements
Rank 1
Quan Nguyen asked on 06 Apr 2011, 11:12 PM
Hi,
Do you have any sample codes for for creating a pie chart with the value of each slice displayed (counter or %).
I have tried the codes below to create pie chart on-fly but couldn't get it done:

........

Dim

 

objChart As New Telerik.Reporting.Chart()

 

 

objChart.SeriesPalette =

"Palette1"

 

 

 

 

 

 

objChart.Style.Color = Color.DarkBlue

 

objChart.BitmapResolution = 96.0F

 

objChart.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf

objChart.Name = strFieldName

objChart.ChartTitle.TextBlock.Text = objChartDetails.ChartTitle

objChart.ChartTitle.Appearance.FillStyle.MainColor = Color.Transparent

objChart.Size =

New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(drReport("Width"), Telerik.Reporting.Drawing.UnitType.Pixel), New Telerik.Reporting.Drawing.Unit(drReport("Height"), Telerik.Reporting.Drawing.UnitType.Pixel))

 

 

objChart.ChartTitle.Appearance.Dimensions.Margins =

New Telerik.Reporting.Charting.Styles.ChartMargins(0, 10, 10, 10)

 

 

objChart.PlotArea.EmptySeriesMessage.Appearance.Visible =

True

 

 

 

 

 

 

objChart.PlotArea.EmptySeriesMessage.Visible =

True

 

 

 

 

 

 

 

 

 

objChart.PlotArea.Appearance.FillStyle.MainColor = Color.White

 

objChart.PlotArea.Appearance.FillStyle.SecondColor = Color.White

 

 

Dim

 

objChartSeries As New ChartSeries()

 

objChartSeries.DefaultLabelValue =

"#%"

 

objChartSeries.Appearance.TextAppearance.Visible =

True

 

objChartSeries.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.ChartSeriesLegendDisplayMode.ItemLabels

objChartSeries.DataLabelsColumn =

"StatName"

 

objChartSeries.Type = objChartDetails.ChartType

objChartSeries.DataYColumn =

"StatCount"

 

 

objChart.Series.Add(objChartSeries)

 

 

........

my data source is from a table with StatName (varchar) and StatCount(int)
StatName      StatCount
Verified          23
No-Verified    65


Attached is a sample of my result.

Thanks
quan



5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Apr 2011, 12:10 PM
Hello Quan,

The following articles elaborate on the desired functionality:

All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Quan Nguyen
Top achievements
Rank 1
answered on 11 Apr 2011, 07:21 PM
Thank you for your reply, I have made some progress but still got 1 issue left for the label of items in pie chart. How do I assign the label for each colored. Right now it just list Item 1 and Item 2. It should list the name of each value for StatName field.
Attach is my current result with question.

Thanks
Quan
0
Accepted
Steve
Telerik team
answered on 12 Apr 2011, 08:17 AM
Hi Quan Nguyen,

You should set the StatName field as value for the DataLabelsColumn property of the series and make sure that the LegendDisplayMode is set to ItemLabels.

All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
c e
Top achievements
Rank 1
answered on 21 May 2011, 06:53 PM
Hi
I followed this sample, but when assign  StatName field as value for the DataLabelsColumn and setting LegendDisplayMode to ItemLabels, I'm ending having the StatName field value in both, close to each area in the chart and in the legend area.

Is it possible to have the StatName  field value + the % near each area in the chart and only the StatName  field value in the legend area?
Besides, is it possible assign specific colors to each area?

Thank in advance


Carlos

0
Steve
Telerik team
answered on 26 May 2011, 07:32 AM
Hi Carlos,

Sure you can, check the Data Binding Chart to a Generic List of Objects help article for a sample.

Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Quan Nguyen
Top achievements
Rank 1
Answers by
Steve
Telerik team
Quan Nguyen
Top achievements
Rank 1
c e
Top achievements
Rank 1
Share this question
or