[英]pygal charts line up horizontally
I am trying to get my pygal.SolidGauge charts to line up in a horizontal line like this: charts in horizontal row 我试图让我的pygal.SolidGauge图表排成一条水平线,如下所示: 水平行中的图表
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 我使用的是Python 3.5.1,这是我的代码
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()
most likely the charts are being rendered in <div>
elements 最有可能的图表是在<div>
元素中呈现的
by default, <div>
elements have display: block;
默认情况下, <div>
元素有display: block;
and will stack vertically 并将垂直堆叠
to test, add the following css to the page 要测试,请将以下css添加到页面中
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, eg 如果是这样,删除测试并将类名添加到图表容器中,例如
html HTML
<div class="chart"></div>
then add css for class 然后为课程添加CSS
css CSS
.chart {
display: inline-block;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.