Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a combined chart in pygal?

Tags:

python

pygal

Is it possible to create a single chart with a line series and a bar series?

chart = pygal.Line()
chart.x_labels = 'Red', 'Blue', 'Green'
chart.y_labels = .0001, .0003, .0004, .00045, .0005
chart.add('line', [.0002, .0005, .00035])
like image 351
user_78361084 Avatar asked Feb 11 '13 17:02

user_78361084


2 Answers

An answer can be found in the documentation at http://www.pygal.org/en/stable/documentation/web.html.

<!DOCTYPE html>
<html>
  <head>
    <!-- ... -->
  </head>
  <body>
    <figure>
       <embed type="image/svg+xml" src="/mysvg.svg" />
    </figure>
  </body>
</html>

Duplicating the line in the <figure> tag allows you to vertically combine your charts, aligning at the left of the screen. With CSS, and defining two figure tags you can then align horizontally the two figures.

like image 188
glihm Avatar answered Oct 03 '22 04:10

glihm


In response to your query from pygal's github issue tracker: no

https://github.com/Kozea/pygal/issues/46

like image 43
Chad Adams Avatar answered Oct 03 '22 05:10

Chad Adams