当前位置:网站首页>Pyechart离线部署
Pyechart离线部署
2022-07-26 11:06:00 【呆萌的代Ma】
Pyechart简介
pyecharts介绍:https://pyecharts.org/#/zh-cn/intro
github页面:https://github.com/pyecharts/pyecharts
pyecharts官方文档:https://pyecharts.readthedocs.io/zh/latest/zh-cn/jupyter_notebook/
首先生成一份pyechart的图片:
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Faker
c = (
Bar()
.add_xaxis(Faker.choose())
.add_yaxis("商家A", Faker.values(), category_gap="80%")
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-单系列柱间距离"))
.render("online_bar.html")
)
可以看到如下图片:
准备离线资源
然后使用:
git clone [email protected].com:pyecharts/pyecharts-assets.git
cd pyecharts-assets
python -m http.server -b 127.0.0.1 30399
同样可以使用默认配置:python -m http.server,会默认在127.0.0.1的8000端口
也可以把服务放到后台:
nohup python -m http.server -b 127.0.0.1 30399 &
然后可以访问相关端口:http://127.0.0.1:30399/#/
后台使用:

生成离线图片
在原有的代码中添加:
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "http://127.0.0.1:30399/assets/"
修改后的代码如下:
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Faker
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "http://127.0.0.1:30399/assets/"
c = (
Bar()
.add_xaxis(Faker.choose())
.add_yaxis("商家A", Faker.values(), category_gap="80%")
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-单系列柱间距离"))
.render("online_bar_2.html")
)
这样会生成online_bar_2.html文件,其中js的依赖文件是:
<script type="text/javascript" src="http://127.0.0.1:30399/assets/echarts.min.js"></script>
这样就可以离线使用pyechart的js了
边栏推荐
猜你喜欢

win10 1903 笔记本开热点出现蓝屏问题

pytest 前后置方法

The combination of pytest confitest.py and fixture

SparkSQL的UDF及分析案例,220725,

easyui02

After 4 months of job search and 15 interviews, I finally got 3 offers, ranking P7+

Visual conversion of nmap vulnerability scanning results

SCADA and three industrial control systems PLC, DCS and FCS

3Dunity游戏项目实战——飞机大战

344. Reverse string
随机推荐
Summary of common cmake commands
[vscode]如何远程连接服务器
贝尔曼期望方程状严谨证明
为什么放弃npm转向yarn了
36.【const函数放在函数前后的区别】
[reprint] the multivariate normal distribution
配置文件以rc结尾什么意思
easyui04
Solve the problem of the popularity of org.apache.commons.codec.binary.base64
-bash: ./build.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录
How to configure the jdbcrealm data source?
mysql数据库进阶
MySQL locking mechanism
Admit it, investing in new energy is for security
新来个技术总监要我做一个 IP 属地功能~
[development tool] ieda red
Toolstrip border removal
Pytest case execution sequence
QT——连接USB摄像头
承认吧 投新能源就是为了安全感