本文整理汇总了Python中pygal.Bar类的典型用法代码示例。如果您正苦于以下问题:Python Bar类的具体用法?Python Bar怎么用?Python Bar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_multiline_title
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()
开发者ID:fredtantini,项目名称:pygal,代码行数:7,代码来源:tests.py
示例2: test_bar_links
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()
开发者ID:Bouska,项目名称:pygal,代码行数:26,代码来源:tests.py
示例3: test_another_sparktext
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()
开发者ID:Bouska,项目名称:pygal,代码行数:8,代码来源:test_sparktext.py
示例4: graph_records
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()
开发者ID:Qalthos,项目名称:locutus,代码行数:8,代码来源:graphs.py
示例5: __call__
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
开发者ID:AlexSnet,项目名称:pygal,代码行数:8,代码来源:test_xml_filters.py
示例6: test_another_sparktext
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()
开发者ID:aroraumang,项目名称:pygal,代码行数:9,代码来源:test_sparktext.py
示例7: test_bar_print_values
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()
开发者ID:fredtantini,项目名称:pygal,代码行数:10,代码来源:tests.py
示例8: test_long_title
def test_long_title():
bar = Bar()
bar.add('Looooooooooooooooooooooooooooooooooong', [2, None, 12])
bar.title = (
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 '
'12345678901 123456789012 1234567890123 12345678901234 '
'123456789012345 1234567890123456 12345678901234567 '
'123456789012345678 1234567890123456789 12345678901234567890 '
'123456789012345 1234567890123456 12345678901234567 '
'12345678901 123456789012 1234567890123 12345678901234 '
'1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890')
return bar.render_response()
开发者ID:fredtantini,项目名称:pygal,代码行数:12,代码来源:tests.py
示例9: test_long_title
def test_long_title():
bar = Bar()
bar.add("Looooooooooooooooooooooooooooooooooong", [2, None, 12])
bar.title = (
"1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 "
"12345678901 123456789012 1234567890123 12345678901234 "
"123456789012345 1234567890123456 12345678901234567 "
"123456789012345678 1234567890123456789 12345678901234567890 "
"123456789012345 1234567890123456 12345678901234567 "
"12345678901 123456789012 1234567890123 12345678901234 "
"1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890"
)
return bar.render_response()
开发者ID:rnjdeltaYoda,项目名称:pygal,代码行数:13,代码来源:tests.py
示例10: getBar
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,代码行数:15,代码来源:bar.py
示例11: test_long_labels
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()
开发者ID:rnjdeltaYoda,项目名称:pygal,代码行数:7,代码来源:tests.py
示例12: test_bar_links
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()
开发者ID:Cortana-,项目名称:pygal,代码行数:18,代码来源:tests.py
示例13: test_long_labels
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()
开发者ID:fredtantini,项目名称:pygal,代码行数:8,代码来源:tests.py
示例14: test_xml_filters_round_trip
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
开发者ID:langelee,项目名称:pygal,代码行数:8,代码来源:test_xml_filters.py
示例15: test_simple_bar
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
开发者ID:jespinoza711,项目名称:pygal,代码行数:12,代码来源:test_bar.py
示例16: test_bar
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()
开发者ID:Kozea,项目名称:pygal,代码行数:7,代码来源:tests.py
示例17: test_xml_filters_change_bars
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)"
开发者ID:AlexSnet,项目名称:pygal,代码行数:10,代码来源:test_xml_filters.py
示例18: test_ylabels
def test_ylabels():
chart = Bar()
chart.x_labels = "Red", "Blue", "Green"
chart.y_labels = [
{"value": 0.0001, "label": "LOL"},
{"value": 0.0003, "label": "ROFL"},
{"value": 0.0004, "label": "MAO"},
{"value": 0.00045, "label": "LMFAO"},
{"value": 0.0005, "label": "GMCB"},
]
chart.add("line", [0.0002, 0.0005, 0.00035])
return chart.render_response()
开发者ID:rnjdeltaYoda,项目名称:pygal,代码行数:12,代码来源:tests.py
示例19: test_ylabels
def test_ylabels():
chart = Bar()
chart.x_labels = 'Red', 'Blue', 'Green'
chart.y_labels = [
{'value': .0001,
'label': 'LOL'},
{'value': .0003,
'label': 'ROFL'},
{'value': .0004,
'label': 'MAO'},
{'value': .00045,
'label': 'LMFAO'},
{'value': .0005,
'label': 'GMCB'}]
chart.add('line', [.0002, .0005, .00035])
return chart.render_response()
开发者ID:fredtantini,项目名称:pygal,代码行数:16,代码来源:tests.py
示例20: get
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,代码行数:23,代码来源:bar.py
注:本文中的pygal.Bar类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论