我很感激这方面的任何帮助。
我需要做的是每次向其中添加一些数据时刷新/更改实时图表的背景图像。实时数据部分工作正常。
我试过“chart.plotBGImage.attr({href: 'xxx'});” 方法,但我收到一个错误:“无法读取未定义的属性 'plotBGImage'”。
关于什么是错的或不同的方法的任何想法?
到目前为止,这是我的代码:
<script type="text/javascript">
var chart1;
function requestData() {
$.ajax({
url: 'get_data/getECGdata.php',
success: function(point) {
var series1 = chart1.series[0],
shift = series1.data.length > 20;
// add the point
chart1.series[0].addPoint(eval(point), true, shift);
//The line below is the one giving the error
//this.chart1.plotBGImage.attr({href: "http://www.highcharts.com/images/stories/logohighcharts.png"});
// call it again after one/two/etc seconds
setTimeout(requestData, 1000);
},
cache: false
});
}
$(document).ready(function() {
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'x',
backgroundColor:'rgba(255, 255, 255, 0.4)',
defaultSeriesType: 'line',
marginTop: 60,
events: {load: requestData}
},
title: {text: 'Live ECG data'},
xAxis: {type: 'datetime', tickPixelInterval: 150, maxZoom: 20 * 1000},
yAxis: {minPadding: 0.2, maxPadding: 0.2, title: {text:'ECG reading', margin: 20 } },
tooltip: {xDateFormat: '%H:%M:%S', shared: true},
credits: {enabled: false},
series: [
{name: 'ECG', color: 'green', data: [] }
]
});
});
</script>