Setting Axis stroke color in Q3

2 posts, 0 answers
  1. Ben Lischner
    Ben Lischner avatar
    17 posts
    Member since:
    Jun 2005

    Posted 05 Nov 2009 Link to this post

    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?
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 06 Nov 2009 Link to this post

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