예에서 데이터는 무작위로 생성됩니다. 버튼을 클릭 한 후 확대/축소 유형을 변경해야합니다. 새가 생성되지 않고하이 차트 - 한 차트에서 다른 차트로 데이터 다시 쓰기
$(function() {
var chartOptions={
chart:{
zoomType : 'x',
events : {
load : function() {
var series = this.series[0];
var chart = this;
setInterval(function() {
var x = (new Date()).getTime(),
y = Math.round(Math.random() * 100);
series.addPoint([x, y]);
chart.redraw();
}, 1000);
}
}
},
series : [{
name : 'AAPL',
data : [null]
}]
};
$('#container').highcharts('StockChart', chartOptions);
$('#button').click(function() {
var chart1 = $('#container').highcharts();
//alert(chart1.series[0].yData);
chartOptions.chart.zoomType = 'y';
$('#container').highcharts(chartOptions);
});
});
은 클릭 버튼 한 후, 기존의 차트가 사라집니다. 방화범은 TypeError: e is undefined
이고 줄은 series.addPoint([x, y]);
입니다. series is undefined
입니다.
chartOptions
은 클릭 처리기에서 전역이므로 한 속성 (zoomType)이 변경되고 나머지는 동일해야합니다.
alert(chart1.series[0].yData);
은 올바른 데이터를 보여줍니다. 그래서 시도 :
$('#button').click(function() {
var chart1 = $('#container').highcharts();
//alert(chart1.series[0].yData);
chartOptions.chart.zoomType = 'y';
var chart2 = $('#container').highcharts(chartOptions);
chart2.series[0].setData(chart1.series[0].data);
chart2.redraw();
});
그런 다음 불을 지르고는 chart2.series is undefined
을 보여줍니다
답장을 보내 주셔서 감사합니다. 불행히도, 나는 여전히 첫 번째 차트에서 두 번째 차트로 데이터를 다시 쓰는 방법을 모른다. 이 시도는 http://pastebin.com/GnMn0JZc 많은 오류를 가져옵니다. 그래도'chart2.series is undefinded','series is undefinded' 등이있다. 이상한, 행 번호 34 없이도,이 예제가 작동하지만 작동하지 않습니다 ... – LancerX