在c3.js中将百分比量表更改为精确值 [英] Change % gauge chart to exact value in c3.js
本文介绍了在c3.js中将百分比量表更改为精确值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更改计量表的单位。我不想显示默认的%值,而是要显示确切的值。我在文档中寻找了该值,但是它不完整,我不确定应该在代码中添加哪个值来对其进行更改。
I am trying to change the units of a gauge chart. Instead of showing the % value by default, I would like to show the exact value. I looked for that in the documentation but it is incomplete and I am not sure which value I should put in the code to change it.
var chart = c3.generate({
bindto: "#chart",
data: {
columns: [
['data', 15.0]
],
type: 'gauge',
},
gauge: {
min: 50,
max: 100,
units: '%' //I want to change that
}
});
推荐答案
我正在回答自己。要获取准确值而不是量规表中的%1,必须添加以下行:
I am answering myself. To get the exact value and not the % one in a gauge chart, it is necessary to add this lines:
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
}
});
这篇关于在c3.js中将百分比量表更改为精确值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文