Custom Legend in Pie Chart

3 posts, 1 answers
  1. Arvind
    Arvind avatar
    6 posts
    Member since:
    Aug 2010

    Posted 04 Aug 2010 Link to this post

    Hi,
       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 =

    "ItemName";

     

    radChart1.DataManager.ValuesXColumn =

    "Value";

     

    radChart1.IntelligentLabelsEnabled =

    true;

     

    radChart1.DataBind();

    radChart1.Series[0].Name =

    "LegendName";

     

    radChart1.Series[0].Appearance.LegendDisplayMode =

    ChartSeriesLegendDisplayMode.ItemLabels;

     

    radChart1.Update();


    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?

    Regards,
    Arvind Robin Kumar.
  2. Answer
    Ves
    Admin
    Ves avatar
    2879 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,
    Ves
    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. UI for WinForms is Visual Studio 2017 Ready
  4. 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