Ted Roper

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromTed Roper
ToMe
Subjectmultigraph updating
Date20 February 2005 16:37
I want to create a web page with more than one Multigraph.  It is a demo
showing a small pump system with levels and pressures changing.

my problem is trying to update the Multigraph without rewriting everything.
Can i update one chart without updating everything else?

<script type="text/javascript" language="javascript1.2">
   function setData() {
       var val = Math.random()*100;
       val = Math.round(val);
       window.status='val='+val;
       //var g1 = new MWJ_graph(40,100,MWJ_bar,false,false);
       g1.addDataSet('#000099','Blue title',[val]);
       //g1.buildGraph();
       window.setTimeout("setData()", 2000)
   }
</script>

I tried various versions of this script, and nothing seems to work.  It
updating one chart possible?
tks,
Ted Roper
FromMe
ToTed Roper
SubjectRe: multigraph updating
Date20 February 2005 21:16
Ted,

The multigraphs are a bit rigid in their design. Once they have been
written, they do not like to change (Otherwise the entire graph would have
to cope with scale changes, etc., and I have not written this functionality
into the script).

It is possible to put the graph in a page in an iframe, and reload that
page with the new data. Something like:
document.getElementById('firstIframe').src = 'graphPage.html?newData='+data;
And the graphPage.html could use my 'Get' method variable reader to read
that new data, and use it in the multigraph script:
http://www.howtocreate.co.uk/jslibs/locvar.js

Other than that, the script could be rewritten, by setting a global
variable to '' at the start of the drawing function, and then replace every
document.write
with
yourVaiable +=

Then at the end of the function, you can use:
document.getElementById('someDiv').innerHTML = yourVariable;

That would rewrite it dynamically. It's a bit of work though ...


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.