Javascript examples for Chart.js:Chart Configuration
Chart.js with Formatted Number Labels
<html> <head> <title>ChartJS 2.2.2 Formatting Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.2/Chart.js"></script> <script type="text/javascript"> window.onload=function(){/*from ww w . ja va 2 s . c o m*/ Chart.scaleService.updateScaleDefaults('linear', { ticks: { callback: function(tick) { return '$' + tick.toLocaleString(); } } }); Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) { var dataset = data.datasets[tooltipItem.datasetIndex]; var datasetLabel = dataset.label || ''; return datasetLabel + ": $" + dataset.data[tooltipItem.index].toLocaleString() + " - Whatever Custom"; }; var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'bar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [1000, 19000, 3100, 15000, 21000, 3000], backgroundColor: [ 'rgba(255, 99, 132, 0.4)', 'rgba(54, 162, 235, 0.4)', 'rgba(255, 206, 86, 0.4)', 'rgba(75, 192, 192, 0.4)', 'rgba(153, 102, 255, 0.4)', 'rgba(255, 159, 64, 0.4)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 2 }] } }); } </script> </head> <body> <canvas id="myChart"></canvas> </body> </html>