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

PointTemplate in Chart with SeriesDescriptor

2 Answers 168 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 27 Jun 2014, 03:56 PM
Hi, How can I set a PointTemplate to chart series, series are defined using SeriesDescriptor.
My goal is to show tooltips in each point of the series
I have tried the following but is not working
Thanks for your help.
<Grid.Resources>
              <DataTemplate x:Key="PointDataTemplate">
                <Ellipse Width="6" Height="6" />
            </DataTemplate>
</Grid.Resources>

<telerik:RadCartesianChart x:Name="MonitoringParameterChart" >
           <telerik:RadCartesianChart.Behaviors>
               <telerik:ChartTooltipBehavior HorizontalOffset="-17" VerticalOffset="-70"/>
           </telerik:RadCartesianChart.Behaviors>
           <telerik:RadCartesianChart.TooltipTemplate>
               <DataTemplate>
                   <Grid>
                       <Path Data="M-1236,-441 L-1208,-441 L-1208,-424 L-1228,-424 L-1230.5,-420 L-1233,-424 L-1236,-424 z"
                                       Stretch="Fill" Fill="#FFFFFFFF" Stroke="#FF767676" StrokeThickness="1" />
                       <TextBlock Margin="6,4,6,10" FontSize="11">
                                           <Run Text="{Binding Value, StringFormat=\{0:#########\}}"/>
                                           <LineBreak/>
                                           <Run Text="{Binding Category, StringFormat=\{0:dd MMM yyyy\}}"/>
                       </TextBlock>
                   </Grid>
               </DataTemplate>
           </telerik:RadCartesianChart.TooltipTemplate>
           <telerik:RadCartesianChart.SeriesProvider>
               <telerik:ChartSeriesProvider x:Name="MonitoringParametersSeriesProvider" Source="{Binding}">
                   <telerik:ChartSeriesProvider.SeriesDescriptors >
                       <telerik:CategoricalSeriesDescriptor ItemsSourcePath="Values" ValuePath="Value" CategoryPath="Time" >
                           <telerik:CategoricalSeriesDescriptor.Style>
                               <Style TargetType="telerik:LineSeries">
                                   <Setter Property="StrokeThickness" Value="1"/>
                                    <Setter Property="PointTemplate" Value="{StaticResource PointDataTemplate}" />
                               </Style>
                           </telerik:CategoricalSeriesDescriptor.Style>
                       </telerik:CategoricalSeriesDescriptor>
                   </telerik:ChartSeriesProvider.SeriesDescriptors>
               </telerik:ChartSeriesProvider>
           </telerik:RadCartesianChart.SeriesProvider>
 
       </telerik:RadCartesianChart>

2 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 30 Jun 2014, 02:58 PM
I found a thread that gave me the solution:
<Setter Property="PointTemplate" ><BR> <Setter.Value><BR>
<DataTemplate><BR> <Ellipse Width="6" Height="6" Fill="{Binding
Converter={StaticResource paletteConverter}}"/><BR> </DataTemplate><BR>
</Setter.Value><BR> </Setter>
public class PaletteConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            CategoricalDataPoint point = value as CategoricalDataPoint;
            LineSeries series = point.Presenter as LineSeries;
            RadCartesianChart chart = series.Chart as RadCartesianChart;
            int seriesIndex = chart.Series.IndexOf(series);
            return chart.Palette.GlobalEntries[seriesIndex].Fill;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
           throw new NotImplementedException();
        }
 
    }

The only troblue is that I have more series than color in the palette.
0
Pavel R. Pavlov
Telerik team
answered on 01 Jul 2014, 08:00 AM
Hello Daniel,

I am happy to hear that you have found an approach that achieves your requirement for custom PointTemplate. Regarding the number of the colors in a palette, if you need to extend the palette (to add more colors) you can take a look at the Creating Custom palettes article. Following it, you will be able to define custom colors that will be used to paint your series. This will allow you to control the number of the series with different colors.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ChartView
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Share this question
or