1

I am trying to get my pygal.SolidGauge charts to line up in a horizontal line like this: charts in horizontal row

But I find that by default the charts are stacking up vertically like this: charts in vertical row

How can I get them to line up horizontally? I am using Python 3.5.1 and here's my code

import pygal

def create_chart():
    gauge_chart = pygal.SolidGauge(show_legend=False, inner_radius=0.70, half_pie=False)

    gauge_chart.add('Max ', [{'value': 58, 'max_value': 100}])
    gauge_chart.add('Min ', [{'value': 42, 'max_value': 100}])
    gauge_chart.add('Mean', [{'value': 28, 'max_value': 100}])

    gauge_chart.render_to_png("chart.png")


if __name__ == "__main__":
    create_chart()
bearrider
  • 172
  • 2
  • 11

1 Answers1

1

most likely the charts are being rendered in <div> elements

by default, <div> elements have display: block;
and will stack vertically

to test, add the following css to the page

div {
  display: inline-block;
}

if correct, the charts will then stack horizontally, assuming the screen is wide enough

if so, remove the test and add a class name to the chart containers, e.g.

html

<div class="chart"></div>

then add css for class

css

.chart {
  display: inline-block;
}
WhiteHat
  • 59,912
  • 7
  • 51
  • 133
  • This is to generate a PNG file to embed in a PDF, not to render in a HTML. But following your suggestion I tried adding a style to the chart as below my_style = Style(display='inline-block') and called in the the method like this : gauge_chart = pygal.SolidGauge(show_legend=False, inner_radius=0.70, half_pie=False, style=my_style) but this hasn't helped... – bearrider Feb 13 '17 at 12:00