Skip to content

Commit 4bad845

Browse files
[fix]知识图谱增加右键菜单 review by songym
1 parent 46cd729 commit 4bad845

File tree

15 files changed

+961
-64
lines changed

15 files changed

+961
-64
lines changed

examples/leaflet/knowledgeGraphMap.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
<script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
1111
<style>
1212
body {
13-
position: absolute;
14-
top: 0;
1513
margin: 0;
1614
padding: 0;
1715
width: 100%;
18-
height: 100%;
16+
height: 100vh;
17+
overflow: hidden;
1918
}
20-
2119
#knowledgeGraph {
2220
width: 100%;
2321
height: 100%;

examples/mapboxgl/knowledgeGraphMap.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
<script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
1111
<style>
1212
body {
13-
position: relative;
14-
top: 0;
1513
margin: 0;
1614
padding: 0;
1715
width: 100%;
18-
height: 100%;
16+
height: 100vh;
1917
overflow: hidden;
2018
}
2119

@@ -32,7 +30,7 @@
3230
<script type="text/javascript">
3331
var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
3432
const graphmap = new mapboxgl.supermap.GraphMap(
35-
host + '/iserver/services/knowledgeGraph-simple/restjsr/graph/graphmaps/图谱'
33+
host + '/iserver/services/knowledgeGraph-sample/restjsr/graph/graphmaps/图谱'
3634
);
3735
</script>
3836
</body>

examples/maplibregl/knowledgeGraphMap.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
<script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
1111
<style>
1212
body {
13-
position: relative;
14-
top: 0;
1513
margin: 0;
1614
padding: 0;
1715
width: 100%;
18-
height: 100%;
16+
height: 100vh;
1917
overflow: hidden;
2018
}
2119

examples/openlayers/knowledgeGraphMap.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
<title data-i18n="resources.title_knowledgeGraphMap"></title>
1010
<script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
1111
<style>
12-
body {
13-
position: absolute;
14-
top: 0;
12+
body {
1513
margin: 0;
1614
padding: 0;
1715
width: 100%;
18-
height: 100%;
16+
height: 100vh;
17+
overflow: hidden;
1918
}
2019

2120
#knowledgeGraph {
@@ -31,7 +30,7 @@
3130
<script type="text/javascript">
3231
var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
3332
const graphmap = new ol.supermap.GraphMap(
34-
host + '/iserver/services/knowledgeGraph-simple/restjsr/graph/graphmaps/图谱'
33+
host + '/iserver/services/knowledgeGraph-simple/restjsr/graph/graphmaps/图谱',{}
3534
);
3635
</script>
3736
</body>

src/common/iServer/KnowledgeGraphService.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ export class KnowledgeGraphService extends CommonServiceBase {
4646
this.processAsync({ url, params, method: 'GET', callback });
4747
}
4848

49+
// /**
50+
// * @function KnowledgeGraphService.prototype.queryById
51+
// * @description 根据实体id查询关联节点。
52+
// * @param {string} id - 实体id。
53+
// * @param {RequestCallback} callback 回调函数。
54+
// */
55+
// queryById(id, callback) {
56+
// const paramKey = 'cypherQuery';
57+
// const url = Util.urlAppend(this.url + '/query.json', `${paramKey}=match p=(n)-[]-(m) where id(n)=${id} return p;`);
58+
// this.processAsync({ url, method: 'GET', callback });
59+
// }
60+
4961
// /**
5062
// * @function KnowledgeGraphService.prototype.getMetaData
5163
// * @description 获取元信息(展示所有实体类型和关系类型。)
@@ -90,15 +102,32 @@ export class KnowledgeGraphService extends CommonServiceBase {
90102
return;
91103
}
92104
const queries = graphMap.dataContent.queries.query;
105+
const expandQueries = this._getGraphMapExpandQuery(graphMap);
106+
queries.push(...expandQueries);
93107
for (let j = 0; j < queries.length; j++) {
94108
const cypherQuery = queries[j];
95109
const res = await this._queryDataBySql(cypherQuery);
96110
data = data.concat([], res);
97111
}
98-
99112
return { data, graphMap };
100113
}
101114

115+
/**
116+
* @private
117+
* @function KnowledgeGraphService.prototype._getGraphMapExpandQuery
118+
* @description 获取graphMap图谱展开节点的query条件
119+
* @param {Object} graphMap -将iServer GraphMap图谱服务的数据
120+
* @param {Array.<string>} 查询条件
121+
*/
122+
_getGraphMapExpandQuery(graphMap) {
123+
const queries = [];
124+
const expandIds = (graphMap.dataContent.expand && JSON.parse(graphMap.dataContent.expand)) || [];
125+
expandIds.forEach((id) => {
126+
queries.push(`match p=(n)-[]-(m) where id(n)=${id} return p;`);
127+
});
128+
return queries;
129+
}
130+
102131
// /**
103132
// * @private
104133
// * @function KnowledgeGraphService.prototype.getEntities

0 commit comments

Comments
 (0)