Browse Source

Merge all css in one tag as a workaround for inkscape one style tag bug. Fixes #7

pull/35/merge
Florian Mounier 12 years ago
parent
commit
133df7ab07
  1. 2
      demo/moulinrouge/__init__.py
  2. 2
      pygal/css/base.css
  3. 6
      pygal/svg.py

2
demo/moulinrouge/__init__.py

@ -96,7 +96,7 @@ def create_app():
@app.route("/sparkline/<style>") @app.route("/sparkline/<style>")
def sparkline(style): def sparkline(style):
line = pygal.Line(style=styles[style]) line = pygal.Line(style=styles[style], pretty_print=True)
line.add('_', [random.randrange(0, 10) for _ in range(25)]) line.add('_', [random.randrange(0, 10) for _ in range(25)])
return Response( return Response(
line.render_sparkline(height=40), mimetype='image/svg+xml') line.render_sparkline(height=40), mimetype='image/svg+xml')

2
pygal/css/base.css

@ -18,7 +18,7 @@
* along with pygal. If not, see <http://www.gnu.org/licenses/>. * along with pygal. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* /*
* Font-sizes from config, override with care * Font-sizes from config, override with care
*/ */

6
pygal/svg.py

@ -60,6 +60,7 @@ class Svg(object):
def add_styles(self): def add_styles(self):
"""Add the css to the svg""" """Add the css to the svg"""
all_css = []
for css in ['base.css'] + list(self.graph.css): for css in ['base.css'] + list(self.graph.css):
if urlparse(css).scheme: if urlparse(css).scheme:
self.processing_instructions.append( self.processing_instructions.append(
@ -76,8 +77,9 @@ class Svg(object):
font_sizes=self.graph.font_sizes()) font_sizes=self.graph.font_sizes())
if not self.graph.pretty_print: if not self.graph.pretty_print:
css_text = minify_css(css_text) css_text = minify_css(css_text)
self.node( all_css.append(css_text)
self.defs, 'style', type='text/css').text = css_text self.node(
self.defs, 'style', type='text/css').text = '\n'.join(all_css)
def add_scripts(self): def add_scripts(self):
"""Add the js to the svg""" """Add the js to the svg"""

Loading…
Cancel
Save