我正在尝试使用 highchart 制作实时数据,但我厌倦了遵循文档并且不明白, 我使用ajax刷新来解决。 当页面第一次重新加载时,我的图表呈现, 当 ajax 执行刷新/2000 毫秒时,我的图表始终呈现黑色
index.php
<script type="text/javascript">
var auto_refresh = setInterval(
function () {
$('#src2').load('monitor.php').fadeIn("slow");
}, 2000); // refresh setiap 00000 milliseconds
</script>
<div id="container" style="min-width: 120px; height: 220px; margin: 0 auto"></div>
</head>
<body>
<div id="src2"></div>
Monitor.php
<script >
$(function () {
$('#container').highcharts({
title: {
text: 'Interval Chart',
x: -20 //center
},
subtitle: {
text: 'Cisco Wallboard',
x: -20
},
xAxis: {
categories: ['1', '2', '3', '4', '5', '6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24']
},
yAxis: {
title: {
text: 'Percentage (%)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '%'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'SCR',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6,7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 100]
}, {
name: 'SL',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}]
});
});
</script>
检查 Firebug , 我不知道这个错误:TypeError: ha is not a function
最佳答案
highchart动态数据更新不需要刷新整个页面,引用highcharts配置对象,只更新系列数据。
关于javascript - Highcharts 在 ajax 刷新时呈现黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26986986/