Javascript examples for highcharts:Line Chart
connectNulls with dotted line for line chart
<html> <head> <title>HC connectNull Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> var data = [4, 5, 1, null, 3, 4, null, 1, 5, null,4]; $(function () {/*from www . j a v a2s. com*/ $('#container').highcharts({ title: { text: 'LineWithNulls' }, subtitle: { text: 'How can I connect the the line in a different color or with a dotted line' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], }, series: [{ data: data , connectNulls: false }] }); var chart = $('#container').highcharts(); var plotLeft = chart.plotLeft; var plotTop = chart.plotTop; for(var i=0;i<data.length;i++){ var path = []; if(data[i] == null){ var p1 = chart.series[0].points[i-1], p2 = chart.series[0].points[i+1]; p2 = p2 == undefined ? p1 : p2; path.push('M'); path.push(p1.plotX+plotLeft, p1.plotY+plotTop); path.push('L'); path.push(p2.plotX+plotLeft, p2.plotY+plotTop); } var line = chart.renderer.path(path) .attr({ 'stroke-width': 2, stroke: Highcharts.getOptions().colors[0], dashstyle: 'ShortDash' }) .add(); } }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 400px; max-width: 800px; margin: 0 auto"></div> </body> </html>