Javascript examples for Chart.js:Chart Tooltip
Chart.js Add Commas to Tooltip and Y-Axis
<html> <head> <title>Chart.js 2.0.0-beta Play</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www. ja va2 s. c om var ctx = document.getElementById("mybarChart"); var barChart = new Chart(ctx, { type: 'bar', data: { labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], datasets: [{ label: 'My Chart', data: [2137, 6282, 8055, 2568, 5985, 3189, 5991, 9263, 5548, 11847, 6644, 5983], backgroundColor: 'rgba(65, 142, 200, 0.2)', borderColor: 'rgba(65, 142, 200, 1)', borderWidth: 1 }], }, options: { tooltips: { callbacks: { label: function(tooltipItem, data) { var value = data.datasets[0].data[tooltipItem.index]; value = value.toString(); value = value.split(/(?=(?:...)*$)/); value = value.join(','); return value; } } }, scales: { yAxes: [{ ticks: { beginAtZero:true, userCallback: function(value, index, values) { value = value.toString(); value = value.split(/(?=(?:...)*$)/); value = value.join(','); return value; } } }], xAxes: [{ ticks: { } }] } } }); } </script> </head> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.0.0-beta2/Chart.min.js"></script> <canvas id="mybarChart" width="470" height="200"> </canvas> </body> </html>