1

Is there any way to only display one value in the tool tip that is displayed when scrolled over on a SciChart IOs line chart? there are numerous examples of how to do it in android and WPF but not for IOs.

1 Answers1

1

You will need to implement following things. First of all, a custom renderable series, e.g. if you are using LineRenderableSeries, you will have to create a new class derived from SCIFastLineRenderableSeries and override toSeriesInfo: method, just like follows

  class CustomLineSeries : SCIFastLineRenderableSeries {
       override func toSeriesInfo(withHitTest info: SCIHitTestInfo) -> SCISeriesInfo! {
                return CustomSeriesInfo(series: self, hitTest: info)
            }
 }

In the following step, we create a CustomSeriesInfo class we are using in our custom renderable series class we've just created:

class CustomSeriesInfo : SCIXySeriesInfo {
    override func createDataSeriesView() -> SCITooltipDataView! {
        let view : CustomSeriesDataView = CustomSeriesDataView.createInstance() as! CustomSeriesDataView

        view.setData(self)
        return view;
    }
}

And finally, we create a custom series data view - an actual view where we show what we want:

class CustomSeriesDataView : SCIXySeriesDataView {

    static override func createInstance() -> SCITooltipDataView! {
        let view : CustomSeriesDataView = (Bundle.main.loadNibNamed("CustomSeriesDataView", owner: nil, options: nil)![0] as? CustomSeriesDataView)!
        view.translatesAutoresizingMaskIntoConstraints = false
        return view
    }

    override func setData(_ data: SCISeriesInfo!) {
        let series : SCIRenderableSeriesProtocol = data.renderableSeries()

        var xFormattedValue : String? = data.fortmatterdValue(fromSeriesInfo: data.xValue(), for: series.dataSeries.xType())
        let xAxis = series.xAxis

        if (xFormattedValue == nil) {
            xFormattedValue = xAxis?.formatCursorText(data.xValue())
        }

        self.dataLabel.text = ""
        self.nameLabel.text = String(format: "X: %@", xFormattedValue!)

        self.invalidateIntrinsicContentSize()
    }
}

Note: you will have to create an actual View and use the CustomSeriesDataView as its main class; and also bind the outlets.

slprog1
  • 71
  • 6