0

我正在使用 RGRaph.gauge 和 .thermometer 插件。

当我第一次打开页面时,一切都正确显示。

但是,如果我将跳转到另一个页面部分然后返回该页面,则画布是空的。

刷新也不起作用。必须按 CTRL+F5 才能在没有缓存的情况下重新加载页面。

我播种可能的解决方案可能是使用,RGraph.ObjectRegistry.Clear();但我不确定何时调用它。

这是我的初始代码:

<!-- Include the RGraph libraries -->
<script src="ui/RGraph/libraries/RGraph.common.core.js" ></script>
<script src="ui/RGraph/libraries/RGraph.gauge.js" ></script>
<!--[if lt IE 9]><script src="ui/RGraph/excanvas/excanvas.js"></script><![endif]-->

脚本和DIV:

<script>
    function PRODgauge (PROD)
    {
        var gauge = new RGraph.Gauge('cvsPROD', 0,20,PROD)

        .Set('units.post', ' K')
        .Set('shadow', false)
        .Set('zoom.shadow', false) 
        .Set('zoom.fade.in', false) 
        .Set('zoom.fade.out', false) 
        .Draw();    

        var s = document.getElementById('PRODvalue');
        s.innerHTML = PROD + ' K';
    }

    function UATgauge (UAT)
    {
        var gauge = new RGraph.Gauge('cvsUAT', 0,20,UAT)

        .Set('units.post', ' K')
        .Set('shadow', false)
        .Set('zoom.shadow', false) 
        .Set('zoom.fade.in', false) 
        .Set('zoom.fade.out', false) 
        .Draw();    

        var s = document.getElementById('UATvalue');
        s.innerHTML = UAT + ' K';
    }

    window.onload = function () {           
        RGraph.AJAX.getNumber('pages/home/last_15min_PROD_data.jsp', PRODgauge);
        RGraph.AJAX.getNumber('pages/home/last_15min_UAT_data.jsp', UATgauge);
        setTimeout(window.onload, 300000);      
    }
</script>

<div id="stats-content">
 <div id="chart1" style="display: inline-block;"></div>
 <div id="chart2" style="display: inline-block;"></div>
 <div id="chart3" style="display: inline-block;"><canvas id="cvsPROD" height="200" width="200">[No canvas support]</canvas><h3 style="position: relative; text-align: center; top: -45px;">PROD</h3><h2 style="text-align: center; position: relative; top: -45px;"><span id="PRODvalue"></span>
 </div>
 <div id="chart4" style="display: inline-block;">
        <canvas id="cvsUAT" height="200" width="200">[No canvas support]</canvas>
        <h3 style="position: relative; text-align: center; top: -45px;">UAT</h3>
        <h2 style="text-align: center; position: relative; top: -45px;"><span id="UATvalue"></span>
 </div>
</div>  

非常感谢雷迪

4

1 回答 1

0

您的图表似乎工作正常。如果您正在谈论的是 IE7/8(我不必对其进行测试),我建议您也尝试更改计时器以简单地刷新页面 - 首先尝试将时间间隔更改为 5000。

于 2014-02-12T16:22:30.320 回答