Manually scroll chart and detect shown data



i want to sync the data in my tableview with the data shown in the graph. The tableview shows sections which represent days. The graph should have days on the x-axis and numerical data on the y-axis.

So when the users scrolls inside the tableview, the graph should also scroll to the point, where the tableview is. Also this should work vice versa. When the user scrolls inside the graph, the tableview should scroll to the selected row.

So the questions is, is it possible to scroll to a specific date value inside the chart via code and can i detect the value, which is shown inside the chart.

Maybe you guys have some idea on that.




Hi Daniel,

Yes, this is all possible! Firstly, you will need to create a chart with a  SChartAxisTypeDateTime axis type for the X axis, and an SChartAxisTypeNumber for the Y axis. The data should be provided to the chart using NSDate for the X values and NSNumber for the Y values. You can enable panning on the X axis via the  setEnableGesturePanning method.

When a pan occurs the chart can inform your code via the SChartDelegate protocol. If you adopt this protocol and implement the sChartIsPanning method (and other assocaited pan methods), you can detect when the user pans the chart. The chart.xAxis.axisRange property is updated to indicate the current location as the user pans. You can then use this to update the UITableView scroll location.

In the other direction, when the user scrolls the table, use the UITableViewDelegate to detect scrolling, then synchronise the chart axis via the setRanegWithMinimum:andMaximum: method.

Hope that helps,

Colin E.


Sounds easy, i will look into these methods.