Javascript examples for Chart.js:Chart Configuration
Chart.js uses padding to scales
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from ww w. jav a 2s.c o m*/ var ctx = document.getElementById("myChart"); var data = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [ { label: "My First dataset", fill: false, lineTension: 0.1, backgroundColor: "rgba(75,192,192,0.4)", borderColor: "rgba(75,192,192,1)", borderCapStyle: 'butt', borderDash: [], borderDashOffset: 0.0, borderJoinStyle: 'miter', pointBorderColor: "rgba(75,192,192,1)", pointBackgroundColor: "#fff", pointBorderWidth: 1, pointHoverRadius: 5, pointHoverBackgroundColor: "rgba(75,192,192,1)", pointHoverBorderColor: "rgba(220,220,220,1)", pointHoverBorderWidth: 2, pointRadius: 1, pointHitRadius: 10, data: [0, 10, 24, 64, 100, 256, 512], spanGaps: false, } ] }; var myChart = new Chart(ctx, { type: 'line', data: data, options: { scales: { yAxes: [{ ticks: { padding: 80, } }], xAxes: [{ ticks: { padding: 80 } }], } } }); } </script> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.js"></script> <canvas id="myChart" width="400" height="400"></canvas> </body> </html>