Javascript examples for Chart.js:Chart Tooltip
Show all values in Chart.js doughnut chart tooltip
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w .j a v a 2 s . c o m var chartColors = { red: 'rgb(255, 99, 132)', orange: 'rgb(255, 159, 64)', yellow: 'rgb(255, 205, 86)', green: 'rgb(75, 192, 192)', blue: 'rgb(54, 162, 235)', purple: 'rgb(153, 102, 255)', grey: 'rgb(231,233,237)' }; var randomScalingFactor = function() { return Math.round(Math.random() * 100); }; var ctx = document.getElementById("chart-area").getContext("2d"); var myPie = new Chart(ctx, { type: 'doughnut', data: { labels: ['blue', 'red', 'green', 'orange'], datasets: [{ label: 'Dataset 1', data: [ randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), ], backgroundColor: [ chartColors.blue, chartColors.red, chartColors.green, chartColors.orange ], }], }, options: { tooltips: { mode: "dataset" } } }); } </script> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> <div id="canvas-holder" style="width:80%"> <canvas id="chart-area"></canvas> </div> </body> </html>