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

Auto Adjust Axis for Current Viewport

1 Answer 133 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Carl Herlitz
Top achievements
Rank 1
Carl Herlitz asked on 18 Mar 2016, 10:25 PM

Hi, I have a question similar to this: http://www.telerik.com/forums/y-axis-values-on-radcartesianchart-with-zoom.

I'd like for the y-axis to auto-adjust its range based off of just the data points displayed, not the entire collection. And it should happen as the user scrolls/zooms. I understand how the solution you provided in the previous forum post works, but it wouldn't work for me because I have many different charts with a variable number of series, different data points being charted, etc.

So, my questions

1) Since the forum post I linked above, have you added the ability to auto-adjust an axis off the current viewport rather than the entire data set?

2) If not, can you think of a generic version of the sample in the previous forum post? One where I don't have to access a series' ItemsSource? I noticed that in the sample, there's this line of code in MainWindow.xaml.cs that gets the range using the series' ItemsSource (Context).

var visibleRange = Context.GetRange(firstElem, lastElem - firstElem).Select(pd => pd.YVal);
How can I replace that with something that can give me the max y-axis values of all chart series within a range? Can I get a collection of all the visible DataPoints? This would also have to work with stacked bar charts, where I'd like to get the total y-axis value of each set of stacked bars.

I attached a screenshot to visualize the issue. The bars are so small because somewhere else in the chart, there's a data point where the max value of both bars, stacked, is about 2.2 million. When a user scrolls to see the data points in the screenshot, the y axis max value should change to probably be about 500K.

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 23 Mar 2016, 04:01 PM
Hi Carl,

No, still there is no auto range feature in RadCartesianChart. However, we have a feature request in our system which you can follow in order to track its status. 

As for your second question, in order to adjust the example from the forum for a scenario with multiple series you will need to write additional code. The chart itself doesn't expose a single collection with all plotted data points. Instead, you will iterate through its Series collection and get their data points through the DataPoints collection. This way you can get the Y axis values for all series. For your convenience I updated the example from the forum post to demonstrate such approach. Please give it a try and let me know if it works for you.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ChartView
Asked by
Carl Herlitz
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or