SChartData

@protocol SChartData <NSObject>

The SChartData protocol allows any object to act as a datapoint within a series on a ShinobiChart. The [SChartDatasource sChart:dataPointAtIndex:forSeriesAtIndex:] method returns an object that implements this protocol. It can be your own object or an instance of the SChartDataPoint class that we supply.

The protocol has two required methods, which return the x and y values for the object. Radial data points return the name of the data point as the x value, and the value of the data point as the y value.

It also has a set of optional methods and properties, which allow you to:

  • Returns the x value of the data point.

    This is used for series that require only a single x value. Series that require multiple x values should implement sChartXValueForKey: and check the specific series class for the required keys.

    Declaration

    Objective-C

    - (nullable id)sChartXValue;

    Swift

    func sChartXValue() -> Any?
  • Returns the y value of the data point.

    This is used for series that require only a single y value. Series that require multiple y values should implement sChartYValueForKey: and check the specific series class for the required keys.

    Declaration

    Objective-C

    - (nullable id)sChartYValue;

    Swift

    func sChartYValue() -> Any?
  • This is used for series that require data values which are independent of the axes. The expected keys can be found on the series that is trying to render the data point.

    An example of this is SChartBubbleDataPoint which has a third data value relating to the size of the bubbles.

    Declaration

    Objective-C

    - (nullable id)sChartValueForKey:(nonnull NSString *)key;

    Swift

    optional func sChartValue(forKey key: String) -> Any?
  • Returns the x value corresponding to the provided key.

    This is only required for series with more than one x value and keys are specified on the series type. For example, OHLC keys include low, high, etc. For series with just a single x value, use sChartXValue instead.

    Declaration

    Objective-C

    - (nullable id)sChartXValueForKey:(nonnull NSString *)key;

    Swift

    optional func sChartXValue(forKey key: String) -> Any?
  • Returns the y value corresponding to the provided key.

    This is only required for series with more than one y value and keys are specified on the series type. For example, OHLC keys include low, high, etc. For series with just a single y value, use sChartYValue instead.

    Declaration

    Objective-C

    - (nullable id)sChartYValueForKey:(nonnull NSString *)key;

    Swift

    optional func sChartYValue(forKey key: String) -> Any?
  • Returns the index of this data point in the chart series which contains it.

    Declaration

    Objective-C

    @optional
    @property (assign, readwrite, nonatomic) NSInteger sChartDataPointIndex;

    Swift

    optional var sChartDataPointIndex: Int { get set }