图表正在加载正常但我无法自动刷新此图表,尝试了setInterval(drawChart,10000);并没有工作。我是否将间隔放在错误的位置?函数是drawChart。
function drawChart(candlestickChartDataOptions, candlestickChartData, chart_id) {
var data = google.visualization.arrayToDataTable(candlestickChartData, true);
var options = {
chartArea: {
left: 40,
top: 20,
width: "100%",
height: "70%"
},
legend:"none",
title:candlestickChartDataOptions.currency1+" price in "+candlestickChartDataOptions.currency2,
bar: { groupWidth: "70%" ,
}, // sets space between bars
candlestick: {
fallingColor: { strokeWidth: 0, fill: "#a52714" }, // red
risingColor: { strokeWidth: 0, fill: "#0f9d58" }, // green
}
};
var chart = new google.visualization.CandlestickChart(document.getElementById(chart_id));
chart.draw(data, options);
}
jQuery( document ).ready(function() {
jQuery( "select#chart_period_'.$chart_id.'" ).change(function() {
setCandlestickPeriod(candlestickChartDataOptions_'.$chart_id.', jQuery(this).val());
candlestickLoadData(candlestickChartDataOptions_'.$chart_id.', "'.$chart_id.'");
});
drawChart();
setInterval(drawChart, 10000);
});
</script>
<div id="<?php echo $chart_id; ?>"></div>
也尝试了这个并且也没有用,$ chart_id是正确的:
<script>
setInterval(function(){
$("<?php echo $chart_id; ?>").load(document.URL + " <?php echo
$chart_id; ?>");
}, 10000)
</script>
出了什么问题?请帮助谢谢。