简体   繁体   English

如何只刷新网页上的饼图?

[英]How to refresh only pie chart on the webpage?

this is my code: 这是我的代码:

<script>
var myVar=setInterval(function(){myTimer()},10000);

function myTimer() {
document.getElementById("show").innerHTML = "hello";
}
</script>
<div id="show">
        <canvas id="chart-area2" width="300" height="300"/>
    </div>

The above displays piechart for 10 seconds and then replaces the piechart with 'hello'. 上面显示饼图10秒钟,然后将饼图替换为“ hello”。 In the place of 'hello' how can i make the piechart display again? 代替“你好”,我该如何再次显示饼图? Will this code refresh the div every 10 seconds? 这段代码会每10秒刷新一次div吗? if not then what are the changes i have to do? 如果不是,那我需要做些什么改变?

the div tag displays the pie chart on the browser. div标签在浏览器上显示饼图。

<script>
    var myVar=setInterval(function(){myTimer()},10000);

    function myTimer() {
        var ctx2 = document.getElementById("chart-area2").getContext("2d"); 
        var pieData2 = ... //You can use AJAX to load new data from the server if you want
        var myPie2 = new Chart(ctx2).Pie(pieData2);
    }
</script>
<div id="show">
    <canvas id="chart-area2" width="300" height="300"/>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM