|
@@ -3,66 +3,6 @@ const { post, api } = require('./api.js');
|
|
|
|
|
|
|
|
|
//关系图
|
|
|
-// function showKnowledgeGraph(keyWord, resultShowId, type) {
|
|
|
-// keyWord = keyWord.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
-// if(isEmpty(keyWord)){
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// var data = {"name":keyWord, 'tree_type':tree_type};
|
|
|
-// $.ajax({
|
|
|
-// type: 'GET',
|
|
|
-// url: '/knowledge',
|
|
|
-// data: data,
|
|
|
-// dataType: 'json',
|
|
|
-// success:function(data){
|
|
|
-// keyWord = data['name']
|
|
|
-// nodes = data['node'];
|
|
|
-// links = data['link'];
|
|
|
-// // nodes = [
|
|
|
-// // {"category": 0, "name": 0, "label":'e1',"symbolSize":40},
|
|
|
-// // {"category": 1, "name": 1, "label":'',"symbol":"diamond", "symbolSize": 10},
|
|
|
-// // {"category": 2, "name": 2, "label": 'e2', "symbolSize": 28},
|
|
|
-// // {"category": 0, "name": 3,"label": 'e1_pro', "symbol":"rect", "symbolSize": [40, 16]},
|
|
|
-// // {"category": 1, "name": 4,"label": 'rel_pro', "symbol":"rect", "symbolSize": [40, 16]},
|
|
|
-// // {"category": 2, "name": 5,"label": 'e2_pro', "symbol":"rect", "symbolSize": [40, 16]}
|
|
|
-// //
|
|
|
-// // ];
|
|
|
-// // links = [
|
|
|
-// // {"source": 0, "target": 1, "value":'rel'},
|
|
|
-// // {"source": 1, "target": 2, "value":''},
|
|
|
-// // {"source": 2, "target": 3, "value":''},
|
|
|
-// // {"source": 2, "target": 4, "value":''},
|
|
|
-// // {"source": 2, "target": 5, "value":''}
|
|
|
-// // ];
|
|
|
-// if(nodes.length < 5){
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// else if(visitQue[visitQue.length - 1] == keyWord)
|
|
|
-// {
|
|
|
-// return;
|
|
|
-// }else{
|
|
|
-// visitQue.push(keyWord);
|
|
|
-// }
|
|
|
-// if(type == 0){
|
|
|
-// $('#searchPlaceholder').val(keyWord);
|
|
|
-// }else if(type == 1){
|
|
|
-// var txt = $(".select_txt").text();
|
|
|
-// updateTree(keyWord, txt);
|
|
|
-// }else if(type == 2){
|
|
|
-// $('#searchPlaceholder').val(keyWord);
|
|
|
-// }else {
|
|
|
-// tree_type = data['tree_type'];
|
|
|
-// console.log(tree_type);
|
|
|
-// updateTree(keyWord,tree_type);
|
|
|
-// }
|
|
|
-// drawGraph(data,resultShowId);
|
|
|
-// },
|
|
|
-// error:function(e){
|
|
|
-// last_word = visitQue.pop();
|
|
|
-// showKnowledgeGraph(last_word, 'graph', 3);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
function getGraph(val, type){
|
|
|
post(api.getGraph,{
|
|
|
"inputStr": val,
|
|
@@ -109,6 +49,7 @@ function drawGraph(data,resultShowId) {
|
|
|
edgeSymbol: ['circle', 'arrow'],
|
|
|
edgeSymbolSize: [1, 5],
|
|
|
edgeLabel: {
|
|
|
+ cursor:'pointer',
|
|
|
normal: {
|
|
|
textStyle: {
|
|
|
fontSize: 20
|
|
@@ -130,6 +71,7 @@ function drawGraph(data,resultShowId) {
|
|
|
normal: {
|
|
|
width: 2,
|
|
|
// color: 'target',
|
|
|
+ cursor:'pointer',
|
|
|
curveness: 0,
|
|
|
opacity: 1
|
|
|
}
|
|
@@ -153,6 +95,7 @@ function drawGraph(data,resultShowId) {
|
|
|
normal: {
|
|
|
show: true,
|
|
|
textStyle: {
|
|
|
+ cursor:'pointer',
|
|
|
},
|
|
|
formatter: function (x) {
|
|
|
var tmp = x.data.label;
|
|
@@ -170,102 +113,7 @@ function drawGraph(data,resultShowId) {
|
|
|
]
|
|
|
};
|
|
|
myChart.setOption(option);
|
|
|
- // myChart = echarts.init(document.getElementById(resultShowId),'light');
|
|
|
- // categories = data['categories'];
|
|
|
- // var legends = categories.slice(2, categories.length);
|
|
|
- // option = {
|
|
|
- // color:colors,
|
|
|
- // tooltip: {
|
|
|
- // formatter: function (x) {
|
|
|
- // return x.data.label;
|
|
|
- // }
|
|
|
- // },
|
|
|
- // toolbox:{
|
|
|
- // show:true,
|
|
|
- // feature:{
|
|
|
- // myBack: {
|
|
|
- // show:true,
|
|
|
- // title:'后退',
|
|
|
- // icon:back_icon,
|
|
|
- // onclick:function () {
|
|
|
- // word = visitQue.pop();
|
|
|
- // if(visitQue.length > 0){
|
|
|
- // word = visitQue.pop();
|
|
|
- // }
|
|
|
- // showKnowledgeGraph(word, 'graph',4);
|
|
|
- // },
|
|
|
- // },
|
|
|
- // restore: {
|
|
|
- // show: true
|
|
|
- // },
|
|
|
- // saveAsImage: {
|
|
|
- // show: true
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
- // legend: {
|
|
|
- // type: 'scroll',
|
|
|
- // bottom: 0,
|
|
|
- // icon: 'circle',
|
|
|
- // data: legends.map(function (a) {
|
|
|
- // return a.name;
|
|
|
- // })
|
|
|
- // },
|
|
|
- // series: [
|
|
|
- // {
|
|
|
- // type: 'graph',
|
|
|
- // layout: 'force',
|
|
|
- // categories: categories,
|
|
|
- // roam: 'move',
|
|
|
- // focusNodeAdjacency: true,
|
|
|
- // edgeSymbol: ['none', 'arrow'],
|
|
|
- // edgeSymbolSize: [1, 5],
|
|
|
- // force: {
|
|
|
- // repulsion: 500,
|
|
|
- // gravity: 0.8,
|
|
|
- // edgeLength: [4, 7],
|
|
|
- // layoutAnimation : true
|
|
|
- // },
|
|
|
- // hoverAnimation:false,
|
|
|
- // // draggable: false,
|
|
|
- // // legendHoverLink: false,
|
|
|
- // lineStyle: {
|
|
|
- // normal: {
|
|
|
- // width: 2,
|
|
|
- // color: 'target',
|
|
|
- // curveness: 0,
|
|
|
- // opacity: 1
|
|
|
- // }
|
|
|
- // },
|
|
|
- // edgeLabel: {
|
|
|
- // normal: {
|
|
|
- // show: true,
|
|
|
- // formatter:"{c}"
|
|
|
- // }
|
|
|
- // },
|
|
|
- // label: {
|
|
|
- // normal: {
|
|
|
- // show: true,
|
|
|
- // formatter: function (x) {
|
|
|
- // var tmp = x.data.label;
|
|
|
- // if(tmp.length >= 8){
|
|
|
- // tmp = tmp.substring(0,3);
|
|
|
- // tmp = tmp + "...";
|
|
|
- // }
|
|
|
- // return tmp;
|
|
|
- // },
|
|
|
- // textStyle: {
|
|
|
- // color: '#000',
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
- // nodes: nodes,
|
|
|
- // links: links
|
|
|
- // }
|
|
|
- // ]
|
|
|
- // };
|
|
|
- // myChart.on('click',dataClick);
|
|
|
- // myChart.setOption(option);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function dataClick(param){
|
|
@@ -299,148 +147,9 @@ function dataClick(param){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// //菜单
|
|
|
-// var setting = {
|
|
|
-// view: {
|
|
|
-// dblClickExpand: false,
|
|
|
-// showLine: true,
|
|
|
-// selectedMulti: false,
|
|
|
-// },
|
|
|
-// data: {
|
|
|
-// simpleData: {
|
|
|
-// enable: true,
|
|
|
-// idKey: "id",
|
|
|
-// pIdKey: "pId",
|
|
|
-// rootPId: ""
|
|
|
-// }
|
|
|
-// },
|
|
|
-// callback: {
|
|
|
-// beforeClick: function (treeId, treeNode) {
|
|
|
-// var zTree = $.fn.zTree.getZTreeObj("tree");
|
|
|
-// if (treeNode.isParent) {
|
|
|
-// zTree.expandNode(treeNode);
|
|
|
-// return false;
|
|
|
-// } else {
|
|
|
-// showKnowledgeGraph(treeNode.name, 'graph', 0);
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// };
|
|
|
-// var zNodes=[];
|
|
|
-// var selectedNode = "";
|
|
|
|
|
|
-// $(document).ready(function () {
|
|
|
-// var url = window.location.pathname;
|
|
|
-// if(url == '/mekg'){
|
|
|
-// var data = {"name":'tree'};
|
|
|
-// var t = $("#tree");
|
|
|
|
|
|
-// var url = window.location.search;
|
|
|
-// if(url.indexOf("?") != -1){
|
|
|
-// var str = decodeURI(url);
|
|
|
-// var name = str.split("=")[1];
|
|
|
-// var tree_ls = {'0':'疾病','1':'药物','2':'诊疗','3':'症状'};
|
|
|
-// showKnowledgeGraph(name,'graph', 2);
|
|
|
-// updateTree(name,tree_ls[str[2]]);
|
|
|
-// }
|
|
|
-// else{
|
|
|
-// showKnowledgeGraph("支气管肺癌" ,"graph",2);
|
|
|
-// updateTree("支气管肺癌","疾病");
|
|
|
-// }
|
|
|
-// }else {
|
|
|
-// showGraphMenu('graph_menu');
|
|
|
-// // get_recommend();
|
|
|
-// // setInterval(get_recommend, 3000);
|
|
|
-// }
|
|
|
|
|
|
-// });
|
|
|
-
|
|
|
-// function showGraphMenu(dom_id) {
|
|
|
-// var data = {'name': dom_id}
|
|
|
-// $.ajax({
|
|
|
-// type: 'GET',
|
|
|
-// url: '/circle_menu',
|
|
|
-// data: data,
|
|
|
-// dataType: 'json',
|
|
|
-// success: function (data) {
|
|
|
-// var nodes = data['nodes'];
|
|
|
-// var links = data['links'];
|
|
|
-// var myChart = echarts.init(document.getElementById(dom_id), 'macarons')
|
|
|
-// var categories = [];
|
|
|
-// for (var i = 0; i < 10; i++) {
|
|
|
-// categories[i] = {
|
|
|
-// name: '' + i
|
|
|
-// }
|
|
|
-// }
|
|
|
-// nodes.forEach(function (node) {
|
|
|
-// node.itemStyle = null;
|
|
|
-// node.value = node.symbolSize;
|
|
|
-// node.category = (node.name % 10);
|
|
|
-// });
|
|
|
-// option = {
|
|
|
-// animationDurationUpdate: 1000,
|
|
|
-// animationEasingUpdate: 'quinticInOut',
|
|
|
-// tooltip: {
|
|
|
-// formatter: function (x) {
|
|
|
-// return x.data.showName;
|
|
|
-// }
|
|
|
-// },
|
|
|
-// series: [{
|
|
|
-// name: '100种常见病',
|
|
|
-// type: 'graph',
|
|
|
-// layout: 'circular',
|
|
|
-// circular: {
|
|
|
-// rotateLabel: true
|
|
|
-// },
|
|
|
-// data: nodes,
|
|
|
-// links: links,
|
|
|
-// categories: categories,
|
|
|
-// label: {
|
|
|
-// normal: {
|
|
|
-// position: 'right',
|
|
|
-// show: true,
|
|
|
-// formatter: function (x) {
|
|
|
-// var len = x.data.showName.length;
|
|
|
-// if (len < 5) {
|
|
|
-// return x.data.showName;
|
|
|
-// } else {
|
|
|
-// return '';
|
|
|
-// }
|
|
|
-
|
|
|
-// },
|
|
|
-// }
|
|
|
-// },
|
|
|
-// lineStyle: {
|
|
|
-// normal: {
|
|
|
-// color: 'source',
|
|
|
-// curveness: 0.3
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }]
|
|
|
-// };
|
|
|
-// function nodeClick(param) {
|
|
|
-// console.log('param',param)
|
|
|
-// var data = param.data;
|
|
|
-// if (data.source !== undefined && data.target !== undefined) {
|
|
|
-// myChart.setOption(option);
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// uri = encodeURI("/mekg?v0=" + data.showName);
|
|
|
-// // console.log(uri);
|
|
|
-// window.open(uri);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// myChart.on('click', nodeClick);
|
|
|
-// myChart.setOption(option);
|
|
|
-
|
|
|
-// },
|
|
|
-// error: function (e) {
|
|
|
-// console.log('error loading graph menu');
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
function getTree(subType, type,showNodeName){
|
|
|
post(api.getTree,
|
|
|
{
|
|
@@ -585,48 +294,9 @@ function updateTree(keyWord, txt) {
|
|
|
$('.iconSelect').remove()
|
|
|
|
|
|
$('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
|
|
|
- // $.ajax({
|
|
|
- // type: 'GET',
|
|
|
- // url: '/load_tree/' + txt,
|
|
|
- // // data: data,
|
|
|
- // dataType: 'json',
|
|
|
- // success: function (data) {
|
|
|
- // zNodes= data['nodes'];
|
|
|
- // tree_type = zNodes[0]['name'];
|
|
|
- // $.fn.zTree.init(t, setting, zNodes);
|
|
|
- // var zTree = $.fn.zTree.getZTreeObj("tree");
|
|
|
- // zTree.selectNode(zTree.getNodeByParam("name", keyWord));
|
|
|
- // },
|
|
|
- // error: function (e) {
|
|
|
- // zNodes = [];
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
-// function queryGraph() {
|
|
|
-// var url = window.location.pathname;
|
|
|
-// if(url == '/mekg'){
|
|
|
-// var node_name = document.getElementById("searchPlaceholder").value;
|
|
|
-// $('#word').empty();
|
|
|
-// $('#word').hide();
|
|
|
-// showKnowledgeGraph(node_name, 'graph', 1);
|
|
|
-// }else{
|
|
|
-// var node_name = document.getElementById("search1").value;
|
|
|
-// node_name = node_name.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
-// $('#word1').empty();
|
|
|
-// $('#word1').hide();
|
|
|
-// if(node_name.length == 0){
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// var type_dic = {'疾病':'0','药物':'1', '诊疗':'2', '症状':'3'};
|
|
|
-// var txt = $('.select_txt1').text();
|
|
|
-// console.log(txt);
|
|
|
-// uri = encodeURI('/mekg?v' + type_dic[txt] + '='+node_name)
|
|
|
-// window.open(uri);
|
|
|
-// }
|
|
|
|
|
|
-// }
|
|
|
|
|
|
function isEmpty(obj){
|
|
|
if(typeof obj == "undefined" || obj == null || obj == ""){
|
|
@@ -650,75 +320,6 @@ function getKeyEvent(evt) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// function getSug() {
|
|
|
-// var url = window.location.pathname, input_id, hint_id, select_cls;
|
|
|
-// if(url == '/mekg'){
|
|
|
-// input_id = "searchPlaceholder";
|
|
|
-// hint_id = "word";
|
|
|
-// select_cls = "select_txt";
|
|
|
-// }else {
|
|
|
-// input_id = "search1";
|
|
|
-// hint_id = "word1";
|
|
|
-// select_cls = "select_txt1";
|
|
|
-// }
|
|
|
-// var input_name = document.getElementById(input_id).value;
|
|
|
-// input_name = input_name.replace(/(^\s*)|(\s*$)/g, "")
|
|
|
-// if (isEmpty(input_name) || keyDown == true){
|
|
|
-// $('#' + hint_id).empty();
|
|
|
-// $('#' + hint_id).hide();
|
|
|
-// if(keyDown == true){
|
|
|
-// keyDown = false;
|
|
|
-// }
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// var res_ls = [];
|
|
|
-// var type_dic = {'疾病':0,'药物':1, '诊疗':2, '症状':3};
|
|
|
-// var txt = $("." + select_cls).text();
|
|
|
-// var data = {'type': type_dic[txt]};
|
|
|
-// $.ajax({
|
|
|
-// type: 'GET',
|
|
|
-// url: '/get_sug/' + input_name,
|
|
|
-// data : data,
|
|
|
-// dataType: 'json',
|
|
|
-// beforeSend:function(){
|
|
|
-// $('#' + hint_id).append('<div>loading......</div>');
|
|
|
-// },
|
|
|
-// success: function (data) {
|
|
|
-// res_ls = data['sug'];
|
|
|
-// // console.log(res_ls);
|
|
|
-// $('#' + hint_id).empty().show();
|
|
|
-// if(res_ls == false){
|
|
|
-// $('#' + hint_id).append('<div class="error">Not Found </div>');
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// for(var i = 0,l=res_ls.length;i<l;i++){
|
|
|
-// $('#' + hint_id).append('<div class="click_work" onclick="select_word(this)">'+ res_ls[i] +'</div>');
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $('#' + hint_id).show();
|
|
|
-// },
|
|
|
-// error: function (e) {
|
|
|
-// $('#' + hint_id).empty().show();
|
|
|
-// $('#' + hint_id).append('<div class="click_work">Not Found </div>');
|
|
|
-// $('#' + hint_id).show();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
-
|
|
|
-// function select_word(obj) {
|
|
|
-// var url = window.location.pathname, input_id, hint_id;
|
|
|
-// var word = $(obj).text();
|
|
|
-// if(url == '/mekg'){
|
|
|
-// input_id = "searchPlaceholder";
|
|
|
-// hint_id = "word";
|
|
|
-// }else{
|
|
|
-// input_id = "search1";
|
|
|
-// hint_id = "word1";
|
|
|
-// }
|
|
|
-
|
|
|
-// $('#' + input_id).val(word);
|
|
|
-// $('#' + hint_id).hide();
|
|
|
-// }
|
|
|
|
|
|
module.exports ={
|
|
|
drawGraph,
|