我有一个函数可以调用Json Response并在Google Plots中绘制数据...我每隔90秒执行一次这个功能,所以它用最新数据更新我的图表....
这很好但无论什么时候它处理它似乎锁定浏览器短暂几秒钟(甚至加载器冻结)我没关系,如果图形部分冻结但我不希望加载器或其他项目冻结我想要的UI在图表更新时仍能正常工作.
有人可以帮助我,也许我应该改变$ .ajax
这是代码:
function UpdateCharts() {
clearInterval(timerId);
BuildLineChart('power-chart', $('#datePower').val(), '1,28,32');
BuildLineChart('voltagecurrent-chart', currentDate, '13,15,17,5,7,9');
BuildLineChart('phasekw-chart', currentDate, '2,3,4');
BuildLineChart('phasevoltage-chart', currentDate, '13,15,17');
BuildLineChart('phasecurrent-chart', currentDate, '5,7,9,11');
timerId = setInterval(UpdateCharts, 90000);
}
// document ready function
$(document).ready(function() {
setTimeout(UpdateCharts, 5000);
});
Run Code Online (Sandbox Code Playgroud)
构建折线图然后执行此操作:
function onDataReceived(seriesData) {
var p = $.plot(placeholder, seriesData.seriesData, options);
}
$.ajax({
url: '/Charts/LineChart?SeriesToGraph=' + dataPoints + '&DatePull=' + chartDate,
method: 'GET',
async: false,
cache: true,
dataType: 'json',
beforeSend: function() {
$("." + placeHold + "-loader").html('<img src="/Assets/images/loaders/circular/066.gif" />');
},
complete: function() {
$("." + placeHold + "-loader").html('');
},
success: onDataReceived
});
Run Code Online (Sandbox Code Playgroud)