Custom Legend in Pie Chart

Thread is closed for posting
3 posts, 1 answers
  1. Arvind
    Arvind avatar
    6 posts
    Member since:
    Aug 2010

    Posted 04 Aug 2010 Link to this post

       The following is the code I use.  I have attached the pie chart generated by this code.


    ICollection<PieChartSeries> pieChartList = new List<PieChartSeries>();



    GeneratePieChart generatePieChart = new GeneratePieChart();


    pieChartList = generatePieChart.GenerateChartSeries();

    radChart1.DataManager.DataSource = pieChartList;

    radChart1.DataManager.LabelsColumn =



    radChart1.DataManager.ValuesXColumn =



    radChart1.IntelligentLabelsEnabled =




    radChart1.Series[0].Name =



    radChart1.Series[0].Appearance.LegendDisplayMode =




    The legends are not displaying the values of the LegendName property of the colloection pieChartList. 
    The LegendName property will have some names like Arvind, Robin, Kumar, Mark, etc...

    Now the radChart is taking the legends as the radChart1.DataManager.LabelsColumnradChart1.DataManager.LabelsColumn's data (ItemName). Is it possible to display a different text for the legend (It should be other than the ItemName)?

    In the above code I am using the line
    radChart1.Series[0].Name = "LegendName";

    Does it have any significance?

    Arvind Robin Kumar.
  2. Answer
    Ves avatar
    2926 posts

    Posted 09 Aug 2010 Link to this post

    Hello Arvind,

    You can wire the ItemDataBound event of RadChart. In the event handler you can set the Name property of each individual ChartSeriesItem -- this is the value which will appear in the legend. The event arguments will hold references to the ChartSeriesItem, ChartSeries and the underlying data. It would be similar to what's shown in this blog post, but you need to set the Name property and not the Label's text.

     Setting the Name property of the ChartSeries would not make any difference in this case. The value of ChartSeries.Name is shown in the legend when the ChartSeries.Appearance.LegendDisplayMode is set to ChartSeriesLegendDisplayMode.SeriesName.

    Kind regards,
    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
  3. André Paulo
    André Paulo avatar
    3 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2010 Link to this post

    i'll put my problem in other topic.
Back to Top