Javascript examples for Chart.js:Line Chart
missing data points in line chart
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w . jav a 2 s. c om var config = { type: 'line', data: { labels: ['Jan\n2018', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], datasets: [{ label: 'Red', borderColor: '#FF0000', backgroundColor: '#FF0000', data: [ 10, 20, 30, 40, 50, 60, undefined, 80, 90, 100, 90, 80 ], }, { label: 'Blue', borderColor: '#0000FF', backgroundColor: '#0000FF', data: [ 10, 20, undefined, 40, 50, 60, 70, 80, 92, undefined, 90, 80 ], }] }, options: { spanGaps: true, responsive: true, maintainAspectRatio: false, title: { display: true, text: 'Chart.js Line Chart - Stacked Area' }, tooltips: { mode: 'index', }, hover: { mode: 'index' }, scales: { xAxes: [{ scaleLabel: { display: true, labelString: 'Month' } }], yAxes: [{ stacked: true, scaleLabel: { display: true, labelString: 'Value' } }] } } }; var ctx1 = document.getElementById('canvas').getContext('2d'); var myChart = new Chart(ctx1, config); $("#on").on("click", function() { myChart.options.spanGaps=true; myChart.update(); }); $("#off").on("click", function() { myChart.options.spanGaps=false; myChart.update(); }); }); </script> </head> <body> <div style="width:100%; height:300px"> <canvas id="canvas" style="width:100%; height:300px"></canvas> </div> <button id="on"> Span Gaps=true </button> <button id="off"> Span Gaps=false </button> </body> </html>