Как мне настроить граф (отрисованный с graphvis) так, чтобы при загрузке html странички он отображался сразу в приближенном масштабе
1.Пробовала zoom, но он убирает всю динамику графа и портит его качество. Мне правки нужно внести именно в html код (python кода у меня нет от данного графа) 2. Пробовала также через: /* var afterzoomlimit = { //here we are setting the zoom limit to move to scale: 1.8, }*/ -не вышло
Вот код графа:
// initialize global variables.
var edges;
var nodes;
var network;
var container;
var options, data;
// This method is responsible for drawing the graph, returns the drawn network
function drawGraph() {
var container = document.getElementById('mynetwork');
// parsing and collecting nodes and edges from the python
nodes = new vis.DataSet([{"color": "#9b1118", "font": {"color": "black"}, "id": "\u0410-2003", "label": "\u0410-2003", "shape": "dot", "title": ""}, //здесь дальше очень много текста, его опустила
edges = new vis.DataSet([{"from": "\u0410-2003", "to": "PDSA 2004"}, {"from": "\u0411-1", "to": "LIRA 0094RI"}, //здесь дальше очень много текста, его опустила
// adding nodes and edges to the graph
data = {nodes: nodes, edges: edges};
var options = {
"configure": {
"enabled": false
},
"edges": {
"color": {
"inherit": true
},
"smooth": {
"enabled": false,
"type": "continuous"
}
},
"interaction": {
"dragNodes": true,
"hideEdgesOnDrag": false,
"hideNodesOnDrag": false
},
"physics": {
"enabled": true,
"stabilization": {
"enabled": true,
"fit": true,
"iterations": 1000,
"onlyDynamicEdges": false,
"updateInterval": 50
}
}
};
// default to using dot shape for nodes
options.nodes = {
shape: "dot"
}
network = new vis.Network(container, data, options);
/* network.on("zoom",function(){ //while zooming
if(network.getScale() <= 1.8% )//the limit you want to stop at
{
network.moveTo(afterzoomlimit); //set this limit so it stops zooming out here
}
});*/
network.on("stabilizationProgress", function(params) {
document.getElementById('loadingBar').removeAttribute("style");
var maxWidth = 496;
var minWidth = 20;
var widthFactor = params.iterations/params.total;
var width = Math.max(minWidth,maxWidth * widthFactor);
document.getElementById('bar').style.width = width + 'px';
document.getElementById('text').innerHTML = Math.round(widthFactor*100) + '%';
});
network.once("stabilizationIterationsDone", function() {
document.getElementById('text').innerHTML = '100%';
document.getElementById('bar').style.width = '496px';
document.getElementById('loadingBar').style.opacity = 0;
// really clean the dom element
setTimeout(function () {document.getElementById('loadingBar').style.display = 'none';}, 500);
});
return network;
}
drawGraph();