Highcharts Demo
author(s):
Torstein Hønsi
by AbhishekRohan
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
<div id="container"></div>
CSS
#container {
margin: 0 auto;
max-width: 400px;
min-width: 380px;
}
JavaScript
// Uncomment to style it like Apple Watch
/*
if (!Highcharts.theme) {
Highcharts.setOptions({
chart: {
backgroundColor: 'black'
},
colors: ['#F62366', '#9DFF02', '#0CCDD6'],
title: {
style: {
color: 'silver'
}
},
tooltip: {
style: {
color: 'silver'
}
}
});
}
// */
/**
* In the chart render event, add icons on top of the circular shapes
*/
function renderIcons() {
// Move icon
if (!this.series[0].icon) {
this.series[0].icon = this.renderer.path(['M', -8, 0, 'L', 8, 0, 'M', 0, -8, 'L', 8, 0, 0, 8])
.attr({
'stroke': '#303030',
'stroke-linecap': 'round',
'stroke-linejoin': 'round',
'stroke-width': 2,
'zIndex': 10
})
.add(this.series[2].group);
}
this.series[0].icon.translate(
this.chartWidth / 2 - 10,
this.plotHeight / 2 - this.series[0].points[0].shapeArgs.innerR -
(this.series[0].points[0].shapeArgs.r - this.series[0].points[0].shapeArgs.innerR) / 2
);
}
Highcharts.chart('container', {
chart: {
type: 'solidgauge',
height: '110%',
events: {
// render: renderIcons
},
events: {
load: function() {
var chart = this,
series = chart.series[0];
if (series.data[0].y > 15) {
series.addPoint(45);
}
if (series.data[0].y > 15) {
series.addPoint(40);
}
}
}
},
title: {
text: 'Activity',
style: {
fontSize: '24px'
}
},
tooltip: {
enabled : false
},
pane: {
background: [{ // Track for Move
outerRadius: '112%',
innerRadius: '88%',
startAngle: 0,
endAngle: 360,
...