UNPKG

react-sigma

Version:

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

51 lines (44 loc) 2.03 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import '../sigma/layout.dagre'; import ReactSigmaLayoutPlugin from './ReactSigmaLayoutPlugin'; /** Dagre layout algorythm. It supposes that sigma graph is already in place, therefore component should not be mounted while graph is unavailable. It can be used within Sigma component if graph is preloaded, or within loader component, like NeoCypher. It accepts all the parameters of Dagre described on its github page: @param {boolean} directed? @param {boolean} multigraph? @param {boolean} compound? @param {"TB"|"BT"|"RL"|"LR"} rankDir? @param {Sigma$Easing} easing Easing mode [see sigma plugin page for more details](https://github.com/Linkurious/linkurious.js/tree/develop/plugins/sigma.layouts.dagre) **/ var Dagre = function Dagre(props) { return !!props.sigma ? /*#__PURE__*/React.createElement(ReactSigmaLayoutPlugin, _extends({ start: function start() { return sigma.layouts.dagre.start(props.sigma); }, config: function config(options) { return sigma.layouts.dagre.configure(props.sigma, options); }, stop: function stop() { return console.warn("dagre stop not implemented"); } }, props)) : null; }; Dagre.propTypes = { directed: PropTypes.bool, multigraph: PropTypes.bool, compound: PropTypes.bool, rankDir: PropTypes.oneOf(["TB", "BT", "RL", "LR"]), easing: function easing() { return (typeof Sigma$Easing === "function" ? PropTypes.instanceOf(Sigma$Easing) : PropTypes.any).apply(this, arguments); }, sigma: function sigma() { return (typeof Sigma === "function" ? PropTypes.instanceOf(Sigma) : PropTypes.any).apply(this, arguments); } }; export default Dagre; import PropTypes from "prop-types";