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

2 Grids Using the same Range

3 Answers 100 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Taylor
Top achievements
Rank 2
Taylor asked on 29 May 2009, 05:31 PM
Hi,

I have 2 charts on a page, one displaying monthly data and the other displaying the average of that data.  I would like these 2 controls to have the same chart range, however letting each auto generate the range obviously doen't do this since the data is quite different.  I know I can manually define each chart's range programmatically, however, I'd like the monthly data to auto generate, and then I programmatically set the averages chart to use that range.  Is there an event that fires once the data is loaded into the chart (and the axises are generated) that I could hook to and then copy the step, min, and max values from it to the average chart?  I tried the loaded event on the chart itself and the chart area, but at that point the min, max, and step values are all 0.

As a visual example of my problem, here's a image of the charts as they stand now:  Image of Chart

You can see the averages on the left are not using the same range as the chart on the right is using.

Thanks for any help anyone can give!

-Taylor Smith

3 Answers, 1 is accepted

Sort by
0
Taylor
Top achievements
Rank 2
answered on 29 May 2009, 05:33 PM
As a side note on this as well, anyone know why the labels on the Y Axis are so wierd in the image?  It seems its rounding the decimal as it seems to change to 1 right around 0.5 (that's where the line series is sitting).
0
Ves
Telerik team
answered on 01 Jun 2009, 12:16 PM
Hello Taylor,

There is no dedicated event for this, but I believe you do not need one. As soon as the chart is populated with data, the axes are configured, so you can access their properties:

RadChart1.ItemsSource = .....;
RadChart2.DefaultView.ChartArea.AxisY.AutoRange = fasle;
RadChart2.DefaultView.ChartArea.AxisY.MinValue = RadChart1.DefaultView.ChartArea.AxisY.MinValue;
....

Note, that altering certain properties might trigger re-calculation, for example setting AxisY.ExtendDirection will force the Y axis to calculate its range one more time, so you need to set second chart's properties after the first one is fully configured.

As for the labels note -- indeed, the labels appear rounded. Have you applied any special formatting to Y axis? Can you please provide more details about this issue? Thank you.

All the best,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Taylor
Top achievements
Rank 2
answered on 01 Jun 2009, 04:36 PM
Thanks for the tip on the label format.  I must have added that in one day testing out what I could do and never took it out.

About the problem with setting the Axis values, here's what I'm running up against.  When I do as you suggested, RadChart1 has a MaxValue of 3, which gets properly applied to RadChart2.  The weird thing is that when the chart actually displays on the screen, the MaxValue is 1.6.  I thought I was going a bit nuts so I threw in some breakpoints and a timer.  What I did was compared the values of RadChart1's Max, Min, and Step values (3, 0, and 1 respectively) right after setting the ItemSource, and then when the timer (set at a 20 sec interval) ticked 20 seconds later.  I was amazed to see that the max value had changed to 1.59999999999 and the step value to 0.2 at somepoint during the process.  

I'm guessing that by setting the values right after setting the item source, the chart hasn't had enough time to render the new axis values and I'm getting the defaults and not the correctly rendered values.

I'm going to try some workarounds and see what I get.

Thanks,

Taylor Smith
Tags
Chart
Asked by
Taylor
Top achievements
Rank 2
Answers by
Taylor
Top achievements
Rank 2
Ves
Telerik team
Share this question
or