Highcharts量表正在四舍五入最大数

Tya*_*ger 2 javascript math highcharts

max设置为非常大的数字(例如666772)时,会发生此问题。Highcharts将采用该数字并将其四舍五入,具体取决于tickPixelInterval设置为什么。

如果将tickPixelInterval值设置为更接近0,则“量表”图表上的最大数字开始接近666772,但仍取整。我想min从0开始(确实如此),然后再使它max成为确切的数字(666772),甚至是四舍五入的版本(667k)。

有没有一种方法可以仅使用仪表图上的min和来执行此操作max

   var gaugeOptions = {

    chart: {
      type: 'solidgauge'
    },

    title: null,

    pane: {
      center: ['50%', '85%'],
      size: '140%',
      startAngle: -90,
      endAngle: 90,
      background: {
        backgroundColor: '#EEE',
        innerRadius: '60%',
        outerRadius: '100%',
        shape: 'arc'
      }
    },

    // the value axis
    yAxis: { 
      stops: [
        [0.1, '#DF5353'], // green
        [0.5, '#DDDF0D'], // yellow
        [0.9, 'green'] // red
      ],
      lineWidth: 0,
      minorTickInterval: null,
      tickPixelInterval: 400,
      tickWidth: 0,
      endOnTick: false,
      maxPadding: 0,
      title: {
        y: -70
      },
      labels: {
        y: 10,
        format: '{value}'
      }
    },

    credits: {
      enabled: false
    },

    tooltip: {
        enabled: false
    },

    plotOptions: {
      solidgauge: {
        dataLabels: {
          y: 5,
          borderWidth: 0,
          useHTML: true
        }
      }
    }

  };

  // Quarter1
  jQuery('#quarter1').highcharts(Highcharts.merge(gaugeOptions, {
    yAxis: {
      min: 0,
      max: 666772,
      title: {
        text: 'Quarter 1'
      }
    },

    series: [{
      name: 'Quarter 1',
      data: [50],
      dataLabels: {
        format: '<div style="text-align:center"><span style="font-size:25px;color:' +
          ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">${y}</span><br/>' +
          '<span style="font-size:12px;color:silver">Quota</span><br/><span>Bonus Elegible</span></div>'
      }
    }]

  }));
Run Code Online (Sandbox Code Playgroud)

小智 5

使用此代码显示准确数量的最小值和最大值。

yAxis: {
min: 0,
max: 2602,
tickPositioner: function() {
  return [this.min, this.max];
} 
Run Code Online (Sandbox Code Playgroud)