Home Reference Source

Function

Static Public Summary
public

Gauge collections type.

public

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

Draws value box at given position

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): CanvasGradient

Creates and returns linear gradient canvas object

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

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 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 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): 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

Return:

CanvasGradient

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