jaraco / svg.charts

SVG Charting Library for Python
MIT License
30 stars 10 forks source link

Make explicit svg height and width declaration optional #4

Closed jaraco closed 8 years ago

jaraco commented 10 years ago

Originally reported by: Oronis (Bitbucket: Oronis, GitHub: Oronis)


Add a config property for setting where to include the width and height declaration items in svg.charts.graph.start_svg().

A very simple patch (because I'm too lazy to look up etree) would be to include a class attribute explicit_size = false then in the start_svg section:

#!python

if self.explicit_size:
    self.root = etree.Element(SVG+"svg", attrib={
            'width': str(self.width),
            'height': str(self.height),
            'viewBox': '0 0 %s %s' % (self.width, self.height),
               '{http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/}scriptImplementation': 'Adobe',
            }, nsmap=NSMAP)
else:
    self.root = etree.Element(SVG+"svg", attrib={
            'viewBox': '0 0 %s %s' % (self.width, self.height),
            '{http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/}scriptImplementation': 'Adobe',
            }, nsmap=NSMAP)

jaraco commented 10 years ago

Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):


Add a hook to allow customization of attributes added to the root SVG element. Fixes #4

jaraco commented 10 years ago

Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):


Oh. I see now the code does include those attributes. You want a way to suppress them.

jaraco commented 10 years ago

Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):


Is there any reason not to include always the size attributes?