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,2718 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computeMetricStack,
|
|
3
|
+
formatPanelValue,
|
|
4
|
+
isMetricStackData,
|
|
5
|
+
metricStackGrain,
|
|
6
|
+
normalizeMetricStack,
|
|
7
|
+
stackError,
|
|
8
|
+
stackRange
|
|
9
|
+
} from "./chunk-7VXZDB45.js";
|
|
10
|
+
import {
|
|
11
|
+
scalePanelSemantics
|
|
12
|
+
} from "./chunk-HZQEQ34U.js";
|
|
13
|
+
import {
|
|
14
|
+
STACK_ROOM
|
|
15
|
+
} from "./chunk-HJXXFPOL.js";
|
|
16
|
+
import {
|
|
17
|
+
normalizeGridData,
|
|
18
|
+
parseGridLegendPanelData,
|
|
19
|
+
parseGridTextPanelData
|
|
20
|
+
} from "./chunk-JL5BRMDT.js";
|
|
21
|
+
import {
|
|
22
|
+
categoryBandFromCenters
|
|
23
|
+
} from "./chunk-CDZHNLO6.js";
|
|
24
|
+
import {
|
|
25
|
+
structureCount
|
|
26
|
+
} from "./chunk-B2EBEXIS.js";
|
|
27
|
+
import {
|
|
28
|
+
isRecord
|
|
29
|
+
} from "./chunk-76ANFJOI.js";
|
|
30
|
+
import {
|
|
31
|
+
CARD_CLASS_WIDTH,
|
|
32
|
+
CARD_MIN_WIDTH,
|
|
33
|
+
DIGIT_SEAT,
|
|
34
|
+
NARROW_SHARE_WIDTH,
|
|
35
|
+
PLOT_FLOOR_RECT,
|
|
36
|
+
VARIANCE_TIER,
|
|
37
|
+
autoPlotPx,
|
|
38
|
+
balanceVarianceTierPlots,
|
|
39
|
+
chartSizing,
|
|
40
|
+
getChart,
|
|
41
|
+
heightOmitted,
|
|
42
|
+
inferLinearYDomain,
|
|
43
|
+
isVarianceTier,
|
|
44
|
+
keysNeedNames,
|
|
45
|
+
legendIsCovered,
|
|
46
|
+
normalizedName,
|
|
47
|
+
prepareFitLayout,
|
|
48
|
+
resolveSizing,
|
|
49
|
+
sizeRefusal,
|
|
50
|
+
stackedColumnPlotPx,
|
|
51
|
+
varianceTierWeights,
|
|
52
|
+
withCalendarLabels
|
|
53
|
+
} from "./chunk-GQPESFAF.js";
|
|
54
|
+
import {
|
|
55
|
+
LEFT_OUT_OF_NOTE,
|
|
56
|
+
PRIORITY,
|
|
57
|
+
boundsOf,
|
|
58
|
+
collectSeriesIdentities,
|
|
59
|
+
createOccupiedIndex,
|
|
60
|
+
frameTextOptions,
|
|
61
|
+
identityAppearance,
|
|
62
|
+
labelCtx,
|
|
63
|
+
labelsToNodes,
|
|
64
|
+
normalizeLegendOption,
|
|
65
|
+
panelNoteTexts,
|
|
66
|
+
partialFootnotes,
|
|
67
|
+
partialIds,
|
|
68
|
+
saysToDate,
|
|
69
|
+
solveFrame,
|
|
70
|
+
solveLabels,
|
|
71
|
+
stringsIn,
|
|
72
|
+
valueNoteLine
|
|
73
|
+
} from "./chunk-2JAWQ7VV.js";
|
|
74
|
+
import {
|
|
75
|
+
disclosureNote,
|
|
76
|
+
disclosuresShown
|
|
77
|
+
} from "./chunk-YTSSXSZR.js";
|
|
78
|
+
import {
|
|
79
|
+
authoredStrings,
|
|
80
|
+
chartStrings,
|
|
81
|
+
currentSmallValues,
|
|
82
|
+
localeStrings,
|
|
83
|
+
notApplicableGlyph
|
|
84
|
+
} from "./chunk-YQ2B3YVF.js";
|
|
85
|
+
import {
|
|
86
|
+
cellMeta,
|
|
87
|
+
cellValue
|
|
88
|
+
} from "./chunk-OAPCJO6W.js";
|
|
89
|
+
import {
|
|
90
|
+
HATCH_STRENGTH_DEFAULT,
|
|
91
|
+
KPI_HOST_TEXT,
|
|
92
|
+
KPI_VALUE_SIZE,
|
|
93
|
+
WIDE_CANVAS_MIN_WIDTH,
|
|
94
|
+
canvasMargin,
|
|
95
|
+
dashToken,
|
|
96
|
+
emphasisWeight,
|
|
97
|
+
markRolePaint,
|
|
98
|
+
panelTypeClass,
|
|
99
|
+
resolveTheme,
|
|
100
|
+
secondaryFont,
|
|
101
|
+
seriesPaint,
|
|
102
|
+
strokeToken,
|
|
103
|
+
themeForWidth,
|
|
104
|
+
themeRegistrations,
|
|
105
|
+
typeWidthClass
|
|
106
|
+
} from "./chunk-II7652VA.js";
|
|
107
|
+
import {
|
|
108
|
+
requireChartCores
|
|
109
|
+
} from "./chunk-2MTWKMEG.js";
|
|
110
|
+
import {
|
|
111
|
+
fmtPathNumber
|
|
112
|
+
} from "./chunk-WLZ54FWG.js";
|
|
113
|
+
import {
|
|
114
|
+
DEFAULT_TARGET,
|
|
115
|
+
NormalizeError,
|
|
116
|
+
TARGET_SIZE,
|
|
117
|
+
accessibleTitle,
|
|
118
|
+
normalizeCategory,
|
|
119
|
+
normalizeSeriesValues,
|
|
120
|
+
resolveCanvasOptions,
|
|
121
|
+
resolveHighlight,
|
|
122
|
+
resolveSize
|
|
123
|
+
} from "./chunk-SGD3ZHID.js";
|
|
124
|
+
import {
|
|
125
|
+
maxOf,
|
|
126
|
+
minOf,
|
|
127
|
+
pushAll
|
|
128
|
+
} from "./chunk-WYJEOMNY.js";
|
|
129
|
+
import {
|
|
130
|
+
defaultMeasurer,
|
|
131
|
+
wrapText
|
|
132
|
+
} from "./chunk-TXINIAFL.js";
|
|
133
|
+
|
|
134
|
+
// src/core/grid/gridKey.ts
|
|
135
|
+
var GRID_KEY_ONLY = /* @__PURE__ */ Symbol("gridKeyOnly");
|
|
136
|
+
function gridPanelsKeepEndNames(options) {
|
|
137
|
+
return options.legend === "none" || options[GRID_KEY_ONLY] !== void 0;
|
|
138
|
+
}
|
|
139
|
+
function gridKeyItems(items, options) {
|
|
140
|
+
let only = options[GRID_KEY_ONLY];
|
|
141
|
+
return only ? items.filter((item) => only.has(item.id)) : items;
|
|
142
|
+
}
|
|
143
|
+
function hatchStrengthFor(panel, grid) {
|
|
144
|
+
let strength = panel.hatchStrength ?? grid.hatchStrength;
|
|
145
|
+
return strength === void 0 ? {} : { hatchStrength: strength };
|
|
146
|
+
}
|
|
147
|
+
function collectGridLegendItems(panels, options, measure) {
|
|
148
|
+
let items = [], seen = /* @__PURE__ */ new Map(), theme = resolveTheme(options.theme), typeClass = panelTypeClass(options) ?? typeWidthClass(resolveSize(options.size).width);
|
|
149
|
+
for (let panel of panels) {
|
|
150
|
+
if (panel.type === "text" || panel.type === "legend") continue;
|
|
151
|
+
let definition = getChart(panel.type);
|
|
152
|
+
if (!definition) continue;
|
|
153
|
+
let panelOptions = panel.options ?? {}, identities = collectSeriesIdentities(definition.layout, panel.data, {
|
|
154
|
+
...definition.defaults,
|
|
155
|
+
...panelOptions,
|
|
156
|
+
...panel.annotations ? { annotations: panel.annotations } : {},
|
|
157
|
+
...options.palette !== void 0 && panelOptions.palette === void 0 ? { palette: options.palette } : {},
|
|
158
|
+
target: options.target,
|
|
159
|
+
theme: panelOptions.theme ?? options.theme,
|
|
160
|
+
locale: panelOptions.locale ?? options.locale,
|
|
161
|
+
...hatchStrengthFor(panelOptions, options),
|
|
162
|
+
...options.strings ? { strings: { ...authoredStrings(options), ...panelOptions.strings } } : {},
|
|
163
|
+
size: options.size,
|
|
164
|
+
measure,
|
|
165
|
+
typeClass
|
|
166
|
+
});
|
|
167
|
+
for (let item of identities) {
|
|
168
|
+
let { marker, ...look } = item, key = panel.type === "variance" && item.id.startsWith("tone:") ? JSON.stringify([item.label, item.id]) : JSON.stringify([item.label, identityAppearance(look, theme)]), at = seen.get(key);
|
|
169
|
+
if (at === void 0)
|
|
170
|
+
seen.set(key, items.length), items.push(item);
|
|
171
|
+
else if (JSON.stringify(items[at].marker) !== JSON.stringify(marker)) {
|
|
172
|
+
let { marker: _dropped, ...plain } = items[at];
|
|
173
|
+
items[at] = plain;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return items;
|
|
178
|
+
}
|
|
179
|
+
function gridLegendInput(items, legendOptions, options, warnings) {
|
|
180
|
+
let keyed = gridKeyItems(items, options);
|
|
181
|
+
if (keyed.length === 0) {
|
|
182
|
+
warnings.push({ code: "grid-legend-empty", severity: "warn", message: "grid legend requested but no chart panel contributes legend items \u2014 legend omitted" });
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (legendOptions.order) {
|
|
186
|
+
let rank = new Map(legendOptions.order.map((id, index) => [id, index]));
|
|
187
|
+
keyed = [...keyed].sort((a, b) => (rank.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b.id) ?? Number.MAX_SAFE_INTEGER));
|
|
188
|
+
}
|
|
189
|
+
return { options: legendOptions, items: keyed };
|
|
190
|
+
}
|
|
191
|
+
function hasLegendPanel(data) {
|
|
192
|
+
let panels = data?.panels;
|
|
193
|
+
return Array.isArray(panels) && panels.some((panel) => panel?.type === "legend");
|
|
194
|
+
}
|
|
195
|
+
function keyName(candidate, labelId) {
|
|
196
|
+
let label = candidate.scene.find((node) => node.id === labelId);
|
|
197
|
+
return label?.t === "text" ? normalizedName(label.lines.join(" ")) : "";
|
|
198
|
+
}
|
|
199
|
+
function gridRequiredKey(baseline, data, options, fitKeyed) {
|
|
200
|
+
if (hasLegendPanel(data)) return baseline;
|
|
201
|
+
let candidateOptions = { ...options, legend: resolveTheme(options.theme).legend?.required ?? "top" }, tried;
|
|
202
|
+
try {
|
|
203
|
+
tried = fitKeyed(candidateOptions);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (!(error instanceof NormalizeError)) throw error;
|
|
206
|
+
return baseline;
|
|
207
|
+
}
|
|
208
|
+
if (tried.refused) return baseline;
|
|
209
|
+
let candidate = tried;
|
|
210
|
+
if (!keysNeedNames(baseline, candidate) || legendIsCovered(baseline, candidate, data, options)) return baseline;
|
|
211
|
+
let items = candidate.legend?.items ?? [], uncovered = items.filter((item) => {
|
|
212
|
+
if (legendIsCovered(baseline, { ...candidate, legend: { ...candidate.legend, items: [item] } }, data, options)) return !1;
|
|
213
|
+
let name = keyName(candidate, item.labelId), fullName = new RegExp(`(?<![\\p{L}\\p{N}_])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_])`, "u");
|
|
214
|
+
return !name || !baseline.scene.some((node) => node.t === "text" && node.part === "legendLabel" && node.id.includes("/") && node.owner.seriesId === item.id && fullName.test(normalizedName(node.lines.join(" "))));
|
|
215
|
+
});
|
|
216
|
+
if (uncovered.length === 0) return baseline;
|
|
217
|
+
let keyed = candidate;
|
|
218
|
+
if (uncovered.length < items.length) {
|
|
219
|
+
let narrow = prepareFitLayout(this, data);
|
|
220
|
+
try {
|
|
221
|
+
let narrowed = narrow(Object.assign({}, candidateOptions, { [GRID_KEY_ONLY]: new Set(uncovered.map((item) => item.id)) }));
|
|
222
|
+
!narrowed.refused && narrowed.legend?.items.length && (keyed = narrowed);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (!(error instanceof NormalizeError)) throw error;
|
|
225
|
+
} finally {
|
|
226
|
+
narrow.finish();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
let names = keyed === candidate ? [] : (keyed.legend?.items ?? []).map((item) => keyName(keyed, item.labelId) || item.id);
|
|
230
|
+
return keyed.warnings.push({
|
|
231
|
+
code: "grid-legend-required",
|
|
232
|
+
severity: "info",
|
|
233
|
+
message: names.length > 0 ? `grid legend cannot be hidden: no direct label names ${names.join(", ")}, so the key row lists ${names.length === 1 ? "that series" : "those series"} only` : "grid legend cannot be hidden because no direct label names the colours and markers it keys"
|
|
234
|
+
}), keyed;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/core/grid/panelAlignment.ts
|
|
238
|
+
function moveChildPlot(child, dl, dr, theme) {
|
|
239
|
+
let effectiveLeft = typeof child.geometry.derived.leftInset == "number" ? child.geometry.derived.leftInset : child.margin.left ?? canvasMargin(theme, child.slot.w).left, effectiveRight = typeof child.geometry.derived.rightInset == "number" ? child.geometry.derived.rightInset : child.margin.right ?? canvasMargin(theme, child.slot.w).right;
|
|
240
|
+
child.margin = { ...child.margin, left: effectiveLeft + dl, right: effectiveRight + dr }, child.geometry = child.relayout(child.margin);
|
|
241
|
+
}
|
|
242
|
+
function alignCategoryPanels(children, theme) {
|
|
243
|
+
let before = new Map(children.map((child) => [child, [child.slot.x + child.geometry.plot.x, child.geometry.plot.w]])), ticksOf = (child) => child.geometry.axes.find((axis) => axis.axis === "x")?.ticks ?? [], candidates = children.filter((child) => child.relayout !== void 0 && ticksOf(child).length >= 2);
|
|
244
|
+
if (candidates.length < 2) return 0;
|
|
245
|
+
let shared = ticksOf(candidates[0]).map((tick) => tick.at).filter((at) => candidates.every((child) => ticksOf(child).some((tick) => tick.at === at)));
|
|
246
|
+
if (shared.length < 2) return 0;
|
|
247
|
+
let [firstId, lastId] = [shared[0], shared.at(-1)], posOf = (child, at) => child.slot.x + ticksOf(child).find((tick) => tick.at === at).pos;
|
|
248
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
249
|
+
let first = maxOf(candidates.map((child) => posOf(child, firstId))), last = minOf(candidates.map((child) => posOf(child, lastId)));
|
|
250
|
+
if (!(last > first)) break;
|
|
251
|
+
let off = candidates.filter((child) => Math.abs(posOf(child, firstId) - first) > 0.01 || Math.abs(posOf(child, lastId) - last) > 0.01);
|
|
252
|
+
if (off.length === 0) break;
|
|
253
|
+
for (let child of off) {
|
|
254
|
+
let x = child.slot.x + child.geometry.plot.x, w = child.geometry.plot.w, f = (posOf(child, firstId) - x) / w, l = (posOf(child, lastId) - x) / w;
|
|
255
|
+
if (!(l > f)) continue;
|
|
256
|
+
let w2 = (last - first) / (l - f), x2 = first - f * w2;
|
|
257
|
+
moveChildPlot(child, x2 - x, x + w - (x2 + w2), theme);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return Math.max(0, maxOf(children.map((child) => {
|
|
261
|
+
let [x, w] = before.get(child), x2 = child.slot.x + child.geometry.plot.x;
|
|
262
|
+
return Math.max(Math.abs(x2 - x), Math.abs(x2 + child.geometry.plot.w - x - w));
|
|
263
|
+
})));
|
|
264
|
+
}
|
|
265
|
+
function alignValuePanels(children, theme, keep) {
|
|
266
|
+
let members = children.filter((child) => child.relayout !== void 0);
|
|
267
|
+
if (members.length < 2) return;
|
|
268
|
+
let heightOf = (child) => (child.geometry[PLOT_FLOOR_RECT] ?? child.geometry.plot).h;
|
|
269
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
270
|
+
let height = minOf(members.map(heightOf)), off = members.filter((child) => heightOf(child) - height > 0.01);
|
|
271
|
+
if (off.length === 0) break;
|
|
272
|
+
for (let child of off) {
|
|
273
|
+
let cut = heightOf(child) - height, above = keep ? keep.above(child) : 0, bottom = child.margin.bottom ?? canvasMargin(theme, child.slot.w).bottom;
|
|
274
|
+
child.margin = { ...child.margin, bottom: bottom + cut * (1 - above), ...keep ? { top: keep.top(child) + cut * above } : {} }, child.geometry = child.relayout(child.margin);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/core/strings/grid.ts
|
|
280
|
+
var EN = {
|
|
281
|
+
// reader-facing wording linked only by its consumers.
|
|
282
|
+
maturingCohortNote: "Maturing cohorts have not had the full time to produce an outcome. Their scoped values are provisional.",
|
|
283
|
+
matureCohort: "Mature cohort",
|
|
284
|
+
provisional: "Provisional",
|
|
285
|
+
metricStack: "Metric stack",
|
|
286
|
+
metricStackWidth: "Metric stack needs {v1} px width.",
|
|
287
|
+
metricStackHeight: "Metric stack needs {v1} px height.",
|
|
288
|
+
sourceMeasures: "{v1} source measures",
|
|
289
|
+
metricStackTitle: "Metric stack of {v1} panels",
|
|
290
|
+
metricStackDesc: "Metric stack: {v1}. Top-down order: {v2}. Independent scales start at zero. {v3}",
|
|
291
|
+
gridPanelsTitle: "Grid of {v1} panels",
|
|
292
|
+
authoredRows: "Authored {v1}",
|
|
293
|
+
compositionColumns: "by {v1} composition",
|
|
294
|
+
gridComposition: "Authored {v1} by {v2} composition: {v3}.{v4}",
|
|
295
|
+
notesClause: " Notes: {v1}.",
|
|
296
|
+
legendName: "Legend",
|
|
297
|
+
legendItemsCount: "{v1} legend items.",
|
|
298
|
+
stackChangeMethod: "Change: average per {v1}, {v2} \u2192 {v3}; rates use volume weighting",
|
|
299
|
+
stackLeftMethod: "Left: volume-weighted mature rates and remaining per 100",
|
|
300
|
+
stackAboveMethod: "Above each panel: volume-weighted mature rates and remaining per 100",
|
|
301
|
+
notYetMature: "Not yet mature",
|
|
302
|
+
labelsShowTotals: "Labels show totals"
|
|
303
|
+
}, DE = {
|
|
304
|
+
// reader-facing wording linked only by its consumers.
|
|
305
|
+
maturingCohortNote: "Noch nicht ausgereifte Kohorten hatten nicht die volle Zeit f\xFCr ein Ergebnis. Ihre Werte im angegebenen Bereich sind vorl\xE4ufig.",
|
|
306
|
+
matureCohort: "Ausgereifte Kohorte",
|
|
307
|
+
provisional: "Vorl\xE4ufig",
|
|
308
|
+
metricStack: "Kennzahlenstapel",
|
|
309
|
+
metricStackWidth: "Kennzahlenstapel braucht {v1} px Breite.",
|
|
310
|
+
metricStackHeight: "Kennzahlenstapel braucht {v1} px H\xF6he.",
|
|
311
|
+
sourceMeasures: "{v1} {v1|Quellkennzahl|Quellkennzahlen}",
|
|
312
|
+
metricStackTitle: "Kennzahlenstapel mit {v1} {v1|Feld|Feldern}",
|
|
313
|
+
metricStackDesc: "Kennzahlenstapel: {v1}. Reihenfolge von oben: {v2}. Unabh\xE4ngige Skalen beginnen bei null. {v3}",
|
|
314
|
+
gridPanelsTitle: "Raster mit {v1} {v1|Feld|Feldern}",
|
|
315
|
+
authoredRows: "Angegeben: {v1}",
|
|
316
|
+
compositionColumns: "mal {v1} Anordnung",
|
|
317
|
+
gridComposition: "Angegebene Anordnung: {v1} mal {v2}: {v3}.{v4}",
|
|
318
|
+
notesClause: " Hinweise: {v1}.",
|
|
319
|
+
legendName: "Legende",
|
|
320
|
+
legendItemsCount: "{v1} {v1|Legendeneintrag|Legendeneintr\xE4ge}.",
|
|
321
|
+
stackChangeMethod: "\xC4nderung: Mittelwert je {v1}, {v2} \u2192 {v3}; Raten sind nach Volumen gewichtet",
|
|
322
|
+
stackLeftMethod: "Links: nach Volumen gewichtete ausgereifte Raten und Rest je 100",
|
|
323
|
+
stackAboveMethod: "\xDCber jedem Feld: nach Volumen gewichtete ausgereifte Raten und Rest je 100",
|
|
324
|
+
notYetMature: "Noch nicht ausgereift",
|
|
325
|
+
labelsShowTotals: "Beschriftungen zeigen Summen"
|
|
326
|
+
}, { chartString } = chartStrings(EN, DE);
|
|
327
|
+
|
|
328
|
+
// src/core/charts/grid/metricStackLayout.ts
|
|
329
|
+
var neutral = { token: "markInk" }, muted = { token: "inkMuted" }, accent = { token: "focus" }, wash = (base, weight, pageFloor) => ({ token: "markInk", theme: { kind: "mix", from: base, to: { token: "background" }, weight, ...pageFloor === void 0 ? {} : { pageFloor } } }), NO_WIDER_SEARCH = /* @__PURE__ */ Symbol("boardplot.metricStackNoWiderSearch");
|
|
330
|
+
function widerThatPlaces(raw, options, size, automatic) {
|
|
331
|
+
let draws = (width) => {
|
|
332
|
+
try {
|
|
333
|
+
return layoutMetricStack(raw, { ...options, size: automatic ? { width } : { width, height: size.height }, [NO_WIDER_SEARCH]: !0 }).scene.length > 0;
|
|
334
|
+
} catch (error) {
|
|
335
|
+
if (error instanceof NormalizeError) return !1;
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}, base = Math.floor(size.width), low = base, high;
|
|
339
|
+
for (let step = 4; step <= 512; step *= 2) {
|
|
340
|
+
if (draws(base + step)) {
|
|
341
|
+
high = base + step;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
low = base + step;
|
|
345
|
+
}
|
|
346
|
+
if (high !== void 0) {
|
|
347
|
+
for (; high - low > 1; ) {
|
|
348
|
+
let mid = Math.floor((low + high) / 2);
|
|
349
|
+
draws(mid) ? high = mid : low = mid;
|
|
350
|
+
}
|
|
351
|
+
return high;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function layoutMetricStack(raw, options) {
|
|
355
|
+
let data = normalizeMetricStack(raw);
|
|
356
|
+
options.stack || stackError("options.stack", "Shared measures require options.stack: {}"), (options.sharedAxis === "none" || options.sharedScale === !0 || options.columns !== void 0 || options.gutters !== void 0 || options.anchors !== void 0 || options.alignmentRules !== void 0 || options.panelOrder !== void 0) && stackError("options", "A metric stack owns top-down order, shared categories, spacing and independent scales; remove conflicting grid controls");
|
|
357
|
+
let stack = options.stack;
|
|
358
|
+
stack.heights && options.rows && stackError("options", "Use stack.heights or rows, not both"), (stack.heights && stack.heights.length !== data.panels.length || options.rows && options.rows.length !== data.panels.length) && stackError("options", "Supply one height or row weight per panel");
|
|
359
|
+
let theme = themeForWidth(resolveTheme(options.theme), resolveSize(options.size).width), measure = options.measure ?? defaultMeasurer, na = notApplicableGlyph(options.strings), computed = computeMetricStack(data, options.locale?.language, na), font = (role, weight) => ({ family: theme.type.family, ...theme.type[role], ...weight ? { weight } : {} }), valueFont = font("label", 700), nameFont = font("label", 700), unitFont = font("axis"), heroFont = font("title", 700), axisFont = font("axis"), noteFont = font("footnote"), keyFont = secondaryFont(theme), heightOf = (f) => f.size * (f.lineHeight ?? 1.2), textBox = (text, f, width) => {
|
|
360
|
+
let lines = wrapText(text, f, width, Number.MAX_SAFE_INTEGER, measure).lines;
|
|
361
|
+
return { lines, w: Math.max(...lines.map((line) => measure(line, f).width), 0), h: heightOf(f) * lines.length };
|
|
362
|
+
}, spacingError = (field, message, fix) => {
|
|
363
|
+
throw new NormalizeError("metric-stack-spacing", field, message, "Increase the named dimension; the engine does not shrink or overlap required labels.", fix);
|
|
364
|
+
}, heightFix = (i, px) => stack.heights ? [{ op: "replace", path: `/options/stack/heights/${i}`, value: px }] : void 0, minGap = Math.ceil(heightOf(axisFont) + 8), gap = Math.max(26, minGap), arrowWidth = Math.max(unitFont.size, measure("\u2192", unitFont).width), spanSpace = measure(" ", unitFont).width, spanWidths = computed.panels.map((p) => measure(p.readout.spanText, unitFont).width + arrowWidth - measure("\u2192", unitFont).width), minGutter = Math.ceil(Math.max(120, maxOf(computed.panels.map((p, i) => Math.max(
|
|
365
|
+
spanWidths[i],
|
|
366
|
+
measure(p.readout.headlineText, heroFont).width,
|
|
367
|
+
...`${p.panel.title} ${p.panel.unit}`.split(/\s+/).map((word) => measure(word, nameFont).width)
|
|
368
|
+
)))) + 4), nameWidth = Math.ceil(maxOf(computed.panels.flatMap((p) => p.panel.title.split(`
|
|
369
|
+
`).map((line) => measure(line, nameFont).width)))) + 4, gutter = Math.max(170, minGutter, Math.min(320, nameWidth)), gutterGap = Math.max(28, heightOf(axisFont)), gutterBoxes = computed.panels.map((p) => ({ name: textBox(p.panel.title, nameFont, gutter), unit: textBox(p.panel.unit, keyFont, gutter) })), partial = partialIds(data.categories), notes = [...options.footnotes || []], listed = [], stateNotes = {}, engineNumbers = [], notesOff = frameTextOptions(options).footnotesOff, stateNote = (state, authored, engine) => {
|
|
370
|
+
if (authored === void 0 && (!disclosuresShown(options) || notesOff)) {
|
|
371
|
+
listed.push(disclosureNote(engine()));
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
stateNotes[state] = notes.length + 1, authored === void 0 && engineNumbers.push(notes.length + 1), notes.push(authored ?? engine());
|
|
375
|
+
};
|
|
376
|
+
computed.maturing.length && stateNote("maturing", data.states?.maturing?.footnote, () => chartString(options, "maturingCohortNote")), partial.size && stateNote("partial", data.states?.partial?.footnote, () => partialFootnotes(data.categories, options.strings)[0]);
|
|
377
|
+
let marker = (value) => value === void 0 || notesOff ? "" : String(value).split("").map((c) => "\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079"[Number(c)]).join(""), visibleValue = (p, i) => p.values[i] !== null, hasProvisional = computed.panels.some((p) => p.states.some((state, i) => state !== "mature" && visibleValue(p, i))), hasMatureLine = (p) => p.panel.type === "line" && p.states.some((state, i) => i > 0 && state === "mature" && p.states[i - 1] === "mature" && visibleValue(p, i) && visibleValue(p, i - 1)), measureIndexes = /* @__PURE__ */ new Map(), emphasizedMeasures = /* @__PURE__ */ new Set();
|
|
378
|
+
for (let p of computed.panels) if (p.panel.type === "column" && "sum" in p.panel.measure && p.parts.length > 1)
|
|
379
|
+
for (let id of p.panel.measure.sum)
|
|
380
|
+
measureIndexes.has(id) || measureIndexes.set(id, measureIndexes.size), p.panel.emphasis && emphasizedMeasures.add(id);
|
|
381
|
+
let columnFill = seriesPaint(0, options.palette), emphasizedFill = markRolePaint("focus", !0), measurePaints = new Map([...measureIndexes].map(([id, i]) => {
|
|
382
|
+
let base2 = emphasizedMeasures.has(id) ? emphasizedFill : columnFill;
|
|
383
|
+
return [id, {
|
|
384
|
+
// A later measure steps back into the page but keeps the 1.4:1 mark floor, as a faded series does.
|
|
385
|
+
mature: i === 0 ? base2 : wash(base2, Math.max(0.16, 0.45 - i * 0.12), 1.4)
|
|
386
|
+
}];
|
|
387
|
+
})), stacked = (p) => p.panel.type === "column" && "sum" in p.panel.measure && p.parts.length > 1, panelKeys = computed.panels.map(() => []), seen = /* @__PURE__ */ new Set();
|
|
388
|
+
computed.panels.forEach((p, pi) => {
|
|
389
|
+
stacked(p) && "sum" in p.panel.measure && p.panel.measure.sum.forEach((id, i) => {
|
|
390
|
+
p.parts[i].some((value, ci) => value !== null && value > 0 && visibleValue(p, ci)) && (seen.add(id), panelKeys[pi].push({ id, label: data.measures.find((m) => m.id === id).label, paint: measurePaints.get(id).mature }));
|
|
391
|
+
});
|
|
392
|
+
}), options.legend === "none" && panelKeys.forEach((items) => items.splice(0));
|
|
393
|
+
let totalsCue = chartString(options, "labelsShowTotals"), keySwatch = 10, keyRow = heightOf(keyFont) + 6, breakWords = (text, width) => text.split(/\r?\n/).flatMap((paragraph) => {
|
|
394
|
+
let lines = [], line = "";
|
|
395
|
+
for (let word of paragraph.split(/[^\S ]+/).filter(Boolean)) {
|
|
396
|
+
let joined = line ? `${line} ${word}` : word;
|
|
397
|
+
if (measure(joined, keyFont).width <= width) {
|
|
398
|
+
line = joined;
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
line && lines.push(line), line = "";
|
|
402
|
+
for (let char of word)
|
|
403
|
+
line && measure(`${line}${char}-`, keyFont).width > width && (lines.push(`${line}-`), line = ""), line += char;
|
|
404
|
+
}
|
|
405
|
+
return (line || !lines.length) && lines.push(line), lines;
|
|
406
|
+
}), keyLayout = (pi, width, column) => {
|
|
407
|
+
let items = [...panelKeys[pi], ...panelKeys[pi].length ? [{ id: "stack:totals", label: totalsCue, paint: void 0 }] : []].map((item) => {
|
|
408
|
+
let inset = item.paint ? keySwatch + 5 : 0, wrapped = wrapText(item.label, keyFont, width - inset, Number.MAX_SAFE_INTEGER, measure), lines = wrapped.truncated ? breakWords(item.label, width - inset) : wrapped.lines, textW = Math.max(...lines.map((line) => measure(line, keyFont).width));
|
|
409
|
+
return { ...item, lines, textW, w: inset + textW, extra: (lines.length - 1) * heightOf(keyFont) };
|
|
410
|
+
}), x = 0, dy = 0, rowExtra = 0;
|
|
411
|
+
return { placed: items.map((item, i) => {
|
|
412
|
+
i > 0 && (column || rowExtra > 0 || item.extra > 0 || x + item.w > width) && (x = 0, dy += keyRow + rowExtra, rowExtra = 0);
|
|
413
|
+
let at = { ...item, dx: x, dy };
|
|
414
|
+
return x += item.w + 14, rowExtra = Math.max(rowExtra, item.extra), at;
|
|
415
|
+
}), h: items.length ? dy + keyRow + rowExtra : 0 };
|
|
416
|
+
}, legend = [];
|
|
417
|
+
if (!seen.size) {
|
|
418
|
+
hasProvisional && computed.panels.some((p) => !p.panel.emphasis && hasMatureLine(p)) && legend.push({ id: "stack:mature", label: chartString(options, "matureCohort"), paint: neutral, key: "line" });
|
|
419
|
+
let emphasis = computed.panels.find((p) => p.panel.emphasis && hasMatureLine(p));
|
|
420
|
+
emphasis && legend.push({ id: "stack:emphasis", label: emphasis.panel.title, paint: accent, key: "line", width: strokeToken(theme, "focus") }), hasProvisional && legend.push({ id: "stack:provisional", label: chartString(options, "provisional"), paint: muted, key: "line", dash: dashToken(theme, "reference") });
|
|
421
|
+
}
|
|
422
|
+
let size = resolveSize(options.size), automatic = heightOmitted(options.size), base = canvasMargin(theme, size.width), margin = { ...base, left: Math.min(24, base.left), right: Math.min(24, base.right), ...options.margin }, frameAt = () => {
|
|
423
|
+
let occupied2 = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frame2 = solveFrame({
|
|
424
|
+
size,
|
|
425
|
+
margin,
|
|
426
|
+
...frameTextOptions(options),
|
|
427
|
+
footnotes: [...notes, ...listed],
|
|
428
|
+
numberedFootnotes: notes,
|
|
429
|
+
unreferencedNotes: [],
|
|
430
|
+
numberedDisclosures: engineNumbers,
|
|
431
|
+
// A state note a marker points at prints with it (an engine-worded one where notes.show lists 'disclosure').
|
|
432
|
+
pointedNotes: [...frameTextOptions(options).pointedNotes ?? [], ...Object.values(stateNotes).map((n) => notes[n - 1])],
|
|
433
|
+
legend: options.legend === "none" ? void 0 : { options: normalizeLegendOption(options.legend, { position: "top" }), items: legend },
|
|
434
|
+
theme,
|
|
435
|
+
measure
|
|
436
|
+
}, occupied2);
|
|
437
|
+
return { occupied: occupied2, frame: frame2 };
|
|
438
|
+
};
|
|
439
|
+
automatic && (size = { ...size, height: Math.max(size.height, 1600) });
|
|
440
|
+
let { occupied, frame } = frameAt(), valueWidth = maxOf(computed.panels.flatMap((p) => p.values.map((v) => v === null ? measure(na, valueFont).width : measure(formatPanelValue(p.panel, v, options.locale?.language), valueFont).width))) + 4, categoryWidth = maxOf(data.categories.flatMap((c) => c.label.split(/\s+/).map((word) => measure(word, keyFont).width))) + 3, valueRoom = Math.max(20, valueWidth, categoryWidth) * data.categories.length, gutterKeys = computed.panels.map((_, i) => keyLayout(i, gutter, !0)), gutterHeights = gutterBoxes.map((box, i) => box.name.h + box.unit.h + heightOf(heroFont) + heightOf(unitFont) + 18 + (gutterKeys[i].h ? gutterKeys[i].h + 6 : 0)), narrow = frame.plot.w - gutter - gutterGap < valueRoom || gutterHeights.some((h, i) => stack.heights !== void 0 && Math.ceil(h) > stack.heights[i]), thin = narrow && frame.plot.w < valueRoom, lastIndex = data.categories.length - 1, named = (ci) => !thin || ci % 2 === lastIndex % 2, plotX = narrow ? frame.plot.x : frame.plot.x + gutter + gutterGap, plotW = narrow ? frame.plot.w : frame.plot.w - gutter - gutterGap, step = plotW / data.categories.length, minimumWidth = Math.ceil(size.width - plotW + (thin ? valueRoom / 2 : valueRoom)), needsWidth = (width) => ({
|
|
441
|
+
type: "grid",
|
|
442
|
+
size,
|
|
443
|
+
plot: frame.plot,
|
|
444
|
+
scene: [],
|
|
445
|
+
labels: [],
|
|
446
|
+
axes: [],
|
|
447
|
+
annotations: [],
|
|
448
|
+
frame: frame.frame,
|
|
449
|
+
marks: { panels: [] },
|
|
450
|
+
derived: {},
|
|
451
|
+
sizing: { aspect: "content", fit: "content", minWidth: width, minHeight: 0, measuredMinWidth: width, measuredMinHeight: 0, naturalWidth: width, naturalHeight: size.height, comfortableWidth: width, comfortableHeight: size.height },
|
|
452
|
+
a11y: { title: chartString(options, "metricStack"), desc: chartString(options, "metricStackWidth", { v1: width }) },
|
|
453
|
+
warnings: [],
|
|
454
|
+
debug: { occupied: [], decisions: [] }
|
|
455
|
+
});
|
|
456
|
+
if (size.width < minimumWidth) return needsWidth(minimumWidth);
|
|
457
|
+
let heads = narrow ? computed.panels.map((p, i) => {
|
|
458
|
+
let name = textBox(p.panel.title, nameFont, frame.plot.w), unit = textBox(p.panel.unit, keyFont, frame.plot.w), unitBeside = name.lines.length === 1 && unit.lines.length === 1 && name.w + 2 * spanSpace + unit.w <= frame.plot.w, spanBeside = measure(p.readout.headlineText, heroFont).width + 3 * spanSpace + spanWidths[i] + 2 * spanSpace <= frame.plot.w, top = unitBeside ? Math.max(name.h, unit.h) : name.h + 2 + unit.h, key = keyLayout(i, frame.plot.w, !1), body = top + 8 + heightOf(heroFont) + (spanBeside ? 0 : 6 + heightOf(unitFont)) + 6;
|
|
459
|
+
return { name, unit, unitBeside, spanBeside, top, key, body, h: body + (key.h ? key.h + 4 : 0) };
|
|
460
|
+
}) : void 0, minimumHeights = gutterHeights.map((h) => Math.ceil(Math.max(narrow ? 0 : h, 3 * heightOf(valueFont) + 20))), heights = computed.panels.map((p, i) => stack.heights?.[i] ?? Math.max(minimumHeights[i], p.panel.type === "column" ? p.parts.length > 1 ? narrow ? 110 : 150 : narrow ? 120 : 200 : narrow ? 90 : 130));
|
|
461
|
+
if (options.rows) {
|
|
462
|
+
let factor = maxOf(minimumHeights.map((h, i) => h / options.rows[i]));
|
|
463
|
+
heights = options.rows.map((w) => w * factor);
|
|
464
|
+
}
|
|
465
|
+
heights.forEach((h, i) => {
|
|
466
|
+
(!Number.isFinite(h) || h < minimumHeights[i]) && spacingError(`options.stack.heights.${i}`, `Panel '${data.panels[i].id}' needs at least ${minimumHeights[i]} px for its readout and value labels`, heightFix(i, minimumHeights[i]));
|
|
467
|
+
});
|
|
468
|
+
let headRoom = heads?.reduce((sum2, head) => sum2 + head.h, 0) ?? 0, partialOnValues = computed.panels.some((p) => p.panel.type === "column" && computed.partial.some((i) => p.values[i] !== null)), partialMark = marker(stateNotes.partial), toDate = ` ${options.strings?.toDate ?? localeStrings(options.locale?.language).toDate}`, categoryName = (c) => c.label + (c.partial ? partialMark ? partialOnValues ? "" : partialMark : saysToDate(c.label, toDate.trim()) ? "" : toDate : ""), categoryBoxes = data.categories.map((c) => textBox(categoryName(c), keyFont, (thin ? 2 : 1) * step - 3)), categoryHeight = maxOf(categoryBoxes.map((b) => b.h)), periodBoxes = data.periods?.map((period) => {
|
|
469
|
+
let indexes = stackRange(data, period), bold = data.windows ? [data.windows.base, data.windows.compare].some((w) => w.from === period.from && w.to === period.to) : indexes.every((i) => computed.mature.includes(i)), f = { ...keyFont, weight: bold ? 700 : keyFont.weight };
|
|
470
|
+
return { ...textBox(period.label, f, indexes.length * step - 4), indexes, bold, font: f };
|
|
471
|
+
}), axisHeight = 12 + categoryHeight + (periodBoxes ? 10 + maxOf(periodBoxes.map((b) => b.h)) : 0) + 10, bandFirstIndex = data.states?.maturing ? data.panels.findIndex((p) => data.states.maturing.panels.includes(p.id)) : -1, firstOverhang = computed.maturing.length ? gap : 0, readLogic = data.panels.some((p) => p.readout === "change") && data.windows ? chartString(options, "stackChangeMethod", { v1: metricStackGrain(data), v2: data.windows.base.label, v3: data.windows.compare.label }) : chartString(options, narrow ? "stackAboveMethod" : "stackLeftMethod"), readLogicBox = textBox(readLogic, keyFont, frame.plot.w), topRoom = readLogicBox.h + 12 + 30 + (bandFirstIndex === 0 ? firstOverhang : 0), neededPlotHeight = topRoom + headRoom + heights.reduce((a, b) => a + b, 0) + gap * (heights.length - 1) + axisHeight, overhead = size.height - frame.plot.h, naturalHeight = Math.ceil(overhead + neededPlotHeight);
|
|
472
|
+
if (automatic)
|
|
473
|
+
size = { ...size, height: naturalHeight }, { occupied, frame } = frameAt();
|
|
474
|
+
else {
|
|
475
|
+
if (frame.plot.h < neededPlotHeight - 0.01)
|
|
476
|
+
return {
|
|
477
|
+
type: "grid",
|
|
478
|
+
size,
|
|
479
|
+
plot: frame.plot,
|
|
480
|
+
scene: [],
|
|
481
|
+
labels: [],
|
|
482
|
+
axes: [],
|
|
483
|
+
annotations: [],
|
|
484
|
+
frame: frame.frame,
|
|
485
|
+
marks: { panels: [] },
|
|
486
|
+
derived: {},
|
|
487
|
+
sizing: { aspect: "content", fit: "content", minWidth: size.width, minHeight: naturalHeight, measuredMinWidth: size.width, measuredMinHeight: naturalHeight, naturalWidth: size.width, naturalHeight, comfortableWidth: size.width, comfortableHeight: naturalHeight },
|
|
488
|
+
a11y: { title: chartString(options, "metricStack"), desc: chartString(options, "metricStackHeight", { v1: naturalHeight }) },
|
|
489
|
+
warnings: [],
|
|
490
|
+
debug: { occupied: [], decisions: [] }
|
|
491
|
+
};
|
|
492
|
+
if (!stack.heights && frame.plot.h > neededPlotHeight) {
|
|
493
|
+
let available = frame.plot.h - topRoom - headRoom - gap * (heights.length - 1) - axisHeight, total = heights.reduce((a, b) => a + b, 0);
|
|
494
|
+
heights = heights.map((h) => h * available / total), neededPlotHeight = frame.plot.h;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
let scene = [...frame.nodes], requests = [], inks = /* @__PURE__ */ new Map(), put = (id, text, f, rect, owner, ink, role = "label", kind = "point", lines = [text], claimId, below) => {
|
|
498
|
+
if (rect.w > 0 && rect.h > 0) {
|
|
499
|
+
let candidates = [{ slot: "fixed", rect, penalty: 0 }, ...below === void 0 ? [] : [{ slot: "fixed", rect: { ...rect, y: below }, penalty: 1 }]];
|
|
500
|
+
requests.push({ id, kind, owner, text, lines, font: f, typeRole: role, priority: PRIORITY.total, pad: 0, candidates, ...claimId ? { claimId } : {} }), inks.set(id, ink);
|
|
501
|
+
}
|
|
502
|
+
}, centerText = (id, text, f, x, y2, owner, ink, role = "label", kind = "point", claimId, below) => {
|
|
503
|
+
let box = measure(text, f);
|
|
504
|
+
put(id, text, f, { x: x - box.width / 2, y: y2, w: box.width, h: heightOf(f) }, owner, ink, role, kind, [text], claimId, below);
|
|
505
|
+
};
|
|
506
|
+
put("stack:read-logic", readLogic, keyFont, { x: frame.plot.x, y: frame.plot.y, w: readLogicBox.w, h: readLogicBox.h }, {}, muted, "secondary", "annotation", readLogicBox.lines), scene.push({ t: "line", id: "stack:header-rule", x1: frame.plot.x, x2: frame.plot.x + frame.plot.w, y1: frame.plot.y + readLogicBox.h + 10, y2: frame.plot.y + readLogicBox.h + 10, stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "headerRule" });
|
|
507
|
+
let plots = [], tops = [], y = frame.plot.y + topRoom;
|
|
508
|
+
heights.forEach((h, i) => {
|
|
509
|
+
tops.push(y), y += heads?.[i].h ?? 0, plots.push({ x: plotX, y, w: plotW, h }), y += h + gap;
|
|
510
|
+
});
|
|
511
|
+
let derived = { gap, gutterWidth: narrow ? 0 : gutter, axisOwner: data.panels.at(-1).id, readouts: computed.panels.map((p) => p.readout), panels: [] }, bandLabelHeight = 0;
|
|
512
|
+
if (computed.maturing.length) {
|
|
513
|
+
let scope = data.states.maturing, indexes = scope.panels.map((id) => data.panels.findIndex((p) => p.id === id)).sort((a, b) => a - b), first = plots[indexes[0]], last = plots[indexes.at(-1)], firstTop = tops[indexes[0]], bandAt = categoryBandFromCenters(data.categories.map((c) => c.id), first, (i) => plotX + (i + 0.5) * step, "x"), left = bandAt(scope.from), right = bandAt(scope.to), rect = { x: left.x, y: firstTop - firstOverhang, w: right.x + right.w - left.x, h: last.y + last.h - firstTop + firstOverhang }, nodeId = "stack:maturing:band";
|
|
514
|
+
derived.band = { rect, panels: indexes.map((i) => data.panels[i].id), categoryIds: computed.maturing.map((i) => data.categories[i].id), nodeId }, scene.push({ t: "rect", id: nodeId, rect, fill: wash(neutral, 0.035), owner: { annotationId: "stack:maturing" }, part: "band" });
|
|
515
|
+
let text = (scope.label ?? chartString(options, "notYetMature")) + marker(stateNotes.maturing), box = textBox(text, noteFont, rect.w - 8);
|
|
516
|
+
bandLabelHeight = box.h, put("stack:maturing:label", text, noteFont, { x: rect.x + (rect.w - box.w) / 2, y: rect.y + 4, w: box.w, h: box.h }, { annotationId: "stack:maturing" }, muted, "footnote", "annotation", box.lines);
|
|
517
|
+
}
|
|
518
|
+
let marks = { panels: [] }, yielding = /* @__PURE__ */ new Set();
|
|
519
|
+
computed.panels.forEach((p, pi) => {
|
|
520
|
+
let formatValue = (value) => formatPanelValue(p.panel, value, options.locale?.language), plot = plots[pi], baseline = plot.y + plot.h, owner = { seriesId: p.panel.id }, color = p.panel.emphasis ? accent : neutral, labelGap = p.panel.type === "line" ? 9 : 5, clearance = heightOf(valueFont) + labelGap + (p.panel.type === "line" ? 4.5 : 0) + 4, bandClear = pi === bandFirstIndex ? Math.max(0, bandLabelHeight + 8 - firstOverhang - (heads?.[pi].h ?? 0)) : 0, headroom = clearance + bandClear;
|
|
521
|
+
plot.h <= headroom + 10 && spacingError(`options.stack.heights.${pi}`, `Panel '${p.panel.id}' needs at least ${Math.ceil(headroom + 11)} px height for its band and labels`, heightFix(pi, Math.ceil(headroom + 11)));
|
|
522
|
+
let visible = (i) => visibleValue(p, i), max = Math.max(maxOf(p.values.map((v, i) => visible(i) ? v ?? 0 : 0)), 0), domainMax = max === 0 ? 1 : max / (1 - headroom / plot.h), py = (v) => baseline - v / domainMax * plot.h, nodeIds = data.categories.map(() => []), displayed = data.categories.map(() => na), emit = (node, ci) => {
|
|
523
|
+
scene.push(node), ci !== void 0 && nodeIds[ci].push(node.id);
|
|
524
|
+
};
|
|
525
|
+
marks.panels.push({ id: p.panel.id, type: p.panel.type, plot, content: { x: frame.plot.x, y: plot.y, w: frame.plot.w, h: plot.h }, title: p.panel.title, row: pi, column: 0 }), derived.panels.push({ id: p.panel.id, domain: [0, domainMax], plot, values: p.values, states: p.states, displayed, nodeIds });
|
|
526
|
+
let boxes = heads?.[pi] ?? gutterBoxes[pi], head = heads?.[pi], gy = tops[pi];
|
|
527
|
+
put(`${p.panel.id}:name`, p.panel.title, nameFont, { x: frame.plot.x, y: gy, w: boxes.name.w, h: boxes.name.h }, owner, { token: "ink" }, "label", "category", boxes.name.lines), head?.unitBeside ? put(`${p.panel.id}:unit`, p.panel.unit, keyFont, { x: frame.plot.x + boxes.name.w + 2 * spanSpace, y: gy + boxes.name.h - boxes.unit.h, w: boxes.unit.w, h: boxes.unit.h }, owner, muted, "secondary", "category", boxes.unit.lines) : (gy += boxes.name.h + 2, put(`${p.panel.id}:unit`, p.panel.unit, keyFont, { x: frame.plot.x, y: gy, w: boxes.unit.w, h: boxes.unit.h }, owner, muted, "secondary", "category", boxes.unit.lines)), gy = head ? tops[pi] + head.top + 8 : gy + boxes.unit.h + 10;
|
|
528
|
+
let hero = measure(p.readout.headlineText, heroFont), headlineClaim = p.readout.claims.find((c) => c.id === `stack:${p.panel.id}:headline` || c.id === `stack:${p.panel.id}:rate`);
|
|
529
|
+
put(`${p.panel.id}:headline`, p.readout.headlineText, heroFont, { x: frame.plot.x, y: gy, w: hero.width, h: heightOf(heroFont) }, owner, color, "title", "point", [p.readout.headlineText], headlineClaim.id);
|
|
530
|
+
let before = p.readout.claims.find((c) => c.id === `stack:${p.panel.id}:before`), after = p.readout.claims.find((c) => c.id === `stack:${p.panel.id}:after`), gx = frame.plot.x;
|
|
531
|
+
head?.spanBeside ? (gx += hero.width + 3 * spanSpace, gy += heightOf(heroFont) / 2 - heightOf(unitFont) / 2 + 0.36 * (heroFont.size - unitFont.size)) : gy += heightOf(heroFont) + 6;
|
|
532
|
+
for (let [suffix, text, claim] of [["before", before.output.displayed, before.id], ["arrow", "\u2192", void 0], ["after", after.output.displayed, after.id]]) {
|
|
533
|
+
suffix === "arrow" && (gx += spanSpace);
|
|
534
|
+
let width = suffix === "arrow" ? arrowWidth : measure(text, unitFont).width;
|
|
535
|
+
put(`${p.panel.id}:${suffix}`, text, unitFont, { x: gx, y: gy, w: width, h: heightOf(unitFont) }, owner, muted, "axis", "point", [text], claim), gx += width + (suffix === "arrow" ? spanSpace : 0);
|
|
536
|
+
}
|
|
537
|
+
let barWidth = step * 0.64, segmentLabels = stacked(p) && !thin && data.categories.every((_, ci) => {
|
|
538
|
+
let part = p.parts[0][ci];
|
|
539
|
+
return !visible(ci) || !part || part / domainMax * plot.h >= heightOf(valueFont) + 10 && measure(formatValue(part), valueFont).width < barWidth - 6;
|
|
540
|
+
}), key = head ? head.key : gutterKeys[pi], keyTop = head ? tops[pi] + head.body : gy + heightOf(unitFont) + 6;
|
|
541
|
+
for (let item of key.placed) {
|
|
542
|
+
if (item.id === "stack:totals" && segmentLabels) continue;
|
|
543
|
+
let kx = frame.plot.x + item.dx, ky = keyTop + item.dy;
|
|
544
|
+
item.paint && scene.push({ t: "rect", id: `${p.panel.id}:key:${item.id}`, rect: { x: kx, y: ky + (keyRow - keySwatch) / 2, w: keySwatch, h: keySwatch }, fill: item.paint, owner: { seriesId: item.id }, part: "swatch" });
|
|
545
|
+
let tx = item.paint ? kx + keySwatch + 5 : kx;
|
|
546
|
+
put(`${p.panel.id}:key:${item.id}:label`, item.label, keyFont, { x: tx, y: ky + (keyRow - heightOf(keyFont)) / 2, w: item.textW, h: heightOf(keyFont) * item.lines.length }, { seriesId: item.id }, muted, "secondary", "category", item.lines);
|
|
547
|
+
}
|
|
548
|
+
if (p.panel.type === "line") {
|
|
549
|
+
for (let i = 1; i < data.categories.length; i++) if (visible(i - 1) && visible(i) && p.states[i - 1] !== "partial" && p.states[i] !== "partial") {
|
|
550
|
+
let provisional = p.states[i - 1] === "maturing" || p.states[i] === "maturing", x1 = plotX + (i - 0.5) * step, y1 = py(p.values[i - 1]), x2 = plotX + (i + 0.5) * step, y2 = py(p.values[i]);
|
|
551
|
+
emit({ t: "line", id: `${p.panel.id}:line:${i}`, x1, y1, x2, y2, stroke: provisional ? muted : color, width: strokeToken(theme, p.panel.emphasis ? "focus" : "data"), ...provisional ? { dash: dashToken(theme, "reference") } : {}, owner, part: provisional ? "provisionalLine" : "line" });
|
|
552
|
+
let length = Math.hypot(x2 - x1, y2 - y1), dx = -(y2 - y1) / length, dy = (x2 - x1) / length;
|
|
553
|
+
occupied.claim(
|
|
554
|
+
{ x: x1 - 1, y: Math.min(y1, y2) - 1, w: x2 - x1 + 2, h: Math.abs(y2 - y1) + 2 },
|
|
555
|
+
"mark",
|
|
556
|
+
{ ...owner, pointId: `segment:${i}` },
|
|
557
|
+
"line",
|
|
558
|
+
[
|
|
559
|
+
{ x: x1 + dx, y: y1 + dy },
|
|
560
|
+
{ x: x2 + dx, y: y2 + dy },
|
|
561
|
+
{ x: x2 - dx, y: y2 - dy },
|
|
562
|
+
{ x: x1 - dx, y: y1 - dy }
|
|
563
|
+
]
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
let latest = data.categories.reduce((last, _, ci) => visible(ci) ? ci : last, -1), valued = (ci) => named(ci) || ci === latest;
|
|
568
|
+
named(latest) || yielding.add(`${p.panel.id}:value:${data.categories[latest - 1]?.id}`), data.categories.forEach((category, ci) => {
|
|
569
|
+
let x = plotX + (ci + 0.5) * step, cellOwner = { seriesId: p.panel.id, categoryId: category.id };
|
|
570
|
+
if (!visible(ci)) {
|
|
571
|
+
valued(ci) && centerText(`${p.panel.id}:value:${category.id}`, na, valueFont, x, baseline - heightOf(valueFont) - 5, cellOwner, muted);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
let v = p.values[ci], top = py(v), provisional = p.states[ci] !== "mature", val = formatValue(v);
|
|
575
|
+
displayed[ci] = val;
|
|
576
|
+
let labelText = val + (p.panel.type === "column" && p.states[ci] === "partial" ? marker(stateNotes.partial) : "");
|
|
577
|
+
if (p.panel.type === "column") {
|
|
578
|
+
let width = barWidth, sum2 = 0, values = "sum" in p.panel.measure ? p.parts.map((part) => part[ci]) : [v];
|
|
579
|
+
values.forEach((part, si) => {
|
|
580
|
+
let h = part / domainMax * plot.h;
|
|
581
|
+
sum2 += part;
|
|
582
|
+
let paints = values.length > 1 && "sum" in p.panel.measure ? measurePaints.get(p.panel.measure.sum[si]) : void 0, fill = paints ? paints.mature : p.panel.emphasis ? emphasizedFill : columnFill, rect = { x: x - width / 2, y: py(sum2), w: width, h }, partOwner = { ...cellOwner, segmentId: String(si) };
|
|
583
|
+
if (emit({ t: "rect", id: `${p.panel.id}:bar:${category.id}:${si}`, rect, fill, ...provisional ? { pattern: "hatch45", hatchEdge: !1, ...paints ? { hatch: { strength: options.hatchStrength ?? HATCH_STRENGTH_DEFAULT.sole, cue: "sole", stacked: !0 } } : {} } : {}, owner: partOwner, part: "segment" }, ci), occupied.claim(rect, "mark", partOwner, "segment"), segmentLabels && si === 0 && part) {
|
|
584
|
+
let text = formatValue(part), ink = provisional ? { token: "ink" } : paints && fill !== color ? { token: "ink", theme: { kind: "contrast-ink", fill } } : { token: "inkInverse" }, tw = measure(text, valueFont).width;
|
|
585
|
+
provisional && emit({ t: "rect", id: `${p.panel.id}:segment-tag:${category.id}`, rect: { x: x - tw / 2 - 2, y: rect.y + 4, w: tw + 4, h: heightOf(valueFont) }, fill: { token: "background" }, radius: 2, owner: partOwner, part: "labelTag" }, ci), centerText(`${p.panel.id}:segment:${category.id}`, text, valueFont, x, rect.y + 4, partOwner, ink);
|
|
586
|
+
}
|
|
587
|
+
}), provisional && emit({ t: "path", id: `${p.panel.id}:outline:${category.id}`, d: `M${fmtPathNumber(x - width / 2)} ${fmtPathNumber(baseline)}V${fmtPathNumber(top)}H${fmtPathNumber(x + width / 2)}V${fmtPathNumber(baseline)}`, stroke: muted, width: strokeToken(theme, "mark"), dash: dashToken(theme, "reference"), owner: cellOwner, part: "provisionalOutline" }, ci);
|
|
588
|
+
} else
|
|
589
|
+
emit({ t: "circle", id: `${p.panel.id}:point:${category.id}`, cx: x, cy: top, r: 4.5, fill: provisional ? { token: "background" } : color, ...provisional ? { stroke: muted, strokeWidth: strokeToken(theme, "mark") } : {}, owner: cellOwner, part: provisional ? "provisionalPoint" : "point" }, ci), occupied.claim({ x: x - 4.5, y: top - 4.5, w: 9, h: 9 }, "mark", cellOwner, "point");
|
|
590
|
+
valued(ci) && centerText(`${p.panel.id}:value:${category.id}`, labelText, valueFont, x, top - labelGap - heightOf(valueFont), cellOwner, provisional ? muted : { token: "ink" }, "label", "point", void 0, p.panel.type === "line" && top + labelGap + heightOf(valueFont) < baseline - 2 ? top + labelGap : void 0);
|
|
591
|
+
}), emit({ t: "line", id: `${p.panel.id}:baseline`, x1: plotX, x2: plotX + plotW, y1: baseline, y2: baseline, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner, part: "baseline" }), occupied.claim({ x: plotX, y: baseline - 0.5, w: plotW, h: 1 }, "axis", owner, "baseline");
|
|
592
|
+
});
|
|
593
|
+
let axisY = plots.at(-1).y + plots.at(-1).h + 8;
|
|
594
|
+
data.categories.forEach((category, i) => {
|
|
595
|
+
let box = categoryBoxes[i], text = categoryName(category);
|
|
596
|
+
if (!named(i)) {
|
|
597
|
+
scene.push({ t: "line", id: `stack:category:tick:${category.id}`, x1: plotX + (i + 0.5) * step, x2: plotX + (i + 0.5) * step, y1: axisY + 2, y2: axisY + 7, stroke: muted, width: strokeToken(theme, "rule"), owner: { categoryId: category.id }, part: "categoryTick" });
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
put(`stack:category:${category.id}`, text, keyFont, { x: plotX + (i + 0.5) * step - box.w / 2, y: axisY, w: box.w, h: box.h }, { categoryId: category.id }, { token: "ink" }, "secondary", "category", box.lines);
|
|
601
|
+
}), data.periods?.forEach((period, i) => {
|
|
602
|
+
let box = periodBoxes[i], { indexes, bold, font: f } = box, x = plotX + indexes[0] * step, y2 = axisY + categoryHeight + 8;
|
|
603
|
+
put(`stack:period:${i}`, period.label, f, { x: x + 2, y: y2 + 4, w: box.w, h: box.h }, { categoryId: period.from }, bold ? { token: "ink" } : muted, "secondary", "category", box.lines), scene.push({ t: "line", id: `stack:period:rule:${i}`, x1: x + 1.5, x2: x + indexes.length * step - 1.5, y1: y2, y2, stroke: bold ? { token: "ink" } : { token: "grid" }, width: strokeToken(theme, bold ? "data" : "rule"), owner: {}, part: "periodRule" });
|
|
604
|
+
});
|
|
605
|
+
for (let request of requests) yielding.has(request.id) && (request.priority = PRIORITY.interior);
|
|
606
|
+
let solved = solveLabels(requests, occupied, { density: "full", pins: options.labelPlacements ?? {}, measure, plot: frame.plot, canvas: { x: 0, y: 0, w: size.width, h: size.height }, darkInk: theme.color.ink, lightInk: theme.color.inkInverse, labelPad: 0 }), fonts = new Map(requests.map((request) => [request.id, request.font]));
|
|
607
|
+
for (let label of solved.placed)
|
|
608
|
+
label.ink = inks.get(label.id) ?? label.ink, label.font = fonts.get(label.id);
|
|
609
|
+
let hidden = solved.placed.filter((l) => l.hidden && !yielding.has(l.id));
|
|
610
|
+
if (hidden.length) {
|
|
611
|
+
let width = options[NO_WIDER_SEARCH] ? void 0 : widerThatPlaces(raw, options, size, automatic);
|
|
612
|
+
if (width !== void 0) return needsWidth(width);
|
|
613
|
+
spacingError("options.size", `Metric stack cannot place ${hidden.map((l) => `'${l.text}'`).join(", ")} at ${size.width} \xD7 ${size.height} px`);
|
|
614
|
+
}
|
|
615
|
+
pushAll(scene, labelsToNodes(theme, solved.placed, () => valueFont));
|
|
616
|
+
let counts = [structureCount("panels", data.panels.length, void 0, options), structureCount("categories", data.categories.length, void 0, options), structureCount("series", data.measures.length, chartString(options, "sourceMeasures", { v1: data.measures.length }))];
|
|
617
|
+
return {
|
|
618
|
+
type: "grid",
|
|
619
|
+
size,
|
|
620
|
+
plot: frame.plot,
|
|
621
|
+
scene,
|
|
622
|
+
labels: solved.placed,
|
|
623
|
+
axes: [{ axis: "x", baselineNodeId: `${data.panels.at(-1).id}:baseline`, ticks: data.categories.map((c, i) => ({ at: c.id, pos: plotX + (i + 0.5) * step, labelId: `stack:category:${c.id}` })) }],
|
|
624
|
+
annotations: [],
|
|
625
|
+
frame: frame.frame,
|
|
626
|
+
legend: frame.legend,
|
|
627
|
+
marks,
|
|
628
|
+
derived: { metricStack: derived, sharedPlotX: plotX, sharedPlotW: plotW, tierGap: gap },
|
|
629
|
+
sizing: { aspect: "content", fit: "content", minWidth: size.width, minHeight: naturalHeight, measuredMinWidth: size.width, measuredMinHeight: naturalHeight, naturalWidth: size.width, naturalHeight, comfortableWidth: size.width, comfortableHeight: naturalHeight },
|
|
630
|
+
a11y: { title: accessibleTitle(options.title, chartString(options, "metricStackTitle", { v1: data.panels.length })), counts, desc: chartString(options, "metricStackDesc", { v1: counts.map((c) => c.text).join(", "), v2: data.panels.map((p) => p.title).join("; "), v3: computed.panels.map((p) => `${p.panel.title}: ${p.readout.headlineText}; ${p.readout.spanText}.`).join(" ") }) },
|
|
631
|
+
warnings: solved.warnings,
|
|
632
|
+
debug: { occupied: occupied.snapshot(), decisions: solved.decisions }
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// src/core/strings/layoutGrid.ts
|
|
637
|
+
var EN2 = {
|
|
638
|
+
// reader-facing wording linked only by its consumers.
|
|
639
|
+
notesClause: " Notes: {v1}.",
|
|
640
|
+
gridChartsTitle: "Grid of {v1} charts",
|
|
641
|
+
gridChartsDesc: "{v1}: {v2}.{v3}",
|
|
642
|
+
alignedExhibit: "Aligned multi-tier exhibit",
|
|
643
|
+
chartGrid: "Chart grid"
|
|
644
|
+
}, DE2 = {
|
|
645
|
+
// reader-facing wording linked only by its consumers.
|
|
646
|
+
notesClause: " Hinweise: {v1}.",
|
|
647
|
+
gridChartsTitle: "Raster mit {v1} {v1|Diagramm|Diagrammen}",
|
|
648
|
+
gridChartsDesc: "{v1}: {v2}.{v3}",
|
|
649
|
+
alignedExhibit: "Ausgerichtete Darstellung mit mehreren Ebenen",
|
|
650
|
+
chartGrid: "Diagrammraster"
|
|
651
|
+
}, { chartString: chartString2 } = chartStrings(EN2, DE2);
|
|
652
|
+
|
|
653
|
+
// src/core/panelNoteData.ts
|
|
654
|
+
function panelNoteData(type, data, language) {
|
|
655
|
+
let def = getChart(type);
|
|
656
|
+
return def?.categoryLabels ? withCalendarLabels(data, language, def.categoryLabels) : data;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/core/grid/childLayout.ts
|
|
660
|
+
var hasKpiFigure = (type) => type === "kpi" || type === "waffle";
|
|
661
|
+
function smallestKpiValueSize(children) {
|
|
662
|
+
let figures = (child) => child.scene.filter((node) => (child.type === "kpi" ? node.id === "label:total:value" : node.id.startsWith("label:total:")) && node.t === "text"), sizes = children.filter((child) => hasKpiFigure(child.type)).map((child) => ({ type: child.type, nodes: figures(child) })).filter(({ type, nodes }) => type !== "waffle" || nodes.length <= 1).flatMap(({ nodes }) => nodes.map((node) => node.t === "text" ? node.font.size : 1 / 0));
|
|
663
|
+
return sizes.length > 1 && maxOf(sizes) > minOf(sizes) ? minOf(sizes) : void 0;
|
|
664
|
+
}
|
|
665
|
+
function layoutChildChart(data, options, layout) {
|
|
666
|
+
let geometry = layout(data, options);
|
|
667
|
+
if (geometry.refused) return geometry;
|
|
668
|
+
if (geometry.sizing?.fit === "content") {
|
|
669
|
+
let height = geometry.sizing.naturalHeight;
|
|
670
|
+
height < geometry.size.height && (geometry = layout(data, { ...options, size: { width: geometry.size.width, height } }));
|
|
671
|
+
}
|
|
672
|
+
if (geometry.refused) return geometry;
|
|
673
|
+
let { sizing, frame } = geometry;
|
|
674
|
+
if (sizing) {
|
|
675
|
+
let minWidth = sizing.measuredMinWidth, minHeight = Math.ceil(Math.max(
|
|
676
|
+
frame.minHeight ?? 0,
|
|
677
|
+
isVarianceTier(options) ? 0 : frame.plotMinHeight ?? 0,
|
|
678
|
+
sizing.measuredMinHeight
|
|
679
|
+
));
|
|
680
|
+
geometry.sizing = resolveSizing({ ...sizing, minWidth, minHeight }, geometry.size, {
|
|
681
|
+
minWidth,
|
|
682
|
+
minHeight,
|
|
683
|
+
naturalWidth: sizing.naturalWidth,
|
|
684
|
+
naturalHeight: sizing.naturalHeight
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
return geometry;
|
|
688
|
+
}
|
|
689
|
+
var sum = (values) => values.reduce((a, b) => a + b, 0);
|
|
690
|
+
function contentRows(children, rows, gaps, automatic) {
|
|
691
|
+
return rows.map((_, row) => {
|
|
692
|
+
let occupants = children.filter((child) => child.row <= row && row < child.row + child.rowSpan);
|
|
693
|
+
if (!(!automatic || occupants.length === 0 || occupants.some((child) => child.geometry.sizing?.fit !== "content")))
|
|
694
|
+
return maxOf(occupants.map((child) => {
|
|
695
|
+
let weight = sum(rows.slice(child.row, child.row + child.rowSpan)), height = child.geometry.sizing.naturalHeight - sum(gaps.slice(child.row, child.row + child.rowSpan - 1));
|
|
696
|
+
return Math.max(0, height) * rows[row] / weight;
|
|
697
|
+
}));
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
function gridRowHeights(height, children, rows, gaps) {
|
|
701
|
+
let fixed = contentRows(children, rows, gaps, !0);
|
|
702
|
+
if (fixed.every((value) => value === void 0)) return;
|
|
703
|
+
let flexibleWeight = sum(rows.filter((_, row) => fixed[row] === void 0)), remaining = Math.max(0, height - sum(gaps) - sum(fixed.map((value) => value ?? 0)));
|
|
704
|
+
return rows.map((weight, row) => fixed[row] ?? remaining * weight / flexibleWeight);
|
|
705
|
+
}
|
|
706
|
+
function gridSizing(size, area, children, rows, columns, rowGaps, columnGaps, automaticRows = !1) {
|
|
707
|
+
let fixed = contentRows(children, rows, rowGaps, automaticRows), required = (axis, weights, gaps, natural = !1) => {
|
|
708
|
+
let heights = weights.map((_, row) => axis === "row" ? fixed[row] : void 0), flexible = weights.map((weight, row) => heights[row] === void 0 ? weight : 0), total = sum(flexible);
|
|
709
|
+
return sum(gaps) + sum(heights.map((value) => value ?? 0)) + Math.max(0, maxOf(children.map((child) => {
|
|
710
|
+
let start = child[axis], span = axis === "row" ? child.rowSpan : child.columnSpan, g = child.geometry, need = axis === "column" ? g.sizing?.minWidth ?? 0 : (natural ? g.sizing?.naturalHeight : g.sizing?.minHeight) ?? (g.refused ? 0 : Math.max(g.frame.minHeight ?? 0, g.frame.plotMinHeight ?? 0)), weight = sum(flexible.slice(start, start + span)), held = sum(heights.slice(start, start + span).map((value) => value ?? 0));
|
|
711
|
+
return weight === 0 ? 0 : Math.max(0, need - held - sum(gaps.slice(start, start + span - 1))) * total / weight;
|
|
712
|
+
})));
|
|
713
|
+
}, hasContentRows = fixed.some((value) => value !== void 0), content = hasContentRows || children.length > 0 && children.every((child) => child.geometry.sizing?.fit === "content"), policy = chartSizing("grid"), chrome = size.height - area.h, minimumRows = required("row", rows, rowGaps), naturalRows = hasContentRows ? Math.max(
|
|
714
|
+
minimumRows,
|
|
715
|
+
sum(rowGaps) + sum(fixed.map((value) => value ?? 0)) + Math.max(0, resolveSizing(policy, size).naturalHeight - chrome - sum(rowGaps)) * sum(rows.filter((_, row) => fixed[row] === void 0)) / sum(rows)
|
|
716
|
+
) : required("row", rows, rowGaps, !0);
|
|
717
|
+
return resolveSizing(content ? { ...policy, fit: "content", aspect: "content", minHeight: 0 } : policy, size, {
|
|
718
|
+
minWidth: size.width - area.w + required("column", columns, columnGaps),
|
|
719
|
+
minHeight: chrome + minimumRows,
|
|
720
|
+
...content ? { naturalHeight: chrome + naturalRows } : {}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
var GridChildRefusal = class extends Error {
|
|
724
|
+
constructor(panelId, child) {
|
|
725
|
+
super(`Grid panel '${panelId}' refused layout`);
|
|
726
|
+
this.panelId = panelId;
|
|
727
|
+
this.child = child;
|
|
728
|
+
}
|
|
729
|
+
panelId;
|
|
730
|
+
child;
|
|
731
|
+
result(size, sizing, panelIndex) {
|
|
732
|
+
let result = sizeRefusal("grid", "Grid", size, sizing), childWarnings = this.child.warnings.map((warning) => ({
|
|
733
|
+
...warning,
|
|
734
|
+
field: ["data", "panels", panelIndex, ...warning.field ?? []],
|
|
735
|
+
...warning.fix ? { fix: warning.fix.map((fix) => ({
|
|
736
|
+
...fix,
|
|
737
|
+
path: `/data/panels/${panelIndex}${fix.path}`
|
|
738
|
+
})) } : {}
|
|
739
|
+
}));
|
|
740
|
+
return result.warnings = this.child.warnings[0]?.code === "size-below-floor" ? [...result.warnings, ...childWarnings] : [...childWarnings, ...result.warnings], result;
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
// src/core/grid/layoutGrid.ts
|
|
745
|
+
function serializableOptions(options) {
|
|
746
|
+
let { measure: _measure, ...rest } = options;
|
|
747
|
+
return rest;
|
|
748
|
+
}
|
|
749
|
+
var TIER_WEIGHT_FIRST = 2.2, TIER_SLACK_PASSES = 32, TIER_SLACK_BACKOFFS = 8;
|
|
750
|
+
function sharedYGroup(panels) {
|
|
751
|
+
let group = null;
|
|
752
|
+
for (let p of panels) {
|
|
753
|
+
let sg = p.options?.scaleGroup, y = sg !== null && typeof sg == "object" && !Array.isArray(sg) ? sg.y : void 0;
|
|
754
|
+
if (typeof y != "string") return null;
|
|
755
|
+
if (group === null) group = y;
|
|
756
|
+
else if (group !== y) return null;
|
|
757
|
+
}
|
|
758
|
+
return group;
|
|
759
|
+
}
|
|
760
|
+
function tierWeights(panels) {
|
|
761
|
+
let uniformScale = sharedYGroup(panels) !== null, varianceWeights = uniformScale ? void 0 : varianceTierWeights(panels);
|
|
762
|
+
return varianceWeights || panels.map(
|
|
763
|
+
(_, index) => index === 0 && panels.length > 1 && !uniformScale ? TIER_WEIGHT_FIRST : 1
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
function sharedCategoryLabelOwner(panels) {
|
|
767
|
+
return panels.findIndex((panel) => {
|
|
768
|
+
let options = isRecord(panel.options) ? panel.options : {};
|
|
769
|
+
return options.labels === !1 ? !1 : !isRecord(options.labels) || options.labels.category !== !1;
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
function bottomUpTierOrder(panels) {
|
|
773
|
+
let owner = sharedCategoryLabelOwner(panels), indexes = panels.map((_, index) => index);
|
|
774
|
+
return owner < 0 ? indexes : [owner, ...indexes.filter((index) => index !== owner)];
|
|
775
|
+
}
|
|
776
|
+
function gridShare(panels, share) {
|
|
777
|
+
return share ?? (varianceTierWeights(panels) ? "category" : "none");
|
|
778
|
+
}
|
|
779
|
+
function soloPanelReserve(share, panels) {
|
|
780
|
+
if (share !== "category" || panels.length !== 1) return 0;
|
|
781
|
+
let panel = panels[0], hasCaption = typeof panel.title == "string" && panel.title.trim().length > 0 || typeof panel.caption == "string" && panel.caption.trim().length > 0, marginTop = panel.options?.margin?.top;
|
|
782
|
+
return hasCaption ? typeof marginTop == "number" ? marginTop : 20 : 0;
|
|
783
|
+
}
|
|
784
|
+
var PANEL_VALUE_NOTE = /* @__PURE__ */ Symbol("panelValueNote"), FACET_HEADED_ROW_GAP = 5, FACET_HEADED_COLUMN_LADDER = [[320, 20], [400, 24], [480, 32], [720, 40], [960, 48]], FACET_GAP_BASE = 28;
|
|
785
|
+
function facetHeadedColumnGap(facetGap, width) {
|
|
786
|
+
let ladder = FACET_HEADED_COLUMN_LADDER, i = ladder.findIndex(([w]) => w >= width), gap;
|
|
787
|
+
if (i === 0) gap = ladder[0][1];
|
|
788
|
+
else if (i < 0) gap = ladder[ladder.length - 1][1];
|
|
789
|
+
else {
|
|
790
|
+
let [w0, g0] = ladder[i - 1], [w1, g1] = ladder[i];
|
|
791
|
+
gap = g0 + (g1 - g0) * (width - w0) / (w1 - w0);
|
|
792
|
+
}
|
|
793
|
+
return Math.round(gap * facetGap / FACET_GAP_BASE);
|
|
794
|
+
}
|
|
795
|
+
function facetHeadedGaps(facetGap, width) {
|
|
796
|
+
return { row: FACET_HEADED_ROW_GAP, column: facetHeadedColumnGap(facetGap, width) };
|
|
797
|
+
}
|
|
798
|
+
var FACET_GAPS = /* @__PURE__ */ Symbol("facetGaps"), SCALE_GROUP_MEMBERS = /* @__PURE__ */ Symbol("scaleGroupMembers");
|
|
799
|
+
function layoutGrid(data, options = {}) {
|
|
800
|
+
let named = [], geometry = layoutGridPass(data, options);
|
|
801
|
+
for (let round = 0; round < 2; round++) {
|
|
802
|
+
if (geometry.refused) return geometry;
|
|
803
|
+
let unprinted = unprintedPanelValues(data, geometry);
|
|
804
|
+
if (unprinted.every((item) => named.includes(item))) break;
|
|
805
|
+
named = [.../* @__PURE__ */ new Set([...named, ...unprinted])], geometry = layoutGridPass(data, { ...options, [PANEL_VALUE_NOTE]: named });
|
|
806
|
+
}
|
|
807
|
+
return geometry;
|
|
808
|
+
}
|
|
809
|
+
function unprintedPanelValues(data, geometry) {
|
|
810
|
+
let byPanel = data.panels.map((panel) => {
|
|
811
|
+
if (panel.type === "likert") return { title: panel.title ?? panel.id, items: [] };
|
|
812
|
+
let prefix = `${panel.id}/`, panelData = panel.data, nameOf = (list, id) => {
|
|
813
|
+
let found = list?.find((entry) => (typeof entry == "string" ? entry : entry.id) === id);
|
|
814
|
+
return found === void 0 ? String(id) : typeof found == "string" ? found : found.label ?? found.id;
|
|
815
|
+
}, unprefix = (id) => id?.startsWith(prefix) ? id.slice(prefix.length) : id, order = (id) => panelData?.categories?.findIndex((entry) => (typeof entry == "string" ? entry : entry.id) === id) ?? -1, items = geometry.labels.filter((label) => label.id.startsWith(prefix) && label.hidden && label.kind === "segment" && /\d/.test(label.text)).sort((a, b) => order(unprefix(a.owner.categoryId)) - order(unprefix(b.owner.categoryId))).map((label) => `${nameOf(panelData?.series, unprefix(label.owner.seriesId))} in ${nameOf(panelData?.categories, unprefix(label.owner.categoryId))} ${label.text}`);
|
|
816
|
+
return { title: panel.title ?? panel.id, items };
|
|
817
|
+
}).filter((entry) => entry.items.length > 0);
|
|
818
|
+
return byPanel.flatMap((entry) => byPanel.length > 1 ? entry.items.map((item) => `${entry.title}: ${item}`) : entry.items);
|
|
819
|
+
}
|
|
820
|
+
function layoutGridPass(data, options = {}) {
|
|
821
|
+
if (options = resolveCanvasOptions(options), !data || !Array.isArray(data.panels) || data.panels.length === 0)
|
|
822
|
+
throw new NormalizeError("empty-data", "panels", "grid requires at least one panel");
|
|
823
|
+
let size = resolveSize(options.size), gridClass = panelTypeClass(options) ?? typeWidthClass(size.width), theme = themeForWidth(resolveTheme(options.theme), gridClass), measure = options.measure ?? defaultMeasurer, share = gridShare(data.panels, options.sharedAxis), compactTiers = share === "category" && data.panels.length > 1, varianceTiers = compactTiers && varianceTierWeights(data.panels) !== void 0, varianceWeights = varianceTiers && sharedYGroup(data.panels) === null ? tierWeights(data.panels) : void 0, warnings = [];
|
|
824
|
+
share === "category" && ((options.columns ?? 1) !== 1 || options.panelOrder !== void 0) && warnings.push({
|
|
825
|
+
code: "grid-tier-order",
|
|
826
|
+
severity: "warn",
|
|
827
|
+
message: "Category tiers use one column and bottom-up order, with the category-axis owner at the bottom; columns and panelOrder do not set their visual order",
|
|
828
|
+
suggest: "use sharedAxis: 'none' for facet columns in array or panelOrder order"
|
|
829
|
+
}), options.valueAxis?.break && warnings.push({ code: "axis-break-unsupported", severity: "warn", message: "chart type 'grid' does not support valueAxis.break \u2014 ignored" });
|
|
830
|
+
let legendInput;
|
|
831
|
+
if (options.legend && options.legend !== "none" && options.legend !== "auto") {
|
|
832
|
+
let legendOptions = typeof options.legend == "string" ? { position: options.legend } : options.legend;
|
|
833
|
+
legendInput = gridLegendInput(collectGridLegendItems(data.panels, options, measure), legendOptions, options, warnings);
|
|
834
|
+
}
|
|
835
|
+
let occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), margin = { ...canvasMargin(theme, size.width), ...options.margin }, frameResult = solveFrame(
|
|
836
|
+
{
|
|
837
|
+
size,
|
|
838
|
+
margin,
|
|
839
|
+
...frameTextOptions(options),
|
|
840
|
+
...panelValueFootnotes(options),
|
|
841
|
+
legend: legendInput,
|
|
842
|
+
theme,
|
|
843
|
+
measure
|
|
844
|
+
},
|
|
845
|
+
occupied
|
|
846
|
+
), area = frameResult.plot, n = data.panels.length, categoryOwner = compactTiers ? sharedCategoryLabelOwner(data.panels) : -1, bottomUpOrder = bottomUpTierOrder(data.panels), columns = share === "category" ? 1 : Math.max(1, options.columns ?? 1), rows = Math.ceil(n / columns), facetGaps = options[FACET_GAPS], gap = columns === 1 ? theme.space.tierGap : facetGaps?.column ?? theme.space.facetGap, rowGap = columns === 1 ? gap : facetGaps?.row ?? gap, slots = [];
|
|
847
|
+
if (share === "category") {
|
|
848
|
+
let gap2 = theme.space.tierGap, weights = tierWeights(data.panels), wSum = weights.reduce((a, b) => a + b, 0), usable = area.h - gap2 * (n - 1), y = area.y + area.h;
|
|
849
|
+
for (let i of bottomUpOrder) {
|
|
850
|
+
let h = usable * weights[i] / wSum;
|
|
851
|
+
y -= h, slots[i] = { x: area.x, y, w: area.w, h }, y -= gap2;
|
|
852
|
+
}
|
|
853
|
+
} else {
|
|
854
|
+
let cols = columns, cw = (area.w - gap * (cols - 1)) / cols, ch = (area.h - rowGap * (rows - 1)) / rows;
|
|
855
|
+
for (let i = 0; i < n; i++) {
|
|
856
|
+
let c = i % cols, r = Math.floor(i / cols);
|
|
857
|
+
slots.push({ x: area.x + c * (cw + gap), y: area.y + r * (ch + rowGap), w: cw, h: ch });
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (share === "category") {
|
|
861
|
+
let idLists = data.panels.map((p) => {
|
|
862
|
+
let d = p.data;
|
|
863
|
+
return Array.isArray(d?.categories) ? d.categories.map((c) => typeof c == "string" ? c : c.id) : null;
|
|
864
|
+
}), first = idLists.findIndex((ids) => ids !== null), firstIds = idLists[first], other = idLists.findIndex((ids) => ids !== null && firstIds != null && (ids.length !== firstIds.length || ids.some((id, index) => id !== firstIds[index])));
|
|
865
|
+
other >= 0 && warnings.push({
|
|
866
|
+
code: "grid-category-mismatch",
|
|
867
|
+
severity: "error",
|
|
868
|
+
message: `sharedAxis "category" aligns every panel on one category axis, but panel '${data.panels[other].id}' has categories ${idLists[other].join(", ")} where panel '${data.panels[first].id}' has ${firstIds.join(", ")}`,
|
|
869
|
+
suggest: "give every panel the same category ids in the same order, or set options.sharedAxis to 'none' so each panel keeps its own axis. The independent axes can need more room; leave the height open or increase the chart size.",
|
|
870
|
+
field: ["data", "panels", other, "data", "categories"]
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
let uniformLineEndpointLegend = !1, keepEndNames = gridPanelsKeepEndNames(options), kpiValueSize, layoutPanel = (panel, panelIndex, slot, marginLR) => {
|
|
874
|
+
let def = getChart(panel.type);
|
|
875
|
+
if (!def)
|
|
876
|
+
throw new NormalizeError("unknown-type", `panels[${panel.id}].type`, `unknown chart type '${panel.type}'`);
|
|
877
|
+
let panelOpts = resolveCanvasOptions(panel.options ?? {}), authoredTitle = typeof panelOpts.title == "string" && panelOpts.title.trim().length > 0 ? panelOpts.title : void 0, panelCaption = panel.caption, tierDetail = compactTiers && typeof panelCaption == "string" && panelCaption.trim().length > 0 ? panelCaption.trim() : void 0, labels = compactTiers && panelIndex !== categoryOwner ? withoutCategoryLabels(panelOpts.labels) : panelOpts.labels, suppressTitle = compactTiers && panelOpts.title !== !1 && (authoredTitle !== void 0 || def.type === "variance"), opts = {
|
|
878
|
+
...def.defaults,
|
|
879
|
+
...panelOpts,
|
|
880
|
+
...hasKpiFigure(def.type) && kpiValueSize !== void 0 ? { [KPI_VALUE_SIZE]: kpiValueSize } : {},
|
|
881
|
+
...def.type === "kpi" ? { [KPI_HOST_TEXT]: stringsIn([panelCaption, panel.title, options.title, options.subtitle, options.footnotes, options.source]) } : {},
|
|
882
|
+
// The value is the panel count, so a tier knows whether it is the only one (isSingleVarianceTier).
|
|
883
|
+
...varianceTiers && def.type === "variance" ? { [VARIANCE_TIER]: data.panels.length } : {},
|
|
884
|
+
...compactTiers ? { ...suppressTitle ? { title: "" } : {}, ...labels !== void 0 ? { labels } : {} } : {},
|
|
885
|
+
...panel.annotations ? { annotations: panel.annotations } : {},
|
|
886
|
+
...legendInput && def.type === "column" ? { [/* @__PURE__ */ Symbol.for("boardplot.panelKeyed")]: !0 } : {},
|
|
887
|
+
...uniformLineEndpointLegend && def.type === "line" ? { gridEndpointIdentity: "legend" } : {},
|
|
888
|
+
target: options.target,
|
|
889
|
+
theme: panelOpts.theme ?? options.theme,
|
|
890
|
+
locale: panelOpts.locale ?? options.locale,
|
|
891
|
+
...hatchStrengthFor(panelOpts, options),
|
|
892
|
+
...options.strings ? { strings: { ...authoredStrings(options), ...panelOpts.strings } } : {},
|
|
893
|
+
size: { width: slot.w, height: slot.h },
|
|
894
|
+
...marginLR ? { margin: { ...panelOpts.margin, ...marginLR } } : {},
|
|
895
|
+
measure,
|
|
896
|
+
typeClass: panelTypeClass(options) ?? typeWidthClass(resolveSize(options.size).width)
|
|
897
|
+
}, probe = layoutChildChart(panel.data, opts, def.layout);
|
|
898
|
+
if (probe.refused) throw new GridChildRefusal(panel.id, probe);
|
|
899
|
+
let autoTierName = probe.derived.tierName, tierCaption = compactTiers && panelOpts.title !== !1 ? authoredTitle ?? (typeof autoTierName == "string" ? autoTierName : void 0) : void 0, tierFont = { family: theme.type.family, ...theme.type.axis }, tierReserve = compactTiers ? (tierCaption ? measure(tierCaption, tierFont).height : 0) + (tierCaption && tierDetail ? theme.space.labelPad : 0) + (tierDetail ? measure(tierDetail, tierFont).height : 0) + (tierCaption || tierDetail ? theme.space.labelPad : 0) : 0, childMargin = isRecord(opts.margin) ? opts.margin : {}, marginTop = typeof childMargin.top == "number" ? childMargin.top : 20, finalOptions = tierReserve > 0 ? { ...opts, margin: { ...childMargin, top: Math.max(marginTop, tierReserve) } } : opts, geo = tierReserve > marginTop ? layoutChildChart(panel.data, finalOptions, def.layout) : probe;
|
|
900
|
+
if (geo.refused) throw new GridChildRefusal(panel.id, geo);
|
|
901
|
+
if (options.target && tierReserve > 0)
|
|
902
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
903
|
+
let missing = Math.ceil(tierReserve - occupiedBounds(geo).y);
|
|
904
|
+
if (missing <= 0) break;
|
|
905
|
+
let margin2 = finalOptions.margin;
|
|
906
|
+
if (finalOptions = { ...finalOptions, margin: { ...margin2, top: (margin2?.top ?? marginTop) + missing } }, geo = layoutChildChart(panel.data, finalOptions, def.layout), geo.refused) throw new GridChildRefusal(panel.id, geo);
|
|
907
|
+
}
|
|
908
|
+
return {
|
|
909
|
+
def,
|
|
910
|
+
geo,
|
|
911
|
+
recordOptions: serializableOptions(finalOptions),
|
|
912
|
+
tierCaption,
|
|
913
|
+
...tierDetail ? { tierDetail } : {}
|
|
914
|
+
};
|
|
915
|
+
}, baseMargins = data.panels.map((p) => {
|
|
916
|
+
let m = resolveCanvasOptions(p.options ?? {}).margin;
|
|
917
|
+
return { left: m?.left ?? 28, right: m?.right ?? 28 };
|
|
918
|
+
}), sharedX, sharedW, landsOnEndpointLegend = (children) => children.some(
|
|
919
|
+
(child) => child.def?.type === "line" && child.geo.derived.endpointLabelEconomy?.strategy === "legend"
|
|
920
|
+
), alignedPanels = (children) => children.map((child, i) => ({
|
|
921
|
+
geometry: child.geo,
|
|
922
|
+
slot: slots[i],
|
|
923
|
+
margin: child.recordOptions.margin ?? {},
|
|
924
|
+
relayout: (margin2) => (Object.assign(child, layoutPanel(data.panels[i], i, slots[i], margin2)), child.geo)
|
|
925
|
+
})), alignSharedValues = (children) => {
|
|
926
|
+
let panels = alignedPanels(children), resolved = options[SCALE_GROUP_MEMBERS];
|
|
927
|
+
if (resolved) {
|
|
928
|
+
for (let ids of Object.values(resolved)) alignValuePanels(panels.filter((_, i) => ids.includes(data.panels[i].id)), theme);
|
|
929
|
+
return children;
|
|
930
|
+
}
|
|
931
|
+
let groups = new Set(data.panels.map((panel) => panel.options?.scaleGroup?.y));
|
|
932
|
+
for (let group of groups) group !== void 0 && alignValuePanels(panels.filter((_, i) => data.panels[i].options?.scaleGroup?.y === group), theme);
|
|
933
|
+
return children;
|
|
934
|
+
}, layoutChildren = () => {
|
|
935
|
+
if (share === "category" && n > 1) {
|
|
936
|
+
let pass1 = data.panels.map((p, i) => layoutPanel(p, i, slots[i], baseMargins[i]));
|
|
937
|
+
!uniformLineEndpointLegend && !keepEndNames && landsOnEndpointLegend(pass1) && (uniformLineEndpointLegend = !0, pass1 = data.panels.map((p, i) => layoutPanel(p, i, slots[i], baseMargins[i]))), sharedX = maxOf(pass1.map((c) => c.geo.plot.x));
|
|
938
|
+
let sharedR = minOf(pass1.map((c) => c.geo.plot.x + c.geo.plot.w));
|
|
939
|
+
sharedW = sharedR - sharedX;
|
|
940
|
+
let aligned = data.panels.map((p, i) => {
|
|
941
|
+
let c1 = pass1[i], effRight = typeof c1.geo.derived.rightInset == "number" ? c1.geo.derived.rightInset : baseMargins[i].right, effLeft = typeof c1.geo.derived.leftInset == "number" ? c1.geo.derived.leftInset : baseMargins[i].left;
|
|
942
|
+
return layoutPanel(p, i, slots[i], {
|
|
943
|
+
left: effLeft + (sharedX - c1.geo.plot.x),
|
|
944
|
+
right: effRight + (c1.geo.plot.x + c1.geo.plot.w - sharedR)
|
|
945
|
+
});
|
|
946
|
+
});
|
|
947
|
+
return alignCategoryPanels(alignedPanels(aligned), theme), alignSharedValues(aligned);
|
|
948
|
+
}
|
|
949
|
+
let children = data.panels.map((p, i) => layoutPanel(p, i, slots[i]));
|
|
950
|
+
return !uniformLineEndpointLegend && !keepEndNames && landsOnEndpointLegend(children) && (uniformLineEndpointLegend = !0, children = data.panels.map((p, i) => layoutPanel(p, i, slots[i]))), alignSharedValues(children);
|
|
951
|
+
}, measureTierContents = (laidOut) => {
|
|
952
|
+
let childContent = laidOut.map((child) => occupiedBounds(child.geo)), tierLabels = laidOut.map((child, index) => {
|
|
953
|
+
if (!child.tierCaption && !child.tierDetail) return;
|
|
954
|
+
let font = { family: theme.type.family, ...theme.type.axis }, titleSize = child.tierCaption ? measure(child.tierCaption, font) : void 0, detailSize = child.tierDetail ? measure(child.tierDetail, font) : void 0, lineGap = titleSize && detailSize ? theme.space.labelPad : 0, height = (titleSize?.height ?? 0) + lineGap + (detailSize?.height ?? 0), y = childContent[index].y - theme.space.labelPad - height, title = titleSize ? { x: 0, y, w: titleSize.width, h: titleSize.height } : void 0;
|
|
955
|
+
y += (titleSize?.height ?? 0) + lineGap;
|
|
956
|
+
let detail = detailSize ? { x: 0, y, w: detailSize.width, h: detailSize.height } : void 0, occupied2 = createOccupiedIndex({ x: 0, y: 0, w: child.geo.size.width, h: child.geo.size.height });
|
|
957
|
+
for (let claim of child.geo.debug.occupied)
|
|
958
|
+
occupied2.claim(claim.rect, claim.kind, claim.owner, claim.part);
|
|
959
|
+
let requests = [], candidates = (rect) => [
|
|
960
|
+
{ slot: "tierLeft", rect, penalty: 0 },
|
|
961
|
+
{ slot: "tierPlotLeft", rect: { ...rect, x: child.geo.plot.x }, penalty: 1 }
|
|
962
|
+
];
|
|
963
|
+
for (let [id, text, rect, priority] of [
|
|
964
|
+
["tier:caption", child.tierCaption, title, PRIORITY.total],
|
|
965
|
+
["tier:detail", child.tierDetail, detail, PRIORITY.valueLine]
|
|
966
|
+
])
|
|
967
|
+
text && rect && requests.push({
|
|
968
|
+
id,
|
|
969
|
+
kind: "axisTitle",
|
|
970
|
+
typeRole: "axis",
|
|
971
|
+
owner: {},
|
|
972
|
+
text,
|
|
973
|
+
lines: [text],
|
|
974
|
+
font,
|
|
975
|
+
priority,
|
|
976
|
+
candidates: candidates(rect)
|
|
977
|
+
});
|
|
978
|
+
let solved = solveLabels(requests, occupied2, {
|
|
979
|
+
density: "full",
|
|
980
|
+
pins: {},
|
|
981
|
+
measure,
|
|
982
|
+
plot: child.geo.plot,
|
|
983
|
+
canvas: { x: 0, y: 0, w: child.geo.size.width, h: child.geo.size.height },
|
|
984
|
+
darkInk: theme.color.ink,
|
|
985
|
+
lightInk: theme.color.inkInverse,
|
|
986
|
+
labelPad: theme.space.labelPad
|
|
987
|
+
});
|
|
988
|
+
for (let label of solved.placed) label.ink = { token: "inkMuted" };
|
|
989
|
+
return { font, solved };
|
|
990
|
+
}), localContent = childContent.map((bounds, index) => {
|
|
991
|
+
let placed = tierLabels[index]?.solved.placed.filter((label) => !label.hidden).map((label) => label.rect) ?? [];
|
|
992
|
+
return placed.length > 0 ? boundsOf([bounds, ...placed]) : bounds;
|
|
993
|
+
});
|
|
994
|
+
return { tierLabels, localContent };
|
|
995
|
+
}, packedTiers = share === "category" && data.panels.every((panel) => getChart(panel.type)?.sizing.fit !== "content"), packReserve = soloPanelReserve(share, data.panels), rowOf = (index) => share === "category" ? n - 1 - bottomUpOrder.indexOf(index) : Math.floor(index / columns), rowWeights = share === "category" ? [...bottomUpOrder].reverse().map((index) => tierWeights(data.panels)[index]) : Array(rows).fill(1), rowGaps = Array(rows - 1).fill(rowGap);
|
|
996
|
+
try {
|
|
997
|
+
let children = layoutChildren();
|
|
998
|
+
kpiValueSize = smallestKpiValueSize(children.map((child) => child.geo)), kpiValueSize !== void 0 && (children = layoutChildren());
|
|
999
|
+
let sizingChildren = () => children.map((child, i) => ({
|
|
1000
|
+
geometry: child.geo,
|
|
1001
|
+
row: rowOf(i),
|
|
1002
|
+
column: i % columns,
|
|
1003
|
+
rowSpan: 1,
|
|
1004
|
+
columnSpan: 1
|
|
1005
|
+
})), heights = gridRowHeights(area.h, sizingChildren(), rowWeights, rowGaps);
|
|
1006
|
+
if (heights) {
|
|
1007
|
+
let y = area.y, starts = heights.map((height, row) => {
|
|
1008
|
+
let start = y;
|
|
1009
|
+
return y += height + (rowGaps[row] ?? 0), start;
|
|
1010
|
+
});
|
|
1011
|
+
slots.forEach((slot, index) => {
|
|
1012
|
+
slot.y = starts[rowOf(index)], slot.h = heights[rowOf(index)];
|
|
1013
|
+
}), children = layoutChildren();
|
|
1014
|
+
}
|
|
1015
|
+
children = balanceVarianceTierPlots(slots, children, varianceWeights, layoutChildren);
|
|
1016
|
+
let tierContents = measureTierContents(children), effectiveTierGap = theme.space.tierGap, requirements = () => gridSizing(
|
|
1017
|
+
size,
|
|
1018
|
+
area,
|
|
1019
|
+
sizingChildren(),
|
|
1020
|
+
packedTiers ? [...bottomUpOrder].reverse().map((index) => children[index].geo.sizing.minHeight) : rowWeights,
|
|
1021
|
+
Array(columns).fill(1),
|
|
1022
|
+
rowGaps,
|
|
1023
|
+
Array(columns - 1).fill(gap),
|
|
1024
|
+
!0
|
|
1025
|
+
);
|
|
1026
|
+
if (packedTiers && requirements().minHeight <= size.height) {
|
|
1027
|
+
let weights = tierWeights(data.panels), wSum = weights.reduce((sum2, weight) => sum2 + weight, 0), gapFloor = Math.min(4, theme.space.tierGap), gapCapacity = (theme.space.tierGap - gapFloor) * (n - 1);
|
|
1028
|
+
for (let pass = 0; pass < TIER_SLACK_PASSES; pass++) {
|
|
1029
|
+
let slack = area.h - packReserve - theme.space.tierGap * (n - 1) - tierContents.localContent.reduce((sum2, bounds) => sum2 + bounds.h, 0);
|
|
1030
|
+
if (slack < 0 && slack >= -gapCapacity) {
|
|
1031
|
+
effectiveTierGap = theme.space.tierGap + slack / (n - 1);
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
if (slack <= theme.space.tierGap) break;
|
|
1035
|
+
let previousSlots = slots.map((slot) => ({ ...slot })), previousChildren = children, previousTierContents = tierContents, previousSharedX = sharedX, previousSharedW = sharedW, growth = Math.max(slack, wSum * theme.space.tierGap), accepted = !1;
|
|
1036
|
+
for (let backoff = 0; backoff < TIER_SLACK_BACKOFFS; backoff++) {
|
|
1037
|
+
previousSlots.forEach((slot, index) => {
|
|
1038
|
+
slots[index] = { ...slot };
|
|
1039
|
+
});
|
|
1040
|
+
let fraction = 2 ** -backoff;
|
|
1041
|
+
for (let i = 0; i < n; i++)
|
|
1042
|
+
slots[i] = { ...slots[i], h: slots[i].h + growth * fraction * weights[i] / wSum };
|
|
1043
|
+
children = balanceVarianceTierPlots(slots, layoutChildren(), varianceWeights, layoutChildren), tierContents = measureTierContents(children);
|
|
1044
|
+
let remaining = area.h - packReserve - theme.space.tierGap * (n - 1) - tierContents.localContent.reduce((sum2, bounds) => sum2 + bounds.h, 0);
|
|
1045
|
+
if (remaining >= -gapCapacity) {
|
|
1046
|
+
effectiveTierGap = remaining < 0 ? theme.space.tierGap + remaining / (n - 1) : theme.space.tierGap, accepted = !0;
|
|
1047
|
+
break;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
if (!accepted) {
|
|
1051
|
+
previousSlots.forEach((slot, index) => {
|
|
1052
|
+
slots[index] = slot;
|
|
1053
|
+
}), children = previousChildren, tierContents = previousTierContents, sharedX = previousSharedX, sharedW = previousSharedW;
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
let sizing = requirements(), { tierLabels, localContent } = tierContents, panelY = slots.map((slot) => slot.y);
|
|
1059
|
+
if (packedTiers) {
|
|
1060
|
+
let cursor = area.y + area.h;
|
|
1061
|
+
for (let i of bottomUpOrder) {
|
|
1062
|
+
let bounds = localContent[i];
|
|
1063
|
+
panelY[i] = cursor - (bounds.y + bounds.h), cursor = bounds.y + panelY[i] - effectiveTierGap;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
let scene = [...frameResult.nodes], labels = [], axes = [], annotations = [], occupiedAll = occupied.snapshot().slice(), decisions = [], marks = { panels: [] };
|
|
1067
|
+
children.forEach((child, i) => {
|
|
1068
|
+
let panel = data.panels[i], slot = slots[i], prefix = `${panel.id}/`, dx = slot.x, dy = panelY[i], geo = child.geo;
|
|
1069
|
+
appendPanelScene(scene, geo, panel.id, prefix, dx, dy);
|
|
1070
|
+
let noteData = panelNoteData(panel.type, panel.data, panel.options?.locale?.language), noteTexts = panelNoteTexts(geo, noteData, panel.options, panel.annotations);
|
|
1071
|
+
for (let label of geo.labels) {
|
|
1072
|
+
let noteText = noteTexts.texts.get(label.id);
|
|
1073
|
+
labels.push({
|
|
1074
|
+
...label,
|
|
1075
|
+
...noteText === void 0 ? {} : { noteText },
|
|
1076
|
+
...noteTexts.leftOut.has(label.id) ? { [LEFT_OUT_OF_NOTE]: !0 } : {},
|
|
1077
|
+
id: prefix + label.id,
|
|
1078
|
+
...label.claimId ? { claimId: prefix + label.claimId } : {},
|
|
1079
|
+
nodeId: label.nodeId ? prefix + label.nodeId : void 0,
|
|
1080
|
+
rect: { ...label.rect, x: label.rect.x + dx, y: label.rect.y + dy },
|
|
1081
|
+
backing: label.backing ? { ...label.backing, x: label.backing.x + dx, y: label.backing.y + dy } : void 0
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
for (let axis of geo.axes)
|
|
1085
|
+
axes.push({
|
|
1086
|
+
...axis,
|
|
1087
|
+
baselineNodeId: axis.baselineNodeId ? prefix + axis.baselineNodeId : void 0,
|
|
1088
|
+
ticks: axis.ticks.map((t) => ({
|
|
1089
|
+
...t,
|
|
1090
|
+
pos: t.pos + (axis.axis === "x" ? dx : dy),
|
|
1091
|
+
labelId: t.labelId ? prefix + t.labelId : void 0,
|
|
1092
|
+
gridNodeId: t.gridNodeId ? prefix + t.gridNodeId : void 0
|
|
1093
|
+
})),
|
|
1094
|
+
scenarioBands: axis.scenarioBands?.map((b) => ({
|
|
1095
|
+
...b,
|
|
1096
|
+
rect: { ...b.rect, x: b.rect.x + dx, y: b.rect.y + dy }
|
|
1097
|
+
}))
|
|
1098
|
+
});
|
|
1099
|
+
for (let ann of geo.annotations)
|
|
1100
|
+
annotations.push({
|
|
1101
|
+
...ann,
|
|
1102
|
+
id: prefix + ann.id,
|
|
1103
|
+
// The event anchor is a child-scene rect: move it with the panel.
|
|
1104
|
+
...ann.event?.anchor ? { event: { ...ann.event, anchor: { ...ann.event.anchor, x: ann.event.anchor.x + dx, y: ann.event.anchor.y + dy } } } : {},
|
|
1105
|
+
nodeIds: ann.nodeIds.map((id) => prefix + id),
|
|
1106
|
+
labelId: ann.labelId ? prefix + ann.labelId : void 0,
|
|
1107
|
+
// The label NODE is prefixed as a node (`<panel>/label:<id>`), not as a
|
|
1108
|
+
// labelId — see PlacedAnnotation.labelNodeId. Concatenating `label:`
|
|
1109
|
+
// onto the prefixed labelId names a node that does not exist.
|
|
1110
|
+
labelNodeId: ann.labelId ? prefix + (ann.labelNodeId ?? `label:${ann.labelId}`) : void 0
|
|
1111
|
+
});
|
|
1112
|
+
for (let occ of geo.debug.occupied)
|
|
1113
|
+
occupiedAll.push({ ...occ, rect: { ...occ.rect, x: occ.rect.x + dx, y: occ.rect.y + dy } });
|
|
1114
|
+
for (let d of geo.debug.decisions)
|
|
1115
|
+
decisions.push({ ...d, labelId: prefix + d.labelId });
|
|
1116
|
+
let warningOffset = warnings.length;
|
|
1117
|
+
for (let w of geo.warnings)
|
|
1118
|
+
warnings.push({ ...w, message: `[${panel.id}] ${w.message}` });
|
|
1119
|
+
let tier = tierLabels[i], titleNodeId, captionNodeId;
|
|
1120
|
+
for (let label of tier?.solved.placed ?? []) {
|
|
1121
|
+
let moved = {
|
|
1122
|
+
...label,
|
|
1123
|
+
id: prefix + label.id,
|
|
1124
|
+
...label.claimId ? { claimId: prefix + label.claimId } : {},
|
|
1125
|
+
rect: { ...label.rect, x: label.rect.x + dx, y: label.rect.y + dy }
|
|
1126
|
+
};
|
|
1127
|
+
if (label.hidden) {
|
|
1128
|
+
labels.push(moved);
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
let part = label.id === "tier:caption" ? "tierCaption" : "panelCaption", nodeId = `${prefix}${label.id}`;
|
|
1132
|
+
moved.nodeId = nodeId, labels.push(moved), scene.push({
|
|
1133
|
+
t: "text",
|
|
1134
|
+
typeRole: "axis",
|
|
1135
|
+
id: nodeId,
|
|
1136
|
+
x: moved.rect.x,
|
|
1137
|
+
y: moved.rect.y,
|
|
1138
|
+
lines: moved.lines,
|
|
1139
|
+
align: "start",
|
|
1140
|
+
font: tier.font,
|
|
1141
|
+
ink: moved.ink,
|
|
1142
|
+
owner: moved.owner,
|
|
1143
|
+
part,
|
|
1144
|
+
origin: { owner: moved.owner, panels: [panel.id] }
|
|
1145
|
+
}), occupiedAll.push({ rect: moved.rect, kind: "label", owner: moved.owner, part }), label.id === "tier:caption" ? titleNodeId = nodeId : captionNodeId = nodeId;
|
|
1146
|
+
}
|
|
1147
|
+
for (let decision of tier?.solved.decisions ?? [])
|
|
1148
|
+
decisions.push({ ...decision, labelId: prefix + decision.labelId });
|
|
1149
|
+
for (let warning of tier?.solved.warnings ?? [])
|
|
1150
|
+
warnings.push({ ...warning, message: `[${panel.id}] ${warning.message}` });
|
|
1151
|
+
let content = localContent[i];
|
|
1152
|
+
marks.panels.push({
|
|
1153
|
+
id: panel.id,
|
|
1154
|
+
type: panel.type,
|
|
1155
|
+
chart: { options: child.recordOptions, geometry: geo, offset: { x: dx, y: dy }, warningOffset, ...panel.options?.theme ? { theme: panel.options.theme } : {} },
|
|
1156
|
+
plot: { x: geo.plot.x + dx, y: geo.plot.y + dy, w: geo.plot.w, h: geo.plot.h },
|
|
1157
|
+
content: { x: content.x + dx, y: content.y + dy, w: content.w, h: content.h },
|
|
1158
|
+
title: child.tierCaption ?? (geo.a11y.title || child.def?.title || panel.id),
|
|
1159
|
+
...titleNodeId ? { titleNodeId } : {},
|
|
1160
|
+
...captionNodeId ? { captionNodeId } : {}
|
|
1161
|
+
});
|
|
1162
|
+
});
|
|
1163
|
+
let first = children[0].geo, compactNotes = children.flatMap((child) => child.geo.a11y.compactNotes ?? []);
|
|
1164
|
+
return {
|
|
1165
|
+
type: "grid",
|
|
1166
|
+
size,
|
|
1167
|
+
sizing,
|
|
1168
|
+
plot: area,
|
|
1169
|
+
scene,
|
|
1170
|
+
labels,
|
|
1171
|
+
axes,
|
|
1172
|
+
annotations,
|
|
1173
|
+
frame: frameResult.frame,
|
|
1174
|
+
legend: frameResult.legend,
|
|
1175
|
+
marks,
|
|
1176
|
+
derived: {
|
|
1177
|
+
sharedPlotX: sharedX,
|
|
1178
|
+
sharedPlotW: sharedW,
|
|
1179
|
+
...compactTiers ? { tierGap: effectiveTierGap } : {}
|
|
1180
|
+
},
|
|
1181
|
+
a11y: {
|
|
1182
|
+
title: accessibleTitle(options.title, chartString2(options, "gridChartsTitle", { v1: n })),
|
|
1183
|
+
counts: children.flatMap((child, i) => [...child.geo.a11y.counts ?? [], ...child.geo.a11y.titleCounts ?? []].filter((count) => marks.panels[i].title.includes(count.text))),
|
|
1184
|
+
desc: chartString2(options, "gridChartsDesc", { v1: share === "category" && n > 1 ? chartString2(options, "alignedExhibit") : chartString2(options, "chartGrid"), v2: marks.panels.map((p) => p.title).join("; "), v3: compactNotes.length > 0 ? chartString2(options, "notesClause", { v1: compactNotes.join("; ") }) : "" }),
|
|
1185
|
+
...compactNotes.length > 0 ? { compactNotes } : {}
|
|
1186
|
+
},
|
|
1187
|
+
warnings,
|
|
1188
|
+
debug: { occupied: occupiedAll, decisions }
|
|
1189
|
+
};
|
|
1190
|
+
} catch (error) {
|
|
1191
|
+
if (!(error instanceof GridChildRefusal)) throw error;
|
|
1192
|
+
let index = data.panels.findIndex((panel) => panel.id === error.panelId);
|
|
1193
|
+
return error.result(size, gridSizing(size, area, [{
|
|
1194
|
+
geometry: error.child,
|
|
1195
|
+
row: rowOf(index),
|
|
1196
|
+
column: index % columns,
|
|
1197
|
+
rowSpan: 1,
|
|
1198
|
+
columnSpan: 1
|
|
1199
|
+
}], rowWeights, Array(columns).fill(1), rowGaps, Array(columns - 1).fill(gap), !0), index);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
function appendPanelScene(scene, geometry, panelId, prefix, dx, dy) {
|
|
1203
|
+
let legendItems = new Map((geometry.legend?.items ?? []).flatMap((item) => [
|
|
1204
|
+
[item.swatchNodeId, item.id],
|
|
1205
|
+
[item.labelId, item.id]
|
|
1206
|
+
]));
|
|
1207
|
+
for (let node of geometry.scene) {
|
|
1208
|
+
let legendItem = node.origin?.legendItem ?? legendItems.get(node.id), moved = {
|
|
1209
|
+
...node,
|
|
1210
|
+
id: prefix + node.id,
|
|
1211
|
+
tx: (node.tx ?? 0) + dx,
|
|
1212
|
+
ty: (node.ty ?? 0) + dy,
|
|
1213
|
+
origin: {
|
|
1214
|
+
owner: node.origin?.owner ?? node.owner,
|
|
1215
|
+
panels: [panelId, ...node.origin?.panels ?? []],
|
|
1216
|
+
...legendItem === void 0 ? {} : { legendItem }
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
scene.push(moved);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
function withoutCategoryLabels(labels) {
|
|
1223
|
+
return labels === !1 ? !1 : { ...isRecord(labels) ? labels : {}, category: !1 };
|
|
1224
|
+
}
|
|
1225
|
+
function occupiedBounds(geometry) {
|
|
1226
|
+
let rects = geometry.debug.occupied.filter((item) => item.kind !== "reserved").map((item) => item.rect);
|
|
1227
|
+
if (rects.length === 0) return geometry.plot;
|
|
1228
|
+
let x1 = minOf(rects.map((rect) => rect.x)), y1 = minOf(rects.map((rect) => rect.y)), x2 = maxOf(rects.map((rect) => rect.x + rect.w)), y2 = maxOf(rects.map((rect) => rect.y + rect.h));
|
|
1229
|
+
return { x: x1, y: y1, w: x2 - x1, h: y2 - y1 };
|
|
1230
|
+
}
|
|
1231
|
+
function panelValueFootnotes(options) {
|
|
1232
|
+
let named = options[PANEL_VALUE_NOTE] ?? [];
|
|
1233
|
+
return named.length === 0 || options.footnotes === !1 ? {} : { footnotes: [...frameTextOptions(options).footnotes ?? [], ...valueNoteLine(chartString2(options, "valuesNotOnColumns"), named, options)] };
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// src/core/charts/grid/layout.ts
|
|
1237
|
+
function assertTrackLimits(options, panels = []) {
|
|
1238
|
+
let refuse = (field, what) => {
|
|
1239
|
+
throw new NormalizeError("grid-too-many-tracks", field, `${what} is over the limit of ${50} tracks`, `use at most ${50} row tracks and ${50} column tracks`);
|
|
1240
|
+
}, over = (value) => typeof value == "number" && !(value <= 50);
|
|
1241
|
+
over(options.columns) && refuse("options.columns", `options.columns ${options.columns}`), Array.isArray(options.columns) && options.columns.length > 50 && refuse("options.columns", "options.columns"), Array.isArray(options.rows) && options.rows.length > 50 && refuse("options.rows", "options.rows"), panels.forEach((panel, index) => {
|
|
1242
|
+
let reach = (start, span) => (start ?? 0) + (span ?? 1);
|
|
1243
|
+
over(reach(panel.row, panel.span?.rows)) && refuse(`panels[${index}]`, `panels[${index}] reaching row ${reach(panel.row, panel.span?.rows)}`), over(reach(panel.column, panel.span?.columns)) && refuse(`panels[${index}]`, `panels[${index}] reaching column ${reach(panel.column, panel.span?.columns)}`);
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
function layoutGrid2(data, options = {}) {
|
|
1247
|
+
options = resolveCanvasOptions(options), assertTrackLimits(options);
|
|
1248
|
+
let metricStack = isMetricStackData(data), formatWarnings = options.format === void 0 ? [] : [{
|
|
1249
|
+
code: "format-unused",
|
|
1250
|
+
severity: "warn",
|
|
1251
|
+
field: ["options", "format"],
|
|
1252
|
+
message: "Grid-level options.format is ignored in this release and will be refused in the next release",
|
|
1253
|
+
suggest: metricStack ? "Set decimals and divisor on each metric stack panel; remove the grid-level format." : "Set format on each numeric panel in data.panels[].options.format; remove the grid-level format.",
|
|
1254
|
+
fix: [{ op: "remove", path: "/options/format" }]
|
|
1255
|
+
}];
|
|
1256
|
+
if (metricStack)
|
|
1257
|
+
return requireChartCores(data.panels.map((panel) => panel.type), (type) => getChart(type) !== void 0), withWarnings(layoutMetricStack(data, options), formatWarnings);
|
|
1258
|
+
options.stack && stackError("data", "Metric stack mode needs shared categories and measures");
|
|
1259
|
+
let normalized = normalizeGridData(data);
|
|
1260
|
+
requireChartCores(normalized.panels.map((panel) => panel.type), (type) => getChart(type) !== void 0), assertTrackLimits(options, normalized.panels), normalized.panels = normalized.panels.map((panel) => panel.options ? { ...panel, options: resolveCanvasOptions(panel.options) } : panel);
|
|
1261
|
+
let authored = usesAuthoredLayout(normalized.panels, options);
|
|
1262
|
+
authored && normalized.rowCaption && (normalized.panels = normalized.panels.map((panel) => ({ ...panel, caption: panel.caption ?? normalized.rowCaption })), delete normalized.rowCaption), options = { ...options, sharedAxis: gridShare(normalized.panels, options.sharedAxis) };
|
|
1263
|
+
let ordered = orderPanels(normalized.panels, options, authored);
|
|
1264
|
+
if (pushAll(ordered.warnings, formatWarnings), options.sharedScale === !0) {
|
|
1265
|
+
let charts = ordered.panels.filter((panel) => panel.type !== "text" && panel.type !== "legend"), semantics = charts.map(panelScaleSemantics), first = semantics[0], matching = first != null && semantics.every((candidate) => candidate !== null && candidate.unit === first.unit && candidate.format === first.format);
|
|
1266
|
+
if (charts.length > 1 && !matching)
|
|
1267
|
+
throw new NormalizeError(
|
|
1268
|
+
"scale-mix",
|
|
1269
|
+
"options.sharedScale",
|
|
1270
|
+
"sharedScale:true needs matching unit and format on every numeric panel",
|
|
1271
|
+
"drop sharedScale, set sharedScale:false, or give every panel the same unit and format"
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
let legacy = (at) => layoutLegacyGrid({ ...normalized, panels: ordered.panels }, at), legacyGrid = (at) => withSliverRoom(withOnePanelContent(withTierPlot(legacy(at), ordered.panels, at), legacy, ordered.panels, at), legacy, at, data), geometry = withWarnings(authored ? layoutAuthoredGrid(ordered.panels, options, normalized.repeatFacet === !0) : legacyGrid(reflowed(legacyGrid, ordered.panels, options, data)), ordered.warnings);
|
|
1275
|
+
return !geometry.refused && heightOmitted(options.size) && geometry.sizing?.fit === "content" && Math.abs(geometry.size.height - geometry.sizing.naturalHeight) > 1 ? layoutGrid2(data, { ...options, size: { width: geometry.size.width, height: geometry.sizing.naturalHeight } }) : withCardFloor(geometry, ordered.panels.map((panel) => panel.type), options);
|
|
1276
|
+
}
|
|
1277
|
+
var seats = (geometry, height) => !geometry.refused && (geometry.sizing?.minHeight ?? 0) <= height, strideLosses = (geometry) => geometry.refused ? Number.POSITIVE_INFINITY : geometry.warnings.filter((warning) => warning.code === "category-stride").length;
|
|
1278
|
+
function reflowed(relayout, panels, options, data) {
|
|
1279
|
+
let columns = options.columns, width = resolveSize(options.size).width;
|
|
1280
|
+
if (options.reflow === !1 || typeof columns != "number" || columns < 3 || panels.length <= columns || width >= CARD_CLASS_WIDTH || legacyGridForm(panels, options) !== "facets") return options;
|
|
1281
|
+
let height = options[TARGET_SIZE]?.fixed.height ?? !heightOmitted(options.size) ? resolveSize(options.size).height : void 0, choose = () => {
|
|
1282
|
+
let open = (count) => strideLosses(relayout({ ...options, columns: count, size: { width } }));
|
|
1283
|
+
if (open(columns) === 0) return columns;
|
|
1284
|
+
for (let fewer = columns - 1; fewer >= 2; fewer--)
|
|
1285
|
+
if (open(fewer) === 0 && (height === void 0 || seats(relayout({ ...options, columns: fewer }), height))) return fewer;
|
|
1286
|
+
return columns;
|
|
1287
|
+
}, { size: _size, measure, ...rest } = options, key = `${width}:${height ?? "auto"}:${currentSmallValues()}:${themeRegistrations()}:${JSON.stringify(rest)}:${JSON.stringify(data)}`, cache = REFLOW_CACHE.get(measure ?? DEFAULT_MEASURER);
|
|
1288
|
+
cache || REFLOW_CACHE.set(measure ?? DEFAULT_MEASURER, cache = /* @__PURE__ */ new Map()), cache.has(key) || (cache.size >= REFLOW_CACHE_SIZE && cache.delete(cache.keys().next().value), cache.set(key, choose()));
|
|
1289
|
+
let chosen = cache.get(key);
|
|
1290
|
+
return chosen === columns ? options : { ...options, columns: chosen };
|
|
1291
|
+
}
|
|
1292
|
+
var REFLOW_CACHE = /* @__PURE__ */ new WeakMap(), DEFAULT_MEASURER = {}, REFLOW_CACHE_SIZE = 64, SLIVER_HIDDEN = "sliver-labels-hidden";
|
|
1293
|
+
function sliversHidden(probe) {
|
|
1294
|
+
return probe.warnings.some((warning) => warning.code === SLIVER_HIDDEN) || (probe.labels ?? []).some((label) => label[DIGIT_SEAT] !== void 0);
|
|
1295
|
+
}
|
|
1296
|
+
var SLIVER_ROOM_STEP = 4, SLIVER_ROOM_MAX = 1.3;
|
|
1297
|
+
function withSliverRoom(geometry, relayout, options, data) {
|
|
1298
|
+
let sizing = geometry.sizing, hides = sliversHidden;
|
|
1299
|
+
if (!sizing || sizing.fit === "content" || geometry.refused || !hides(geometry) || (options.sharedAxis === "category" || options.sharedAxis === void 0 ? 1 : Math.max(1, Number(options.columns ?? 1))) > 1 || geometry.marks.panels.filter((panel) => panel.chart).length !== 1) return geometry;
|
|
1300
|
+
let { width, height } = geometry.size, at = (h) => relayout({ ...options, size: { ...resolveSize(options.size), width, height: h } }), start = Math.max(height, sizing.naturalHeight), withNatural = (found) => found === void 0 ? geometry : { ...geometry, sizing: { ...sizing, naturalHeight: found } }, { size: _size, measure, ...rest } = options, key = `${width}:${start}:${currentSmallValues()}:${themeRegistrations()}:${JSON.stringify(rest)}:${JSON.stringify(data)}`, cache = SLIVER_ROOM_CACHE.get(measure ?? DEFAULT_MEASURER);
|
|
1301
|
+
return cache || SLIVER_ROOM_CACHE.set(measure ?? DEFAULT_MEASURER, cache = /* @__PURE__ */ new Map()), cache.has(key) || (cache.size >= SLIVER_ROOM_CACHE_SIZE && cache.delete(cache.keys().next().value), cache.set(key, sliverRoomHeight(start, height, at, hides))), withNatural(cache.get(key));
|
|
1302
|
+
}
|
|
1303
|
+
var SLIVER_ROOM_CACHE = /* @__PURE__ */ new WeakMap(), SLIVER_ROOM_CACHE_SIZE = 64;
|
|
1304
|
+
function sliverRoomHeight(start, height, at, hides) {
|
|
1305
|
+
if (start !== height) {
|
|
1306
|
+
let probe = at(start);
|
|
1307
|
+
if (probe.refused || !hides(probe)) return;
|
|
1308
|
+
}
|
|
1309
|
+
let low = start, high = Math.floor(start * SLIVER_ROOM_MAX), top = at(high);
|
|
1310
|
+
if (!(top.refused || hides(top))) {
|
|
1311
|
+
for (; high - low > SLIVER_ROOM_STEP; ) {
|
|
1312
|
+
let mid = Math.floor((low + high) / 2), probe = at(mid);
|
|
1313
|
+
!probe.refused && !hides(probe) ? high = mid : low = mid;
|
|
1314
|
+
}
|
|
1315
|
+
return high;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
var STANDALONE_COMPACT = /* @__PURE__ */ new Set(["bullet", "pie", "slope"]), panelCompacts = (type) => !STANDALONE_COMPACT.has(type) && type !== "grid" && (getChart(type)?.sizing ?? chartSizing(type)).compactFloor !== void 0;
|
|
1319
|
+
function withCardFloor(geometry, types, options) {
|
|
1320
|
+
if (geometry.refused) return geometry;
|
|
1321
|
+
let sizing = geometry.sizing;
|
|
1322
|
+
if (sizing && options.mode === "compact" && geometry.size.width < CARD_CLASS_WIDTH && sizing.minWidth > Math.max(CARD_MIN_WIDTH, sizing.measuredMinWidth)) {
|
|
1323
|
+
let minWidth = Math.max(CARD_MIN_WIDTH, sizing.measuredMinWidth);
|
|
1324
|
+
return { ...geometry, sizing: { ...sizing, minWidth, comfortableWidth: Math.ceil(minWidth * 1.25) } };
|
|
1325
|
+
}
|
|
1326
|
+
let charts = types.filter((type) => type !== "text" && type !== "legend");
|
|
1327
|
+
return !sizing || sizing.minWidth <= CARD_MIN_WIDTH || charts.length === 0 || !charts.every(panelCompacts) ? geometry : { ...geometry, sizing: { ...sizing, minWidth: CARD_MIN_WIDTH, measuredMinWidth: Math.min(sizing.measuredMinWidth, CARD_MIN_WIDTH), comfortableWidth: Math.ceil(CARD_MIN_WIDTH * 1.25) } };
|
|
1328
|
+
}
|
|
1329
|
+
function compactPanelMode(panel, canvasWidth) {
|
|
1330
|
+
return panel.type === "text" || panel.type === "legend" || panel.options?.mode !== void 0 ? {} : panelCompacts(panel.type) && canvasWidth < CARD_CLASS_WIDTH ? { mode: "compact" } : {};
|
|
1331
|
+
}
|
|
1332
|
+
function withWarnings(geometry, warnings) {
|
|
1333
|
+
return warnings.length === 0 ? geometry : { ...geometry, warnings: [...geometry.warnings ?? [], ...warnings] };
|
|
1334
|
+
}
|
|
1335
|
+
function orderPanels(panels, options, authored) {
|
|
1336
|
+
let order = options.panelOrder ?? "sheet";
|
|
1337
|
+
if (order === "sheet" || options.sharedAxis === "category") return { panels, warnings: [] };
|
|
1338
|
+
if (authored)
|
|
1339
|
+
return {
|
|
1340
|
+
panels,
|
|
1341
|
+
warnings: [
|
|
1342
|
+
{
|
|
1343
|
+
code: "panel-order-authored-placement",
|
|
1344
|
+
severity: "warn",
|
|
1345
|
+
message: `panelOrder '${order}' is ignored: this grid places its panels with authored row/column coordinates, so the array order does not decide what sits where`,
|
|
1346
|
+
suggest: "remove the authored row/column coordinates, or drop panelOrder"
|
|
1347
|
+
}
|
|
1348
|
+
]
|
|
1349
|
+
};
|
|
1350
|
+
let key = (panel) => {
|
|
1351
|
+
let data = panel.data, series = data?.series;
|
|
1352
|
+
if (!Array.isArray(series)) return null;
|
|
1353
|
+
let categories = Array.isArray(data?.categories) ? data.categories.map(normalizeCategory) : void 0, normalized = categories ? series.map((entry, si) => ({ ...entry, values: normalizeSeriesValues(entry, categories, si) })) : series;
|
|
1354
|
+
categories && (panel.data = { ...data, categories, series: normalized });
|
|
1355
|
+
let measured = normalized.filter((entry) => entry?.role !== "reference"), total = null;
|
|
1356
|
+
for (let entry of measured) {
|
|
1357
|
+
let values = Array.isArray(entry.values) ? entry.values : [], cells = order.startsWith("last") ? values.slice(-1) : values;
|
|
1358
|
+
for (let cell of cells) {
|
|
1359
|
+
let value = cellValue(cell);
|
|
1360
|
+
value !== null && (total = (total ?? 0) + value);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return total;
|
|
1364
|
+
}, keys = new Map(panels.map((panel, index) => [index, key(panel)])), descending = order.endsWith("Desc"), sorted = panels.map((panel, index) => ({ panel, index })).sort((left, right) => {
|
|
1365
|
+
let a = keys.get(left.index) ?? null, b = keys.get(right.index) ?? null;
|
|
1366
|
+
return a === null && b === null ? left.index - right.index : a === null ? 1 : b === null ? -1 : a !== b ? descending ? b - a : a - b : left.index - right.index;
|
|
1367
|
+
}).map((entry) => entry.panel), unmeasured = panels.filter((_, index) => keys.get(index) === null), warnings = unmeasured.length === 0 ? [] : [
|
|
1368
|
+
{
|
|
1369
|
+
code: "panel-order-unmeasured",
|
|
1370
|
+
severity: "info",
|
|
1371
|
+
message: `panelOrder '${order}' could not rank ${unmeasured.length} panel(s) with no numeric value; they keep authored order at the end`
|
|
1372
|
+
}
|
|
1373
|
+
];
|
|
1374
|
+
return { panels: sorted, warnings };
|
|
1375
|
+
}
|
|
1376
|
+
function gridTypeClass(options) {
|
|
1377
|
+
return panelTypeClass(options) ?? typeWidthClass(resolveSize(options.size).width);
|
|
1378
|
+
}
|
|
1379
|
+
function measuredCaption(text, font, width, measure) {
|
|
1380
|
+
let lines = wrapText(text, font, width, Number.MAX_SAFE_INTEGER, measure).lines, sizes = lines.map((line) => measure(line, font));
|
|
1381
|
+
return {
|
|
1382
|
+
lines,
|
|
1383
|
+
width: Math.max(...sizes.map((size) => size.width)),
|
|
1384
|
+
height: Math.max(...sizes.map((size) => size.height)) + (lines.length - 1) * font.size * (font.lineHeight ?? 1.2)
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
function panelCaptionBand(panel, theme, measure, slot, highlighted, compact = !1, shift = 0) {
|
|
1388
|
+
let margin = isRecord(panel.options?.margin) ? panel.options.margin : {}, sides = canvasMargin(theme, slot.w), x = slot.x + numeric(margin.left, sides.left), y = slot.y + numeric(margin.top, 20) - measureCaptionBand(panel, theme, measure, slot.w, compact) + shift, nodes = [], claims = [];
|
|
1389
|
+
for (let [part, value, font, ink] of [
|
|
1390
|
+
[compact ? "tierCaption" : "panelTitle", panel.title, compact ? { family: theme.type.family, ...theme.type.axis } : { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) }, { token: compact ? "inkMuted" : highlighted.size === 0 || highlighted.has(panel.id) ? "ink" : "inkMuted" }],
|
|
1391
|
+
["panelCaption", panel.caption, { family: theme.type.family, ...theme.type.axis }, { token: "inkMuted" }]
|
|
1392
|
+
]) {
|
|
1393
|
+
if (!value) continue;
|
|
1394
|
+
let width = Math.max(1, slot.w - numeric(margin.left, sides.left) - numeric(margin.right, sides.right)), text = measuredCaption(value, font, width, measure), { lines } = text, id = `panel:${panel.id}:${part === "panelCaption" ? "caption" : "title"}`, rect = { x, y, w: text.width, h: text.height }, occupied = createOccupiedIndex(rect), solved = solveLabels([{
|
|
1395
|
+
id,
|
|
1396
|
+
kind: "annotation",
|
|
1397
|
+
typeRole: "axis",
|
|
1398
|
+
owner: {},
|
|
1399
|
+
text: value,
|
|
1400
|
+
lines,
|
|
1401
|
+
font,
|
|
1402
|
+
priority: PRIORITY.total,
|
|
1403
|
+
candidates: [{ slot: "panelCaption", rect, penalty: 0 }],
|
|
1404
|
+
role: "note"
|
|
1405
|
+
}], occupied, {
|
|
1406
|
+
density: "full",
|
|
1407
|
+
pins: {},
|
|
1408
|
+
measure,
|
|
1409
|
+
plot: rect,
|
|
1410
|
+
canvas: rect,
|
|
1411
|
+
darkInk: theme.color.ink,
|
|
1412
|
+
lightInk: theme.color.inkInverse,
|
|
1413
|
+
labelPad: 0
|
|
1414
|
+
});
|
|
1415
|
+
pushAll(nodes, labelsToNodes(theme, solved.placed.map((label) => ({ ...label, capHeight: void 0 })), () => font).map((node) => node.t === "text" ? { ...node, ink, part } : node)), claims.push({ rect, kind: "frame", owner: {} }), y += text.height + 2;
|
|
1416
|
+
}
|
|
1417
|
+
return { nodes, claims };
|
|
1418
|
+
}
|
|
1419
|
+
function shareRowGridlines(geometry, columns) {
|
|
1420
|
+
let panels = geometry.marks.panels;
|
|
1421
|
+
for (let start = 0; start < panels.length; start += columns) {
|
|
1422
|
+
let first = panels[start], source = first?.chart?.geometry.plot;
|
|
1423
|
+
if (!first || !source) continue;
|
|
1424
|
+
let lines = geometry.scene.filter((node) => node.t === "line" && node.part === "gridline" && node.id.startsWith(`${first.id}/`));
|
|
1425
|
+
for (let panel of panels.slice(start + 1, start + columns)) {
|
|
1426
|
+
let chart = panel.chart;
|
|
1427
|
+
if (!chart) continue;
|
|
1428
|
+
let plot = chart.geometry.plot, at = (y) => plot.y + (y - source.y) * (plot.h / Math.max(1, source.h)), copies = lines.map((line) => ({
|
|
1429
|
+
...line,
|
|
1430
|
+
id: `${panel.id}/${line.id.slice(first.id.length + 1)}`,
|
|
1431
|
+
owner: {},
|
|
1432
|
+
x1: plot.x,
|
|
1433
|
+
x2: plot.x + plot.w,
|
|
1434
|
+
y1: at(line.y1),
|
|
1435
|
+
y2: at(line.y2),
|
|
1436
|
+
tx: chart.offset.x,
|
|
1437
|
+
ty: chart.offset.y
|
|
1438
|
+
})), index = geometry.scene.findIndex((node) => node.id.startsWith(`${panel.id}/`)), tail = geometry.scene.splice(index < 0 ? geometry.scene.length : index);
|
|
1439
|
+
pushAll(geometry.scene, copies), pushAll(geometry.scene, tail);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
var SHARED_AXIS_EDGE = 8, FACET_PLOT_SHARE = 0.5, FACET_COLUMN_SHARE = 0.85, FACET_HEAD_TOP = 5, FACET_HEAD_PULL = 11;
|
|
1444
|
+
function facetSpan(geometry) {
|
|
1445
|
+
let plot = geometry.plot, bars = geometry.marks?.bars, tops = Array.isArray(bars) ? bars.flatMap((bar) => bar.rect && bar.rect.h > 0 ? [bar.rect.y] : []) : [];
|
|
1446
|
+
return tops.length > 0 ? plot.y + plot.h - minOf(tops) : plot.h;
|
|
1447
|
+
}
|
|
1448
|
+
function facetPlotHeight(width, share, rowCount) {
|
|
1449
|
+
return Math.max(share * width, rowCount === 1 ? 0.5 * width + 90 : 0);
|
|
1450
|
+
}
|
|
1451
|
+
var ROW_CAPTION_TOP = 6;
|
|
1452
|
+
function legacyGridForm(panels, options) {
|
|
1453
|
+
let category = (options.sharedAxis ?? "category") === "category";
|
|
1454
|
+
return category && panels.length > 1 ? "tiers" : (category ? 1 : Math.max(1, Number(options.columns ?? 1))) > 1 && panels.length > 1 && new Set(panels.map((panel) => panel.type)).size === 1 && chartSizing(panels[0].type).fit === "fill" ? "facets" : "panels";
|
|
1455
|
+
}
|
|
1456
|
+
function compactStacks(data, options = {}) {
|
|
1457
|
+
if (isMetricStackData(data) || options.anchors !== void 0 || options.alignmentRules !== void 0) return !1;
|
|
1458
|
+
let { panels: placed, ...rest } = data, key = Array.isArray(placed) ? JSON.stringify([
|
|
1459
|
+
options.columns,
|
|
1460
|
+
options.rows,
|
|
1461
|
+
options.gutters,
|
|
1462
|
+
options.sharedAxis,
|
|
1463
|
+
rest,
|
|
1464
|
+
placed.map((panel) => [panel.type, panel.row, panel.column, panel.span, panel.align, panel.options?.variant])
|
|
1465
|
+
]) : void 0, answer = key === void 0 ? void 0 : COMPACT_STACKS.get(key);
|
|
1466
|
+
if (answer === void 0) {
|
|
1467
|
+
let { panels } = normalizeGridData(data), authored = Array.isArray(options.columns) ? options.columns.length : options.columns ?? (options.rows ? Math.ceil(panels.length / options.rows.length) : Math.ceil(Math.sqrt(panels.length)));
|
|
1468
|
+
answer = usesAuthoredLayout(panels, options) && gridShare(panels, options.sharedAxis) !== "category" && Math.max(authored, ...panels.map((panel) => (panel.column ?? 0) + (panel.span?.columns ?? 1))) >= 2, key !== void 0 && (COMPACT_STACKS.size >= 64 && COMPACT_STACKS.delete(COMPACT_STACKS.keys().next().value), COMPACT_STACKS.set(key, answer));
|
|
1469
|
+
}
|
|
1470
|
+
return answer;
|
|
1471
|
+
}
|
|
1472
|
+
var COMPACT_STACKS = /* @__PURE__ */ new Map();
|
|
1473
|
+
function gridFormOf(data, options = {}) {
|
|
1474
|
+
if (isMetricStackData(data)) return "metric-stack";
|
|
1475
|
+
let { panels } = normalizeGridData(data);
|
|
1476
|
+
return usesAuthoredLayout(panels, options) ? "panels" : legacyGridForm(panels, { ...options, sharedAxis: gridShare(panels, options.sharedAxis) });
|
|
1477
|
+
}
|
|
1478
|
+
function layoutLegacyGrid(normalized, options) {
|
|
1479
|
+
let theme = themeForWidth(resolveTheme(options.theme), gridTypeClass(options)), measure = options.measure ?? defaultMeasurer, groupResult = resolveSharedYDomains(normalized.panels, options, normalized.repeatFacet === !0), form = legacyGridForm(groupResult.panels, options), compactTiers = form === "tiers", canvasWidth = resolveSize(options.size).width, gridMargin = { ...canvasMargin(theme, canvasWidth), ...options.margin }, columns = options.sharedAxis === "category" || options.sharedAxis === void 0 ? 1 : Math.max(1, Number(options.columns ?? 1)), facets = form === "facets", sharedAxis = facets && sharedYGroup(groupResult.panels) !== null && groupResult.panels.every((panel) => {
|
|
1480
|
+
let axis = panel.options?.valueAxis;
|
|
1481
|
+
return isRecord(axis) && axis.show === !0;
|
|
1482
|
+
}), rowCaption = facets ? normalized.rowCaption : void 0, facetHeads = facets && !sharedAxis, headedGaps = facetHeads ? facetHeadedGaps(theme.space.facetGap, canvasWidth) : void 0, gap = columns === 1 ? theme.space.tierGap : headedGaps?.column ?? theme.space.facetGap, slotWidth = (canvasWidth - gridMargin.left - gridMargin.right - gap * (columns - 1)) / columns, rowCaptionFont = { family: theme.type.family, ...theme.type.axis }, rowCaptionHeight = rowCaption ? measuredCaption(rowCaption, rowCaptionFont, canvasWidth - gridMargin.left - gridMargin.right, measure).height + 6 : 0, preparedPanels = groupResult.panels.map((authoredPanel, index) => {
|
|
1483
|
+
let childTitle = authoredPanel.options?.title, panel = facets && authoredPanel.title === void 0 && typeof childTitle == "string" && childTitle.trim().length > 0 ? { ...authoredPanel, title: childTitle, options: Object.fromEntries(Object.entries(authoredPanel.options).filter(([key]) => key !== "title")) } : authoredPanel, captionHeight = compactTiers ? 0 : measureCaptionBand(panel, theme, measure, slotWidth), panelOptions = panel.options ?? {}, margin = isRecord(panelOptions.margin) ? panelOptions.margin : {}, { title: panelTitle, ...panelWithoutTitle } = panel, axis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, firstRow = index < columns, headTop = facetHeads ? FACET_HEAD_TOP : 20, pull = facetHeads && captionHeight > 0 ? FACET_HEAD_PULL : 0;
|
|
1484
|
+
return {
|
|
1485
|
+
...compactTiers ? panelWithoutTitle : panel,
|
|
1486
|
+
options: {
|
|
1487
|
+
...panelOptions,
|
|
1488
|
+
...sharedAxis ? { valueAxis: { ...axis, gridlines: axis.gridlines ?? !0, ...index % columns === 0 ? {} : { show: !1 } } } : {},
|
|
1489
|
+
...compactTiers && panelOptions.title === void 0 && panelTitle ? { title: panelTitle } : {},
|
|
1490
|
+
...options.palette !== void 0 && panelOptions.palette === void 0 ? { palette: options.palette } : {},
|
|
1491
|
+
...compactPanelMode(panel, canvasWidth),
|
|
1492
|
+
// Facets: the grid's canvas margin and gutter are the panel's side margins; a
|
|
1493
|
+
// facet adds none of its own, so its plot spans the panel.
|
|
1494
|
+
// A compact panel on a narrow card spends no width on side margins either.
|
|
1495
|
+
margin: { ...facets ? { left: 0, right: 0, bottom: 0 } : compactPanelMode(panel, canvasWidth).mode ? { left: 0, right: 0 } : {}, ...margin, top: numeric(margin.top, firstRow && rowCaptionHeight > 0 ? ROW_CAPTION_TOP : headTop) + captionHeight + (firstRow ? rowCaptionHeight : 0) - pull }
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
}), members = Object.fromEntries(Object.entries(groupResult.members).filter(([group]) => group !== DEFAULT_Y_GROUP && groupResult.domains[group])), composeOptions = { ...options, [SCALE_GROUP_MEMBERS]: members, ...headedGaps ? { [FACET_GAPS]: headedGaps } : {} }, geometry = layoutGrid(
|
|
1499
|
+
{ panels: preparedPanels },
|
|
1500
|
+
composeOptions
|
|
1501
|
+
);
|
|
1502
|
+
if (geometry.refused) return geometry;
|
|
1503
|
+
if (sharedAxis) {
|
|
1504
|
+
let reserve = Math.max(0, maxOf(geometry.marks.panels.filter((_, index) => index % columns === 0).map((panel) => panel.chart?.geometry.plot.x ?? 0))), hang = Math.min(reserve, Math.max(0, gridMargin.left - SHARED_AXIS_EDGE));
|
|
1505
|
+
if (hang > 0 && (geometry = layoutGrid(
|
|
1506
|
+
{ panels: preparedPanels.map((panel, index) => index % columns === 0 ? { ...panel, options: { ...panel.options, margin: { ...panel.options.margin, left: -hang } } } : panel) },
|
|
1507
|
+
composeOptions
|
|
1508
|
+
)), geometry.refused) return geometry;
|
|
1509
|
+
shareRowGridlines(geometry, columns);
|
|
1510
|
+
}
|
|
1511
|
+
let slots = geometry.marks.panels.map((panel) => ({
|
|
1512
|
+
...geometry.plot,
|
|
1513
|
+
...(options.sharedAxis ?? "category") !== "category" && panel.chart ? { x: panel.chart.offset.x, y: panel.chart.offset.y, w: slotWidth } : {}
|
|
1514
|
+
})), captionSlots = compactTiers ? [] : preparedPanels.map((panel, index) => ({ panel, slot: slots[index] })), captionNodes = [], captionClaims = [], highlighted = new Set(
|
|
1515
|
+
resolveHighlight(options.highlight).filter((id) => preparedPanels.some((panel) => panel.id === id))
|
|
1516
|
+
), facetPull = facetHeads && preparedPanels[0] && measureCaptionBand(preparedPanels[0], theme, measure, slotWidth) > 0 ? FACET_HEAD_PULL : 0;
|
|
1517
|
+
if (rowCaption && preparedPanels.length > 0) {
|
|
1518
|
+
let first = preparedPanels[0], top = numeric(first.options.margin.top, 20) - measureCaptionBand(first, theme, measure, slotWidth), band = panelCaptionBand(
|
|
1519
|
+
{ id: "grid", type: "text", data: {}, caption: rowCaption, options: { margin: { left: 0, right: 0, top } } },
|
|
1520
|
+
theme,
|
|
1521
|
+
measure,
|
|
1522
|
+
{ ...slots[0], w: canvasWidth - gridMargin.left - gridMargin.right },
|
|
1523
|
+
highlighted,
|
|
1524
|
+
!1,
|
|
1525
|
+
facetPull
|
|
1526
|
+
);
|
|
1527
|
+
pushAll(captionNodes, band.nodes), pushAll(captionClaims, band.claims);
|
|
1528
|
+
}
|
|
1529
|
+
for (let entry of captionSlots) {
|
|
1530
|
+
let band = panelCaptionBand(entry.panel, theme, measure, entry.slot, highlighted, !1, facetHeads && measureCaptionBand(entry.panel, theme, measure, slotWidth) > 0 ? FACET_HEAD_PULL : 0);
|
|
1531
|
+
entry.titleNodeId = band.nodes.find((n) => n.part === "panelTitle")?.id, entry.captionNodeId = band.nodes.find((n) => n.part === "panelCaption")?.id, pushAll(captionNodes, band.nodes), pushAll(captionClaims, band.claims);
|
|
1532
|
+
}
|
|
1533
|
+
let markById = new Map(geometry.marks.panels.map((panel) => [panel.id, panel]));
|
|
1534
|
+
for (let entry of captionSlots) {
|
|
1535
|
+
let mark = markById.get(entry.panel.id);
|
|
1536
|
+
mark && (entry.titleNodeId && !mark.titleNodeId && (mark.titleNodeId = entry.titleNodeId), entry.captionNodeId && (mark.captionNodeId = entry.captionNodeId));
|
|
1537
|
+
}
|
|
1538
|
+
let rowCount = Math.ceil(geometry.marks.panels.length / columns), share = Math.max(FACET_PLOT_SHARE, FACET_COLUMN_SHARE / rowCount), tallest = geometry.marks.panels.flatMap((panel) => panel.chart ? [panel.chart.geometry] : []).reduce((best, chart) => !best || facetSpan(chart) > facetSpan(best) ? chart : best, void 0), headedChange = (target) => {
|
|
1539
|
+
let span = tallest ? facetSpan(tallest) : 0;
|
|
1540
|
+
return span > 0 ? (target - span) * (tallest.plot.h / span) : -1 / 0;
|
|
1541
|
+
}, rowChange = facets && geometry.sizing ? Array.from({ length: rowCount }, (_, row) => maxOf(geometry.marks.panels.slice(row * columns, (row + 1) * columns).map((panel) => panel.chart ? facetHeads ? headedChange(facetPlotHeight(panel.chart.geometry.plot.w, share, rowCount)) : facetPlotHeight(panel.chart.geometry.plot.w, share, rowCount) - panel.chart.geometry.plot.h : -1 / 0))) : [], change = rowChange.every(Number.isFinite) ? rowChange.reduce((total, value) => total + value, 0) : 0, sizing = rowChange.length > 0 && Math.abs(change) > 0.5 && geometry.sizing ? { ...geometry.sizing, naturalHeight: Math.max(geometry.sizing.minHeight, Math.ceil(geometry.size.height + change)) } : geometry.sizing;
|
|
1542
|
+
return {
|
|
1543
|
+
...geometry,
|
|
1544
|
+
...sizing ? { sizing } : {},
|
|
1545
|
+
scene: [...geometry.scene, ...captionNodes],
|
|
1546
|
+
warnings: [...geometry.warnings, ...groupResult.warnings],
|
|
1547
|
+
derived: {
|
|
1548
|
+
...geometry.derived,
|
|
1549
|
+
...Object.keys(groupResult.domains).length > 0 ? { sharedYDomains: groupResult.domains } : {}
|
|
1550
|
+
},
|
|
1551
|
+
debug: {
|
|
1552
|
+
...geometry.debug,
|
|
1553
|
+
occupied: [...geometry.debug.occupied, ...captionClaims]
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
var TIER_PLOT_FLOOR = 10.5, TIER_HEIGHT_STEP = 16;
|
|
1558
|
+
function withTierPlot(geometry, panels, options) {
|
|
1559
|
+
let sizing = geometry.sizing, weights = options.sharedAxis === "category" && sharedYGroup(panels) === null ? varianceTierWeights(panels) : void 0;
|
|
1560
|
+
if (!weights || !sizing || geometry.refused) return geometry;
|
|
1561
|
+
let column = panels.findIndex((panel) => panel.type === "column"), columnOptions = panels[column].options;
|
|
1562
|
+
if (columnOptions?.variant !== "stacked") return geometry;
|
|
1563
|
+
let open = options[TARGET_SIZE]?.fixed.height === !1, hides = open && sliversHidden(geometry), { width, height } = geometry.size, plots = geometry.marks.panels.map((panel) => panel.chart?.geometry.plot.h ?? 0), share = weights.reduce((sum2, weight) => sum2 + weight, 0) / weights[column], need = autoPlotPx(options.target ?? DEFAULT_TARGET, width) * share, reservePlot = stackedColumnPlotPx("column", columnOptions, width), reserve = Math.ceil(reservePlot * share), reach = need / share + reservePlot, squashed = plots.some((plot) => plot <= TIER_PLOT_FLOOR), id = panels[column].id, columnData = panels[column].data, withheld = new Set(columnData?.series?.flatMap((series) => series.values.flatMap((cell, index) => cellMeta(cell)?.label === !1 ? [`${id}/segment:${series.id}:${columnData.categories?.[index]?.id}`] : [])) ?? []), needs = hides ? geometry.labels.filter((label) => label.id.startsWith(`${id}/segment:`) && !withheld.has(label.id)).map((label) => {
|
|
1564
|
+
let mark = geometry.scene.find((node) => node.id === label.id.replace("/segment:", "/mark:"));
|
|
1565
|
+
return plots[column] * ((label[DIGIT_SEAT]?.lineH ?? label.rect.h) + STACK_ROOM) / (mark?.rect?.h ?? 0);
|
|
1566
|
+
}) : [], wanted = Math.max(0, maxOf(needs.filter((plot) => plot <= reach))), drawn = plots[column] + (sizing.naturalHeight - height) / share;
|
|
1567
|
+
if (weights.length > 2 && (!open || !hides || wanted <= drawn + 0.5))
|
|
1568
|
+
return open && !hides && height > sizing.naturalHeight ? { ...geometry, sizing: { ...sizing, fit: "content", naturalHeight: height } } : geometry;
|
|
1569
|
+
let tierHeight = Math.ceil(height + need - plots.reduce((sum2, plot) => sum2 + plot, 0) - (squashed ? Math.max(0, sizing.minHeight - height) : 0) - 1e-6);
|
|
1570
|
+
if (open && !squashed && !hides && height > sizing.naturalHeight && height > tierHeight + 2 * TIER_HEIGHT_STEP && height <= tierHeight + reserve + 2 * TIER_HEIGHT_STEP)
|
|
1571
|
+
return { ...geometry, sizing: { ...sizing, fit: "content", naturalHeight: height } };
|
|
1572
|
+
let found = !squashed && wanted > Math.max(need / share, drawn) ? tierHeight + reserve : tierHeight;
|
|
1573
|
+
if (found <= sizing.naturalHeight + (squashed ? TIER_HEIGHT_STEP : 0))
|
|
1574
|
+
return squashed ? { ...geometry, sizing: { ...sizing, fit: "content" } } : geometry;
|
|
1575
|
+
let naturalHeight = !squashed && found - height <= TIER_HEIGHT_STEP && height - found <= 2 * TIER_HEIGHT_STEP ? height : found;
|
|
1576
|
+
return { ...geometry, sizing: { ...sizing, fit: "content", naturalHeight } };
|
|
1577
|
+
}
|
|
1578
|
+
function withOnePanelContent(geometry, relayout, panels, options) {
|
|
1579
|
+
let sizing = geometry.sizing, target = options.target ?? DEFAULT_TARGET, { width, height } = geometry.size, columns = options.sharedAxis === "category" || options.sharedAxis === void 0 ? 1 : Math.max(1, Number(options.columns ?? 1));
|
|
1580
|
+
if (!sizing || sizing.fit !== "fill" || geometry.refused || columns !== 1 || panels.length !== 1 || width < NARROW_SHARE_WIDTH || width >= WIDE_CANVAS_MIN_WIDTH) return geometry;
|
|
1581
|
+
let panel = panels[0], plotPx = autoPlotPx(target, width) + stackedColumnPlotPx(panel.type, panel.options, width), content = (probe) => {
|
|
1582
|
+
let chart = probe.marks.panels[0]?.chart?.geometry;
|
|
1583
|
+
return chart && chart.sizing?.fit === "fill" ? Math.ceil(probe.size.height - chart.plot.h + plotPx - 1e-6) : void 0;
|
|
1584
|
+
}, found = content(geometry);
|
|
1585
|
+
if (found === void 0) return geometry;
|
|
1586
|
+
if (found = Math.min(sizing.naturalHeight, found), Math.abs(found - height) > 1) {
|
|
1587
|
+
let probe = relayout({ ...options, size: { ...resolveSize(options.size), width, height: found } }), again = probe.refused ? void 0 : content(probe);
|
|
1588
|
+
again !== void 0 && (found = Math.min(sizing.naturalHeight, again));
|
|
1589
|
+
}
|
|
1590
|
+
let naturalHeight = Math.max(sizing.minHeight, found);
|
|
1591
|
+
return naturalHeight === sizing.naturalHeight ? geometry : { ...geometry, sizing: { ...sizing, naturalHeight } };
|
|
1592
|
+
}
|
|
1593
|
+
function usesAuthoredLayout(panels, options) {
|
|
1594
|
+
return Array.isArray(options.columns) || options.rows !== void 0 || options.gutters !== void 0 || options.anchors !== void 0 || options.alignmentRules !== void 0 || panels.some(
|
|
1595
|
+
(panel) => panel.type === "text" || panel.type === "legend" || panel.row !== void 0 || panel.column !== void 0 || panel.span !== void 0 || panel.align !== void 0
|
|
1596
|
+
);
|
|
1597
|
+
}
|
|
1598
|
+
function isAuthoredVarianceStack(panels, options) {
|
|
1599
|
+
if ((options.sharedAxis ?? "category") !== "category" || !varianceTierWeights(panels)) return !1;
|
|
1600
|
+
let columns = Array.isArray(options.columns) ? options.columns.length : options.columns ?? Math.max(1, Math.ceil(Math.sqrt(panels.length))), placements = panels.map((panel, index) => ({
|
|
1601
|
+
row: panel.row ?? Math.floor(index / columns),
|
|
1602
|
+
column: panel.column ?? index % columns
|
|
1603
|
+
}));
|
|
1604
|
+
return new Set(placements.map((placement) => placement.column)).size === 1 && new Set(placements.map((placement) => placement.row)).size === panels.length && panels.every((panel) => (panel.span?.rows ?? 1) === 1 && (panel.span?.columns ?? 1) === 1);
|
|
1605
|
+
}
|
|
1606
|
+
function layoutAuthoredGrid(rawPanels, options, repeatFacet) {
|
|
1607
|
+
let theme = themeForWidth(resolveTheme(options.theme), gridTypeClass(options)), size = resolveSize(options.size), measure = options.measure ?? defaultMeasurer, warnings = [], automaticRows = options.rows === void 0, naturalTierWeights = options.sharedAxis === "category" && options.rows === void 0 && sharedYGroup(rawPanels) === null ? varianceTierWeights(rawPanels) : void 0;
|
|
1608
|
+
if (options.sharedAxis === "category") {
|
|
1609
|
+
let bottomUp = bottomUpTierOrder(rawPanels), weights = tierWeights(rawPanels);
|
|
1610
|
+
(((Array.isArray(options.columns) ? options.columns.length : options.columns) ?? 1) !== 1 || options.panelOrder !== void 0 || rawPanels.some((panel) => panel.row !== void 0 || panel.column !== void 0 || panel.span !== void 0) || options.rows !== void 0 && options.rows.length !== rawPanels.length) && warnings.push({
|
|
1611
|
+
code: "grid-tier-order",
|
|
1612
|
+
severity: "warn",
|
|
1613
|
+
message: "Category tiers use one column and bottom-up order, with the category-axis owner at the bottom; authored placement and panelOrder do not set their visual order",
|
|
1614
|
+
suggest: "use sharedAxis: 'none' for authored facet placement"
|
|
1615
|
+
});
|
|
1616
|
+
let authoredWeights = options.rows?.length === rawPanels.length ? options.rows : weights;
|
|
1617
|
+
options = { ...options, columns: 1, rows: [...bottomUp].reverse().map((index) => authoredWeights[index]) }, rawPanels = rawPanels.map((panel, index) => ({
|
|
1618
|
+
...panel,
|
|
1619
|
+
row: rawPanels.length - 1 - bottomUp.indexOf(index),
|
|
1620
|
+
column: 0,
|
|
1621
|
+
span: void 0
|
|
1622
|
+
}));
|
|
1623
|
+
}
|
|
1624
|
+
({ panels: rawPanels, options } = stackNarrowReadouts(rawPanels, options, theme, measure, size.width));
|
|
1625
|
+
let stacked = stackCompactPanels(rawPanels, options, size.width);
|
|
1626
|
+
stacked.options !== options && (automaticRows = !0), { panels: rawPanels, options } = stacked, options.valueAxis?.break && warnings.push({
|
|
1627
|
+
code: "axis-break-unsupported",
|
|
1628
|
+
severity: "warn",
|
|
1629
|
+
message: "chart type 'grid' does not support valueAxis.break \u2014 ignored"
|
|
1630
|
+
});
|
|
1631
|
+
let legendItems = collectGridLegendItems(rawPanels, options, measure), legendInput;
|
|
1632
|
+
if (options.legend && options.legend !== "none" && options.legend !== "auto") {
|
|
1633
|
+
let legendOptions = normalizeLegendOption(options.legend);
|
|
1634
|
+
legendInput = gridLegendInput(legendItems, legendOptions, options, warnings);
|
|
1635
|
+
}
|
|
1636
|
+
let occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frameResult = solveFrame(
|
|
1637
|
+
{
|
|
1638
|
+
size,
|
|
1639
|
+
margin: { ...canvasMargin(theme, size.width), ...options.margin },
|
|
1640
|
+
...frameTextOptions(options),
|
|
1641
|
+
legend: legendInput,
|
|
1642
|
+
theme,
|
|
1643
|
+
measure
|
|
1644
|
+
},
|
|
1645
|
+
occupied
|
|
1646
|
+
), area = frameResult.plot, authoredColumnCount = Array.isArray(options.columns) ? options.columns.length : typeof options.columns == "number" ? options.columns : void 0, fallbackColumns = authoredColumnCount ?? (options.rows ? Math.max(1, Math.ceil(rawPanels.length / options.rows.length)) : Math.max(1, Math.ceil(Math.sqrt(rawPanels.length)))), provisional = rawPanels.map((panel, index) => ({
|
|
1647
|
+
row: panel.row ?? Math.floor(index / fallbackColumns),
|
|
1648
|
+
column: panel.column ?? index % fallbackColumns,
|
|
1649
|
+
rowSpan: panel.span?.rows ?? 1,
|
|
1650
|
+
columnSpan: panel.span?.columns ?? 1
|
|
1651
|
+
}));
|
|
1652
|
+
provisional.forEach((entry, index) => {
|
|
1653
|
+
let exceedsRows = options.rows !== void 0 && entry.row + entry.rowSpan > options.rows.length, exceedsColumns = authoredColumnCount !== void 0 && entry.column + entry.columnSpan > authoredColumnCount;
|
|
1654
|
+
if (!exceedsRows && !exceedsColumns) return;
|
|
1655
|
+
let panel = rawPanels[index];
|
|
1656
|
+
throw new NormalizeError(
|
|
1657
|
+
"grid-span-exceeds-tracks",
|
|
1658
|
+
`panels[${index}].span`,
|
|
1659
|
+
`panel '${panel.id}' spans to row ${entry.row + entry.rowSpan} and column ${entry.column + entry.columnSpan}, outside the authored ${options.rows?.length ?? "derived"}\xD7${authoredColumnCount ?? "derived"} grid`,
|
|
1660
|
+
"add tracks or reduce the span"
|
|
1661
|
+
);
|
|
1662
|
+
});
|
|
1663
|
+
let occupant = /* @__PURE__ */ new Map();
|
|
1664
|
+
provisional.forEach((entry, index) => {
|
|
1665
|
+
for (let r = entry.row; r < entry.row + entry.rowSpan; r++)
|
|
1666
|
+
for (let c = entry.column; c < entry.column + entry.columnSpan; c++) {
|
|
1667
|
+
let first = occupant.get(`${r}:${c}`);
|
|
1668
|
+
if (first !== void 0)
|
|
1669
|
+
throw new NormalizeError(
|
|
1670
|
+
"grid-cell-overlap",
|
|
1671
|
+
`panels[${index}]`,
|
|
1672
|
+
`panels '${rawPanels[first].id}' and '${rawPanels[index].id}' both occupy row ${r}, column ${c}`,
|
|
1673
|
+
"move a panel or reduce its span"
|
|
1674
|
+
);
|
|
1675
|
+
occupant.set(`${r}:${c}`, index);
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
let columnCount = Math.max(
|
|
1679
|
+
authoredColumnCount ?? 0,
|
|
1680
|
+
maxOf(provisional.map((entry) => entry.column + entry.columnSpan))
|
|
1681
|
+
), rowCount = Math.max(
|
|
1682
|
+
options.rows?.length ?? 0,
|
|
1683
|
+
maxOf(provisional.map((entry) => entry.row + entry.rowSpan))
|
|
1684
|
+
);
|
|
1685
|
+
if (columnCount <= 0 || rowCount <= 0)
|
|
1686
|
+
throw new NormalizeError("grid-empty-tracks", "options.rows", "grid requires row and column tracks");
|
|
1687
|
+
let rowWeights = options.rows ?? Array.from({ length: rowCount }, () => 1), columnWeights = Array.isArray(options.columns) ? options.columns : Array.from({ length: columnCount }, () => 1);
|
|
1688
|
+
if (rowWeights.length !== rowCount || columnWeights.length !== columnCount)
|
|
1689
|
+
throw new NormalizeError(
|
|
1690
|
+
"grid-track-count",
|
|
1691
|
+
"options",
|
|
1692
|
+
`tracks declare ${rowWeights.length}\xD7${columnWeights.length}; panels require ${rowCount}\xD7${columnCount}`
|
|
1693
|
+
);
|
|
1694
|
+
let rowGaps = resolveGaps(options.gutters?.rows, rowCount - 1, theme.space.tierGap, "rows"), columnGaps = resolveGaps(options.gutters?.columns, columnCount - 1, theme.space.facetGap, "columns"), rowBands = trackBands(area.y, area.h, rowWeights, rowGaps, options.gutters?.rows !== void 0), baseColumnBands = trackBands(area.x, area.w, columnWeights, columnGaps, options.gutters?.columns !== void 0), scaledPanels = resolveSharedYDomains(
|
|
1695
|
+
rawPanels.filter((panel) => panel.type !== "text" && panel.type !== "legend"),
|
|
1696
|
+
options,
|
|
1697
|
+
repeatFacet
|
|
1698
|
+
);
|
|
1699
|
+
pushAll(warnings, scaledPanels.warnings);
|
|
1700
|
+
let scaledById = new Map(scaledPanels.panels.map((panel) => [panel.id, panel])), panels = rawPanels.map((panel) => scaledById.get(panel.id) ?? panel), baseChildSlots = provisional.map((placement, index) => {
|
|
1701
|
+
let raw = spanRect(rowBands, baseColumnBands, placement);
|
|
1702
|
+
return alignInside(raw, panels[index].align);
|
|
1703
|
+
}), uniformLineEndpointLegend = !1, layoutChildren = (slots) => panels.map(
|
|
1704
|
+
(panel, index) => layoutAuthoredChild(
|
|
1705
|
+
panel,
|
|
1706
|
+
provisional[index],
|
|
1707
|
+
slots[index],
|
|
1708
|
+
panels,
|
|
1709
|
+
options,
|
|
1710
|
+
legendItems,
|
|
1711
|
+
theme,
|
|
1712
|
+
measure
|
|
1713
|
+
)
|
|
1714
|
+
), uniformizeLineEndpointIdentity = (children, slots) => uniformLineEndpointLegend || gridPanelsKeepEndNames(options) || !children.some(
|
|
1715
|
+
(child) => child.panel.type === "line" && child.geometry.derived.endpointLabelEconomy?.strategy === "legend"
|
|
1716
|
+
) ? children : (uniformLineEndpointLegend = !0, panels = panels.map(
|
|
1717
|
+
(panel) => panel.type === "line" ? {
|
|
1718
|
+
...panel,
|
|
1719
|
+
options: { ...panel.options, gridEndpointIdentity: "legend" }
|
|
1720
|
+
} : panel
|
|
1721
|
+
), layoutChildren(slots));
|
|
1722
|
+
try {
|
|
1723
|
+
let children = uniformizeLineEndpointIdentity(layoutChildren(baseChildSlots), baseChildSlots), sharedAnchors = {}, columnBands = baseColumnBands;
|
|
1724
|
+
if (options.anchors?.categories === "column" || options.anchors?.categories === "all") {
|
|
1725
|
+
if (columnBands = categoryColumnBands(
|
|
1726
|
+
children,
|
|
1727
|
+
baseColumnBands,
|
|
1728
|
+
columnGaps,
|
|
1729
|
+
warnings
|
|
1730
|
+
), columnBands !== baseColumnBands) {
|
|
1731
|
+
let anchoredSlots = provisional.map((placement, index) => {
|
|
1732
|
+
let columns = placement.columnSpan === 1 ? columnBands : baseColumnBands;
|
|
1733
|
+
return alignInside(
|
|
1734
|
+
spanRect(rowBands, columns, placement),
|
|
1735
|
+
panels[index].align
|
|
1736
|
+
);
|
|
1737
|
+
});
|
|
1738
|
+
children = uniformizeLineEndpointIdentity(layoutChildren(anchoredSlots), anchoredSlots);
|
|
1739
|
+
}
|
|
1740
|
+
let indents = readoutIndents(children, columnBands.length);
|
|
1741
|
+
indents.size > 0 && (panels = panels.map((panel) => indents.has(panel.id) ? { ...panel, readoutIndent: indents.get(panel.id) } : panel), children = children.map((child, index) => indents.has(child.panel.id) ? layoutAuthoredChild(panels[index], child.placement, child.slot, panels, options, legendItems, theme, measure) : child));
|
|
1742
|
+
}
|
|
1743
|
+
let columnRects = columnBands.map((band) => ({
|
|
1744
|
+
x: band.start,
|
|
1745
|
+
y: area.y,
|
|
1746
|
+
w: band.size,
|
|
1747
|
+
h: area.h
|
|
1748
|
+
})), edgeScopes = new Set(options.sharedAxis === "category" ? ["column"] : []);
|
|
1749
|
+
options.anchors?.plotEdges && edgeScopes.add(options.anchors.plotEdges), options.anchors?.categories && edgeScopes.add(options.anchors.categories);
|
|
1750
|
+
for (let scope of edgeScopes)
|
|
1751
|
+
scope !== "row" && (children = alignPlotEdges(children, scope, sharedAnchors, warnings, theme));
|
|
1752
|
+
if (options.anchors?.categories && options.anchors.categories !== "row") {
|
|
1753
|
+
let moved = Math.max(0, maxOf(scopeGroups(children, options.anchors.categories).map((group) => alignCategoryPanels(group, theme))));
|
|
1754
|
+
if (moved > 0.01) for (let key of Object.keys(sharedAnchors)) key.startsWith("plotEdges:") && delete sharedAnchors[key];
|
|
1755
|
+
moved > 0.01 && options.anchors.plotEdges && warnings.push({
|
|
1756
|
+
code: "grid-anchor-incompatible",
|
|
1757
|
+
severity: "warn",
|
|
1758
|
+
message: `category centres are aligned across panels whose types inset their categories differently, so their plot edges differ by up to ${Math.round(moved * 10) / 10}px`
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
if (automaticRows) {
|
|
1762
|
+
let valueSize = smallestKpiValueSize(children.map((child) => child.geometry));
|
|
1763
|
+
if (valueSize !== void 0)
|
|
1764
|
+
for (let child of children)
|
|
1765
|
+
hasKpiFigure(child.panel.type) && (child.geometry = child.relayout(child.margin, valueSize));
|
|
1766
|
+
let heights = gridRowHeights(area.h, children.map((child) => ({ geometry: child.geometry, ...child.placement })), rowWeights, rowGaps);
|
|
1767
|
+
if (heights) {
|
|
1768
|
+
let y = area.y;
|
|
1769
|
+
rowBands = heights.map((height, row) => {
|
|
1770
|
+
let band = { start: y, size: height };
|
|
1771
|
+
return y += height + (rowGaps[row] ?? 0), band;
|
|
1772
|
+
}), children = children.map((child) => (Object.assign(child.slot, alignInside(spanRect(
|
|
1773
|
+
rowBands,
|
|
1774
|
+
child.placement.columnSpan === 1 ? columnBands : baseColumnBands,
|
|
1775
|
+
child.placement
|
|
1776
|
+
), child.panel.align)), child.relayout ? { ...child, geometry: child.relayout(child.margin, valueSize) } : layoutAuthoredChild(child.panel, child.placement, child.slot, panels, options, legendItems, theme, measure)));
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
if (naturalTierWeights) {
|
|
1780
|
+
let wrap = () => children.map((child) => ({ child, geo: child.geometry })), tierSlots = children.map((child) => child.slot);
|
|
1781
|
+
for (let pass = 0; pass < 3; pass++)
|
|
1782
|
+
balanceVarianceTierPlots(tierSlots, wrap(), naturalTierWeights, () => {
|
|
1783
|
+
for (let child of children) child.geometry = child.relayout(child.margin);
|
|
1784
|
+
return wrap();
|
|
1785
|
+
});
|
|
1786
|
+
let contentHeight = () => children.reduce((sum2, child) => sum2 + authoredOccupiedBounds(child.geometry).h, 0), available = area.h - rowGaps.reduce((sum2, gap) => sum2 + gap, 0), weight = naturalTierWeights.reduce((sum2, value) => sum2 + value, 0), packed = children.every((child) => !child.panel.align) && !options.anchors?.baselines;
|
|
1787
|
+
if (packed && children.every((child) => child.slot.h >= (child.geometry.sizing?.minHeight ?? 0)))
|
|
1788
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
1789
|
+
let slack = available - contentHeight();
|
|
1790
|
+
if (slack < 1) break;
|
|
1791
|
+
let previous = children.map((child) => child.slot.h), accepted = !1;
|
|
1792
|
+
for (let backoff = 0; backoff < 8; backoff++)
|
|
1793
|
+
if (children.forEach((child, index) => {
|
|
1794
|
+
child.slot.h = previous[index] + slack * naturalTierWeights[index] / weight / 2 ** backoff, child.geometry = child.relayout(child.margin);
|
|
1795
|
+
}), balanceVarianceTierPlots(tierSlots, wrap(), naturalTierWeights, () => {
|
|
1796
|
+
for (let child of children) child.geometry = child.relayout(child.margin);
|
|
1797
|
+
return wrap();
|
|
1798
|
+
}), contentHeight() <= available) {
|
|
1799
|
+
accepted = !0;
|
|
1800
|
+
break;
|
|
1801
|
+
}
|
|
1802
|
+
if (!accepted) {
|
|
1803
|
+
children.forEach((child, index) => {
|
|
1804
|
+
child.slot.h = previous[index], child.geometry = child.relayout(child.margin);
|
|
1805
|
+
});
|
|
1806
|
+
break;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
rowWeights = rowWeights.map((_, row) => tierSlots[provisional.findIndex((p) => p.row === row)].h), rowBands = trackBands(area.y, area.h, rowWeights, rowGaps, options.gutters?.rows !== void 0), tierSlots.forEach((slot, index) => {
|
|
1810
|
+
slot.y = rowBands[provisional[index].row].start;
|
|
1811
|
+
});
|
|
1812
|
+
let bottom = area.y + area.h;
|
|
1813
|
+
for (let index of packed ? bottomUpTierOrder(panels) : []) {
|
|
1814
|
+
let child = children[index], bounds = authoredOccupiedBounds(child.geometry);
|
|
1815
|
+
child.slot.y = bottom - bounds.y - bounds.h, rowBands[child.placement.row] = { start: bottom - bounds.h, size: bounds.h }, bottom -= bounds.h + (rowGaps[child.placement.row - 1] ?? 0);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
let rowRects = rowBands.map((band) => ({ x: area.x, y: band.start, w: area.w, h: band.size }));
|
|
1819
|
+
(options.anchors?.categories === "column" || options.anchors?.categories === "all") && recordCategoryColumnAnchors(children, columnBands, sharedAnchors, warnings), options.anchors?.baselines && (children = alignBaselines(children, options.anchors.baselines, sharedAnchors));
|
|
1820
|
+
let keepBaselines = options.anchors?.baselines ? {
|
|
1821
|
+
top: (child) => child.margin.top ?? numeric(isRecord(child.panel.options?.margin) ? child.panel.options.margin.top : void 0, 20),
|
|
1822
|
+
above: (child) => {
|
|
1823
|
+
let baseline = baselineY(child.geometry), { y, h } = child.geometry.plot;
|
|
1824
|
+
return baseline === null || !(h > 0) ? 1 : Math.min(1, Math.max(0, (baseline - y) / h));
|
|
1825
|
+
}
|
|
1826
|
+
} : void 0;
|
|
1827
|
+
for (let [group, ids] of Object.entries(scaledPanels.members))
|
|
1828
|
+
group === DEFAULT_Y_GROUP || !scaledPanels.domains[group] || alignValuePanels(children.filter((child) => ids.includes(child.panel.id)), theme, keepBaselines);
|
|
1829
|
+
let kpiValueSize = smallestKpiValueSize(children.map((child) => child.geometry));
|
|
1830
|
+
if (kpiValueSize !== void 0)
|
|
1831
|
+
for (let child of children)
|
|
1832
|
+
hasKpiFigure(child.panel.type) && (child.geometry = child.relayout(child.margin, kpiValueSize));
|
|
1833
|
+
let scene = [...frameResult.nodes], labels = [], axes = [], annotations = [], occupiedAll = occupied.snapshot().slice(), decisions = [], marks = { panels: [], alignmentRules: [] };
|
|
1834
|
+
for (let child of children) {
|
|
1835
|
+
let need = child.geometry.sizing;
|
|
1836
|
+
options.sharedAxis === "category" && child.geometry.size.height + 1e-6 < (child.geometry.frame.plotMinHeight ?? 0) && warnings.push({
|
|
1837
|
+
code: "grid-panel-too-short",
|
|
1838
|
+
severity: "warn",
|
|
1839
|
+
message: `panel '${child.panel.id}' is below its measured plot height floor`,
|
|
1840
|
+
suggest: "increase its authored rows weight or increase the grid height"
|
|
1841
|
+
}), child.panel.align && (child.slot.w < (need?.minWidth ?? 0) || child.slot.h < (need?.minHeight ?? child.geometry.frame.minHeight ?? 0)) && warnings.push({
|
|
1842
|
+
code: "grid-panel-too-short",
|
|
1843
|
+
severity: "error",
|
|
1844
|
+
message: `panel '${child.panel.id}' needs a larger fixed alignment size`
|
|
1845
|
+
}), appendAuthoredChild(child, scene, labels, axes, annotations, occupiedAll, decisions, warnings, marks);
|
|
1846
|
+
}
|
|
1847
|
+
let childById = new Map(children.map((child) => [child.panel.id, child])), ruleIds = /* @__PURE__ */ new Set();
|
|
1848
|
+
for (let rule of options.alignmentRules ?? []) {
|
|
1849
|
+
if (ruleIds.has(rule.id))
|
|
1850
|
+
throw new NormalizeError(
|
|
1851
|
+
"duplicate-id",
|
|
1852
|
+
"options.alignmentRules",
|
|
1853
|
+
`duplicate alignment rule id '${rule.id}' \u2014 ids key guide scene identities`
|
|
1854
|
+
);
|
|
1855
|
+
ruleIds.add(rule.id);
|
|
1856
|
+
let source = childById.get(rule.at.panelId);
|
|
1857
|
+
if (!source)
|
|
1858
|
+
throw new NormalizeError(
|
|
1859
|
+
"grid-rule-panel",
|
|
1860
|
+
`options.alignmentRules.${rule.id}.at.panelId`,
|
|
1861
|
+
`alignment rule '${rule.id}' names unknown panel '${rule.at.panelId}'`
|
|
1862
|
+
);
|
|
1863
|
+
let coordinate = resolveRuleCoordinate(source, rule.at.anchor, rule.at.categoryId);
|
|
1864
|
+
if (coordinate === null || coordinate.axis !== (rule.orientation === "vertical" ? "x" : "y"))
|
|
1865
|
+
throw new NormalizeError(
|
|
1866
|
+
"grid-rule-anchor",
|
|
1867
|
+
`options.alignmentRules.${rule.id}.at`,
|
|
1868
|
+
`alignment rule '${rule.id}' cannot resolve ${rule.orientation} guide from ${rule.at.anchor}${rule.at.categoryId ? ` '${rule.at.categoryId}'` : ""} on panel '${source.panel.id}'`
|
|
1869
|
+
);
|
|
1870
|
+
let from = rule.fromPanelId ? childById.get(rule.fromPanelId) : void 0, to = rule.toPanelId ? childById.get(rule.toPanelId) : void 0;
|
|
1871
|
+
if (rule.fromPanelId && !from || rule.toPanelId && !to)
|
|
1872
|
+
throw new NormalizeError(
|
|
1873
|
+
"grid-rule-panel",
|
|
1874
|
+
`options.alignmentRules.${rule.id}`,
|
|
1875
|
+
`alignment rule '${rule.id}' names an unknown from/to panel`
|
|
1876
|
+
);
|
|
1877
|
+
let nodeId = `grid:alignment:${rule.id}`;
|
|
1878
|
+
if (rule.orientation === "vertical") {
|
|
1879
|
+
let y1 = from?.slot.y ?? area.y, y2 = (to?.slot.y ?? area.y) + (to?.slot.h ?? area.h), runs = guideRuns(occupiedAll, "vertical", coordinate.value, y1, y2);
|
|
1880
|
+
scene.push(runs.length === 1 && runs[0][0] === Math.min(y1, y2) && runs[0][1] === Math.max(y1, y2) ? { t: "line", id: nodeId, x1: coordinate.value, y1, x2: coordinate.value, y2, stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" } : { t: "path", id: nodeId, d: runs.map(([a, b]) => `M${fmtPathNumber(coordinate.value)} ${fmtPathNumber(a)}V${fmtPathNumber(b)}`).join(""), stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" }), occupiedAll.push({
|
|
1881
|
+
rect: { x: coordinate.value - 0.5, y: Math.min(y1, y2), w: 1, h: Math.abs(y2 - y1) },
|
|
1882
|
+
kind: "axis",
|
|
1883
|
+
owner: {},
|
|
1884
|
+
part: "alignmentRule"
|
|
1885
|
+
});
|
|
1886
|
+
} else {
|
|
1887
|
+
let x1 = from?.slot.x ?? area.x, x2 = (to?.slot.x ?? area.x) + (to?.slot.w ?? area.w), runs = guideRuns(occupiedAll, "horizontal", coordinate.value, x1, x2);
|
|
1888
|
+
scene.push(runs.length === 1 && runs[0][0] === Math.min(x1, x2) && runs[0][1] === Math.max(x1, x2) ? { t: "line", id: nodeId, x1, y1: coordinate.value, x2, y2: coordinate.value, stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" } : { t: "path", id: nodeId, d: runs.map(([a, b]) => `M${fmtPathNumber(a)} ${fmtPathNumber(coordinate.value)}H${fmtPathNumber(b)}`).join(""), stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" }), occupiedAll.push({
|
|
1889
|
+
rect: { x: Math.min(x1, x2), y: coordinate.value - 0.5, w: Math.abs(x2 - x1), h: 1 },
|
|
1890
|
+
kind: "axis",
|
|
1891
|
+
owner: {},
|
|
1892
|
+
part: "alignmentRule"
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
marks.alignmentRules.push({ id: rule.id, nodeId, orientation: rule.orientation });
|
|
1896
|
+
}
|
|
1897
|
+
let compactNotes = children.flatMap((child) => child.geometry.a11y.compactNotes ?? []);
|
|
1898
|
+
return {
|
|
1899
|
+
type: "grid",
|
|
1900
|
+
size,
|
|
1901
|
+
sizing: withReadoutPlotHeight(
|
|
1902
|
+
gridSizing(size, area, children.map((child) => ({ geometry: child.geometry, ...child.placement })), rowWeights, columnWeights, rowGaps, columnGaps, automaticRows),
|
|
1903
|
+
size,
|
|
1904
|
+
automaticRows ? children : []
|
|
1905
|
+
),
|
|
1906
|
+
plot: area,
|
|
1907
|
+
scene,
|
|
1908
|
+
labels,
|
|
1909
|
+
axes,
|
|
1910
|
+
annotations,
|
|
1911
|
+
frame: frameResult.frame,
|
|
1912
|
+
legend: frameResult.legend,
|
|
1913
|
+
marks,
|
|
1914
|
+
derived: {
|
|
1915
|
+
tracks: { rows: rowRects, columns: columnRects, rowGaps, columnGaps },
|
|
1916
|
+
...Object.keys(sharedAnchors).length > 0 ? { sharedAnchors } : {},
|
|
1917
|
+
...Object.keys(scaledPanels.domains).length > 0 ? { sharedYDomains: scaledPanels.domains } : {}
|
|
1918
|
+
},
|
|
1919
|
+
a11y: {
|
|
1920
|
+
titleCounts: [structureCount("panels", panels.length, void 0, options)],
|
|
1921
|
+
title: accessibleTitle(options.title, chartString(options, "gridPanelsTitle", { v1: panels.length })),
|
|
1922
|
+
counts: [
|
|
1923
|
+
structureCount("rows", rowCount, chartString(options, "authoredRows", { v1: rowCount })),
|
|
1924
|
+
structureCount("columns", columnCount, chartString(options, "compositionColumns", { v1: columnCount })),
|
|
1925
|
+
...children.flatMap((child) => {
|
|
1926
|
+
let title = child.panel.title ?? child.geometry.a11y.title;
|
|
1927
|
+
return [...child.geometry.a11y.counts ?? [], ...child.geometry.a11y.titleCounts ?? []].filter((count) => title.includes(count.text));
|
|
1928
|
+
})
|
|
1929
|
+
],
|
|
1930
|
+
desc: chartString(options, "gridComposition", { v1: rowCount, v2: columnCount, v3: marks.panels.map((panel) => panel.title).join("; "), v4: compactNotes.length > 0 ? chartString(options, "notesClause", { v1: compactNotes.join("; ") }) : "" }),
|
|
1931
|
+
...compactNotes.length > 0 ? { compactNotes } : {}
|
|
1932
|
+
},
|
|
1933
|
+
warnings,
|
|
1934
|
+
debug: { occupied: occupiedAll, decisions }
|
|
1935
|
+
};
|
|
1936
|
+
} catch (error) {
|
|
1937
|
+
if (!(error instanceof GridChildRefusal)) throw error;
|
|
1938
|
+
let index = panels.findIndex((panel) => panel.id === error.panelId);
|
|
1939
|
+
return error.result(size, gridSizing(
|
|
1940
|
+
size,
|
|
1941
|
+
area,
|
|
1942
|
+
[{ geometry: error.child, ...provisional[index] }],
|
|
1943
|
+
rowWeights,
|
|
1944
|
+
columnWeights,
|
|
1945
|
+
rowGaps,
|
|
1946
|
+
columnGaps,
|
|
1947
|
+
automaticRows
|
|
1948
|
+
), index);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
function layoutAuthoredChild(panel, placement, slot, panels, parentOptions, allLegendItems, theme, measure) {
|
|
1952
|
+
if (panel.type === "text")
|
|
1953
|
+
return {
|
|
1954
|
+
panel,
|
|
1955
|
+
placement,
|
|
1956
|
+
slot,
|
|
1957
|
+
margin: {},
|
|
1958
|
+
geometry: layoutTextPanel(panel, slot, theme, measure)
|
|
1959
|
+
};
|
|
1960
|
+
if (panel.type === "legend") {
|
|
1961
|
+
let parsed = parseGridLegendPanelData(panel.data), allow = parsed.from ? new Set(parsed.from) : void 0, items = allow ? collectGridLegendItems(
|
|
1962
|
+
panels.filter((candidate) => allow.has(candidate.id)),
|
|
1963
|
+
parentOptions,
|
|
1964
|
+
measure
|
|
1965
|
+
) : allLegendItems;
|
|
1966
|
+
return {
|
|
1967
|
+
panel,
|
|
1968
|
+
placement,
|
|
1969
|
+
slot,
|
|
1970
|
+
margin: {},
|
|
1971
|
+
geometry: layoutLegendPanel(panel, slot, items, theme, measure, parentOptions)
|
|
1972
|
+
};
|
|
1973
|
+
}
|
|
1974
|
+
let definition = getChart(panel.type);
|
|
1975
|
+
if (!definition)
|
|
1976
|
+
throw new NormalizeError(
|
|
1977
|
+
"unknown-type",
|
|
1978
|
+
`panels[${panel.id}].type`,
|
|
1979
|
+
`unknown chart type '${panel.type}'`
|
|
1980
|
+
);
|
|
1981
|
+
let authoredOptions = panel.options ?? {}, compactTiers = parentOptions.sharedAxis === "category" && panels.length > 1, authoredTitle = panel.title ?? (typeof authoredOptions.title == "string" ? authoredOptions.title : void 0), panelOptions = parentOptions.sharedAxis === "category" && panels.indexOf(panel) !== sharedCategoryLabelOwner(panels) ? { ...authoredOptions, labels: withoutCategoryLabels(authoredOptions.labels) } : authoredOptions, authoredMargin = isRecord(panelOptions.margin) ? panelOptions.margin : {}, recordOptions, relayout = (margin2, kpiValueSize) => {
|
|
1982
|
+
let captionPanel = compactTiers ? { ...panel, title: panelOptions.title === !1 ? void 0 : authoredTitle } : panel, captionHeight = () => measureCaptionBand(captionPanel, theme, measure, slot.w, compactTiers), marginTop = numeric(margin2.top ?? authoredMargin.top, 20), resolvedOptions = {
|
|
1983
|
+
...definition.defaults,
|
|
1984
|
+
...panelOptions,
|
|
1985
|
+
...(panelOptions.locale ?? parentOptions.locale) === void 0 ? {} : { locale: panelOptions.locale ?? parentOptions.locale },
|
|
1986
|
+
...Object.keys(authoredStrings(parentOptions) ?? {}).length ? { strings: { ...authoredStrings(parentOptions), ...panelOptions.strings } } : {},
|
|
1987
|
+
...compactTiers && panelOptions.title !== !1 && (authoredTitle !== void 0 || panel.type === "variance") ? { title: "" } : {},
|
|
1988
|
+
...hasKpiFigure(panel.type) && kpiValueSize !== void 0 ? { [KPI_VALUE_SIZE]: kpiValueSize } : {},
|
|
1989
|
+
...panel.type === "kpi" ? { [KPI_HOST_TEXT]: stringsIn([panel.title, panel.caption, parentOptions.title, parentOptions.subtitle, parentOptions.footnotes, parentOptions.source]) } : {},
|
|
1990
|
+
...panel.type === "variance" && isAuthoredVarianceStack(panels, parentOptions) ? { [VARIANCE_TIER]: panels.length } : {},
|
|
1991
|
+
...panel.annotations ? { annotations: panel.annotations } : {},
|
|
1992
|
+
...parentOptions.palette !== void 0 && panelOptions.palette === void 0 ? { palette: parentOptions.palette } : {},
|
|
1993
|
+
// A status panel resolves its hatch strength in its own layout.
|
|
1994
|
+
...hatchStrengthFor(panelOptions, parentOptions),
|
|
1995
|
+
theme: panelOptions.theme ?? parentOptions.theme,
|
|
1996
|
+
target: parentOptions.target,
|
|
1997
|
+
size: { width: slot.w, height: slot.h },
|
|
1998
|
+
margin: { ...authoredMargin, ...margin2, top: compactTiers ? Math.max(marginTop, captionHeight()) : marginTop + measureCaptionBand({ ...panel, options: { ...panelOptions, margin: { ...authoredMargin, ...margin2 } } }, theme, measure, slot.w) },
|
|
1999
|
+
measure,
|
|
2000
|
+
typeClass: gridTypeClass(parentOptions)
|
|
2001
|
+
}, geometry = layoutChildChart(panel.data, resolvedOptions, definition.layout);
|
|
2002
|
+
if (geometry.refused) throw new GridChildRefusal(panel.id, geometry);
|
|
2003
|
+
let tierName = geometry.derived.tierName;
|
|
2004
|
+
if (compactTiers && panelOptions.title !== !1 && !captionPanel.title && tierName && (captionPanel.title = tierName, captionHeight() > resolvedOptions.margin.top && (resolvedOptions.margin.top = captionHeight(), geometry = layoutChildChart(panel.data, resolvedOptions, definition.layout), geometry.refused)))
|
|
2005
|
+
throw new GridChildRefusal(panel.id, geometry);
|
|
2006
|
+
let { measure: _measure, ...serializable } = resolvedOptions;
|
|
2007
|
+
recordOptions = serializable;
|
|
2008
|
+
let captionY = compactTiers && isAuthoredVarianceStack(panels, parentOptions) ? authoredOccupiedBounds(geometry).y - resolvedOptions.margin.top - theme.space.labelPad : 0, band = panelCaptionBand({ ...captionPanel, options: resolvedOptions }, theme, measure, { x: 0, y: captionY, w: slot.w, h: slot.h }, new Set(resolveHighlight(parentOptions.highlight)), compactTiers);
|
|
2009
|
+
return pushAll(geometry.scene, band.nodes), pushAll(geometry.debug.occupied, band.claims), geometry;
|
|
2010
|
+
}, margin = { ...authoredMargin };
|
|
2011
|
+
return { panel, placement, slot, geometry: relayout(margin), margin, relayout, recordOptions: () => recordOptions };
|
|
2012
|
+
}
|
|
2013
|
+
function readoutIndents(children, columns) {
|
|
2014
|
+
let indents = /* @__PURE__ */ new Map(), chart = children.find((child) => child.placement.column === 0 && child.placement.columnSpan === columns && child.geometry.axes.find((axis) => axis.axis === "x")?.ticks.length === columns), ticks = chart?.geometry.axes.find((axis) => axis.axis === "x")?.ticks;
|
|
2015
|
+
if (!chart || !ticks || columns < 2) return indents;
|
|
2016
|
+
for (let child of children) {
|
|
2017
|
+
if (child.panel.type !== "text" || child.placement.columnSpan !== 1 || child.panel.readoutLead) continue;
|
|
2018
|
+
let category = ticks[child.placement.column]?.at, lefts = chart.geometry.scene.flatMap((node) => node.t === "rect" && node.part === "bar" && node.owner?.categoryId === category ? [node.rect.x + (node.tx ?? 0)] : []);
|
|
2019
|
+
if (lefts.length === 0) continue;
|
|
2020
|
+
let indent = chart.slot.x + minOf(lefts) - child.slot.x - TEXT_PANEL_PAD;
|
|
2021
|
+
indent > 0.5 && indent < child.slot.w * 2 / 3 && indents.set(child.panel.id, indent);
|
|
2022
|
+
}
|
|
2023
|
+
return indents;
|
|
2024
|
+
}
|
|
2025
|
+
function stackNarrowReadouts(panels, options, theme, measure, width) {
|
|
2026
|
+
let anchored = options.anchors?.categories === "column" || options.anchors?.categories === "all", columns = Array.isArray(options.columns) ? options.columns.length : typeof options.columns == "number" ? options.columns : void 0;
|
|
2027
|
+
if (!anchored || columns === void 0 || columns < 2 || width >= CARD_CLASS_WIDTH) return { panels, options };
|
|
2028
|
+
let chart = panels.find((panel) => panel.type !== "text" && panel.type !== "legend" && (panel.column ?? 0) === 0 && panel.span?.columns === columns && (panel.span?.rows ?? 1) === 1), categories = chart && isRecord(chart.data) && Array.isArray(chart.data.categories) ? chart.data.categories : [];
|
|
2029
|
+
if (!chart || categories.length !== columns) return { panels, options };
|
|
2030
|
+
let readouts = panels.filter((panel) => panel.type === "text" && panel.row !== void 0 && panel.row > (chart.row ?? 0) && panel.column !== void 0 && (panel.span?.columns ?? 1) === 1 && (panel.span?.rows ?? 1) === 1), row = readouts[0]?.row, inRow = readouts.filter((panel) => panel.row === row);
|
|
2031
|
+
if (row === void 0 || inRow.length !== columns || new Set(inRow.map((panel) => panel.column)).size !== columns || panels.some((panel) => panel !== chart && !inRow.includes(panel))) return { panels, options };
|
|
2032
|
+
let weights = options.columns, shares = Array.isArray(weights) ? weights : Array.from({ length: columns }, () => 1), total = shares.reduce((sum2, value) => sum2 + value, 0), margin = canvasMargin(theme, width), gaps = resolveGaps(options.gutters?.columns, columns - 1, theme.space.facetGap, "columns"), inner = width - margin.left - margin.right - gaps.reduce((sum2, gap) => sum2 + gap, 0), titleFont = { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) };
|
|
2033
|
+
if (!inRow.some((panel) => {
|
|
2034
|
+
let title = isRecord(panel.data) && typeof panel.data.title == "string" ? panel.data.title : "";
|
|
2035
|
+
return title !== "" && measure(title, titleFont).width > inner * shares[panel.column] / total - 2 * TEXT_PANEL_PAD;
|
|
2036
|
+
})) return { panels, options };
|
|
2037
|
+
let rows = options.rows?.flatMap((weight, index) => index === row ? inRow.map(() => weight) : [weight]), label = (index) => {
|
|
2038
|
+
let category = categories[index];
|
|
2039
|
+
return isRecord(category) ? String(category.label ?? category.id ?? "") : "";
|
|
2040
|
+
}, authored = options.gutters?.rows, gutters = { ...options.gutters, rows: Array.from({ length: row + columns - 1 }, (_, index) => index >= row ? READOUT_STACK_GAP : typeof authored == "number" ? authored : authored?.[index] ?? theme.space.tierGap) };
|
|
2041
|
+
return {
|
|
2042
|
+
options: { ...options, ...rows ? { rows } : {}, gutters },
|
|
2043
|
+
panels: panels.map((panel) => {
|
|
2044
|
+
if (!inRow.includes(panel)) return panel.row !== void 0 && panel.row > row ? { ...panel, row: panel.row + columns - 1 } : panel;
|
|
2045
|
+
let lead = label(panel.column);
|
|
2046
|
+
return { ...panel, row: row + panel.column, column: 0, span: { ...panel.span, columns }, ...lead ? { readoutLead: lead } : {} };
|
|
2047
|
+
})
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
function stackCompactPanels(panels, options, width) {
|
|
2051
|
+
let authored = Array.isArray(options.columns) ? options.columns.length : options.columns ?? (options.rows ? Math.ceil(panels.length / options.rows.length) : Math.ceil(Math.sqrt(panels.length))), columns = Math.max(authored, ...panels.map((panel) => (panel.column ?? 0) + (panel.span?.columns ?? 1)));
|
|
2052
|
+
if (options.mode !== "compact" || panelTypeClass(options) !== void 0 || width >= CARD_CLASS_WIDTH || columns < 2 || options.anchors !== void 0 || options.alignmentRules !== void 0) return { panels, options };
|
|
2053
|
+
let { rows: _rows, columns: _gutterColumns, ...gutters } = options.gutters ?? {};
|
|
2054
|
+
return {
|
|
2055
|
+
options: { ...options, columns: 1, rows: void 0, gutters },
|
|
2056
|
+
// A chart panel takes the card's width as the same chart alone does: the grid's margin, not its own beside it.
|
|
2057
|
+
panels: panels.map((panel, index) => ({
|
|
2058
|
+
...panel,
|
|
2059
|
+
row: index,
|
|
2060
|
+
column: 0,
|
|
2061
|
+
span: void 0,
|
|
2062
|
+
...panel.type === "text" || panel.type === "legend" ? {} : { options: { ...panel.options, margin: { left: 0, right: 0, ...isRecord(panel.options?.margin) ? panel.options.margin : {} } } }
|
|
2063
|
+
}))
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
var READOUT_PLOT_BASE = 82, READOUT_PLOT_SLOPE = 0.15;
|
|
2067
|
+
function withReadoutPlotHeight(sizing, size, children) {
|
|
2068
|
+
if (!children.some((child) => child.panel.type === "text")) return sizing;
|
|
2069
|
+
let charts = children.filter((child) => child.panel.type !== "text" && child.panel.type !== "legend" && child.geometry.sizing?.fit !== "content");
|
|
2070
|
+
if (charts.length === 0) return sizing;
|
|
2071
|
+
let change = maxOf(charts.map((child) => {
|
|
2072
|
+
let plot = child.geometry.plot;
|
|
2073
|
+
return READOUT_PLOT_BASE + READOUT_PLOT_SLOPE * plot.w - plot.h;
|
|
2074
|
+
})), naturalHeight = Math.max(sizing.minHeight, Math.ceil(size.height + change));
|
|
2075
|
+
return { ...sizing, naturalHeight, comfortableHeight: Math.max(sizing.comfortableHeight, naturalHeight) };
|
|
2076
|
+
}
|
|
2077
|
+
var TEXT_PANEL_PAD = 6, READOUT_STACK_GAP = 6, READOUT_STACK_PAD = 2;
|
|
2078
|
+
function layoutTextPanel(panel, slot, theme, measure) {
|
|
2079
|
+
let data = parseGridTextPanelData(panel.data), occupied = createOccupiedIndex({ x: 0, y: 0, w: slot.w, h: slot.h }), titleFont = { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) }, bodyFont = { family: theme.type.family, ...theme.type.label }, requests = [], pad = TEXT_PANEL_PAD, indent = panel.readoutIndent ?? 0, lead = panel.readoutLead, cap = Math.max(20, slot.w - pad * (lead || indent > 0 ? 1 : 2) - indent), padY = lead ? READOUT_STACK_PAD : pad, y = padY, lastGap = 0, leadGap = measure("\u2002", bodyFont).width, leadWidth = lead && data.title ? measure(lead, bodyFont).width + leadGap : 0, add = (id, text, font, priority, prefix = "", offset = 0) => {
|
|
2080
|
+
let lines = wrapMeasured(`${prefix}${text}`, font, Math.max(20, cap - offset), Number.MAX_SAFE_INTEGER, measure), w = Math.max(1, ...lines.map((line) => measure(line, font).width)), h = lines.length * font.size * (font.lineHeight ?? 1.2);
|
|
2081
|
+
requests.push({
|
|
2082
|
+
id,
|
|
2083
|
+
kind: "annotation",
|
|
2084
|
+
typeRole: font === titleFont ? "axis" : "label",
|
|
2085
|
+
owner: { categoryId: panel.id },
|
|
2086
|
+
text: lines.join(" "),
|
|
2087
|
+
lines,
|
|
2088
|
+
font,
|
|
2089
|
+
priority,
|
|
2090
|
+
candidates: [{ slot: "panelFlow", rect: { x: pad + indent + offset, y, w, h }, penalty: 0 }],
|
|
2091
|
+
// Authored panel prose: a note, never a value label.
|
|
2092
|
+
role: "note"
|
|
2093
|
+
}), lastGap = font === titleFont ? lead || indent > 0 ? 4 : 6 : 4, y += h + lastGap;
|
|
2094
|
+
};
|
|
2095
|
+
if (lead && data.title) {
|
|
2096
|
+
let h = bodyFont.size * (bodyFont.lineHeight ?? 1.2);
|
|
2097
|
+
requests.push({
|
|
2098
|
+
id: `text:${panel.id}:lead`,
|
|
2099
|
+
kind: "annotation",
|
|
2100
|
+
typeRole: "label",
|
|
2101
|
+
owner: { categoryId: panel.id },
|
|
2102
|
+
text: lead,
|
|
2103
|
+
lines: [lead],
|
|
2104
|
+
font: bodyFont,
|
|
2105
|
+
priority: PRIORITY.total,
|
|
2106
|
+
candidates: [{ slot: "panelFlow", rect: { x: pad + indent, y, w: leadWidth - leadGap, h }, penalty: 0 }],
|
|
2107
|
+
role: "note"
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
data.title && add(`text:${panel.id}:title`, data.title, titleFont, PRIORITY.total, "", leadWidth), data.body && add(`text:${panel.id}:body`, data.body, bodyFont, PRIORITY.valueLine), (data.bullets ?? []).forEach(
|
|
2111
|
+
(bullet, index) => add(`text:${panel.id}:bullet:${index + 1}`, bullet, bodyFont, PRIORITY.extreme, "\u2022 ")
|
|
2112
|
+
);
|
|
2113
|
+
let solveCtx = labelCtx(theme, { width: slot.w, height: slot.h }, {}, {
|
|
2114
|
+
density: "full",
|
|
2115
|
+
measure,
|
|
2116
|
+
plot: { x: 0, y: 0, w: slot.w, h: slot.h },
|
|
2117
|
+
labelPad: 2
|
|
2118
|
+
}), solved = solveLabels(requests, occupied, solveCtx), nodes = labelsToNodes(
|
|
2119
|
+
theme,
|
|
2120
|
+
solved.placed,
|
|
2121
|
+
(label) => label.id.endsWith(":title") ? titleFont : bodyFont
|
|
2122
|
+
).map((node) => {
|
|
2123
|
+
let ink = textPanelInk(node.id, data.tone);
|
|
2124
|
+
return ink && node.t === "text" ? { ...node, ink } : node;
|
|
2125
|
+
}), contentHeight = Math.ceil(y - lastGap + padY);
|
|
2126
|
+
return {
|
|
2127
|
+
type: "grid-text",
|
|
2128
|
+
size: { width: slot.w, height: slot.h },
|
|
2129
|
+
plot: { x: 0, y: 0, w: slot.w, h: slot.h },
|
|
2130
|
+
scene: nodes,
|
|
2131
|
+
labels: solved.placed,
|
|
2132
|
+
axes: [],
|
|
2133
|
+
annotations: [],
|
|
2134
|
+
// A text panel is as tall as its prose: an automatic row of text panels
|
|
2135
|
+
// takes that height and leaves the rest of the canvas to the charts.
|
|
2136
|
+
sizing: {
|
|
2137
|
+
aspect: "content",
|
|
2138
|
+
fit: "content",
|
|
2139
|
+
minWidth: 0,
|
|
2140
|
+
minHeight: contentHeight,
|
|
2141
|
+
measuredMinWidth: 0,
|
|
2142
|
+
measuredMinHeight: contentHeight,
|
|
2143
|
+
naturalWidth: slot.w,
|
|
2144
|
+
naturalHeight: contentHeight,
|
|
2145
|
+
comfortableWidth: slot.w,
|
|
2146
|
+
comfortableHeight: contentHeight
|
|
2147
|
+
},
|
|
2148
|
+
frame: { minHeight: y - lastGap + padY },
|
|
2149
|
+
marks: {},
|
|
2150
|
+
derived: {},
|
|
2151
|
+
a11y: {
|
|
2152
|
+
title: data.title ?? panel.title ?? panel.id,
|
|
2153
|
+
desc: [data.body, ...data.bullets ?? []].filter(Boolean).join(" ")
|
|
2154
|
+
},
|
|
2155
|
+
warnings: solved.warnings,
|
|
2156
|
+
debug: { occupied: occupied.snapshot(), decisions: solved.decisions }
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2159
|
+
function layoutLegendPanel(panel, slot, items, theme, measure, parentOptions) {
|
|
2160
|
+
let occupied = createOccupiedIndex({ x: 0, y: 0, w: slot.w, h: slot.h }), frame = solveFrame(
|
|
2161
|
+
{
|
|
2162
|
+
size: { width: slot.w, height: slot.h },
|
|
2163
|
+
margin: { top: 4, right: 4, bottom: 4, left: 4 },
|
|
2164
|
+
...frameTextOptions({ title: panel.title, mode: parentOptions.mode, theme: parentOptions.theme, target: parentOptions.target }),
|
|
2165
|
+
legend: items.length > 0 ? { options: { position: "top" }, items } : void 0,
|
|
2166
|
+
theme,
|
|
2167
|
+
measure
|
|
2168
|
+
},
|
|
2169
|
+
occupied
|
|
2170
|
+
), warnings = items.length > 0 ? [] : [{
|
|
2171
|
+
code: "grid-legend-empty",
|
|
2172
|
+
severity: "warn",
|
|
2173
|
+
message: `legend panel '${panel.id}' has no contributing chart legend items`
|
|
2174
|
+
}];
|
|
2175
|
+
return frame.legend && (frame.frame.minHeight = frame.legend.rect.y + frame.legend.rect.h + 4), {
|
|
2176
|
+
type: "grid-legend",
|
|
2177
|
+
size: { width: slot.w, height: slot.h },
|
|
2178
|
+
plot: frame.plot,
|
|
2179
|
+
scene: frame.nodes,
|
|
2180
|
+
labels: [],
|
|
2181
|
+
axes: [],
|
|
2182
|
+
annotations: [],
|
|
2183
|
+
legend: frame.legend,
|
|
2184
|
+
frame: frame.frame,
|
|
2185
|
+
marks: {},
|
|
2186
|
+
derived: {},
|
|
2187
|
+
a11y: { title: panel.title ?? chartString(parentOptions, "legendName"), desc: chartString(parentOptions, "legendItemsCount", { v1: items.length }) },
|
|
2188
|
+
warnings,
|
|
2189
|
+
debug: { occupied: occupied.snapshot(), decisions: [] }
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
function resolveGaps(authored, count, fallback, axis) {
|
|
2193
|
+
if (count <= 0) return [];
|
|
2194
|
+
if (authored === void 0) return Array.from({ length: count }, () => fallback);
|
|
2195
|
+
if (typeof authored == "number") return Array.from({ length: count }, () => authored);
|
|
2196
|
+
if (authored.length !== count)
|
|
2197
|
+
throw new NormalizeError(
|
|
2198
|
+
"grid-gutter-count",
|
|
2199
|
+
`options.gutters.${axis}`,
|
|
2200
|
+
`${axis} gutters require exactly ${count} value${count === 1 ? "" : "s"} for the authored tracks; received ${authored.length}`
|
|
2201
|
+
);
|
|
2202
|
+
return [...authored];
|
|
2203
|
+
}
|
|
2204
|
+
function trackBands(start, span, weights, gaps, authoredGaps) {
|
|
2205
|
+
let usable = span - gaps.reduce((sum2, gap) => sum2 + gap, 0);
|
|
2206
|
+
if (authoredGaps && usable <= 0)
|
|
2207
|
+
throw new NormalizeError(
|
|
2208
|
+
"grid-gutters-exceed-space",
|
|
2209
|
+
"options.gutters",
|
|
2210
|
+
`authored gutters consume ${span - usable}px of ${span}px available space`,
|
|
2211
|
+
"make options.gutters smaller, or give the grid a larger size: the title, panel heads and gutters share the canvas"
|
|
2212
|
+
);
|
|
2213
|
+
let total = weights.reduce((sum2, weight) => sum2 + weight, 0), cursor = start;
|
|
2214
|
+
return weights.map((weight, index) => {
|
|
2215
|
+
let size = Math.max(0, usable) * weight / total, band = { start: cursor, size };
|
|
2216
|
+
return cursor += size + (gaps[index] ?? 0), band;
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
function spanRect(rows, columns, placement) {
|
|
2220
|
+
let firstRow = rows[placement.row], lastRow = rows[placement.row + placement.rowSpan - 1], firstColumn = columns[placement.column], lastColumn = columns[placement.column + placement.columnSpan - 1];
|
|
2221
|
+
return {
|
|
2222
|
+
x: firstColumn.start,
|
|
2223
|
+
y: firstRow.start,
|
|
2224
|
+
w: lastColumn.start + lastColumn.size - firstColumn.start,
|
|
2225
|
+
h: lastRow.start + lastRow.size - firstRow.start
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2228
|
+
function alignInside(raw, align) {
|
|
2229
|
+
if (!align) return raw;
|
|
2230
|
+
let horizontal = align.horizontal ?? "stretch", vertical = align.vertical ?? "stretch", w = horizontal === "stretch" ? raw.w : Math.min(raw.w, align.width ?? raw.w), h = vertical === "stretch" ? raw.h : Math.min(raw.h, align.height ?? raw.h), x = horizontal === "end" ? raw.x + raw.w - w : horizontal === "center" ? raw.x + (raw.w - w) / 2 : raw.x, y = vertical === "end" ? raw.y + raw.h - h : vertical === "center" ? raw.y + (raw.h - h) / 2 : raw.y;
|
|
2231
|
+
return { x, y, w, h };
|
|
2232
|
+
}
|
|
2233
|
+
function scopeGroups(children, scope) {
|
|
2234
|
+
if (scope === "all") return [children];
|
|
2235
|
+
let groups = /* @__PURE__ */ new Map();
|
|
2236
|
+
for (let child of children) {
|
|
2237
|
+
let key = scope === "row" ? child.placement.row : child.placement.column, members = groups.get(key) ?? [];
|
|
2238
|
+
members.push(child), groups.set(key, members);
|
|
2239
|
+
}
|
|
2240
|
+
return [...groups.values()];
|
|
2241
|
+
}
|
|
2242
|
+
function categoryColumnBands(children, columnBands, columnGaps, warnings) {
|
|
2243
|
+
let candidates = children.flatMap((child) => {
|
|
2244
|
+
let axis = child.geometry.axes.find((candidate) => candidate.axis === "x");
|
|
2245
|
+
return child.placement.column === 0 && child.placement.columnSpan === columnBands.length && axis?.ticks.length === columnBands.length ? [{ child, axis }] : [];
|
|
2246
|
+
});
|
|
2247
|
+
if (candidates.length === 0 || columnBands.length < 2) return columnBands;
|
|
2248
|
+
let centers = candidates[0].axis.ticks.map(
|
|
2249
|
+
(tick) => candidates[0].child.slot.x + tick.pos
|
|
2250
|
+
);
|
|
2251
|
+
for (let { child, axis } of candidates.slice(1))
|
|
2252
|
+
axis.ticks.map((tick) => child.slot.x + tick.pos).some((value, index) => Math.abs(value - centers[index]) > 1e-6) && warnings.push({
|
|
2253
|
+
code: "grid-anchor-incompatible",
|
|
2254
|
+
severity: "warn",
|
|
2255
|
+
message: `panel '${child.panel.id}' proposes category anchors that conflict with panel '${candidates[0].child.panel.id}'`
|
|
2256
|
+
});
|
|
2257
|
+
let signs = [1], offsets = [0];
|
|
2258
|
+
for (let index = 0; index < centers.length - 1; index += 1) {
|
|
2259
|
+
let available = centers[index + 1] - centers[index] - columnGaps[index];
|
|
2260
|
+
if (!(available > 0))
|
|
2261
|
+
return warnings.push({
|
|
2262
|
+
code: "grid-anchor-incompatible",
|
|
2263
|
+
severity: "warn",
|
|
2264
|
+
message: `category anchors leave no room for authored column gutter ${index + 1}`
|
|
2265
|
+
}), columnBands;
|
|
2266
|
+
signs.push(-signs[index]), offsets.push(2 * available - offsets[index]);
|
|
2267
|
+
}
|
|
2268
|
+
let lower = 1, upper = Number.POSITIVE_INFINITY;
|
|
2269
|
+
for (let index = 0; index < signs.length; index += 1)
|
|
2270
|
+
signs[index] === 1 ? lower = Math.max(lower, 1 - offsets[index]) : upper = Math.min(upper, offsets[index] - 1);
|
|
2271
|
+
upper = Math.min(upper, 2 * (centers[0] - columnBands[0].start));
|
|
2272
|
+
let last = columnBands.length - 1, lastRoom = 2 * (columnBands[last].start + columnBands[last].size - centers[last]);
|
|
2273
|
+
if (signs[last] === 1 ? upper = Math.min(upper, lastRoom - offsets[last]) : lower = Math.max(lower, offsets[last] - lastRoom), lower > upper)
|
|
2274
|
+
return warnings.push({
|
|
2275
|
+
code: "grid-anchor-incompatible",
|
|
2276
|
+
severity: "warn",
|
|
2277
|
+
message: "category anchors cannot form positive column tracks inside the authored grid"
|
|
2278
|
+
}), columnBands;
|
|
2279
|
+
let leastSquares = signs.reduce(
|
|
2280
|
+
(sum2, sign, index) => sum2 + sign * (columnBands[index].size - offsets[index]),
|
|
2281
|
+
0
|
|
2282
|
+
) / signs.length, firstWidth = Math.max(lower, Math.min(upper, leastSquares));
|
|
2283
|
+
return centers.map((center, index) => {
|
|
2284
|
+
let size = signs[index] * firstWidth + offsets[index];
|
|
2285
|
+
return { start: center - size / 2, size };
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
function recordCategoryColumnAnchors(children, columnBands, derived, warnings) {
|
|
2289
|
+
for (let child of children) {
|
|
2290
|
+
let axis = child.geometry.axes.find((candidate) => candidate.axis === "x");
|
|
2291
|
+
child.placement.column !== 0 || child.placement.columnSpan !== columnBands.length || axis?.ticks.length !== columnBands.length || axis.ticks.forEach((tick, index) => {
|
|
2292
|
+
let target = columnBands[index].start + columnBands[index].size / 2, actual = child.slot.x + tick.pos;
|
|
2293
|
+
if (derived[`category:column:${child.panel.id}:${tick.at}`] = target, Math.abs(actual - target) > 1e-6) {
|
|
2294
|
+
let miss = Math.round(Math.abs(actual - target) * 1e3) / 1e3;
|
|
2295
|
+
warnings.push({
|
|
2296
|
+
code: "grid-anchor-inexact",
|
|
2297
|
+
severity: "warn",
|
|
2298
|
+
message: `panel '${child.panel.id}' category '${tick.at}' missed its authored column anchor by ${miss}px`
|
|
2299
|
+
});
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
function alignPlotEdges(input, scope, derived, warnings, theme) {
|
|
2305
|
+
let children = [...input];
|
|
2306
|
+
for (let [groupIndex, group] of scopeGroups(children, scope).entries()) {
|
|
2307
|
+
let candidates = group.filter((child) => child.relayout !== void 0);
|
|
2308
|
+
if (candidates.length < 2) continue;
|
|
2309
|
+
let left = maxOf(candidates.map((child) => child.slot.x + child.geometry.plot.x)), right = minOf(candidates.map((child) => child.slot.x + child.geometry.plot.x + child.geometry.plot.w));
|
|
2310
|
+
if (!(right > left)) {
|
|
2311
|
+
warnings.push({
|
|
2312
|
+
code: "grid-anchor-incompatible",
|
|
2313
|
+
severity: "warn",
|
|
2314
|
+
message: `${scope} plot-edge alignment group ${groupIndex + 1} has no shared horizontal span \u2014 plot edges were left unchanged`
|
|
2315
|
+
});
|
|
2316
|
+
continue;
|
|
2317
|
+
}
|
|
2318
|
+
derived[`plotEdges:${scope}:${groupIndex}:left`] = left, derived[`plotEdges:${scope}:${groupIndex}:right`] = right;
|
|
2319
|
+
for (let child of candidates) {
|
|
2320
|
+
let currentLeft = child.slot.x + child.geometry.plot.x, currentRight = currentLeft + child.geometry.plot.w;
|
|
2321
|
+
moveChildPlot(child, left - currentLeft, currentRight - right, theme);
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
return children;
|
|
2325
|
+
}
|
|
2326
|
+
function alignBaselines(input, scope, derived) {
|
|
2327
|
+
let children = [...input];
|
|
2328
|
+
for (let [groupIndex, group] of scopeGroups(children, scope).entries()) {
|
|
2329
|
+
let candidates = group.flatMap((child) => {
|
|
2330
|
+
let baseline = baselineY(child.geometry);
|
|
2331
|
+
return baseline === null || !child.relayout ? [] : [{ child, baseline: child.slot.y + baseline }];
|
|
2332
|
+
});
|
|
2333
|
+
if (candidates.length < 2) continue;
|
|
2334
|
+
let target = minOf(candidates.map((entry) => entry.baseline));
|
|
2335
|
+
derived[`baseline:${scope}:${groupIndex}`] = target;
|
|
2336
|
+
for (let entry of candidates) {
|
|
2337
|
+
let delta = entry.baseline - target;
|
|
2338
|
+
delta <= 0 || (entry.child.margin = {
|
|
2339
|
+
...entry.child.margin,
|
|
2340
|
+
bottom: (entry.child.margin.bottom ?? 16) + delta
|
|
2341
|
+
}, entry.child.geometry = entry.child.relayout(entry.child.margin));
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
return children;
|
|
2345
|
+
}
|
|
2346
|
+
function baselineY(geometry) {
|
|
2347
|
+
let axis = geometry.axes.find((candidate) => candidate.axis === "x" && candidate.baselineNodeId), node = axis?.baselineNodeId ? geometry.scene.find((candidate) => candidate.id === axis.baselineNodeId) : void 0;
|
|
2348
|
+
return node?.t === "line" && node.y1 === node.y2 ? node.y1 : null;
|
|
2349
|
+
}
|
|
2350
|
+
function guideRuns(occupied, orientation, at, start, end) {
|
|
2351
|
+
let vertical = orientation === "vertical", blocks = occupied.filter((claim) => claim.part !== "alignmentRule" && claim.rect.w > 2 && claim.rect.h > 2).filter((claim) => vertical ? claim.rect.x < at && claim.rect.x + claim.rect.w > at : claim.rect.y < at && claim.rect.y + claim.rect.h > at).map((claim) => vertical ? [claim.rect.y - 3, claim.rect.y + claim.rect.h + 3] : [claim.rect.x - 3, claim.rect.x + claim.rect.w + 3]).sort((a, b) => a[0] - b[0]), runs = [], from = Math.min(start, end), last = Math.max(start, end);
|
|
2352
|
+
for (let [a, b] of blocks)
|
|
2353
|
+
Math.min(a, last) - from >= 12 && runs.push([from, Math.min(a, last)]), from = Math.max(from, b);
|
|
2354
|
+
return last - from >= 12 && runs.push([from, last]), runs;
|
|
2355
|
+
}
|
|
2356
|
+
function appendAuthoredChild(child, scene, labels, axes, annotations, occupied, decisions, warnings, marks) {
|
|
2357
|
+
let prefix = `${child.panel.id}/`, dx = child.slot.x, dy = child.slot.y, legendItems = new Map((child.geometry.legend?.items ?? []).flatMap((item) => [
|
|
2358
|
+
[item.swatchNodeId, item.id],
|
|
2359
|
+
[item.labelId, item.id]
|
|
2360
|
+
]));
|
|
2361
|
+
for (let node of child.geometry.scene) {
|
|
2362
|
+
let legendItem = node.origin?.legendItem ?? legendItems.get(node.id);
|
|
2363
|
+
scene.push({
|
|
2364
|
+
...node,
|
|
2365
|
+
id: prefix + node.id,
|
|
2366
|
+
owner: prefixPanelOwner(node.owner, prefix),
|
|
2367
|
+
tx: (node.tx ?? 0) + dx,
|
|
2368
|
+
ty: (node.ty ?? 0) + dy,
|
|
2369
|
+
origin: {
|
|
2370
|
+
owner: node.origin?.owner ?? node.owner,
|
|
2371
|
+
panels: [child.panel.id, ...node.origin?.panels ?? []],
|
|
2372
|
+
...legendItem === void 0 ? {} : { legendItem }
|
|
2373
|
+
}
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
let noteData = panelNoteData(
|
|
2377
|
+
child.panel.type,
|
|
2378
|
+
child.panel.data,
|
|
2379
|
+
child.panel.options?.locale?.language
|
|
2380
|
+
), noteTexts = panelNoteTexts(child.geometry, noteData, child.panel.options, child.panel.annotations);
|
|
2381
|
+
for (let label of child.geometry.labels) {
|
|
2382
|
+
let noteText = noteTexts.texts.get(label.id), named = noteText === void 0 ? label : { ...label, noteText };
|
|
2383
|
+
labels.push(translatePlacedLabel(noteTexts.leftOut.has(label.id) ? { ...named, [LEFT_OUT_OF_NOTE]: !0 } : named, prefix, dx, dy));
|
|
2384
|
+
}
|
|
2385
|
+
for (let axis of child.geometry.axes)
|
|
2386
|
+
axes.push({
|
|
2387
|
+
...axis,
|
|
2388
|
+
baselineNodeId: axis.baselineNodeId ? prefix + axis.baselineNodeId : void 0,
|
|
2389
|
+
ticks: axis.ticks.map((tick) => ({
|
|
2390
|
+
...tick,
|
|
2391
|
+
pos: tick.pos + (axis.axis === "x" ? dx : dy),
|
|
2392
|
+
labelId: tick.labelId ? prefix + tick.labelId : void 0,
|
|
2393
|
+
gridNodeId: tick.gridNodeId ? prefix + tick.gridNodeId : void 0
|
|
2394
|
+
})),
|
|
2395
|
+
scenarioBands: axis.scenarioBands?.map((band) => ({
|
|
2396
|
+
...band,
|
|
2397
|
+
rect: { ...band.rect, x: band.rect.x + dx, y: band.rect.y + dy }
|
|
2398
|
+
}))
|
|
2399
|
+
});
|
|
2400
|
+
for (let annotation of child.geometry.annotations)
|
|
2401
|
+
annotations.push({
|
|
2402
|
+
...annotation,
|
|
2403
|
+
id: prefix + annotation.id,
|
|
2404
|
+
// The event anchor is a child-scene rect: move it with the panel.
|
|
2405
|
+
...annotation.event?.anchor ? { event: { ...annotation.event, anchor: translateRect(annotation.event.anchor, dx, dy) } } : {},
|
|
2406
|
+
nodeIds: annotation.nodeIds.map((id) => prefix + id),
|
|
2407
|
+
labelId: annotation.labelId ? prefix + annotation.labelId : void 0,
|
|
2408
|
+
labelNodeId: annotation.labelNodeId ? prefix + annotation.labelNodeId : annotation.labelId ? prefix + `label:${annotation.labelId}` : void 0
|
|
2409
|
+
});
|
|
2410
|
+
for (let claim of child.geometry.debug.occupied)
|
|
2411
|
+
occupied.push({
|
|
2412
|
+
...claim,
|
|
2413
|
+
owner: prefixPanelOwner(claim.owner, prefix),
|
|
2414
|
+
rect: { ...claim.rect, x: claim.rect.x + dx, y: claim.rect.y + dy }
|
|
2415
|
+
});
|
|
2416
|
+
for (let decision of child.geometry.debug.decisions)
|
|
2417
|
+
decisions.push({ ...decision, labelId: prefix + decision.labelId });
|
|
2418
|
+
let warningOffset = warnings.length;
|
|
2419
|
+
pushAll(
|
|
2420
|
+
warnings,
|
|
2421
|
+
child.geometry.warnings.map(({ field: _field, fix: _fix, ...warning }) => ({
|
|
2422
|
+
...warning,
|
|
2423
|
+
message: `[${child.panel.id}] ${warning.message}`,
|
|
2424
|
+
owner: warning.owner ? prefixPanelOwner(warning.owner, prefix) : void 0
|
|
2425
|
+
}))
|
|
2426
|
+
);
|
|
2427
|
+
let content = authoredOccupiedBounds(child.geometry);
|
|
2428
|
+
marks.panels.push({
|
|
2429
|
+
id: child.panel.id,
|
|
2430
|
+
type: child.panel.type,
|
|
2431
|
+
...child.recordOptions ? { chart: { options: child.recordOptions(), geometry: child.geometry, offset: { x: dx, y: dy }, warningOffset, warningOwnerPrefix: prefix, ...child.panel.options?.theme ? { theme: child.panel.options.theme } : {} } } : {},
|
|
2432
|
+
plot: {
|
|
2433
|
+
x: child.geometry.plot.x + dx,
|
|
2434
|
+
y: child.geometry.plot.y + dy,
|
|
2435
|
+
w: child.geometry.plot.w,
|
|
2436
|
+
h: child.geometry.plot.h
|
|
2437
|
+
},
|
|
2438
|
+
content: { x: content.x + dx, y: content.y + dy, w: content.w, h: content.h },
|
|
2439
|
+
title: child.panel.title ?? child.geometry.a11y.title ?? child.panel.id,
|
|
2440
|
+
row: child.placement.row,
|
|
2441
|
+
column: child.placement.column,
|
|
2442
|
+
rowSpan: child.placement.rowSpan,
|
|
2443
|
+
columnSpan: child.placement.columnSpan
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
var PLACED_LABEL_TRANSLATION_IS_EXHAUSTIVE = !0;
|
|
2447
|
+
function translatePlacedLabel(label, prefix, dx, dy) {
|
|
2448
|
+
return {
|
|
2449
|
+
...label,
|
|
2450
|
+
id: prefix + label.id,
|
|
2451
|
+
...label.claimId ? { claimId: prefix + label.claimId } : {},
|
|
2452
|
+
nodeId: label.nodeId ? prefix + label.nodeId : void 0,
|
|
2453
|
+
owner: prefixPanelOwner(label.owner, prefix),
|
|
2454
|
+
rect: translateRect(label.rect, dx, dy),
|
|
2455
|
+
backing: label.backing ? translateRect(label.backing, dx, dy) : void 0,
|
|
2456
|
+
leader: label.leader ? { ...label.leader, d: translateLeaderPath(label.leader.d, dx, dy) } : void 0
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
var PANEL_LOCAL_OWNER_FIELDS = [
|
|
2460
|
+
"annotationId",
|
|
2461
|
+
"valueLineId"
|
|
2462
|
+
];
|
|
2463
|
+
var OWNER_FIELD_CLASSIFICATION_IS_EXHAUSTIVE = !0;
|
|
2464
|
+
function prefixPanelOwner(owner, prefix) {
|
|
2465
|
+
let translated = { ...owner };
|
|
2466
|
+
for (let field of PANEL_LOCAL_OWNER_FIELDS) {
|
|
2467
|
+
let id = owner[field];
|
|
2468
|
+
id !== void 0 && (translated[field] = prefix + id);
|
|
2469
|
+
}
|
|
2470
|
+
return translated;
|
|
2471
|
+
}
|
|
2472
|
+
function translateRect(rect, dx, dy) {
|
|
2473
|
+
return { ...rect, x: rect.x + dx, y: rect.y + dy };
|
|
2474
|
+
}
|
|
2475
|
+
function translateLeaderPath(path, dx, dy) {
|
|
2476
|
+
let coordinateIndex = 0;
|
|
2477
|
+
return path.replace(
|
|
2478
|
+
/-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/gi,
|
|
2479
|
+
(raw) => String(Number(raw) + (coordinateIndex++ % 2 === 0 ? dx : dy))
|
|
2480
|
+
);
|
|
2481
|
+
}
|
|
2482
|
+
function authoredOccupiedBounds(geometry) {
|
|
2483
|
+
let rects = geometry.debug.occupied.filter((item) => item.kind !== "reserved").map((item) => item.rect);
|
|
2484
|
+
return rects.length > 0 ? boundsOf(rects) : geometry.plot;
|
|
2485
|
+
}
|
|
2486
|
+
function resolveRuleCoordinate(child, anchor, categoryId) {
|
|
2487
|
+
if (anchor === "plotLeft") return { axis: "x", value: child.slot.x + child.geometry.plot.x };
|
|
2488
|
+
if (anchor === "plotRight")
|
|
2489
|
+
return {
|
|
2490
|
+
axis: "x",
|
|
2491
|
+
value: child.slot.x + child.geometry.plot.x + child.geometry.plot.w
|
|
2492
|
+
};
|
|
2493
|
+
if (anchor === "baseline") {
|
|
2494
|
+
let value = baselineY(child.geometry);
|
|
2495
|
+
return value === null ? null : { axis: "y", value: child.slot.y + value };
|
|
2496
|
+
}
|
|
2497
|
+
if (!categoryId) return null;
|
|
2498
|
+
let tick = child.geometry.axes.find((candidate) => candidate.axis === "x")?.ticks.find((candidate) => candidate.at === categoryId);
|
|
2499
|
+
return tick ? { axis: "x", value: child.slot.x + tick.pos } : null;
|
|
2500
|
+
}
|
|
2501
|
+
function textPanelInk(id, tone) {
|
|
2502
|
+
if (tone === "muted") return { token: "inkMuted" };
|
|
2503
|
+
if (tone === "message")
|
|
2504
|
+
return { token: id.endsWith(":title") ? "ink" : "inkMuted" };
|
|
2505
|
+
}
|
|
2506
|
+
function wrapMeasured(text, font, maxWidth, maxLines, measure) {
|
|
2507
|
+
let words = text.split(/\s+/).filter(Boolean), lines = [], current = "";
|
|
2508
|
+
for (let word of words) {
|
|
2509
|
+
let next = current ? `${current} ${word}` : word;
|
|
2510
|
+
if (current && measure(next, font).width > maxWidth) {
|
|
2511
|
+
if (lines.push(current), current = word, lines.length === maxLines - 1) break;
|
|
2512
|
+
} else
|
|
2513
|
+
current = next;
|
|
2514
|
+
}
|
|
2515
|
+
return current && lines.length < maxLines && lines.push(current), lines.length > 0 ? lines : [""];
|
|
2516
|
+
}
|
|
2517
|
+
var DEFAULT_Y_GROUP = "grid:y";
|
|
2518
|
+
function panelScaleSemantics(panel) {
|
|
2519
|
+
return scalePanelSemantics({
|
|
2520
|
+
type: panel.type,
|
|
2521
|
+
data: panel.data,
|
|
2522
|
+
options: panel.options
|
|
2523
|
+
});
|
|
2524
|
+
}
|
|
2525
|
+
function probePanelGeometry(panel, options, valueAxis) {
|
|
2526
|
+
let definition = getChart(panel.type);
|
|
2527
|
+
if (!definition) return null;
|
|
2528
|
+
let panelOptions = panel.options ?? {};
|
|
2529
|
+
return layoutChildChart(panel.data, {
|
|
2530
|
+
...definition.defaults,
|
|
2531
|
+
...panelOptions,
|
|
2532
|
+
...panel.annotations ? { annotations: panel.annotations } : {},
|
|
2533
|
+
theme: panelOptions.theme ?? options.theme,
|
|
2534
|
+
size: { width: 720, height: 405 },
|
|
2535
|
+
valueAxis,
|
|
2536
|
+
measure: options.measure,
|
|
2537
|
+
typeClass: gridTypeClass(options)
|
|
2538
|
+
}, definition.layout);
|
|
2539
|
+
}
|
|
2540
|
+
function panelValueAxisBreak(panel) {
|
|
2541
|
+
let valueAxis = isRecord(panel.options?.valueAxis) ? panel.options.valueAxis : void 0, raw = valueAxis && isRecord(valueAxis.break) ? valueAxis.break : null;
|
|
2542
|
+
if (!raw) return null;
|
|
2543
|
+
let { from, to } = raw;
|
|
2544
|
+
return typeof from != "number" || typeof to != "number" ? null : { from, to };
|
|
2545
|
+
}
|
|
2546
|
+
function sharedBreakForGroup(panels, indexes) {
|
|
2547
|
+
let authored = [];
|
|
2548
|
+
for (let index of indexes) {
|
|
2549
|
+
let axisBreak = panelValueAxisBreak(panels[index]);
|
|
2550
|
+
axisBreak && authored.push(axisBreak);
|
|
2551
|
+
}
|
|
2552
|
+
return authored.length === 0 ? { kind: "none" } : new Set(authored.map((axisBreak) => `${axisBreak.from}|${axisBreak.to}`)).size > 1 ? { kind: "mismatch" } : { kind: "one", axisBreak: authored[0] };
|
|
2553
|
+
}
|
|
2554
|
+
function groupHonorsSharedBreak(panels, indexes, domain, axisBreak, options) {
|
|
2555
|
+
for (let index of indexes) {
|
|
2556
|
+
let panel = panels[index], panelOptions = panel.options ?? {}, valueAxis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, geometry = null;
|
|
2557
|
+
try {
|
|
2558
|
+
geometry = probePanelGeometry(panel, options, {
|
|
2559
|
+
...valueAxis,
|
|
2560
|
+
show: !0,
|
|
2561
|
+
min: domain[0],
|
|
2562
|
+
max: domain[1],
|
|
2563
|
+
break: axisBreak
|
|
2564
|
+
});
|
|
2565
|
+
} catch {
|
|
2566
|
+
return !1;
|
|
2567
|
+
}
|
|
2568
|
+
if (!geometry || geometry.refused || !geometry.axes.some((axis) => axis.axis === "y" && axis.break !== void 0)) return !1;
|
|
2569
|
+
}
|
|
2570
|
+
return !0;
|
|
2571
|
+
}
|
|
2572
|
+
function resolveSharedYDomains(panels, options, repeatFacet) {
|
|
2573
|
+
let groups = /* @__PURE__ */ new Map();
|
|
2574
|
+
panels.forEach((panel, index) => {
|
|
2575
|
+
let scaleGroup = isRecord(panel.options?.scaleGroup) ? panel.options.scaleGroup : void 0;
|
|
2576
|
+
if (typeof scaleGroup?.y != "string") return;
|
|
2577
|
+
let members = groups.get(scaleGroup.y) ?? [];
|
|
2578
|
+
members.push(index), groups.set(scaleGroup.y, members);
|
|
2579
|
+
});
|
|
2580
|
+
let panelDomains = panels.map((panel) => {
|
|
2581
|
+
let panelOptions = panel.options ?? {}, valueAxis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, { break: _ignoredBreak, ...axisWithoutBreak } = valueAxis, probe = probePanelGeometry(panel, options, { ...axisWithoutBreak, show: !0 });
|
|
2582
|
+
return probe && !probe.refused ? inferLinearYDomain(probe) : null;
|
|
2583
|
+
}), authoredGroups = groups.size > 0, semantics = panels.map(panelScaleSemantics), firstSemantics = semantics[0], matchingSemantics = firstSemantics != null && semantics.every(
|
|
2584
|
+
(candidate) => candidate !== null && candidate.unit === firstSemantics.unit && candidate.format === firstSemantics.format
|
|
2585
|
+
), sameMeasure = options.sharedScale === !0 || repeatFacet || firstSemantics?.unit != null || !!options.unit?.trim(), defaultShareEligible = panels.length > 1 && panelDomains.every((domain) => domain !== null) && matchingSemantics && sameMeasure;
|
|
2586
|
+
options.sharedScale !== !1 && !authoredGroups && defaultShareEligible && groups.set(
|
|
2587
|
+
DEFAULT_Y_GROUP,
|
|
2588
|
+
panels.map((_, index) => index)
|
|
2589
|
+
);
|
|
2590
|
+
let clampWarnings = leaveClampedPanelsOut(groups, panels), groupByIndex = /* @__PURE__ */ new Map();
|
|
2591
|
+
for (let [group, indexes] of groups)
|
|
2592
|
+
for (let index of indexes) groupByIndex.set(index, group);
|
|
2593
|
+
let { domains, breaks, warnings } = unionSharedYGroups(groups, panels, panelDomains, options);
|
|
2594
|
+
return {
|
|
2595
|
+
panels: pinSharedYAxis(panels, groupByIndex, domains, breaks),
|
|
2596
|
+
domains,
|
|
2597
|
+
members: Object.fromEntries([...groups].map(([group, indexes]) => [group, indexes.map((index) => panels[index].id)])),
|
|
2598
|
+
warnings: [...clampWarnings, ...warnings]
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
function ownYScale(panel) {
|
|
2602
|
+
let valueAxis = panel.options?.valueAxis;
|
|
2603
|
+
if (!isRecord(valueAxis)) return;
|
|
2604
|
+
if (valueAxis.log === !0 || valueAxis.log === "y" || valueAxis.log === "both") return "log";
|
|
2605
|
+
let clamp = valueAxis.clamp;
|
|
2606
|
+
if (!isRecord(clamp)) return;
|
|
2607
|
+
let y = isRecord(clamp.y) ? clamp.y : {};
|
|
2608
|
+
return [clamp.min, clamp.max, y.min, y.max].some((bound) => typeof bound == "number") ? "clamp" : void 0;
|
|
2609
|
+
}
|
|
2610
|
+
function leaveClampedPanelsOut(groups, panels) {
|
|
2611
|
+
let warnings = [];
|
|
2612
|
+
for (let [group, indexes] of groups) {
|
|
2613
|
+
let own = indexes.filter((index) => ownYScale(panels[index]) !== void 0);
|
|
2614
|
+
if (own.length !== 0 && (groups.set(group, indexes.filter((index) => !own.includes(index))), group !== DEFAULT_Y_GROUP))
|
|
2615
|
+
for (let reason of ["clamp", "log"]) {
|
|
2616
|
+
let names = own.filter((index) => ownYScale(panels[index]) === reason).map((index) => `'${panels[index].id ?? index}'`).join(", ");
|
|
2617
|
+
names && warnings.push({
|
|
2618
|
+
code: `scale-${reason}`,
|
|
2619
|
+
severity: "warn",
|
|
2620
|
+
message: `panel ${names} ${reason === "clamp" ? "caps its vertical axis with valueAxis.clamp" : "draws its vertical axis on a log scale"}, so it keeps its own y scale and leaves y scale group '${group}'`,
|
|
2621
|
+
suggest: `drop valueAxis.${reason} to share the scale, or take the panel out of scaleGroup.y`
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
return warnings;
|
|
2626
|
+
}
|
|
2627
|
+
function unionSharedYGroups(groups, panels, panelDomains, options) {
|
|
2628
|
+
let domains = {}, breaks = {}, warnings = [];
|
|
2629
|
+
for (let [group, indexes] of groups) {
|
|
2630
|
+
if (indexes.length < 2) continue;
|
|
2631
|
+
let memberDomains = [];
|
|
2632
|
+
for (let index of indexes) {
|
|
2633
|
+
let domain2 = panelDomains[index];
|
|
2634
|
+
domain2 && memberDomains.push(domain2);
|
|
2635
|
+
}
|
|
2636
|
+
if (memberDomains.length !== indexes.length) {
|
|
2637
|
+
group !== DEFAULT_Y_GROUP && warnings.push({
|
|
2638
|
+
code: "scale-mix",
|
|
2639
|
+
severity: "warn",
|
|
2640
|
+
message: `y scale group '${group}' contains a panel without a numeric linear y scale`
|
|
2641
|
+
});
|
|
2642
|
+
continue;
|
|
2643
|
+
}
|
|
2644
|
+
let domain = [
|
|
2645
|
+
minOf(memberDomains.map((entry) => entry[0])),
|
|
2646
|
+
maxOf(memberDomains.map((entry) => entry[1]))
|
|
2647
|
+
], agreed = sharedBreakForGroup(panels, indexes);
|
|
2648
|
+
if (agreed.kind === "mismatch") {
|
|
2649
|
+
warnings.push({
|
|
2650
|
+
code: "scale-break-mismatch",
|
|
2651
|
+
severity: "error",
|
|
2652
|
+
message: `y scale group '${group}' has conflicting valueAxis.break spans, so panels keep independent scales`,
|
|
2653
|
+
suggest: "give every panel in the group the same valueAxis.break, or drop the breaks"
|
|
2654
|
+
});
|
|
2655
|
+
continue;
|
|
2656
|
+
}
|
|
2657
|
+
if (agreed.kind === "one" && !groupHonorsSharedBreak(panels, indexes, domain, agreed.axisBreak, options)) {
|
|
2658
|
+
warnings.push({
|
|
2659
|
+
code: "scale-break-incompatible",
|
|
2660
|
+
severity: "error",
|
|
2661
|
+
message: `y scale group '${group}' cannot honour valueAxis.break { from: ${agreed.axisBreak.from}, to: ${agreed.axisBreak.to} } on every panel, so panels keep independent scales`,
|
|
2662
|
+
suggest: "choose a break every panel can honour, or drop valueAxis.break"
|
|
2663
|
+
});
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
domains[group] = domain, agreed.kind === "one" && (breaks[group] = agreed.axisBreak);
|
|
2667
|
+
}
|
|
2668
|
+
return { domains, breaks, warnings };
|
|
2669
|
+
}
|
|
2670
|
+
function pinSharedYAxis(panels, groupByIndex, domains, breaks) {
|
|
2671
|
+
return panels.map((panel, index) => {
|
|
2672
|
+
let group = groupByIndex.get(index), domain = group === void 0 ? void 0 : domains[group];
|
|
2673
|
+
if (!domain) return panel;
|
|
2674
|
+
let panelOptions = panel.options ?? {}, valueAxis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, axisBreak = group === void 0 ? void 0 : breaks[group];
|
|
2675
|
+
return {
|
|
2676
|
+
...panel,
|
|
2677
|
+
options: {
|
|
2678
|
+
...panelOptions,
|
|
2679
|
+
valueAxis: {
|
|
2680
|
+
...valueAxis,
|
|
2681
|
+
min: domain[0],
|
|
2682
|
+
max: domain[1],
|
|
2683
|
+
...axisBreak ? { break: axisBreak } : {}
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
function measureCaptionBand(panel, theme, measure, slotWidth, compact = !1) {
|
|
2690
|
+
let margin = isRecord(panel.options?.margin) ? panel.options.margin : {}, sides = canvasMargin(theme, slotWidth), width = Math.max(1, slotWidth - numeric(margin.left, sides.left) - numeric(margin.right, sides.right)), heightOf = (text, font) => measuredCaption(text, font, width, measure).height, height = 0;
|
|
2691
|
+
return panel.title && (height += heightOf(panel.title, compact ? { family: theme.type.family, ...theme.type.axis } : { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) })), panel.title && panel.caption && (height += 2), panel.caption && (height += heightOf(panel.caption, { family: theme.type.family, ...theme.type.axis })), height > 0 ? height + 6 : 0;
|
|
2692
|
+
}
|
|
2693
|
+
function numeric(value, fallback) {
|
|
2694
|
+
return typeof value == "number" ? value : fallback;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
// src/core/charts/grid/core.ts
|
|
2698
|
+
function normalizeGridInput(raw) {
|
|
2699
|
+
return isMetricStackData(raw) ? normalizeMetricStack(raw) : normalizeGridData(raw);
|
|
2700
|
+
}
|
|
2701
|
+
var gridCore = {
|
|
2702
|
+
type: "grid",
|
|
2703
|
+
sizing: { ...chartSizing("grid"), minWidth: CARD_MIN_WIDTH },
|
|
2704
|
+
title: "Grid / multi-tier",
|
|
2705
|
+
summary: "Facets, variance tiers and metric stacks with shared categories and computed readouts",
|
|
2706
|
+
aliases: ["facets"],
|
|
2707
|
+
layout: layoutGrid2,
|
|
2708
|
+
defaults: {},
|
|
2709
|
+
annotationKinds: [],
|
|
2710
|
+
prepare: normalizeGridInput,
|
|
2711
|
+
requiredKey: gridRequiredKey,
|
|
2712
|
+
compactForm: compactStacks
|
|
2713
|
+
};
|
|
2714
|
+
|
|
2715
|
+
export {
|
|
2716
|
+
gridFormOf,
|
|
2717
|
+
gridCore
|
|
2718
|
+
};
|