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

– 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

  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

  gradientSharpness

Sharpness of gradient, [0;1]. 0 means very smooth color transition, 1 means very sharp one. The default value is 0.2.

@property (nonatomic, assign) float gradientSharpness

Discussion

This value has effect if isGradient flag is set to YES only.

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