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


Python Line.render方法代码示例

本文整理汇总了Python中pygal.Line.render方法的典型用法代码示例。如果您正苦于以下问题:Python Line.render方法的具体用法?Python Line.render怎么用?Python Line.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygal.Line的用法示例。


在下文中一共展示了Line.render方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_config_alterations_kwargs

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_alterations_kwargs():
    class LineConfig(Config):
        show_legend = False
        fill = True
        pretty_print = True
        x_labels = ["a", "b", "c"]

    config = LineConfig()

    line1 = Line(config)
    line1.add("_", [1, 2, 3])
    l1 = line1.render()

    line1.stroke = False
    l1bis = line1.render()
    assert l1 != l1bis

    line2 = Line(config)
    line2.add("_", [1, 2, 3])
    l2 = line2.render()
    assert l1 == l2
    assert l1bis != l2

    line3 = Line(config, title="Title")
    line3.add("_", [1, 2, 3])
    l3 = line3.render()
    assert l3 != l2

    l2bis = line2.render()
    assert l2 == l2bis
开发者ID:Zanarh,项目名称:pygal,代码行数:32,代码来源:test_config.py

示例2: test_config_alterations_kwargs

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_alterations_kwargs():
    """Assert a config can be changed with keyword args"""

    class LineConfig(Config):
        no_prefix = True
        show_legend = False
        fill = True
        pretty_print = True
        x_labels = ['a', 'b', 'c']

    config = LineConfig()

    line1 = Line(config)
    line1.add('_', [1, 2, 3])
    l1 = line1.render()

    line1.stroke = False
    l1bis = line1.render()
    assert l1 != l1bis

    line2 = Line(config)
    line2.add('_', [1, 2, 3])
    l2 = line2.render()
    assert l1 == l2
    assert l1bis != l2

    line3 = Line(config, title='Title')
    line3.add('_', [1, 2, 3])
    l3 = line3.render()
    assert l3 != l2

    l2bis = line2.render()
    assert l2 == l2bis
开发者ID:ConnorMooreLUC,项目名称:pygal,代码行数:35,代码来源:test_config.py

示例3: test_config_behaviours

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_behaviours():
    line1 = Line()
    line1.show_legend = False
    line1.fill = True
    line1.pretty_print = True
    line1.x_labels = ['a', 'b', 'c']
    line1.add('_', [1, 2, 3])
    l1 = line1.render()

    line2 = Line(
        show_legend=False,
        fill=True,
        pretty_print=True,
        x_labels=['a', 'b', 'c'])
    line2.add('_', [1, 2, 3])
    l2 = line2.render()
    assert l1 == l2

    class LineConfig(Config):
        show_legend = False
        fill = True
        pretty_print = True
        x_labels = ['a', 'b', 'c']

    line3 = Line(LineConfig)
    line3.add('_', [1, 2, 3])
    l3 = line3.render()
    assert l1 == l3

    line4 = Line(LineConfig())
    line4.add('_', [1, 2, 3])
    l4 = line4.render()
    assert l1 == l4
开发者ID:NicholasShatokhin,项目名称:spindl,代码行数:35,代码来源:test_config.py

示例4: test_config_behaviours

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_behaviours():
    """Test that all different way to set config produce same results"""
    line1 = Line()
    line1.show_legend = False
    line1.fill = True
    line1.pretty_print = True
    line1.no_prefix = True
    line1.x_labels = ['a', 'b', 'c']
    line1.add('_', [1, 2, 3])
    l1 = line1.render()

    q = line1.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".legend")) == 0
    assert len(q(".x.axis .guides")) == 3
    assert len(q(".y.axis .guides")) == 11
    assert len(q(".dots")) == 3
    assert q(".axis.x text").map(texts) == ['a', 'b', 'c']

    line2 = Line(
        show_legend=False,
        fill=True,
        pretty_print=True,
        no_prefix=True,
        x_labels=['a', 'b', 'c'])
    line2.add('_', [1, 2, 3])
    l2 = line2.render()
    assert l1 == l2

    class LineConfig(Config):
        show_legend = False
        fill = True
        pretty_print = True
        no_prefix = True
        x_labels = ['a', 'b', 'c']

    line3 = Line(LineConfig)
    line3.add('_', [1, 2, 3])
    l3 = line3.render()
    assert l1 == l3

    line4 = Line(LineConfig())
    line4.add('_', [1, 2, 3])
    l4 = line4.render()
    assert l1 == l4

    line_config = Config()
    line_config.show_legend = False
    line_config.fill = True
    line_config.pretty_print = True
    line_config.no_prefix = True
    line_config.x_labels = ['a', 'b', 'c']

    line5 = Line(line_config)
    line5.add('_', [1, 2, 3])
    l5 = line5.render()
    assert l1 == l5
开发者ID:Frankie-666,项目名称:pygal,代码行数:61,代码来源:test_config.py

示例5: test_config_behaviours

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_behaviours():
    line1 = Line()
    line1.show_legend = False
    line1.fill = True
    line1.pretty_print = True
    line1.no_prefix = True
    line1.x_labels = ["a", "b", "c"]
    line1.add("_", [1, 2, 3])
    l1 = line1.render()

    q = line1.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".legend")) == 0
    assert len(q(".x.axis .guides")) == 3
    assert len(q(".y.axis .guides")) == 21
    assert len(q(".dots")) == 3
    assert q(".axis.x text").map(texts) == ["a", "b", "c"]

    line2 = Line(show_legend=False, fill=True, pretty_print=True, no_prefix=True, x_labels=["a", "b", "c"])
    line2.add("_", [1, 2, 3])
    l2 = line2.render()
    assert l1 == l2

    class LineConfig(Config):
        show_legend = False
        fill = True
        pretty_print = True
        no_prefix = True
        x_labels = ["a", "b", "c"]

    line3 = Line(LineConfig)
    line3.add("_", [1, 2, 3])
    l3 = line3.render()
    assert l1 == l3

    line4 = Line(LineConfig())
    line4.add("_", [1, 2, 3])
    l4 = line4.render()
    assert l1 == l4

    line_config = Config()
    line_config.show_legend = False
    line_config.fill = True
    line_config.pretty_print = True
    line_config.no_prefix = True
    line_config.x_labels = ["a", "b", "c"]

    line5 = Line(line_config)
    line5.add("_", [1, 2, 3])
    l5 = line5.render()
    assert l1 == l5
开发者ID:Cortana-,项目名称:pygal,代码行数:55,代码来源:test_config.py

示例6: test_parametric_styles_with_parameters

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_parametric_styles_with_parameters():
    """Test a parametric style with parameters"""
    line = Line(style=RotateStyle(
        '#de3804', step=12, max_=180, base_style=LightStyle))
    line.add('_', [1, 2, 3])
    line.x_labels = 'abc'
    assert line.render()
开发者ID:ConnorMooreLUC,项目名称:pygal,代码行数:9,代码来源:test_style.py

示例7: test_parametric_styles

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_parametric_styles():
    chart = None
    for style in STYLES:
        line = Line(style=style('#f4e83a'))
        line.add('_', [1, 2, 3])
        line.x_labels = 'abc'
        new_chart = line.render()
        assert chart != new_chart
        chart = new_chart
开发者ID:AlexSnet,项目名称:pygal,代码行数:11,代码来源:test_style.py

示例8: test_config_alterations_class

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_alterations_class():
    class LineConfig(Config):
        show_legend = False
        fill = True
        pretty_print = True
        x_labels = ['a', 'b', 'c']

    line1 = Line(LineConfig)
    line1.add('_', [1, 2, 3])
    l1 = line1.render()

    LineConfig.stroke = False
    line2 = Line(LineConfig)
    line2.add('_', [1, 2, 3])
    l2 = line2.render()
    assert l1 != l2

    l1bis = line1.render()
    assert l1 == l1bis
开发者ID:NicholasShatokhin,项目名称:spindl,代码行数:21,代码来源:test_config.py

示例9: test_parametric_styles

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_parametric_styles():
    """Test that no parametric produce the same result"""
    chart = None
    for style in STYLES:
        line = Line(style=style('#f4e83a'))
        line.add('_', [1, 2, 3])
        line.x_labels = 'abc'
        new_chart = line.render()
        assert chart != new_chart
        chart = new_chart
开发者ID:Kozea,项目名称:pygal,代码行数:12,代码来源:test_style.py

示例10: word_count

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def word_count(text_sample_directory):

    print "Opening '" + text_sample_directory + "'"

    # Dictionary of each word that gets encountered
    words = {}

    for text_file in os.listdir(text_sample_directory):
        with open(text_sample_directory + text_file) as f:
            sys.stdout.write(".")
            sys.stdout.flush()

            for line in f:

                line = line.lower()
                line = clean(line)

                replace_characters = '[email protected]#$%^&*:;<>(){}[]|\/\'`"_,.'
                for character in replace_characters:
                    line = line.replace(character, "")

                word_list = line.split(" ")
                for word in word_list:

                    if word and word in words:
                        words[word] += 1
                    else:
                        words[word] = 1

    output_name = text_sample_directory.strip("/")

    writer = csv.writer(open(output_name + ".csv", "wb"))
    sorted_dict = sorted(words.items(), key=lambda x:x[1], reverse=True)

    # Get the count of occurance for the word that occurs the most
    max_value = int(sorted_dict[0][1])
    keys = []
    values = []

    for key, value in sorted_dict:
        keys.append(key)
        values.append(value)
        writer.writerow([key, value])

    line_chart = Line()
    line_chart.title = "Word Occurance Graph"
    line_chart.x_labels = keys
    line_chart.add(output_name,  values)

    svg_data = line_chart.render()
    graphfile = open(output_name + ".svg", "w")
    graphfile.write(svg_data)


    print "\nWriting '" + output_name + "'"
开发者ID:gunthercox,项目名称:AttitudeEngine,代码行数:57,代码来源:word_count.py

示例11: test_config_alterations_instance

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_alterations_instance():
    class LineConfig(Config):
        show_legend = False
        fill = True
        pretty_print = True
        x_labels = ["a", "b", "c"]

    config = LineConfig()
    line1 = Line(config)
    line1.add("_", [1, 2, 3])
    l1 = line1.render()

    config.stroke = False
    line2 = Line(config)
    line2.add("_", [1, 2, 3])
    l2 = line2.render()
    assert l1 != l2

    l1bis = line1.render()
    assert l1 == l1bis
开发者ID:Zanarh,项目名称:pygal,代码行数:22,代码来源:test_config.py

示例12: test_config_alterations_instance

# 需要导入模块: from pygal import Line [as 别名]
# 或者: from pygal.Line import render [as 别名]
def test_config_alterations_instance():
    """Assert a config can be changed on instance"""
    class LineConfig(Config):
        no_prefix = True
        show_legend = False
        fill = True
        pretty_print = True
        x_labels = ['a', 'b', 'c']

    config = LineConfig()
    line1 = Line(config)
    line1.add('_', [1, 2, 3])
    l1 = line1.render()

    config.stroke = False
    line2 = Line(config)
    line2.add('_', [1, 2, 3])
    l2 = line2.render()
    assert l1 != l2

    l1bis = line1.render()
    assert l1 == l1bis
开发者ID:Frankie-666,项目名称:pygal,代码行数:24,代码来源:test_config.py


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