with Sigma.js
I am trying to make it work within an iframe, I get the error Container not found
, it does not recognize the div with id="graphContainer"
with which sigma renders the graphics. the iframe belongs to an Ifobox belonging to another library cesium.js
. so I am modifying the iframe with jquery
. if I can modify the iframe but sigma.js
does not recognize the sun that I insert the iframe.
I define that it is asynchronous requested by jquery
$.ajaxPrefilter(function (options, original_Options, jqXHR) {
options.async = true;
});
I select the iframe
var $iframe = $('.cesium-infoBox-iframe');
I do not know why but if I do not do it with ready I get another error
$iframe.ready(function () {
// inserto la libreria sigma.js en el hean del iframe
var js_iframe = document.createElement('script');
js_iframe.setAttribute('src', 'sigma.min.js');
$iframe.contents().find("head").append(js_iframe);
// inserto el div contenedor para sigma, dentro de otro div ya existente en el body del iframe
var js_iframe2 = document.createElement('div');
js_iframe2.setAttribute('id', 'graphContainer');
$iframe.contents().find(".cesium-infoBox-description").append(js_iframe2);
// inserto el fichero sigma_infobox.js abajo del div de id="graphContainer" dentro del div ya existente en el iframe
var js_iframe3 = document.createElement('script');
js_iframe3.setAttribute('src', 'sigma_infobox.js');
$iframe.contents().find(".cesium-infoBox-description").append(js_iframe3);
});
the file sigma_infobox.js
"use strict";
var s = new sigma('graphContainer');
//set some default graph settings
s.settings({
defaultNodeColor: '#f00',
edgeColor: '#000'
});
//manually build up a graph from nodes and edges
s.graph.addNode({
id: 'node0',
label: 'Foo',
x: 0,
y: 0,
size: 1
});
s.graph.addNode({
id: 'node1',
label: 'Bar',
x: 1,
y: 0,
size: 1
});
s.graph.addEdge({
id: 'edge0',
source: 'node0',
target: 'node1',
});*/
s.refresh();