Dynamic Chart - Legend doesn't update

5 posts, 0 answers
  1. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 06 Nov 2013 Link to this post

    Hi everyone

    I have a HTMLChart that gets populated via the database, based on a drop down.

    It works fine, it populates and sets the pie chart, but the legend doesn't update. For example, if the first selection has 2 values, I get two legends, but when I then I get a selection with 4 values, it stays 2 values in the legend? Also, I have set the DataFormatString, but it stays with 4 decimals for the yValue?

    <telerik:RadHtmlChart ID="uxPieChart" runat="server">
        <PlotArea>
            <Series>
                <telerik:PieSeries StartAngle="90">
                    <LabelsAppearance Position="Circle" DataFormatString="{0:C}" />
                    <TooltipsAppearance DataFormatString="{0:C}" />
                </telerik:PieSeries>
            </Series>
        </PlotArea>
        <ChartTitle Text=""/>
    </telerik:RadHtmlChart>
    uxPieChart.PlotArea.Series.Clear();               
     
    int fundID = int.Parse(uxFundList.SelectedValue);
     
    DataTable dt = Fund.BudgetBreakDown(fundID);
     
    PieSeries pieSeries = new PieSeries();
    SeriesItem item;
     
    foreach (DataRow budgetRow in dt.Rows)
    {
        item = new SeriesItem();
        item.YValue = Decimal.Parse(budgetRow["Amount"].ToString());
        item.Name = budgetRow["Header"].ToString();
        pieSeries.Items.Add(item);
    }
     
    uxPieChart.PlotArea.Series.Add(pieSeries);
    Any ideas?

    Thank you

    [EDIT] It was due to 0 Values coming through from the DB, you couldn't see it on the chart, but it created a legend. Sorted it out now.
  2. Stamo Gochev
    Admin
    Stamo Gochev avatar
    157 posts

    Posted 07 Nov 2013 Link to this post

    Hello Jako,

    There shouldn't be a problem with the update of legend's items, so I am glad that you have managed to resolve the issue on your own.

    Regards,
    Stamo Gochev
    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
  4. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 07 Nov 2013 Link to this post

    Hi Stamo

    I still have the issue with the values not being displayed as a Currency?

    As you can see I do set the DataFormatString but it's not working.

    Am I missing something?

    Thanks.
  5. Stamo Gochev
    Admin
    Stamo Gochev avatar
    157 posts

    Posted 12 Nov 2013 Link to this post

    Hi Jako,

    The reason why the PieSeries' labels are not formatted as a currency is that you have set the DataFormatString property for the PieSeries in the markup:
    <telerik:PieSeries StartAngle="90">
        <LabelsAppearance Position="Circle" DataFormatString="{0:C}" />
        <TooltipsAppearance DataFormatString="{0:C}" />
    </telerik:PieSeries>
    Note that we remove this series in the code-behind file:
    uxPieChart.PlotArea.Series.Clear();
    so its configuration does not have any effect at all.

    In order to format the labels as currencies, you should set the DataFormatString property for the second PieSeries, which is created in the code-behind file:
    PieSeries pieSeries = new PieSeries();
    pieSeries.LabelsAppearance.DataFormatString = "{0:C}";
    I am attaching a sample page with this modification. Could you have a look at it and inform me if you could apply it in your page as well?

    Regards,
    Stamo Gochev
    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.
  6. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 12 Nov 2013 Link to this post

    Thanks, that did the trick.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017