Change datasource on zoom


For our IOS application we want to change the datasource of the chart when a zoom event happens.

By default we show things on a session level, when the user zooms out we go to daytotals, zoom out again go to week totals, and so on.

And zooming in does the opposit. We want to do this by changing the datasource of the graph, is there a way to do this with the shinobi library?


Hi M.N.Mulder,

This can be done by implementing the SChartDelegate method “sChartIsZooming:” to change your chart’s datasource property when the span of your axis’ range hits your limits.

Please find below an example of this method that will update a chart’s datasource to a new one (CustomDatasource) then reload and redraw the chart when the axis span gets less than 5.

-(void)sChartIsZooming:(ShinobiChart *)chart {
    double span = [chart.xAxis.axisRange.span doubleValue];
    if(span < 5) {
        if(!_firstDS) {
            _firstDS = [CustomDatasource new];
        chart.datasource = _firstDS;
        [chart reloadData];
        [chart redrawChart];

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn