Change% gauge chart to exact value in c3.js

I am trying to change the units of a calibration chart. Instead of showing the default% value, I would like to show the exact value. I've looked for this in the documentation, but it's incomplete and I'm not sure what value I have to 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
}
});

      

+3


source to share


1 answer


I answer myself. To get the exact value and not the% in the calibration chart, add the following 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
    }
});

      

+13


source







All Articles