Search code examples
iosshinobi

How to link a chart axis to a chart series using the Shinobi iOS SDK?


I added a secondary axis to my chart using addYAxis:(SChartAxis *)newYAxis. How do I get the second series linked to the new axis?

I found (BOOL)isLinkedToSeries:(SChartSeries *)series in SChartAxis.h. But how do I create the initial link?


Solution

  • When you have multiple axes on a ShinobiChart, then you can use the sChart:xAxisForSeriesAtIndex: and sChart:yAxisForSeriesAtIndex: on the SChartDataSource protocol.

    For example, if you have 2 y-axes, and 2 series, and you want the first series associated with the first axes, and the second axis with the second series then implement the following method on your datasource:

    - (SChartAxis *)sChart:(ShinobiChart *)chart yAxisForSeriesAtIndex:(int)index
    {
        return chart.allYAxes[index];
    }