本文整理汇总了Python中pygal.Bar.add方法的典型用法代码示例。如果您正苦于以下问题:Python Bar.add方法的具体用法?Python Bar.add怎么用?Python Bar.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygal.Bar
的用法示例。
在下文中一共展示了Bar.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bar
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_bar():
bar = Bar(dynamic_print_values=True, show_minor_x_labels=False)
bar.add('1', [1, 2, 3])
bar.add('2', [4, 5, 6])
bar.x_labels = [2, 4, 6]
bar.x_labels_major = [4]
return bar.render_response()
示例2: test_bar_links
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_bar_links():
bar = Bar(style=styles['neon'])
bar.js = ('http://l:2343/svg.jquery.js',
'http://l:2343/pygal-tooltips.js')
bar.add('1234', [
{'value': 10,
'label': 'Ten',
'xlink': 'http://google.com?q=10'},
{'value': 20,
'tooltip': 'Twenty',
'xlink': 'http://google.com?q=20'},
30,
{'value': 40,
'label': 'Forty',
'xlink': 'http://google.com?q=40'}
])
bar.add('4321', [40, {
'value': 30,
'label': 'Thirty',
'xlink': 'http://google.com?q=30'
}, 20, 10])
bar.x_labels = map(str, range(1, 5))
bar.logarithmic = True
bar.zero = 1
return bar.render_response()
示例3: test_multiline_title
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_multiline_title():
bar = Bar()
bar.add('Looooooooooooooooooooooooooooooooooong', [2, None, 12])
bar.title = (
'First line \n Second line \n Third line'
)
return bar.render_response()
示例4: test_another_sparktext
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_another_sparktext():
"""Test that same data produces same sparktext"""
chart = Line()
chart.add('_', [0, 30, 55, 80, 33, 150])
assert chart.render_sparktext() == u('▁▂▃▄▂█')
assert chart.render_sparktext() == chart.render_sparktext()
chart2 = Bar()
chart2.add('_', [0, 30, 55, 80, 33, 150])
assert chart2.render_sparktext() == chart.render_sparktext()
示例5: test_long_labels
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_long_labels():
bar = Bar()
bar.add("Long", [2, None, 12])
bar.title = "1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890"
bar.x_labels = "a" * 100, "b " * 50, "cc ! " * 20
bar.x_label_rotation = 45
return bar.render_response()
示例6: graph_records
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def graph_records(record_files):
chart = Bar(BaseConfig)
max_len = max(map(len, record_files.values()))
for name, record_list in sort_domains(record_files.items()):
chart.add(name, [x[0].total_seconds()/86400 for x in record_list] +
[None] * (max_len - len(record_list)))
return chart.render()
示例7: test_another_sparktext
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_another_sparktext():
chart = Line()
chart.add('_', [0, 30, 55, 80, 33, 150])
assert chart.render_sparktext() == u('▁▂▃▄▂█')
assert chart.render_sparktext() == chart.render_sparktext()
chart2 = Bar()
chart2.add('_', [0, 30, 55, 80, 33, 150])
assert chart2.render_sparktext() == chart.render_sparktext()
示例8: __call__
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def __call__(self, T):
subplot = Bar(legend_at_bottom=True, explicit_size=True, width=800, height=150)
subplot.add("Difference", self.data)
subplot = subplot.render_tree()
subplot = subplot.xpath("g")[0]
T.insert(2, subplot)
T.xpath("g")[1].set('transform', 'translate(0,150), scale(1,0.75)')
return T
示例9: test_long_labels
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_long_labels():
bar = Bar()
bar.add('Long', [2, None, 12])
bar.title = (
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890')
bar.x_labels = 'a' * 100, 'b ' * 50, 'cc ! ' * 20
bar.x_label_rotation = 45
return bar.render_response()
示例10: test_xml_filters_round_trip
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_xml_filters_round_trip():
plot = Bar()
plot.add("A", [60, 75, 80, 78, 83, 90])
plot.add("B", [92, 87, 81, 73, 68, 55])
before = plot.render()
plot.add_xml_filter(lambda T: T)
after = plot.render()
assert before == after
示例11: test_unsorted
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_unsorted():
bar = Bar(style=styles["neon"], human_readable=True)
bar.add("A", {"red": 10, "green": 12, "blue": 14})
bar.add("B", {"green": 11, "blue": 7})
bar.add("C", {"blue": 7})
bar.add("D", {})
bar.add("E", {"blue": 2, "red": 13})
bar.x_labels = ("red", "green", "blue")
return bar.render_response()
示例12: test_unsorted
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_unsorted():
bar = Bar(style=styles['neon'])
bar.add('A', {'red': 10, 'green': 12, 'blue': 14})
bar.add('B', {'green': 11, 'blue': 7})
bar.add('C', {'blue': 7})
bar.add('D', {})
bar.add('E', {'blue': 2, 'red': 13})
bar.x_labels = ('red', 'green', 'blue')
return bar.render_response()
示例13: test_xml_filters_change_bars
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_xml_filters_change_bars():
plot = Bar(legend_at_bottom=True, explicit_size=True, width=800, height=600)
A = [60, 75, 80, 78, 83, 90]
B = [92, 87, 81, 73, 68, 55]
plot.add("A", A)
plot.add("B", B)
plot.add_xml_filter(ChangeBarsXMLFilter(A,B))
q = plot.render_tree()
assert len(q.xpath("g")) == 2
assert q.xpath("g")[1].attrib["transform"] == "translate(0,150), scale(1,0.75)"
示例14: test_bar_print_values
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_bar_print_values():
bar = Bar(print_values=True, js=[],
style=styles['default'](
value_font_family='googlefont:Raleway',
value_font_size=30,
value_colors=(None, None, 'blue', 'red', 'green')
))
for i in range(12):
bar.add('', i)
return bar.render_response()
示例15: test_simple_bar
# 需要导入模块: from pygal import Bar [as 别名]
# 或者: from pygal.Bar import add [as 别名]
def test_simple_bar():
bar = Bar()
rng = [-3, -32, -39]
bar.add("test1", rng)
bar.add("test2", map(abs, rng))
bar.x_labels = map(str, rng)
bar.title = "Bar test"
q = bar.render_pyquery()
assert len(q(".axis.x")) == 1
assert len(q(".axis.y")) == 1
assert len(q(".legend")) == 2
assert len(q(".plot .series rect")) == 2 * 3