crosshairMovedToXValue not called in chart delegate



I’d like the delegate for a line chart to be called when the crosshair is created or moved, so I can extract the coordinates of the crosshair.

In the view controller that owns the chart, I have adopted SChartDelegate, and created a delegate:

    func sChart(_ chart: ShinobiChart, crosshairMovedToXValue x: AnyObject, andYValue y: AnyObject) {
        if let tapX = x.doubleValue {
            if let time = signalGraph.xAxis?.dataValue(forPixelValue: tapX).doubleValue {
However, my delegate is never called. Do I have to subclass the crosshair class in order for my delegate to be called, or am I missing something else really basic?



Hi Andromeda,

Once you have implemented the delegate method you need to assign the delegate to your chart like so:

chart.delegate = yourDelegate

Let me know if you have any questions.

Kind regards,
Andrew Polkinghorn.


Oh dear - embarassingly, I’d set the delegate for the other ShinobiChart on this screen, but for this chart I’d only set the datasource, and forgotten to set the delegate! Thanks for the reminder!


Hi Andromeda,

No problem!

Glad you got it sorted. :slight_smile:

Kind regards,
Andrew Polkinghorn.