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

Simulating a PointSeries

1 Answer 60 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Peter Chapman
Top achievements
Rank 1
Peter Chapman asked on 06 Jun 2013, 10:56 AM
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>

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 11 Jun 2013, 07:41 AM
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.

Tags
ChartView
Asked by
Peter Chapman
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or