NChartBrushScale Class Reference

Inherits from NSObject
Declared in NChartBrushScale.h

Overview

The NChartBrushScale class provides scale that transforms values into brushes like a step mapping function.
The scale contains array of reference values and array of brushes. It returns brush for given value according to these arrays:


brushes[n]
values[n - 1]
...
brushes[4]
values[3]
brushes[3]
values[2]
brushes[2]
values[1]
brushes[1]
values[0]
brushes[0]

This is equivalent to the following pseudo code:


if value <= values[0] return brushes[0];
if value > values[i] and value <= values[i + 1] return brush[i + 1];
if value > values[last] return brush[last]

So the array of brushes should contain n elements and array of values should contain n - 1. Values should be sorted (NChartBrushScale does not sort them automatically). If they are not, it can lead to strange results. If brush index goes out of range, nil is returned.

+ brushScaleWithBrushes:andValues:

Create new instance of NChartBrushScale with arrays of brushes and values.

+ (NChartBrushScale *)brushScaleWithBrushes:(NSArray *)brushes andValues:(NSArray *)values

Parameters

brushes
values
  • array of values represented with NSNumber.

Return Value

a new instance of NChartBrushScale.

Declared In

NChartBrushScale.h

+ linearBrushScaleWithBrushes:minValue:maxValue:

Create new instance of NChartBrushScale with linear space of values.

+ (NChartBrushScale *)linearBrushScaleWithBrushes:(NSArray *)brushes minValue:(double)minValue maxValue:(double)maxValue

Parameters

brushes
minValue
  • minimal value.
maxValue
  • maximal value

Return Value

a new instance of NChartBrushScale.

Declared In

NChartBrushScale.h

+ logarithmicBrushScaleWithBrushes:minValue:maxValue:logarithmBase:

Create new instance of NChartBrushScale with logarithmic space of values.

+ (NChartBrushScale *)logarithmicBrushScaleWithBrushes:(NSArray *)brushes minValue:(double)minValue maxValue:(double)maxValue logarithmBase:(double)logarithmBase

Parameters

brushes
minValue
  • minimal value.
maxValue
  • maximal value
logarithmBase
  • logarithm base.

Return Value

a new instance of NChartBrushScale.

Declared In

NChartBrushScale.h

– initWithBrushes:andValues:

Init new instance of NChartBrushScale with arrays of brushes and values.

- (id)initWithBrushes:(NSArray *)brushes andValues:(NSArray *)values

Parameters

brushes
values
  • array of values represented with NSNumber.

Return Value

initialized instance of NChartBrushScale.

Declared In

NChartBrushScale.h

– initLinearWithBrushes:minValue:maxValue:

Init new instance of NChartBrushScale with linear space of values.

- (id)initLinearWithBrushes:(NSArray *)brushes minValue:(double)minValue maxValue:(double)maxValue

Parameters

brushes
minValue
  • minimal value.
maxValue
  • maximal value

Return Value

a new instance of NChartBrushScale.

Declared In

NChartBrushScale.h

– initLogarithmicWithBrushes:minValue:maxValue:logarithmBase:

Init new instance of NChartBrushScale with logarithmic space of values.

- (id)initLogarithmicWithBrushes:(NSArray *)brushes minValue:(double)minValue maxValue:(double)maxValue logarithmBase:(double)logarithmBase

Parameters

brushes
minValue
  • minimal value.
maxValue
  • maximal value
logarithmBase
  • logarithm base.

Return Value

a new instance of NChartBrushScale.

Declared In

NChartBrushScale.h

  brushes

Array of brushes.

@property (nonatomic, readonly) NSArray *brushes

Declared In

NChartBrushScale.h

  values

Array of values.

@property (nonatomic, readonly) NSArray *values

Declared In

NChartBrushScale.h

  isGradient

Flag determining if scale can return gradient colors. The default value is YES.
The gradient scale assumes that the array of brushes contains instances of NChartSolidColorBrush and linearly interpolates colors that correspond to the neighbor values.

@property (nonatomic, assign) BOOL isGradient

Declared In

NChartBrushScale.h

  isLogarithmic

Flag determining if the scale is linear (NO) or logarithmic (YES). The default value is NO.

@property (nonatomic, assign) BOOL isLogarithmic

Declared In

NChartBrushScale.h

  logarithmBase

Logarithm base. Takes effect if isLogarithmic is YES only. The default value is 10.

@property (nonatomic, assign) double logarithmBase

Declared In

NChartBrushScale.h

  isStrict

Strict brush range flag. The default value is NO. Strict brush range (YES in this property) means, that if value is less than value[0] or bigger than value[n - 1], clear (transparent) brush is returned. Otherwhise (NO in this property), brushes[0] and brushes[n] respectively is returned.

@property (nonatomic, assign) BOOL isStrict

Declared In

NChartBrushScale.h

– brushForValue:

Get value for brush.

- (NChartBrush *)brushForValue:(NSNumber *)value

Parameters

value
  • value to get brush for.

Return Value

brush for given value.

Declared In

NChartBrushScale.h