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