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

RadChart with different ItemLabel

1 Answer 140 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Tyler Watson
Top achievements
Rank 1
Tyler Watson asked on 09 Apr 2010, 05:58 AM
Good afternoon ladies and gentlemen,

I want to create a Pie chart using a RadChart control as declared below: 

<telerik:RadChart runat="server" ID="RadChart1" DefaultType="Pie" Skin="Office2007"
                            <telerik:ChartSeries Name="Total" DataLabelsColumn="Name" DataYColumn="Total" Type="Pie" Appearance-LegendDisplayMode="ItemLabels"
                                    <FillStyle FillType="Solid" MainColor="69, 115, 167"
                                    <TextAppearance TextProperties-Color="Black"
                                    <Border Color="69, 115, 167" /> 
                            <XAxis AutoScale="False" Step="1"
                            <AxisLabel TextBlock-Text="#Y"></AxisLabel> 
                                <Appearance Color="134, 134, 134"
                            <Appearance Dimensions-Margins="10,10,10,10"
                                <FillStyle FillType="Solid" MainColor="255, 255, 255"
                                <Border Visible="false" /> 
                        <Appearance Border-Visible="false" FillStyle-MainColor="White" /> 
                        <ChartTitle Visible="false" /> 
                        <Legend Visible="true" /> 

Is it possible to have the legend display a different data column as opposed to which is specified by DataLabelsColumn?

The reason for this is I want the axis labels to display the totals as specified in the Total column, and have the legend display something meaningful as the Name column.

If I change the DataLabelsColumn to Count, it also modified the Legend text which isn't what I want.  Am I missing something?  The datasource comes from a stored procedure, and is bound via codebehind at runtime.

Thankyou for your assistance,


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 13 Apr 2010, 10:50 AM
Hello Tyler,

The text shown in the legend items is actually the value of the Name property of the ChartSeriesItem. Unfortunately, there is no property like DataNamesColumn, so you will have to assign the Name property manually. You can wire the ItemDataBound event of RadChart and modify each ChartSeriesItem:

protected void RadChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
        e.SeriesItem.Name = (e.DataItem as DataRowView)["MyLegendColumnName"].ToString();

Best 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.
Chart (Obsolete)
Asked by
Tyler Watson
Top achievements
Rank 1
Answers by
Telerik team
Share this question