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

Item borders in radchart type pie

1 Answer 81 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Roberto
Top achievements
Rank 1
Roberto asked on 22 Nov 2012, 10:32 AM
Hi everyone,

I had a problem with radchart type pie.

I had two chartseriesitem and there is not problem when two items have value. The problem comes when one of two haven't value. In this case, there is a line that appears and shows something like the end of the item that has value (100%).

A possible solution is to remove the border, but I can't remove because a requeriment is that pie have borders.

for example, you have a pie with two sectors. Both sectors have borders. The first of sector, have 100% value and second 0%. If we remove the borders, the line dissapears, but the border of the first sector too. Is any way to preserve the border of the first sector without the line?



Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 26 Nov 2012, 05:17 PM
Hello Roberto,

You can use the ItemDataBound event of the RadChart to check if a series item is empty and if it is - you can remove it. Then you can check in the BeforeLayout event if the series has only one item and if that is the case - set the color of the border of the series to transparent: 
//Register for the events before the DataBind() method is called
RadChart1.ItemDataBound += RadChart1_ItemDataBound;
RadChart1.BeforeLayout += RadChart1_BeforeLayout;
RadChart1.DataBind();
 
void RadChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
{
    if (e.SeriesItem.Empty)
        e.ChartSeries.RemoveItem(e.SeriesItem);
}
 
void RadChart1_BeforeLayout(object sender, EventArgs e)
{
    if (this.RadChart1.Series[0].Items.Count == 1)
        this.RadChart1.Series[0].Appearance.Border.Color = Color.Transparent;
}

 

All the best,
Petar Kirov
the Telerik team
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 their blog feed now.
Tags
Chart (Obsolete)
Asked by
Roberto
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or