Create ShinobiChart object - but don't load data/draw chart


I would like to be able to init a ShinobiChart object, _without_ having the chart loading and drawing itself instantainously.

I only want it to load/draw when I tell it to.

Is this possible? As far as I can tell it loads the first time as soon as it’s created.

Another thing, am also looking for a way to cancel an ongoing loading/rendering of the chart - e.g. the user scrolls the graph out of view/leaves the page. 




I would suggest loading your chart with 0 series, then just reload your chart & update your data-source when your ready to display some data.

As for the ongoing loading/rendering, I don’t think I quite understand. A chart should only reload its data when you tell it to (by calling reloadData) and it should only redraw, either when you tell it to, or the user is interacting with it.



Yes, that is what I do now. It just seems a bit silly loading and drawing with 0 series/data. Then just to reload and redraw again with actual data. You do get console warnings as well from the 0 series - but perhaps the performance overhead is low.

With cancel I mean, yes I tell it to reload/redraw, but then something might happen - such as the user scrolling away from the view (if the graph is in a scroll view) - so I want the ongoing reload/redraw to cancel (as quickly as possibly) - thus not to spending unnecassary resources.


Hi there,

I’m sharing the same problem :(. Hopeing to seek some advise here too.

My problem is the shinobi charts is trying to load before my data is in.

How should I cater for this kind of situation?

Here is what I’m doing with the series 

    if ([self.liveDataDictFull count] > 1) {

        NSLog(@“I got data %@”,self.liveDataDictFull);

        if (chart == liveBarChart) {

            return 3;



is this likely how you would do it?

Thank you 


Bump thread.


Hey guys,

I think the answer here is completely depends upon your what you are trying to achieve so I’ll try to explain the chart’s behaviour.

Upon layoutSubviews or a [chart redrawChart] the chart will lay out its subviews and attempt a render. The chart will only attempt to load data if the reloadData flag has been set by calling [chart reloadData]. On the first render, the chart will always attempt to load data from its data source. This is why it is required that your chart is given a datasource before its first render. Since the datasource is being queried, it must return something. If you don’t have any data, you should tell the chart that you don’t have any data by returning 0 series from the number of series datasource method. In this case the chart will render no data, and the axes will default to a default range. So, in summary the chart won’t load it’s data as soon as it is initialised, it will only attempt to draw in the first run loop after it has been placed in your view hierarchy - much like any other UIView.

There’s nothing stopping you from styling the chart as appropriate for your application, e.g:
- Setting the ranges of your chart to something that makes more sense (0-100 if you were displaying percentages).

  • Hiding the tick marks completely so that your chart is only displaying axes & titles.
  • Having a placeholder view and then adding the chart when you know you’ve got data to load.

These are all examples I’ve just pulled out of my head, but the solution to this problem really does depend on how you would like your application to behave.

925dk: With regards to cancelling a reload - this isn’t possible. If a reload and a redraw has been called on your chart then it will always complete fully. If you’ve done this on the main thread and you’ve got a tonne of datapoints then yes, this may cause the main thread to block. However, there is always the option of loading the data on a background thread to negate this.

Jan Akerman


Thanks for your nice reply. And I think you’re right, it’s just behaving as any other UIView/delegate paradigm thingy would.

I’ve changed my code (some time ago) to “lazy load & add shinobi as subview” only _after_ I have data for it (until then a loader is shown). That works ok. 

Slightly unrelated/related - it would be nice if we could silence warnings from the library (e.g. 0 data warnings - it can be a bit noisy with the warnings).


Hi 925dk,

No problem - I’m glad to help! We’ve actually had that feedback before and we’ve got a task to look into how we can improve our logging, potentially providing different logging levels that you can silence. I can’t provide a date that we’ll be able to provide this but I just wanted to let you know that it is definitely on our radar.  :laughing: