This is a migrated thread and some comments may be shown as answers.

Problems setting % to SeriesItem.Name

5 Answers 105 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
André Paulo
Top achievements
Rank 1
André Paulo asked on 10 Aug 2010, 03:45 PM
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?

5 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 13 Aug 2010, 08:15 AM
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
0
André Paulo
Top achievements
Rank 1
answered on 13 Aug 2010, 03:14 PM
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?
0
Ves
Telerik team
answered on 18 Aug 2010, 11:38 AM
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
0
Trevor
Top achievements
Rank 1
answered on 11 Aug 2011, 08:37 AM
How can this be implemented when using asp:SqlDataSource?
0
Ves
Telerik team
answered on 16 Aug 2011, 02:22 PM
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 >>

Tags
Chart (obsolete as of Q1 2013)
Asked by
André Paulo
Top achievements
Rank 1
Answers by
Ves
Telerik team
André Paulo
Top achievements
Rank 1
Trevor
Top achievements
Rank 1
Share this question
or