Highcharts选项不起作用 [英] Highcharts Options not working
问题描述
plotOptions:{
heatmap:{
nullColor:'#3bd268',
tooltip:{
valueDecimals:2,
},
},
}
您可以将工具提示返回为小数点后两位:
tooltip:{
formatter:function(){
return'< b>'+ this.series.xAxis.categories [this.point.x] + < / b个已售出< b>'+
this.point.value.toFixed(2)+'< / b> < br>< b>'+ this.series.yAxis.categories [this.point.y] +'< / b>';
$ b 至于你的数据,我可能会分配数据先到变量,然后遍历它,检测它是否是 string
。然后,您可以为其分配 null
以使其正常工作。
您也可以在此实例中修正小数点,如果您愿意的话。
myData = [
[
[0,1,aa],
[0,2,8],
[0,3,24],
[ 0,4,67],
[1,0,92],
[1,1,58] .....
........... .....
(var key in myData){
if(myData.hasOwnProperty(key)){
if(typeof(myData [key] [2] )=='string')
myData [key] [2] = null;
}
}
......
系列:[{
名称:'每位员工的销售额',
borderWidth:1,
data:myData,//< - 在此添加myData
dataLabels:{
启用:true,
颜色:'black',
style:{
textShadow:'none',
HcTextStroke:null
}
}
}]
演示: http:// jsfiddle .net / robschmuecker / 548DQ / 1 /
So, I have got this code, and when the cell value is NaN (Not a number), it is showed with the black colour, not with this one, and the tooltip with all the decimals. What am I missing?
plotOptions: {
heatmap: {
nullColor: '#3bd268',
tooltip: {
valueDecimals: 2,
},
},
}
解决方案 You can return the tooltip down to say 2 decimal points as such:
tooltip: {
formatter: function () {
return '<b>' + this.series.xAxis.categories[this.point.x] + '</b> sold <br><b>' +
this.point.value.toFixed(2) + '</b> items on <br><b>' + this.series.yAxis.categories[this.point.y] + '</b>';
}
}
As for your data, I would perhaps assign the data to variable first and then iterate over it detecting if it is a string
. Then you can assign a null
to it to make it work correctly.
You could also in this instance fix the decimals if you so wished.
myData = [
[0, 0, 10.873453],
[0, 1, "aa"],
[0, 2, 8],
[0, 3, 24],
[0, 4, 67],
[1, 0, 92],
[1, 1, 58] .....
................
for (var key in myData) {
if (myData.hasOwnProperty(key)) {
if(typeof (myData[key][2]) == 'string')
myData[key][2] = null;
}
}
......
series: [{
name: 'Sales per employee',
borderWidth: 1,
data: myData, // <-- Add myData here
dataLabels: {
enabled: true,
color: 'black',
style: {
textShadow: 'none',
HcTextStroke: null
}
}
}]
Demo: http://jsfiddle.net/robschmuecker/548DQ/1/
这篇关于Highcharts选项不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!