开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (4)
标签 (24)
master
dev
scatter_extra_name
0.3.x
v0.5.6
v0.5.5
v0.5.4
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.1
v0.4.0
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.7
v0.2.6
v0.2.4
v0.2.3
v0.2.2
v0.2.1
v0.2.0
master
分支 (4)
标签 (24)
master
dev
scatter_extra_name
0.3.x
v0.5.6
v0.5.5
v0.5.4
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.1
v0.4.0
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.7
v0.2.6
v0.2.4
v0.2.3
v0.2.2
v0.2.1
v0.2.0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (4)
标签 (24)
master
dev
scatter_extra_name
0.3.x
v0.5.6
v0.5.5
v0.5.4
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.1
v0.4.0
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.7
v0.2.6
v0.2.4
v0.2.3
v0.2.2
v0.2.1
v0.2.0
pyecharts
/
test
/
test_base.py
pyecharts
/
test
/
test_base.py
test_base.py 5.20 KB
一键复制 编辑 原始数据 按行查看 历史
jaska 提交于 2018年05月10日 20:57 +08:00 . True theme (#546)
# coding=utf-8
from __future__ import unicode_literals
import os
import sys
import json
import pandas as pd
import numpy as np
from nose.tools import eq_, raises
from mock import patch, MagicMock
from pyecharts import Bar, Map, jupyter_image
import pyecharts.exceptions as exceptions
from test.constants import CLOTHES
from test.utils import get_default_rendering_file_content
TITLE = "柱状图数据堆叠示例"
def create_a_bar(title, renderer="canvas"):
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar(title, renderer=renderer)
bar.add("商家A", CLOTHES, v1, is_stack=True)
bar.add("商家B", CLOTHES, v2, is_stack=True)
return bar
def test_theme_option():
bar = create_a_bar(TITLE, renderer="svg")
bar.use_theme("dark")
html = bar.render_embed()
assert "'dark'" in html
@raises(exceptions.InvalidTheme)
def test_invalid_theme_option():
bar = create_a_bar(TITLE, renderer="svg")
bar.use_theme("brilliant")
def test_svg_option():
bar = create_a_bar(TITLE, renderer="svg")
html = bar.render_embed()
assert "{renderer: 'svg'}" in html
def test_svg_option_in_note_book():
bar = create_a_bar(TITLE, renderer="svg")
html = bar._repr_html_()
assert "{renderer: 'svg'}" in html
def test_canvas_option():
bar = create_a_bar(TITLE)
html = bar.render_embed()
assert "{renderer: 'canvas'}" in html
def test_canvas_option_in_notebook():
bar = create_a_bar(TITLE)
html = bar._repr_html_()
assert "{renderer: 'canvas'}" in html
def test_embed_option():
bar = create_a_bar(TITLE)
html = bar.render_embed()
json_encoded_title = json.dumps(TITLE)
assert json_encoded_title in html
assert "<html>" not in html
assert "<body>" not in html
def test_jupyter_repr_png():
bar = create_a_bar(TITLE)
assert bar._repr_png_() is None
def test_jupyter_repr_jpeg():
bar = create_a_bar(TITLE)
assert bar._repr_jpeg_() is None
def test_jupyter_repr_svg():
bar = create_a_bar(TITLE)
assert bar._repr_svg_() is None
@patch("pyecharts.engine.create_default_environment")
@patch("os.unlink")
def test_render_as_svg(fake_unlink, fake_factory):
fake_env = MagicMock(
render_chart_to_file=MagicMock(return_value="fake svg")
)
fake_factory.return_value = fake_env
with jupyter_image("svg"):
bar = create_a_bar("test", renderer="svg")
svg_content = bar._repr_svg_()
fake_unlink.assert_called()
eq_(svg_content, "fake svg")
@raises(exceptions.InvalidConfiguration)
def test_render_as_svg_with_wrong_configuration():
with jupyter_image("svg"):
bar = create_a_bar("test")
bar._repr_svg_()
@raises(exceptions.InvalidConfiguration)
def test_render_as_png_with_wrong_configuration():
with jupyter_image("png"):
bar = create_a_bar("test", renderer="svg")
bar._repr_png_()
def test_base_get_js_dependencies():
bar = create_a_bar(TITLE)
dependencies = bar.get_js_dependencies()
expected = ["echarts.min"]
eq_(dependencies, expected)
def test_numpy_array():
v1 = np.array([5, 20, 36, 10, 75, 90])
bar = Bar(TITLE)
bar.add("商家A", CLOTHES, v1, is_stack=True)
html = bar.render_embed()
json_encoded_title = json.dumps(TITLE)
assert json_encoded_title in html
def test_pandas_dataframe():
title = "bar chart"
index = pd.date_range("3/8/2017", periods=6, freq="M")
df1 = pd.DataFrame(np.random.randn(6), index=index)
df2 = pd.DataFrame(np.random.randn(6), index=index)
dtvalue1 = [i[0] for i in df1.values]
dtvalue2 = [i[0] for i in df2.values]
_index = [i for i in df1.index.format()]
bar = Bar(title, "Profit and loss situation")
bar.add("profit", _index, dtvalue1)
bar.add("loss", _index, dtvalue2)
html = bar.render_embed()
assert title in html
def test_echarts_position_in_render_html():
value = [20, 190, 253, 77, 65]
attr = ["汕头市", "汕尾市", "揭阳市", "阳江市", "肇庆市"]
map = Map("广东地图示例", width=1200, height=600, page_title=TITLE)
map.add(
"",
attr,
value,
maptype="广东",
is_visualmap=True,
visual_text_color="#000",
)
map.render()
actual_content = get_default_rendering_file_content()
assert TITLE in actual_content
def test_show_config():
stdout_ = sys.stdout
captured_stdout = "stdout.txt"
try:
with open(captured_stdout, "w") as f:
sys.stdout = f
bar = create_a_bar("new")
bar.print_echarts_options()
except Exception as e:
# whatever happens, continue and restore stdout
print(e)
sys.stdout = stdout_
with open(captured_stdout, "r") as f:
content = f.read()
assert "None" not in content
assert "null" not in content
assert "false" in content
assert "False" not in content
os.unlink(captured_stdout)
def test_base_cast_records():
records = [{"key": 1}, {"value": 2}]
keys, values = Bar.cast(records)
eq_(keys, ["key", "value"])
eq_(values, [1, 2])
def test_base_cast_dict():
adict = {"key": 1, "value": 2}
keys, values = Bar.cast(adict)
eq_(keys, ["key", "value"])
eq_(values, [1, 2])
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Python Echarts Plotting Library
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/pythonista/pyecharts.git
git@gitee.com:pythonista/pyecharts.git
pythonista
pyecharts
pyecharts
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /