Javascript 剑道图不会刷新
我用的是剑道图,第一次打电话很好,但是当我打电话的时候Javascript 剑道图不会刷新,javascript,ajax,kendo-ui,Javascript,Ajax,Kendo Ui,我用的是剑道图,第一次打电话很好,但是当我打电话的时候 setInterval(getCharts,800)图表每次都会返回旧的结果。如果我刷新页面,图表将显示更新结果。我做错了什么 如果我调用$(#chartid).data('KendoChart').datasource.read()它带来错误数据源未定义 function myCallback(result) { // Code that depends on 'result' totalcountvar
setInterval(getCharts,800)代码>图表每次都会返回旧的结果。如果我刷新页面,图表将显示更新结果。我做错了什么
如果我调用$(#chartid).data('KendoChart').datasource.read()代码>它带来错误数据源未定义
function myCallback(result) {
// Code that depends on 'result'
totalcountvar = result;
return totalcountvar;
}
function foo(callback, id) {
$.ajax({
type: "POST",
url: "Data/OutageCountHandler.ashx?id=" + id,
data: "{}",
async: false,
contentType: "text/json; charset=utf-8",
dataType: "json",
success: callback
});
}
function createChart2(chartid, c_title, fieldName, q_id) {
if (q_id == 2) { foo(myCallback, 4); c_title = c_title + totalcountvar; }
if (q_id == 3) { foo(myCallback, 2); c_title = c_title + totalcountvar; }
if (q_id == 4) { foo(myCallback, 3); c_title = c_title + totalcountvar; }
var sharableDataSource = new kendo.data.DataSource({
transport: {
read: {
url: "Data/ChartDataHandler.ashx?id=" + q_id,
dataType: "json"
}
}
});
// Bind data to Chart
$("#" + chartid).kendoChart({
theme: "moonlight",
chartArea: {
width: 800,
height: 400,
},
title: {
text: c_title
},
dataSource: sharableDataSource,
series: [{
field: fieldName.replace(/\s+/g, ''),
name: fieldName,
color: "#3074D8",
noteTextField: "Type",
notes: {
icon: {
visible: false
},
line: {
length: 20,
color: "transparent"
},
label: {
field:"Type",
position: "outside"
}
}
}],
seriesDefaults: {
type: "column",
labels: {
visible: true,
background: "transparent"
}
},
categoryAxis: {
field: "Area",
},
tooltip: {
visible: true,
background: "white",
format: "{0}",
template: "#= series.name #: #= value #"
},
legend: {
position: "bottom"
}
});
}
是否执行$(#chartid).data('kendoChart').dataSource.read();work???No its会导致错误,即其undefinedSorry在jQuery选择器$('#chartid').data('kendoChart').dataSource.read()中缺少'代码>我创建了这个Dojo,它每5秒更新一次。我正在使用他们的数据,这些数据不会改变,但你至少应该看到它刷新。