JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; max-width: 400px; height: 300px; margin: 0 auto"></div>
JavaScript
$(function () {
$('#container').highcharts({
chart: {
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},
title: {
text: 'Speedometer'
},
pane: {
startAngle: -90,
endAngle: 90,
background: null
},
plotOptions: {
gauge: {
dataLabels: {
enabled: false
},
dial: {
baseLength: '0%',
baseWidth: 10,
radius: '100%',
rearLength: '0%',
topWidth: 1
}
}
},
// the value axis
yAxis: {
labels: {
enabled: false
},
minorTickLength: 0,
min: 0,
max: 100,
tickLength: 0,
plotBands: [{
from: 0,
to: 25,
color: 'rgb(192, 0, 0)', // red
thickness: '50%'
}, {
from: 25,
to: 75,
color: 'rgb(255, 192, 0)', // yellow
thickness: '50%'
}, {
from: 75,
to: 100,
color: 'rgb(155, 187, 89)', // green
thickness: '50%'
}]
},
series: [{
name: 'Speed',
data: [80]
}]
},
// Add some life
function (chart) {
if (!chart.renderer.forExport) {
setInterval(function () {
var point = chart.series[0].points[0],
newVal,
inc = Math.round((Math.random() - 0.5) * 20);
newVal = point.y + inc;
if (newVal < 0 || newVal > 100) {
newVal = point.y - inc;
}
point.update(newVal);
}, 3000);
}
});
});