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

Advanced Chart Functionality

1 Answer 67 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jay
Top achievements
Rank 1
Jay asked on 16 Apr 2012, 09:23 PM
I was wondering if i can expand the series legend box and have more information in it like the attached picture. I would like to have legend look like what it has for "top 5 spending" is it possible?

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 19 Apr 2012, 09:24 AM
Hello Jay,

Expanding the legend like the scenario you have described is not supported out of the box.

In order to display custom count of legend items, you can either set them manually by wiring to the BeforeLayout event like this:
void radChart_BeforeLayout(object sender, EventArgs e)
    {
        radChart.Legend.Visible = true;
        radChart.Legend.Clear();
        radChart.Legend.Items.Clear();
        radChart.Legend.RemoveAllLabels();
 
        LabelItem label1 = new LabelItem();
        label1.TextBlock.Text = "Label 1";
        label1.Visible = true;
        radChart.Legend.Items.Add(label1);
 
 
        LabelItem label2 = new LabelItem();
        label2.TextBlock.Text = "Label 2";
        label2.Visible = true;
        radChart.Legend.Items.Add(label2);
 
        LabelItem label3 = new LabelItem();
        label3.TextBlock.Text = "Label 3";
        label3.Visible = true;
        radChart.Legend.Items.Add(label3);
 
        radChart.Legend.Add(label1);
        radChart.Legend.Add(label2);
        radChart.Legend.Add(label3);
    }
or 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.

Hope this helps.

Greetings,
Peshito
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Chart (obsolete as of Q1 2013)
Asked by
Jay
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or