ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 动态实时数据 * 载入数据 ~~~ <script type="text/javascript" src="{relative_root}jquery/jquery-1.12.4.min.js"></script> <script type="text/javascript" src="{relative_root}highcharts/highcharts.js"></script> ~~~ * 承载容器 ~~~ <div id="container" style="height:600px;"></div> ~~~ * 调起js ~~~ var para = {}; para.global = {useUTC: false}; Highcharts.setOptions(para); var json = {}; json.chart = { type: 'spline', events: { load: function () { var series = this.series[0], chart = this; setInterval(function () { var x = (new Date()).getTime(), // 当前时间 y = 1; // 随机值 series.addPoint([x, y], true, true); }, 3000); } } }; json.title = {text: '动态模拟实时数据'}; json.xAxis = {type: 'datetime', tickPixelInterval: 150}; json.yAxis = {title: {text: null}}; json.tooltip = { formatter: function () { return '<b>' + this.series.name + '</b><br/>' + Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) + '<br/>' + Highcharts.numberFormat(this.y, 2); } }; json.legend = {enabled: false}; json.series = [{ name: '随机数据', data: (function () { // 生成随机值 var data = [],time = (new Date()).getTime(),i; for (i = 0; i <= 10; i ++) { data.push({ x: time + i * 1000, y: i }); } return data; }()) }]; $('#container').highcharts(json); ~~~