我使用的是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> 非常感谢你,雷迪
发布于 2014-02-13 00:22:30
您的图表看起来工作正常。如果你正在谈论的是IE7/8 (我不需要测试),我建议你也试着改变你的计时器,简单地刷新页面-首先,试着把时间间隔改为5000。
https://stackoverflow.com/questions/21727957
复制相似问题