change style of series item label

5 posts, 0 answers
  1. cielo valdoz
    cielo valdoz avatar
    33 posts
    Member since:
    Dec 2009

    Posted 20 Apr 2010 Link to this post

    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> 

  2. Grtjn
    Grtjn avatar
    129 posts
    Member since:
    Feb 2010

    Posted 20 Apr 2010 Link to this post

    Hi,

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

    Hope it helps...

    Gertjan
  3. DevCraft banner
  4. Sia
    Admin
    Sia avatar
    667 posts

    Posted 20 Apr 2010 Link to this post

    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.
  5. cielo valdoz
    cielo valdoz avatar
    33 posts
    Member since:
    Dec 2009

    Posted 21 Apr 2010 Link to this post

    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?
  6. Sia
    Admin
    Sia avatar
    667 posts

    Posted 22 Apr 2010 Link to this post

    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.
Back to Top
DevCraft banner