Home Reference Source
import BaseGauge from 'canvas-gauges/lib/BaseGauge.js'
public class | source

BaseGauge

Extends:

EventEmitter → BaseGauge

Direct Subclass:

LinearGauge, RadialGauge

Basic abstract BaseGauge class implementing common functionality for different type of gauges.

It should not be instantiated directly but must be extended by a final gauge implementation.

Example:


class MyCoolGauge extends BaseGauge {

    // theses methods below MUST be implemented:

    constructor(options) {
       // ... do something with options
       super(options);
       // ... implement anything else
    }

    draw() {
        // ... some implementation here
        return this;
    }
}

Static Member Summary

Static Public Members
public static get

Returns gauges version string

Static Method Summary

Static Public Methods
public static

ensureValue(value: *, min: number): number

Ensures value is proper number

public static

fromElement(element: HTMLElement)

Initializes gauge from a given HTML element (given element should be valid HTML canvas gauge definition)

public static

initialize(type: string, options: GenericOptions): *

Inject given gauge object into DOM

public static

mod(n: number, m: number): number

Corrects javascript modulus bug

Static Protected Methods
protected static

configure(options: *): BaseGauge

Updates gauge options

Constructor Summary

Public Constructor
public abstract

Member Summary

Public Members
public
public
public

True if gauge has been drawn for the first time, false otherwise.

public

Gauge options

public

Gauge type class

public set

value(value: number): *

Sets new value for this gauge.

public get

Returns current value of the gauge

public

Gauges version string

Method Summary

Public Methods
public

Performs destruction of this object properly

public abstract

Triggering gauge render on a canvas.

public

Updates gauge configuration options at runtime and redraws the gauge

Static Public Members

public static get version: string: * source

Returns gauges version string

Return:

string

Static Public Methods

public static ensureValue(value: *, min: number): number source

Ensures value is proper number

Params:

NameTypeAttributeDescription
value *
min number

Return:

number

public static fromElement(element: HTMLElement) source

Initializes gauge from a given HTML element (given element should be valid HTML canvas gauge definition)

Params:

NameTypeAttributeDescription
element HTMLElement

public static initialize(type: string, options: GenericOptions): * source

Inject given gauge object into DOM

Params:

NameTypeAttributeDescription
type string
options GenericOptions

Return:

*

public static mod(n: number, m: number): number source

Corrects javascript modulus bug

Params:

NameTypeAttributeDescription
n number
m number

Return:

number

Static Protected Methods

protected static configure(options: *): BaseGauge source

Updates gauge options

Params:

NameTypeAttributeDescription
options *

Return:

BaseGauge

Public Constructors

public abstract constructor(options: GenericOptions) source

Params:

NameTypeAttributeDescription
options GenericOptions

Public Members

public animation: Animation source

public canvas: SmartCanvas source

public initialized: boolean source

True if gauge has been drawn for the first time, false otherwise.

public options: GenericOptions source

Gauge options

public type: BaseGauge source

Gauge type class

public set value(value: number): * source

Sets new value for this gauge. If gauge is animated by configuration it will trigger a proper animation. Upsetting a value triggers gauge redraw.

public get value: number: * source

Returns current value of the gauge

Return:

number

public version: string source

Gauges version string

Public Methods

public destroy() source

Performs destruction of this object properly

public abstract draw(): BaseGauge source

Triggering gauge render on a canvas.

Return:

BaseGauge

public update(options: RadialGaugeOptions): BaseGauge source

Updates gauge configuration options at runtime and redraws the gauge

Params:

NameTypeAttributeDescription
options RadialGaugeOptions

Return:

BaseGauge