本文整理汇总了Python中pyecharts.Bar.cast方法的典型用法代码示例。如果您正苦于以下问题:Python Bar.cast方法的具体用法?Python Bar.cast怎么用?Python Bar.cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyecharts.Bar
的用法示例。
在下文中一共展示了Bar.cast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_template_for_chart
# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import cast [as 别名]
def test_custom_template_for_chart():
data = [{
'name': '衬衫',
'value': 5
}, {
'name': '羊毛衫',
'value': 20
}, {
'name': '雪纺衫',
'value': 36
}]
configure(echarts_template_dir='.')
online()
data1 = {'衬衫': '34', '羊毛衫': 45, '雪纺衫': 40}
names, values = Bar.cast(data)
names1, values1 = Bar.cast(data1)
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", names, values, is_stack=True)
bar.add("商家B", names1, values1, is_stack=True)
bar.render(path='new_version_bar.html')
with codecs.open('new_version_bar.html', 'r', 'utf-8') as f:
actual_content = f.read()
assert "</html>" in actual_content
示例2: test_custom_template_for_chart
# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import cast [as 别名]
def test_custom_template_for_chart():
data = [
{"name": "衬衫", "value": 5},
{"name": "羊毛衫", "value": 20},
{"name": "雪纺衫", "value": 36},
]
configure(echarts_template_dir=".")
data1 = {"衬衫": "34", "羊毛衫": 45, "雪纺衫": 40}
names, values = Bar.cast(data)
names1, values1 = Bar.cast(data1)
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", names, values, is_stack=True)
bar.add("商家B", names1, values1, is_stack=True)
bar.render(path="new_version_bar.html")
with codecs.open("new_version_bar.html", "r", "utf-8") as f:
actual_content = f.read()
assert "</html>" in actual_content
示例3: test_base_cast_dict
# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import cast [as 别名]
def test_base_cast_dict():
adict = {"key": 1, "value": 2}
keys, values = Bar.cast(adict)
eq_(keys, ["key", "value"])
eq_(values, [1, 2])
示例4: test_base_cast_records
# 需要导入模块: from pyecharts import Bar [as 别名]
# 或者: from pyecharts.Bar import cast [as 别名]
def test_base_cast_records():
records = [{"key": 1}, {"value": 2}]
keys, values = Bar.cast(records)
eq_(keys, ["key", "value"])
eq_(values, [1, 2])