Menu

#1340 svg viewbox and hypertext labels

None
closed-out-of-date
nobody
None
2016-05-21
2014-02-24
Anonymous
No

Currenty hypertext labels can be cut off, if they are too close to the border. See this example

set terminal svg mouse jsdir 'http://gnuplot.sourceforge.net/demo_hypertext/'
set output 'file\example.svg'
plot '-' using 1:2:3 with labels hypertext point pt 8
0 1 "Sometext"
1 2 "Somelongtext"
e

The label "Somelongtext" can only be seen partially, since the resulting svg-File contains the the viewbox parameter

< svg  onload="if (typeof(gnuplot_svg)!='undefined') gnuplot_svg.Init(evt)" 
 width="600" height="480"
 viewBox="0 0 600 480"
 xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink" >

If the viewBox is not set, the label "Somelongtext" can be read fully. I don't know why the viewBox is set, but at least in this context, I would suggest to ommit the viewBox.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2014-02-28

    I have modified gnuplot_svg.js so that the hypertext box "bounces" off the bottom of the plot area. Doing the same for the right margin should be possible but requires a bunch of extra bookkeeping. You can see it here:
    http://gnuplot.sourceforge.net/demo_svg_4.7/hypertext.html

    At least in the context of using a web browser to view the svg plot, modifying the viewBox does not help. The plot area is still bounded by the width and height properties.

     
  • Ethan Merritt

    Ethan Merritt - 2014-02-28
    • status: open --> pending
     
  • Ethan Merritt

    Ethan Merritt - 2014-03-02

    Now bounces off both the bottom and the right edge.

     
    • Mark

      Mark - 2014-03-12

      Thanks for the great work! Can you tell me where you put the javascript-File? This one http://gnuplot.sourceforge.net/demo_svg_4.7/gnuplot_svg.js only bounces only off the bottom.

       
      • Ethan Merritt

        Ethan Merritt - 2014-03-12
         
        • Mark

          Mark - 2014-03-12

          There seems to be an issue with that if there are more lines in the hypertext box. Line 2 is indentend by one space, line 3 by two spaces, ...

           
          • Ethan Merritt

            Ethan Merritt - 2014-03-13

            Hmm. It works just fine here when viewed in the chrome browser.

            But firefox seems to get the text width wrong, which could lead to alignment problems as well as an incorrect box size.

            What browser are you using? Is it possible to get a screenshot that show the incorrect display?

             
            • Mark

              Mark - 2014-03-13

              I just tested the update you made and now everything works fine. (by the way, I did use Google Chrome too when the bug occured)

               
              • Mark

                Mark - 2014-03-13

                and would it be possible to highlight the point just in the linked example or should I open a separate feature-request?

                 
  • Ethan Merritt

    Ethan Merritt - 2014-03-02
    • status: pending --> closed-fixed
     
  • Ethan Merritt

    Ethan Merritt - 2014-03-13
    • status: closed-fixed --> open-works-for-me
     
  • Ethan Merritt

    Ethan Merritt - 2014-03-13
    • status: open-works-for-me --> closed-fixed
     
  • Mark

    Mark - 2015-05-27

    The left alignment currently does not work (IE, Firefox or Chrome), the second line is offset by a whole line to the right, the third line is offset by two lines. Some update of http://gnuplot.cvs.sourceforge.net/viewvc/gnuplot/gnuplot/term/js/gnuplot_svg.js must have caused this problem, since everything was working fine so far.

     
  • Mark

    Mark - 2015-05-27

    The problem seems to be related to this line in the gnuplot_svg.js

    if (typeof tspan_element == tspan')

    when I remove it, everything works fine.

     
  • Mark

    Mark - 2015-05-27
    • status: closed-fixed --> open
    • Group: -->
    • Priority: 5 -->
     
  • Ethan Merritt

    Ethan Merritt - 2015-05-27

    I can't reproduce the problem. Could you attach a link to a document that shows the error?

    FWIW the line that you quote above contains an error (missing quote) that is not in the original source file. Could it have gotten corrupted somehow?

     
  • Mark

    Mark - 2015-05-27

    The missing quote was just a copy and paste error, sorry about that. I uploaded a file to pastebin, I hope this helps http://pastebin.com/CbUsCa7G The mouseover has 3 lines, only the first is aligned well

     
  • Ethan Merritt

    Ethan Merritt - 2015-05-28

    I am guessing that the problem is a mismatch between the code produced by gnuplot version 4.7, which is what your file says it was created with, and the gnuplot_svg.js mousing code from version 5.1 (current cvs), which is what the file links to. But it's only a guess.

    I'm not seeing any problem with svg files produced by 5.1 and linked to the mousing script for 5.1

     
  • Mark

    Mark - 2015-05-29

    I just updated to latest official release 5.00 (gp500-win64-mingw) und the error still occurs. I would like to test version 5.1 but I don't know where to download the binaries for windows.

     
  • Mark

    Mark - 2015-05-29

    Maybe this gnuplot-code reproduces the error in your environment?

    set ylabel 'A'
    set grid
    set xlabel 'B'
    set encoding iso_8859_1
    set title 'some words'
    set key horizontal box center top
    set term svg size 1280,600 name '' mouse jsdir 'http://gnuplot.cvs.sourceforge.net/viewvc/gnuplot/gnuplot/term/js/' lw 1.5 font 'Arial,18'
    set output 'test.svg'
    plot '-' using 1:2 with lines lt 2 lw 0.5 lc rgb 'red' title 'Test', '-' using 1:2:3 with labels hypertext point pt 5 ps 0.5 lw 0.5 lc rgb 'red' title '' ;
    0.0 11.8 " Capacity: 1 \n name: B" 
    e
    0.0 11.8 " Capacity: 1 \n name: B" 
    e
    
     
  • Ethan Merritt

    Ethan Merritt - 2015-05-30

    Yes. That test code reproduces the error. And as you say, removing the test for (typeof tspan_element == 'tspan') makes it work again.

    So color me confused. I don't really have time right now to track down the history of that test and sort out what the proper fix is, but for now I will comment out that test line in the CVS version.

     
  • Ethan Merritt

    Ethan Merritt - 2016-05-21
    • status: open --> closed-out-of-date
     

Log in to post a comment.