hendry
hendry

Reputation: 10833

Gnuplot HTML canvas to static page with zoom

My goal is to get an interactive gnuplot where you can zoom into a time range like that upon http://gnuplot.info/demo_canvas_5.2/

HTML canvas zoom

gnuplot> set terminal canvas
Terminal type is now 'canvas'
Options are ' rounded size 600,400 enhanced fsize 10 lw 1 fontscale 1 standalone'
gnuplot> set output 'output.html'
gnuplot> plot [0:25] sin(x)
gnuplot>
[hendry@t480s c]$ grep .js output.html
<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
<script src="/usr/share/gnuplot/5.4/js/canvastext.js"></script>
<script src="/usr/share/gnuplot/5.4/js/gnuplot_common.js"></script>
<script src="/usr/share/gnuplot/5.4/js/gnuplot_dashedlines.js"></script>
// short forms of commands provided by gnuplot_common.js
<link type="text/css" href="/usr/share/gnuplot/5.4/js/gnuplot_mouse.css" rel="stylesheet">

On my local gnuplot 5.4 patchlevel 0 it references local js, so I need to rewrite that and it doesn't have the zoom buttons (no table id="gnuplot_mousebox"). Am I missing a trick to get a more encapsulated / Web ready version of canvas like the demo http://gnuplot.info/demo_canvas_5.2/ ?

Upvotes: 2

Views: 776

Answers (1)

Ethan
Ethan

Reputation: 15118

Not sure what you mean by "it references local js". If you mean the URLs in the <script src=foo> elements point to local files, that can be changed by using the terminal option jsdir. For example if you are creating files to publish on "https://gnuplot.hendry.org" then you would use something like

 set term canvas standalone mousing jsdir "https://gnuplot.hendry.org"

The demo is just that, a demo, not a toolkit. You are welcome to copy the html fragment defining that mousebox element, or create your own. It's in the gnuplot distribution package.

https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/demo/html/mousebox.template

Edit: From help set term canvas

 The default `standalone` mode creates an html page containing javascript
 code that renders the plot using the HTML 5 canvas element.  The html page
 links to two required javascript files 'canvastext.js' and 'gnuplot_common.js'.
 An additional file 'gnuplot_dashedlines.js' is needed to support dashed lines.
 By default these point to local files, on unix-like systems usually in
 directory /usr/local/share/gnuplot/<version>/js.  See installation notes for
 other platforms. You can change this by using the `jsdir` option to specify
 either a different local directory or a general URL.  The latter is usually
 appropriate if the plot is exported for viewing on remote client machines.

 All plots produced by the canvas terminal are mouseable.  The additional
 keyword `mousing` causes the `standalone` mode to add a mouse-tracking box
 underneath the plot. It also adds a link to a javascript file
 'gnuplot_mouse.js' and to a stylesheet for the mouse box 'gnuplot_mouse.css'
 in the same local or URL directory as 'canvastext.js'.

Upvotes: 3

Related Questions