How to add LabelDefinitions into ChartSeriesProvider

5 posts, 1 answers
  1. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 09 Jun 2015 Link to this post

    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>
  2. Answer
    Martin
    Admin
    Martin avatar
    1101 posts

    Posted 09 Jun 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joel
    Joel avatar
    53 posts
    Member since:
    Sep 2013

    Posted 09 Jun 2015 Link to this post

    It works! Thanks.
  5. Renier Pretorius
    Renier Pretorius avatar
    46 posts
    Member since:
    Apr 2010

    Posted 22 Apr in reply to Martin Link to this post

     

    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

     

  6. Renier Pretorius
    Renier Pretorius avatar
    46 posts
    Member since:
    Apr 2010

    Posted 22 Apr in reply to Renier Pretorius Link to this post

    Solved it. Did not need the RotatePanel bit after all.
Back to Top
UI for WPF is Visual Studio 2017 Ready