#1220 Canvas: Always clear before plotting



using the canvas terminal, the plot is redrawn on every mouseover event without clearing the canvas.

This can be seen best with transparency, e.g. third example on http://gnuplot.sourceforge.net/demo_canvas_4.7/circles.html:

On every mouseover (leave the canvas area with the mouse and enter again), the circles get darker.

The attached patch fixes this.

Maybe this could be improved, so that the plot must not be redrawn every time (or is there a reason for this?)


1 Attachments


  • Ethan Merritt

    Ethan Merritt - 2013-03-13

    There are reasons for the current behaviors, but it could all be done more cleverly.

    1) The reason for redrawing a plot on mouse-over is that there may be multiple plots displayed on the page but only one of them is "active". When the mouse enters one of the plots, that plot becomes active and the tracking variables are reset to appropriate values by re-executing the corresponding javascript commands. This could probably be avoided by keeping track of the most recent active plot, and skipping re-execution if it is the same as the plot that received the mouse-over event. A more substantial re-write would keep separate tracking variables (including zoom state) for each plot on the page, and have the mouse-over event swap recover the variables from the saved state.

    2) If we clear the canvas before each redraw then any previous annotations (e.g. coordinates from left mouse-click) are lost. Currently annotations are drawn once but not stored. A possible modification would be to save them in some persistent structure. Another possibility would be to clear by default, but disable subsequent clears if and only if there is an annotation event.

  • fergus101

    fergus101 - 2013-04-12

    Another related issue would be that the mouse has to "enter" the plot for the plot to get active (in multiplot case). If mouse "sits" over plot1 and another plot is loaded later, mouse has to be moved off plot1 and then back on the plot1 else second plot remains active.

  • Ethan Merritt

    Ethan Merritt - 2013-05-07
    • status: open --> open-fixed
  • Ethan Merritt

    Ethan Merritt - 2013-05-07

    The first fix above is now in CVS. The plot canvas is not redrawn on mouseover if the mouse has not visited a different plot canvas since leaving. This preserves transparency, annotations, and zoom state.

  • Ethan Merritt

    Ethan Merritt - 2013-05-20
    • status: open-fixed --> closed-fixed

Log in to post a comment.