Simulating a PointSeries

2 posts, 0 answers
  1. Peter Chapman
    Peter Chapman avatar
    17 posts
    Member since:
    May 2010

    Posted 06 Jun 2013 Link to this post

    Hi Telerik,

    I'm glad to see you're including a point series in your next release. At the moment I'm simulating a point series by styling a LineSeries, and making the stroke transparent. I then use a PointTemplate to make the point, as below.

    My question is how can I bind the fill brush of the ellipse I'm using to the palette colour for the series?

    thanks

     <Style x:Key="LineSeriesAsPointsStyle" TargetType="{x:Type telerik:LineSeries}">
        <Setter Property="StrokeShapeStyle">
        <Setter.Value>
        <Style TargetType="{x:Type Path}">
        <Setter Property="Stroke" Value="#00000000"/>
        <Setter Property="StrokeThickness" Value="0"/>
        </Style>
        </Setter.Value>
        </Setter>
    <Setter Property="PointTemplate">
    <Setter.Value>
    <DataTemplate>
    <Ellipse Height="7" Width="7" Fill="Red" /><!-- here is the problem -->
    </DataTemplate>
    </Setter.Value>
    </Setter>
        </Style>
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 11 Jun 2013 Link to this post

    Hi Peter,

    The workaround with releases before Q2 2013 is to bind the Fill/Background of you PointTemplate and use a converter like this:
    <DataTemplate>
       <Ellipse Height="7" Width="7"
            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();
        }
    }

    Actually, you can try the Q2 2013 Beta release which was released last week if you want to used PointSeries out-of-the-box.

    You need to go to your account -> Products & Subscriptions -> RadControls for WPF -> Download Installer and other resources -> and at the bottom of list you should be able to find the files for Beta release.

    Let me know if I can assist you further.

    Regards,
    Petar Kirov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top