What is the equivalent of SChartPixelToPointMapper on Android?


#1

What is the equivalent of SChartPixelToPointMapper on Android?

By the way your Search function has been broken for months. I can’t search anything & hence have to create new probably duplicate topic.


#2

Hi torinnguyen,

The nearest equivalent in the Android  shinobicharts API is the pixel to data, and data to pixel conversion methods on the Axis class:

These methods allow you to convert between data values and their equivalent pixel positions. Importantly the chart must have been laid out in order for the values returned to be meaningful. The ShinobiChart.OnInternalLayoutListener callback interface can be useful in that respect.

Kind regards,

Patrick


#3

so is there another way to get an intermediate data value between 2 data points? x-axis is date axis, y-axis is number axis, normal line chart.


#4

Hi torinnguyen,

The two methods I mentioned above work for any values on the axis, they don’t snap to the nearest data point or anything like that. So for example, one thing you can do is use the ShinobiChart.OnGestureListener to capture pixel positions of user touches. These pixel positions can then be translated to data values using the getUserValueForPixelValue method on each axis (and so this data value may sit between two data points in your series).

Similarly you can work out the pixel position for a value in data terms that is between two data points in your series, using the getPixelValueForUserValue method.

I hope that helps, if I’ve misunderstood what you were asking do let me know!

Kind regards,

Patrick


#5

The function of SChartPixelToPointMapper on iOS is to map value from one axis to another axis. The 2 functions being mentioned here only work on 1 axis itself.

Here is my use case, and I have successfully implemented it on iOS, now porting to Android.

  • My x-axis is date values axis. And I have data for 01/01/2016 and 31/01/2016.

  • My y-axis is float numbers data corresponding to the dates on x-axis.

  • I let me user freely pan & zoom the chart. At times, the very first point on the linechart touching y-axis is between 2 dates above, say 10/01/2016.

  • I have a text label that inform user what is the y-value of this very first visible point. How do I get this y-value corresponding to 10/01/2016?

I can’t use either functions being discussed because I only know my x-value is 10/01/2016 from xAxis.range.min value. I can’t translate this across to y-axis. This was when I needed to use mapper on iOS.


#6

Hi

Thanks for providing the extra information - we understand what it is that you are trying to do. As you have identified, the Android charts API currently does not function in quite the same way as its iOS counterpart. 

Firstly, we apologise for this - we do strive to achieve feature parity between our Android and iOS products and we do base our development on customer demand. As such I have added an item to our backlog to include this feature. I cannot of course provide dates of when such a feature will become available at present. 

In the meantime, there may be a work around albeit rather convoluted. Also, we have not tried this solution ourselves so it may not provide the functionality which you need, but it may be worth some consideration. The basic steps would be:

-Using the methods (previously mentioned) on the Axis, obtain a pixel value for your known data value (in your example, this is 10/01/2016, for the x axis). 

-Choose a suitable pixel value for the other axis (in this example, the y axis) - you could again use the conversion methods on the Axis to covert from the maximum data value of the visible range, to a pixel value.

-Ensure the crosshair and tool tip are not shown when a user long presses the chart - to achieve this you could use the api methods on the crosshair itself and the OnTrackingInfoChangedForCrosshair (and Tooltip) lister methods

-Using the standard Android framework methods, programmatically perform a long press on your chart, using the pixel values already calculated

-Implement the OnTrackingInfoChangedForCrosshairListener

-Using the values given to you when the onTrackingInfoChanged method is called on the listener, you should be able to obtain the mapped y value which you need.

I hope that this helps, 

thanks,

Kai.