栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

Highcharts 多个Y轴动态刷新数据的实现代码

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Highcharts 多个Y轴动态刷新数据的实现代码

效果图:

js代码:

$(function() {
  $(document).ready(function() {
    Highcharts.setOptions({
      global: {
 useUTC: false
      }
    });
    var chart;
    chart = new Highcharts.Chart({
      chart: {
 renderTo: 'container',
 type: 'spline',
 animation: Highcharts.svg,
 // don't animate in old IE 
 marginRight: 10,
 events: {
   load: function() {}
 }
      },
      title: {
 text: 'Live random data'
      },
      xAxis: {
 type: 'datetime',
 tickPixelInterval: 150
      },
      yAxis: [{
 title: {
   text: 'Value'
 },
 plotLines: [{
   value: 0,
   width: 1,
   color: '#808080'
 }]
      },
      {
 title: {
   text: 'Name'
 },
 plotLines: [{
   value: 0,
   width: 1,
   color: '#808080'
 }]
      }],
      tooltip: {
 formatter: function() {
   return '' + this.series.name + '
' + Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '
' + Highcharts.numberFormat(this.y, 2); } }, legend: { enabled: false }, exporting: { enabled: false }, series: [{ name: 'Random data', data: (function() { // generate an array of random data var data = [], time = (new Date()).getTime(), i; for (i = -19; i <= 0; i++) { data.push({ x: time + i * 1000, y: Math.random() }); } return data; })() }, { name: 'Random data', data: (function() { // generate an array of random data var data = [], time = (new Date()).getTime(), i; for (i = -19; i <= 0; i++) { data.push({ x: time + i * 1000, y: Math.random() }); } return data; })() }] }); // set up the updating of the chart each second var series = chart.series[0]; var series1 = chart.series[1]; setInterval(function() { var x = (new Date()).getTime(), // current time y = Math.random(); series.addPoint([x, y + 1], true, true); series1.addPoint([x, y - 1], true, true); }, 1000); }); });

html代码:


 
 
 
 


 

以上这篇Highcharts 多个Y轴动态刷新数据的实现代码 就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/96636.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号