Completed
Last Updated: 30 Jan 2015 13:18 by ADMIN
ADMIN
George
Created on: 27 Feb 2014 12:15
Category: ChartView
Type: Bug Report
0
FIX. RadChartView - PieSeries do not show the legend properly, the values are not initialized
To reproduce:

Add a RadChartView to a Form. Use the following code:

this.Chart.AreaType = ChartAreaType.Pie;
this.Chart.ShowLegend = true;
PieSeries series = new PieSeries();
series.DataPoints.Add(new PieDataPoint(50, "Germany"));
series.DataPoints.Add(new PieDataPoint(70, "United States"));
series.DataPoints.Add(new PieDataPoint(40, "France"));
series.DataPoints.Add(new PieDataPoint(25, "United Kingdom"));
series.ShowLabels = true;
this.Chart.Series.Add(series);

Workaround:

Private Sub LegendElement_VisualItemCreating(sender As Object, e As LegendItemElementCreatingEventArgs)
    Dim pieElement As PiePointElement = DirectCast(e.LegendItem.Element, PiePointElement)
    Dim dataPoint As PieDataPoint = DirectCast(pieElement.DataPoint, PieDataPoint)
    e.LegendItem.Title = dataPoint.Name
End Sub
1 comment
ADMIN
Ivan Petrov
Posted on: 13 Jan 2015 12:45
Currently the PieDataPoint constructor taking two parameters uses the second (string) one as the name for the PieDataPoint. This name is used by the theming mechanism and is not displayed anywhere in the chart. To change the value displayed for a given pie data point in the chart legend you can use one of three approaches:
1. The workaround demonstrated above.
2. You can set the Label property of each data point.
3. You can use the DisplayMember property of the PieSeries if you are using the chart in bound mode.

Note that 2 and 3 will also change the text displayed for the individual pie segments inside the chart area.

As of Q1 2015 pie data points will have a LegendTitle property which will define the text displayed in the chart legend. You will also have access to a LegendTitleMember property which can be used for bound mode scenarios. The Name property will be obsolete and the constructor will use the second parameter to set the LegendTitle instead of the Name property.