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"
                                <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,

  2. Ves
    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,
    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