Menu

#516 Canvas terminal not fully functional

None
open
nobody
None
None
2020-11-21
2020-11-20
MBaz
No

When saving a plot with the canvas terminal, some of the functionality of the mousing interface seems to be missing. In particular, zooming and mouse tracking works, as well as the zoom restore/zoom reset buttons. However, the grid button and the plot on/off buttons do not seem to be functional.

To reproduce, run these commands (I tested on gnuplot 5.4 on Linux and on Firefox 82.0.2):

set terminal canvas mousing
set output 'canvastest.html'
plot sin(x)
set output

and open the file canvastest.html in a web browser. Click on the grid button and the plot on/off button; in my case, they have no effect.

I have compared the code in gnuplot's canvas demo pages with the code produced by gnuplot, and they seem to be different. I have posted some of my findings after poking around the javascript code and mousing css here: https://groups.google.com/g/comp.graphics.apps.gnuplot/c/XCBWLhUu8sU

Discussion

  • Ethan Merritt

    Ethan Merritt - 2020-11-20

    I will try to find time to respond at more length later, perhaps after moving this to Feature Requests. Just quickly:

    The toggles can only toggle things that are actually in the plot. So the ① button can only toggle a "plot 1" if it is there and is the sort of plot that can be toggled. That includes pretty much everything in a 2D plot but only some variants of graphs created with splot.

    1) For me your simple example does produce an html file containing a plot that can be toggled by clicking on the ① symbol (tested with Chrome). I did nothing special, so I don't have any suggestions as to what might not be working for you. Did you try turning on the debugging dashboard in your browser? It might show error messages or let you trace the mouse events.

    2) The grid widget can only toggle a grid if there is one in the plot. So add a "set grid" to your commands and it should work. There probably should be some option to say "add a grid but start with it toggled off", but there isn't. That could be a feature request.

    There are a lot of things that could be improved for the canvas terminal. It was written back when HTML5 was still being developed, and was at the time limited by lack of support in the standard for such things as text rendering (D'oh!). Since then of course the standard and browsers that implement have added lots of features, not least of which is letting the browser render the text. Gnuplot's canvas driver should be extended or rewritten from scratch to take advantage. It would make a great relatively self-contained project for someone who is interested in contributing to gnuplot.

     
  • Ethan Merritt

    Ethan Merritt - 2020-11-21

    Ticket moved from /p/gnuplot/bugs/2367/

    Can't be converted:

    • _milestone:
    • _priority:
     
  • MBaz

    MBaz - 2020-11-21

    Ethan, thank you for your reply. I have had a chance to run more tests, both in Firefox and in Chromium. I can toggle the plots now; I don't know what I was doing wrong before. These are my conclusions and feature requests:

    • Documentation: The mousebox appears to the left of the plot, not the bottom, as stated in the documentation.

    • Documentation: State that the # button is only active if set grid has been issued.

    • Feature request: add a configuration option to the canvas terminal to place the mousebox at the bottom. Some environments, such as interactive notebooks (like Jupyter), which is my use case for the canvas terminal, are narrow, and placing the mousebox on the bottom would allow the plot itself to be wider and thus easier to read.

    • Feature request: make the # button always active, even if no set grid command has been issued. This would make the behavior consistent with other terminals, such as qt.

    • Minor feature request: the plot toggle button appears as 1, not ①, both in Chrome and Firefox. Maybe I am missing some particular font?

    I wish I knew HTML and javascript better, because I'd love to be able to contribute these features.

     

Log in to post a comment.