Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
e2d9f4ba
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
e2d9f4ba
编写于
7月 20, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: mkae code city works
上级
fe05188d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
7 deletion
+65
-7
static/.gitignore
static/.gitignore
+1
-0
static/index.html
static/index.html
+64
-7
未找到文件。
static/.gitignore
浏览文件 @
e2d9f4ba
disk.tree.json
visual.json
static/index.html
浏览文件 @
e2d9f4ba
...
...
@@ -8,11 +8,68 @@
</head>
<body>
<div
id=
"main"
style=
"width:
600px;height:400
px;"
></div>
<div
id=
"main"
style=
"width:
1440px;height:768
px;"
></div>
<script>
var
myChart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
));
console
.
log
(
$
(
'
disk.tree.json
'
));
$
.
get
(
'
disk.tree.json
'
,
function
(
diskData
)
{
$
.
get
(
'
visual.json
'
,
function
(
diskData
)
{
function
hierarchy
(
data
,
delimiter
=
"
.
"
)
{
let
root
;
const
map
=
new
Map
;
data
.
forEach
(
function
find
(
data
)
{
const
{
name
}
=
data
;
if
(
map
.
has
(
name
))
return
map
.
get
(
name
);
const
i
=
name
.
lastIndexOf
(
delimiter
);
map
.
set
(
name
,
data
);
if
(
i
>=
0
)
{
let
found
=
find
({
name
:
name
.
substring
(
0
,
i
),
children
:
[]});
if
(
found
.
children
)
{
found
.
children
.
push
(
data
);
}
else
{
return
data
}
data
.
name
=
name
.
substring
(
i
+
1
);
}
else
{
root
=
data
;
}
return
data
;
});
return
root
;
}
var
dMap
=
{}
for
(
let
node
of
diskData
.
nodes
)
{
dMap
[
node
.
id
]
=
{
name
:
"
root.
"
+
node
.
id
,
value
:
1
}
}
for
(
let
link
of
diskData
.
links
)
{
if
(
link
.
source
===
link
.
target
)
{
continue
}
if
(
!
dMap
[
link
.
source
])
{
dMap
[
link
.
source
]
=
{
name
:
"
root.
"
+
link
.
source
,
value
:
1
}
}
else
{
dMap
[
link
.
source
].
value
++
}
}
console
.
log
(
dMap
);
var
jdata
=
Object
.
values
(
dMap
)
let
data
=
hierarchy
(
jdata
);
data
.
children
.
forEach
(
function
(
item
,
index
,
object
)
{
if
(
item
.
name
===
''
)
{
object
.
splice
(
index
,
1
);
}
});
console
.
log
(
data
);
var
formatUtil
=
echarts
.
format
;
function
getLevelOption
()
{
return
[
...
...
@@ -38,7 +95,7 @@ $.get('disk.tree.json', function (diskData) {
}
myChart
.
setOption
({
title
:
{
text
:
'
Disk Usage
'
,
text
:
'
Call
'
,
left
:
'
center
'
},
tooltip
:
{
...
...
@@ -53,14 +110,14 @@ $.get('disk.tree.json', function (diskData) {
return
[
'
<div class="tooltip-title">
'
+
formatUtil
.
encodeHTML
(
treePath
.
join
(
'
/
'
))
+
'
</div>
'
,
'
Disk Usage:
'
+
formatUtil
.
addCommas
(
value
)
+
'
KB
'
,
'
Call
'
+
formatUtil
.
addCommas
(
value
)
+
'
'
,
].
join
(
''
);
}
},
series
:
[
{
name
:
'
Disk Usage
'
,
name
:
'
Code city
'
,
type
:
'
treemap
'
,
visibleMin
:
300
,
label
:
{
...
...
@@ -71,7 +128,7 @@ $.get('disk.tree.json', function (diskData) {
borderColor
:
'
#fff
'
},
levels
:
getLevelOption
(),
data
:
d
iskData
data
:
d
ata
.
children
}
]
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录