How to programatically set the Legend on a PIE Chart

4 posts, 0 answers
  1. bill
    bill avatar
    14 posts
    Member since:
    Sep 2008

    Posted 16 Mar 2009 Link to this post

    How would you programatically create chartlegened itmes for a pie chart and be able to associate them with a specific chart such that it matches the colors of the specific chart.   I am able to programatically create ChartLegendItems and add them to the chart i.e.
    chart1.defaultview.chartlegend.Items.Add(chartlegenditem1) ... but the items show up with white background.  How do I associate the chartlegenditems with the chart so that the colors match?


  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 19 Mar 2009 Link to this post

    Hello Bill,

    Actually, you shouldn't have to do this. The legend items are controlled by the SeriesDefinition.LegendDisplayMode property. For pie and doughnut series definition this property is set LegendDisplayMode.DataPointLabel by default, so for each slice there is an item in the legend and this item is automatically styled by RadChart to match the style of the corresponding chart item.

    Regards,
    Ves
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Kevin
    Kevin avatar
    3 posts
    Member since:
    Mar 2009

    Posted 02 Apr 2009 Link to this post

    I need to do something similar. I know how to get the colors to match up with each other, but I'd like to be able to choose what those colors are. Is there any way to do this for the pie chart?
  4. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 06 Apr 2009 Link to this post

    Hi Kevin,

    As suggested in the support ticket you opened, the best approach is to use the MVVM pattern which is heavily utilized in silverlight applications. We have prepared an online example which should help users trying to implement it with RadChart for Silverlight.

    Regards,
    Vladimir Milev
Back to Top