Javascript examples for Chart.js:Bar Chart
Add x axis from the line in bar line chart
<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.6.0/Chart.bundle.min.js"></script> <script type="text/javascript"> window.onload=function(){//from w w w . ja v a2 s .co m var barChartData = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: 'Dataset 1', yAxisID: "y-axis-1", data: [3,2,7,4,5,7,6] }, { type: "line", fill: false, label: 'Dataset 2', borderColor: '#faa', backgroundColor: "#faa", yAxisID: "y-axis-2", data: [11,13,21,13,16,21,18] }] }; var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx, { type: 'bar', data: barChartData, options: { responsive: true, title:{ display:true, text:"Chart.js Bar Chart - Multi Axis" }, tooltips: { mode: 'index', intersect: true }, scales: { yAxes: [{ display: true, position: "left", id: "y-axis-1", ticks: { callback: function(value, index, values) { return value + " Kg"; } } }, { display: true, position: "right", id: "y-axis-2", gridLines: { drawOnChartArea: false }, ticks: { callback: function(value, index, values) { return "? " + value; } } }], } } }); } </script> </head> <body> <div style="width: 75%"> <canvas id="canvas"></canvas> </div> </body> </html>