设置highstock导航数据

时间:2017-03-25 17:20:55

标签: javascript highcharts highstock

我正在使用highstock(highchart)。我需要从单独的数组中为导航栏设置数据。

我的json格式是:

[{"SensorID":2,"Temperature":34.0,"Humidity":56.0,"Carbon":87.0,"DateTime":"2017-03-08T10:07:00","ID":10},{"SensorID":2,"Temperature":34.0,"Humidity":43.0,"Carbon":87.0,"DateTime":"2017-03-09T12:00:00","ID":12},{"SensorID":2,"Temperature":23.0,"Humidity":89.0,"Carbon":65.0,"DateTime":"2017-03-09T12:00:00","ID":13},{"SensorID":2,"Temperature":34.0,"Humidity":56.0,"Carbon":87.0,"DateTime":"2017-03-08T10:07:00","ID":16},{"SensorID":2,"Temperature":87.0,"Humidity":34.0,"Carbon":23.0,"DateTime":"2017-03-08T10:07:00","ID":18},{"SensorID":2,"Temperature":44.0,"Humidity":67.0,"Carbon":43.0,"DateTime":"2017-03-08T10:07:00","ID":20},{"SensorID":2,"Temperature":100.0,"Humidity":100.0,"Carbon":100.0,"DateTime":"2017-03-08T10:07:00","ID":21},{"SensorID":2,"Temperature":70.0,"Humidity":20.0,"Carbon":50.0,"DateTime":"2017-03-08T10:07:00","ID":22}]

我将这些数据推送到不同的数组,如humidity_array,Date_array等,并将这些数组分配给一系列图表。但是如何动态地将date_array分配给highstock中的导航栏。

1 个答案:

答案 0 :(得分:1)

添加或更新为普通系列,但showInNavigator设置为truevisible设置为false。

  chart.addSeries({
    data: [4,3,2,1],
    showInNavigator: true,
    visible: false
  });

示例:http://jsfiddle.net/q8xe7qLp/