complete knowledge graph and modify the province to place
This commit is contained in:
parent
89b3bdf9cf
commit
d269d45c37
62
demo.html
62
demo.html
|
@ -69,12 +69,12 @@
|
|||
<div class="show_detail">
|
||||
<span class="iconfont icon-gengduo more_icon"></span>
|
||||
<ul class="detail_info">
|
||||
<li class="info_txt" data-key="prov">省份</li>
|
||||
<li class="info_txt" data-key="prov">地点</li>
|
||||
<li class="info_txt" data-key="lon">经纬度</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="search-prov">
|
||||
<input class="search_input" placeholder="请输入省份" />
|
||||
<input class="search_input" placeholder="请输入地点" />
|
||||
<span class="search_icon iconfont icon-search"></span>
|
||||
</div>
|
||||
<div class="lat_lon_sec">
|
||||
|
@ -1094,42 +1094,51 @@
|
|||
"links":[]
|
||||
}}
|
||||
currentGraph = {
|
||||
nodes: {},
|
||||
links: {},
|
||||
}
|
||||
nodeMap = {};
|
||||
category = 1
|
||||
symbolSize = 40
|
||||
nodes: {},
|
||||
links: {},
|
||||
}
|
||||
nodeMap = {};
|
||||
category = 1
|
||||
symbolSize = 40
|
||||
init(city)
|
||||
});
|
||||
|
||||
myChart.setOption(option);
|
||||
|
||||
function fillInfo(result) {
|
||||
function fillInfo(result, name) {
|
||||
// graphList = {"keyword":{
|
||||
// "nodes":[],
|
||||
// "links":[]
|
||||
// }}
|
||||
if (graphList.keyword.nodes.length == 0) {
|
||||
formNode = {"name":result.data.entity, "category":category, "symbolSize":symbolSize}
|
||||
formNode = {"name":name, "category":category, "symbolSize":symbolSize}
|
||||
graphList.keyword.nodes[0]=formNode
|
||||
category += 1
|
||||
symbolSize -= 5
|
||||
}
|
||||
else if (graphList.keyword.nodes[0].name == result.data.entity) {
|
||||
else if (graphList.keyword.nodes[0].name == name) {
|
||||
return 0
|
||||
}
|
||||
else {
|
||||
// console.log(name)
|
||||
category = nodeMap[name].category + 1
|
||||
symbolSize = nodeMap[name].symbolSize - 5
|
||||
}
|
||||
|
||||
nodeLen = graphList.keyword.nodes.length
|
||||
linkLen = graphList.keyword.links.length
|
||||
source = result.data.entity
|
||||
// console.log(result)
|
||||
source = name
|
||||
for (i = 0; i < result.data.avp.length; i++) {
|
||||
if (source == result.data.avp[i][1]) {
|
||||
nodeLen--
|
||||
linkLen--
|
||||
continue
|
||||
}
|
||||
formNode = {"name":result.data.avp[i][1], "category":category, "symbolSize":symbolSize}
|
||||
graphList.keyword.nodes[nodeLen+i]=formNode
|
||||
formLink = {"source":source, "target":result.data.avp[i][1]}
|
||||
graphList.keyword.links[linkLen+i]=formLink
|
||||
}
|
||||
// console.log(graphList)
|
||||
}
|
||||
|
||||
|
||||
|
@ -1158,7 +1167,7 @@
|
|||
alert("nothing")
|
||||
return 0
|
||||
}
|
||||
fillInfo(result)
|
||||
fillInfo(result, name)
|
||||
nodeMap = {};
|
||||
graph = graphList.keyword
|
||||
for (let i = 0; i < graph.nodes.length; i++) {
|
||||
|
@ -1186,7 +1195,6 @@
|
|||
};
|
||||
}
|
||||
redrawGraph();
|
||||
// append(result.data.entity)
|
||||
}
|
||||
|
||||
function loadData(name) {
|
||||
|
@ -1195,13 +1203,9 @@
|
|||
alert("nothing")
|
||||
return 0
|
||||
}
|
||||
fillInfo(result)
|
||||
// nodeMap = {};
|
||||
fillInfo(result, name)
|
||||
nodeMap = {};
|
||||
graph = graphList.keyword
|
||||
// console.log("qiubing2")
|
||||
console.log(graph)
|
||||
// console.log(nodeMap)
|
||||
len = nodeMap.length
|
||||
for (let i = 0; i < graph.nodes.length; i++) {
|
||||
nodeMap[graph.nodes[i].name] = graph.nodes[i];
|
||||
nodeMap[graph.nodes[i].name]['links'] = {};
|
||||
|
@ -1232,10 +1236,6 @@
|
|||
|
||||
let node = nodeMap[nodeName];
|
||||
|
||||
// console.log(node)
|
||||
// console.log("qiubing3")
|
||||
// console.log(nodeName)
|
||||
// console.log(nodeMap)
|
||||
if (node.hasAppend === true || Object.keys(node.nodes).length === 0 || Object.keys(node.links).length === 0) {
|
||||
alert("无法继续展开");
|
||||
return
|
||||
|
@ -1269,10 +1269,8 @@
|
|||
}
|
||||
// 根据更新后的option重新画图
|
||||
function redrawGraph() {
|
||||
// console.log(currentGraph)
|
||||
optionGraph.series[0].data = Object.values(currentGraph.nodes);
|
||||
optionGraph.series[0].links = Object.values(currentGraph.links);
|
||||
// console.log(optionGraph);
|
||||
myChartGraph.setOption(optionGraph);
|
||||
}
|
||||
|
||||
|
@ -1315,14 +1313,14 @@
|
|||
{
|
||||
name: 4,
|
||||
itemStyle: {
|
||||
color: '#61a0a8'
|
||||
color: '#999ea4'
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
name: 5,
|
||||
itemStyle: {
|
||||
color: '#999ea4'
|
||||
color: '#555555'
|
||||
},
|
||||
}
|
||||
],
|
||||
|
@ -1363,10 +1361,6 @@
|
|||
if (node.hasAppend === true) {
|
||||
remove(node.name)
|
||||
} else {
|
||||
// console.log("qiubing")
|
||||
// console.log(node)
|
||||
// console.log(nodeMap)
|
||||
// console.log(node.name)
|
||||
loadData(node.name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue