Home Reference Source

Function

Static Public Summary
public

Gauge collections type.

public

drawShadow(context: Canvas2DContext, options: GenericOptions, shadowDrawn: boolean): boolean

Draws the shadow if it was not drawn

public

drawValueBox(context: Canvas2DContext, options: GenericOptions, value: number | string, x: number, y: number, max: number)

Draws value box at given position

public

font(options: GenericOptions, target: string, baseSize: number): *

Constructs font styles for canvas fonts

public

formatContext(options: GenericOptions | any, format: string): string

Format string unit string format using option members Format option to set the “units” attribute.

public

Formats a number for display on the dial's plate using the majorTicksFormat config option.

public

linearGradient(context: Canvas2DContext, colorFrom: string, colorTo: string, length: number, isVertical: boolean, from: number): CanvasGradient

Creates and returns linear gradient canvas object

public

normalizedValue(options: GenericOptions): {normal: number, indented: number}

Returns normalized value

public

padValue(val: number, options: RadialGaugeOptions | {valueInt: number, valueDec: number}): string

Pads a given value with leading zeros using the given options

public

radialPoint(radius: number, angle: number): {x: number, y: number}

Calculates and returns radial point coordinates

public

radians(degrees: number): number

Transforms degrees to radians

public

roundRect(context: Canvas2DContext, x: number, y: number, w: number, h: number, r: number)

Draws rounded corners rectangle

public

vendorize(prop: string, from: HTMLElement | Window | object): *

Look-ups for a proper vendor-specific property and returns its value

public

Examines if a given error is something to throw or to ignore

Static Public

public Collection() source

import Collection from 'canvas-gauges/lib/Collection.js'

Gauge collections type.

It is used ES5 declaration here, because babel transpiles inheritance incorrectly in this case.

public drawShadow(context: Canvas2DContext, options: GenericOptions, shadowDrawn: boolean): boolean source

import {drawShadow} from 'canvas-gauges/lib/drawings.js'

Draws the shadow if it was not drawn

Params:

NameTypeAttributeDescription
context Canvas2DContext
options GenericOptions
shadowDrawn boolean

Return:

boolean

public drawValueBox(context: Canvas2DContext, options: GenericOptions, value: number | string, x: number, y: number, max: number) source

import {drawValueBox} from 'canvas-gauges/lib/drawings.js'

Draws value box at given position

Params:

NameTypeAttributeDescription
context Canvas2DContext
options GenericOptions
value number | string
x number
y number
max number

public font(options: GenericOptions, target: string, baseSize: number): * source

import {font} from 'canvas-gauges/lib/drawings.js'

Constructs font styles for canvas fonts

Params:

NameTypeAttributeDescription
options GenericOptions
target string
baseSize number

Return:

*

public formatContext(options: GenericOptions | any, format: string): string source

import {formatContext} from 'canvas-gauges/lib/drawings.js'

Format string unit string format using option members Format option to set the “units” attribute. For example “{value} % {title}” which replaces the attributes inside {} to the same member in the option object. So if title is set to “Hour” and value to “50” the units will be “50% Hour”.

Params:

NameTypeAttributeDescription
options GenericOptions | any
format string

Return:

string

public formatMajorTickNumber(num: number, options: object): string source

import {formatMajorTickNumber} from 'canvas-gauges/lib/drawings.js'

Formats a number for display on the dial's plate using the majorTicksFormat config option.

Params:

NameTypeAttributeDescription
num number

number to format

options object

Return:

string

formatted number

public linearGradient(context: Canvas2DContext, colorFrom: string, colorTo: string, length: number, isVertical: boolean, from: number): CanvasGradient source

import {linearGradient} from 'canvas-gauges/lib/drawings.js'

Creates and returns linear gradient canvas object

Params:

NameTypeAttributeDescription
context Canvas2DContext
colorFrom string
colorTo string
length number
isVertical boolean
  • optional
from number
  • optional

Return:

CanvasGradient

public normalizedValue(options: GenericOptions): {normal: number, indented: number} source

import {normalizedValue} from 'canvas-gauges/lib/drawings.js'

Returns normalized value

Params:

NameTypeAttributeDescription
options GenericOptions

Return:

{normal: number, indented: number}

public padValue(val: number, options: RadialGaugeOptions | {valueInt: number, valueDec: number}): string source

import {padValue} from 'canvas-gauges/lib/drawings.js'

Pads a given value with leading zeros using the given options

Params:

NameTypeAttributeDescription
val number
options RadialGaugeOptions | {valueInt: number, valueDec: number}

Return:

string

public radialPoint(radius: number, angle: number): {x: number, y: number} source

import {radialPoint} from 'canvas-gauges/lib/drawings.js'

Calculates and returns radial point coordinates

Params:

NameTypeAttributeDescription
radius number
angle number

Return:

{x: number, y: number}

public radians(degrees: number): number source

import {radians} from 'canvas-gauges/lib/drawings.js'

Transforms degrees to radians

Params:

NameTypeAttributeDescription
degrees number

Return:

number

public roundRect(context: Canvas2DContext, x: number, y: number, w: number, h: number, r: number) source

import {roundRect} from 'canvas-gauges/lib/drawings.js'

Draws rounded corners rectangle

Params:

NameTypeAttributeDescription
context Canvas2DContext
x number
y number
w number
h number
r number

public vendorize(prop: string, from: HTMLElement | Window | object): * source

import vendorize from 'canvas-gauges/lib/vendorize.js'

Look-ups for a proper vendor-specific property and returns its value

Params:

NameTypeAttributeDescription
prop string
from HTMLElement | Window | object
  • optional

default is window

Return:

*

Example:

var requestAnimationFrame = vendorize('requestAnimationFrame');
// it will refer properly to:
//  - window.requestAnimationFrame by default or to
//  - window.webkitRequestAnimationFrame or to
//  - window.mozRequestAnimationFrame or to
//  - window.msRequestAnimationFrame or to
//  - window.oRequestAnimationFrame
// depending on the current browser vendor

public verifyError(err: Error) source

import {verifyError} from 'canvas-gauges/lib/drawings.js'

Examines if a given error is something to throw or to ignore

Params:

NameTypeAttributeDescription
err Error