Highcharts Solid Gauge - compute color or use solid color

author(s): Edo

by Edo

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

JavaScript

$(function() {

  Highcharts.chart('container-cpu', {

    chart: {
      type: 'solidgauge'
    },

    title: null,

    pane: {
      center: ['50%', '85%'],
      size: '140%',
      startAngle: -90,
      endAngle: 90,
      background: {
        backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
        innerRadius: '60%',
        outerRadius: '100%',
        shape: 'arc'
      }
    },

    tooltip: {
      enabled: false
    },

    yAxis: {
      min: 0,
      max: 100,
      title: {
        text: 'CPU'
      },
       stops: [
        [0.5, 'green'], // green
        [0.9, 'yellow'], // yellow
        [1, 'red'] // red
      ]
      
    },



    series: [{
      name: 'HDD',
      data: [51],
      color: 'blue'
    }]

  });
});