Problems setting % to SeriesItem.Name

6 posts, 0 answers
  1. André Paulo
    André Paulo avatar
    3 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2010 Link to this post

    Hello ... i'm taking some problems to set the % to the SeriesItem.Name, 
    It doesn't change to the % value when my graphic renders.

    i also set the ActiveRegion.Tooltip and Label.TextBlock.Text from SeriesItem as the same, but it doesn't work for the Name.


    protected void RadChart1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
    {
        e.SeriesItem.Label.TextBlock.Appearance.TextProperties.Font = new System.Drawing.Font("Arial",
                10, System.Drawing.FontStyle.Bold);
      
        DataRowView row = e.DataItem as DataRowView;
        e.SeriesItem.Label.TextBlock.Text = string.Format("{0} - #%", row["DS_PRODUTO"]);
        e.SeriesItem.ActiveRegion.Tooltip = string.Format("{0} - #%", row["DS_PRODUTO"]);
      
        e.SeriesItem.Name = string.Format("{0} - #%", row["DS_PRODUTO"]);
      
    }

    is it a bug? limitation? my mistake?

    Could anyone help me?
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 13 Aug 2010 Link to this post

    Hello André Paulo,

    Unfortunately, this has not been designed to work for the ChartSeriesItem.Name property. As a workaround you can wire the BeforeLayout event. At this moment the labels are already calculated, so that you can copy their values to the Name property.

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. André Paulo
    André Paulo avatar
    3 posts
    Member since:
    Aug 2010

    Posted 13 Aug 2010 Link to this post

    Hello Ves,

    Thanks for the help.

    i've tried to do the thing that you've suggested but it doesn't works yet.

    have i made any mistake with the code?

    void RadChart1_BeforeLayout(object sender, EventArgs e)
        {
            if( RadChart1.Series.Count > 0 )
            {
                for (int i = 0; i < RadChart1.Series[0].Items.Count; i++ )
                {
                    RadChart1.Series[0].Items[i].Name = RadChart1.Series[0].Items[i].Label.TextBlock.Text;
                }
            }
              
      
        }

    the text in the legend still with the #%.

    Debuging, the property is setted, but it doesn't appear to the legend box.

    can you help me?
  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 18 Aug 2010 Link to this post

    Hi André Paulo,

    Please, accept my apologies for the misleading answer I provided. Indeed, the solution involves wiring the BeforeLayout event. However, modifications made to the ChartSeriesItems at that stage will not be propagated to the legend. So, the correct approach should be to update directly the legend items:

    void radChart1_BeforeLayout(object sender, EventArgs e)
    {
        if (radChart1.Series.Count > 0)
        {
            for (int i = 0; i < radChart1.Series[0].Items.Count; i++)
            {
                radChart1.Legend.Items[i].TextBlock.Text = radChart1.Series[0].Items[i].Label.TextBlock.Text;
            }
        }
    }

    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
  6. Trevor
    Trevor avatar
    3 posts
    Member since:
    Jul 2011

    Posted 11 Aug 2011 Link to this post

    How can this be implemented when using asp:SqlDataSource?
  7. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 16 Aug 2011 Link to this post

    Hello Trevor,

    This implementation is not related to the way the chart is populated with data. It will be valid for asp:SqlDataSource too, given that you use RadChart for ASP.NET AJAX. Is there any specific problem, which would not allow you to implement this?

    Best regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top
UI for WinForms is Visual Studio 2017 Ready