1 line
3.9 KiB
JavaScript
1 line
3.9 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[70],{548:function(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VisJsGraphViewer", function() { return VisJsGraphViewer; });\n/* harmony import */ var vis_network__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(560);\n/* harmony import */ var mobx_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(69);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\nvar __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\n\n\n\nlet VisJsGraphViewer = class VisJsGraphViewer extends react__WEBPACK_IMPORTED_MODULE_2__["Component"] {\n constructor() {\n super(...arguments);\n this.divRef = react__WEBPACK_IMPORTED_MODULE_2__["createRef"]();\n this.nodes = new vis_network__WEBPACK_IMPORTED_MODULE_0__[/* DataSet */ "a"]();\n this.edges = new vis_network__WEBPACK_IMPORTED_MODULE_0__[/* DataSet */ "a"]();\n }\n render() {\n return react__WEBPACK_IMPORTED_MODULE_2__["createElement"]("div", { style: { height: "100%" }, ref: this.divRef });\n }\n synchronizeData() {\n const newNodes = new Set();\n for (const n of this.props.nodes) {\n newNodes.add(n.id);\n this.nodes.update({\n id: n.id,\n label: n.label !== undefined ? n.label : n.id,\n color: n.color,\n shape: n.shape,\n });\n }\n this.nodes.forEach(item => {\n if (!newNodes.has(item.id)) {\n this.nodes.remove(item);\n }\n });\n function getIdOfEdge(e) {\n if (e.id) {\n return e.id;\n }\n return e.from + "####" + e.to + "|" + e.label;\n }\n const newEdges = new Set();\n for (const n of this.props.edges) {\n const id = getIdOfEdge(n);\n newEdges.add(id);\n this.edges.update({\n id: id,\n label: n.label !== undefined ? n.label : "",\n from: n.from,\n to: n.to,\n color: n.color,\n dashes: n.dashes,\n });\n }\n this.edges.forEach(item => {\n if (!newEdges.has(item.id)) {\n this.edges.remove(item);\n }\n });\n }\n componentDidUpdate() {\n this.synchronizeData();\n }\n componentDidMount() {\n this.synchronizeData();\n const data = {\n nodes: this.nodes,\n edges: this.edges,\n };\n const options = {\n edges: {\n arrows: {\n to: { enabled: true, scaleFactor: 1, type: "arrow" },\n },\n },\n };\n const network = new vis_network__WEBPACK_IMPORTED_MODULE_0__[/* Network */ "b"](this.divRef.current, data, options);\n }\n};\nVisJsGraphViewer = __decorate([\n mobx_react__WEBPACK_IMPORTED_MODULE_1__["observer"]\n], VisJsGraphViewer);\n\n//# sourceMappingURL=VisJsGraphViewer.js.map\n\n//# sourceURL=webpack:///../visualization/dist/visualizers/graph-visualizers/VisJsGraphViewer.js?')}}]); |