UNPKG

react-sigma

Version:

Lightweight but powerful library for drawing network graphs built on top of SigmaJS

1 lines 2.95 kB
var Sigma=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=184)}({184:function(e,t){(function(){(function(e){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.neo4j"),sigma.utils.pkg("sigma.utils"),sigma.neo4j.send=function(e,t,n,o,r){var a,i,s,u=sigma.utils.xhr();if(a=e,"object"==typeof e&&(a=e.url,i=e.user,s=e.password),!u)throw"XMLHttpRequest not supported, cannot load the file.";a+=t,u.open(n,a,!0),i&&s&&u.setRequestHeader("Authorization","Basic "+btoa(i+":"+s)),u.setRequestHeader("Accept","application/json"),u.setRequestHeader("Content-type","application/json; charset=utf-8"),u.onreadystatechange=function(){4===u.readyState&&r(JSON.parse(u.responseText))},u.send(o)},sigma.neo4j.cypher_parse=function(e,t){var n,o={nodes:[],edges:[]},r={},a={};for(n in e.results[0].data.forEach((function(e){e.graph.nodes.forEach((function(e){var n=t.node(e);n.id in r||(r[n.id]=n)})),e.graph.relationships.forEach((function(e){var n=t.edge(e);n.id in a||(a[n.id]=n)}))})),r)o.nodes.push(r[n]);for(n in a)o.edges.push(a[n]);return o},sigma.neo4j.cypher=function(e,t,n,o,r){var a,i;r||(r=sigma.neo4j.defaultProducers),a=JSON.stringify({statements:[{statement:t,resultDataContents:["graph"],includeStats:!1}]}),i=function(e){return function(t){var o;o=sigma.neo4j.cypher_parse(t,r),n instanceof sigma?(n.graph.clear(),n.graph.read(o)):"object"==typeof n?((n=new sigma(n)).graph.read(o),n.refresh()):"function"==typeof n&&(e=n,n=null),e&&e(n||o)}},sigma.neo4j.send(e,"/db/data/transaction/commit","POST",a,i(o))},sigma.neo4j.getLabels=function(e,t){sigma.neo4j.send(e,"/db/data/labels","GET",null,t)},sigma.neo4j.getTypes=function(e,t){sigma.neo4j.send(e,"/db/data/relationship/types","GET",null,t)},sigma.neo4j.defaultProducers={node:function(e){return{id:e.id,label:e.id,x:Math.random(),y:Math.random(),size:1,color:"#666666",neo4j_labels:e.labels,neo4j_data:e.properties}},edge:function(e){return{id:e.id,label:e.type,source:e.startNode,target:e.endNode,color:"#7D7C8E",neo4j_type:e.type,neo4j_data:e.properties}}}}).call(window)}).call(window)}});