Basic gauge
by oysteinmoseng
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/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Chart showing use of plot bands with a gauge series.
</p>
</figure>
CSS
.highcharts-figure,
.highcharts-data-table table {
min-width: 280px;
max-width: 500px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
.highcharts-description {
margin: 0.3rem 10px;
}
JavaScript
Highcharts.chart('container', {
chart: {
type: 'gauge',
height: 300,
spacingBottom: -150
},
title: {
text: 'Revenue this month'
},
// Defines the gauge area
_pane: {
startAngle: -90,
endAngle: 90,
background: null
},
// The value axis
yAxis: {
min: 0,
max: 200000,
tickWidth: 0,
minorTickInterval: null,
labels: {
distance: 20
},
lineWidth: 0,
plotBands: [{
from: 0,
to: 130000,
color: '#DF5353', // red
thickness: '25%'
}, {
from: 132000,
to: 160000,
color: '#DDDF0D', // yellow
thickness: '25%'
}, {
from: 162000,
to: 200000,
color: '#55BF3B', // green
thickness: '25%'
}]
},
series: [{
name: 'Revenue',
enableMouseTracking: false,
data: [80000],
tooltip: {
valuePrefix: '$'
},
// Show a large data label
dataLabels: {
format: '${y:,.0f}',
borderWidth: 0,
verticalAlign: 'bottom',
y: -10,
style: {
fontSize: '1.4em'
}
},
// The dial pointer can be heavily customized
dial: {
radius: '72%', // Matching the plot band thickness
backgroundColor: '#222',
baseWidth: 12,
baseLength: '85%',
rearLength: '-85%'
},
pivot: {
radius: 0
}
}]
});