Spider background label color

5 posts, 1 answers
  1. Jeff Kershner
    Jeff Kershner avatar
    62 posts
    Member since:
    Aug 2009

    Posted 17 Sep 2010 Link to this post

    I can't figure out how to make the background color of a spider label to be transparent.  I am using this for a palette:

    chart.PaletteBrushes.Clear();
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 2, 123, 8)));
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 238, 192, 5)));
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 238, 97, 6)));
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 1, 240, 6)));
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 238, 240, 6)));
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 179, 181, 183)));
    chart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 237, 240, 242)));
      
    chart.PaletteBrushes.Repeat = true;

    Pie definition:
    PieSeriesDefinition def = new PieSeriesDefinition();
      
    def.RadiusFactor = 0.8;
    def.LabelSettings.ShowConnectors = true;
    def.LabelSettings.SpiderModeEnabled = true;
    def.LabelSettings.LabelOffset = 20.0;
    def.InteractivitySettings.HoverScope = InteractivityScope.Item;
    def.InteractivitySettings.SelectionScope = InteractivityScope.Item;
    def.InteractivitySettings.SelectionMode = ChartSelectionMode.Single;
    pieSeries.Definition = def;

    I can't find anywhere were I can set the brush for the spider label.
  2. Jeff Kershner
    Jeff Kershner avatar
    62 posts
    Member since:
    Aug 2009

    Posted 21 Sep 2010 Link to this post

    Still waiting for an anwer for this?  Is this not possible?
  3. Sia
    Admin
    Sia avatar
    745 posts

    Posted 21 Sep 2010 Link to this post

    Hello Jeff Kershner,

    You need to re-template your labels as shown in this example. Please try it and let us know if further questions arise.

    All the best,
    Sia
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  4. Jeff Kershner
    Jeff Kershner avatar
    62 posts
    Member since:
    Aug 2009

    Posted 21 Sep 2010 Link to this post

    From that example, it looks like I need to add a UserControl.Resources with a nested Style called CustomLabelStyle.  And then in the code behind do something like this:

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

    Is that correct?  When I try to do that, I get an Unhandled exception.. Failed to create a System.Type from telerik:SeriesItemLabel.

    I have the following namespace in the xaml:

    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"

  5. Answer
    Sia
    Admin
    Sia avatar
    745 posts

    Posted 21 Sep 2010 Link to this post

    Hi Jeff Kershner,

    Exactly, just need to use a different namespace:
    xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"

    In that case the resource should be:
    <Style x:Key="CustomLabelStyle" TargetType="telerikCharting:SeriesItemLabel">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="2,0" />
        <Setter Property="IsHitTestVisible" Value="False"/>
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="telerikCharting:SeriesItemLabel">
                    <Canvas>
                        <Polyline x:Name="PART_Connector"
                                    Points="{TemplateBinding ConnectorPoints}"
                                    Visibility="{TemplateBinding ConnectorVisibility}"
                                    Style="{TemplateBinding ConnectorStyle}"
                                    Stroke="{TemplateBinding Stroke}"
                                    StrokeThickness="{TemplateBinding StrokeThickness}" />
                        <Border x:Name="PART_TextContainer"
                                Canvas.Left="{TemplateBinding TextContainerCanvasLeft}"
                                Canvas.Top="{TemplateBinding TextContainerCanvasTop}"
                                BorderBrush="{TemplateBinding Stroke}"
                                Background="Transparent">
                            <TextBlock TextAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        Margin="{TemplateBinding Padding}"
                                        Foreground="Black"
                                        Text="{TemplateBinding Content}" />
                        </Border>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    and set it to the data series' definition:
    dataSeries.Definition.SeriesItemLabelStyle = this.Resources["CustomLabelStyle"] as Style;

    All the best,
    Sia
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
Back to Top