[Android] Axis not displaying range properly


#1

So I have a graph setup which cycles through different data. Most of them are fine, however, it seems when the range is larger than about 50-60, the range doesn’t display properly. I don’t mean visually, I mean it doesn’t actually show the range that I set.

So, I set a range of min 9, max 72, and the displayed range is actually around 42-72. Then I end up with a graph which seems like it didnt plot the points, which it did, but they are off screen, and you have to pan around looking for the data.

I’ve tried setting the majorTickFrequency to see if that helps, and it does not.

Thanks,

Ryan


#2

I resolved this by re-instantiating the axis I was having an issue with. I think it was a zoom issue (when double tapping the graph, it resets and things are fine), but I wasnt able to find a resetZoom type of method.

Ryan


#3

Hello Ryanbis,

Thanks for getting in touch. In order to see your data, or a particular data range on an axis, you should not need to remove and replace the axis.

When you first add your data to the series, the chart will by default attempt to display the data range (plus any set padding) for each axis. May I ask, do you at any point set a default range on your axis? This is done with this method: https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/Axis.html#setDefaultRange(com.shinobicontrols.charts.Range<T>)

This is the range, on an axis which will initially be displayed and also will be displayed if the zoom is reset.

If you do set a default range, make sure this is done before any data is loaded, as if done after an initial data load you may see no effect. 

If you wish to display a particular range after data has been added to your series, you may wish to use the following method:

https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/Axis.html#requestCurrentDisplayedRange(T, T)

Please note that if you request a range on an axis which will violate any restrictions that exist on the range, the request will be ignored. For example if you request a range greater than the data range and the axis does not allow panning beyond this range, you will see no update in the displayed range. Please see the following methods:

https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/Axis.html#allowPanningOutOfDefaultRange(boolean)

https://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.7.2/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/Axis.html#allowPanningOutOfMaxRange(boolean)

I hope this information helps you,

Thanks

Kai.


#4

Kai,

The situation is a little different. I have one screen with the chart. Under the chart are two buttons to switch the data being displayed. On first load, everything is fine. When switching the data (which requires loading the data from a sqlite db, then dumping that data into shinobi), that’s when I had the issue. I do set the range (which is why I was confused as to why it didn’t seem to have any effect). It’s setup to set the range before putting the data into shinobi. The only way I was able to get it to work properly, was to reinstantiate the axis I was having the issue with when I change data types.

Thanks for the reply,

Ryan


#5

Hello Ryanbis,

Thank you for coming back to us. I am glad that you have a solution to your issue, but I do feel that really, you should not need to take this rather harsh approach to achieve the desired range on your axis. It does sound to me like you are setting up your chart in the correct way. We are not aware of any current issues with our axis ranges, but we would like to look into this further, in case some issue does exist.

Would it be at all possible for you to send us a small sample application which demonstrates this issue please? If this is possible, please send it to info@shinobicontrols.com

Thanks for your help,

Kind regards,

Kai.


#6

Kai,

Unfortunately it would take too much time to rip out what I have in my current code (it’s private IP), so I won’t be sending you a sample app. However, what I think would solve the problem I was having, would be a method to reset the default range. When double-tapping the graph, it reset the view so that the range is how it should be. I could not find any method which does this.

Thanks for the reply,

Ryan


#7

Hi Ryan,

The Axis class has a method on it called setDoubleTapBehavior() - it takes an Axis.DoubleTapBehavior which can either be RESET_TO_DEFAULT_RANGE or ZOOM_IN (which is the default). I wonder if the RESET_TO_DEFAULT_RANGE option is what you’re looking for?

Kind regards,

Patrick


#8

Hi Patrick,

I already have that set. What I was looking for was a way to do that without having to actually double-tap on the screen (perform the reset to default range programmatically, instead of forcing the user to double tap).

Thanks,

Ryan


#9

Hi Ryan,

Sorry I’m with you now! Yeah there isn’t a specific method to do this so I think you’d need to do something like:

NumberRange defaultRange = (NumberRange) xAxis.getDefaultRange();
xAxis.requestCurrentDisplayedRange(defaultRange.getMinimum(), defaultRange.getMaximum());

Kind regards,

Patrick