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

Chart Axis Style for changing the color

5 Answers 88 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Li
Top achievements
Rank 1
Li asked on 09 Mar 2011, 08:43 AM
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.

5 Answers, 1 is accepted

Sort by
0
Li
Top achievements
Rank 1
answered on 09 Mar 2011, 08:44 AM
And..how can I change them all White.Thanks~
0
Nikolay
Telerik team
answered on 11 Mar 2011, 09:14 AM
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!
0
Li
Top achievements
Rank 1
answered on 10 Apr 2011, 04:16 AM
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>


0
Nikolay
Telerik team
answered on 13 Apr 2011, 08:06 AM
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
0
Li
Top achievements
Rank 1
answered on 15 Apr 2011, 08:27 AM
Thanks~~~!!
Tags
Chart
Asked by
Li
Top achievements
Rank 1
Answers by
Li
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or