如果特定日期的数据不存在,则显示空白 space

Display blank space if data is not present for a particular date

如果 Highstock 中没有这些日期的数据,我想显示空白 space。如果 11 月份的数据不存在,则该月的 Highstock 上应显示空白 space。应显示 10 月和 12 月的数据。

$(function() {

  var data = [
    /* Sep 2009 */
    [1253836800000, 26.05],
    [1254096000000, 26.59],
    [1254182400000, 26.48],
    [1254268800000, 26.48],
    /* Oct 2009 */
    [1254355200000, 25.84],
    [1254441600000, 26.41],
    [1254700800000, 26.57],
    [1254787200000, 27.14],
    [1254873600000, 27.18],
    [1254960000000, 27.04],
    [1255046400000, 27.21],
    [1255305600000, 27.26],
    [1255392000000, 27.15],
    [1255478400000, 27.33],
    [1255564800000, 27.22],
    [1255651200000, 26.86],
    [1255910400000, 27.12],
    [1255996800000, 28.39],
    [1256083200000, 29.27],
    [1256169600000, 29.31],
    [1256256000000, 29.13],
    [1256515200000, 28.93],
    [1256601600000, 28.20],
    [1256688000000, 27.49],
    [1256774400000, 28.05],
    [1256860800000, 26.93],
    /* Dec 2009 */
    [1259625600000, 28.14],
    [1259712000000, 28.03],
    [1259798400000, 28.07],
    [1259884800000, 27.62],
    [1260144000000, 26.99],
    [1260230400000, 27.12],
    [1260316800000, 28.26],
    [1260403200000, 28.06],
    [1260489600000, 27.81],
    [1260748800000, 28.14],
    [1260835200000, 27.74],
    [1260921600000, 27.86],
    [1261008000000, 27.41],
    [1261094400000, 27.92],
    [1261353600000, 28.32],
    [1261440000000, 28.62],
    [1261526400000, 28.87],
    [1261612800000, 29.86],
    [1261958400000, 30.23],
    [1262044800000, 29.87],
    [1262131200000, 30.23],
    [1262217600000, 30.10]
  ];
  /*$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
   */ // Create the chart
  $('#container').highcharts('StockChart', {
    xAxis: {
      ordinal: false
    },

    rangeSelector: {
      selected: 1
    },

    title: {
      text: 'AAPL Stock Price'
    },

    series: [{
      name: 'AAPL',
      data: data,
      tooltip: {
        valueDecimals: 2
      }
    }]
  });
});
//});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>

<div id="container" style="height: 400px; min-width: 310px"></div>

View on JSFiddle

我认为你需要尝试一下 gapSize:

Defines when to display a gap in the graph. A gap size of 5 means that if the distance between two points is greater than five times that of the two closest points, the graph will be broken.

series: [{
    name: 'AAPL',
    data: data,
    gapSize: 5,
    tooltip: {
        valueDecimals: 2
    }
}]

下面的工作示例:

$(function() {

  var data = [
    /* Sep 2009 */
    [1253836800000, 26.05],
    [1254096000000, 26.59],
    [1254182400000, 26.48],
    [1254268800000, 26.48],
    /* Oct 2009 */
    [1254355200000, 25.84],
    [1254441600000, 26.41],
    [1254700800000, 26.57],
    [1254787200000, 27.14],
    [1254873600000, 27.18],
    [1254960000000, 27.04],
    [1255046400000, 27.21],
    [1255305600000, 27.26],
    [1255392000000, 27.15],
    [1255478400000, 27.33],
    [1255564800000, 27.22],
    [1255651200000, 26.86],
    [1255910400000, 27.12],
    [1255996800000, 28.39],
    [1256083200000, 29.27],
    [1256169600000, 29.31],
    [1256256000000, 29.13],
    [1256515200000, 28.93],
    [1256601600000, 28.20],
    [1256688000000, 27.49],
    [1256774400000, 28.05],
    [1256860800000, 26.93],
    /* Dec 2009 */
    [1259625600000, 28.14],
    [1259712000000, 28.03],
    [1259798400000, 28.07],
    [1259884800000, 27.62],
    [1260144000000, 26.99],
    [1260230400000, 27.12],
    [1260316800000, 28.26],
    [1260403200000, 28.06],
    [1260489600000, 27.81],
    [1260748800000, 28.14],
    [1260835200000, 27.74],
    [1260921600000, 27.86],
    [1261008000000, 27.41],
    [1261094400000, 27.92],
    [1261353600000, 28.32],
    [1261440000000, 28.62],
    [1261526400000, 28.87],
    [1261612800000, 29.86],
    [1261958400000, 30.23],
    [1262044800000, 29.87],
    [1262131200000, 30.23],
    [1262217600000, 30.10]
  ];
  /*$.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
   */ // Create the chart
  $('#container').highcharts('StockChart', {
    xAxis: {
      ordinal: false
    },

    rangeSelector: {
      selected: 1
    },

    title: {
      text: 'AAPL Stock Price'
    },

    series: [{
      name: 'AAPL',
      data: data,
      gapSize: 5,
      tooltip: {
        valueDecimals: 2
      }
    }]
  });
});
//});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>

<div id="container" style="height: 400px; min-width: 310px"></div>

View on JSFiddle