SChartLegendItem

@protocol SChartLegendItem <NSObject>

Specifies the interface required by the legend to display chart series. A series should adopt this protocol if it wishes to specify how it is represented in the legend.

The SChartSeries base class adopts this protocol and therefore any subclasses can specify their representation in the legend by overriding the methods here. All the series types provided by shinobicharts already provide their own implementation of these methods, so you should only need to implement them yourself if you are looking for custom behavior.

  • Returns the text displayed in the legend for the series.

    This is relevant for cartesian series, but is not used for radial series. For radial series, use titleForSliceInLegend.

    Declaration

    Objective-C

    - (nonnull NSString *)titleForSeriesInLegend;

    Swift

    optional func titleForSeriesInLegend() -> String
  • Returns the text displayed in the legend for the slice at the given index in the first series on the chart.

    This is only relevant for radial series. This method will be called for each of the slices in the first series in the chart. If this is implemented, symbolForSeriesInLegend will not be called. Instead of displaying a symbol for each series, we will display more detailed information about the first series in the chart.

    Declaration

    Objective-C

    - (nonnull NSString *)titleForSliceInLegend:(NSInteger)index;

    Swift

    optional func titleForSlice(inLegend index: Int) -> String

    Parameters

    index

    The index of the relevant slice in the first chart series.

  • Returns the text color used for series titles in the legend.

    By default, the text color is taken from the chart theme. If you implement this method yourself, the value it returns takes precedence.

    Declaration

    Objective-C

    - (nonnull UIColor *)textColorForSeriesTitleInLegend;

    Swift

    optional func textColorForSeriesTitleInLegend() -> UIColor
  • Returns the symbol representing a cartesian series in the legend.

    All of the series types provided by shinobicharts return an appropriate symbol to represent them in the legend. If you would like to use a custom symbol, you can subclass one of the series types, and override this method.

    For radial series, you should use symbolForSliceInLegend: instead.

    Declaration

    Objective-C

    - (nonnull SChartLegendSymbol *)symbolForSeriesInLegend;

    Swift

    optional func symbolForSeriesInLegend() -> SChartLegendSymbol
  • Returns the symbol representing a slice in the first radial series on the chart.

    All of the series types provided by shinobicharts return an appropriate symbol type to be used in the legend. If you would like to use a custom symbol, you can subclass one of the series types, and override this method.

    For cartesian series, you should use symbolForSeriesInLegend instead.

    Declaration

    Objective-C

    - (nonnull SChartLegendSymbol *)symbolForSliceInLegend:(NSInteger)index;

    Swift

    optional func symbolForSlice(inLegend index: Int) -> SChartLegendSymbol
  • Returns a solid block of color representing a cartesian series in the legend.

    Declaration

    Objective-C

    - (nonnull SChartLegendSymbol *)blockSymbolForSeriesInLegend;

    Swift

    optional func blockSymbolForSeriesInLegend() -> SChartLegendSymbol