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

Same color to Y Axis as its corressponding Line.

4 Answers 115 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 2
Rahul asked on 11 Mar 2011, 02:45 PM
I want same color to Y Axis as its corressponding Line.
Check out the attached image for more information.
Thanx in advance.

4 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 16 Mar 2011, 08:48 AM
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!
0
Rahul
Top achievements
Rank 2
answered on 16 Mar 2011, 12:30 PM
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.
0
Rahul
Top achievements
Rank 2
answered on 16 Mar 2011, 01:07 PM
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.
0
Accepted
Yavor
Telerik team
answered on 21 Mar 2011, 09:14 AM
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
Tags
Chart
Asked by
Rahul
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Rahul
Top achievements
Rank 2
Share this question
or