Pie Chart Legend

Thread is closed for posting
2 posts, 0 answers
  1. Joan
    Joan avatar
    44 posts
    Member since:
    Dec 2011

    Posted 07 Mar 2012 Link to this post

    Is it possible to add an extra item to a pie chart legend with the new item as the last one?  I can add an the extra item, but it always appears first.
  2. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 12 Mar 2012 Link to this post

    Hello Joan,

    You can achieve the desired effect by adding the custom legend item in the RadChart.BeforeLayout event handler like this:
    public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            ChartSeries series1 = new ChartSeries();
            if (!IsPostBack)
                ChartSeries series = new ChartSeries() { Type = ChartSeriesType.Pie };
                series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
                series.Items.Add(new ChartSeriesItem(20) { Name = "Test 1" });
                series.Items.Add(new ChartSeriesItem(40) { Name = "Test 2" });
                series.Items.Add(new ChartSeriesItem(60) { Name = "Test 3" });
                radChart.BeforeLayout += this.radChart_BeforeLayout;
        private void radChart_BeforeLayout(object sender, EventArgs e)
            var style = new FillStyle();
            style.MainColor = Color.Red;
            style.FillType = FillType.Solid;
            radChart.Legend.AddCustomItemToLegend("Custom", style, DefaultFigures.Cross);

    Hope this helps.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top