将%规格图更改为c3.js中的精确值

die*_*opf 4 javascript c3.js

我正在尝试更改仪表图表的单位.我希望显示确切的值,而不是默认显示%值.我在文档中查找了它,但它不完整,我不确定应该在代码中添加哪个值来更改它.

var chart = c3.generate({
bindto: "#chart",
data: {
    columns: [
        ['data', 15.0]
    ],
    type: 'gauge',
},
gauge: {
    min: 50,
    max: 100,
    units: '%' //I want to change that
}
});
Run Code Online (Sandbox Code Playgroud)

die*_*opf 16

我在回答自己.要获得精确值而不是仪表图中的%,需要添加以下行:

var chart = c3.generate({
    bindto: "#chart",
    data: {
    columns: [
        ['data', 15.0]
     ],
    type: 'gauge',
    },
    gauge: {
    label:{
    format: function(value, ratio){
      return value; //returning here the value and not the ratio
      },
    },
    min: 50,
    max: 100,
    units: '%' //this is only the text for the label
    }
});
Run Code Online (Sandbox Code Playgroud)