1

Is it possible to Draw this type of gauges in the left and right of the circle using Highcharts? Basically left side gauge is representing the shorts' %age at left, the right side gauge is representing the shorts' %age at right, and the center is one simple round circle with the %age of center shots.

enter image description here

1 Answers1

3

Series variable pie it's looks fit better for this case. Tooltip we built setting useHTML:true, circle at the center we rendered by SVG renderer.

Highcharts.chart('container', {
  chart: {
    events: {
      render() {
        const chart = this;
        if (!chart.customCenterCircle) {
          chart.customCenterCircle = chart.renderer.circle(
            chart.plotLeft + chart.plotSizeX / 2,
            chart.plotTop + chart.plotSizeY / 2,
            0
          ).add().toFront();
        }
        if (!chart.customCenterText) {
          chart.customCenterText = chart.renderer.text('50%', 0, 0).css({
            fontSize: '24px',
            color: '#d4d4d4'
          }).add().toFront();
        }
        chart.customCenterCircle.animate({
          x: chart.plotLeft + chart.plotSizeX / 2,
          y: chart.plotTop + chart.plotSizeY / 2,
          r: chart.series[0].center[3] / 2,
          fill: 'rgba(31, 112, 31, 0.5)',
          stroke: 'rgba(154, 214, 154, 1)',
          'stroke-width': 4
        });
        chart.customCenterText.attr({
          x: chart.plotLeft + chart.plotSizeX / 2 -
            chart.customCenterText.getBBox().width / 2,
          y: chart.plotTop + chart.plotSizeY / 2 -
            chart.customCenterText.getBBox().y -
            chart.customCenterText.getBBox().height / 2
        });
      }
    }
  },
  tooltip: {
    backgroundColor: '#ffffff',
    borderWidth: 0,
    useHTML: true,
    formatter: function() {
      return `<p><h1 style="color:${this.color};">${this.y}</h1></br>${this.key}</p>`
    }
  },
  series: [{
    type: 'variablepie',
    minPointSize: 0,
    innerSize: '30%',
    startAngle: 30,
    dataLabels: {
      enabled: false
    },
    borderWidth: 3,
    zMin: 0,
    data: [{
      y: 80,
      z: 100,
            name: 'other',
      color: 'black'
    }, {
      y: 30,
      z: 100,
            name: 'missed right',
      color: 'red'
    }, {
      y: 50,
      z: 0
    }, {
      y: 25,
      z: 80,
            name: 'missed right',
      color: 'red'
    }, {
      y: 75,
      z: 80,
            name: 'other',
      color: 'black'
    }, {
      y: 60,
      z: 0,
            name: 'other',
    }]
  }]
});

Live demo: https://jsfiddle.net/BlackLabel/sc9vwzjt/2/

API References:

https://www.highcharts.com/docs/chart-and-series-types/variable-radius-pie-chart

https://api.highcharts.com/highcharts/series.variablepie

https://api.highcharts.com/class-reference/Highcharts.SVGRenderer

Sebastian Hajdus
  • 1,422
  • 1
  • 5
  • 14