chartjs-colorful

chartjs-colorful - v1.0.0 / helpers

Namespace: helpers

Table of contents

Classes

Variables

Functions

Variables

DebugPlugin

Const DebugPlugin: Object

debug console.log plugin.

Type declaration

Name Type
id string

Functions

clampColor

clampColor(linear, min, max, colorMin?, colorMax?): ColorLinear

Get the function is input value [min,max] translate to [colorMin, colorMax] then call linear. ex) linear:(red -> blue), min:0, max:20, colorMin: 1.0, colorMax: 0.0 returned function call by ‘0’ then returned ‘blue’. returned function call by ‘20’ then returned ‘red’.

Parameters

Name Type Default value
linear ColorLinear undefined
min number undefined
max number undefined
colorMin number 0
colorMax number 1

Returns

ColorLinear


clampValue

clampValue(min, max, rangeMin?, rangeMax?): (value: number) => number

Get the function is input value [min,max] translate to [colorMin, colorMax]. ex) min:0, max:20, colorMin: 1.0, colorMax: 0.0 returned function call by ‘0’ then returned ‘1.0’. returned function call by ‘20’ then returned ‘0.0’.

Parameters

Name Type Default value
min number undefined
max number undefined
rangeMin number 0.0
rangeMax number 1.0

Returns

fn

▸ (value): number

Parameters
Name Type
value number
Returns

number


createAlphaConverter

createAlphaConverter(alpha): ColorConverter

Create color’s alpha converter.

Parameters

Name Type
alpha number

Returns

ColorConverter


createColors

createColors(linear, count, includeOne?): Colors

create Colors from ColorLinear.

includeOne=false(default) => [0, 1].
includeOne=true => [0, 1).
If linear returns the same value for 0 and 1, specify include=false. For example, linear created with createRotateLinear

Parameters

Name Type Default value
linear ColorLinear undefined
count number undefined
includeOne undefined | boolean true

Returns

Colors


createConvertColorBuilder

createConvertColorBuilder(): ConvertColorBuilder

Returns

ConvertColorBuilder


createLinear

createLinear(color): ColorLinear

Parameters

Name Type
color string

Returns

ColorLinear


createRotateLinear

createRotateLinear(color, reverse?): ColorLinear

Parameters

Name Type Default value
color string undefined
reverse boolean false

Returns

ColorLinear


createScriptableColor

createScriptableColor(valueFn, linear): ScriptableColor

Parameters

Name Type
valueFn ScriptableValue
linear ColorLinear

Returns

ScriptableColor


createScriptableValue

createScriptableValue(value): ScriptableValue

Parameters

Name Type
value string | ScriptableValue

Returns

ScriptableValue


getColor

getColor(colors, index): string

Parameters

Name Type
colors Colors
index number

Returns

string


getColors

getColors(colors, count, startIndex?): Colors

Parameters

Name Type Default value
colors Colors undefined
count number undefined
startIndex number 0

Returns

Colors


halfTransparent

halfTransparent(color): string

Get a half-transparent color.

#FFFFFF -> #FFFFFF80

Parameters

Name Type
color string

Returns

string


isFunction

isFunction(v): v is Function

Parameters

Name Type
v any

Returns

v is Function


isNumber

isNumber(v): v is number

Parameters

Name Type
v any

Returns

v is number


throughNull

throughNull<V, R>(fn): (v: V | null | undefined) => R | null

v is null then return null. v is NOT null then return fn(v).

Type parameters

Name
V
R

Parameters

Name Type
fn (v: V) => R

Returns

fn

▸ (v): R | null

Parameters
Name Type
v V | null | undefined
Returns

R | null


transparent

transparent(color): string

Get a transparent color.

#FFFFFF -> #FFFFFF00

Parameters

Name Type
color string

Returns

string