Javascript examples for Chart.js:Bar Chart
Customizing tooltip on chart.js bar chart
<html lang="en"> <head> <title>Chart.js Bar Chart Custom Tooltip</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <style> body{/* w ww . ja v a 2 s . co m*/ background-color: #333; } #barChart{ background-color: aliceblue; border-radius: 6px; } </style> </head> <body translate="no"> <div class="container"> <br> <div class="row"> <div class="col-md-1"></div> <div class="col-md-10"> <canvas id="barChart"></canvas> </div> <div class="col-md-1"></div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script> <script> var canvas = document.getElementById("barChart"); var ctx = canvas.getContext('2d'); Chart.defaults.global.defaultFontColor = 'dodgerblue'; Chart.defaults.global.defaultFontSize = 16; var data = { labels: ["Vanilla", "Chocolate", "Strawberry"], datasets: [ { label: "Ice Cream Prices ", fill: true, backgroundColor: [ 'moccasin', 'saddlebrown', 'lightpink'], data: [11, 9, 4] } ] }; var options = { tooltips: { callbacks: { label: function(tooltipItem) { return "$" + Number(tooltipItem.yLabel) + " and so worth it !"; } } }, title: { display: true, text: 'Ice Cream Truck', position: 'bottom' }, scales: { yAxes: [{ ticks: { beginAtZero:true } }] } }; var myBarChart = new Chart(ctx, { type: 'bar', data: data, options: options }); </script> </body> </html>