Chart Axis Style for changing the color

6 posts, 0 answers
  1. Li
    Li avatar
    5 posts
    Member since:
    Mar 2011

    Posted 09 Mar 2011 Link to this post

    Hi,
    I'm using the Chart to show my datas.But I can't find what the help say,"this.radChart.DefaultView.ChartArea.AxisY.AxisStyles.AxisLineStyle
    ".
    AxisLineStyle is not available to me.
    Is it because I'm in trial version?
    Thanks.
  2. Li
    Li avatar
    5 posts
    Member since:
    Mar 2011

    Posted 09 Mar 2011 Link to this post

    And..how can I change them all White.Thanks~
  3. Nikolay
    Admin
    Nikolay avatar
    397 posts

    Posted 11 Mar 2011 Link to this post

    Hi Li,

    In order to customize the axes you may create custom styles for X and Y axes in the following manner :
    <Style x:Name="CustomAxisYStyle" TargetType="Line">
                    <Setter Property="Stroke" Value="White" />
                    <Setter Property="StrokeThickness" Value="5" />
    </Style>
    <Style x:Name="CustomAxisXStyle" TargetType="Line">
                    <Setter Property="Stroke" Value="White" />
                    <Setter Property="StrokeThickness" Value="5" />
    </Style>
     and in code behind :
    this.RadChart1.DefaultView.ChartArea.AxisX.AxisStyles.AxisLineStyle = this.Resources["CustomAxisXStyle"] as Style;
    this.RadChart1.DefaultView.ChartArea.AxisY.AxisStyles.AxisLineStyle = this.Resources["CustomAxisYStyle"] as Style;

    This way both axes would be white. In case you only want to change the colors of the axes, you may also use the AxisElementBrush property of the RadChart.

    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!
  4. Li
    Li avatar
    5 posts
    Member since:
    Mar 2011

    Posted 09 Apr 2011 Link to this post

    thanks for your reply~
    I've got the solution from your examples.
    Now I want to style the 2D Area .
    Could you give me a copy of the controltemplete?
    Like the LineStyle Below~
    Thanks!~

    <Style x:Name="CustomLineStyle" TargetType="telerik:Line">
               <Setter Property="Template">
                   <Setter.Value>
                       <ControlTemplate TargetType="telerik:Line">
                           <Canvas>
                               <Line x:Name="PART_LineGeometry"
                                 Fill="{Binding DataItem.PopulationColor}"
                                 Stroke="{Binding DataItem.PopulationColor}"
                                 StrokeThickness="3"
                                 X1="0"
                                 Y1="{TemplateBinding StartPointY}"
                                 X2="{TemplateBinding EndPointX}"
                                 Y2="{TemplateBinding EndPointY}"
                                  />
                               <telerik:PointMark x:Name="PART_PointMark"
                                                      Canvas.Top="{TemplateBinding StartPointY}"
                                                      PointMarkCanvasLeft="{TemplateBinding PointMarkCanvasLeft}"
                                                      PointMarkCanvasTop="{TemplateBinding PointMarkCanvasTop}"
                                                      Visibility="{TemplateBinding PointMarkVisibility}"
                                                      ShapeStyle="{TemplateBinding PointMarkShapeStyle}"
                                                      Style="{TemplateBinding PointMarkItemStyle}" />
     
                           </Canvas>
                       </ControlTemplate>
                   </Setter.Value>
               </Setter>
           </Style>


  5. Nikolay
    Admin
    Nikolay avatar
    397 posts

    Posted 13 Apr 2011 Link to this post

    Hi Li,

    You may find the templates for all elements in your Chart_SL project under Themes -> Chart -> Styles_style.xaml .Here is the Area one :
    <Style x:Name="CustomAreaStyle" TargetType="telerikCharting:Area">
     <Setter Property="Template" >
                <Setter.Value>
                    <ControlTemplate TargetType="telerikCharting:Area">
                        <Canvas>
                            <Rectangle x:Name="PART_AreaRectangle"
                                    Height="{TemplateBinding ItemActualHeight}" 
                                    Width="{TemplateBinding ItemActualWidth}" 
                                    Fill="Transparent" />
    <telerikCharting:PointMark x:Name="PART_PointMark"
                                                           Canvas.Top="{TemplateBinding StartPointY}"
                                                           PointMarkCanvasLeft="{TemplateBinding PointMarkCanvasLeft}"
                                                           PointMarkCanvasTop="{TemplateBinding PointMarkCanvasTop}"
                                                           Visibility="{TemplateBinding PointMarkVisibility}"
                                                           ShapeStyle="{TemplateBinding PointMarkShapeStyle}" 
                                                           Style="{TemplateBinding PointMarkItemStyle}" />
                        </Canvas>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    Hope this helps.

    Regards,
    Nikolay
    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
  6. Li
    Li avatar
    5 posts
    Member since:
    Mar 2011

    Posted 15 Apr 2011 Link to this post

    Thanks~~~!!
Back to Top