A simple SVG-based animated circular gauge.
Running npm run build
will build ./build/svg-gauge-circle.min.js
.
Running npm run dev
will start up a dev server, go to http://localhost:3333/index-dev.html
to see an example.
See demo for an example.
sgc = new SvgGaugeCircle(size, value, cutoffValue, maxValue, fontSize, strokeWidth)
:size
: length of a side of a square bounding box in which the element is drawnvalue
: a value to be shown on the gaugecutoffValue
: threshold/cutoff value shown on the gaugemaxValue
: maximum value that can be shown on the gauge ie. number at which the gauge's external circle would be 100% filledfontSize
: font size of the digits shown in pxstrokeWidth
: width of the external circle
sgc.draw(container)
- draw the gauge inside of thecontainer
element; this will return aPromise
that is resolved when drawing of the gauge has been finished
The gauge will be styled using the following classes:
sgc-inner-circle
: for internal circle properties (usestroke
for circle's edge)sgc-outer-circle
: for external circle properties (don't usefill
here)sgc-stroke
: for the animated stroke properties before it reaches the cutoffValuesgc-stroke-cutoff
: for the animated stroke properties after it reached the cutoffValuesgc-text
: for text properties
#container1 .sgc-text {
color: #171d69;
font-family: Arial;
}
#container1 .sgc-inner-circle {
stroke: #ca4545;
fill: #ff9595;
}
#container1 .sgc-outer-circle {
stroke: #980e0e;
stroke-width: 2;
}
#container1 .sgc-stroke {
stroke: #78cd78;
}
#container1 .sgc-stroke-cutoff {
stroke: #ffe395;
}
- update the gauge after drawing it first time
See LICENSE
.