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! 
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']))."/";). 

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!

aniston's picture

Re: New Visualisation Widget - Smoothie realtime

Hello, I'm trying to use this Visualization Widget but keep getting the same problem as mentioned above ie: only the scrolling background with no graphic display.

$path is working well as i made a check to display it on the same page and it was correct.

An I waited well over 20 seconds to see if i get a display refresh but that too does not help I tried setting a couple of values for ufac like 100, 1000, 10000, 20000 but still no graph just the same black background with scrolling grey lines.

Any help will be appreciated.

regards,

aniston

raulzanardo's picture

Re: New Visualisation Widget - Smoothie realtime

I'm having the same problem here.

No data display on the graph.

But the plugin (smoothie.js) is working fine with the example from the site (http://smoothiecharts.org/).

 

aniston's picture

Re: New Visualisation Widget - Smoothie realtime

Just an update,

using FireFox and (F12) Firebug console, I noticed that there is no data in the array (attached screenshot)

HTH to find out where we are going wrong.

thankx.

raulzanardo's picture

Re: New Visualisation Widget - Smoothie realtime

Just found the problem.

The function "vis_feed_data" is using the address wrong in the array.

 

        function vis_feed_data(apikey,feedid,start,end,line,oldref)
        {
            $.ajax({
            url: path+'feed/data.json',
            data: "&apikey="+apikey+"&id="+feedid+"&start="+start+"&end="+end+"&dp=0",

            
            dataType: 'json',
            success: function(data)
            {
                var prev;
                if (oldref == 0)
                prev = old;
                else
                prev = old1;

                if (data[0] != undefined && data[0][1] != prev)
                {
                line.append(new Date().getTime(), data[0][1]);
                if (oldref == 0)
                    old = data[0][1];
                else
                    old1 = data[0][1];
                }
            }
            });
        }

 

 

This should solve the problem, because the return of the value in the json part of the function is [[time, value]]. So the address should be 0 for the first and 1 for the second.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.