Page 2 of 3

Loading data into jqplot from database

Posted: Tue Jul 08, 2014 4:45 am
by Peter Castle

Got it!

First step was to bind the results to a javascript:

Image


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 4:46 am
by Peter Castle

Second step was to keep adding the results to local storage variables as each value arrives:

Image


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 4:47 am
by Peter Castle

Once this is complete. Setup the jqplot arrays:

Image


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 4:48 am
by Peter Castle

And plot away:

Image


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 4:50 am
by Peter Castle

Not sure if this is the most efficient method, but it works just fine.


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 5:44 am
by Kateryna Grynko

Hi Peter,

Thank you for sharing this!


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 5:54 am
by Peter Castle

Not a problem.

Any tips on how to refresh a jqplot graph? Each time the graph updates, it simply writes directly over the last one making a mess.

I have tried the following:

-----------------------------------------------------------------------------------------------------

var plot = JSON.parse(localStorage.getItem("plot"));

if(plot)
{
plot.destroy();
}

plot = $.jqplot(.....);

localStorage.setItem('plot', JSON.stringify(plot));

----------------------------------------------------------------------------------------------------

Unfortunately I am unable to store and retrieve the 'plot' variable in local storage between plots. Each time I try to read it back from local storage, it is clear again.


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 5:57 am
by Peter Castle

Here you can see the axis labels are messy:

Image


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 6:16 am
by Peter Castle

Maybe there is a simple way of clearing the html object?


Loading data into jqplot from database

Posted: Tue Jul 08, 2014 8:30 am
by Kateryna Grynko

Hi Peter,

Here is how to delete jqplot:
pre$("#myplot").html("");/pre