pygal icon indicating copy to clipboard operation
pygal copied to clipboard

Background images for plots

Open never-eat-yellow-snow opened this issue 9 years ago • 4 comments

See also: https://github.com/Kozea/pygal/issues/216

This one also adds support for a preserve_aspect configuration for keeping the graph's aspect ratio (in case this makes sense for the graph). I didn't fiddle with the tests yet.

I also realized that this branch somehow contains the other two pull requests - this is probably because I'm new to git and done something wrong...

Anyway, please give me some feedback whether this feature has chances for the mainline or not.

never-eat-yellow-snow avatar Jun 07 '15 15:06 never-eat-yellow-snow

I am in vacation right now I'll review as soon as I come back. Cheers. (For multiple pull requests you have to create a separate branch for each)

Le dim. 7 juin 2015 11:15, never-eat-yellow-snow [email protected] a écrit :

See also: #216 https://github.com/Kozea/pygal/issues/216

This one also adds support for a preserve_aspect configuration for keeping the graph's aspect ratio (in case this makes sense for the graph). I didn't fiddle with the tests yet.

I also realized that this branch somehow contains the other two pull requests - this is probably because I'm new to git and done something wrong...

Anyway, please give me some feedback whether this feature has chances for

the mainline or not.

You can view, comment on, or merge this pull request online at:

https://github.com/Kozea/pygal/pull/219 Commit Summary

  • Remove explicit open() calls on .css and .svg map files
  • fix testcases (run on linux, python3.4 with equivalent results to master branch)
  • - fix specifying a value_formatter, needed to be excluded from the json dictionary
  • Merge pull request #1 from never-eat-yellow-snow/py2exe
  • Merge pull request #2 from never-eat-yellow-snow/pie-value-formatter
  • add possibility for background images

File Changes

  • M pygal/config.py https://github.com/Kozea/pygal/pull/219/files#diff-0 (7)
  • A pygal/css/init.py https://github.com/Kozea/pygal/pull/219/files#diff-1 (0)
  • R pygal/css/base_css.py https://github.com/Kozea/pygal/pull/219/files#diff-2 (2)
  • R pygal/css/graph_css.py https://github.com/Kozea/pygal/pull/219/files#diff-3 (2)
  • R pygal/css/style_css.py https://github.com/Kozea/pygal/pull/219/files#diff-4 (2)
  • M pygal/graph/base.py https://github.com/Kozea/pygal/pull/219/files#diff-5 (2)
  • M pygal/graph/frenchmap.py https://github.com/Kozea/pygal/pull/219/files#diff-6 (14)
  • M pygal/graph/graph.py https://github.com/Kozea/pygal/pull/219/files#diff-7 (25)
  • A pygal/graph/maps/init.py https://github.com/Kozea/pygal/pull/219/files#diff-8 (0)
  • R pygal/graph/maps/ch_cantons_svg.py https://github.com/Kozea/pygal/pull/219/files#diff-9 (3)
  • R pygal/graph/maps/fr_departments_svg.py https://github.com/Kozea/pygal/pull/219/files#diff-10 (2)
  • R pygal/graph/maps/fr_regions_svg.py https://github.com/Kozea/pygal/pull/219/files#diff-11 (2)
  • R pygal/graph/maps/worldmap_svg.py https://github.com/Kozea/pygal/pull/219/files#diff-12 (2)
  • M pygal/graph/pie.py https://github.com/Kozea/pygal/pull/219/files#diff-13 (13)
  • M pygal/graph/swissmap.py https://github.com/Kozea/pygal/pull/219/files#diff-14 (7)
  • M pygal/graph/worldmap.py https://github.com/Kozea/pygal/pull/219/files#diff-15 (7)
  • M pygal/svg.py https://github.com/Kozea/pygal/pull/219/files#diff-16 (38)
  • M pygal/view.py https://github.com/Kozea/pygal/pull/219/files#diff-17 (49)
  • M setup.py https://github.com/Kozea/pygal/pull/219/files#diff-18 (2)

Patch Links:

  • https://github.com/Kozea/pygal/pull/219.patch
  • https://github.com/Kozea/pygal/pull/219.diff

— Reply to this email directly or view it on GitHub https://github.com/Kozea/pygal/pull/219.

paradoxxxzero avatar Jun 07 '15 15:06 paradoxxxzero

I did, but I probably made the mistake to merge them all back to the master branch of my fork... Anyway I'd clean up this mess when you say that this is something you consider for the main line.

Happy holiday!

never-eat-yellow-snow avatar Jun 07 '15 20:06 never-eat-yellow-snow

So I looked into it, it may be useful to have a background image feature. This PR needs some cleaning (there's print statements for instance). Also, the preserve aspect ration seems to force a 1:1 ratio, wouldn't be better to adapt to the image ratio ?

paradoxxxzero avatar Jun 23 '15 12:06 paradoxxxzero

I'm aware of the need for the cleanup and I'll do it, if this is something you are willing to merge. I use this currently like this to create an overlay over a background image (assuming image.png has 600x400 pixels):

from pygal import XY

chart=XY(show_dots=False, 
         interpolate='hermite',
         include_x_axis=True,
         background_image="image.png",
         preserve_aspect=True,
         width = 600,
         height= 400,
         show_legend = False,
         )

chart.add('lowerleft', [(0,0)])
chart.add('upperright',[(600,400)])
chart.add('test', [(110,110), (500,300)])
out = chart.render()
open("test.svg", "wb").write(out)

You see that I have to manually add lowerleft and upperright hints to ensure the limits of the axis (maybe a seperate API would be good for that?).

never-eat-yellow-snow avatar Jun 23 '15 17:06 never-eat-yellow-snow