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

2 posts, 1 answers
  1. Vinc3nt
    Vinc3nt avatar
    10 posts
    Member since:
    Jun 2013

    Posted 05 Jul 2013 Link to this post

    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
  2. Answer
    Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 10 Jul 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top