Canvas-based JavaScript Knob/Dial Component – pure-knob

Category: Chart & Graph , Javascript | January 14, 2019
Author: andrepxx
Views Total: 3,162
Official Page: Go to website
Last Update: January 14, 2019
License: MIT


Canvas-based JavaScript Knob/Dial Component – pure-knob


A pure JavaScript knob component to render canvas-based, highly customizable knobs/dials/gauges on the web app.


  • Supports both mouse drag and touch events.
  • Double click to change the value manually.
  • Easy to customize the appearance of the knob/dial.

Basic usage:

Import the main JavaScript file pureknob.js into the html document.

<script src="pureknob.js"></script>

Create a new knob instance (300x300px).

var myKnob = pureknob.createKnob(300, 300);

Set properties. All possible properties:

  • angleStart: start angle
  • angleEnd: end angle
  • angleOffset: offset
  • colorBG: color of the knob track.
  • colorFG: color of the knob gauge / indicator.
  • needle: decide whether to use a simple marker / needle instead of a filling gauge to indicate value along the knob’s track.
  • readonly: is readonly?
  • trackWidth: track width
  • textScale: increase/ decrease the font size. (1.0 is default font size.)
  • valMin: min value
  • valMax: max value
  • val: default value
myKnob.setProperty(propertyName, value);

Set the initial value you prefer.


Set the peak value


Append the knob to an element.

<div id="demo"></div>
var node = knob.node();
var elem = document.getElementById('demo');

Add an event listener to the knob.

var listener = function(knob, value) {




  • Add functionality for custom formatting and scaling.


  • Add support for entry of numeric values on Android.


  • Add support for bar graph control.

You Might Be Interested In:

Leave a Reply