iOS Charting Documentation - SciChart
Tutorial 05 - Adding Tooltips and Legends

Adding Tooltips & Legends to a Chart

So far in the tutorial series, we have created a new chart, added an XAxis, YAxis, some series and also some zoom and pan behaviours.

Tutorials Repository

As it was mentioned previously - we've created Git repository with all Tutorials. So you can clone/download the appropriate project you need!

We're going to extend this now to add Legends and Tooltips to the chart. Modify the existing code from Tutorial 04 - Adding Zooming, Panning Behavior as follows.
Update the addModifiers() method with following code:

Adding Tooltips and Legends to the chart
Copy Code
    func addModifiers(){
        let rolloverModifier = SCIRolloverModifier()
        let legend = SCILegendModifier()
        let groupModifier = SCIChartModifierCollection(childModifiers: [xAxisDragmodifier, yAxisDragmodifier, pinchZoomModifier, extendZoomModifier, legend, rolloverModifier])
        sciChartSurface?.chartModifiers = groupModifier

The legends require that DataSeries are named. So, we adjust the code from Tutorial 03 - Adding Series to the chart to give series a name:

Naming DataSeries for the Legend
Copy Code
    func createDataSeries(){
        // Init line data series
        lineDataSeries = SCIXyDataSeries(xType: .double, yType: .double)
        lineDataSeries.seriesName = "Line Series"
        for i in 0..<500{
            lineDataSeries.appendX(SCIGeneric(i), y: SCIGeneric(sin(Double(i))*0.01))
        // Init scatter data series
        scatterDataSeries = SCIXyDataSeries(xType: .double, yType: .double)
        scatterDataSeries.seriesName = "Scatter Series"
        for i in 0..<500{
            scatterDataSeries.appendX(SCIGeneric(i), y: SCIGeneric(cos(Double(i))*0.01))


As result, the legend with data sereis names. You can now select/deselect data series - the result will be appearing and dissapearing renderable series on your screen


Further Reading

SciChart features a number of tooltip types, as well as cursors, and each of the elements are fully customizable. Please see the articles below to see how to further customize the chart legends and tooltips:

  1. The RolloverModifier - adding time series tooltips to a chart
  2. The CursorModifier - adding crosshairs and optional tooltips
  3. The TooltipModifier - tooltips more suited for scatter or irregular data
  4. The LegendModifier - creating, customizing and templating legends