@Ghazascanner
_2019runbot
Ghazascanner File Manager
server :Linux www.thesweb.ru 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64
Current Path :
/
var
/
www
/
www-root
/
data
/
www
/
new.labinform.ru
/
oent_thes
/
Path :
Upload File :
New :
File
Dir
/var/www/www-root/data/www/new.labinform.ru/oent_thes/thes_network.php
<div data-options="region:'west', border: true, collapsed: true, width: '50%', split: true, onResize: function() { if (thes_network && thes_network.setOptions) thes_network.setOptions({ height: (document.getElementById('thes_network').parentElement.offsetHeight - 1) + 'px' }); }, tools: '#thes_network_tools'/*, hideCollapsedContent:false*/" title="Граф" > <div id="thes_network"> </div> <div id="thes_network_tools"> <input title="Динамика/Статика" class="easyui-switchbutton" style="margin-right: 6px; width: 50px; height: 16px" data-options="onText: 'Дин.', offText: 'Стат.', checked: true, onChange: thes_change_dinam"> <a title="Разложить по новой" href="javascript:void(0)" class="icon-reload" onclick="javascript:thes_network.stabilize();" style="margin-right: 6px"></a> <a title="Добавить концепт" href="javascript:void(0)" class="icon-add" onclick="javascript:add_conc_to_graph('#thes_network'); /*ThesConcepts.add_conc_to_graph('#thes_network');*/" style="margin-right: 6px"></a> <a title="Добавить дерево" href="javascript:void(0)" class="icon-tree" onclick="javascript:add_tree_to_graph('#thes_network');" style="margin-right: 6px"></a> <a title="Сохранить в XML" href="javascript:void(0)" class="icon-save" onclick="javascript:thes_network_save_to_file();" style="margin-right: 6px"></a> <a title="Сохранить в JSON" href="javascript:void(0)" class="icon-save" onclick="javascript:thes_network_save_to_json();" style="margin-right: 6px"></a> <a title="Очистить граф" href="javascript:void(0)" class="icon-cancel" onclick="javascript:ThesConcepts.clear_graph('#thes_network');" style="margin-right: 6px"></a> <a title="Настройки" href="javascript:void(0)" class="icon-edit" onclick="javascript:$('#thes_network_settings').dialog('open');" style="margin-right: 6px"></a> <a href="#" class="easyui-menubutton" data-options="showEvent: 'click', menu:'#thes_network_tools_menu', plain: true" style="width: 60px; height: 16px; font-weight: bold">Еще...</a> <div id="thes_network_tools_menu" > <div data-options="iconCls:'undo'" onclick="javascript:set_sel_nodes_phys(false);">Отключить вершины при раскладке</div> <div data-options="iconCls:'undo'" onclick="javascript:set_sel_nodes_phys(true);">Включить вершины при раскладке</div> <div data-options="iconCls:'stop'" onclick="javascript:set_sel_nodes_fixed(true);">Жестко закрепить вершины</div> <div data-options="iconCls:'stop'" onclick="javascript:set_sel_nodes_fixed(false);">Жестко открепить вершины</div> <div data-options="iconCls:'undo'" onclick="javascript:add_child_sel(true);">Выделить связанные</div> </div> </div> <!-- settings dialog --> <div id="thes_network_settings" class="easyui-dialog dialogtext" title="Выбор запроса и осей" data-options="network: thes_network, network_options: thes_network_options, cls: 'c1', border: 'thin', closed: true, onOpen: open_thes_network_settings, buttons:[{text: 'Сохранить', handler: function() { thes_network_settings_save(); $('#thes_network_settings').dialog('close');} }, { text:'Отмена', handler: function(){ $('#thes_network_settings').dialog('close'); }}]" style="height: 600px; width: 400px"> <fieldset class="thes_network_fieldset"><legend>Вершины</legend> <label for="thes_network_settings_nodes_font_face" class="label-top">Шрифт:</label> <select id="thes_network_settings_nodes_font_face" class="easyui-combobox" data-options="readonly: false, panelHeight: 'auto', onChange: thes_network_settings_save" style="width: 170px"> <option>Arial</option> <option>Tahoma</option> <option>Times New Roman</option> <option>Sans-Serif</option> <option>Cursive</option> <option>Monospace</option> <option>Verdana</option> <option>Serif</option> </select> <label for="thes_network_settings_nodes_font_size" class="label-top">Размер шрифта: <b>10</b></label> <input class="easyui-slider" id="thes_network_settings_nodes_font_size" value="10" data-options="showTip: false, onChange: thes_network_settings_save" style="width:170px;"> </fieldset> <fieldset class="thes_network_fieldset"><legend>Связи</legend> <label for="thes_network_settings_edges_length" class="label-top">Длина: <b>200</b></label> <input class="easyui-slider" id="thes_network_settings_edges_length" value="200" data-options="showTip: false, onChange: thes_network_settings_save, max: 1000, min: 0" style="width:170px;"> <label for="thes_network_settings_edges_width" class="label-top">Толщина: <b>200</b></label> <input class="easyui-slider" id="thes_network_settings_edges_width" value="2" data-options="showTip: false, onChange: thes_network_settings_save, max: 30, min: 0" style="width: 170px;"> <label for="thes_network_settings_edges_roundness" class="label-top">Изгиб: <b>2</b></label> <input class="easyui-slider" id="thes_network_settings_edges_roundness" value="2" data-options="showTip: false, onChange: thes_network_settings_save, max: 10, min: 0" style="width: 170px;"> <label for="thes_network_settings_edges_font_size" class="label-top">Размер шрифта: <b>12</b></label> <input class="easyui-slider" id="thes_network_settings_edges_font_size" value="12" data-options="showTip: false, onChange: thes_network_settings_save, max: 100, min: 0" style="width: 170px;"> <label for="thes_network_settings_edges_font_face" class="label-top">Шрифт:</label> <select id="thes_network_settings_edges_font_face" class="easyui-combobox" data-options="readonly: false, panelHeight: 'auto', onChange: thes_network_settings_save" style="width: 170px"> <option>Arial</option> <option>Tahoma</option> <option>Times New Roman</option> <option>Sans-Serif</option> <option>Cursive</option> <option>Monospace</option> <option>Verdana</option> <option>Serif</option> </select> <label for="thes_network_settings_edges_font_align" class="label-top">Положение надписи:</label> <select id="thes_network_settings_edges_font_align" class="easyui-combobox" data-options="readonly: false, panelHeight: 'auto', onChange: thes_network_settings_save" style="width: 170px"> <option value="middle">по середине</option> <option value="top">сверху</option> <option value="bottom">снизу</option> <option value="horizontal">Горизонтально</option> </select> </fieldset> <fieldset class="thes_network_fieldset"><legend>Укладка</legend> <label for="thes_network_settings_physics_forceAtlas2Based_centralGravity" class="label-top">Центр. гравитация: <b>0.001</b></label> <input class="easyui-slider" id="thes_network_settings_physics_forceAtlas2Based_centralGravity" value="10" data-options="showTip: false, onChange: thes_network_settings_save, max: 300, min: 1" style="width: 170px;"> <label for="thes_network_settings_physics_forceAtlas2Based_gravitationalConstant" class="label-top">Гравитац. константа: <b>-15</b></label> <input class="easyui-slider" id="thes_network_settings_physics_forceAtlas2Based_gravitationalConstant" value="-15" data-options="showTip: false, onChange: thes_network_settings_save, max: 0, min: -200" style="width: 170px;"> <label for="thes_network_settings_physics_forceAtlas2Based_springConstant" class="label-top">Пружина-жесткость: <b>0.1</b></label> <input class="easyui-slider" id="thes_network_settings_physics_forceAtlas2Based_springConstant" value="10" data-options="showTip: false, onChange: thes_network_settings_save, max: 200, min: 1" style="width: 170px;"> <label for="thes_network_settings_physics_forceAtlas2Based_springLength" class="label-top">Пружина-длина: <b>50</b></label> <input class="easyui-slider" id="thes_network_settings_physics_forceAtlas2Based_springLength" value="50" data-options="showTip: false, onChange: thes_network_settings_save, max: 1000, min: 1" style="width: 170px;"> </fieldset> </div> <!-- tree dialog --> <div id="thes_network_tree_add" class="easyui-dialog dialogtext" title="Добавить дерево" data-options="network: thes_network, cls: 'c1', border: 'thin', closed: true"> <label for="thes_network_tree_add_conceptname" class="label-top">Концепт</label> <input id="thes_network_tree_add_conceptname" class="easyui-textbox" data-options="readonly: true" style="width: 300px"> <label for="thes_network_tree_add_updown" class="label-top">Направление</label> <select id="thes_network_tree_add_updown" class="easyui-combobox" data-options="readonly: false" style="width: 170px"> <option value="0">Дерево вниз</option> <option value="1">Дерево вверх</option> </select> <label for="thes_network_tree_add_maxlevel" class="label-top">Максимальная глубина</label> <input id="thes_network_tree_add_maxlevel" class="easyui-numberspinner" data-options="value: 5" style="width: 170px"> <label for="thes_network_tree_add_max_item" class="label-top">Максимум вершин</label> <input id="thes_network_tree_add_max_item" class="easyui-numberspinner" data-options="value: 200" style="width: 170px"> <br> <input class="easyui-checkbox" id="thes_network_tree_add_plusonelevel" name="thes_network_tree_add_plusonelevel" value="1" label="Дерево + 1"> <br> <input class="easyui-checkbox" id="thes_network_tree_add_closure" name="thes_network_tree_add_closure" value="1" label="Замыкание"> </div> </div> <script type="text/javascript"> function add_unique_edge(thes_edges, concept1id, concept2id, relationstr, aspect) { var eid = 'T' + concept1id + '_T' + concept2id; var efrom = 'T' + concept1id; var eto = 'T' + concept2id; var earrows = 'to'; var erel = relationstr; var easp = aspect; if ((relationstr == 'ВЫШЕ') || (relationstr == 'ЦЕЛОЕ')) { eid = 'T' + concept2id + '_T' + concept1id; efrom = 'T' + concept2id; eto = 'T' + concept1id; if (relationstr == 'ВЫШЕ') erel = 'НИЖЕ'; else erel = 'ЧАСТЬ'; } else if ((relationstr == 'АССОЦ') && (aspect == '1')) { eid = 'T' + concept2id + '_T' + concept1id; efrom = 'T' + concept2id; eto = 'T' + concept1id; easp = ''; erel = 'АСЦ2' } else if ((relationstr == 'АССОЦ') && (aspect == '2')) { easp = ''; erel = 'АСЦ2' } else if (relationstr == 'АССОЦ') { if (concept2id < concept1id) { eid = 'T' + concept2id + '_T' + concept1id; efrom = 'T' + concept2id; eto = 'T' + concept1id; earrows = 'to, from'; } } edashes = undefined; if (erel == 'ЧАСТЬ') edashes = [12,6]; else if (erel == 'АСЦ2') edashes = [4,5,0,5]; else if (erel == 'АССОЦ') edashes = [0,7]; if (!thes_edges.get(eid)) thes_edges.add({ id: eid, from: efrom, to: eto, label: erel + (easp ? '(' + easp + ')': ''), shadow: true, arrows: earrows, dashes: edashes, }); } function add_tree_to_graph(gr) { var sel = $('#concepts').datagrid('getSelected'); if (sel) { $('#thes_network_tree_add_conceptname').textbox('setValue', sel.conceptstr); $('#thes_network_tree_add_conceptname').textbox('options').conceptid = sel.conceptid; } else { $.messager.alert({ title:'Ошибка!', msg: 'Не выбран концепт', border:'thin', timeout: 0, showType:'slide' }); return false; } $('#thes_network_tree_add').dialog({width: 400, height: 340, closed: false, modal: true, buttons:[ {text: 'Построить', handler: function() { add_tree($('#thes_network_tree_add_conceptname').textbox('options').conceptid, $('#thes_network_tree_add_updown').combobox('getValue'), $('#thes_network_tree_add_maxlevel').numberspinner('getValue'), $('#thes_network_tree_add_max_item').numberspinner('getValue'), $('#thes_network_tree_add_plusonelevel').checkbox('options').checked, $('#thes_network_tree_add_closure').checkbox('options').checked ); $('#thes_network_tree_add').dialog('close'); } }, { text:'Отмена', handler: function(){ $('#thes_network_tree_add').dialog('close'); }} ], }); thes_network.fit(); return true; } function add_conc_to_graph(gr) { var sel = $('#concepts').datagrid('getSelected'); if (sel) { add_tree(sel.conceptid, 0, 1, 10000, false, true); add_tree(sel.conceptid, 1, 1, 10000, false, true); } thes_network.fit(); } function add_tree(cid, up, maxlevel, maxcount, plusonelevel, closure) { var noloadcolor = 'rgba(183,223,249,0.99)'; var loadcolor = 'rgba(178,236,208,0.99)'; var highlightcolor = 'rgba(255,183,183,0.99)'; d = $('#domain_filter').combobox('options').domainmask; url = 'json/action.php?action=gettreeconc&conceptid=' + cid + '&maxlevel=' + (maxlevel ? maxlevel : 0) + '&maxcount=' + (maxcount ? maxcount : 0) + '&up=' + (parseInt(up) ? '1' : '0') + '&plusonelevel=' + (plusonelevel ? '1' : '0') + '&zamykanie=' + (closure ? '1' : '0'); if (d > 0) url += '&domainmask=' + encodeURIComponent(d); if ($('#domain_filter_type').prop('checked')) url += '&domainmasktype=or' else url += '&domainmasktype=and'; $.ajax( { type: "GET", url: url, //data: jQuery.param(data), }).done(function(data) { if (data.error != "") $.messager.show({title:'Ошибка', msg: data.error, border:'thin', cls:'c3', timeout: 10000, showType:'slide' }); else { $.messager.show({ title:'Успешно', msg: data.message, border:'thin', cls:'c4', timeout: 5000, showType:'slide' }); data.nodes.forEach(function(it) { var find = thes_nodes.get('T' + it.cid); if (!find) thes_nodes.add({ id: 'T' + it.cid, label: it.cstr, rel_load: false, color: { background: noloadcolor, border:'#713E7F'/*, highlight: { background: highlightcolor, border: 'black'}*/}, }); }); data.edges.forEach(function(it) { add_unique_edge(thes_edges, it.concept1id, it.concept2id, it.relationstr, it.aspect); }); } }).fail(function(data) { $.messager.alert({ title:'Ошибка!', msg:'Ошибка: ' + data.responseText, border:'thin', timeout: 0, showType:'slide' }); }) ; //console.log(data); return true; } function thes_network_save_to_file() { var ids = thes_nodes.getIds(); var poss = thes_network.getPositions(); var str = '<' + '?xml version="1.0" encoding="UTF-8" standalone="no"?' + '>\n'; str += '<graphview>\n'; str += '<graph>\n'; str += '<nodes>\n'; for (var i = 0; i < thes_nodes.length; i++) { var id = ids[i]; var node = thes_nodes.get(id); str += '<node id="' + node.id + '" label="' + node.label + '">\n'; str += ' <attvalues>\n'; str += ' <attvalue for="weight" value="1"/>\n'; str += ' <attvalue for="docs_cnt" value="1"/>\n'; str += ' <attvalue for="description" value="1 документов"/>\n'; str += ' <attvalue for="node_type" value="Концепт "' + node.label + '""/>\n'; str += ' <attvalue for="feat_type" value="ТЕРМИН"/>\n'; str += ' <attvalue for="node_name" value="' + node.label + '"/>\n'; str += ' </attvalues>\n'; str += ' <viz:size value="10"/>'; str += ' <viz:position x="' + poss[id].x + '" y="' + poss[id].y + '" z="0.0"/>'; str += ' <viz:color b="0" g="0" r="0"/>'; str += '</node>\n'; } str += '</nodes>\n'; str += '<edges>\n'; var ids2 = thes_edges.getIds(); for (var i = 0; i < thes_edges.length; i++) { var id = ids2[i]; var edge = thes_edges.get(id); str += '<edge id="' + edge.id + '" label="' + edge.label + '" source="' + edge.from + '" target="' + edge.to + '" weight="1">\n'; str += ' <viz:color b="0" g="0" r="0" />\n'; str += ' <attvalues>\n'; str += ' <attvalue for="weight" value="1"/>\n'; if (edge.label == 'АССОЦ') str += ' <attvalue for="edge_type" value="undirected"/>\n'; else str += ' <attvalue for="edge_type" value="directed"/>\n'; str += ' </attvalues>\n'; str += '</edge>\n'; } str += '</edges>\n'; str += '</graph>\n'; str += '</graphview>\n'; var date = new Date(); var dateString = date.getFullYear() + '' + (date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth()+1) + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '_' + date.toLocaleTimeString().replace(/:/g, ''); downloadString(str, "text/xml", "thes_" + dateString + ".gexf"); return str; } function thes_network_save_to_json() { var ids = thes_nodes.getIds(); var poss = thes_network.getPositions(); var snodes = [] var ids2 = thes_edges.getIds(); for (var i = 0; i < ids.length; i++) { var id = ids[i]; var node = thes_nodes.get(id); var rels = []; for (var j = 0; j < ids2.length; j++) { var id2 = ids2[j]; var edge = thes_edges.get(id2); if (edge.from == id) { var node2 = thes_nodes.get(edge.to); rels.push({rel_name: edge.label, rel_concept_id: edge.to.substr(1), rel_concept_name: node2.label }); } //console.log(rels); } snodes.push({concept_id: node.id.substr(1), concept_name: node.label, pos_x: poss[id].x, pos_y: poss[id].y, rels: rels }); } var str = JSON.stringify(snodes); var date = new Date(); var dateString = date.getFullYear() + '' + (date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth()+1) + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '_' + date.toLocaleTimeString().replace(/:/g, ''); downloadString(str, "text/plain", "thes_" + dateString + ".json"); return str; } function downloadString(text, fileType, fileName) { var blob = new Blob([text], { type: fileType }); var a = document.createElement('a'); a.download = fileName; a.href = URL.createObjectURL(blob); a.dataset.downloadurl = [fileType, a.download, a.href].join(':'); a.style.display = "none"; document.body.appendChild(a); a.click(); document.body.removeChild(a); setTimeout(function() { URL.revokeObjectURL(a.href); }, 1500); } function thes_change_dinam(checked) { var o = null; if (checked) o = { physics: true }; else o = { physics: false }; //var xthes_network = $('#thes_network_settings').dialog('options').network; thes_network.setOptions(o); } function set_sel_nodes_fixed(en) { thes_network.getSelection().nodes.forEach(function(node) { thes_nodes.update({id: node, fixed: en }); }); } function set_sel_nodes_phys(en) { thes_network.getSelection().nodes.forEach(function(node) { thes_nodes.update({id: node, physics: en }); }); } function add_child_sel(en) { var arr = []; thes_network.getSelection().nodes.forEach(function(node) { arr.push(node); var cn = thes_network.getConnectedNodes(node); cn.forEach(function(node) {arr.push(node2); }); }); thes_network.setSelection({nodes: arr}); } function open_thes_network_settings() { var o = $('#thes_network_settings').dialog('options').network_options; $('#thes_network_settings_nodes_font_size').slider('setValue', o.nodes.font.size); $('#thes_network_settings_nodes_font_face').combobox('setValue', o.nodes.font.face); $('#thes_network_settings_edges_length').slider('setValue', o.edges.length); $('#thes_network_settings_edges_font_size').slider('setValue', o.edges.font.size); $('#thes_network_settings_edges_width').slider('setValue', o.edges.width); $('#thes_network_settings_edges_font_face').combobox('setValue', o.edges.font.face); $('#thes_network_settings_edges_font_align').combobox('setValue', o.edges.font.align); $('#thes_network_settings_edges_roundness').slider('setValue', o.edges.smooth.roundness * 10); $('#thes_network_settings_physics_forceAtlas2Based_centralGravity').slider('setValue', o.physics.forceAtlas2Based.centralGravity * 10000); $('#thes_network_settings_physics_forceAtlas2Based_gravitationalConstant').slider('setValue', o.physics.forceAtlas2Based.gravitationalConstant); $('#thes_network_settings_physics_forceAtlas2Based_springConstant').slider('setValue', o.physics.forceAtlas2Based.springConstant * 100); $('#thes_network_settings_physics_forceAtlas2Based_springLength').slider('setValue', o.physics.forceAtlas2Based.springLength); thes_network_settings_save(); } function thes_network_settings_save() { var o = $('#thes_network_settings').dialog('options').network_options; $("#thes_network_settings_nodes_font_size").prev().children('b').text($('#thes_network_settings_nodes_font_size').slider('getValue')); $("#thes_network_settings_edges_length").prev().children('b').text($('#thes_network_settings_edges_length').slider('getValue')); $("#thes_network_settings_edges_width").prev().children('b').text($('#thes_network_settings_edges_width').slider('getValue')); $("#thes_network_settings_edges_font_size").prev().children('b').text($('#thes_network_settings_edges_font_size').slider('getValue')); $("#thes_network_settings_edges_roundness").prev().children('b').text($('#thes_network_settings_edges_roundness').slider('getValue') / 10.0); $("#thes_network_settings_physics_forceAtlas2Based_centralGravity").prev().children('b').text('' + ($('#thes_network_settings_physics_forceAtlas2Based_centralGravity').slider('getValue') / 10000.0).toFixed(3)); $("#thes_network_settings_physics_forceAtlas2Based_gravitationalConstant").prev().children('b').text($('#thes_network_settings_physics_forceAtlas2Based_gravitationalConstant').slider('getValue')); $("#thes_network_settings_physics_forceAtlas2Based_springConstant").prev().children('b').text(($('#thes_network_settings_physics_forceAtlas2Based_springConstant').slider('getValue') / 100.0).toFixed(2)); $("#thes_network_settings_physics_forceAtlas2Based_springLength").prev().children('b').text($('#thes_network_settings_physics_forceAtlas2Based_springLength').slider('getValue') ); var xthes_network = $('#thes_network_settings').dialog('options').network; o.nodes.font.size = parseInt($('#thes_network_settings_nodes_font_size').slider('getValue')); o.nodes.font.face = $('#thes_network_settings_nodes_font_face').combobox('getValue'); o.edges.length = parseInt($('#thes_network_settings_edges_length').slider('getValue')); o.edges.width = parseInt($('#thes_network_settings_edges_width').slider('getValue')); o.edges.font.size = parseInt($('#thes_network_settings_edges_font_size').slider('getValue')); o.edges.font.face = $('#thes_network_settings_edges_font_face').combobox('getValue'); o.edges.font.align = $('#thes_network_settings_edges_font_align').combobox('getValue'); o.edges.smooth.roundness = parseInt($('#thes_network_settings_edges_roundness').slider('getValue')) / 10.0; o.physics.forceAtlas2Based.centralGravity = $('#thes_network_settings_physics_forceAtlas2Based_centralGravity').slider('getValue') / 10000.0; o.physics.forceAtlas2Based.gravitationalConstant = $('#thes_network_settings_physics_forceAtlas2Based_gravitationalConstant').slider('getValue'); o.physics.forceAtlas2Based.springConstant = $('#thes_network_settings_physics_forceAtlas2Based_springConstant').slider('getValue') / 100.0; o.physics.forceAtlas2Based.springLength = $('#thes_network_settings_physics_forceAtlas2Based_springLength').slider('getValue'); xthes_network.setOptions(o); } var thes_network; var thes_nodes = new vis.DataSet(); var thes_edges = new vis.DataSet(); var thes_network_container = document.getElementById('thes_network'); var thes_network_data = { nodes: thes_nodes, edges: thes_edges }; var thes_network_options = { interaction: { //dragView: false, multiselect: true, }, groups: { group_fixed: { fixed: true }, group_physnone: { physics: false, fixed: false } }, nodes: { shape: 'box', //size: 2, shadow: true, font: { face: 'Arial', size: 12, //face: 'Tahoma' }, widthConstraint: { maximum: 200 }, borderWidthSelected: 1, borderWidth: 1, color: { highlight: { background: '#FBAEB1', border: '#E94B9C',}, //hover: { border: 'green', background: '#D2E5FF' }, }, }, edges: { font: { align: 'middle', face: 'Arial', size: 12, strokeWidth: 4, // px strokeColor: '#ffffff', //multi: 'html', }, //size: 25, width: 2, length: 200, arrowStrikethrough: false, shadow: true, color:{color: 'rgb(127, 66, 175)', highlight: 'blue'}, //arrows: { to: { scaleFactor: 1 }}, smooth: { type: 'curvedCW', /*forceDirection: 'vertical', */roundness: 0.2 } //width: 0.15, //smooth: {type: 'continuous'} }, //network.setOptions({nodes:{shadow:shadowState},edges:{shadow:shadowState}}); /* layout: { hierarchical: { enabled: true, levelSeparation: 200, direction: 'UD' } }, physics: { hierarchicalRepulsion: { nodeDistance: 50 } } */ layout: { hierarchical: { enabled: false, //sortMethod: 'directed', //direction: 'UD' } }, /*interaction: { tooltipDelay: 50, hideEdgesOnDrag: false },*/ physics: { /*stabilization: false, barnesHut: { gravitationalConstant: -40000, springConstant: 0.001, springLength: 200 }*/ forceAtlas2Based: { gravitationalConstant: -50, centralGravity: 0.003, springLength: 150, springConstant: 0.32 }, maxVelocity: 146, solver: 'forceAtlas2Based', timestep: 0.45, stabilization: {iterations: 250} /* forceAtlas2Based: { gravitationalConstant: -104, centralGravity: 0.02, springLength: 200, springConstant: 0.18 }, maxVelocity: 146, solver: 'forceAtlas2Based', timestep: 0.65, stabilization: { iterations: 50 } */ }, //physics:false, }; thes_network = new vis.Network(thes_network_container, thes_network_data, thes_network_options); thes_network.on('doubleClick', function (params) { if (params.nodes.length > 0) { var c = {conceptid: params.nodes[0].substr(1)}; //return ThesConcepts.relation_goto_conc('#concepts', c); return ThesConcepts.reopen_conc_pos('#concepts', c.conceptid, true); //alert(params.nodes.length); //var data = nodes.get(params.nodes[0]); // get the data from selected node //nodeContent.innerHTML = JSON.stringify(data, undefined, 3); // show the data in the div } }); //select rect nodes >> var thes_network_drawingSurfaceImageData; var thes_network_ctx; var thes_network_canvas; var thes_network_rect = null; //, thes_network_drag = false; function saveDrawingSurface(ctx, canvas) { thes_network_drawingSurfaceImageData = ctx.getImageData(0, 0, canvas.width, canvas.height); } function restoreDrawingSurface(ctx, drawingSurfaceImageData) { ctx.putImageData(drawingSurfaceImageData, 0, 0); } function selectNodesFromHighlight(network, nodes, appendnew) { var fromX, toX, fromY, toY; var nodesIdInDrawing = []; var xRange = getStartToEnd(thes_network_rect.startX, thes_network_rect.w); var yRange = getStartToEnd(thes_network_rect.startY, thes_network_rect.h); var sels = []; if (appendnew) sels = network.getSelectedNodes(); var allNodes = nodes.get(); for (var i = 0; i < allNodes.length; i++) { var curNode = allNodes[i]; var nodePosition = network.getPositions([curNode.id]); var nodeXY = network.canvasToDOM({x: nodePosition[curNode.id].x, y: nodePosition[curNode.id].y}); if ((xRange.start <= nodeXY.x && nodeXY.x <= xRange.end && yRange.start <= nodeXY.y && nodeXY.y <= yRange.end) || (appendnew && (sels.indexOf(curNode.id) != -1))) { nodesIdInDrawing.push(curNode.id); } } network.selectNodes(nodesIdInDrawing); } function getStartToEnd(start, theLen) { return theLen > 0 ? {start: start, end: start + theLen} : {start: start + theLen, end: start}; } $(document).ready(function() { $(thes_network_container).on("mousemove", function(e) { if (thes_network_rect/*drag*/) { restoreDrawingSurface(thes_network_ctx, thes_network_drawingSurfaceImageData); thes_network_rect.w = e.offsetX/*(e.pageX - this.offsetLeft)*/ - thes_network_rect.startX; thes_network_rect.h = e.offsetY/*(e.pageY - this.offsetTop)*/ - thes_network_rect.startY ; thes_network_ctx.setLineDash([5]); thes_network_ctx.strokeStyle = "rgb(0, 102, 0)"; thes_network_ctx.strokeRect(thes_network_rect.startX, thes_network_rect.startY, thes_network_rect.w, thes_network_rect.h); thes_network_ctx.setLineDash([]); thes_network_ctx.fillStyle = "rgba(0, 255, 0, 0.2)"; thes_network_ctx.fillRect(thes_network_rect.startX, thes_network_rect.startY, thes_network_rect.w, thes_network_rect.h); } }); $(thes_network_container).on("mousedown", function(e) { if (e.button == 2) { selectedNodes = e.ctrlKey ? thes_network.getSelectedNodes() : null; saveDrawingSurface(thes_network_ctx, thes_network_canvas); var that = this; thes_network_rect = {} thes_network_rect.startX = e.offsetX/*e.pageX - this.offsetLeft*/; thes_network_rect.startY = e.offsetY/*e.pageY - this.offsetTop*/; //drag = true; this.style.cursor = "crosshair"; } }); $(thes_network_container).on("mouseup", function(e) { if (e.button == 2) { restoreDrawingSurface(thes_network_ctx, thes_network_drawingSurfaceImageData); //drag = false; thes_network_container.style.cursor = "default"; selectNodesFromHighlight(thes_network, thes_nodes, e.ctrlKey == true); thes_network_rect = null; } }); thes_network_canvas = thes_network.canvas.frame.canvas; thes_network_canvas.oncontextmenu = function() { return false; }; thes_network_canvas.oncontextmenu = function() { return false; }; thes_network_ctx = thes_network_canvas.getContext('2d'); }); //<< select rect nodes //thes_network.setOptions({ }); //nodes.clear(); //edges.clear(); //thes_network.fit(); </script>