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

Find the color of my serie when use of Z-Index

1 Answer 41 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Vinc3nt
Top achievements
Rank 1
Vinc3nt asked on 05 Jul 2013, 07:26 AM
Hi,

I have define a PointTemplate wich create a white ellipse filled with the color of the serie.
When I don't use Z-Index to put the Bar Serie and Area Serie behind, I can find easily the color of the serie (the index of the serie equals to the index of the color in palette) .
But when I use Z-Index, the series' order is different so I can't find my color.

Is there a way to find the color use by the serie without using the index ?

Thank you in advance,
Vincent

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Kirov
Telerik team
answered on 10 Jul 2013, 07:46 AM
Hi Vincent,

RadChartView takes colors from its palette in same order as its series appear in the chart.Series collection (independent from their .ZIndex values). This means that you can use a converter for the ellipse fill like this:
<DataTemplate>
    <Ellipse Width="5" Height="5" Fill="{Binding Converter={StaticResource PaletteConveter}}"/>
</DataTemplate>
public class PaletteConveter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        var dp = value as DataPoint;
 
        var series = (dp.Presenter as CartesianSeries);
 
        var chart = series.ParentOfType<RadCartesianChart>();
 
        var palette = chart.Palette;
 
        int seriesIndex = chart.Series.IndexOf(series);
        int paletteColorsCount = palette.GlobalEntries.Count;
 
        var brush = palette.GlobalEntries[seriesIndex % paletteColorsCount].Fill;
 
        return brush;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

I hope this helps.
 
Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Vinc3nt
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or