RadChart with different ItemLabel

Thread is closed for posting
2 posts, 0 answers
  1. Tyler Watson
    Tyler Watson avatar
    2 posts
    Member since:
    Mar 2010

    Posted 09 Apr 2010 Link to this post

    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.
  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 13 Apr 2010 Link to this post

    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.
Back to Top