当前位置: 首页>>代码示例>>Python>>正文


Python Bar.render_to_file方法代码示例

本文整理汇总了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')
开发者ID:finalbattle,项目名称:echo-static,代码行数:17,代码来源:bar.py

示例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')}))
开发者ID:finalbattle,项目名称:echo-static,代码行数:25,代码来源:bar.py

示例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')
开发者ID:aFraley,项目名称:d6_prob,代码行数:32,代码来源:analyze.py


注:本文中的pygal.Bar.render_to_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。