javascript - Highcharts :(Solid Gauge) How to generate gauge dial with an arrow end.

标签 javascript css highcharts

我正在尝试使用 Highcharts (实心表)创建自定义数据刻度盘。

请帮帮我。

我无法生成像实心仪表尖刻度盘那样的箭头端。这是我当前的图表:

更新代码:请复制粘贴下面提供的 fiddle 链接中的代码:

$(function() {

var gaugeOptions = {

chart: {
  type: 'solidgauge',
  height: 80,
  width: 120,
  backgroundColor: null
},

title: null,

pane: {
  center: ['50%', '60%'],
  size: '100%',
  startAngle: -90,
  endAngle: 90,
  background: {
    innerRadius: '60%',
    outerRadius: '100%',
    shape: 'arc'
  }
},
credits: {
  enabled: false
},

tooltip: {
  enabled: false
},

plotOptions: {
  solidgauge: {
    dataLabels: {
      y: 5,
      borderWidth: 0,
      useHTML: true
    }
  },
  gauge: {
    dial: {
      baseWidth: 1,
      topWidth: 1
    },
    pivot: {
     radius: 3,
     borderWidth: 1
     }
    }
  }
};

  // The speed gauge
  $('#container-speed').highcharts(Highcharts.merge(gaugeOptions, {
    yAxis: {
       min: 0,
       max: 5,
       tickPositions: [],
       plotBands: [{ // mark the weekend
      color: {
      linearGradient: [0, 0, 300, 0],
      stops: [
        [0.1, '#55BF3B'], // green
        [0.2, '#DDDF0D'], // yellow
        [0.3, '#DF5353']
      ]
      },
      from: 0,
      to: 5,
      innerRadius: '60%',
      outerRadius: '100%',
  }],
},
series: [{
  name: 'Ship Average',
  type: 'gauge',
  data: [2],

  color: {
    linearGradient: [0, 0, 300, 0],
    stops: [
      [0.1, '#55BF3B'], // green
      [0.25, '#DDDF0D'], // yellow
      [0.4, '#DF5353']
    ]
  },
  dataLabels: {
    format: '<span style="font-size:10px;color:grey;">{y} delays</span></div>',
    y: 30,
    borderWidth: 0
  },
  tooltip: {
    valueSuffix: ' days'
  }
  }]

}));
});

http://jsfiddle.net/n9gfeor2/29/

预期结果: enter image description here

最佳答案

可以通过包装拨号方法(翻译)和编辑路径来实现。

    point.shapeArgs = {
      d: dialOptions.path || [
      'M', -rearLength, -baseWidth / 2,
                          'L',
                          baseLength, -baseWidth / 2,
                          radius, -topWidth / 2,
                          radius - 10, -topWidth / 2 - 10,
                          'M',
                          radius, -topWidth / 2,
                          'L',
                          radius - 10, -topWidth / 2 + 10,
                          'M',
                          radius, -topWidth / 2,
                          baseLength, baseWidth / 2, -rearLength, baseWidth / 2,
                          'z'
    ],

简单演示:

关于javascript - Highcharts :(Solid Gauge) How to generate gauge dial with an arrow end.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45237517/

相关文章:

javascript - 返回多个回显作为 Ajax 请求的数据

javascript - Dropbox API 不返回 png 文件的元数据

javascript - 使用上下键导航网页和隐藏/显示 div

html - hover时如何将div网格元素做成链接并叠加图片?

javascript - Highcharts stockChart 中的多点选择

javascript - 如何使用 Highcharts 和大量动态数据构建 Angular

Javascript - 复选框和本地存储。如果有匹配的值,则选中复选框

javascript - IE7 在某些机器上崩溃,调试栏中出现错误,但看不到 'showstopper'

javascript - 使用 Bootstrap 创建动态网格以显示视频

javascript - 如何在时间和值(value)交换的 Highcharts 中绘制数据?