Activity gauge High Chart with Gradient

2019-07-26 07:49发布

I want to use gradient in below chart.

Please help me on this concern.

Thanks in advance.

  Link : http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/gauge-activity/

enter image description here

enter image description here

1条回答
Lonely孤独者°
2楼-- · 2019-07-26 08:18

You should be able to use small trick for adding gradient to your angular gauge. You can use yAxis.stops for adding color gradients to your chart:

yAxis: {
  min: 0,
  max: 100,
  lineWidth: 0,
  tickPositions: [],
  stops: [
    [0.1, '#55BF3B'], // green
    [0.5, '#DDDF0D'], // yellow
    [0.9, '#DF5353'] // red
  ],
},

Then you can add points between your axis min and your value, so they will have different colors depending on points value.

function(chart) {
    var y = this.series[0].data[0].y;
    for (var i = y; i >= 0; i = i - (y / 80)) {
      chart.addSeries({
        data: [{
          y: i,
          radius: '100%',
          innerRadius: '100%',
        }],
        stickyTracking: false,
        enableMouseTracking: false
      }, false)
    }
    chart.redraw();
    Highcharts.each(chart.series, function(s) {
      s.update({
        borderColor: s.data[0].color
      }, false);
    });
    chart.redraw();
  }

Here you can find an example how it can work: http://jsfiddle.net/5ajoegb9/1/

查看更多
登录 后发表回答