Completed
Last Updated: 10 Feb 2016 14:29 by ADMIN
ADMIN
Dimitar
Created on: 13 Jan 2016 11:02
Category: ChartView
Type: Bug Report
1
FIX. RadChartView - the legend is not updated when one is removing data points from the series.
To reproduce:
public RadForm1()
{
    InitializeComponent();
    this.radChartView1.AreaType = ChartAreaType.Pie;
    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.radChartView1.Series.Add(series);

    radChartView1.ShowLegend = true;
}
Random rnd = new Random();
private void radButton1_Click(object sender, EventArgs e)
{
     this.radChartView1.Series[0].DataPoints.RemoveAt(0);
     this.radChartView1.Series[0].DataPoints.Add(new PieDataPoint(rnd.Next(100), rnd.Next(100).ToString()));
}

Workaround:

private void radButton1_Click(object sender, EventArgs e)
{
    this.radChartView1.Series[0].DataPoints.RemoveAt(0);
    this.radChartView1.Series[0].DataPoints.Add(new PieDataPoint(50, rnd.Next(100).ToString()));

    this.radChartView1.ChartElement.LegendElement.Items.Clear();

    foreach (PieSeries series in radChartView1.Series)
    {
        for (int i = 0; i < series.DataPoints.Count; i++)
        {
            var dataPoint = series.DataPoints[i] as PieDataPoint;
            var element = series.Children[i] as PiePointElement;

            var legendItem = new LegendItem(element);
            legendItem.Title = dataPoint.LegendTitle;
          
            this.radChartView1.ChartElement.LegendElement.Items.Add(legendItem);
        }
        
    }
}
0 comments