Same color to Y Axis as its corressponding Line.

5 posts, 2 answers
  1. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 11 Mar 2011 Link to this post

    I want same color to Y Axis as its corressponding Line.
    Check out the attached image for more information.
    Thanx in advance.
  2. Answer
    Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 16 Mar 2011 Link to this post

    Hello Rahul,

    You can use a style for the additional axis, with the proper color. This may look something like this:

    <Style x:Key="AxisLineStyle" TargetType="Line">
    <Setter Property="Stroke" Value="Orange"/>
    <Setter Property="StrokeThickness" Value="5"/>
    </Style>

    then, in the code behind, you can set the style in question directly to the additional y axis:

    AxisY axisY = new AxisY();
    axisY.AxisName = "AxisY_South";
    axisY.Title = "Kilowatt [kW]";
    axisY.AxisStyles.AxisLineStyle = this.Resources["AxisLineStyle"] as Style;
    Chart1.DefaultView.ChartArea.AdditionalYAxes.Add(axisY);

    I hope this gets you started properly.

    All the best,
    Yavor
    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!
  3. DevCraft banner
  4. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 16 Mar 2011 Link to this post

    First of all thanks for ur reply. It helped me a lot.
    But one more problem I'm Having is that the no. of Y-axises is not fixed.
    It may be one or two or five y-axis will be there.
    So how can i manage the line series color with corresponding Y-axis
    color.
    Please give me solution for this problem.
    Try to solve it in code behind or in C#.net.

    Thanks in advance.
  5. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 16 Mar 2011 Link to this post

    First of all thanks for ur reply. It helped me a lot.
    But one more problem I'm Having is that the no. of Y-axises is not fixed.
    It may be one or two or five y-axis will be there.
    So how can i manage the line series color with corresponding Y-axis
    color.
    Please give me solution for this problem.
    Try to solve it in code behind or in C#.net.

    Thanks in advance.
  6. Answer
    Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 21 Mar 2011 Link to this post

    Hi Rahul,

    In such case, you can declare statically the maximum number of styles that you expect to have shown in your application, for example 10. Then, once you start adding additional y axis to the control, you can assign a style to each one of them, at the time the axis is created, much in the same manner demonstrated before. I hope this information helps.

    Kind regards,
    Yavor
    the Telerik team
Back to Top
DevCraft banner