Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
92efab1f
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 搜索 >>
未验证
提交
92efab1f
编写于
7月 20, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add simple code city
上级
6e73f105
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
293 addition
and
0 deletion
+293
-0
static/code-city.html
static/code-city.html
+293
-0
未找到文件。
static/code-city.html
0 → 100644
浏览文件 @
92efab1f
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Coca Code City
</title>
<script
src=
"https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"
></script>
<script
src=
"https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js"
></script>
<script
src=
"https://cdn.bootcdn.net/ajax/libs/echarts-gl/1.1.2/echarts-gl.min.js "
></script>
</head>
<body>
<div
id=
"main"
style=
"width: 1440px;height:768px;"
></div>
<script>
var
myChart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
));
myChart
.
showLoading
();
$
.
get
(
'
visual.json
'
,
function
(
diskData
)
{
myChart
.
hideLoading
();
var
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
width
=
canvas
.
height
=
2048
;
var
treemapChart
=
echarts
.
init
(
canvas
);
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
++
}
}
var
jdata
=
Object
.
values
(
dMap
)
let
data
=
hierarchy
(
jdata
);
data
.
children
.
forEach
(
function
(
item
,
index
,
object
)
{
if
(
item
.
name
===
''
)
{
object
.
splice
(
index
,
1
);
}
});
var
colorPalette
=
[
'
#d87c7c
'
,
'
#919e8b
'
,
'
#d7ab82
'
,
'
#6e7074
'
,
'
#61a0a8
'
,
'
#efa18d
'
,
'
#787464
'
,
'
#cc7e63
'
,
'
#724e58
'
,
'
#4b565b
'
];
var
formatUtil
=
echarts
.
format
;
let
upperLabel
=
{
color
:
"
#000
"
,
show
:
true
,
height
:
10
,
fontSize
:
8
};
function
getLevelOption
()
{
return
[
{
colorAlpha
:
[
0.5
,
1
],
itemStyle
:
{
borderColor
:
'
#555
'
,
borderWidth
:
0
,
gapWidth
:
0
}
},
{
colorAlpha
:
[
0.5
,
1
],
itemStyle
:
{
borderColor
:
'
#555
'
,
borderWidth
:
1
,
gapWidth
:
1
}
},
{
upperLabel
:
upperLabel
,
colorMappingBy
:
'
id
'
,
colorSaturation
:
[
0.2
,
0.8
],
itemStyle
:
{
borderColorSaturation
:
0.7
,
gapWidth
:
1
,
borderWidth
:
1
}
},
{
upperLabel
:
upperLabel
,
colorMappingBy
:
'
id
'
,
itemStyle
:
{
borderColorSaturation
:
0.9
,
gapWidth
:
1
}
},
{
upperLabel
:
upperLabel
,
colorMappingBy
:
'
id
'
,
itemStyle
:
{
borderColorSaturation
:
0.8
,
gapWidth
:
1
}
},
{
upperLabel
:
upperLabel
,
borderColor
:
'
#fff
'
,
itemStyle
:
{
borderColorSaturation
:
0.9
,
gapWidth
:
1
}
}
];
}
function
colorMappingChange
(
value
)
{
var
levelOption
=
getLevelOption
(
value
);
chart
.
setOption
({
series
:
[{
levels
:
levelOption
}]
});
}
treemapChart
.
setOption
({
title
:
{
left
:
'
center
'
},
tooltip
:
{
formatter
:
function
(
info
)
{
var
value
=
info
.
value
;
var
treePathInfo
=
info
.
treePathInfo
;
var
treePath
=
[];
for
(
var
i
=
1
;
i
<
treePathInfo
.
length
;
i
++
)
{
treePath
.
push
(
treePathInfo
[
i
].
name
);
}
return
[
'
<div class="tooltip-title">
'
+
formatUtil
.
encodeHTML
(
treePath
.
join
(
'
.
'
))
+
'
</div>
'
,
'
Call
'
+
formatUtil
.
addCommas
(
value
)
+
'
'
,
].
join
(
''
);
}
},
series
:
[
{
name
:
"
coca
"
,
type
:
'
treemap
'
,
visibleMin
:
1200
,
width
:
1200
,
height
:
768
,
label
:
{
position
:
'
insideTopLeft
'
,
formatter
:
function
(
params
)
{
var
arr
=
[
'
{name|
'
+
params
.
name
+
'
}
'
,
];
return
arr
;
},
rich
:
{
name
:
{
fontSize
:
12
,
color
:
'
#fff
'
}
}
},
itemStyle
:
{
borderColor
:
'
#fff
'
},
visualDimension
:
2
,
levels
:
getLevelOption
(),
data
:
data
.
children
}
]
});
var
treemapData
=
treemapChart
.
getModel
().
getSeriesByIndex
(
0
).
getData
();
var
tree
=
treemapData
.
tree
;
echarts
.
registerMap
(
'
treemap
'
,
{
type
:
'
FeatureCollection
'
,
features
:
treemapData
.
mapArray
(
function
(
idx
)
{
var
itemLayout
=
treemapData
.
getItemLayout
(
idx
);
if
(
itemLayout
&&
itemLayout
.
height
&&
itemLayout
.
width
&&
!
itemLayout
.
invisible
)
{
return
{
type
:
'
Feature
'
,
geometry
:
{
type
:
'
Polygon
'
,
coordinates
:
[[
[
itemLayout
.
x
,
2048
-
itemLayout
.
y
],
[
itemLayout
.
x
+
itemLayout
.
width
,
2048
-
itemLayout
.
y
],
[
itemLayout
.
x
+
itemLayout
.
width
,
2048
-
itemLayout
.
y
-
itemLayout
.
height
],
[
itemLayout
.
x
,
2048
-
itemLayout
.
y
-
itemLayout
.
height
]
]]
},
properties
:
{
name
:
treemapData
.
getName
(
idx
)
}
}
}
}).
filter
(
function
(
item
)
{
return
!!
item
;
})
});
var
regions
=
treemapData
.
mapArray
(
function
(
idx
)
{
var
itemLayout
=
treemapData
.
getItemLayout
(
idx
);
if
(
itemLayout
&&
itemLayout
.
height
&&
itemLayout
.
width
&&
!
itemLayout
.
invisible
)
{
return
{
height
:
tree
.
getNodeByDataIndex
(
idx
).
depth
+
1
,
name
:
treemapData
.
getName
(
idx
)
// itemStyle: {
// areaColor: treemapData.getItemVisual(idx, 'color')
// }
};
}
}).
filter
(
function
(
item
)
{
return
!!
item
;
});
myChart
.
setOption
({
geo3D
:
{
silent
:
true
,
map
:
'
treemap
'
,
instancing
:
true
,
regions
:
regions
,
aspectScale
:
1
,
lambertMaterial
:
{
detailTexture
:
treemapChart
},
projectUVOnGround
:
true
,
postEffect
:
{
enable
:
true
,
screenSpaceAmbientOcclusion
:
{
enable
:
true
,
radius
:
3
,
intensity
:
1.5
},
depthOfField
:
{
enable
:
true
,
blurRadius
:
3
}
},
viewControl
:
{
minBeta
:
-
Infinity
,
maxBeta
:
Infinity
}
},
series
:
[]
});
window
.
addEventListener
(
'
resize
'
,
function
()
{
myChart
.
resize
();
});
});
</script>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录