Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HTML5 Canvas element in Google Chrome

1,655 views
Skip to first unread message

Alex van der Spek

unread,
Feb 16, 2010, 6:30:21 AM2/16/10
to
This is what I do:

set out 'tst.html'
set term canvas
plot sin(x)
set out win
replot

The last two lines are (apparently) necessary to close the html file.

In Google Chrome (my default browser), on Windows Vista, loads the file but
shows an empty frame when I click in the page. Inspection of the source file
shows, at the bottom of the file.

<div class="gnuplot">
<table class="plot">
<tr><td>
<canvas id="gnuplot_canvas" width="600" height="400" tabindex="0">
Sorry, your browser seems not to support the HTML 5 canvas element
</canvas>
</td></tr>
</table>
</div>
</body>
</html>

Somehow there appears to be a remnant if IE7 floating around and gnuplot
thinks the canvas element is not supported. Does that mean the plot is not
produced in Google Chrome? What can I do to resolve this? I am not even sure
if it is a gnuplot issue or a Vista issue although I would not be surprised
if it is the latter.

I tried the canvas example page
(http://gnuplot.sourceforge.net/demo_canvas/) This seems to work fine,
showing it is not Chrome causing the issue.

Regards,
Alex van der Spek

sfeam

unread,
Feb 16, 2010, 1:36:14 PM2/16/10
to

The plots on the demo page were produced by gnuplot, so it seems there
is no fundamental problem.

You don't give a complete description of what you did, but two things
occur to me:

1) if you are trying to make a stand-alone HTML document you need to say
so when you select the terminal:

set term canvas standalone

Otherwise the output is suitable for embedding in a web page, but you need
to construct that web page using some additional script or tool.

2) the gnuplot output relies on being able to load shared javascript
modules. So you need to make sure that they are indeed loadable from
the URL in the plot document. Please read the output from
help set term canvas

Alex van der Spek

unread,
Feb 16, 2010, 4:49:48 PM2/16/10
to
Thank you, I def will have to polish up on my HTML. One thing I did note,
however, the page source has lines like:

<script src="C:\Users\ZDoor\gnuplot\share/js/gnuplot_common.js"></script>

All lines containing either 'src' or 'href' tags have forward slashes around
js. This looks alien to me. Manually changing this to backslashes does not
produce the desired result.

Adding standalone and mousing to set:

set term canvas standalone mousing

This adds on the page the mouse coordinate table (empty) and it adds place
holders (empty) for the menu bar items as shown on gnuplot.info pages for
the canvas element. Nothing is plotted though. I looks like I am not quite
getting it yet. I read the README, but am still puzzled.

Regards,
Alex van der Spek

"sfeam" <sf...@users.sourceforge.net> wrote in message
news:hleoj0$i8m$1...@news.eternal-september.org...

sfeam

unread,
Feb 16, 2010, 7:05:44 PM2/16/10
to
Alex van der Spek wrote:

> Thank you, I def will have to polish up on my HTML. One thing I did note,
> however, the page source has lines like:
>
> <script src="C:\Users\ZDoor\gnuplot\share/js/gnuplot_common.js"></script>
>
> All lines containing either 'src' or 'href' tags have forward slashes
> around js. This looks alien to me. Manually changing this to backslashes
> does not produce the desired result.

The built-in default is set at the time gnuplot is built from source.
I assume yours is a build for Windows, and someone set the default
directory tree to C:\Users\ZDoor\gnuplot\share

[warning: I will now describe what happens in the current CVS version
and the upcoming version 4.4.0. If your executable is older, it may
behave slightly differently.]

You can change this either by setting the environmental variable
GNUPLOT_JS_DIR or by specifying a directory when you initialize the
terminal:
set term canvas jsdir 'http://myserver/directory/for/javascripts'

In all cases the URL must be one that your browser can read.
NB: Gnuplot does not have to access this directory!
It is the user's browser that needs to look here.
Of course, you have to make sure that the files have been placed in
that directory. This is obviously a separate operation, especially
if the directory is on a different machine that is acting as your
web server.

Ethan

Alex van der Spek

unread,
Feb 17, 2010, 12:58:23 PM2/17/10
to
Thanks Ethan,

The strange thing is that I am using a testing binary. I did not built this
from source, not did anyone else. Somehow it picks up the fact that gnuplot
is installed in C:\Users\ZDoor\gnuplot. This is where the bin directory
resides.

I will continue trying with your latest tips.

Alex


"sfeam" <sf...@users.sourceforge.net> wrote in message

news:hlfbsr$kvn$1...@news.eternal-september.org...

Alex van der Spek

unread,
Apr 15, 2010, 8:13:30 AM4/15/10
to
This works fine now!

the jsdir needs to be specified with forward slashes like this:

set terminal canvas standalone mousing size 600,400 fsize 10 lw 1 jsdir
"C:/Users/ZDoor/gnuplot/binary/share/gnuplot/4.4/js"

Not with backslashes as is customary on Windows.

I do not know if this has anything to do with it but I moved to using
gnuplot 4.4.0, binaries on Windows.

Alex van der Spek

"Alex van der Spek" <zd...@xs4all.nl> wrote in message
news:4b7c2e46$0$22916$e4fe...@news.xs4all.nl...

0 new messages