score:4

Accepted answer

instead of modifying your callbacks why not using a condition inside them, testing a global variable?

for example:

tooltips: {
  mode: 'index',
  intersect: false,
  callbacks: {
    label: function (tooltipitems, data) {
      if (percent)
        return addcommas(tooltipitems.xlabel) + "%";
      else
        return addcommas(tooltipitems.xlabel);
    }
  }
},

here is a jsfiddle showing this approach: https://jsfiddle.net/beaver71/nk6rz1f3/


Related Query

More Query from same tag