Does anyone know if I can use the High Charts
speed o meter with Ajax calls? I was thinking in the following function putting the call in where I point out. But I know sometimes this types of graphs, charts, meters
don't like Ajax calls.
// Add some life
function (chart) {
setInterval(function () {
var point = chart.series[0].points[0],
newVal,
inc = **Ajax call here**;
newVal = point.y + inc;
if (newVal < 0 || newVal > 20) {
newVal = point.y - inc;
}
point.update(newVal);
}, 3000);
In fact I really don't need an Ajax call within the function. I just need an Ajax call to the server, check to see if it's 'squaking
' if it is use a Boolean set that to true and then use a random number between say 1-20
, and if it's not just set the function to output 0;.
It's essentially a bandwidth meter so to speak, I'm just wondering if it's possible with this meter before I spend 5 hours on it for nothing if it's not possible. Can anyone give suggestions?
Here is the meter in JSFiddle where I'm currently messing around with it.
Certainly you can
setInterval(function () {
var point = chart.series[0].points[0],
newVal,
inc = 0;
$.get('squaking', function (data) {
newVal = point.y + data.inc;
if (newVal < 0 || newVal > 20) {
newVal = point.y - data.inc;
}
point.update(newVal);
});
}, 3000);
I'm assuming here that "squaking" is a server side function that returns a JSON result containing a value for inc. Once the data is returned, the chart is then updated.