@krainovsd/graph 0.14.0-beta.9 → 0.15.0-beta.1

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.
Files changed (78) hide show
  1. package/lib/cjs/index.cjs +636 -375
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/esm/constants/force-controls.js +6 -4
  4. package/lib/esm/constants/force-controls.js.map +1 -1
  5. package/lib/esm/constants/highlight-controls.js +6 -3
  6. package/lib/esm/constants/highlight-controls.js.map +1 -1
  7. package/lib/esm/constants/link-controls.js +6 -3
  8. package/lib/esm/constants/link-controls.js.map +1 -1
  9. package/lib/esm/constants/node-controls.js +6 -3
  10. package/lib/esm/constants/node-controls.js.map +1 -1
  11. package/lib/esm/index.js +8 -6
  12. package/lib/esm/index.js.map +1 -1
  13. package/lib/esm/module/GraphCanvas/GraphCanvas.js +36 -17
  14. package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
  15. package/lib/esm/module/GraphCanvas/StaticGraphCanvas.js +127 -0
  16. package/lib/esm/module/GraphCanvas/StaticGraphCanvas.js.map +1 -0
  17. package/lib/esm/module/GraphCanvas/constants/graph-settings.js +6 -7
  18. package/lib/esm/module/GraphCanvas/constants/graph-settings.js.map +1 -1
  19. package/lib/esm/module/GraphCanvas/constants/highlight-settings.js +1 -4
  20. package/lib/esm/module/GraphCanvas/constants/highlight-settings.js.map +1 -1
  21. package/lib/esm/module/GraphCanvas/constants/index.js +6 -4
  22. package/lib/esm/module/GraphCanvas/constants/index.js.map +1 -1
  23. package/lib/esm/module/GraphCanvas/constants/link-settings.js +1 -9
  24. package/lib/esm/module/GraphCanvas/constants/link-settings.js.map +1 -1
  25. package/lib/esm/module/GraphCanvas/constants/node-settings.js +1 -10
  26. package/lib/esm/module/GraphCanvas/constants/node-settings.js.map +1 -1
  27. package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js +6 -4
  28. package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js.map +1 -1
  29. package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js +0 -3
  30. package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js.map +1 -1
  31. package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js +6 -3
  32. package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js.map +1 -1
  33. package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js +6 -3
  34. package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js.map +1 -1
  35. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +20 -6
  36. package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
  37. package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js +6 -4
  38. package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js.map +1 -1
  39. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +6 -4
  40. package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -1
  41. package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js +1 -1
  42. package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
  43. package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +25 -27
  44. package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
  45. package/lib/esm/module/GraphCanvas/lib/utils/is-overlaps-node.js.map +1 -1
  46. package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js +2 -1
  47. package/lib/esm/module/GraphCanvas/lib/utils/node-by-pointer-getter.js.map +1 -1
  48. package/lib/esm/module/GraphCanvas/lib/utils/node-highlight.js +7 -11
  49. package/lib/esm/module/GraphCanvas/lib/utils/node-highlight.js.map +1 -1
  50. package/lib/esm/module/GraphCanvas/lib/utils/node-iteration-extractor.js +3 -0
  51. package/lib/esm/module/GraphCanvas/lib/utils/node-iteration-extractor.js.map +1 -1
  52. package/lib/esm/module/GraphCanvas/lib/utils/precompute-graph.js +24 -0
  53. package/lib/esm/module/GraphCanvas/lib/utils/precompute-graph.js.map +1 -0
  54. package/lib/esm/module/GraphCanvas/lib/utils/prepare-graph-data.js +49 -0
  55. package/lib/esm/module/GraphCanvas/lib/utils/prepare-graph-data.js.map +1 -0
  56. package/lib/esm/module/GraphCanvas/slices/draw-links.js +24 -42
  57. package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
  58. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +80 -168
  59. package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
  60. package/lib/esm/module/GraphCanvas/slices/draw-text.js +1 -9
  61. package/lib/esm/module/GraphCanvas/slices/draw-text.js.map +1 -1
  62. package/lib/esm/module/GraphCanvas/slices/export-svg.js +4 -5
  63. package/lib/esm/module/GraphCanvas/slices/export-svg.js.map +1 -1
  64. package/lib/esm/module/GraphCanvas/slices/init-dnd.js +15 -3
  65. package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -1
  66. package/lib/esm/module/GraphCanvas/slices/init-draw.js +212 -8
  67. package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
  68. package/lib/esm/module/GraphCanvas/slices/init-pointer.js +6 -8
  69. package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
  70. package/lib/esm/module/GraphCanvas/slices/init-simulation.js +3 -4
  71. package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
  72. package/lib/esm/module/GraphCanvas/slices/init-zoom.js +2 -4
  73. package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
  74. package/lib/esm/module/GraphCanvas/slices/update-link-cache.js +5 -5
  75. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js +17 -29
  76. package/lib/esm/module/GraphCanvas/slices/update-node-cache.js.map +1 -1
  77. package/lib/index.d.ts +94 -43
  78. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"draw-nodes.js","sources":["../../../../../src/module/GraphCanvas/slices/draw-nodes.ts"],"sourcesContent":["import { isNumber } from \"@krainovsd/js-helpers\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { isNodeVisible, nodeFade, nodeHighlight } from \"../lib\";\nimport type { NodeInterface } from \"../types\";\nimport { drawText } from \"./draw-text\";\n\nexport function getDrawNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(nodeRenders: (() => void)[], textRenders: (() => void)[]) {\n return function drawNode(\n this: GraphCanvas<NodeData, LinkData>,\n node: NodeInterface<NodeData>,\n index: number,\n ) {\n if (!this.context || !node.x || !node.y) return;\n if (node.visible != undefined && !node.visible) {\n node._radius = 0;\n node._width = 0;\n node._height = 0;\n\n return;\n }\n\n const nodeOptions = this.nodeOptionsCache[index];\n if (!nodeOptions) return;\n\n if (nodeOptions.nodeDraw && nodeOptions.textDraw) {\n nodeRenders.push(() => {\n if (nodeOptions.nodeDraw) {\n nodeOptions.nodeDraw.bind(this)(node, nodeOptions);\n }\n });\n\n textRenders.push(() => {\n if (nodeOptions.textDraw) {\n nodeOptions.textDraw.bind(this)(node, nodeOptions);\n }\n });\n\n return;\n }\n\n let radius = nodeOptions.radius;\n let width = nodeOptions.width;\n let height = nodeOptions.height;\n let alpha = nodeOptions.alpha;\n let color = nodeOptions.color;\n let borderColor = nodeOptions.borderColor;\n let borderWidth = nodeOptions.borderWidth;\n let textAlpha = nodeOptions.textAlpha;\n let textSize = nodeOptions.textSize;\n let textShiftX = nodeOptions.textShiftX;\n let textShiftY = nodeOptions.textShiftY;\n let textWeight = nodeOptions.textWeight;\n let labelSize = nodeOptions.labelSize;\n let labelWeight = nodeOptions.labelWeight;\n let labelAlpha = nodeOptions.labelAlpha;\n /** Highlight */\n if (this.highlightedNeighbors && this.highlightedNode) {\n /** By Node Not Highlight */\n if (!this.highlightedNeighbors.has(node.id) && this.highlightedNode.id != node.id) {\n const fadingOptions = nodeFade({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelFadingMin: this.highlightSettings.highlightByNodeForLabelFadingMin,\n highlightForNodeColorFading: this.highlightSettings.highlightByNodeForNodeColorFading,\n highlightForNodeFadingMin: this.highlightSettings.highlightByNodeForNodeFadingMin,\n highlightForTextFadingMin: this.highlightSettings.highlightByNodeForTextFadingMin,\n });\n alpha = fadingOptions.alpha;\n color = fadingOptions.color;\n textAlpha = fadingOptions.textAlpha;\n labelAlpha = fadingOptions.labelAlpha;\n } else if (\n !this.highlightSettings.highlightByNodeOnlyRoot ||\n (this.highlightSettings.highlightByNodeOnlyRoot && this.highlightedNode.id === node.id)\n ) {\n /** By Node Highlight */\n const highlightOptions = nodeHighlight({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelSizingAdditional:\n this.highlightSettings.highlightByNodeForLabelSizingAdditional,\n highlightForLabelWeightAdditional:\n this.highlightSettings.highlightByNodeForLabelWeightAdditional,\n highlightForNodeBorderColor: this.highlightSettings.highlightByNodeForNodeBorderColor,\n highlightForNodeBorderSizingAdditional:\n this.highlightSettings.highlightByNodeForNodeBorderSizingAdditional,\n highlightForNodeColor: this.highlightSettings.highlightByNodeForNodeColor,\n highlightForNodeSizingAdditional:\n this.highlightSettings.highlightByNodeForNodeSizingAdditional,\n highlightForNodeSizingAdditionalCoefficient:\n this.highlightSettings.highlightByNodeForNodeSizingAdditionalCoefficient,\n highlightForTextShiftXAdditional:\n this.highlightSettings.highlightByNodeForTextShiftXAdditional,\n highlightForTextShiftYAdditional:\n this.highlightSettings.highlightByNodeForTextShiftYAdditional,\n highlightForTextSizingAdditional:\n this.highlightSettings.highlightByNodeForTextSizingAdditional,\n highlightForTextWeightAdditional:\n this.highlightSettings.highlightByNodeForTextWeightAdditional,\n });\n color = highlightOptions.color;\n borderColor = highlightOptions.borderColor;\n borderWidth = highlightOptions.borderWidth;\n radius = highlightOptions.radiusInitial;\n width = highlightOptions.widthInitial;\n height = highlightOptions.heightInitial;\n textSize = highlightOptions.textSize;\n textShiftX = highlightOptions.textShiftX;\n textShiftY = highlightOptions.textShiftY;\n textWeight = highlightOptions.textWeight;\n labelSize = highlightOptions.labelSize;\n labelWeight = highlightOptions.labelWeight;\n }\n }\n if (this.highlightedNeighbors && this.highlightedLink) {\n /** By Link Not Highlight */\n if (\n !this.highlightedNeighbors.has(node.id) &&\n this.highlightedLink.source !== node &&\n this.highlightedLink.target !== node\n ) {\n const fadingOptions = nodeFade({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelFadingMin: this.highlightSettings.highlightByLinkForLabelFadingMin,\n highlightForNodeColorFading: this.highlightSettings.highlightByLinkForNodeColorFading,\n highlightForNodeFadingMin: this.highlightSettings.highlightByLinkForNodeFadingMin,\n highlightForTextFadingMin: this.highlightSettings.highlightByLinkForTextFadingMin,\n });\n alpha = fadingOptions.alpha;\n color = fadingOptions.color;\n textAlpha = fadingOptions.textAlpha;\n labelAlpha = fadingOptions.labelAlpha;\n } else {\n /** By Link Highlight */\n\n const highlightOptions = nodeHighlight({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelSizingAdditional:\n this.highlightSettings.highlightByLinkForLabelSizingAdditional,\n highlightForLabelWeightAdditional:\n this.highlightSettings.highlightByLinkForLabelWeightAdditional,\n highlightForNodeBorderColor: this.highlightSettings.highlightByLinkForNodeBorderColor,\n highlightForNodeBorderSizingAdditional:\n this.highlightSettings.highlightByLinkForNodeBorderSizingAdditional,\n highlightForNodeColor: this.highlightSettings.highlightByLinkForNodeColor,\n highlightForNodeSizingAdditional:\n this.highlightSettings.highlightByLinkForNodeSizingAdditional,\n highlightForNodeSizingAdditionalCoefficient:\n this.highlightSettings.highlightByLinkForNodeSizingAdditionalCoefficient,\n highlightForTextShiftXAdditional:\n this.highlightSettings.highlightByLinkForTextShiftXAdditional,\n highlightForTextShiftYAdditional:\n this.highlightSettings.highlightByLinkForTextShiftYAdditional,\n highlightForTextSizingAdditional:\n this.highlightSettings.highlightByLinkForTextSizingAdditional,\n highlightForTextWeightAdditional:\n this.highlightSettings.highlightByLinkForTextWeightAdditional,\n });\n color = highlightOptions.color;\n borderColor = highlightOptions.borderColor;\n borderWidth = highlightOptions.borderWidth;\n radius = highlightOptions.radiusInitial;\n width = highlightOptions.widthInitial;\n height = highlightOptions.heightInitial;\n textSize = highlightOptions.textSize;\n textShiftX = highlightOptions.textShiftX;\n textShiftY = highlightOptions.textShiftY;\n textWeight = highlightOptions.textWeight;\n labelSize = highlightOptions.labelSize;\n labelWeight = highlightOptions.labelWeight;\n }\n }\n\n /** Node parameters */\n node._radius = radius;\n node._borderWidth = borderWidth;\n node._width = width;\n node._height = height;\n node._borderRadius =\n isNumber(nodeOptions.borderRadius) && nodeOptions.borderRadius > 0\n ? Math.min(nodeOptions.borderRadius, nodeOptions.width / 2, nodeOptions.height / 2)\n : 0;\n node._shape = nodeOptions.shape ?? \"circle\";\n\n /** Node Visibility */\n if (\n !isNodeVisible({\n height: this.height,\n width: this.width,\n transform: this.areaTransform,\n node,\n })\n ) {\n node._visible = false;\n\n return;\n }\n node._visible = true;\n\n /** Node draw */\n nodeRenders.push(() => {\n if (!this.context || !node.x || !node.y) return;\n\n this.context.beginPath();\n this.context.globalAlpha = alpha;\n this.context.lineWidth = borderWidth;\n this.context.strokeStyle = borderColor;\n this.context.fillStyle = color;\n const labelLines = this.cachedNodeLabel[index];\n\n switch (nodeOptions.shape) {\n case \"circle\": {\n if (!node.image) {\n this.context.arc(node.x, node.y, radius, 0, 2 * Math.PI);\n this.context.fill();\n if (borderWidth > 0) {\n this.context.stroke();\n }\n } else {\n this.context.arc(node.x, node.y, radius, 0, 2 * Math.PI);\n this.context.closePath();\n this.context.save();\n this.context.clip();\n\n this.context.drawImage(\n node.image,\n node.x - radius,\n node.y - radius,\n radius * 2,\n radius * 2,\n );\n\n this.context.restore();\n if (borderWidth > 0) {\n this.context.stroke();\n }\n }\n\n if (node.label && labelLines) {\n this.context.globalAlpha = labelAlpha;\n drawText({\n context: this.context,\n lines: labelLines,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textGap: nodeOptions.labelGap,\n textSize: labelSize,\n textStyle: nodeOptions.labelStyle,\n textWeight: labelWeight,\n x: node.x,\n y: node.y + labelSize / 3,\n });\n }\n\n break;\n }\n case \"square\": {\n if (!node.image) {\n this.context.roundRect(\n node.x - width / 2,\n node.y - height / 2,\n width,\n height,\n node._borderRadius,\n );\n this.context.fill();\n if (borderWidth > 0) {\n this.context.stroke();\n }\n } else {\n this.context.roundRect(\n node.x - width / 2,\n node.y - height / 2,\n width,\n height,\n node._borderRadius,\n );\n this.context.closePath();\n this.context.save();\n this.context.clip();\n this.context.drawImage(\n node.image,\n node.x - width / 2,\n node.y - height / 2,\n width,\n height,\n );\n this.context.restore();\n\n if (borderWidth > 0) {\n this.context.stroke();\n }\n }\n if (node.label && labelLines) {\n this.context.globalAlpha = labelAlpha;\n drawText({\n context: this.context,\n lines: labelLines,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textGap: nodeOptions.labelGap,\n textSize: labelSize,\n textStyle: nodeOptions.labelStyle,\n textWeight: labelWeight,\n x: node.x,\n y: node.y + labelSize / 3,\n });\n }\n break;\n }\n case \"text\": {\n if (this.nodeSettings.textNodeDebug) {\n this.context.strokeRect(node.x - width / 2, node.y - height / 2, width, height);\n }\n\n if (nodeOptions.label && labelLines)\n drawText({\n lines: labelLines,\n context: this.context,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: labelSize,\n x: node.x,\n y: node.y + textSize / 4 - (labelLines.length - 1) * (textSize / 2),\n textStyle: nodeOptions.labelStyle,\n textWeight,\n textGap: nodeOptions.labelGap,\n });\n this.context.fill();\n if (borderWidth > 0) {\n this.context.stroke();\n }\n break;\n }\n default: {\n this.context.arc(node.x, node.y, radius, 0, 2 * Math.PI);\n this.context.fill();\n if (borderWidth > 0) {\n this.context.stroke();\n }\n break;\n }\n }\n });\n\n if (nodeOptions.nodeExtraDraw) {\n nodeRenders.push(() => {\n nodeOptions?.nodeExtraDraw?.bind?.(this)?.(node, {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n });\n });\n }\n\n /** Text draw */\n const textLines = this.cachedNodeText[index];\n if (nodeOptions.textVisible && nodeOptions.text && textLines) {\n textRenders.push(() => {\n if (nodeOptions.textDraw) {\n nodeOptions.textDraw.bind(this)(node, {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n });\n\n return;\n }\n\n if (!this.context || !node.x || !node.y || !nodeOptions.text) return;\n this.context.beginPath();\n this.context.globalAlpha = textAlpha;\n\n let y = node.y + textShiftY;\n if (nodeOptions.shape === \"circle\") {\n y += radius;\n }\n if (nodeOptions.shape === \"square\" || nodeOptions.shape === \"text\") {\n y += height / 2;\n }\n\n drawText({\n lines: textLines,\n context: this.context,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize,\n x: node.x + textShiftX,\n y,\n textStyle: nodeOptions.textStyle,\n textWeight,\n textGap: nodeOptions.textGap,\n });\n\n if (nodeOptions.textExtraDraw) {\n nodeOptions.textExtraDraw.bind(this)(node, {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n });\n }\n });\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAMgB,SAAA,WAAW,CAGzB,WAA2B,EAAE,WAA2B,EAAA;AACxD,IAAA,OAAO,SAAS,QAAQ,CAEtB,IAA6B,EAC7B,KAAa,EAAA;AAEb,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;Y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BAAA,IAAI,WAAW,CAAC,aAAa,EAAE;oBAC7B,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;AACzC,wBAAA,GAAG,WAAW;wBACd,MAAM;wBACN,KAAK;wBACL,KAAK;wBACL,SAAS;wBACT,QAAQ;wBACR,UAAU;wBACV,UAAU;wBACV,UAAU;AACX,qBAAA,CAAC;;AAEN,aAAC,CAAC;;AAEN,KAAC;AACH;;;;"}
1
+ {"version":3,"file":"draw-nodes.js","sources":["../../../../../src/module/GraphCanvas/slices/draw-nodes.ts"],"sourcesContent":["import { isNumber } from \"@krainovsd/js-helpers\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { isNodeVisible, nodeFade, nodeHighlight } from \"../lib\";\nimport type { Area, DeferredDraw, NodeDrawBatch, NodeInterface, NodeTextDrawBatch } from \"../types\";\n\nexport function getDrawNode<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(\n nodeBatch: Record<string, NodeDrawBatch[]>,\n nodeImageBatch: Record<string, NodeDrawBatch[]>,\n textBatch: Record<string, Record<string, NodeTextDrawBatch[]>>,\n deferredNodeRender: DeferredDraw[],\n deferredTextRender: DeferredDraw[],\n area: Area,\n) {\n return function drawNode(\n this: GraphCanvas<NodeData, LinkData>,\n node: NodeInterface<NodeData>,\n index: number,\n ) {\n if (!this.context || !node.x || !node.y) return;\n if (node.visible != undefined && !node.visible) {\n node._radius = 0;\n node._width = 0;\n node._height = 0;\n return;\n }\n const nodeOptions = this.nodeOptionsCache[index];\n if (!nodeOptions) return;\n if (nodeOptions.nodeDraw && nodeOptions.textDraw) {\n deferredNodeRender.push(() => {\n if (nodeOptions.nodeDraw) {\n nodeOptions.nodeDraw.bind(this)(node, nodeOptions);\n }\n });\n deferredTextRender.push(() => {\n if (nodeOptions.textDraw) {\n nodeOptions.textDraw.bind(this)(node, nodeOptions);\n }\n });\n return;\n }\n let radius = nodeOptions.radius;\n let width = nodeOptions.width;\n let height = nodeOptions.height;\n let alpha = nodeOptions.alpha;\n let color = nodeOptions.color;\n let borderColor = nodeOptions.borderColor;\n let borderWidth = nodeOptions.borderWidth;\n let textAlpha = nodeOptions.textAlpha;\n let textSize = nodeOptions.textSize;\n let textShiftX = nodeOptions.textShiftX;\n let textShiftY = nodeOptions.textShiftY;\n let textWeight = nodeOptions.textWeight;\n let labelSize = nodeOptions.labelSize;\n let labelWeight = nodeOptions.labelWeight;\n let labelAlpha = nodeOptions.labelAlpha;\n /** Highlight */\n if (this.highlightedNeighbors && this.highlightedNode) {\n /** By Node Not Highlight */\n if (!this.highlightedNeighbors.has(node.id) && this.highlightedNode.id != node.id) {\n const fadingOptions = nodeFade({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelFadingMin: this.highlightSettings.highlightByNodeForLabelFadingMin,\n highlightForNodeColorFading: this.highlightSettings.highlightByNodeForNodeColorFading,\n highlightForNodeFadingMin: this.highlightSettings.highlightByNodeForNodeFadingMin,\n highlightForTextFadingMin: this.highlightSettings.highlightByNodeForTextFadingMin,\n });\n alpha = fadingOptions.alpha;\n color = fadingOptions.color;\n textAlpha = fadingOptions.textAlpha;\n labelAlpha = fadingOptions.labelAlpha;\n } else if (\n !this.highlightSettings.highlightByNodeOnlyRoot ||\n (this.highlightSettings.highlightByNodeOnlyRoot && this.highlightedNode.id === node.id)\n ) {\n /** By Node Highlight */\n const highlightOptions = nodeHighlight({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelSizingAdditional:\n this.highlightSettings.highlightByNodeForLabelSizingAdditional,\n highlightForLabelWeightAdditional:\n this.highlightSettings.highlightByNodeForLabelWeightAdditional,\n highlightForNodeBorderColor: this.highlightSettings.highlightByNodeForNodeBorderColor,\n highlightForNodeBorderSizingAdditional:\n this.highlightSettings.highlightByNodeForNodeBorderSizingAdditional,\n highlightForNodeColor: this.highlightSettings.highlightByNodeForNodeColor,\n highlightForNodeSizingAdditional:\n this.highlightSettings.highlightByNodeForNodeSizingAdditional,\n highlightForNodeSizingAdditionalCoefficient:\n this.highlightSettings.highlightByNodeForNodeSizingAdditionalCoefficient,\n highlightForTextShiftXAdditional:\n this.highlightSettings.highlightByNodeForTextShiftXAdditional,\n highlightForTextShiftYAdditional:\n this.highlightSettings.highlightByNodeForTextShiftYAdditional,\n highlightForTextSizingAdditional:\n this.highlightSettings.highlightByNodeForTextSizingAdditional,\n highlightForTextWeightAdditional:\n this.highlightSettings.highlightByNodeForTextWeightAdditional,\n });\n color = highlightOptions.color;\n borderColor = highlightOptions.borderColor;\n borderWidth = highlightOptions.borderWidth;\n radius = highlightOptions.radiusInitial;\n width = highlightOptions.widthInitial;\n height = highlightOptions.heightInitial;\n textSize = highlightOptions.textSize;\n textShiftX = highlightOptions.textShiftX;\n textShiftY = highlightOptions.textShiftY;\n textWeight = highlightOptions.textWeight;\n labelSize = highlightOptions.labelSize;\n labelWeight = highlightOptions.labelWeight;\n }\n }\n if (this.highlightedNeighbors && this.highlightedLink) {\n /** By Link Not Highlight */\n if (\n !this.highlightedNeighbors.has(node.id) &&\n this.highlightedLink.source !== node &&\n this.highlightedLink.target !== node\n ) {\n const fadingOptions = nodeFade({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelFadingMin: this.highlightSettings.highlightByLinkForLabelFadingMin,\n highlightForNodeColorFading: this.highlightSettings.highlightByLinkForNodeColorFading,\n highlightForNodeFadingMin: this.highlightSettings.highlightByLinkForNodeFadingMin,\n highlightForTextFadingMin: this.highlightSettings.highlightByLinkForTextFadingMin,\n });\n alpha = fadingOptions.alpha;\n color = fadingOptions.color;\n textAlpha = fadingOptions.textAlpha;\n labelAlpha = fadingOptions.labelAlpha;\n } else {\n /** By Link Highlight */\n\n const highlightOptions = nodeHighlight({\n highlightProgress: this.highlightProgress,\n nodeOptions,\n highlightForLabelSizingAdditional:\n this.highlightSettings.highlightByLinkForLabelSizingAdditional,\n highlightForLabelWeightAdditional:\n this.highlightSettings.highlightByLinkForLabelWeightAdditional,\n highlightForNodeBorderColor: this.highlightSettings.highlightByLinkForNodeBorderColor,\n highlightForNodeBorderSizingAdditional:\n this.highlightSettings.highlightByLinkForNodeBorderSizingAdditional,\n highlightForNodeColor: this.highlightSettings.highlightByLinkForNodeColor,\n highlightForNodeSizingAdditional:\n this.highlightSettings.highlightByLinkForNodeSizingAdditional,\n highlightForNodeSizingAdditionalCoefficient:\n this.highlightSettings.highlightByLinkForNodeSizingAdditionalCoefficient,\n highlightForTextShiftXAdditional:\n this.highlightSettings.highlightByLinkForTextShiftXAdditional,\n highlightForTextShiftYAdditional:\n this.highlightSettings.highlightByLinkForTextShiftYAdditional,\n highlightForTextSizingAdditional:\n this.highlightSettings.highlightByLinkForTextSizingAdditional,\n highlightForTextWeightAdditional:\n this.highlightSettings.highlightByLinkForTextWeightAdditional,\n });\n color = highlightOptions.color;\n borderColor = highlightOptions.borderColor;\n borderWidth = highlightOptions.borderWidth;\n radius = highlightOptions.radiusInitial;\n width = highlightOptions.widthInitial;\n height = highlightOptions.heightInitial;\n textSize = highlightOptions.textSize;\n textShiftX = highlightOptions.textShiftX;\n textShiftY = highlightOptions.textShiftY;\n textWeight = highlightOptions.textWeight;\n labelSize = highlightOptions.labelSize;\n labelWeight = highlightOptions.labelWeight;\n }\n }\n node._radius = radius;\n node._borderWidth = borderWidth;\n node._width = width;\n node._height = height;\n node._borderRadius =\n isNumber(nodeOptions.borderRadius) && nodeOptions.borderRadius > 0\n ? Math.min(nodeOptions.borderRadius, nodeOptions.width / 2, nodeOptions.height / 2)\n : 0;\n node._shape = nodeOptions.shape ?? \"circle\";\n if (!isNodeVisible(node, area)) {\n node._visible = false;\n return;\n }\n node._visible = true;\n\n const nodeBatchKey = `${alpha}|${borderColor}|${borderWidth}|${color}`;\n let nodeGroup: NodeDrawBatch[];\n if (!node.image) {\n nodeBatch[nodeBatchKey] ??= [];\n nodeGroup = nodeBatch[nodeBatchKey];\n } else {\n nodeImageBatch[nodeBatchKey] ??= [];\n nodeGroup = nodeImageBatch[nodeBatchKey];\n }\n nodeGroup.push({\n shape: nodeOptions.shape,\n x: node.x,\n y: node.y,\n radius,\n width,\n height,\n image: node.image,\n });\n const labelLines = this.cachedNodeLabel[index];\n if (labelLines && labelLines.length > 0) {\n let y = node.y + labelSize / 3;\n let weight = labelWeight;\n if (nodeOptions.shape == \"text\") {\n y = node.y + textSize / 4 - (labelLines.length - 1) * (textSize / 2);\n weight = textWeight;\n }\n const font = `${nodeOptions.labelStyle} normal ${weight} ${labelSize}px ${nodeOptions.labelFont}`;\n textBatch[font] ??= {};\n const fontBatch = textBatch[font];\n const textBatchKey = `${labelAlpha}|${nodeOptions.labelAlign}|${nodeOptions.labelColor}`;\n fontBatch[textBatchKey] ??= [];\n const textGroup = fontBatch[textBatchKey];\n for (let i = 0; i < labelLines.length; i++) {\n const line = labelLines[i];\n textGroup.push({\n text: line,\n x: node.x,\n y: y + i * textSize + i * nodeOptions.textGap,\n });\n }\n }\n if (nodeOptions.nodeExtraDraw) {\n deferredNodeRender.push(() => {\n nodeOptions?.nodeExtraDraw?.bind?.(this)?.(node, {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n });\n });\n }\n const textLines = this.cachedNodeText[index];\n if (textLines && textLines.length > 0) {\n if (nodeOptions.textDraw) {\n deferredTextRender.push(() => {\n nodeOptions?.textDraw?.bind?.(this)?.(node, {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n });\n });\n }\n let y = node.y + textShiftY;\n if (nodeOptions.shape === \"circle\") {\n y += radius;\n }\n if (nodeOptions.shape === \"square\" || nodeOptions.shape === \"text\") {\n y += height / 2;\n }\n const font = `${nodeOptions.textStyle} normal ${textWeight} ${textSize}px ${nodeOptions.textFont}`;\n textBatch[font] ??= {};\n const fontBatch = textBatch[font];\n const textBatchKey = `${textAlpha}|${nodeOptions.textAlign}|${nodeOptions.textColor}`;\n fontBatch[textBatchKey] ??= [];\n const textGroup = fontBatch[textBatchKey];\n for (let i = 0; i < textLines.length; i++) {\n const line = textLines[i];\n textGroup.push({\n text: line,\n x: node.x + textShiftX,\n y: y + i * textSize + i * nodeOptions.textGap,\n });\n }\n if (nodeOptions.textExtraDraw) {\n deferredTextRender.push(() => {\n nodeOptions?.textExtraDraw?.bind?.(this)?.(node, {\n ...nodeOptions,\n radius,\n alpha,\n color,\n textAlpha,\n textSize,\n textShiftX,\n textShiftY,\n textWeight,\n });\n });\n }\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKgB,SAAA,WAAW,CAIzB,SAA0C,EAC1C,cAA+C,EAC/C,SAA8D,EAC9D,kBAAkC,EAClC,kBAAkC,EAClC,IAAU,EAAA;AAEV,IAAA,OAAO,SAAS,QAAQ,CAEtB,IAA6B,EAC7B,KAAa,EAAA;AAEb,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAAE;QACzC,IAAI,IAAI,CAAC,OAAO,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AAC9C,YAAA,IAAI,CAAC,OAAO,GAAG,CAAC;AAChB,YAAA,IAAI,CAAC,MAAM,GAAG,CAAC;AACf,YAAA,IAAI,CAAC,OAAO,GAAG,CAAC;YAChB;;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;AAChD,QAAA,IAAI,CAAC,WAAW;YAAE;QAClB,IAAI,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAAE;AAChD,YAAA,kBAAkB,CAAC,IAAI,CAAC,MAAK;AAC3B,gBAAA,IAAI,WAAW,CAAC,QAAQ,EAAE;AACxB,oBAAA,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC;;AAEtD,aAAC,CAA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AAO;AAC9C,iBAAA,CAAC;;AAEJ,YAAA,IAAI,WAAW,CAAC,aAAa,EAAE;AAC7B,gBAAA,kBAAkB,CAAC,IAAI,CAAC,MAAK;oBAC3B,WAAW,EAAE,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE;AAC/C,wBAAA,GAAG,WAAW;wBACd,MAAM;wBACN,KAAK;wBACL,KAAK;wBACL,SAAS;wBACT,QAAQ;wBACR,UAAU;wBACV,UAAU;wBACV,UAAU;AACX,qBAAA,CAAC;AACJ,iBAAC,CAAC;;;AAGR,KAAC;AACH;;;;"}
@@ -1,12 +1,4 @@
1
1
  const SPACE = " ";
2
- function drawText({ context, textAlign, textColor, textFont, textStyle, textGap, textWeight, textSize, x, y, lines, }) {
3
- context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;
4
- context.fillStyle = textColor;
5
- context.textAlign = textAlign;
6
- lines.forEach((line, index) => {
7
- context.fillText(line, x, y + index * textSize + index * textGap);
8
- });
9
- }
10
2
  function getTextLines({ context, textAlign, textColor, textFont, textStyle, textWeight, textSize, text, maxWidth, }) {
11
3
  context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;
12
4
  context.fillStyle = textColor;
@@ -43,5 +35,5 @@ function getTextLines({ context, textAlign, textColor, textFont, textStyle, text
43
35
  return { lines, currentMaxSize };
44
36
  }
45
37
 
46
- export { drawText, getTextLines };
38
+ export { getTextLines };
47
39
  //# sourceMappingURL=draw-text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"draw-text.js","sources":["../../../../../src/module/GraphCanvas/slices/draw-text.ts"],"sourcesContent":["import type { TextStyleEnum } from \"../types\";\n\nexport type DrawTextOptions = {\n lines: string[];\n x: number;\n y: number;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textGap: number;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n};\n\nconst SPACE = \" \";\n\nexport function drawText({\n context,\n textAlign,\n textColor,\n textFont,\n textStyle,\n textGap,\n textWeight,\n textSize,\n x,\n y,\n lines,\n}: DrawTextOptions) {\n context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;\n context.fillStyle = textColor;\n context.textAlign = textAlign;\n\n lines.forEach((line, index) => {\n context.fillText(line, x, y + index * textSize + index * textGap);\n });\n}\n\nexport type GetTextLines = {\n text: string;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n maxWidth: number;\n};\nexport function getTextLines({\n context,\n textAlign,\n textColor,\n textFont,\n textStyle,\n textWeight,\n textSize,\n text,\n maxWidth,\n}: GetTextLines) {\n context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;\n context.fillStyle = textColor;\n context.textAlign = textAlign;\n\n const spaceWidth = context.measureText(\" \").width;\n const lines: string[] = [];\n let lineWidth = 0;\n let line = \"\";\n let currentMaxSize = 0;\n\n for (const word of text.split(\" \")) {\n const size = context.measureText(word).width;\n lineWidth += size + spaceWidth;\n\n if (line === \"\") {\n line = word;\n\n continue;\n }\n if (lineWidth > maxWidth) {\n const initialSize = lineWidth - size - spaceWidth;\n if (initialSize > currentMaxSize) currentMaxSize = initialSize;\n\n lineWidth = size;\n lines.push(line);\n line = word;\n } else {\n lineWidth += spaceWidth;\n line += `${SPACE}${word}`;\n }\n }\n\n if (line !== \"\") lines.push(line);\n if (lineWidth > currentMaxSize) currentMaxSize = lineWidth;\n\n return { lines, currentMaxSize };\n}\n"],"names":[],"mappings":"AAgBA,MAAM,KAAK,GAAG,GAAG;AAEX,SAAU,QAAQ,CAAC,EACvB,OAAO,EACP,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,CAAC,EACD,CAAC,EACD,KAAK,GACW,EAAA;AAChB,IAAA,OAAO,CAAC,IAAI,GAAG,CAAA,EAAG,SAA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AAG,QAAQ,EAAE;AACxB,YAAA,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,UAAU;YACjD,IAAI,WAAW,GAAG,cAAc;gBAAE,cAAc,GAAG,WAAW;YAE9D,SAAS,GAAG,IAAI;AAChB,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,IAAI,GAAG,IAAI;;aACN;YACL,SAAS,IAAI,UAAU;AACvB,YAAA,IAAI,IAAI,CAAG,EAAA,KAAK,CAAG,EAAA,IAAI,EAAE;;;IAI7B,IAAI,IAAI,KAAK,EAAE;AAAE,QAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACjC,IAAI,SAAS,GAAG,cAAc;QAAE,cAAc,GAAG,SAAS;AAE1D,IAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE;AAClC;;;;"}
1
+ {"version":3,"file":"draw-text.js","sources":["../../../../../src/module/GraphCanvas/slices/draw-text.ts"],"sourcesContent":["import type { TextStyleEnum } from \"../types\";\n\nexport type DrawTextOptions = {\n lines: string[];\n x: number;\n y: number;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textGap: number;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n};\n\nconst SPACE = \" \";\n\nexport type GetTextLines = {\n text: string;\n textSize: number;\n textStyle: TextStyleEnum;\n textWeight: number;\n textFont: string;\n textColor: string;\n textAlign: CanvasTextAlign;\n context: CanvasRenderingContext2D;\n maxWidth: number;\n};\nexport function getTextLines({\n context,\n textAlign,\n textColor,\n textFont,\n textStyle,\n textWeight,\n textSize,\n text,\n maxWidth,\n}: GetTextLines) {\n context.font = `${textStyle} normal ${textWeight} ${textSize}px ${textFont}`;\n context.fillStyle = textColor;\n context.textAlign = textAlign;\n\n const spaceWidth = context.measureText(\" \").width;\n const lines: string[] = [];\n let lineWidth = 0;\n let line = \"\";\n let currentMaxSize = 0;\n\n for (const word of text.split(\" \")) {\n const size = context.measureText(word).width;\n lineWidth += size + spaceWidth;\n\n if (line === \"\") {\n line = word;\n\n continue;\n }\n if (lineWidth > maxWidth) {\n const initialSize = lineWidth - size - spaceWidth;\n if (initialSize > currentMaxSize) currentMaxSize = initialSize;\n\n lineWidth = size;\n lines.push(line);\n line = word;\n } else {\n lineWidth += spaceWidth;\n line += `${SPACE}${word}`;\n }\n }\n\n if (line !== \"\") lines.push(line);\n if (lineWidth > currentMaxSize) currentMaxSize = lineWidth;\n\n return { lines, currentMaxSize };\n}\n"],"names":[],"mappings":"AAgBA,MAAM,KAAK,GAAG,GAAG;AAaX,SAAU,YAAY,CAAC,EAC3B,OAAO,EACP,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,QAAQ,GACK,EAAA;AACb,IAAA,OAAO,CAAC,IAAI,GAAG,CAAA,EAAG,SAAS,CAAA,QAAA,EAAW,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,GAAA,EAAM,QAAQ,CAAA,CAAE;AAC5E,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;AAC7B,IAAA,OAAO,CAAC,SAAS,GAAG,SAAS;IAE7B,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK;IACjD,MAAM,KAAK,GAAa,EAAE;IAC1B,IAAI,SAAS,GAAG,CAAC;IACjB,IAAI,IAAI,GAAG,EAAE;IACb,IAAI,cAAc,GAAG,CAAC;IAEtB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK;AAC5C,QAAA,SAAS,IAAI,IAAI,GAAG,UAAU;AAE9B,QAAA,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,IAAI,GAAG,IAAI;YAEX;;AAEF,QAAA,IAAI,SAAS,GAAG,QAAQ,EAAE;AACxB,YAAA,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,UAAU;YACjD,IAAI,WAAW,GAAG,cAAc;gBAAE,cAAc,GAAG,WAAW;YAE9D,SAAS,GAAG,IAAI;AAChB,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,IAAI,GAAG,IAAI;;aACN;YACL,SAAS,IAAI,UAAU;AACvB,YAAA,IAAI,IAAI,CAAG,EAAA,KAAK,CAAG,EAAA,IAAI,EAAE;;;IAI7B,IAAI,IAAI,KAAK,EAAE;AAAE,QAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACjC,IAAI,SAAS,GAAG,cAAc;QAAE,cAAc,GAAG,SAAS;AAE1D,IAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE;AAClC;;;;"}
@@ -1,14 +1,13 @@
1
1
  import { cloneDeep } from '@krainovsd/js-helpers';
2
2
  import { zoomIdentity } from 'd3-zoom';
3
3
  import '../constants/force-settings.js';
4
- import '../constants/graph-settings.js';
5
- import '../constants/highlight-settings.js';
6
- import '../constants/link-settings.js';
7
- import '../constants/node-settings.js';
8
4
  import { computeGraphBounds } from '../lib/utils/compute-graph-bounds.js';
9
5
  import 'd3-array';
10
- import { SvgContextAdapter } from '../lib/utils/svg-context.js';
6
+ import 'd3-force';
7
+ import 'd3-selection';
8
+ import 'd3-drag';
11
9
  import { initDraw } from './init-draw.js';
10
+ import { SvgContextAdapter } from '../lib/utils/svg-context.js';
12
11
 
13
12
  function exportToSvgSlice(filename = "graph.svg", fit = false) {
14
13
  this.tick();
@@ -1 +1 @@
1
- {"version":3,"file":"export-svg.js","sources":["../../../../../src/module/GraphCanvas/slices/export-svg.ts"],"sourcesContent":["import { cloneDeep } from \"@krainovsd/js-helpers\";\nimport { zoomIdentity } from \"d3-zoom\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { computeGraphBounds } from \"../lib\";\nimport { SvgContextAdapter } from \"../lib/utils/svg-context\";\nimport { initDraw } from \"./init-draw\";\n\nexport function exportToSvgSlice<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, filename: string = \"graph.svg\", fit: boolean = false) {\n this.tick();\n\n let svgWidth = this.width;\n let svgHeight = this.height;\n\n const svgParts: string[] = [];\n const adapter = new SvgContextAdapter(svgParts);\n\n const clone = Object.assign(Object.create(Object.getPrototypeOf(this)), this) as GraphCanvas<\n NodeData,\n LinkData\n >;\n clone.context = adapter as unknown as CanvasRenderingContext2D;\n clone.isSelecting = false;\n clone.listeners = {} as typeof this.listeners;\n clone.nodes = cloneDeep(this.nodes);\n clone.links = cloneDeep(this.links);\n clone.particles = cloneDeep(this.particles);\n\n if (fit) {\n const bounds = computeGraphBounds(clone.nodes);\n if (bounds) {\n const pad = 50;\n const graphWidth = bounds.maxX - bounds.minX;\n const graphHeight = bounds.maxY - bounds.minY;\n if (graphWidth > 0 && graphHeight > 0) {\n svgWidth = graphWidth + pad * 2;\n svgHeight = graphHeight + pad * 2;\n const graphCenterX = bounds.minX + graphWidth / 2;\n const graphCenterY = bounds.minY + graphHeight / 2;\n clone.areaTransform = zoomIdentity\n .translate(svgWidth / 2, svgHeight / 2)\n .translate(-graphCenterX, -graphCenterY);\n clone.width = svgWidth;\n clone.height = svgHeight;\n }\n }\n }\n\n const draw = initDraw.call<\n GraphCanvas<NodeData, LinkData>,\n Parameters<typeof initDraw>,\n ReturnType<typeof initDraw>\n >(clone);\n draw();\n adapter.closeTransform();\n\n const svg = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${svgWidth}\" height=\"${svgHeight}\">`,\n ...svgParts,\n \"</svg>\",\n ].join(\"\\n\");\n\n const blob = new Blob([svg], { type: \"image/svg+xml;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = filename;\n a.click();\n URL.revokeObjectURL(url);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;SAOgB,gB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AG,UAAU,GAAG,CAAC;gBACjD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,GAAG,WAAW,GAAG,CAAC;gBAClD,KAAK,CAAC,aAAa,GAAG;qBACnB,SAAS,CAAC,QAAQ,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC;AACrC,qBAAA,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC;AAC1C,gBAAA,KAAK,CAAC,KAAK,GAAG,QAAQ;AACtB,gBAAA,KAAK,CAAC,MAAM,GAAG,SAAS;;;;IAK9B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAIxB,KAAK,CAAC;AACR,IAAA,IAAI,EAAE;IACN,OAAO,CAAC,cAAc,EAAE;AAExB,IAAA,MAAM,GAAG,GAAG;QACV,CAAkD,+CAAA,EAAA,QAAQ,CAAa,UAAA,EAAA,SAAS,CAAI,EAAA,CAAA;AACpF,QAAA,GAAG,QAAQ;QACX,QAAQ;AACT,KAAA,CAAC,IAAI,CAAC,IAAI,CAAC;AAEZ,IAAA,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;IACrE,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;IACrC,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;AACrC,IAAA,CAAC,CAAC,IAAI,GAAG,GAAG;AACZ,IAAA,CAAC,CAAC,QAAQ,GAAG,QAAQ;IACrB,CAAC,CAAC,KAAK,EAAE;AACT,IAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"export-svg.js","sources":["../../../../../src/module/GraphCanvas/slices/export-svg.ts"],"sourcesContent":["import { cloneDeep } from \"@krainovsd/js-helpers\";\nimport { zoomIdentity } from \"d3-zoom\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { computeGraphBounds } from \"../lib\";\nimport { SvgContextAdapter } from \"../lib/utils/svg-context\";\nimport { initDraw } from \"./init-draw\";\n\nexport function exportToSvgSlice<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, filename: string = \"graph.svg\", fit: boolean = false) {\n this.tick();\n\n let svgWidth = this.width;\n let svgHeight = this.height;\n\n const svgParts: string[] = [];\n const adapter = new SvgContextAdapter(svgParts);\n\n const clone = Object.assign(Object.create(Object.getPrototypeOf(this)), this) as GraphCanvas<\n NodeData,\n LinkData\n >;\n clone.context = adapter as unknown as CanvasRenderingContext2D;\n clone.isSelecting = false;\n clone.listeners = {} as typeof this.listeners;\n clone.nodes = cloneDeep(this.nodes);\n clone.links = cloneDeep(this.links);\n clone.particles = cloneDeep(this.particles);\n\n if (fit) {\n const bounds = computeGraphBounds(clone.nodes);\n if (bounds) {\n const pad = 50;\n const graphWidth = bounds.maxX - bounds.minX;\n const graphHeight = bounds.maxY - bounds.minY;\n if (graphWidth > 0 && graphHeight > 0) {\n svgWidth = graphWidth + pad * 2;\n svgHeight = graphHeight + pad * 2;\n const graphCenterX = bounds.minX + graphWidth / 2;\n const graphCenterY = bounds.minY + graphHeight / 2;\n clone.areaTransform = zoomIdentity\n .translate(svgWidth / 2, svgHeight / 2)\n .translate(-graphCenterX, -graphCenterY);\n clone.width = svgWidth;\n clone.height = svgHeight;\n }\n }\n }\n\n const draw = initDraw.call<\n GraphCanvas<NodeData, LinkData>,\n Parameters<typeof initDraw>,\n ReturnType<typeof initDraw>\n >(clone);\n draw();\n adapter.closeTransform();\n\n const svg = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${svgWidth}\" height=\"${svgHeight}\">`,\n ...svgParts,\n \"</svg>\",\n ].join(\"\\n\");\n\n const blob = new Blob([svg], { type: \"image/svg+xml;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = filename;\n a.click();\n URL.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AAG,CAAC;gBACjC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,GAAG,UAAU,GAAG,CAAC;gBACjD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,GAAG,WAAW,GAAG,CAAC;gBAClD,KAAK,CAAC,aAAa,GAAG;qBACnB,SAAS,CAAC,QAAQ,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC;AACrC,qBAAA,SAAS,CAAC,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC;AAC1C,gBAAA,KAAK,CAAC,KAAK,GAAG,QAAQ;AACtB,gBAAA,KAAK,CAAC,MAAM,GAAG,SAAS;;;;IAK9B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAIxB,KAAK,CAAC;AACR,IAAA,IAAI,EAAE;IACN,OAAO,CAAC,cAAc,EAAE;AAExB,IAAA,MAAM,GAAG,GAAG;QACV,CAAkD,+CAAA,EAAA,QAAQ,CAAa,UAAA,EAAA,SAAS,CAAI,EAAA,CAAA;AACpF,QAAA,GAAG,QAAQ;QACX,QAAQ;AACT,KAAA,CAAC,IAAI,CAAC,IAAI,CAAC;AAEZ,IAAA,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC;IACrE,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;IACrC,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;AACrC,IAAA,CAAC,CAAC,IAAI,GAAG,GAAG;AACZ,IAAA,CAAC,CAAC,QAAQ,GAAG,QAAQ;IACrB,CAAC,CAAC,KAAK,EAAE;AACT,IAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AAC1B;;;;"}
@@ -3,7 +3,7 @@ import { greatest } from 'd3-array';
3
3
  import { drag } from 'd3-drag';
4
4
  import { select } from 'd3-selection';
5
5
 
6
- function initDnd() {
6
+ function initDnd(staticMode = false) {
7
7
  if (!this.area || !this.nodes)
8
8
  throw new Error("bad init data");
9
9
  const dragHandler = drag()
@@ -31,8 +31,20 @@ function initDnd() {
31
31
  const mouseEvent = event.sourceEvent;
32
32
  const [pointerX, pointerY] = this.getPointerAreaPosition(mouseEvent);
33
33
  if (this._translateExtent) {
34
- event.subject.fx = Math.max(this._translateExtent[0][0], Math.min(this._translateExtent[1][0], pointerX));
35
- event.subject.fy = Math.max(this._translateExtent[0][1], Math.min(this._translateExtent[1][1], pointerY));
34
+ const x = Math.max(this._translateExtent[0][0], Math.min(this._translateExtent[1][0], pointerX));
35
+ const y = Math.max(this._translateExtent[0][1], Math.min(this._translateExtent[1][1], pointerY));
36
+ if (staticMode) {
37
+ event.subject.x = x;
38
+ event.subject.y = y;
39
+ }
40
+ else {
41
+ event.subject.fx = x;
42
+ event.subject.fy = y;
43
+ }
44
+ }
45
+ else if (staticMode) {
46
+ event.subject.x = pointerX;
47
+ event.subject.y = pointerY;
36
48
  }
37
49
  else {
38
50
  event.subject.fx = pointerX;
@@ -1 +1 @@
1
- {"version":3,"file":"init-dnd.js","sources":["../../../../../src/module/GraphCanvas/slices/init-dnd.ts"],"sourcesContent":["import { isBoolean } from \"@krainovsd/js-helpers\";\nimport { greatest } from \"d3-array\";\nimport { drag as d3Drag } from \"d3-drag\";\nimport { select as d3Select } from \"d3-selection\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport type { DragEventInterface } from \"../types\";\n\nexport function initDnd<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.area || !this.nodes) throw new Error(\"bad init data\");\n\n const dragHandler = d3Drag<HTMLCanvasElement, unknown>()\n .subject((event: DragEventInterface<NodeData>) => {\n if (this.listeners.onDragSubject) {\n return this.listeners.onDragSubject.call(this, event);\n }\n\n const mouseEvent = event.sourceEvent as MouseEvent | TouchEvent;\n const [pointerX, pointerY] = this.getPointerAreaPosition(mouseEvent);\n\n return greatest(this.nodes, (node) => {\n if (!node.x || !node.y || (isBoolean(node.drag) && !node.drag)) return undefined;\n\n return this.graphSettings.dragPlaceCoefficient(node, pointerX, pointerY);\n });\n })\n .on(\"start\", (event: DragEventInterface<NodeData>) => {\n this.listeners.onStartDragFinished?.call?.(this, event);\n })\n .on(\"drag\", (event: DragEventInterface<NodeData>) => {\n if (!this.isDragging) {\n this.isDragging = true;\n if (this.simulation) this.simulation.alphaTarget(0.3).restart();\n }\n\n const mouseEvent = event.sourceEvent as MouseEvent | TouchEvent;\n const [pointerX, pointerY] = this.getPointerAreaPosition(mouseEvent);\n\n if (this._translateExtent) {\n event.subject.fx = Math.max(\n this._translateExtent[0][0],\n Math.min(this._translateExtent[1][0], pointerX),\n );\n event.subject.fy = Math.max(\n this._translateExtent[0][1],\n Math.min(this._translateExtent[1][1], pointerY),\n );\n } else {\n event.subject.fx = pointerX;\n event.subject.fy = pointerY;\n }\n\n this.listeners.onMoveDragFinished?.call?.(this, event);\n })\n .on(\"end\", (event: DragEventInterface<NodeData>) => {\n this.isDragging = false;\n\n if (!event.active && this.simulation) this.simulation.alphaTarget(0);\n\n const sourceEvent = event.sourceEvent as MouseEvent | TouchEvent;\n if (sourceEvent.altKey) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(sourceEvent);\n if (this._translateExtent) {\n event.subject.fx = Math.max(\n this._translateExtent[0][0],\n Math.min(this._translateExtent[1][0], pointerX),\n );\n event.subject.fy = Math.max(\n this._translateExtent[0][1],\n Math.min(this._translateExtent[1][1], pointerY),\n );\n } else {\n event.subject.fx = pointerX;\n event.subject.fy = pointerY;\n }\n } else {\n event.subject.fx = null;\n event.subject.fy = null;\n }\n\n this.listeners.onEndDragFinished?.call?.(this, event);\n });\n\n d3Select(this.area).call(dragHandler);\n}\n"],"names":["d3Drag","d3Select"],"mappings":";;;;;SAOgB,OAAO,GAAA;IAIrB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;AAAE,QAA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AC,WAAW,CAAC;AACrE,YAAA,IAAI,IAAI,CAAC,gBAAgB,EAAE;AACzB,gBAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CACzB,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAChD;AACD,gBAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CACzB,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAChD;;iBACI;AACL,gBAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ;AAC3B,gBAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ;;;aAExB;AACL,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;AACvB,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;;AAGzB,QAAA,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,CAAC;AACvD,KAAC,CAAC;IAEJC,MAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;AACvC;;;;"}
1
+ {"version":3,"file":"init-dnd.js","sources":["../../../../../src/module/GraphCanvas/slices/init-dnd.ts"],"sourcesContent":["import { isBoolean } from \"@krainovsd/js-helpers\";\nimport { greatest } from \"d3-array\";\nimport { drag as d3Drag } from \"d3-drag\";\nimport { select as d3Select } from \"d3-selection\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport type { DragEventInterface } from \"../types\";\n\nexport function initDnd<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, staticMode: boolean = false) {\n if (!this.area || !this.nodes) throw new Error(\"bad init data\");\n\n const dragHandler = d3Drag<HTMLCanvasElement, unknown>()\n .subject((event: DragEventInterface<NodeData>) => {\n if (this.listeners.onDragSubject) {\n return this.listeners.onDragSubject.call(this, event);\n }\n\n const mouseEvent = event.sourceEvent as MouseEvent | TouchEvent;\n const [pointerX, pointerY] = this.getPointerAreaPosition(mouseEvent);\n\n return greatest(this.nodes, (node) => {\n if (!node.x || !node.y || (isBoolean(node.drag) && !node.drag)) return undefined;\n\n return this.graphSettings.dragPlaceCoefficient(node, pointerX, pointerY);\n });\n })\n .on(\"start\", (event: DragEventInterface<NodeData>) => {\n this.listeners.onStartDragFinished?.call?.(this, event);\n })\n .on(\"drag\", (event: DragEventInterface<NodeData>) => {\n if (!this.isDragging) {\n this.isDragging = true;\n if (this.simulation) this.simulation.alphaTarget(0.3).restart();\n }\n\n const mouseEvent = event.sourceEvent as MouseEvent | TouchEvent;\n const [pointerX, pointerY] = this.getPointerAreaPosition(mouseEvent);\n\n if (this._translateExtent) {\n const x = Math.max(\n this._translateExtent[0][0],\n Math.min(this._translateExtent[1][0], pointerX),\n );\n const y = Math.max(\n this._translateExtent[0][1],\n Math.min(this._translateExtent[1][1], pointerY),\n );\n if (staticMode) {\n event.subject.x = x;\n event.subject.y = y;\n } else {\n event.subject.fx = x;\n event.subject.fy = y;\n }\n } else if (staticMode) {\n event.subject.x = pointerX;\n event.subject.y = pointerY;\n } else {\n event.subject.fx = pointerX;\n event.subject.fy = pointerY;\n }\n\n this.listeners.onMoveDragFinished?.call?.(this, event);\n })\n .on(\"end\", (event: DragEventInterface<NodeData>) => {\n this.isDragging = false;\n\n if (!event.active && this.simulation) this.simulation.alphaTarget(0);\n\n const sourceEvent = event.sourceEvent as MouseEvent | TouchEvent;\n if (sourceEvent.altKey) {\n const [pointerX, pointerY] = this.getPointerAreaPosition(sourceEvent);\n if (this._translateExtent) {\n event.subject.fx = Math.max(\n this._translateExtent[0][0],\n Math.min(this._translateExtent[1][0], pointerX),\n );\n event.subject.fy = Math.max(\n this._translateExtent[0][1],\n Math.min(this._translateExtent[1][1], pointerY),\n );\n } else {\n event.subject.fx = pointerX;\n event.subject.fy = pointerY;\n }\n } else {\n event.subject.fx = null;\n event.subject.fy = null;\n }\n\n this.listeners.onEndDragFinished?.call?.(this, event);\n });\n\n d3Select(this.area).call(dragHandler);\n}\n"],"names":["d3Drag","d3Select"],"mappings":";;;;;AAOgB,SAAA,OAAO,CAGkB,UAAA,GAAsB,KAAK,EAAA;IAClE,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAE/D,MAAM,WAAW,GAAGA,IAAM;AACvB,SAAA,OAAO,CAAC,CAAC,KAAmC,KAAI;AAC/C,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;;AAGvD,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,WAAsC;AAC/D,QAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC;QAEpE,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,KAAI;YACnC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,gBAAA,OAAO,SAAS;AAEhF,YAAA,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAC1E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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAChD;;iBACI;AACL,gBAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ;AAC3B,gBAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ;;;aAExB;AACL,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;AACvB,YAAA,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;;AAGzB,QAAA,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,CAAC;AACvD,KAAC,CAAC;IAEJC,MAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;AACvC;;;;"}
@@ -3,7 +3,33 @@ import { setDrawTime } from '../../../lib/draw-time.js';
3
3
  import { getDrawLink } from './draw-links.js';
4
4
  import { getDrawNode } from './draw-nodes.js';
5
5
 
6
+ const COS_PI_6 = 0.8660254037844386;
7
+ const SIN_PI_6 = 0.5;
8
+ function clearBatch(batch) {
9
+ // eslint-disable-next-line guard-for-in
10
+ for (const key in batch) {
11
+ batch[key].length = 0;
12
+ }
13
+ }
14
+ function clearNestedBatch(batch) {
15
+ // eslint-disable-next-line guard-for-in
16
+ for (const outerKey in batch) {
17
+ const inner = batch[outerKey];
18
+ // eslint-disable-next-line guard-for-in
19
+ for (const innerKey in inner) {
20
+ inner[innerKey].length = 0;
21
+ }
22
+ }
23
+ }
6
24
  function initDraw() {
25
+ const nodeBatch = {};
26
+ const nodeImageBatch = {};
27
+ const textBatch = {};
28
+ const deferredNodeDraw = [];
29
+ const deferredTextDraw = [];
30
+ const linkBatch = {};
31
+ const particleBatch = {};
32
+ const arrowBatch = {};
7
33
  function draw() {
8
34
  if (!this.context)
9
35
  return;
@@ -11,18 +37,196 @@ function initDraw() {
11
37
  this.listeners.onDraw.call(this);
12
38
  return;
13
39
  }
40
+ clearBatch(nodeBatch);
41
+ clearBatch(nodeImageBatch);
42
+ clearNestedBatch(textBatch);
43
+ deferredNodeDraw.length = 0;
44
+ deferredTextDraw.length = 0;
45
+ clearBatch(linkBatch);
46
+ clearBatch(particleBatch);
47
+ clearBatch(arrowBatch);
48
+ const k = this.areaTransform.k;
49
+ const area = {
50
+ left: -this.areaTransform.x / k,
51
+ right: (this.width - this.areaTransform.x) / k,
52
+ top: -this.areaTransform.y / k,
53
+ bottom: (this.height - this.areaTransform.y) / k,
54
+ };
14
55
  this.context.save();
15
56
  this.context.clearRect(0, 0, this.width, this.height);
16
57
  this.context.translate(this.areaTransform.x, this.areaTransform.y);
17
58
  this.context.scale(this.areaTransform.k, this.areaTransform.k);
18
- const textRenders = [];
19
- const nodeRenders = [];
20
- this.nodes.forEach(getDrawNode(nodeRenders, textRenders).bind(this));
21
- /** links */
22
- this.links.forEach(getDrawLink().bind(this));
23
- /** nodes */
24
- nodeRenders.forEach((render) => render());
25
- textRenders.forEach((render) => render());
59
+ this.nodes.forEach(getDrawNode(nodeBatch, nodeImageBatch, textBatch, deferredNodeDraw, deferredTextDraw, area), this);
60
+ this.links.forEach(getDrawLink(linkBatch, particleBatch, arrowBatch, performance.now()), this);
61
+ const linkKeys = Object.keys(linkBatch);
62
+ for (let i = 0; i < linkKeys.length; i++) {
63
+ const key = linkKeys[i];
64
+ const group = linkBatch[key];
65
+ const [alpha, color, width] = key.split("|");
66
+ this.context.beginPath();
67
+ this.context.globalAlpha = +alpha;
68
+ this.context.strokeStyle = color;
69
+ this.context.lineWidth = +width;
70
+ this.context.setLineDash([]);
71
+ for (let j = 0; j < group.length; j++) {
72
+ const item = group[j];
73
+ if (!item.curve) {
74
+ this.context.moveTo(item.xStart, item.yStart);
75
+ this.context.lineTo(item.xEnd, item.yEnd);
76
+ }
77
+ else {
78
+ this.context.moveTo(item.xStart, item.yStart);
79
+ this.context.quadraticCurveTo(item.xControl, item.yControl, item.xEnd, item.yEnd);
80
+ }
81
+ }
82
+ this.context.stroke();
83
+ }
84
+ const particleKeys = Object.keys(particleBatch);
85
+ for (let i = 0; i < particleKeys.length; i++) {
86
+ const key = particleKeys[i];
87
+ const group = particleBatch[key];
88
+ const [bcolor, width, color] = key.split("|");
89
+ this.context.beginPath();
90
+ this.context.globalAlpha = 1;
91
+ this.context.strokeStyle = bcolor;
92
+ this.context.lineWidth = +width;
93
+ this.context.fillStyle = color;
94
+ for (let j = 0; j < group.length; j++) {
95
+ const item = group[j];
96
+ this.context.moveTo(item.x + item.r, item.y);
97
+ this.context.arc(item.x, item.y, item.r, 0, Math.PI * 2);
98
+ }
99
+ this.context.fill();
100
+ if (+width > 0) {
101
+ this.context.stroke();
102
+ }
103
+ }
104
+ const arrowKeys = Object.keys(arrowBatch);
105
+ for (let i = 0; i < arrowKeys.length; i++) {
106
+ const key = arrowKeys[i];
107
+ const group = arrowBatch[key];
108
+ const [alpha, bcolor, width, color] = key.split("|");
109
+ this.context.beginPath();
110
+ this.context.globalAlpha = +alpha;
111
+ this.context.strokeStyle = bcolor;
112
+ this.context.lineWidth = +width;
113
+ this.context.fillStyle = color;
114
+ for (let j = 0; j < group.length; j++) {
115
+ const item = group[j];
116
+ this.context.moveTo(item.x, item.y);
117
+ const cosA = Math.cos(item.angle);
118
+ const sinA = Math.sin(item.angle);
119
+ const cos1 = cosA * COS_PI_6 + sinA * SIN_PI_6;
120
+ const sin1 = sinA * COS_PI_6 - cosA * SIN_PI_6;
121
+ const cos2 = cosA * COS_PI_6 - sinA * SIN_PI_6;
122
+ const sin2 = sinA * COS_PI_6 + cosA * SIN_PI_6;
123
+ this.context.lineTo(item.x - item.size * cos1, item.y - item.size * sin1);
124
+ this.context.lineTo(item.x - item.size * cos2, item.y - item.size * sin2);
125
+ this.context.closePath();
126
+ }
127
+ this.context.fill();
128
+ if (+width > 0) {
129
+ this.context.stroke();
130
+ }
131
+ }
132
+ const nodeKeys = Object.keys(nodeBatch);
133
+ for (let i = 0; i < nodeKeys.length; i++) {
134
+ const key = nodeKeys[i];
135
+ const group = nodeBatch[key];
136
+ const [alpha, bcolor, width, color] = key.split("|");
137
+ this.context.beginPath();
138
+ this.context.globalAlpha = +alpha;
139
+ this.context.strokeStyle = bcolor;
140
+ this.context.lineWidth = +width;
141
+ this.context.fillStyle = color;
142
+ for (let j = 0; j < group.length; j++) {
143
+ const item = group[j];
144
+ switch (item.shape) {
145
+ case "circle": {
146
+ this.context.moveTo(item.x + item.radius, item.y);
147
+ this.context.arc(item.x, item.y, item.radius, 0, 2 * Math.PI);
148
+ break;
149
+ }
150
+ case "square": {
151
+ this.context.roundRect(item.x - item.width / 2, item.y - item.height / 2, item.width, item.height, item.radius);
152
+ break;
153
+ }
154
+ case "text": {
155
+ if (this.nodeSettings.textNodeDebug) {
156
+ this.context.rect(item.x - item.width / 2, item.y - item.height / 2, item.width, item.height);
157
+ }
158
+ break;
159
+ }
160
+ }
161
+ }
162
+ this.context.fill();
163
+ if (+width > 0) {
164
+ this.context.stroke();
165
+ }
166
+ }
167
+ const nodeImageKeys = Object.keys(nodeImageBatch);
168
+ for (let i = 0; i < nodeImageKeys.length; i++) {
169
+ const key = nodeImageKeys[i];
170
+ const group = nodeImageBatch[key];
171
+ const [alpha, bcolor, width, color] = key.split("|");
172
+ this.context.globalAlpha = +alpha;
173
+ this.context.strokeStyle = bcolor;
174
+ this.context.lineWidth = +width;
175
+ this.context.fillStyle = color;
176
+ for (let j = 0; j < group.length; j++) {
177
+ const item = group[j];
178
+ if (!item.image)
179
+ continue;
180
+ this.context.beginPath();
181
+ switch (item.shape) {
182
+ case "circle": {
183
+ this.context.arc(item.x, item.y, item.radius, 0, 2 * Math.PI);
184
+ this.context.closePath();
185
+ this.context.save();
186
+ this.context.clip();
187
+ this.context.drawImage(item.image, item.x - item.radius, item.y - item.radius, item.radius * 2, item.radius * 2);
188
+ this.context.restore();
189
+ break;
190
+ }
191
+ case "square": {
192
+ this.context.roundRect(item.x - item.width / 2, item.y - item.height / 2, item.width, item.height, item.radius);
193
+ this.context.closePath();
194
+ this.context.save();
195
+ this.context.clip();
196
+ this.context.drawImage(item.image, item.x - item.width / 2, item.y - item.height / 2, item.width, item.height);
197
+ this.context.restore();
198
+ break;
199
+ }
200
+ default: {
201
+ continue;
202
+ }
203
+ }
204
+ if (+width > 0) {
205
+ this.context.stroke();
206
+ }
207
+ }
208
+ }
209
+ const textKeys = Object.keys(textBatch);
210
+ for (let i = 0; i < textKeys.length; i++) {
211
+ const font = textKeys[i];
212
+ const fontGroup = textBatch[font];
213
+ const textInnerKeys = Object.keys(fontGroup);
214
+ this.context.font = font;
215
+ for (let j = 0; j < textInnerKeys.length; j++) {
216
+ const key = textInnerKeys[j];
217
+ const group = fontGroup[key];
218
+ const [alpha, align, color] = key.split("|");
219
+ this.context.globalAlpha = +alpha;
220
+ this.context.textAlign = align;
221
+ this.context.fillStyle = color;
222
+ for (let k = 0; k < group.length; k++) {
223
+ const item = group[k];
224
+ this.context.fillText(item.text, item.x, item.y);
225
+ }
226
+ }
227
+ }
228
+ deferredNodeDraw.forEach((draw) => draw());
229
+ deferredTextDraw.forEach((draw) => draw());
26
230
  this.context.restore();
27
231
  /** selection rectangle */
28
232
  if (this.isSelecting && this.selectionRect) {
@@ -1 +1 @@
1
- {"version":3,"file":"init-draw.js","sources":["../../../../../src/module/GraphCanvas/slices/init-draw.ts"],"sourcesContent":["import { setDrawTime } from \"@/lib\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport { getDrawLink } from \"./draw-links\";\nimport { getDrawNode } from \"./draw-nodes\";\n\nexport function initDraw<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n function draw(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.context) return;\n\n if (this.listeners.onDraw) {\n this.listeners.onDraw.call(this);\n\n return;\n }\n\n this.context.save();\n this.context.clearRect(0, 0, this.width, this.height);\n this.context.translate(this.areaTransform.x, this.areaTransform.y);\n this.context.scale(this.areaTransform.k, this.areaTransform.k);\n\n const textRenders: (() => void)[] = [];\n const nodeRenders: (() => void)[] = [];\n this.nodes.forEach(getDrawNode<NodeData, LinkData>(nodeRenders, textRenders).bind(this));\n\n /** links */\n this.links.forEach(getDrawLink<NodeData, LinkData>().bind(this));\n\n /** nodes */\n\n nodeRenders.forEach((render) => render());\n textRenders.forEach((render) => render());\n\n this.context.restore();\n\n /** selection rectangle */\n if (this.isSelecting && this.selectionRect) {\n const rect = this.selectionRect;\n const screenX = Math.min(rect.x1, rect.x2) * this.areaTransform.k + this.areaTransform.x;\n const screenY = Math.min(rect.y1, rect.y2) * this.areaTransform.k + this.areaTransform.y;\n const screenW = Math.abs(rect.x2 - rect.x1) * this.areaTransform.k;\n const screenH = Math.abs(rect.y2 - rect.y1) * this.areaTransform.k;\n\n this.context.fillStyle = \"rgba(66, 133, 244, 0.2)\";\n this.context.fillRect(screenX, screenY, screenW, screenH);\n this.context.strokeStyle = \"rgba(66, 133, 244, 0.8)\";\n this.context.lineWidth = 2;\n this.context.strokeRect(screenX, screenY, screenW, screenH);\n }\n this.listeners.onDrawFinished?.call?.(this);\n }\n\n if (this.graphSettings.showDrawTime) {\n return setDrawTime(draw.bind(this), this.graphSettings.showDrawTimeEveryTick);\n }\n\n return draw.bind(this);\n}\n"],"names":[],"mappings":";;;;;SAKgB,QAAQ,GAAA;AAItB,IAAA,SAAS,IAAI,GAAA;QACX,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE;AAEnB,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YAEhC;;AAGF,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;AACnB,QAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE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,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;YAClE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAElE,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,yBAAyB;AAClD,YAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;AACzD,YAAA,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG,yBAAyB;AACpD,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC;AAC1B,YAAA,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;;QAE7D,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;;AAG7C,IAAA,IAAI,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;AACnC,QAAA,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC;;AAG/E,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACxB;;;;"}
1
+ {"version":3,"file":"init-draw.js","sources":["../../../../../src/module/GraphCanvas/slices/init-draw.ts"],"sourcesContent":["import { setDrawTime } from \"@/lib\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport type {\n Area,\n DeferredDraw,\n LinkArrowDrawBatch,\n LinkDrawBatch,\n LinkParticleDrawBatch,\n NodeDrawBatch,\n NodeTextDrawBatch,\n} from \"../types\";\nimport { getDrawLink } from \"./draw-links\";\nimport { getDrawNode } from \"./draw-nodes\";\n\nconst COS_PI_6 = 0.8660254037844386;\nconst SIN_PI_6 = 0.5;\n\nfunction clearBatch<T>(batch: Record<string, T[]>) {\n // eslint-disable-next-line guard-for-in\n for (const key in batch) {\n batch[key].length = 0;\n }\n}\n\nfunction clearNestedBatch<T>(batch: Record<string, Record<string, T[]>>) {\n // eslint-disable-next-line guard-for-in\n for (const outerKey in batch) {\n const inner = batch[outerKey];\n // eslint-disable-next-line guard-for-in\n for (const innerKey in inner) {\n inner[innerKey].length = 0;\n }\n }\n}\n\nexport function initDraw<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n const nodeBatch: Record<string, NodeDrawBatch[]> = {};\n const nodeImageBatch: Record<string, NodeDrawBatch[]> = {};\n const textBatch: Record<string, Record<string, NodeTextDrawBatch[]>> = {};\n const deferredNodeDraw: DeferredDraw[] = [];\n const deferredTextDraw: DeferredDraw[] = [];\n const linkBatch: Record<string, LinkDrawBatch[]> = {};\n const particleBatch: Record<string, LinkParticleDrawBatch[]> = {};\n const arrowBatch: Record<string, LinkArrowDrawBatch[]> = {};\n\n function draw(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.context) return;\n if (this.listeners.onDraw) {\n this.listeners.onDraw.call(this);\n return;\n }\n clearBatch(nodeBatch);\n clearBatch(nodeImageBatch);\n clearNestedBatch(textBatch);\n deferredNodeDraw.length = 0;\n deferredTextDraw.length = 0;\n clearBatch(linkBatch);\n clearBatch(particleBatch);\n clearBatch(arrowBatch);\n const k = this.areaTransform.k;\n const area: Area = {\n left: -this.areaTransform.x / k,\n right: (this.width - this.areaTransform.x) / k,\n top: -this.areaTransform.y / k,\n bottom: (this.height - this.areaTransform.y) / k,\n };\n this.context.save();\n this.context.clearRect(0, 0, this.width, this.height);\n this.context.translate(this.areaTransform.x, this.areaTransform.y);\n this.context.scale(this.areaTransform.k, this.areaTransform.k);\n this.nodes.forEach(\n getDrawNode<NodeData, LinkData>(\n nodeBatch,\n nodeImageBatch,\n textBatch,\n deferredNodeDraw,\n deferredTextDraw,\n area,\n ),\n this,\n );\n this.links.forEach(\n getDrawLink<NodeData, LinkData>(linkBatch, particleBatch, arrowBatch, performance.now()),\n this,\n );\n const linkKeys = Object.keys(linkBatch);\n for (let i = 0; i < linkKeys.length; i++) {\n const key = linkKeys[i];\n const group = linkBatch[key];\n const [alpha, color, width] = key.split(\"|\");\n this.context.beginPath();\n this.context.globalAlpha = +alpha;\n this.context.strokeStyle = color;\n this.context.lineWidth = +width;\n this.context.setLineDash([]);\n for (let j = 0; j < group.length; j++) {\n const item = group[j];\n if (!item.curve) {\n this.context.moveTo(item.xStart, item.yStart);\n this.context.lineTo(item.xEnd, item.yEnd);\n } else {\n this.context.moveTo(item.xStart, item.yStart);\n this.context.quadraticCurveTo(item.xControl, item.yControl, item.xEnd, item.yEnd);\n }\n }\n this.context.stroke();\n }\n const particleKeys = Object.keys(particleBatch);\n for (let i = 0; i < particleKeys.length; i++) {\n const key = particleKeys[i];\n const group = particleBatch[key];\n const [bcolor, width, color] = key.split(\"|\");\n this.context.beginPath();\n this.context.globalAlpha = 1;\n this.context.strokeStyle = bcolor;\n this.context.lineWidth = +width;\n this.context.fillStyle = color;\n for (let j = 0; j < group.length; j++) {\n const item = group[j];\n this.context.moveTo(item.x + item.r, item.y);\n this.context.arc(item.x, item.y, item.r, 0, Math.PI * 2);\n }\n this.context.fill();\n if (+width > 0) {\n this.context.stroke();\n }\n }\n const arrowKeys = Object.keys(arrowBatch);\n for (let i = 0; i < arrowKeys.length; i++) {\n const key = arrowKeys[i];\n const group = arrowBatch[key];\n const [alpha, bcolor, width, color] = key.split(\"|\");\n this.context.beginPath();\n this.context.globalAlpha = +alpha;\n this.context.strokeStyle = bcolor;\n this.context.lineWidth = +width;\n this.context.fillStyle = color;\n for (let j = 0; j < group.length; j++) {\n const item = group[j];\n this.context.moveTo(item.x, item.y);\n const cosA = Math.cos(item.angle);\n const sinA = Math.sin(item.angle);\n const cos1 = cosA * COS_PI_6 + sinA * SIN_PI_6;\n const sin1 = sinA * COS_PI_6 - cosA * SIN_PI_6;\n const cos2 = cosA * COS_PI_6 - sinA * SIN_PI_6;\n const sin2 = sinA * COS_PI_6 + cosA * SIN_PI_6;\n this.context.lineTo(item.x - item.size * cos1, item.y - item.size * sin1);\n this.context.lineTo(item.x - item.size * cos2, item.y - item.size * sin2);\n this.context.closePath();\n }\n this.context.fill();\n if (+width > 0) {\n this.context.stroke();\n }\n }\n const nodeKeys = Object.keys(nodeBatch);\n for (let i = 0; i < nodeKeys.length; i++) {\n const key = nodeKeys[i];\n const group = nodeBatch[key];\n const [alpha, bcolor, width, color] = key.split(\"|\");\n this.context.beginPath();\n this.context.globalAlpha = +alpha;\n this.context.strokeStyle = bcolor;\n this.context.lineWidth = +width;\n this.context.fillStyle = color;\n for (let j = 0; j < group.length; j++) {\n const item = group[j];\n switch (item.shape) {\n case \"circle\": {\n this.context.moveTo(item.x + item.radius, item.y);\n this.context.arc(item.x, item.y, item.radius, 0, 2 * Math.PI);\n break;\n }\n case \"square\": {\n this.context.roundRect(\n item.x - item.width / 2,\n item.y - item.height / 2,\n item.width,\n item.height,\n item.radius,\n );\n break;\n }\n case \"text\": {\n if (this.nodeSettings.textNodeDebug) {\n this.context.rect(\n item.x - item.width / 2,\n item.y - item.height / 2,\n item.width,\n item.height,\n );\n }\n break;\n }\n default: {\n }\n }\n }\n this.context.fill();\n if (+width > 0) {\n this.context.stroke();\n }\n }\n const nodeImageKeys = Object.keys(nodeImageBatch);\n for (let i = 0; i < nodeImageKeys.length; i++) {\n const key = nodeImageKeys[i];\n const group = nodeImageBatch[key];\n const [alpha, bcolor, width, color] = key.split(\"|\");\n this.context.globalAlpha = +alpha;\n this.context.strokeStyle = bcolor;\n this.context.lineWidth = +width;\n this.context.fillStyle = color;\n for (let j = 0; j < group.length; j++) {\n const item = group[j];\n if (!item.image) continue;\n this.context.beginPath();\n switch (item.shape) {\n case \"circle\": {\n this.context.arc(item.x, item.y, item.radius, 0, 2 * Math.PI);\n this.context.closePath();\n this.context.save();\n this.context.clip();\n this.context.drawImage(\n item.image,\n item.x - item.radius,\n item.y - item.radius,\n item.radius * 2,\n item.radius * 2,\n );\n this.context.restore();\n break;\n }\n case \"square\": {\n this.context.roundRect(\n item.x - item.width / 2,\n item.y - item.height / 2,\n item.width,\n item.height,\n item.radius,\n );\n this.context.closePath();\n this.context.save();\n this.context.clip();\n this.context.drawImage(\n item.image,\n item.x - item.width / 2,\n item.y - item.height / 2,\n item.width,\n item.height,\n );\n this.context.restore();\n break;\n }\n default: {\n continue;\n }\n }\n if (+width > 0) {\n this.context.stroke();\n }\n }\n }\n const textKeys = Object.keys(textBatch);\n for (let i = 0; i < textKeys.length; i++) {\n const font = textKeys[i];\n const fontGroup = textBatch[font];\n const textInnerKeys = Object.keys(fontGroup);\n this.context.font = font;\n for (let j = 0; j < textInnerKeys.length; j++) {\n const key = textInnerKeys[j];\n const group = fontGroup[key];\n const [alpha, align, color] = key.split(\"|\");\n this.context.globalAlpha = +alpha;\n this.context.textAlign = align as CanvasTextAlign;\n this.context.fillStyle = color;\n for (let k = 0; k < group.length; k++) {\n const item = group[k];\n this.context.fillText(item.text, item.x, item.y);\n }\n }\n }\n deferredNodeDraw.forEach((draw) => draw());\n deferredTextDraw.forEach((draw) => draw());\n this.context.restore();\n\n /** selection rectangle */\n if (this.isSelecting && this.selectionRect) {\n const rect = this.selectionRect;\n const screenX = Math.min(rect.x1, rect.x2) * this.areaTransform.k + this.areaTransform.x;\n const screenY = Math.min(rect.y1, rect.y2) * this.areaTransform.k + this.areaTransform.y;\n const screenW = Math.abs(rect.x2 - rect.x1) * this.areaTransform.k;\n const screenH = Math.abs(rect.y2 - rect.y1) * this.areaTransform.k;\n\n this.context.fillStyle = \"rgba(66, 133, 244, 0.2)\";\n this.context.fillRect(screenX, screenY, screenW, screenH);\n this.context.strokeStyle = \"rgba(66, 133, 244, 0.8)\";\n this.context.lineWidth = 2;\n this.context.strokeRect(screenX, screenY, screenW, screenH);\n }\n this.listeners.onDrawFinished?.call?.(this);\n }\n\n if (this.graphSettings.showDrawTime) {\n return setDrawTime(draw.bind(this), this.graphSettings.showDrawTimeEveryTick);\n }\n\n return draw.bind(this);\n}\n"],"names":[],"mappings":";;;;;AAcA,MAAM,QAAQ,GAAG,kBAAkB;AACnC,MAAM,QAAQ,GAAG,GAAG;AAEpB,SAAS,UAAU,CAAI,KAA0B,EAAA;;AAE/C,IAAA,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;AACvB,QAAA,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;;AAEzB;AAEA,SAAS,gBAAgB,CAAI,KAA0C,EAAA;;AAErE,IAAA,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;AAC5B,QAAA,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;;AAE7B,QAAA,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;AAC5B,YAAA,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC;;;AAGhC;SAEgB,QAAQ,GAAA;IAItB,MAAM,SAAS,GAAoC,EAAE;IACrD,MAAM,cAAc,GAAoC,EAAE;IAC1D,MAAM,SAAS,GAAwD,EAAE;IACzE,MAAM,gBAAgB,GAAmB,EAAE;IAC3C,MAAM,gBAAgB,GAAmB,EAAE;IAC3C,MAAM,SAAS,GAAoC,EAAE;IACrD,MAAM,aAAa,GAA4C,EAAE;IACjE,MAAM,UAAU,GAAyC,EAAE;AAE3D,IAAA,SAAS,IAAI,GAAA;QACX,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE;AACnB,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC;;QAEF,UAAU,CAAC,SAAS,CAAC;QACrB,UAAU,CAAC,cAAc,CAAC;QAC1B,gBAAgB,CAAC,SAAS,CAAC;AAC3B,QAAA,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CAAC,WAAW,GAAG,yBAAyB;AACpD,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC;AAC1B,YAAA,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;;QAE7D,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;;AAG7C,IAAA,IAAI,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;AACnC,QAAA,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC;;AAG/E,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACxB;;;;"}
@@ -1,11 +1,12 @@
1
1
  import '../constants/force-settings.js';
2
- import '../constants/graph-settings.js';
3
- import '../constants/highlight-settings.js';
4
- import '../constants/link-settings.js';
5
- import '../constants/node-settings.js';
6
2
  import '@krainovsd/js-helpers';
7
3
  import { nodeByPointerGetter } from '../lib/utils/node-by-pointer-getter.js';
8
4
  import { linkByPointerGetter } from '../lib/utils/link-by-pointer-getter.js';
5
+ import 'd3-force';
6
+ import 'd3-selection';
7
+ import 'd3-zoom';
8
+ import 'd3-array';
9
+ import 'd3-drag';
9
10
 
10
11
  function initPointer() {
11
12
  if (!this.area || !this.nodes)
@@ -13,6 +14,7 @@ function initPointer() {
13
14
  function onHover(event) {
14
15
  if (!this.area || this.isSelecting)
15
16
  return;
17
+ const [pointerX, pointerY] = this.getPointerAreaPosition(event);
16
18
  let currentNode;
17
19
  let currentLink;
18
20
  const checkHighlightNode = this.highlightSettings.highlightByHoverNode && !this.isDragging;
@@ -20,7 +22,6 @@ function initPointer() {
20
22
  let highlightNode = true;
21
23
  let highlightLink = true;
22
24
  if (checkHighlightNode) {
23
- const [pointerX, pointerY] = this.getPointerAreaPosition(event);
24
25
  currentNode = nodeByPointerGetter({
25
26
  pointerX,
26
27
  pointerY,
@@ -33,7 +34,6 @@ function initPointer() {
33
34
  this.area.style.cursor = "pointer";
34
35
  }
35
36
  else if (checkHighlightLink) {
36
- const [pointerX, pointerY] = this.getPointerAreaPosition(event);
37
37
  currentLink = linkByPointerGetter({
38
38
  pointerX,
39
39
  pointerY,
@@ -57,7 +57,6 @@ function initPointer() {
57
57
  if (!this.listeners.onHover)
58
58
  return;
59
59
  if (!currentNode && !checkHighlightNode) {
60
- const [pointerX, pointerY] = this.getPointerAreaPosition(event);
61
60
  currentNode = nodeByPointerGetter({
62
61
  pointerX,
63
62
  pointerY,
@@ -65,7 +64,6 @@ function initPointer() {
65
64
  });
66
65
  }
67
66
  if (!currentNode && (!checkHighlightNode || (!checkHighlightLink && !currentLink))) {
68
- const [pointerX, pointerY] = this.getPointerAreaPosition(event);
69
67
  currentLink = linkByPointerGetter({
70
68
  pointerX,
71
69
  pointerY,