How to add extra value (customized ) to a pie chart ??

Thread is closed for posting
2 posts, 0 answers
  1. Santele
    Santele avatar
    15 posts
    Member since:
    Jul 2013

    Posted 04 Sep 2013 Link to this post

    HI, Am using a pie chart where I have to show a value on chart. I am able to show the value "Value1" but not value2. How can I achieve to show both these values?

    <Series>
                                                <telerik:ChartSeries Name="Series0" Type="Pie" DataYColumn="value1" DataYColumn2="value2" >
                                                    <appearance legenddisplaymode="lables">
                                                        <FillStyle FillType="Solid" ">
                                                        </FillStyle>
                                                        <TextAppearance TextProperties-Color="Black">
                                                        </TextAppearance>
                                                        <Border Color="" />
                                                </appearance>
                                                </telerik:ChartSeries>
                                            </Series>

    In code behind: am trying 
    radchart1.Series[0].DefaultLabelValue = "#Y, #Y2";


    Please help me on this.
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 09 Sep 2013 Link to this post

    Hi Santele,

    Using the DefaultLabelValue property you can not show value2 because the DataYColumn2 binding is not evaluated for Pie series.

    Instead you can use the ItemDataBound event to set the format of each item label, like this:
    this.radChart1.ItemDataBound += radChart1_ItemDataBound;
     
    this.radChart1.DataBind();
     
    void radChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
    {
        var dataItem = (DataRowView)e.DataItem;
        e.SeriesItem.Label.TextBlock.Text =
        string.Format("{0}, {1}",
            dataItem["value1"],
            dataItem["value2"]);
    }

    I hope this helps.

    Regards,
    Petar Kirov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top