Highstocks动态图 - 时间戳图模式问题

时间:2017-08-31 10:44:59

标签: highcharts highstock

我正在使用Highstocks动态图表,其时间滑块类似于 here

Highcharts.setOptions({
    global: {
        useUTC: false
    }
});

// Create the chart
Highcharts.stockChart('container', {
    chart: {
        events: {
            load: function () {

                // set up the updating of the chart each second
                var series = this.series[0];
                setInterval(function () {
                    var x = (new Date()).getTime(), // current time
                        y = Math.round(Math.random() * 100);
                    series.addPoint([x, y], true, true);
                }, 1000);
            }
        }
    },

    rangeSelector: {
        buttons: [{
            count: 1,
            type: 'minute',
            text: '1M'
        }, {
            count: 5,
            type: 'minute',
            text: '5M'
        }, {
            type: 'all',
            text: 'All'
        }],
        inputEnabled: false,
        selected: 0
    },

    title: {
        text: 'Live random data'
    },

    exporting: {
        enabled: false
    },

    series: [{
        name: 'Random data',
        data: (function () {
            // generate an array of random data
            var data = [],
                time = (new Date()).getTime(),
                i;

            for (i = -999; i <= 0; i += 1) {
                data.push([
                    time + i * 1000,
                    Math.round(Math.random() * 100)
                ]);
            }
            return data;
        }())
    }]
});
<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>

我唯一的区别是我可以在图表中有1到n个行,这些行将在特定时间段后继续更新。现在我的问题是

  1. 虽然我在顶部绘制了多个折线图,但我在时间滑块内的图表底部只看到一个折线图。它是预期的还是时间滑块也应该具有与图形顶部相同数量的图形?
  2. 图表底部时间滑块内的折线图表示什么?我无法看到底部图形的模式与我的任何顶部图形模式相似。高图表是否采用了所有顶部图形的并集,然后构造了一个单一的底部图形模式,或者是否存在底部时间滑块图形模式的任何其他逻辑。请解释。
  3. 提前致谢!

2 个答案:

答案 0 :(得分:0)

我试图创建问题

对于上述问题1和2,将由navigator

解决
plotOptions: {
        series: {
            showInNavigator: true
        }
    },

使用showInNavigator: true

在导航器中可以看到每个折线图

Highcharts.setOptions({
  global: {
    useUTC: false
  }
});

// Create the chart
Highcharts.stockChart('container', {
  chart: {
    events: {
      load: function() {

        // set up the updating of the chart each second
        var series = this.series[0];
        var series1 = this.series[1];
        setInterval(function() {
          var x = (new Date()).getTime(), // current time
            y1 = Math.round(Math.random() * 10),
            y2 = Math.round(Math.random() * 100);
          series.addPoint([x, y1], true, true);
          series1.addPoint([x, y2], true, true);
        }, 1000);
      }
    }
  },

  rangeSelector: {
    buttons: [{
      count: 1,
      type: 'minute',
      text: '1M'
    }, {
      count: 5,
      type: 'minute',
      text: '5M'
    }, {
      type: 'all',
      text: 'All'
    }],
    inputEnabled: false,
    selected: 0
  },

  title: {
    text: 'Live random data'
  },

  exporting: {
    enabled: false
  },
  plotOptions: {
    series: {
      showInNavigator: true
    }
  },

  series: [{
    name: 'Random data',
    data: (function() {
      // generate an array of random data
      var data = [],
        time = (new Date()).getTime(),
        i;

      for (i = -999; i <= 0; i += 1) {
        data.push([
          time + i * 1000,
          Math.round(Math.random() * 10)
        ]);
      }
      return data;
    }())
  }, {
    name: 'Random data1',
    data: (function() {
      // generate an array of random data
      var data = [],
        time = (new Date()).getTime(),
        i;

      for (i = -999; i <= 0; i += 1) {
        data.push([
          time + i * 1000,
          Math.round(Math.random() * 100)
        ]);
      }
      return data;
    }())
  }]
});
<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>

对于我看不到底部图形的模式类似于我的任何顶部图形模式,是的它几乎相同,因为导航器中实际图形的小尺寸

答案 1 :(得分:0)

  1. 您可以在每个系列中设置showInNavigator属性。

  2. 在Highstock中,除非您使用navigator.series.dataGrouping.enabled禁用dataGrouping,否则将在导航器系列中启用dataGrouping。此外,导航器显示整个范围,因此当它显示全范围时,将其与主系列进行比较。

  3. 示例:
    http://jsfiddle.net/pgr1st89/ - 使用showInNavigator
    http://jsfiddle.net/vomu0xug/ - 禁用数据分组并显示整个范围