AWFSeriesItem

Objective-C

@interface AWFSeriesItem : NSObject <NSCopying>

Swift

class AWFSeriesItem : NSObject, NSCopying

The AWFSeriesItem class represents a single dataset that is displayed in a graph view. This class parses and stores its data as well as provides the necessary styling configuration for a graph renderer.

  • The title of the series.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull title;

    Swift

    var title: String { get set }
  • The unique identifier for the series. If not assigned, a random string will be generated for the identifier.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull identifier;

    Swift

    var identifier: String { get set }
  • An array of data points for the series.

    The array can contain be array of arrays (@[@[x1, y1], @[x2, y2]]), an array of AWFSeriesPoint instances or an array of AWFWeatherObject instances (if returned from an object loader.

    Declaration

    Objective-C

    @property (nonatomic, strong) NSArray *_Nonnull data;

    Swift

    var data: [Any] { get set }
  • The property key path to use for x-axis values from objects loaded by the associated object loader.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull xAxisPropertyName;

    Swift

    var xAxisPropertyName: String { get set }
  • The property key path to use for y-axis values from objects loaded by the associated object loader.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull yAxisPropertyName;

    Swift

    var yAxisPropertyName: String { get set }
  • The value interval of the data.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat interval;

    Swift

    var interval: CGFloat { get set }
  • Whether or not the series item’s range should be constrained to only positive values.

    Declaration

    Objective-C

    @property (nonatomic) BOOL constrainToPositiveValues;

    Swift

    var constrainToPositiveValues: Bool { get set }
  • Whether the time value should be ignored for date-specific values. Default is NO.

    Declaration

    Objective-C

    @property (nonatomic) BOOL ignoreTime;

    Swift

    var ignoreTime: Bool { get set }
  • Whether zero values should be ignored in the series. Default is NO.

    Declaration

    Objective-C

    @property (nonatomic) BOOL ignoreZeroValues;

    Swift

    var ignoreZeroValues: Bool { get set }

Styling a Series Item

  • The graph renderer type to use to render the series item.

    Declaration

    Objective-C

    @property (nonatomic) AWFGraphRendererType rendererType;

    Swift

    var rendererType: AWFGraphRendererType { get set }
  • The fill color used for the series item.

    When using a renderer type of AWFGraphRendererTypeBar, this will be the color of each bar in the series. For AWFGraphRendererTypeLine, the fill color defines the color of the region underneath the line.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIColor *fillColor;

    Swift

    var fillColor: UIColor? { get set }
  • The stroke color used for the series item.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIColor *strokeColor;

    Swift

    var strokeColor: UIColor? { get set }
  • The width of the stroke to use for the series item.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat strokeWidth;

    Swift

    var strokeWidth: CGFloat { get set }
  • The point radius to use for the series item. This is only used for a renderer type of AWFGraphRendererTypeLine.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat pointRadius;

    Swift

    var pointRadius: CGFloat { get set }
  • An array of AWFSeriesPoint instances representing the series data.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSArray *points;

    Swift

    var points: [Any]? { get }
  • The minimum date found within the series data, if any.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSDate *minDate;

    Swift

    var minDate: Date? { get }
  • The maximum date found within the series data, if any.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSDate *maxDate;

    Swift

    var maxDate: Date? { get }
  • Returns the range of values within the series data for the specified axis.

    Declaration

    Objective-C

    - (AWFGraphSeriesRange)rangeForAxis:(AWFGraphAxisType)axis;

    Swift

    func range(for axis: AWFGraphAxisType) -> AWFGraphSeriesRange

    Parameters

    axis

    The axis to return the range for

  • Returns the closest data point in the series to the specified value and axis.

    Declaration

    Objective-C

    - (nullable AWFSeriesPoint *)closestPointToValue:(CGFloat)value
                                             forAxis:(AWFGraphAxisType)axis;

    Swift

    func closestPoint(toValue value: CGFloat, for axis: AWFGraphAxisType) -> AWFSeriesPoint?

    Parameters

    value

    The value to return the closest data point for

    axis

    The axis the value is on

  • Sets the block used to format values in the series for display.

    Declaration

    Objective-C

    - (void)setValueFormatter:(nullable AWFGraphValueFormatter)formatter;

    Swift

    func setValueFormatter(_ formatter: AWFGraphValueFormatter?)

    Parameters

    formatter

    The block to be used to format values

  • Returns a value formatted using the defined formatter block.

    Declaration

    Objective-C

    - (nonnull NSString *)formatValue:(CGFloat)value;

    Swift

    func formatValue(_ value: CGFloat) -> String

    Parameters

    value

    The value to format

    Return Value

    A formatted string from the value