Solid gauge
author(s):
Torstein Hønsi
by Guillaume Seguin
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>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container-speed" class="chart-container"></div>
</figure>
CSS
.highcharts-figure .chart-container {
width: 400px;
height: 350px;
float: left;
}
.highcharts-figure, .highcharts-data-table table {
width: 600px;
margin: 0 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;
}
@media (max-width: 600px) {
.highcharts-figure, .highcharts-data-table table {
width: 100%;
}
.highcharts-figure .chart-container {
width: 300px;
float: none;
margin: 0 auto;
}
}
JavaScript
var gaugeOptions = {
chart: {
type: 'gauge'
},
title: {text: 'null'},
pane: {
center: ['50%', '50%'],
size: '80%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor:'#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
},
exporting: {
enabled: true
},
tooltip: {
enabled: false
},
// the value axis
yAxis: {
/* stops: [
[0.0, '#a50026'],
[0.1, '#d73027'],
[0.2, '#f46d43'],
[0.3, '#fdae61'],
[0.4, '#fee08b'],
[0.5, '#d9ef8b'],
[0.6, '#a6d96a'],
[0.7, '#66bd63'],
[0.8, '#1a9850'],
[0.9, '#006837']
], */
},
plotOptions: {
gauge: {
dataLabels: {
format: '<div style="text-align: center">Estimation<br><span style="font-size: 16px;color: #006837">{y:,.0f} €</span></div>',
useHTML: true,
enabled: true
},
pivot: {
radius: 0
}
}
}
};
// The speed gauge
Highcharts.chart('container-speed', Highcharts.merge(gaugeOptions, {
yAxis: [{
lineWidth: 0,
minorTickInterval: null,
tickWidth: 1,
tickColor: '#606060',
tickLength: 57,
tickPosition: 'inside',
title: {
text: null,
y: -80
},/*
labels: {
enabled: true,
useHTML: true
}, */
min: 0,
max: 800000,
tickPositions: [706000],
showFirstLabel: false,
showLastLabel: false,
labels: {
x: 5,
/* x: -5, */
y: -10,
distance: 25,
format: '<div style="text-align:center;"><strong class="size-h5"><span>Prix moyen des <br/>biens similaires</span><br>{value} €</strong></div>'
},
plotBands:...