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

change style of series item label

4 Answers 147 Views
Chart
This is a migrated thread and some comments may be shown as answers.
cielo valdoz
Top achievements
Rank 1
cielo valdoz asked on 20 Apr 2010, 09:00 AM
Hi,

I upgraded to new 2010 version (Q1 2010) then the foreground color of x-axis and y-axis label becomes black. How can i change the style of it? Pls check the attached image.

I set the foreground color into White but still the color is black. Pls help.
Thanks
    <Style x:Key="CustomStyle" TargetType="telerikCharting:Bar">  
            <Setter Property="Template">  
                <Setter.Value> 
                    <ControlTemplate TargetType="telerikCharting:Bar">  
                        <Canvas> 
                            <Rectangle x:Name="PART_DefiningGeometry"   
                                   Height="{TemplateBinding ItemActualHeight}" 
                                   Width="{TemplateBinding ItemActualWidth}" 
                                   RadiusX="2"   
                                   RadiusY="2"   
                                   StrokeThickness="1" 
                                   Fill="{Binding DataItem.StockHealthColor}"/>  
                             <telerikCharting:SeriesItemLabel x:Name="PART_SeriesItemLabelBar" 
                                   HorizontalAlignment="Center" 
                                   Width="{TemplateBinding ItemActualWidth}" 
                                   Foreground="White" 
                                   /> 
                            <Canvas.RenderTransform> 
                                <ScaleTransform x:Name="PART_AnimationTransform" ScaleY="0" /> 
                            </Canvas.RenderTransform> 
                            <Canvas.Triggers> 
                                <EventTrigger RoutedEvent="Rectangle.Loaded">  
                                    <EventTrigger.Actions> 
                                        <BeginStoryboard> 
                                            <Storyboard BeginTime="00:00:00.5" 
                                                    x:Name="PART_Storyboard">  
                                                <DoubleAnimationUsingKeyFrames   
                                                        Storyboard.TargetName="PART_AnimationTransform"   
                                                        Storyboard.TargetProperty="ScaleY" 
                                                        Duration="00:00:00.5" 
                                                        BeginTime="00:00:00.2">  
                                                    <SplineDoubleKeyFrame KeySpline="0.646,0.239,1,1" KeyTime="00:00:00" Value="0.025"/>  
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.495" Value="0.99" KeySpline="0.26,0.564,0.512,1"/>  
                                                </DoubleAnimationUsingKeyFrames> 
                                                <DoubleAnimationUsingKeyFrames   
                                                        Storyboard.TargetName="PART_DefiningGeometry"   
                                                        Storyboard.TargetProperty="Opacity" 
                                                        Duration="00:00:00.5" 
                                                        BeginTime="00:00:00.2">  
                                                    <SplineDoubleKeyFrame KeySpline="0.646,0.239,1,1" KeyTime="00:00:00" Value="0.7"/>  
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.495" Value="1" KeySpline="0.26,0.564,0.512,1"/>  
                                                </DoubleAnimationUsingKeyFrames> 
                                            </Storyboard> 
                                        </BeginStoryboard> 
                                    </EventTrigger.Actions> 
                                </EventTrigger> 
                            </Canvas.Triggers> 
                        </Canvas> 
                    </ControlTemplate> 
                </Setter.Value> 
            </Setter> 
        </Style> 

4 Answers, 1 is accepted

Sort by
0
Grtjn
Top achievements
Rank 1
answered on 20 Apr 2010, 11:26 AM
Hi,

Try this:
            radChart.AxisElementBrush = new SolidColorBrush(Colors.White);  
            radChart.AxisForeground = new SolidColorBrush(Colors.White); 

Hope it helps...

Gertjan
0
Sia
Telerik team
answered on 20 Apr 2010, 01:49 PM
Hi cielo valdoz,

In addition to Gertjan's message, I would suggest using the following styles if you need to change the foregrounds of the ChartTitle and the ChartLegend:
<Style x:Key="CustomLegend" TargetType="chart:ChartLegend" >
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="White" />
</Style>
 
<Style x:Key="CustomTitle" TargetType="chart:ChartTitle">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="OuterBorderThickness" Value="0" />
</Style>
 
<Style x:Key="CustomLegendItemTemplate" TargetType="chart:ChartLegendItem" >
    <Setter Property="Foreground" Value="White" />
</Style>

and set them in your code behind:
RadChart1.DefaultView.ChartLegend.Style = this.LayoutRoot.Resources["CustomLegend"] as Style;
RadChart1.DefaultView.ChartTitle.Style = this.LayoutRoot.Resources["CustomTitle"] as Style;
RadChart1.DefaultView.ChartLegend.LegendItemStyle = this.LayoutRoot.Resources["CustomLegendItemTemplate"] as Style;

Hope this helps.

Best wishes,
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
cielo valdoz
Top achievements
Rank 1
answered on 22 Apr 2010, 03:42 AM
Hi,

I mean the Y and X axis label of the chart. Its a ChartArea but it does not have a AxisElementBrush property. I think the default Axis style is black. How can i change it?
0
Sia
Telerik team
answered on 22 Apr 2010, 01:23 PM
Hi cielo valdoz,

The properties mentioned below are available after our 2010.Q1 Release. If you use older version of our controls, please update to the latest version.

The AxisElementBrush property replaces the default background color of the Axes and the Ticks.
RadChart1.AxisElementBrush = new SolidColorBrush(Colors.White);
where RadChart1 is the x:Name of your RadChart.

The AxisForeground replaces the default foreground of the X and Y axis and the foreground of the Axes' titles.
RadChart1.AxisForeground = new SolidColorBrush(Colors.White);

Kind regards,
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
cielo valdoz
Top achievements
Rank 1
Answers by
Grtjn
Top achievements
Rank 1
Sia
Telerik team
cielo valdoz
Top achievements
Rank 1
Share this question
or