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"
                        <Series> 
                            <telerik:ChartSeries Name="Total" DataLabelsColumn="Name" DataYColumn="Total" Type="Pie" Appearance-LegendDisplayMode="ItemLabels"
                                <Appearance> 
                                    <FillStyle FillType="Solid" MainColor="69, 115, 167"
                                    </FillStyle> 
                                    <TextAppearance TextProperties-Color="Black"
                                    </TextAppearance> 
                                    <Border Color="69, 115, 167" /> 
                                </Appearance> 
                            </telerik:ChartSeries> 
                        </Series> 
                        <PlotArea> 
                            <XAxis AutoScale="False" Step="1"
                            <AxisLabel TextBlock-Text="#Y"></AxisLabel> 
                                <Appearance Color="134, 134, 134"
                                </Appearance> 
                            </XAxis> 
                            <Appearance Dimensions-Margins="10,10,10,10"
                                <FillStyle FillType="Solid" MainColor="255, 255, 255"
                                </FillStyle> 
                                <Border Visible="false" /> 
                            </Appearance> 
                        </PlotArea> 
                        <Appearance Border-Visible="false" FillStyle-MainColor="White" /> 
                        <ChartTitle Visible="false" /> 
                        <Legend Visible="true" /> 
                    </telerik:RadChart> 

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,

Regards,
Tyler.

1 Answer, 1 is accepted

Sort by
0
Ves
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,
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.
Tags
Chart (Obsolete)
Asked by
Tyler Watson
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or