Javascript 使用getJSON从WebMethod Highcharts实时数据获取数据
我在下图中看到了我想从WebMethod(WebMethod在WebService中)插入数据的图表: 显然我需要使用GetJSON。。。 但是我不知道怎么。。。。Javascript 使用getJSON从WebMethod Highcharts实时数据获取数据,javascript,asp.net,web-services,highcharts,getjson,Javascript,Asp.net,Web Services,Highcharts,Getjson,我在下图中看到了我想从WebMethod(WebMethod在WebService中)插入数据的图表: 显然我需要使用GetJSON。。。 但是我不知道怎么。。。。 你能帮我举个例子吗?但你的服务回报是什么?json/xml或其他不同的东西?嗨,我的WebMethod只返回一个int-val…请通过返回的数据。 Highcharts.setOptions({ global: { useUTC: false } }); chart3 = new Highchart
你能帮我举个例子吗?但你的服务回报是什么?json/xml或其他不同的东西?嗨,我的WebMethod只返回一个int-val…请通过返回的数据。
Highcharts.setOptions({
global: {
useUTC: false
}
});
chart3 = new Highcharts.Chart({
credits: {
enabled: false
},
chart: {
renderTo: 'container3',
type: 'spline',
animation: Highcharts.svg, // ne marche pas dans les IE anciens
marginRight: 10,
events: {
load: function() {
// MAJ du chart chaque seconde
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), // temps
y = Math.random();
series.addPoint([x, y], true, true);
}, 1000);
}
}
},
title: {
text: 'test'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Random data',
data: (function() {
// generation de valeurs aléatoires
var data = [],
time = (new Date()).getTime(),
i;
function onSucess(result) {
alert(result);
}
for (i = -19; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
})()
}]
});
public int getInt()
{
val2 = rand.Next(1, 100);
return val2;
}