Solid gauge

author(s): Torstein Hønsi

by sundaramkumar

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-speed" class="chart-container"></div>

CSS

.highcharts-figure .chart-container {
    width: 300px;
    height: 200px;
    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 chartSpeed = Highcharts.chart('container-speed', {
  chart: {
    type: 'solidgauge',
    height: 140
  },

  title: null,
  legend: {
    enabled: true,
    floating: true
  },
  pane: {
    center: ['10%', '65%'],
    size: '140%',
    startAngle: -120,
    endAngle: 120,
    background: {
      backgroundColor: Highcharts.defaultOptions.legend.backgroundColor || '#EEE',
      innerRadius: '60%',
      outerRadius: '90%',
      shape: 'arc'
    }
  },

  tooltip: {
    enabled: false
  },

  // the value axis
  yAxis: {
    min: 0,
    max: 100,
    labels: {
      enabled: false
    },
    gridLineColor: 'transparent',
    lineColor: 'transparent',
    minorTickLength: 0,
    tickColor: Highcharts.defaultOptions.legend.backgroundColor,
    stops: [
      [0.1, '#729c49'], // green
      [0.5, '#e2cf40'], // yellow
      [0.9, '#e46c00'] // red
    ],
    plotBands: [{
      from: 0,
      to: 70,
      color: "#729c49",
      innerRadius: "60%",
      label: {
        text: ''
      },
    }, {
      from: 70,
      to: 90,
      color: "#e2cf40",
      innerRadius: "60%",
      label: {
        text: ''
      }
    }, {
      from: 90,
      to: 100,
      color: "#e46c00",
      innerRadius: "60%",
      label: {
        text: ''
      }
    }]
  },

  plotOptions: {
    series: {
      dataLabels: {
        y: 5,
        borderWidth: 0,
        useHTML: true
      }
    },
    guage: {
      pivot: {
        borderColor: 'transparent',
        backgroundColor: 'white',
        radius: 0
      },
    }
  },

  credits: {
    enabled: false
  },

  series: [{
    name: 'Speed',
    data: [92],
    type: 'gauge',
    dial: {
      path: [
        ['M', 40, 0],
        ['l', 50, 0],
        ['l', 0, 0],
        ['l', 0, 10],
        ['l', -50, 0]
      ],
      backgroundColor: '#2b2b2baa'
    },
    dataLabels: {
      format: '<div style="text-align:center;margin-top:-35px">' +
        '<span style="font-size:25px">{y}</span><br/>' +
        '</div>'
   ...