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

Setting Axis stroke color in Q3

1 Answer 74 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ben Lischner
Top achievements
Rank 1
Ben Lischner asked on 05 Nov 2009, 06:38 PM
In Q2, you could set the color of the axes of charts like this:

<Style x:Name="BarAxisXStyle" TargetType="chart:AxisX2D">
    <Setter Property="Stroke" Value="Black" />
</Style>
<Style x:Name="BarAxisYStyle" TargetType="chart:AxisY2D">
    <Setter Property="Stroke" Value="Black" />
</Style>

Chart.DefaultView.ChartArea.AxisXStyle = this.BarAxisXStyle;
Chart.DefaultView.ChartArea.AxisYStyle = this.BarAxisYStyle;

This no longer works in Q3 as Storke is not a valid property any more. Does anyone know what the replacement is?

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 06 Nov 2009, 11:55 AM
Hello Ben,

Indeed this syntax is no longer applicable -- with the Q3 2009 release you can achieve the desired effect like this:

XAML
<UserControl.Resources>
    <Style x:Name="CustomAxisXStyle" TargetType="telerikCharting:AxisX2D">
        <Setter Property="AxisLineStyle">
            <Setter.Value>
                <Style TargetType="Shape">
                    <Setter Property="Stroke" Value="Orange" />
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
 
    <Style x:Name="CustomAxisYStyle" TargetType="telerikCharting:AxisY2D">
        <Setter Property="AxisLineStyle">
            <Setter.Value>
                <Style TargetType="Shape">
                    <Setter Property="Stroke" Value="Orange" />
                </Style>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>
 
<Grid x:Name="LayoutRoot" Background="White">
    <telerik:RadChart x:Name="RadChart1">
    </telerik:RadChart>
</Grid>

C#
RadChart1.DefaultView.ChartArea.AxisXStyle = this.CustomAxisXStyle;
RadChart1.DefaultView.ChartArea.AxisYStyle = this.CustomAxisYStyle;
 
RadChart1.ItemsSource = new double[] { 1, 2, 3};


or alternatively like this (setting directly the line element style and targeting Line):

XAML
<UserControl.Resources>
 
    <Style x:Name="CustomAxisLineStyle" TargetType="Line">
        <Setter Property="Stroke" Value="Orange" />
    </Style>
 
</UserControl.Resources>
 
<Grid x:Name="LayoutRoot" Background="White">
    <telerik:RadChart x:Name="RadChart1">
    </telerik:RadChart>
</Grid>

C#
RadChart1.DefaultView.ChartArea.AxisX.AxisStyles.AxisLineStyle = this.CustomAxisLineStyle;
RadChart1.DefaultView.ChartArea.AxisY.AxisStyles.AxisLineStyle = this.CustomAxisLineStyle;
 
RadChart1.ItemsSource = new double[] { 1, 2, 3};


We will update the documentation immediately as well. Sorry for the temporary inconvenience.


Kind regards,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart
Asked by
Ben Lischner
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or