react-sigma
Version:
Lightweight but powerful library for drawing network graphs built on top of SigmaJS
73 lines (50 loc) • 3.38 kB
JavaScript
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import React from 'react';
import '../sigma/plugins.relativeSize';
/**
RelativeSize component, interface for RelativeSize sigma plugin.
It supposes that sigma graph is already in place, therefore component should not be
mounted until graph is available. It can be used within Sigma component if graph is
preloaded, or within loader component, like NeoCypher.
Sets nodes sizes corresponding its degree.
@param {number} initialSize start size for every node, will be multiplied by Math.sqrt(node.degree)
**/
var RelativeSize =
/*#__PURE__*/
function (_React$Component) {
_inherits(RelativeSize, _React$Component);
function RelativeSize(props) {
var _this;
_classCallCheck(this, RelativeSize);
_this = _possibleConstructorReturn(this, _getPrototypeOf(RelativeSize).call(this, props));
_defineProperty(_assertThisInitialized(_this), "render", function () {
return null;
});
sigma.plugins.relativeSize(_this.props.sigma, _this.props.initialSize);
return _this;
}
return RelativeSize;
}(React.Component);
_defineProperty(RelativeSize, "propTypes", {
initialSize: PropTypes.number.isRequired,
sigma: function (_sigma) {
function sigma() {
return _sigma.apply(this, arguments);
}
sigma.toString = function () {
return _sigma.toString();
};
return sigma;
}(function () {
return (typeof sigma === "function" ? PropTypes.instanceOf(sigma) : PropTypes.any).apply(this, arguments);
})
});
export default RelativeSize;
import PropTypes from "prop-types";