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

Spider background label color

4 Answers 71 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jeff Kershner
Top achievements
Rank 1
Jeff Kershner asked on 17 Sep 2010, 11:24 PM

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.

4 Answers, 1 is accepted

Sort by
0
Jeff Kershner
Top achievements
Rank 1
answered on 21 Sep 2010, 04:35 PM
Still waiting for an anwer for this?  Is this not possible?
0
Sia
Telerik team
answered on 21 Sep 2010, 04:51 PM
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
0
Jeff Kershner
Top achievements
Rank 1
answered on 21 Sep 2010, 05:08 PM

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"

0
Accepted
Sia
Telerik team
answered on 21 Sep 2010, 05:26 PM
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
Tags
Chart
Asked by
Jeff Kershner
Top achievements
Rank 1
Answers by
Jeff Kershner
Top achievements
Rank 1
Sia
Telerik team
Share this question
or