How can I implement the thousands separator shown last year into the latest build? Thanks!
You can vote for #438 and then use the template field as a function that will produce the necessary output.
:+1: #438 is merged and released so you should be able to do this.
Something like this should do the trick:
scaleLabel: function(label){return label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}
Is that possible to have a thousands separator for the tooltips as well?
// String - Template string for single tooltips
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",
// String - Template string for single tooltips
multiTooltipTemplate: "<%= value %>",
BTW: The comment above multiTooltipTemplate says: "Template string for single tooltips" here: http://www.chartjs.org/docs/#getting-started-global-chart-configuration
got it:
Chart.defaults.global.multiTooltipTemplate = function(label){
return label.datasetLabel + ': ' + label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
};
here's the final example including thousands separators for tooltips: http://jsbin.com/jihadu/1/edit?html,js,output
+1
+1
I'm using Angular Chart.js (Anyway; it's Chart.js) here is how I thousand separate the tooltip number:
$scope.chartOption = {
tooltips: {
enabled: true,
callbacks: {
label: function (tooltipItems, data) {
return data.datasets[tooltipItems.datasetIndex].label + ' : ' + tooltipItems.yLabel.toLocaleString();
}
}
}
}
got it:
Chart.defaults.global.multiTooltipTemplate = function(label){
return label.datasetLabel + ': ' + label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
};
Only your solution works for me, thanks dude
Most helpful comment
I'm using Angular Chart.js (Anyway; it's Chart.js) here is how I thousand separate the tooltip number: