Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #1348
| From | sfeam <sfeam@users.sourceforge.net> |
|---|---|
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: Multiple canvas plots share same state variable? |
| Followup-To | comp.graphics.apps.gnuplot |
| Date | 2012-08-21 09:26 -0700 |
| Organization | gnuplot development team |
| Message-ID | <k10cr7$38f$1@dont-email.me> (permalink) |
| References | <93687e00-9428-4a48-a203-88724c19c651@googlegroups.com> |
Followups directed to: comp.graphics.apps.gnuplot
tombert wrote:
> Hi all,
>
> I wonder why the gnuplot canvas javascript are using a common static
> variable var gnuplot = { }
>
> For example in file gnuplot_common.js there is the statement
> if (gnuplot.zoomed) {
> ....
> }
>
> When I build up multiple independent plots in a single html page,
> zooming into one plot automatically zooms the other plots.
>
> Am I doing something wrong? Did I miss something?
Apparently so, because if you look at the demo plots on
http://gnuplot.sourceforge.net/demo_canvas/
you will see they do not suffer from the problem you describe.
In fact the gnuplot object you mention is there exactly for the
purpose of isolating the different plots from each other and from
any other javascript entities that might otherwise be in the same
namespace.
If you place multiple canvas elements on the same page, you must
give them distinct names. The name of the "active" canvas is loaded
into the gnuplot object when the canvas is entered, and the contents
of the object are repopulated to correspond to the new active plot.
Please read the file .../term/js/README
This does have the down-side that if the mouse later returns to a canvas
that was previously zoomed, the data structure is repopulated from
the original plot description so the previous zoom state is lost.
If saving that state is important to you, you could add a save/restore
operation to the set of actions triggered on mouse exit/entry.
You would not need to modify gnuplot itself to do this, it would
be sufficient to locally modify the script file gnuplot_mouse.js.
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar
Multiple canvas plots share same state variable? tombert <tombert.groups@live.at> - 2012-08-21 01:40 -0700
Re: Multiple canvas plots share same state variable? sfeam <sfeam@users.sourceforge.net> - 2012-08-21 09:26 -0700
Re: Multiple canvas plots share same state variable? tombert <tombert.groups@live.at> - 2012-08-22 01:49 -0700
Re: Multiple canvas plots share same state variable? sfeam <sfeam@users.sourceforge.net> - 2012-08-22 08:39 -0700
csiph-web