UNPKG

react-sigma-conglei

Version:

Lightweight but powerful library for drawing network graphs built on top of dunnock/react-sigma

171 lines (151 loc) 5.11 kB
var Sigma = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 128); /******/ }) /************************************************************************/ /******/ ({ /***/ 128: /***/ (function(module, exports) { /*** IMPORTS FROM imports-loader ***/ (function() { ;(function(undefined) { 'use strict'; if (typeof sigma === 'undefined') throw 'sigma is not declared'; // Initialize package: sigma.utils.pkg('sigma.parsers'); sigma.utils.pkg('sigma.utils'); /** * Just an XmlHttpRequest polyfill for different IE versions. * * @return {*} The XHR like object. */ sigma.utils.xhr = function() { if (window.XMLHttpRequest) return new XMLHttpRequest(); var names, i; if (window.ActiveXObject) { names = [ 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ]; for (i in names) try { return new ActiveXObject(names[i]); } catch (e) {} } return null; }; /** * This function loads a JSON file and creates a new sigma instance or * updates the graph of a given instance. It is possible to give a callback * that will be executed at the end of the process. * * @param {string} url The URL of the JSON file. * @param {object|sigma} sig A sigma configuration object or a sigma * instance. * @param {?function} callback Eventually a callback to execute after * having parsed the file. It will be called * with the related sigma instance as * parameter. */ sigma.parsers.json = function(url, sig, callback) { var graph, xhr = sigma.utils.xhr(); if (!xhr) throw 'XMLHttpRequest not supported, cannot load the file.'; xhr.open('GET', url, true); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { graph = JSON.parse(xhr.responseText); // Update the instance's graph: if (sig instanceof sigma) { sig.graph.clear(); sig.graph.read(graph); // ...or instantiate sigma if needed: } else if (typeof sig === 'object') { sig.graph = graph; sig = new sigma(sig); // ...or it's finally the callback: } else if (typeof sig === 'function') { callback = sig; sig = null; } // Call the callback if specified: if (callback) callback(sig || graph); } }; xhr.send(); }; }).call(this); }.call(window)); /***/ }) /******/ });