本文整理汇总了Python中pygal.Bar.render_to_file方法的典型用法代码示例。如果您正苦于以下问题:Python Bar.render_to_file方法的具体用法?Python Bar.render_to_file怎么用?Python Bar.render_to_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygal.Bar
的用法示例。
在下文中一共展示了Bar.render_to_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getBar
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import render_to_file [as 别名]
def getBar(self):
from pygal import Bar
path = os.path.join(base_path, 'pygal_js', 'javascripts', 'bar', 'bar_chart.svg')
config.width = 500
config.height = 400
bar_chart = Bar(config, width=400, height=300, legend_box_size=10)
bar_chart.add('Fibonacci', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) # Add some values
bar_chart.render_to_file(path)
#fileio = StringIO()
#im.save(fileio, 'svg')
##im.save('img.gif', 'gif')
#im.show()
#return ''.join(char), fileio
return os.path.join(SVG_PATH, 'bar', 'bar_chart.svg')
示例2: get
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import render_to_file [as 别名]
def get(self):
from pygal import Bar
path = os.path.join(base_path, 'pygal_js', 'javascripts', 'bar', 'bar_chart.svg')
config.width = 500
config.height = 400
#bar_chart = Bar(config, width=400, height=300, legend_box_size=10)
args = self.args
for k, v in args.items():
if v.isdigit():
args[k] = int(v)
bar_chart = Bar(config, **args)
data = self.args.get("data", "")
x_labels = self.args.get("x_labels", "")
bar_chart.add('Fibonacci', [int(i) for i in data.split(",")]) # Add some values
bar_chart.x_labels = x_labels.split(",")
bar_chart.render_to_file(path)
#fileio = StringIO()
#im.save(fileio, 'svg')
##im.save('img.gif', 'gif')
#im.show()
#return ''.join(char), fileio
return self.write(simplejson.dumps({"data":os.path.join(SVG_PATH, 'bar', 'bar_chart.svg')}))
示例3: int
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import render_to_file [as 别名]
"""Determine a value based on its percentage."""
p_index = int(p * len(x))
return str(sorted(x)[p_index])
##############
# Dispersion #
##############
def data_range(x):
return str(max(x) - min(x))
# Execute tests and save the results.
with open('data.txt', 'w') as f:
f.write('Two D6 Analysis')
f.write('\nMean result: ' + mean(results))
f.write('\nMedian result: ' + median(results))
f.write('\nQuantile result: ' + quantile(results, .90))
f.write('\nData Range: ' + data_range(results))
# Visualize the results.
hist = Bar()
hist.title = 'Results of rolling 2d6 1,000,000 times.'
hist.x_labels = [i for i in range(2, die1.num_sides * 2 + 1)]
hist.x_title = 'Result'
hist.y_title = 'Frequency of Result'
hist.add('2d6', frequencies)
hist.render_to_file('test.svg')