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

Accessing LineSeries LabelDefinitions inside CategoricalSeriesDescriptor

2 Answers 202 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sivakumar
Top achievements
Rank 1
Sivakumar asked on 14 Mar 2016, 01:39 AM
I am trying to provide custom label definition for dynamic line series.I could not set access LabelDefinitions for line series type  inside CategoricalSeriesDescriptor.Style . Can you please suggest how to do it ? 
<telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding YourData}">
        <telerik:ChartSeriesProvider.SeriesDescriptors>
            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="YourData" ValuePath="Value" CategoryPath="Category">
                <telerik:CategoricalSeriesDescriptor.Style>
                    <Style TargetType="telerik:LineSeries">
                        <Setter Property="LabelDefinitions">
                            <Setter.Value>
                                <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Center" >
                                    <telerik:ChartSeriesLabelDefinition.Template>
                                        <DataTemplate>
                                            <TextBlock Foreground="DarkBlue" Text="{Binding DataItem.Value}" />
                                        </DataTemplate>
                                    </telerik:ChartSeriesLabelDefinition.Template>
                                </telerik:ChartSeriesLabelDefinition>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </telerik:CategoricalSeriesDescriptor.Style>
            </telerik:CategoricalSeriesDescriptor>
        </telerik:ChartSeriesProvider.SeriesDescriptors>
    </telerik:ChartSeriesProvider>
</telerik:RadCartesianChart.SeriesProvider>

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 16 Mar 2016, 09:30 AM
Hi Sivakumar,

You cannot set LabelDefinitions collection through style because it is read-only. In order to add labels definitions you can use an attached property to set the definition and in the OnPropertyChangedCallback push it in the LabelDefinitions of the series. You can find this approach demonstrated in the Label Template Customization example.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Sivakumar
Top achievements
Rank 1
answered on 17 Mar 2016, 01:30 AM
Thanks Martin...It is working..
Tags
ChartView
Asked by
Sivakumar
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Sivakumar
Top achievements
Rank 1
Share this question
or