You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a example in spark-line documentation that, shows mouse hover data. since mouse hover is possible then, there is a possibilities to use spark-line for real time data visualization given that data comes from json API and the API gives only one value at a time not data array.
For example, if you call the API in time, t -and receive 10 after in time (t+1) it gives 12 again in time (t+2) it gives 20 and so on...
How to to visualize these data in spark-line with animation (like mouse hover example)
The text was updated successfully, but these errors were encountered:
Mohammadsalahuddin
changed the title
Real tilme data plotting with animation (similar to mouse hover)
Real time data plotting with animation (similar to mouse hover)
Mar 5, 2017
functiondrawMouseSpeedDemo(){varmrefreshinterval=500;// update display every 500msvarlastmousex=-1;varlastmousey=-1;varlastmousetime;varmousetravel=0;varmpoints=[];varmpoints_max=30;$('html').mousemove(function(e){varmousex=e.pageX;varmousey=e.pageY;if(lastmousex>-1){mousetravel+=Math.max(Math.abs(mousex-lastmousex),Math.abs(mousey-lastmousey));}lastmousex=mousex;lastmousey=mousey;});varmdraw=function(){varmd=newDate();vartimenow=md.getTime();if(lastmousetime&&lastmousetime!=timenow){varpps=Math.round(mousetravel/(timenow-lastmousetime)*1000);mpoints.push(pps);if(mpoints.length>mpoints_max)mpoints.splice(0,1);mousetravel=0;$('#mousespeed').sparkline(mpoints,{width: mpoints.length*2,tooltipSuffix: ' pixels per second'});}lastmousetime=timenow;setTimeout(mdraw,mrefreshinterval);}// We could use setInterval instead, but I prefer to do it this waysetTimeout(mdraw,mrefreshinterval);
mpoints is array to show data.
sparkline is redrawed everytime.
In this example, when you move your mouse, mousemove event is triggered.
and when mpoint's last time and now time is different, they push now mousespeed data to `mpoints' then redraw.
if mpoints length is too long(above mpoints_max), old data is spliced.
to make your idea possible, I think you can use this demo, setInterval, ajax.
hope this helps.
There is a example in spark-line documentation that, shows mouse hover data. since mouse hover is possible then, there is a possibilities to use spark-line for real time data visualization given that data comes from json API and the API gives only one value at a time not data array.
For example, if you call the API in time, t -and receive 10 after in time (t+1) it gives 12 again in time (t+2) it gives 20 and so on...
How to to visualize these data in spark-line with animation (like mouse hover example)
The text was updated successfully, but these errors were encountered: