Как зафиксировать граф (отрисованный с graphvis) по центру блока, в который он вставлен?
Сейчас при открытии страницы граф располагается в верхнем левом углу большого блока:
Хочу, чтобы при открытии граф был по центру, и еще в идеально в таком же расположении вершин:
Я бы хотела, чтобы граф отображался по центру при открытии сразу.
Вот кусок кода, отвечающий за стиль блока, в котором находится граф:
#mynetwork1 {
width: 77%;
height: 450px;
background-color: ffffff;
border: none;
margin-left:120px;
}
а вот кусок кода самого графа:
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('mynetwork1');
nodes = new vis.DataSet([{"color": "#CCCCCC", "font": {"color": "black"}, // и так далее
edges = new vis.DataSet([{"arrows": "to", "from": "\u041d-52/1,2", "to": "\u041f-104", "width": 1}, // и так далее
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": false,
"stabilization": {
"enabled": true,
"fit": 1.3,
"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.moveTo({ 'scale' : 1.3});
return network;
}
drawGraph();
