Javascript examples for Chart.js:Legend
add a legend?
<html> <head> <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.1/Chart.min.js"></script> <script type="text/javascript"> window.onload=function(){/* www. j av a 2s . co m*/ var xLabels = { 1 : 'HELLO', 2 : 'THERE', 3 : 'MY', 4 : 'FRIEND' } var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'bar', data: { labels: [1, 2, 3, 4], datasets: [{ data: [12, 19, 3, 10] }] }, options: { scales: { xAxes: [{ ticks: { callback: function (value, index, values) { return xLabels[value]; } } }] } } }); } </script> </head> <body> <canvas id="myChart" width="400" height="400"></canvas> </body> </html>