Highcharts Options not working

北战南征 提交于 2019-12-25 00:53:07

问题


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,
        },
  },
}

http://jsfiddle.net/548DQ/


回答1:


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/



来源:https://stackoverflow.com/questions/24761282/highcharts-options-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!