Here is a patch on gnuplot_svg.js to support hypertext into a dynamic svg and svg that are embedded somewhere in a html page. The original version does not convert the evt.clientX/Y location which is relative to the page to the locX/Y relative to the svg itself.
The patch only adds a few lines.
Tested on IE11 and Chrome Version 50.0.2661.94.
Thanks for the patch.
I would like to confirm that it works as intended before applying it.
Could you help me understand what is the problem it fixes? I am not aware of any errors with hypertext and dynamic svg, but it may be that I have never tested a plot that shows the error you are contending with. For example, does the on-line hypertext demo not work in your browser?
http://gnuplot.sourceforge.net/demo_svg_5.0/hypertext.html
This demo uses dynamic svg embedded in a web page and for me it works fine with the current javascript support file. The text is correctly placed after zoom/unzoom operations (<ctrl>+ / <ctrl>-) It also works with your patched version, but I would like to see a case where there the current script fails and the patched script succeeds. Do you have one?</ctrl></ctrl>
Hi Ethan,
No it does not work if I embed the svg in a html file and I resize the svg.
I attached an html file that embeds the resulting svg in a html file and a screenshot of my screen when I look at it. You will notice an offset between the mouse and the hypertext box. This is due to the position of the mouse relative to the top of the client area of the browser: The hypertext is displayed relative to the graph with the coordinates of the mouse relative to the browser client area: Not the same reference!
You have all the details of my version of gnuplot in the svg file.
Oh and is also a problem within the updateCoordBox: The coordinates are transformed ok but there is additionnal code that just undoes the transformation. I don't understand the purpose of that code but it should not be there or writen that way. (e.g. gnuplot_svg.updateCoordBox = function(t, evt)).
I attached the latest gnuplot_svg.js with all corrections.
Thank you,