With streaming data, how do I get the SChartDateTimeAxis tick labels to scroll with my series line?


Version 2.5.4 of ShinobiCharts
iOS7 iPad Air (via Simulator)

I have the following chart rendering with real time information, but I can’t figure out how to get my xAxis tick labels to move with the line as it is updated.  I took a look at the AppendData project included with the charting library and noticed that it was using the SChartNumberAxis with a faster frequency and it had no problem smoothly pushing the tick labels on the xAxis with the line.  How can I do that for times/dates?

Here’s my current setup for the chart in my ChartController.m file:

- (ShinobiChart *)buildChart:(id<SChartDatasource>)dataSource {
  ShinobiChart *chart = [[ShinobiChart alloc] initWithFrame:self.view.frame

  chart.datasource = dataSource;
  [chart applyTheme:[SChartDarkTheme new]];

  chart.xAxis.majorTickFrequency = [SChartDateFrequency dateFrequencyWithHour:1];

  chart.frame = CGRectMake(10, 10, self.view.frame.size.width - 20, self.view.frame.size.height - 20);

  chart.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

  return chart;

My data comes in at 15 minute intervals and I update the chart like so:

- (void)redrawChart
  [self.chart reloadData];
  [self.chart redrawChart];

Any help would be appreciated,


Angelo Lakra


Any takers?


Hi alakra,

I think you might be assuming that a call to redrawChart animates any change in range, but this is not the case. I am guessing that each time you redraw you have the same number of data points (you are deducting the same number from the start of the data that you are adding to the end)? If that’s the case and the number of data points you are shifting the data by is a multiple of the tick frequency then your data points will always be in the same location each time a redraw happens.

The smooth scrolling of the x axis in AppendData is an optical illusion brought about by a combination of things:

  1. The number of data points being shifted by is not a multiple of the tick frequency
  2. The rate at which the updates are happening is very fast (once every 0.01 seconds)

If you were to slow down the update to something like once every 2 seconds it should become clear that the app is not animating the range change.

You may be able to use the above information to change your frequency/data-shift/update-rate to make your chart appear as though the x axis is panning smoothly.

Alternatively you could tell the chart to stop auto updating its ranges on a redraw (chart.autoCalculateAxisRanges = NO) and then pan the chart by setting to your new desired range with animation by using setRangeWithMinimum:andMaximum:withAnimation:. This strategy will mean that the chart defnitely will animate to the new range for each update, but I am not sure how smooth the panning will appear.

Hope the above suggestions help!  :laughing: