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

How to add LabelDefinitions into ChartSeriesProvider

4 Answers 214 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Iron
Joel asked on 09 Jun 2015, 09:39 AM

I want to know how to add LabelDefinitions within this SeriesProvider.

<telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding PolygonFuncTable, Mode=OneWay}">
        <telerik:ChartSeriesProvider.SeriesDescriptors>
            <!-- Polygon -->
            <telerik:ScatterSeriesDescriptor ItemsSourcePath="ColorPoints" XValuePath="X" YValuePath="Y">
                <telerik:ScatterSeriesDescriptor.Style>
                    <Style TargetType="telerik:ScatterLineSeries">
                        <Setter Property="RenderOptions" Value="{StaticResource renderOptions}" />
                        <Setter Property="StrokeThickness" Value="2"/>
                        <Setter Property="Stroke" Value="Black"/>
                        <Setter Property="ShowLabels" Value="False"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=chkShowLabel, Path=IsChecked}" Value="True">
                                <Setter Property="ShowLabels" Value="True"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </telerik:ScatterSeriesDescriptor.Style>
                
            </telerik:ScatterSeriesDescriptor>
 
        </telerik:ChartSeriesProvider.SeriesDescriptors>
    </telerik:ChartSeriesProvider>
</telerik:RadCartesianChart.SeriesProvider>

4 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 09 Jun 2015, 01:18 PM
Hi Joel,

Since the LabelDefinitions collection of the series is not available in the Style's Setters' properties you use an attached property to add the label definition in it. You can see the Label Template Customization example that demonstrates such approach. Please give it a try and let me know if it works for you. As a side note, the example is in Silverlight, but it shares its code with the WPF version and the used approach for the label definition is the same.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Joel
Top achievements
Rank 1
Iron
answered on 10 Jun 2015, 01:10 AM
It works! Thanks.
0
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
answered on 22 Apr 2016, 09:59 AM

 

I am trying to do something very similar and the proposed solution works fine but now i want to rotate the text of the label to display vertically. I know this is the WPF forum, but I am trying to do this in Silverlight. I have tried the following:

<DataTemplate x:Key="labelTemplate">
                <Grid Width="Auto" Height="Auto">
                    <common:RotatePanel Grid.Row="1" Grid.Column="0" >
                        <ContentControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <TextBlock Text="{Binding DataItem.Series}"
                                       Margin="5"
                                       VerticalAlignment="Bottom"
                                       HorizontalAlignment="Left">
                                <TextBlock.RenderTransform>
                                    <RotateTransform Angle="-90"/>
                                </TextBlock.RenderTransform>
                            </TextBlock>
                        </ContentControl>
                    </common:RotatePanel>
                </Grid>
            </DataTemplate>

But the result is that the text gets cut off to probably the original height before rotate.

Regards

Renier

 

0
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
answered on 22 Apr 2016, 10:11 AM
Solved it. Did not need the RotatePanel bit after all.
Tags
ChartView
Asked by
Joel
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Joel
Top achievements
Rank 1
Iron
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or