moritz / svg-plot

Various plot types with SVG output, with Perl 6
Artistic License 2.0
13 stars 5 forks source link

bundled examples generate only svg header line, no drawing #8

Closed nd3i closed 8 years ago

nd3i commented 8 years ago

The two examples bundled with SVG::Plot, run under current Rakudo (2016.03-113-g37857b2) generate only the svg header element and no drawing elements.

$ perl6 circle.pl
<svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="250" />

I asked for help on reddit; https://www.reddit.com/r/perl6/comments/4e133o/problem_using_svgplot/?sort=old There are links to more details in this thread: https://www.reddit.com/r/perl6/comments/4e133o/problem_using_svgplot/d1wrz35

It seems that SVG::Plot is generating a couple of bare lists in the output data structure, which leads to XML::Writer ignoring everything but the top svg => [ ] pair. /u/raiph suggested this may have happened with the GLR.

nd3i commented 8 years ago

Here's a patch showing the changes that work for me.

I've no idea if this is right; I only got here through trial-and-error. But the examples seem to be working.

flatten_diff.txt

niner commented 8 years ago

Your changes look entirely reasonable to me. Can you create a pull request please?

MasterDuke17 commented 8 years ago

If I specify :full I get no body, but the height and width are set, if I specify :!full I get a body, but the height and width aren't set. I also had to make a change to SVG (https://github.com/moritz/svg/issues/1), I don't know if they're related.

MasterDuke17 commented 8 years ago

For example, using the same example/circle.pl.

unmodified:

perl6 circle.pl 
# <svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="250" />

adding :!full to the plot() call:

perl6 circle.pl
# Method 'key' not found for invocant of class 'Array'
  in method serialize at /usr/share/perl6/vendor/sources/A82811D3E34196F12B956F15901F062744206B18 (SVG) line 12
  in block <unit> at circle.pl line 12
perl6 --version
# This is Rakudo version 2016.07.1 built on MoarVM version 2016.07
implementing Perl 6.c.
Xliff commented 8 years ago

This patch should allow the payload XML properly display. This also looks to eliminate the error regarding "method 'key' not found...", however I'm not sure if the output is valid.

Cheers!

plot_patch.txt

Xliff commented 8 years ago

Looks like nd3i beat me to the punch a while ago, however I did not notice his changes in a recently cloned version of the code.

If you need me to update things and submit a PR, please let me know.

moritz commented 8 years ago

@Xliff as on issue #10, please make a PR or push directly. Thanks!

MasterDuke17 commented 8 years ago

@Xliff++ Thanks, that patch worked. I plan to release a version of Benchable soon that uses all Perl 6 modules and SVG::Plot was the last thing I was waiting for.

Xliff commented 8 years ago

Excellent! Glad I could help. Looking forward to seeing what you have in Benchable.