无法在热图上设置值的格式

问题描述 投票:1回答:2

我正在使用highcharts来创建热图。我想在热图上使用%符号作为后缀。这是片段:

series: [{
            name: 'Sales per employee',
            borderWidth: 1,
            data: [[0,0,10],[0,1,19],[0,2,8],[0,3,24],[0,4,67],[1,0,92],[1,1,58],[1,2,78],[1,3,117],[1,4,48]],
            dataLabels: {
                enabled: true,
                color: 'black',
                format: '{value}%',
            }
        }]

{value}%没有工作,因为价值似乎是空的。如果我将其更改为{y}%它会起作用,除非它使用热图的y值(而不是该位置的实际值)。我应该使用dataLabels以外的东西吗?

javascript highcharts highmaps
2个回答
1
投票

您应该使用formatter选项:

dataLabels: {
    enabled: true,
    color: 'black',
    //format: '{value} %',
    formatter: function(){
         return this.point.value + ' %';
     }
}

Fiddle


0
投票

为了使它工作使用{point.value}%而不是{value}%

dataLabels: {
  enabled: true,
  format: '{point.value}%'  
}

现场演示:http://jsfiddle.net/kkulig/0k0hc3j5/

© www.soinside.com 2019 - 2024. All rights reserved.