Javascript examples for Chart.js:Line Chart
zooming and panning option on category scales for line chart
<html lang="en"> <head> <style> .myChartDiv {// ww w. j a v a 2 s. c o m max-width: 600px; max-height: 400px; } </style> </head> <body translate="no"> <div class="myChartDiv"> <canvas id="myChart" width="600" height="400"></canvas> </div> <script src="https://npmcdn.com/chart.js@latest/dist/Chart.bundle.min.js"></script> <script src="https://npmcdn.com/Chart.Zoom.js@latest/Chart.Zoom.min.js"></script> <script> var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'line', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3] }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] }, // Container for pan options pan: { // Boolean to enable panning enabled: true, // Panning directions. Remove the appropriate direction to disable // Eg. 'y' would only allow panning in the y direction mode: 'xy' }, // Container for zoom options zoom: { // Boolean to enable zooming enabled: true, // Zooming directions. Remove the appropriate direction to disable // Eg. 'y' would only allow zooming in the y direction mode: 'xy', } } }); //# sourceURL=pen.js </script> </body> </html>