yjc_branch
王天宝_Git实践 3 years ago
parent 9e78f40205
commit 93ab890b30

@ -0,0 +1,3 @@
# 默认忽略的文件
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (pythonProject1)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject1.iml" filepath="$PROJECT_DIR$/.idea/pythonProject1.iml" />
</modules>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,39 @@
from pyecharts import options as opts
from pyecharts.charts import Graph
from pyecharts.globals import CurrentConfig
import csv
# 设置 echarts 的在线主机
CurrentConfig.ONLINE_HOST = "http://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/"
# 读取名字文件,并添加节点
nodes = []
with open('name.csv') as f:
reader = csv.reader(f)
for line in reader:
nodes.append(opts.GraphNode(name=line[0]))
# 读取关系文件,并添加关系
links = []
with open('relation.csv') as f:
reader = csv.reader(f)
next(reader) # 跳过标题行
for line in reader:
links.append(opts.GraphLink(source=line[0], target=line[1], value=line[2]))
# 生成关系图
c = (
Graph()
.add("", nodes, links, repulsion=4000,
edge_label=opts.LabelOpts(is_show=True, position="middle", formatter="{c}"))
.set_global_opts(
title_opts=opts.TitleOpts(title="简单关系图", subtitle="by pyecharts"),
legend_opts=opts.LegendOpts(is_show=True),
tooltip_opts=opts.TooltipOpts(trigger="item"),
visualmap_opts=opts.VisualMapOpts(max_=10, min_=0),
toolbox_opts=opts.ToolboxOpts(is_show=True),
xaxis_opts=opts.AxisOpts(is_show=True),
yaxis_opts=opts.AxisOpts(is_show=True),
)
)
c.render("简单关系图.html")

@ -0,0 +1,22 @@
刘备
关羽
张飞
诸葛亮
曹操
荀彧
孙权
周瑜
赵云
曹丕
曹植
吕布
貂蝉
袁绍
袁术
孙策
魏延
张辽
张郃
司马懿
周仓
糜夫人
1 刘备
2 关羽
3 张飞
4 诸葛亮
5 曹操
6 荀彧
7 孙权
8 周瑜
9 赵云
10 曹丕
11 曹植
12 吕布
13 貂蝉
14 袁绍
15 袁术
16 孙策
17 魏延
18 张辽
19 张郃
20 司马懿
21 周仓
22 糜夫人

@ -0,0 +1,4 @@
Tom
Jerry
Lucy
John
1 Tom
2 Jerry
3 Lucy
4 John

@ -0,0 +1,11 @@
刘备, 关羽,5
刘备, 张飞,5
刘备, 诸葛亮,5
曹操, 荀彧,5
曹操, 刘备,5
孙权, 周瑜,5
关羽, 张飞,5
赵云, 张飞,5
曹丕, 曹植,5
吕布, 貂蝉,5
袁绍, 袁术,5
1 刘备 关羽 5
2 刘备 张飞 5
3 刘备 诸葛亮 5
4 曹操 荀彧 5
5 曹操 刘备 5
6 孙权 周瑜 5
7 关羽 张飞 5
8 赵云 张飞 5
9 曹丕 曹植 5
10 吕布 貂蝉 5
11 袁绍 袁术 5

@ -0,0 +1,4 @@
Tom,Jerry,5
Tom,Lucy,3
Jerry,Lucy,4
John,Tom,2
1 Tom Jerry 5
2 Tom Lucy 3
3 Jerry Lucy 4
4 John Tom 2

@ -0,0 +1,265 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Awesome-pyecharts</title>
<script type="text/javascript" src="http://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/echarts.min.js"></script>
</head>
<body >
<div id="468da4d6cef548d189298c72237d4cdb" class="chart-container" style="width:900px; height:500px; "></div>
<script>
var chart_468da4d6cef548d189298c72237d4cdb = echarts.init(
document.getElementById('468da4d6cef548d189298c72237d4cdb'), 'white', {renderer: 'canvas'});
var option_468da4d6cef548d189298c72237d4cdb = {
"animation": true,
"animationThreshold": 2000,
"animationDuration": 1000,
"animationEasing": "cubicOut",
"animationDelay": 0,
"animationDurationUpdate": 300,
"animationEasingUpdate": "cubicOut",
"animationDelayUpdate": 0,
"aria": {
"enabled": false
},
"color": [
"#5470c6",
"#91cc75",
"#fac858",
"#ee6666",
"#73c0de",
"#3ba272",
"#fc8452",
"#9a60b4",
"#ea7ccc"
],
"series": [
{
"type": "graph",
"layout": "force",
"symbolSize": 10,
"circular": {
"rotateLabel": false
},
"force": {
"repulsion": 4000,
"gravity": 0.2,
"edgeLength": 30,
"friction": 0.6,
"layoutAnimation": true
},
"label": {
"show": true,
"margin": 8
},
"lineStyle": {
"show": true,
"width": 1,
"opacity": 1,
"curveness": 0,
"type": "solid"
},
"roam": true,
"draggable": false,
"focusNodeAdjacency": true,
"data": [
{
"name": "Tom",
"fixed": false
},
{
"name": "Jerry",
"fixed": false
},
{
"name": "Lucy",
"fixed": false
},
{
"name": "John",
"fixed": false
}
],
"edgeLabel": {
"show": true,
"position": "middle",
"margin": 8,
"formatter": "{c}"
},
"edgeSymbol": [
null,
null
],
"edgeSymbolSize": 10,
"links": [
{
"source": "Tom",
"target": "Lucy",
"value": "3"
},
{
"source": "Jerry",
"target": "Lucy",
"value": "4"
},
{
"source": "John",
"target": "Tom",
"value": "2"
}
]
}
],
"legend": [
{
"data": [],
"selected": {},
"show": true,
"padding": 5,
"itemGap": 10,
"itemWidth": 25,
"itemHeight": 14,
"backgroundColor": "transparent",
"borderColor": "#ccc",
"borderWidth": 1,
"borderRadius": 0,
"pageButtonItemGap": 5,
"pageButtonPosition": "end",
"pageFormatter": "{current}/{total}",
"pageIconColor": "#2f4554",
"pageIconInactiveColor": "#aaa",
"pageIconSize": 15,
"animationDurationUpdate": 800,
"selector": false,
"selectorPosition": "auto",
"selectorItemGap": 7,
"selectorButtonGap": 10
}
],
"tooltip": {
"show": true,
"trigger": "item",
"triggerOn": "mousemove|click",
"axisPointer": {
"type": "line"
},
"showContent": true,
"alwaysShowContent": false,
"showDelay": 0,
"hideDelay": 100,
"enterable": false,
"confine": false,
"appendToBody": false,
"transitionDuration": 0.4,
"textStyle": {
"fontSize": 14
},
"borderWidth": 0,
"padding": 5,
"order": "seriesAsc"
},
"title": [
{
"show": true,
"text": "\u7b80\u5355\u5173\u7cfb\u56fe",
"target": "blank",
"subtext": "by pyecharts",
"subtarget": "blank",
"padding": 5,
"itemGap": 10,
"textAlign": "auto",
"textVerticalAlign": "auto",
"triggerEvent": false
}
],
"toolbox": {
"show": true,
"orient": "horizontal",
"itemSize": 15,
"itemGap": 10,
"left": "80%",
"feature": {
"saveAsImage": {
"type": "png",
"backgroundColor": "auto",
"connectedBackgroundColor": "#fff",
"show": true,
"title": "\u4fdd\u5b58\u4e3a\u56fe\u7247",
"pixelRatio": 1
},
"restore": {
"show": true,
"title": "\u8fd8\u539f"
},
"dataView": {
"show": true,
"title": "\u6570\u636e\u89c6\u56fe",
"readOnly": false,
"lang": [
"\u6570\u636e\u89c6\u56fe",
"\u5173\u95ed",
"\u5237\u65b0"
],
"backgroundColor": "#fff",
"textareaColor": "#fff",
"textareaBorderColor": "#333",
"textColor": "#000",
"buttonColor": "#c23531",
"buttonTextColor": "#fff"
},
"dataZoom": {
"show": true,
"title": {
"zoom": "\u533a\u57df\u7f29\u653e",
"back": "\u533a\u57df\u7f29\u653e\u8fd8\u539f"
},
"icon": {},
"filterMode": "filter"
},
"magicType": {
"show": true,
"type": [
"line",
"bar",
"stack",
"tiled"
],
"title": {
"line": "\u5207\u6362\u4e3a\u6298\u7ebf\u56fe",
"bar": "\u5207\u6362\u4e3a\u67f1\u72b6\u56fe",
"stack": "\u5207\u6362\u4e3a\u5806\u53e0",
"tiled": "\u5207\u6362\u4e3a\u5e73\u94fa"
},
"icon": {}
}
}
},
"visualMap": {
"show": true,
"type": "continuous",
"min": 0,
"max": 10,
"inRange": {
"color": [
"#50a3ba",
"#eac763",
"#d94e5d"
]
},
"calculable": true,
"inverse": false,
"splitNumber": 5,
"hoverLink": true,
"orient": "vertical",
"padding": 5,
"showLabel": true,
"itemWidth": 20,
"itemHeight": 140,
"borderWidth": 0
}
};
chart_468da4d6cef548d189298c72237d4cdb.setOption(option_468da4d6cef548d189298c72237d4cdb);
</script>
</body>
</html>
Loading…
Cancel
Save