Show gap of missing data with Highstock chart - Javascript highcharts

Javascript examples for highcharts:Stock Chart

Description

Show gap of missing data with Highstock chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Stock Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {//from www  .j  a v a 2  s . co m
    (function (H) {
        // Wrap getSegments to change gapSize functionality to work based on time (milliseconds)
        H.wrap(H.Series.prototype, 'getSegments', function (proceed) {
            var cPR = this.xAxis.closestPointRange;
            this.xAxis.closestPointRange = 1;
            proceed.apply(this, Array.prototype.slice.call(arguments, 1));
            this.xAxis.closestPointRange = cPR;
        });
    }(Highcharts));
    $('#container').highcharts('StockChart', {
        rangeSelector: {
            selected: 1
        },
        plotOptions: {
            line: {
                gapSize: 300000 // 5 minutes in milliseconds
            }
        },
        series: [{
            name: 'USD to EUR',
            data: [
                [0,1],
                [1000,1],
                [5000,1],
                [306000,1], // Gap 5:01
                [310000,1],
                [315000,1],
                [320000,1],
                [625000,1], // Gap 5:05
                [645000,1],
            ]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px; min-width: 600px"></div> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script>  
   </body>
</html>

Related Tutorials