boardplot 0.0.0-stage → 0.52.5
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/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/NOTICE.md +180 -0
- package/README.md +208 -2
- package/THIRD_PARTY_NOTICES.md +1110 -0
- package/dist/DiagnosticDetails-UNYNYCAH.js +69 -0
- package/dist/ReaderBox-VUNSFKZY.js +137 -0
- package/dist/annotateEngine-H7OW4H3W.js +30 -0
- package/dist/build-identity.json +6 -0
- package/dist/chunk-24WB3HMB.js +621 -0
- package/dist/chunk-263SZKIL.js +8 -0
- package/dist/chunk-27QQEWNV.js +18 -0
- package/dist/chunk-2AKWCMS4.js +24 -0
- package/dist/chunk-2DHJJ2EN.js +24 -0
- package/dist/chunk-2EQE4E3I.js +22 -0
- package/dist/chunk-2GELJH37.js +88 -0
- package/dist/chunk-2JAWQ7VV.js +3874 -0
- package/dist/chunk-2LMCD3ZR.js +6 -0
- package/dist/chunk-2MTWKMEG.js +841 -0
- package/dist/chunk-2SGIHKKU.js +33 -0
- package/dist/chunk-2UVTHU7A.js +1146 -0
- package/dist/chunk-33CBPK5Q.js +2800 -0
- package/dist/chunk-33PLBIMA.js +176 -0
- package/dist/chunk-35DZP2R2.js +22 -0
- package/dist/chunk-3D3D3D23.js +25 -0
- package/dist/chunk-3EZRM4YM.js +92 -0
- package/dist/chunk-3GZECHOK.js +802 -0
- package/dist/chunk-3HHNQPAH.js +68 -0
- package/dist/chunk-3I6RANBJ.js +1058 -0
- package/dist/chunk-3SIRPKMP.js +12 -0
- package/dist/chunk-3W23F7EY.js +185 -0
- package/dist/chunk-3XQ635KD.js +24 -0
- package/dist/chunk-3ZCKEANJ.js +24 -0
- package/dist/chunk-4DNOEV3Q.js +25857 -0
- package/dist/chunk-4GB7TBY7.js +373 -0
- package/dist/chunk-4SM2ONUC.js +18 -0
- package/dist/chunk-5C7TWNYZ.js +79 -0
- package/dist/chunk-5DJXJXDE.js +58 -0
- package/dist/chunk-5ENRZX6I.js +687 -0
- package/dist/chunk-5KWXRYAT.js +294 -0
- package/dist/chunk-5T5YW52S.js +47 -0
- package/dist/chunk-627P6T25.js +936 -0
- package/dist/chunk-62FR4FYJ.js +23 -0
- package/dist/chunk-6JUJ2DU3.js +67 -0
- package/dist/chunk-6KWIQ5KF.js +18 -0
- package/dist/chunk-6UBEGKIQ.js +25 -0
- package/dist/chunk-6XE3GVGU.js +116 -0
- package/dist/chunk-76ANFJOI.js +227 -0
- package/dist/chunk-7IFLQMJL.js +160 -0
- package/dist/chunk-7JVAQX6C.js +28 -0
- package/dist/chunk-7QDAHY5M.js +63 -0
- package/dist/chunk-7VXZDB45.js +149 -0
- package/dist/chunk-7X65ZQN4.js +38 -0
- package/dist/chunk-A2FHZH7E.js +1410 -0
- package/dist/chunk-A372DLQX.js +54 -0
- package/dist/chunk-A3ULWR5N.js +76 -0
- package/dist/chunk-A4QZXLXF.js +7 -0
- package/dist/chunk-A5JWFZVU.js +1467 -0
- package/dist/chunk-A5LZUYK4.js +59 -0
- package/dist/chunk-A6XCAQ52.js +89 -0
- package/dist/chunk-A7A4PDG5.js +24 -0
- package/dist/chunk-A7IEVBYI.js +35 -0
- package/dist/chunk-ACXX2JNL.js +6 -0
- package/dist/chunk-AFK47A6O.js +25 -0
- package/dist/chunk-ALKTNXMR.js +3650 -0
- package/dist/chunk-AOQ6VF5H.js +6 -0
- package/dist/chunk-ASAON7G4.js +648 -0
- package/dist/chunk-ATTE3FYC.js +24 -0
- package/dist/chunk-AZOUSKZD.js +728 -0
- package/dist/chunk-B2EBEXIS.js +113 -0
- package/dist/chunk-B67K5X4M.js +58 -0
- package/dist/chunk-BBL3R5YZ.js +186 -0
- package/dist/chunk-BIDIGDGH.js +6 -0
- package/dist/chunk-BKYMLFUG.js +69 -0
- package/dist/chunk-BLFWUMTD.js +12 -0
- package/dist/chunk-BM6SFFWF.js +6 -0
- package/dist/chunk-BUPLB3EX.js +129 -0
- package/dist/chunk-BVWU6GOB.js +47 -0
- package/dist/chunk-BW5VLBSZ.js +15 -0
- package/dist/chunk-C64FBRJO.js +290 -0
- package/dist/chunk-CAE2HK2G.js +295 -0
- package/dist/chunk-CCQNL33L.js +446 -0
- package/dist/chunk-CDZHNLO6.js +42 -0
- package/dist/chunk-COKHNEJP.js +24 -0
- package/dist/chunk-COYPDRJK.js +21 -0
- package/dist/chunk-CRZKGHZ6.js +1810 -0
- package/dist/chunk-CS4DHFNG.js +128 -0
- package/dist/chunk-CYDZP5W6.js +1589 -0
- package/dist/chunk-D4BIV6WG.js +1072 -0
- package/dist/chunk-D4SOADBD.js +19 -0
- package/dist/chunk-DCCJRLAJ.js +422 -0
- package/dist/chunk-DFKTS6XJ.js +75 -0
- package/dist/chunk-DGDOGOTQ.js +25 -0
- package/dist/chunk-DLC23CKC.js +53 -0
- package/dist/chunk-DRTA6JG5.js +160 -0
- package/dist/chunk-DVKBU23L.js +97 -0
- package/dist/chunk-E2HEVF23.js +692 -0
- package/dist/chunk-EC2NAYPQ.js +24 -0
- package/dist/chunk-EKQK5D6G.js +14 -0
- package/dist/chunk-EKQMYG2B.js +2353 -0
- package/dist/chunk-ELYU6TRQ.js +98 -0
- package/dist/chunk-EQT3EPTB.js +203 -0
- package/dist/chunk-ERAIVAK5.js +1359 -0
- package/dist/chunk-ETHWK2RZ.js +16 -0
- package/dist/chunk-EWVKBRLV.js +72 -0
- package/dist/chunk-F77BNDAT.js +43 -0
- package/dist/chunk-FGAGGPFF.js +566 -0
- package/dist/chunk-FIANWJXX.js +19 -0
- package/dist/chunk-FIWNDOMO.js +6 -0
- package/dist/chunk-FOKEGVPB.js +24 -0
- package/dist/chunk-FT3F72C3.js +30 -0
- package/dist/chunk-FT47HQ5U.js +47 -0
- package/dist/chunk-GDOW2KNP.js +19 -0
- package/dist/chunk-GDQ3NGDZ.js +17 -0
- package/dist/chunk-GH3ZMBFX.js +563 -0
- package/dist/chunk-GQPESFAF.js +3378 -0
- package/dist/chunk-GQS46LC3.js +50 -0
- package/dist/chunk-GULJ6KVT.js +587 -0
- package/dist/chunk-GWQIXU37.js +2774 -0
- package/dist/chunk-GZ2VNM4L.js +24 -0
- package/dist/chunk-GZ4RHGIW.js +836 -0
- package/dist/chunk-H4H4O62O.js +46 -0
- package/dist/chunk-H57TJD3B.js +72 -0
- package/dist/chunk-H7UZZ7KP.js +24 -0
- package/dist/chunk-HAAUJDGB.js +83 -0
- package/dist/chunk-HFG76JTS.js +296 -0
- package/dist/chunk-HJXXFPOL.js +211 -0
- package/dist/chunk-HTYFQHRC.js +24 -0
- package/dist/chunk-HUF6TQ2J.js +24 -0
- package/dist/chunk-HUFCSX2Y.js +89 -0
- package/dist/chunk-HX3MQ3H4.js +26 -0
- package/dist/chunk-HZQEQ34U.js +296 -0
- package/dist/chunk-I322G5UG.js +888 -0
- package/dist/chunk-IDDA5INB.js +60 -0
- package/dist/chunk-IDTLHPTK.js +60 -0
- package/dist/chunk-II7652VA.js +2918 -0
- package/dist/chunk-IN4QT33I.js +38 -0
- package/dist/chunk-IV2UXZXX.js +16 -0
- package/dist/chunk-IXSZ7OKR.js +133 -0
- package/dist/chunk-IYEFEBRN.js +41 -0
- package/dist/chunk-IZ35GMGB.js +2543 -0
- package/dist/chunk-IZCOG3FS.js +28 -0
- package/dist/chunk-JA755JHN.js +379 -0
- package/dist/chunk-JETXFF3M.js +33 -0
- package/dist/chunk-JFBEAUJ6.js +24 -0
- package/dist/chunk-JFG4DHKQ.js +48 -0
- package/dist/chunk-JL5BRMDT.js +179 -0
- package/dist/chunk-JLCAWQ3H.js +195 -0
- package/dist/chunk-JLZM7XMZ.js +525 -0
- package/dist/chunk-JMH5MD5A.js +19 -0
- package/dist/chunk-JRPI64AQ.js +3066 -0
- package/dist/chunk-JSX3C6LL.js +344 -0
- package/dist/chunk-JY4R3GML.js +83 -0
- package/dist/chunk-JYBT2JNY.js +61 -0
- package/dist/chunk-K2HNV4LE.js +2008 -0
- package/dist/chunk-KAXJFL7N.js +43 -0
- package/dist/chunk-KDMKHR5A.js +32 -0
- package/dist/chunk-KFFNCDX6.js +19 -0
- package/dist/chunk-KKWZWP67.js +24 -0
- package/dist/chunk-KOJ5QETJ.js +8 -0
- package/dist/chunk-KPMGGE4W.js +51 -0
- package/dist/chunk-KS7DXCXH.js +27 -0
- package/dist/chunk-KSYVTEKR.js +24 -0
- package/dist/chunk-KU4YS6HN.js +61 -0
- package/dist/chunk-KYELSLDJ.js +40 -0
- package/dist/chunk-LC3PSQJJ.js +383 -0
- package/dist/chunk-LC6DYCTG.js +85 -0
- package/dist/chunk-LNKY5Z2X.js +23 -0
- package/dist/chunk-LO2DANS6.js +302 -0
- package/dist/chunk-M4SPKUZE.js +7 -0
- package/dist/chunk-M4YLED7M.js +17 -0
- package/dist/chunk-M6KTNAND.js +746 -0
- package/dist/chunk-MCOIEWW6.js +54 -0
- package/dist/chunk-MDYLOIS2.js +48 -0
- package/dist/chunk-MEISCROL.js +24 -0
- package/dist/chunk-MFLH5ZDQ.js +69 -0
- package/dist/chunk-MIXKQJ64.js +935 -0
- package/dist/chunk-MJMJEURO.js +359 -0
- package/dist/chunk-MNJ2DHU6.js +526 -0
- package/dist/chunk-NEVSQGOI.js +63 -0
- package/dist/chunk-NG5IGZXC.js +1179 -0
- package/dist/chunk-NLOMCLKI.js +3303 -0
- package/dist/chunk-NMCOUVN5.js +24 -0
- package/dist/chunk-NT3HAZYT.js +51 -0
- package/dist/chunk-NXNQQ3DS.js +382 -0
- package/dist/chunk-NYEY6W5R.js +569 -0
- package/dist/chunk-OAPCJO6W.js +23 -0
- package/dist/chunk-OH7FA4TF.js +251 -0
- package/dist/chunk-OLNORNCT.js +331 -0
- package/dist/chunk-OQEBOVUO.js +30 -0
- package/dist/chunk-ORUJI3VB.js +83 -0
- package/dist/chunk-PEN2DK7T.js +49 -0
- package/dist/chunk-PGIQMQRU.js +1650 -0
- package/dist/chunk-PTVOXB5T.js +39 -0
- package/dist/chunk-PUVGWJQ5.js +24 -0
- package/dist/chunk-PWROWDZS.js +137 -0
- package/dist/chunk-Q6XJOJTY.js +29 -0
- package/dist/chunk-QBR6IKIX.js +50 -0
- package/dist/chunk-QETGGFH2.js +30 -0
- package/dist/chunk-QG6MOQLI.js +2934 -0
- package/dist/chunk-QGCEHR6S.js +13 -0
- package/dist/chunk-QHFQHQDC.js +43 -0
- package/dist/chunk-QHRE2M6V.js +26 -0
- package/dist/chunk-QKL7IY42.js +38 -0
- package/dist/chunk-QN6JHMGU.js +44 -0
- package/dist/chunk-QNHZXFRA.js +347 -0
- package/dist/chunk-QPWRHDLZ.js +17 -0
- package/dist/chunk-QVABTUDS.js +80 -0
- package/dist/chunk-QXILAMAU.js +28 -0
- package/dist/chunk-QZAT46PP.js +95 -0
- package/dist/chunk-R3WI7ZLE.js +545 -0
- package/dist/chunk-R5SWC3EW.js +30 -0
- package/dist/chunk-RJQ5YS3Q.js +40 -0
- package/dist/chunk-RNOD2UWF.js +613 -0
- package/dist/chunk-RNXITK5M.js +24 -0
- package/dist/chunk-ROXO4R3J.js +16 -0
- package/dist/chunk-RQ5DNYLG.js +10 -0
- package/dist/chunk-RSWVH7DB.js +24 -0
- package/dist/chunk-RTJXOIIQ.js +12 -0
- package/dist/chunk-RZNYW7UP.js +133 -0
- package/dist/chunk-S4F27M7N.js +37 -0
- package/dist/chunk-S4ONWRJE.js +28 -0
- package/dist/chunk-S53OGZL6.js +168 -0
- package/dist/chunk-S5ADHIZK.js +2508 -0
- package/dist/chunk-S62M63LU.js +19 -0
- package/dist/chunk-S7VDRUED.js +62 -0
- package/dist/chunk-SGD3ZHID.js +250 -0
- package/dist/chunk-SGSPYHFE.js +40 -0
- package/dist/chunk-SLTMRTXV.js +597 -0
- package/dist/chunk-SXGTRZFN.js +26 -0
- package/dist/chunk-SZPTTNW7.js +16 -0
- package/dist/chunk-T3IGJARD.js +22 -0
- package/dist/chunk-TA3TFKYZ.js +86 -0
- package/dist/chunk-TNEHPP3H.js +18 -0
- package/dist/chunk-TPYV2FTV.js +25 -0
- package/dist/chunk-TPZB2YWR.js +25 -0
- package/dist/chunk-TSR5YDPS.js +1266 -0
- package/dist/chunk-TTR7EWNH.js +170 -0
- package/dist/chunk-TVHLKVUO.js +24 -0
- package/dist/chunk-TXINIAFL.js +198 -0
- package/dist/chunk-TXZBBZOG.js +58 -0
- package/dist/chunk-UEU46Q3D.js +300 -0
- package/dist/chunk-UMDEWWXT.js +33 -0
- package/dist/chunk-UQSVWO7Z.js +334 -0
- package/dist/chunk-UZF3G2FN.js +942 -0
- package/dist/chunk-V422EKLW.js +24 -0
- package/dist/chunk-V4DYVLOO.js +433 -0
- package/dist/chunk-V4VC25UL.js +128 -0
- package/dist/chunk-V667FCIJ.js +12 -0
- package/dist/chunk-VABRPZVC.js +43 -0
- package/dist/chunk-VB2MJLET.js +19 -0
- package/dist/chunk-VDAKTZQP.js +18 -0
- package/dist/chunk-VDAZPGR2.js +79 -0
- package/dist/chunk-VXZFQKBJ.js +21 -0
- package/dist/chunk-VYMGZ27S.js +133 -0
- package/dist/chunk-W2RGSGRR.js +131 -0
- package/dist/chunk-W7UZXD5D.js +1109 -0
- package/dist/chunk-WDUNR2VI.js +2718 -0
- package/dist/chunk-WHSTEAVP.js +229 -0
- package/dist/chunk-WJMUMN3I.js +127 -0
- package/dist/chunk-WLZ54FWG.js +120 -0
- package/dist/chunk-WMJPFLF3.js +2980 -0
- package/dist/chunk-WRHFBCVY.js +24 -0
- package/dist/chunk-WVSNSWBJ.js +47 -0
- package/dist/chunk-WYJEOMNY.js +31 -0
- package/dist/chunk-WYJMV62X.js +24 -0
- package/dist/chunk-WZGJSQKN.js +29 -0
- package/dist/chunk-WZL4EEBS.js +11 -0
- package/dist/chunk-X7TXGKRX.js +272 -0
- package/dist/chunk-XB4KZ6WO.js +81 -0
- package/dist/chunk-XDLQRSSH.js +266 -0
- package/dist/chunk-XDS4UZGR.js +113 -0
- package/dist/chunk-XEGRWWNO.js +30 -0
- package/dist/chunk-XO5ONLVM.js +420 -0
- package/dist/chunk-XPWRD424.js +24 -0
- package/dist/chunk-XTNV2YMB.js +50 -0
- package/dist/chunk-XW5J5JAX.js +42 -0
- package/dist/chunk-XY5O74BH.js +33 -0
- package/dist/chunk-XYONCO5Q.js +984 -0
- package/dist/chunk-Y4PXIJMD.js +829 -0
- package/dist/chunk-YAYRRKC7.js +24 -0
- package/dist/chunk-YEDYBMCW.js +210 -0
- package/dist/chunk-YFG4E3N2.js +1161 -0
- package/dist/chunk-YHTO46W2.js +2670 -0
- package/dist/chunk-YI2ZVTCB.js +38 -0
- package/dist/chunk-YKO3VCTF.js +24 -0
- package/dist/chunk-YP3I6W7T.js +24 -0
- package/dist/chunk-YQ2B3YVF.js +687 -0
- package/dist/chunk-YS6KMYM4.js +91 -0
- package/dist/chunk-YTSSXSZR.js +197 -0
- package/dist/chunk-Z256ACGC.js +27 -0
- package/dist/chunk-Z2MGTKDR.js +20 -0
- package/dist/chunk-Z5VSLLNY.js +23 -0
- package/dist/chunk-Z7X3RGGA.js +22 -0
- package/dist/chunk-ZF43WRG3.js +29 -0
- package/dist/chunk-ZJKOLOVF.js +1754 -0
- package/dist/chunk-ZQ4VFQID.js +76 -0
- package/dist/chunk-ZSLGN6CO.js +89 -0
- package/dist/chunk-ZVTFZF4V.js +542 -0
- package/dist/cli/index.js +9 -0
- package/dist/core-5Z6UW5DS.js +31 -0
- package/dist/core-6ANZ2OWO.js +40 -0
- package/dist/core-6LLJNZ4O.js +37 -0
- package/dist/core-CPN2HF75.js +33 -0
- package/dist/core-CS7AKNME.js +37 -0
- package/dist/core-DBRILYNB.js +38 -0
- package/dist/core-DU77ZYPR.js +34 -0
- package/dist/core-E6YD7VU4.js +32 -0
- package/dist/core-EE55P6XK.js +56 -0
- package/dist/core-FFLPH5XK.js +41 -0
- package/dist/core-IV26EL5C.js +32 -0
- package/dist/core-IZVZ2B7Y.js +34 -0
- package/dist/core-JQV7STNF.js +34 -0
- package/dist/core-KBH3EJZV.js +32 -0
- package/dist/core-KFBW5PRT.js +36 -0
- package/dist/core-KWGXHBJE.js +37 -0
- package/dist/core-MZMR2DF4.js +32 -0
- package/dist/core-OK2ZY5OJ.js +29 -0
- package/dist/core-OV5MPTZP.js +43 -0
- package/dist/core-OW5V74Q4.js +40 -0
- package/dist/core-PL64QPOH.js +57 -0
- package/dist/core-PVINU5JJ.js +33 -0
- package/dist/core-QUYSNTC7.js +34 -0
- package/dist/core-RE3L6YCM.js +29 -0
- package/dist/core-RUA3EWW3.js +39 -0
- package/dist/core-RY6IFRKM.js +35 -0
- package/dist/core-SCWEVNUY.js +34 -0
- package/dist/core-SE67HHFG.js +55 -0
- package/dist/core-T5Q4DSH2.js +32 -0
- package/dist/core-TJX3I7KH.js +37 -0
- package/dist/core-ULUA5ZB2.js +55 -0
- package/dist/core-WLVU2HWX.js +46 -0
- package/dist/core-WQPHNVNY.js +51 -0
- package/dist/core-XXIOJY2X.js +52 -0
- package/dist/core-ZH7XTJTD.js +39 -0
- package/dist/core-ZHE7N4NS.js +50 -0
- package/dist/core-ZJYLJWZQ.js +38 -0
- package/dist/dataTable-IL7HVDHL.js +58 -0
- package/dist/engine-MYLZI5VH.js +961 -0
- package/dist/fixtures.d.ts +1 -0
- package/dist/fixtures.js +40 -0
- package/dist/fontTables-ZYBUCJ5N.js +18 -0
- package/dist/fonts.d.ts +1 -0
- package/dist/fonts.js +19 -0
- package/dist/geo/dach.d.ts +1 -0
- package/dist/geo/dach.js +14 -0
- package/dist/geo/de-states.d.ts +1 -0
- package/dist/geo/de-states.js +14 -0
- package/dist/geo/eu27.d.ts +1 -0
- package/dist/geo/eu27.js +14 -0
- package/dist/geo/europe.d.ts +1 -0
- package/dist/geo/europe.js +14 -0
- package/dist/geo/index.d.ts +1 -0
- package/dist/geo/index.js +41 -0
- package/dist/geo/us-states.d.ts +1 -0
- package/dist/geo/us-states.js +14 -0
- package/dist/geo/world.d.ts +1 -0
- package/dist/geo/world.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +363 -0
- package/dist/main-ISJ53IS5.js +568 -0
- package/dist/mcp/server.js +1023 -0
- package/dist/module-SVEW5ZUE.js +137233 -0
- package/dist/react/bar.d.ts +1 -0
- package/dist/react/bar.js +80 -0
- package/dist/react/bartable.d.ts +1 -0
- package/dist/react/bartable.js +70 -0
- package/dist/react/box.d.ts +1 -0
- package/dist/react/box.js +64 -0
- package/dist/react/bullet.d.ts +1 -0
- package/dist/react/bullet.js +71 -0
- package/dist/react/butterfly.d.ts +1 -0
- package/dist/react/butterfly.js +65 -0
- package/dist/react/choropleth.d.ts +1 -0
- package/dist/react/choropleth.js +67 -0
- package/dist/react/cohort.d.ts +1 -0
- package/dist/react/cohort.js +69 -0
- package/dist/react/column.d.ts +1 -0
- package/dist/react/column.js +85 -0
- package/dist/react/combo.d.ts +1 -0
- package/dist/react/combo.js +85 -0
- package/dist/react/creative.d.ts +1 -0
- package/dist/react/creative.js +61 -0
- package/dist/react/diagram.d.ts +1 -0
- package/dist/react/diagram.js +60 -0
- package/dist/react/dimswitch.d.ts +1 -0
- package/dist/react/dimswitch.js +71 -0
- package/dist/react/dot.d.ts +1 -0
- package/dist/react/dot.js +69 -0
- package/dist/react/export.d.ts +1 -0
- package/dist/react/export.js +657 -0
- package/dist/react/funnel.d.ts +1 -0
- package/dist/react/funnel.js +62 -0
- package/dist/react/gantt.d.ts +1 -0
- package/dist/react/gantt.js +62 -0
- package/dist/react/grid.d.ts +1 -0
- package/dist/react/grid.js +66 -0
- package/dist/react/heatmap.d.ts +1 -0
- package/dist/react/heatmap.js +67 -0
- package/dist/react/histogram.d.ts +1 -0
- package/dist/react/histogram.js +85 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +503 -0
- package/dist/react/kpi.d.ts +1 -0
- package/dist/react/kpi.js +67 -0
- package/dist/react/likert.d.ts +1 -0
- package/dist/react/likert.js +82 -0
- package/dist/react/line.d.ts +1 -0
- package/dist/react/line.js +80 -0
- package/dist/react/mekko.d.ts +1 -0
- package/dist/react/mekko.js +70 -0
- package/dist/react/pareto.d.ts +1 -0
- package/dist/react/pareto.js +89 -0
- package/dist/react/pie.d.ts +1 -0
- package/dist/react/pie.js +63 -0
- package/dist/react/prepare.d.ts +1 -0
- package/dist/react/prepare.js +277 -0
- package/dist/react/pvm.d.ts +1 -0
- package/dist/react/pvm.js +67 -0
- package/dist/react/pyramid.d.ts +1 -0
- package/dist/react/pyramid.js +66 -0
- package/dist/react/sankey.d.ts +1 -0
- package/dist/react/sankey.js +59 -0
- package/dist/react/scatter.d.ts +1 -0
- package/dist/react/scatter.js +62 -0
- package/dist/react/slope.d.ts +1 -0
- package/dist/react/slope.js +63 -0
- package/dist/react/sparkline.d.ts +1 -0
- package/dist/react/sparkline.js +59 -0
- package/dist/react/spec.d.ts +1 -0
- package/dist/react/spec.js +370 -0
- package/dist/react/status.d.ts +1 -0
- package/dist/react/status.js +64 -0
- package/dist/react/story.d.ts +1 -0
- package/dist/react/story.js +140 -0
- package/dist/react/table.d.ts +1 -0
- package/dist/react/table.js +68 -0
- package/dist/react/theme.d.ts +1 -0
- package/dist/react/theme.js +53 -0
- package/dist/react/tilemap.d.ts +1 -0
- package/dist/react/tilemap.js +66 -0
- package/dist/react/treemap.d.ts +1 -0
- package/dist/react/treemap.js +61 -0
- package/dist/react/variance.d.ts +1 -0
- package/dist/react/variance.js +64 -0
- package/dist/react/waffle.d.ts +1 -0
- package/dist/react/waffle.js +62 -0
- package/dist/react/waterfall.d.ts +1 -0
- package/dist/react/waterfall.js +67 -0
- package/dist/resvg-ZOVDIZTV.js +23 -0
- package/dist/rows.d.ts +1 -0
- package/dist/rows.js +23 -0
- package/dist/rowsModule-3Y4I3M3E.js +27 -0
- package/dist/schema-2BMZOHXI.js +22 -0
- package/dist/schema-2GUBWOBC.js +26 -0
- package/dist/schema-34ZELWRQ.js +25 -0
- package/dist/schema-3BHL2B76.js +22 -0
- package/dist/schema-4735XAZX.js +29 -0
- package/dist/schema-5YTNQ6JY.js +22 -0
- package/dist/schema-7J3NAIN2.js +27 -0
- package/dist/schema-AOJJ7JZB.js +22 -0
- package/dist/schema-CVMV4LRA.js +22 -0
- package/dist/schema-D3RCMN3T.js +22 -0
- package/dist/schema-E2ISJ65D.js +23 -0
- package/dist/schema-E6YOSOWB.js +28 -0
- package/dist/schema-EQQB43AY.js +22 -0
- package/dist/schema-EVLLL5UF.js +22 -0
- package/dist/schema-EYQ5IBLF.js +23 -0
- package/dist/schema-EYZVD73N.js +22 -0
- package/dist/schema-G4KFMQBL.js +22 -0
- package/dist/schema-GH7IKSOU.js +23 -0
- package/dist/schema-IF5N3J56.js +42 -0
- package/dist/schema-IG7JIR4H.js +23 -0
- package/dist/schema-JJYJOQTT.js +23 -0
- package/dist/schema-KFC4WYH4.js +32 -0
- package/dist/schema-L7263JMT.js +25 -0
- package/dist/schema-MEAFRXVH.js +53 -0
- package/dist/schema-P63S63GE.js +23 -0
- package/dist/schema-P7LJFJAJ.js +22 -0
- package/dist/schema-PA2MXYY4.js +23 -0
- package/dist/schema-PDZ6256H.js +23 -0
- package/dist/schema-PNC3Z7AH.js +25 -0
- package/dist/schema-QEVSIMGO.js +22 -0
- package/dist/schema-QJJPRRE7.js +22 -0
- package/dist/schema-S3EQKVOT.js +23 -0
- package/dist/schema-STGL44TL.js +22 -0
- package/dist/schema-T4NE2EAO.js +22 -0
- package/dist/schema-TQYTESG3.js +22 -0
- package/dist/schema-W376PAJG.js +22 -0
- package/dist/schema-XYYDUUHS.js +26 -0
- package/dist/specValidation-NVBIZMEE.js +48 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +24 -0
- package/dist/themeShapeRules-5C2463YH.js +11 -0
- package/dist/types/core/a11y/accessibility.d.ts +43 -0
- package/dist/types/core/a11y/recordsShared.d.ts +44 -0
- package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
- package/dist/types/core/a11y/types.d.ts +116 -0
- package/dist/types/core/annotate.d.ts +300 -0
- package/dist/types/core/annotateArms.d.ts +37 -0
- package/dist/types/core/annotateFields.d.ts +30 -0
- package/dist/types/core/annotateGapBracket.d.ts +66 -0
- package/dist/types/core/annotateLinks.d.ts +47 -0
- package/dist/types/core/annotateTargets.d.ts +90 -0
- package/dist/types/core/axis.d.ts +179 -0
- package/dist/types/core/bandSelect.d.ts +10 -0
- package/dist/types/core/bands.d.ts +14 -0
- package/dist/types/core/calendarLabels.d.ts +101 -0
- package/dist/types/core/charts/band/stacks.d.ts +155 -0
- package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
- package/dist/types/core/charts/bar/layout.d.ts +95 -0
- package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
- package/dist/types/core/charts/bartable/types.d.ts +192 -0
- package/dist/types/core/charts/box/fixtures.d.ts +12 -0
- package/dist/types/core/charts/box/types.d.ts +110 -0
- package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
- package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
- package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
- package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
- package/dist/types/core/charts/choropleth/types.d.ts +117 -0
- package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
- package/dist/types/core/charts/cohort/types.d.ts +165 -0
- package/dist/types/core/charts/column/anomaly.d.ts +204 -0
- package/dist/types/core/charts/column/fixtures.d.ts +12 -0
- package/dist/types/core/charts/column/layout.d.ts +116 -0
- package/dist/types/core/charts/column/model.d.ts +295 -0
- package/dist/types/core/charts/column/types.d.ts +56 -0
- package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
- package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
- package/dist/types/core/charts/combo/layout.d.ts +48 -0
- package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
- package/dist/types/core/charts/creative/types.d.ts +73 -0
- package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
- package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
- package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
- package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
- package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
- package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
- package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
- package/dist/types/core/charts/gantt/layout.d.ts +56 -0
- package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
- package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
- package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
- package/dist/types/core/charts/grid/normalize.d.ts +99 -0
- package/dist/types/core/charts/grid/schema.d.ts +168 -0
- package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
- package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
- package/dist/types/core/charts/histogram/types.d.ts +98 -0
- package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
- package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
- package/dist/types/core/charts/likert/layout.d.ts +111 -0
- package/dist/types/core/charts/line/fixtures.d.ts +16 -0
- package/dist/types/core/charts/line/types.d.ts +6 -0
- package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
- package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
- package/dist/types/core/charts/pareto/layout.d.ts +68 -0
- package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
- package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
- package/dist/types/core/charts/pvm/types.d.ts +118 -0
- package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
- package/dist/types/core/charts/pyramid/types.d.ts +92 -0
- package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
- package/dist/types/core/charts/sankey/types.d.ts +116 -0
- package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
- package/dist/types/core/charts/scatter/types.d.ts +58 -0
- package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
- package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
- package/dist/types/core/charts/status/fixtures.d.ts +8 -0
- package/dist/types/core/charts/status/layout.d.ts +71 -0
- package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
- package/dist/types/core/charts/table/fixtures.d.ts +7 -0
- package/dist/types/core/charts/table/resolve.d.ts +72 -0
- package/dist/types/core/charts/table/view.d.ts +156 -0
- package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
- package/dist/types/core/charts/tilemap/types.d.ts +94 -0
- package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
- package/dist/types/core/charts/treemap/types.d.ts +78 -0
- package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
- package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
- package/dist/types/core/charts/waffle/types.d.ts +117 -0
- package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
- package/dist/types/core/claims/browser.d.ts +49 -0
- package/dist/types/core/claims/manifest.d.ts +22 -0
- package/dist/types/core/dateFormat.d.ts +39 -0
- package/dist/types/core/deferred.d.ts +121 -0
- package/dist/types/core/diagnostics/describe.d.ts +149 -0
- package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
- package/dist/types/core/doc/bareChart.d.ts +2 -0
- package/dist/types/core/doc/diagnostics.d.ts +124 -0
- package/dist/types/core/doc/docExpand.d.ts +39 -0
- package/dist/types/core/doc/document.d.ts +43 -0
- package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
- package/dist/types/core/doc/specError.d.ts +6 -0
- package/dist/types/core/emptyData.d.ts +27 -0
- package/dist/types/core/eventLane.d.ts +208 -0
- package/dist/types/core/fontMetrics/index.d.ts +47 -0
- package/dist/types/core/fontMetrics/injected.d.ts +40 -0
- package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
- package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
- package/dist/types/core/footer.d.ts +59 -0
- package/dist/types/core/format.d.ts +149 -0
- package/dist/types/core/formatPrecision.d.ts +136 -0
- package/dist/types/core/formatSpec.d.ts +302 -0
- package/dist/types/core/frame.d.ts +583 -0
- package/dist/types/core/geo/packs/all.d.ts +7 -0
- package/dist/types/core/geo/packs/dach.d.ts +16 -0
- package/dist/types/core/geo/packs/de-states.d.ts +16 -0
- package/dist/types/core/geo/packs/eu27.d.ts +16 -0
- package/dist/types/core/geo/packs/europe.d.ts +16 -0
- package/dist/types/core/geo/packs/index.d.ts +22 -0
- package/dist/types/core/geo/packs/registry.d.ts +37 -0
- package/dist/types/core/geo/packs/us-states.d.ts +16 -0
- package/dist/types/core/geo/packs/world.d.ts +16 -0
- package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
- package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
- package/dist/types/core/geo/tiles/index.d.ts +8 -0
- package/dist/types/core/geo/tiles/types.d.ts +36 -0
- package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
- package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
- package/dist/types/core/geo/types.d.ts +146 -0
- package/dist/types/core/geometry.d.ts +102 -0
- package/dist/types/core/grid/sharedScale.d.ts +82 -0
- package/dist/types/core/icons.d.ts +227 -0
- package/dist/types/core/inputError.d.ts +14 -0
- package/dist/types/core/isoDate.d.ts +2 -0
- package/dist/types/core/isoTime.d.ts +7 -0
- package/dist/types/core/label/categoryRow.d.ts +332 -0
- package/dist/types/core/label/occupied.d.ts +41 -0
- package/dist/types/core/label/ownership.d.ts +83 -0
- package/dist/types/core/label/solver.d.ts +380 -0
- package/dist/types/core/label/tickRow.d.ts +78 -0
- package/dist/types/core/live/types.d.ts +50 -0
- package/dist/types/core/normalize/shared.d.ts +56 -0
- package/dist/types/core/notes.d.ts +174 -0
- package/dist/types/core/othersShade.d.ts +9 -0
- package/dist/types/core/periodYears.d.ts +9 -0
- package/dist/types/core/polyline.d.ts +11 -0
- package/dist/types/core/rangeRules.d.ts +19 -0
- package/dist/types/core/ratioTier.d.ts +120 -0
- package/dist/types/core/readerStrings.d.ts +13 -0
- package/dist/types/core/reading.d.ts +120 -0
- package/dist/types/core/registry.d.ts +178 -0
- package/dist/types/core/repaintGeometry.d.ts +19 -0
- package/dist/types/core/request.d.ts +124 -0
- package/dist/types/core/rows.d.ts +45 -0
- package/dist/types/core/scale.d.ts +106 -0
- package/dist/types/core/schema/capability.d.ts +229 -0
- package/dist/types/core/schema/namedColumns.d.ts +45 -0
- package/dist/types/core/schema/reference.d.ts +31 -0
- package/dist/types/core/schema/refusals.d.ts +45 -0
- package/dist/types/core/schema/unknownKeys.d.ts +45 -0
- package/dist/types/core/seriesIdentity.d.ts +120 -0
- package/dist/types/core/shareRounding.d.ts +49 -0
- package/dist/types/core/sizing.d.ts +330 -0
- package/dist/types/core/staticFooter.d.ts +6 -0
- package/dist/types/core/story.d.ts +41 -0
- package/dist/types/core/structureCounts.d.ts +10 -0
- package/dist/types/core/svg/renderSvg.d.ts +51 -0
- package/dist/types/core/target.d.ts +89 -0
- package/dist/types/core/text.d.ts +113 -0
- package/dist/types/core/theme.d.ts +478 -0
- package/dist/types/core/themeFields.d.ts +11 -0
- package/dist/types/core/themeRules.d.ts +111 -0
- package/dist/types/core/themeShape.d.ts +87 -0
- package/dist/types/core/themeValidate.d.ts +15 -0
- package/dist/types/core/timeAxis.d.ts +106 -0
- package/dist/types/core/types/annotations.d.ts +223 -0
- package/dist/types/core/types/cell.d.ts +82 -0
- package/dist/types/core/types/data.d.ts +309 -0
- package/dist/types/core/types/diagram.d.ts +234 -0
- package/dist/types/core/types/index.d.ts +8 -0
- package/dist/types/core/types/options.d.ts +1583 -0
- package/dist/types/core/types/scene.d.ts +990 -0
- package/dist/types/core/types/sizing.d.ts +51 -0
- package/dist/types/core/types/table.d.ts +873 -0
- package/dist/types/core/types/theme.d.ts +806 -0
- package/dist/types/core/zoom.d.ts +106 -0
- package/dist/types/fixtures/index.d.ts +40 -0
- package/dist/types/fixtures/registry.d.ts +15 -0
- package/dist/types/fonts.d.ts +10 -0
- package/dist/types/index.d.ts +70 -0
- package/dist/types/react/BoardplotTheme.d.ts +9 -0
- package/dist/types/react/DimSwitchChart.d.ts +36 -0
- package/dist/types/react/ScaleGroup.d.ts +31 -0
- package/dist/types/react/SceneRenderer.d.ts +23 -0
- package/dist/types/react/SizePlaceholder.d.ts +51 -0
- package/dist/types/react/StoryFrame.d.ts +42 -0
- package/dist/types/react/TableChart.d.ts +220 -0
- package/dist/types/react/a11ySurface.d.ts +20 -0
- package/dist/types/react/barrelCharts.d.ts +1023 -0
- package/dist/types/react/charts/bar.d.ts +28 -0
- package/dist/types/react/charts/bartable.d.ts +27 -0
- package/dist/types/react/charts/box.d.ts +27 -0
- package/dist/types/react/charts/bullet.d.ts +28 -0
- package/dist/types/react/charts/butterfly.d.ts +28 -0
- package/dist/types/react/charts/choropleth.d.ts +27 -0
- package/dist/types/react/charts/cohort.d.ts +52 -0
- package/dist/types/react/charts/column.d.ts +27 -0
- package/dist/types/react/charts/combo.d.ts +7 -0
- package/dist/types/react/charts/creative.d.ts +27 -0
- package/dist/types/react/charts/diagram.d.ts +162 -0
- package/dist/types/react/charts/dimswitch.d.ts +6 -0
- package/dist/types/react/charts/dot.d.ts +28 -0
- package/dist/types/react/charts/funnel.d.ts +28 -0
- package/dist/types/react/charts/gantt.d.ts +28 -0
- package/dist/types/react/charts/grid.d.ts +29 -0
- package/dist/types/react/charts/heatmap.d.ts +28 -0
- package/dist/types/react/charts/histogram.d.ts +27 -0
- package/dist/types/react/charts/kpi.d.ts +28 -0
- package/dist/types/react/charts/likert.d.ts +27 -0
- package/dist/types/react/charts/line.d.ts +28 -0
- package/dist/types/react/charts/mekko.d.ts +28 -0
- package/dist/types/react/charts/pareto.d.ts +28 -0
- package/dist/types/react/charts/pie.d.ts +28 -0
- package/dist/types/react/charts/pvm.d.ts +27 -0
- package/dist/types/react/charts/pyramid.d.ts +27 -0
- package/dist/types/react/charts/sankey.d.ts +27 -0
- package/dist/types/react/charts/scatter.d.ts +28 -0
- package/dist/types/react/charts/slope.d.ts +28 -0
- package/dist/types/react/charts/sparkline.d.ts +28 -0
- package/dist/types/react/charts/status.d.ts +27 -0
- package/dist/types/react/charts/table.d.ts +6 -0
- package/dist/types/react/charts/tilemap.d.ts +27 -0
- package/dist/types/react/charts/treemap.d.ts +27 -0
- package/dist/types/react/charts/variance.d.ts +28 -0
- package/dist/types/react/charts/waffle.d.ts +28 -0
- package/dist/types/react/charts/waterfall.d.ts +28 -0
- package/dist/types/react/createChartComponent.d.ts +135 -0
- package/dist/types/react/export/clipboard.d.ts +8 -0
- package/dist/types/react/export/csv.d.ts +2 -0
- package/dist/types/react/export/frame.d.ts +35 -0
- package/dist/types/react/export/index.d.ts +7 -0
- package/dist/types/react/export/png.d.ts +14 -0
- package/dist/types/react/export/svg.d.ts +5 -0
- package/dist/types/react/export/types.d.ts +69 -0
- package/dist/types/react/export/useExport.d.ts +17 -0
- package/dist/types/react/exportLink.d.ts +49 -0
- package/dist/types/react/footerFrame.d.ts +25 -0
- package/dist/types/react/hover/dataTable.d.ts +13 -0
- package/dist/types/react/hover/engine.d.ts +210 -0
- package/dist/types/react/hover/keyboard.d.ts +44 -0
- package/dist/types/react/hover/labelCard.d.ts +170 -0
- package/dist/types/react/hover/placement.d.ts +49 -0
- package/dist/types/react/index.d.ts +16 -0
- package/dist/types/react/parseChartSpec.d.ts +16 -0
- package/dist/types/react/prepare.d.ts +32 -0
- package/dist/types/react/prepared.d.ts +53 -0
- package/dist/types/react/preparedTable.d.ts +15 -0
- package/dist/types/react/rowsInput.d.ts +55 -0
- package/dist/types/react/rowsModule.d.ts +18 -0
- package/dist/types/react/rowsStore.d.ts +50 -0
- package/dist/types/react/scale-group.d.ts +2 -0
- package/dist/types/react/scaleGroupContext.d.ts +22 -0
- package/dist/types/react/scenePaint.d.ts +10 -0
- package/dist/types/react/scrollState.d.ts +26 -0
- package/dist/types/react/spec.d.ts +65 -0
- package/dist/types/react/specValidation.d.ts +45 -0
- package/dist/types/react/story.d.ts +15 -0
- package/dist/types/react/theme.d.ts +9 -0
- package/dist/types/react/themeContext.d.ts +44 -0
- package/dist/types/react/useChartLayout.d.ts +22 -0
- package/dist/types/react/useContainerSize.d.ts +57 -0
- package/dist/types/react/useHover.d.ts +100 -0
- package/dist/types/react/useZoom.d.ts +50 -0
- package/dist/types/rows.d.ts +58 -0
- package/dist/types/tableLooks.d.ts +6 -0
- package/dist/types/theme.d.ts +3 -0
- package/dist/types/validate.d.ts +3 -0
- package/dist/validate.d.ts +1 -0
- package/dist/validate.js +222 -0
- package/docs/FONTS.md +68 -0
- package/docs/TELEMETRY.md +94 -0
- package/docs/manual.md +838 -0
- package/docs/reference/bar.md +222 -0
- package/docs/reference/bartable.md +143 -0
- package/docs/reference/box.md +93 -0
- package/docs/reference/bullet.md +118 -0
- package/docs/reference/butterfly.md +117 -0
- package/docs/reference/choropleth.md +148 -0
- package/docs/reference/cohort.md +149 -0
- package/docs/reference/column.md +275 -0
- package/docs/reference/combo.md +219 -0
- package/docs/reference/creative.md +147 -0
- package/docs/reference/diagram.md +191 -0
- package/docs/reference/dimswitch.md +1395 -0
- package/docs/reference/dot.md +117 -0
- package/docs/reference/fixtures.md +1088 -0
- package/docs/reference/funnel.md +121 -0
- package/docs/reference/gantt.md +132 -0
- package/docs/reference/grid.md +302 -0
- package/docs/reference/heatmap.md +127 -0
- package/docs/reference/histogram.md +77 -0
- package/docs/reference/kpi.md +115 -0
- package/docs/reference/likert.md +113 -0
- package/docs/reference/line.md +436 -0
- package/docs/reference/mekko.md +114 -0
- package/docs/reference/options.md +313 -0
- package/docs/reference/pareto.md +102 -0
- package/docs/reference/pie.md +114 -0
- package/docs/reference/pvm.md +114 -0
- package/docs/reference/pyramid.md +99 -0
- package/docs/reference/react.md +703 -0
- package/docs/reference/reading.md +28 -0
- package/docs/reference/sankey.md +110 -0
- package/docs/reference/scatter.md +211 -0
- package/docs/reference/slope.md +126 -0
- package/docs/reference/sparkline.md +74 -0
- package/docs/reference/status.md +107 -0
- package/docs/reference/table.md +673 -0
- package/docs/reference/theme.md +361 -0
- package/docs/reference/tilemap.md +121 -0
- package/docs/reference/treemap.md +86 -0
- package/docs/reference/variance.md +126 -0
- package/docs/reference/waffle.md +106 -0
- package/docs/reference/waterfall.md +164 -0
- package/llms.txt +57 -0
- package/package.json +437 -4
|
@@ -0,0 +1,3303 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chartPalette,
|
|
3
|
+
chartTheme
|
|
4
|
+
} from "./chunk-SXGTRZFN.js";
|
|
5
|
+
import {
|
|
6
|
+
diagramKindError
|
|
7
|
+
} from "./chunk-JFBEAUJ6.js";
|
|
8
|
+
import {
|
|
9
|
+
compileIcon
|
|
10
|
+
} from "./chunk-BUPLB3EX.js";
|
|
11
|
+
import {
|
|
12
|
+
rowDrivenHeight
|
|
13
|
+
} from "./chunk-COYPDRJK.js";
|
|
14
|
+
import {
|
|
15
|
+
structureCount
|
|
16
|
+
} from "./chunk-B2EBEXIS.js";
|
|
17
|
+
import {
|
|
18
|
+
CARD_MIN_WIDTH,
|
|
19
|
+
chartSizing,
|
|
20
|
+
contentSizing,
|
|
21
|
+
resolveSizing,
|
|
22
|
+
sizeRefusal
|
|
23
|
+
} from "./chunk-GQPESFAF.js";
|
|
24
|
+
import {
|
|
25
|
+
PRIORITY,
|
|
26
|
+
boundsOf,
|
|
27
|
+
clamp,
|
|
28
|
+
createOccupiedIndex,
|
|
29
|
+
fitText,
|
|
30
|
+
frameTextOptions,
|
|
31
|
+
inflate,
|
|
32
|
+
labelCtx,
|
|
33
|
+
labelsToNodes,
|
|
34
|
+
rectCenter,
|
|
35
|
+
rectContains,
|
|
36
|
+
rectsOverlap,
|
|
37
|
+
solveFrame,
|
|
38
|
+
solveLabels
|
|
39
|
+
} from "./chunk-2JAWQ7VV.js";
|
|
40
|
+
import {
|
|
41
|
+
chartStrings
|
|
42
|
+
} from "./chunk-YQ2B3YVF.js";
|
|
43
|
+
import {
|
|
44
|
+
canvasMargin,
|
|
45
|
+
contrastInkPaint,
|
|
46
|
+
dashToken,
|
|
47
|
+
emphasisWeight,
|
|
48
|
+
headingWeight,
|
|
49
|
+
markRolePaint,
|
|
50
|
+
paintColor,
|
|
51
|
+
panelTypeClass,
|
|
52
|
+
resolveSurface,
|
|
53
|
+
resolveTheme,
|
|
54
|
+
seriesPaint,
|
|
55
|
+
strokeToken,
|
|
56
|
+
themeForWidth
|
|
57
|
+
} from "./chunk-II7652VA.js";
|
|
58
|
+
import {
|
|
59
|
+
monotonePath,
|
|
60
|
+
monotoneSegments
|
|
61
|
+
} from "./chunk-WLZ54FWG.js";
|
|
62
|
+
import {
|
|
63
|
+
NormalizeError,
|
|
64
|
+
TARGET_SIZE,
|
|
65
|
+
accessibleTitle,
|
|
66
|
+
resolveSize
|
|
67
|
+
} from "./chunk-SGD3ZHID.js";
|
|
68
|
+
import {
|
|
69
|
+
maxOf,
|
|
70
|
+
minOf,
|
|
71
|
+
pushAll
|
|
72
|
+
} from "./chunk-WYJEOMNY.js";
|
|
73
|
+
import {
|
|
74
|
+
compareText,
|
|
75
|
+
defaultMeasurer,
|
|
76
|
+
wrapText
|
|
77
|
+
} from "./chunk-TXINIAFL.js";
|
|
78
|
+
|
|
79
|
+
// src/core/strings/diagram.ts
|
|
80
|
+
var EN = {
|
|
81
|
+
// reader-facing wording linked only by its consumers.
|
|
82
|
+
category: "Category",
|
|
83
|
+
group: "Group",
|
|
84
|
+
position: "Position",
|
|
85
|
+
diagramTitle: "{v1} diagram",
|
|
86
|
+
diagramDesc: "{v1} diagram with {v2} nodes and {v3} relationships.",
|
|
87
|
+
readingOrder: "Reading order: {v1}.",
|
|
88
|
+
relationshipsSentence: "Relationships: {v1}.",
|
|
89
|
+
groupsSentence: "Groups: {v1}.",
|
|
90
|
+
lanesSentence: "Lanes: {v1}.",
|
|
91
|
+
top: "top",
|
|
92
|
+
left: "left",
|
|
93
|
+
right: "right",
|
|
94
|
+
milestone: "Milestone",
|
|
95
|
+
containsMembers: "{v1} contains {v2}",
|
|
96
|
+
noNodes: "no nodes",
|
|
97
|
+
diagramHierarchy: "hierarchy",
|
|
98
|
+
diagramIssueTree: "issue-tree",
|
|
99
|
+
diagramLinearProcess: "linear-process",
|
|
100
|
+
diagramCustomerJourney: "customer-journey",
|
|
101
|
+
diagramCircularProcess: "circular-process",
|
|
102
|
+
diagramStrategyHouse: "strategy-house",
|
|
103
|
+
diagramRoadmap: "roadmap"
|
|
104
|
+
}, DE = {
|
|
105
|
+
// reader-facing wording linked only by its consumers.
|
|
106
|
+
category: "Kategorie",
|
|
107
|
+
group: "Gruppe",
|
|
108
|
+
position: "Position",
|
|
109
|
+
diagramTitle: "Diagramm: {v1}",
|
|
110
|
+
diagramDesc: "Diagramm: {v1} mit {v2} Knoten und {v3} {v3|Beziehung|Beziehungen}.",
|
|
111
|
+
readingOrder: "Lesereihenfolge: {v1}.",
|
|
112
|
+
relationshipsSentence: "Beziehungen: {v1}.",
|
|
113
|
+
groupsSentence: "Gruppen: {v1}.",
|
|
114
|
+
lanesSentence: "Bahnen: {v1}.",
|
|
115
|
+
top: "oben",
|
|
116
|
+
left: "links",
|
|
117
|
+
right: "rechts",
|
|
118
|
+
milestone: "Meilenstein",
|
|
119
|
+
containsMembers: "{v1} enth\xE4lt {v2}",
|
|
120
|
+
noNodes: "keine Knoten",
|
|
121
|
+
diagramHierarchy: "Hierarchie",
|
|
122
|
+
diagramIssueTree: "Problembaum",
|
|
123
|
+
diagramLinearProcess: "Linearer Ablauf",
|
|
124
|
+
diagramCustomerJourney: "Kundenablauf",
|
|
125
|
+
diagramCircularProcess: "Kreisprozess",
|
|
126
|
+
diagramStrategyHouse: "Strategiehaus",
|
|
127
|
+
diagramRoadmap: "Zeitplan"
|
|
128
|
+
}, { chartString } = chartStrings(EN, DE);
|
|
129
|
+
|
|
130
|
+
// src/core/charts/diagram/ids.ts
|
|
131
|
+
var encodePart = (value) => {
|
|
132
|
+
let encoded = encodeURIComponent(value);
|
|
133
|
+
return `${encoded.length}:${encoded}`;
|
|
134
|
+
};
|
|
135
|
+
function diagramSceneId(namespace, ...parts) {
|
|
136
|
+
return [namespace, ...parts].map(encodePart).join("|");
|
|
137
|
+
}
|
|
138
|
+
function automaticEdgeId(preset, index, source, target) {
|
|
139
|
+
return `auto:${diagramSceneId(preset, String(index), source, target)}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/core/charts/diagram/model.ts
|
|
143
|
+
var stableOrder = (items) => items.map((item, sourceIndex) => ({ item, sourceIndex })).sort(
|
|
144
|
+
(a, b) => (a.item.order ?? a.sourceIndex) - (b.item.order ?? b.sourceIndex) || compareText(a.item.id, b.item.id)
|
|
145
|
+
).map(({ item }) => item);
|
|
146
|
+
function normalizeDiagramModel(rawData, rawOptions) {
|
|
147
|
+
if (!Array.isArray(rawData.nodes) || rawData.nodes.length === 0) throw new NormalizeError("empty-data", "nodes", "diagram requires at least one node");
|
|
148
|
+
let data = {
|
|
149
|
+
// Presets can add generated ports; keep those on layout-owned nodes.
|
|
150
|
+
nodes: stableOrder(rawData.nodes).map((node) => ({ ...node })),
|
|
151
|
+
edges: [...rawData.edges ?? []].sort((a, b) => compareText(a.id, b.id)),
|
|
152
|
+
groups: stableOrder(rawData.groups ?? []),
|
|
153
|
+
lanes: stableOrder(rawData.lanes ?? []),
|
|
154
|
+
key: rawData.key ?? []
|
|
155
|
+
};
|
|
156
|
+
return validatePreset(data, rawOptions, rawData.nodes), { data, options: rawOptions };
|
|
157
|
+
}
|
|
158
|
+
function validatePreset(data, options, authoredNodes) {
|
|
159
|
+
let membership = data.nodes.filter((node) => node.groupId || node.laneId), requireKinds = () => {
|
|
160
|
+
let error = diagramKindError(authoredNodes, options);
|
|
161
|
+
if (error) throw error;
|
|
162
|
+
};
|
|
163
|
+
if (options.variant === "customer-journey" || options.variant === "roadmap") {
|
|
164
|
+
if (data.groups.length > 0 || data.nodes.some((node) => node.groupId))
|
|
165
|
+
throw new NormalizeError(
|
|
166
|
+
"invalid-membership",
|
|
167
|
+
"groups",
|
|
168
|
+
`variant '${options.variant}' reads lane membership, not groups`
|
|
169
|
+
);
|
|
170
|
+
if (data.lanes.length === 0 || data.lanes.some((lane) => lane.orientation !== "vertical"))
|
|
171
|
+
throw new NormalizeError(
|
|
172
|
+
"invalid-membership",
|
|
173
|
+
"lanes",
|
|
174
|
+
`variant '${options.variant}' requires vertical lanes`
|
|
175
|
+
);
|
|
176
|
+
let member = data.nodes.find((node) => !node.laneId);
|
|
177
|
+
if (member)
|
|
178
|
+
throw new NormalizeError(
|
|
179
|
+
"invalid-membership",
|
|
180
|
+
`nodes[${member.id}].laneId`,
|
|
181
|
+
`variant '${options.variant}' requires every node to name its phase lane`
|
|
182
|
+
);
|
|
183
|
+
if (requireKinds(), options.variant === "roadmap" && !data.nodes.some((node) => node.kind === "milestone"))
|
|
184
|
+
throw new NormalizeError("invalid-roadmap", "nodes", "roadmap requires at least one milestone");
|
|
185
|
+
validateMonotonePins(data, options);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (options.variant === "strategy-house") {
|
|
189
|
+
if (data.lanes.length > 0 || data.nodes.some((node) => node.laneId))
|
|
190
|
+
throw new NormalizeError("invalid-membership", "lanes", "variant 'strategy-house' reads groups, not lanes");
|
|
191
|
+
let vision = data.nodes.filter((node) => node.kind === "vision"), foundation = data.nodes.filter((node) => node.kind === "foundation");
|
|
192
|
+
if (vision.length !== 1 || vision[0].shape.kind !== "roof")
|
|
193
|
+
throw new NormalizeError("invalid-strategy-house", "nodes", "strategy-house requires exactly one roof-shaped vision");
|
|
194
|
+
if (foundation.length !== 1)
|
|
195
|
+
throw new NormalizeError("invalid-strategy-house", "nodes", "strategy-house requires exactly one foundation");
|
|
196
|
+
if (!data.nodes.some((node) => node.kind === "initiative") || !data.nodes.some((node) => node.kind === "enabler"))
|
|
197
|
+
throw new NormalizeError("invalid-strategy-house", "nodes", "strategy-house requires initiatives and enablers");
|
|
198
|
+
if (data.groups.length === 0)
|
|
199
|
+
throw new NormalizeError("invalid-strategy-house", "groups", "strategy-house requires objective groups");
|
|
200
|
+
let invalid = data.nodes.find(
|
|
201
|
+
(node) => node.kind === "initiative" && (!node.groupId || !data.groups.some((group) => group.id === node.groupId))
|
|
202
|
+
);
|
|
203
|
+
if (invalid)
|
|
204
|
+
throw new NormalizeError(
|
|
205
|
+
"invalid-membership",
|
|
206
|
+
`nodes[${invalid.id}].groupId`,
|
|
207
|
+
"strategy-house initiatives require an objective group"
|
|
208
|
+
);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (options.variant !== "hierarchy" && membership.length > 0)
|
|
212
|
+
throw new NormalizeError(
|
|
213
|
+
"invalid-membership",
|
|
214
|
+
`nodes[${membership[0].id}]`,
|
|
215
|
+
`variant '${options.variant}' does not read group or lane membership`
|
|
216
|
+
);
|
|
217
|
+
if (data.lanes.length > 0 || options.variant !== "hierarchy" && data.groups.length > 0)
|
|
218
|
+
throw new NormalizeError(
|
|
219
|
+
"invalid-membership",
|
|
220
|
+
options.variant === "hierarchy" ? "lanes" : "groups",
|
|
221
|
+
`variant '${options.variant}' does not read this membership surface`
|
|
222
|
+
);
|
|
223
|
+
requireKinds(), (options.variant === "hierarchy" || options.variant === "issue-tree") && validateRootedDag(data, options.variant);
|
|
224
|
+
}
|
|
225
|
+
function validateRootedDag(data, variant) {
|
|
226
|
+
if (data.nodes.length === 1 && data.edges.length === 0) return;
|
|
227
|
+
let nodeIds = new Set(data.nodes.map((node) => node.id)), primary = data.edges.filter((edge) => edge.dash !== "dotted"), incoming = new Map(data.nodes.map((node) => [node.id, 0]));
|
|
228
|
+
primary.forEach((edge) => incoming.set(edge.target.nodeId, incoming.get(edge.target.nodeId) + 1));
|
|
229
|
+
let roots = [...incoming].filter(([, count]) => count === 0).map(([id]) => id), outgoing = /* @__PURE__ */ new Map();
|
|
230
|
+
primary.forEach((edge) => {
|
|
231
|
+
let targets = outgoing.get(edge.source.nodeId) ?? [];
|
|
232
|
+
targets.push(edge.target.nodeId), outgoing.set(edge.source.nodeId, targets);
|
|
233
|
+
});
|
|
234
|
+
let path = [], visited = /* @__PURE__ */ new Set(), visit = (id) => {
|
|
235
|
+
let at = path.indexOf(id);
|
|
236
|
+
if (at >= 0)
|
|
237
|
+
throw new NormalizeError(
|
|
238
|
+
"diagram-cycle",
|
|
239
|
+
"edges",
|
|
240
|
+
`${variant} primary graph contains a cycle: ${[...path.slice(at), id].join(" \u2192 ")}`,
|
|
241
|
+
"remove or dot (dash: dotted) one edge of the loop"
|
|
242
|
+
);
|
|
243
|
+
if (!visited.has(id)) {
|
|
244
|
+
path.push(id);
|
|
245
|
+
for (let target of (outgoing.get(id) ?? []).sort(compareText)) visit(target);
|
|
246
|
+
path.pop(), visited.add(id);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
if (roots.length === 0 && [...nodeIds].sort(compareText).forEach(visit), roots.length !== 1)
|
|
250
|
+
throw new NormalizeError("invalid-root", "edges", `${variant} requires one primary root, found ${roots.length}`);
|
|
251
|
+
if (visit(roots[0]), visited.size !== nodeIds.size)
|
|
252
|
+
throw new NormalizeError("invalid-root", "edges", `${variant} primary graph is disconnected`);
|
|
253
|
+
}
|
|
254
|
+
function validateMonotonePins(data, options) {
|
|
255
|
+
if (options.variant !== "roadmap") return;
|
|
256
|
+
let laneOrder = new Map(data.lanes.map((lane, index) => [lane.id, index])), pinned = data.nodes.filter((node) => node.kind === "milestone" && node.position).sort(
|
|
257
|
+
(a, b) => (laneOrder.get(a.laneId) ?? 0) - (laneOrder.get(b.laneId) ?? 0) || (a.order ?? 0) - (b.order ?? 0) || compareText(a.id, b.id)
|
|
258
|
+
);
|
|
259
|
+
for (let index = 1; index < pinned.length; index++) {
|
|
260
|
+
let previous = pinned[index - 1].position, current = pinned[index].position;
|
|
261
|
+
if (current.x <= previous.x || current.y > previous.y)
|
|
262
|
+
throw new NormalizeError(
|
|
263
|
+
"non-monotone-roadmap",
|
|
264
|
+
`nodes[${pinned[index].id}].position`,
|
|
265
|
+
"authored roadmap milestone positions must increase in x and rise monotonically"
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/core/charts/diagram/primitives.ts
|
|
271
|
+
var q = (value) => Math.round(value * 2) / 2, qPoint = (point) => ({ x: q(point.x), y: q(point.y) }), qRect = (rect) => ({
|
|
272
|
+
x: q(rect.x),
|
|
273
|
+
y: q(rect.y),
|
|
274
|
+
w: q(rect.w),
|
|
275
|
+
h: q(rect.h)
|
|
276
|
+
}), nodeOwner = (id) => ({ pointId: id }), edgeOwner = (id) => ({ segmentId: id }), groupOwner = (id) => ({ seriesId: id }), laneOwner = (id) => ({ categoryId: id });
|
|
277
|
+
function createDiagramPalette(theme, keys, paletteName, sharedKeys = /* @__PURE__ */ new Set(), trailingKeys = []) {
|
|
278
|
+
let sorted = [...new Set(keys)].sort(), trailing = [...new Set(trailingKeys)].filter((key) => !sorted.includes(key)).sort(), ranks = new Map([...sorted, ...trailing].map((key, index) => [key, index])), resolveDiagramPaint = (role, paletteKey) => {
|
|
279
|
+
switch (role ?? "primary") {
|
|
280
|
+
case "accent":
|
|
281
|
+
return { token: "focus" };
|
|
282
|
+
case "secondary":
|
|
283
|
+
return { token: "neutralLight" };
|
|
284
|
+
case "muted":
|
|
285
|
+
return { token: "neutralLight", tint: 0.55 };
|
|
286
|
+
case "good":
|
|
287
|
+
return { token: "good" };
|
|
288
|
+
case "bad":
|
|
289
|
+
return { token: "bad" };
|
|
290
|
+
case "warn":
|
|
291
|
+
return { token: "warn" };
|
|
292
|
+
case "category":
|
|
293
|
+
return seriesPaint(ranks.get(paletteKey ?? "") ?? 0, paletteName);
|
|
294
|
+
default:
|
|
295
|
+
return paletteName === void 0 ? { token: "series-1" } : seriesPaint(0, paletteName);
|
|
296
|
+
}
|
|
297
|
+
}, css = (role, paletteKey) => paintColor(theme, resolveDiagramPaint(role, paletteKey)), primary = resolveDiagramPaint("primary"), phase = {
|
|
298
|
+
token: "token" in primary ? primary.token : "series-1",
|
|
299
|
+
theme: { kind: "visible-tint", base: primary, amount: 0.8, floor: 1.3, roundStep: !0 }
|
|
300
|
+
}, fill = (role, paletteKey) => role === "good" || role === "bad" || role === "warn" ? markRolePaint(role, !0) : resolveDiagramPaint(role, paletteKey);
|
|
301
|
+
return { paint: resolveDiagramPaint, css, lane: (role, paletteKey) => (role ?? "primary") === "primary" || role === "category" && !sharedKeys.has(paletteKey ?? "") ? phase : fill(role, paletteKey), fill };
|
|
302
|
+
}
|
|
303
|
+
var PANEL_ROLES = /* @__PURE__ */ new Set(["primary", "secondary", "muted"]);
|
|
304
|
+
function nodeFillPaint(node, palette, theme) {
|
|
305
|
+
return node.shape.kind === "text" ? { token: "background" } : node.kind === "painPoint" && node.role === void 0 ? { token: "neutralLight" } : theme?.marks?.nodeFill === "panel" && PANEL_ROLES.has(node.role ?? "primary") ? { token: "background" } : palette.fill(node.role, node.paletteKey);
|
|
306
|
+
}
|
|
307
|
+
function nodeFillCss(node, palette, theme) {
|
|
308
|
+
return paintColor(theme, nodeFillPaint(node, palette, theme));
|
|
309
|
+
}
|
|
310
|
+
function nodeRing(theme, role) {
|
|
311
|
+
return {
|
|
312
|
+
stroke: { token: theme.marks?.nodeStroke ?? (role === "muted" ? "grid" : "axis") },
|
|
313
|
+
width: theme.marks?.nodeStrokeWidth ?? strokeToken(theme, "hair")
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function measuredNodeSize(node, textWidth, lineHeight, u) {
|
|
317
|
+
let iconReserve = node.icon || node.shape.kind === "icon" ? 4.5 * u : 0, secondary = node.secondaryLabel ? 2 * lineHeight + u : 0, base = {
|
|
318
|
+
width: Math.max(10 * u, textWidth + 4 * u, iconReserve + 4 * u),
|
|
319
|
+
height: Math.max(7 * u, lineHeight + secondary + iconReserve + 3 * u)
|
|
320
|
+
}, lower = node.minSize ? {
|
|
321
|
+
width: Math.max(base.width, node.minSize.width),
|
|
322
|
+
height: Math.max(base.height, node.minSize.height)
|
|
323
|
+
} : base;
|
|
324
|
+
return node.size ? { width: Math.max(node.size.width, lower.width), height: Math.max(node.size.height, lower.height) } : lower;
|
|
325
|
+
}
|
|
326
|
+
function nodeRadius(theme) {
|
|
327
|
+
return theme.marks?.nodeRadius ?? resolveSurface(theme).chipRadius;
|
|
328
|
+
}
|
|
329
|
+
function nodeShapeScene(node, resolved, palette, theme, org) {
|
|
330
|
+
let { rect } = resolved, owner = nodeOwner(node.id), fill = org?.fill ?? nodeFillPaint(node, palette, theme), ring = org?.ringPaint ?? nodeRing(theme, node.role), bare = org !== void 0 && !org.ring && !org.ringPaint, stroke = bare ? void 0 : ring.stroke, ringWidth = bare ? void 0 : ring.width, id = diagramSceneId("node", node.id), out = [], common = {
|
|
331
|
+
id,
|
|
332
|
+
owner,
|
|
333
|
+
part: "diagramNode",
|
|
334
|
+
display: { value: node.label, state: node.kind }
|
|
335
|
+
};
|
|
336
|
+
switch (node.shape.kind) {
|
|
337
|
+
case "circle": {
|
|
338
|
+
out.push({
|
|
339
|
+
t: "circle",
|
|
340
|
+
...common,
|
|
341
|
+
cx: q(rect.x + rect.w / 2),
|
|
342
|
+
cy: q(rect.y + rect.h / 2),
|
|
343
|
+
r: q(Math.min(rect.w, rect.h) / 2),
|
|
344
|
+
fill,
|
|
345
|
+
stroke,
|
|
346
|
+
strokeWidth: ringWidth
|
|
347
|
+
});
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
case "pill":
|
|
351
|
+
out.push({ t: "rect", ...common, rect, fill, stroke, strokeWidth: ringWidth, radius: q(rect.h / 2) });
|
|
352
|
+
break;
|
|
353
|
+
case "roundedRect":
|
|
354
|
+
if (node.kind === "painPoint" && node.role === void 0 && !org?.plainShape) {
|
|
355
|
+
let radius = q(node.shape.radius ?? nodeRadius(theme));
|
|
356
|
+
out.push({
|
|
357
|
+
t: "path",
|
|
358
|
+
...common,
|
|
359
|
+
d: roundedRectPath(rect, radius),
|
|
360
|
+
fill,
|
|
361
|
+
stroke,
|
|
362
|
+
width: ringWidth,
|
|
363
|
+
dash: dashToken(theme, "reference")
|
|
364
|
+
}), out.push({
|
|
365
|
+
t: "line",
|
|
366
|
+
id: diagramSceneId("node", node.id, "accent"),
|
|
367
|
+
x1: q(rect.x),
|
|
368
|
+
y1: q(rect.y + radius),
|
|
369
|
+
x2: q(rect.x),
|
|
370
|
+
y2: q(rect.y + rect.h - radius),
|
|
371
|
+
stroke: { token: "bad" },
|
|
372
|
+
width: strokeToken(theme, "mark"),
|
|
373
|
+
lineCap: "round",
|
|
374
|
+
owner,
|
|
375
|
+
part: "diagramPainAccent"
|
|
376
|
+
});
|
|
377
|
+
} else
|
|
378
|
+
out.push({
|
|
379
|
+
t: "rect",
|
|
380
|
+
...common,
|
|
381
|
+
rect,
|
|
382
|
+
fill,
|
|
383
|
+
stroke,
|
|
384
|
+
strokeWidth: ringWidth,
|
|
385
|
+
radius: q(node.shape.radius ?? nodeRadius(theme))
|
|
386
|
+
});
|
|
387
|
+
break;
|
|
388
|
+
case "chevron": {
|
|
389
|
+
let tip = q(Math.min(rect.w * (node.shape.tip ?? 0.16), rect.h));
|
|
390
|
+
out.push({
|
|
391
|
+
t: "path",
|
|
392
|
+
...common,
|
|
393
|
+
d: org?.d ?? chevronPath(rect, tip),
|
|
394
|
+
fill,
|
|
395
|
+
stroke,
|
|
396
|
+
width: ringWidth
|
|
397
|
+
});
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
case "roof": {
|
|
401
|
+
let apex = node.shape.apex ?? 0.5, inset = node.shape.eaveInset ?? 0;
|
|
402
|
+
out.push({
|
|
403
|
+
t: "path",
|
|
404
|
+
...common,
|
|
405
|
+
d: `M${q(rect.x + inset * rect.w)} ${q(rect.y + rect.h)}L${q(rect.x + apex * rect.w)} ${q(rect.y)}L${q(rect.x + rect.w - inset * rect.w)} ${q(rect.y + rect.h)}Z`,
|
|
406
|
+
fill,
|
|
407
|
+
stroke,
|
|
408
|
+
width: ringWidth
|
|
409
|
+
});
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
case "text":
|
|
413
|
+
out.push({
|
|
414
|
+
t: "rect",
|
|
415
|
+
...common,
|
|
416
|
+
rect,
|
|
417
|
+
fill: { token: "background" },
|
|
418
|
+
owner,
|
|
419
|
+
part: "diagramTextReserve"
|
|
420
|
+
});
|
|
421
|
+
break;
|
|
422
|
+
default:
|
|
423
|
+
out.push({ t: "rect", ...common, rect, fill, stroke, strokeWidth: ringWidth });
|
|
424
|
+
}
|
|
425
|
+
let icon = node.icon ?? (node.shape.kind === "icon" ? node.shape.name : void 0);
|
|
426
|
+
if (icon) {
|
|
427
|
+
let lineHeight = theme.type.label.size * (theme.type.label.lineHeight ?? 1.2), centredCircle = node.kind === "step" && node.shape.kind === "circle", size = q(
|
|
428
|
+
Math.min(
|
|
429
|
+
Math.max(1, rect.w - 4 * theme.space.labelPad),
|
|
430
|
+
centredCircle ? rect.h * 0.62 : rect.h * 0.42,
|
|
431
|
+
2.5 * lineHeight
|
|
432
|
+
)
|
|
433
|
+
), box = org?.iconBox ? qRect(org.iconBox) : {
|
|
434
|
+
x: q(rect.x + (rect.w - size) / 2),
|
|
435
|
+
y: q(
|
|
436
|
+
centredCircle ? rect.y + (rect.h - size) / 2 : rect.y + theme.space.labelPad
|
|
437
|
+
),
|
|
438
|
+
w: size,
|
|
439
|
+
h: size
|
|
440
|
+
}, width = strokeToken(theme, "rule"), iconInk = contrastInkPaint(fill);
|
|
441
|
+
compileIcon(icon, box).forEach((primitive, index) => {
|
|
442
|
+
let primitiveId = diagramSceneId("icon", node.id, String(index));
|
|
443
|
+
primitive.kind === "circle" ? out.push({
|
|
444
|
+
t: "circle",
|
|
445
|
+
id: primitiveId,
|
|
446
|
+
cx: primitive.cx,
|
|
447
|
+
cy: primitive.cy,
|
|
448
|
+
r: primitive.r,
|
|
449
|
+
fill,
|
|
450
|
+
stroke: iconInk,
|
|
451
|
+
strokeWidth: strokeToken(theme, "rule"),
|
|
452
|
+
owner,
|
|
453
|
+
part: "diagramIcon"
|
|
454
|
+
}) : out.push({
|
|
455
|
+
t: "path",
|
|
456
|
+
id: primitiveId,
|
|
457
|
+
d: primitive.d,
|
|
458
|
+
stroke: iconInk,
|
|
459
|
+
width,
|
|
460
|
+
lineCap: "round",
|
|
461
|
+
owner,
|
|
462
|
+
part: "diagramIcon"
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
return out;
|
|
467
|
+
}
|
|
468
|
+
function roundedRectPath(rect, radius) {
|
|
469
|
+
let r = q(Math.min(radius, rect.w / 2, rect.h / 2));
|
|
470
|
+
return `M${q(rect.x + r)} ${q(rect.y)}L${q(rect.x + rect.w - r)} ${q(rect.y)}Q${q(rect.x + rect.w)} ${q(rect.y)} ${q(rect.x + rect.w)} ${q(rect.y + r)}L${q(rect.x + rect.w)} ${q(rect.y + rect.h - r)}Q${q(rect.x + rect.w)} ${q(rect.y + rect.h)} ${q(rect.x + rect.w - r)} ${q(rect.y + rect.h)}L${q(rect.x + r)} ${q(rect.y + rect.h)}Q${q(rect.x)} ${q(rect.y + rect.h)} ${q(rect.x)} ${q(rect.y + rect.h - r)}L${q(rect.x)} ${q(rect.y + r)}Q${q(rect.x)} ${q(rect.y)} ${q(rect.x + r)} ${q(rect.y)}Z`;
|
|
471
|
+
}
|
|
472
|
+
function chevronPath(rect, tip, leftward = !1) {
|
|
473
|
+
let notch = Math.min(tip * 0.7, rect.w / 5), x = (dx) => q(leftward ? rect.x + rect.w - dx : rect.x + dx);
|
|
474
|
+
return `M${x(0)} ${q(rect.y)}L${x(rect.w - tip)} ${q(rect.y)}L${x(rect.w)} ${q(rect.y + rect.h / 2)}L${x(rect.w - tip)} ${q(rect.y + rect.h)}L${x(0)} ${q(rect.y + rect.h)}L${x(notch)} ${q(rect.y + rect.h / 2)}Z`;
|
|
475
|
+
}
|
|
476
|
+
function polylinePath(points) {
|
|
477
|
+
return points.map((point, index) => `${index === 0 ? "M" : "L"}${q(point.x)} ${q(point.y)}`).join("");
|
|
478
|
+
}
|
|
479
|
+
function pointBounds(points) {
|
|
480
|
+
return boundsOf(points.map((point) => ({ x: point.x, y: point.y, w: 0, h: 0 })));
|
|
481
|
+
}
|
|
482
|
+
function segmentBounds(from, to, strokeWidth2) {
|
|
483
|
+
return inflate(
|
|
484
|
+
{
|
|
485
|
+
x: Math.min(from.x, to.x),
|
|
486
|
+
y: Math.min(from.y, to.y),
|
|
487
|
+
w: Math.abs(to.x - from.x),
|
|
488
|
+
h: Math.abs(to.y - from.y)
|
|
489
|
+
},
|
|
490
|
+
strokeWidth2 / 2
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
function pathBounds(points, strokeWidth2 = 0) {
|
|
494
|
+
return inflate(pointBounds(points), strokeWidth2 / 2);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/core/charts/diagram/presets.ts
|
|
498
|
+
function layoutPreset(theme, context) {
|
|
499
|
+
let captions = new Map(context.data.nodes.filter((node) => node.caption).map((node) => [
|
|
500
|
+
node.id,
|
|
501
|
+
wrapText(node.caption, context.font, Math.max(context.sizes.get(node.id).width, 16 * context.u), 2, context.measure).lines.length * context.lineHeight + 2 * context.u
|
|
502
|
+
])), external = context.options.variant === "circular-process" || context.options.variant === "roadmap", reserved = context.options.variant !== "linear-process" && !external, result = dispatchPreset(theme, reserved ? { ...context, bodySizes: context.sizes, sizes: new Map([...context.sizes].map(([id, size]) => [id, { ...size, height: size.height + (captions.get(id) ?? 0) }])) } : context);
|
|
503
|
+
if (reserved) for (let [id, height] of captions) {
|
|
504
|
+
let rect = result.nodeRects.get(id);
|
|
505
|
+
rect && result.nodeRects.set(id, { ...rect, h: Math.max(context.sizes.get(id).height, rect.h - height) });
|
|
506
|
+
}
|
|
507
|
+
if (reserved) for (let edge of result.edges) {
|
|
508
|
+
if (!edge.waypoints || edge.source.portId !== "auto:tree-out" || edge.target.portId !== "auto:tree-in") continue;
|
|
509
|
+
let source = result.nodeRects.get(edge.source.nodeId), target = result.nodeRects.get(edge.target.nodeId);
|
|
510
|
+
edge.waypoints = edge.waypoints.map((point, index) => ({
|
|
511
|
+
...point,
|
|
512
|
+
y: clamp(((index === 0 ? source.y + source.h / 2 : target.y + target.h / 2) - context.plot.y) / context.plot.h, 0, 1)
|
|
513
|
+
}));
|
|
514
|
+
}
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
function dispatchPreset(theme, context) {
|
|
518
|
+
switch (context.options.variant) {
|
|
519
|
+
case "hierarchy":
|
|
520
|
+
return layoutHierarchy(context);
|
|
521
|
+
case "issue-tree":
|
|
522
|
+
return layoutIssueTree(context);
|
|
523
|
+
case "linear-process":
|
|
524
|
+
return layoutLinear(context);
|
|
525
|
+
case "customer-journey":
|
|
526
|
+
return layoutJourney(theme, context);
|
|
527
|
+
case "circular-process":
|
|
528
|
+
return layoutCircular(context);
|
|
529
|
+
case "strategy-house":
|
|
530
|
+
return layoutStrategyHouse(context);
|
|
531
|
+
case "roadmap":
|
|
532
|
+
return layoutRoadmap(theme, context);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
var emptyResult = (data) => ({
|
|
536
|
+
nodeRects: /* @__PURE__ */ new Map(),
|
|
537
|
+
readingOrder: data.nodes.map((node) => node.id),
|
|
538
|
+
edges: [...data.edges],
|
|
539
|
+
syntheticEdgeIds: [],
|
|
540
|
+
groups: [],
|
|
541
|
+
lanes: [],
|
|
542
|
+
decorationScene: [],
|
|
543
|
+
decorationClaims: [],
|
|
544
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
545
|
+
}), placeAuthored = (result, context) => {
|
|
546
|
+
for (let node of context.data.nodes) {
|
|
547
|
+
if (!node.position) continue;
|
|
548
|
+
let size = context.sizes.get(node.id), bodyHeight = context.bodySizes?.get(node.id).height ?? size.height;
|
|
549
|
+
result.nodeRects.set(
|
|
550
|
+
node.id,
|
|
551
|
+
qRect({
|
|
552
|
+
x: context.plot.x + node.position.x * context.plot.w - size.width / 2,
|
|
553
|
+
y: context.plot.y + node.position.y * context.plot.h - bodyHeight / 2,
|
|
554
|
+
w: size.width,
|
|
555
|
+
h: size.height
|
|
556
|
+
})
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
if (context.bodySizes) for (let node of context.data.nodes) node.position && node.caption && keepClearOf(result, context, node.id);
|
|
560
|
+
};
|
|
561
|
+
function keepClearOf(result, context, id) {
|
|
562
|
+
let gap = 2 * context.u, fixed = result.nodeRects.get(id), centre = (rect) => rect.y + rect.h / 2, placed = context.data.nodes.filter((node) => result.nodeRects.has(node.id)), free = placed.filter((node) => !node.position).map((node) => node.id), authored = placed.filter((node) => node.position && node.id !== id).map((node) => result.nodeRects.get(node.id)), down = (other) => centre(result.nodeRects.get(other)) >= centre(fixed), rank = new Map(free.map((other, index) => [other, Math.abs(centre(result.nodeRects.get(other)) - centre(fixed)) + index * 1e-6])), moved = /* @__PURE__ */ new Map(), current = (other) => moved.get(other) ?? result.nodeRects.get(other), queue = [id];
|
|
563
|
+
for (let steps = 0; queue.length > 0; steps++) {
|
|
564
|
+
if (steps > 4 * free.length + 4) return;
|
|
565
|
+
let from = queue.shift(), blocker = from === id ? fixed : current(from);
|
|
566
|
+
for (let other of free) {
|
|
567
|
+
if (other === from || from !== id && (down(other) !== down(from) || rank.get(other) <= rank.get(from))) continue;
|
|
568
|
+
let rect = current(other);
|
|
569
|
+
rectsOverlap(inflate(blocker, gap / 2), inflate(rect, gap / 2)) && (moved.set(other, qRect({ ...rect, y: down(other) ? blocker.y + blocker.h + gap : blocker.y - gap - rect.h })), queue.push(other));
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if ([...moved.values()].every((rect) => rect.y >= context.plot.y && rect.y + rect.h <= context.plot.y + context.plot.h && !authored.some((other) => rectsOverlap(other, rect))))
|
|
573
|
+
for (let [other, rect] of moved) result.nodeRects.set(other, rect);
|
|
574
|
+
}
|
|
575
|
+
function graphTree(data) {
|
|
576
|
+
let nodes = new Map(data.nodes.map((node) => [node.id, node])), incoming = new Map(data.nodes.map((node) => [node.id, 0])), outgoing = /* @__PURE__ */ new Map();
|
|
577
|
+
for (let edge of data.edges) {
|
|
578
|
+
if (edge.dash === "dotted") continue;
|
|
579
|
+
incoming.set(edge.target.nodeId, incoming.get(edge.target.nodeId) + 1);
|
|
580
|
+
let edges = outgoing.get(edge.source.nodeId) ?? [];
|
|
581
|
+
edges.push(edge), outgoing.set(edge.source.nodeId, edges);
|
|
582
|
+
}
|
|
583
|
+
for (let edges of outgoing.values()) edges.sort((a, b) => nodeOrder(nodes.get(a.target.nodeId), nodes.get(b.target.nodeId)));
|
|
584
|
+
let root = [...incoming].find(([, count]) => count === 0)[0], ranks = /* @__PURE__ */ new Map([[root, 0]]), waiting = new Map(incoming), order = [root];
|
|
585
|
+
for (let index = 0; index < order.length; index++) {
|
|
586
|
+
let source = order[index];
|
|
587
|
+
for (let edge of outgoing.get(source) ?? []) {
|
|
588
|
+
let target = edge.target.nodeId;
|
|
589
|
+
ranks.set(target, Math.max(ranks.get(target) ?? 0, ranks.get(source) + 1)), waiting.set(target, waiting.get(target) - 1), waiting.get(target) === 0 && order.push(target);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
let children = /* @__PURE__ */ new Map(), treeEdges = /* @__PURE__ */ new Set(), placed = /* @__PURE__ */ new Set([root]);
|
|
593
|
+
for (let source of order)
|
|
594
|
+
for (let edge of outgoing.get(source) ?? []) {
|
|
595
|
+
let target = edge.target.nodeId;
|
|
596
|
+
if (placed.has(target) || ranks.get(target) !== ranks.get(source) + 1) continue;
|
|
597
|
+
placed.add(target);
|
|
598
|
+
let siblings = children.get(source) ?? [];
|
|
599
|
+
siblings.push(nodes.get(target)), children.set(source, siblings), treeEdges.add(edge.id);
|
|
600
|
+
}
|
|
601
|
+
return { ranks, nodes, children, treeEdges };
|
|
602
|
+
}
|
|
603
|
+
function layoutHierarchy(context) {
|
|
604
|
+
let result = emptyResult(context.data), { ranks, nodes, children: primaryChildren, treeEdges: placementEdges } = graphTree(context.data), levels = /* @__PURE__ */ new Map();
|
|
605
|
+
for (let node of context.data.nodes) {
|
|
606
|
+
let rank = ranks.get(node.id) ?? 0;
|
|
607
|
+
levels.set(rank, [...levels.get(rank) ?? [], node]);
|
|
608
|
+
}
|
|
609
|
+
let root = [...levels.get(0) ?? []].sort(nodeOrder)[0], branches = [...levels.get(1) ?? []].sort(nodeOrder), descendants = /* @__PURE__ */ new Map();
|
|
610
|
+
for (let branch of branches) {
|
|
611
|
+
let ordered = [], visit = (id) => {
|
|
612
|
+
for (let node of primaryChildren.get(id) ?? [])
|
|
613
|
+
ordered.push(node), visit(node.id);
|
|
614
|
+
};
|
|
615
|
+
visit(branch.id), descendants.set(branch.id, ordered);
|
|
616
|
+
}
|
|
617
|
+
let layerGap = 8 * context.u, nodeGap = 3 * context.u, rootSize = context.sizes.get(root.id), branchHeight = branches.length > 0 ? maxOf(branches.map((node) => context.sizes.get(node.id).height)) : 0, laneWidth = branches.length > 0 ? context.plot.w / branches.length : context.plot.w, treeWidths = /* @__PURE__ */ new Map(), treeWidth = (id) => {
|
|
618
|
+
let cached = treeWidths.get(id);
|
|
619
|
+
if (cached !== void 0) return cached;
|
|
620
|
+
let kids = primaryChildren.get(id) ?? [], row = kids.reduce((sum, kid) => sum + treeWidth(kid.id), 0) + Math.max(0, kids.length - 1) * nodeGap, width = Math.max(context.sizes.get(id).width, row);
|
|
621
|
+
return treeWidths.set(id, width), width;
|
|
622
|
+
}, treeDepth = (id) => {
|
|
623
|
+
let kids = primaryChildren.get(id) ?? [];
|
|
624
|
+
return kids.length === 0 ? 0 : maxOf(kids.map((kid) => layerGap + context.sizes.get(kid.id).height + treeDepth(kid.id)));
|
|
625
|
+
}, treeBranches = new Set(branches.filter((branch) => treeWidth(branch.id) <= laneWidth - 2 * context.u).map((branch) => branch.id)), treeNodes = new Set([...treeBranches].flatMap((id) => (descendants.get(id) ?? []).map((node) => node.id))), descendantHeight = Math.max(
|
|
626
|
+
0,
|
|
627
|
+
maxOf([...descendants.entries()].map(
|
|
628
|
+
([branchId, nodes2]) => treeBranches.has(branchId) ? Math.max(0, treeDepth(branchId) - layerGap) : nodes2.reduce(
|
|
629
|
+
(sum, node, index) => sum + context.sizes.get(node.id).height + (index === 0 ? 0 : nodeGap),
|
|
630
|
+
0
|
|
631
|
+
)
|
|
632
|
+
))
|
|
633
|
+
), contentHeight = rootSize.height + (branches.length > 0 ? layerGap + branchHeight : 0) + (descendantHeight > 0 ? layerGap + descendantHeight : 0), contentTop = context.plot.y + Math.max(0, (context.plot.h - contentHeight) / 2);
|
|
634
|
+
contentHeight > context.plot.h && (result.compressed = !0);
|
|
635
|
+
let rootWidth = Math.min(rootSize.width, context.plot.w);
|
|
636
|
+
if (rootWidth < rootSize.width && (result.compressed = !0), result.nodeRects.set(
|
|
637
|
+
root.id,
|
|
638
|
+
qRect({
|
|
639
|
+
x: context.plot.x + (context.plot.w - rootWidth) / 2,
|
|
640
|
+
y: contentTop,
|
|
641
|
+
w: rootWidth,
|
|
642
|
+
h: rootSize.height
|
|
643
|
+
})
|
|
644
|
+
), branches.length > 0) {
|
|
645
|
+
let branchY = contentTop + rootSize.height + layerGap;
|
|
646
|
+
branches.forEach((branch, branchIndex) => {
|
|
647
|
+
let size = context.sizes.get(branch.id), width = Math.min(size.width, Math.max(48, laneWidth - 2 * context.u));
|
|
648
|
+
width < size.width && (result.compressed = !0);
|
|
649
|
+
let laneX = context.plot.x + branchIndex * laneWidth;
|
|
650
|
+
if (result.nodeRects.set(
|
|
651
|
+
branch.id,
|
|
652
|
+
qRect({
|
|
653
|
+
x: laneX + (laneWidth - width) / 2,
|
|
654
|
+
y: branchY + (branchHeight - size.height) / 2,
|
|
655
|
+
w: width,
|
|
656
|
+
h: size.height
|
|
657
|
+
})
|
|
658
|
+
), treeBranches.has(branch.id)) {
|
|
659
|
+
let placeChildren = (parentId) => {
|
|
660
|
+
let parent = result.nodeRects.get(parentId), kids = primaryChildren.get(parentId) ?? [];
|
|
661
|
+
if (kids.length === 0) return;
|
|
662
|
+
let row = kids.reduce((sum, kid) => sum + treeWidth(kid.id), 0) + (kids.length - 1) * nodeGap, left = clamp(parent.x + parent.w / 2 - row / 2, laneX + context.u, laneX + laneWidth - context.u - row);
|
|
663
|
+
for (let kid of kids) {
|
|
664
|
+
let kidSize = context.sizes.get(kid.id), span = treeWidth(kid.id);
|
|
665
|
+
result.nodeRects.set(kid.id, qRect({ x: left + (span - kidSize.width) / 2, y: parent.y + parent.h + layerGap, w: kidSize.width, h: kidSize.height })), placeChildren(kid.id), left += span + nodeGap;
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
placeChildren(branch.id);
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
let descendantY = branchY + branchHeight + layerGap;
|
|
672
|
+
for (let node of descendants.get(branch.id) ?? []) {
|
|
673
|
+
let nodeSize = context.sizes.get(node.id), rank = ranks.get(node.id) ?? 2, x = laneX + 2 * context.u + 2 * context.u + Math.max(0, rank - 2) * context.u, width2 = Math.min(
|
|
674
|
+
nodeSize.width,
|
|
675
|
+
Math.max(48, laneX + laneWidth - context.u - x)
|
|
676
|
+
);
|
|
677
|
+
width2 < nodeSize.width && (result.compressed = !0), result.nodeRects.set(
|
|
678
|
+
node.id,
|
|
679
|
+
qRect({ x, y: descendantY, w: width2, h: nodeSize.height })
|
|
680
|
+
), descendantY += nodeSize.height + nodeGap;
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
result.readingOrder = [...levels.keys()].sort((a, b) => a - b).flatMap((rank) => [...levels.get(rank)].sort(nodeOrder).map((node) => node.id)), placeAuthored(result, context);
|
|
685
|
+
let ensureHierarchyPort = (nodeId, port) => {
|
|
686
|
+
let node = nodes.get(nodeId);
|
|
687
|
+
node.ports?.some((candidate) => candidate.id === port.id) || (node.ports = [...node.ports ?? [], port]);
|
|
688
|
+
}, treeEdges = [];
|
|
689
|
+
result.edges = result.edges.map((edge) => {
|
|
690
|
+
if (!placementEdges.has(edge.id) || edge.waypoints?.length || edge.source.portId || edge.target.portId) return edge;
|
|
691
|
+
let targetRank = ranks.get(edge.target.nodeId) ?? 0;
|
|
692
|
+
if (targetRank === 1 || treeNodes.has(edge.target.nodeId)) {
|
|
693
|
+
let source2 = result.nodeRects.get(edge.source.nodeId);
|
|
694
|
+
if (result.nodeRects.get(edge.target.nodeId).y < source2.y + source2.h) return edge;
|
|
695
|
+
ensureHierarchyPort(edge.source.nodeId, { id: "auto:tree-down", at: { side: "bottom" }, intent: "out" }), ensureHierarchyPort(edge.target.nodeId, { id: "auto:tree-top", at: { side: "top" }, intent: "in", capacity: 1 });
|
|
696
|
+
let tree = {
|
|
697
|
+
...edge,
|
|
698
|
+
source: { ...edge.source, portId: "auto:tree-down" },
|
|
699
|
+
target: { ...edge.target, portId: "auto:tree-top" },
|
|
700
|
+
routing: "orthogonal"
|
|
701
|
+
};
|
|
702
|
+
return treeEdges.push(tree), tree;
|
|
703
|
+
}
|
|
704
|
+
if (targetRank < 2) return edge;
|
|
705
|
+
let source = result.nodeRects.get(edge.source.nodeId), target = result.nodeRects.get(edge.target.nodeId), siblingEdges = result.edges.filter(
|
|
706
|
+
(candidate) => candidate.dash !== "dotted" && candidate.source.nodeId === edge.source.nodeId && (ranks.get(candidate.target.nodeId) ?? 0) >= 2
|
|
707
|
+
), spineX = target.x - (siblingEdges.some((candidate) => candidate.arrowEnd) ? 3 : 2) * context.u, sourceChannelY = source.y + source.h + context.u, targetChannelY = target.y + target.h / 2, sourcePortId = "auto:hierarchy-out", targetPortId = "auto:hierarchy-in", siblingCount = siblingEdges.length;
|
|
708
|
+
return ensureHierarchyPort(edge.source.nodeId, {
|
|
709
|
+
id: sourcePortId,
|
|
710
|
+
at: { side: "bottom", offset: 0.2 },
|
|
711
|
+
intent: "out",
|
|
712
|
+
capacity: Math.max(1, siblingCount)
|
|
713
|
+
}), ensureHierarchyPort(edge.target.nodeId, {
|
|
714
|
+
id: targetPortId,
|
|
715
|
+
at: { side: "left" },
|
|
716
|
+
intent: "in",
|
|
717
|
+
capacity: 1
|
|
718
|
+
}), {
|
|
719
|
+
...edge,
|
|
720
|
+
source: { ...edge.source, portId: sourcePortId },
|
|
721
|
+
target: { ...edge.target, portId: targetPortId },
|
|
722
|
+
routing: "orthogonal",
|
|
723
|
+
waypoints: [
|
|
724
|
+
{
|
|
725
|
+
x: clamp((spineX - context.plot.x) / context.plot.w, 0, 1),
|
|
726
|
+
y: clamp((sourceChannelY - context.plot.y) / context.plot.h, 0, 1)
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
x: clamp((spineX - context.plot.x) / context.plot.w, 0, 1),
|
|
730
|
+
y: clamp((targetChannelY - context.plot.y) / context.plot.h, 0, 1)
|
|
731
|
+
}
|
|
732
|
+
]
|
|
733
|
+
};
|
|
734
|
+
}), result.groups = groupsFromMembers(context, result);
|
|
735
|
+
let u = context.u, stub = (arrow) => u * (arrow ? 3 : 1), rectOf = (end) => result.nodeRects.get(end.nodeId), frameTop = (edge) => {
|
|
736
|
+
let group = result.groups.find((group2) => group2.memberNodeIds.includes(edge.target.nodeId));
|
|
737
|
+
return group && !group.memberNodeIds.includes(edge.source.nodeId) ? group.bounds.y : 1 / 0;
|
|
738
|
+
}, midway = (edge) => {
|
|
739
|
+
let bottom = rectOf(edge.source).y + rectOf(edge.source).h;
|
|
740
|
+
return bottom + (rectOf(edge.target).y - bottom) / 2;
|
|
741
|
+
}, nx = (x) => clamp((x - context.plot.x) / context.plot.w, 0, 1), byParent = /* @__PURE__ */ new Map();
|
|
742
|
+
for (let edge of treeEdges) byParent.set(edge.source.nodeId, [...byParent.get(edge.source.nodeId) ?? [], edge]);
|
|
743
|
+
for (let siblings of byParent.values()) {
|
|
744
|
+
let source = rectOf(siblings[0].source), ceiling = minOf(siblings.map((edge) => frameTop(edge) - u)), lowest = source.y + source.h + maxOf(siblings.map((edge) => stub(edge.arrowStart))), run = Math.min(ceiling, minOf(siblings.map((edge) => rectOf(edge.target).y - stub(edge.arrowEnd)))), lift = run >= lowest && siblings.some((edge) => frameTop(edge) - u < midway(edge));
|
|
745
|
+
for (let edge of siblings) {
|
|
746
|
+
let target = rectOf(edge.target), ny = clamp(((lift ? run : midway(edge)) - context.plot.y) / context.plot.h, 0, 1);
|
|
747
|
+
edge.waypoints = [{ x: nx(source.x + source.w / 2), y: ny }, { x: nx(target.x + target.w / 2), y: ny }];
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return result;
|
|
751
|
+
}
|
|
752
|
+
function layoutIssueTree(context) {
|
|
753
|
+
let result = emptyResult(context.data), { ranks, nodes, children, treeEdges: placementEdges } = graphTree(context.data), columns = /* @__PURE__ */ new Map();
|
|
754
|
+
for (let node of context.data.nodes) {
|
|
755
|
+
let rank = ranks.get(node.id) ?? 0;
|
|
756
|
+
columns.set(rank, [...columns.get(rank) ?? [], node]);
|
|
757
|
+
}
|
|
758
|
+
let count = maxOf(columns.keys()) + 1, cellW = context.plot.w / count, widths = new Map(
|
|
759
|
+
[...columns].map(([rank, nodes2]) => {
|
|
760
|
+
let preferred = maxOf(nodes2.map((node) => context.sizes.get(node.id).width)), width = Math.min(cellW - 3 * context.u, preferred);
|
|
761
|
+
return width < preferred && (result.compressed = !0), [rank, width];
|
|
762
|
+
})
|
|
763
|
+
);
|
|
764
|
+
for (let node of context.data.nodes) {
|
|
765
|
+
if (!node.secondaryLabel) continue;
|
|
766
|
+
let width = Math.max(1, widths.get(ranks.get(node.id) ?? 0) - 4 * context.u), primary = wrapText(node.label, context.font, width, 3, context.measure).lines.length, secondary = wrapText(node.secondaryLabel, context.font, width, 2, context.measure).lines.length, size = context.sizes.get(node.id), icon = node.icon || node.shape.kind === "icon" ? 4.5 * context.u : 0;
|
|
767
|
+
context.sizes.set(node.id, { ...size, height: Math.max(size.height, (primary + secondary) * context.lineHeight + icon + 3.5 * context.u) });
|
|
768
|
+
}
|
|
769
|
+
let nodeGap = 2 * context.u, subtreeHeights = /* @__PURE__ */ new Map(), subtreeHeight = (id) => {
|
|
770
|
+
let cached = subtreeHeights.get(id);
|
|
771
|
+
if (cached !== void 0) return cached;
|
|
772
|
+
let nodeHeight = context.sizes.get(id).height, descendants = children.get(id) ?? [], childHeight = descendants.reduce((sum, child) => sum + subtreeHeight(child.id), 0) + Math.max(0, descendants.length - 1) * nodeGap, height = Math.max(nodeHeight, childHeight);
|
|
773
|
+
return subtreeHeights.set(id, height), height;
|
|
774
|
+
}, root = [...columns.get(0) ?? []].sort(nodeOrder)[0], totalHeight = subtreeHeight(root.id);
|
|
775
|
+
if (totalHeight > context.plot.h) {
|
|
776
|
+
let heights = context.data.nodes.map((node) => {
|
|
777
|
+
let size = context.sizes.get(node.id), width = Math.max(1, widths.get(ranks.get(node.id) ?? 0) - 4 * context.u), primary = wrapText(node.label, context.font, width, 3, context.measure).lines.length, icon = node.icon || node.shape.kind === "icon" ? 4.5 * context.u : 0, minimum = Math.max(
|
|
778
|
+
7 * context.u,
|
|
779
|
+
primary * context.lineHeight + icon + 3 * context.u,
|
|
780
|
+
node.minSize?.height ?? 0,
|
|
781
|
+
node.size?.height ?? 0
|
|
782
|
+
);
|
|
783
|
+
return { id: node.id, size, minimum: node.secondaryLabel ? minimum : size.height };
|
|
784
|
+
}), resize = (fraction) => {
|
|
785
|
+
for (let { id, size, minimum } of heights) context.sizes.set(id, {
|
|
786
|
+
...size,
|
|
787
|
+
height: minimum + Math.max(0, size.height - minimum) * fraction
|
|
788
|
+
});
|
|
789
|
+
return subtreeHeights.clear(), subtreeHeight(root.id);
|
|
790
|
+
}, lo = 0, hi = 1;
|
|
791
|
+
for (let pass = 0; pass < 12; pass++) {
|
|
792
|
+
let mid = (lo + hi) / 2;
|
|
793
|
+
resize(mid) <= context.plot.h - 1 ? lo = mid : hi = mid;
|
|
794
|
+
}
|
|
795
|
+
totalHeight = resize(lo);
|
|
796
|
+
}
|
|
797
|
+
let contentTop = context.plot.y + Math.max(0, (context.plot.h - totalHeight) / 2);
|
|
798
|
+
totalHeight > context.plot.h && (result.compressed = !0);
|
|
799
|
+
let placeSubtree = (node, top, height) => {
|
|
800
|
+
let descendants = children.get(node.id) ?? [], centre = top + height / 2;
|
|
801
|
+
if (descendants.length > 0) {
|
|
802
|
+
let childTotal = descendants.reduce((sum, child) => sum + subtreeHeight(child.id), 0) + (descendants.length - 1) * nodeGap, childTop = top + (height - childTotal) / 2, childCentres = descendants.map((child) => {
|
|
803
|
+
let childHeight = subtreeHeight(child.id), childCentre = placeSubtree(child, childTop, childHeight);
|
|
804
|
+
return childTop += childHeight + nodeGap, childCentre;
|
|
805
|
+
});
|
|
806
|
+
centre = (childCentres[0] + childCentres[childCentres.length - 1]) / 2;
|
|
807
|
+
}
|
|
808
|
+
let rank = ranks.get(node.id) ?? 0, size = context.sizes.get(node.id);
|
|
809
|
+
return result.nodeRects.set(
|
|
810
|
+
node.id,
|
|
811
|
+
qRect({
|
|
812
|
+
x: context.plot.x + rank * cellW + context.u,
|
|
813
|
+
y: centre - size.height / 2,
|
|
814
|
+
w: widths.get(rank),
|
|
815
|
+
h: size.height
|
|
816
|
+
})
|
|
817
|
+
), centre;
|
|
818
|
+
};
|
|
819
|
+
if (placeSubtree(root, contentTop, totalHeight), context.data.nodes.length === 1) {
|
|
820
|
+
let rect = result.nodeRects.get(root.id);
|
|
821
|
+
result.nodeRects.set(root.id, qRect({ ...rect, x: context.plot.x + (context.plot.w - rect.w) / 2 }));
|
|
822
|
+
}
|
|
823
|
+
return result.readingOrder = [...columns.keys()].sort((a, b) => a - b).flatMap(
|
|
824
|
+
(rank) => [...columns.get(rank)].sort(
|
|
825
|
+
(a, b) => result.nodeRects.get(a.id).y - result.nodeRects.get(b.id).y || nodeOrder(a, b)
|
|
826
|
+
).map((node) => node.id)
|
|
827
|
+
), placeAuthored(result, context), result.edges = result.edges.map((edge) => {
|
|
828
|
+
if (!placementEdges.has(edge.id) || edge.waypoints?.length || edge.source.portId || edge.target.portId) return edge;
|
|
829
|
+
let source = result.nodeRects.get(edge.source.nodeId), target = result.nodeRects.get(edge.target.nodeId);
|
|
830
|
+
if (!source || !target || target.x <= source.x + source.w) return edge;
|
|
831
|
+
let trunkX = source.x + source.w + (target.x - source.x - source.w) / 2;
|
|
832
|
+
return ensurePort(nodes, edge.source.nodeId, { id: "auto:tree-out", at: { side: "right" }, intent: "out" }), ensurePort(nodes, edge.target.nodeId, { id: "auto:tree-in", at: { side: "left" }, intent: "in", capacity: 1 }), {
|
|
833
|
+
...edge,
|
|
834
|
+
source: { ...edge.source, portId: "auto:tree-out" },
|
|
835
|
+
target: { ...edge.target, portId: "auto:tree-in" },
|
|
836
|
+
routing: "orthogonal",
|
|
837
|
+
waypoints: [
|
|
838
|
+
{ x: clamp((trunkX - context.plot.x) / context.plot.w, 0, 1), y: clamp((source.y + source.h / 2 - context.plot.y) / context.plot.h, 0, 1) },
|
|
839
|
+
{ x: clamp((trunkX - context.plot.x) / context.plot.w, 0, 1), y: clamp((target.y + target.h / 2 - context.plot.y) / context.plot.h, 0, 1) }
|
|
840
|
+
]
|
|
841
|
+
};
|
|
842
|
+
}), result;
|
|
843
|
+
}
|
|
844
|
+
function ensurePort(nodes, nodeId, port) {
|
|
845
|
+
let node = nodes.get(nodeId);
|
|
846
|
+
node.ports?.some((candidate) => candidate.id === port.id) || (node.ports = [...node.ports ?? [], port]);
|
|
847
|
+
}
|
|
848
|
+
function layoutLinear(context) {
|
|
849
|
+
let result = emptyResult(context.data), steps = [...context.data.nodes].sort(nodeOrder), gap = context.u, cellW = (context.plot.w - gap * (steps.length - 1)) / steps.length, uniformW = Math.floor(cellW * 2) / 2, contentW = steps.length * uniformW + (steps.length - 1) * gap;
|
|
850
|
+
steps.some((step) => context.sizes.get(step.id).width > uniformW) && (result.compressed = !0);
|
|
851
|
+
let startX = q(context.plot.x + (context.plot.w - contentW) / 2), badgeReserve = 2 * context.u, captions = steps.flatMap((step) => step.caption ? [step.caption] : []), captionReserve = 0;
|
|
852
|
+
if (captions.length > 0) {
|
|
853
|
+
let theme = themeForWidth(
|
|
854
|
+
resolveTheme(context.options.theme),
|
|
855
|
+
panelTypeClass(context.options) ?? resolveSize(context.options.size).width
|
|
856
|
+
), captionFont = {
|
|
857
|
+
family: theme.type.family,
|
|
858
|
+
...theme.type.label
|
|
859
|
+
}, captionWidth = Math.max(uniformW, 16 * context.u);
|
|
860
|
+
captionReserve = context.u + maxOf(captions.map(
|
|
861
|
+
(caption) => wrapText(caption, captionFont, captionWidth, 2, context.measure).lines.length * context.lineHeight
|
|
862
|
+
));
|
|
863
|
+
}
|
|
864
|
+
let bodyH = Math.min(
|
|
865
|
+
Math.max(
|
|
866
|
+
12 * context.u,
|
|
867
|
+
maxOf(steps.map((step) => context.sizes.get(step.id).height))
|
|
868
|
+
),
|
|
869
|
+
context.plot.h - badgeReserve - captionReserve
|
|
870
|
+
), blockH = badgeReserve + bodyH + captionReserve, bodyY = context.plot.y + Math.max(0, (context.plot.h - blockH) / 2) + badgeReserve;
|
|
871
|
+
return steps.forEach((node, index) => {
|
|
872
|
+
let x = q(startX + index * (uniformW + gap));
|
|
873
|
+
result.nodeRects.set(
|
|
874
|
+
node.id,
|
|
875
|
+
qRect({
|
|
876
|
+
x,
|
|
877
|
+
y: bodyY,
|
|
878
|
+
w: uniformW,
|
|
879
|
+
h: bodyH
|
|
880
|
+
})
|
|
881
|
+
);
|
|
882
|
+
}), result.readingOrder = steps.map((node) => node.id), placeAuthored(result, context), result;
|
|
883
|
+
}
|
|
884
|
+
function layoutJourney(theme, context) {
|
|
885
|
+
let result = emptyResult(context.data), lanes = context.data.lanes, serpentine = context.options.variant === "customer-journey" && context.options.flow === "serpentine", rowCount = serpentine && lanes.length > 1 ? 2 : 1, perRow = Math.ceil(lanes.length / rowCount), laneW = context.plot.w / perRow, headerH = 7 * context.u, nodeGap = 3 * context.u, anchorReserve = 3 * context.u, visualRows = Array.from(
|
|
886
|
+
{ length: rowCount },
|
|
887
|
+
(_, row) => lanes.slice(row * perRow, Math.min(lanes.length, (row + 1) * perRow))
|
|
888
|
+
), membersByLane = new Map(
|
|
889
|
+
lanes.map((lane) => [
|
|
890
|
+
lane.id,
|
|
891
|
+
context.data.nodes.filter((node) => node.laneId === lane.id).sort(nodeOrder)
|
|
892
|
+
])
|
|
893
|
+
), cardRows = visualRows.map((rowLanes) => {
|
|
894
|
+
let memberRows = Math.max(
|
|
895
|
+
0,
|
|
896
|
+
maxOf(rowLanes.map((lane) => membersByLane.get(lane.id).length))
|
|
897
|
+
);
|
|
898
|
+
return Array.from({ length: memberRows }, (_, memberIndex) => {
|
|
899
|
+
let peers = rowLanes.flatMap((lane) => {
|
|
900
|
+
let node = membersByLane.get(lane.id)[memberIndex];
|
|
901
|
+
return node ? [node] : [];
|
|
902
|
+
}), height = maxOf(peers.map((node) => context.sizes.get(node.id).height)), hasIcon = peers.some(
|
|
903
|
+
(node) => node.icon || node.shape.kind === "icon"
|
|
904
|
+
);
|
|
905
|
+
return {
|
|
906
|
+
height,
|
|
907
|
+
contentTopReserve: hasIcon ? Math.min(height * 0.42, 28) : 0
|
|
908
|
+
};
|
|
909
|
+
});
|
|
910
|
+
}), rowHeights = cardRows.map((rows) => {
|
|
911
|
+
let stackHeight = rows.reduce((sum, row) => sum + row.height, 0) + Math.max(0, rows.length - 1) * nodeGap;
|
|
912
|
+
return headerH + anchorReserve + stackHeight;
|
|
913
|
+
}), betweenRows = rowCount > 1 ? 3 * context.u : 0, totalHeight = rowHeights.reduce((sum, height) => sum + height, 0) + Math.max(0, rowCount - 1) * betweenRows;
|
|
914
|
+
totalHeight > context.plot.h && (result.compressed = !0);
|
|
915
|
+
let contentTop = context.plot.y + Math.max(0, (context.plot.h - totalHeight) / 2), rowTops = rowHeights.map(
|
|
916
|
+
(_, row) => contentTop + rowHeights.slice(0, row).reduce((sum, height) => sum + height, 0) + row * betweenRows
|
|
917
|
+
);
|
|
918
|
+
return lanes.forEach((lane, laneIndex) => {
|
|
919
|
+
let row = Math.floor(laneIndex / perRow), local = laneIndex % perRow, visualColumn = serpentine && row % 2 === 1 ? perRow - local - 1 : local, x = context.plot.x + visualColumn * laneW, y = rowTops[row], laneH = rowHeights[row], bounds = qRect({ x, y, w: laneW, h: laneH }), headerBox = qRect({ x, y, w: laneW, h: headerH }), members = membersByLane.get(lane.id);
|
|
920
|
+
members.some((node) => context.sizes.get(node.id).width > laneW - 2 * context.u) && (result.compressed = !0);
|
|
921
|
+
let cardY = y + headerH + anchorReserve;
|
|
922
|
+
members.forEach((node, index) => {
|
|
923
|
+
let cardRow = cardRows[row][index], height = cardRow.height;
|
|
924
|
+
result.contentTopReserves.set(node.id, cardRow.contentTopReserve), result.nodeRects.set(
|
|
925
|
+
node.id,
|
|
926
|
+
qRect({
|
|
927
|
+
x: x + context.u,
|
|
928
|
+
y: cardY,
|
|
929
|
+
w: laneW - 2 * context.u,
|
|
930
|
+
h: height
|
|
931
|
+
})
|
|
932
|
+
), cardY += height + nodeGap;
|
|
933
|
+
}), result.lanes.push({ id: lane.id, bounds, headerBox, memberNodeIds: members.map((node) => node.id) });
|
|
934
|
+
let fill = context.palette.lane(lane.role, lane.paletteKey);
|
|
935
|
+
if (result.decorationScene.push({
|
|
936
|
+
t: "path",
|
|
937
|
+
id: diagramSceneId("lane", lane.id, "header"),
|
|
938
|
+
// The return row of a serpentine reads right to left, and says so.
|
|
939
|
+
d: chevronPath(headerBox, Math.min(2 * context.u, headerBox.w / 6), serpentine && row % 2 === 1),
|
|
940
|
+
fill,
|
|
941
|
+
owner: laneOwner(lane.id),
|
|
942
|
+
part: "diagramLaneHeader"
|
|
943
|
+
}), result.decorationClaims.push({ rect: headerBox, owner: laneOwner(lane.id), part: "diagramLaneHeader" }), local > 0) {
|
|
944
|
+
let ruleX = q(x), from = { x: ruleX, y: q(y + headerH) }, to = { x: ruleX, y: q(y + laneH) };
|
|
945
|
+
result.decorationScene.push({
|
|
946
|
+
t: "line",
|
|
947
|
+
id: diagramSceneId("lane", lane.id, "partition"),
|
|
948
|
+
x1: from.x,
|
|
949
|
+
y1: from.y,
|
|
950
|
+
x2: to.x,
|
|
951
|
+
y2: to.y,
|
|
952
|
+
stroke: { token: "grid" },
|
|
953
|
+
width: strokeToken(theme, "rule"),
|
|
954
|
+
dash: dashToken(theme, "reference"),
|
|
955
|
+
owner: laneOwner(lane.id),
|
|
956
|
+
part: "diagramLanePartition"
|
|
957
|
+
}), result.decorationClaims.push({
|
|
958
|
+
rect: segmentBounds(from, to, 1),
|
|
959
|
+
owner: laneOwner(lane.id),
|
|
960
|
+
part: "diagramLanePartition"
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
let anchorY = q(y + headerH + context.u), anchorX = q(x + laneW / 2);
|
|
964
|
+
result.decorationScene.push({
|
|
965
|
+
t: "circle",
|
|
966
|
+
id: diagramSceneId("lane", lane.id, "anchor"),
|
|
967
|
+
cx: anchorX,
|
|
968
|
+
cy: anchorY,
|
|
969
|
+
r: q(context.u / 2),
|
|
970
|
+
fill,
|
|
971
|
+
owner: laneOwner(lane.id),
|
|
972
|
+
part: "diagramJourneyAnchor"
|
|
973
|
+
}), result.decorationClaims.push({
|
|
974
|
+
rect: qRect({
|
|
975
|
+
x: anchorX - context.u / 2,
|
|
976
|
+
y: anchorY - context.u / 2,
|
|
977
|
+
w: context.u,
|
|
978
|
+
h: context.u
|
|
979
|
+
}),
|
|
980
|
+
owner: laneOwner(lane.id),
|
|
981
|
+
part: "diagramJourneyAnchor"
|
|
982
|
+
}), members.forEach((node, memberIndex) => {
|
|
983
|
+
let rect = result.nodeRects.get(node.id), channelX = q(memberIndex % 2 === 0 ? rect.x + context.u : rect.x + rect.w - context.u), d = `M${anchorX} ${anchorY}L${channelX} ${anchorY}L${channelX} ${q(rect.y)}`;
|
|
984
|
+
result.decorationScene.push({
|
|
985
|
+
t: "path",
|
|
986
|
+
id: diagramSceneId("leader", lane.id, node.id),
|
|
987
|
+
d,
|
|
988
|
+
stroke: { token: "leader" },
|
|
989
|
+
width: strokeToken(theme, "rule"),
|
|
990
|
+
dash: dashToken(theme, "dotted"),
|
|
991
|
+
lineCap: "round",
|
|
992
|
+
owner: { pointId: node.id },
|
|
993
|
+
part: "diagramJourneyLeader"
|
|
994
|
+
});
|
|
995
|
+
let owner = { pointId: node.id };
|
|
996
|
+
result.decorationClaims.push({
|
|
997
|
+
rect: segmentBounds(
|
|
998
|
+
{ x: anchorX, y: anchorY },
|
|
999
|
+
{ x: channelX, y: anchorY },
|
|
1000
|
+
1
|
|
1001
|
+
),
|
|
1002
|
+
owner,
|
|
1003
|
+
part: "diagramJourneyLeader"
|
|
1004
|
+
}), result.decorationClaims.push({
|
|
1005
|
+
rect: segmentBounds(
|
|
1006
|
+
{ x: channelX, y: anchorY },
|
|
1007
|
+
{ x: channelX, y: q(rect.y) },
|
|
1008
|
+
1
|
|
1009
|
+
),
|
|
1010
|
+
owner,
|
|
1011
|
+
part: "diagramJourneyLeader"
|
|
1012
|
+
});
|
|
1013
|
+
});
|
|
1014
|
+
}), result.readingOrder = lanes.flatMap((lane) => membersByLane.get(lane.id).map((node) => node.id)), result;
|
|
1015
|
+
}
|
|
1016
|
+
function circularRing(steps, plot, u, text) {
|
|
1017
|
+
let cap = Math.min(plot.w, plot.h) / 3.5, lineHeight = text.font.size * (text.font.lineHeight ?? 1.2), own = (step) => {
|
|
1018
|
+
let icon = step.icon || step.shape.kind === "icon" ? 2.5 * lineHeight : 0, secondary = step.secondaryLabel ? Math.min(cap, text.measure(step.secondaryLabel, text.font).width + 4 * u) : 0;
|
|
1019
|
+
return Math.max(icon, secondary, step.size?.width ?? 0, step.size?.height ?? 0, step.minSize?.width ?? 0, step.minSize?.height ?? 0);
|
|
1020
|
+
}, diameter = Math.max(8 * u, Math.min(16 + 0.08 * plot.w, 0.6 * plot.h), maxOf(steps.map(own))), captionHeight = Math.max(0, maxOf(steps.map((step) => step.caption ? wrapText(step.caption, text.font, Math.max(diameter, 16 * u), 2, text.measure).lines.length * lineHeight + 2 * u : 0))), minRadius = steps.length > 2 ? (diameter + captionHeight + 2 * u) / (2 * Math.sin(Math.PI / steps.length)) : diameter + captionHeight, labelWidth = Math.min(18 * u, plot.w / 5), maxRadius = Math.min((plot.h - 2 * circularLabelBand(text.font, u) - diameter) / 2, (plot.w - diameter) / 2 - labelWidth - 2 * u);
|
|
1021
|
+
return { diameter, radius: Math.max(minRadius, Math.min(20 + 0.128 * plot.w, maxRadius)) };
|
|
1022
|
+
}
|
|
1023
|
+
function circularLabelBand(font, u) {
|
|
1024
|
+
return 2 * font.size * (font.lineHeight ?? 1.2) + 2 * u;
|
|
1025
|
+
}
|
|
1026
|
+
function layoutCircular(context) {
|
|
1027
|
+
let result = emptyResult(context.data), steps = [...context.data.nodes].sort(nodeOrder), { diameter: ringDiameter, radius } = circularRing(steps, context.plot, context.u, context), centre = { x: context.plot.x + context.plot.w / 2, y: context.plot.y + context.plot.h / 2 };
|
|
1028
|
+
return steps.forEach((node, index) => {
|
|
1029
|
+
let angle = -Math.PI / 2 + index * Math.PI * 2 / steps.length, diameter = ringDiameter;
|
|
1030
|
+
result.nodeRects.set(
|
|
1031
|
+
node.id,
|
|
1032
|
+
qRect({
|
|
1033
|
+
x: centre.x + Math.cos(angle) * radius - diameter / 2,
|
|
1034
|
+
y: centre.y + Math.sin(angle) * radius - diameter / 2,
|
|
1035
|
+
w: diameter,
|
|
1036
|
+
h: diameter
|
|
1037
|
+
})
|
|
1038
|
+
);
|
|
1039
|
+
}), result.readingOrder = steps.map((node) => node.id), steps.length > 1 && result.edges.length === 0 && (result.edges = steps.map((step, index) => {
|
|
1040
|
+
let target = steps[(index + 1) % steps.length];
|
|
1041
|
+
return {
|
|
1042
|
+
id: automaticEdgeId("circular-process", index, step.id, target.id),
|
|
1043
|
+
source: { nodeId: step.id },
|
|
1044
|
+
target: { nodeId: target.id },
|
|
1045
|
+
routing: "curved",
|
|
1046
|
+
arrowEnd: !0,
|
|
1047
|
+
role: "secondary"
|
|
1048
|
+
};
|
|
1049
|
+
}), result.syntheticEdgeIds = result.edges.map((edge) => edge.id)), placeAuthored(result, context), result;
|
|
1050
|
+
}
|
|
1051
|
+
function strategyHouseBands(data, width, u, font, measure, headFont = font) {
|
|
1052
|
+
let lineH = font.size * (font.lineHeight ?? 1.2), groups = data.groups, columnW = width / Math.max(1, groups.length), lines = (node, w) => node ? wrapText(node.label, node.kind === "initiative" || node.kind === "enabler" ? font : headFont, Math.max(1, w - 4 * u), 3, measure).lines.length : 1, objectives = data.nodes.filter((node) => node.kind === "objective").sort(nodeOrder), enablers = data.nodes.filter((node) => node.kind === "enabler").sort(nodeOrder), foundation = data.nodes.find((node) => node.kind === "foundation"), columns = groups.map((group) => data.nodes.filter((node) => node.kind === "initiative" && node.groupId === group.id).sort(nodeOrder)), rows = Math.max(1, maxOf(columns.map((cells2) => cells2.length))), pad = 2.6 * u, wide = width >= 120 * u, header = Math.max(1, maxOf(objectives.map((node) => lines(node, columnW - u)))) * lineH + (wide ? 3.3 * u : pad), cells = Array.from({ length: rows }, (_, row) => Math.max(2, maxOf(columns.map((cells2) => cells2[row] ? lines(cells2[row], columnW - u) : 1))) * lineH + (wide ? 4.2 * u : pad)), bands = enablers.map((node) => lines(node, width - u) * lineH + pad), base = lines(foundation, width) * lineH + pad, roof = Math.max(3.6 * lineH, 0.09 * width), gap = { roof: 1.2 * u, header: wide ? 1.2 * u : 0.8 * u, cell: wide ? 1.2 * u : 0.8 * u, body: wide ? 2.8 * u : 2 * u, band: 0.6 * u, base: u }, height = roof + gap.roof + header + gap.header + cells.reduce((sum, value) => sum + value, 0) + Math.max(0, rows - 1) * gap.cell + (bands.length > 0 ? gap.body + bands.reduce((sum, value) => sum + value, 0) + (bands.length - 1) * gap.band + gap.base : gap.body) + base;
|
|
1053
|
+
return { roof, header, cells, bands, base, gap, height, inset: wide ? 0.8 * u : 0.6 * u };
|
|
1054
|
+
}
|
|
1055
|
+
function layoutStrategyHouse(context) {
|
|
1056
|
+
let result = emptyResult(context.data), vision = context.data.nodes.find((node) => node.kind === "vision"), foundation = context.data.nodes.find((node) => node.kind === "foundation"), enablers = context.data.nodes.filter((node) => node.kind === "enabler").sort(nodeOrder), objectives = context.data.nodes.filter((node) => node.kind === "objective").sort(nodeOrder), groups = context.data.groups, px = Math.ceil(context.plot.x * 2) / 2, py = Math.ceil(context.plot.y * 2) / 2, pw = Math.floor((context.plot.x + context.plot.w) * 2) / 2 - px, ph = Math.floor((context.plot.y + context.plot.h) * 2) / 2 - py, bands = strategyHouseBands(context.data, pw, context.u, context.font, context.measure, context.headFont), k = ph / bands.height, columnW = pw / groups.length, inset = bands.inset, bodyTop = py + (bands.roof + bands.gap.roof) * k, cellTop = bodyTop + (bands.header + bands.gap.header) * k, foundationTop = q(py + ph - bands.base * k);
|
|
1057
|
+
result.nodeRects.set(vision.id, qRect({ x: px, y: py, w: pw, h: bands.roof * k }));
|
|
1058
|
+
let visionWrap = wrapText(vision.label, context.headFont ?? context.font, Math.max(1, pw - 4 * context.u), 3, context.measure).lines, visionLines = visionWrap.length, roofH = bands.roof * k, widest = Math.max(...visionWrap.map((line) => context.measure(line, context.headFont ?? context.font).width)), clearOfSlopes = 2 * (roofH * (widest / 2 + context.u)) / (pw / 2) - roofH + visionLines * context.lineHeight, roofReserve = Math.min(Math.max(roofH / 3, clearOfSlopes), roofH - 2.5 * context.u - visionLines * context.lineHeight);
|
|
1059
|
+
roofReserve > 0 && result.contentTopReserves.set(vision.id, roofReserve);
|
|
1060
|
+
let bottom = cellTop;
|
|
1061
|
+
groups.forEach((group, groupIndex) => {
|
|
1062
|
+
let x = px + groupIndex * columnW, objective = objectives.find((node) => node.groupId === group.id) ?? objectives[groupIndex], titleBox = qRect({ x: x + inset, y: bodyTop, w: columnW - 2 * inset, h: bands.header * k });
|
|
1063
|
+
objective && result.nodeRects.set(objective.id, titleBox);
|
|
1064
|
+
let initiatives = context.data.nodes.filter((node) => node.kind === "initiative" && node.groupId === group.id).sort(nodeOrder), y2 = cellTop;
|
|
1065
|
+
initiatives.forEach((node, index) => {
|
|
1066
|
+
let h = (bands.cells[index] ?? bands.cells[bands.cells.length - 1]) * k;
|
|
1067
|
+
result.nodeRects.set(node.id, qRect({ x: x + inset, y: y2, w: columnW - 2 * inset, h })), y2 += h + bands.gap.cell * k;
|
|
1068
|
+
}), bottom = Math.max(bottom, cellTop + bands.cells.reduce((sum, value) => sum + value, 0) * k + Math.max(0, bands.cells.length - 1) * bands.gap.cell * k), result.groups.push({
|
|
1069
|
+
id: group.id,
|
|
1070
|
+
bounds: qRect({ x, y: bodyTop, w: columnW, h: bottom - bodyTop }),
|
|
1071
|
+
titleBox,
|
|
1072
|
+
memberNodeIds: [
|
|
1073
|
+
...objective ? [objective.id] : [],
|
|
1074
|
+
...initiatives.map((node) => node.id)
|
|
1075
|
+
]
|
|
1076
|
+
});
|
|
1077
|
+
});
|
|
1078
|
+
let y = bottom + bands.gap.body * k;
|
|
1079
|
+
return enablers.forEach((node, index) => {
|
|
1080
|
+
let h = bands.bands[index] * k;
|
|
1081
|
+
result.nodeRects.set(node.id, qRect({ x: px + inset, y, w: pw - 2 * inset, h })), y += h + bands.gap.band * k;
|
|
1082
|
+
}), result.nodeRects.set(
|
|
1083
|
+
foundation.id,
|
|
1084
|
+
qRect({
|
|
1085
|
+
x: px,
|
|
1086
|
+
y: foundationTop,
|
|
1087
|
+
w: pw,
|
|
1088
|
+
h: py + ph - foundationTop
|
|
1089
|
+
})
|
|
1090
|
+
), result.readingOrder = [
|
|
1091
|
+
vision.id,
|
|
1092
|
+
...objectives.map((node) => node.id),
|
|
1093
|
+
...groups.flatMap(
|
|
1094
|
+
(group) => context.data.nodes.filter((node) => node.kind === "initiative" && node.groupId === group.id).sort(nodeOrder).map((node) => node.id)
|
|
1095
|
+
),
|
|
1096
|
+
...enablers.map((node) => node.id),
|
|
1097
|
+
foundation.id
|
|
1098
|
+
], result;
|
|
1099
|
+
}
|
|
1100
|
+
function layoutRoadmap(theme, context) {
|
|
1101
|
+
let result = emptyResult(context.data), lanes = context.data.lanes, laneW = context.plot.w / lanes.length, headerH = 7 * context.u, trajectoryTop = context.plot.y + headerH + 6 * context.u, trajectoryBottom = context.plot.y + context.plot.h - 7 * context.u, milestones = lanes.flatMap(
|
|
1102
|
+
(lane) => context.data.nodes.filter((node) => node.laneId === lane.id && node.kind === "milestone").sort(nodeOrder)
|
|
1103
|
+
), ordinal = 0, points = [];
|
|
1104
|
+
if (lanes.forEach((lane, laneIndex) => {
|
|
1105
|
+
let x = context.plot.x + laneIndex * laneW, bounds = qRect({ x, y: context.plot.y, w: laneW, h: context.plot.h }), headerBox = qRect({ x, y: context.plot.y, w: laneW, h: headerH }), members = context.data.nodes.filter((node) => node.laneId === lane.id).sort(nodeOrder), laneMilestones = members.filter((node) => node.kind === "milestone");
|
|
1106
|
+
laneMilestones.forEach((node, localIndex) => {
|
|
1107
|
+
let authored = node.position, px = authored ? context.plot.x + authored.x * context.plot.w : x + (localIndex + 1) / (laneMilestones.length + 1) * laneW, progress = milestones.length === 1 ? 0.5 : ordinal / (milestones.length - 1), py = authored ? context.plot.y + authored.y * context.plot.h : trajectoryBottom - progress * (trajectoryBottom - trajectoryTop), diameter = Math.min(4 * context.u, context.sizes.get(node.id).height);
|
|
1108
|
+
result.nodeRects.set(
|
|
1109
|
+
node.id,
|
|
1110
|
+
qRect({ x: px - diameter / 2, y: py - diameter / 2, w: diameter, h: diameter })
|
|
1111
|
+
), points.push(qPoint({ x: px, y: py })), ordinal++;
|
|
1112
|
+
}), result.lanes.push({ id: lane.id, bounds, headerBox, memberNodeIds: members.map((node) => node.id) });
|
|
1113
|
+
let fill = context.palette.lane(lane.role, lane.paletteKey);
|
|
1114
|
+
if (result.decorationScene.push({
|
|
1115
|
+
t: "path",
|
|
1116
|
+
id: diagramSceneId("lane", lane.id, "header"),
|
|
1117
|
+
d: chevronPath(headerBox, Math.min(2 * context.u, headerBox.w / 6)),
|
|
1118
|
+
fill,
|
|
1119
|
+
owner: laneOwner(lane.id),
|
|
1120
|
+
part: "diagramLaneHeader"
|
|
1121
|
+
}), result.decorationClaims.push({ rect: headerBox, owner: laneOwner(lane.id), part: "diagramLaneHeader" }), laneIndex > 0) {
|
|
1122
|
+
let from = { x: q(x), y: q(context.plot.y + headerH) }, to = { x: q(x), y: q(context.plot.y + context.plot.h) };
|
|
1123
|
+
result.decorationScene.push({
|
|
1124
|
+
t: "line",
|
|
1125
|
+
id: diagramSceneId("lane", lane.id, "partition"),
|
|
1126
|
+
x1: from.x,
|
|
1127
|
+
y1: from.y,
|
|
1128
|
+
x2: to.x,
|
|
1129
|
+
y2: to.y,
|
|
1130
|
+
stroke: { token: "grid" },
|
|
1131
|
+
width: strokeToken(theme, "rule"),
|
|
1132
|
+
dash: dashToken(theme, "reference"),
|
|
1133
|
+
owner: laneOwner(lane.id),
|
|
1134
|
+
part: "diagramLanePartition"
|
|
1135
|
+
}), result.decorationClaims.push({
|
|
1136
|
+
rect: segmentBounds(from, to, 1),
|
|
1137
|
+
owner: laneOwner(lane.id),
|
|
1138
|
+
part: "diagramLanePartition"
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
}), result.trajectory = points, points.length > 0) {
|
|
1142
|
+
let d = points.length === 1 ? `M${q(points[0].x - 2 * context.u)} ${q(points[0].y)}L${q(points[0].x + 2 * context.u)} ${q(points[0].y)}` : monotonePath(points);
|
|
1143
|
+
result.decorationScene.push({
|
|
1144
|
+
t: "path",
|
|
1145
|
+
id: diagramSceneId("roadmap", "trajectory"),
|
|
1146
|
+
d,
|
|
1147
|
+
stroke: { token: "axis" },
|
|
1148
|
+
width: strokeToken(theme, "rule"),
|
|
1149
|
+
lineCap: "round",
|
|
1150
|
+
owner: {},
|
|
1151
|
+
part: "diagramTrajectory"
|
|
1152
|
+
});
|
|
1153
|
+
let claimPoints = points.length === 1 ? [
|
|
1154
|
+
{ x: q(points[0].x - 2 * context.u), y: q(points[0].y) },
|
|
1155
|
+
{ x: q(points[0].x + 2 * context.u), y: q(points[0].y) }
|
|
1156
|
+
] : monotoneSegments(points).flatMap(
|
|
1157
|
+
(segment, segmentIndex) => sampleCubic(segment.from, segment.c1, segment.c2, segment.to).slice(
|
|
1158
|
+
segmentIndex === 0 ? 0 : 1
|
|
1159
|
+
)
|
|
1160
|
+
);
|
|
1161
|
+
claimPoints.slice(0, -1).forEach((from, index) => {
|
|
1162
|
+
let to = claimPoints[index + 1], midpoint = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 }, localMilestone = points.map((point, pointIndex) => ({
|
|
1163
|
+
pointIndex,
|
|
1164
|
+
distance: Math.hypot(point.x - midpoint.x, point.y - midpoint.y)
|
|
1165
|
+
})).sort((a, b) => a.distance - b.distance || a.pointIndex - b.pointIndex)[0];
|
|
1166
|
+
result.decorationClaims.push({
|
|
1167
|
+
rect: segmentBounds(from, to, 2),
|
|
1168
|
+
owner: localMilestone && localMilestone.distance <= 5 * context.u ? nodeOwner(milestones[localMilestone.pointIndex].id) : {},
|
|
1169
|
+
part: "diagramTrajectory"
|
|
1170
|
+
});
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
return result.readingOrder = lanes.flatMap(
|
|
1174
|
+
(lane) => context.data.nodes.filter((node) => node.laneId === lane.id).sort(nodeOrder).map((node) => node.id)
|
|
1175
|
+
), result;
|
|
1176
|
+
}
|
|
1177
|
+
function sampleCubic(from, c1, c2, to) {
|
|
1178
|
+
return Array.from({ length: 33 }, (_, index) => {
|
|
1179
|
+
let t = index / 32, inverse = 1 - t;
|
|
1180
|
+
return qPoint({
|
|
1181
|
+
x: inverse * inverse * inverse * from.x + 3 * inverse * inverse * t * c1.x + 3 * inverse * t * t * c2.x + t * t * t * to.x,
|
|
1182
|
+
y: inverse * inverse * inverse * from.y + 3 * inverse * inverse * t * c1.y + 3 * inverse * t * t * c2.y + t * t * t * to.y
|
|
1183
|
+
});
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
function groupsFromMembers(context, result) {
|
|
1187
|
+
let centre = (rect) => rect.x + rect.w / 2, parents = new Map(result.edges.flatMap((edge) => edge.target.portId === "auto:tree-top" ? [[edge.target.nodeId, centre(result.nodeRects.get(edge.source.nodeId))]] : [])), font = context.titleFont, line = font.size * (font.lineHeight ?? 1.2), width = (text) => context.measure(text, font).width, groups = context.data.groups.map((group) => {
|
|
1188
|
+
let members = context.data.nodes.filter((node) => node.groupId === group.id), rects = members.map((node) => result.nodeRects.get(node.id)), pad = group.padding ?? 3 * context.u;
|
|
1189
|
+
return { group, members, rects, memberBounds: boundsOf(rects), pad };
|
|
1190
|
+
}), frames = groups.map(({ memberBounds: b, pad }) => ({ x: b.x - pad, y: b.y - pad, w: b.w + 2 * pad, h: b.h + 2 * pad }));
|
|
1191
|
+
return groups.map(({ group, members, rects, memberBounds, pad }, index) => {
|
|
1192
|
+
let header = Math.max(group.padding ?? pad, line + context.u / 2), left = memberBounds.x - pad, right = memberBounds.x + memberBounds.w + pad, title = { x: memberBounds.x, w: memberBounds.w }, entered = rects.filter((rect, at) => parents.has(members[at].id) && rect.y === memberBounds.y);
|
|
1193
|
+
if (entered.length > 0) {
|
|
1194
|
+
let crossings = entered.map(centre).sort((a, b) => a - b), edges = [left, ...crossings.flatMap((x) => [x - context.u, x + context.u]), right], stretches = edges.flatMap((x, at) => at % 2 === 0 ? [{ x, w: edges[at + 1] - x }] : []), top = memberBounds.y - pad, bottom = memberBounds.y + memberBounds.h + pad, beside = [...frames.filter((_, at) => at !== index), ...[...result.nodeRects].flatMap(([id, rect]) => members.some((node) => node.id === id) ? [] : [rect])].filter((rect) => rect.y < bottom && rect.y + rect.h > top), roomLeft = Math.max(0, left - Math.max(context.plot.x, maxOf(beside.filter((rect) => rect.x + rect.w <= left).map((rect) => rect.x + rect.w + context.u)))), roomRight = Math.max(0, Math.min(context.plot.x + context.plot.w, minOf(beside.filter((rect) => rect.x >= right).map((rect) => rect.x - context.u))) - right), runs = entered.map((rect) => {
|
|
1195
|
+
let [a, b] = [centre(rect), parents.get(members[rects.indexOf(rect)].id)].sort((p, q2) => p - q2);
|
|
1196
|
+
return { a, b };
|
|
1197
|
+
}), place = (need, clearOfRuns) => {
|
|
1198
|
+
let fits = stretches.map((stretch2, at2) => ({ stretch: stretch2, at: at2, room: at2 === 0 ? roomLeft : at2 === stretches.length - 1 ? roomRight : 0 })).filter(({ stretch: stretch2, room }) => stretch2.w + room >= need && (!clearOfRuns || runs.every(({ a, b }) => stretch2.x >= b || stretch2.x + stretch2.w <= a)));
|
|
1199
|
+
if (fits.length === 0) return !1;
|
|
1200
|
+
let { stretch, at } = fits.reduce((best, fit) => fit.stretch.w > best.stretch.w ? fit : best), grow = Math.max(0, need - stretch.w);
|
|
1201
|
+
return at === 0 ? left -= grow : right += grow, title = { x: at === 0 ? stretch.x - grow : stretch.x, w: stretch.w + grow }, !0;
|
|
1202
|
+
};
|
|
1203
|
+
if (!place(width(group.title) + 2 * context.u, !0) && !place(width(group.title) + 2 * context.u, !1)) {
|
|
1204
|
+
let words = group.title.split(" "), split = words.slice(1).map((_, at) => Math.max(width(words.slice(0, at + 1).join(" ")), width(words.slice(at + 1).join(" "))));
|
|
1205
|
+
split.length > 0 && place(Math.min(...split) + 2 * context.u, !0) ? header = Math.max(header, 2 * line + context.u / 2) : title = stretches.reduce((best, stretch) => stretch.w > best.w ? stretch : best);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return frames[index] = { x: left, y: memberBounds.y - header, w: right - left, h: memberBounds.h + header + pad }, {
|
|
1209
|
+
id: group.id,
|
|
1210
|
+
bounds: qRect(frames[index]),
|
|
1211
|
+
titleBox: qRect({
|
|
1212
|
+
x: title.x,
|
|
1213
|
+
y: memberBounds.y - header,
|
|
1214
|
+
w: title.w,
|
|
1215
|
+
h: header
|
|
1216
|
+
}),
|
|
1217
|
+
memberNodeIds: members.map((node) => node.id)
|
|
1218
|
+
};
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
function nodeOrder(a, b) {
|
|
1222
|
+
return a.order === void 0 || b.order === void 0 ? 0 : a.order - b.order || compareText(a.id, b.id);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// src/core/charts/diagram/orgChart.ts
|
|
1226
|
+
var snap = (value) => Math.round(value - 0.5) + 0.5, snapUp = (value) => Math.ceil(value) + 0.5;
|
|
1227
|
+
function orgChartEligible(data, options) {
|
|
1228
|
+
return options.variant === "hierarchy" && plainTree(data, !0, 2);
|
|
1229
|
+
}
|
|
1230
|
+
function plainTree(data, icons, maxDepth) {
|
|
1231
|
+
if (data.groups.length > 0 || data.lanes.length > 0 || data.nodes.length < 2 || data.edges.length !== data.nodes.length - 1) return !1;
|
|
1232
|
+
let plainNode = (node) => !node.position && !node.ports?.length && !node.size && !node.minSize && !node.caption && !node.badge && !node.secondaryLabel && !node.groupId && !node.laneId && (icons || !node.icon) && !node.label.includes(`
|
|
1233
|
+
`) && (node.shape.kind === "roundedRect" || node.shape.kind === "rectangle");
|
|
1234
|
+
if (!data.nodes.every(plainNode) || !data.edges.every((edge) => !edge.dash && !edge.label && !edge.waypoints?.length && !edge.arrowStart && !edge.arrowEnd && !edge.source.portId && !edge.target.portId && (edge.routing === void 0 || edge.routing === "orthogonal"))) return !1;
|
|
1235
|
+
let incoming = new Map(data.nodes.map((node) => [node.id, 0]));
|
|
1236
|
+
for (let edge of data.edges) {
|
|
1237
|
+
if (!incoming.has(edge.source.nodeId) || !incoming.has(edge.target.nodeId)) return !1;
|
|
1238
|
+
incoming.set(edge.target.nodeId, incoming.get(edge.target.nodeId) + 1);
|
|
1239
|
+
}
|
|
1240
|
+
if ([...incoming].filter(([, count]) => count === 0).length !== 1 || [...incoming.values()].some((count) => count > 1)) return !1;
|
|
1241
|
+
let depth = levelsOf(data);
|
|
1242
|
+
return depth !== void 0 && depth.size === data.nodes.length && maxOf(depth.values()) <= maxDepth;
|
|
1243
|
+
}
|
|
1244
|
+
function levelsOf(data) {
|
|
1245
|
+
let targets = new Set(data.edges.map((edge) => edge.target.nodeId)), root = data.nodes.find((node) => !targets.has(node.id));
|
|
1246
|
+
if (!root) return;
|
|
1247
|
+
let levels = /* @__PURE__ */ new Map([[root.id, 0]]), queue = [root.id];
|
|
1248
|
+
for (; queue.length; ) {
|
|
1249
|
+
let id = queue.shift();
|
|
1250
|
+
for (let edge of data.edges)
|
|
1251
|
+
edge.source.nodeId !== id || levels.has(edge.target.nodeId) || (levels.set(edge.target.nodeId, levels.get(id) + 1), queue.push(edge.target.nodeId));
|
|
1252
|
+
}
|
|
1253
|
+
return levels;
|
|
1254
|
+
}
|
|
1255
|
+
var byOrder = (a, b) => a.order === void 0 || b.order === void 0 ? 0 : a.order - b.order || compareText(a.id, b.id);
|
|
1256
|
+
function layoutOrgChart(data, plot, labelFont, measure, u) {
|
|
1257
|
+
let levels = levelsOf(data), root = data.nodes.find((node) => levels.get(node.id) === 0), kidsOf = (id) => data.edges.filter((edge) => edge.source.nodeId === id).map((edge) => data.nodes.find((node) => node.id === edge.target.nodeId)).sort(byOrder), branches = kidsOf(root.id), leaves = new Map(branches.map((branch) => [branch.id, kidsOf(branch.id)])), leafFont = { ...labelFont, size: labelFont.size > 13 ? labelFont.size - 1 : labelFont.size }, fonts = new Map(data.nodes.map((node) => [node.id, levels.get(node.id) === 2 ? leafFont : labelFont])), text = (node) => measure(node.label, fonts.get(node.id)).width, icon = 4 * u, iconLead = 6.8 * u, padRight = u, leafPad = (mode2) => mode2 === "tree" ? 2 * u : 1.8 * u, need = (node, mode2) => node.icon ? iconLead + text(node) + padRight : (levels.get(node.id) === 2 ? leafPad(mode2) : 2 * u) + text(node) + padRight, rootNeed = text(root) + 4 * u + (root.icon ? icon + u : 0), maxNeed = (nodes, mode2) => Math.max(0, maxOf(nodes.map((node) => need(node, mode2)))), allLeaves = [...leaves.values()].flat(), wide = plot.w >= 160 * u, lineFloor = (font) => font.size * (font.lineHeight ?? 1.2) + 2 * u, heightsFor = (mode2) => {
|
|
1258
|
+
let base = mode2 === "tree" ? wide ? [8.8, 8, 6.8] : [8, 7.6, 6.4] : mode2 === "stacked" ? [7.2, 6.8, 5.8] : [6.8, 6.8, 5.6];
|
|
1259
|
+
return [Math.max(base[0] * u, lineFloor(labelFont)), Math.max(base[1] * u, lineFloor(labelFont)), Math.max(base[2] * u, lineFloor(leafFont))];
|
|
1260
|
+
};
|
|
1261
|
+
if (rootNeed > plot.w) return;
|
|
1262
|
+
let rects = /* @__PURE__ */ new Map(), put = (id, rect) => {
|
|
1263
|
+
rects.set(id, qRect(rect));
|
|
1264
|
+
}, routes = /* @__PURE__ */ new Map(), mode, height = 0;
|
|
1265
|
+
{
|
|
1266
|
+
let gap = (wide ? 2.4 : 1.6) * u, columnGap = (wide ? 10.8 : 6) * u, slots = branches.map((branch) => Math.max(1, leaves.get(branch.id).length)), total = slots.reduce((sum, value) => sum + value, 0), leafW = Math.min(28 * u, (plot.w - (branches.length - 1) * columnGap - slots.reduce((sum, value) => sum + (value - 1) * gap, 0)) / total), columns = slots.map((count) => count * leafW + (count - 1) * gap), narrowest = minOf(columns), branchW = Math.min(narrowest, Math.max(maxNeed(branches, "tree"), 0.65 * narrowest));
|
|
1267
|
+
if (leafW >= maxNeed(allLeaves, "tree") && branchW >= maxNeed(branches, "tree")) {
|
|
1268
|
+
mode = "tree";
|
|
1269
|
+
let [h0, h1, h2] = heightsFor(mode), [gap0, gap1] = (wide ? [7.2, 5.2] : [7.2, 4.8]).map((value) => value * u);
|
|
1270
|
+
height = h0 + gap0 + h1 + (allLeaves.length > 0 ? gap1 + h2 : 0);
|
|
1271
|
+
let top = plot.y + Math.max(0, (plot.h - height) / 2), rootW = Math.min(plot.w, Math.max(rootNeed, Math.min(1.29 * branchW, 0.36 * plot.w))), span = columns.reduce((sum, value) => sum + value, 0) + (branches.length - 1) * columnGap;
|
|
1272
|
+
put(root.id, { x: plot.x + (plot.w - rootW) / 2, y: top, w: rootW, h: h0 });
|
|
1273
|
+
let left = plot.x + (plot.w - span) / 2;
|
|
1274
|
+
branches.forEach((branch, index) => {
|
|
1275
|
+
let column = columns[index], branchY = top + h0 + gap0;
|
|
1276
|
+
put(branch.id, { x: left + (column - branchW) / 2, y: branchY, w: branchW, h: h1 });
|
|
1277
|
+
let kids = leaves.get(branch.id), rowW = kids.length * leafW + Math.max(0, kids.length - 1) * gap;
|
|
1278
|
+
kids.forEach((kid, kidIndex) => put(kid.id, {
|
|
1279
|
+
x: left + (column - rowW) / 2 + kidIndex * (leafW + gap),
|
|
1280
|
+
y: branchY + h1 + gap1,
|
|
1281
|
+
w: leafW,
|
|
1282
|
+
h: h2
|
|
1283
|
+
})), left += column + columnGap;
|
|
1284
|
+
});
|
|
1285
|
+
let bus = (parent, child, id) => {
|
|
1286
|
+
let from = snap(parent.x + parent.w / 2), to = snap(child.x + child.w / 2), y = snap(parent.y + parent.h + (child.y - parent.y - parent.h) / 2);
|
|
1287
|
+
routes.set(id, { points: from === to ? [{ x: from, y: parent.y + parent.h }, { x: to, y: child.y }] : [{ x: from, y: parent.y + parent.h }, { x: from, y }, { x: to, y }, { x: to, y: child.y }], targetSide: "top" });
|
|
1288
|
+
};
|
|
1289
|
+
for (let edge of data.edges) bus(rects.get(edge.source.nodeId), rects.get(edge.target.nodeId), edge.id);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
let spine = (parent, child, id) => {
|
|
1293
|
+
let x = snapUp(parent.x + 2 * u), y = snap(child.y + child.h / 2);
|
|
1294
|
+
routes.set(id, { points: [{ x, y: parent.y + parent.h }, { x, y }, { x: child.x, y }], targetSide: "left" });
|
|
1295
|
+
};
|
|
1296
|
+
if (!mode)
|
|
1297
|
+
for (let columnGap of [Math.max(2 * u, 0.035 * plot.w), 2 * u]) {
|
|
1298
|
+
let column = (plot.w - (branches.length - 1) * columnGap) / branches.length;
|
|
1299
|
+
if (column < maxNeed(branches, "stacked") || column - 3.6 * u < maxNeed(allLeaves, "stacked")) continue;
|
|
1300
|
+
mode = "stacked";
|
|
1301
|
+
let [h0, h1, h2] = heightsFor(mode), gap0 = 4.8 * u, first = 2.4 * u, pitch = h2 + 1.4 * u, deepest = Math.max(0, maxOf(branches.map((branch) => {
|
|
1302
|
+
let count = leaves.get(branch.id).length;
|
|
1303
|
+
return count === 0 ? 0 : first + count * pitch - 1.4 * u;
|
|
1304
|
+
})));
|
|
1305
|
+
height = h0 + gap0 + h1 + deepest;
|
|
1306
|
+
let top = plot.y + Math.max(0, (plot.h - height) / 2), rootW = Math.min(plot.w, Math.max(rootNeed, Math.min(1.29 * column, 0.36 * plot.w)));
|
|
1307
|
+
put(root.id, { x: plot.x + (plot.w - rootW) / 2, y: top, w: rootW, h: h0 }), branches.forEach((branch, index) => {
|
|
1308
|
+
let x = plot.x + index * (column + columnGap);
|
|
1309
|
+
put(branch.id, { x, y: top + h0 + gap0, w: column, h: h1 });
|
|
1310
|
+
let branchRect = rects.get(branch.id);
|
|
1311
|
+
leaves.get(branch.id).forEach((kid, kidIndex) => {
|
|
1312
|
+
let leaf = { x: x + 3.6 * u, y: branchRect.y + h1 + first + kidIndex * pitch, w: column - 3.6 * u, h: h2 };
|
|
1313
|
+
put(kid.id, leaf);
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
for (let edge of data.edges) {
|
|
1317
|
+
let parent = rects.get(edge.source.nodeId), child = rects.get(edge.target.nodeId);
|
|
1318
|
+
if (edge.source.nodeId !== root.id) {
|
|
1319
|
+
spine(parent, child, edge.id);
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
let from = snap(parent.x + parent.w / 2), to = snap(child.x + child.w / 2), y = snap(parent.y + parent.h + gap0 / 2);
|
|
1323
|
+
routes.set(edge.id, { points: [{ x: from, y: parent.y + parent.h }, { x: from, y }, { x: to, y }, { x: to, y: child.y }], targetSide: "top" });
|
|
1324
|
+
}
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
if (!mode && plot.w - 4 * u >= maxNeed(branches, "outline") && plot.w - 8 * u >= maxNeed(allLeaves, "outline")) {
|
|
1328
|
+
mode = "outline";
|
|
1329
|
+
let [h0, h1, h2] = heightsFor(mode), y = 0, placed = [[root.id, { x: plot.x, y, w: plot.w, h: h0 }]];
|
|
1330
|
+
y += h0 + 2 * u, branches.forEach((branch, index) => {
|
|
1331
|
+
placed.push([branch.id, { x: plot.x + 4 * u, y, w: plot.w - 4 * u, h: h1 }]), y += h1;
|
|
1332
|
+
let kids = leaves.get(branch.id);
|
|
1333
|
+
kids.forEach((kid, kidIndex) => {
|
|
1334
|
+
y += kidIndex === 0 ? 1.6 * u : 1.2 * u, placed.push([kid.id, { x: plot.x + 8 * u, y, w: plot.w - 8 * u, h: h2 }]), y += h2;
|
|
1335
|
+
}), index < branches.length - 1 && (y += kids.length > 0 ? 2.8 * u : 2 * u);
|
|
1336
|
+
}), height = y;
|
|
1337
|
+
let top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1338
|
+
for (let [id, rect] of placed) put(id, { ...rect, y: rect.y + top });
|
|
1339
|
+
for (let edge of data.edges) spine(rects.get(edge.source.nodeId), rects.get(edge.target.nodeId), edge.id);
|
|
1340
|
+
}
|
|
1341
|
+
if (!mode) return;
|
|
1342
|
+
let labelBoxes = /* @__PURE__ */ new Map(), icons = /* @__PURE__ */ new Map();
|
|
1343
|
+
for (let node of data.nodes) {
|
|
1344
|
+
let rect = rects.get(node.id), width = text(node), x;
|
|
1345
|
+
if (node.id === root.id) {
|
|
1346
|
+
let group = width + (node.icon ? icon + u : 0);
|
|
1347
|
+
x = rect.x + (rect.w - group) / 2 + (node.icon ? icon + u : 0);
|
|
1348
|
+
} else
|
|
1349
|
+
x = rect.x + (node.icon ? iconLead : levels.get(node.id) === 2 ? leafPad(mode) : 2 * u);
|
|
1350
|
+
node.icon && icons.set(node.id, { x: x - u - icon, y: rect.y + (rect.h - icon) / 2, w: icon, h: icon }), labelBoxes.set(node.id, { x, y: rect.y, w: Math.max(width, rect.x + rect.w - padRight - x), h: rect.h });
|
|
1351
|
+
}
|
|
1352
|
+
let readingOrder = [0, 1, 2].flatMap((level) => data.nodes.filter((node) => levels.get(node.id) === level).sort(byOrder).map((node) => node.id));
|
|
1353
|
+
return {
|
|
1354
|
+
mode,
|
|
1355
|
+
routes,
|
|
1356
|
+
fonts,
|
|
1357
|
+
labelBoxes,
|
|
1358
|
+
icons,
|
|
1359
|
+
preset: {
|
|
1360
|
+
nodeRects: rects,
|
|
1361
|
+
readingOrder,
|
|
1362
|
+
edges: [...data.edges],
|
|
1363
|
+
syntheticEdgeIds: [],
|
|
1364
|
+
groups: [],
|
|
1365
|
+
lanes: [],
|
|
1366
|
+
decorationScene: [],
|
|
1367
|
+
decorationClaims: [],
|
|
1368
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
// src/core/charts/diagram/issueTreeCompact.ts
|
|
1374
|
+
function issueTreeEligible(data, options) {
|
|
1375
|
+
if (options.variant !== "issue-tree" || !plainTree(data, !1, 4)) return !1;
|
|
1376
|
+
let levels = levelsOf(data), depth = maxOf(levels.values()), parents = new Set(data.edges.map((edge) => edge.source.nodeId));
|
|
1377
|
+
return depth >= 2 && data.nodes.every((node) => parents.has(node.id) || levels.get(node.id) === depth);
|
|
1378
|
+
}
|
|
1379
|
+
function layoutIssueTreeCompact(data, plot, labelFont, measure, u, headWeight) {
|
|
1380
|
+
let levels = levelsOf(data), depth = maxOf(levels.values()), root = data.nodes.find((node) => levels.get(node.id) === 0), kidsOf = (id) => data.edges.filter((edge) => edge.source.nodeId === id).map((edge) => data.nodes.find((node) => node.id === edge.target.nodeId)).sort(byOrder), parentOf = new Map(data.edges.map((edge) => [edge.target.nodeId, edge.source.nodeId])), bold = { ...labelFont, weight: headWeight }, fonts = new Map(data.nodes.map((node) => [node.id, (levels.get(node.id) ?? 0) <= 1 ? bold : labelFont])), text = (node) => measure(node.label, fonts.get(node.id)).width, byLevel = (level) => data.nodes.filter((node) => levels.get(node.id) === level), widest = (level) => maxOf(byLevel(level).map(text)), leavesInOrder = [], walk = (node) => {
|
|
1381
|
+
let kids = kidsOf(node.id);
|
|
1382
|
+
kids.length === 0 && leavesInOrder.push(node), kids.forEach(walk);
|
|
1383
|
+
};
|
|
1384
|
+
walk(root);
|
|
1385
|
+
let ancestors = (id) => {
|
|
1386
|
+
let out = [];
|
|
1387
|
+
for (let at = parentOf.get(id); at !== void 0; at = parentOf.get(at)) out.push(at);
|
|
1388
|
+
return out;
|
|
1389
|
+
}, leafGap = (previous, next) => {
|
|
1390
|
+
let before = ancestors(previous.id), shared = ancestors(next.id).findIndex((id) => before.includes(id));
|
|
1391
|
+
return [1.2, 3.2, 6, 6][Math.max(0, shared)] * u;
|
|
1392
|
+
}, wide = plot.w >= 160 * u, rects = /* @__PURE__ */ new Map(), put = (id, rect) => {
|
|
1393
|
+
rects.set(id, qRect(rect));
|
|
1394
|
+
}, routes = /* @__PURE__ */ new Map(), lineFloor = labelFont.size * (labelFont.lineHeight ?? 1.2) + 2 * u, mode;
|
|
1395
|
+
{
|
|
1396
|
+
let pad = 2 * u, need = Array.from({ length: depth + 1 }, (_, level) => widest(level) + 2 * pad), sum = need.reduce((total, value) => total + value, 0), gutter = Math.min(8.8 * u, (plot.w - sum) / depth);
|
|
1397
|
+
if (gutter >= 4.8 * u) {
|
|
1398
|
+
mode = "columns";
|
|
1399
|
+
let scale = (plot.w - depth * gutter) / sum, widths = need.map((value) => value * scale), heights = Array.from({ length: depth + 1 }, (_, level) => Math.max(lineFloor, (level === 0 ? wide ? 7.6 : 6.8 : level === 1 ? wide ? 6.8 : 6 : wide ? 6 : 5.6) * u)), xs = widths.map((_, level) => plot.x + widths.slice(0, level).reduce((total, value) => total + value, 0) + level * gutter), y = 0, centres = /* @__PURE__ */ new Map();
|
|
1400
|
+
leavesInOrder.forEach((leaf, index) => {
|
|
1401
|
+
index > 0 && (y += leafGap(leavesInOrder[index - 1], leaf));
|
|
1402
|
+
let h = heights[depth];
|
|
1403
|
+
centres.set(leaf.id, y + h / 2), y += h;
|
|
1404
|
+
});
|
|
1405
|
+
let height = y, centreOf = (node) => {
|
|
1406
|
+
let known = centres.get(node.id);
|
|
1407
|
+
if (known !== void 0) return known;
|
|
1408
|
+
let kids = kidsOf(node.id).map(centreOf), centre = (kids[0] + kids.at(-1)) / 2;
|
|
1409
|
+
return centres.set(node.id, centre), centre;
|
|
1410
|
+
}, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1411
|
+
for (let node of data.nodes) {
|
|
1412
|
+
let level = levels.get(node.id), h = heights[level];
|
|
1413
|
+
put(node.id, { x: xs[level], y: top + centreOf(node) - h / 2, w: widths[level], h });
|
|
1414
|
+
}
|
|
1415
|
+
for (let edge of data.edges) {
|
|
1416
|
+
let parent = rects.get(edge.source.nodeId), child = rects.get(edge.target.nodeId), from = snap(parent.y + parent.h / 2), to = snap(child.y + child.h / 2), x = snap(parent.x + parent.w + gutter / 2);
|
|
1417
|
+
routes.set(edge.id, {
|
|
1418
|
+
points: from === to ? [{ x: parent.x + parent.w, y: from }, { x: child.x, y: to }] : [{ x: parent.x + parent.w, y: from }, { x, y: from }, { x, y: to }, { x: child.x, y: to }],
|
|
1419
|
+
sourceSide: "right",
|
|
1420
|
+
targetSide: "left"
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
if (!mode)
|
|
1426
|
+
for (let [indent, bracket, pad] of [[4.8, 6, 2], [2.8, 2.8, 1.2], [2, 2, 1.2]]) {
|
|
1427
|
+
let indented = Math.max(...Array.from({ length: depth - 1 }, (_, index) => widest(index + 1))) + 2 * pad * u, leafNeed = widest(depth) + 2 * pad * u, spare = plot.w - (depth - 1) * indent * u - bracket * u - indented - leafNeed;
|
|
1428
|
+
if (widest(0) + 2 * pad * u > plot.w || spare < 0) continue;
|
|
1429
|
+
mode = "outline";
|
|
1430
|
+
let nodeW = indented + spare / 2, leafW = leafNeed + spare / 2, leafX = plot.x + plot.w - leafW, rootH = Math.max(lineFloor, 6.8 * u), branchH = Math.max(lineFloor, 6 * u), rowH = Math.max(lineFloor, 5.6 * u), placed = [[root.id, { x: plot.x, y: 0, w: plot.w, h: rootH }]], y = rootH + 3.2 * u, place = (node, isFirst) => {
|
|
1431
|
+
let level = levels.get(node.id), x = plot.x + level * indent * u, kids = kidsOf(node.id);
|
|
1432
|
+
if (level < depth - 1) {
|
|
1433
|
+
placed.push([node.id, { x, y, w: nodeW, h: branchH }]), y += branchH + 2 * u, kids.forEach((kid, index) => place(kid, index === 0));
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
isFirst || (y += 1.6 * u);
|
|
1437
|
+
let stack = kids.length * rowH + Math.max(0, kids.length - 1) * 1.2 * u, groupH = Math.max(rowH, stack);
|
|
1438
|
+
placed.push([node.id, { x, y: y + (groupH - rowH) / 2, w: nodeW, h: rowH }]), kids.forEach((kid, index) => placed.push([kid.id, { x: leafX, y: y + (groupH - stack) / 2 + index * (rowH + 1.2 * u), w: leafW, h: rowH }])), y += groupH;
|
|
1439
|
+
};
|
|
1440
|
+
kidsOf(root.id).forEach((branch, index) => {
|
|
1441
|
+
index > 0 && (y += 3.2 * u), place(branch, !0);
|
|
1442
|
+
});
|
|
1443
|
+
let top = plot.y + Math.max(0, (plot.h - y) / 2);
|
|
1444
|
+
for (let [id, rect] of placed) put(id, { ...rect, y: rect.y + top });
|
|
1445
|
+
for (let edge of data.edges) {
|
|
1446
|
+
let parent = rects.get(edge.source.nodeId), child = rects.get(edge.target.nodeId), childLevel = levels.get(edge.target.nodeId), to = snap(child.y + child.h / 2);
|
|
1447
|
+
if (childLevel === depth) {
|
|
1448
|
+
let from = snap(parent.y + parent.h / 2), x2 = snap(parent.x + parent.w + (child.x - parent.x - parent.w) / 2);
|
|
1449
|
+
routes.set(edge.id, {
|
|
1450
|
+
points: from === to ? [{ x: parent.x + parent.w, y: from }, { x: child.x, y: to }] : [{ x: parent.x + parent.w, y: from }, { x: x2, y: from }, { x: x2, y: to }, { x: child.x, y: to }],
|
|
1451
|
+
sourceSide: "right",
|
|
1452
|
+
targetSide: "left"
|
|
1453
|
+
});
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
let x = snap(parent.x + Math.min(indent * u, child.x - parent.x) / 2);
|
|
1457
|
+
routes.set(edge.id, { points: [{ x, y: parent.y + parent.h }, { x, y: to }, { x: child.x, y: to }], targetSide: "left" });
|
|
1458
|
+
}
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
if (!mode) return;
|
|
1462
|
+
let labelBoxes = /* @__PURE__ */ new Map();
|
|
1463
|
+
for (let node of data.nodes) {
|
|
1464
|
+
let rect = rects.get(node.id);
|
|
1465
|
+
labelBoxes.set(node.id, { x: rect.x + u, y: rect.y, w: Math.max(1, rect.w - 2 * u), h: rect.h });
|
|
1466
|
+
}
|
|
1467
|
+
let rings = new Map(data.nodes.filter((node) => levels.get(node.id) === depth && (node.role === "muted" || node.role === void 0)).map((node) => [node.id, { stroke: { token: "neutral", tint: 0.7 }, width: 0.75 }]));
|
|
1468
|
+
return {
|
|
1469
|
+
mode,
|
|
1470
|
+
routes,
|
|
1471
|
+
fonts,
|
|
1472
|
+
labelBoxes,
|
|
1473
|
+
icons: /* @__PURE__ */ new Map(),
|
|
1474
|
+
centred: !0,
|
|
1475
|
+
rings,
|
|
1476
|
+
preset: {
|
|
1477
|
+
nodeRects: rects,
|
|
1478
|
+
readingOrder: Array.from({ length: depth + 1 }, (_, level) => byLevel(level).sort(byOrder).map((node) => node.id)).flat(),
|
|
1479
|
+
edges: [...data.edges],
|
|
1480
|
+
syntheticEdgeIds: [],
|
|
1481
|
+
groups: [],
|
|
1482
|
+
lanes: [],
|
|
1483
|
+
decorationScene: [],
|
|
1484
|
+
decorationClaims: [],
|
|
1485
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// src/core/charts/diagram/journeyCompact.ts
|
|
1491
|
+
function journeyEligible(data, options) {
|
|
1492
|
+
return options.variant !== "customer-journey" || options.flow === "serpentine" || data.edges.length > 0 || data.groups.length > 0 || data.lanes.length === 0 || data.lanes.length > 8 ? !1 : data.nodes.every((node) => node.kind === "painPoint" && node.laneId && !node.position && !node.ports?.length && !node.size && !node.minSize && !node.caption && !node.badge && !node.secondaryLabel && !node.label.includes(`
|
|
1493
|
+
`) && (node.shape.kind === "roundedRect" || node.shape.kind === "rectangle"));
|
|
1494
|
+
}
|
|
1495
|
+
var judged = (node) => node.role === "bad" || node.role === "warn" || node.role === "good";
|
|
1496
|
+
function layoutJourneyCompact(data, options, plot, labelFont, headerFont, measure, u, palette, headWeight) {
|
|
1497
|
+
let lanes = data.lanes, members = new Map(lanes.map((lane) => [lane.id, data.nodes.filter((node) => node.laneId === lane.id).sort(byOrder)])), card = { ...labelFont, size: labelFont.size > 13 ? labelFont.size - 1 : labelFont.size }, bold = { ...card, weight: headWeight }, fonts = new Map(data.nodes.map((node) => [node.id, judged(node) ? bold : card])), lineH = card.size * (card.lineHeight ?? 1.2), pad = 2 * u, padRight = 1.2 * u, icon = 2.6 * u, lead = (node) => node.icon ? 5.2 * u : pad, linesIn = (node, width) => wrapText(node.label, fonts.get(node.id), Math.max(1, width - lead(node) - padRight), 3, measure), fits = (node, width, maxLines) => {
|
|
1498
|
+
let wrapped = linesIn(node, width);
|
|
1499
|
+
return !wrapped.truncated && wrapped.lines.length <= maxLines;
|
|
1500
|
+
}, cardH = (lines) => Math.max(6 * u, lines * lineH + 2.6 * u), headerText = (label) => label ? measure(label, headerFont).width : 0, rects = /* @__PURE__ */ new Map(), put = (id, rect) => {
|
|
1501
|
+
rects.set(id, qRect(rect));
|
|
1502
|
+
}, result = {
|
|
1503
|
+
nodeRects: rects,
|
|
1504
|
+
readingOrder: lanes.flatMap((lane) => members.get(lane.id).map((node) => node.id)),
|
|
1505
|
+
edges: [],
|
|
1506
|
+
syntheticEdgeIds: [],
|
|
1507
|
+
groups: [],
|
|
1508
|
+
lanes: [],
|
|
1509
|
+
decorationScene: [],
|
|
1510
|
+
decorationClaims: [],
|
|
1511
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
1512
|
+
}, header = (laneId, d, box, fill) => {
|
|
1513
|
+
result.decorationScene.push({ t: "path", id: diagramSceneId("lane", laneId, "header"), d, fill, owner: laneOwner(laneId), part: "diagramLaneHeader" }), result.decorationClaims.push({ rect: box, owner: laneOwner(laneId), part: "diagramLaneHeader" });
|
|
1514
|
+
}, mode, gap = 1.6 * u, pitch = (plot.w + gap) / lanes.length, boxW = pitch - gap, tip = Math.min(1.6 * u, boxW / 6);
|
|
1515
|
+
if (lanes.every((lane) => headerText(lane.label) <= boxW - 2 * tip - u) && data.nodes.every((node) => fits(node, boxW, 2))) {
|
|
1516
|
+
mode = "columns";
|
|
1517
|
+
let headerH = 6 * u, rows = Math.max(0, maxOf(lanes.map((lane) => members.get(lane.id).length))), rowHeights = Array.from({ length: rows }, (_, row) => Math.max(0, maxOf(lanes.map((lane) => {
|
|
1518
|
+
let node = members.get(lane.id)[row];
|
|
1519
|
+
return node ? cardH(linesIn(node, boxW).lines.length) : 0;
|
|
1520
|
+
})))), height = headerH + (rows > 0 ? 2 * u : 0) + rowHeights.reduce((sum, value) => sum + value, 0) + Math.max(0, rows - 1) * 1.2 * u, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1521
|
+
lanes.forEach((lane, index) => {
|
|
1522
|
+
let x = plot.x + index * pitch, box = qRect({ x, y: top, w: boxW, h: headerH }), y = top + headerH + 2 * u;
|
|
1523
|
+
members.get(lane.id).forEach((node, row) => {
|
|
1524
|
+
put(node.id, { x, y, w: boxW, h: rowHeights[row] }), y += rowHeights[row] + 1.2 * u;
|
|
1525
|
+
});
|
|
1526
|
+
let bottom = Math.max(box.y + box.h, maxOf(members.get(lane.id).map((node) => rects.get(node.id).y + rects.get(node.id).h)));
|
|
1527
|
+
result.lanes.push({ id: lane.id, bounds: qRect({ x, y: top, w: boxW, h: bottom - top }), headerBox: box, memberNodeIds: members.get(lane.id).map((node) => node.id) });
|
|
1528
|
+
let d = index === 0 ? `M${q(box.x)} ${q(box.y)}L${q(box.x + box.w - tip)} ${q(box.y)}L${q(box.x + box.w)} ${q(box.y + box.h / 2)}L${q(box.x + box.w - tip)} ${q(box.y + box.h)}L${q(box.x)} ${q(box.y + box.h)}Z` : chevronPath(box, tip);
|
|
1529
|
+
header(lane.id, d, box, palette.lane(lane.role, lane.paletteKey));
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
if (!mode && options.variant === "customer-journey" && options.flow === void 0) {
|
|
1533
|
+
let chevronW = Math.max(maxOf(lanes.map((lane) => headerText(lane.label))) + 4 * u, Math.min(18.4 * u, 0.25 * plot.w)), cardGap = 1.2 * u, left = plot.x + chevronW + 1.6 * u, cardW = (plot.x + plot.w - left - cardGap) / 2;
|
|
1534
|
+
if (cardW > 0 && data.nodes.every((node) => fits(node, cardW, 3))) {
|
|
1535
|
+
mode = "rows";
|
|
1536
|
+
let tipH = 1.2 * u, y = 0, placed = [];
|
|
1537
|
+
lanes.forEach((lane) => {
|
|
1538
|
+
let cards = members.get(lane.id), rowHeights = [];
|
|
1539
|
+
for (let i = 0; i < cards.length; i += 2)
|
|
1540
|
+
rowHeights.push(Math.max(...cards.slice(i, i + 2).map((node) => cardH(linesIn(node, cardW).lines.length))));
|
|
1541
|
+
let stack = rowHeights.reduce((sum, value) => sum + value, 0) + Math.max(0, rowHeights.length - 1) * cardGap, bodyH = Math.max(stack + 0.8 * u, 7.6 * u), out = [], cardY = y + (bodyH - stack) / 2;
|
|
1542
|
+
rowHeights.forEach((rowH, row) => {
|
|
1543
|
+
cards.slice(row * 2, row * 2 + 2).forEach((node, column) => out.push([node.id, { x: left + column * (cardW + cardGap), y: cardY, w: cardW, h: rowH }])), cardY += rowH + cardGap;
|
|
1544
|
+
}), placed.push({ lane: lane.id, box: { x: plot.x, y, w: chevronW, h: bodyH }, cards: out }), y += bodyH + u;
|
|
1545
|
+
});
|
|
1546
|
+
let height = y - u + tipH, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1547
|
+
placed.forEach(({ lane: laneId, box: raw, cards }, index) => {
|
|
1548
|
+
let box = qRect({ ...raw, y: raw.y + top });
|
|
1549
|
+
for (let [id, rect] of cards) put(id, { ...rect, y: rect.y + top });
|
|
1550
|
+
let lane = lanes.find((candidate) => candidate.id === laneId), mid = box.x + box.w / 2, d = `M${q(box.x)} ${q(box.y)}` + (index > 0 ? `L${q(mid)} ${q(box.y + tipH)}` : "") + `L${q(box.x + box.w)} ${q(box.y)}L${q(box.x + box.w)} ${q(box.y + box.h)}L${q(mid)} ${q(box.y + box.h + tipH)}L${q(box.x)} ${q(box.y + box.h)}Z`, label = qRect({ x: box.x, y: box.y + (index > 0 ? tipH : 0), w: box.w, h: box.h - (index > 0 ? tipH : 0) }), memberIds = members.get(laneId).map((node) => node.id), bottom = Math.max(box.y + box.h + tipH, maxOf(memberIds.map((id) => rects.get(id).y + rects.get(id).h)));
|
|
1551
|
+
result.lanes.push({ id: laneId, bounds: qRect({ x: plot.x, y: box.y, w: plot.w, h: bottom - box.y }), headerBox: label, memberNodeIds: memberIds }), header(laneId, d, { ...box, h: box.h + tipH }, palette.lane(lane.role, lane.paletteKey));
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
if (!mode) return;
|
|
1556
|
+
let labelBoxes = /* @__PURE__ */ new Map(), icons = /* @__PURE__ */ new Map(), fills = /* @__PURE__ */ new Map(), rings = /* @__PURE__ */ new Map();
|
|
1557
|
+
for (let node of data.nodes) {
|
|
1558
|
+
let rect = rects.get(node.id), x = rect.x + lead(node);
|
|
1559
|
+
labelBoxes.set(node.id, { x, y: rect.y, w: Math.max(1, rect.x + rect.w - padRight - x), h: rect.h }), node.icon && icons.set(node.id, { x: rect.x + 2.8 * u - icon / 2, y: rect.y + (rect.h - icon) / 2, w: icon, h: icon }), judged(node) ? node.role === "bad" && fills.set(node.id, markRolePaint("bad")) : (fills.set(node.id, { token: "background" }), rings.set(node.id, { stroke: { token: "leader" }, width: 1 }));
|
|
1560
|
+
}
|
|
1561
|
+
return { mode, preset: result, routes: /* @__PURE__ */ new Map(), fonts, labelBoxes, icons, rings, fills, plainShape: !0 };
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// src/core/charts/diagram/linearCompact.ts
|
|
1565
|
+
function linearEligible(data, options) {
|
|
1566
|
+
return options.variant !== "linear-process" || data.edges.length > 0 || data.groups.length > 0 || data.lanes.length > 0 || data.nodes.length === 0 ? !1 : data.nodes.every((node) => node.kind === "step" && node.shape.kind === "chevron" && !node.position && !node.ports?.length && !node.size && !node.minSize && !node.badge && !node.secondaryLabel && !node.label.includes(`
|
|
1567
|
+
`));
|
|
1568
|
+
}
|
|
1569
|
+
function layoutLinearCompact(data, plot, nameFont, badgeFont, captionFont, measure, u, badgeText, headerGap = 0) {
|
|
1570
|
+
let steps = [...data.nodes].sort(byOrder), n = steps.length, size = nameFont.size, lineH = size * (nameFont.lineHeight ?? 1.2), captionLineH = captionFont.size * (captionFont.lineHeight ?? 1.2), nameW = (node) => measure(node.label, nameFont).width, disc = q(Math.max(20, badgeFont.size * 1.5, maxOf(steps.map((node) => measure(badgeText(node), badgeFont).width + 2 * u)))), discGap = 1.5 * u, icons = steps.some((node) => node.icon), rects = /* @__PURE__ */ new Map(), labelBoxes = /* @__PURE__ */ new Map(), iconBoxes = /* @__PURE__ */ new Map(), badges = /* @__PURE__ */ new Map(), paths = /* @__PURE__ */ new Map(), captionBoxes = /* @__PURE__ */ new Map(), extent = [], fonts = new Map(steps.map((node) => [node.id, nameFont])), result = {
|
|
1571
|
+
nodeRects: rects,
|
|
1572
|
+
readingOrder: steps.map((node) => node.id),
|
|
1573
|
+
edges: [],
|
|
1574
|
+
syntheticEdgeIds: [],
|
|
1575
|
+
groups: [],
|
|
1576
|
+
lanes: [],
|
|
1577
|
+
decorationScene: [],
|
|
1578
|
+
decorationClaims: [],
|
|
1579
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
1580
|
+
}, captionLines = (node, width) => node.caption ? wrapText(node.caption, captionFont, Math.max(1, width), 2, measure) : void 0, mode, rowH = q(icons ? Math.min(10 * size, Math.max(6.5 * size, 0.1 * plot.w)) : 4 * size), tip = q(0.2 * rowH), gap = 1.5 * u, chevronW = (plot.w + (n - 1) * (tip - gap)) / n, pitch = chevronW - tip + gap, nameRoom = chevronW - 2 * tip - 2 * u - disc - discGap, nameLines = (node) => wrapText(node.label, nameFont, Math.max(1, nameRoom), 2, measure), linesW = (lines) => Math.max(...lines.map((line) => measure(line, nameFont).width));
|
|
1581
|
+
if (nameRoom >= 12 * u && steps.every((node) => !nameLines(node).truncated) && steps.every((node) => {
|
|
1582
|
+
let lines = captionLines(node, pitch - u);
|
|
1583
|
+
return !lines || !lines.truncated;
|
|
1584
|
+
})) {
|
|
1585
|
+
mode = "columns";
|
|
1586
|
+
let captionH = Math.max(0, maxOf(steps.map((node) => (captionLines(node, pitch - u)?.lines.length ?? 0) * captionLineH))), height = rowH + (captionH > 0 ? 3 * u + captionH : 0), spare = Math.max(0, plot.h - height), top = q(plot.y + Math.min(headerGap, spare) + Math.max(0, (spare - headerGap) / 2));
|
|
1587
|
+
headerGap > 0 && extent.push(qRect({ x: plot.x, y: top - headerGap, w: plot.w, h: height + headerGap })), steps.forEach((node, index) => {
|
|
1588
|
+
let x = plot.x + index * pitch, centre = x + chevronW / 2;
|
|
1589
|
+
rects.set(node.id, qRect({ x, y: top, w: pitch - gap, h: rowH }));
|
|
1590
|
+
let right = x + chevronW;
|
|
1591
|
+
paths.set(node.id, `M${q(x)} ${top}L${q(right - tip)} ${top}L${q(right)} ${q(top + rowH / 2)}L${q(right - tip)} ${q(top + rowH)}L${q(x)} ${q(top + rowH)}` + (index > 0 ? `L${q(x + tip)} ${q(top + rowH / 2)}` : "") + "Z"), extent.push(qRect({ x, y: top, w: chevronW, h: rowH }));
|
|
1592
|
+
let row = icons ? top + 0.72 * rowH : top + rowH / 2, name = nameLines(node).lines, groupW = disc + discGap + linesW(name), left = centre - groupW / 2;
|
|
1593
|
+
if (badges.set(node.id, qRect({ x: left, y: row - disc / 2, w: disc, h: disc })), labelBoxes.set(node.id, { x: q(left + disc + discGap), y: row - name.length * lineH / 2, w: Math.ceil(linesW(name)) + 1, h: name.length * lineH }), node.icon) {
|
|
1594
|
+
let icon = q(0.3 * rowH);
|
|
1595
|
+
iconBoxes.set(node.id, { x: q(centre - icon / 2), y: q(top + 0.32 * rowH - icon / 2), w: icon, h: icon });
|
|
1596
|
+
}
|
|
1597
|
+
let lines = captionLines(node, pitch - u);
|
|
1598
|
+
if (lines) {
|
|
1599
|
+
let w = Math.max(...lines.lines.map((line) => measure(line, captionFont).width));
|
|
1600
|
+
captionBoxes.set(node.id, { rect: { x: q(centre - w / 2), y: q(top + rowH + 3 * u), w, h: lines.lines.length * captionLineH }, lines: lines.lines });
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
if (!mode) {
|
|
1605
|
+
let bandH = q(Math.max(2.6 * size, lineH + 2 * u, disc + 2 * u)), point = q(2 * u), stackGap = 1.5 * u, icon = q(Math.min(22, bandH - 2 * u)), lead = 2 * u + disc + discGap, tail = icons ? 2 * u + icon + 2 * u : 2 * u, need = Math.ceil(lead + maxOf(steps.map(nameW)) + tail), captionGap = 3 * u, widestCaption = Math.max(0, maxOf(steps.map((node) => node.caption ? measure(node.caption, captionFont).width : 0))), room = plot.w - (widestCaption > 0 ? captionGap + widestCaption : 0), bandW = Math.floor(Math.max(need, Math.min(75 * u, Math.round(0.65 * plot.w), room))), captionW = plot.w - bandW - captionGap;
|
|
1606
|
+
if (bandW > plot.w || steps.some((node) => captionLines(node, captionW)?.truncated)) return;
|
|
1607
|
+
let rowPitch = Math.max(bandH + stackGap, maxOf(steps.map((node) => (captionLines(node, captionW)?.lines.length ?? 0) * captionLineH + stackGap))), height = (n - 1) * rowPitch + bandH + point, top = plot.y + Math.max(0, (plot.h - height) / 2);
|
|
1608
|
+
steps.forEach((node, index) => {
|
|
1609
|
+
let x = q(plot.x), y = q(top + index * rowPitch), right = q(plot.x + bandW), mid = q(plot.x + bandW / 2);
|
|
1610
|
+
rects.set(node.id, { x, y, w: right - x, h: bandH }), paths.set(node.id, `M${x} ${y}` + (index > 0 ? `L${mid} ${q(y + point)}` : "") + `L${right} ${y}L${right} ${q(y + bandH)}L${mid} ${q(y + bandH + point)}L${x} ${q(y + bandH)}Z`), extent.push({ x, y, w: right - x, h: bandH + point });
|
|
1611
|
+
let row = y + bandH / 2 + (index > 0 ? point / 4 : 0);
|
|
1612
|
+
badges.set(node.id, qRect({ x: x + 2 * u, y: row - disc / 2, w: disc, h: disc })), labelBoxes.set(node.id, { x: q(x + lead), y: row - lineH / 2, w: Math.max(1, right - tail - (x + lead)), h: lineH }), node.icon && iconBoxes.set(node.id, { x: q(right - 2 * u - icon), y: q(row - icon / 2), w: icon, h: icon });
|
|
1613
|
+
let lines = captionLines(node, captionW);
|
|
1614
|
+
if (lines) {
|
|
1615
|
+
let w = Math.max(...lines.lines.map((line) => measure(line, captionFont).width)), h = lines.lines.length * captionLineH;
|
|
1616
|
+
captionBoxes.set(node.id, { rect: { x: q(right + captionGap), y: q(row - h / 2), w, h }, lines: lines.lines });
|
|
1617
|
+
}
|
|
1618
|
+
}), mode = "rows";
|
|
1619
|
+
}
|
|
1620
|
+
let muted = { token: "inkMuted" }, labelInks = new Map(steps.filter((node) => node.caption).map((node) => [`caption-label:${node.id}`, muted]));
|
|
1621
|
+
return {
|
|
1622
|
+
mode,
|
|
1623
|
+
preset: result,
|
|
1624
|
+
routes: /* @__PURE__ */ new Map(),
|
|
1625
|
+
fonts,
|
|
1626
|
+
labelBoxes,
|
|
1627
|
+
icons: iconBoxes,
|
|
1628
|
+
badges,
|
|
1629
|
+
badgePaint: { token: "background" },
|
|
1630
|
+
paths,
|
|
1631
|
+
captionBoxes,
|
|
1632
|
+
labelInks,
|
|
1633
|
+
extent,
|
|
1634
|
+
plainShape: !0
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
// src/core/charts/diagram/roadmapCompact.ts
|
|
1639
|
+
function roadmapEligible(data, options) {
|
|
1640
|
+
return options.variant !== "roadmap" || data.edges.length > 0 || data.groups.length > 0 || data.lanes.length === 0 || data.lanes.length > 8 ? !1 : data.nodes.every((node) => node.kind === "milestone" && node.laneId && node.shape.kind === "circle" && !node.position && !node.ports?.length && !node.size && !node.minSize && !node.caption && !node.badge && !node.secondaryLabel && !node.icon && !node.label.includes(`
|
|
1641
|
+
`));
|
|
1642
|
+
}
|
|
1643
|
+
function layoutRoadmapCompact(data, options, plot, labelFont, laneFont, measure, u, palette, theme) {
|
|
1644
|
+
let strokeWidth2 = strokeToken(theme, "rule"), lanes = data.lanes, members = new Map(lanes.map((lane) => [lane.id, data.nodes.filter((node) => node.laneId === lane.id).sort(byOrder)])), milestones = lanes.flatMap((lane) => members.get(lane.id)), m = milestones.length;
|
|
1645
|
+
if (m === 0) return;
|
|
1646
|
+
let lineH = labelFont.size * (labelFont.lineHeight ?? 1.2), wide = plot.w >= 110 * u, r = q((wide ? 0.46 : 0.385) * labelFont.size), bandH = q(2 * laneFont.size), tip = q(0.6 * laneFont.size), laneGap = 1, laneW = (plot.w - (lanes.length - 1) * laneGap) / lanes.length, textW = (lines) => Math.max(...lines.map((line) => measure(line, labelFont).width)), ramp = options.palette === void 0 && data.key.length === 0 && lanes.every((lane) => lane.role === "category" && data.nodes.some((node) => node.paletteKey !== void 0 && node.paletteKey === lane.paletteKey)), rampPaint = (index) => seriesPaint((index + 1) % lanes.length), laneFill = new Map(lanes.map((lane, index) => [lane.id, ramp ? rampPaint(index) : palette.lane(lane.role, lane.paletteKey)])), x0 = wide ? 4 * u : r + 3, lead = (dx, pitch2, height) => Math.max(r + u, dx * (height / 2 + 3) / pitch2 + 2.5), pitchMin = lineH + 1.5 * u, pitchMax = 7 * u, pitch = pitchMin, placed = [];
|
|
1647
|
+
for (let [laneIndex, lane] of lanes.entries()) {
|
|
1648
|
+
let nodes = members.get(lane.id), left = plot.x + laneIndex * (laneW + laneGap), right = left + laneW - (laneIndex === lanes.length - 1 ? 0 : 2), seat = (k, dx, wrap) => {
|
|
1649
|
+
let x = left + x0 + k * dx, room = right - x, single = measure(nodes[k].label, labelFont).width, offset = lead(dx, pitch, lineH);
|
|
1650
|
+
if (offset + single <= room) return { x, dx, lines: [nodes[k].label], offset };
|
|
1651
|
+
if (!wrap) return;
|
|
1652
|
+
let wrapped = wrapText(nodes[k].label, labelFont, Math.max(1, room - lead(dx, pitch, 2 * lineH)), 2, measure);
|
|
1653
|
+
return wrapped.truncated ? void 0 : { x, dx, lines: wrapped.lines, offset: lead(dx, pitch, wrapped.lines.length * lineH) };
|
|
1654
|
+
}, chosen;
|
|
1655
|
+
for (let wrap of [!1, !0]) for (let dx = Math.round(0.16 * laneW); dx >= 0 && !chosen; dx -= 2) {
|
|
1656
|
+
let seats2 = nodes.map((_, k) => seat(k, dx, wrap));
|
|
1657
|
+
seats2.every((value) => value !== void 0) && (chosen = seats2);
|
|
1658
|
+
}
|
|
1659
|
+
if (!chosen) return;
|
|
1660
|
+
chosen.forEach((value, k) => placed.push({ node: nodes[k], laneIndex, ...value }));
|
|
1661
|
+
}
|
|
1662
|
+
let heights = placed.map((item) => item.lines.length * lineH), gapsAt = (p) => placed.slice(1).map((_, i) => Math.max(p, (heights[i] + heights[i + 1]) / 2 + 2)), above = (p) => Math.max(p, heights[m - 1] / 2 + u), below = Math.max(r, heights[0] / 2) + 2 * u, total = (p) => bandH + above(p) + gapsAt(p).reduce((sum, value) => sum + value, 0) + below, rowPitch = pitchMax;
|
|
1663
|
+
for (; rowPitch > pitchMin && total(rowPitch) > plot.h; ) rowPitch = Math.max(pitchMin, rowPitch - 0.5);
|
|
1664
|
+
let gaps = gapsAt(rowPitch), bandTop = q(plot.y), bottomRow = bandTop + bandH + above(rowPitch) + gaps.reduce((sum, value) => sum + value, 0), ys = [bottomRow];
|
|
1665
|
+
gaps.forEach((gap) => ys.push(ys[ys.length - 1] - gap));
|
|
1666
|
+
let partitionBottom = q(bottomRow + below);
|
|
1667
|
+
placed.forEach((item, index) => {
|
|
1668
|
+
let next = placed[index + 1];
|
|
1669
|
+
item.offset = lead(item.dx, next && next.laneIndex === item.laneIndex ? gaps[index] : 1 / 0, heights[index]);
|
|
1670
|
+
});
|
|
1671
|
+
let rects = /* @__PURE__ */ new Map(), seats = /* @__PURE__ */ new Map(), fills = /* @__PURE__ */ new Map(), rings = /* @__PURE__ */ new Map(), points = [];
|
|
1672
|
+
placed.forEach((item, index) => {
|
|
1673
|
+
let y = q(ys[index]), x = q(item.x);
|
|
1674
|
+
rects.set(item.node.id, { x: x - r, y: y - r, w: 2 * r, h: 2 * r });
|
|
1675
|
+
let h = heights[index];
|
|
1676
|
+
seats.set(item.node.id, { rect: qRect({ x: x + item.offset, y: y - h / 2, w: textW(item.lines), h }), lines: item.lines });
|
|
1677
|
+
let lane = lanes[item.laneIndex];
|
|
1678
|
+
ramp && item.node.role === "category" && item.node.paletteKey === lane.paletteKey && fills.set(item.node.id, laneFill.get(lane.id)), rings.set(item.node.id, { stroke: { token: "axis" }, width: 0.75 }), index > 0 && placed[index - 1].laneIndex !== item.laneIndex && points.push({ x: points[points.length - 1].x, y }), points.push({ x, y });
|
|
1679
|
+
});
|
|
1680
|
+
let result = {
|
|
1681
|
+
nodeRects: rects,
|
|
1682
|
+
readingOrder: milestones.map((node) => node.id),
|
|
1683
|
+
edges: [],
|
|
1684
|
+
syntheticEdgeIds: [],
|
|
1685
|
+
groups: [],
|
|
1686
|
+
lanes: [],
|
|
1687
|
+
decorationScene: [],
|
|
1688
|
+
decorationClaims: [],
|
|
1689
|
+
contentTopReserves: /* @__PURE__ */ new Map()
|
|
1690
|
+
};
|
|
1691
|
+
lanes.forEach((lane, index) => {
|
|
1692
|
+
let x = plot.x + index * (laneW + laneGap), box = qRect({ x, y: bandTop, w: laneW, h: bandH }), d2 = `M${box.x} ${box.y}L${q(box.x + box.w - tip)} ${box.y}L${q(box.x + box.w)} ${q(box.y + box.h / 2)}L${q(box.x + box.w - tip)} ${q(box.y + box.h)}L${box.x} ${q(box.y + box.h)}` + (index > 0 ? `L${q(box.x + tip)} ${q(box.y + box.h / 2)}` : "") + "Z";
|
|
1693
|
+
result.decorationScene.push({ t: "path", id: diagramSceneId("lane", lane.id, "header"), d: d2, fill: laneFill.get(lane.id), owner: laneOwner(lane.id), part: "diagramLaneHeader" }), result.decorationClaims.push({ rect: box, owner: laneOwner(lane.id), part: "diagramLaneHeader" });
|
|
1694
|
+
let label = qRect({ x: box.x + (index > 0 ? tip : 0), y: box.y, w: box.w - tip - (index > 0 ? tip : 0), h: box.h });
|
|
1695
|
+
if (result.lanes.push({
|
|
1696
|
+
id: lane.id,
|
|
1697
|
+
bounds: qRect({ x, y: bandTop, w: laneW, h: partitionBottom - bandTop }),
|
|
1698
|
+
headerBox: label,
|
|
1699
|
+
memberNodeIds: members.get(lane.id).map((node) => node.id)
|
|
1700
|
+
}), index > 0) {
|
|
1701
|
+
let from = { x: q(x - laneGap / 2) + 0.5, y: q(bandTop + bandH + u) }, to = { x: from.x, y: partitionBottom };
|
|
1702
|
+
result.decorationScene.push({
|
|
1703
|
+
t: "line",
|
|
1704
|
+
id: diagramSceneId("lane", lane.id, "partition"),
|
|
1705
|
+
x1: from.x,
|
|
1706
|
+
y1: from.y,
|
|
1707
|
+
x2: to.x,
|
|
1708
|
+
y2: to.y,
|
|
1709
|
+
stroke: { token: "grid" },
|
|
1710
|
+
width: strokeWidth2,
|
|
1711
|
+
dash: dashToken(theme, "reference"),
|
|
1712
|
+
owner: laneOwner(lane.id),
|
|
1713
|
+
part: "diagramLanePartition"
|
|
1714
|
+
}), result.decorationClaims.push({ rect: segmentBounds(from, to, 1), owner: laneOwner(lane.id), part: "diagramLanePartition" });
|
|
1715
|
+
}
|
|
1716
|
+
}), result.trajectory = placed.map((item, index) => ({ x: q(item.x), y: q(ys[index]) }));
|
|
1717
|
+
let d = points.length === 1 ? `M${q(points[0].x - 2 * u)} ${points[0].y}L${q(points[0].x + 2 * u)} ${points[0].y}` : points.map((point, index) => `${index === 0 ? "M" : "L"}${point.x} ${point.y}`).join("");
|
|
1718
|
+
result.decorationScene.push({
|
|
1719
|
+
t: "path",
|
|
1720
|
+
id: diagramSceneId("roadmap", "trajectory"),
|
|
1721
|
+
d,
|
|
1722
|
+
stroke: { token: "axis" },
|
|
1723
|
+
width: strokeWidth2,
|
|
1724
|
+
owner: {},
|
|
1725
|
+
part: "diagramTrajectory"
|
|
1726
|
+
}), points.slice(1).forEach((to, index) => {
|
|
1727
|
+
let from = points[index], pieces = Math.max(1, Math.ceil(Math.hypot(to.x - from.x, to.y - from.y) / 3));
|
|
1728
|
+
for (let piece = 0; piece < pieces; piece++) {
|
|
1729
|
+
let a = { x: from.x + (to.x - from.x) * piece / pieces, y: from.y + (to.y - from.y) * piece / pieces }, b = { x: from.x + (to.x - from.x) * (piece + 1) / pieces, y: from.y + (to.y - from.y) * (piece + 1) / pieces };
|
|
1730
|
+
result.decorationClaims.push({ rect: segmentBounds(a, b, strokeWidth2), owner: {}, part: "diagramTrajectory" });
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
let fonts = new Map(data.nodes.map((node) => [node.id, labelFont]));
|
|
1734
|
+
return {
|
|
1735
|
+
mode: "columns",
|
|
1736
|
+
preset: result,
|
|
1737
|
+
routes: /* @__PURE__ */ new Map(),
|
|
1738
|
+
fonts,
|
|
1739
|
+
labelBoxes: new Map([...rects].map(([id, rect]) => [id, { ...rect }])),
|
|
1740
|
+
icons: /* @__PURE__ */ new Map(),
|
|
1741
|
+
rings,
|
|
1742
|
+
fills,
|
|
1743
|
+
plainShape: !0,
|
|
1744
|
+
seats,
|
|
1745
|
+
laneFills: laneFill,
|
|
1746
|
+
extent: [{ x: plot.x, y: bandTop, w: plot.w, h: partitionBottom - bandTop }]
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// src/core/charts/diagram/routing.ts
|
|
1751
|
+
var RouteObstacles = class {
|
|
1752
|
+
constructor(rects) {
|
|
1753
|
+
this.rects = rects;
|
|
1754
|
+
}
|
|
1755
|
+
rects;
|
|
1756
|
+
horizontal = /* @__PURE__ */ new Map();
|
|
1757
|
+
vertical = /* @__PURE__ */ new Map();
|
|
1758
|
+
pointRows = /* @__PURE__ */ new Map();
|
|
1759
|
+
contains(point) {
|
|
1760
|
+
let row = this.pointRows.get(point.y);
|
|
1761
|
+
return row || (row = this.rects.filter((rect) => point.y > rect.y && point.y < rect.y + rect.h), this.pointRows.set(point.y, row)), row.some((rect) => pointInsideOpenRect(point, rect));
|
|
1762
|
+
}
|
|
1763
|
+
blocks(a, b) {
|
|
1764
|
+
let horizontal = a.y === b.y;
|
|
1765
|
+
if (!horizontal && a.x !== b.x)
|
|
1766
|
+
return this.rects.some((rect) => segmentIntersectsOpenRect(a, b, rect));
|
|
1767
|
+
let index = horizontal ? this.horizontal : this.vertical, coordinate = horizontal ? a.y : a.x, candidates = index.get(coordinate);
|
|
1768
|
+
return candidates || (candidates = this.rects.filter((rect) => {
|
|
1769
|
+
let start = (horizontal ? rect.y : rect.x) + 1e-6, span = Math.max(0, (horizontal ? rect.h : rect.w) - 2e-6);
|
|
1770
|
+
return !(coordinate - start < 0 || start + span - coordinate < 0);
|
|
1771
|
+
}), index.set(coordinate, candidates)), candidates.some((rect) => segmentIntersectsOpenRect(a, b, rect));
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
function routeDiagramEdges(theme, input) {
|
|
1775
|
+
let nodeById = new Map(input.nodes.map((node) => [node.id, node])), portsByNode = /* @__PURE__ */ new Map(), warnings = [], resolved = [], scene = [], claims = [], labelBoxes = /* @__PURE__ */ new Map(), acceptedSegments = [], used = /* @__PURE__ */ new Map(), reserved = [...input.reserved];
|
|
1776
|
+
for (let edge of [...input.edges].sort((a, b) => compareText(a.id, b.id))) {
|
|
1777
|
+
let sourceNode = nodeById.get(edge.source.nodeId), targetNode = nodeById.get(edge.target.nodeId), sourceRect = input.nodeRects.get(sourceNode.id), targetRect = input.nodeRects.get(targetNode.id), sourceCandidates = endpointCandidates(sourceNode, sourceRect, edge.source.portId, "source", used), targetCandidates = endpointCandidates(targetNode, targetRect, edge.target.portId, "target", used), requested = edge.routing ?? "orthogonal", fixed = input.fixedRoutes?.get(edge.id);
|
|
1778
|
+
if (fixed) {
|
|
1779
|
+
let points2 = fixed.points, start = points2[0], end = points2.at(-1), sourcePort = resolvePort(
|
|
1780
|
+
sourceNode.id,
|
|
1781
|
+
sourceRect,
|
|
1782
|
+
fixed.sourceSide === "right" ? { id: "auto:org-out", at: { side: "right", offset: (start.y - sourceRect.y) / sourceRect.h }, intent: "out" } : { id: "auto:org-out", at: { side: "bottom", offset: (start.x - sourceRect.x) / sourceRect.w }, intent: "out" },
|
|
1783
|
+
!0
|
|
1784
|
+
), targetPort = resolvePort(targetNode.id, targetRect, fixed.targetSide === "top" ? { id: "auto:org-in", at: { side: "top", offset: (end.x - targetRect.x) / targetRect.w }, intent: "in" } : { id: "auto:org-in", at: { side: "left", offset: (end.y - targetRect.y) / targetRect.h }, intent: "in" }, !0), edgeResult2 = {
|
|
1785
|
+
id: edge.id,
|
|
1786
|
+
source: endpoint({ ...sourcePort, point: start }, points2[1] ?? end, input.clearance),
|
|
1787
|
+
target: endpoint({ ...targetPort, point: end }, points2.at(-2) ?? start, input.clearance),
|
|
1788
|
+
requestedRouting: requested,
|
|
1789
|
+
actualRouting: requested,
|
|
1790
|
+
route: {
|
|
1791
|
+
kind: "polyline",
|
|
1792
|
+
points: points2,
|
|
1793
|
+
segments: points2.slice(0, -1).map((from, index) => ({ from, to: points2[index + 1] })),
|
|
1794
|
+
bounds: pathBounds(points2, strokeWidth(theme, edge))
|
|
1795
|
+
},
|
|
1796
|
+
bends: countBends(points2),
|
|
1797
|
+
crossings: 0,
|
|
1798
|
+
sceneNodeIds: []
|
|
1799
|
+
};
|
|
1800
|
+
edgeResult2.sceneNodeIds = emitRouteScene(theme, edge, edgeResult2, scene, claims, input.clearance, warnings, input.palette, input.edgePaint), resolved.push(edgeResult2), recordPorts({ ...sourcePort, point: start }, { ...targetPort, point: end }, portsByNode, used);
|
|
1801
|
+
continue;
|
|
1802
|
+
}
|
|
1803
|
+
if (input.preset === "circular-process" && requested === "curved") {
|
|
1804
|
+
let circular = circularRoute(
|
|
1805
|
+
edge,
|
|
1806
|
+
sourceCandidates[0],
|
|
1807
|
+
targetCandidates[0],
|
|
1808
|
+
sourceRect,
|
|
1809
|
+
targetRect,
|
|
1810
|
+
input.plot,
|
|
1811
|
+
input.clearance,
|
|
1812
|
+
input.reserved
|
|
1813
|
+
), arrowIds = emitRouteScene(
|
|
1814
|
+
theme,
|
|
1815
|
+
edge,
|
|
1816
|
+
circular,
|
|
1817
|
+
scene,
|
|
1818
|
+
claims,
|
|
1819
|
+
input.clearance,
|
|
1820
|
+
warnings,
|
|
1821
|
+
input.palette,
|
|
1822
|
+
input.edgePaint
|
|
1823
|
+
);
|
|
1824
|
+
resolved.push({ ...circular, sceneNodeIds: arrowIds }), recordPorts(sourceCandidates[0].port, targetCandidates[0].port, portsByNode, used);
|
|
1825
|
+
continue;
|
|
1826
|
+
}
|
|
1827
|
+
let hard = input.nodes.map((node) => {
|
|
1828
|
+
let rect = input.nodeRects.get(node.id);
|
|
1829
|
+
return node.id === sourceNode.id || node.id === targetNode.id ? rect : inflate(rect, input.clearance);
|
|
1830
|
+
});
|
|
1831
|
+
pushAll(hard, reserved.map((rect) => inflate(rect, input.clearance / 2)));
|
|
1832
|
+
let obstacles = new RouteObstacles(hard), channels = {
|
|
1833
|
+
x: [...new Set([
|
|
1834
|
+
input.plot.x + input.clearance,
|
|
1835
|
+
input.plot.x + input.plot.w - input.clearance,
|
|
1836
|
+
...hard.flatMap((rect) => [rect.x, rect.x + rect.w])
|
|
1837
|
+
].map(q))],
|
|
1838
|
+
y: [...new Set([
|
|
1839
|
+
input.plot.y + input.clearance,
|
|
1840
|
+
input.plot.y + input.plot.h - input.clearance,
|
|
1841
|
+
...hard.flatMap((rect) => [rect.y, rect.y + rect.h])
|
|
1842
|
+
].map(q))]
|
|
1843
|
+
}, best;
|
|
1844
|
+
for (let source of sourceCandidates)
|
|
1845
|
+
for (let target of targetCandidates) {
|
|
1846
|
+
let candidate = routePair(
|
|
1847
|
+
input.preset,
|
|
1848
|
+
requested,
|
|
1849
|
+
source.port,
|
|
1850
|
+
target.port,
|
|
1851
|
+
edge,
|
|
1852
|
+
obstacles,
|
|
1853
|
+
input.plot,
|
|
1854
|
+
input.clearance,
|
|
1855
|
+
acceptedSegments,
|
|
1856
|
+
channels
|
|
1857
|
+
);
|
|
1858
|
+
if (!candidate) continue;
|
|
1859
|
+
let degraded = requested === "curved" || requested === "straight" && candidate.bends > 0 || requested === "elbow" && candidate.bends > 1, selectionCost = routeCost(candidate) + endpointDirectionCost(
|
|
1860
|
+
source.port,
|
|
1861
|
+
target.port,
|
|
1862
|
+
sourceRect,
|
|
1863
|
+
targetRect,
|
|
1864
|
+
input.clearance
|
|
1865
|
+
), automaticCount = +!source.explicit + +!target.explicit;
|
|
1866
|
+
(!best || selectionCost < best.selectionCost || selectionCost === best.selectionCost && (candidate.bends < best.candidate.bends || candidate.bends === best.candidate.bends && (candidate.crossings < best.candidate.crossings || candidate.crossings === best.candidate.crossings && (automaticCount < best.automaticCount || automaticCount === best.automaticCount && (compareText(
|
|
1867
|
+
serializePoints(candidate.points),
|
|
1868
|
+
serializePoints(best.candidate.points)
|
|
1869
|
+
) < 0 || serializePoints(candidate.points) === serializePoints(best.candidate.points) && `${source.port.portId}\0${target.port.portId}` < `${best.source.port.portId}\0${best.target.port.portId}`))))) && (best = {
|
|
1870
|
+
candidate,
|
|
1871
|
+
source,
|
|
1872
|
+
target,
|
|
1873
|
+
degraded,
|
|
1874
|
+
selectionCost,
|
|
1875
|
+
automaticCount
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
if (!best) {
|
|
1879
|
+
warnings.push({
|
|
1880
|
+
code: "diagram-route-unresolved",
|
|
1881
|
+
severity: "error",
|
|
1882
|
+
message: `edge '${edge.id}' has no obstacle-safe route`,
|
|
1883
|
+
owner: edgeOwner(edge.id)
|
|
1884
|
+
});
|
|
1885
|
+
continue;
|
|
1886
|
+
}
|
|
1887
|
+
best.degraded && warnings.push({
|
|
1888
|
+
code: "diagram-route-degraded",
|
|
1889
|
+
severity: "warn",
|
|
1890
|
+
message: `edge '${edge.id}' requested ${requested} routing and used orthogonal routing to preserve clearance`,
|
|
1891
|
+
owner: edgeOwner(edge.id)
|
|
1892
|
+
});
|
|
1893
|
+
for (let [end, selected, candidates] of [
|
|
1894
|
+
["source", best.source, sourceCandidates],
|
|
1895
|
+
["target", best.target, targetCandidates]
|
|
1896
|
+
])
|
|
1897
|
+
selected.explicit || !candidates.some((candidate) => candidate.explicit) || warnings.push({
|
|
1898
|
+
code: "diagram-port-degraded",
|
|
1899
|
+
severity: "warn",
|
|
1900
|
+
message: `edge '${edge.id}' used an automatic ${end} port because no authored candidate produced the safest route`,
|
|
1901
|
+
owner: edgeOwner(edge.id)
|
|
1902
|
+
});
|
|
1903
|
+
best.candidate.crossings > 0 && warnings.push({
|
|
1904
|
+
code: "diagram-edge-crossing",
|
|
1905
|
+
severity: "warn",
|
|
1906
|
+
message: `edge '${edge.id}' has ${best.candidate.crossings} unavoidable crossing${best.candidate.crossings === 1 ? "" : "s"}`,
|
|
1907
|
+
owner: edgeOwner(edge.id)
|
|
1908
|
+
});
|
|
1909
|
+
let points = simplify(best.candidate.points), sourceEndpoint = endpoint(
|
|
1910
|
+
best.source.port,
|
|
1911
|
+
points[1] ?? points[0],
|
|
1912
|
+
edge.arrowStart ? 3 * input.clearance : input.clearance
|
|
1913
|
+
), targetEndpoint = endpoint(
|
|
1914
|
+
best.target.port,
|
|
1915
|
+
points[points.length - 2] ?? points[points.length - 1],
|
|
1916
|
+
edge.arrowEnd ? 3 * input.clearance : input.clearance
|
|
1917
|
+
), route = {
|
|
1918
|
+
kind: "polyline",
|
|
1919
|
+
points,
|
|
1920
|
+
segments: points.slice(0, -1).map((from, index) => ({ from, to: points[index + 1] })),
|
|
1921
|
+
bounds: pathBounds(points, strokeWidth(theme, edge))
|
|
1922
|
+
}, edgeResult = {
|
|
1923
|
+
id: edge.id,
|
|
1924
|
+
source: sourceEndpoint,
|
|
1925
|
+
target: targetEndpoint,
|
|
1926
|
+
requestedRouting: requested,
|
|
1927
|
+
actualRouting: best.degraded ? "orthogonal" : requested,
|
|
1928
|
+
route,
|
|
1929
|
+
bends: countBends(points),
|
|
1930
|
+
crossings: countCrossings(points, acceptedSegments),
|
|
1931
|
+
sceneNodeIds: []
|
|
1932
|
+
}, labelSize = edge.label ? input.labelSizes.get(edge.id) : void 0;
|
|
1933
|
+
if (edge.label && labelSize) {
|
|
1934
|
+
let labelBox = chooseEdgeLabelBox(points, labelSize, hard, reserved, input.plot, input.clearance);
|
|
1935
|
+
labelBox ? (edgeResult.labelBox = labelBox, labelBoxes.set(edge.id, labelBox), reserved.push(labelBox)) : warnings.push({
|
|
1936
|
+
code: "diagram-edge-label-unplaced",
|
|
1937
|
+
severity: "warn",
|
|
1938
|
+
message: `edge label '${edge.label}' on '${edge.id}' has no collision-free candidate`,
|
|
1939
|
+
owner: edgeOwner(edge.id)
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
edgeResult.sceneNodeIds = emitRouteScene(
|
|
1943
|
+
theme,
|
|
1944
|
+
edge,
|
|
1945
|
+
edgeResult,
|
|
1946
|
+
scene,
|
|
1947
|
+
claims,
|
|
1948
|
+
input.clearance,
|
|
1949
|
+
warnings,
|
|
1950
|
+
input.palette
|
|
1951
|
+
), resolved.push(edgeResult), edgeResult.route.kind === "polyline" && edgeResult.route.segments.forEach(
|
|
1952
|
+
(segment) => acceptedSegments.push({ edgeId: edge.id, from: segment.from, to: segment.to })
|
|
1953
|
+
), recordPorts(best.source.port, best.target.port, portsByNode, used);
|
|
1954
|
+
}
|
|
1955
|
+
for (let ports of portsByNode.values())
|
|
1956
|
+
ports.forEach((port) => {
|
|
1957
|
+
port.used = used.get(portKey(port)) ?? 0;
|
|
1958
|
+
}), ports.sort((a, b) => compareText(a.portId, b.portId));
|
|
1959
|
+
return { edges: resolved, scene, warnings, portsByNode, labelBoxes, claims };
|
|
1960
|
+
}
|
|
1961
|
+
function endpointCandidates(node, rect, portId, end, used) {
|
|
1962
|
+
let authored = (node.ports ?? []).filter((port) => !portId || port.id === portId).filter((port) => end === "source" ? port.intent !== "in" : port.intent !== "out").filter((port) => port.capacity === void 0 || (used.get(`${node.id}\0${port.id}`) ?? 0) < port.capacity).map((port) => ({ port: resolvePort(node.id, rect, port, !1), explicit: !0 }));
|
|
1963
|
+
if (portId) return authored;
|
|
1964
|
+
let automatic = ["top", "right", "bottom", "left"].map((side) => ({
|
|
1965
|
+
port: resolvePort(
|
|
1966
|
+
node.id,
|
|
1967
|
+
rect,
|
|
1968
|
+
{ id: `auto:${side}`, at: { side }, intent: "bidi" },
|
|
1969
|
+
!0
|
|
1970
|
+
),
|
|
1971
|
+
explicit: !1
|
|
1972
|
+
}));
|
|
1973
|
+
return authored.length > 0 ? [...authored, ...automatic] : automatic;
|
|
1974
|
+
}
|
|
1975
|
+
function resolvePort(nodeId, rect, source, automatic) {
|
|
1976
|
+
let point, normal;
|
|
1977
|
+
if ("side" in source.at) {
|
|
1978
|
+
let offset = source.at.offset ?? 0.5;
|
|
1979
|
+
switch (source.at.side) {
|
|
1980
|
+
case "top":
|
|
1981
|
+
point = { x: rect.x + rect.w * offset, y: rect.y }, normal = { x: 0, y: -1 };
|
|
1982
|
+
break;
|
|
1983
|
+
case "right":
|
|
1984
|
+
point = { x: rect.x + rect.w, y: rect.y + rect.h * offset }, normal = { x: 1, y: 0 };
|
|
1985
|
+
break;
|
|
1986
|
+
case "bottom":
|
|
1987
|
+
point = { x: rect.x + rect.w * offset, y: rect.y + rect.h }, normal = { x: 0, y: 1 };
|
|
1988
|
+
break;
|
|
1989
|
+
case "left":
|
|
1990
|
+
point = { x: rect.x, y: rect.y + rect.h * offset }, normal = { x: -1, y: 0 };
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
1993
|
+
} else {
|
|
1994
|
+
let distance = (source.at.perimeter % 1 + 1) % 1 * 2 * (rect.w + rect.h);
|
|
1995
|
+
distance <= rect.w ? (point = { x: rect.x + rect.w / 2 + distance, y: rect.y }, normal = { x: 0, y: -1 }) : distance <= rect.w + rect.h ? (point = { x: rect.x + rect.w, y: rect.y + distance - rect.w }, normal = { x: 1, y: 0 }) : distance <= 2 * rect.w + rect.h ? (point = { x: rect.x + rect.w - (distance - rect.w - rect.h), y: rect.y + rect.h }, normal = { x: 0, y: 1 }) : (point = { x: rect.x, y: rect.y + rect.h - (distance - 2 * rect.w - rect.h) }, normal = { x: -1, y: 0 });
|
|
1996
|
+
}
|
|
1997
|
+
return {
|
|
1998
|
+
nodeId,
|
|
1999
|
+
portId: source.id,
|
|
2000
|
+
automatic,
|
|
2001
|
+
point: qPoint(point),
|
|
2002
|
+
normal,
|
|
2003
|
+
intent: source.intent ?? "bidi",
|
|
2004
|
+
capacity: source.capacity,
|
|
2005
|
+
used: 0
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
function routePair(preset, requested, source, target, edge, obstacles, plot, clearance, accepted, channels) {
|
|
2009
|
+
let sourceEscape = qPoint({
|
|
2010
|
+
x: source.point.x + source.normal.x * clearance * (edge.arrowStart ? 3 : 1),
|
|
2011
|
+
y: source.point.y + source.normal.y * clearance * (edge.arrowStart ? 3 : 1)
|
|
2012
|
+
}), targetEscape = qPoint({
|
|
2013
|
+
x: target.point.x + target.normal.x * clearance * (edge.arrowEnd ? 3 : 1),
|
|
2014
|
+
y: target.point.y + target.normal.y * clearance * (edge.arrowEnd ? 3 : 1)
|
|
2015
|
+
});
|
|
2016
|
+
if (!routeClear([source.point, sourceEscape], obstacles, plot) || !routeClear([targetEscape, target.point], obstacles, plot))
|
|
2017
|
+
return visibilityGridRoute(source.point, target.point, sourceEscape, targetEscape, obstacles, plot, clearance, accepted);
|
|
2018
|
+
let waypoints = (edge.waypoints ?? []).map(
|
|
2019
|
+
(point) => qPoint({ x: plot.x + point.x * plot.w, y: plot.y + point.y * plot.h })
|
|
2020
|
+
), special = edge.waypoints?.length || !["hierarchy", "issue-tree"].includes(preset) ? void 0 : preset === "hierarchy" ? hierarchyCandidate(source, target, sourceEscape, targetEscape) : issueTreeCandidate(source, target, sourceEscape, targetEscape), candidateBodies = [];
|
|
2021
|
+
special && candidateBodies.push(special), requested === "straight" && candidateBodies.push([sourceEscape, targetEscape]), candidateBodies.push(
|
|
2022
|
+
[sourceEscape, { x: targetEscape.x, y: sourceEscape.y }, targetEscape],
|
|
2023
|
+
[sourceEscape, { x: sourceEscape.x, y: targetEscape.y }, targetEscape]
|
|
2024
|
+
), channels.x.forEach(
|
|
2025
|
+
(x) => candidateBodies.push([
|
|
2026
|
+
sourceEscape,
|
|
2027
|
+
{ x: q(x), y: sourceEscape.y },
|
|
2028
|
+
{ x: q(x), y: targetEscape.y },
|
|
2029
|
+
targetEscape
|
|
2030
|
+
])
|
|
2031
|
+
), channels.y.forEach(
|
|
2032
|
+
(y) => candidateBodies.push([
|
|
2033
|
+
sourceEscape,
|
|
2034
|
+
{ x: sourceEscape.x, y: q(y) },
|
|
2035
|
+
{ x: targetEscape.x, y: q(y) },
|
|
2036
|
+
targetEscape
|
|
2037
|
+
])
|
|
2038
|
+
);
|
|
2039
|
+
let routeBodies = waypoints.length === 0 ? candidateBodies : routeThroughWaypoints(sourceEscape, targetEscape, waypoints, obstacles, plot), best;
|
|
2040
|
+
for (let body of routeBodies) {
|
|
2041
|
+
let points = simplify([source.point, ...body, target.point].map(qPoint)), bends = countBends(points), length = routeLength(points);
|
|
2042
|
+
if (best && length + bends * 32 > routeCost(best) || !routeClear(points, obstacles, plot)) continue;
|
|
2043
|
+
let candidate = { points, bends, length, crossings: countCrossings(points, accepted) };
|
|
2044
|
+
(!best || compareRoute(candidate, best, source.portId, target.portId) < 0) && (best = candidate);
|
|
2045
|
+
}
|
|
2046
|
+
return best ?? visibilityGridRoute(source.point, target.point, sourceEscape, targetEscape, obstacles, plot, clearance, accepted);
|
|
2047
|
+
}
|
|
2048
|
+
function hierarchyCandidate(source, target, sourceEscape, targetEscape) {
|
|
2049
|
+
let y = q((source.point.y + target.point.y) / 2);
|
|
2050
|
+
return [sourceEscape, { x: sourceEscape.x, y }, { x: targetEscape.x, y }, targetEscape];
|
|
2051
|
+
}
|
|
2052
|
+
function issueTreeCandidate(source, target, sourceEscape, targetEscape) {
|
|
2053
|
+
let x = q((source.point.x + target.point.x) / 2);
|
|
2054
|
+
return [sourceEscape, { x, y: sourceEscape.y }, { x, y: targetEscape.y }, targetEscape];
|
|
2055
|
+
}
|
|
2056
|
+
function routeThroughWaypoints(start, end, waypoints, obstacles, plot) {
|
|
2057
|
+
let routes = [[start]], stops = [...waypoints, end];
|
|
2058
|
+
for (let stop of stops) {
|
|
2059
|
+
let next = [];
|
|
2060
|
+
for (let route of routes) {
|
|
2061
|
+
let from = route[route.length - 1], legs = [
|
|
2062
|
+
[from, { x: stop.x, y: from.y }, stop],
|
|
2063
|
+
[from, { x: from.x, y: stop.y }, stop]
|
|
2064
|
+
];
|
|
2065
|
+
for (let leg of legs)
|
|
2066
|
+
routeClear(leg, obstacles, plot) && next.push([...route.slice(0, -1), ...leg]);
|
|
2067
|
+
}
|
|
2068
|
+
if (routes = next, routes.length === 0) return [];
|
|
2069
|
+
}
|
|
2070
|
+
return routes;
|
|
2071
|
+
}
|
|
2072
|
+
function visibilityGridRoute(source, target, sourceEscape, targetEscape, obstacles, plot, clearance, accepted) {
|
|
2073
|
+
if ([sourceEscape, targetEscape].some((point) => !pointInPlot(point, plot) || obstacles.contains(point))) return;
|
|
2074
|
+
let xs = uniqueSorted([
|
|
2075
|
+
sourceEscape.x,
|
|
2076
|
+
targetEscape.x,
|
|
2077
|
+
plot.x + clearance,
|
|
2078
|
+
plot.x + plot.w - clearance,
|
|
2079
|
+
...obstacles.rects.flatMap((rect) => [rect.x, rect.x + rect.w])
|
|
2080
|
+
]), ys = uniqueSorted([
|
|
2081
|
+
sourceEscape.y,
|
|
2082
|
+
targetEscape.y,
|
|
2083
|
+
plot.y + clearance,
|
|
2084
|
+
plot.y + plot.h - clearance,
|
|
2085
|
+
...obstacles.rects.flatMap((rect) => [rect.y, rect.y + rect.h])
|
|
2086
|
+
]), vertices = [], index = /* @__PURE__ */ new Map();
|
|
2087
|
+
ys.forEach(
|
|
2088
|
+
(y) => xs.forEach((x) => {
|
|
2089
|
+
let point = { x, y };
|
|
2090
|
+
!pointInPlot(point, plot) || obstacles.contains(point) || (index.set(pointKey(point), vertices.length), vertices.push(point));
|
|
2091
|
+
})
|
|
2092
|
+
);
|
|
2093
|
+
let startIndex = index.get(pointKey(sourceEscape)), endIndex = index.get(pointKey(targetEscape));
|
|
2094
|
+
if (startIndex === void 0 || endIndex === void 0) return;
|
|
2095
|
+
let neighbors = /* @__PURE__ */ new Map();
|
|
2096
|
+
for (let yi = 0; yi < ys.length; yi++) {
|
|
2097
|
+
let row = xs.flatMap((x) => {
|
|
2098
|
+
let value = index.get(pointKey({ x, y: ys[yi] }));
|
|
2099
|
+
return value === void 0 ? [] : [value];
|
|
2100
|
+
});
|
|
2101
|
+
connectVisible(row, vertices, obstacles, neighbors);
|
|
2102
|
+
}
|
|
2103
|
+
for (let xi = 0; xi < xs.length; xi++) {
|
|
2104
|
+
let column = ys.flatMap((y) => {
|
|
2105
|
+
let value = index.get(pointKey({ x: xs[xi], y }));
|
|
2106
|
+
return value === void 0 ? [] : [value];
|
|
2107
|
+
});
|
|
2108
|
+
connectVisible(column, vertices, obstacles, neighbors);
|
|
2109
|
+
}
|
|
2110
|
+
let queue = new GridSearchHeap();
|
|
2111
|
+
queue.push({ node: startIndex, direction: source.x === sourceEscape.x ? "v" : "h", cost: 0, path: [startIndex], key: serializeIndices([startIndex]) });
|
|
2112
|
+
let best = /* @__PURE__ */ new Map();
|
|
2113
|
+
for (let current = queue.pop(); current; current = queue.pop()) {
|
|
2114
|
+
let stateKey = `${current.node}:${current.direction}`;
|
|
2115
|
+
if (!((best.get(stateKey) ?? 1 / 0) <= current.cost)) {
|
|
2116
|
+
if (best.set(stateKey, current.cost), current.node === endIndex)
|
|
2117
|
+
return scoreRoute(
|
|
2118
|
+
[source, ...current.path.map((value) => vertices[value]), target].map(qPoint),
|
|
2119
|
+
accepted
|
|
2120
|
+
);
|
|
2121
|
+
for (let neighbor of neighbors.get(current.node) ?? []) {
|
|
2122
|
+
let a = vertices[current.node], b = vertices[neighbor];
|
|
2123
|
+
if (current.node === startIndex && (b.x - a.x) * (sourceEscape.x - source.x) + (b.y - a.y) * (sourceEscape.y - source.y) < 0 || neighbor === endIndex && (a.x - b.x) * (targetEscape.x - target.x) + (a.y - b.y) * (targetEscape.y - target.y) < 0) continue;
|
|
2124
|
+
let direction = a.x === b.x ? "v" : "h", length = Math.abs(a.x - b.x) + Math.abs(a.y - b.y), bend = current.direction !== "none" && current.direction !== direction ? 8 * clearance : 0, path = [...current.path, neighbor];
|
|
2125
|
+
queue.push({
|
|
2126
|
+
node: neighbor,
|
|
2127
|
+
direction,
|
|
2128
|
+
cost: current.cost + length + bend,
|
|
2129
|
+
path,
|
|
2130
|
+
key: serializeIndices(path)
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
var GridSearchHeap = class {
|
|
2137
|
+
entries = [];
|
|
2138
|
+
push(entry) {
|
|
2139
|
+
let entries = this.entries;
|
|
2140
|
+
entries.push(entry);
|
|
2141
|
+
let index = entries.length - 1;
|
|
2142
|
+
for (; index > 0; ) {
|
|
2143
|
+
let parent = index - 1 >> 1;
|
|
2144
|
+
if (compareGridEntries(entries[index], entries[parent]) >= 0) break;
|
|
2145
|
+
[entries[index], entries[parent]] = [entries[parent], entries[index]], index = parent;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
pop() {
|
|
2149
|
+
let entries = this.entries;
|
|
2150
|
+
if (entries.length === 0) return;
|
|
2151
|
+
let top = entries[0], last = entries.pop();
|
|
2152
|
+
if (entries.length > 0) {
|
|
2153
|
+
entries[0] = last;
|
|
2154
|
+
let index = 0;
|
|
2155
|
+
for (; ; ) {
|
|
2156
|
+
let left = 2 * index + 1, right = left + 1, smallest = index;
|
|
2157
|
+
if (left < entries.length && compareGridEntries(entries[left], entries[smallest]) < 0 && (smallest = left), right < entries.length && compareGridEntries(entries[right], entries[smallest]) < 0 && (smallest = right), smallest === index) break;
|
|
2158
|
+
[entries[index], entries[smallest]] = [entries[smallest], entries[index]], index = smallest;
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
return top;
|
|
2162
|
+
}
|
|
2163
|
+
}, compareGridEntries = (a, b) => a.cost - b.cost || compareText(a.key, b.key);
|
|
2164
|
+
function connectVisible(ordered, vertices, obstacles, neighbors) {
|
|
2165
|
+
for (let index = 0; index < ordered.length - 1; index++) {
|
|
2166
|
+
let a = ordered[index], b = ordered[index + 1];
|
|
2167
|
+
obstacles.blocks(vertices[a], vertices[b]) || (neighbors.set(a, [...neighbors.get(a) ?? [], b]), neighbors.set(b, [...neighbors.get(b) ?? [], a]));
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
function circularRoute(edge, source, target, sourceRect, targetRect, plot, clearance, reserved) {
|
|
2171
|
+
let centre = rectCenter(plot), sourceCentre = rectCenter(sourceRect), targetCentre = rectCenter(targetRect), a = Math.atan2(sourceCentre.y - centre.y, sourceCentre.x - centre.x), b = Math.atan2(targetCentre.y - centre.y, targetCentre.x - centre.x);
|
|
2172
|
+
for (; b <= a; ) b += Math.PI * 2;
|
|
2173
|
+
let mid = (a + b) / 2, baseRadius = Math.max(
|
|
2174
|
+
Math.hypot(sourceCentre.x - centre.x, sourceCentre.y - centre.y),
|
|
2175
|
+
Math.hypot(targetCentre.x - centre.x, targetCentre.y - centre.y)
|
|
2176
|
+
) + 4 * clearance, control = qPoint({
|
|
2177
|
+
x: centre.x + Math.cos(mid) * baseRadius,
|
|
2178
|
+
y: centre.y + Math.sin(mid) * baseRadius
|
|
2179
|
+
}), start = pointOnRectToward(sourceRect, control), end = pointOnRectToward(targetRect, control);
|
|
2180
|
+
for (let step = 0; step <= 8; step++) {
|
|
2181
|
+
let radius = baseRadius + step * 2 * clearance, candidateControl = qPoint({
|
|
2182
|
+
x: centre.x + Math.cos(mid) * radius,
|
|
2183
|
+
y: centre.y + Math.sin(mid) * radius
|
|
2184
|
+
}), candidateStart = pointOnRectToward(sourceRect, candidateControl), candidateEnd = pointOnRectToward(targetRect, candidateControl), points = sampleQuadratic([candidateStart, candidateControl, candidateEnd]);
|
|
2185
|
+
if (points.every((point) => pointInPlot(point, plot)) && reserved.every((rect) => !routeIntersectsRect(points, rect))) {
|
|
2186
|
+
control = candidateControl, start = candidateStart, end = candidateEnd;
|
|
2187
|
+
break;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
let d = `M${q(start.x)} ${q(start.y)}Q${q(control.x)} ${q(control.y)} ${q(end.x)} ${q(end.y)}`, bounds = boundsOf([start, control, end].map((point) => ({ x: point.x, y: point.y, w: 0, h: 0 })));
|
|
2191
|
+
return {
|
|
2192
|
+
id: edge.id,
|
|
2193
|
+
source: endpoint({ ...source.port, point: start }, control, clearance),
|
|
2194
|
+
target: endpoint({ ...target.port, point: end }, control, clearance),
|
|
2195
|
+
requestedRouting: "curved",
|
|
2196
|
+
actualRouting: "curved",
|
|
2197
|
+
route: { kind: "path", d, controlPoints: [start, control, end], bounds },
|
|
2198
|
+
bends: 0,
|
|
2199
|
+
crossings: 0,
|
|
2200
|
+
sceneNodeIds: []
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
function emitRouteScene(theme, edge, resolved, scene, claims, clearance, warnings, palette, plainPaint = { token: "leader" }) {
|
|
2204
|
+
let ids = [], shaftId = diagramSceneId("edge", edge.id), width = strokeWidth(theme, edge), dash = edgeDash(theme, edge.dash), paint = edge.role === void 0 || edge.role === "secondary" || edge.role === "muted" ? plainPaint : palette.paint(edge.role, edge.paletteKey);
|
|
2205
|
+
if (resolved.route.kind === "path" ? (scene.push({
|
|
2206
|
+
t: "path",
|
|
2207
|
+
id: shaftId,
|
|
2208
|
+
d: resolved.route.d,
|
|
2209
|
+
stroke: paint,
|
|
2210
|
+
width,
|
|
2211
|
+
dash,
|
|
2212
|
+
lineCap: edge.dash === "dotted" ? "round" : "butt",
|
|
2213
|
+
owner: edgeOwner(edge.id),
|
|
2214
|
+
part: "diagramEdge"
|
|
2215
|
+
}), sampleQuadratic(resolved.route.controlPoints).forEach((point, index, points) => {
|
|
2216
|
+
let next = points[index + 1];
|
|
2217
|
+
next && claims.push({
|
|
2218
|
+
rect: segmentBounds(point, next, width),
|
|
2219
|
+
edgeId: edge.id,
|
|
2220
|
+
part: "diagramEdge"
|
|
2221
|
+
});
|
|
2222
|
+
})) : (scene.push({
|
|
2223
|
+
t: "path",
|
|
2224
|
+
id: shaftId,
|
|
2225
|
+
d: polylinePath(resolved.route.points),
|
|
2226
|
+
stroke: paint,
|
|
2227
|
+
width,
|
|
2228
|
+
dash,
|
|
2229
|
+
lineCap: edge.dash === "dotted" ? "round" : "butt",
|
|
2230
|
+
owner: edgeOwner(edge.id),
|
|
2231
|
+
part: "diagramEdge"
|
|
2232
|
+
}), resolved.route.segments.forEach(
|
|
2233
|
+
(segment) => claims.push({ rect: segmentBounds(segment.from, segment.to, width), edgeId: edge.id, part: "diagramEdge" })
|
|
2234
|
+
)), ids.push(shaftId), edge.arrowEnd) {
|
|
2235
|
+
let arrow = arrowScene(edge, resolved, !1, clearance, paint);
|
|
2236
|
+
arrow ? (scene.push(arrow), ids.push(arrow.id)) : warnings.push({
|
|
2237
|
+
code: "diagram-arrowhead-unplaced",
|
|
2238
|
+
severity: "warn",
|
|
2239
|
+
message: `edge '${edge.id}' omitted its end arrow because the terminal segment is too short`,
|
|
2240
|
+
owner: edgeOwner(edge.id)
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
if (edge.arrowStart) {
|
|
2244
|
+
let arrow = arrowScene(edge, resolved, !0, clearance, paint);
|
|
2245
|
+
arrow ? (scene.push(arrow), ids.push(arrow.id)) : warnings.push({
|
|
2246
|
+
code: "diagram-arrowhead-unplaced",
|
|
2247
|
+
severity: "warn",
|
|
2248
|
+
message: `edge '${edge.id}' omitted its start arrow because the terminal segment is too short`,
|
|
2249
|
+
owner: edgeOwner(edge.id)
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
return ids;
|
|
2253
|
+
}
|
|
2254
|
+
function sampleQuadratic(controlPoints) {
|
|
2255
|
+
if (controlPoints.length !== 3) return [...controlPoints];
|
|
2256
|
+
let [start, control, end] = controlPoints;
|
|
2257
|
+
return Array.from({ length: 17 }, (_, index) => {
|
|
2258
|
+
let t = index / 16, inverse = 1 - t;
|
|
2259
|
+
return qPoint({
|
|
2260
|
+
x: inverse * inverse * start.x + 2 * inverse * t * control.x + t * t * end.x,
|
|
2261
|
+
y: inverse * inverse * start.y + 2 * inverse * t * control.y + t * t * end.y
|
|
2262
|
+
});
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
function arrowScene(edge, resolved, atStart, clearance, fill) {
|
|
2266
|
+
let points = resolved.route.kind === "polyline" ? resolved.route.points : resolved.route.controlPoints;
|
|
2267
|
+
if (points.length < 2) return;
|
|
2268
|
+
let tip = atStart ? points[0] : points[points.length - 1], previous = atStart ? points[1] : points[points.length - 2], dx = tip.x - previous.x, dy = tip.y - previous.y, length = Math.hypot(dx, dy);
|
|
2269
|
+
if (length < 3 * clearance) return;
|
|
2270
|
+
let arrowLength = 3 * clearance, arrowWidth = 2 * clearance, ux = dx / length, uy = dy / length, bx = tip.x - ux * arrowLength, by = tip.y - uy * arrowLength, px = -uy * arrowWidth / 2, py = ux * arrowWidth / 2;
|
|
2271
|
+
return {
|
|
2272
|
+
t: "path",
|
|
2273
|
+
id: diagramSceneId("arrow", edge.id, atStart ? "start" : "end"),
|
|
2274
|
+
d: `M${q(tip.x)} ${q(tip.y)}L${q(bx + px)} ${q(by + py)}L${q(bx - px)} ${q(by - py)}Z`,
|
|
2275
|
+
fill,
|
|
2276
|
+
owner: edgeOwner(edge.id),
|
|
2277
|
+
part: "diagramArrow"
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
function chooseEdgeLabelBox(points, size, hard, reserved, plot, clearance) {
|
|
2281
|
+
let segments = points.slice(0, -1).map((from, index) => ({ from, to: points[index + 1] })).sort(
|
|
2282
|
+
(a, b) => Math.hypot(b.to.x - b.from.x, b.to.y - b.from.y) - Math.hypot(a.to.x - a.from.x, a.to.y - a.from.y)
|
|
2283
|
+
);
|
|
2284
|
+
for (let segment of segments) {
|
|
2285
|
+
let centre = {
|
|
2286
|
+
x: (segment.from.x + segment.to.x) / 2,
|
|
2287
|
+
y: (segment.from.y + segment.to.y) / 2
|
|
2288
|
+
}, accepted = [
|
|
2289
|
+
{ x: centre.x - size.width / 2, y: centre.y - size.height - clearance, w: size.width, h: size.height },
|
|
2290
|
+
{ x: centre.x - size.width / 2, y: centre.y + clearance, w: size.width, h: size.height }
|
|
2291
|
+
].map((rect) => ({ x: q(rect.x), y: q(rect.y), w: q(rect.w), h: q(rect.h) })).find(
|
|
2292
|
+
(rect) => rect.x >= plot.x && rect.y >= plot.y && rect.x + rect.w <= plot.x + plot.w && rect.y + rect.h <= plot.y + plot.h && ![...hard, ...reserved].some((obstacle) => rectsOverlapOpen(rect, obstacle))
|
|
2293
|
+
);
|
|
2294
|
+
if (accepted) return accepted;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
function endpoint(port, toward, clearance) {
|
|
2298
|
+
let dx = toward.x - port.point.x, dy = toward.y - port.point.y, length = Math.hypot(dx, dy) || 1;
|
|
2299
|
+
return {
|
|
2300
|
+
nodeId: port.nodeId,
|
|
2301
|
+
portId: port.portId,
|
|
2302
|
+
point: port.point,
|
|
2303
|
+
escapePoint: qPoint({
|
|
2304
|
+
x: port.point.x + dx / length * clearance,
|
|
2305
|
+
y: port.point.y + dy / length * clearance
|
|
2306
|
+
})
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
function recordPorts(source, target, portsByNode, used) {
|
|
2310
|
+
for (let port of [source, target]) {
|
|
2311
|
+
let key = portKey(port);
|
|
2312
|
+
used.set(key, (used.get(key) ?? 0) + 1);
|
|
2313
|
+
let ports = portsByNode.get(port.nodeId) ?? [];
|
|
2314
|
+
ports.some((candidate) => candidate.portId === port.portId) || ports.push({ ...port }), portsByNode.set(port.nodeId, ports);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
var portKey = (port) => `${port.nodeId}\0${port.portId}`;
|
|
2318
|
+
function edgeDash(theme, style) {
|
|
2319
|
+
return style === "dotted" ? dashToken(theme, "dotted") : style === "dashed" ? dashToken(theme, "reference") : void 0;
|
|
2320
|
+
}
|
|
2321
|
+
function strokeWidth(theme, edge) {
|
|
2322
|
+
return strokeToken(theme, edge.weight === "hairline" ? "hair" : edge.weight === "strong" ? "focus" : "rule");
|
|
2323
|
+
}
|
|
2324
|
+
function scoreRoute(points, accepted) {
|
|
2325
|
+
return {
|
|
2326
|
+
points,
|
|
2327
|
+
bends: countBends(points),
|
|
2328
|
+
crossings: countCrossings(points, accepted),
|
|
2329
|
+
length: routeLength(points)
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
function routeLength(points) {
|
|
2333
|
+
return points.slice(0, -1).reduce((sum, point, index) => {
|
|
2334
|
+
let next = points[index + 1];
|
|
2335
|
+
return sum + Math.hypot(next.x - point.x, next.y - point.y);
|
|
2336
|
+
}, 0);
|
|
2337
|
+
}
|
|
2338
|
+
function routeCost(route) {
|
|
2339
|
+
return route.length + route.bends * 32 + route.crossings * 80;
|
|
2340
|
+
}
|
|
2341
|
+
function endpointDirectionCost(source, target, sourceRect, targetRect, clearance) {
|
|
2342
|
+
let from = rectCenter(sourceRect), to = rectCenter(targetRect), length = Math.hypot(to.x - from.x, to.y - from.y) || 1, direction = { x: (to.x - from.x) / length, y: (to.y - from.y) / length }, sourceDot = source.normal.x * direction.x + source.normal.y * direction.y, targetDot = target.normal.x * -direction.x + target.normal.y * -direction.y;
|
|
2343
|
+
return (2 - sourceDot - targetDot) * 6 * clearance;
|
|
2344
|
+
}
|
|
2345
|
+
function compareRoute(a, b, sourcePort, targetPort) {
|
|
2346
|
+
let costA = routeCost(a), costB = routeCost(b);
|
|
2347
|
+
return costA - costB || a.bends - b.bends || a.crossings - b.crossings || compareText(serializePoints(a.points), serializePoints(b.points)) || compareText(sourcePort, targetPort);
|
|
2348
|
+
}
|
|
2349
|
+
function countBends(points) {
|
|
2350
|
+
let bends = 0;
|
|
2351
|
+
for (let index = 1; index < points.length - 1; index++) {
|
|
2352
|
+
let a = points[index - 1], b = points[index], c = points[index + 1], cross = (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);
|
|
2353
|
+
Math.abs(cross) > 1e-9 && bends++;
|
|
2354
|
+
}
|
|
2355
|
+
return bends;
|
|
2356
|
+
}
|
|
2357
|
+
function countCrossings(points, accepted) {
|
|
2358
|
+
let count = 0;
|
|
2359
|
+
for (let index = 0; index < points.length - 1; index++) {
|
|
2360
|
+
let a = points[index], b = points[index + 1];
|
|
2361
|
+
for (let prior of accepted)
|
|
2362
|
+
segmentsCrossInterior(a, b, prior.from, prior.to) && count++;
|
|
2363
|
+
}
|
|
2364
|
+
return count;
|
|
2365
|
+
}
|
|
2366
|
+
function routeIntersectsRect(points, rect) {
|
|
2367
|
+
return points.slice(0, -1).some((from, index) => segmentIntersectsOpenRect(from, points[index + 1], rect));
|
|
2368
|
+
}
|
|
2369
|
+
function simplify(points) {
|
|
2370
|
+
let deduped = points.filter(
|
|
2371
|
+
(point, index) => index === 0 || point.x !== points[index - 1].x || point.y !== points[index - 1].y
|
|
2372
|
+
), out = [];
|
|
2373
|
+
for (let index = 0; index < deduped.length; index++) {
|
|
2374
|
+
let point = deduped[index], a = out[out.length - 2], b = out[out.length - 1], preserveEndpointEscape = index <= 1 || index >= deduped.length - 2, sameDirection = a && b && (b.x - a.x) * (point.x - b.x) + (b.y - a.y) * (point.y - b.y) > 0;
|
|
2375
|
+
!preserveEndpointEscape && a && b && sameDirection && (a.x === b.x && b.x === point.x || a.y === b.y && b.y === point.y) ? out[out.length - 1] = point : out.push(point);
|
|
2376
|
+
}
|
|
2377
|
+
return out;
|
|
2378
|
+
}
|
|
2379
|
+
function routeClear(points, obstacles, plot) {
|
|
2380
|
+
return points.every((point) => pointInPlot(point, plot)) && points.slice(0, -1).every((from, index) => !obstacles.blocks(from, points[index + 1]));
|
|
2381
|
+
}
|
|
2382
|
+
function segmentIntersectsOpenRect(a, b, rect) {
|
|
2383
|
+
let ix = rect.x + 1e-6, iy = rect.y + 1e-6, iw = Math.max(0, rect.w - 2 * 1e-6), ih = Math.max(0, rect.h - 2 * 1e-6), dx = b.x - a.x, dy = b.y - a.y, t0 = 0, t1 = 1;
|
|
2384
|
+
for (let edge = 0; edge < 4; edge++) {
|
|
2385
|
+
let p = edge === 0 ? -dx : edge === 1 ? dx : edge === 2 ? -dy : dy, qValue = edge === 0 ? a.x - ix : edge === 1 ? ix + iw - a.x : edge === 2 ? a.y - iy : iy + ih - a.y;
|
|
2386
|
+
if (p === 0) {
|
|
2387
|
+
if (qValue < 0) return !1;
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
let ratio = qValue / p;
|
|
2391
|
+
if (p < 0 ? t0 = Math.max(t0, ratio) : t1 = Math.min(t1, ratio), t0 > t1) return !1;
|
|
2392
|
+
}
|
|
2393
|
+
return t1 >= 0 && t0 <= 1 && t0 <= t1;
|
|
2394
|
+
}
|
|
2395
|
+
function pointInsideOpenRect(point, rect) {
|
|
2396
|
+
return point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h;
|
|
2397
|
+
}
|
|
2398
|
+
function pointInPlot(point, plot) {
|
|
2399
|
+
return point.x >= plot.x && point.y >= plot.y && point.x <= plot.x + plot.w && point.y <= plot.y + plot.h;
|
|
2400
|
+
}
|
|
2401
|
+
function rectsOverlapOpen(a, b) {
|
|
2402
|
+
return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
|
|
2403
|
+
}
|
|
2404
|
+
function segmentsCrossInterior(a, b, c, d) {
|
|
2405
|
+
let denominator = (b.x - a.x) * (d.y - c.y) - (b.y - a.y) * (d.x - c.x);
|
|
2406
|
+
if (Math.abs(denominator) < 1e-9) return !1;
|
|
2407
|
+
let t = ((c.x - a.x) * (d.y - c.y) - (c.y - a.y) * (d.x - c.x)) / denominator, u = ((c.x - a.x) * (b.y - a.y) - (c.y - a.y) * (b.x - a.x)) / denominator;
|
|
2408
|
+
return t > 1e-6 && t < 1 - 1e-6 && u > 1e-6 && u < 1 - 1e-6;
|
|
2409
|
+
}
|
|
2410
|
+
function pointOnRectToward(rect, target) {
|
|
2411
|
+
let centre = rectCenter(rect), dx = target.x - centre.x, dy = target.y - centre.y, scale = 1 / Math.max(Math.abs(dx) / (rect.w / 2), Math.abs(dy) / (rect.h / 2), 1e-9);
|
|
2412
|
+
return qPoint({ x: centre.x + dx * scale, y: centre.y + dy * scale });
|
|
2413
|
+
}
|
|
2414
|
+
var pointKey = (point) => `${q(point.x)},${q(point.y)}`, uniqueSorted = (values) => [...new Set(values.map(q))].sort((a, b) => a - b), serializePoints = (points) => points.map((point) => `${q(point.x)},${q(point.y)}`).join(";"), serializeIndices = (indices) => indices.join(",");
|
|
2415
|
+
|
|
2416
|
+
// src/core/charts/diagram/layout.ts
|
|
2417
|
+
var DIAGRAM_MIN_WIDTH = 480, NARROW_PRESETS = /* @__PURE__ */ new Set(["circular-process", "strategy-house"]);
|
|
2418
|
+
function layoutDiagram(rawData, rawOptions, measureMinimum = !0) {
|
|
2419
|
+
return layoutDiagramPass(rawData, rawOptions, measureMinimum);
|
|
2420
|
+
}
|
|
2421
|
+
function layoutDiagramPass(rawData, rawOptions, measureMinimum, fitOnly = !1) {
|
|
2422
|
+
if (!rawOptions?.variant)
|
|
2423
|
+
throw new NormalizeError(
|
|
2424
|
+
"invalid-options",
|
|
2425
|
+
"options.variant",
|
|
2426
|
+
"diagram requires an explicit variant"
|
|
2427
|
+
);
|
|
2428
|
+
let { data, options } = normalizeDiagramModel(rawData, rawOptions), theme = chartTheme(options), size = resolveSize(options.size), measure = options.measure ?? defaultMeasurer, u = Math.max(4, theme.space.labelPad), warnings = [], palette = chartPalette(theme, options.palette, warnings);
|
|
2429
|
+
pushAll(warnings, duplicateOrderWarnings(data, options));
|
|
2430
|
+
let categoryKeys = diagramCategoryKeys([...data.nodes, ...data.groups, ...data.lanes]), diagramPalette = createDiagramPalette(
|
|
2431
|
+
theme,
|
|
2432
|
+
categoryKeys,
|
|
2433
|
+
palette ? options.palette : void 0,
|
|
2434
|
+
new Set([...data.nodes, ...data.groups, ...data.key, ...data.edges].flatMap((item) => item.paletteKey ? [item.paletteKey] : [])),
|
|
2435
|
+
diagramCategoryKeys(data.edges)
|
|
2436
|
+
), keyedRoles = new Set(data.key.map((entry) => entry.role)), unkeyed = [...new Set(data.nodes.flatMap((node) => (node.role === "good" || node.role === "bad" || node.role === "warn") && !keyedRoles.has(node.role) ? [node.role] : []))];
|
|
2437
|
+
unkeyed.length > 0 && warnings.push({
|
|
2438
|
+
code: "diagram-tone-unexplained",
|
|
2439
|
+
severity: "info",
|
|
2440
|
+
message: `nodes filled in the ${unkeyed.join(", ")} tone read by convention; name it in data.key when the tone means something else`,
|
|
2441
|
+
suggest: `name it in data.key, for example { role: '${unkeyed[0]}', label: '\u2026' }`
|
|
2442
|
+
});
|
|
2443
|
+
let keyItems = data.key.map((entry, index) => entry.line !== void 0 ? { id: `key:${index}`, label: entry.label, paint: { token: "leader" }, key: "line", width: strokeToken(theme, "rule"), ...entry.line === "solid" ? {} : { dash: edgeDash(theme, entry.line), lineCap: entry.line === "dotted" ? "round" : "butt" } } : {
|
|
2444
|
+
id: `key:${index}`,
|
|
2445
|
+
label: entry.label,
|
|
2446
|
+
// The fill the nodes of that role wear, as nodeFillPaint paints them.
|
|
2447
|
+
paint: nodeFillPaint(
|
|
2448
|
+
data.nodes.find((node) => node.role === entry.role && node.paletteKey === entry.paletteKey) ?? { id: `key:${index}`, kind: "step", label: entry.label, shape: { kind: "rectangle" }, role: entry.role, paletteKey: entry.paletteKey },
|
|
2449
|
+
diagramPalette,
|
|
2450
|
+
theme
|
|
2451
|
+
)
|
|
2452
|
+
}), occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frame = solveFrame(
|
|
2453
|
+
{
|
|
2454
|
+
size,
|
|
2455
|
+
margin: { ...canvasMargin(theme, size.width), ...options.margin },
|
|
2456
|
+
...frameTextOptions(options),
|
|
2457
|
+
unit: void 0,
|
|
2458
|
+
...keyItems.length > 0 ? { legend: { options: { position: theme.legend?.required ?? "top" }, items: keyItems } } : {},
|
|
2459
|
+
theme,
|
|
2460
|
+
measure
|
|
2461
|
+
},
|
|
2462
|
+
occupied
|
|
2463
|
+
), plot = frame.plot, labelFont = { family: theme.type.family, ...theme.type.label }, axisFont = { family: theme.type.family, ...theme.type.axis }, stepFont = { ...labelFont, weight: emphasisWeight(theme) }, headFont = { ...labelFont, weight: headingWeight(theme) }, badgeFont = options.variant === "linear-process" ? { ...labelFont, weight: emphasisWeight(theme) } : labelFont, laneFont = options.variant === "roadmap" ? { ...axisFont, weight: headingWeight(theme) } : axisFont, nodeFontById = (id) => {
|
|
2464
|
+
let node = data.nodes.find((candidate) => candidate.id === id);
|
|
2465
|
+
return node ? presetFont(node) : void 0;
|
|
2466
|
+
}, presetFont = (node) => options.variant === "linear-process" && node.kind === "step" ? stepFont : options.variant === "strategy-house" && (node.kind === "vision" || node.kind === "objective" || node.kind === "foundation") ? headFont : void 0, captionFont = options.variant === "linear-process" ? axisFont : labelFont, lineHeight = labelFont.size * (labelFont.lineHeight ?? 1.2), externalLabels = options.variant === "circular-process" || options.variant === "roadmap", pills = new Map(data.nodes.filter((node) => node.badge && node.badge.text.length > 3).map((node) => {
|
|
2467
|
+
let text = measure(node.badge.text, badgeFont), height = q(Math.max(4 * u, text.height + u));
|
|
2468
|
+
return [node.id, { width: q(Math.max(height, text.width + 2 * u)), height }];
|
|
2469
|
+
})), stepNumbers = /* @__PURE__ */ new Map(), kindCounts = /* @__PURE__ */ new Map();
|
|
2470
|
+
for (let node of data.nodes) {
|
|
2471
|
+
let count = (kindCounts.get(node.kind) ?? 0) + 1;
|
|
2472
|
+
kindCounts.set(node.kind, count), stepNumbers.set(node.id, count);
|
|
2473
|
+
}
|
|
2474
|
+
let badgeText = (node) => node.badge?.text ?? String(stepNumbers.get(node.id)), badgeSizes = new Map(data.nodes.filter((node) => node.badge || options.variant === "linear-process").map((node) => {
|
|
2475
|
+
let text = measure(badgeText(node), badgeFont), diameter = q(Math.max(4 * u, text.width + 2 * u, text.height + 2 * u));
|
|
2476
|
+
return [node.id, pills.get(node.id) ?? { width: diameter, height: diameter }];
|
|
2477
|
+
})), nodeSizes = new Map(
|
|
2478
|
+
data.nodes.map((node) => {
|
|
2479
|
+
let size2 = measuredNodeSize(node, Math.max(measure(node.label, presetFont(node) ?? labelFont).width, node.secondaryLabel ? measure(node.secondaryLabel, labelFont).width : 0), lineHeight, u), pill = badgeSizes.get(node.id);
|
|
2480
|
+
return [node.id, pill && !externalLabels ? { width: Math.max(size2.width, pill.width + 2 * u), height: size2.height + pill.height } : size2];
|
|
2481
|
+
})
|
|
2482
|
+
), presetContext = {
|
|
2483
|
+
data,
|
|
2484
|
+
options,
|
|
2485
|
+
plot,
|
|
2486
|
+
sizes: nodeSizes,
|
|
2487
|
+
lineHeight,
|
|
2488
|
+
u,
|
|
2489
|
+
palette: diagramPalette,
|
|
2490
|
+
measure,
|
|
2491
|
+
font: labelFont,
|
|
2492
|
+
titleFont: axisFont,
|
|
2493
|
+
headFont
|
|
2494
|
+
}, org = orgChartEligible(data, options) ? layoutOrgChart(data, plot, labelFont, measure, u) : issueTreeEligible(data, options) ? layoutIssueTreeCompact(data, plot, labelFont, measure, u, headingWeight(theme)) : journeyEligible(data, options) ? layoutJourneyCompact(data, options, plot, labelFont, axisFont, measure, u, diagramPalette, headingWeight(theme)) : linearEligible(data, options) ? layoutLinearCompact(
|
|
2495
|
+
data,
|
|
2496
|
+
plot,
|
|
2497
|
+
stepFont,
|
|
2498
|
+
badgeFont,
|
|
2499
|
+
captionFont,
|
|
2500
|
+
measure,
|
|
2501
|
+
u,
|
|
2502
|
+
badgeText,
|
|
2503
|
+
size.width >= 720 ? 2 * stepFont.size : 0
|
|
2504
|
+
) : roadmapEligible(data, options) ? layoutRoadmapCompact(data, options, plot, labelFont, laneFont, measure, u, diagramPalette, theme) : void 0, narrow = org !== void 0 || NARROW_PRESETS.has(options.variant), narrowCard = !narrow && panelTypeClass(options) === void 0 && size.width < DIAGRAM_MIN_WIDTH, probe = fitOnly && !narrowCard, preset = org?.preset ?? layoutPreset(theme, presetContext);
|
|
2505
|
+
if (!externalLabels && !org)
|
|
2506
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
2507
|
+
let changed = !1;
|
|
2508
|
+
for (let node of data.nodes) {
|
|
2509
|
+
let rect = preset.nodeRects.get(node.id);
|
|
2510
|
+
if (!rect) continue;
|
|
2511
|
+
let width = Math.max(1, rect.w - 4 * u), lines = wrapText(node.label, presetFont(node) ?? labelFont, width, 3, measure).lines.length, secondary = node.secondaryLabel ? wrapText(node.secondaryLabel, labelFont, width, 2, measure).lines.length * lineHeight + u : 0, icon = Math.max(preset.contentTopReserves.get(node.id) ?? 0, node.icon || node.shape.kind === "icon" ? Math.max(4.5 * u, 28) : 0), height = lines * lineHeight + secondary + icon + 3 * u + (badgeSizes.get(node.id)?.height ?? 0), current = nodeSizes.get(node.id);
|
|
2512
|
+
height > current.height && (nodeSizes.set(node.id, { ...current, height }), changed = !0);
|
|
2513
|
+
}
|
|
2514
|
+
if (!changed) break;
|
|
2515
|
+
preset = layoutPreset(theme, presetContext);
|
|
2516
|
+
}
|
|
2517
|
+
if (preset.compressed && warnings.push({
|
|
2518
|
+
code: "diagram-layout-compressed",
|
|
2519
|
+
severity: "info",
|
|
2520
|
+
message: `${options.variant} reduced legal node width below its preferred measured width`
|
|
2521
|
+
}), options.variant === "circular-process" && data.nodes.length < 2 && warnings.push({
|
|
2522
|
+
code: "diagram-cycle-degenerate",
|
|
2523
|
+
severity: "info",
|
|
2524
|
+
message: `circular-process has ${data.nodes.length} step${data.nodes.length === 1 ? "" : "s"}; no false full cycle was invented`
|
|
2525
|
+
}), options.variant === "customer-journey" && options.flow === "serpentine" && data.lanes.length > 1 && warnings.push({
|
|
2526
|
+
code: "diagram-layout-wrapped",
|
|
2527
|
+
severity: "info",
|
|
2528
|
+
message: `customer-journey wrapped ${data.lanes.length} phases into a serpentine reading path`
|
|
2529
|
+
}), options.variant === "customer-journey" || options.variant === "roadmap")
|
|
2530
|
+
for (let lane of data.lanes)
|
|
2531
|
+
data.nodes.some((node) => node.laneId === lane.id) || warnings.push({
|
|
2532
|
+
code: "diagram-empty-phase",
|
|
2533
|
+
severity: "info",
|
|
2534
|
+
message: `phase '${lane.label ?? lane.id}' has no members`,
|
|
2535
|
+
owner: laneOwner(lane.id)
|
|
2536
|
+
});
|
|
2537
|
+
let refusedIds = ensurePositionContract(rawData.nodes, data.nodes, preset.nodeRects, plot, warnings), labelRequests = [], labelKinds = /* @__PURE__ */ new Map(), boldLeads = /* @__PURE__ */ new Map(), nodeMarks = [], nodeScene = [], badgeScene = [], groupScene = [], framedGroups = options.variant !== "strategy-house" || theme.marks?.nodeStroke !== void 0, groups = preset.groups.map((group) => {
|
|
2538
|
+
let authored = data.groups.find((candidate) => candidate.id === group.id), nodeId = diagramSceneId("group", group.id);
|
|
2539
|
+
return framedGroups && groupScene.push({
|
|
2540
|
+
t: "rect",
|
|
2541
|
+
id: nodeId,
|
|
2542
|
+
rect: group.bounds,
|
|
2543
|
+
fill: { token: "others", tint: 0.82 },
|
|
2544
|
+
stroke: diagramPalette.paint(authored.role, authored.paletteKey),
|
|
2545
|
+
// A group frame follows the node ring's width and corner.
|
|
2546
|
+
strokeWidth: theme.marks?.nodeStrokeWidth ?? strokeToken(theme, "hair"),
|
|
2547
|
+
radius: theme.marks?.nodeRadius ?? resolveSurface(theme).chipRadius,
|
|
2548
|
+
owner: groupOwner(group.id),
|
|
2549
|
+
part: "diagramGroup"
|
|
2550
|
+
}), options.variant === "hierarchy" && addBoxLabelRequest(
|
|
2551
|
+
labelRequests,
|
|
2552
|
+
labelKinds,
|
|
2553
|
+
`group-label:${group.id}`,
|
|
2554
|
+
"diagramGroup",
|
|
2555
|
+
groupOwner(group.id),
|
|
2556
|
+
authored.title,
|
|
2557
|
+
group.titleBox,
|
|
2558
|
+
axisFont,
|
|
2559
|
+
measure,
|
|
2560
|
+
PRIORITY.endpoint,
|
|
2561
|
+
options.target
|
|
2562
|
+
), { ...group, sceneNodeIds: framedGroups ? [nodeId] : [] };
|
|
2563
|
+
}), numberedPhases = options.variant === "customer-journey" && options.flow === "serpentine" && data.lanes.length > 1, lanes = preset.lanes.map((lane, laneIndex) => {
|
|
2564
|
+
let authored = data.lanes.find((candidate) => candidate.id === lane.id);
|
|
2565
|
+
return lane.headerBox && authored.label && addBoxLabelRequest(
|
|
2566
|
+
labelRequests,
|
|
2567
|
+
labelKinds,
|
|
2568
|
+
`lane-label:${lane.id}`,
|
|
2569
|
+
"diagramLane",
|
|
2570
|
+
laneOwner(lane.id),
|
|
2571
|
+
numberedPhases ? `${laneIndex + 1} ${authored.label}` : authored.label,
|
|
2572
|
+
lane.headerBox,
|
|
2573
|
+
laneFont,
|
|
2574
|
+
measure,
|
|
2575
|
+
PRIORITY.endpoint,
|
|
2576
|
+
options.target,
|
|
2577
|
+
paintColor(theme, org?.laneFills?.get(lane.id) ?? diagramPalette.lane(authored.role, authored.paletteKey)),
|
|
2578
|
+
org?.laneFills?.get(lane.id) ?? diagramPalette.lane(authored.role, authored.paletteKey)
|
|
2579
|
+
), {
|
|
2580
|
+
...lane,
|
|
2581
|
+
sceneNodeIds: [
|
|
2582
|
+
diagramSceneId("lane", lane.id, "header"),
|
|
2583
|
+
diagramSceneId("lane", lane.id, "partition")
|
|
2584
|
+
].filter((id) => preset.decorationScene.some((node) => node.id === id))
|
|
2585
|
+
};
|
|
2586
|
+
});
|
|
2587
|
+
preset.decorationClaims.forEach(
|
|
2588
|
+
(claim) => occupied.claim(claim.rect, "mark", claim.owner, claim.part)
|
|
2589
|
+
);
|
|
2590
|
+
for (let [id, pill] of badgeSizes) {
|
|
2591
|
+
let rect = preset.nodeRects.get(id);
|
|
2592
|
+
rect && !externalLabels && !org?.badges && preset.nodeRects.set(id, qRect({ ...rect, y: rect.y + pill.height / 2, h: rect.h - pill.height / 2 }));
|
|
2593
|
+
}
|
|
2594
|
+
for (let node of data.nodes) {
|
|
2595
|
+
let rect = preset.nodeRects.get(node.id);
|
|
2596
|
+
if (!rect)
|
|
2597
|
+
throw new NormalizeError(
|
|
2598
|
+
"diagram-node-unplaced",
|
|
2599
|
+
`nodes[${node.id}]`,
|
|
2600
|
+
`variant '${options.variant}' did not place node '${node.id}'`
|
|
2601
|
+
);
|
|
2602
|
+
let icon = node.icon ?? (node.shape.kind === "icon" ? node.shape.name : void 0), iconReserve = org ? 0 : preset.contentTopReserves.get(node.id) ?? (icon ? Math.min(rect.h * 0.42, 28) : 0), contentRect = org ? org.labelBoxes.get(node.id) : qRect({
|
|
2603
|
+
x: rect.x + 2 * u,
|
|
2604
|
+
y: rect.y + 1.25 * u,
|
|
2605
|
+
w: Math.max(1, rect.w - 4 * u),
|
|
2606
|
+
h: Math.max(1, rect.h - 2.5 * u)
|
|
2607
|
+
}), pill = pills.get(node.id), badgeSize = badgeSizes.get(node.id);
|
|
2608
|
+
if (badgeSize && !externalLabels && !org?.badges) {
|
|
2609
|
+
let reserve = Math.max(0, badgeSize.height / 2 + u - 1.25 * u);
|
|
2610
|
+
contentRect.y += reserve, contentRect.h = Math.max(1, contentRect.h - reserve);
|
|
2611
|
+
}
|
|
2612
|
+
iconReserve && (contentRect.y += iconReserve, contentRect.h = Math.max(1, contentRect.h - iconReserve));
|
|
2613
|
+
let resolved = {
|
|
2614
|
+
id: node.id,
|
|
2615
|
+
kind: node.kind,
|
|
2616
|
+
shape: node.shape,
|
|
2617
|
+
rect,
|
|
2618
|
+
contentRect,
|
|
2619
|
+
ports: [],
|
|
2620
|
+
labelIds: [],
|
|
2621
|
+
sceneNodeIds: []
|
|
2622
|
+
}, shapes = nodeShapeScene(
|
|
2623
|
+
node,
|
|
2624
|
+
resolved,
|
|
2625
|
+
diagramPalette,
|
|
2626
|
+
theme,
|
|
2627
|
+
org ? {
|
|
2628
|
+
iconBox: org.icons.get(node.id),
|
|
2629
|
+
ring: theme.marks?.nodeStroke !== void 0,
|
|
2630
|
+
...theme.marks?.nodeStroke === void 0 && org.rings?.has(node.id) ? { ringPaint: org.rings.get(node.id) } : {},
|
|
2631
|
+
...org.fills?.has(node.id) ? { fill: org.fills.get(node.id) } : {},
|
|
2632
|
+
...org.plainShape ? { plainShape: !0 } : {},
|
|
2633
|
+
...org.paths?.has(node.id) ? { d: org.paths.get(node.id) } : {}
|
|
2634
|
+
} : options.variant === "strategy-house" && theme.marks?.nodeStroke === void 0 ? { ring: !1 } : void 0
|
|
2635
|
+
);
|
|
2636
|
+
if (pushAll(resolved.sceneNodeIds, shapes.map((shape) => shape.id)), pushAll(nodeScene, shapes), occupied.claim(rect, "mark", nodeOwner(node.id), "diagramNode"), addNodeLabels(
|
|
2637
|
+
node,
|
|
2638
|
+
resolved,
|
|
2639
|
+
options,
|
|
2640
|
+
org?.fonts.get(node.id) ?? presetFont(node) ?? labelFont,
|
|
2641
|
+
measure,
|
|
2642
|
+
u,
|
|
2643
|
+
labelRequests,
|
|
2644
|
+
labelKinds,
|
|
2645
|
+
warnings,
|
|
2646
|
+
org?.fills?.has(node.id) ? paintColor(theme, org.fills.get(node.id)) : nodeFillCss(node, diagramPalette, theme),
|
|
2647
|
+
plot,
|
|
2648
|
+
org?.fills?.get(node.id) ?? nodeFillPaint(node, diagramPalette, theme),
|
|
2649
|
+
boldLeads,
|
|
2650
|
+
options.variant === "roadmap" ? preset.lanes.find((lane) => lane.id === node.laneId)?.bounds : void 0,
|
|
2651
|
+
org !== void 0 && !org.centred,
|
|
2652
|
+
emphasisWeight(theme),
|
|
2653
|
+
org?.captionBoxes ? { font: captionFont, box: org.captionBoxes.get(node.id) } : org?.seats ? { font: labelFont, seat: org.seats.get(node.id) } : void 0
|
|
2654
|
+
), node.badge || options.variant === "linear-process") {
|
|
2655
|
+
let badgePaint = org?.badgePaint ?? (node.badge ? diagramPalette.fill(node.badge.role, node.badge.paletteKey) : { token: "neutralMark" }), text = badgeText(node), diameter = q(Math.max(4 * u, measure(text, badgeFont).width + 2 * u)), badgeBox = org?.badges?.get(node.id) ?? qRect({
|
|
2656
|
+
x: rect.x + u,
|
|
2657
|
+
y: rect.y - (badgeSize?.height ?? diameter) / 2,
|
|
2658
|
+
w: badgeSize?.width ?? diameter,
|
|
2659
|
+
h: badgeSize?.height ?? diameter
|
|
2660
|
+
});
|
|
2661
|
+
if (rectContains({ x: 0, y: 0, w: size.width, h: size.height }, badgeBox)) {
|
|
2662
|
+
let badgeId = diagramSceneId("badge", node.id);
|
|
2663
|
+
badgeScene.push({
|
|
2664
|
+
...pill ? { t: "rect", rect: badgeBox, radius: resolveSurface(theme).chipRadius } : {
|
|
2665
|
+
t: "circle",
|
|
2666
|
+
cx: q(badgeBox.x + badgeBox.w / 2),
|
|
2667
|
+
cy: q(badgeBox.y + badgeBox.h / 2),
|
|
2668
|
+
r: q(badgeBox.w / 2)
|
|
2669
|
+
},
|
|
2670
|
+
id: badgeId,
|
|
2671
|
+
fill: badgePaint,
|
|
2672
|
+
owner: nodeOwner(node.id),
|
|
2673
|
+
part: "diagramBadge"
|
|
2674
|
+
}), occupied.claim(badgeBox, "mark", nodeOwner(node.id), "diagramBadge"), resolved.badgeBox = badgeBox, resolved.sceneNodeIds.push(badgeId), addBoxLabelRequest(
|
|
2675
|
+
labelRequests,
|
|
2676
|
+
labelKinds,
|
|
2677
|
+
`badge-label:${node.id}`,
|
|
2678
|
+
"diagramBadge",
|
|
2679
|
+
nodeOwner(node.id),
|
|
2680
|
+
text,
|
|
2681
|
+
badgeBox,
|
|
2682
|
+
badgeFont,
|
|
2683
|
+
measure,
|
|
2684
|
+
PRIORITY.endpoint,
|
|
2685
|
+
options.target,
|
|
2686
|
+
paintColor(theme, badgePaint),
|
|
2687
|
+
badgePaint,
|
|
2688
|
+
// Authored badge text is a name; the linear-process sequence number is a value.
|
|
2689
|
+
node.badge ? "category" : "value"
|
|
2690
|
+
);
|
|
2691
|
+
} else node.badge && warnings.push({
|
|
2692
|
+
code: "diagram-size-too-small",
|
|
2693
|
+
severity: "error",
|
|
2694
|
+
message: `badge '${text}' on node '${node.id}' cannot fit the canvas`,
|
|
2695
|
+
suggest: `shorten badge '${text}' or give node '${node.id}' more space`,
|
|
2696
|
+
owner: nodeOwner(node.id)
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
nodeMarks.push(resolved);
|
|
2700
|
+
}
|
|
2701
|
+
let solvedStructural = solveLabels(labelRequests, occupied, labelCtx(theme, size, {}, {
|
|
2702
|
+
density: "full",
|
|
2703
|
+
measure,
|
|
2704
|
+
plot,
|
|
2705
|
+
labelPad: 1
|
|
2706
|
+
}));
|
|
2707
|
+
remapLabelKinds(solvedStructural.placed, labelKinds);
|
|
2708
|
+
for (let label of solvedStructural.placed) {
|
|
2709
|
+
let node = org?.badges && label.id.startsWith("badge-label:") ? data.nodes.find((candidate) => candidate.id === label.owner.pointId) : void 0, ink = org?.labelInks?.get(label.id) ?? (node ? nodeFillPaint(node, diagramPalette, theme) : void 0);
|
|
2710
|
+
ink && !label.hidden && (label.ink = ink);
|
|
2711
|
+
}
|
|
2712
|
+
if (pushAll(warnings, solvedStructural.warnings), translateLabelLosses(solvedStructural.placed, labelKinds, warnings), probe && (warnings.some((warning) => warning.severity === "error") || sizeWarning(
|
|
2713
|
+
nodeMarks.filter((node) => !refusedIds.has(node.id)),
|
|
2714
|
+
plot,
|
|
2715
|
+
warnings,
|
|
2716
|
+
options.variant,
|
|
2717
|
+
0
|
|
2718
|
+
))) return { warnings };
|
|
2719
|
+
if (probe && fitOnly === "structural") return { warnings };
|
|
2720
|
+
for (let label of solvedStructural.placed) {
|
|
2721
|
+
let nodeId = label.owner.pointId;
|
|
2722
|
+
if (!nodeId) continue;
|
|
2723
|
+
let mark = nodeMarks.find((candidate) => candidate.id === nodeId);
|
|
2724
|
+
mark && (mark.labelIds.push(label.id), label.kind === "diagramCaption" && !label.hidden && (mark.captionBox = label.rect));
|
|
2725
|
+
}
|
|
2726
|
+
let structuralLabelNodes = probe ? [] : labelsToNodes(
|
|
2727
|
+
theme,
|
|
2728
|
+
solvedStructural.placed,
|
|
2729
|
+
(label) => ["diagramLane", "diagramGroup", "diagramBadge"].includes(label.kind) ? labelKinds.get(label.id) === "diagramBadge" ? badgeFont : labelKinds.get(label.id) === "diagramLane" ? laneFont : axisFont : labelKinds.get(label.id) === "diagramCaption" && org?.captionBoxes ? captionFont : (label.owner.pointId ? org?.fonts.get(label.owner.pointId) ?? (label.id.startsWith("node-label:") ? nodeFontById(label.owner.pointId) : void 0) : void 0) ?? labelFont
|
|
2730
|
+
).flatMap((node) => splitBoldLead(node, boldLeads, emphasisWeight(theme))), reservedForRouting = solvedStructural.placed.filter((label) => !label.hidden).map((label) => label.rect), edgeLabelSizes = new Map(
|
|
2731
|
+
preset.edges.flatMap(
|
|
2732
|
+
(edge) => edge.label ? [[edge.id, { width: measure(edge.label, labelFont).width, height: measure(edge.label, labelFont).height }]] : []
|
|
2733
|
+
)
|
|
2734
|
+
), routed = routeDiagramEdges(theme, {
|
|
2735
|
+
preset: options.variant,
|
|
2736
|
+
nodes: data.nodes,
|
|
2737
|
+
nodeRects: preset.nodeRects,
|
|
2738
|
+
edges: preset.edges,
|
|
2739
|
+
plot,
|
|
2740
|
+
clearance: u,
|
|
2741
|
+
labelSizes: edgeLabelSizes,
|
|
2742
|
+
reserved: reservedForRouting,
|
|
2743
|
+
palette: diagramPalette,
|
|
2744
|
+
...org ? { fixedRoutes: org.routes, ...org.centred ? {} : { edgePaint: { token: "neutral", tint: 0.2 } } } : options.variant === "circular-process" ? { edgePaint: { token: "neutral" } } : {}
|
|
2745
|
+
});
|
|
2746
|
+
if (pushAll(warnings, routed.warnings), probe) return { warnings };
|
|
2747
|
+
routed.claims.forEach(
|
|
2748
|
+
(claim) => occupied.claim(claim.rect, "mark", { segmentId: claim.edgeId }, claim.part)
|
|
2749
|
+
), nodeMarks.forEach((node) => {
|
|
2750
|
+
node.ports = routed.portsByNode.get(node.id) ?? [];
|
|
2751
|
+
});
|
|
2752
|
+
let edgeLabelRequests = [], edgeLabelKinds = /* @__PURE__ */ new Map();
|
|
2753
|
+
preset.edges.forEach((edge) => {
|
|
2754
|
+
let rect = routed.labelBoxes.get(edge.id);
|
|
2755
|
+
!edge.label || !rect || addBoxLabelRequest(
|
|
2756
|
+
edgeLabelRequests,
|
|
2757
|
+
edgeLabelKinds,
|
|
2758
|
+
`edge-label:${edge.id}`,
|
|
2759
|
+
"diagramEdge",
|
|
2760
|
+
{ segmentId: edge.id },
|
|
2761
|
+
edge.label,
|
|
2762
|
+
rect,
|
|
2763
|
+
labelFont,
|
|
2764
|
+
measure,
|
|
2765
|
+
PRIORITY.interior,
|
|
2766
|
+
options.target
|
|
2767
|
+
);
|
|
2768
|
+
});
|
|
2769
|
+
let solvedEdges = solveLabels(edgeLabelRequests, occupied, labelCtx(theme, size, {}, {
|
|
2770
|
+
density: "full",
|
|
2771
|
+
measure,
|
|
2772
|
+
plot,
|
|
2773
|
+
labelPad: 1
|
|
2774
|
+
}));
|
|
2775
|
+
remapLabelKinds(solvedEdges.placed, edgeLabelKinds), pushAll(warnings, solvedEdges.warnings);
|
|
2776
|
+
let edgeLabelNodes = labelsToNodes(theme, solvedEdges.placed, () => labelFont), { laneGroupLabels, nodeLabels, accessoryLabels } = groupStructuralLabels(structuralLabelNodes), scene = [
|
|
2777
|
+
...frame.nodes,
|
|
2778
|
+
...groupScene,
|
|
2779
|
+
...preset.decorationScene,
|
|
2780
|
+
...routed.scene,
|
|
2781
|
+
...nodeScene,
|
|
2782
|
+
...laneGroupLabels,
|
|
2783
|
+
...nodeLabels,
|
|
2784
|
+
...badgeScene,
|
|
2785
|
+
...accessoryLabels,
|
|
2786
|
+
...edgeLabelNodes
|
|
2787
|
+
], labels = [...solvedStructural.placed, ...solvedEdges.placed], a11y = diagramA11y(data, options, preset.readingOrder, preset.edges), nodeLabelLosses = warnings.filter((warning) => warning.code === "diagram-node-label-unplaced"), tooSmall = sizeWarning(
|
|
2788
|
+
nodeMarks.filter((node) => !refusedIds.has(node.id)),
|
|
2789
|
+
plot,
|
|
2790
|
+
warnings,
|
|
2791
|
+
options.variant,
|
|
2792
|
+
new Set(nodeLabelLosses.map((warning) => warning.owner?.pointId ?? warning.message)).size
|
|
2793
|
+
), contentRects = [
|
|
2794
|
+
...nodeMarks.map((node) => node.rect),
|
|
2795
|
+
...groups.map((group) => group.bounds),
|
|
2796
|
+
...lanes.map((lane) => lane.bounds),
|
|
2797
|
+
...nodeMarks.flatMap((node) => badgeSizes.has(node.id) && node.badgeBox ? [node.badgeBox] : []),
|
|
2798
|
+
...labels.filter((label) => !label.hidden).map((label) => label.rect),
|
|
2799
|
+
...org?.extent ?? []
|
|
2800
|
+
], sizing = org ? contentSizing("diagram", size, plot, contentRects) : naturalDiagramSizing(options, data, nodeSizes, labelFont, measure, u, contentSizing("diagram", size, plot, contentRects), size, plot, headFont), unreadable = narrowCard && (solvedStructural.placed.some((label) => !label.hidden && label.title !== void 0 && CARD_TEXT_KINDS.has(label.kind)) || labels.some((label) => !!label.hidden && label.hidden !== "redundant") || solvedEdges.placed.some((label) => !label.hidden && label.title !== void 0) || refusedIds.size > 0 || groups.some((group, i) => groups.slice(i + 1).some((other) => rectsOverlap(group.bounds, other.bounds)))), refusedNarrow = unreadable && rawOptions[TARGET_SIZE]?.fixed.height !== !1, requiredAccessoryLoss = warnings.some((warning) => warning.code === "diagram-size-too-small" && warning.severity === "error"), minimumRequiredSize = (tooSmall || requiredAccessoryLoss || refusedIds.size > 0) && measureMinimum && !refusedNarrow ? measuredDiagramMinimum(
|
|
2801
|
+
size,
|
|
2802
|
+
sizing.naturalHeight,
|
|
2803
|
+
panelTypeClass(options) !== void 0,
|
|
2804
|
+
(candidate, structuralOnly) => layoutDiagramPass(
|
|
2805
|
+
rawData,
|
|
2806
|
+
{ ...rawOptions, size: candidate },
|
|
2807
|
+
!1,
|
|
2808
|
+
structuralOnly ? "structural" : !0
|
|
2809
|
+
)
|
|
2810
|
+
) : void 0;
|
|
2811
|
+
if (minimumRequiredSize) {
|
|
2812
|
+
sizing.minWidth = sizing.measuredMinWidth = minimumRequiredSize.width > size.width ? minimumRequiredSize.width : sizing.minWidth, sizing.minHeight = sizing.measuredMinHeight = minimumRequiredSize.height, sizing.naturalWidth = Math.max(sizing.naturalWidth, sizing.minWidth), sizing.naturalHeight = Math.max(sizing.naturalHeight, sizing.minHeight);
|
|
2813
|
+
for (let warning of [...nodeLabelLosses, ...warnings.filter((w) => w.code === "diagram-size-too-small" || w.code === "fixed-position-outside" || w.code === "fixed-position-overlap")])
|
|
2814
|
+
warning.suggest = `${warning.suggest ? `${warning.suggest}; ` : ""}render at ${minimumRequiredSize.width}\xD7${minimumRequiredSize.height}, or shorten the labels`, warning.fix = [{ op: "replace", path: "/options/size", value: minimumRequiredSize }];
|
|
2815
|
+
}
|
|
2816
|
+
let grow = rowDrivenHeight({ options: rawOptions, width: size.width, height: size.height, chromeH: 0, rowsH: sizing.naturalHeight });
|
|
2817
|
+
if (grow !== void 0) return layoutDiagram(rawData, { ...rawOptions, size: { width: size.width, height: grow } }, measureMinimum);
|
|
2818
|
+
let openHeight = narrowCard && rawOptions[TARGET_SIZE]?.fixed.height === !1, contentHeight = Math.ceil(sizing.naturalHeight - 1e-6);
|
|
2819
|
+
if (openHeight && contentHeight > size.height + 2)
|
|
2820
|
+
return layoutDiagram(rawData, { ...rawOptions, size: { width: size.width, height: contentHeight } }, measureMinimum);
|
|
2821
|
+
if (unreadable) {
|
|
2822
|
+
let policy = { ...chartSizing("diagram"), minWidth: DIAGRAM_MIN_WIDTH };
|
|
2823
|
+
return sizeRefusal("diagram", "Diagram", size, resolveSizing(policy, size));
|
|
2824
|
+
}
|
|
2825
|
+
return !narrow && !narrowCard && panelTypeClass(options) === void 0 && (sizing.minWidth = Math.max(sizing.minWidth, DIAGRAM_MIN_WIDTH)), {
|
|
2826
|
+
type: "diagram",
|
|
2827
|
+
size,
|
|
2828
|
+
sizing,
|
|
2829
|
+
plot,
|
|
2830
|
+
scene,
|
|
2831
|
+
labels,
|
|
2832
|
+
axes: [],
|
|
2833
|
+
annotations: [],
|
|
2834
|
+
frame: frame.frame,
|
|
2835
|
+
...frame.legend ? { legend: frame.legend } : {},
|
|
2836
|
+
marks: {
|
|
2837
|
+
nodes: nodeMarks,
|
|
2838
|
+
edges: routed.edges,
|
|
2839
|
+
groups,
|
|
2840
|
+
lanes
|
|
2841
|
+
},
|
|
2842
|
+
derived: {
|
|
2843
|
+
variant: options.variant,
|
|
2844
|
+
readingOrder: preset.readingOrder,
|
|
2845
|
+
syntheticEdgeIds: preset.syntheticEdgeIds,
|
|
2846
|
+
degradedEdgeIds: routed.edges.filter((edge) => edge.requestedRouting !== edge.actualRouting).map((edge) => edge.id),
|
|
2847
|
+
...minimumRequiredSize ? { minimumRequiredSize } : {},
|
|
2848
|
+
clearance: u,
|
|
2849
|
+
...preset.trajectory ? { trajectory: preset.trajectory } : {}
|
|
2850
|
+
},
|
|
2851
|
+
a11y,
|
|
2852
|
+
warnings,
|
|
2853
|
+
debug: {
|
|
2854
|
+
occupied: occupied.snapshot(),
|
|
2855
|
+
decisions: [...solvedStructural.decisions, ...solvedEdges.decisions]
|
|
2856
|
+
}
|
|
2857
|
+
};
|
|
2858
|
+
}
|
|
2859
|
+
function addNodeLabels(node, resolved, options, font, measure, u, requests, kinds, warnings, fillCss, plot, insidePaint, boldLeads, laneBox, start = !1, leadWeight = font.weight, caption) {
|
|
2860
|
+
let external = options.variant === "roadmap" || options.variant === "circular-process", ring = options.variant === "circular-process" ? circularSide(resolved.rect, plot) : void 0, ringWidth = ring === "left" ? resolved.rect.x - plot.x - 2 * u : ring === "right" ? plot.x + plot.w - resolved.rect.x - resolved.rect.w - 2 * u : plot.w / 2, maxWidth = ring ? Math.max(Math.min(18 * u, plot.w / 4), ringWidth) : external ? Math.min(18 * u, plot.w / Math.max(2, options.variant === "roadmap" ? 5 : 4)) : resolved.contentRect.w, externalFit = {
|
|
2861
|
+
target: options.target,
|
|
2862
|
+
typeRole: "label",
|
|
2863
|
+
...external && !ring ? { wider: plot.w / (options.variant === "roadmap" ? 5 : 4) } : {}
|
|
2864
|
+
}, id = `node-label:${node.id}`, cut = options.variant === "circular-process" ? node.label.indexOf(`
|
|
2865
|
+
`) : -1, bold = { ...font, weight: leadWeight }, lead = cut > 0 ? fitText(node.label.slice(0, cut), bold, maxWidth, 1, measure, externalFit) : void 0, seat = caption?.seat, wrapped = seat ? { lines: seat.lines, title: void 0 } : lead ? (() => {
|
|
2866
|
+
let rest = fitText(node.label.slice(cut + 1), font, maxWidth, 2, measure, externalFit);
|
|
2867
|
+
return { lines: [...lead.lines, ...rest.lines], title: lead.title ?? rest.title };
|
|
2868
|
+
})() : fitText(node.label, font, maxWidth, 3, measure, externalFit);
|
|
2869
|
+
lead && boldLeads.set(id, lead.lines.length);
|
|
2870
|
+
let lineH = font.size * (font.lineHeight ?? 1.2), width = Math.max(1, ...wrapped.lines.map((line, index) => measure(line, index < (lead?.lines.length ?? 0) ? bold : font).width)), height = wrapped.lines.length * lineH, secondary = node.secondaryLabel ? fitText(node.secondaryLabel, font, resolved.contentRect.w, 2, measure, { target: options.target, typeRole: "label" }) : void 0, secondaryHeight = (secondary?.lines.length ?? 0) * lineH, secondaryFits = secondary && !secondary.title && height + secondaryHeight + u <= resolved.contentRect.h, primaryHeight = resolved.contentRect.h - (!external && secondaryFits ? secondaryHeight + u : 0);
|
|
2871
|
+
kinds.set(id, "diagramNode");
|
|
2872
|
+
let candidates = seat ? [{ slot: "right", rect: qRect(seat.rect), penalty: 0 }] : !external && height > primaryHeight + 0.5 ? [] : external ? externalCandidates(
|
|
2873
|
+
resolved.rect,
|
|
2874
|
+
width,
|
|
2875
|
+
height,
|
|
2876
|
+
u,
|
|
2877
|
+
options.variant === "roadmap",
|
|
2878
|
+
plot,
|
|
2879
|
+
laneBox
|
|
2880
|
+
) : [
|
|
2881
|
+
{
|
|
2882
|
+
slot: "inside",
|
|
2883
|
+
rect: qRect({
|
|
2884
|
+
x: start ? resolved.contentRect.x : resolved.contentRect.x + (resolved.contentRect.w - width) / 2,
|
|
2885
|
+
y: resolved.contentRect.y + (primaryHeight - height) / 2,
|
|
2886
|
+
w: width,
|
|
2887
|
+
h: height
|
|
2888
|
+
}),
|
|
2889
|
+
penalty: 0,
|
|
2890
|
+
insideFill: fillCss,
|
|
2891
|
+
insidePaint
|
|
2892
|
+
}
|
|
2893
|
+
];
|
|
2894
|
+
if (requests.push({
|
|
2895
|
+
id,
|
|
2896
|
+
kind: "point",
|
|
2897
|
+
markAnchored: !1,
|
|
2898
|
+
typeRole: "label",
|
|
2899
|
+
owner: nodeOwner(node.id),
|
|
2900
|
+
text: node.label,
|
|
2901
|
+
lines: wrapped.lines,
|
|
2902
|
+
...wrapped.title !== void 0 ? { title: wrapped.title } : {},
|
|
2903
|
+
font,
|
|
2904
|
+
priority: PRIORITY.valueLine,
|
|
2905
|
+
...ring === "left" ? { align: "end" } : ring === "above" || ring === "below" ? { align: "middle" } : { align: "start" },
|
|
2906
|
+
candidates
|
|
2907
|
+
}), wrapped.title !== void 0 && warnings.push({
|
|
2908
|
+
code: "diagram-node-label-unplaced",
|
|
2909
|
+
severity: "error",
|
|
2910
|
+
message: `primary label on node '${node.id}' cannot fit without truncation`,
|
|
2911
|
+
owner: nodeOwner(node.id)
|
|
2912
|
+
}), node.secondaryLabel && secondary) {
|
|
2913
|
+
let secondaryWidth = Math.max(1, ...secondary.lines.map((line) => measure(line, font).width)), secondaryId = `secondary-label:${node.id}`;
|
|
2914
|
+
kinds.set(secondaryId, "diagramSecondary"), requests.push({
|
|
2915
|
+
id: secondaryId,
|
|
2916
|
+
kind: "point",
|
|
2917
|
+
markAnchored: !1,
|
|
2918
|
+
typeRole: "label",
|
|
2919
|
+
owner: nodeOwner(node.id),
|
|
2920
|
+
text: node.secondaryLabel,
|
|
2921
|
+
lines: secondary.lines,
|
|
2922
|
+
...secondary.title !== void 0 ? { title: secondary.title } : {},
|
|
2923
|
+
font,
|
|
2924
|
+
priority: PRIORITY.interior,
|
|
2925
|
+
candidates: secondaryFits ? [
|
|
2926
|
+
{
|
|
2927
|
+
slot: "inside-secondary",
|
|
2928
|
+
rect: qRect({
|
|
2929
|
+
x: resolved.contentRect.x + (resolved.contentRect.w - secondaryWidth) / 2,
|
|
2930
|
+
y: resolved.contentRect.y + resolved.contentRect.h - secondaryHeight,
|
|
2931
|
+
w: secondaryWidth,
|
|
2932
|
+
h: secondaryHeight
|
|
2933
|
+
}),
|
|
2934
|
+
penalty: 0,
|
|
2935
|
+
insideFill: fillCss,
|
|
2936
|
+
insidePaint
|
|
2937
|
+
}
|
|
2938
|
+
] : []
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
addNodeCaption(node, resolved, options, caption?.font ?? font, measure, u, requests, kinds, caption?.box);
|
|
2942
|
+
}
|
|
2943
|
+
function circularSide(rect, plot) {
|
|
2944
|
+
let dx = rect.x + rect.w / 2 - (plot.x + plot.w / 2), dy = rect.y + rect.h / 2 - (plot.y + plot.h / 2);
|
|
2945
|
+
return Math.abs(dx) > Math.abs(dy) ? dx < 0 ? "left" : "right" : dy < 0 ? "above" : "below";
|
|
2946
|
+
}
|
|
2947
|
+
function externalCandidates(rect, width, height, u, roadmap, plot, laneBox) {
|
|
2948
|
+
let cx = rect.x + rect.w / 2, cy = rect.y + rect.h / 2, candidates = [
|
|
2949
|
+
{
|
|
2950
|
+
slot: "above",
|
|
2951
|
+
rect: qRect({ x: cx - width / 2, y: rect.y - height - 2 * u, w: width, h: height }),
|
|
2952
|
+
penalty: 0,
|
|
2953
|
+
leaderFrom: { x: cx, y: cy }
|
|
2954
|
+
},
|
|
2955
|
+
{
|
|
2956
|
+
slot: "below",
|
|
2957
|
+
rect: qRect({ x: cx - width / 2, y: rect.y + rect.h + 2 * u, w: width, h: height }),
|
|
2958
|
+
penalty: 1,
|
|
2959
|
+
leaderFrom: { x: cx, y: cy }
|
|
2960
|
+
},
|
|
2961
|
+
{
|
|
2962
|
+
slot: "right",
|
|
2963
|
+
rect: qRect({ x: rect.x + rect.w + 2 * u, y: cy - height / 2, w: width, h: height }),
|
|
2964
|
+
penalty: 2,
|
|
2965
|
+
leaderFrom: { x: cx, y: cy }
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
slot: "left",
|
|
2969
|
+
rect: qRect({ x: rect.x - width - 2 * u, y: cy - height / 2, w: width, h: height }),
|
|
2970
|
+
penalty: 3,
|
|
2971
|
+
leaderFrom: { x: cx, y: cy }
|
|
2972
|
+
}
|
|
2973
|
+
];
|
|
2974
|
+
if (roadmap) {
|
|
2975
|
+
if (laneBox && width + 2 * u <= laneBox.w) {
|
|
2976
|
+
let x = Math.max(laneBox.x + u, Math.min(laneBox.x + laneBox.w - width - u, cx - width / 2));
|
|
2977
|
+
candidates.unshift(...candidates.slice(0, 2).map((candidate) => ({
|
|
2978
|
+
...candidate,
|
|
2979
|
+
slot: `${candidate.slot}InLane`,
|
|
2980
|
+
rect: { ...candidate.rect, x: q(x) }
|
|
2981
|
+
})));
|
|
2982
|
+
let clampX = (left) => q(Math.max(laneBox.x + u, Math.min(laneBox.x + laneBox.w - width - u, left)));
|
|
2983
|
+
for (let above of [!0, !1]) for (let right of [!0, !1])
|
|
2984
|
+
candidates.push({
|
|
2985
|
+
slot: `${above ? "above" : "below"}${right ? "Right" : "Left"}InLane`,
|
|
2986
|
+
rect: qRect({
|
|
2987
|
+
x: clampX(right ? rect.x + rect.w + u : rect.x - width - u),
|
|
2988
|
+
y: above ? rect.y - height - u : rect.y + rect.h + u,
|
|
2989
|
+
w: width,
|
|
2990
|
+
h: height
|
|
2991
|
+
}),
|
|
2992
|
+
penalty: 4,
|
|
2993
|
+
leaderFrom: { x: cx, y: cy }
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2996
|
+
return candidates;
|
|
2997
|
+
}
|
|
2998
|
+
let plotCentre = { x: plot.x + plot.w / 2, y: plot.y + plot.h / 2 }, dx = cx - plotCentre.x, dy = cy - plotCentre.y, radialSlot = Math.abs(dx) > Math.abs(dy) ? dx < 0 ? "left" : "right" : dy < 0 ? "above" : "below";
|
|
2999
|
+
return [
|
|
3000
|
+
...candidates.filter((candidate) => candidate.slot === radialSlot).map((candidate) => ({ ...candidate, slot: "outside", penalty: 0 })),
|
|
3001
|
+
...candidates.map((candidate, index) => ({ ...candidate, penalty: index + 1 }))
|
|
3002
|
+
];
|
|
3003
|
+
}
|
|
3004
|
+
function addBoxLabelRequest(requests, kinds, id, kind, owner, text, box, font, measure, priority, target, insideFill, insidePaint, role) {
|
|
3005
|
+
let wrapped = fitText(text, font, Math.max(1, box.w - 8), 2, measure, { target, typeRole: kind === "diagramBadge" || kind === "diagramEdge" ? "label" : "axis" }), lineH = font.size * (font.lineHeight ?? 1.2), width = Math.max(1, ...wrapped.lines.map((line) => measure(line, font).width)), height = wrapped.lines.length * lineH;
|
|
3006
|
+
kinds.set(id, kind), requests.push({
|
|
3007
|
+
id,
|
|
3008
|
+
kind: "annotation",
|
|
3009
|
+
typeRole: kind === "diagramBadge" || kind === "diagramEdge" ? "label" : "axis",
|
|
3010
|
+
owner,
|
|
3011
|
+
text,
|
|
3012
|
+
lines: wrapped.lines,
|
|
3013
|
+
...wrapped.title !== void 0 ? { title: wrapped.title } : {},
|
|
3014
|
+
font,
|
|
3015
|
+
priority,
|
|
3016
|
+
...role ? { role } : {},
|
|
3017
|
+
candidates: [
|
|
3018
|
+
{
|
|
3019
|
+
slot: "inside",
|
|
3020
|
+
rect: qRect({
|
|
3021
|
+
x: box.x + (box.w - width) / 2,
|
|
3022
|
+
y: box.y + (box.h - height) / 2,
|
|
3023
|
+
w: width,
|
|
3024
|
+
h: height
|
|
3025
|
+
}),
|
|
3026
|
+
penalty: 0,
|
|
3027
|
+
...insideFill ? { insideFill, insidePaint } : {}
|
|
3028
|
+
}
|
|
3029
|
+
]
|
|
3030
|
+
});
|
|
3031
|
+
}
|
|
3032
|
+
function remapLabelKinds(labels, kinds) {
|
|
3033
|
+
labels.forEach((label) => {
|
|
3034
|
+
let kind = kinds.get(label.id);
|
|
3035
|
+
kind && (label.kind = kind);
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
function translateLabelLosses(labels, kinds, warnings) {
|
|
3039
|
+
for (let label of labels) {
|
|
3040
|
+
if (!label.hidden) continue;
|
|
3041
|
+
let kind = kinds.get(label.id), code = kind === "diagramNode" ? "diagram-node-label-unplaced" : kind === "diagramSecondary" ? "diagram-secondary-label-unplaced" : kind === "diagramCaption" ? "diagram-caption-unplaced" : kind === "diagramBadge" ? "diagram-size-too-small" : void 0;
|
|
3042
|
+
code && warnings.push({
|
|
3043
|
+
code,
|
|
3044
|
+
severity: kind === "diagramNode" || kind === "diagramBadge" ? "error" : "warn",
|
|
3045
|
+
message: `${kind} '${label.text}' has no collision-free placement`,
|
|
3046
|
+
...kind === "diagramBadge" ? { suggest: `shorten badge '${label.text}' or give node '${label.owner.pointId}' more space` } : {},
|
|
3047
|
+
...kind === "diagramCaption" ? { suggest: "increase the canvas height or node spacing; shorten the caption or move it into secondaryLabel if it must stay inside the node" } : {},
|
|
3048
|
+
owner: label.owner
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
function ensurePositionContract(authored, nodes, rects, plot, warnings) {
|
|
3053
|
+
let fixed = nodes.filter((node) => node.position && rects.has(node.id)), refused = /* @__PURE__ */ new Set(), span = (from, size) => `${q(from)} to ${q(from + size)}`;
|
|
3054
|
+
for (let node of fixed) {
|
|
3055
|
+
let rect = rects.get(node.id);
|
|
3056
|
+
rectContains(plot, rect) || (refused.add(node.id), warnings.push({
|
|
3057
|
+
code: "fixed-position-outside",
|
|
3058
|
+
severity: "error",
|
|
3059
|
+
message: `fixed node '${node.id}' leaves the plot: the node spans x ${span(rect.x, rect.w)} and y ${span(rect.y, rect.h)} px, the plot x ${span(plot.x, plot.w)} and y ${span(plot.y, plot.h)} px`,
|
|
3060
|
+
suggest: `move nodes[${node.id}].position inward, or enlarge the canvas`,
|
|
3061
|
+
field: ["data", "nodes", authored.findIndex((candidate) => candidate.id === node.id), "position"],
|
|
3062
|
+
owner: nodeOwner(node.id)
|
|
3063
|
+
}));
|
|
3064
|
+
}
|
|
3065
|
+
for (let left = 0; left < fixed.length; left++)
|
|
3066
|
+
for (let right = left + 1; right < fixed.length; right++) {
|
|
3067
|
+
let [a, b] = [fixed[left], fixed[right]];
|
|
3068
|
+
rectsOverlap(rects.get(a.id), rects.get(b.id)) && (refused.add(a.id).add(b.id), warnings.push({
|
|
3069
|
+
code: "fixed-position-overlap",
|
|
3070
|
+
severity: "error",
|
|
3071
|
+
message: `fixed nodes '${a.id}' and '${b.id}' overlap`,
|
|
3072
|
+
suggest: `move nodes[${b.id}].position apart from '${a.id}', or enlarge the canvas`,
|
|
3073
|
+
field: ["data", "nodes", authored.findIndex((candidate) => candidate.id === b.id), "position"],
|
|
3074
|
+
owner: nodeOwner(b.id)
|
|
3075
|
+
}));
|
|
3076
|
+
}
|
|
3077
|
+
return refused;
|
|
3078
|
+
}
|
|
3079
|
+
function duplicateOrderWarnings(data, options) {
|
|
3080
|
+
return [
|
|
3081
|
+
["nodes", options.variant === "linear-process" || options.variant === "circular-process" ? data.nodes : []],
|
|
3082
|
+
["groups", data.groups],
|
|
3083
|
+
["lanes", data.lanes]
|
|
3084
|
+
].flatMap(([name, items]) => {
|
|
3085
|
+
let byOrder2 = /* @__PURE__ */ new Map();
|
|
3086
|
+
for (let item of items) item.order !== void 0 && byOrder2.set(item.order, [...byOrder2.get(item.order) ?? [], item.id]);
|
|
3087
|
+
return [...byOrder2].filter(([, ids]) => ids.length > 1).map(([order, ids]) => ({
|
|
3088
|
+
code: "diagram-order-duplicate",
|
|
3089
|
+
severity: "warn",
|
|
3090
|
+
message: `${name} ${ids.map((id) => `'${id}'`).join(", ")} share order ${order}; they are sequenced by id instead`,
|
|
3091
|
+
suggest: "give each item its own order value"
|
|
3092
|
+
}));
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
function sizeWarning(nodes, plot, warnings, preset, requiredLabelLosses) {
|
|
3096
|
+
let outside = nodes.filter((node) => !rectContains(plot, node.rect, -0.5)), overlaps = 0;
|
|
3097
|
+
for (let left = 0; left < nodes.length; left++)
|
|
3098
|
+
for (let right = left + 1; right < nodes.length; right++) {
|
|
3099
|
+
let a = nodes[left], b = nodes[right];
|
|
3100
|
+
(a.shape.kind === "circle" && b.shape.kind === "circle" ? Math.hypot(a.rect.x + a.rect.w / 2 - b.rect.x - b.rect.w / 2, a.rect.y + a.rect.h / 2 - b.rect.y - b.rect.h / 2) < (a.rect.w + b.rect.w) / 2 - 0.5 : rectsOverlap(a.rect, b.rect)) && overlaps++;
|
|
3101
|
+
}
|
|
3102
|
+
return outside.length === 0 && overlaps === 0 && requiredLabelLosses === 0 ? !1 : (warnings.push({
|
|
3103
|
+
code: "diagram-size-too-small",
|
|
3104
|
+
severity: "error",
|
|
3105
|
+
message: `${preset} does not fit required content (${outside.length} outside, ${overlaps} overlaps, ${requiredLabelLosses} required labels unplaced)`
|
|
3106
|
+
}), !0);
|
|
3107
|
+
}
|
|
3108
|
+
function measuredDiagramMinimum(received, naturalHeight, nested, layoutAt) {
|
|
3109
|
+
let policy = chartSizing("diagram"), floor = { width: received.width, height: nested ? 1 : policy.minHeight }, fits = (size2, structuralOnly = !1) => !layoutAt(size2, structuralOnly).warnings.some((w) => w.severity === "error"), size = { width: floor.width, height: Math.ceil(Math.max(floor.height, naturalHeight)) };
|
|
3110
|
+
if (!fits(size)) {
|
|
3111
|
+
let taller = { ...size, height: Math.max(size.height, received.height, 270) * 2 };
|
|
3112
|
+
if (fits(taller)) size = taller;
|
|
3113
|
+
else {
|
|
3114
|
+
let found = !1;
|
|
3115
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
3116
|
+
if (size = { width: size.width * 2, height: Math.max(size.height, received.height) }, fits(size)) {
|
|
3117
|
+
found = !0;
|
|
3118
|
+
break;
|
|
3119
|
+
}
|
|
3120
|
+
let tall = { ...size, height: Math.max(size.height, received.height) * 2 };
|
|
3121
|
+
if (fits(tall)) {
|
|
3122
|
+
size = tall, found = !0;
|
|
3123
|
+
break;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
if (!found) return;
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
for (let axis of ["width", "height"]) {
|
|
3130
|
+
let minimum = (structuralOnly) => {
|
|
3131
|
+
let low = floor[axis] - 1, high = size[axis];
|
|
3132
|
+
for (; high - low > 1; ) {
|
|
3133
|
+
let mid = Math.floor((low + high) / 2), probe = { ...size, [axis]: mid };
|
|
3134
|
+
fits(probe, structuralOnly) ? high = mid : low = mid;
|
|
3135
|
+
}
|
|
3136
|
+
return { ...size, [axis]: high };
|
|
3137
|
+
}, structural = minimum(!0);
|
|
3138
|
+
size = structural[axis] === size[axis] || fits(structural) ? structural : minimum(!1);
|
|
3139
|
+
}
|
|
3140
|
+
return size;
|
|
3141
|
+
}
|
|
3142
|
+
function diagramA11y(data, options, readingOrder, edges) {
|
|
3143
|
+
let labels = new Map(data.nodes.map((node) => [node.id, node.label])), order = readingOrder.map((id) => labels.get(id) ?? id).join("; "), relationships = edges.map((edge) => `${labels.get(edge.source.nodeId) ?? edge.source.nodeId} \u2192 ${labels.get(edge.target.nodeId) ?? edge.target.nodeId}`).join("; "), groups = data.groups.map((group) => {
|
|
3144
|
+
let members = data.nodes.filter((node) => node.groupId === group.id).map((node) => node.label).join(", ");
|
|
3145
|
+
return chartString(options, "containsMembers", { v1: group.title, v2: members || chartString(options, "noNodes") });
|
|
3146
|
+
}).join("; "), lanes = data.lanes.map((lane) => {
|
|
3147
|
+
let members = data.nodes.filter((node) => node.laneId === lane.id).map((node) => node.label).join(", ");
|
|
3148
|
+
return chartString(options, "containsMembers", { v1: lane.label ?? lane.id, v2: members || chartString(options, "noNodes") });
|
|
3149
|
+
}).join("; ");
|
|
3150
|
+
return {
|
|
3151
|
+
title: accessibleTitle(options.title, chartString(options, "diagramTitle", { v1: chartString(options, { hierarchy: "diagramHierarchy", "issue-tree": "diagramIssueTree", "linear-process": "diagramLinearProcess", "customer-journey": "diagramCustomerJourney", "circular-process": "diagramCircularProcess", "strategy-house": "diagramStrategyHouse", roadmap: "diagramRoadmap" }[options.variant]) })),
|
|
3152
|
+
counts: [structureCount("nodes", data.nodes.length, void 0, options), structureCount("relationships", edges.length, void 0, options)],
|
|
3153
|
+
desc: [
|
|
3154
|
+
chartString(options, "diagramDesc", { v1: chartString(options, { hierarchy: "diagramHierarchy", "issue-tree": "diagramIssueTree", "linear-process": "diagramLinearProcess", "customer-journey": "diagramCustomerJourney", "circular-process": "diagramCircularProcess", "strategy-house": "diagramStrategyHouse", roadmap: "diagramRoadmap" }[options.variant]), v2: data.nodes.length, v3: edges.length }),
|
|
3155
|
+
chartString(options, "readingOrder", { v1: order }),
|
|
3156
|
+
relationships ? chartString(options, "relationshipsSentence", { v1: relationships }) : "",
|
|
3157
|
+
groups ? chartString(options, "groupsSentence", { v1: groups }) : "",
|
|
3158
|
+
lanes ? chartString(options, "lanesSentence", { v1: lanes }) : ""
|
|
3159
|
+
].filter(Boolean).join(" ")
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
function diagramCategoryKeys(items) {
|
|
3163
|
+
return items.flatMap((item) => item.role === "category" && item.paletteKey ? [item.paletteKey] : []);
|
|
3164
|
+
}
|
|
3165
|
+
function splitBoldLead(node, boldLeads, weight) {
|
|
3166
|
+
if (node.t !== "text" || !node.id.startsWith("label:")) return [node];
|
|
3167
|
+
let count = boldLeads.get(node.id.slice(6));
|
|
3168
|
+
if (count === void 0 || count >= node.lines.length)
|
|
3169
|
+
return [node];
|
|
3170
|
+
let lineH = node.font.size * (node.font.lineHeight ?? 1.2);
|
|
3171
|
+
return [
|
|
3172
|
+
{ ...node, lines: node.lines.slice(0, count), font: { ...node.font, weight } },
|
|
3173
|
+
{ ...node, id: `${node.id}:detail`, lines: node.lines.slice(count), y: node.y + count * lineH }
|
|
3174
|
+
];
|
|
3175
|
+
}
|
|
3176
|
+
var CARD_TEXT_KINDS = /* @__PURE__ */ new Set(["diagramNode", "diagramSecondary", "diagramGroup", "diagramLane"]);
|
|
3177
|
+
function groupStructuralLabels(structuralLabelNodes) {
|
|
3178
|
+
let laneGroupLabels = structuralLabelNodes.filter(
|
|
3179
|
+
(node) => ["diagramLane", "diagramGroup"].includes(node.part)
|
|
3180
|
+
), nodeLabels = structuralLabelNodes.filter(
|
|
3181
|
+
(node) => ["diagramNode", "diagramSecondary"].includes(node.part)
|
|
3182
|
+
), accessoryLabels = structuralLabelNodes.filter(
|
|
3183
|
+
(node) => ["diagramBadge", "diagramCaption"].includes(node.part)
|
|
3184
|
+
);
|
|
3185
|
+
return { laneGroupLabels, nodeLabels, accessoryLabels };
|
|
3186
|
+
}
|
|
3187
|
+
function addNodeCaption(node, resolved, options, font, measure, u, requests, kinds, box) {
|
|
3188
|
+
let lineH = font.size * (font.lineHeight ?? 1.2);
|
|
3189
|
+
if (node.caption && box) {
|
|
3190
|
+
let captionId = `caption-label:${node.id}`;
|
|
3191
|
+
kinds.set(captionId, "diagramCaption"), requests.push({
|
|
3192
|
+
id: captionId,
|
|
3193
|
+
kind: "annotation",
|
|
3194
|
+
typeRole: "label",
|
|
3195
|
+
owner: nodeOwner(node.id),
|
|
3196
|
+
text: node.caption,
|
|
3197
|
+
lines: box.lines,
|
|
3198
|
+
font,
|
|
3199
|
+
priority: PRIORITY.interior,
|
|
3200
|
+
candidates: [{ slot: "below", rect: qRect(box.rect), penalty: 0 }]
|
|
3201
|
+
});
|
|
3202
|
+
} else if (node.caption) {
|
|
3203
|
+
let caption = fitText(node.caption, font, Math.max(resolved.rect.w, 16 * u), 2, measure, { target: options.target, typeRole: "label" }), captionWidth = Math.max(1, ...caption.lines.map((line) => measure(line, font).width)), captionHeight = caption.lines.length * lineH, captionId = `caption-label:${node.id}`;
|
|
3204
|
+
kinds.set(captionId, "diagramCaption"), requests.push({
|
|
3205
|
+
id: captionId,
|
|
3206
|
+
kind: "annotation",
|
|
3207
|
+
typeRole: "label",
|
|
3208
|
+
owner: nodeOwner(node.id),
|
|
3209
|
+
text: node.caption,
|
|
3210
|
+
lines: caption.lines,
|
|
3211
|
+
...caption.title !== void 0 ? { title: caption.title } : {},
|
|
3212
|
+
font,
|
|
3213
|
+
priority: PRIORITY.interior,
|
|
3214
|
+
candidates: [
|
|
3215
|
+
{
|
|
3216
|
+
slot: "below",
|
|
3217
|
+
rect: qRect({
|
|
3218
|
+
x: resolved.rect.x + (resolved.rect.w - captionWidth) / 2,
|
|
3219
|
+
y: resolved.rect.y + resolved.rect.h + (options.variant === "linear-process" ? u : 2 * u),
|
|
3220
|
+
w: captionWidth,
|
|
3221
|
+
h: captionHeight
|
|
3222
|
+
}),
|
|
3223
|
+
penalty: 0
|
|
3224
|
+
},
|
|
3225
|
+
{
|
|
3226
|
+
slot: "above",
|
|
3227
|
+
rect: qRect({
|
|
3228
|
+
x: resolved.rect.x + (resolved.rect.w - captionWidth) / 2,
|
|
3229
|
+
y: resolved.rect.y - captionHeight - 2 * u,
|
|
3230
|
+
w: captionWidth,
|
|
3231
|
+
h: captionHeight
|
|
3232
|
+
}),
|
|
3233
|
+
penalty: 1
|
|
3234
|
+
}
|
|
3235
|
+
]
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
function naturalDiagramSizing(options, data, sizes, font, measure, u, measured, size, plot, headFont = font) {
|
|
3240
|
+
let nodes = data.nodes, authored = nodes.length > 0 && nodes.every((node) => node.position !== void 0), linear = options.variant === "linear-process";
|
|
3241
|
+
if (options.variant === "strategy-house" && !authored)
|
|
3242
|
+
return { ...measured, naturalHeight: Math.ceil(Math.max(measured.minHeight, size.height - plot.h + strategyHouseBands(data, plot.w, u, font, measure, headFont).height)) };
|
|
3243
|
+
if (options.variant !== "circular-process" && options.variant !== "roadmap" && !authored && !linear) return measured;
|
|
3244
|
+
let plotHeight = plot.w;
|
|
3245
|
+
if (linear) {
|
|
3246
|
+
let width = (plot.w - u * (nodes.length - 1)) / nodes.length, captions = nodes.filter((node) => node.caption).map((node) => wrapText(node.caption, font, Math.max(width, 16 * u), 2, measure).lines.length * font.size * (font.lineHeight ?? 1.2));
|
|
3247
|
+
plotHeight = 2 * u + Math.max(12 * u, maxOf([...sizes.values()].map((size2) => size2.height))) + (captions.length ? u + maxOf(captions) : 0);
|
|
3248
|
+
} else if (authored) plotHeight = authoredPlotHeight(nodes, sizes, plot.w, u);
|
|
3249
|
+
else if (options.variant === "circular-process") {
|
|
3250
|
+
let { diameter, radius } = circularRing(nodes, { w: plot.w, h: 1 / 0 }, u, { font, measure });
|
|
3251
|
+
plotHeight = 2 * radius + diameter + 2 * circularLabelBand(font, u);
|
|
3252
|
+
} else if (options.variant === "roadmap") {
|
|
3253
|
+
let milestones = nodes.filter((node) => node.kind === "milestone"), lineH = font.size * (font.lineHeight ?? 1.2), rows = milestones.map((node) => {
|
|
3254
|
+
let diameter = Math.min(4 * u, sizes.get(node.id).height), labelHeight = wrapText(node.label, font, Math.min(18 * u, plot.w / 5), 3, measure).lines.length * lineH, captionHeight = node.caption ? wrapText(node.caption, font, Math.max(diameter, 16 * u), 2, measure).lines.length * lineH + 2 * u : 0;
|
|
3255
|
+
return diameter + 2 * u + labelHeight + captionHeight;
|
|
3256
|
+
});
|
|
3257
|
+
plotHeight = 20 * u + rows.reduce((total, height) => total + height, 0);
|
|
3258
|
+
}
|
|
3259
|
+
return { ...measured, naturalHeight: Math.ceil(Math.max(measured.minHeight, size.height - plot.h + plotHeight)) };
|
|
3260
|
+
}
|
|
3261
|
+
function authoredPlotHeight(nodes, sizes, width, u) {
|
|
3262
|
+
let height = 0;
|
|
3263
|
+
for (let node of nodes) {
|
|
3264
|
+
let y = node.position.y, half = sizes.get(node.id).height / 2;
|
|
3265
|
+
y > 0 && y < 1 && (height = Math.max(height, half / y, half / (1 - y)));
|
|
3266
|
+
}
|
|
3267
|
+
for (let i = 0; i < nodes.length; i++) for (let other of nodes.slice(i + 1)) {
|
|
3268
|
+
let node = nodes[i], first = sizes.get(node.id), second = sizes.get(other.id), dx = Math.abs(node.position.x - other.position.x) * width, dy = Math.abs(node.position.y - other.position.y);
|
|
3269
|
+
dx < (first.width + second.width) / 2 && dy > 0 && (height = Math.max(height, ((first.height + second.height) / 2 + 3 * u) / dy));
|
|
3270
|
+
}
|
|
3271
|
+
return height;
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
// src/core/charts/diagram/core.ts
|
|
3275
|
+
function normalizeDiagramData(data) {
|
|
3276
|
+
return {
|
|
3277
|
+
nodes: data.nodes.map((node) => ({
|
|
3278
|
+
...node,
|
|
3279
|
+
ports: node.ports ? [...node.ports] : void 0
|
|
3280
|
+
})),
|
|
3281
|
+
edges: data.edges ? [...data.edges] : [],
|
|
3282
|
+
groups: data.groups ? [...data.groups] : [],
|
|
3283
|
+
lanes: data.lanes ? [...data.lanes] : [],
|
|
3284
|
+
...data.key ? { key: [...data.key] } : {}
|
|
3285
|
+
};
|
|
3286
|
+
}
|
|
3287
|
+
var diagramCore = {
|
|
3288
|
+
type: "diagram",
|
|
3289
|
+
// A hierarchy draws as a compact org chart down to a 320 px card; every
|
|
3290
|
+
// other layout still reports the 480 px floor itself (layout.ts).
|
|
3291
|
+
sizing: { ...chartSizing("diagram"), minWidth: CARD_MIN_WIDTH },
|
|
3292
|
+
title: "Diagram",
|
|
3293
|
+
summary: "Deterministic node-edge diagrams with seven consulting presets, obstacle-aware routing, and structural descriptions",
|
|
3294
|
+
layout: layoutDiagram,
|
|
3295
|
+
defaults: {},
|
|
3296
|
+
annotationKinds: [],
|
|
3297
|
+
prepare: normalizeDiagramData
|
|
3298
|
+
};
|
|
3299
|
+
|
|
3300
|
+
export {
|
|
3301
|
+
normalizeDiagramData,
|
|
3302
|
+
diagramCore
|
|
3303
|
+
};
|