(id)transformValueToExternal:(id)value for monotouch?



I am working on translating the rangeChart example into Monotouch.

I noticed in the example the object-C code exposes one internal API:

@interface SChartAxis (IntExtTransforms)
- (id)transformValueToInternal:(id)value;
- (id)transformValueToExternal:(id)value;

How would I do this in Monotouch?

examples I found for object c:


Hi tomtom,

This is tricky, as you’ve seen. The blog in question was largely derived from the source of our Play app, which was never really written with MonoTouch in mind. Objective C is a lot more relaxed about accessing private methods than Mono/.NET and this kind of pratice is more common in that world.

That said, it is possible to provide bindings in your application. Bindings are generally autogenerated by the MT tools, but you can hand-write them, and they resolve down to message passing. The relevant code would end up something like this:

static readonly IntPtr selTransformValueToInternal_ = Selector.GetHandle (“transformValueToInternal:”);

return (NSObject) Runtime.GetNSObject (MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr (axis.SuperHandle, selTransformValueToInternal_, value.Handle));

However, we do not encourage you to use internal API in this way, the code is provided without any guarantee that it will do what you want, and we have no plans to translate this blog post into C#. You may also need to add #usings and references as appropriate.


Robin Sillem

Lead Developer



Hi Robin,

Thank you for your response. It was what I expected. I totally agree with not wrapping unoffical APIs. They tent to change over time :slight_smile: That’s why we keep them internal.

I do like the functionality to translate from a touch/pan event to the actual data point. I need this quite a bit to trigger detail views.
I was wondering there are any plans to have an exposed API for that?

Currently I just calcluate the ratio of the control and apply this to the data ranges. It works on non logarithm easily but is not as precise as this nice API.




Hi Tom

To answer your first question there aren’t any current plans to expose that part of the API. However, our development priorities are very customer driven and we’ll put this on our backlog and fully investigate this issue.

A possible improvement to your current solution would be to import the SChartCanvas class to access the frame of your charts data series using the following code:

CGRect rect = chart.canvas.glView.frame;

You can then use this width to work out a more accurate ratio when converting touch/pan events to the actual data points.

I implemented a simple example that implemented this feature where I applied the above rect to an empty UIView then implement the UIView’s “-touchesEnded:withEvent:” method with the following code to get the correct ratio:

UITouch *touch = [[event allTouches] anyObject];
CGRect rect = lineChart.canvas.glView.frame;
UIView *view = [[UIView alloc] initWithFrame:rect];
[[self view] addSubview:view];
CGPoint loc = [touch locationInView:view];
float ratio = loc.x/rect.size.width;

This example only catered for a lower boundary which then informed the charts data source to use the newly calculated ratio then reloaded the charts data and redrew the chart.

This doesn’t solve the exposed API issue but it should increase the accuracy of your data points.


Andrew Polkinghorn.