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

Pie Chart SeriesItemLabelStyle and connectors not showing

1 Answer 90 Views
Chart
This is a migrated thread and some comments may be shown as answers.
jason
Top achievements
Rank 1
jason asked on 07 Mar 2011, 07:29 PM
I have created a pie chart with you most recent binaries.  I ran it and everything looked good (spider mode was visible) but then when I applied a SeriesItemLabelStyle to my pie chart the connectors no longer show up?  Am I missing a property in the style?  Here is my style and also a code snippet of where I apply it.  I also attached a screen shot of the pie chart.

<Style x:Key="PieLabelStyle" TargetType="series:SeriesItemLabel">
        <Setter Property="ConnectorVisibility" Value="Visible" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="series:SeriesItemLabel">
                    <Border x:Name="PART_TextContainer" BorderBrush="Black"  CornerRadius="2" BorderThickness="1" Style="{TemplateBinding LabelStyle}">
                        <Grid >
                            <Grid.ColumnDefinitions >
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding DataItem.XVal}" Foreground="Black" />
                            <TextBlock Grid.Column="1" Text="{Binding DataItem.YVal}" Foreground="Black" />
                            <Rectangle Fill="LightBlue" Opacity=".3" Grid.ColumnSpan="2"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
I tried this in the Chart_DataBound method:
(series.Definition as SeriesDefinition).SeriesItemLabelStyle = _resources["PieLabelStyle"as Style;

and also this:
 (definitions[0] as RadialSeriesDefinition).SeriesItemLabelStyle = _resources["PieLabelStyle"as Style;

I thought I found a couple similar posts on this but none of the replies seemed to work. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 10 Mar 2011, 09:14 AM
Hi jason,

The connectors are not displayed because you are missing the Path from the style that contains the PathFigure x:Name="PART_Connector". Please, consider setting the style in the following manner :
<Style x:Key="PieLabelStyle" TargetType="telerikChart:SeriesItemLabel">
    <Setter Property="ConnectorVisibility" Value="Visible" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="telerikChart:SeriesItemLabel">
                <Canvas x:Name="PART_MainContainer">
                    <Path    Visibility="{TemplateBinding ConnectorVisibility}"
                       Style="{TemplateBinding ConnectorStyle}"
                       Stroke="{TemplateBinding Stroke}"
                       StrokeThickness="{TemplateBinding StrokeThickness}">
                        <Path.Data>
                            <PathGeometry >
                                <PathGeometry.Figures>
                                    <PathFigure x:Name="PART_Connector">
                                        <PathFigure.Segments>
                                            <PolyLineSegment />
                                        </PathFigure.Segments>
                                    </PathFigure>
                                </PathGeometry.Figures>
                            </PathGeometry>
                        </Path.Data>
                    </Path>
                    <Grid >
                        <Grid.ColumnDefinitions >
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{Binding DataItem.XVal}" Foreground="Black" />
                        <TextBlock Grid.Column="1" Text="{Binding DataItem.YVal}" Foreground="Black" />
                        <Rectangle Fill="LightBlue" Opacity=".3" Grid.ColumnSpan="2"/>
                        <Border x:Name="PART_TextContainer" BorderBrush="Black" Grid.ColumnSpan="2" CornerRadius="2" BorderThickness="1" Style="{TemplateBinding LabelStyle}">
                        </Border>
                    </Grid>
                </Canvas>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

RadChart1.DefaultSeriesDefinition.SeriesItemLabelStyle = this.Resources["PieLabelStyle"] as Style;

This way the connectors should be displayed correctly. Hope this helps.

Best wishes,
Nikolay
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Chart
Asked by
jason
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or