Can we retrieve the visible series on a chart?


#1

Here’s my problem: out of the box, it’s easy to zoom/pan into some weirdness.

I can correct for this if I have the highest, and lowest y value within the currently visible range. Not the yValues labeled on the yAxis, but instead the actual values on the chart.

Basically I want to find the lowest, and highest y values in the visible range and set the actual scope of the yaxis to that so I can bring the chart back to earth. 

[_chart.yAxis setRangeWithMinimum:lowest_low andMaximum:highest_high];

Is this info stored anywhere? Or any ideas how it should be derived? 


#2

A little clarification:

In cases like the image below the lowest plotted point is much greater than the lowest yAxis value, and the max value is way above the the highest yAxis value. This is the case where I want to manually readjust the yAxis min/max.

What I’d like is to be able to iterate through the series within the visible xAxis. I suppose I could loop through the entire series and compare the xAxis.visibleSeries.max/min to determine which bars are within the current window, but this seems like a roundabout hack. Is there a better way to retrieve the series currently plotted along the xaxis?


#3

Hi Damien,

Simply doing this should sort your problem:

SChartRange *yRange = _chart.yAxis.visibleRange;

[_chart.yAxis setRangeWithMinimum:yRange.minimum andMaximum:yRange.maximum];

The visible range contains the range that is currently visible, taking into account any baselines, bar/column widths etc into consideration too.

I hope this helped.

Jan