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.