[英]Highcharts Gauge chart is rounding down max number
當max
設置為一個非常大的數字(例如666772)時會出現問題.Highcharts將取數字並將其向下舍入,具體取決於tickPixelInterval
的設置。
如果我將tickPixelInterval
值設置為接近0,則Gauge圖表上的最大數字開始接近666772,但仍然是四舍五入的。 我希望min
從0開始(它確實如此),然后將max
設置為確切的數字(666772),或者甚至是向下舍入的版本(667k)。
有沒有辦法在Gauge圖表上只顯示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>'
}
}]
}));
使用此代碼顯示精確金額的最小值和最大值。
yAxis: {
min: 0,
max: 2602,
tickPositioner: function() {
return [this.min, this.max];
}
將endOnTick:false ( http://api.highcharts.com/highcharts#yAxis.endOnTick )添加到您的軸。 例如
yAxis: {
min: 0,
max: 666772,
title: {
text: 'Quarter 1'
},
endOnTick:false
}
我發現還有另一種方法可以做到這一點。 如果用tickAmount: 2,
替換tickPixelInterval: 400,
那么它將僅顯示最小值和最大值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.