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

Setting Chart Legend - PIE

1 Answer 97 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 25 Aug 2009, 02:11 PM
Hello,
I've inserted a pie chart inside my report and it does a sum of some percentage....with other reporting tool I was able to set at 0-cost the legend to match the seriesitem portion of the pie... here I'm not able to.. here's the code I use:

 private void chart1_NeedDataSource(object sender, EventArgs e) 
        { 
            Telerik.Reporting.Processing.Chart procChart = (Telerik.Reporting.Processing.Chart)sender; 
 
            List<AccountPositionDetail> accountPositionDetailList = GetAccountPositionDetailFromDataSet(this.DataSource as DataSet); 
            ChartSeries cs = new ChartSeries(); 
            cs.Type = ChartSeriesType.Pie; 
            var groupedAccountPosition = accountPositionDetailList.GroupBy(o1 => o1.ClassMifid); 
 
            chart1.Legend.Clear(); 
            foreach (IGrouping<int, AccountPositionDetail> igp in groupedAccountPosition) 
            { 
                ChartSeriesItem csi = new ChartSeriesItem(igp.Sum(o1 => o1.PercOnCTV)); 
 
               cs.Items.Add(csi); 
 
            } 
            chart1.Series.Add(cs); 
 
 
        } 

I've got only a legend Item called "Series XX"... in other chart type (BAR for example) I add different Series and it show...here not...any suggestion?

I've also found this enumerator, but I don't know where to set it : ChartSeriesLegendDisplayMode.ItemLabels;

Thanks

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 25 Aug 2009, 07:27 PM
chart1.Legend.Items[0].TextBlock.Text = "" 

Could also work (I think). You could call it at the end of your function there once the chart has been created and given a data source.



Tags
General Discussions
Asked by
Michele
Top achievements
Rank 2
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or