@linkurious/ogma-linkurious-parser 4.0.1 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ogma/features/styles.d.ts +7 -7
- package/dist/ogma/features/styles.js.map +1 -1
- package/dist/styles/edgeAttributes.d.ts +8 -8
- package/dist/styles/edgeAttributes.js +15 -14
- package/dist/styles/edgeAttributes.js.map +1 -1
- package/dist/styles/itemAttributes.d.ts +24 -28
- package/dist/styles/itemAttributes.js +29 -22
- package/dist/styles/itemAttributes.js.map +1 -1
- package/dist/styles/nodeAttributes.d.ts +8 -8
- package/dist/styles/nodeAttributes.js +21 -19
- package/dist/styles/nodeAttributes.js.map +1 -1
- package/dist/styles/styleRule.d.ts +8 -8
- package/dist/styles/styleRule.js +1 -0
- package/dist/styles/styleRule.js.map +1 -1
- package/dist/styles/styleRules.d.ts +5 -5
- package/dist/styles/styleRules.js +13 -10
- package/dist/styles/styleRules.js.map +1 -1
- package/package.json +5 -5
|
@@ -103,7 +103,7 @@ export declare class StylesViz {
|
|
|
103
103
|
/**
|
|
104
104
|
* Create / refresh an ogma rule for node colors
|
|
105
105
|
*/
|
|
106
|
-
refreshNodeColors(colorStyleRules: Array<LKStyleRule
|
|
106
|
+
refreshNodeColors(colorStyleRules: Array<LKStyleRule<INodeStyle>>): void;
|
|
107
107
|
/**
|
|
108
108
|
* Return an array of StyleRules with only the style that need to be applied
|
|
109
109
|
*/
|
|
@@ -120,33 +120,33 @@ export declare class StylesViz {
|
|
|
120
120
|
*
|
|
121
121
|
* @param {Array<any>} iconStyleRules
|
|
122
122
|
*/
|
|
123
|
-
refreshNodeIcons(iconStyleRules: Array<LKStyleRule
|
|
123
|
+
refreshNodeIcons(iconStyleRules: Array<LKStyleRule<INodeStyle>>): void;
|
|
124
124
|
/**
|
|
125
125
|
* Create / refresh an ogma rule for node sizes
|
|
126
126
|
*
|
|
127
127
|
* @param {Array<any>} sizeStyleRules
|
|
128
128
|
*/
|
|
129
|
-
refreshNodeSize(sizeStyleRules: Array<LKStyleRule
|
|
129
|
+
refreshNodeSize(sizeStyleRules: Array<LKStyleRule<INodeStyle>>): void;
|
|
130
130
|
/**
|
|
131
131
|
* Create / refresh an ogma rule for node images
|
|
132
132
|
*
|
|
133
133
|
* @param {Array<any>} shapeStyleRules
|
|
134
134
|
*/
|
|
135
|
-
refreshNodeShape(shapeStyleRules: Array<LKStyleRule
|
|
135
|
+
refreshNodeShape(shapeStyleRules: Array<LKStyleRule<INodeStyle>>): void;
|
|
136
136
|
/**
|
|
137
137
|
* Create / refresh an ogma rule for edge colors
|
|
138
138
|
*/
|
|
139
|
-
refreshEdgeColors(colorStyleRules: Array<LKStyleRule
|
|
139
|
+
refreshEdgeColors(colorStyleRules: Array<LKStyleRule<IEdgeStyle>>): void;
|
|
140
140
|
/**
|
|
141
141
|
* Create / refresh an ogma rule for edge width
|
|
142
142
|
*
|
|
143
143
|
* @param {Array<LKStyleRule>} widthStyleRules
|
|
144
144
|
*/
|
|
145
|
-
refreshEdgeWidth(widthStyleRules: Array<LKStyleRule
|
|
145
|
+
refreshEdgeWidth(widthStyleRules: Array<LKStyleRule<IEdgeStyle>>): void;
|
|
146
146
|
/**
|
|
147
147
|
* Create / refresh an ogma rule for edge width
|
|
148
148
|
*
|
|
149
149
|
* @param {Array<LKStyleRule>} shapeStyleRules
|
|
150
150
|
*/
|
|
151
|
-
refreshEdgeShape(shapeStyleRules: Array<LKStyleRule
|
|
151
|
+
refreshEdgeShape(shapeStyleRules: Array<LKStyleRule<IEdgeStyle>>): void;
|
|
152
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/ogma/features/styles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAsBb,6BASe;AACf,6CAAwC;AAYxC,MAAM,2BAA2B,GAAgD;IAC/E,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,eAAe,EAAE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AC9C,cAAc,EAAE;oBACd,KAAK,EAAE,CAAC,IAAwB,EAAE,EAAE;wBAClC,IAAI,IAAI,KAAK,SAAS,EAAE;4BACtB,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;yBACnD;oBACH,CAAC;iBACF;gBACD,gBAAgB,EAAE,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,EAAC;aACvC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SAC/B;IACH,CAAC;CACF;AA5qBD,8BA4qBC","sourcesContent":["'use strict';\n\nimport * as o from '@linkurious/ogma';\nimport {\n Edge,\n EdgeAttributesValue,\n NodeAttributesValue,\n StyleClass,\n StyleRule\n} from '@linkurious/ogma';\nimport {\n GenericObject,\n IEdgeStyle,\n INodeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n OgmaEdgeShape,\n OgmaNodeShape,\n TextOptions\n} from '@linkurious/rest-client';\n\nimport {\n BASE_GREY,\n EdgeAttributes,\n LKOgma,\n NodeAttributes,\n OgmaTools,\n StyleRule as LKStyleRule,\n StyleRules,\n StyleType\n} from '../..';\nimport {Tools} from '../../tools/tools';\n\nexport interface StylesConfig {\n nodeColorStyleRules: Array<LKStyleRule>;\n nodeIconStyleRules: Array<LKStyleRule>;\n nodeSizeStyleRules: Array<LKStyleRule>;\n nodeShapeStyleRules?: Array<LKStyleRule>;\n edgeColorStyleRules: Array<LKStyleRule>;\n edgeWidthStyleRules: Array<LKStyleRule>;\n edgeShapeStyleRules?: Array<LKStyleRule>;\n}\n\nconst HOVERED_SELECTED_NODE_STYLE: NodeAttributesValue<LkNodeData, LkEdgeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outerStroke: {width: 2},\n outline: false\n};\n\nconst HOVERED_SELECTED_EDGE_STYLE: EdgeAttributesValue<LkEdgeData, LkNodeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outline: false\n};\n\nconst NODE_HALO_CONFIGURATION = {\n color: '#FFF',\n width: 7,\n scalingMethod: 'scaled',\n strokeWidth: 0,\n hideNonAdjacentEdges: false\n} as {\n color: '#FFF';\n width: 7;\n strokeWidth: 0;\n};\n\nconst EDGE_HALO_CONFIGURATION = {\n color: '#FFF',\n scalingMethod: 'scaled',\n width: 4\n} as {\n color: '#FFF';\n width: 4;\n};\n\nconst DEFAULT_OGMA_FONT = \"'roboto', sans-serif\";\nconst DARK_FONT_COLOR = '#000';\nconst CLEAR_FONT_COLOR = '#FFF';\nconst ITEM_DEFAULT_COLOR = '#7f7f7f';\nexport const FILTER_OPACITY = 0.2;\n\nexport class StylesViz {\n private _ogma: LKOgma;\n private _exportClass!: StyleClass;\n private _nodeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _nodeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n private _edgeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _edgeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n\n private _nodeAttributes: NodeAttributes = new NodeAttributes({});\n private _edgeAttributes: EdgeAttributes = new EdgeAttributes({});\n\n private _ogmaNodeColor!: StyleRule;\n private _ogmaNodeIcon!: StyleRule;\n private _ogmaNodeSize!: StyleRule;\n private _ogmaNodeShape!: StyleRule;\n private _ogmaEdgeColor!: StyleRule;\n private _ogmaEdgeWidth!: StyleRule;\n private _ogmaEdgeShape!: StyleRule;\n private _defaultConfiguration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n };\n\n constructor(\n ogma: LKOgma,\n configuration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n }\n ) {\n this._ogma = ogma;\n this._defaultConfiguration = configuration;\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n this._ogma.styles.setSelectedNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n // setting default styles\n this._nodeDefaultStylesRules = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n padding: 5,\n minVisibleSize:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.minVisibleSize\n ? this._defaultConfiguration.node.text.minVisibleSize\n : 12,\n maxLineLength:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.maxLineLength !== undefined\n ? this._defaultConfiguration.node.text.maxLineLength\n : 30,\n position:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.nodePosition !== undefined\n ? this._defaultConfiguration.node.text.nodePosition\n : 'bottom',\n backgroundColor:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.backgroundColor !== undefined\n ? this._defaultConfiguration.node.text.backgroundColor\n : 'null',\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.color !== undefined\n ? this._defaultConfiguration.node.text.color\n : 'black',\n size:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.size !== undefined\n ? this._defaultConfiguration.node.text.size\n : 14,\n margin: 5\n },\n radius: this.defaultNodeRadius(this._defaultConfiguration.node),\n icon: {\n minVisibleSize: 15\n },\n color: ITEM_DEFAULT_COLOR,\n shape:\n this._defaultConfiguration.node.shape !== undefined\n ? this._defaultConfiguration.node.shape\n : ('circle' as OgmaNodeShape),\n innerStroke: {\n width: 3\n },\n outline: false\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n this._ogma.styles.setSelectedEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n // setting default styles\n this._edgeDefaultStylesRules = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n minVisibleSize:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.minVisibleSize\n ? this._defaultConfiguration.edge.text.minVisibleSize\n : 3,\n maxLineLength:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.maxLineLength !== undefined\n ? this._defaultConfiguration.edge.text.maxLineLength\n : 30,\n backgroundColor:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.backgroundColor !== undefined\n ? this._defaultConfiguration.edge.text.backgroundColor\n : null,\n font:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.font !== undefined\n ? this._defaultConfiguration.edge.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.edge !== undefined &&\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.color !== undefined\n ? this._defaultConfiguration.edge.text.color\n : 'black',\n size:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.size !== undefined\n ? this._defaultConfiguration.edge.text.size\n : 14\n },\n width: this.defaultEdgeWidth(this._defaultConfiguration.edge),\n shape:\n this._defaultConfiguration.edge.shape !== undefined\n ? this._defaultConfiguration.edge.shape\n : 'arrow',\n color: ITEM_DEFAULT_COLOR\n }\n });\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultHalo(): void {\n // setting default halo style\n this._nodeDefaultHaloRules = this._ogma.styles.addRule({\n nodeSelector: (node) => node && !node.hasClass('filtered'),\n nodeAttributes: {\n halo: (node) => {\n if (\n node !== undefined &&\n !node.hasClass('filtered') &&\n (node.isSelected() ||\n node.getAdjacentNodes({}).isSelected().includes(true) ||\n node.getAdjacentEdges().isSelected().includes(true))\n ) {\n return {\n ...NODE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // recalculate the rule *only* when itself or adjacent\n // elements change their selection status\n nodeDependencies: {\n self: {\n selection: true\n },\n adjacentNodes: {\n selection: true\n },\n adjacentEdges: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultHalo(): void {\n // setting default halo styles\n this._edgeDefaultHaloRules = this._ogma.styles.addRule({\n edgeSelector: (edge: Edge) =>\n edge && edge.getSource() && edge.getTarget() && !edge.hasClass('filtered'),\n edgeAttributes: {\n halo: (edge) => {\n if (\n edge &&\n !edge.hasClass('filtered') &&\n (edge.isSelected() || edge.getSource().isSelected() || edge.getTarget().isSelected())\n ) {\n return {\n ...EDGE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // this rule will only be invoked when the selection status\n // of the edge or it's extremities is changed\n edgeDependencies: {\n self: {\n selection: true\n },\n extremities: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Return the default node radius set in configuration or 5\n *\n * @returns {number}\n */\n private defaultNodeRadius(styles: any): number {\n return this.defaultStylesHas(styles, ['nodeRadius']) ? styles.nodeRadius : 5;\n }\n\n /**\n * Return the default edge width set in configuration or 1\n *\n * @returns {number}\n */\n private defaultEdgeWidth(styles: any): number {\n return this.defaultStylesHas(styles, ['edgeWidth']) ? styles.edgeWidth : 1;\n }\n\n /**\n * Check if a style property exists in the default styles object\n */\n private defaultStylesHas(styles: GenericObject<unknown>, propertyPath: Array<string>): boolean {\n if (!Tools.isDefined(styles)) {\n return false;\n }\n return Tools.getIn(styles, propertyPath) !== undefined;\n }\n\n /**\n * Set styles for the class \"filtered\"\n */\n public setFilterClass(): void {\n this._ogma.styles.createClass({\n name: 'filtered',\n nodeAttributes: {\n opacity: FILTER_OPACITY,\n layer: -1,\n detectable: false,\n badges: {\n topRight: {\n text: null\n },\n bottomRight: {\n text: null\n }\n },\n text: null,\n color: 'rgb(240, 240, 240)',\n innerStroke: {\n width: 1,\n color: BASE_GREY,\n minVisibleSize: 1\n },\n shape: 'circle',\n image: null,\n icon: null,\n radius: '100%'\n },\n edgeAttributes: {\n opacity: FILTER_OPACITY,\n layer: -1,\n detectable: false,\n text: null,\n color: BASE_GREY,\n shape: 'line',\n width: 0.2\n }\n });\n }\n\n /**\n * Set the class for exported nodes and edges\n */\n public setExportClass(textWrappingLength?: boolean): void {\n if (!this._exportClass) {\n this._exportClass = this._ogma.styles.createClass({\n name: 'exported',\n nodeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12,\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n },\n edgeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12\n },\n halo: null\n }\n });\n } else {\n this._exportClass.update({\n nodeAttributes: {\n text: {\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n }\n });\n }\n }\n\n /**\n * Set the rule to display badges\n */\n public setBadgeRule() {\n this._ogma.styles.createClass({\n name: 'degreeIndicator',\n nodeAttributes: {\n badges: {\n topRight: (node) => {\n if (node !== undefined) {\n const degree = Tools.getHiddenNeighbors(node.toList());\n const badgeContent = Tools.formatNumber(degree);\n if (degree > 0) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n const isSupernode = node.getData(['statistics', 'supernode']);\n let content = null;\n if (+badgeContent !== 0) {\n content = isSupernode ? badgeContent + '+' : badgeContent;\n }\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : DEFAULT_OGMA_FONT,\n scale: 0.4,\n color: textColor,\n content: content\n }\n };\n }\n }\n }\n }\n }\n });\n this._ogma.styles.createClass({\n name: 'pinnedIndicator',\n nodeAttributes: {\n badges: {\n bottomRight: (node) => {\n if (node !== undefined && !node.getAttribute('layoutable')) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font: 'FontAwesome',\n scale: 0.4,\n color: textColor,\n content: node.getAttribute('layoutable') ? null : '\\uf08d'\n }\n };\n }\n }\n }\n },\n nodeDependencies: {\n self: {attributes: ['layoutable']}\n }\n });\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('degreeIndicator'));\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('pinnedIndicator'));\n }\n\n /**\n * Delete the rule to display badges\n */\n public deleteBadgeRule() {\n this._ogma.getNodes().removeClasses(['degreeIndicator', 'pinnedIndicator'], 0);\n }\n\n /**\n * set text overlap to true or false\n *\n * @param {boolean} overlap\n */\n public toggleTextOverlap(overlap?: boolean): void {\n this._ogma.setOptions({texts: {preventOverlap: overlap}});\n }\n\n /**\n * refresh nodes and edge rules\n *\n */\n public refreshRules(): void {\n this._nodeDefaultStylesRules.refresh();\n this._edgeDefaultStylesRules.refresh();\n }\n\n /**\n * Create / refresh an ogma rule for node colors\n */\n public refreshNodeColors(colorStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaNodeColor)) {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor = this._ogma.styles.addRule({\n nodeAttributes: {\n color: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.color(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor.refresh();\n // TODO refresh node icons when moving the code from LKE\n // this.refreshIconsColor();\n }\n }\n\n /**\n * Return an array of StyleRules with only the style that need to be applied\n */\n public getStyleRule(\n state: Array<IStyleRule<INodeStyle | IEdgeStyle>>,\n styleType: StyleType\n ): LKStyleRule[] {\n return new StyleRules(state)[styleType];\n }\n\n public initNodeColors(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeColorRules = this.getStyleRule(nodeRules, StyleType.COLOR);\n this.refreshNodeColors(nodeColorRules);\n }\n\n public initNodesIcons(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeIconsRules = this.getStyleRule(nodeRules, StyleType.ICON);\n this.refreshNodeIcons(nodeIconsRules);\n }\n\n public initNodesSizes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeSizeRules = this.getStyleRule(nodeRules, StyleType.SIZE);\n this.refreshNodeSize(nodeSizeRules);\n }\n\n public initNodesShapes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeShapesRules = this.getStyleRule(nodeRules, StyleType.SHAPE);\n this.refreshNodeShape(nodeShapesRules);\n }\n\n public initEdgesWidth(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesWidthRules = this.getStyleRule(edgeRules, StyleType.WIDTH);\n this.refreshEdgeWidth(edgesWidthRules);\n }\n\n public initEdgesShape(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesShapeRules = this.getStyleRule(edgeRules, StyleType.SHAPE);\n this.refreshEdgeShape(edgesShapeRules);\n }\n\n public initEdgesColor(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesColorRules = this.getStyleRule(edgeRules, StyleType.COLOR);\n this.refreshEdgeColors(edgesColorRules);\n }\n\n /**\n * Create / refresh an ogma rule for node icons\n *\n * @param {Array<any>} iconStyleRules\n */\n public refreshNodeIcons(iconStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaNodeIcon)) {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n this._ogmaNodeIcon = this._ogma.styles.addRule({\n nodeAttributes: {\n icon: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.icon(node.getData()).icon;\n }\n },\n image: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.icon(node.getData()).image;\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n this._ogmaNodeIcon.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node sizes\n *\n * @param {Array<any>} sizeStyleRules\n */\n public refreshNodeSize(sizeStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaNodeSize)) {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize = this._ogma.styles.addRule({\n nodeAttributes: {\n radius: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.size(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node images\n *\n * @param {Array<any>} shapeStyleRules\n */\n public refreshNodeShape(shapeStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaNodeShape)) {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape = this._ogma.styles.addRule({\n nodeAttributes: {\n shape: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.shape(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge colors\n */\n public refreshEdgeColors(colorStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaEdgeColor)) {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor = this._ogma.styles.addRule({\n edgeAttributes: {\n color: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.color(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} widthStyleRules\n */\n public refreshEdgeWidth(widthStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaEdgeWidth)) {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth = this._ogma.styles.addRule({\n edgeAttributes: {\n width: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.width(edge.getData());\n }\n }\n },\n edgeDependencies: {\n self: {data: true}\n }\n });\n } else {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} shapeStyleRules\n */\n public refreshEdgeShape(shapeStyleRules: Array<LKStyleRule>): void {\n if (!Tools.isDefined(this._ogmaEdgeShape)) {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape = this._ogma.styles.addRule({\n edgeAttributes: {\n shape: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.shape(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape.refresh();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/ogma/features/styles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAsBb,6BASe;AACf,6CAAwC;AAYxC,MAAM,2BAA2B,GAAgD;IAC/E,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,CAAC;KAClB;IACD,WAAW,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC;IACvB,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,MAAM,2BAA2B,GAAgD;IAC/E,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,CAAC;KAClB;IACD,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,CAAC;IACR,aAAa,EAAE,QAAQ;IACvB,WAAW,EAAE,CAAC;IACd,oBAAoB,EAAE,KAAK;CAK5B,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,MAAM;IACb,aAAa,EAAE,QAAQ;IACvB,KAAK,EAAE,CAAC;CAIT,CAAC;AAEF,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AACjD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AACxB,QAAA,cAAc,GAAG,GAAG,CAAC;AAElC,MAAa,SAAS;IAmCpB,YACE,IAAY,EACZ,aAaC;QAxCK,oBAAe,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I,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SAC/B;IACH,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,eAA+C;QACrE,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;YACzC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC9C,cAAc,EAAE;oBACd,KAAK,EAAE,CAAC,IAAwB,EAAE,EAAE;wBAClC,IAAI,IAAI,KAAK,SAAS,EAAE;4BACtB,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;yBACnD;oBACH,CAAC;iBACF;gBACD,gBAAgB,EAAE,EAAC,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,EAAC;aACvC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,eAAe,EAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SAC/B;IACH,CAAC;CACF;AA9rBD,8BA8rBC","sourcesContent":["'use strict';\n\nimport * as o from '@linkurious/ogma';\nimport {\n Edge,\n EdgeAttributesValue,\n NodeAttributesValue,\n StyleClass,\n StyleRule\n} from '@linkurious/ogma';\nimport {\n GenericObject,\n IEdgeStyle,\n INodeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n OgmaEdgeShape,\n OgmaNodeShape,\n TextOptions\n} from '@linkurious/rest-client';\n\nimport {\n BASE_GREY,\n EdgeAttributes,\n LKOgma,\n NodeAttributes,\n OgmaTools,\n StyleRule as LKStyleRule,\n StyleRules,\n StyleType\n} from '../..';\nimport {Tools} from '../../tools/tools';\n\nexport interface StylesConfig {\n nodeColorStyleRules: Array<LKStyleRule>;\n nodeIconStyleRules: Array<LKStyleRule>;\n nodeSizeStyleRules: Array<LKStyleRule>;\n nodeShapeStyleRules?: Array<LKStyleRule>;\n edgeColorStyleRules: Array<LKStyleRule>;\n edgeWidthStyleRules: Array<LKStyleRule>;\n edgeShapeStyleRules?: Array<LKStyleRule>;\n}\n\nconst HOVERED_SELECTED_NODE_STYLE: NodeAttributesValue<LkNodeData, LkEdgeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outerStroke: {width: 2},\n outline: false\n};\n\nconst HOVERED_SELECTED_EDGE_STYLE: EdgeAttributesValue<LkEdgeData, LkNodeData> = {\n text: {\n style: 'bold',\n backgroundColor: '#fff',\n minVisibleSize: 0\n },\n outline: false\n};\n\nconst NODE_HALO_CONFIGURATION = {\n color: '#FFF',\n width: 7,\n scalingMethod: 'scaled',\n strokeWidth: 0,\n hideNonAdjacentEdges: false\n} as {\n color: '#FFF';\n width: 7;\n strokeWidth: 0;\n};\n\nconst EDGE_HALO_CONFIGURATION = {\n color: '#FFF',\n scalingMethod: 'scaled',\n width: 4\n} as {\n color: '#FFF';\n width: 4;\n};\n\nconst DEFAULT_OGMA_FONT = \"'roboto', sans-serif\";\nconst DARK_FONT_COLOR = '#000';\nconst CLEAR_FONT_COLOR = '#FFF';\nconst ITEM_DEFAULT_COLOR = '#7f7f7f';\nexport const FILTER_OPACITY = 0.2;\n\nexport class StylesViz {\n private _ogma: LKOgma;\n private _exportClass!: StyleClass;\n private _nodeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _nodeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n private _edgeDefaultStylesRules!: StyleRule<LkNodeData, LkEdgeData>;\n // @ts-ignore\n private _edgeDefaultHaloRules!: StyleRule<LkNodeData, LkEdgeData>;\n\n private _nodeAttributes: NodeAttributes = new NodeAttributes({});\n private _edgeAttributes: EdgeAttributes = new EdgeAttributes({});\n\n private _ogmaNodeColor!: StyleRule;\n private _ogmaNodeIcon!: StyleRule;\n private _ogmaNodeSize!: StyleRule;\n private _ogmaNodeShape!: StyleRule;\n private _ogmaEdgeColor!: StyleRule;\n private _ogmaEdgeWidth!: StyleRule;\n private _ogmaEdgeShape!: StyleRule;\n private _defaultConfiguration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n };\n\n constructor(\n ogma: LKOgma,\n configuration: {\n node: {\n nodeRadius?: number;\n shape?: OgmaNodeShape;\n text?: TextOptions & {\n nodePosition?: 'right' | 'left' | 'top' | 'bottom' | 'center';\n };\n };\n edge: {\n edgeWidth?: number;\n shape?: OgmaEdgeShape;\n text?: TextOptions;\n };\n }\n ) {\n this._ogma = ogma;\n this._defaultConfiguration = configuration;\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n this._ogma.styles.setSelectedNodeAttributes(HOVERED_SELECTED_NODE_STYLE);\n // setting default styles\n this._nodeDefaultStylesRules = this._ogma.styles.addRule({\n nodeAttributes: {\n text: {\n padding: 5,\n minVisibleSize:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.minVisibleSize\n ? this._defaultConfiguration.node.text.minVisibleSize\n : 12,\n maxLineLength:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.maxLineLength !== undefined\n ? this._defaultConfiguration.node.text.maxLineLength\n : 30,\n position:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.nodePosition !== undefined\n ? this._defaultConfiguration.node.text.nodePosition\n : 'bottom',\n backgroundColor:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.backgroundColor !== undefined\n ? this._defaultConfiguration.node.text.backgroundColor\n : 'null',\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.color !== undefined\n ? this._defaultConfiguration.node.text.color\n : 'black',\n size:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.size !== undefined\n ? this._defaultConfiguration.node.text.size\n : 14,\n margin: 5\n },\n radius: this.defaultNodeRadius(this._defaultConfiguration.node),\n icon: {\n minVisibleSize: 15\n },\n color: ITEM_DEFAULT_COLOR,\n shape:\n this._defaultConfiguration.node.shape !== undefined\n ? this._defaultConfiguration.node.shape\n : ('circle' as OgmaNodeShape),\n innerStroke: {\n width: 3\n },\n outline: false\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultStyles(): void {\n // setting selection and hover attributes\n this._ogma.styles.setHoveredEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n this._ogma.styles.setSelectedEdgeAttributes(HOVERED_SELECTED_EDGE_STYLE);\n // setting default styles\n this._edgeDefaultStylesRules = this._ogma.styles.addRule({\n edgeAttributes: {\n text: {\n minVisibleSize:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.minVisibleSize\n ? this._defaultConfiguration.edge.text.minVisibleSize\n : 3,\n maxLineLength:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.maxLineLength !== undefined\n ? this._defaultConfiguration.edge.text.maxLineLength\n : 30,\n backgroundColor:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.backgroundColor !== undefined\n ? this._defaultConfiguration.edge.text.backgroundColor\n : null,\n font:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.font !== undefined\n ? this._defaultConfiguration.edge.text.font\n : \"'roboto', sans-serif\",\n color:\n this._defaultConfiguration.edge !== undefined &&\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.color !== undefined\n ? this._defaultConfiguration.edge.text.color\n : 'black',\n size:\n this._defaultConfiguration.edge.text !== undefined &&\n this._defaultConfiguration.edge.text.size !== undefined\n ? this._defaultConfiguration.edge.text.size\n : 14\n },\n width: this.defaultEdgeWidth(this._defaultConfiguration.edge),\n shape:\n this._defaultConfiguration.edge.shape !== undefined\n ? this._defaultConfiguration.edge.shape\n : 'arrow',\n color: ITEM_DEFAULT_COLOR\n }\n });\n }\n\n /**\n * Set nodes default styles based on the configuration\n */\n public setNodesDefaultHalo(): void {\n // setting default halo style\n this._nodeDefaultHaloRules = this._ogma.styles.addRule({\n nodeSelector: (node) => node && !node.hasClass('filtered'),\n nodeAttributes: {\n halo: (node) => {\n if (\n node !== undefined &&\n !node.hasClass('filtered') &&\n (node.isSelected() ||\n node.getAdjacentNodes({}).isSelected().includes(true) ||\n node.getAdjacentEdges().isSelected().includes(true))\n ) {\n return {\n ...NODE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // recalculate the rule *only* when itself or adjacent\n // elements change their selection status\n nodeDependencies: {\n self: {\n selection: true\n },\n adjacentNodes: {\n selection: true\n },\n adjacentEdges: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Set edges default styles based on the configuration\n */\n public setEdgesDefaultHalo(): void {\n // setting default halo styles\n this._edgeDefaultHaloRules = this._ogma.styles.addRule({\n edgeSelector: (edge: Edge) =>\n edge && edge.getSource() && edge.getTarget() && !edge.hasClass('filtered'),\n edgeAttributes: {\n halo: (edge) => {\n if (\n edge &&\n !edge.hasClass('filtered') &&\n (edge.isSelected() || edge.getSource().isSelected() || edge.getTarget().isSelected())\n ) {\n return {\n ...EDGE_HALO_CONFIGURATION,\n scalingMethod: this._ogma.geo.enabled() ? 'fixed' : 'scaled'\n };\n }\n return null;\n }\n },\n // this rule will only be invoked when the selection status\n // of the edge or it's extremities is changed\n edgeDependencies: {\n self: {\n selection: true\n },\n extremities: {\n selection: true\n }\n }\n });\n }\n\n /**\n * Return the default node radius set in configuration or 5\n *\n * @returns {number}\n */\n private defaultNodeRadius(styles: any): number {\n return this.defaultStylesHas(styles, ['nodeRadius']) ? styles.nodeRadius : 5;\n }\n\n /**\n * Return the default edge width set in configuration or 1\n *\n * @returns {number}\n */\n private defaultEdgeWidth(styles: any): number {\n return this.defaultStylesHas(styles, ['edgeWidth']) ? styles.edgeWidth : 1;\n }\n\n /**\n * Check if a style property exists in the default styles object\n */\n private defaultStylesHas(styles: GenericObject<unknown>, propertyPath: Array<string>): boolean {\n if (!Tools.isDefined(styles)) {\n return false;\n }\n return Tools.getIn(styles, propertyPath) !== undefined;\n }\n\n /**\n * Set styles for the class \"filtered\"\n */\n public setFilterClass(): void {\n this._ogma.styles.createClass({\n name: 'filtered',\n nodeAttributes: {\n opacity: FILTER_OPACITY,\n layer: -1,\n detectable: false,\n badges: {\n topRight: {\n text: null\n },\n bottomRight: {\n text: null\n }\n },\n text: null,\n color: 'rgb(240, 240, 240)',\n innerStroke: {\n width: 1,\n color: BASE_GREY,\n minVisibleSize: 1\n },\n shape: 'circle',\n image: null,\n icon: null,\n radius: '100%'\n },\n edgeAttributes: {\n opacity: FILTER_OPACITY,\n layer: -1,\n detectable: false,\n text: null,\n color: BASE_GREY,\n shape: 'line',\n width: 0.2\n }\n });\n }\n\n /**\n * Set the class for exported nodes and edges\n */\n public setExportClass(textWrappingLength?: boolean): void {\n if (!this._exportClass) {\n this._exportClass = this._ogma.styles.createClass({\n name: 'exported',\n nodeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12,\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n },\n edgeAttributes: {\n text: {\n minVisibleSize: 0,\n size: 12\n },\n halo: null\n }\n });\n } else {\n this._exportClass.update({\n nodeAttributes: {\n text: {\n maxLineLength: textWrappingLength ? 30 : 0\n },\n halo: null\n }\n });\n }\n }\n\n /**\n * Set the rule to display badges\n */\n public setBadgeRule() {\n this._ogma.styles.createClass({\n name: 'degreeIndicator',\n nodeAttributes: {\n badges: {\n topRight: (node) => {\n if (node !== undefined) {\n const degree = Tools.getHiddenNeighbors(node.toList());\n const badgeContent = Tools.formatNumber(degree);\n if (degree > 0) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n const isSupernode = node.getData(['statistics', 'supernode']);\n let content = null;\n if (+badgeContent !== 0) {\n content = isSupernode ? badgeContent + '+' : badgeContent;\n }\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font:\n this._defaultConfiguration.node.text !== undefined &&\n this._defaultConfiguration.node.text.font !== undefined\n ? this._defaultConfiguration.node.text.font\n : DEFAULT_OGMA_FONT,\n scale: 0.4,\n color: textColor,\n content: content\n }\n };\n }\n }\n }\n }\n }\n });\n this._ogma.styles.createClass({\n name: 'pinnedIndicator',\n nodeAttributes: {\n badges: {\n bottomRight: (node) => {\n if (node !== undefined && !node.getAttribute('layoutable')) {\n const nodeColor = Array.isArray(node.getAttribute('color'))\n ? node.getAttribute('color')![0]\n : node.getAttribute('color');\n const textColor = OgmaTools.isBright(nodeColor as o.Color)\n ? DARK_FONT_COLOR\n : CLEAR_FONT_COLOR;\n return {\n color: 'inherit',\n minVisibleSize: 20,\n stroke: {\n width: 0,\n color: null\n },\n text: {\n font: 'FontAwesome',\n scale: 0.4,\n color: textColor,\n content: node.getAttribute('layoutable') ? null : '\\uf08d'\n }\n };\n }\n }\n }\n },\n nodeDependencies: {\n self: {attributes: ['layoutable']}\n }\n });\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('degreeIndicator'));\n this._ogma.events.on('addNodes', (nodesEvent) => nodesEvent.nodes.addClass('pinnedIndicator'));\n }\n\n /**\n * Delete the rule to display badges\n */\n public deleteBadgeRule() {\n this._ogma.getNodes().removeClasses(['degreeIndicator', 'pinnedIndicator'], 0);\n }\n\n /**\n * set text overlap to true or false\n *\n * @param {boolean} overlap\n */\n public toggleTextOverlap(overlap?: boolean): void {\n this._ogma.setOptions({texts: {preventOverlap: overlap}});\n }\n\n /**\n * refresh nodes and edge rules\n *\n */\n public refreshRules(): void {\n this._nodeDefaultStylesRules.refresh();\n this._edgeDefaultStylesRules.refresh();\n }\n\n /**\n * Create / refresh an ogma rule for node colors\n */\n public refreshNodeColors(colorStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeColor)) {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor = this._ogma.styles.addRule({\n nodeAttributes: {\n color: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.color(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({color: colorStyleRules});\n this._ogmaNodeColor.refresh();\n // TODO refresh node icons when moving the code from LKE\n // this.refreshIconsColor();\n }\n }\n\n /**\n * Return an array of StyleRules with only the style that need to be applied\n */\n public getStyleRule(\n state: Array<IStyleRule<INodeStyle | IEdgeStyle>>,\n styleType: StyleType\n ): LKStyleRule[] {\n return new StyleRules(state)[styleType];\n }\n\n public initNodeColors(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>): void {\n const nodeColorRules = this.getStyleRule(\n nodeRules,\n StyleType.COLOR\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeColors(nodeColorRules);\n }\n\n public initNodesIcons(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeIconsRules = this.getStyleRule(\n nodeRules,\n StyleType.ICON\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeIcons(nodeIconsRules);\n }\n\n public initNodesSizes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeSizeRules = this.getStyleRule(nodeRules, StyleType.SIZE) as LKStyleRule<INodeStyle>[];\n this.refreshNodeSize(nodeSizeRules);\n }\n\n public initNodesShapes(nodeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const nodeShapesRules = this.getStyleRule(\n nodeRules,\n StyleType.SHAPE\n ) as LKStyleRule<INodeStyle>[];\n this.refreshNodeShape(nodeShapesRules);\n }\n\n public initEdgesWidth(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesWidthRules = this.getStyleRule(\n edgeRules,\n StyleType.WIDTH\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeWidth(edgesWidthRules);\n }\n\n public initEdgesShape(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesShapeRules = this.getStyleRule(\n edgeRules,\n StyleType.SHAPE\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeShape(edgesShapeRules);\n }\n\n public initEdgesColor(edgeRules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n const edgesColorRules = this.getStyleRule(\n edgeRules,\n StyleType.COLOR\n ) as LKStyleRule<IEdgeStyle>[];\n this.refreshEdgeColors(edgesColorRules);\n }\n\n /**\n * Create / refresh an ogma rule for node icons\n *\n * @param {Array<any>} iconStyleRules\n */\n public refreshNodeIcons(iconStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeIcon)) {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n this._ogmaNodeIcon = this._ogma.styles.addRule({\n nodeAttributes: {\n icon: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.icon(node.getData()).icon;\n }\n },\n image: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.icon(node.getData()).image;\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({icon: iconStyleRules});\n this._ogmaNodeIcon.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node sizes\n *\n * @param {Array<any>} sizeStyleRules\n */\n public refreshNodeSize(sizeStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeSize)) {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize = this._ogma.styles.addRule({\n nodeAttributes: {\n radius: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.size(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({size: sizeStyleRules});\n this._ogmaNodeSize.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for node images\n *\n * @param {Array<any>} shapeStyleRules\n */\n public refreshNodeShape(shapeStyleRules: Array<LKStyleRule<INodeStyle>>): void {\n if (!Tools.isDefined(this._ogmaNodeShape)) {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape = this._ogma.styles.addRule({\n nodeAttributes: {\n shape: (node: o.Node | undefined) => {\n if (node !== undefined) {\n return this._nodeAttributes.shape(node.getData());\n }\n }\n },\n nodeDependencies: {self: {data: true}}\n });\n } else {\n this._nodeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaNodeShape.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge colors\n */\n public refreshEdgeColors(colorStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeColor)) {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor = this._ogma.styles.addRule({\n edgeAttributes: {\n color: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.color(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({color: colorStyleRules});\n this._ogmaEdgeColor.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} widthStyleRules\n */\n public refreshEdgeWidth(widthStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeWidth)) {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth = this._ogma.styles.addRule({\n edgeAttributes: {\n width: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.width(edge.getData());\n }\n }\n },\n edgeDependencies: {\n self: {data: true}\n }\n });\n } else {\n this._edgeAttributes.refresh({width: widthStyleRules});\n this._ogmaEdgeWidth.refresh();\n }\n }\n\n /**\n * Create / refresh an ogma rule for edge width\n *\n * @param {Array<LKStyleRule>} shapeStyleRules\n */\n public refreshEdgeShape(shapeStyleRules: Array<LKStyleRule<IEdgeStyle>>): void {\n if (!Tools.isDefined(this._ogmaEdgeShape)) {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape = this._ogma.styles.addRule({\n edgeAttributes: {\n shape: (edge: o.Edge | undefined) => {\n if (edge !== undefined) {\n return this._edgeAttributes.shape(edge.getData());\n }\n }\n },\n edgeDependencies: {self: {data: true}}\n });\n } else {\n this._edgeAttributes.refresh({shape: shapeStyleRules});\n this._ogmaEdgeShape.refresh();\n }\n }\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Color } from '@linkurious/ogma';
|
|
2
|
-
import { LkEdgeData, OgmaEdgeShape } from '@linkurious/rest-client';
|
|
2
|
+
import { IEdgeStyle, LkEdgeData, OgmaEdgeShape } from '@linkurious/rest-client';
|
|
3
3
|
import { StyleRule } from './styleRule';
|
|
4
4
|
import { ItemAttributes } from './itemAttributes';
|
|
5
5
|
export declare enum EdgeWidthExtrema {
|
|
6
6
|
MIN = 50,
|
|
7
7
|
MAX = 200
|
|
8
8
|
}
|
|
9
|
-
export declare class EdgeAttributes extends ItemAttributes {
|
|
9
|
+
export declare class EdgeAttributes extends ItemAttributes<IEdgeStyle> {
|
|
10
10
|
constructor(rulesMap: {
|
|
11
|
-
color?: Array<StyleRule
|
|
12
|
-
shape?: Array<StyleRule
|
|
13
|
-
width?: Array<StyleRule
|
|
11
|
+
color?: Array<StyleRule<IEdgeStyle>>;
|
|
12
|
+
shape?: Array<StyleRule<IEdgeStyle>>;
|
|
13
|
+
width?: Array<StyleRule<IEdgeStyle>>;
|
|
14
14
|
});
|
|
15
15
|
/**
|
|
16
16
|
* Return rule that can be applied to the data
|
|
@@ -27,20 +27,20 @@ export declare class EdgeAttributes extends ItemAttributes {
|
|
|
27
27
|
/**
|
|
28
28
|
* Generate size for a given node
|
|
29
29
|
*/
|
|
30
|
-
width(data: LkEdgeData): string | undefined;
|
|
30
|
+
width(data: LkEdgeData): string | number | undefined;
|
|
31
31
|
/**
|
|
32
32
|
* return the corresponding width to the value
|
|
33
33
|
* @param value
|
|
34
34
|
* @param rule
|
|
35
35
|
* @param isLog
|
|
36
36
|
*/
|
|
37
|
-
static getAutomaticRangeWidth(value: number, rule: StyleRule
|
|
37
|
+
static getAutomaticRangeWidth(value: number, rule: StyleRule<IEdgeStyle>, isLog?: boolean): string | undefined;
|
|
38
38
|
/**
|
|
39
39
|
* Return an object containing all node attributes needed by Ogma to style a node
|
|
40
40
|
*/
|
|
41
41
|
all(data: LkEdgeData): {
|
|
42
42
|
color: Color;
|
|
43
43
|
shape: OgmaEdgeShape | undefined;
|
|
44
|
-
width: string | undefined;
|
|
44
|
+
width: string | undefined | number;
|
|
45
45
|
};
|
|
46
46
|
}
|
|
@@ -42,7 +42,7 @@ class EdgeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
42
42
|
}
|
|
43
43
|
else if (typeof rule.style.color === 'object') {
|
|
44
44
|
const propValue = tools_1.Tools.getIn(data, rule.style.color.input);
|
|
45
|
-
color = itemAttributes_1.ItemAttributes.autoColor(`${propValue}`, rule.style.ignoreCase);
|
|
45
|
+
color = itemAttributes_1.ItemAttributes.autoColor(`${propValue}`, rule.style.color.ignoreCase);
|
|
46
46
|
}
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
@@ -64,20 +64,21 @@ class EdgeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
64
64
|
width(data) {
|
|
65
65
|
if (this._rulesMap.width !== undefined) {
|
|
66
66
|
const styleRule = EdgeAttributes.matchStyle(this._rulesMap.width, data);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (widthStyle
|
|
70
|
-
widthStyle.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
if (styleRule !== undefined) {
|
|
68
|
+
const widthStyle = styleRule === null || styleRule === void 0 ? void 0 : styleRule.style.width;
|
|
69
|
+
if (widthStyle !== undefined && this.isAutoRange(widthStyle)) {
|
|
70
|
+
if (widthStyle.input !== undefined &&
|
|
71
|
+
widthStyle.max !== undefined &&
|
|
72
|
+
widthStyle.min !== undefined) {
|
|
73
|
+
const propertyName = widthStyle.input[1];
|
|
74
|
+
const propertyValue = tools_1.Tools.parseNumber(data.properties[propertyName]);
|
|
75
|
+
const isLog = widthStyle.scale && widthStyle.scale === rest_client_1.AutoRangeScale.LOGARITHMIC;
|
|
76
|
+
return EdgeAttributes.getAutomaticRangeWidth(propertyValue, styleRule, isLog);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return widthStyle;
|
|
77
81
|
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return widthStyle;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edgeAttributes.js","sourceRoot":"","sources":["../../src/styles/edgeAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,
|
|
1
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,KAAK,CAAC,IAAI,CAAC;SACxB,CAAC;IACJ,CAAC;CACF;AArID,wCAqIC","sourcesContent":["'use strict';\nimport {Color} from '@linkurious/ogma';\nimport {\n AutoRangeScale,\n IEdgeStyle,\n LkEdgeData,\n OgmaEdgeShape,\n IStyleAutoRange\n} from '@linkurious/rest-client';\n\nimport {Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {BASE_GREY, ItemAttributes} from './itemAttributes';\n\nexport enum EdgeWidthExtrema {\n MIN = 50,\n MAX = 200\n}\n\nexport class EdgeAttributes extends ItemAttributes<IEdgeStyle> {\n constructor(rulesMap: {\n color?: Array<StyleRule<IEdgeStyle>>;\n shape?: Array<StyleRule<IEdgeStyle>>;\n width?: Array<StyleRule<IEdgeStyle>>;\n }) {\n super(rulesMap);\n }\n\n /**\n * Return rule that can be applied to the data\n */\n private static matchStyle(\n styleRules: Array<StyleRule<IEdgeStyle>>,\n data: LkEdgeData\n ): StyleRule<IEdgeStyle> | undefined {\n if (data === undefined) {\n return;\n }\n for (let i = 0; i < styleRules.length; ++i) {\n if (styleRules[i].canApplyTo(data)) {\n return styleRules[i];\n }\n }\n }\n\n /**\n * Generate color for a given edge (call only if _rulesMap.color exists)\n */\n public color(data: LkEdgeData): Color {\n if (!Tools.isDefined(data)) {\n return BASE_GREY;\n }\n let color;\n for (let j = 0; j < this._rulesMap.color!.length; ++j) {\n const rule = this._rulesMap.color![j];\n if (rule.canApplyTo(data)) {\n if (typeof rule.style.color === 'string') {\n color = rule.style.color;\n } else if (typeof rule.style.color === 'object') {\n const propValue = Tools.getIn(data, rule.style.color.input);\n color = ItemAttributes.autoColor(`${propValue}`, rule.style.color.ignoreCase);\n }\n break;\n }\n }\n return Tools.isDefined(color) ? color : BASE_GREY;\n }\n\n /**\n * Generate shape for a given node\n */\n public shape(data: LkEdgeData): OgmaEdgeShape | undefined {\n if (this._rulesMap.shape !== undefined) {\n return EdgeAttributes.matchStyle(this._rulesMap.shape, data)?.style.shape;\n }\n }\n\n /**\n * Generate size for a given node\n */\n public width(data: LkEdgeData): string | number | undefined {\n if (this._rulesMap.width !== undefined) {\n const styleRule = EdgeAttributes.matchStyle(this._rulesMap.width, data);\n if (styleRule !== undefined) {\n const widthStyle = styleRule?.style.width;\n if (widthStyle !== undefined && this.isAutoRange(widthStyle)) {\n if (\n widthStyle.input !== undefined &&\n widthStyle.max !== undefined &&\n widthStyle.min !== undefined\n ) {\n const propertyName: string = widthStyle.input[1];\n const propertyValue = Tools.parseNumber(data.properties[propertyName]);\n const isLog = widthStyle.scale && widthStyle.scale === AutoRangeScale.LOGARITHMIC;\n return EdgeAttributes.getAutomaticRangeWidth(propertyValue, styleRule, isLog);\n }\n } else {\n return widthStyle;\n }\n }\n }\n }\n\n /**\n * return the corresponding width to the value\n * @param value\n * @param rule\n * @param isLog\n */\n public static getAutomaticRangeWidth(\n value: number,\n rule: StyleRule<IEdgeStyle>,\n isLog = false\n ): string | undefined {\n return isLog\n ? this.getAutomaticRangeStyleLog(\n value,\n rule.style.width as IStyleAutoRange,\n EdgeWidthExtrema.MIN,\n EdgeWidthExtrema.MAX\n )\n : this.getAutomaticRangeStyleLinear(\n value,\n rule.style.width as IStyleAutoRange,\n EdgeWidthExtrema.MIN,\n EdgeWidthExtrema.MAX\n );\n }\n\n /**\n * Return an object containing all node attributes needed by Ogma to style a node\n */\n public all(\n data: LkEdgeData\n ): {\n color: Color;\n shape: OgmaEdgeShape | undefined;\n width: string | undefined | number;\n } {\n if (!Tools.isDefined(data)) {\n return {\n color: BASE_GREY,\n shape: OgmaEdgeShape.ARROW,\n width: '100%'\n };\n }\n return {\n color: this.color(data),\n shape: this.shape(data),\n width: this.width(data)\n };\n }\n}\n"]}
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { Color } from '@linkurious/ogma';
|
|
2
|
+
import { IEdgeStyle, INodeStyle, IStyleAutoRange } from '@linkurious/rest-client';
|
|
2
3
|
import { StyleRule } from './styleRule';
|
|
3
4
|
import { NodeSizeExtrema } from './nodeAttributes';
|
|
4
5
|
import { EdgeWidthExtrema } from './edgeAttributes';
|
|
5
6
|
export declare const BASE_GREY = "#7f7f7f";
|
|
6
7
|
export declare const PALETTE: string[];
|
|
7
|
-
export declare class ItemAttributes {
|
|
8
|
+
export declare class ItemAttributes<T extends INodeStyle | IEdgeStyle> {
|
|
8
9
|
protected colorsCache: Map<string, Color | Array<Color>>;
|
|
9
10
|
protected _rulesMap: {
|
|
10
|
-
color?: Array<StyleRule
|
|
11
|
-
icon?: Array<StyleRule
|
|
12
|
-
image?: Array<StyleRule
|
|
13
|
-
shape?: Array<StyleRule
|
|
14
|
-
size?: Array<StyleRule
|
|
15
|
-
width?: Array<StyleRule
|
|
11
|
+
color?: Array<StyleRule<T>>;
|
|
12
|
+
icon?: Array<StyleRule<T>>;
|
|
13
|
+
image?: Array<StyleRule<T>>;
|
|
14
|
+
shape?: Array<StyleRule<T>>;
|
|
15
|
+
size?: Array<StyleRule<T>>;
|
|
16
|
+
width?: Array<StyleRule<T>>;
|
|
16
17
|
};
|
|
17
18
|
constructor(rulesMap: {
|
|
18
|
-
color?: Array<StyleRule
|
|
19
|
-
icon?: Array<StyleRule
|
|
20
|
-
image?: Array<StyleRule
|
|
21
|
-
shape?: Array<StyleRule
|
|
22
|
-
size?: Array<StyleRule
|
|
23
|
-
width?: Array<StyleRule
|
|
19
|
+
color?: Array<StyleRule<T>>;
|
|
20
|
+
icon?: Array<StyleRule<T>>;
|
|
21
|
+
image?: Array<StyleRule<T>>;
|
|
22
|
+
shape?: Array<StyleRule<T>>;
|
|
23
|
+
size?: Array<StyleRule<T>>;
|
|
24
|
+
width?: Array<StyleRule<T>>;
|
|
24
25
|
});
|
|
25
26
|
/**
|
|
26
27
|
* Refresh the rules
|
|
27
28
|
*/
|
|
28
29
|
refresh(rulesMap: {
|
|
29
|
-
color?: Array<StyleRule
|
|
30
|
-
icon?: Array<StyleRule
|
|
31
|
-
image?: Array<StyleRule
|
|
32
|
-
shape?: Array<StyleRule
|
|
33
|
-
size?: Array<StyleRule
|
|
34
|
-
width?: Array<StyleRule
|
|
30
|
+
color?: Array<StyleRule<T>>;
|
|
31
|
+
icon?: Array<StyleRule<T>>;
|
|
32
|
+
image?: Array<StyleRule<T>>;
|
|
33
|
+
shape?: Array<StyleRule<T>>;
|
|
34
|
+
size?: Array<StyleRule<T>>;
|
|
35
|
+
width?: Array<StyleRule<T>>;
|
|
35
36
|
}): void;
|
|
36
37
|
/**
|
|
37
38
|
* Return the color for a node when style color is auto
|
|
@@ -44,7 +45,7 @@ export declare class ItemAttributes {
|
|
|
44
45
|
/**
|
|
45
46
|
* Get color of a type
|
|
46
47
|
*/
|
|
47
|
-
static getTypeColor(rule: StyleRule
|
|
48
|
+
static getTypeColor(rule: StyleRule<IEdgeStyle | INodeStyle>, type: string): string | undefined | null;
|
|
48
49
|
/**
|
|
49
50
|
* return the corresponding size to the value with a linear function
|
|
50
51
|
* @param value
|
|
@@ -52,10 +53,7 @@ export declare class ItemAttributes {
|
|
|
52
53
|
* @param higher
|
|
53
54
|
* @param extrema
|
|
54
55
|
*/
|
|
55
|
-
static getAutomaticRangeStyleLinear(value: number, { max, min }:
|
|
56
|
-
max: number;
|
|
57
|
-
min: number;
|
|
58
|
-
}, lower: EdgeWidthExtrema | NodeSizeExtrema, higher: EdgeWidthExtrema | NodeSizeExtrema): string;
|
|
56
|
+
static getAutomaticRangeStyleLinear(value: number, { max, min }: IStyleAutoRange, lower: EdgeWidthExtrema | NodeSizeExtrema, higher: EdgeWidthExtrema | NodeSizeExtrema): string | undefined;
|
|
59
57
|
/**
|
|
60
58
|
* return the corresponding size to the value with a logarithmic function
|
|
61
59
|
* @param value
|
|
@@ -63,8 +61,6 @@ export declare class ItemAttributes {
|
|
|
63
61
|
* @param higher
|
|
64
62
|
* @param extrema
|
|
65
63
|
*/
|
|
66
|
-
static getAutomaticRangeStyleLog(value: number, { max, min }:
|
|
67
|
-
|
|
68
|
-
min: number;
|
|
69
|
-
}, lower: EdgeWidthExtrema | NodeSizeExtrema, higher: EdgeWidthExtrema | NodeSizeExtrema): string;
|
|
64
|
+
static getAutomaticRangeStyleLog(value: number, { max, min }: IStyleAutoRange, lower: EdgeWidthExtrema | NodeSizeExtrema, higher: EdgeWidthExtrema | NodeSizeExtrema): string | undefined;
|
|
65
|
+
isAutoRange(value: string | number | IStyleAutoRange): value is IStyleAutoRange;
|
|
70
66
|
}
|
|
@@ -87,15 +87,17 @@ class ItemAttributes {
|
|
|
87
87
|
* @param extrema
|
|
88
88
|
*/
|
|
89
89
|
static getAutomaticRangeStyleLinear(value, { max, min }, lower, higher) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
if (max !== undefined && min !== undefined) {
|
|
91
|
+
// apply default style when min equal max
|
|
92
|
+
if (max === min || isNaN(value)) {
|
|
93
|
+
return '100%';
|
|
94
|
+
}
|
|
95
|
+
// calculate the linear function f(x) = ax + b
|
|
96
|
+
const a = (higher - lower) / (max - min);
|
|
97
|
+
const b = (lower * max - higher * min) / (max - min);
|
|
98
|
+
const size = Math.floor(value * a + b);
|
|
99
|
+
return `${size}%`;
|
|
93
100
|
}
|
|
94
|
-
// calculate the linear function f(x) = ax + b
|
|
95
|
-
const a = (higher - lower) / (max - min);
|
|
96
|
-
const b = (lower * max - higher * min) / (max - min);
|
|
97
|
-
const size = Math.floor(value * a + b);
|
|
98
|
-
return `${size}%`;
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
101
103
|
* return the corresponding size to the value with a logarithmic function
|
|
@@ -105,21 +107,26 @@ class ItemAttributes {
|
|
|
105
107
|
* @param extrema
|
|
106
108
|
*/
|
|
107
109
|
static getAutomaticRangeStyleLog(value, { max, min }, lower, higher) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
if (min !== undefined && max !== undefined) {
|
|
111
|
+
// apply default style when min equal max
|
|
112
|
+
if (max === min || isNaN(value)) {
|
|
113
|
+
return '100%';
|
|
114
|
+
}
|
|
115
|
+
// apply an offset for all the values (including min and max)
|
|
116
|
+
if (min < 1) {
|
|
117
|
+
value += Math.abs(min) + 1;
|
|
118
|
+
max += Math.abs(min) + 1;
|
|
119
|
+
min += Math.abs(min) + 1;
|
|
120
|
+
}
|
|
121
|
+
// calculate the logarithmic function f(x) = Math.floor(a*log(x) + b)
|
|
122
|
+
const a = (higher - lower) / (Math.log(max) - Math.log(min));
|
|
123
|
+
const b = (lower * Math.log(max) - higher * Math.log(min)) / (Math.log(max) - Math.log(min));
|
|
124
|
+
const size = Math.floor(a * Math.log(value) + b);
|
|
125
|
+
return `${size}%`;
|
|
111
126
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
max += Math.abs(min) + 1;
|
|
116
|
-
min += Math.abs(min) + 1;
|
|
117
|
-
}
|
|
118
|
-
// calculate the logarithmic function f(x) = Math.floor(a*log(x) + b)
|
|
119
|
-
const a = (higher - lower) / (Math.log(max) - Math.log(min));
|
|
120
|
-
const b = (lower * Math.log(max) - higher * Math.log(min)) / (Math.log(max) - Math.log(min));
|
|
121
|
-
const size = Math.floor(a * Math.log(value) + b);
|
|
122
|
-
return `${size}%`;
|
|
127
|
+
}
|
|
128
|
+
isAutoRange(value) {
|
|
129
|
+
return typeof value === 'object' && (value === null || value === void 0 ? void 0 : value.type) === 'autoRange';
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
exports.ItemAttributes = ItemAttributes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemAttributes.js","sourceRoot":"","sources":["../../src/styles/itemAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,gDAAwB;
|
|
1
|
+
{"version":3,"file":"itemAttributes.js","sourceRoot":"","sources":["../../src/styles/itemAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,gDAAwB;AAIxB,0CAAqC;AAMxB,QAAA,SAAS,GAAG,SAAS,CAAC;AACtB,QAAA,OAA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,CAAC,GAAG,CAAC,CAAC;gBAC3B,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACzB,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aAC1B;YACD,sEAAsE;YACtE,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7F,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YAEjD,OAAO,GAAG,IAAI,GAAG,CAAC;SACnB;IACH,CAAC;IAEM,WAAW,CAAC,KAAwC;QACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,WAAW,CAAC;IAClE,CAAC;CACF;AAxJD,wCAwJC","sourcesContent":["'use strict';\n\nimport sha1 from 'sha1';\nimport {Color} from '@linkurious/ogma';\nimport {IEdgeStyle, INodeStyle, IStyleAutoRange} from '@linkurious/rest-client';\n\nimport {Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {NodeSizeExtrema} from './nodeAttributes';\nimport {EdgeWidthExtrema} from './edgeAttributes';\n\nexport const BASE_GREY = '#7f7f7f';\nexport const PALETTE = [\n '#9467bd',\n '#e377c2',\n '#1f77b4',\n '#17becf',\n '#2ca02c',\n '#bcbd22',\n '#d62728',\n '#ff7f0e',\n '#8c564b',\n '#c5b0d5',\n '#f7b6d2',\n '#aec7e8',\n '#9edae5',\n '#98df8a',\n '#dbdb8d',\n '#ff9896',\n '#ffbb78',\n '#c49c94'\n];\n\nexport class ItemAttributes<T extends INodeStyle | IEdgeStyle> {\n protected colorsCache: Map<string, Color | Array<Color>> = new Map();\n protected _rulesMap: {\n color?: Array<StyleRule<T>>;\n icon?: Array<StyleRule<T>>;\n image?: Array<StyleRule<T>>;\n shape?: Array<StyleRule<T>>;\n size?: Array<StyleRule<T>>;\n width?: Array<StyleRule<T>>;\n } = {};\n\n constructor(rulesMap: {\n color?: Array<StyleRule<T>>;\n icon?: Array<StyleRule<T>>;\n image?: Array<StyleRule<T>>;\n shape?: Array<StyleRule<T>>;\n size?: Array<StyleRule<T>>;\n width?: Array<StyleRule<T>>;\n }) {\n this.refresh(rulesMap);\n }\n\n /**\n * Refresh the rules\n */\n public refresh(rulesMap: {\n color?: Array<StyleRule<T>>;\n icon?: Array<StyleRule<T>>;\n image?: Array<StyleRule<T>>;\n shape?: Array<StyleRule<T>>;\n size?: Array<StyleRule<T>>;\n width?: Array<StyleRule<T>>;\n }): void {\n if (rulesMap.color !== undefined) {\n this.colorsCache = new Map();\n }\n this._rulesMap = {\n color: rulesMap.color ? [...rulesMap.color].reverse() : this._rulesMap.color,\n icon: rulesMap.icon ? [...rulesMap.icon].reverse() : this._rulesMap.icon,\n image: rulesMap.image ? [...rulesMap.image].reverse() : this._rulesMap.image,\n shape: rulesMap.shape ? [...rulesMap.shape].reverse() : this._rulesMap.shape,\n size: rulesMap.size ? [...rulesMap.size].reverse() : this._rulesMap.size,\n width: rulesMap.width ? [...rulesMap.width].reverse() : this._rulesMap.width\n };\n }\n\n /**\n * Return the color for a node when style color is auto\n */\n public static autoColor(value: string, ignoreCase?: boolean): string {\n if (!Tools.isDefined(value)) {\n return BASE_GREY;\n }\n return PALETTE[\n ItemAttributes.getRandomUniqueColorPaletteIndex(value, PALETTE.length, ignoreCase)\n ];\n }\n\n /**\n * Return a number from 0 to number of occurrence in a palette based on a property\n */\n private static getRandomUniqueColorPaletteIndex(\n input: string,\n modulo: number,\n ignoreCase: boolean | undefined\n ): number {\n if (ignoreCase) {\n input = input.toLowerCase();\n }\n return +('0x' + sha1(input).substr(-4)) % modulo;\n }\n\n /**\n * Get color of a type\n */\n public static getTypeColor(\n rule: StyleRule<IEdgeStyle | INodeStyle>,\n type: string\n ): string | undefined | null {\n if (typeof rule.style.color === 'object' && rule.style.color.input[0] !== 'properties') {\n return ItemAttributes.autoColor(type, rule.style.color.ignoreCase);\n }\n if (!Tools.isDefined(rule.input) && typeof rule.style.color !== 'object') {\n return rule.style.color;\n }\n return null;\n }\n\n /**\n * return the corresponding size to the value with a linear function\n * @param value\n * @param lower\n * @param higher\n * @param extrema\n */\n public static getAutomaticRangeStyleLinear(\n value: number,\n {max, min}: IStyleAutoRange,\n lower: EdgeWidthExtrema | NodeSizeExtrema,\n higher: EdgeWidthExtrema | NodeSizeExtrema\n ): string | undefined {\n if (max !== undefined && min !== undefined) {\n // apply default style when min equal max\n if (max === min || isNaN(value)) {\n return '100%';\n }\n\n // calculate the linear function f(x) = ax + b\n const a = (higher - lower) / (max - min);\n const b = (lower * max - higher * min) / (max - min);\n const size = Math.floor(value * a + b);\n\n return `${size}%`;\n }\n }\n\n /**\n * return the corresponding size to the value with a logarithmic function\n * @param value\n * @param lower\n * @param higher\n * @param extrema\n */\n public static getAutomaticRangeStyleLog(\n value: number,\n {max, min}: IStyleAutoRange,\n lower: EdgeWidthExtrema | NodeSizeExtrema,\n higher: EdgeWidthExtrema | NodeSizeExtrema\n ): string | undefined {\n if (min !== undefined && max !== undefined) {\n // apply default style when min equal max\n if (max === min || isNaN(value)) {\n return '100%';\n }\n // apply an offset for all the values (including min and max)\n if (min < 1) {\n value += Math.abs(min) + 1;\n max += Math.abs(min) + 1;\n min += Math.abs(min) + 1;\n }\n // calculate the logarithmic function f(x) = Math.floor(a*log(x) + b)\n const a = (higher - lower) / (Math.log(max) - Math.log(min));\n const b = (lower * Math.log(max) - higher * Math.log(min)) / (Math.log(max) - Math.log(min));\n const size = Math.floor(a * Math.log(value) + b);\n\n return `${size}%`;\n }\n }\n\n public isAutoRange(value: string | number | IStyleAutoRange): value is IStyleAutoRange {\n return typeof value === 'object' && value?.type === 'autoRange';\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color } from '@linkurious/ogma';
|
|
2
|
-
import {
|
|
2
|
+
import { INodeStyle, IStyleIcon, IStyleImage, LkNodeData, OgmaNodeShape } from '@linkurious/rest-client';
|
|
3
3
|
import { StyleRule } from './styleRule';
|
|
4
4
|
import { ItemAttributes } from './itemAttributes';
|
|
5
5
|
export interface OgmaImage extends IStyleImage {
|
|
@@ -9,13 +9,13 @@ export declare enum NodeSizeExtrema {
|
|
|
9
9
|
MIN = 50,
|
|
10
10
|
MAX = 500
|
|
11
11
|
}
|
|
12
|
-
export declare class NodeAttributes extends ItemAttributes {
|
|
12
|
+
export declare class NodeAttributes extends ItemAttributes<INodeStyle> {
|
|
13
13
|
constructor(rulesMap: {
|
|
14
|
-
color?: Array<StyleRule
|
|
15
|
-
icon?: Array<StyleRule
|
|
16
|
-
image?: Array<StyleRule
|
|
17
|
-
shape?: Array<StyleRule
|
|
18
|
-
size?: Array<StyleRule
|
|
14
|
+
color?: Array<StyleRule<INodeStyle>>;
|
|
15
|
+
icon?: Array<StyleRule<INodeStyle>>;
|
|
16
|
+
image?: Array<StyleRule<INodeStyle>>;
|
|
17
|
+
shape?: Array<StyleRule<INodeStyle>>;
|
|
18
|
+
size?: Array<StyleRule<INodeStyle>>;
|
|
19
19
|
});
|
|
20
20
|
/**
|
|
21
21
|
* Run the callback if an item match with a style in the array of rules
|
|
@@ -46,7 +46,7 @@ export declare class NodeAttributes extends ItemAttributes {
|
|
|
46
46
|
* @param rule
|
|
47
47
|
* @param isLog
|
|
48
48
|
*/
|
|
49
|
-
static getAutomaticRangeSize(value: number, rule: StyleRule
|
|
49
|
+
static getAutomaticRangeSize(value: number, rule: StyleRule<INodeStyle>, isLog?: boolean): string | undefined;
|
|
50
50
|
/**
|
|
51
51
|
* Return an object containing all node attributes needed by Ogma to style a node
|
|
52
52
|
*/
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NodeAttributes = exports.NodeSizeExtrema = void 0;
|
|
7
|
+
const rest_client_1 = require("@linkurious/rest-client");
|
|
7
8
|
const sha1_1 = __importDefault(require("sha1"));
|
|
8
9
|
const tools_1 = require("../tools/tools");
|
|
9
10
|
const __1 = require("..");
|
|
@@ -48,7 +49,7 @@ class NodeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
48
49
|
}
|
|
49
50
|
let colors = [];
|
|
50
51
|
for (let i = 0; i < itemData.categories.length; ++i) {
|
|
51
|
-
let
|
|
52
|
+
let color = null;
|
|
52
53
|
for (let j = 0; j < this._rulesMap.color.length; ++j) {
|
|
53
54
|
const rule = this._rulesMap.color[j];
|
|
54
55
|
if (rule.itemType !== undefined &&
|
|
@@ -60,19 +61,19 @@ class NodeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
60
61
|
if (typeof rule.style.color === 'object') {
|
|
61
62
|
const propValue = tools_1.Tools.getIn(itemData, rule.style.color.input);
|
|
62
63
|
if (Array.isArray(propValue)) {
|
|
63
|
-
|
|
64
|
+
color = itemAttributes_1.ItemAttributes.autoColor(itemData.categories[i], rule.style.color.ignoreCase);
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
|
-
|
|
67
|
+
color = itemAttributes_1.ItemAttributes.autoColor(`${propValue}`, rule.style.color.ignoreCase);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
else {
|
|
70
|
-
|
|
71
|
+
color = rule.style.color;
|
|
71
72
|
}
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
colors.push(
|
|
76
|
+
colors.push(color);
|
|
76
77
|
}
|
|
77
78
|
colors = colors.filter((c) => tools_1.Tools.isDefined(c));
|
|
78
79
|
if (colors.length === 0) {
|
|
@@ -86,6 +87,7 @@ class NodeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
86
87
|
* Generate icon for a given node
|
|
87
88
|
*/
|
|
88
89
|
icon(itemData) {
|
|
90
|
+
var _a, _b;
|
|
89
91
|
const rawColors = this.color(itemData);
|
|
90
92
|
const color = Array.isArray(rawColors) ? rawColors[0] : rawColors;
|
|
91
93
|
let result = {};
|
|
@@ -98,26 +100,27 @@ class NodeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
98
100
|
}
|
|
99
101
|
for (let i = 0; i < rules.length; ++i) {
|
|
100
102
|
if (rules[i].canApplyTo(itemData)) {
|
|
101
|
-
|
|
103
|
+
const style = rules[i].style;
|
|
104
|
+
if ('icon' in style && typeof style.icon === 'object') {
|
|
102
105
|
result = {
|
|
103
106
|
icon: {
|
|
104
|
-
content:
|
|
105
|
-
font:
|
|
107
|
+
content: (_a = style.icon) === null || _a === void 0 ? void 0 : _a.content,
|
|
108
|
+
font: (_b = style.icon) === null || _b === void 0 ? void 0 : _b.font,
|
|
106
109
|
scale: 0.5,
|
|
107
110
|
color: __1.OgmaTools.isBright(color) ? '#000000' : '#FFFFFF'
|
|
108
111
|
}
|
|
109
112
|
};
|
|
110
113
|
}
|
|
111
|
-
else if ('image' in
|
|
114
|
+
else if ('image' in style && typeof style.image === 'object') {
|
|
112
115
|
result = {
|
|
113
116
|
image: {
|
|
114
|
-
url: tools_1.Tools.getType(
|
|
115
|
-
tools_1.Tools.getType(
|
|
116
|
-
?
|
|
117
|
-
: tools_1.Tools.getIn(itemData,
|
|
118
|
-
scale:
|
|
119
|
-
fit:
|
|
120
|
-
tile:
|
|
117
|
+
url: tools_1.Tools.getType(style.image.url) === 'imageUrl' ||
|
|
118
|
+
tools_1.Tools.getType(style.image.url) === 'image'
|
|
119
|
+
? style.image.url
|
|
120
|
+
: tools_1.Tools.getIn(itemData, style.image.url.path),
|
|
121
|
+
scale: style.image.scale,
|
|
122
|
+
fit: style.image.fit,
|
|
123
|
+
tile: style.image.tile,
|
|
121
124
|
minVisibleSize: 0
|
|
122
125
|
}
|
|
123
126
|
};
|
|
@@ -147,14 +150,13 @@ class NodeAttributes extends itemAttributes_1.ItemAttributes {
|
|
|
147
150
|
if (this._rulesMap.size !== undefined) {
|
|
148
151
|
NodeAttributes.matchStyle(this._rulesMap.size, itemData, (styleRule) => {
|
|
149
152
|
const sizeStyle = styleRule.style.size;
|
|
150
|
-
if (sizeStyle
|
|
153
|
+
if (this.isAutoRange(sizeStyle)) {
|
|
151
154
|
if (sizeStyle.input !== undefined &&
|
|
152
155
|
sizeStyle.max !== undefined &&
|
|
153
156
|
sizeStyle.min !== undefined) {
|
|
154
157
|
const propertyName = sizeStyle.input[1];
|
|
155
158
|
const propertyValue = tools_1.Tools.parseNumber(itemData.properties[propertyName]);
|
|
156
|
-
|
|
157
|
-
const isLog = sizeStyle.scale && sizeStyle.scale === 'logarithmic';
|
|
159
|
+
const isLog = sizeStyle.scale && sizeStyle.scale === rest_client_1.AutoRangeScale.LOGARITHMIC;
|
|
158
160
|
result = NodeAttributes.getAutomaticRangeSize(propertyValue, styleRule, isLog);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeAttributes.js","sourceRoot":"","sources":["../../src/styles/nodeAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAGb,gDAAwB;AAExB,0CAAqC;AACrC,0BAA6B;AAG7B,qDAA2D;AAM3D,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oDAAQ,CAAA;IACR,qDAAS,CAAA;AACX,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,Q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/E,OAAO,KAAK;YACV,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAC5B,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,eAAe,CAAC,GAAG,EACnB,eAAe,CAAC,GAAG,CACpB;YACH,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAC/B,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,IAAI,EACf,eAAe,CAAC,GAAG,EACnB,eAAe,CAAC,GAAG,CACpB,CAAC;IACR,CAAC;IAED;;OAEG;IACI,GAAG,CACR,QAAoB;QAQpB,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO;gBACL,KAAK,EAAE,0BAAS;aACjB,CAAC;SACH;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC3B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,KAAK,EAAE,aAAa,CAAC,KAAK;SAC3B,CAAC;IACJ,CAAC;CACF;AA/ND,wCA+NC","sourcesContent":["'use strict';\nimport {Color} from '@linkurious/ogma';\nimport {LkNodeData, OgmaNodeShape, IStyleImage, IStyleIcon} from '@linkurious/rest-client';\nimport sha1 from 'sha1';\n\nimport {Tools} from '../tools/tools';\nimport {OgmaTools} from '..';\n\nimport {StyleRule} from './styleRule';\nimport {BASE_GREY, ItemAttributes} from './itemAttributes';\n\nexport interface OgmaImage extends IStyleImage {\n url?: string;\n}\n\nexport enum NodeSizeExtrema {\n MIN = 50,\n MAX = 500\n}\n\nexport class NodeAttributes extends ItemAttributes {\n constructor(rulesMap: {\n color?: Array<StyleRule>;\n icon?: Array<StyleRule>;\n image?: Array<StyleRule>;\n shape?: Array<StyleRule>;\n size?: Array<StyleRule>;\n }) {\n super(rulesMap);\n }\n\n /**\n * Run the callback if an item match with a style in the array of rules\n */\n private static matchStyle(\n styleRules: Array<StyleRule>,\n itemData: LkNodeData,\n callback: (style: StyleRule) => unknown\n ): void {\n if (!Tools.isDefined(itemData)) {\n return;\n }\n if (!Tools.isDefined(styleRules)) {\n return;\n }\n for (let i = 0; i < styleRules.length; ++i) {\n if (styleRules[i].canApplyTo(itemData)) {\n callback(styleRules[i]);\n break;\n }\n }\n }\n\n /**\n * Generate color for a given node (call only if _rulesMap.color is defined\n */\n public color(itemData: LkNodeData): Color | Array<Color> {\n if (!Tools.isDefined(itemData)) {\n return [BASE_GREY];\n }\n const hash = sha1(JSON.stringify(itemData));\n const cachedColor = this.colorsCache.get(hash);\n if (cachedColor !== undefined) {\n return cachedColor;\n }\n let colors = [];\n for (let i = 0; i < itemData.categories.length; ++i) {\n let c = null;\n for (let j = 0; j < this._rulesMap.color!.length; ++j) {\n const rule = this._rulesMap.color![j];\n if (\n rule.itemType !== undefined &&\n rule.itemType !== null &&\n rule.itemType !== itemData.categories[i]\n ) {\n continue;\n }\n if (rule.canApplyTo(itemData)) {\n if (typeof rule.style.color === 'object') {\n const propValue = Tools.getIn(itemData, rule.style.color.input);\n if (Array.isArray(propValue)) {\n c = ItemAttributes.autoColor(itemData.categories[i], rule.style.ignoreCase);\n } else {\n c = ItemAttributes.autoColor(`${propValue}`, rule.style.ignoreCase);\n }\n } else {\n c = rule.style.color;\n }\n break;\n }\n }\n colors.push(c);\n }\n colors = colors.filter((c) => Tools.isDefined(c));\n if (colors.length === 0) {\n colors = [BASE_GREY];\n }\n const finalColor = colors.length === 1 ? colors[0] : colors;\n this.colorsCache.set(hash, finalColor);\n return finalColor;\n }\n\n /**\n * Generate icon for a given node\n */\n public icon(\n itemData: LkNodeData\n ): {\n icon?: IStyleIcon;\n image?: OgmaImage | null;\n } {\n const rawColors = this.color(itemData);\n const color = Array.isArray(rawColors) ? rawColors[0] : rawColors;\n let result = {};\n const rules = [...(this._rulesMap.image || []), ...(this._rulesMap.icon || [])];\n if (!Tools.isDefined(itemData)) {\n return {\n icon: {},\n image: {}\n };\n }\n for (let i = 0; i < rules.length; ++i) {\n if (rules[i].canApplyTo(itemData)) {\n if ('icon' in rules[i].style) {\n result = {\n icon: {\n content: rules[i].style.icon.content,\n font: rules[i].style.icon.font,\n scale: 0.5,\n color: OgmaTools.isBright(color) ? '#000000' : '#FFFFFF'\n }\n };\n } else if ('image' in rules[i].style) {\n result = {\n image: {\n url:\n Tools.getType(rules[i].style.image.url) === 'imageUrl' ||\n Tools.getType(rules[i].style.image.url) === 'image'\n ? rules[i].style.image.url\n : Tools.getIn(itemData, rules[i].style.image.url.path),\n scale: rules[i].style.image.scale,\n fit: rules[i].style.image.fit,\n tile: rules[i].style.image.tile,\n minVisibleSize: 0\n }\n };\n }\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Generate shape for a given node\n */\n public shape(itemData: LkNodeData): OgmaNodeShape | undefined {\n let result = undefined;\n if (this._rulesMap.shape !== undefined) {\n NodeAttributes.matchStyle(this._rulesMap.shape, itemData, (styleRule) => {\n result = styleRule.style.shape;\n });\n }\n return result;\n }\n\n /**\n * Generate size for a given node\n */\n public size(itemData: LkNodeData): number | undefined {\n let result = undefined;\n if (this._rulesMap.size !== undefined) {\n NodeAttributes.matchStyle(this._rulesMap.size, itemData, (styleRule) => {\n const sizeStyle = styleRule.style.size;\n if (sizeStyle.type === 'autoRange') {\n if (\n sizeStyle.input !== undefined &&\n sizeStyle.max !== undefined &&\n sizeStyle.min !== undefined\n ) {\n const propertyName: string = sizeStyle.input[1];\n const propertyValue = Tools.parseNumber(itemData.properties[propertyName]);\n //to update with the correct enum type\n const isLog = sizeStyle.scale && sizeStyle.scale === 'logarithmic';\n result = NodeAttributes.getAutomaticRangeSize(propertyValue, styleRule, isLog);\n }\n } else {\n result = sizeStyle;\n }\n });\n }\n return result;\n }\n\n /**\n * return the corresponding size to the value\n * @param value\n * @param rule\n * @param isLog\n */\n public static getAutomaticRangeSize(value: number, rule: StyleRule, isLog = false): string {\n return isLog\n ? this.getAutomaticRangeStyleLog(\n value,\n rule.style.size,\n NodeSizeExtrema.MIN,\n NodeSizeExtrema.MAX\n )\n : this.getAutomaticRangeStyleLinear(\n value,\n rule.style.size,\n NodeSizeExtrema.MIN,\n NodeSizeExtrema.MAX\n );\n }\n\n /**\n * Return an object containing all node attributes needed by Ogma to style a node\n */\n public all(\n itemData: LkNodeData\n ): {\n radius?: number | undefined;\n color: Color | Array<Color>;\n shape?: OgmaNodeShape | undefined;\n icon?: IStyleIcon;\n image?: IStyleImage | null;\n } {\n if (!Tools.isDefined(itemData)) {\n return {\n color: BASE_GREY\n };\n }\n const generatedIcon = this.icon(itemData);\n return {\n radius: this.size(itemData),\n color: this.color(itemData),\n shape: this.shape(itemData),\n icon: generatedIcon.icon,\n image: generatedIcon.image\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeAttributes.js","sourceRoot":"","sources":["../../src/styles/nodeAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,yDASiC;AACjC,gDAAwB;AAExB,0CAAqC;AACrC,0BAA6B;AAG7B,qDAA2D;AAM3D,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oDAAQ,CAAA;IACR,qDAAS,CAAA;AACX,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAED,MAAa,cAAe,SAAQ,+BAA0B;IAC5D,YAAY,QAMX;QACC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,UAAU,CACvB,UAAwC,EACxC,QAAoB,EACpB,QAAmD;QAEnD,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO;SACR;QACD,IAAI,CAAC,aAAK,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;YAChC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CAAC;SACH;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC3B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,KAAK,EAAE,aAAa,CAAC,KAAK;SAC3B,CAAC;IACJ,CAAC;CACF;AAvOD,wCAuOC","sourcesContent":["'use strict';\nimport {Color} from '@linkurious/ogma';\nimport {\n AutoRangeScale,\n IImageDataValue,\n INodeStyle,\n IStyleAutoRange,\n IStyleIcon,\n IStyleImage,\n LkNodeData,\n OgmaNodeShape\n} from '@linkurious/rest-client';\nimport sha1 from 'sha1';\n\nimport {Tools} from '../tools/tools';\nimport {OgmaTools} from '..';\n\nimport {StyleRule} from './styleRule';\nimport {BASE_GREY, ItemAttributes} from './itemAttributes';\n\nexport interface OgmaImage extends IStyleImage {\n url?: string;\n}\n\nexport enum NodeSizeExtrema {\n MIN = 50,\n MAX = 500\n}\n\nexport class NodeAttributes extends ItemAttributes<INodeStyle> {\n constructor(rulesMap: {\n color?: Array<StyleRule<INodeStyle>>;\n icon?: Array<StyleRule<INodeStyle>>;\n image?: Array<StyleRule<INodeStyle>>;\n shape?: Array<StyleRule<INodeStyle>>;\n size?: Array<StyleRule<INodeStyle>>;\n }) {\n super(rulesMap);\n }\n\n /**\n * Run the callback if an item match with a style in the array of rules\n */\n private static matchStyle(\n styleRules: Array<StyleRule<INodeStyle>>,\n itemData: LkNodeData,\n callback: (style: StyleRule<INodeStyle>) => unknown\n ): void {\n if (!Tools.isDefined(itemData)) {\n return;\n }\n if (!Tools.isDefined(styleRules)) {\n return;\n }\n for (let i = 0; i < styleRules.length; ++i) {\n if (styleRules[i].canApplyTo(itemData)) {\n callback(styleRules[i]);\n break;\n }\n }\n }\n\n /**\n * Generate color for a given node (call only if _rulesMap.color is defined\n */\n public color(itemData: LkNodeData): Color | Array<Color> {\n if (!Tools.isDefined(itemData)) {\n return [BASE_GREY];\n }\n const hash = sha1(JSON.stringify(itemData));\n const cachedColor = this.colorsCache.get(hash);\n if (cachedColor !== undefined) {\n return cachedColor;\n }\n let colors: Array<string | null> = [];\n for (let i = 0; i < itemData.categories.length; ++i) {\n let color = null;\n for (let j = 0; j < this._rulesMap.color!.length; ++j) {\n const rule = this._rulesMap.color![j];\n if (\n rule.itemType !== undefined &&\n rule.itemType !== null &&\n rule.itemType !== itemData.categories[i]\n ) {\n continue;\n }\n if (rule.canApplyTo(itemData)) {\n if (typeof rule.style.color === 'object') {\n const propValue = Tools.getIn(itemData, rule.style.color.input);\n if (Array.isArray(propValue)) {\n color = ItemAttributes.autoColor(itemData.categories[i], rule.style.color.ignoreCase);\n } else {\n color = ItemAttributes.autoColor(`${propValue}`, rule.style.color.ignoreCase);\n }\n } else {\n color = rule.style.color as string;\n }\n break;\n }\n }\n colors.push(color);\n }\n colors = colors.filter((c) => Tools.isDefined(c));\n if (colors.length === 0) {\n colors = [BASE_GREY];\n }\n const finalColor = colors.length === 1 ? colors[0] : colors;\n this.colorsCache.set(hash, finalColor);\n return finalColor;\n }\n\n /**\n * Generate icon for a given node\n */\n public icon(\n itemData: LkNodeData\n ): {\n icon?: IStyleIcon;\n image?: OgmaImage | null;\n } {\n const rawColors = this.color(itemData);\n const color = Array.isArray(rawColors) ? rawColors[0] : rawColors;\n let result = {};\n const rules = [...(this._rulesMap.image || []), ...(this._rulesMap.icon || [])];\n if (!Tools.isDefined(itemData)) {\n return {\n icon: {},\n image: {}\n };\n }\n for (let i = 0; i < rules.length; ++i) {\n if (rules[i].canApplyTo(itemData)) {\n const style = rules[i].style;\n if ('icon' in style && typeof style.icon === 'object') {\n result = {\n icon: {\n content: style.icon?.content as string,\n font: style.icon?.font,\n scale: 0.5,\n color: OgmaTools.isBright(color) ? '#000000' : '#FFFFFF'\n }\n };\n } else if ('image' in style && typeof style.image === 'object') {\n result = {\n image: {\n url:\n Tools.getType(style.image.url as string) === 'imageUrl' ||\n Tools.getType(style.image.url as string) === 'image'\n ? style.image.url\n : Tools.getIn(itemData, (style.image.url as IImageDataValue).path),\n scale: style.image.scale,\n fit: style.image.fit,\n tile: style.image.tile,\n minVisibleSize: 0\n }\n };\n }\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Generate shape for a given node\n */\n public shape(itemData: LkNodeData): OgmaNodeShape | undefined {\n let result = undefined;\n if (this._rulesMap.shape !== undefined) {\n NodeAttributes.matchStyle(this._rulesMap.shape, itemData, (styleRule) => {\n result = styleRule.style.shape;\n });\n }\n return result;\n }\n\n /**\n * Generate size for a given node\n */\n public size(itemData: LkNodeData): number | undefined {\n let result = undefined;\n if (this._rulesMap.size !== undefined) {\n NodeAttributes.matchStyle(\n this._rulesMap.size,\n itemData,\n (styleRule: StyleRule<INodeStyle>) => {\n const sizeStyle = styleRule.style.size as string | number | IStyleAutoRange;\n if (this.isAutoRange(sizeStyle)) {\n if (\n sizeStyle.input !== undefined &&\n sizeStyle.max !== undefined &&\n sizeStyle.min !== undefined\n ) {\n const propertyName: string = sizeStyle.input[1];\n const propertyValue = Tools.parseNumber(itemData.properties[propertyName]);\n const isLog = sizeStyle.scale && sizeStyle.scale === AutoRangeScale.LOGARITHMIC;\n result = NodeAttributes.getAutomaticRangeSize(propertyValue, styleRule, isLog);\n }\n } else {\n result = sizeStyle;\n }\n }\n );\n }\n return result;\n }\n\n /**\n * return the corresponding size to the value\n * @param value\n * @param rule\n * @param isLog\n */\n public static getAutomaticRangeSize(\n value: number,\n rule: StyleRule<INodeStyle>,\n isLog = false\n ): string | undefined {\n return isLog\n ? this.getAutomaticRangeStyleLog(\n value,\n rule.style.size as IStyleAutoRange,\n NodeSizeExtrema.MIN,\n NodeSizeExtrema.MAX\n )\n : this.getAutomaticRangeStyleLinear(\n value,\n rule.style.size as IStyleAutoRange,\n NodeSizeExtrema.MIN,\n NodeSizeExtrema.MAX\n );\n }\n\n /**\n * Return an object containing all node attributes needed by Ogma to style a node\n */\n public all(\n itemData: LkNodeData\n ): {\n radius?: number | undefined;\n color: Color | Array<Color>;\n shape?: OgmaNodeShape | undefined;\n icon?: IStyleIcon;\n image?: IStyleImage | null;\n } {\n if (!Tools.isDefined(itemData)) {\n return {\n color: BASE_GREY\n };\n }\n const generatedIcon = this.icon(itemData);\n return {\n radius: this.size(itemData),\n color: this.color(itemData),\n shape: this.shape(itemData),\n icon: generatedIcon.icon,\n image: generatedIcon.image\n };\n }\n}\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IEdgeStyle, IStyleRule, LkEdgeData, LkNodeData, INodeStyle, SelectorType } from '@linkurious/rest-client';
|
|
1
|
+
import { IEdgeStyle, IStyleRule, LkEdgeData, LkNodeData, INodeStyle, IRangeValues, SelectorType } from '@linkurious/rest-client';
|
|
2
2
|
export declare enum StyleRuleType {
|
|
3
3
|
AUTO_RANGE = "autoRange"
|
|
4
4
|
}
|
|
5
|
-
export declare class StyleRule
|
|
5
|
+
export declare class StyleRule<T extends INodeStyle | IEdgeStyle = INodeStyle | IEdgeStyle> implements IStyleRule<T> {
|
|
6
6
|
type: SelectorType;
|
|
7
7
|
input: string[] | undefined;
|
|
8
8
|
index: number;
|
|
9
|
+
style: T;
|
|
9
10
|
itemType?: string;
|
|
10
|
-
value:
|
|
11
|
-
|
|
12
|
-
constructor(model: IStyleRule<INodeStyle | IEdgeStyle>);
|
|
11
|
+
value: IRangeValues | number | string | boolean;
|
|
12
|
+
constructor(model: IStyleRule<T>);
|
|
13
13
|
static isAutomaticRange(rule: IStyleRule<IEdgeStyle | INodeStyle>): boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Return an int describing specificity of the style. 4 = very specific / 1 = not specific
|
|
@@ -20,7 +20,7 @@ export declare class StyleRule implements IStyleRule<INodeStyle | IEdgeStyle> {
|
|
|
20
20
|
/**
|
|
21
21
|
* Return true if this style match values
|
|
22
22
|
*/
|
|
23
|
-
matchValues(itemType: string | undefined, input: Array<string> | undefined, value:
|
|
23
|
+
matchValues(itemType: string | undefined, input: Array<string> | undefined, value: string): boolean;
|
|
24
24
|
static inputExists(type: SelectorType, input: Array<string> | undefined): input is Array<string>;
|
|
25
25
|
/**
|
|
26
26
|
* Return true if a style can apply to a node
|
|
@@ -51,7 +51,7 @@ export declare class StyleRule implements IStyleRule<INodeStyle | IEdgeStyle> {
|
|
|
51
51
|
/**
|
|
52
52
|
* Return true or false on rule type 'is' if the current node match the rule
|
|
53
53
|
*/
|
|
54
|
-
static checkIs(data: LkNodeData | LkEdgeData, input: Array<string>, value:
|
|
54
|
+
static checkIs(data: LkNodeData | LkEdgeData, input: Array<string>, value: IRangeValues | number | string | boolean): boolean;
|
|
55
55
|
/**
|
|
56
56
|
* Check that value of itemType match for the node
|
|
57
57
|
*/
|
|
@@ -70,7 +70,7 @@ export declare class StyleRule implements IStyleRule<INodeStyle | IEdgeStyle> {
|
|
|
70
70
|
* @param {string} itemType
|
|
71
71
|
* @return {boolean}
|
|
72
72
|
*/
|
|
73
|
-
static matchAny(itemType:
|
|
73
|
+
static matchAny(itemType: string | null | undefined): boolean;
|
|
74
74
|
/**
|
|
75
75
|
* Return the color for a type
|
|
76
76
|
*/
|
package/dist/styles/styleRule.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleRule.js","sourceRoot":"","sources":["../../src/styles/styleRule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yDAQiC;AAEjC,0BAAkC;AAClC,0CAAqC;AAErC,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,yCAAwB,CAAA;AAC1B,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB;AAED,MAAa,SAAS;IAQpB,YAAY,KAA0C;QACpD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB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,CAAC,QAAQ,CAAC,QAAoB;QACzC,OAAO,QAAQ,KAAK,SAAS,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,IAAY;QAC9B,IAAI,KAAK,CAAC;QACV,IACE,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;YAC9C,IAAI,CAAC,IAAI,KAAK,0BAAY,CAAC,GAAG;YAC9B,CAAC,aAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAC5B;YACA,KAAK,GAAG,kBAAc,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA5OD,8BA4OC","sourcesContent":["'use strict';\n\nimport {\n IEdgeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n INodeStyle,\n SelectorType,\n IStyleAutoRange\n} from '@linkurious/rest-client';\n\nimport {ItemAttributes} from '..';\nimport {Tools} from '../tools/tools';\n\nexport enum StyleRuleType {\n AUTO_RANGE = 'autoRange'\n}\n\nexport class StyleRule implements IStyleRule<INodeStyle | IEdgeStyle> {\n public type: SelectorType;\n public input: string[] | undefined;\n public index: number;\n public itemType?: string;\n public value: any;\n public style: any;\n\n constructor(model: IStyleRule<INodeStyle | IEdgeStyle>) {\n this.type = model.type;\n this.input = model.input;\n this.index = model.index;\n this.itemType = model.itemType;\n this.style = model.style;\n this.value = model.value;\n }\n\n public static isAutomaticRange(rule: IStyleRule<IEdgeStyle | INodeStyle>): boolean {\n return (\n rule.style !== undefined &&\n (((rule.style as IEdgeStyle).width !== undefined &&\n ((rule.style as IEdgeStyle).width as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE) ||\n ((rule.style as INodeStyle).size !== undefined &&\n ((rule.style as INodeStyle).size as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE))\n );\n }\n\n /**\n * Return an int describing specificity of the style. 4 = very specific / 1 = not specific\n *\n * @return {number}\n */\n get specificity(): 1 | 2 | 3 | 4 {\n if (this.itemType !== undefined && this.input !== undefined) {\n return 4;\n }\n if (this.itemType === undefined && this.input !== undefined) {\n return 3;\n }\n if (this.itemType !== undefined && this.input === undefined) {\n return 2;\n }\n return 1;\n }\n\n /**\n * Return true if this style match values\n */\n public matchValues(\n itemType: string | undefined,\n input: Array<string> | undefined,\n value: any\n ): boolean {\n if (Tools.isDefined(input)) {\n return (\n ((itemType === this.itemType || !Tools.isDefined(this.itemType)) &&\n Tools.isEqual(['properties', ...input], this.input) &&\n Tools.isEqual(value, this.value)) ||\n (this.type === 'any' &&\n !Tools.isDefined(this.input) &&\n typeof this.style.color === 'object' &&\n this.style.color.input[1] === input[0])\n );\n }\n\n if (Tools.isDefined(this.itemType)) {\n return itemType === this.itemType && !Tools.isDefined(this.input);\n }\n\n return !Tools.isDefined(this.input);\n }\n\n public static inputExists(\n type: SelectorType,\n input: Array<string> | undefined\n ): input is Array<string> {\n return type !== SelectorType.ANY;\n }\n\n /**\n * Return true if a style can apply to a node\n */\n public canApplyTo(data: LkNodeData | LkEdgeData): boolean {\n const types = 'categories' in data ? data.categories : [data.type];\n let typePredicate = false;\n switch (this.type) {\n case SelectorType.ANY:\n typePredicate = StyleRule.checkAny(data, this.style);\n break;\n\n case SelectorType.NO_VALUE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNoValue(data, this.input);\n }\n break;\n\n case SelectorType.NAN:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNan(data, this.input);\n }\n break;\n\n case SelectorType.RANGE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkRange(Tools.getIn(data, this.input), this.value);\n }\n break;\n\n case SelectorType.IS:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkIs(data, this.input, this.value);\n }\n break;\n }\n return typePredicate && StyleRule.checkItemType(types, this.itemType);\n }\n\n /**\n * Return true or false on rule type 'any' if the current node match the rule\n */\n public static checkAny(data: LkNodeData | LkEdgeData, style: INodeStyle | IEdgeStyle): boolean {\n // return true if autoColor by a property and this property exists in node\n if (typeof style.color === 'object') {\n return Tools.isDefined(Tools.getIn(data, style.color.input));\n }\n return true;\n }\n\n /**\n * Return true or false on rule type 'noValue' if the current node match the rule\n */\n public static checkNoValue(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.valueExists(Tools.getIn(data, input));\n }\n\n /**\n * Return true or false on rule type 'NaN' if the current node match the rule\n */\n public static checkNan(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.isNumber(Tools.getIn(data, input));\n }\n\n /**\n * Return true if predicate is true for the node value\n *\n * @param value\n * @param comparator\n * @return {boolean}\n */\n public static checkRange(\n value: number,\n comparator: {[key in '<=' | '<' | '>' | '>=']?: number}\n ): boolean {\n return (\n (comparator['<='] === undefined || value <= comparator['<=']) &&\n (comparator['<'] === undefined || value < comparator['<']) &&\n (comparator['>'] === undefined || value > comparator['>']) &&\n (comparator['>='] === undefined || value >= comparator['>='])\n );\n }\n\n /**\n * Return true or false on rule type 'is' if the current node match the rule\n */\n public static checkIs(data: LkNodeData | LkEdgeData, input: Array<string>, value: any): boolean {\n if (!Tools.isDefined(input)) {\n return false;\n }\n const itemValue = Tools.getIn(data, input);\n let formattedValue = itemValue;\n if (\n Tools.isDefined(itemValue) &&\n typeof itemValue === 'object' &&\n (itemValue.type === 'date' || itemValue.type === 'datetime')\n ) {\n let timezone = itemValue.timezone;\n if (itemValue.timezone === 'Z') {\n timezone = '+00:00';\n }\n formattedValue = Tools.formatDate(\n itemValue.value,\n itemValue.type === 'datetime',\n Tools.timezoneToMilliseconds(timezone) / 1000\n );\n }\n return Tools.isEqual(formattedValue, value);\n }\n\n /**\n * Check that value of itemType match for the node\n */\n public static checkItemType(types: Array<string>, itemType: string | undefined): boolean {\n return StyleRule.matchCategory(types, itemType) || StyleRule.matchAny(itemType);\n }\n\n /**\n * Return true if itemType is defined and category exists in an array of categories\n *\n * @param {Array<string> | string} types\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchCategory(\n types: Array<string> | string,\n itemType: string | undefined\n ): boolean {\n return (\n Tools.isDefined(itemType) &&\n (Array.isArray(types) ? types.includes(itemType) : Tools.isEqual(types, itemType))\n );\n }\n\n /**\n * Return true if itemType is undefined\n *\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchAny(itemType: any | null): boolean {\n return itemType === undefined;\n }\n\n /**\n * Return the color for a type\n */\n public getTypeColor(type: string): string | undefined | null {\n let color;\n if (\n StyleRule.checkItemType([type], this.itemType) &&\n this.type === SelectorType.ANY &&\n !Tools.isDefined(this.input)\n ) {\n color = ItemAttributes.getTypeColor(this, type);\n }\n return color;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"styleRule.js","sourceRoot":"","sources":["../../src/styles/styleRule.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yDASiC;AAEjC,0BAAkC;AAClC,0CAAqC;AAErC,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,yCAAwB,CAAA;AAC1B,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB;AAED,MAAa,SAAS;IASpB,YAAY,KAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,qCAAqC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAiD,CAAC;IACvE,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,IAAyC;QACtE,OAAO,CACL,IAAI,CAAC,KAAK,KAAK,SAAS;YACxB,C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AAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArPD,8BAqPC","sourcesContent":["'use strict';\n\nimport {\n IEdgeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n INodeStyle,\n IRangeValues,\n SelectorType,\n IStyleAutoRange\n} from '@linkurious/rest-client';\n\nimport {ItemAttributes} from '..';\nimport {Tools} from '../tools/tools';\n\nexport enum StyleRuleType {\n AUTO_RANGE = 'autoRange'\n}\n\nexport class StyleRule<T extends INodeStyle | IEdgeStyle = INodeStyle | IEdgeStyle>\n implements IStyleRule<T> {\n public type: SelectorType;\n public input: string[] | undefined;\n public index: number;\n public style: T;\n public itemType?: string;\n public value: IRangeValues | number | string | boolean;\n\n constructor(model: IStyleRule<T>) {\n this.type = model.type;\n this.input = model.input;\n this.index = model.index;\n this.itemType = model.itemType;\n this.style = model.style;\n // cast to remove undefined from type\n this.value = model.value as IRangeValues | number | string | boolean;\n }\n\n public static isAutomaticRange(rule: IStyleRule<IEdgeStyle | INodeStyle>): boolean {\n return (\n rule.style !== undefined &&\n (((rule.style as IEdgeStyle).width !== undefined &&\n ((rule.style as IEdgeStyle).width as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE) ||\n ((rule.style as INodeStyle).size !== undefined &&\n ((rule.style as INodeStyle).size as IStyleAutoRange).type === StyleRuleType.AUTO_RANGE))\n );\n }\n\n /**\n * Return an int describing specificity of the style. 4 = very specific / 1 = not specific\n *\n * @return {number}\n */\n get specificity(): 1 | 2 | 3 | 4 {\n if (this.itemType !== undefined && this.input !== undefined) {\n return 4;\n }\n if (this.itemType === undefined && this.input !== undefined) {\n return 3;\n }\n if (this.itemType !== undefined && this.input === undefined) {\n return 2;\n }\n return 1;\n }\n\n /**\n * Return true if this style match values\n */\n public matchValues(\n itemType: string | undefined,\n input: Array<string> | undefined,\n value: string\n ): boolean {\n if (Tools.isDefined(input)) {\n return (\n ((itemType === this.itemType || !Tools.isDefined(this.itemType)) &&\n Tools.isEqual(['properties', ...input], this.input) &&\n Tools.isEqual(value, this.value)) ||\n (this.type === 'any' &&\n !Tools.isDefined(this.input) &&\n typeof this.style.color === 'object' &&\n this.style.color.input[1] === input[0])\n );\n }\n\n if (Tools.isDefined(this.itemType)) {\n return itemType === this.itemType && !Tools.isDefined(this.input);\n }\n\n return !Tools.isDefined(this.input);\n }\n\n public static inputExists(\n type: SelectorType,\n input: Array<string> | undefined\n ): input is Array<string> {\n return type !== SelectorType.ANY;\n }\n\n /**\n * Return true if a style can apply to a node\n */\n public canApplyTo(data: LkNodeData | LkEdgeData): boolean {\n const types = 'categories' in data ? data.categories : [data.type];\n let typePredicate = false;\n switch (this.type) {\n case SelectorType.ANY:\n typePredicate = StyleRule.checkAny(data, this.style);\n break;\n\n case SelectorType.NO_VALUE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNoValue(data, this.input);\n }\n break;\n\n case SelectorType.NAN:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkNan(data, this.input);\n }\n break;\n\n case SelectorType.RANGE:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkRange(\n Tools.getIn(data, this.input),\n this.value as IRangeValues\n );\n }\n break;\n\n case SelectorType.IS:\n if (StyleRule.inputExists(this.type, this.input)) {\n typePredicate = StyleRule.checkIs(data, this.input, this.value);\n }\n break;\n }\n return typePredicate && StyleRule.checkItemType(types, this.itemType);\n }\n\n /**\n * Return true or false on rule type 'any' if the current node match the rule\n */\n public static checkAny(data: LkNodeData | LkEdgeData, style: INodeStyle | IEdgeStyle): boolean {\n // return true if autoColor by a property and this property exists in node\n if (typeof style.color === 'object') {\n return Tools.isDefined(Tools.getIn(data, style.color.input));\n }\n return true;\n }\n\n /**\n * Return true or false on rule type 'noValue' if the current node match the rule\n */\n public static checkNoValue(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.valueExists(Tools.getIn(data, input));\n }\n\n /**\n * Return true or false on rule type 'NaN' if the current node match the rule\n */\n public static checkNan(data: LkNodeData | LkEdgeData, input: Array<string>): boolean {\n return !Tools.isNumber(Tools.getIn(data, input));\n }\n\n /**\n * Return true if predicate is true for the node value\n *\n * @param value\n * @param comparator\n * @return {boolean}\n */\n public static checkRange(\n value: number,\n comparator: {[key in '<=' | '<' | '>' | '>=']?: number}\n ): boolean {\n return (\n (comparator['<='] === undefined || value <= comparator['<=']) &&\n (comparator['<'] === undefined || value < comparator['<']) &&\n (comparator['>'] === undefined || value > comparator['>']) &&\n (comparator['>='] === undefined || value >= comparator['>='])\n );\n }\n\n /**\n * Return true or false on rule type 'is' if the current node match the rule\n */\n public static checkIs(\n data: LkNodeData | LkEdgeData,\n input: Array<string>,\n value: IRangeValues | number | string | boolean\n ): boolean {\n if (!Tools.isDefined(input)) {\n return false;\n }\n const itemValue = Tools.getIn(data, input);\n let formattedValue = itemValue;\n if (\n Tools.isDefined(itemValue) &&\n typeof itemValue === 'object' &&\n (itemValue.type === 'date' || itemValue.type === 'datetime')\n ) {\n let timezone = itemValue.timezone;\n if (itemValue.timezone === 'Z') {\n timezone = '+00:00';\n }\n formattedValue = Tools.formatDate(\n itemValue.value,\n itemValue.type === 'datetime',\n Tools.timezoneToMilliseconds(timezone) / 1000\n );\n }\n return Tools.isEqual(formattedValue, value);\n }\n\n /**\n * Check that value of itemType match for the node\n */\n public static checkItemType(types: Array<string>, itemType: string | undefined): boolean {\n return StyleRule.matchCategory(types, itemType) || StyleRule.matchAny(itemType);\n }\n\n /**\n * Return true if itemType is defined and category exists in an array of categories\n *\n * @param {Array<string> | string} types\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchCategory(\n types: Array<string> | string,\n itemType: string | undefined\n ): boolean {\n return (\n Tools.isDefined(itemType) &&\n (Array.isArray(types) ? types.includes(itemType) : Tools.isEqual(types, itemType))\n );\n }\n\n /**\n * Return true if itemType is undefined\n *\n * @param {string} itemType\n * @return {boolean}\n */\n public static matchAny(itemType: string | null | undefined): boolean {\n return itemType === undefined;\n }\n\n /**\n * Return the color for a type\n */\n public getTypeColor(type: string): string | undefined | null {\n let color;\n if (\n StyleRule.checkItemType([type], this.itemType) &&\n this.type === SelectorType.ANY &&\n !Tools.isDefined(this.input)\n ) {\n color = ItemAttributes.getTypeColor(this, type);\n }\n return color;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IEdgeStyle, IStyleRule, LkEdgeData, LkNodeData, INodeStyle, SelectorType, IStyleIcon, IStyleImage, IStyles } from '@linkurious/rest-client';
|
|
1
|
+
import { IEdgeStyle, IStyleRule, LkEdgeData, LkNodeData, INodeStyle, SelectorType, IStyleIcon, IStyleImage, IStyles, IRangeValues } from '@linkurious/rest-client';
|
|
2
2
|
import { StyleRule } from './styleRule';
|
|
3
3
|
export declare enum StyleType {
|
|
4
4
|
COLOR = "color",
|
|
@@ -57,7 +57,7 @@ export declare class StyleRules {
|
|
|
57
57
|
/**
|
|
58
58
|
* Return an object containing for each node style a sorted array of StyleRule
|
|
59
59
|
*
|
|
60
|
-
* @return {
|
|
60
|
+
* @return {{[key: string]: Array<StyleRule>} }
|
|
61
61
|
*/
|
|
62
62
|
get nodeRules(): {
|
|
63
63
|
[key: string]: Array<StyleRule>;
|
|
@@ -65,7 +65,7 @@ export declare class StyleRules {
|
|
|
65
65
|
/**
|
|
66
66
|
* Return an object containing for each edge style a sorted array of StyleRule
|
|
67
67
|
*
|
|
68
|
-
* @return {
|
|
68
|
+
* @return { {[key: string]: Array<StyleRule>}}
|
|
69
69
|
*/
|
|
70
70
|
get edgeRules(): {
|
|
71
71
|
[key: string]: Array<StyleRule>;
|
|
@@ -77,14 +77,14 @@ export declare class StyleRules {
|
|
|
77
77
|
/**
|
|
78
78
|
* Return the legend for a specific style type (color, icon, image...)
|
|
79
79
|
*/
|
|
80
|
-
static getLegendForStyle(styleType:
|
|
80
|
+
static getLegendForStyle(styleType: StyleType, styles: Array<StyleRule>, itemsData: Array<LkNodeData | LkEdgeData>): Array<{
|
|
81
81
|
label: string;
|
|
82
82
|
value: string | number | IStyleIcon | IStyleImage;
|
|
83
83
|
}>;
|
|
84
84
|
/**
|
|
85
85
|
* Sanitize value for legend
|
|
86
86
|
*/
|
|
87
|
-
static sanitizeValue(styleType: SelectorType, value:
|
|
87
|
+
static sanitizeValue(styleType: SelectorType, value: IRangeValues | number | string | boolean): string;
|
|
88
88
|
/**
|
|
89
89
|
* Add items in legend for automatic coloring
|
|
90
90
|
*/
|
|
@@ -73,7 +73,7 @@ class StyleRules {
|
|
|
73
73
|
/**
|
|
74
74
|
* Return an object containing for each node style a sorted array of StyleRule
|
|
75
75
|
*
|
|
76
|
-
* @return {
|
|
76
|
+
* @return {{[key: string]: Array<StyleRule>} }
|
|
77
77
|
*/
|
|
78
78
|
get nodeRules() {
|
|
79
79
|
return {
|
|
@@ -87,7 +87,7 @@ class StyleRules {
|
|
|
87
87
|
/**
|
|
88
88
|
* Return an object containing for each edge style a sorted array of StyleRule
|
|
89
89
|
*
|
|
90
|
-
* @return {
|
|
90
|
+
* @return { {[key: string]: Array<StyleRule>}}
|
|
91
91
|
*/
|
|
92
92
|
get edgeRules() {
|
|
93
93
|
return {
|
|
@@ -153,7 +153,9 @@ class StyleRules {
|
|
|
153
153
|
const label = tools_1.Tools.isDefined(styleRule.input)
|
|
154
154
|
? `${StyleRules.getTypeLabel(styleRule.itemType)}.${styleRule.input[1]} ${StyleRules.sanitizeValue(styleRule.type, styleRule.value)}`
|
|
155
155
|
: `${StyleRules.getTypeLabel(styleRule.itemType)}`;
|
|
156
|
-
const value =
|
|
156
|
+
const value = styleType === StyleType.WIDTH
|
|
157
|
+
? styleRule.style[styleType]
|
|
158
|
+
: styleRule.style[styleType];
|
|
157
159
|
StyleRules.updateLegend(result, { label: label, value: value });
|
|
158
160
|
}
|
|
159
161
|
}
|
|
@@ -164,13 +166,13 @@ class StyleRules {
|
|
|
164
166
|
* Sanitize value for legend
|
|
165
167
|
*/
|
|
166
168
|
static sanitizeValue(styleType, value) {
|
|
169
|
+
let template = '';
|
|
167
170
|
switch (styleType) {
|
|
168
171
|
case rest_client_1.SelectorType.NO_VALUE:
|
|
169
172
|
return 'is undefined';
|
|
170
173
|
case rest_client_1.SelectorType.NAN:
|
|
171
174
|
return 'is not an number';
|
|
172
175
|
case rest_client_1.SelectorType.RANGE:
|
|
173
|
-
let template = '';
|
|
174
176
|
Object.keys(value).forEach((k, i) => {
|
|
175
177
|
if (i > 0) {
|
|
176
178
|
template += ' and ';
|
|
@@ -185,23 +187,24 @@ class StyleRules {
|
|
|
185
187
|
* Add items in legend for automatic coloring
|
|
186
188
|
*/
|
|
187
189
|
static addLegendAutoColors(itemsData, styleRule, currentLegend) {
|
|
188
|
-
const
|
|
190
|
+
const colorStyle = styleRule.style.color;
|
|
191
|
+
const propertyKey = colorStyle.input[1];
|
|
189
192
|
itemsData.forEach((data) => {
|
|
190
|
-
const propValue = tools_1.Tools.getIn(data,
|
|
193
|
+
const propValue = tools_1.Tools.getIn(data, colorStyle.input);
|
|
191
194
|
if (Array.isArray(propValue)) {
|
|
192
195
|
propValue.forEach((value) => {
|
|
193
|
-
const label =
|
|
196
|
+
const label = colorStyle.input.includes('properties')
|
|
194
197
|
? `${StyleRules.getTypeLabel(styleRule.itemType)}.${propertyKey} = ${value}`
|
|
195
198
|
: `${StyleRules.getTypeLabel(value)}`;
|
|
196
|
-
const color = itemAttributes_1.ItemAttributes.autoColor(value,
|
|
199
|
+
const color = itemAttributes_1.ItemAttributes.autoColor(value, colorStyle.ignoreCase);
|
|
197
200
|
StyleRules.updateLegend(currentLegend, { label: label, value: color });
|
|
198
201
|
});
|
|
199
202
|
}
|
|
200
203
|
else {
|
|
201
|
-
const label =
|
|
204
|
+
const label = colorStyle.input.includes('properties')
|
|
202
205
|
? `${StyleRules.getTypeLabel(styleRule.itemType)}.${propertyKey} = ${propValue}`
|
|
203
206
|
: `${StyleRules.getTypeLabel(propValue)}`;
|
|
204
|
-
const value = itemAttributes_1.ItemAttributes.autoColor(propValue,
|
|
207
|
+
const value = itemAttributes_1.ItemAttributes.autoColor(propValue, colorStyle.ignoreCase);
|
|
205
208
|
StyleRules.updateLegend(currentLegend, { label: label, value: value });
|
|
206
209
|
}
|
|
207
210
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleRules.js","sourceRoot":"","sources":["../../src/styles/styleRules.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yDAUiC;AAEjC,0CAA6C;AAE7C,2CAAsC;AACtC,qDAAgD;AAEhD,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,0BAAa,CAAA;IACb,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,4BAAe,CAAA;AACjB,CAAC,EAPW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAOpB;AAMY,QAAA,YAAY,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEjE,MAAa,UAAU;IAGrB,YAAY,KAAiD;QAC3D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAW,KAAK;QACd,OAAO,IAAA,cAAM,EAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,oBAAY,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACH,IAAW,IAAI;QACb,OAAO,IAAA,cAAM,EACX;YACE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACxD,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAC1D,EACD,oBAAY,CACb,CAAC;IACJ,CAAC;IAED;;;;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,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5F,eAAe,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACxD,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACnC,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC;gBACvB,QAAQ,EAAE,CAAC;aACZ;iBAAM;gBACL,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aAC7B;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,eAAe,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACxD,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACnC,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC;gBACvB,QAAQ,EAAE,CAAC;aACZ;iBAAM;gBACL,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aAC7B;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AA7TD,gCA6TC","sourcesContent":["'use strict';\n\nimport {\n IEdgeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n INodeStyle,\n SelectorType,\n IStyleIcon,\n IStyleImage,\n IStyles\n} from '@linkurious/rest-client';\n\nimport {sortBy, Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {ItemAttributes} from './itemAttributes';\n\nexport enum StyleType {\n COLOR = 'color',\n ICON = 'icon',\n SIZE = 'size',\n IMAGE = 'image',\n SHAPE = 'shape',\n WIDTH = 'width'\n}\n\nexport interface Legend {\n [key: string]: Array<{label: string; value: string | IStyleIcon | IStyleImage | number}>;\n}\n\nexport const SORTING_RULE = ['specificity', 'itemType', 'index'];\n\nexport class StyleRules {\n private _rules: Array<IStyleRule<INodeStyle | IEdgeStyle>>;\n\n constructor(rules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n this._rules = rules;\n }\n\n /**\n * Return an array of StyleRule with only 'color' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get color(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.COLOR, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'icon' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get icon(): Array<StyleRule> {\n return sortBy(\n [\n ...(StyleRules.getBy(StyleType.ICON, this._rules) || []),\n ...(StyleRules.getBy(StyleType.IMAGE, this._rules) || [])\n ],\n SORTING_RULE\n );\n }\n\n /**\n * Return an array of StyleRule with only 'image' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get image(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.IMAGE, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'shape' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get shape(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.SHAPE, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'size' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get size(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.SIZE, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'width' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get width(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.WIDTH, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an object containing for each node style a sorted array of StyleRule\n *\n * @return {any}\n */\n public get nodeRules(): {[key: string]: Array<StyleRule>} {\n return {\n color: this.color,\n icon: this.icon,\n image: this.image,\n shape: this.shape,\n size: this.size\n };\n }\n\n /**\n * Return an object containing for each edge style a sorted array of StyleRule\n *\n * @return {any}\n */\n public get edgeRules(): {[key: string]: Array<StyleRule>} {\n return {\n color: this.color,\n shape: this.shape,\n width: this.width\n };\n }\n\n /**\n * Generate a legend with an array of style rules and existing items in visualization\n */\n public generateLegend(itemsData: Array<LkNodeData | LkEdgeData>): Legend {\n const result: Legend = {};\n if (itemsData.length === 0) {\n return result;\n }\n\n if ('categories' in itemsData[0]) {\n Object.keys(this.nodeRules).forEach((style: string) => {\n result[style] = StyleRules.getLegendForStyle(style, this.nodeRules[style], itemsData);\n });\n } else {\n Object.keys(this.edgeRules).forEach((style: string) => {\n result[style] = StyleRules.getLegendForStyle(style, this.edgeRules[style], itemsData);\n });\n }\n return result;\n }\n\n /**\n * Return the legend for a specific style type (color, icon, image...)\n */\n public static getLegendForStyle(\n styleType: string,\n styles: Array<StyleRule>,\n itemsData: Array<LkNodeData | LkEdgeData>\n ): Array<{label: string; value: string | number | IStyleIcon | IStyleImage}> {\n const result: Array<{label: string; value: string | number | IStyleIcon | IStyleImage}> = [];\n const data = itemsData.filter((i) => i);\n for (let i = 0; i < styles.length; i++) {\n const styleRule = new StyleRule(styles[i]);\n const ruleExistsInViz = data.some((itemData) => {\n return styleRule.canApplyTo(itemData);\n });\n if (ruleExistsInViz) {\n if (styleType === StyleType.COLOR && typeof styleRule.style.color === 'object') {\n StyleRules.addLegendAutoColors(data, styleRule, result);\n } else if (styleType === StyleType.ICON && 'image' in styleRule.style) {\n // style is a custom icon\n const label = Tools.isDefined(styleRule.input)\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${\n styleRule.input[1]\n } ${StyleRules.sanitizeValue(styleRule.type, styleRule.value)}`\n : `${StyleRules.getTypeLabel(styleRule.itemType)}`;\n const imageStyle = styleRule.style.image as IStyleImage;\n if (\n imageStyle.url &&\n typeof imageStyle.url === 'object' &&\n imageStyle.url.type === 'data'\n ) {\n // If the custom icon is read from a node property-value dynamically, then we\n // skip it from the legend, because it could be a different image for each node,\n // thus bloating the legend.\n } else {\n const value = styleRule.style.image;\n StyleRules.updateLegend(result, {label: label, value: value});\n }\n } else {\n const label = Tools.isDefined(styleRule.input)\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${\n styleRule.input[1]\n } ${StyleRules.sanitizeValue(styleRule.type, styleRule.value)}`\n : `${StyleRules.getTypeLabel(styleRule.itemType)}`;\n const value = styleRule.style[styleType];\n StyleRules.updateLegend(result, {label: label, value: value});\n }\n }\n }\n\n return result;\n }\n\n /**\n * Sanitize value for legend\n */\n public static sanitizeValue(styleType: SelectorType, value: any): string {\n switch (styleType) {\n case SelectorType.NO_VALUE:\n return 'is undefined';\n\n case SelectorType.NAN:\n return 'is not an number';\n\n case SelectorType.RANGE:\n let template = '';\n Object.keys(value).forEach((k, i) => {\n if (i > 0) {\n template += ' and ';\n }\n template += `${k} ${value[k]}`;\n });\n return template;\n }\n\n return typeof value === 'object' ? `= ${JSON.stringify(value)}` : `= ${value}`;\n }\n\n /**\n * Add items in legend for automatic coloring\n */\n public static addLegendAutoColors(\n itemsData: Array<LkNodeData | LkEdgeData>,\n styleRule: StyleRule,\n currentLegend: Array<{label: string; value: string | number | IStyleIcon | IStyleImage}>\n ): void {\n const propertyKey: string = styleRule.style.color.input[1];\n itemsData.forEach((data) => {\n const propValue = Tools.getIn(data, styleRule.style.color.input);\n if (Array.isArray(propValue)) {\n propValue.forEach((value) => {\n const label = styleRule.style.color.input.includes('properties')\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${propertyKey} = ${value}`\n : `${StyleRules.getTypeLabel(value)}`;\n const color = ItemAttributes.autoColor(value, styleRule.style.color.ignoreCase);\n StyleRules.updateLegend(currentLegend, {label: label, value: color});\n });\n } else {\n const label = styleRule.style.color.input.includes('properties')\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${propertyKey} = ${propValue}`\n : `${StyleRules.getTypeLabel(propValue)}`;\n const value = ItemAttributes.autoColor(propValue, styleRule.style.color.ignoreCase);\n StyleRules.updateLegend(currentLegend, {label: label, value: value});\n }\n });\n }\n\n /**\n * Return the label of item type for a legend item\n */\n public static getTypeLabel(type: string | undefined | null): string {\n return type === undefined ? 'All' : type === null ? 'Others' : type;\n }\n\n /**\n * Check if a legend item already exists and overwrite it / push it\n */\n public static updateLegend(\n legend: Array<{label: string; value: string | number | IStyleIcon | IStyleImage}>,\n {label, value}: {[key: string]: string}\n ): void {\n const indexOfLegendItem = legend.map((r) => r.label).indexOf(label);\n if (indexOfLegendItem < 0) {\n legend.push({label: label, value: value});\n } else {\n legend[indexOfLegendItem] = {label: label, value: value};\n }\n }\n\n /**\n * return an array of StyleRule, containing only the desired style\n */\n public static getBy(\n styleType: StyleType,\n rules: Array<IStyleRule<INodeStyle | IEdgeStyle>>\n ): Array<StyleRule> {\n return rules\n .filter((style: IStyleRule<INodeStyle | IEdgeStyle>) => {\n switch (styleType) {\n case StyleType.COLOR:\n return style.style.color !== undefined;\n\n case StyleType.ICON:\n return 'icon' in style.style && style.style.icon !== undefined;\n\n case StyleType.IMAGE:\n return 'image' in style.style && style.style.image !== undefined;\n\n case StyleType.SHAPE:\n return style.style.shape !== undefined;\n\n case StyleType.SIZE:\n return 'size' in style.style && style.style.size !== undefined;\n\n case StyleType.WIDTH:\n return 'width' in style.style && style.style.width !== undefined;\n }\n })\n .map((style: IStyleRule<INodeStyle | IEdgeStyle>) => StyleRules.getRule(style, styleType));\n }\n\n /**\n * From a RawStyle, generate a StyleRule of a specific style\n */\n public static getRule(\n rawRule: IStyleRule<INodeStyle | IEdgeStyle>,\n styleType: StyleType\n ): StyleRule {\n const rule = Tools.clone(rawRule);\n rule.style = {[styleType]: rule.style[styleType]};\n return new StyleRule(rule);\n }\n\n /**\n * Check for non unique index in styles rules and update them if exists\n */\n public static sanitizeStylesIndex(styles: IStyles): IStyles {\n const seenIndex: Array<number> = [];\n const sanitizedStyles: IStyles = Tools.clone(styles);\n let maxIndex =\n Math.max(...[...styles.node.map((s) => s.index), ...styles.edge.map((s) => s.index)]) + 1;\n sanitizedStyles.node = sanitizedStyles.node.map((style) => {\n if (seenIndex.includes(style.index)) {\n style.index = maxIndex;\n maxIndex++;\n } else {\n seenIndex.push(style.index);\n }\n return style;\n });\n sanitizedStyles.edge = sanitizedStyles.edge.map((style) => {\n if (seenIndex.includes(style.index)) {\n style.index = maxIndex;\n maxIndex++;\n } else {\n seenIndex.push(style.index);\n }\n return style;\n });\n return sanitizedStyles;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"styleRules.js","sourceRoot":"","sources":["../../src/styles/styleRules.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yDAYiC;AAEjC,0CAA6C;AAE7C,2CAAsC;AACtC,qDAAgD;AAEhD,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,0BAAa,CAAA;IACb,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,4BAAe,CAAA;AACjB,CAAC,EAPW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAOpB;AAMY,QAAA,YAAY,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEjE,MAAa,UAAU;IAGrB,YAAY,KAAiD;QAC3D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAW,KAAK;QACd,OAAO,IAAA,cAAM,EAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,oBAAY,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACH,IAAW,IAAI;QACb,OAAO,IAAA,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,eAAe,CAAC;IACzB,CAAC;CACF;AA5UD,gCA4UC","sourcesContent":["'use strict';\n\nimport {\n IEdgeStyle,\n IStyleRule,\n LkEdgeData,\n LkNodeData,\n INodeStyle,\n SelectorType,\n IStyleIcon,\n IStyleImage,\n IStyles,\n IStyleColor,\n IRangeValues\n} from '@linkurious/rest-client';\n\nimport {sortBy, Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {ItemAttributes} from './itemAttributes';\n\nexport enum StyleType {\n COLOR = 'color',\n ICON = 'icon',\n SIZE = 'size',\n IMAGE = 'image',\n SHAPE = 'shape',\n WIDTH = 'width'\n}\n\nexport interface Legend {\n [key: string]: Array<{label: string; value: string | IStyleIcon | IStyleImage | number}>;\n}\n\nexport const SORTING_RULE = ['specificity', 'itemType', 'index'];\n\nexport class StyleRules {\n private _rules: Array<IStyleRule<INodeStyle | IEdgeStyle>>;\n\n constructor(rules: Array<IStyleRule<INodeStyle | IEdgeStyle>>) {\n this._rules = rules;\n }\n\n /**\n * Return an array of StyleRule with only 'color' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get color(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.COLOR, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'icon' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get icon(): Array<StyleRule> {\n return sortBy(\n [\n ...(StyleRules.getBy(StyleType.ICON, this._rules) || []),\n ...(StyleRules.getBy(StyleType.IMAGE, this._rules) || [])\n ],\n SORTING_RULE\n );\n }\n\n /**\n * Return an array of StyleRule with only 'image' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get image(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.IMAGE, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'shape' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get shape(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.SHAPE, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'size' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get size(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.SIZE, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an array of StyleRule with only 'width' rules and sorted by specificity, itemType and index\n *\n * @return {Array<StyleRule>}\n */\n public get width(): Array<StyleRule> {\n return sortBy(StyleRules.getBy(StyleType.WIDTH, this._rules), SORTING_RULE);\n }\n\n /**\n * Return an object containing for each node style a sorted array of StyleRule\n *\n * @return {{[key: string]: Array<StyleRule>} }\n */\n public get nodeRules(): {[key: string]: Array<StyleRule>} {\n return {\n color: this.color,\n icon: this.icon,\n image: this.image,\n shape: this.shape,\n size: this.size\n };\n }\n\n /**\n * Return an object containing for each edge style a sorted array of StyleRule\n *\n * @return { {[key: string]: Array<StyleRule>}}\n */\n public get edgeRules(): {[key: string]: Array<StyleRule>} {\n return {\n color: this.color,\n shape: this.shape,\n width: this.width\n };\n }\n\n /**\n * Generate a legend with an array of style rules and existing items in visualization\n */\n public generateLegend(itemsData: Array<LkNodeData | LkEdgeData>): Legend {\n const result: Legend = {};\n if (itemsData.length === 0) {\n return result;\n }\n\n if ('categories' in itemsData[0]) {\n Object.keys(this.nodeRules).forEach((style: string) => {\n result[style] = StyleRules.getLegendForStyle(\n style as StyleType,\n this.nodeRules[style],\n itemsData\n );\n });\n } else {\n Object.keys(this.edgeRules).forEach((style: string) => {\n result[style] = StyleRules.getLegendForStyle(\n style as StyleType,\n this.edgeRules[style],\n itemsData\n );\n });\n }\n return result;\n }\n\n /**\n * Return the legend for a specific style type (color, icon, image...)\n */\n public static getLegendForStyle(\n styleType: StyleType,\n styles: Array<StyleRule>,\n itemsData: Array<LkNodeData | LkEdgeData>\n ): Array<{label: string; value: string | number | IStyleIcon | IStyleImage}> {\n const result: Array<{label: string; value: string | number | IStyleIcon | IStyleImage}> = [];\n const data = itemsData.filter((i) => i);\n for (let i = 0; i < styles.length; i++) {\n const styleRule = new StyleRule(styles[i]);\n const ruleExistsInViz = data.some((itemData) => {\n return styleRule.canApplyTo(itemData);\n });\n if (ruleExistsInViz) {\n if (styleType === StyleType.COLOR && typeof styleRule.style.color === 'object') {\n StyleRules.addLegendAutoColors(data, styleRule, result);\n } else if (styleType === StyleType.ICON && 'image' in styleRule.style) {\n // style is a custom icon\n const label = Tools.isDefined(styleRule.input)\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${\n styleRule.input[1]\n } ${StyleRules.sanitizeValue(styleRule.type, styleRule.value)}`\n : `${StyleRules.getTypeLabel(styleRule.itemType)}`;\n const imageStyle = styleRule.style.image as IStyleImage;\n if (\n imageStyle.url &&\n typeof imageStyle.url === 'object' &&\n imageStyle.url.type === 'data'\n ) {\n // If the custom icon is read from a node property-value dynamically, then we\n // skip it from the legend, because it could be a different image for each node,\n // thus bloating the legend.\n } else {\n const value = styleRule.style.image;\n StyleRules.updateLegend(result, {label: label, value: value as string});\n }\n } else {\n const label = Tools.isDefined(styleRule.input)\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${\n styleRule.input[1]\n } ${StyleRules.sanitizeValue(styleRule.type, styleRule.value)}`\n : `${StyleRules.getTypeLabel(styleRule.itemType)}`;\n const value =\n styleType === StyleType.WIDTH\n ? (styleRule.style as IEdgeStyle)[styleType]\n : (styleRule.style as INodeStyle)[styleType];\n StyleRules.updateLegend(result, {label: label, value: value as string});\n }\n }\n }\n\n return result;\n }\n\n /**\n * Sanitize value for legend\n */\n public static sanitizeValue(\n styleType: SelectorType,\n value: IRangeValues | number | string | boolean\n ): string {\n let template = '';\n switch (styleType) {\n case SelectorType.NO_VALUE:\n return 'is undefined';\n\n case SelectorType.NAN:\n return 'is not an number';\n\n case SelectorType.RANGE:\n Object.keys(value).forEach((k, i) => {\n if (i > 0) {\n template += ' and ';\n }\n template += `${k} ${(value as IRangeValues)[k as keyof IRangeValues]}`;\n });\n return template;\n }\n\n return typeof value === 'object' ? `= ${JSON.stringify(value)}` : `= ${value}`;\n }\n\n /**\n * Add items in legend for automatic coloring\n */\n public static addLegendAutoColors(\n itemsData: Array<LkNodeData | LkEdgeData>,\n styleRule: StyleRule,\n currentLegend: Array<{label: string; value: string | number | IStyleIcon | IStyleImage}>\n ): void {\n const colorStyle = styleRule.style.color as IStyleColor;\n const propertyKey: string = colorStyle.input[1];\n itemsData.forEach((data) => {\n const propValue = Tools.getIn(data, colorStyle.input);\n if (Array.isArray(propValue)) {\n propValue.forEach((value) => {\n const label = colorStyle.input.includes('properties')\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${propertyKey} = ${value}`\n : `${StyleRules.getTypeLabel(value)}`;\n const color = ItemAttributes.autoColor(value, colorStyle.ignoreCase);\n StyleRules.updateLegend(currentLegend, {label: label, value: color});\n });\n } else {\n const label = colorStyle.input.includes('properties')\n ? `${StyleRules.getTypeLabel(styleRule.itemType)}.${propertyKey} = ${propValue}`\n : `${StyleRules.getTypeLabel(propValue)}`;\n const value = ItemAttributes.autoColor(propValue, colorStyle.ignoreCase);\n StyleRules.updateLegend(currentLegend, {label: label, value: value});\n }\n });\n }\n\n /**\n * Return the label of item type for a legend item\n */\n public static getTypeLabel(type: string | undefined | null): string {\n return type === undefined ? 'All' : type === null ? 'Others' : type;\n }\n\n /**\n * Check if a legend item already exists and overwrite it / push it\n */\n public static updateLegend(\n legend: Array<{label: string; value: string | number | IStyleIcon | IStyleImage}>,\n {label, value}: {[key: string]: string}\n ): void {\n const indexOfLegendItem = legend.map((r) => r.label).indexOf(label);\n if (indexOfLegendItem < 0) {\n legend.push({label: label, value: value});\n } else {\n legend[indexOfLegendItem] = {label: label, value: value};\n }\n }\n\n /**\n * return an array of StyleRule, containing only the desired style\n */\n public static getBy(\n styleType: StyleType,\n rules: Array<IStyleRule<INodeStyle | IEdgeStyle>>\n ): Array<StyleRule> {\n return rules\n .filter((style: IStyleRule<INodeStyle | IEdgeStyle>) => {\n switch (styleType) {\n case StyleType.COLOR:\n return style.style.color !== undefined;\n\n case StyleType.ICON:\n return 'icon' in style.style && style.style.icon !== undefined;\n\n case StyleType.IMAGE:\n return 'image' in style.style && style.style.image !== undefined;\n\n case StyleType.SHAPE:\n return style.style.shape !== undefined;\n\n case StyleType.SIZE:\n return 'size' in style.style && style.style.size !== undefined;\n\n case StyleType.WIDTH:\n return 'width' in style.style && style.style.width !== undefined;\n }\n })\n .map((style: IStyleRule<INodeStyle | IEdgeStyle>) => StyleRules.getRule(style, styleType));\n }\n\n /**\n * From a RawStyle, generate a StyleRule of a specific style\n */\n public static getRule(\n rawRule: IStyleRule<INodeStyle | IEdgeStyle>,\n styleType: StyleType\n ): StyleRule {\n const rule = Tools.clone(rawRule);\n rule.style = {[styleType]: rule.style[styleType]};\n return new StyleRule(rule);\n }\n\n /**\n * Check for non unique index in styles rules and update them if exists\n */\n public static sanitizeStylesIndex(styles: IStyles): IStyles {\n const seenIndex: Array<number> = [];\n const sanitizedStyles: IStyles = Tools.clone(styles);\n let maxIndex =\n Math.max(...[...styles.node.map((s) => s.index), ...styles.edge.map((s) => s.index)]) + 1;\n sanitizedStyles.node = sanitizedStyles.node.map((style) => {\n if (seenIndex.includes(style.index)) {\n style.index = maxIndex;\n maxIndex++;\n } else {\n seenIndex.push(style.index);\n }\n return style;\n });\n sanitizedStyles.edge = sanitizedStyles.edge.map((style) => {\n if (seenIndex.includes(style.index)) {\n style.index = maxIndex;\n maxIndex++;\n } else {\n seenIndex.push(style.index);\n }\n return style;\n });\n return sanitizedStyles;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkurious/ogma-linkurious-parser",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"author": "Linkurious SAS",
|
|
5
5
|
"description": "Parse and load a Linkurious visualization in Ogma with one line of code ",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": "18.
|
|
16
|
+
"node": "18.15.0"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"prepare": "tsc -b",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"sha1": "1.1.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@linkurious/ogma": "4.
|
|
52
|
+
"@linkurious/ogma": "4.4.4"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@linkurious/ogma": "4.
|
|
56
|
-
"@linkurious/rest-client": "4.0.
|
|
55
|
+
"@linkurious/ogma": "4.4.4",
|
|
56
|
+
"@linkurious/rest-client": "4.0.4",
|
|
57
57
|
"@rollup/plugin-buble": "0.21.3",
|
|
58
58
|
"@rollup/plugin-commonjs": "17.0.0",
|
|
59
59
|
"@rollup/plugin-json": "4.1.0",
|