@mapbox/canvas-dial

1.0.0 • Public • Published

canvas-dial

A simple dial or gauge implemented in HTML5 Canvas and designed to be performant and flexible.

Demo

API

new Dial(element, options) create a new dial, owning a single DOM element. Options are listed below

dial.draw(value) update the dial to show a new value.

Options

  {
    // the width & height of the gauge canvas element
    diameter: 20,
    // the width of the stroke indicating the gauge's background
    // and foreground values
    width: 8,
    // the outer width of the gauge
    outer: 15,
    // the gap at the bottom of the gauge, if any
    gap: 10,
    // the strokeStyle of the background that indicates
    // the total range of the gauge
    background: '#eee',
    // the strokeStyle of the dial - the part that shows data
    foreground: '#00f',
    // the minimum value in the scale.
    min: 0,
    // the value from which the gauge starts. 0 is common
    // for absolute values, 0.5 can be useful for things like
    // saturation/desaturation
    start: 0.5,
    // the maximum value represented by the gauge
    max: 1
  }

Package Sidebar

Install

npm i @mapbox/canvas-dial

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user