UNPKG

react-sigma

Version:

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

76 lines (55 loc) 2.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireDefault(require("react")); require("../sigma/nodes"); var _propTypes = _interopRequireDefault(require("prop-types")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } /** NodeShapes component, interface for customShapes 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 LoadJSON. Note! this Component requires "canvas" renderer to work. Extra node properties: - node.type='shape-name' - node shape renderer e.g. node.type='cross'. - node.borderColor - e.g. node.borderColor='#FF3333' Details on shapes configuration and possibility to apply images to nodes, please refer to [plugin page](https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.renderers.customShapes#images). See [plugin page](https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.renderers.customEdgeShapes) for more datails on implementation. @param {string} default set default sigma node renderer to be applied to nodes where type is not set @example ``` <Sigma renderer="canvas" graph={{nodes:["id0", "id1"], edges:[{id:"e0",source:"id0",target:"id1"}]}}> <NodeShapes default="star"/> </Sigma> ``` @example Supported shapes ``` type Sigma$Node$Shapes = "def" | "pacman" | "star" | "equilateral" | "cross" | "diamond" | "circle" | "square"; ``` **/ class NodeShapes extends _react.default.Component { constructor(props) { super(props); _defineProperty(this, "render", () => null); if (this.props.sigma && this.props.default) this.props.sigma.settings({ defaultNodeType: this.props.default }); } } _defineProperty(NodeShapes, "propTypes", { default: function () { return (typeof Sigma$Node$Shapes === "function" ? _propTypes.default.instanceOf(Sigma$Node$Shapes) : _propTypes.default.any).apply(this, arguments); }, sigma: function () { return (typeof sigma === "function" ? _propTypes.default.instanceOf(sigma) : _propTypes.default.any).apply(this, arguments); } }); var _default = NodeShapes; exports.default = _default;