import asyncio
from aiohttp import TCPConnector, ClientSession
import pyecharts.options as opts
from pyecharts.charts import Graph
async def get_json_data(url: str) -> dict:
async with ClientSession(connector=TCPConnector(ssl=False)) as session:
async with session.get(url=url) as response:
return await response.json()
# 获取官方的数据
data = asyncio.run(
get_json_data(
url="https://echarts.apache.org/examples/data/asset/data/npmdepgraph.min10.json"
)
)
nodes = [
{
"x": node["x"],
"y": node["y"],
"id": node["id"],
"name": node["label"],
"symbolSize": node["size"],
"itemStyle": {"normal": {"color": node["color"]}},
}
for node in data["nodes"]
]
edges = [
{"source": edge["sourceID"], "target": edge["targetID"]} for edge in data["edges"]
]
(
Graph(init_opts=opts.InitOpts(width="1600px", height="800px"))
.add(
series_name="",
nodes=nodes,
links=edges,
layout="none",
is_roam=True,
is_focusnode=True,
label_opts=opts.LabelOpts(is_show=False),
linestyle_opts=opts.LineStyleOpts(width=0.5, curve=0.3, opacity=0.7),
)
.set_global_opts(title_opts=opts.TitleOpts(title="NPM Dependencies"))
.render("npm_dependencies.html")
)
【Python数据可视化源码实例Pyecharts库集合】关系图.zip
版权申诉
136 浏览量
2023-07-12
14:31:30
上传
评论
收藏 40KB ZIP 举报
技术宅小伙
- 粉丝: 311
- 资源: 1802
最新资源
- cmak-3.0.0.6.zip
- Map2ShpPro-Demo.zip
- vue3 的 main.ts 文件,包含了 elementui-plus 注册,icon 全局注册等常用注册
- Typecho博客主题Joe素颜执念修改版
- SP8K32-TB-VB一款2个N-Channel沟道SOP8的MOSFET晶体管参数介绍与应用说明
- Alibaba 阿里P9百亿级高并发系统设计手册最新全彩PDF版本
- Socket通讯验证工具 可验证本机端口是否被占用 验证服务端端口是否开通或可访问 查看服务端与客户端的socket发送信息
- SP8K31-TB-VB一款2个N-Channel沟道SOP8的MOSFET晶体管参数介绍与应用说明
- 安卓AndroidStudio基于百度云平台人脸识别学生考勤签到系统
- 红外温度传感器的原理及应用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈