New Visualisation Widget - Smoothie realtime

Hey Guys, I just spent a bit of time putting together a new widget using the Smoothie charts api (http://smoothiecharts.org/). 

It seems to work really well, you can see some pictures below:

 

It also works really well on iPhone and other mobile browsers..

 

Just a note to view it on the iPhone full screen you must first visit the page in safari, then add the page to your home screen, then the next time you open it (from the home screen) it will be shown in full screen mode.

 

To install it add the smoothie.php file to your emoncms3/Vis/ Folder then you can either view it directly with:

http://YOURSERVER/emoncms3/Vis/smoothie?feedid=1&feedid2=2&apikey=APIKEY...

Where feedid and feedid2 are the ID for the two feeds you want to graph (the second one being optional) and ufac being the "update factor" or basically the delay for the graph so it seems like its showing in real time (it builds up in this example 20 seconds of data then starts showing it to you).

I also put another little html page together so i can browse to it easily showing the page in an iframe, its in the attachments as s.php you can also put this in the /Vis/ directory or anywhere else just make sure you set the src correctly for the iframe, or put it in your dashboard with:

<iframe style="width: 100%; height: 100%; overflow: margin: 0px;" src="smoothie.php?
       apikey=APIKEY&feedid=9&ufac=23000">
 </iframe>
 
You must also have the smoothie.js file and put it in the /Vis/ folder with everything else.
I've uploaded a slightly modified version (just changed line 44 from true to false) so that the graph doesn't keep re-adjusting the window.
 
Also make sure you remove the _.txt from the three files in the attachments when you put them on your server. (forum file uploader doesnt like .php and .js files)
 
 
Please feel free to play around and fix up my very rushed code! 
AttachmentSize
smoothie.php_.txt3.54 KB
s.php_.txt915 bytes
smoothie.js_.txt12.06 KB
TrystanLea's picture

Re: New Visualisation Widget - Smoothie realtime

Wow, very nice! will try it out thanks a lot!

Larsjo's picture

Re: New Visualisation Widget - Smoothie realtime

Looks nice, will have a go on it.

Thx for the work.

__________________________

cant get it to work.

I put in my APIkey (read) and my feedid

Get at fine scrolling black box, but no data.

 

 

<iframe style="width: 917px; height: 400px; overflow: margin: 2px;" src="http://(mypath)/smoothie/smoothie.php?
       apikey=f19a2cceacf6f7c5021a11dae45f842c&amp;feedid=3&amp;feedid2=4&amp;ufac=23000">
 </iframe>
 
 
Any help ?
 
Shervanator's picture

Re: New Visualisation Widget - Smoothie realtime

Ah i see whats wrong, if you want to put it in a smoothie folder within the Vis folder (so: /Vis/smoothie/ which is probably a better idea) then use this new version of the smoothie.php

(I changed line 13 to be 'Vis/smoothie', '', $_SERVER['SCRIPT_NAME']))."/";). 

AttachmentSize
smoothie.php_.txt 3.55 KB
Larsjo's picture

Re: New Visualisation Widget - Smoothie realtime

I dont think its the path thats the problem, because i get a black scrolling layout. Just missing the data from the feed.

Even when i change the php to point direct to my paht, there is still no feeds.

Shervanator's picture

Re: New Visualisation Widget - Smoothie realtime

Basically what you want your $path variable to be set to for your project is http://juelsminde.org/sol/ 

This line should have got that for you:

$path = dirname("http://".$_SERVER['HTTP_HOST'].str_replace('Vis/smoothie', '', $_SERVER['SCRIPT_NAME']))."/";

You could try commenting out lines 14 and 15 (with // put in front of it) so the stuff above (since its split over two lines). 
And then set:
 
$path = "http://juelsminde.org/sol/";
 
see if that fixes it

 

Larsjo's picture

Re: New Visualisation Widget - Smoothie realtime

hehe, just found out that i had to wait for the graph to show, 20 sec is a long time. and when ever i press F5 gess i have to wait again.

 

Sorry...

PeterN's picture

Re: New Visualisation Widget - Smoothie realtime

Nice addition Shervin thanks. Looks great, very clean.

I also agree 20 seconds is a very long time even when expecting it.

Cheers

TrystanLea's picture

Re: New Visualisation Widget - Smoothie realtime

Hello Shervin, I've added it to the emoncms github repo exactly as you detail above. its really great, thanks a lot!