This question is locked. New answers and comments are not allowed.
Hello,
I'm working (for the first time) with a RadChart (pie).
I'm binding it to a IBindingList<MyClass>. MyClass defines 2 properties, one for the legend and the other is for the percentage.
Id like to set the color for individual slices depending on the item object they are representing. I would distinguish them using the property wich contains the legend (It's called "Name").
Is it possible? I'm trying this, which is not working:
(after Data Binding)
grafica1.Series[0].Items[0].Appearance.FillStyle.MainColor = Color.LightGreen;
grafica1.Series[0].Items[1].Appearance.FillStyle.MainColor = Color.Yellow;
grafica1.Series[0].Items[2].Appearance.FillStyle.MainColor = Color.Red;
grafica1.UpdateGraphics();
and also this:
private void grafica1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
{
if (e.SeriesItem != null)
{
DataRowView percentage = e.DataItem as DataRowView;
if (percentage != null)
{
if (percentage["Name"] == "Apto")
e.SeriesItem.Appearance.FillStyle.MainColor = Color.LightGreen;
else if (percentage["Name"] == "Móvil")
e.SeriesItem.Appearance.FillStyle.MainColor = Color.Yellow;
else
e.SeriesItem.Appearance.FillStyle.MainColor = Color.Red;
grafica1.UpdateGraphics();
e.SeriesItem.Label.TextBlock.Text = string.Format("{0} %", percentage["Cantidad"]);
}
}
}
None of these aproaches is working :(
Best regards,
Gonzalo
I'm working (for the first time) with a RadChart (pie).
I'm binding it to a IBindingList<MyClass>. MyClass defines 2 properties, one for the legend and the other is for the percentage.
Id like to set the color for individual slices depending on the item object they are representing. I would distinguish them using the property wich contains the legend (It's called "Name").
Is it possible? I'm trying this, which is not working:
(after Data Binding)
grafica1.Series[0].Items[0].Appearance.FillStyle.MainColor = Color.LightGreen;
grafica1.Series[0].Items[1].Appearance.FillStyle.MainColor = Color.Yellow;
grafica1.Series[0].Items[2].Appearance.FillStyle.MainColor = Color.Red;
grafica1.UpdateGraphics();
and also this:
private void grafica1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
{
if (e.SeriesItem != null)
{
DataRowView percentage = e.DataItem as DataRowView;
if (percentage != null)
{
if (percentage["Name"] == "Apto")
e.SeriesItem.Appearance.FillStyle.MainColor = Color.LightGreen;
else if (percentage["Name"] == "Móvil")
e.SeriesItem.Appearance.FillStyle.MainColor = Color.Yellow;
else
e.SeriesItem.Appearance.FillStyle.MainColor = Color.Red;
grafica1.UpdateGraphics();
e.SeriesItem.Label.TextBlock.Text = string.Format("{0} %", percentage["Cantidad"]);
}
}
}
None of these aproaches is working :(
Best regards,
Gonzalo