Zoom in and show more datapoints


Hello everyone!

I want to have a chart which shows lets say 30 data points for month April.
When a user zooms in to a time frame of 2 weeks of the month April, i want to show more detailed data points. 
Show 30 datapoints for those 2 weeks. When you dont refresh the data, the user will only see 15 data points.

This can be implemented in many ways, i have 2 questions myself, any suggestion is welcome =).

A. Is it possible to have multiple datasources on a chart which are connected to a zoom level?

I case that is not possible.
B. Is it possible to get the range of the X-axis which is currently show?
With this i hope to achieve, when a user zooms to a certain level, another invisible chart will be shown instead with more detailed data.

C. If A or B is possible, is this also possible in Xamarin?

I really hope i can use shinobi control to solve this issue.


Key Kamikze,

What you are after sounds entirely possible.

A) Whilst you can’t have multiple datasources set to one chart at a single time, you can switch datasources over. However, I think it would make more sense to create a smart datasource that provides the correct data to your chart depending on your zoome level (size of your axis range).

B) To get the range of your X-axis you want to do the following:


C) Both A & B are possible using Xamarin, however, the syntax for B would be slightly different :laughing:.



Thanks for your reply Jan,

I’ll start playing with Shinobi in Xamarin now.
Do you by any chance have an example of a ‘smart’ data source? Doesnt matter if its in Objective-C ill just translate it myself.
Sounds like the perfect solution :smiley: exactly what i am loking for =)


By “smart” I simply meant a datasource which does things a little bit more intelligently than just returning static data.

Whilst I don’t have an example of a datasource that returns different data depending on zoom levels, you have exactly the right idea with your question B. You would need to trigger a reloadData when you reach a certain zoom level, and at this point your “smart” datasource can decide what points it should return depending on the ranges of the axes.



Ahh i thought there might be a default option. I have already implemented what i want to achieve with numbers on the X-Axis. 
Currently im stuck on transforming the XAxis.AxisRange.Minimum to a formatted date.
The X-axis shows the dates and the data i have perfectly, zooming in gives me a more detailed X-axis as i wanted.

So my final question on this matter is, how can i convert a NSNumber returned by the AxisRange.Minumum into a DateTime object.
The following NSNumber ( 1362954636.188198 ) should represent March, 11 2013


Ok - it seems as though I thought you wanted something more complicated whereby you needed to reload your data while you were zooming.

The date is actually represented as a long, with the integer part being seconds from 1st Jan 1970. NSDate provides a static method to convert this number, specifically +dateWithTimeIntervalSince1970:. You can then use an NSDateFormatter to get a formatted string from this date.



Thank you! I kept using the wrong one and ended up with wrong dates. 

This is how i formatted the NSNumber to a Date i can use ( for anyone else that has a similar problem )

Thanks for the great and quick support. TIme to get things started for real now =D

protected override void OnFinishedPanning (ShinobiChart chart)
NSDate date = NSDate.FromTimeIntervalSince1970 (Double.Parse (chart.XAxis.AxisRange.Minimum.ToString ()));
            NSDateFormatter formatter = new NSDateFormatter ();
            formatter.DateFormat = "MMMM/dd/yyyy";
            NSString dateString = new NSString (formatter.ToString (date));
            Console.WriteLine (dateString);


Thanks for sharing your solution on the forum - I’m sure it will help others in the future.