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,3378 @@
|
|
|
1
|
+
import {
|
|
2
|
+
prepareFractionAnnotations
|
|
3
|
+
} from "./chunk-3EZRM4YM.js";
|
|
4
|
+
import {
|
|
5
|
+
COMPACT_SOURCE_LINES,
|
|
6
|
+
DATE_TICK_STRIDES,
|
|
7
|
+
DENSITY_VALUES,
|
|
8
|
+
FOOTNOTE_REFS,
|
|
9
|
+
LADDER_TOLERANCE,
|
|
10
|
+
LEGEND_HEIGHT,
|
|
11
|
+
PRIORITY,
|
|
12
|
+
UNIT_LINE,
|
|
13
|
+
UNVERIFIED_DENSITY_REFUSALS,
|
|
14
|
+
aspectClassFor,
|
|
15
|
+
authoredNotes,
|
|
16
|
+
boundsOf,
|
|
17
|
+
createOccupiedIndex,
|
|
18
|
+
cutWithTitle,
|
|
19
|
+
dataOrder,
|
|
20
|
+
dateTickKeep,
|
|
21
|
+
dateTickKeepCalendar,
|
|
22
|
+
dateTickOrdinals,
|
|
23
|
+
densityNoteInList,
|
|
24
|
+
finishCutLabelNotes,
|
|
25
|
+
fitText,
|
|
26
|
+
footnoteMark,
|
|
27
|
+
footnoteSwitch,
|
|
28
|
+
frameTextOptions,
|
|
29
|
+
furnitureBudget,
|
|
30
|
+
furnitureScoped,
|
|
31
|
+
groundEdges,
|
|
32
|
+
hiddenNoteLine,
|
|
33
|
+
isOwnMark,
|
|
34
|
+
ladderHeights,
|
|
35
|
+
markLostOnBandWarnings,
|
|
36
|
+
markNotedLabels,
|
|
37
|
+
needsSeriesKey,
|
|
38
|
+
owedHiddenLabels,
|
|
39
|
+
plotChromeFloor,
|
|
40
|
+
rectsOverlap,
|
|
41
|
+
reportLabelOmissions,
|
|
42
|
+
scatterGroupIdentities,
|
|
43
|
+
scatterGroupNameIsDrawn,
|
|
44
|
+
settledAutoHeight,
|
|
45
|
+
subtitleLine,
|
|
46
|
+
unitMissing,
|
|
47
|
+
unitPrinted,
|
|
48
|
+
withAuthoredFootnotes,
|
|
49
|
+
withCutLabelNotes,
|
|
50
|
+
withDensityNotes,
|
|
51
|
+
withHiddenLabelNote,
|
|
52
|
+
withNoteInA11y
|
|
53
|
+
} from "./chunk-2JAWQ7VV.js";
|
|
54
|
+
import {
|
|
55
|
+
COMPACT_OMITTED_NOTES,
|
|
56
|
+
copyFrame,
|
|
57
|
+
disclosureNote,
|
|
58
|
+
freedChromeOf,
|
|
59
|
+
liveFooterExtra,
|
|
60
|
+
partNeedOf,
|
|
61
|
+
rankKeyShown,
|
|
62
|
+
staticFrame,
|
|
63
|
+
withEngineNotes
|
|
64
|
+
} from "./chunk-YTSSXSZR.js";
|
|
65
|
+
import {
|
|
66
|
+
DATE_NAME_LANGUAGES,
|
|
67
|
+
dateNames
|
|
68
|
+
} from "./chunk-QBR6IKIX.js";
|
|
69
|
+
import {
|
|
70
|
+
chartRefusals,
|
|
71
|
+
isRefused
|
|
72
|
+
} from "./chunk-DCCJRLAJ.js";
|
|
73
|
+
import {
|
|
74
|
+
MAGNITUDE_DIVISOR,
|
|
75
|
+
decimalCap,
|
|
76
|
+
formatWithSpec,
|
|
77
|
+
neededDecimals,
|
|
78
|
+
parseISODate
|
|
79
|
+
} from "./chunk-ASAON7G4.js";
|
|
80
|
+
import {
|
|
81
|
+
AUTO_MAX_DECIMALS,
|
|
82
|
+
chartString,
|
|
83
|
+
singleStops,
|
|
84
|
+
withChartDefaultStrings,
|
|
85
|
+
withLocaleStrings,
|
|
86
|
+
withNumberMarks,
|
|
87
|
+
withSmallValues,
|
|
88
|
+
wordLanguage
|
|
89
|
+
} from "./chunk-YQ2B3YVF.js";
|
|
90
|
+
import {
|
|
91
|
+
GRAMMAR_STROKE,
|
|
92
|
+
REMOVED_NAMES,
|
|
93
|
+
TABLE_HEAD_PARTS,
|
|
94
|
+
WIDE_CANVAS_MIN_WIDTH,
|
|
95
|
+
casingUnderFills,
|
|
96
|
+
fillEdges,
|
|
97
|
+
gridDash,
|
|
98
|
+
labelsOnFills,
|
|
99
|
+
libraryPatch,
|
|
100
|
+
marksOnBands,
|
|
101
|
+
panelTypeClass,
|
|
102
|
+
referenceLineClearance,
|
|
103
|
+
removedNameWarnings,
|
|
104
|
+
resolveTargetTheme,
|
|
105
|
+
resolveTheme,
|
|
106
|
+
secondaryFont,
|
|
107
|
+
spaceTokens,
|
|
108
|
+
stampHatchLook,
|
|
109
|
+
strokeToken,
|
|
110
|
+
tableHeadFloorPx,
|
|
111
|
+
textScaleOf,
|
|
112
|
+
textSizeOf,
|
|
113
|
+
typeWidthClass,
|
|
114
|
+
withoutOrphanAnnotationMarks
|
|
115
|
+
} from "./chunk-II7652VA.js";
|
|
116
|
+
import {
|
|
117
|
+
loadedDeferred
|
|
118
|
+
} from "./chunk-2MTWKMEG.js";
|
|
119
|
+
import {
|
|
120
|
+
addWhereAbsent
|
|
121
|
+
} from "./chunk-ZQ4VFQID.js";
|
|
122
|
+
import {
|
|
123
|
+
DEFAULT_TARGET,
|
|
124
|
+
NormalizeError,
|
|
125
|
+
TARGET_SIZE,
|
|
126
|
+
naturalOutputSize,
|
|
127
|
+
resolveCanvasOptions,
|
|
128
|
+
resolveSize,
|
|
129
|
+
resolveSubtitle,
|
|
130
|
+
resolveTargetSize,
|
|
131
|
+
targetFloorsPx,
|
|
132
|
+
withDefaultTarget
|
|
133
|
+
} from "./chunk-SGD3ZHID.js";
|
|
134
|
+
import {
|
|
135
|
+
maxOf,
|
|
136
|
+
minOf,
|
|
137
|
+
pushAll
|
|
138
|
+
} from "./chunk-WYJEOMNY.js";
|
|
139
|
+
import {
|
|
140
|
+
compareText,
|
|
141
|
+
defaultMeasurer,
|
|
142
|
+
measureText,
|
|
143
|
+
wrapText
|
|
144
|
+
} from "./chunk-TXINIAFL.js";
|
|
145
|
+
|
|
146
|
+
// src/core/themeDensity.ts
|
|
147
|
+
var COMPACT_SPACE_RATIO = 22 / 27, LABEL_PAD = { min: 1, max: 16 }, TIER_FACET = { min: 4, max: 64 }, LEGEND_ROW = { min: 12, max: 28 }, GAP = { min: 0, max: 32 }, CANVAS = { min: 0, max: 96 };
|
|
148
|
+
function scaleSpacePx(value, min, max) {
|
|
149
|
+
return value === 0 && min === 0 ? 0 : Math.min(max, Math.max(min, Math.round(value * COMPACT_SPACE_RATIO)));
|
|
150
|
+
}
|
|
151
|
+
function scaleMargin(margin) {
|
|
152
|
+
return {
|
|
153
|
+
top: scaleSpacePx(margin.top, CANVAS.min, CANVAS.max),
|
|
154
|
+
right: scaleSpacePx(margin.right, CANVAS.min, CANVAS.max),
|
|
155
|
+
bottom: scaleSpacePx(margin.bottom, CANVAS.min, CANVAS.max),
|
|
156
|
+
left: scaleSpacePx(margin.left, CANVAS.min, CANVAS.max)
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function scaleGap(tokens, wide) {
|
|
160
|
+
return {
|
|
161
|
+
titleSubtitle: scaleSpacePx(tokens.gapTitleSubtitle, GAP.min, GAP.max),
|
|
162
|
+
subtitlePlot: scaleSpacePx(tokens.gapSubtitlePlot, GAP.min, GAP.max),
|
|
163
|
+
subtitlePlotWide: scaleSpacePx(wide.gapSubtitlePlot, GAP.min, GAP.max),
|
|
164
|
+
axisFootnote: scaleSpacePx(tokens.gapAxisFootnote, GAP.min, GAP.max),
|
|
165
|
+
axisFootnoteWide: scaleSpacePx(wide.gapAxisFootnote, GAP.min, GAP.max),
|
|
166
|
+
footnoteSource: scaleSpacePx(tokens.gapFootnoteSource, GAP.min, GAP.max),
|
|
167
|
+
legend: scaleSpacePx(tokens.gapLegend, GAP.min, GAP.max)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function themeForDensity(theme, density = "comfortable", width) {
|
|
171
|
+
if (density !== "compact") return theme;
|
|
172
|
+
let base = spaceTokens(theme, width !== void 0 && width < WIDE_CANVAS_MIN_WIDTH ? width : WIDE_CANVAS_MIN_WIDTH - 1), wide = spaceTokens(theme, WIDE_CANVAS_MIN_WIDTH);
|
|
173
|
+
return {
|
|
174
|
+
...theme,
|
|
175
|
+
space: {
|
|
176
|
+
tierGap: scaleSpacePx(theme.space.tierGap, TIER_FACET.min, TIER_FACET.max),
|
|
177
|
+
facetGap: scaleSpacePx(theme.space.facetGap, TIER_FACET.min, TIER_FACET.max),
|
|
178
|
+
labelPad: scaleSpacePx(theme.space.labelPad, LABEL_PAD.min, LABEL_PAD.max),
|
|
179
|
+
canvas: { base: scaleMargin(base.margin), wide: scaleMargin(wide.margin) },
|
|
180
|
+
gap: scaleGap(base, wide),
|
|
181
|
+
legendRowH: scaleSpacePx(base.legendRowH, LEGEND_ROW.min, LEGEND_ROW.max),
|
|
182
|
+
// A fixed bar row is the theme's row, at every density.
|
|
183
|
+
...theme.space.barRow ? { barRow: theme.space.barRow } : {}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/core/compact.ts
|
|
189
|
+
function tightTheme(ref, width) {
|
|
190
|
+
let dense = themeForDensity(resolveTheme(ref), "compact", width), preset = (typeof ref == "string" ? ref : ref?.preset) ?? "boardroom", authored = typeof ref == "object" && ref !== null ? ref.overrides ?? {} : {};
|
|
191
|
+
return { preset, overrides: libraryPatch({ ...authored, space: dense.space }, authored) };
|
|
192
|
+
}
|
|
193
|
+
function authoredList(options) {
|
|
194
|
+
return options.authoredFootnotes ?? options.footnotes;
|
|
195
|
+
}
|
|
196
|
+
var MOVED_SUBTITLE = /* @__PURE__ */ Symbol("boardplot.movedSubtitle");
|
|
197
|
+
function omittedCompactNotes(type, options) {
|
|
198
|
+
let hasReplacementNote = "methodNote" in options && options.methodNote === !1, preserveNotes = staticFrame.pinned || type === "bullet" || hasReplacementNote || !options.title, moved = options[MOVED_SUBTITLE], hidden = hiddenNoteLine(options);
|
|
199
|
+
return preserveNotes ? [] : authoredNotes(options).filter((note) => note !== moved && note !== hidden);
|
|
200
|
+
}
|
|
201
|
+
function compactOptions(type, options, floor, width) {
|
|
202
|
+
let omitted = omittedCompactNotes(type, options), base = omitted.length === 0 ? { ...options, mode: "compact" } : withAuthoredFootnotes({ ...options, mode: "compact", [COMPACT_OMITTED_NOTES]: omitted.length }, authoredNotes(options).filter((note) => !omitted.includes(note)), authoredList(options));
|
|
203
|
+
return floor ? withAuthoredFootnotes({
|
|
204
|
+
...base,
|
|
205
|
+
legend: options.legend,
|
|
206
|
+
// The tight band keeps the author's density. Value labels fit one by
|
|
207
|
+
// one against the marks, in priority order; a forced 'minimal' would drop
|
|
208
|
+
// every segment value as a block although they fit. An authored
|
|
209
|
+
// 'minimal' keeps its gate.
|
|
210
|
+
theme: tightTheme(options.theme, width),
|
|
211
|
+
sizeFloor: floor
|
|
212
|
+
// Notes that stay on the canvas stay in the list: the registry puts the note that names a
|
|
213
|
+
// hidden label there, and a cleared list left that label owed (the chart then refused for it).
|
|
214
|
+
}, authoredNotes(options).filter((note) => !omitted.includes(note)), authoredList(options)) : base;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/core/grid/varianceTiers.ts
|
|
218
|
+
var VARIANCE_TIER = /* @__PURE__ */ Symbol("varianceTier");
|
|
219
|
+
function varianceTierWeights(panels) {
|
|
220
|
+
if (!(panels.length < 2 || panels.filter((panel) => panel.type === "column").length !== 1) && panels.every((panel) => panel.type === "column" || panel.type === "variance" && panel.options?.variant !== "integrated"))
|
|
221
|
+
return panels.map((panel) => panel.type !== "column" ? 1 : panel.options?.variant === "stacked" && panels.length === 2 ? 3 : 4);
|
|
222
|
+
}
|
|
223
|
+
function isSingleVarianceTier(options) {
|
|
224
|
+
return !!(options && typeof options == "object" && options[VARIANCE_TIER] === 2);
|
|
225
|
+
}
|
|
226
|
+
function isVarianceTier(options) {
|
|
227
|
+
return !!(options && typeof options == "object" && options[VARIANCE_TIER]);
|
|
228
|
+
}
|
|
229
|
+
function balanceVarianceTierPlots(slots, children, weights, layout) {
|
|
230
|
+
if (!weights) return children;
|
|
231
|
+
let measured = children;
|
|
232
|
+
if (children.some((child) => child.geo.plot.h <= 10)) {
|
|
233
|
+
let heights2 = slots.map((slot) => slot.h), extra = maxOf(heights2);
|
|
234
|
+
try {
|
|
235
|
+
slots.forEach((slot) => {
|
|
236
|
+
slot.h += extra;
|
|
237
|
+
}), measured = layout();
|
|
238
|
+
} finally {
|
|
239
|
+
slots.forEach((slot, i) => {
|
|
240
|
+
slot.h = heights2[i];
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (measured.some((child) => child.geo.plot.h <= 10)) return layout();
|
|
244
|
+
}
|
|
245
|
+
let chrome = measured.map((child) => child.geo.size.height - child.geo.plot.h), total = slots.reduce((sum, slot, i) => sum + slot.h - chrome[i], 0), weight = weights.reduce((sum, value) => sum + value, 0), heights = weights.map((value) => total * value / weight);
|
|
246
|
+
return heights.some((height) => height < 10) || heights.every((height, i) => Math.abs(height - children[i].geo.plot.h) < 1e-3) ? measured === children ? children : layout() : (slots.forEach((slot, i) => {
|
|
247
|
+
slot.h = chrome[i] + heights[i];
|
|
248
|
+
}), layout());
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// src/core/lint/type.ts
|
|
252
|
+
var displayPx = (value) => String(Math.round(value * 100) / 100), MARK_MIN_EFFECTIVE_PX = {
|
|
253
|
+
seriesStroke: 1.25,
|
|
254
|
+
markerRadius: 2,
|
|
255
|
+
dashSegment: 1.25
|
|
256
|
+
};
|
|
257
|
+
function effectiveMarkerRadius(rawNode) {
|
|
258
|
+
let node = rawNode;
|
|
259
|
+
if (node.part !== "marker") return;
|
|
260
|
+
if (node.t === "circle" && typeof node.r == "number") return node.r;
|
|
261
|
+
if (node.t === "rect" && typeof node.rect?.w == "number" && typeof node.rect.h == "number")
|
|
262
|
+
return Math.min(node.rect.w, node.rect.h) / 2;
|
|
263
|
+
if (node.t !== "path" || typeof node.d != "string" || !/^[MLZ0-9eE+.,\s-]+$/.test(node.d)) return;
|
|
264
|
+
let coordinates = node.d.match(/[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/gi)?.map(Number) ?? [];
|
|
265
|
+
if (coordinates.length < 4 || coordinates.length % 2 !== 0 || coordinates.some((value) => !Number.isFinite(value)))
|
|
266
|
+
return;
|
|
267
|
+
let xs = coordinates.filter((_, index) => index % 2 === 0), ys = coordinates.filter((_, index) => index % 2 === 1);
|
|
268
|
+
return Math.min(maxOf(xs) - minOf(xs), maxOf(ys) - minOf(ys)) / 2;
|
|
269
|
+
}
|
|
270
|
+
function typeDocLints(type, options, geo, observedWidth) {
|
|
271
|
+
if (geo.warnings?.some((w) => w.severity === "error")) return [];
|
|
272
|
+
let target = options?.target ?? geo.presentation?.target ?? DEFAULT_TARGET;
|
|
273
|
+
return targetTypeLints(type, options, geo, target, observedWidth).filter((finding) => !geo.warnings?.some((existing) => existing.code === finding.code && existing.message === finding.message));
|
|
274
|
+
}
|
|
275
|
+
function targetTypeLints(type, options, geo, target, observedWidth) {
|
|
276
|
+
let roleFloors = targetFloorsPx(target), headFloor = tableHeadFloorPx(target), emitted = /* @__PURE__ */ new Map();
|
|
277
|
+
for (let raw of geo.scene) {
|
|
278
|
+
let node = raw;
|
|
279
|
+
if (node.t !== "text" || node.opacity === 0 || node.lines?.every((line) => line.length === 0) || typeof node.font?.size != "number" || !Number.isFinite(node.font.size) || node.font.size <= 0) continue;
|
|
280
|
+
let role = node.typeRole ?? "label", floor = TABLE_HEAD_PARTS.has(node.part ?? "") ? headFloor : roleFloors[role], key = `${role}|${node.font.size}|${floor}`, existing = emitted.get(key);
|
|
281
|
+
existing ? existing.count++ : emitted.set(key, { role, size: node.font.size, floor, count: 1 });
|
|
282
|
+
}
|
|
283
|
+
let entries = [...emitted.values()].sort((a, b) => compareText(a.role, b.role) || a.size - b.size || a.floor - b.floor), details = (scale2) => entries.filter((entry) => entry.size * scale2 < entry.floor - 1e-9).map(({ role, size, floor, count }) => `${role} ${displayPx(size)}px \u2192 ${displayPx(size * scale2)} effective px (floor ${displayPx(floor)}, ${count} node${count === 1 ? "" : "s"})`), findings = [], native = details(1), textScale = textScaleOf(options), textSize = textSizeOf(options);
|
|
284
|
+
if (native.length > 0 && textScale < 1) {
|
|
285
|
+
let below = entries.filter((entry) => entry.size < entry.floor - 1e-9), worst = below.reduce((a, b) => b.floor / b.size > a.floor / a.size ? b : a), smallest = below.reduce((a, b) => b.size < a.size ? b : a), needed = Math.ceil(textScale * (worst.floor / worst.size) * 100 - 1e-6) / 100, option = textSize === void 0 ? "textScale" : "textSize", neededSize = textSize === void 0 ? void 0 : Math.ceil(textSize * (worst.floor / worst.size) * 100 - 1e-6) / 100;
|
|
286
|
+
findings.push({
|
|
287
|
+
code: "text-below-floor",
|
|
288
|
+
severity: "warn",
|
|
289
|
+
message: `'${type}' draws text below the ${target} floor at ${option} ${displayPx(textSize ?? textScale)}: the smallest is ${smallest.role} ${displayPx(smallest.size)}px (floor ${displayPx(smallest.floor)}px); ${native.join("; ")}.`,
|
|
290
|
+
suggest: textSize === void 0 ? `Raise textScale to ${displayPx(needed)}.` : `Raise textSize to ${displayPx(neededSize)}.`,
|
|
291
|
+
field: ["options", textSize === void 0 ? "textScale" : "textSize"]
|
|
292
|
+
});
|
|
293
|
+
} else native.length > 0 && findings.push({
|
|
294
|
+
code: "type-below-native-min",
|
|
295
|
+
severity: "warn",
|
|
296
|
+
message: `'${type}' has text below the ${target} floor at its natural size: ${native.join("; ")}.`,
|
|
297
|
+
suggest: "Increase the authored type sizes to the target floors, then render again."
|
|
298
|
+
});
|
|
299
|
+
let embed = options?.embed, width = observedWidth ?? embed?.width;
|
|
300
|
+
if (typeof width != "number" || !Number.isFinite(width) || width <= 0 || geo.size.width <= 0) return findings;
|
|
301
|
+
let scale = width / geo.size.width, minimumScale = Math.max(0.9, maxOf(entries.map(({ size, floor }) => floor / size)));
|
|
302
|
+
if (scale < minimumScale - 1e-9) {
|
|
303
|
+
let violations = details(scale);
|
|
304
|
+
findings.push({
|
|
305
|
+
code: "type-below-effective-min",
|
|
306
|
+
severity: "warn",
|
|
307
|
+
message: `'${type}' has ${observedWidth === void 0 ? "declared" : "observed"} display width ${displayPx(width)}px on a ${displayPx(geo.size.width)}px canvas (scale ${displayPx(scale)}; minimum safe scale ${displayPx(minimumScale)}).` + (violations.length ? ` ${violations.join("; ")}.` : " Display shrink exceeds 10%."),
|
|
308
|
+
suggest: `Render for the actual slot, allow scrolling, or offer a full-size view at least ${Math.ceil(geo.size.width * minimumScale)}px wide.`,
|
|
309
|
+
...observedWidth === void 0 ? { field: ["options", "embed", "width"] } : {}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return pushAll(findings, markDocLints(type, geo, width, observedWidth !== void 0)), findings;
|
|
313
|
+
}
|
|
314
|
+
function markDocLints(type, geo, embedWidth, observed = !1) {
|
|
315
|
+
let s = embedWidth / geo.size.width, canvasWidth = geo.size.width, EPS = 1e-9, findings = [], markViolations = /* @__PURE__ */ new Map(), addMark = (label, raw, floor) => {
|
|
316
|
+
if (raw * s >= floor - EPS) return;
|
|
317
|
+
let key = `${label}|${raw}|${floor}`, current = markViolations.get(key);
|
|
318
|
+
current ? current.count += 1 : markViolations.set(key, { label, raw, floor, count: 1 });
|
|
319
|
+
};
|
|
320
|
+
for (let rawNode of geo.scene) {
|
|
321
|
+
let node = rawNode, stroke = rawNode.stroke, pageColour = typeof stroke == "object" && stroke !== null && stroke.token === "background";
|
|
322
|
+
if ((node.t === "line" || node.t === "path") && (node.part === "line" || node.part === "referenceLine") && typeof node.width == "number" && !pageColour) {
|
|
323
|
+
let isContextStroke = node.part === "referenceLine" || node.width < 2, series = node.owner?.seriesId ? ` '${node.owner.seriesId}'` : "", floor = node.part === "referenceLine" ? GRAMMAR_STROKE.rule : MARK_MIN_EFFECTIVE_PX.seriesStroke;
|
|
324
|
+
addMark(`${isContextStroke ? "context " : "hero/series "}stroke${series}`, node.width, floor);
|
|
325
|
+
for (let [index, segment] of (node.dash ?? []).entries())
|
|
326
|
+
if (Number.isFinite(segment) && segment > 0) {
|
|
327
|
+
let painted = index % 2 === 0 && node.lineCap === "round" ? segment + node.width : segment;
|
|
328
|
+
addMark("dash segment", painted, MARK_MIN_EFFECTIVE_PX.dashSegment);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (node.part === "marker") {
|
|
332
|
+
let radius = effectiveMarkerRadius(node);
|
|
333
|
+
radius !== void 0 && addMark("marker radius", radius, MARK_MIN_EFFECTIVE_PX.markerRadius);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (markViolations.size > 0) {
|
|
337
|
+
let markSMin = 0, details = [...markViolations.values()].sort((a, b) => a.floor - b.floor || a.raw - b.raw || compareText(a.label, b.label)).map(({ label, raw: rawSize, floor, count }) => (markSMin = Math.max(markSMin, floor / rawSize), `${label} ${rawSize}px \u2192 ${(rawSize * s).toFixed(1)} effective px (floor ${floor}, ${count} node${count === 1 ? "" : "s"})`)), minEmbed = Math.ceil(canvasWidth * markSMin);
|
|
338
|
+
findings.push({
|
|
339
|
+
code: "mark-below-effective-min",
|
|
340
|
+
// The mark floor is the mark half of the existing effective-pixel text gate, so
|
|
341
|
+
// it deliberately shares the registered severity.
|
|
342
|
+
severity: "warn",
|
|
343
|
+
message: `'${type}' has ${observed ? "observed" : "declared"} display width ${displayPx(embedWidth)} on a ${displayPx(canvasWidth)} canvas, so it is shown at ${s.toFixed(2)} of drawn size: ${details.join("; ")}. At that scale the marks disappear.`,
|
|
344
|
+
suggest: `Embed it at ${minEmbed}px or wider, or render a canvas the size of the slot.`,
|
|
345
|
+
...observed ? {} : { field: ["options", "embed", "width"] }
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
return findings;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/core/legendPolicy.ts
|
|
352
|
+
var AUTO_LEGEND = /* @__PURE__ */ Symbol("autoLegend");
|
|
353
|
+
function isAutomaticLegend(options) {
|
|
354
|
+
return options?.[AUTO_LEGEND] === !0;
|
|
355
|
+
}
|
|
356
|
+
var ID_FIELDS = ["seriesId", "segmentId", "categoryId", "pointId"], REFERENCE_PARTS = /* @__PURE__ */ new Set(["referenceLine", "referenceTick", "referenceMarker"]);
|
|
357
|
+
function normalizedName(text) {
|
|
358
|
+
return text.replace(/\s+/gu, " ").trim();
|
|
359
|
+
}
|
|
360
|
+
function labelContexts(type, data, options, prefix = "") {
|
|
361
|
+
let definition = getChart(type);
|
|
362
|
+
if (type = definition?.type ?? type, type !== "grid") return [{ type, data, options, prefix }];
|
|
363
|
+
let panels = (definition?.prepare?.(data) ?? data)?.panels;
|
|
364
|
+
return Array.isArray(panels) ? panels.flatMap((panel) => {
|
|
365
|
+
let panelPrefix = `${prefix}${panel.id}/`;
|
|
366
|
+
return labelContexts(panel.type, panel.data, panel.options, panelPrefix).map((context) => ({
|
|
367
|
+
...context,
|
|
368
|
+
...context.prefix === panelPrefix ? { panelTitleId: `${prefix}panel:${panel.id}:title` } : {}
|
|
369
|
+
}));
|
|
370
|
+
}) : [];
|
|
371
|
+
}
|
|
372
|
+
function panelTitlesCoverSeries(body, contexts, id, name) {
|
|
373
|
+
let panels = contexts.flatMap((context) => {
|
|
374
|
+
let series = context.data?.series, primary = Array.isArray(series) ? series.filter((entry) => entry.role !== "reference") : [];
|
|
375
|
+
return primary.some((entry) => entry.id === id) ? [{ context, primary }] : [];
|
|
376
|
+
});
|
|
377
|
+
return panels.length > 0 && panels.every(({ context, primary }) => primary.length === 1 && body.some((node) => (node.id === `label:${context.panelTitleId}` || node.part === "tierCaption" && node.id.startsWith(context.prefix)) && node.t === "text" && name.test(normalizedName(node.lines.join(" ")))));
|
|
378
|
+
}
|
|
379
|
+
function labelIncludesName(node, field, context, marks) {
|
|
380
|
+
if (!context) return !1;
|
|
381
|
+
let { type, options, prefix } = context;
|
|
382
|
+
if (options?.labels === !1) return !1;
|
|
383
|
+
let identity = field === "seriesId" || field === "segmentId" ? "series" : "category", setting = options?.labels?.[node.part];
|
|
384
|
+
return setting === !1 ? !1 : node.part === "axisTitle" ? type === "combo" && identity === "series" : Array.isArray(setting) ? (type === "bar" || type === "dot") && (node.part === "point" || node.part === "segment") ? !1 : setting.includes(identity) : node.part === "category" ? identity === "category" : type === "pie" && node.part === "outsidePie" && identity === "category" ? options?.labels?.category !== !1 && marks.filter((mark) => mark.part === "slice" && mark.id.startsWith(prefix)).length <= 4 : node.part === "point" ? !1 : node.part === "series" && identity === "series";
|
|
385
|
+
}
|
|
386
|
+
function subtitleCoversSeries(geometry, data, options, id, name) {
|
|
387
|
+
let series = data?.series, primary = Array.isArray(series) ? series.filter((entry) => entry.role !== "reference") : [];
|
|
388
|
+
if (primary.length !== 1 || primary[0].id !== id) return !1;
|
|
389
|
+
let subtitle = resolveSubtitle(options?.subtitle);
|
|
390
|
+
if (!subtitle) return !1;
|
|
391
|
+
let lines = geometry.scene.flatMap((entry) => entry.t === "text" && entry.part === "subtitle" ? entry.lines : []);
|
|
392
|
+
if (!name.test(normalizedName(lines.join(" ")))) return !1;
|
|
393
|
+
let descriptors = [subtitle.measure];
|
|
394
|
+
return unitPrinted({ subtitle, unit: options?.unit, unitShown: options?.unitShown }) && descriptors.push(options.unit), descriptors.some((text) => name.test(normalizedName(text)));
|
|
395
|
+
}
|
|
396
|
+
function legendIsCovered(baseline, candidate, data, options) {
|
|
397
|
+
if (baseline.legend?.items.length && baseline.type !== "scatter") return !1;
|
|
398
|
+
let body = baseline.scene.filter((node) => node.part !== "legendLabel" && node.part !== "swatch");
|
|
399
|
+
if (body.some((node) => REFERENCE_PARTS.has(node.part))) return !1;
|
|
400
|
+
let marks = body.filter((node) => node.t !== "text" && node.part !== "labelSwatch"), contexts = labelContexts(baseline.type, data, options).sort((a, b) => b.prefix.length - a.prefix.length), scatterGroups = baseline.type === "scatter" ? scatterGroupIdentities(data, baseline) : [];
|
|
401
|
+
return (candidate.legend?.items ?? []).every((item) => {
|
|
402
|
+
if (baseline.legend?.items.some((existing) => existing.id === item.id)) return !0;
|
|
403
|
+
let keyLabel = candidate.scene.find((node) => node.id === item.labelId);
|
|
404
|
+
if (keyLabel?.t !== "text") return !1;
|
|
405
|
+
let name = normalizedName(keyLabel.lines.join(" "));
|
|
406
|
+
if (!name) return !1;
|
|
407
|
+
let group = scatterGroups.find((group2) => group2.id === item.id);
|
|
408
|
+
if (group) return scatterGroupNameIsDrawn(baseline, group);
|
|
409
|
+
let field = ID_FIELDS.find((key) => marks.some((node) => node.owner[key] === item.id));
|
|
410
|
+
if (!field) return !1;
|
|
411
|
+
let escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), fullName = new RegExp(`(?<![\\p{L}\\p{N}_])${escaped}(?![\\p{L}\\p{N}_])`, "u");
|
|
412
|
+
return field === "seriesId" && panelTitlesCoverSeries(body, contexts, item.id, fullName) || candidate.legend?.items.length === 1 && field === "seriesId" && subtitleCoversSeries(baseline, data, options, item.id, new RegExp(fullName.source, "iu")) ? !0 : body.some((node) => node.t === "text" && node.owner[field] === item.id && fullName.test(normalizedName(node.lines.join(" "))) && labelIncludesName(node, field, contexts.find((context) => node.id.startsWith(context.prefix)), marks));
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function keysNeedNames(baseline, candidate) {
|
|
416
|
+
let items = candidate.legend?.items ?? [];
|
|
417
|
+
return items.length > 1 || items.length === 1 && !baseline.scene.some((node) => node.owner.seriesId === items[0].id);
|
|
418
|
+
}
|
|
419
|
+
function unitLineMeasure(data, options) {
|
|
420
|
+
let series = data?.series, names = Array.isArray(series) ? series.filter((entry) => entry?.role !== "reference").map((entry) => typeof entry.label == "string" ? entry.label.trim() : "") : [];
|
|
421
|
+
return names.length > 0 && names.length <= 2 && names.every(Boolean) ? names.join(` ${chartString(options, "and")} `) : "";
|
|
422
|
+
}
|
|
423
|
+
function footnoteRefs(data) {
|
|
424
|
+
let refs = /* @__PURE__ */ new Set(), walk = (value, depth) => {
|
|
425
|
+
if (!(depth > 6 || value === null || typeof value != "object")) {
|
|
426
|
+
if (Array.isArray(value)) {
|
|
427
|
+
for (let entry of value) walk(entry, depth + 1);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
for (let [key, entry] of Object.entries(value))
|
|
431
|
+
key === "footnote" && typeof entry == "number" ? refs.add(entry) : walk(entry, depth + 1);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
return walk(data, 0), refs;
|
|
435
|
+
}
|
|
436
|
+
function layoutWithLegendPolicy(definition, data, options) {
|
|
437
|
+
let run = prepareLegendLayout(definition, data);
|
|
438
|
+
try {
|
|
439
|
+
return run(options);
|
|
440
|
+
} finally {
|
|
441
|
+
run.finish();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function prepareLegendLayout(definition, data, origins = /* @__PURE__ */ new WeakMap()) {
|
|
445
|
+
let baseline = prepareFitLayout(definition, data, origins), candidate = prepareFitLayout(definition, data, origins), unitBaseline = prepareFitLayout(definition, data, origins), unitCandidate = prepareFitLayout(definition, data, origins), compactLayouts = /* @__PURE__ */ new Map(), series = data?.series, names = new Map(Array.isArray(series) ? series.map((item) => [item.id, item.label ?? item.id]) : []), refs = footnoteRefs(data), run = ((options) => {
|
|
446
|
+
Array.isArray(options?.footnotes) && options.footnotes.length > 0 && (options = Object.assign({}, options, { [FOOTNOTE_REFS]: refs }));
|
|
447
|
+
let automatic = names.size > 0 && !contentSized(definition.type, options) && panelTypeClass(options) === void 0 && (options?.legend === void 0 || options.legend === "auto");
|
|
448
|
+
automatic && options?.[LEGEND_HEIGHT] === void 0 && (options = Object.assign({}, options, { [LEGEND_HEIGHT]: { height: "auto", names } }));
|
|
449
|
+
let result = layoutWithKeys(definition, data, options, baseline, candidate);
|
|
450
|
+
if (!result.refused && panelTypeClass(options) === void 0 && unitMissing(options, result)) {
|
|
451
|
+
let withLine = layoutWithKeys(definition, data, Object.assign({}, options, { [UNIT_LINE]: unitLineMeasure(data, options) }), unitBaseline, unitCandidate);
|
|
452
|
+
withLine.refused || (result = withLine);
|
|
453
|
+
}
|
|
454
|
+
if (!result.refused && result.legend && panelTypeClass(options) === void 0 && options?.[LEGEND_HEIGHT]?.height === "auto" && automatic) {
|
|
455
|
+
let furniture = (geo) => geo.size.height - (geo.frame.plotRect ?? geo.plot).h + (geo.derived.tickBand?.reserved ?? 0), excess = furniture(result) - result.size.height * furnitureBudget(result.size.width);
|
|
456
|
+
if (excess > 0 && excess < result.legend.rect.h && result.legend.items.every((item) => {
|
|
457
|
+
let label = result.scene.find((node) => node.id === item.labelId);
|
|
458
|
+
return label?.t === "text" && names.get(item.id) === (label.title ?? label.lines.join(" "));
|
|
459
|
+
})) {
|
|
460
|
+
let height = result.legend.rect.h - excess, drawCompact = compactLayouts.get(height);
|
|
461
|
+
drawCompact || (drawCompact = prepareLegendLayout(definition, data, origins), compactLayouts.set(height, drawCompact));
|
|
462
|
+
let compact = drawCompact(Object.assign({}, options, { size: result.size, [LEGEND_HEIGHT]: { height, names } }));
|
|
463
|
+
if (!compact.refused && furniture(compact) <= compact.size.height * furnitureBudget(compact.size.width) + 0.5) return compact;
|
|
464
|
+
}
|
|
465
|
+
if (excess > 0.5 && result.legend.items.some((item) => {
|
|
466
|
+
let label = result.scene.find((node) => node.id === item.labelId);
|
|
467
|
+
return label?.t === "text" && label.title !== void 0 && label.title !== label.lines.join(" ");
|
|
468
|
+
})) {
|
|
469
|
+
let drawFull = compactLayouts.get(1 / 0);
|
|
470
|
+
drawFull || (drawFull = prepareLegendLayout(definition, data, origins), compactLayouts.set(1 / 0, drawFull));
|
|
471
|
+
let full = drawFull(Object.assign({}, options, { [LEGEND_HEIGHT]: { height: 1 / 0, names } }));
|
|
472
|
+
if (!full.refused) return full;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return !result.refused && panelTypeClass(options) === void 0 && result.warnings.push(...typeDocLints(definition.type, options, result)), result;
|
|
476
|
+
});
|
|
477
|
+
return run.finish = () => {
|
|
478
|
+
baseline.finish(), candidate.finish(), unitBaseline.finish(), unitCandidate.finish();
|
|
479
|
+
for (let draw of compactLayouts.values()) draw.finish();
|
|
480
|
+
compactLayouts.clear();
|
|
481
|
+
}, run;
|
|
482
|
+
}
|
|
483
|
+
function layoutWithKeys(definition, data, options, fitBaseline, fitCandidate) {
|
|
484
|
+
let requested = options?.legend === "auto", baselineOptions = requested ? { ...options, legend: void 0 } : options, baseline = fitBaseline(baselineOptions);
|
|
485
|
+
if (!baseline.refused && options?.legend === "none" && definition.requiredKey && panelTypeClass(options) === void 0)
|
|
486
|
+
return definition.requiredKey(baseline, data, options, fitCandidate);
|
|
487
|
+
if (baseline.refused || !requested && (options?.legend !== void 0 || panelTypeClass(options) !== void 0 || resolveTheme(options?.theme).legend?.auto !== !0 && !needsSeriesKey(definition.type, data, options, baseline))) return baseline;
|
|
488
|
+
let candidateOptions = Object.assign({}, baselineOptions, { [AUTO_LEGEND]: !0 });
|
|
489
|
+
candidateOptions.legend = "top", definition.type !== "mekko" && (candidateOptions.mode = baseline.mode);
|
|
490
|
+
let candidate = fitCandidate(candidateOptions);
|
|
491
|
+
if (candidate.refused) {
|
|
492
|
+
let probe = definition.layout(data, baseline.mode === "compact" ? compactOptions(definition.type, candidateOptions) : candidateOptions);
|
|
493
|
+
return !probe.refused && legendIsCovered(baseline, probe, data, baselineOptions) ? baseline : candidate;
|
|
494
|
+
}
|
|
495
|
+
if (!candidate.legend?.items.length) return baseline;
|
|
496
|
+
let candidateIds = new Set(candidate.legend.items.map((item) => item.id));
|
|
497
|
+
return baseline.legend?.items.some((item) => !item.id.startsWith("__event") && !candidateIds.has(item.id)) || legendIsCovered(baseline, candidate, data, baselineOptions) ? baseline : candidate;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// src/core/calendarLabels.ts
|
|
501
|
+
var MONTH = /^(\d{4})-(0[1-9]|1[0-2])$/, WEEK = /^(\d{4})-W(0[1-9]|[1-4]\d|5[0-3])$/, QUARTER = /^(\d{4})-Q([1-4])$/, utc = (year, month, day = 1) => {
|
|
502
|
+
let date = /* @__PURE__ */ new Date(0);
|
|
503
|
+
return date.setUTCFullYear(year, month, day), date;
|
|
504
|
+
};
|
|
505
|
+
function isoWeek(date) {
|
|
506
|
+
let thursday = utc(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + 3 - (date.getUTCDay() + 6) % 7), weekYear = thursday.getUTCFullYear();
|
|
507
|
+
return { week: 1 + Math.floor((thursday.getTime() - utc(weekYear, 0, 1).getTime()) / 6048e5), weekYear };
|
|
508
|
+
}
|
|
509
|
+
function pointOf(text) {
|
|
510
|
+
let day = parseISODate(text);
|
|
511
|
+
if (day) return { unit: "day", date: day };
|
|
512
|
+
let month = MONTH.exec(text);
|
|
513
|
+
if (month) return { unit: "month", date: utc(+month[1], +month[2] - 1) };
|
|
514
|
+
let quarter = QUARTER.exec(text);
|
|
515
|
+
if (quarter) return { unit: "quarter", date: utc(+quarter[1], (+quarter[2] - 1) * 3) };
|
|
516
|
+
let week = WEEK.exec(text);
|
|
517
|
+
if (!week) return;
|
|
518
|
+
let jan4 = utc(+week[1], 0, 4), date = utc(+week[1], 0, 4 - (jan4.getUTCDay() + 6) % 7 + (+week[2] - 1) * 7), iso = isoWeek(date);
|
|
519
|
+
return iso.weekYear === +week[1] && iso.week === +week[2] ? { unit: "week", date, ...iso } : void 0;
|
|
520
|
+
}
|
|
521
|
+
var monthIndex = (date) => date.getUTCFullYear() * 12 + date.getUTCMonth(), isMonthEnd = (date) => utc(date.getUTCFullYear(), date.getUTCMonth() + 1, 0).getUTCDate() === date.getUTCDate();
|
|
522
|
+
function dayUnit(dates) {
|
|
523
|
+
if (dates.length < 2) return "day";
|
|
524
|
+
let ends = dates.every(isMonthEnd);
|
|
525
|
+
if (!ends && !dates.every((date) => date.getUTCDate() === 1)) return "day";
|
|
526
|
+
let months = dates.map(monthIndex), steps = months.slice(1).map((m, i) => m - months[i]);
|
|
527
|
+
if (steps.some((step) => step <= 0)) return "day";
|
|
528
|
+
let phase = ends ? 2 : 0;
|
|
529
|
+
return months.every((m) => m % 12 === (ends ? 11 : 0)) && steps.every((step) => step % 12 === 0) ? "year" : months.every((m) => m % 3 === phase) && steps.every((step) => step % 3 === 0) ? "quarter" : "month";
|
|
530
|
+
}
|
|
531
|
+
function calendarCategories(categories, language, yearRow = !1) {
|
|
532
|
+
return deriveCalendar(categories, language, yearRow)?.categories;
|
|
533
|
+
}
|
|
534
|
+
function calendarNames(categories, language) {
|
|
535
|
+
return deriveCalendar(categories, language)?.names;
|
|
536
|
+
}
|
|
537
|
+
function deriveCalendar(categories, language, yearRow = !1) {
|
|
538
|
+
let unlabelled = (raw) => typeof raw == "string" || raw.label === void 0;
|
|
539
|
+
if (categories.length === 0 || !categories.some(unlabelled)) return;
|
|
540
|
+
let points = categories.map((raw) => pointOf(typeof raw == "string" ? raw : raw.date ?? raw.id));
|
|
541
|
+
if (points.some((point) => point === void 0)) return;
|
|
542
|
+
let kinds = new Set(points.map((point) => point.unit));
|
|
543
|
+
if (kinds.size !== 1) return;
|
|
544
|
+
let kind = [...kinds][0], unit = kind === "day" ? dayUnit(points.map((point) => point.date)) : kind, tag = (wordLanguage(language) ?? "en").toLowerCase().replace(/_/g, "-"), de = tag === "de" || tag.startsWith("de-"), us = tag === "en-us", months = dateNames(language).monthsShort, inRow = yearRow && (unit === "day" || unit === "month" || unit === "quarter"), previous, years = unit !== "year" && new Set(points.map((point) => point.weekYear ?? point.date.getUTCFullYear())).size > 1, names = [];
|
|
545
|
+
return { categories: categories.map((raw, i) => {
|
|
546
|
+
let point = points[i], { date } = point, year = unit === "week" ? point.weekYear ?? isoWeek(date).weekYear : date.getUTCFullYear(), yearShown = unit !== "year" && !inRow && year !== previous;
|
|
547
|
+
unlabelled(raw) && (previous = year);
|
|
548
|
+
let month = months[date.getUTCMonth()], day = date.getUTCDate(), calendar = {
|
|
549
|
+
unit,
|
|
550
|
+
year,
|
|
551
|
+
yearShown,
|
|
552
|
+
...inRow ? { yearRow: !0 } : {}
|
|
553
|
+
}, category = typeof raw == "string" ? { id: raw, calendar } : { ...raw, calendar };
|
|
554
|
+
if (!unlabelled(raw)) return { ...category, calendar: { ...category.calendar, yearShown: !1 } };
|
|
555
|
+
let week = String(point.week ?? isoWeek(date).week).padStart(2, "0"), base = unit === "year" ? String(year) : unit === "quarter" ? `Q${Math.floor(date.getUTCMonth() / 3) + 1}` : unit === "month" ? month : unit === "week" ? de ? `KW ${week}` : `W${week}` : de ? `${day}. ${month}` : us ? `${month} ${day}` : `${day} ${month}`;
|
|
556
|
+
inRow && unit === "day" && (calendar.weekday = `${dateNames(language).daysShort[date.getUTCDay()]} ${base}`);
|
|
557
|
+
let named = `${base}${us && unit === "day" ? "," : ""} ${year}`;
|
|
558
|
+
return names[i] = unit === "year" ? base : named, { ...category, ...years && { calendar: { ...calendar, named } }, label: yearShown ? named : base };
|
|
559
|
+
}), names };
|
|
560
|
+
}
|
|
561
|
+
function calendarMonths(texts) {
|
|
562
|
+
let points = texts.map((text) => text === void 0 ? void 0 : pointOf(text)), kind = points[0]?.unit;
|
|
563
|
+
if (!kind || points.some((point) => point?.unit !== kind)) return;
|
|
564
|
+
let unit = kind === "day" ? dayUnit(points.map((point) => point.date)) : kind;
|
|
565
|
+
if (unit !== "month" && unit !== "quarter") return { unit };
|
|
566
|
+
let months = points.map((point) => monthIndex(point.date));
|
|
567
|
+
return months.every((m, i) => i === 0 || m > months[i - 1]) ? { unit, months } : void 0;
|
|
568
|
+
}
|
|
569
|
+
function dateTickRow(cats, dateTicks, language, weekStartsOn) {
|
|
570
|
+
let n = cats.length, dates = cats.map((category) => category.date), ordinals = dateTickOrdinals(dates, dateTicks, weekStartsOn), calendarTicks = dateTicks === "months" || dateTicks === "quarters" || dateTicks === "years", keep = ordinals ? calendarTicks ? dateTickKeepCalendar(dates, dateTicks) : dateTickKeep(dates, dateTicks, weekStartsOn, !0) : null, dated = cats.map((category) => ({ id: category.id, date: category.date })), full = null, inRow = null, fullCalendar = () => full === null ? full = calendarCategories(dated, language) : full, rowCalendar = () => inRow === null ? inRow = calendarCategories(dated, language, !0) : inRow;
|
|
571
|
+
return {
|
|
572
|
+
// A tick at the first category of each interval; the row thins them by the interval.
|
|
573
|
+
ticks: ordinals?.map((ordinal, i) => i === 0 || ordinal !== ordinals[i - 1]) ?? null,
|
|
574
|
+
plan: keep ? { keep, dateStride: { ordinals, strides: DATE_TICK_STRIDES[dateTicks], ...calendarTicks ? { calendar: !0 } : {} } } : {},
|
|
575
|
+
name(row) {
|
|
576
|
+
if (calendarTicks && row.calendar?.some((info) => info?.unit === "day" && info.yearRow)) {
|
|
577
|
+
let inRow2 = rowCalendar(), full2 = fullCalendar();
|
|
578
|
+
inRow2 && full2 && (row.labels = row.labels.map((label, i) => label === inRow2[i].label ? full2[i].label : label), row.calendar = full2.map((category, i) => row.calendar[i] && category.calendar));
|
|
579
|
+
}
|
|
580
|
+
if (dateTicks === "years" && ordinals && (row.labels = row.labels.map((label, i) => i !== n - 1 && label.includes(String(ordinals[i])) ? String(ordinals[i]) : label)), dateTicks === "months" && ordinals) {
|
|
581
|
+
let derived = fullCalendar(), months = dateNames(language).monthsShort;
|
|
582
|
+
derived?.[0]?.calendar.unit === "day" && (row.labels = row.labels.map((label, i) => {
|
|
583
|
+
let own = derived[i];
|
|
584
|
+
if (i === n - 1 || label !== own.label) return label;
|
|
585
|
+
let month = months[(ordinals[i] % 12 + 12) % 12];
|
|
586
|
+
return own.calendar.yearShown || i === 0 ? `${month} ${own.calendar.year}` : month;
|
|
587
|
+
}));
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function dayCategories(cats) {
|
|
593
|
+
if (calendarMonths(cats.map((category) => category.date ?? category.id))?.unit === "day")
|
|
594
|
+
return cats.map((category) => category.date === void 0 ? { ...category, date: category.id } : category);
|
|
595
|
+
}
|
|
596
|
+
var lastMonthRow;
|
|
597
|
+
function longDayMonths(cats, stride, language) {
|
|
598
|
+
if (stride <= 28) return;
|
|
599
|
+
let key = JSON.stringify([language ?? null, cats.map((category) => [category.id, category.date ?? null])]);
|
|
600
|
+
if (lastMonthRow?.key !== key) {
|
|
601
|
+
let days = dayCategories(cats);
|
|
602
|
+
lastMonthRow = { key, row: days ? dateTickRow(days, "months", language) : null };
|
|
603
|
+
}
|
|
604
|
+
return lastMonthRow.row ?? void 0;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/core/label/tickRow.ts
|
|
608
|
+
var PROSE_TICK_MAX_LINES = 2, MONTH_NAME = `(?:${[...new Set(DATE_NAME_LANGUAGES.flatMap((language) => {
|
|
609
|
+
let names = dateNames(language);
|
|
610
|
+
return [...names.months, ...names.monthsShort].map((name) => name.replace(/\.$/, "").toLowerCase());
|
|
611
|
+
}))].join("|")})\\.?(?!\\p{L})`, MONTH_START = new RegExp(`^${MONTH_NAME}`, "iu"), SHORT_SLASH_DATE = /^(?:0?[1-9]|1[0-2])\/(?:0?[1-9]|[12]\d|3[01])$/, SHORT_DASH_DATE = /^(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/, TICK_PATTERNS = [
|
|
612
|
+
// numeric ranges joined by an en dash (histogram bins): 0–344 · 1,032–1,376;
|
|
613
|
+
// a hyphen range stays prose so bucket labels like 1-2 keep their old class
|
|
614
|
+
/^[+-]?\d[\d,. \u202F\u00A0]*%?\s?\u2013\s?[+-]?\d[\d,. \u202F\u00A0]*%?$/,
|
|
615
|
+
// plain numbers: 42 · -3.5 · 1,000 · 1 000 · 12% (magnitude suffixes are
|
|
616
|
+
// value-axis territory, not category labels — deliberately absent; group
|
|
617
|
+
// separators: comma, dot, ASCII space, U+202F, U+00A0)
|
|
618
|
+
/^[+-]?\d[\d,. \u202F\u00A0]*%?$/,
|
|
619
|
+
// ISO dates: 2021 (matched above), 2021-01, 2021-01-15
|
|
620
|
+
/^\d{4}-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12]\d|3[01]))?$/,
|
|
621
|
+
// short numeric dates: MM-DD, D.M., DD.MM., M/D
|
|
622
|
+
SHORT_DASH_DATE,
|
|
623
|
+
/^(?:0?[1-9]|[12]\d|3[01])\.(?:0?[1-9]|1[0-2])\.$/,
|
|
624
|
+
SHORT_SLASH_DATE,
|
|
625
|
+
// ISO week: 2024-W05 / 2024W5
|
|
626
|
+
/^\d{4}-?W\d{1,2}$/i,
|
|
627
|
+
// quarters: Q1 2024 · Q1-24 · Q1'24 · 2024-Q1 · 2024 Q1
|
|
628
|
+
/^Q[1-4][ \-']?\d{2,4}$/i,
|
|
629
|
+
/^\d{4}[ -]?Q[1-4]$/i,
|
|
630
|
+
// half-years: 2024 · H2-24
|
|
631
|
+
/^H[12][ \-']?\d{2,4}$/i,
|
|
632
|
+
// month names: Jan-24 · Jan 24 · Jan'24 · January 2024
|
|
633
|
+
new RegExp(`^${MONTH_NAME}[ \\-']?\\d{2,4}$`, "iu"),
|
|
634
|
+
// Month-day labels use the same one-line date policy in every language,
|
|
635
|
+
// with the year the engine's own date labels add at a year change.
|
|
636
|
+
new RegExp(`^(?:0?[1-9]|[12]\\d|3[01])\\.?\\s+${MONTH_NAME}(?:\\s+\\d{4})?$`, "iu"),
|
|
637
|
+
new RegExp(`^${MONTH_NAME}\\s+(?:0?[1-9]|[12]\\d|3[01])(?:,?\\s+\\d{4})?$`, "iu"),
|
|
638
|
+
// fiscal years: FY21 · FY 2021 · FY'22
|
|
639
|
+
/^FY[ ']?\d{2,4}$/i
|
|
640
|
+
];
|
|
641
|
+
function isDateNumericTickLabel(label) {
|
|
642
|
+
let text = label.trim();
|
|
643
|
+
return text.length === 0 ? !1 : TICK_PATTERNS.some((pattern) => pattern.test(text));
|
|
644
|
+
}
|
|
645
|
+
function isDateNumericTickSequence(labels) {
|
|
646
|
+
let nonEmpty = labels.map((label) => label.trim()).filter(Boolean);
|
|
647
|
+
if (nonEmpty.length > 0 && nonEmpty.every((label) => SHORT_SLASH_DATE.test(label)) && nonEmpty.every((label) => Number(label.split("/")[1]) <= 12))
|
|
648
|
+
return !1;
|
|
649
|
+
if (nonEmpty.length > 1 && nonEmpty.every((label) => SHORT_DASH_DATE.test(label))) {
|
|
650
|
+
let pairs = nonEmpty.map((label) => label.split("-").map(Number));
|
|
651
|
+
if (pairs.slice(1).every((pair, index) => pair[0] > pairs[index][1])) return !1;
|
|
652
|
+
}
|
|
653
|
+
let seen = 0;
|
|
654
|
+
for (let label of labels)
|
|
655
|
+
if (label.trim().length !== 0) {
|
|
656
|
+
if (!isDateNumericTickLabel(label)) return !1;
|
|
657
|
+
seen++;
|
|
658
|
+
}
|
|
659
|
+
return seen > 0;
|
|
660
|
+
}
|
|
661
|
+
function tickLabelX(cx, width, index, count, edgeAnchored) {
|
|
662
|
+
if (edgeAnchored && count > 1) {
|
|
663
|
+
if (index === 0) return cx;
|
|
664
|
+
if (index === count - 1) return cx - width;
|
|
665
|
+
}
|
|
666
|
+
return cx - width / 2;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// src/core/collide.ts
|
|
670
|
+
function sweepHide(items, gap = 2) {
|
|
671
|
+
let keep = new Array(items.length).fill(!1), order = items.map((_, i) => i).sort((a, b) => items[b].priority - items[a].priority || a - b), kept = [];
|
|
672
|
+
for (let i of order) {
|
|
673
|
+
let it = items[i], start = it.start, end = it.start + it.size;
|
|
674
|
+
kept.some((k) => start < k.end + gap && k.start < end + gap) || (keep[i] = !0, kept.push({ start, end }));
|
|
675
|
+
}
|
|
676
|
+
return keep;
|
|
677
|
+
}
|
|
678
|
+
function spread1D(items, bounds, gap = 2) {
|
|
679
|
+
return calculateSpread1D(items, bounds, gap, !1).positions;
|
|
680
|
+
}
|
|
681
|
+
function spread1DResult(items, bounds, gap = 2) {
|
|
682
|
+
return calculateSpread1D(items, bounds, gap, !0);
|
|
683
|
+
}
|
|
684
|
+
function warnSpreadOverflow(warnings, fits, message) {
|
|
685
|
+
fits || warnings.push({ code: "label-spread-overflow", severity: "warn", message });
|
|
686
|
+
}
|
|
687
|
+
function calculateSpread1D(items, bounds, gap, containImpossiblePack) {
|
|
688
|
+
let n = items.length;
|
|
689
|
+
if (n === 0) return { positions: [], fits: !0 };
|
|
690
|
+
let [lo, hi] = bounds, span = Math.max(0, hi - lo), required = items.reduce((sum, item) => sum + item.size, 0) + gap * Math.max(0, n - 1), order = items.map((_, i) => i).sort((a, b) => items[a].desired - items[b].desired || a - b);
|
|
691
|
+
if (required > span && containImpossiblePack) {
|
|
692
|
+
let maxHalfSize = Math.min(
|
|
693
|
+
span / 2,
|
|
694
|
+
maxOf(items.map((item) => Math.max(0, item.size) / 2))
|
|
695
|
+
), first = lo + maxHalfSize, last = hi - maxHalfSize, positions = new Array(n);
|
|
696
|
+
for (let k = 0; k < n; k++) {
|
|
697
|
+
let idx = order[k];
|
|
698
|
+
positions[idx] = n === 1 ? (lo + hi) / 2 : first + (last - first) * (k / (n - 1));
|
|
699
|
+
}
|
|
700
|
+
return { positions, fits: !1 };
|
|
701
|
+
}
|
|
702
|
+
let clusters = [];
|
|
703
|
+
for (let k = 0; k < n; k++) {
|
|
704
|
+
let idx = order[k], it = items[idx], cur = { indices: [k], sumDesired: it.desired, size: it.size };
|
|
705
|
+
for (; clusters.length > 0; ) {
|
|
706
|
+
let prev = clusters[clusters.length - 1], prevCenter = prev.sumDesired / prev.indices.length, prevEnd = clamp1(prevCenter - prev.size / 2, lo, hi - prev.size) + prev.size, curCenter = cur.sumDesired / cur.indices.length;
|
|
707
|
+
if (clamp1(curCenter - cur.size / 2, lo, hi - cur.size) < prevEnd + gap)
|
|
708
|
+
clusters.pop(), cur = {
|
|
709
|
+
indices: [...prev.indices, ...cur.indices],
|
|
710
|
+
sumDesired: prev.sumDesired + cur.sumDesired,
|
|
711
|
+
size: prev.size + gap + cur.size
|
|
712
|
+
};
|
|
713
|
+
else
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
clusters.push(cur);
|
|
717
|
+
}
|
|
718
|
+
let posBySortedIndex = new Array(n);
|
|
719
|
+
for (let c of clusters) {
|
|
720
|
+
let center = c.sumDesired / c.indices.length, start = clamp1(center - c.size / 2, lo, Math.max(lo, hi - c.size));
|
|
721
|
+
for (let k of c.indices) {
|
|
722
|
+
let idx = order[k], it = items[idx];
|
|
723
|
+
posBySortedIndex[k] = start + it.size / 2, start += it.size + gap;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
let out = new Array(n);
|
|
727
|
+
for (let k = 0; k < n; k++) out[order[k]] = posBySortedIndex[k];
|
|
728
|
+
return { positions: out, fits: required <= span };
|
|
729
|
+
}
|
|
730
|
+
function clamp1(v, lo, hi) {
|
|
731
|
+
return hi < lo || v < lo ? lo : v > hi ? hi : v;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/core/label/categoryRow.ts
|
|
735
|
+
var CATEGORY_ROW_FROM_END = /* @__PURE__ */ Symbol("categoryRowFromEnd"), CATEGORY_ROW_VERTICAL = /* @__PURE__ */ Symbol("categoryRowVertical"), YEAR_ROW_GAP = 2, SPREAD_GAP = 7.5;
|
|
736
|
+
function yearRowRequests(plan, top) {
|
|
737
|
+
let under = (plan.underRow?.items ?? []).map(({ index, text, x, w, h }) => ({
|
|
738
|
+
id: `category-under:${index}`,
|
|
739
|
+
kind: "category",
|
|
740
|
+
owner: {},
|
|
741
|
+
text,
|
|
742
|
+
lines: [text],
|
|
743
|
+
typeRole: plan.typeRole,
|
|
744
|
+
font: plan.font,
|
|
745
|
+
priority: PRIORITY.endpoint,
|
|
746
|
+
candidates: [{ slot: "below", rect: { x, y: top + plan.underRow.offset, w, h }, penalty: 0 }]
|
|
747
|
+
})), row = plan.yearRow;
|
|
748
|
+
if (!row) return under;
|
|
749
|
+
let seen = /* @__PURE__ */ new Map();
|
|
750
|
+
return [...under, ...row.years.map(({ id, text, x, w, h }) => {
|
|
751
|
+
let n = (seen.get(id) ?? 0) + 1;
|
|
752
|
+
return seen.set(id, n), {
|
|
753
|
+
id: `${id}${n > 1 ? `-${n}` : ""}`,
|
|
754
|
+
kind: "category",
|
|
755
|
+
owner: {},
|
|
756
|
+
text,
|
|
757
|
+
lines: [text],
|
|
758
|
+
typeRole: plan.typeRole,
|
|
759
|
+
font: plan.font,
|
|
760
|
+
priority: PRIORITY.endpoint,
|
|
761
|
+
candidates: [{ slot: "below", rect: { x, y: top + row.offset, w, h }, penalty: 0 }]
|
|
762
|
+
};
|
|
763
|
+
})];
|
|
764
|
+
}
|
|
765
|
+
function categoryLineAlign(plan, index) {
|
|
766
|
+
return plan.rotation === 0 && (plan.infos[index]?.lines.length ?? 0) > 1 ? { align: "middle" } : {};
|
|
767
|
+
}
|
|
768
|
+
var SIN45 = Math.SQRT1_2, ROTATED_NAME_AIR = 5, nth = (k) => `${k}${k % 100 >= 11 && k % 100 <= 13 ? "th" : ["th", "st", "nd", "rd"][k % 10] ?? "th"}`, ROTATED_HEIGHT_SHARE = 0.3, VERTICAL_HEIGHT_SHARE = 0.5, VERTICAL_MIN_WIDTH = 130, ROTATED_MIN_WIDTH = 110, DATE_ROW_LABELS = 8, YEAR_LABEL = /^(?:FY\s?)?\d{4}$|^(?:FY\s?)?'?\d{2}$/;
|
|
769
|
+
function calendarLike(labels) {
|
|
770
|
+
return labels.length > 1 && labels.every((l) => {
|
|
771
|
+
let t = l.trim();
|
|
772
|
+
return MONTH_START.test(t) || /^\d{4}-(0[1-9]|1[0-2])$/.test(t) || /^W\d{1,2}\b/i.test(t) || /\bQ[1-4]\b/.test(t) || YEAR_LABEL.test(t);
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
function numberedSequence(labels) {
|
|
776
|
+
if (labels.length < 2) return !1;
|
|
777
|
+
let parts = labels.map((label) => /^(\D*)(\d+)(\D*)$/.exec(label.trim())), first = parts[0];
|
|
778
|
+
return first != null && parts.every((m, i) => m !== null && m[1] === first[1] && m[3] === first[3] && Number(m[2]) === Number(first[2]) + i);
|
|
779
|
+
}
|
|
780
|
+
function strideCandidates(labels) {
|
|
781
|
+
let n = labels.length, generic = [2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 25, 30, 40, 50, 60, 100], preferred = [];
|
|
782
|
+
return labels.every((l) => MONTH_START.test(l.trim()) || /^\d{4}-(0[1-9]|1[0-2])$/.test(l.trim())) ? [3, 6, 12, 24, 36].filter((k) => k < n) : labels.every((l) => /\bQ[1-4]\b/.test(l.trim())) ? [2, 4, 8, 12].filter((k) => k < n) : (labels.every((l) => YEAR_LABEL.test(l.trim())) && (preferred = [2, 5, 10]), [...preferred, ...generic.filter((k) => !preferred.includes(k))].filter((k) => k < n));
|
|
783
|
+
}
|
|
784
|
+
function twoKept(a, b) {
|
|
785
|
+
let keep = [];
|
|
786
|
+
return keep[a] = !0, keep[b] = !0, keep.pair = [a, b], keep;
|
|
787
|
+
}
|
|
788
|
+
function strideAfterFontLadder(labels, infos, baseFont, requested, pinned, dateStride, fits, plan, yearPins = [], fromEnd = !1, minStride = 0) {
|
|
789
|
+
let n = labels.length, pair = twoKept, yieldToPins = (keep2) => {
|
|
790
|
+
for (let i = 0; i < n; i++)
|
|
791
|
+
if (!(!pinned[i] || !keep2[i])) {
|
|
792
|
+
for (let dir of [-1, 1])
|
|
793
|
+
for (let j = i + dir; j >= 0 && j < n; j += dir)
|
|
794
|
+
if (keep2[j]) {
|
|
795
|
+
if (pinned[j] || fits(infos, pair(Math.min(i, j), Math.max(i, j)))) break;
|
|
796
|
+
keep2[j] = !1;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}, requestedRank = [];
|
|
800
|
+
if (requested) {
|
|
801
|
+
let rank = 0;
|
|
802
|
+
labels.forEach((_, i) => {
|
|
803
|
+
requestedRank.push(requested[i] ? rank++ : rank);
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
let ordinal = (i) => dateStride ? dateStride.ordinals[i] : requested ? requestedRank[i] : i, restart = [];
|
|
807
|
+
labels.forEach((_, i) => restart.push(yearPins[i] ? i : restart[i - 1] ?? -1));
|
|
808
|
+
let steady = (keep2, k) => {
|
|
809
|
+
let drawn = labels.map((_, i) => i).filter((i) => keep2[i]), gaps = drawn.slice(1).map((i, d) => ordinal(i) - ordinal(drawn[d]));
|
|
810
|
+
return requested === void 0 && gaps.pop(), gaps.every((g) => Math.abs(g - k) <= 1) && maxOf(gaps) - minOf(gaps) <= 1;
|
|
811
|
+
}, ticks = requested?.filter(Boolean).length ?? n, calendar = dateStride?.calendar === !0, each = calendar && requested === void 0 ? dateStride.perStep ?? 1 : 1, candidates = dateStride ? dateStride.strides.filter((k) => k < ticks * each && k >= minStride) : strideCandidates(labels), attempt = (k, restartAtYears) => {
|
|
812
|
+
let from = (i) => fromEnd ? ordinal(n - 1) : restartAtYears && restart[i] >= 0 ? ordinal(restart[i]) : 0, onStride = (i) => (ordinal(i) - from(i)) % k === 0, keep2 = labels.map((_, i) => !fromEnd && pinned[i] || onStride(i) && (requested?.[i] ?? !0));
|
|
813
|
+
if (!fromEnd && requested === void 0 && !keep2[n - 1]) {
|
|
814
|
+
let previous = n - 2;
|
|
815
|
+
for (; ; ) {
|
|
816
|
+
for (; previous >= 0 && !keep2[previous]; ) previous -= 1;
|
|
817
|
+
if (previous < 0 || fits(infos, pair(previous, n - 1))) {
|
|
818
|
+
keep2[n - 1] = !0;
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
if (!dateStride || pinned[previous]) break;
|
|
822
|
+
keep2[previous] = !1;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
fromEnd || yieldToPins(keep2);
|
|
826
|
+
let shown = keep2.filter(Boolean).length;
|
|
827
|
+
if (!(dateStride && requested !== void 0 && shown > DATE_ROW_LABELS && candidates.some((next) => next > k)) && !(!fits(infos, keep2) || restartAtYears && !steady(keep2, k)))
|
|
828
|
+
return plan(baseFont, infos, keep2, "stride", {
|
|
829
|
+
stride: k / each,
|
|
830
|
+
warnings: [
|
|
831
|
+
{
|
|
832
|
+
code: "category-stride",
|
|
833
|
+
severity: "info",
|
|
834
|
+
message: `category labels: showing every ${nth(k / each)} of ${ticks} (${shown} drawn) \u2014 the row does not fit all at ${baseFont.size}px`,
|
|
835
|
+
suggest: "widen the canvas or aggregate the periods to show every label"
|
|
836
|
+
}
|
|
837
|
+
]
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
for (let restartAtYears of !fromEnd && yearPins.some(Boolean) ? [!0, !1] : [!1])
|
|
841
|
+
for (let k of candidates) {
|
|
842
|
+
let found = attempt(k, restartAtYears);
|
|
843
|
+
if (found) {
|
|
844
|
+
if (!fromEnd && !dateStride && (requested === void 0 || pinned[n - 1]) && !restartAtYears && (n - 1) % k !== 0)
|
|
845
|
+
for (let d of candidates.filter((d2) => d2 > k && d2 <= 2 * k && 2 * d2 <= n - 1 && (n - 1) % d2 === 0).sort((a, b) => a - b)) {
|
|
846
|
+
let both = attempt(d, !1);
|
|
847
|
+
if (both) return both;
|
|
848
|
+
}
|
|
849
|
+
if (fromEnd && !dateStride && requested === void 0 && (n - 1) % k !== 0) {
|
|
850
|
+
let quarterRow = labels.every((l) => /\bQ[1-4]\b/.test(l.trim()));
|
|
851
|
+
for (let d of [.../* @__PURE__ */ new Set([...candidates, ...quarterRow ? [3] : []])].sort((a, b) => a - b)) {
|
|
852
|
+
if (d === k || d > 2 * k || 2 * d > n - 1 || (n - 1) % d !== 0) continue;
|
|
853
|
+
let both = attempt(d, !1);
|
|
854
|
+
if (both) return both;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return found;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (fromEnd || calendar) return plan(baseFont, infos, labels.map((_, i) => i === n - 1 || pinned[i]), "stride", {
|
|
861
|
+
stride: n,
|
|
862
|
+
warnings: [{ code: "category-stride", severity: "warn", message: `category labels: only the latest of ${n} fits \u2014 the axis is too narrow for its periods`, suggest: "widen the canvas or aggregate the periods" }]
|
|
863
|
+
});
|
|
864
|
+
let keep = labels.map((_, i) => pinned[i] || (i === 0 || i === n - 1) && (requested?.[i] ?? !0)), endsFit = fits(infos, keep);
|
|
865
|
+
return endsFit || (keep = labels.map((_, i) => pinned[i] || i === 0 && (requested?.[i] ?? !0))), plan(baseFont, infos, keep, "stride", {
|
|
866
|
+
stride: n - 1,
|
|
867
|
+
warnings: [
|
|
868
|
+
{
|
|
869
|
+
code: "category-stride",
|
|
870
|
+
severity: "warn",
|
|
871
|
+
message: `category labels: only the first${endsFit ? " and last" : ""} of ${n} fit \u2014 the axis is too narrow for its periods`,
|
|
872
|
+
suggest: "widen the canvas or aggregate the periods"
|
|
873
|
+
}
|
|
874
|
+
]
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function namesByFit(labels, infos, baseFont, requested, pinned, priority, fits, plan, ownsItsRoom = () => !0) {
|
|
878
|
+
let n = labels.length, eligible = (i, step = 1) => (requested?.[i] ?? !0) && ownsItsRoom(i, infos[i].w, step), pair = twoKept, anchor = labels.map((_, i) => pinned[i]);
|
|
879
|
+
labels.map((_, i) => i).filter((i) => (priority?.[i] ?? 0) > 0 && !anchor[i] && eligible(i)).sort((a, b) => priority[b] - priority[a] || a - b).forEach((i) => {
|
|
880
|
+
anchor[i] = !0, fits(infos, anchor) || (anchor[i] = !1);
|
|
881
|
+
});
|
|
882
|
+
let keep = [...anchor], stride = n;
|
|
883
|
+
for (let k = 1; k <= n; k++) {
|
|
884
|
+
let candidate = labels.map((_, i) => anchor[i] || i % k === 0 && eligible(i, k));
|
|
885
|
+
if (!((requested?.[0] ?? !0) && !candidate[0] && candidate.filter(Boolean).length < 3) && (candidate.forEach((kept, i) => {
|
|
886
|
+
!kept || anchor[i] || labels.some((_, j) => anchor[j] && j !== i && !fits(infos, pair(Math.min(i, j), Math.max(i, j)))) && (candidate[i] = !1);
|
|
887
|
+
}), candidate.some((kept, i) => kept && !anchor[i]) && fits(infos, candidate))) {
|
|
888
|
+
keep = candidate, stride = k;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
let named = labels.map((label) => label.trim() !== ""), shownNames = keep.filter((kept, i) => kept && named[i]).length;
|
|
893
|
+
return plan(baseFont, infos, keep, "stride", {
|
|
894
|
+
stride,
|
|
895
|
+
warnings: [{
|
|
896
|
+
code: "category-stride",
|
|
897
|
+
severity: "warn",
|
|
898
|
+
message: `category labels: ${shownNames} of ${named.filter(Boolean).length} names drawn, ${stride >= n ? "only the first" : `every ${stride === 1 ? "one" : nth(stride)} from the first`}${priority ? " plus priority names" : ""} \u2014 the names do not fit horizontally and the row is too narrow to rotate them`,
|
|
899
|
+
suggest: "widen the canvas, use a horizontal chart, or pass priority so the names that matter are drawn first"
|
|
900
|
+
}]
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
function hangingLabelReserve(plotH, domain, lowest, room) {
|
|
904
|
+
if (lowest === void 0 || !(lowest < 0) || room <= 0) return 0;
|
|
905
|
+
let [lo, hi] = domain, share = hi > lo ? (lowest - lo) / (hi - lo) : 0;
|
|
906
|
+
return Math.max(0, (room - share * plotH) / (1 - share));
|
|
907
|
+
}
|
|
908
|
+
function categoryRowTop(y, lowestEnd, hangingEnd, room) {
|
|
909
|
+
return Math.max(y(Math.min(0, lowestEnd)), hangingEnd === void 0 || !(hangingEnd < 0) ? -1 / 0 : y(hangingEnd) + room);
|
|
910
|
+
}
|
|
911
|
+
var rowPlans;
|
|
912
|
+
function withCategoryRowPlans(run) {
|
|
913
|
+
if (rowPlans) return run();
|
|
914
|
+
rowPlans = /* @__PURE__ */ new Map();
|
|
915
|
+
try {
|
|
916
|
+
return run();
|
|
917
|
+
} finally {
|
|
918
|
+
rowPlans = void 0;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
function planCategoryRow(input) {
|
|
922
|
+
if (!rowPlans) {
|
|
923
|
+
let cascade = planCategoryRowCascade(input);
|
|
924
|
+
return spreadUpright(input, cascade) ?? cascade;
|
|
925
|
+
}
|
|
926
|
+
let plans = rowPlans.get(input.measure);
|
|
927
|
+
plans || rowPlans.set(input.measure, plans = /* @__PURE__ */ new Map());
|
|
928
|
+
let key = JSON.stringify({ ...input, measure: void 0 }), plan = plans.get(key);
|
|
929
|
+
if (!plan) {
|
|
930
|
+
let cascade = planCategoryRowCascade(input);
|
|
931
|
+
plans.set(key, plan = spreadUpright(input, cascade) ?? cascade);
|
|
932
|
+
}
|
|
933
|
+
return { ...plan, warnings: [...plan.warnings], cutNotes: [...plan.cutNotes] };
|
|
934
|
+
}
|
|
935
|
+
function spreadUpright(input, plan) {
|
|
936
|
+
let n = input.labels.length;
|
|
937
|
+
if (plan.rotation === 0 || plan.dateNumeric || input.widths || n < 3 || input.spreadBeforeRotate === !1) return;
|
|
938
|
+
let { centers, step } = input, [x0, x1] = input.range ?? [centers[0] - step / 2, centers[n - 1] + step / 2], font = input.fonts[0], endRoom = (i) => Math.max(step, Math.min(
|
|
939
|
+
input.measure(input.labels[i], font).width,
|
|
940
|
+
2 * (i === 0 ? centers[0] - x0 : x1 - centers[n - 1])
|
|
941
|
+
)), upright = planCategoryRowCascade({ ...input, widths: input.labels.map((_, i) => i === 0 || i === n - 1 ? endRoom(i) : 2 * step - 8) }), drawn = (p) => p.keep.filter(Boolean).length, whole = (p, lines) => p.rotation === 0 && drawn(p) >= drawn(plan) && p.infos.every((info, i) => !p.keep[i] || !info.truncated && info.lines.length <= lines);
|
|
942
|
+
if (whole(upright, 1)) return upright;
|
|
943
|
+
let font0 = input.fonts[0], widestWord = (label) => Math.max(0, ...label.split(/\s+/).filter(Boolean).map((word) => input.measure(word, font0).width)), wrapped = planCategoryRowCascade({ ...input, widths: input.labels.map((label, i) => i === 0 || i === n - 1 ? endRoom(i) : Math.max(step, Math.ceil(widestWord(label)) + 1)) });
|
|
944
|
+
return whole(wrapped, PROSE_TICK_MAX_LINES) ? wrapped : void 0;
|
|
945
|
+
}
|
|
946
|
+
function planCategoryRowCascade(input) {
|
|
947
|
+
let measured = /* @__PURE__ */ new Map(), sourceMeasure = input.measure;
|
|
948
|
+
input = withCalendarRule({ ...input, measure: (text, font) => {
|
|
949
|
+
let texts = measured.get(font);
|
|
950
|
+
texts || measured.set(font, texts = /* @__PURE__ */ new Map());
|
|
951
|
+
let size = texts.get(text);
|
|
952
|
+
if (!size) {
|
|
953
|
+
let { width, height, ascent } = sourceMeasure(text, font);
|
|
954
|
+
texts.set(text, size = { width, height, ascent });
|
|
955
|
+
}
|
|
956
|
+
return size;
|
|
957
|
+
} });
|
|
958
|
+
let bundled = sourceMeasure === defaultMeasurer || sourceMeasure === measureText, plan = planRow(input, bundled), weekdays = plan.step === "fit" && input.calendar?.length === input.labels.length && input.calendar.every((info, i) => info?.weekday?.endsWith(` ${input.labels[i]}`)) ? input.calendar.map((info) => info.weekday) : void 0, withWeekdays = weekdays && planRow({ ...input, labels: weekdays }, bundled);
|
|
959
|
+
if (withWeekdays?.step === "fit") return withWeekdays;
|
|
960
|
+
if (input.strideFromEnd && input.calendar && !plan.yearRow) {
|
|
961
|
+
let drawnYears = new Set(input.calendar.flatMap((info, i) => info && plan.keep[i] ? [info.year] : [])), namedYears = new Set(input.calendar.flatMap((info, i) => info && plan.keep[i] && (info.yearShown || input.labels[i].includes(String(info.year))) ? [info.year] : []));
|
|
962
|
+
[...drawnYears].some((year) => !namedYears.has(year)) && (input = {
|
|
963
|
+
...input,
|
|
964
|
+
labels: input.labels.map((label, i) => input.calendar[i]?.yearShown ? label.replace(new RegExp(` ${input.calendar[i].year}$`), "") : label),
|
|
965
|
+
calendar: input.calendar.map((info) => info && { ...info, yearShown: !1, yearRow: !0 })
|
|
966
|
+
}, plan = planRow(input, bundled));
|
|
967
|
+
}
|
|
968
|
+
let short = plan.step === "fit" ? void 0 : shortMonthNames(input.labels);
|
|
969
|
+
if (!short) return plan;
|
|
970
|
+
let shortPlan = planRow({ ...input, labels: short }, bundled);
|
|
971
|
+
return { ...shortPlan, infos: shortPlan.infos.map((info, i) => ({ ...info, title: info.title ?? input.labels[i] })) };
|
|
972
|
+
}
|
|
973
|
+
function withCalendarRule(input) {
|
|
974
|
+
if (input.dateStride || !input.dates) return input;
|
|
975
|
+
let calendar = calendarMonths(input.dates);
|
|
976
|
+
if (!calendar) return input;
|
|
977
|
+
if (!calendar.months)
|
|
978
|
+
return calendar.unit === "day" || calendar.unit === "week" ? { ...input, strideFromEnd: !0 } : input;
|
|
979
|
+
let quarters = calendar.unit === "quarter";
|
|
980
|
+
return { ...input, dateStride: { ordinals: calendar.months, strides: quarters ? [6, 12, 24, 36] : [3, 6, 12, 24, 36], calendar: !0, perStep: quarters ? 3 : 1 } };
|
|
981
|
+
}
|
|
982
|
+
var lowerMonths = /* @__PURE__ */ new Map();
|
|
983
|
+
function shortMonthNames(labels) {
|
|
984
|
+
if (labels.length < 2) return;
|
|
985
|
+
let lower = labels.map((label) => label.trim().toLowerCase());
|
|
986
|
+
for (let language of DATE_NAME_LANGUAGES) {
|
|
987
|
+
let { months, monthsShort } = dateNames(language), byName = lowerMonths.get(months);
|
|
988
|
+
byName || (byName = /* @__PURE__ */ new Map(), months.forEach((month, i) => {
|
|
989
|
+
byName.has(month.toLowerCase()) || byName.set(month.toLowerCase(), i);
|
|
990
|
+
}), lowerMonths.set(months, byName));
|
|
991
|
+
let index = [];
|
|
992
|
+
for (let label of lower) {
|
|
993
|
+
let i = byName.get(label);
|
|
994
|
+
if (i === void 0) break;
|
|
995
|
+
index.push(i);
|
|
996
|
+
}
|
|
997
|
+
if (index.length === lower.length && index.some((i) => monthsShort[i] !== months[i])) return index.map((i) => monthsShort[i]);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function planRow(input, bundled) {
|
|
1001
|
+
let { labels, centers, step, measure } = input, n = labels.length, dateNumeric = input.calendar?.length === n && input.calendar.every(Boolean) || isDateNumericTickSequence(labels), periodRow = dateNumeric || input.periods === !0 || calendarLike(labels), secondary = periodRow && input.secondary !== void 0 && input.secondary.size < input.fonts[0].size ? { ...input.secondary, size: input.fonts[0].size } : void 0, fonts = (secondary ? [secondary, ...input.fonts.filter((font) => font.size < secondary.size)] : input.fonts).filter((font, index) => index === 0 || font.size >= targetFloorsPx(input.target ?? DEFAULT_TARGET, input.textScale)[secondary ? "secondary" : "axis"]), gap = input.gap ?? 4, padding = input.padding ?? 6, allowRotate = input.rotate ?? !0, orderedProse = (input.ordered || input.strideFromEnd || numberedSequence(labels)) && !dateNumeric, baseFont = fonts[0], growingWidths = (font) => bundled && font.size > 0 && (font.letterSpacing ?? 0) >= 0, maxRotatedWidth = input.maxRotatedWidth ?? rotatedWidthCap(input.plotHeight, n * step, baseFont), widthAt = (i) => input.widths?.[i] ?? step, suffixAt = (i) => input.suffixes?.[i] ?? "", withSuffix = (info, i, font) => {
|
|
1002
|
+
let suffix = suffixAt(i);
|
|
1003
|
+
if (!suffix) return info;
|
|
1004
|
+
let lines = [...info.lines];
|
|
1005
|
+
return lines[lines.length - 1] = `${lines[lines.length - 1] ?? ""}${suffix}`, { ...info, lines, w: info.w + measure(suffix, font).width };
|
|
1006
|
+
}, measuredRows = /* @__PURE__ */ new Map(), measureAll = (font, maxLines, preserveBreaks = !1, pad = padding) => {
|
|
1007
|
+
let rows = measuredRows.get(font);
|
|
1008
|
+
rows || measuredRows.set(font, rows = /* @__PURE__ */ new Map());
|
|
1009
|
+
let key = maxLines <= 1 ? `1:${preserveBreaks}` : `${maxLines}:${pad}`, cached = rows.get(key);
|
|
1010
|
+
if (cached) return cached;
|
|
1011
|
+
let infos = labels.map((label, i) => {
|
|
1012
|
+
let reserve = suffixAt(i) ? measure(suffixAt(i), font).width : 0;
|
|
1013
|
+
if (dateNumeric || maxLines <= 1) {
|
|
1014
|
+
let lines2 = preserveBreaks ? label.split(`
|
|
1015
|
+
`) : [label];
|
|
1016
|
+
return withSuffix({
|
|
1017
|
+
lines: lines2,
|
|
1018
|
+
w: Math.max(...lines2.map((line) => measure(line, font).width), 1),
|
|
1019
|
+
h: lines2.length * font.size * (font.lineHeight ?? 1.2),
|
|
1020
|
+
truncated: !1
|
|
1021
|
+
}, i, font);
|
|
1022
|
+
}
|
|
1023
|
+
let width = Math.max(widthAt(i) - pad - reserve, 1), single2 = !growingWidths(font) || /[\n\u200d\u{E0020}-\u{E007F}]/u.test(label) ? void 0 : label.split(/[^\S\u00a0\u202f]+/).filter(Boolean).join(" ");
|
|
1024
|
+
if (single2 !== void 0 && measure(single2, font).width <= width)
|
|
1025
|
+
return withSuffix({ lines: [single2], w: Math.max(measure(single2, font).width, 1), h: font.size * (font.lineHeight ?? 1.2), truncated: !1 }, i, font);
|
|
1026
|
+
let wrap = fitText(label, font, width, maxLines, measure), lines = wrap.lines.length ? wrap.lines : [""];
|
|
1027
|
+
return withSuffix({
|
|
1028
|
+
lines,
|
|
1029
|
+
w: Math.max(...lines.map((l) => measure(l, font).width), 1),
|
|
1030
|
+
h: lines.length * font.size * (font.lineHeight ?? 1.2),
|
|
1031
|
+
truncated: wrap.title !== void 0,
|
|
1032
|
+
...wrap.title !== void 0 ? { title: wrap.title } : {}
|
|
1033
|
+
}, i, font);
|
|
1034
|
+
});
|
|
1035
|
+
return rows.set(key, infos), infos;
|
|
1036
|
+
}, words = labels.map((label) => /[\n\u200d\u{E0020}-\u{E007F}]/u.test(label) ? [] : label.split(/[^\S\u00a0\u202f]+/).filter(Boolean)), wholeRows = (font, maxLines, pad = padding, kept) => growingWidths(font) && words.some((parts, i) => (!kept || kept[i]) && parts.some((word) => measure(word, font).width > Math.max(widthAt(i) - pad - (suffixAt(i) ? measure(suffixAt(i), font).width : 0), 1))) ? void 0 : measureAll(font, maxLines, !1, pad), rowStart = n > 0 ? centers[0] - widthAt(0) / 2 : 0, rowEnd = n > 0 ? centers[n - 1] + widthAt(n - 1) / 2 : 0, stridingOrdered = !1, spreadX, anchor = (i, w) => spreadX?.[i] !== void 0 ? spreadX[i] : input.edgeAnchored === !0 || stridingOrdered ? tickLabelX(centers[i], w, i, n, !0) : Math.max(rowStart, Math.min(centers[i] - w / 2, rowEnd - w)), xOf = (infos) => (i) => anchor(i, infos[i].w), ownsItsRoom = (i, w, step2 = 1) => {
|
|
1037
|
+
let x = anchor(i, w);
|
|
1038
|
+
return (i - step2 < 0 || x >= centers[i - step2]) && (i + step2 > n - 1 || x + w <= centers[i + step2]);
|
|
1039
|
+
}, fits = (infos, keep, minGap = gap) => {
|
|
1040
|
+
let x = xOf(infos), two2 = keep.pair;
|
|
1041
|
+
if (two2) {
|
|
1042
|
+
let [a, b] = two2;
|
|
1043
|
+
return !(x(a) + infos[a].w + (pinned[a] && pinned[b] ? Math.min(minGap, 4) : minGap) > x(b));
|
|
1044
|
+
}
|
|
1045
|
+
let previous;
|
|
1046
|
+
for (let i = 0; i < n; i++) {
|
|
1047
|
+
if (!keep[i]) continue;
|
|
1048
|
+
let need = previous !== void 0 && pinned[previous] && pinned[i] ? Math.min(minGap, 4) : minGap;
|
|
1049
|
+
if (previous !== void 0 && x(previous) + infos[previous].w + need > x(i)) return !1;
|
|
1050
|
+
previous = i;
|
|
1051
|
+
}
|
|
1052
|
+
return !0;
|
|
1053
|
+
}, requested = input.keep, calendarRule = input.dateStride?.calendar === !0, yearPins = labels.map((_, i) => !input.strideFromEnd && !calendarRule && input.calendar?.[i]?.yearShown === !0), yearSpans = [];
|
|
1054
|
+
input.calendar?.forEach((info, i) => {
|
|
1055
|
+
if (!info?.yearRow && !info?.monthRow) return;
|
|
1056
|
+
let last2 = yearSpans.at(-1);
|
|
1057
|
+
last2 && last2.year === info.year && last2.month === info.monthRow && last2.to === i - 1 ? last2.to = i : yearSpans.push({ year: info.year, ...info.monthRow ? { month: info.monthRow } : {}, from: i, to: i });
|
|
1058
|
+
});
|
|
1059
|
+
let underAt = (i) => input.under?.[i] ?? "", pinned = labels.map((_, i) => calendarRule ? i === n - 1 || suffixAt(i) !== "" || underAt(i) !== "" || input.pinned?.[i] === !0 : input.strideFromEnd ? i === n - 1 || underAt(i) !== "" : suffixAt(i) !== "" || underAt(i) !== "" || yearPins[i] || input.pinned?.[i] === !0), all = labels.map((_, i) => pinned[i] || (requested?.[i] ?? !0)), monthRow = (xAt, font, lineH) => {
|
|
1060
|
+
let kept = [];
|
|
1061
|
+
for (let s = yearSpans.length - 1; s >= 0; s--) {
|
|
1062
|
+
let span = yearSpans[s], w = measure(`${span.month} ${span.year}`, font).width, x = Math.max(rowStart, Math.min(xAt(span.from), rowEnd - w));
|
|
1063
|
+
kept.length > 0 && x + w + 2 * gap > kept[0].x || kept.unshift({ span, x });
|
|
1064
|
+
}
|
|
1065
|
+
return kept.map(({ span, x }, k) => {
|
|
1066
|
+
let text = k === 0 || kept[k - 1].span.year !== span.year ? `${span.month} ${span.year}` : span.month;
|
|
1067
|
+
return { id: `category-month:${span.year}-${span.month}`, text, x, w: measure(text, font).width, h: lineH };
|
|
1068
|
+
});
|
|
1069
|
+
}, plan = (font, infos, keep, stepName, extra = {}) => {
|
|
1070
|
+
let rotation = extra.rotation ?? 0;
|
|
1071
|
+
rotation !== 0 && input.under?.some(Boolean) && (infos = infos.map((info, i) => {
|
|
1072
|
+
let words2 = underAt(i);
|
|
1073
|
+
if (!words2 || !keep[i]) return info;
|
|
1074
|
+
let lines = [...info.lines];
|
|
1075
|
+
return lines[lines.length - 1] = `${lines[lines.length - 1] ?? ""} ${words2}`, { ...info, lines, w: info.w + measure(` ${words2}`, font).width };
|
|
1076
|
+
}));
|
|
1077
|
+
let drawn = infos.filter((_, i) => keep[i]), maxLines = rotation ? 1 : Math.max(1, maxOf(drawn.map((info) => info.lines.length))), lineH = font.size * (font.lineHeight ?? 1.2), labelsHeight = rotation === 90 ? Math.max(maxOf(drawn.map((info) => info.w)), 1) : rotation ? Math.max(maxOf(drawn.map((info) => info.w)), 1) * SIN45 + lineH * SIN45 : maxLines * lineH, xAt = xOf(infos), hasMonths = yearSpans.some((span) => span.month), years = hasMonths ? monthRow(xAt, font, lineH) : yearSpans.map(({ year, from, to }) => {
|
|
1078
|
+
let w = measure(String(year), font).width;
|
|
1079
|
+
return { id: `category-year:${year}`, text: String(year), w, h: lineH, x: Math.max(rowStart, Math.min((centers[from] + centers[to]) / 2 - w / 2, rowEnd - w)) };
|
|
1080
|
+
});
|
|
1081
|
+
if (!hasMonths && input.calendar?.[yearSpans[0]?.from ?? -1]?.unit === "day" && years.some((year, i) => i > 0 && years[i - 1].x + years[i - 1].w + gap > year.x)) {
|
|
1082
|
+
let keptYears = new Set(input.calendar.flatMap((info, i) => info && keep[i] ? [String(info.year)] : []));
|
|
1083
|
+
years = years.filter((year) => keptYears.has(year.text));
|
|
1084
|
+
}
|
|
1085
|
+
let underItems = rotation !== 0 ? [] : labels.flatMap((_, i) => {
|
|
1086
|
+
let text = underAt(i);
|
|
1087
|
+
if (!text || !keep[i]) return [];
|
|
1088
|
+
let w = measure(text, font).width, mid = xAt(i) + infos[i].w / 2;
|
|
1089
|
+
return [{ index: i, text, w, h: lineH, x: Math.max(rowStart, Math.min(mid - w / 2, rowEnd - w)) }];
|
|
1090
|
+
}), namesHeight = labelsHeight + (underItems.length > 0 ? YEAR_ROW_GAP + lineH : 0), rowHeight = namesHeight + (years.length > 0 ? YEAR_ROW_GAP + lineH : 0);
|
|
1091
|
+
return {
|
|
1092
|
+
dateNumeric,
|
|
1093
|
+
typeRole: secondary ? "secondary" : "axis",
|
|
1094
|
+
font,
|
|
1095
|
+
infos,
|
|
1096
|
+
keep,
|
|
1097
|
+
stride: extra.stride ?? 1,
|
|
1098
|
+
rotation,
|
|
1099
|
+
maxLines,
|
|
1100
|
+
rowHeight,
|
|
1101
|
+
x: xOf(infos),
|
|
1102
|
+
anchor,
|
|
1103
|
+
step: stepName,
|
|
1104
|
+
warnings: extra.warnings ?? [],
|
|
1105
|
+
cutNotes: extra.cutNotes ?? [],
|
|
1106
|
+
...years.length > 0 ? { yearRow: { offset: namesHeight + YEAR_ROW_GAP, years } } : {},
|
|
1107
|
+
...underItems.length > 0 ? { underRow: { offset: labelsHeight + YEAR_ROW_GAP, items: underItems } } : {}
|
|
1108
|
+
};
|
|
1109
|
+
}, referenceStride = () => {
|
|
1110
|
+
if (!calendarRule || !input.reference) return 0;
|
|
1111
|
+
let pitch = input.reference.width / n, reference = planRow({
|
|
1112
|
+
...input,
|
|
1113
|
+
reference: void 0,
|
|
1114
|
+
step: pitch,
|
|
1115
|
+
edgeAnchored: !1,
|
|
1116
|
+
centers: labels.map((_, i) => input.reference.x + pitch * (i + 0.5))
|
|
1117
|
+
}, bundled);
|
|
1118
|
+
return reference.step === "stride" ? reference.stride * (input.dateStride?.perStep ?? 1) : 0;
|
|
1119
|
+
}, blank = labels.map((label) => label.replace(/[\s\u200b]/g, "") === ""), names = blank.filter((isBlank) => !isBlank).length;
|
|
1120
|
+
if (periodRow && names > 0 && names * 2 < n)
|
|
1121
|
+
for (let f = 0; ; f++) {
|
|
1122
|
+
let font = fonts[f], infos = measureAll(font, 1, !0), collides = (before, after) => {
|
|
1123
|
+
let need = pinned[before] && pinned[after] ? Math.min(gap, 4) : gap;
|
|
1124
|
+
return anchor(before, infos[before].w) + infos[before].w + need > anchor(after, infos[after].w);
|
|
1125
|
+
}, keep = labels.map((_, i) => !blank[i]), dropped = [], kept = [];
|
|
1126
|
+
for (let i = 0; i < n; i++)
|
|
1127
|
+
if (keep[i]) {
|
|
1128
|
+
for (let before = kept.at(-1); before !== void 0 && collides(before, i); before = kept.at(-1)) {
|
|
1129
|
+
let loser = pinned[i] && !pinned[before] ? before : i;
|
|
1130
|
+
if (keep[loser] = !1, dropped.push(labels[loser]), loser === i) break;
|
|
1131
|
+
kept.pop();
|
|
1132
|
+
}
|
|
1133
|
+
keep[i] && kept.push(i);
|
|
1134
|
+
}
|
|
1135
|
+
if (dropped.length === 0 || f === fonts.length - 1)
|
|
1136
|
+
return plan(font, infos, keep, f === 0 ? "fit" : "font-down", dropped.length === 0 ? {} : {
|
|
1137
|
+
stride: 1,
|
|
1138
|
+
warnings: [{
|
|
1139
|
+
code: "category-stride",
|
|
1140
|
+
severity: "warn",
|
|
1141
|
+
message: `category labels: ${names - dropped.length} of ${names} names drawn, ${dropped.map((label) => `'${label}'`).join(", ")} collide with a neighbouring name`
|
|
1142
|
+
}]
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
if (dateNumeric || orderedProse) {
|
|
1146
|
+
for (let f = 0; f < fonts.length; f++) {
|
|
1147
|
+
let font = fonts[f], infos = measureAll(font, 1, orderedProse);
|
|
1148
|
+
if (fits(infos, all) && (!orderedProse || infos.every((info, i) => !all[i] || info.w <= rowEnd - rowStart)))
|
|
1149
|
+
return plan(font, infos, all, f === 0 ? "fit" : "font-down", {
|
|
1150
|
+
warnings: f === 0 ? [] : [
|
|
1151
|
+
{
|
|
1152
|
+
code: "category-font-stepped",
|
|
1153
|
+
severity: "info",
|
|
1154
|
+
message: `category labels use the ${font.size}px step so all ${n} fit on one row`
|
|
1155
|
+
}
|
|
1156
|
+
]
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
if (dateNumeric) {
|
|
1160
|
+
let font = fonts.at(-1);
|
|
1161
|
+
return strideAfterFontLadder(labels, measureAll(font, 1), font, requested, pinned, input.dateStride, fits, plan, yearPins, input.strideFromEnd && !calendarRule, referenceStride());
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
let plain = measureAll(baseFont, 1, !0), plainGap = labels.some((label) => /\S\s+\S/.test(label)) && labels.every((label) => label.trim().split(/\s+/).every((word) => word.length >= 3)) ? Math.max(gap, baseFont.size / 2) : gap;
|
|
1165
|
+
if (plain.every((info, i) => info.w + gap <= widthAt(i)) && fits(plain, all, plainGap)) return plan(baseFont, plain, all, "fit");
|
|
1166
|
+
let two = wholeRows(baseFont, PROSE_TICK_MAX_LINES);
|
|
1167
|
+
if (two && !two.some((info) => info.truncated) && fits(two, all))
|
|
1168
|
+
return plan(baseFont, two, all, two.some((info) => info.lines.length > 1) ? "wrap" : "fit");
|
|
1169
|
+
let three = wholeRows(baseFont, 3);
|
|
1170
|
+
if (three && !three.some((info) => info.truncated) && fits(three, all)) return plan(baseFont, three, all, "wrap");
|
|
1171
|
+
for (let font of fonts.slice(1)) {
|
|
1172
|
+
let infos = wholeRows(font, 3);
|
|
1173
|
+
if (infos && !infos.some((info) => info.truncated) && fits(infos, all))
|
|
1174
|
+
return plan(font, infos, all, "font-down", {
|
|
1175
|
+
warnings: [
|
|
1176
|
+
{
|
|
1177
|
+
code: "category-font-stepped",
|
|
1178
|
+
severity: "info",
|
|
1179
|
+
message: `category labels use the ${font.size}px step so all ${n} names fit unabridged`
|
|
1180
|
+
}
|
|
1181
|
+
]
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
for (let font of fonts)
|
|
1185
|
+
for (let lines of [PROSE_TICK_MAX_LINES, 3]) {
|
|
1186
|
+
let slot = wholeRows(font, lines, 0);
|
|
1187
|
+
if (slot && !slot.some((info) => info.truncated) && fits(slot, all)) return plan(font, slot, all, font === baseFont ? "wrap" : "font-down");
|
|
1188
|
+
}
|
|
1189
|
+
for (let font of fonts)
|
|
1190
|
+
for (let lines of [1, PROSE_TICK_MAX_LINES, 3]) {
|
|
1191
|
+
let infos = lines === 1 ? measureAll(font, 1, !0, 0) : wholeRows(font, lines, 0, all);
|
|
1192
|
+
if (!infos || infos.some((info, i) => all[i] && (info.truncated || info.w > widthAt(i)))) continue;
|
|
1193
|
+
let kept = labels.flatMap((_, i) => all[i] ? [i] : []);
|
|
1194
|
+
for (let spreadGap of [.../* @__PURE__ */ new Set([Math.max(gap, SPREAD_GAP), gap])]) {
|
|
1195
|
+
let spread = spread1DResult(kept.map((i) => ({ desired: centers[i], size: infos[i].w })), [rowStart, rowEnd], spreadGap);
|
|
1196
|
+
if (!spread.fits) continue;
|
|
1197
|
+
let xs = [];
|
|
1198
|
+
if (kept.forEach((i, k) => {
|
|
1199
|
+
xs[i] = spread.positions[k] - infos[i].w / 2;
|
|
1200
|
+
}), !!kept.every((i) => xs[i] <= centers[i] && xs[i] + infos[i].w >= centers[i] && (i === 0 || xs[i] >= centers[i - 1]) && (i === n - 1 || xs[i] + infos[i].w <= centers[i + 1]))) {
|
|
1201
|
+
if (spreadX = xs, fits(infos, all)) return plan(font, infos, all, font !== baseFont ? "font-down" : infos.some((info) => info.lines.length > 1) ? "wrap" : "fit");
|
|
1202
|
+
spreadX = void 0;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (orderedProse) {
|
|
1207
|
+
stridingOrdered = !0;
|
|
1208
|
+
let font = fonts.at(-1), thinned = strideAfterFontLadder(labels, measureAll(font, 1, !0), font, calendarRule && input.keep === void 0 ? void 0 : all, pinned, calendarRule ? input.dateStride : void 0, fits, plan, [], input.strideFromEnd && !calendarRule, referenceStride());
|
|
1209
|
+
if ((input.strideFromEnd || thinned.keep.filter(Boolean).length > 1) && fits(thinned.infos, thinned.keep) && thinned.infos.every((info, i) => !thinned.keep[i] || info.w <= rowEnd - rowStart)) return thinned;
|
|
1210
|
+
stridingOrdered = !1;
|
|
1211
|
+
}
|
|
1212
|
+
for (let font of fonts) {
|
|
1213
|
+
let flat = measureAll(font, 1, !0);
|
|
1214
|
+
if (!flat.some((info) => info.truncated) && flat.every((info, i) => info.w <= widthAt(i)) && fits(flat, all, 4)) return plan(font, flat, all, font === baseFont ? "fit" : "font-down");
|
|
1215
|
+
}
|
|
1216
|
+
let everyName = input.everyName === !0 && !orderedProse, room45 = allowRotate && fonts.some((font) => step * SIN45 >= font.size * (font.lineHeight ?? 1.2) + 2);
|
|
1217
|
+
if (allowRotate && (input.rotate90 || everyName && !room45)) {
|
|
1218
|
+
let upright = fonts.filter((font2) => step >= font2.size * (font2.lineHeight ?? 1.2) + 2), cap = Math.max(VERTICAL_MIN_WIDTH, Math.floor((input.plotHeight ?? 0) * VERTICAL_HEIGHT_SHARE)), font = upright.find((f) => measureAll(f, 1).every((info) => info.w <= cap)) ?? upright[0];
|
|
1219
|
+
if (font) {
|
|
1220
|
+
let cutNames = [], infos = measureAll(font, 1).map((info, i) => {
|
|
1221
|
+
if (info.w <= cap) return info;
|
|
1222
|
+
let cut2 = cutWithTitle(info.lines[0], font, cap, measure);
|
|
1223
|
+
return cutNames.push(labels[i]), { ...info, lines: [cut2.text], w: cap, truncated: !0, ...cut2.title !== void 0 ? { title: cut2.title } : {} };
|
|
1224
|
+
});
|
|
1225
|
+
return plan(font, infos, all, "rotate", {
|
|
1226
|
+
rotation: 90,
|
|
1227
|
+
warnings: [
|
|
1228
|
+
{
|
|
1229
|
+
code: "category-labels-rotated",
|
|
1230
|
+
severity: "info",
|
|
1231
|
+
message: `category labels rotated -90\xB0: ${n} names do not fit horizontally on up to 3 lines at ${Math.round(step)}px per category`,
|
|
1232
|
+
suggest: "a horizontal chart keeps names upright"
|
|
1233
|
+
},
|
|
1234
|
+
...cutNames.length > 0 ? [categoryCutLint(cutNames, !1, "on the vertical axis")] : []
|
|
1235
|
+
]
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
if (allowRotate) {
|
|
1240
|
+
let rotatable = fonts.filter((font2) => step * SIN45 >= font2.size * (font2.lineHeight ?? 1.2) + 2), font = rotatable.find((font2) => measureAll(font2, 1).every((info) => info.w <= maxRotatedWidth)) ?? rotatable[0];
|
|
1241
|
+
if (font) {
|
|
1242
|
+
let cutNotes = [], cutNames = [], infos = measureAll(font, 1).map((info, i) => {
|
|
1243
|
+
if (info.w <= maxRotatedWidth) return info;
|
|
1244
|
+
let mark = input.cutMarkFrom === void 0 || suffixAt(i) ? "" : ` ${footnoteMark(input.cutMarkFrom + cutNotes.length)}`, suffix = suffixAt(i) + mark, reserve = suffix ? measure(suffix, font).width : 0, bare = suffixAt(i) && info.lines[0].endsWith(suffixAt(i)) ? info.lines[0].slice(0, -suffixAt(i).length) : info.lines[0], cut2 = cutWithTitle(bare, font, Math.max(maxRotatedWidth - reserve, 1), measure);
|
|
1245
|
+
return cutNames.push(labels[i]), mark && cutNotes.push(disclosureNote(`${mark.trim()} ${labels[i]}.`)), { ...info, lines: [`${cut2.text}${suffix}`], w: maxRotatedWidth, truncated: !0, ...cut2.title !== void 0 ? { title: cut2.title } : {} };
|
|
1246
|
+
});
|
|
1247
|
+
return plan(font, infos, all, "rotate", {
|
|
1248
|
+
rotation: 45,
|
|
1249
|
+
cutNotes,
|
|
1250
|
+
warnings: [
|
|
1251
|
+
{
|
|
1252
|
+
code: "category-labels-rotated",
|
|
1253
|
+
severity: "info",
|
|
1254
|
+
message: `category labels rotated 45\xB0: ${n} names do not fit horizontally on up to 3 lines at ${Math.round(step)}px per category`,
|
|
1255
|
+
suggest: 'a horizontal chart (bar, or variant: "horizontal" on waterfall) keeps names upright'
|
|
1256
|
+
},
|
|
1257
|
+
...cutNames.length > 0 ? [categoryCutLint(cutNames, cutNotes.length === cutNames.length)] : []
|
|
1258
|
+
]
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
let single = measureAll(baseFont, 1);
|
|
1263
|
+
if (!everyName && single.some((info, i) => info.w <= widthAt(i) * n - padding))
|
|
1264
|
+
return namesByFit(labels, single, baseFont, void 0, pinned, input.priority, fits, plan, ownsItsRoom);
|
|
1265
|
+
let cutCount = (infos) => infos.filter((info) => info.truncated).length, last = { font: baseFont, infos: two ?? measureAll(baseFont, PROSE_TICK_MAX_LINES) };
|
|
1266
|
+
for (let candidate of [{ font: baseFont, infos: three ?? measureAll(baseFont, 3) }, ...fonts.slice(1).map((font) => ({ font, infos: measureAll(font, 3) }))]) {
|
|
1267
|
+
let fitsNow = fits(candidate.infos, all), fitsLast = fits(last.infos, all);
|
|
1268
|
+
(fitsNow && !fitsLast || fitsNow === fitsLast && cutCount(candidate.infos) < cutCount(last.infos)) && (last = candidate);
|
|
1269
|
+
}
|
|
1270
|
+
if (last.infos.some((info, i) => all[i] && info.truncated && /^…?$/.test(info.lines[0].trim())))
|
|
1271
|
+
return namesByFit(labels, single, baseFont, requested, pinned, input.priority, fits, plan, ownsItsRoom);
|
|
1272
|
+
let cut = labels.filter((_, i) => last.infos[i].lines.some((line) => line.includes("\u2026")));
|
|
1273
|
+
return plan(last.font, last.infos, all, "ellipsis", {
|
|
1274
|
+
warnings: [
|
|
1275
|
+
{
|
|
1276
|
+
code: "category-labels-truncated",
|
|
1277
|
+
severity: "warn",
|
|
1278
|
+
message: `${cut.length} of ${n} category labels are cut with an ellipsis \u2014 the pitch of ${Math.round(step)}px holds neither the wrapped nor the rotated name: ${cut.map((label) => `'${label}'`).join(", ")}`,
|
|
1279
|
+
suggest: "widen the canvas, shorten the names, or use a horizontal chart",
|
|
1280
|
+
detail: { cut }
|
|
1281
|
+
}
|
|
1282
|
+
]
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
function categoryCutLint(names, noted, where = "on the rotated axis") {
|
|
1286
|
+
return {
|
|
1287
|
+
code: "category-labels-truncated",
|
|
1288
|
+
severity: noted ? "info" : "warn",
|
|
1289
|
+
message: `${names.length === 1 ? "one category label is" : `${names.length} category labels are`} cut ${where}: ${names.map((name) => `'${name}'`).join(", ")}` + (noted ? "; the full name is in the notes list" : "; the full name is in the SVG title only"),
|
|
1290
|
+
suggest: "shorten the name, widen the canvas, or use a bar chart to keep names upright",
|
|
1291
|
+
detail: { cut: [...names] }
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
function rotatedWidthCap(plotHeight, rowWidth, font) {
|
|
1295
|
+
if (plotHeight === void 0) return ROTATED_MIN_WIDTH;
|
|
1296
|
+
let lineH = font.size * (font.lineHeight ?? 1.2), byHeight = plotHeight * ROTATED_HEIGHT_SHARE / SIN45 - lineH, byWidth = rowWidth * 0.5 / SIN45 - lineH;
|
|
1297
|
+
return Math.max(ROTATED_MIN_WIDTH, Math.floor(Math.min(byHeight, byWidth)));
|
|
1298
|
+
}
|
|
1299
|
+
function rotatedClaimRect(anchorX, anchorY, lineHeight, rowTop) {
|
|
1300
|
+
let y = Math.max(anchorY - lineHeight * SIN45 / 2, rowTop === void 0 ? -1 / 0 : rowTop + 3);
|
|
1301
|
+
return { x: anchorX - lineHeight, y, w: lineHeight, h: lineHeight };
|
|
1302
|
+
}
|
|
1303
|
+
function rotatedLeftOverhang(plan, centers, minX) {
|
|
1304
|
+
if (plan.rotation !== 45) return 0;
|
|
1305
|
+
let lineH = plan.font.size * (plan.font.lineHeight ?? 1.2), overhang = 0;
|
|
1306
|
+
return plan.infos.forEach((info, i) => {
|
|
1307
|
+
if (!plan.keep[i]) return;
|
|
1308
|
+
let left = centers[i] - (info.w + lineH) * SIN45;
|
|
1309
|
+
overhang = Math.max(overhang, minX - left);
|
|
1310
|
+
}), Math.ceil(overhang);
|
|
1311
|
+
}
|
|
1312
|
+
function verticalNameRect(centerX, rowTop, width, font) {
|
|
1313
|
+
let lineH = font.size * (font.lineHeight ?? 1.2), pivotX = centerX + font.size * VERTICAL_CAP_SHARE / 2, pivotY = rowTop + 4 + lineH * SIN45 / 2;
|
|
1314
|
+
return { x: pivotX - lineH, y: pivotY - lineH * SIN45 / 2, w: lineH, h: lineH * SIN45 / 2 + width };
|
|
1315
|
+
}
|
|
1316
|
+
var VERTICAL_CAP_SHARE = 0.72;
|
|
1317
|
+
|
|
1318
|
+
// src/core/sizing.ts
|
|
1319
|
+
var ROW_TYPES = /* @__PURE__ */ new Set(["bar", "bartable", "bullet", "butterfly", "gantt", "likert", "cohort", "table", "funnel", "status", "heatmap"]), ROW_FAMILY = ["bar", "bartable", "funnel", "butterfly", "likert", "status", "gantt", "cohort", "heatmap", "bullet"], BAND_FAMILY = ["waterfall", "pareto", "variance", "pyramid", "box", "mekko", "pvm"], CARD_MIN_WIDTH = 280, CARD_CLASS_WIDTH = 480, CARD_STEPS = [400, CARD_CLASS_WIDTH];
|
|
1320
|
+
var CARD_FLOOR_CONTENT_TYPES = /* @__PURE__ */ new Set(["butterfly", "diagram", "funnel", "grid", "heatmap", "kpi", "status"]), REPAIR_PROBE_TYPES = /* @__PURE__ */ new Set(["status", "bullet"]), CARD_FLOOR_TYPES = /* @__PURE__ */ new Set([...ROW_FAMILY, ...BAND_FAMILY]), CONTENT_TYPES = /* @__PURE__ */ new Set([...ROW_TYPES, "kpi", "pie", "diagram", "sparkline", "slope", "choropleth"]), ROW_COMPACT_FLOOR = { width: CARD_MIN_WIDTH, height: 28 }, BAND_COMPACT_FLOOR = { width: CARD_MIN_WIDTH, height: 180 }, COMPACT_FLOORS = {
|
|
1321
|
+
column: { width: 280, height: 180 },
|
|
1322
|
+
line: { width: 280, height: 180 },
|
|
1323
|
+
scatter: { width: 280, height: 240 },
|
|
1324
|
+
dot: { width: 280, height: 240 },
|
|
1325
|
+
combo: { width: 280, height: 240 },
|
|
1326
|
+
histogram: { width: 280, height: 240 },
|
|
1327
|
+
treemap: { width: 280, height: 180 },
|
|
1328
|
+
pie: { width: 280, height: 160 },
|
|
1329
|
+
slope: { width: 280, height: 180 },
|
|
1330
|
+
// A grid at the shared minimum height: its compact form (one column of panels) is only the
|
|
1331
|
+
// fallback of a refused full layout (FALLBACK_COMPACT), never a band under its minimum.
|
|
1332
|
+
grid: { width: 280, height: 270 },
|
|
1333
|
+
// A bullet has no compact form under mode 'compact' (only density 'compact'), so it has no compact floor: its measured width gates.
|
|
1334
|
+
...Object.fromEntries(ROW_FAMILY.filter((type) => type !== "status" && type !== "bullet").map((type) => [type, ROW_COMPACT_FLOOR])),
|
|
1335
|
+
...Object.fromEntries(BAND_FAMILY.filter((type) => type !== "mekko").map((type) => [type, BAND_COMPACT_FLOOR]))
|
|
1336
|
+
}, SIZE_TOLERANCE = 0.5, FALLBACK_COMPACT = /* @__PURE__ */ new Set(["grid"]);
|
|
1337
|
+
function belowMinimum(policy, size, options, type) {
|
|
1338
|
+
return policy.compactFloor !== void 0 && options?.belowMinimum !== "refuse" && !FALLBACK_COMPACT.has(type) && !fitsSize(size, policy);
|
|
1339
|
+
}
|
|
1340
|
+
var MIN_COMPACT_PLOT = 80, HOLDS_COMPACT_PLOT = /* @__PURE__ */ new Set(["column", "line", "combo", "histogram", "slope", ...BAND_FAMILY.filter((type) => type !== "mekko")]), HARD_COMPACT_PLOT = 40, HARD_KEEPS_COMPACT_PLOT = /* @__PURE__ */ new Set(["slope"]);
|
|
1341
|
+
function namesDrawnSeries(data, result) {
|
|
1342
|
+
let series = data?.series, entries = (Array.isArray(series) ? series : []).filter((entry) => typeof entry.id == "string").map((entry) => ({ id: entry.id, name: typeof entry.label == "string" ? entry.label : entry.id }));
|
|
1343
|
+
if (entries.length < 2) return !0;
|
|
1344
|
+
let naming = /* @__PURE__ */ new Set(["legendLabel", "series", "lineEnd", "seriesName", "axisTitle"]), keyInk = /* @__PURE__ */ new Set(["swatch", "legendKey", "legendLine"]), active = /* @__PURE__ */ new Set(), named = /* @__PURE__ */ new Set(), walk = (node) => {
|
|
1345
|
+
if (!node || typeof node != "object") return;
|
|
1346
|
+
let item = node, owner = item.owner?.seriesId ?? item.origin?.owner?.seriesId;
|
|
1347
|
+
if (owner !== void 0 && item.opacity !== 0)
|
|
1348
|
+
if (item.t === "text" && Array.isArray(item.lines)) {
|
|
1349
|
+
let text = item.lines.join(" "), entry = entries.find((candidate) => candidate.id === owner);
|
|
1350
|
+
text.trim() !== "" && (["point", "segment", "total", "grandTotal"].includes(item.part ?? "") && active.add(owner), entry && (naming.has(item.part ?? "") || text.includes(entry.name)) && named.add(owner));
|
|
1351
|
+
} else !keyInk.has(item.part ?? "") && (item.t !== "path" || /[LCHV]/i.test(item.d ?? "")) && active.add(owner);
|
|
1352
|
+
Array.isArray(item.children) && item.children.forEach(walk);
|
|
1353
|
+
};
|
|
1354
|
+
(result.scene ?? []).forEach(walk);
|
|
1355
|
+
let drawn = entries.filter((entry) => active.has(entry.id));
|
|
1356
|
+
return drawn.length < 2 || drawn.every((entry) => named.has(entry.id));
|
|
1357
|
+
}
|
|
1358
|
+
function atHardMinimum(options) {
|
|
1359
|
+
return options?.[HARD_MINIMUM] === !0;
|
|
1360
|
+
}
|
|
1361
|
+
function plotFloorRows(options) {
|
|
1362
|
+
return atHardMinimum(options) ? 2 : 3;
|
|
1363
|
+
}
|
|
1364
|
+
function requestFloor(policy) {
|
|
1365
|
+
let compact = policy.compactFloor;
|
|
1366
|
+
return compact ? { width: Math.min(compact.width, policy.minWidth), height: Math.min(compact.height, policy.minHeight) } : { width: policy.minWidth, height: policy.minHeight };
|
|
1367
|
+
}
|
|
1368
|
+
var DIAGRAM_BELOW_SHARED_MIN = !0, DIAGRAM_MIN_HEIGHT = 160;
|
|
1369
|
+
function chartSizing(type, options) {
|
|
1370
|
+
let compactKpi = type === "kpi" && options?.density === "compact", compactBullet = type === "bullet" && options?.density === "compact", cardFloor = CARD_FLOOR_TYPES.has(type);
|
|
1371
|
+
return {
|
|
1372
|
+
aspect: type === "scatter" ? "4:3" : type === "pie" ? "1:1" : CONTENT_TYPES.has(type) ? "content" : "16:9",
|
|
1373
|
+
minWidth: type === "table" ? 100 : type === "sparkline" ? 88 : compactKpi ? 280 : compactBullet ? 120 : type === "kpi" || type === "pie" || type === "choropleth" || cardFloor ? CARD_MIN_WIDTH : CARD_CLASS_WIDTH,
|
|
1374
|
+
minHeight: type === "scatter" ? 360 : type === "pie" ? 320 : type === "table" ? 80 : type === "sparkline" ? 24 : ROW_TYPES.has(type) || type === "kpi" ? 28 : type === "diagram" && DIAGRAM_BELOW_SHARED_MIN ? DIAGRAM_MIN_HEIGHT : 270,
|
|
1375
|
+
fit: CONTENT_TYPES.has(type) ? "content" : "fill",
|
|
1376
|
+
// A compact-density bullet is already its smallest form at 120 px: the row compact floor would raise it.
|
|
1377
|
+
...Object.hasOwn(COMPACT_FLOORS, type) && !compactBullet ? { compactFloor: COMPACT_FLOORS[type] } : {}
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function contentSized(type, options, fit = chartSizing(type).fit) {
|
|
1381
|
+
return (heightOmitted(options?.size) || type === "grid") && panelTypeClass(options) === void 0 && fit === "content";
|
|
1382
|
+
}
|
|
1383
|
+
function widthOnly(size) {
|
|
1384
|
+
return typeof size == "object" && size !== null && size.height === void 0;
|
|
1385
|
+
}
|
|
1386
|
+
function heightOmitted(size) {
|
|
1387
|
+
return size === void 0 || widthOnly(size);
|
|
1388
|
+
}
|
|
1389
|
+
function capPitch(room, count, cap) {
|
|
1390
|
+
return Math.min(cap, room / Math.max(1, count));
|
|
1391
|
+
}
|
|
1392
|
+
function aspectHeight(policy, size) {
|
|
1393
|
+
let [w, h] = policy.aspect.split(":");
|
|
1394
|
+
return policy.fit === "fill" && h ? Math.round(size.width * +h / +w) : size.height;
|
|
1395
|
+
}
|
|
1396
|
+
var TALL_ASPECT_CAP_WIDTH = 720;
|
|
1397
|
+
function hostlessHeight(policy, width, fallbackHeight, card = !1) {
|
|
1398
|
+
let full = aspectHeight(policy, { width, height: fallbackHeight }), aspect = card && policy.fit === "fill" && policy.aspect !== "16:9" && width < WIDE_CANVAS_MIN_WIDTH ? Math.min(full, aspectHeight(policy, { width: TALL_ASPECT_CAP_WIDTH, height: fallbackHeight })) : full, floor = card && policy.fit === "fill" ? policy.minHeight : requestFloor(policy).height;
|
|
1399
|
+
return card && policy.fit === "fill" && policy.aspect === "16:9" && width < WIDE_CANVAS_MIN_WIDTH ? floor : card && policy.fit === "fill" && floor > aspect && width < WIDE_CANVAS_MIN_WIDTH ? Math.ceil(floor) : policy.fit === "fill" && floor > aspect ? ladderHeights(width).find((step) => step.height >= floor)?.height ?? floor : Math.max(floor, aspect);
|
|
1400
|
+
}
|
|
1401
|
+
var PLOT_FLOOR_PX = { report: 160, print: 160, slide: 160, dashboard: 140 }, PLOT_FLOOR_SHARE = 0.5, NARROW_SHARE_WIDTH = 600, NARROW_PLOT_FLOOR_SHARE = 0.4;
|
|
1402
|
+
function plotFloorShare(width, options) {
|
|
1403
|
+
options !== void 0 && (shareRead = !0);
|
|
1404
|
+
let chosen = options?.[PLOT_SHARE];
|
|
1405
|
+
return chosen !== void 0 ? chosen : width < NARROW_SHARE_WIDTH ? NARROW_PLOT_FLOOR_SHARE : PLOT_FLOOR_SHARE;
|
|
1406
|
+
}
|
|
1407
|
+
function autoPlotShare(definition, options, width) {
|
|
1408
|
+
return declaredSizing(definition, options).aspect === "16:9" && definition.type !== "waterfall" ? plotFloorShare(width, options) : PLOT_FLOOR_SHARE;
|
|
1409
|
+
}
|
|
1410
|
+
var PLOT_SHARE = /* @__PURE__ */ Symbol("boardplot.plotShare"), shareRead = !1, DIGIT_SEAT = /* @__PURE__ */ Symbol("boardplot.digitSeat");
|
|
1411
|
+
function notedForSize(label) {
|
|
1412
|
+
return label.noted === !0 || label[DIGIT_SEAT]?.noted === !0;
|
|
1413
|
+
}
|
|
1414
|
+
function hiddenForSpace(result) {
|
|
1415
|
+
return result.refused ? 1 / 0 : result.labels.filter((label) => notedForSize(label) || label.noteCounted || (label.hidden === "collision" || label.hidden === "density") && label.kind !== "tick").length;
|
|
1416
|
+
}
|
|
1417
|
+
function narrowShareApplies(definition, options) {
|
|
1418
|
+
if (!options || !widthOnly(options.size) || PLOT_SHARE in options || panelTypeClass(options) !== void 0 || definition.type === "grid" || definition.type === "waterfall" || definition.type === "treemap" || definition.type === "sankey") return !1;
|
|
1419
|
+
let declared = declaredSizing(definition, options);
|
|
1420
|
+
return declared.fit !== "content" && declared.aspect === "16:9" && plotFloorShare(resolveSize(options.size, options.target).width) < PLOT_FLOOR_SHARE;
|
|
1421
|
+
}
|
|
1422
|
+
var PLOT_FLOOR_RECT = /* @__PURE__ */ Symbol("boardplot.plotFloorRect");
|
|
1423
|
+
function plotForFloor(geometry) {
|
|
1424
|
+
return geometry[PLOT_FLOOR_RECT] ?? geometry.plot;
|
|
1425
|
+
}
|
|
1426
|
+
var CONTENT_PLOT_HEIGHT = /* @__PURE__ */ Symbol("boardplot.contentPlotHeight");
|
|
1427
|
+
function autoHeightNeed(geometry, target, plotPx, share, freed) {
|
|
1428
|
+
let part = partNeedOf(geometry.frame), need = Math.max(plotFloorHeight(geometry, target, plotPx, share, freed), part), content = geometry[CONTENT_PLOT_HEIGHT];
|
|
1429
|
+
if (content === void 0) return { need, holds: !1 };
|
|
1430
|
+
let H = geometry.size.height, chrome = H - geometry.plot.h + freed, floor = Math.ceil(Math.max(chrome + plotPx, chrome / (1 - share)) - 1e-6), contentNeed = Math.ceil(H - geometry.plot.h + content.px - 1e-6);
|
|
1431
|
+
return !content.exact && contentNeed >= floor ? { need, holds: !1 } : { need: Math.max(H, contentNeed, part), holds: H >= contentNeed && H >= part };
|
|
1432
|
+
}
|
|
1433
|
+
function plotFloorHeight(geometry, target, plotPx = PLOT_FLOOR_PX[target], share = plotFloorShare(geometry.size.width), freed = 0) {
|
|
1434
|
+
let chrome = geometry.size.height - plotForFloor(geometry).h + freed;
|
|
1435
|
+
return Math.ceil(Math.max(geometry.size.height, chrome + plotPx, chrome / (1 - share)) - 1e-6);
|
|
1436
|
+
}
|
|
1437
|
+
function plotRepairHeight(geometry, target) {
|
|
1438
|
+
let chrome = geometry.size.height - plotForFloor(geometry).h, certified = plotChromeFloor.get(geometry.frame) ?? chrome;
|
|
1439
|
+
return plotFloorHeight(
|
|
1440
|
+
geometry,
|
|
1441
|
+
target,
|
|
1442
|
+
void 0,
|
|
1443
|
+
void 0,
|
|
1444
|
+
freedChromeOf(geometry.frame) + Math.max(0, certified - chrome)
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
function autoPlotPx(target, width) {
|
|
1448
|
+
return width >= WIDE_CANVAS_MIN_WIDTH ? PLOT_FLOOR_PX[target] : Math.max(PLOT_FLOOR_PX[target], Math.round(150 + 0.115 * width));
|
|
1449
|
+
}
|
|
1450
|
+
var STACKED_COLUMN_PLOT_PX = 80, STACKED_COLUMN_WIDE_PLOT_PX = 65;
|
|
1451
|
+
function stackedColumnPlotPx(type, options, width) {
|
|
1452
|
+
let variant = options?.variant;
|
|
1453
|
+
return type !== "column" || variant !== "stacked" && variant !== "stacked100" ? 0 : variant === "stacked" && width !== void 0 && width >= NARROW_SHARE_WIDTH ? STACKED_COLUMN_WIDE_PLOT_PX : STACKED_COLUMN_PLOT_PX;
|
|
1454
|
+
}
|
|
1455
|
+
var AREA100_PLOT_PX = 40, VARIANCE_ABSOLUTE_PLOT_PX = 45, VARIANCE_RELATIVE_NARROW_PLOT_PX = -25, MEKKO_UNIT_NARROW_PLOT_PX = -40;
|
|
1456
|
+
function wholeBridgePlotPx(type, options, width) {
|
|
1457
|
+
if (type !== "waterfall" && type !== "pvm" || width === void 0 || width >= WIDE_CANVAS_MIN_WIDTH) return 0;
|
|
1458
|
+
let bridge = options;
|
|
1459
|
+
return bridge?.valueAxis?.break !== void 0 && bridge.valueAxis.break !== !1 ? 0 : type === "pvm" ? width < CARD_CLASS_WIDTH ? 20 : width < 720 ? 55 : 40 : bridge?.variant === "horizontal" ? width < CARD_CLASS_WIDTH ? 0 : width < 720 ? 15 : width < 960 ? 40 : 60 : width < 400 ? 80 : width < 720 ? 72 : Math.max(73, 100 - (width - 720) * 27 / 240);
|
|
1460
|
+
}
|
|
1461
|
+
function typePlotPx(type, options, width) {
|
|
1462
|
+
if (type === "waterfall" || type === "pvm") return wholeBridgePlotPx(type, options, width);
|
|
1463
|
+
if (type === "line" && options?.variant === "stacked100-area") return AREA100_PLOT_PX;
|
|
1464
|
+
if (type === "variance" && width !== void 0 && width >= CARD_CLASS_WIDTH && (options?.variant ?? "absolute") === "absolute")
|
|
1465
|
+
return VARIANCE_ABSOLUTE_PLOT_PX;
|
|
1466
|
+
let narrow = width !== void 0 && width < NARROW_SHARE_WIDTH;
|
|
1467
|
+
return narrow && type === "variance" && options?.variant === "relative" ? VARIANCE_RELATIVE_NARROW_PLOT_PX : narrow && type === "mekko" && options?.variant === "stacked" ? MEKKO_UNIT_NARROW_PLOT_PX : stackedColumnPlotPx(type, options, width);
|
|
1468
|
+
}
|
|
1469
|
+
function resolveSizing(policy, size, measured = {}) {
|
|
1470
|
+
policy = { ...policy, ...measured.fit ? { fit: measured.fit, aspect: measured.aspect ?? policy.aspect } : {} };
|
|
1471
|
+
let measuredMinWidth = ceilFloor(measured.measuredMinWidth ?? measured.minWidth ?? 0, size.width), measuredMinHeight = ceilFloor(measured.measuredMinHeight ?? measured.minHeight ?? 0, size.height), minWidth = ceilFloor(Math.max(policy.minWidth, measured.minWidth ?? 0), size.width), minHeight = ceilFloor(Math.max(policy.minHeight, measured.minHeight ?? 0), size.height);
|
|
1472
|
+
return {
|
|
1473
|
+
...policy,
|
|
1474
|
+
minWidth,
|
|
1475
|
+
minHeight,
|
|
1476
|
+
measuredMinWidth,
|
|
1477
|
+
measuredMinHeight,
|
|
1478
|
+
naturalWidth: ceilSizing(Math.max(minWidth, measured.naturalWidth ?? size.width)),
|
|
1479
|
+
naturalHeight: ceilSizing(Math.max(minHeight, measured.naturalHeight ?? aspectHeight(policy, size))),
|
|
1480
|
+
comfortableWidth: Math.ceil(minWidth * 1.25),
|
|
1481
|
+
comfortableHeight: Math.ceil(minHeight * 1.25),
|
|
1482
|
+
...measured.hint ? { hint: measured.hint } : {}
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
function ceilSizing(value) {
|
|
1486
|
+
let nearest = Math.round(value);
|
|
1487
|
+
return Math.abs(value - nearest) <= Number.EPSILON * Math.max(1, Math.abs(value)) * 4 ? nearest : Math.ceil(value);
|
|
1488
|
+
}
|
|
1489
|
+
function ceilFloor(value, received) {
|
|
1490
|
+
let whole = ceilSizing(value);
|
|
1491
|
+
return value <= received && whole > received + SIZE_TOLERANCE ? received : whole;
|
|
1492
|
+
}
|
|
1493
|
+
function rowSizing(type, size, input) {
|
|
1494
|
+
return resolveSizing({ ...chartSizing(type), minWidth: 0 }, size, {
|
|
1495
|
+
minWidth: input.minWidth,
|
|
1496
|
+
minHeight: input.chromeH + input.minimumRowsH,
|
|
1497
|
+
naturalWidth: input.naturalWidth,
|
|
1498
|
+
naturalHeight: input.chromeH + Math.max(input.minimumRowsH, input.naturalRowsH),
|
|
1499
|
+
...input.hint ? { hint: input.hint } : {}
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
function contentSizing(type, size, plot, rects, square = !1) {
|
|
1503
|
+
let bounds = boundsOf(rects), width = size.width - plot.w + bounds.w, height = size.height - plot.h + bounds.h;
|
|
1504
|
+
return resolveSizing({ ...chartSizing(type), minWidth: 0 }, size, {
|
|
1505
|
+
naturalWidth: square ? Math.max(width, height) : width,
|
|
1506
|
+
naturalHeight: square ? Math.max(width, height) : height
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
var NATURAL_BAND_STEP = 72;
|
|
1510
|
+
function bandSizing(type, size, plotW, step, minPlotW) {
|
|
1511
|
+
let naturalPlotW = step > 0 ? plotW * NATURAL_BAND_STEP / step : plotW;
|
|
1512
|
+
return resolveSizing({ ...chartSizing(type), minWidth: 0, minHeight: 0 }, size, {
|
|
1513
|
+
naturalWidth: size.width - plotW + naturalPlotW,
|
|
1514
|
+
...minPlotW !== void 0 ? { minWidth: size.width - plotW + minPlotW } : {}
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
function matrixWidths(chromeW, columns, gap, headers, cell = 0) {
|
|
1518
|
+
return {
|
|
1519
|
+
minWidth: chromeW + columns + (columns - 1) * gap + (headers[0] ?? 0) + (headers.at(-1) ?? 0),
|
|
1520
|
+
naturalWidth: chromeW + columns * Math.max(28, cell, maxOf(headers)) + (columns - 1) * gap
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
function requiredSize(size, sizing) {
|
|
1524
|
+
return { width: Math.max(size.width, sizing.minWidth), height: Math.max(size.height, sizing.minHeight) };
|
|
1525
|
+
}
|
|
1526
|
+
function fitsSize(size, sizing) {
|
|
1527
|
+
return size.width + SIZE_TOLERANCE >= sizing.minWidth && size.height + SIZE_TOLERANCE >= sizing.minHeight;
|
|
1528
|
+
}
|
|
1529
|
+
function sizeRefusal(type, title, size, sizing) {
|
|
1530
|
+
let fix = requiredSize(size, sizing);
|
|
1531
|
+
fix.width = size.width >= sizing.minWidth ? size.width : ceilSizing(fix.width), fix.height = size.height >= sizing.minHeight ? size.height : ceilSizing(fix.height);
|
|
1532
|
+
let px = (value) => Number.isInteger(value) ? value : Math.ceil(value * 100 - 1e-6) / 100, text = `${px(fix.width)} \xD7 ${px(fix.height)}px`;
|
|
1533
|
+
return {
|
|
1534
|
+
refused: !0,
|
|
1535
|
+
type,
|
|
1536
|
+
title,
|
|
1537
|
+
size,
|
|
1538
|
+
sizing,
|
|
1539
|
+
warnings: [{
|
|
1540
|
+
code: "size-below-floor",
|
|
1541
|
+
severity: "error",
|
|
1542
|
+
message: `${title} needs at least ${text}; received ${+size.width.toFixed(2)} \xD7 ${+size.height.toFixed(2)}px`,
|
|
1543
|
+
suggest: `Render it at ${text} or larger.${sizing.hint ? ` ${sizing.hint}` : ""}`,
|
|
1544
|
+
field: ["options", "size"],
|
|
1545
|
+
expected: { minimum: fix, inclusive: !0 },
|
|
1546
|
+
fix: [{
|
|
1547
|
+
op: "replace",
|
|
1548
|
+
path: "/options/size",
|
|
1549
|
+
value: fix
|
|
1550
|
+
}]
|
|
1551
|
+
}]
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
function verifiedSizeRepair(initial, accepts) {
|
|
1555
|
+
let limit = { width: Math.ceil(initial.width * 4), height: Math.ceil(Math.max(initial.height * 4, initial.height + 4096)) };
|
|
1556
|
+
for (let width = initial.width; width <= limit.width; width *= 2) {
|
|
1557
|
+
let low = initial.height, height = initial.height;
|
|
1558
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
1559
|
+
if (accepts({ width, height })) {
|
|
1560
|
+
for (; height - low > 1; ) {
|
|
1561
|
+
let mid = Math.floor((low + height) / 2);
|
|
1562
|
+
accepts({ width, height: mid }) ? height = mid : low = mid;
|
|
1563
|
+
}
|
|
1564
|
+
return { size: { width, height }, limit };
|
|
1565
|
+
}
|
|
1566
|
+
if (height === limit.height) break;
|
|
1567
|
+
low = height, height = Math.min(limit.height, Math.ceil(height * 2));
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
return { limit };
|
|
1571
|
+
}
|
|
1572
|
+
function requireGeometry(result) {
|
|
1573
|
+
if (result.refused) {
|
|
1574
|
+
let refusal = result.warnings[0];
|
|
1575
|
+
throw Object.assign(new NormalizeError(
|
|
1576
|
+
refusal.code,
|
|
1577
|
+
refusal.field?.join(".") ?? "",
|
|
1578
|
+
refusal.message,
|
|
1579
|
+
refusal.suggest,
|
|
1580
|
+
refusal.fix
|
|
1581
|
+
), { expected: refusal.expected });
|
|
1582
|
+
}
|
|
1583
|
+
return result;
|
|
1584
|
+
}
|
|
1585
|
+
function declaredSizing(definition, options) {
|
|
1586
|
+
let own = definition.sizing ?? chartSizing(definition.type);
|
|
1587
|
+
definition.type === "bullet" && options?.density === "compact" && (own = { ...own, compactFloor: void 0 });
|
|
1588
|
+
let minWidth = chartSizing(definition.type, options).minWidth;
|
|
1589
|
+
return minWidth === chartSizing(definition.type).minWidth ? own : { ...own, minWidth };
|
|
1590
|
+
}
|
|
1591
|
+
function slopeContentHeight(geometry, plotAt720) {
|
|
1592
|
+
let { plot, size, labels } = geometry, stacks = [0, 0];
|
|
1593
|
+
for (let label of labels)
|
|
1594
|
+
label.kind !== "series" || label.hidden === "redundant" || (stacks[label.rect.x + label.rect.w / 2 < plot.x + plot.w / 2 ? 0 : 1] += Math.max(label.rect.h, 13));
|
|
1595
|
+
return Math.ceil(size.height - plot.h + Math.max(...stacks, plotAt720) - 1e-6);
|
|
1596
|
+
}
|
|
1597
|
+
function fitLayout(definition, data, options) {
|
|
1598
|
+
let run = prepareFitLayout(definition, data);
|
|
1599
|
+
try {
|
|
1600
|
+
return run(options);
|
|
1601
|
+
} finally {
|
|
1602
|
+
run.finish();
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
var mekkoHeightFloors = /* @__PURE__ */ new WeakMap();
|
|
1606
|
+
function prepareFitLayout(definition, data, origins = /* @__PURE__ */ new WeakMap()) {
|
|
1607
|
+
let probes = /* @__PURE__ */ new Map(), heightFloors = definition.type === "mekko" ? mekkoHeightFloors.get(origins) ?? /* @__PURE__ */ new Map() : void 0;
|
|
1608
|
+
heightFloors && mekkoHeightFloors.set(origins, heightFloors);
|
|
1609
|
+
let at = (runOptions, compact) => {
|
|
1610
|
+
let size = runOptions?.size, targetSize = runOptions?.[TARGET_SIZE], fixed = targetSize?.fixed, key = `${typeof size == "object" ? `${size?.width}x${size?.height}:${size?.unit}` : String(size)}:${compact}:${forcedCompact(runOptions)}:${String(runOptions?.mode)}:${runOptions?.belowMinimum}:${fixed?.width}:${fixed?.height}:${targetSize?.sizePx.width}:${targetSize?.sizePx.height}:${isWidthProbe(definition.type, runOptions)}:${runOptions?.[ACCEPTANCE_PROBE]}`, result = probes.get(key);
|
|
1611
|
+
if (result === void 0) {
|
|
1612
|
+
let fixedMekko = definition.type === "mekko" && (runOptions?.variant ?? "stacked100") === "stacked100", requested = fixedMekko ? resolveSize(size, runOptions?.target) : void 0, floorKey = fixedMekko ? JSON.stringify([
|
|
1613
|
+
requested.width,
|
|
1614
|
+
compact,
|
|
1615
|
+
forcedCompact(runOptions),
|
|
1616
|
+
runOptions?.mode,
|
|
1617
|
+
runOptions?.belowMinimum,
|
|
1618
|
+
runOptions?.legend,
|
|
1619
|
+
frameTextOptions(runOptions ?? {})
|
|
1620
|
+
]) : "", floor2 = fixedMekko ? heightFloors?.get(floorKey) : void 0;
|
|
1621
|
+
if (floor2 && runOptions?.[FIXED_SIZE_PROBE] && requested.height + SIZE_TOLERANCE < floor2.minHeight)
|
|
1622
|
+
return sizeRefusal(definition.type, definition.title, requested, { ...floor2 });
|
|
1623
|
+
result = fitSizeMemo(definition, data, runOptions, compact), fixedMekko && result.sizing && (result.refused ? plotChromeFloor.has(result) : plotChromeFloor.has(result.frame)) && heightFloors.set(floorKey, result.sizing), probes.set(key, result);
|
|
1624
|
+
}
|
|
1625
|
+
let copy = { ...result, ...result.sizing ? { sizing: { ...result.sizing } } : {} }, floor = plotChromeFloor.get(result);
|
|
1626
|
+
return floor !== void 0 && plotChromeFloor.set(copy, floor), origins.set(copy, result), copy;
|
|
1627
|
+
}, run = ((options) => withLayoutMemo(() => {
|
|
1628
|
+
let inherited = options?.[CARD_HEIGHT_MEMO], borrowed = inherited?.active && inherited.type === definition.type, memo = borrowed ? inherited : { type: definition.type, active: !0, heights: /* @__PURE__ */ new Map() };
|
|
1629
|
+
options = { ...options, [CARD_HEIGHT_MEMO]: memo };
|
|
1630
|
+
try {
|
|
1631
|
+
if (definition.type !== "grid" && widthOnly(options.size) && declaredSizing(definition, options).fit === "fill" && panelTypeClass(options) === void 0) {
|
|
1632
|
+
let width = resolveSize(options.size, options.target).width;
|
|
1633
|
+
width < CARD_CLASS_WIDTH && cardClassHeight(definition, data, options, width);
|
|
1634
|
+
}
|
|
1635
|
+
let fitted = fitOrRepair(definition, data, options, at), copy = copyLayout(fitted);
|
|
1636
|
+
return origins.set(copy, origins.get(fitted) ?? fitted), withPlotFloorWarning(copy, options, definition.title);
|
|
1637
|
+
} finally {
|
|
1638
|
+
borrowed || (memo.active = !1, memo.heights.clear(), memo.references = void 0);
|
|
1639
|
+
}
|
|
1640
|
+
}));
|
|
1641
|
+
return run.finish = () => {
|
|
1642
|
+
probes.clear(), heightFloors?.clear();
|
|
1643
|
+
}, run;
|
|
1644
|
+
}
|
|
1645
|
+
function copyLayout(result) {
|
|
1646
|
+
return result.refused ? { ...result, sizing: { ...result.sizing }, warnings: [...result.warnings] } : {
|
|
1647
|
+
...result,
|
|
1648
|
+
sizing: result.sizing ? { ...result.sizing } : void 0,
|
|
1649
|
+
warnings: [...result.warnings],
|
|
1650
|
+
frame: copyFrame(result.frame),
|
|
1651
|
+
a11y: { ...result.a11y, desc: singleStops(result.a11y.desc) },
|
|
1652
|
+
labels: result.labels.map((label) => ({ ...label })),
|
|
1653
|
+
scene: result.scene.map((node) => ({ ...node }))
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
function fitOrRepair(definition, data, options, atSize) {
|
|
1657
|
+
let first = fitAt(definition, data, options, atSize);
|
|
1658
|
+
if (!first.refused) {
|
|
1659
|
+
let grown = grownForNotes(definition, data, options, first, forcedCompact(options), atSize);
|
|
1660
|
+
return grownForFurniture(definition, data, options, grown, forcedCompact(options), atSize);
|
|
1661
|
+
}
|
|
1662
|
+
if (definition.type === "grid" && first.warnings[0]?.code !== "size-below-floor") return first;
|
|
1663
|
+
let received = first.size, constraints = options?.[TARGET_SIZE] ?? resolveTargetSize(options?.target ?? DEFAULT_TARGET, options?.size);
|
|
1664
|
+
if (isWidthProbe(definition.type, options) && constraints.fixed.width && !constraints.fixed.height && first.warnings[0]?.code === "size-below-floor" && received.width < first.sizing.minWidth) return first;
|
|
1665
|
+
let compact = options?.mode === "compact" || belowMinimum(declaredSizing(definition, options), first.size, options, definition.type) || forcedCompact(options), fixedFallback = options && (compact || definition.type === "treemap" || definition.type === "sankey") && options.belowMinimum !== "refuse" && options.mode !== "full" && panelTypeClass(options) === void 0 && constraints.fixed.width && constraints.fixed.height, warnHardMinimum = (fitted) => {
|
|
1666
|
+
let target = options?.target ?? DEFAULT_TARGET, height = Math.max(requiredSize(received, first.sizing).height, plotFloorHeight(fitted, target));
|
|
1667
|
+
return fitted.warnings.some((warning) => warning.code === "plot-under-floor") || fitted.warnings.push({
|
|
1668
|
+
code: "plot-under-floor",
|
|
1669
|
+
severity: "warn",
|
|
1670
|
+
message: `the fixed height draws the plot under its floor, at the type's hard minimum; the chart needs ${height} px`,
|
|
1671
|
+
suggest: `Give the chart an estimated ${height} px of height, or leave the height out so the chart takes it. Use measure() for the exact verified size.`,
|
|
1672
|
+
field: ["options", "size"],
|
|
1673
|
+
fix: [{ op: "replace", path: "/options/size", value: { width: received.width, height } }]
|
|
1674
|
+
}), fitted;
|
|
1675
|
+
};
|
|
1676
|
+
if (fixedFallback) {
|
|
1677
|
+
let fitted = fitAt(definition, data, { ...options, [HARD_MINIMUM]: !0 });
|
|
1678
|
+
if (!fitted.refused && namesDrawnSeries(data, fitted)) return warnHardMinimum(fitted);
|
|
1679
|
+
}
|
|
1680
|
+
let sourceStep = !!(!staticFrame.pinned && compact && options?.source && constraints.fixed.width && constraints.fixed.height);
|
|
1681
|
+
if (sourceStep && options)
|
|
1682
|
+
for (let lines of [1, 0]) {
|
|
1683
|
+
let fitted = fitAt(definition, data, { ...options, [COMPACT_SOURCE_LINES]: lines });
|
|
1684
|
+
if (!fitted.refused) return fitted;
|
|
1685
|
+
}
|
|
1686
|
+
if (fixedFallback) {
|
|
1687
|
+
let authored = options, subtitle = resolveSubtitle(authored.subtitle), line = subtitle && authored.footnotes !== !1 && !authored.unit?.trim() ? subtitleLine(subtitle) : void 0, footer = sourceStep ? { ...options, [COMPACT_SOURCE_LINES]: 0 } : options, moved = line === void 0 ? footer : { ...footer, subtitle: void 0, footnotes: [...authored.footnotes || [], line], [MOVED_SUBTITLE]: line };
|
|
1688
|
+
for (let hard of [!1, !0]) {
|
|
1689
|
+
if (!hard && line === void 0) continue;
|
|
1690
|
+
let fitted = fitAt(definition, data, hard ? { ...moved, [HARD_MINIMUM]: !0 } : moved);
|
|
1691
|
+
if (!fitted.refused && !(hard && !namesDrawnSeries(data, fitted)))
|
|
1692
|
+
return line !== void 0 && fitted.warnings.push({
|
|
1693
|
+
code: "subtitle-moved-to-notes",
|
|
1694
|
+
severity: "warn",
|
|
1695
|
+
message: `the fixed height has no room for the subtitle, so it moved into the notes list: ${line}`,
|
|
1696
|
+
suggest: `Give the chart ${requiredSize(received, first.sizing).height} px of height to keep the subtitle on the canvas.`,
|
|
1697
|
+
field: ["options", "size"]
|
|
1698
|
+
}), hard ? warnHardMinimum(fitted) : fitted;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
let automatic = !constraints.fixed.height;
|
|
1702
|
+
if ((!automatic || REPAIR_PROBE_TYPES.has(definition.type)) && options?.[FIXED_SIZE_PROBE]) return first;
|
|
1703
|
+
let holdsCompact = automatic ? forcedCompact(options) : forcedCompact(options) || compact && options?.mode !== "compact" && compactFallbackApplies(definition, options, data), declared = declaredSizing(definition, options), keepCompact = (size) => holdsCompact && (automatic || fitsSize(size, declared)), at = (floor2) => {
|
|
1704
|
+
let size = requiredSize(received, floor2);
|
|
1705
|
+
return automatic && (size.height = hostlessHeight(
|
|
1706
|
+
{ ...floor2, compactFloor: void 0 },
|
|
1707
|
+
size.width,
|
|
1708
|
+
size.height,
|
|
1709
|
+
panelTypeClass(options) === void 0
|
|
1710
|
+
)), fitOnce(definition, data, { ...options, size }, keepCompact(size), atSize);
|
|
1711
|
+
}, floor = first.sizing, next = first;
|
|
1712
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
1713
|
+
if (next = at(floor), !isRefused(next)) {
|
|
1714
|
+
if (REPAIR_PROBE_TYPES.has(definition.type) && (floor = resolveSizing(floor, received, {
|
|
1715
|
+
...floor,
|
|
1716
|
+
minWidth: Math.max(floor.minWidth, next.sizing.minWidth),
|
|
1717
|
+
minHeight: Math.max(floor.minHeight, next.sizing.minHeight)
|
|
1718
|
+
})), next.sizing.fit !== floor.fit && (floor = {
|
|
1719
|
+
...floor,
|
|
1720
|
+
fit: next.sizing.fit,
|
|
1721
|
+
aspect: next.sizing.aspect,
|
|
1722
|
+
naturalHeight: next.sizing.naturalHeight
|
|
1723
|
+
}), next.sizing.minHeight < floor.minHeight) {
|
|
1724
|
+
let smaller = { ...floor, minHeight: next.sizing.minHeight }, lower = at(smaller);
|
|
1725
|
+
isRefused(lower) || (floor = smaller, next = lower);
|
|
1726
|
+
}
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
let raised = resolveSizing(floor, received, next.sizing);
|
|
1730
|
+
if (raised.minWidth === floor.minWidth && raised.minHeight === floor.minHeight) break;
|
|
1731
|
+
floor = raised;
|
|
1732
|
+
}
|
|
1733
|
+
if (!constraints.fixed.width || automatic && floor.minWidth <= received.width) {
|
|
1734
|
+
if (!isRefused(next) && automatic && next.sizing?.fit === "content" && next.sizing.naturalHeight !== next.size.height) {
|
|
1735
|
+
let natural = fitOnce(definition, data, { ...options, size: { width: next.size.width } }, holdsCompact && automatic, atSize);
|
|
1736
|
+
if (!isRefused(natural)) return natural;
|
|
1737
|
+
}
|
|
1738
|
+
if (!isRefused(next)) return next;
|
|
1739
|
+
}
|
|
1740
|
+
if (REPAIR_PROBE_TYPES.has(definition.type) && floor.minWidth > received.width)
|
|
1741
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
1742
|
+
let pinned = getChart(definition.type)?.layout(data, {
|
|
1743
|
+
...withoutForcedCompact(options),
|
|
1744
|
+
size: requiredSize(received, floor),
|
|
1745
|
+
[FIXED_SIZE_PROBE]: !0
|
|
1746
|
+
});
|
|
1747
|
+
if (!pinned || !isRefused(pinned) || !pinned.sizing) break;
|
|
1748
|
+
let raised = resolveSizing(floor, received, pinned.sizing);
|
|
1749
|
+
if (raised.minWidth === floor.minWidth && raised.minHeight === floor.minHeight) break;
|
|
1750
|
+
floor = raised;
|
|
1751
|
+
}
|
|
1752
|
+
if (definition.type !== "table") return sizeRefusal(definition.type, definition.title, received, floor);
|
|
1753
|
+
let { hint: _repairHint, ...repairFloor } = floor;
|
|
1754
|
+
return sizeRefusal(definition.type, definition.title, received, {
|
|
1755
|
+
...repairFloor,
|
|
1756
|
+
...first.sizing?.hint ? { hint: first.sizing.hint } : {}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
function withPlotFloorWarning(result, options, title) {
|
|
1760
|
+
let target = options?.target ?? DEFAULT_TARGET;
|
|
1761
|
+
if (isRefused(result))
|
|
1762
|
+
return result.warnings = result.warnings.filter((warning) => warning.code !== "plot-under-floor"), result;
|
|
1763
|
+
if (result.refused || heightOmitted(options?.size) || panelTypeClass(options) !== void 0 || result.sizing?.fit !== "fill") return result;
|
|
1764
|
+
let plot = plotForFloor(result);
|
|
1765
|
+
if (plot.h + SIZE_TOLERANCE >= PLOT_FLOOR_PX[target] || result.warnings.some((warning) => warning.code === "plot-under-floor")) return result;
|
|
1766
|
+
let height = plotFloorHeight(result, target);
|
|
1767
|
+
return result.sizing && rankKeyShown(options) && result.frame.noteList?.some((note) => note.kind === "disclosure" && note.inFrame) ? sizeRefusal(result.type, title, result.size, { ...result.sizing, minHeight: height, measuredMinHeight: Math.min(result.sizing.measuredMinHeight, height) }) : (result.warnings.push({
|
|
1768
|
+
code: "plot-under-floor",
|
|
1769
|
+
severity: "warn",
|
|
1770
|
+
message: `the fixed height leaves the plot ${Math.round(plot.h)} px, under its ${PLOT_FLOOR_PX[target]} px floor on the ${target} target; the chart needs ${height} px`,
|
|
1771
|
+
suggest: `Give the chart ${height} px of height, or leave the height out so the chart takes it.`,
|
|
1772
|
+
field: ["options", "size"],
|
|
1773
|
+
fix: [{ op: "replace", path: "/options/size", value: { width: result.size.width, height } }]
|
|
1774
|
+
}), result);
|
|
1775
|
+
}
|
|
1776
|
+
var NOTE_GROWTH_SHARE = 0.25;
|
|
1777
|
+
function grownForNotes(definition, data, options, first, compact = !1, atSize) {
|
|
1778
|
+
let constraints = options?.[TARGET_SIZE] ?? resolveTargetSize(options?.target ?? DEFAULT_TARGET, options?.size), owes = (layout) => !layout.refused && layout.labels.some(notedForSize);
|
|
1779
|
+
if (constraints.fixed.height || panelTypeClass(options) !== void 0 || !owes(first)) return first;
|
|
1780
|
+
let width = first.size.width, at = (height) => {
|
|
1781
|
+
let layout = fitOnce(definition, data, { ...options, size: { width, height } }, compact, atSize);
|
|
1782
|
+
return !layout.refused && layout.sizing && widthOnly(options?.size) && (layout.sizing = { ...layout.sizing, naturalHeight: Math.max(layout.sizing.naturalHeight, layout.size.height) }), layout;
|
|
1783
|
+
}, target = options.target, share = autoPlotShare(definition, options, width), fill = declaredSizing(definition, options).fit !== "content" && definition.type !== "grid", short = (layout) => fill && !layout.refused && plotFloorHeight(layout, target, PLOT_FLOOR_PX[target], share, freedChromeOf(layout.frame)) > layout.size.height + SIZE_TOLERANCE, ladder = ladderHeights(width).map((step) => step.height).filter((height) => height > first.size.height * (1 + LADDER_TOLERANCE)), steps = width >= WIDE_CANVAS_MIN_WIDTH || ladder.length > 0 ? ladder : [Math.ceil(first.size.height * (1 + NOTE_GROWTH_SHARE))], below = first.size.height, top;
|
|
1784
|
+
for (let height of steps) {
|
|
1785
|
+
let next = at(height);
|
|
1786
|
+
if (next.refused || (top = next), next.refused || owes(next) || short(next)) {
|
|
1787
|
+
below = height;
|
|
1788
|
+
continue;
|
|
1789
|
+
}
|
|
1790
|
+
if (width >= WIDE_CANVAS_MIN_WIDTH) return next;
|
|
1791
|
+
let best2 = next, low2 = below, high2 = height;
|
|
1792
|
+
for (; high2 - low2 > 1; ) {
|
|
1793
|
+
let mid = Math.floor((low2 + high2) / 2), probe = at(mid);
|
|
1794
|
+
probe.refused || owes(probe) || short(probe) ? low2 = mid : (best2 = probe, high2 = mid);
|
|
1795
|
+
}
|
|
1796
|
+
return best2;
|
|
1797
|
+
}
|
|
1798
|
+
let noted = (layout) => layout.refused ? 1 / 0 : layout.labels.filter(notedForSize).length;
|
|
1799
|
+
if (width >= WIDE_CANVAS_MIN_WIDTH || top === void 0 || noted(top) >= noted(first) || short(top)) return first;
|
|
1800
|
+
let goal = noted(top), best = top, low = first.size.height, high = top.size.height;
|
|
1801
|
+
for (; high - low > 1; ) {
|
|
1802
|
+
let mid = Math.floor((low + high) / 2), probe = at(mid);
|
|
1803
|
+
noted(probe) > goal || short(probe) ? low = mid : (best = probe, high = mid);
|
|
1804
|
+
}
|
|
1805
|
+
return best;
|
|
1806
|
+
}
|
|
1807
|
+
function furnitureShare(geo) {
|
|
1808
|
+
let tickBand = geo.derived?.tickBand;
|
|
1809
|
+
return (geo.size.height - (geo.frame.plotRect ?? geo.plot).h + (tickBand?.reserved ?? 0)) / geo.size.height;
|
|
1810
|
+
}
|
|
1811
|
+
var FURNITURE_EPS = 2e-3;
|
|
1812
|
+
function grownForFurniture(definition, data, options, first, compact = !1, atSize) {
|
|
1813
|
+
let constraints = options?.[TARGET_SIZE] ?? resolveTargetSize(options?.target ?? DEFAULT_TARGET, options?.size);
|
|
1814
|
+
if (first.refused || constraints.fixed.height || panelTypeClass(options) !== void 0 || definition.type === "grid" || contentSized(definition.type, options, declaredSizing(definition, options).fit)) return first;
|
|
1815
|
+
let cls = aspectClassFor(definition.type, options, first.marks);
|
|
1816
|
+
if (!cls || !furnitureScoped(cls, first.size)) return first;
|
|
1817
|
+
let width = first.size.width, budget = furnitureBudget(width), noted = first.labels.some(notedForSize), over = (layout) => layout.refused || !noted && layout.labels.some(notedForSize) || furnitureShare(layout) > budget + FURNITURE_EPS;
|
|
1818
|
+
if (!over(first)) return first;
|
|
1819
|
+
let at = (height2) => {
|
|
1820
|
+
let layout = fitOnce(definition, data, { ...options, size: { width, height: height2 } }, compact, atSize);
|
|
1821
|
+
return !layout.refused && layout.sizing && widthOnly(options?.size) && (layout.sizing = { ...layout.sizing, naturalHeight: Math.max(layout.sizing.naturalHeight, layout.size.height) }), layout;
|
|
1822
|
+
}, steps = ladderHeights(width).map((step) => step.height).filter((height2) => height2 > first.size.height).sort((a, b) => a - b), top = steps.at(-1);
|
|
1823
|
+
if (top === void 0 || Math.ceil(furnitureShare(first) * first.size.height / budget) > top) return first;
|
|
1824
|
+
if (width >= WIDE_CANVAS_MIN_WIDTH) {
|
|
1825
|
+
for (let height2 of steps) {
|
|
1826
|
+
let next = at(height2);
|
|
1827
|
+
if (!over(next)) return next;
|
|
1828
|
+
}
|
|
1829
|
+
return first;
|
|
1830
|
+
}
|
|
1831
|
+
let height = first.size.height, furniture = furnitureShare(first) * height;
|
|
1832
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
1833
|
+
height = Math.min(top, Math.max(height + 1, Math.ceil(furniture / budget)));
|
|
1834
|
+
let layout = at(height);
|
|
1835
|
+
if (!over(layout)) return layout;
|
|
1836
|
+
if (layout.refused || height === top) return first;
|
|
1837
|
+
furniture = furnitureShare(layout) * height;
|
|
1838
|
+
}
|
|
1839
|
+
return first;
|
|
1840
|
+
}
|
|
1841
|
+
var HARD_MINIMUM = /* @__PURE__ */ Symbol("boardplot.hardMinimum"), LAYOUT_CALL = /* @__PURE__ */ Symbol("boardplot.layoutCall"), FULL_LAYOUT_PROBE = /* @__PURE__ */ Symbol("boardplot.fullLayoutProbe"), VERIFY_ADVICE = /* @__PURE__ */ Symbol("boardplot.verifyAdvice"), FORCE_COMPACT = /* @__PURE__ */ Symbol("boardplot.forceCompact"), WIDTH_PROBE = /* @__PURE__ */ Symbol("boardplot.widthProbe"), FIXED_SIZE_PROBE = /* @__PURE__ */ Symbol("boardplot.fixedSizeProbe"), ACCEPTANCE_PROBE = /* @__PURE__ */ Symbol("boardplot.acceptanceProbe");
|
|
1842
|
+
function isWidthProbe(type, options) {
|
|
1843
|
+
return options?.[WIDTH_PROBE] === type && options?.belowMinimum === "refuse" && panelTypeClass(options) === void 0;
|
|
1844
|
+
}
|
|
1845
|
+
function forcedCompact(options) {
|
|
1846
|
+
return options?.[FORCE_COMPACT] === !0;
|
|
1847
|
+
}
|
|
1848
|
+
function withoutForcedCompact(options) {
|
|
1849
|
+
if (options === null || typeof options != "object" || !(FORCE_COMPACT in options)) return options;
|
|
1850
|
+
let { [FORCE_COMPACT]: _forced, ...rest } = options;
|
|
1851
|
+
return rest;
|
|
1852
|
+
}
|
|
1853
|
+
function fitAt(definition, data, options, atSize) {
|
|
1854
|
+
let result = fitOnce(definition, data, options, forcedCompact(options), atSize);
|
|
1855
|
+
return widthOnly(options?.size) && !result.refused && result.sizing && (result.sizing.naturalHeight = Math.max(result.sizing.naturalHeight, result.size.height)), result;
|
|
1856
|
+
}
|
|
1857
|
+
function compactFallbackApplies(definition, options, data) {
|
|
1858
|
+
return declaredSizing(definition, options).compactFloor !== void 0 && options?.belowMinimum !== "refuse" && options?.size !== void 0 && panelTypeClass(options) === void 0 && definition.type !== "mekko" && options?.mode !== "full" && (data === void 0 || definition.compactForm?.(data, options) !== !1);
|
|
1859
|
+
}
|
|
1860
|
+
function compactReplacesRefusal(definition, options, data) {
|
|
1861
|
+
if (!FALLBACK_COMPACT.has(definition.type) || forcedCompact(options) || !compactFallbackApplies(definition, options, data)) return !1;
|
|
1862
|
+
let requested = options?.[TARGET_SIZE] ?? resolveTargetSize(options?.target ?? DEFAULT_TARGET, options?.size);
|
|
1863
|
+
return !(requested.fixed.height && !fitsSize(requested.sizePx, declaredSizing(definition, options)));
|
|
1864
|
+
}
|
|
1865
|
+
var CARD_HEIGHT_MEMO = /* @__PURE__ */ Symbol("boardplot.cardHeightMemo");
|
|
1866
|
+
function cardReferenceHeight(data, options, wider, draw, capture) {
|
|
1867
|
+
let memo = options[CARD_HEIGHT_MEMO];
|
|
1868
|
+
if (!memo?.active) {
|
|
1869
|
+
let result2 = draw(wider);
|
|
1870
|
+
return result2.refused ? void 0 : result2.size.height;
|
|
1871
|
+
}
|
|
1872
|
+
let same = (a, b) => a === b || Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => item === b[i]), entries = memo.references ??= [], match = entries.find((entry) => entry.data === data && resolveSize(entry.options.size, entry.options.target).width === resolveSize(wider.size, wider.target).width && [.../* @__PURE__ */ new Set([...Object.keys(entry.options), ...Object.keys(wider)])].every((key) => key === "size" || same(entry.options[key], wider[key])));
|
|
1873
|
+
if (match)
|
|
1874
|
+
return match.restore?.(), match.height;
|
|
1875
|
+
let result = draw({ ...wider, [CARD_HEIGHT_MEMO]: memo }), height = result.refused ? void 0 : result.size.height;
|
|
1876
|
+
return entries.push({ data, options: wider, height, restore: capture?.() }), height;
|
|
1877
|
+
}
|
|
1878
|
+
function cardClassHeight(definition, data, options, width, cachedOnly = !1) {
|
|
1879
|
+
let own = options, raw = Object.fromEntries(Object.entries(own).filter(([key2]) => key2 !== "authoredFootnotes" && key2 !== "footnotesOff"));
|
|
1880
|
+
raw.footnotes = own.footnotesOff ? !1 : own.authoredFootnotes ?? own.footnotes, raw.size = { width: CARD_STEPS.find((step) => step > width) }, AUTO_LEGEND in own && delete raw.mode, (AUTO_LEGEND in own || "legend" in raw && raw.legend === void 0) && (raw.legend = "auto");
|
|
1881
|
+
let scope = options[CARD_HEIGHT_MEMO], memo = scope?.active && scope.type === definition.type ? scope : void 0, key = JSON.stringify([raw.size.width, raw.mode, raw.legend, raw.belowMinimum]);
|
|
1882
|
+
if (cachedOnly) return memo?.heights.get(key);
|
|
1883
|
+
if (memo?.heights.has(key)) return memo.heights.get(key);
|
|
1884
|
+
let layout = getChart(definition.type)?.layout ?? ((d, o) => fitLayout(definition, d, o));
|
|
1885
|
+
memo && (raw[CARD_HEIGHT_MEMO] = memo);
|
|
1886
|
+
let height;
|
|
1887
|
+
try {
|
|
1888
|
+
let wider = layout(data, raw);
|
|
1889
|
+
height = isRefused(wider) ? void 0 : wider.size.height;
|
|
1890
|
+
} catch (error) {
|
|
1891
|
+
if (!(error instanceof NormalizeError)) throw error;
|
|
1892
|
+
}
|
|
1893
|
+
return memo?.heights.set(key, height), height;
|
|
1894
|
+
}
|
|
1895
|
+
function fitOnce(definition, data, options, compactFallback, atSize) {
|
|
1896
|
+
let declared = declaredSizing(definition, options);
|
|
1897
|
+
if (widthOnly(options?.size)) {
|
|
1898
|
+
let contentHeight2 = function() {
|
|
1899
|
+
for (let pass = 0; pass < 4; pass++) {
|
|
1900
|
+
let probe = at(width, height), natural = probe.sizing?.naturalHeight;
|
|
1901
|
+
if (natural === height || (definition.type === "table" || definition.type === "dimswitch") && !probe.refused && probe.size.height === natural || definition.type === "pie" && !probe.refused && settledAutoHeight.has(probe.frame) && probe.size.height === natural) return probe;
|
|
1902
|
+
if (natural === void 0 || (height = natural, probe.sizing?.fit !== "content")) break;
|
|
1903
|
+
}
|
|
1904
|
+
return at(width, height);
|
|
1905
|
+
};
|
|
1906
|
+
var contentHeight = contentHeight2;
|
|
1907
|
+
let at = (width2, height2) => {
|
|
1908
|
+
let fixed = { ...options, size: { width: width2, height: height2 } };
|
|
1909
|
+
return atSize ? atSize(fixed, compactFallback) : fitSizeMemo(definition, data, fixed, compactFallback);
|
|
1910
|
+
}, width = resolveSize(options.size, options.target).width, target = options.target ?? DEFAULT_TARGET, nested = panelTypeClass(options) !== void 0, height = hostlessHeight(declared, width, resolveSize(options.size, options.target).height, !nested);
|
|
1911
|
+
if (declared.fit === "content" || definition.type === "grid") {
|
|
1912
|
+
let settled = contentHeight2();
|
|
1913
|
+
if (definition.type === "grid" && !nested) {
|
|
1914
|
+
let share = autoPlotShare(definition, options, width);
|
|
1915
|
+
for (let pass = 0; pass < 3 && !settled.refused; pass++) {
|
|
1916
|
+
let need = plotFloorHeight(settled, target, PLOT_FLOOR_PX[target], share, freedChromeOf(settled.frame));
|
|
1917
|
+
if (need <= settled.size.height + SIZE_TOLERANCE) break;
|
|
1918
|
+
let tall2 = at(width, need);
|
|
1919
|
+
if (tall2.refused || plotForFloor(tall2).h <= plotForFloor(settled).h + SIZE_TOLERANCE) break;
|
|
1920
|
+
settled = tall2;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
if (nested || width >= CARD_CLASS_WIDTH || settled.refused || !CARD_FLOOR_CONTENT_TYPES.has(definition.type)) return settled;
|
|
1924
|
+
let wider = cardClassHeight(definition, data, options, width);
|
|
1925
|
+
if (wider === void 0 || settled.size.height + SIZE_TOLERANCE >= wider) return settled;
|
|
1926
|
+
let tall = at(width, wider);
|
|
1927
|
+
return tall.refused ? settled : tall;
|
|
1928
|
+
}
|
|
1929
|
+
if (!nested) {
|
|
1930
|
+
let plotShare = autoPlotShare(definition, options, width), floorShare = autoPlotShare(definition, { ...options, [PLOT_SHARE]: void 0 }, width), plotPx = declared.aspect === "16:9" ? autoPlotPx(target, width) + typePlotPx(definition.type, options, width) : PLOT_FLOOR_PX[target], freed = (r) => r.refused ? 0 : freedChromeOf(r.frame);
|
|
1931
|
+
width < CARD_CLASS_WIDTH && (height = Math.max(height, cardClassHeight(definition, data, options, width, !0) ?? 0));
|
|
1932
|
+
let search = (plotPx2, startHeight) => {
|
|
1933
|
+
let height2 = startHeight, previous, directRefusal, triedDirectRefusal = !1;
|
|
1934
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
1935
|
+
let probe = at(width, height2);
|
|
1936
|
+
if (directRefusal) {
|
|
1937
|
+
let chrome2 = probe.refused ? 1 / 0 : probe.size.height - plotForFloor(probe).h + freed(probe), floor2 = Math.ceil(Math.max(chrome2 + plotPx2, chrome2 / (1 - plotShare)) - 1e-6);
|
|
1938
|
+
if (probe.refused || floor2 !== height2) {
|
|
1939
|
+
height2 = directRefusal.height, pass = directRefusal.pass, directRefusal = void 0;
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1942
|
+
directRefusal = void 0;
|
|
1943
|
+
}
|
|
1944
|
+
let short = probe.refused && probe.size.width + SIZE_TOLERANCE >= (probe.sizing?.minWidth ?? 1 / 0) ? probe.sizing.minHeight : 0;
|
|
1945
|
+
if (short > height2) {
|
|
1946
|
+
let chrome2 = pass < 7 && !triedDirectRefusal && ["mekko", "column", "histogram"].includes(definition.type) ? plotChromeFloor.get(probe) : void 0, candidateHeight = chrome2 === void 0 ? short : Math.max(
|
|
1947
|
+
short,
|
|
1948
|
+
Math.ceil(Math.max(chrome2 + plotPx2, chrome2 / (1 - plotShare)) - 1e-6)
|
|
1949
|
+
);
|
|
1950
|
+
candidateHeight > short && (directRefusal = { height: short, pass }, triedDirectRefusal = !0), height2 = candidateHeight;
|
|
1951
|
+
continue;
|
|
1952
|
+
}
|
|
1953
|
+
if (probe.refused) break;
|
|
1954
|
+
let gain = previous && !previous.refused ? (plotForFloor(probe).h - plotForFloor(previous).h) / (probe.size.height - previous.size.height) : void 0, underShare = previous !== void 0 && !previous.refused && plotForFloor(previous).h + 1e-6 < floorShare * previous.size.height;
|
|
1955
|
+
if (gain !== void 0 && gain < 0.5 && !(gain > 0 && underShare) && partNeedOf(previous.frame) <= previous.size.height) return previous;
|
|
1956
|
+
let { need, holds } = autoHeightNeed(probe, target, plotPx2, plotShare, freed(probe));
|
|
1957
|
+
if (holds || settledAutoHeight.has(probe.frame) && need <= probe.size.height || need <= height2 && previous === void 0) return probe;
|
|
1958
|
+
if (need <= height2) {
|
|
1959
|
+
if (probe.size.height - previous.size.height <= 1) return probe;
|
|
1960
|
+
let certified = plotChromeFloor.get(probe.frame) === void 0 ? void 0 : plotChromeFloor.get(probe.frame) + freed(probe);
|
|
1961
|
+
if (certified !== void 0 && Math.ceil(Math.max(certified + plotPx2, certified / (1 - plotShare)) - 1e-6) === height2) return probe;
|
|
1962
|
+
let chrome2 = probe.size.height - plotForFloor(probe).h + freed(probe), floor2 = Math.ceil(Math.max(chrome2 + plotPx2, chrome2 / (1 - plotShare)) - 1e-6), candidateHeight = Math.max(previous.size.height + 1, floor2), dynamicFrame = (definition.type === "waterfall" || definition.type === "pvm") && options.annotations?.some((annotation) => annotation.kind === "cagr") || definition.type === "scatter", candidate = candidateHeight === height2 || dynamicFrame ? probe : at(width, candidateHeight);
|
|
1963
|
+
if (!dynamicFrame && !candidate.refused && autoHeightNeed(candidate, target, plotPx2, plotShare, freed(candidate)).need <= candidateHeight) {
|
|
1964
|
+
let candidateChrome = candidate.size.height - plotForFloor(candidate).h + freed(candidate), checkedFloor = Math.ceil(Math.max(candidateChrome + plotPx2, candidateChrome / (1 - plotShare)) - 1e-6);
|
|
1965
|
+
if (candidateHeight === previous.size.height + 1 || checkedFloor === candidateHeight) return candidate;
|
|
1966
|
+
}
|
|
1967
|
+
let low2 = previous.size.height, best2 = probe;
|
|
1968
|
+
for (; best2.size.height - low2 > 2; ) {
|
|
1969
|
+
let mid = Math.floor((low2 + best2.size.height) / 2), between = at(width, mid);
|
|
1970
|
+
!between.refused && autoHeightNeed(between, target, plotPx2, plotShare, freed(between)).need <= mid ? best2 = between : low2 = mid;
|
|
1971
|
+
}
|
|
1972
|
+
return best2;
|
|
1973
|
+
}
|
|
1974
|
+
previous = probe;
|
|
1975
|
+
let certifiedChrome = ["mekko", "column", "histogram"].includes(definition.type) ? plotChromeFloor.get(probe.frame) : void 0, chrome = certifiedChrome === void 0 ? void 0 : certifiedChrome + freed(probe), floor = chrome === void 0 ? need : Math.ceil(Math.max(chrome + plotPx2, chrome / (1 - plotShare)) - 1e-6);
|
|
1976
|
+
height2 = floor > height2 ? floor : need;
|
|
1977
|
+
}
|
|
1978
|
+
return at(width, height2);
|
|
1979
|
+
}, first = search(plotPx, height), plainPx = declared.aspect === "16:9" ? autoPlotPx(target, width) + typePlotPx(definition.type, options) : plotPx;
|
|
1980
|
+
if (plainPx === plotPx || hiddenForSpace(first) === 0) return first;
|
|
1981
|
+
let plain = search(plainPx, height);
|
|
1982
|
+
if (hiddenForSpace(plain) >= hiddenForSpace(first)) return first;
|
|
1983
|
+
if (plain.refused || first.refused || plain.size.height <= first.size.height) return plain;
|
|
1984
|
+
let low = first.size.height, best = plain;
|
|
1985
|
+
for (; best.size.height - low > 1; ) {
|
|
1986
|
+
let mid = Math.floor((low + best.size.height) / 2), probe = at(width, mid);
|
|
1987
|
+
!probe.refused && hiddenForSpace(probe) <= hiddenForSpace(plain) ? best = probe : low = mid;
|
|
1988
|
+
}
|
|
1989
|
+
return best;
|
|
1990
|
+
}
|
|
1991
|
+
return at(width, height);
|
|
1992
|
+
}
|
|
1993
|
+
return atSize ? atSize(options, compactFallback) : fitSizeMemo(definition, data, options, compactFallback);
|
|
1994
|
+
}
|
|
1995
|
+
function withoutCallState(options) {
|
|
1996
|
+
if (!options || !(CARD_HEIGHT_MEMO in options || LAYOUT_CALL in options || FULL_LAYOUT_PROBE in options || FIXED_SIZE_PROBE in options || ACCEPTANCE_PROBE in options)) return options;
|
|
1997
|
+
let {
|
|
1998
|
+
[CARD_HEIGHT_MEMO]: _card,
|
|
1999
|
+
[LAYOUT_CALL]: _call,
|
|
2000
|
+
[FULL_LAYOUT_PROBE]: _probe,
|
|
2001
|
+
[FIXED_SIZE_PROBE]: _fixed,
|
|
2002
|
+
[ACCEPTANCE_PROBE]: _accept,
|
|
2003
|
+
...raw
|
|
2004
|
+
} = options;
|
|
2005
|
+
return raw;
|
|
2006
|
+
}
|
|
2007
|
+
var layoutMemo, memoObjectIds = /* @__PURE__ */ new WeakMap(), memoSymbolIds = /* @__PURE__ */ new Map(), memoNextId = 0;
|
|
2008
|
+
function withLayoutMemo(run) {
|
|
2009
|
+
if (layoutMemo) return run();
|
|
2010
|
+
layoutMemo = /* @__PURE__ */ new Map();
|
|
2011
|
+
try {
|
|
2012
|
+
return withEngineNotes(() => withCategoryRowPlans(run));
|
|
2013
|
+
} finally {
|
|
2014
|
+
layoutMemo = void 0, memoSymbolIds = /* @__PURE__ */ new Map();
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
function memoId(value) {
|
|
2018
|
+
if (typeof value == "symbol") {
|
|
2019
|
+
let id2 = memoSymbolIds.get(value);
|
|
2020
|
+
return id2 === void 0 && memoSymbolIds.set(value, id2 = ++memoNextId), id2;
|
|
2021
|
+
}
|
|
2022
|
+
let id = memoObjectIds.get(value);
|
|
2023
|
+
return id === void 0 && memoObjectIds.set(value, id = ++memoNextId), id;
|
|
2024
|
+
}
|
|
2025
|
+
function memoKey(value, depth = 0) {
|
|
2026
|
+
if (--memoKeyBudget < 0) throw MEMO_KEY_TOO_LONG;
|
|
2027
|
+
switch (typeof value) {
|
|
2028
|
+
case "string":
|
|
2029
|
+
if ((memoKeyBudget -= value.length) < 0) throw MEMO_KEY_TOO_LONG;
|
|
2030
|
+
return JSON.stringify(value);
|
|
2031
|
+
case "number": {
|
|
2032
|
+
let text = Object.is(value, -0) ? "-0" : String(value);
|
|
2033
|
+
if ((memoKeyBudget -= text.length) < 0) throw MEMO_KEY_TOO_LONG;
|
|
2034
|
+
return text;
|
|
2035
|
+
}
|
|
2036
|
+
case "boolean":
|
|
2037
|
+
return value ? "t" : "f";
|
|
2038
|
+
case "undefined":
|
|
2039
|
+
return "u";
|
|
2040
|
+
case "bigint":
|
|
2041
|
+
return `${value}n`;
|
|
2042
|
+
case "symbol":
|
|
2043
|
+
return `s${memoId(value)}`;
|
|
2044
|
+
case "function":
|
|
2045
|
+
return `#${memoId(value)}`;
|
|
2046
|
+
}
|
|
2047
|
+
if (value === null) return "n";
|
|
2048
|
+
if (value === memoKeyData) return "D";
|
|
2049
|
+
if ((memoKeyBudget -= 8) < 0) throw MEMO_KEY_TOO_LONG;
|
|
2050
|
+
let object = value;
|
|
2051
|
+
if (Array.isArray(object)) {
|
|
2052
|
+
if (depth > 24 || Object.isFrozen(object)) return `#${memoId(object)}`;
|
|
2053
|
+
let out2 = "[";
|
|
2054
|
+
for (let i = 0; i < object.length; i++) out2 += (i ? "," : "") + (i in object ? memoKey(object[i], depth + 1) : "h");
|
|
2055
|
+
return Object.keys(object).length === object.length ? `${out2}]` : `#${memoId(object)}`;
|
|
2056
|
+
}
|
|
2057
|
+
if (depth > 24 || Object.isFrozen(object)) return `#${memoId(object)}`;
|
|
2058
|
+
if (object instanceof Set) {
|
|
2059
|
+
let out2 = "S[";
|
|
2060
|
+
for (let item of object) out2 += `${memoKey(item, depth + 1)},`;
|
|
2061
|
+
return `${out2}]`;
|
|
2062
|
+
}
|
|
2063
|
+
if (object instanceof Map) {
|
|
2064
|
+
let out2 = "M[";
|
|
2065
|
+
for (let [name, item] of object) out2 += `${memoKey(name, depth + 1)}:${memoKey(item, depth + 1)},`;
|
|
2066
|
+
return `${out2}]`;
|
|
2067
|
+
}
|
|
2068
|
+
let proto = Object.getPrototypeOf(object);
|
|
2069
|
+
if (proto !== Object.prototype && proto !== null) return `#${memoId(object)}`;
|
|
2070
|
+
let out = "{";
|
|
2071
|
+
if (depth === 0) {
|
|
2072
|
+
let ordered = Reflect.ownKeys(object).filter((key) => object[key] !== void 0).map((key) => [memoName(key), key]).sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
2073
|
+
for (let [name, key] of ordered) out += `${name}:${memoKey(object[key], 1)},`;
|
|
2074
|
+
return `${out}}`;
|
|
2075
|
+
}
|
|
2076
|
+
for (let key of Reflect.ownKeys(object)) {
|
|
2077
|
+
let entry = object[key];
|
|
2078
|
+
out += `${memoName(key)}:${memoKey(entry, depth + 1)},`;
|
|
2079
|
+
}
|
|
2080
|
+
return `${out}}`;
|
|
2081
|
+
}
|
|
2082
|
+
function memoName(key) {
|
|
2083
|
+
let name = typeof key == "symbol" ? `s${memoId(key)}` : JSON.stringify(key);
|
|
2084
|
+
if ((memoKeyBudget -= name.length) < 0) throw MEMO_KEY_TOO_LONG;
|
|
2085
|
+
return name;
|
|
2086
|
+
}
|
|
2087
|
+
var MEMO_KEY_LIMIT = 2e5, MEMO_KEY_TOO_LONG = /* @__PURE__ */ Symbol("memoKeyTooLong"), memoKeyBudget = 0, memoKeyData;
|
|
2088
|
+
function memoCopy(result) {
|
|
2089
|
+
let copy = { ...result, warnings: [...result.warnings], ...result.sizing ? { sizing: { ...result.sizing } } : {} }, floor = plotChromeFloor.get(result);
|
|
2090
|
+
return floor !== void 0 && plotChromeFloor.set(copy, floor), copy;
|
|
2091
|
+
}
|
|
2092
|
+
function fitSizeMemo(definition, data, options, compactFallback) {
|
|
2093
|
+
let memo = layoutMemo;
|
|
2094
|
+
if (!memo || data === null || typeof data != "object" || panelTypeClass(options) !== void 0 || definition.type === "gantt" && options?.[ACCEPTANCE_PROBE])
|
|
2095
|
+
return fitSize(definition, data, options, compactFallback);
|
|
2096
|
+
let card = options?.[CARD_HEIGHT_MEMO], share = options?.[PLOT_SHARE], keyed = withoutCallState(options);
|
|
2097
|
+
if (share !== void 0) {
|
|
2098
|
+
let { [PLOT_SHARE]: _share, ...rest } = keyed;
|
|
2099
|
+
keyed = rest;
|
|
2100
|
+
}
|
|
2101
|
+
memoKeyBudget = MEMO_KEY_LIMIT, memoKeyData = data;
|
|
2102
|
+
let optionsKey;
|
|
2103
|
+
try {
|
|
2104
|
+
optionsKey = memoKey(keyed);
|
|
2105
|
+
} catch (error) {
|
|
2106
|
+
if (error !== MEMO_KEY_TOO_LONG) throw error;
|
|
2107
|
+
return fitSize(definition, data, options, compactFallback);
|
|
2108
|
+
} finally {
|
|
2109
|
+
memoKeyData = void 0;
|
|
2110
|
+
}
|
|
2111
|
+
let key = `${memoId(definition)}|${memoId(data)}|${compactFallback}|${definition.type === "gantt" && card ? memoId(card) : ""}|${optionsKey}`, entry = memo.get(key) ?? {};
|
|
2112
|
+
if (entry.result) return memoCopy(entry.result);
|
|
2113
|
+
let shared = entry.byShare?.get(share);
|
|
2114
|
+
if (shared)
|
|
2115
|
+
return shareRead = !0, memoCopy(shared);
|
|
2116
|
+
let outer = shareRead;
|
|
2117
|
+
shareRead = !1;
|
|
2118
|
+
let result, readsShare = !0;
|
|
2119
|
+
try {
|
|
2120
|
+
result = fitSize(definition, data, options, compactFallback), readsShare = shareRead;
|
|
2121
|
+
} finally {
|
|
2122
|
+
shareRead = outer || readsShare;
|
|
2123
|
+
}
|
|
2124
|
+
let copy = memoCopy(result);
|
|
2125
|
+
return readsShare ? (entry.byShare ??= /* @__PURE__ */ new Map()).set(share, copy) : entry.result = copy, memo.set(key, entry), result;
|
|
2126
|
+
}
|
|
2127
|
+
function fitSize(definition, data, options, compactFallback) {
|
|
2128
|
+
let declared = declaredSizing(definition, options), requested = resolveSize(options?.size, options?.target), nested = panelTypeClass(options) !== void 0, floor = requestFloor(declared), growsFull = definition.type === "pie" && !(options?.[TARGET_SIZE] ?? resolveTargetSize(options?.target ?? DEFAULT_TARGET, options?.size)).fixed.height, tight = !nested && (compactFallback || belowMinimum(declared, growsFull ? { ...requested, height: declared.minHeight } : requested, options, definition.type)), gatePolicy = tight ? { ...declared, minWidth: floor.width, minHeight: floor.height } : declared;
|
|
2129
|
+
if (!nested && !fitsSize(requested, definition.type === "grid" ? { ...gatePolicy, minHeight: 0 } : gatePolicy))
|
|
2130
|
+
return sizeRefusal(definition.type, definition.title, requested, resolveSizing(gatePolicy, requested));
|
|
2131
|
+
let mode = tight || definition.type !== "mekko" && options?.mode === "compact" ? "compact" : "full", layoutOptions = mode === "compact" ? compactOptions(definition.type, options ?? {}, tight ? floor : void 0, requested.width) : options, rawOptions = definition.type === "kpi" ? { ...layoutOptions, typeClass: "M" } : layoutOptions, layout = (runOptions) => {
|
|
2132
|
+
let clean = withoutCallState(runOptions), memo = runOptions?.[CARD_HEIGHT_MEMO];
|
|
2133
|
+
return definition.layout(data, definition.type === "gantt" ? {
|
|
2134
|
+
...clean,
|
|
2135
|
+
...memo ? { [CARD_HEIGHT_MEMO]: memo } : {},
|
|
2136
|
+
...runOptions?.[ACCEPTANCE_PROBE] ? { [ACCEPTANCE_PROBE]: !0 } : {}
|
|
2137
|
+
} : clean);
|
|
2138
|
+
}, geometry = layout(rawOptions), heightShort = tight && requested.height < declared.minHeight;
|
|
2139
|
+
if (definition.type === "slope" && !geometry.refused && layoutOptions?.variant === "diverging") {
|
|
2140
|
+
let naturalHeight = geometry.sizing.naturalHeight;
|
|
2141
|
+
options?.size === void 0 && !nested && Math.abs(naturalHeight - geometry.size.height) > 2 && (geometry = layout({ ...layoutOptions, size: { width: geometry.size.width, height: naturalHeight } }));
|
|
2142
|
+
} else if (definition.type === "slope" && !geometry.refused) {
|
|
2143
|
+
let reference = geometry.size.width === 720 && geometry.size.height === 405 ? geometry : layout({ ...layoutOptions, size: { width: 720, height: 405 } }), naturalHeight = slopeContentHeight(geometry, reference.refused ? geometry.plot.h : reference.plot.h);
|
|
2144
|
+
options?.size === void 0 && !nested && Math.abs(naturalHeight - geometry.size.height) > 2 && (geometry = layout({ ...layoutOptions, size: { width: geometry.size.width, height: naturalHeight } })), geometry.refused || (geometry.sizing = { ...geometry.sizing, naturalHeight });
|
|
2145
|
+
}
|
|
2146
|
+
if (geometry.refused) return geometry;
|
|
2147
|
+
let footerExtra = liveFooterExtra.get(geometry.frame) ?? 0, floorWithFooter = Math.max(
|
|
2148
|
+
geometry.sizing?.minHeight ?? 0,
|
|
2149
|
+
geometry.frame.minHeight ?? 0,
|
|
2150
|
+
geometry.frame.plotMinHeight ?? 0,
|
|
2151
|
+
(heightShort || tight) && HOLDS_COMPACT_PLOT.has(definition.type) ? Math.ceil(geometry.size.height + (atHardMinimum(options) && !HARD_KEEPS_COMPACT_PLOT.has(definition.type) ? HARD_COMPACT_PLOT : MIN_COMPACT_PLOT) - plotForFloor(geometry).h) : 0
|
|
2152
|
+
), measured = {
|
|
2153
|
+
...geometry.sizing,
|
|
2154
|
+
...definition.type === "kpi" ? { naturalWidth: Math.min(geometry.sizing?.naturalWidth ?? 360, 360) } : {},
|
|
2155
|
+
// The height that holds a plot of MIN_COMPACT_PLOT px is the measured floor (HOLDS_COMPACT_PLOT).
|
|
2156
|
+
minHeight: floorWithFooter - footerExtra,
|
|
2157
|
+
measuredMinHeight: Math.max(geometry.sizing?.measuredMinHeight ?? 0, geometry.frame.minHeight ?? 0, isVarianceTier(layoutOptions) ? 0 : geometry.frame.plotMinHeight ?? 0)
|
|
2158
|
+
}, policy = definition.type === "grid" && measured.fit === "content" ? { ...declared, minHeight: 0 } : declared;
|
|
2159
|
+
if (geometry.sizing = resolveSizing(nested && measured.fit === "content" ? { ...policy, minWidth: 0 } : policy, geometry.size, measured), geometry.sizing.compactFloor !== void 0 && definition.compactForm?.(data, options) === !1) {
|
|
2160
|
+
let { compactFloor: _none, ...sizing } = geometry.sizing;
|
|
2161
|
+
geometry.sizing = sizing;
|
|
2162
|
+
}
|
|
2163
|
+
let gate = tight ? resolveSizing(gatePolicy, geometry.size, measured) : geometry.sizing;
|
|
2164
|
+
geometry.mode = mode;
|
|
2165
|
+
let omittedNotes = mode === "compact" ? omittedCompactNotes(definition.type, options ?? {}) : [];
|
|
2166
|
+
if (omittedNotes.length > 0 && (geometry.a11y.desc += ` Notes: ${omittedNotes.join("; ")}.`, geometry.a11y.compactNotes = [...geometry.a11y.compactNotes ?? [], ...omittedNotes], geometry.warnings.push({
|
|
2167
|
+
code: "compact-notes-omitted",
|
|
2168
|
+
severity: "info",
|
|
2169
|
+
message: `compact mode leaves these notes off the canvas and in the accessible description: ${omittedNotes.join(" | ")}`
|
|
2170
|
+
})), footerExtra > 0 && geometry.size.height < floorWithFooter && !geometry.warnings.some((warning) => warning.code === "plot-under-floor")) {
|
|
2171
|
+
let height = Math.ceil(floorWithFooter);
|
|
2172
|
+
geometry.warnings.push({
|
|
2173
|
+
code: "plot-under-floor",
|
|
2174
|
+
severity: "warn",
|
|
2175
|
+
message: `the source and notes rows under the chart take ${Math.ceil(footerExtra)} px from the plot, which draws under its floor; the chart needs ${height} px`,
|
|
2176
|
+
suggest: `Give the chart ${height} px of height, or leave the height out so the chart takes it.`,
|
|
2177
|
+
field: ["options", "size"],
|
|
2178
|
+
fix: [{ op: "replace", path: "/options/size", value: { width: geometry.size.width, height } }]
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
if (nested || geometry.warnings.some((w) => w.code === "invalid-options") || definition.type === "diagram" && isRefused(geometry) || fitsSize(geometry.size, gate)) return geometry;
|
|
2182
|
+
let refusal = sizeRefusal(definition.type, definition.title, geometry.size, gate), chrome = plotChromeFloor.get(geometry.frame);
|
|
2183
|
+
return chrome !== void 0 && plotChromeFloor.set(refusal, chrome), refusal;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
// src/core/paretoTail.ts
|
|
2187
|
+
function crowdedTailCut(ranked) {
|
|
2188
|
+
let total = ranked.reduce((sum, r) => sum + r.value, 0);
|
|
2189
|
+
if (!(total > 0)) return;
|
|
2190
|
+
let limit = total * 2 / 100, cut = ranked.length;
|
|
2191
|
+
for (; cut > 0 && ranked[cut - 1].value < limit; ) cut -= 1;
|
|
2192
|
+
return ranked.length - cut > 12 && cut > 0 ? cut : void 0;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
// src/core/itemBudget.ts
|
|
2196
|
+
var ITEM_BUDGET = 2e3, TYPE_BUDGETS = { likert: 500, mekko: 2e4 }, TOO_MANY_ITEMS = "too-many-items", BUDGETED_LISTS = {
|
|
2197
|
+
column: ["categories"],
|
|
2198
|
+
bar: ["categories"],
|
|
2199
|
+
combo: ["categories"],
|
|
2200
|
+
dot: ["categories"],
|
|
2201
|
+
variance: ["categories"],
|
|
2202
|
+
butterfly: ["categories"],
|
|
2203
|
+
funnel: ["categories"],
|
|
2204
|
+
mekko: ["categories"],
|
|
2205
|
+
waffle: ["categories"],
|
|
2206
|
+
bartable: ["categories"],
|
|
2207
|
+
heatmap: ["categories", "series"],
|
|
2208
|
+
status: ["rows", "columns"],
|
|
2209
|
+
bullet: ["rows"],
|
|
2210
|
+
gantt: ["rows"],
|
|
2211
|
+
pareto: ["items"],
|
|
2212
|
+
waterfall: ["items"],
|
|
2213
|
+
likert: ["items"],
|
|
2214
|
+
treemap: ["items"],
|
|
2215
|
+
pyramid: ["bands"],
|
|
2216
|
+
cohort: ["cohorts"]
|
|
2217
|
+
}, TOP_N_TYPES = /* @__PURE__ */ new Set(["bar", "butterfly", "column", "mekko", "pareto", "likert", "pyramid"]), VIEWPORT_TYPES = /* @__PURE__ */ new Set(["column", "combo"]);
|
|
2218
|
+
function barTotalsAtLeast(data, threshold) {
|
|
2219
|
+
let series = data?.series, categories = data?.categories ?? [], totals = new Float64Array(categories.length);
|
|
2220
|
+
if (Array.isArray(series)) for (let one of series) {
|
|
2221
|
+
let values = one?.values;
|
|
2222
|
+
if (Array.isArray(values))
|
|
2223
|
+
for (let i = 0; i < totals.length && i < values.length; i += 1) {
|
|
2224
|
+
let cell = values[i], value = typeof cell == "number" ? cell : cell?.v;
|
|
2225
|
+
typeof value == "number" && Number.isFinite(value) && (totals[i] = totals[i] + value);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
let count = 0;
|
|
2229
|
+
for (let total of totals) Math.abs(total) >= threshold && (count += 1);
|
|
2230
|
+
return count;
|
|
2231
|
+
}
|
|
2232
|
+
function drawnCount(type, key, list, data, options) {
|
|
2233
|
+
let count = list.length, topN = options?.topN;
|
|
2234
|
+
if (TOP_N_TYPES.has(type) && topN?.n !== void 0 && topN.n > 0 && !(type === "column" && options?.anomaly)) {
|
|
2235
|
+
let kept = Math.min(count, type === "bar" ? Math.max(1, topN.n) : topN.n);
|
|
2236
|
+
type === "bar" && topN.threshold !== void 0 && (kept = Math.min(kept, Math.max(1, barTotalsAtLeast(data, topN.threshold)))), count = Math.min(count, kept + (topN.rest === !1 || kept === count ? 0 : 1));
|
|
2237
|
+
}
|
|
2238
|
+
if (VIEWPORT_TYPES.has(type) && key === "categories") {
|
|
2239
|
+
let ends = options?.viewDomain?.x;
|
|
2240
|
+
if (ends) {
|
|
2241
|
+
let first = list.findIndex((category) => category?.id === ends[0]), last = list.findIndex((category) => category?.id === ends[1]);
|
|
2242
|
+
count = first < 0 || last < 0 ? 0 : Math.abs(last - first) + 1;
|
|
2243
|
+
}
|
|
2244
|
+
let window = options?.window?.last;
|
|
2245
|
+
window !== void 0 && window > 0 && (count = Math.min(count, window));
|
|
2246
|
+
}
|
|
2247
|
+
if (type === "pareto" && options?.topN === void 0) {
|
|
2248
|
+
let values = list.filter((item) => !item?.rest).map((item) => item?.value).filter((value) => typeof value == "number" && Number.isFinite(value) && value >= 0).sort((a, b) => b - a), fold = crowdedTailCut(values.map((value) => ({ value })));
|
|
2249
|
+
fold !== void 0 && (count = Math.min(count, fold + 1 + list.length - values.length));
|
|
2250
|
+
}
|
|
2251
|
+
return count;
|
|
2252
|
+
}
|
|
2253
|
+
var NOUNS = { series: "rows" };
|
|
2254
|
+
function checkItemBudget(type, data, options) {
|
|
2255
|
+
let lists = BUDGETED_LISTS[type];
|
|
2256
|
+
if (!lists) return;
|
|
2257
|
+
let budget = TYPE_BUDGETS[type] ?? ITEM_BUDGET;
|
|
2258
|
+
for (let key of lists) {
|
|
2259
|
+
let list = data?.[key];
|
|
2260
|
+
if (!Array.isArray(list) || list.length <= budget || drawnCount(type, key, list, data, options) <= budget) continue;
|
|
2261
|
+
let noun = NOUNS[key] ?? key, fix = TOP_N_TYPES.has(type) ? ", set topN to keep the largest" : "";
|
|
2262
|
+
throw new NormalizeError(
|
|
2263
|
+
TOO_MANY_ITEMS,
|
|
2264
|
+
key,
|
|
2265
|
+
`${list.length} ${noun} exceed the ${budget} a ${type} chart draws; its layout would take minutes`,
|
|
2266
|
+
`aggregate the ${noun} first (weeks or months, or the largest with a rest)${fix}, or draw dated values as a line, which samples long series`,
|
|
2267
|
+
void 0,
|
|
2268
|
+
["data", key]
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
// src/core/scale.ts
|
|
2274
|
+
function applyAxisBounds(domain, extent, axis, warnings) {
|
|
2275
|
+
return axis?.min === void 0 && axis?.max === void 0 ? domain : domain.map((value, i) => {
|
|
2276
|
+
let bound = i === 0 ? "min" : "max", authored = axis?.[bound];
|
|
2277
|
+
if (authored === void 0) return value;
|
|
2278
|
+
let drawn = i === 0 ? Math.min(authored, extent[i]) : Math.max(authored, extent[i]);
|
|
2279
|
+
return drawn !== authored && warnings.push({
|
|
2280
|
+
code: `value-axis-${bound}-ignored`,
|
|
2281
|
+
severity: "warn",
|
|
2282
|
+
message: `valueAxis.${bound} ${authored} cannot contain the plotted values and their required space; the axis extends to ${drawn}`,
|
|
2283
|
+
suggest: `Set valueAxis.${bound} to ${drawn}, or remove valueAxis.${bound}.`,
|
|
2284
|
+
field: ["options", "valueAxis", bound],
|
|
2285
|
+
fix: [{ op: "replace", path: `/options/valueAxis/${bound}`, value: drawn }]
|
|
2286
|
+
}), drawn;
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
var AXIS_BREAK_GAP = 12, MAX_TICK_COUNT = 1e3;
|
|
2290
|
+
function normalizeTickCount(targetCount) {
|
|
2291
|
+
return Number.isFinite(targetCount) ? Math.min(MAX_TICK_COUNT, Math.max(1, Math.floor(targetCount))) : 5;
|
|
2292
|
+
}
|
|
2293
|
+
function niceStep(rawStep) {
|
|
2294
|
+
if (!(rawStep > 0) || !Number.isFinite(rawStep)) return 1;
|
|
2295
|
+
let exp = Math.floor(Math.log10(rawStep)), base = Math.pow(10, exp), m = rawStep / base, step = (m <= 1 + 1e-9 ? 1 : m <= 2 + 1e-9 ? 2 : m <= 5 + 1e-9 ? 5 : 10) * base;
|
|
2296
|
+
return Number.isFinite(step) && step > 0 ? step : rawStep;
|
|
2297
|
+
}
|
|
2298
|
+
function finiteBounds(lo, hi, fallbackLo, fallbackHi) {
|
|
2299
|
+
let safeLo = Number.isFinite(lo) ? lo : Number.isFinite(fallbackLo) ? fallbackLo : 0, safeHi = Number.isFinite(hi) ? hi : Number.isFinite(fallbackHi) ? fallbackHi : 1;
|
|
2300
|
+
return [safeLo, safeHi];
|
|
2301
|
+
}
|
|
2302
|
+
function niceDomain(min, max, targetTicks = 5, options = {}) {
|
|
2303
|
+
let dataExtent = options.dataExtent;
|
|
2304
|
+
if (!Number.isFinite(min) || !Number.isFinite(max)) {
|
|
2305
|
+
let lo = Number.isFinite(min) ? min : Number.isFinite(dataExtent?.[0]) ? dataExtent[0] : 0, hi = Number.isFinite(max) ? max : Number.isFinite(dataExtent?.[1]) ? dataExtent[1] : 1;
|
|
2306
|
+
return niceDomain(Math.min(lo, hi), Math.max(lo, hi), targetTicks, options);
|
|
2307
|
+
}
|
|
2308
|
+
if (min === max)
|
|
2309
|
+
return min === 0 ? [0, 1] : min > 0 ? [0, Math.max(niceStep(min * 1.2), min)] : [Math.min(-niceStep(-min * 1.2), min), 0];
|
|
2310
|
+
if (!dataExtent) {
|
|
2311
|
+
let step2 = niceStep((max - min) / Math.max(1, targetTicks));
|
|
2312
|
+
return finiteBounds(snapDown(min, step2), snapUp(max, step2), min, max);
|
|
2313
|
+
}
|
|
2314
|
+
let intentMin = Number.isFinite(min) ? min : dataExtent[0], intentMax = Number.isFinite(max) ? max : dataExtent[1], clampMin, clampMax;
|
|
2315
|
+
if (dataExtent && options.preserveDataSideOfZero) {
|
|
2316
|
+
let [dataMin, dataMax] = dataExtent;
|
|
2317
|
+
dataMin >= 0 && dataMax > 0 ? (intentMin = Math.max(0, intentMin), clampMin = 0) : dataMin < 0 && dataMax <= 0 && (intentMax = Math.min(0, intentMax), clampMax = 0);
|
|
2318
|
+
}
|
|
2319
|
+
let step = niceStep((intentMax - intentMin) / Math.max(1, targetTicks)), snap = () => {
|
|
2320
|
+
let lo = Math.max(clampMin ?? -1 / 0, snapDown(intentMin, step)), hi = Math.min(clampMax ?? 1 / 0, snapUp(intentMax, step));
|
|
2321
|
+
return finiteBounds(lo, hi, intentMin, intentMax);
|
|
2322
|
+
}, domain = snap(), wasteLimit = options.maxWasteFraction, totalLimit = options.maxTotalWasteFraction;
|
|
2323
|
+
if (wasteLimit === void 0 && totalLimit === void 0 || dataExtent[0] === dataExtent[1])
|
|
2324
|
+
return domain;
|
|
2325
|
+
for (let attempt = 0; attempt < 32; attempt++) {
|
|
2326
|
+
let span = domain[1] - domain[0], belowWaste = (dataExtent[0] - domain[0]) / span, aboveWaste = (domain[1] - dataExtent[1]) / span;
|
|
2327
|
+
if ((wasteLimit === void 0 || belowWaste <= wasteLimit + 1e-12 && aboveWaste <= wasteLimit + 1e-12) && (totalLimit === void 0 || belowWaste + aboveWaste <= totalLimit + 1e-12))
|
|
2328
|
+
return domain;
|
|
2329
|
+
step = previousNiceStep(step), domain = snap();
|
|
2330
|
+
}
|
|
2331
|
+
return finiteBounds(intentMin, intentMax, min, max);
|
|
2332
|
+
}
|
|
2333
|
+
function previousNiceStep(step) {
|
|
2334
|
+
let exp = Math.floor(Math.log10(step)), base = Math.pow(10, exp), mantissa = step / base;
|
|
2335
|
+
return mantissa > 2 + 1e-9 ? 2 * base : mantissa > 1 + 1e-9 ? base : 5 * base / 10;
|
|
2336
|
+
}
|
|
2337
|
+
function axisGrid(min, max) {
|
|
2338
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || !(max > min)) return;
|
|
2339
|
+
let coarse = niceStep((max - min) / 5), best;
|
|
2340
|
+
for (let step2 of [coarse, previousNiceStep(coarse)]) {
|
|
2341
|
+
let lo2 = snapDown(min, step2), hi2 = snapUp(max, step2);
|
|
2342
|
+
best && ((hi2 - lo2) / step2 > 8 + 1e-9 || hi2 - lo2 >= best.hi - best.lo - step2 * 1e-9) || (best = { lo: lo2, hi: hi2, step: step2 });
|
|
2343
|
+
}
|
|
2344
|
+
let { lo, hi, step } = best, count = Math.round((hi - lo) / step);
|
|
2345
|
+
if (!(!Number.isFinite(lo) || !Number.isFinite(hi) || !Number.isFinite(count) || count > 8))
|
|
2346
|
+
return { domain: [lo, hi], ticks: Array.from({ length: count + 1 }, (_, i) => i === count ? hi : onGrid(Math.round(lo / step) + i, step)) };
|
|
2347
|
+
}
|
|
2348
|
+
function seatRoom(value, domain, seat, plotH) {
|
|
2349
|
+
let free = (domain[1] - value) / (domain[1] - domain[0]);
|
|
2350
|
+
return free >= 0 && free < 1 ? Math.max(0, (seat - free * Math.max(0, plotH)) / (1 - free)) : 0;
|
|
2351
|
+
}
|
|
2352
|
+
function linearScale(domain, range) {
|
|
2353
|
+
let [d0, d1] = domain, [r0, r1] = range, dd = d1 - d0 || 1, scale = ((value) => value === d1 && d1 !== d0 ? r1 : r0 + (value - d0) / dd * (r1 - r0));
|
|
2354
|
+
return scale.domain = [d0, d1], scale.range = [r0, r1], scale.invert = (px) => d0 + (px - r0) / (r1 - r0 || 1) * dd, scale.ticks = (targetCount = 5) => {
|
|
2355
|
+
let out = [], ascending = d1 >= d0, lo = Math.min(d0, d1), hi = Math.max(d0, d1), span = hi - lo, target = normalizeTickCount(targetCount), step = niceStep(span / target), start = Math.ceil(lo / step) * step;
|
|
2356
|
+
if (!Number.isFinite(lo) || !Number.isFinite(hi)) return out;
|
|
2357
|
+
if (!Number.isFinite(span))
|
|
2358
|
+
return d0 === d1 ? [d0] : [d0, d1];
|
|
2359
|
+
if (!Number.isFinite(start) || !(step > 0)) return out;
|
|
2360
|
+
let drifted = hi + step * 1e-9, limit = Number.isFinite(drifted) ? drifted : hi;
|
|
2361
|
+
for (let v = start; Number.isFinite(v) && v <= limit; ) {
|
|
2362
|
+
out.push(Math.abs(v) < step * 1e-9 ? 0 : roundToStep(v, step));
|
|
2363
|
+
let next = v + step;
|
|
2364
|
+
if (!(next > v)) break;
|
|
2365
|
+
v = next;
|
|
2366
|
+
}
|
|
2367
|
+
return ascending ? out : out.reverse();
|
|
2368
|
+
}, scale;
|
|
2369
|
+
}
|
|
2370
|
+
function brokenLinearScale(domain, range, axisBreak, gap = AXIS_BREAK_GAP) {
|
|
2371
|
+
let [d0, d1] = domain, [r0, r1] = range, lowerDomain = axisBreak.from - d0, upperDomain = d1 - axisBreak.to, retainedDomain = lowerDomain + upperDomain, direction = r1 >= r0 ? 1 : -1, rangeSpan = Math.abs(r1 - r0), gapPx = Math.min(Math.max(0, gap), rangeSpan), retainedPixels = rangeSpan - gapPx, lowerPixels = retainedDomain > 0 ? retainedPixels * (lowerDomain / retainedDomain) : 0, rangeFrom = r0 + direction * lowerPixels, rangeTo = rangeFrom + direction * gapPx, interpolate = (value, a, b, x, y) => {
|
|
2372
|
+
let span = b - a;
|
|
2373
|
+
return span === 0 ? x : x + (value - a) / span * (y - x);
|
|
2374
|
+
}, scale = ((value) => value <= axisBreak.from ? interpolate(value, d0, axisBreak.from, r0, rangeFrom) : value >= axisBreak.to ? interpolate(value, axisBreak.to, d1, rangeTo, r1) : interpolate(value, axisBreak.from, axisBreak.to, rangeFrom, rangeTo));
|
|
2375
|
+
return scale.domain = [d0, d1], scale.range = [r0, r1], scale.break = {
|
|
2376
|
+
...axisBreak,
|
|
2377
|
+
rangeFrom,
|
|
2378
|
+
rangeTo,
|
|
2379
|
+
position: (rangeFrom + rangeTo) / 2,
|
|
2380
|
+
gap: gapPx
|
|
2381
|
+
}, scale.invert = (px) => {
|
|
2382
|
+
let offset = (px - r0) * direction, gapStart = (rangeFrom - r0) * direction, gapEnd = (rangeTo - r0) * direction;
|
|
2383
|
+
return offset <= gapStart ? interpolate(offset, 0, gapStart, d0, axisBreak.from) : offset >= gapEnd ? interpolate(offset, gapEnd, rangeSpan, axisBreak.to, d1) : interpolate(offset, gapStart, gapEnd, axisBreak.from, axisBreak.to);
|
|
2384
|
+
}, scale.ticks = (targetCount = 5) => {
|
|
2385
|
+
let total = normalizeTickCount(targetCount), lowerTarget = Math.max(1, Math.round(total * (lowerDomain / retainedDomain))), upperTarget = Math.max(1, Math.round(total * (upperDomain / retainedDomain))), epsilon = Math.max(1, Math.abs(d1 - d0)) * 1e-12, lower = linearScale([d0, axisBreak.from], [0, 1]).ticks(lowerTarget).filter((value) => value < axisBreak.from - epsilon), upper = linearScale([axisBreak.to, d1], [0, 1]).ticks(upperTarget).filter((value) => value > axisBreak.to + epsilon);
|
|
2386
|
+
return [.../* @__PURE__ */ new Set([...lower, ...upper])].sort((a, b) => a - b);
|
|
2387
|
+
}, scale;
|
|
2388
|
+
}
|
|
2389
|
+
function invalidLinearBreakReason(domain, axisBreak, renderedValues, drawnBy) {
|
|
2390
|
+
let [d0, d1] = domain, { from, to } = axisBreak;
|
|
2391
|
+
if (!Number.isFinite(from) || !Number.isFinite(to) || !(from < to))
|
|
2392
|
+
return "from and to must be finite with from < to";
|
|
2393
|
+
if (!(d0 < from && to < d1)) return "from and to must both lie strictly inside the domain";
|
|
2394
|
+
if (from <= 0 && to >= 0) return "the omitted span must not contain zero";
|
|
2395
|
+
let inside = renderedValues.find((value) => value > from && value < to);
|
|
2396
|
+
if (inside === void 0) return;
|
|
2397
|
+
let cause = drawnBy?.(inside);
|
|
2398
|
+
return `the omitted span contains rendered value ${inside}${cause ? `, drawn by ${cause}` : ""}`;
|
|
2399
|
+
}
|
|
2400
|
+
function crossesLinearBreak(start, end, axisBreak) {
|
|
2401
|
+
let lo = Math.min(start, end), hi = Math.max(start, end);
|
|
2402
|
+
return lo <= axisBreak.from && hi >= axisBreak.to;
|
|
2403
|
+
}
|
|
2404
|
+
function snapDown(v, step) {
|
|
2405
|
+
let k = Math.floor(v / step + 1e-9), lo = onGrid(k, step);
|
|
2406
|
+
return lo <= v ? lo : onGrid(k - 1, step);
|
|
2407
|
+
}
|
|
2408
|
+
function snapUp(v, step) {
|
|
2409
|
+
let k = Math.ceil(v / step - 1e-9), hi = onGrid(k, step);
|
|
2410
|
+
return hi >= v ? hi : onGrid(k + 1, step);
|
|
2411
|
+
}
|
|
2412
|
+
function onGrid(k, step) {
|
|
2413
|
+
let raw = k * step, rounded = roundToStep(raw, step);
|
|
2414
|
+
return Math.abs(rounded - raw) <= step * 1e-6 ? rounded : raw;
|
|
2415
|
+
}
|
|
2416
|
+
function roundToStep(v, step) {
|
|
2417
|
+
let decimals = Math.max(0, -Math.floor(Math.log10(step)) + 1);
|
|
2418
|
+
return decimals + 1 <= 12 ? Number(v.toFixed(decimals + 1)) : Number(v.toPrecision(12));
|
|
2419
|
+
}
|
|
2420
|
+
function bandScale(count, range, opts = {}) {
|
|
2421
|
+
let paddingInner = opts.paddingInner ?? 0.35, paddingOuter = opts.paddingOuter ?? paddingInner / 2, [r0, r1] = range;
|
|
2422
|
+
if (!Number.isInteger(count) || count < 0)
|
|
2423
|
+
throw new RangeError("bandScale count must be a nonnegative integer");
|
|
2424
|
+
if (!Number.isFinite(r0) || !Number.isFinite(r1) || r1 < r0)
|
|
2425
|
+
throw new RangeError("bandScale range must contain finite ascending values");
|
|
2426
|
+
if (!Number.isFinite(paddingInner) || paddingInner < 0 || paddingInner > 1)
|
|
2427
|
+
throw new RangeError("bandScale paddingInner must be between 0 and 1");
|
|
2428
|
+
if (!Number.isFinite(paddingOuter) || paddingOuter < 0 || paddingOuter > 1)
|
|
2429
|
+
throw new RangeError("bandScale paddingOuter must be between 0 and 1");
|
|
2430
|
+
if (opts.gapAfter?.some((gap) => !Number.isFinite(gap) || gap < 0))
|
|
2431
|
+
throw new RangeError("bandScale gapAfter values must be finite and nonnegative");
|
|
2432
|
+
let extent = r1 - r0, n = Math.max(1, count), extraGaps = Array.from(
|
|
2433
|
+
{ length: n },
|
|
2434
|
+
(_, i) => i < n - 1 ? Math.max(0, opts.gapAfter?.[i] ?? 0) : 0
|
|
2435
|
+
), extraGapTotal = extraGaps.reduce((sum, value) => sum + value, 0), stepSize = extent / (n - paddingInner + 2 * paddingOuter + extraGapTotal), rawBandwidth = stepSize * (1 - paddingInner), wholeBandwidth = Math.round(rawBandwidth), bandwidth = Math.abs(rawBandwidth - wholeBandwidth) < 1e-9 ? wholeBandwidth : rawBandwidth, start = r0 + stepSize * paddingOuter, offsets = [], extraBefore = 0;
|
|
2436
|
+
for (let i = 0; i < n; i++)
|
|
2437
|
+
offsets[i] = extraBefore, extraBefore += extraGaps[i];
|
|
2438
|
+
return {
|
|
2439
|
+
position: (i) => start + stepSize * (i + (offsets[i] ?? extraBefore)),
|
|
2440
|
+
center: (i) => start + stepSize * (i + (offsets[i] ?? extraBefore)) + bandwidth / 2,
|
|
2441
|
+
bandwidth,
|
|
2442
|
+
step: stepSize,
|
|
2443
|
+
count: n,
|
|
2444
|
+
range: [r0, r1]
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
function niceBelow(v) {
|
|
2448
|
+
let out = [];
|
|
2449
|
+
for (let power = 10 ** Math.floor(Math.log10(v)), k = 0; k < 8; k++, power /= 10)
|
|
2450
|
+
for (let step of [5, 2.5, 2, 1]) step * power <= v * (1 + 1e-9) && out.push(step * power);
|
|
2451
|
+
return out;
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
// src/core/axis.ts
|
|
2455
|
+
function tickFormatter(spec, ticks) {
|
|
2456
|
+
if (spec.autoMagnitude) {
|
|
2457
|
+
let largest2 = Math.max(0, maxOf(ticks.filter(Number.isFinite).map(Math.abs))), magnitude = spec.magnitude;
|
|
2458
|
+
for (; magnitude !== "none" && largest2 < MAGNITUDE_DIVISOR[magnitude]; ) magnitude = magnitude === "t" ? "bn" : magnitude === "bn" ? "m" : magnitude === "m" ? "k" : "none";
|
|
2459
|
+
magnitude !== spec.magnitude && (spec = { ...spec, magnitude, ...magnitude === "none" ? { autoMagnitude: void 0, rollMagnitude: void 0 } : {} });
|
|
2460
|
+
}
|
|
2461
|
+
let divisor = MAGNITUDE_DIVISOR[spec.magnitude], scaled = ticks.map((tick) => tick / divisor).filter((tick) => Number.isFinite(tick) && (spec.magnitude === "none" || Math.abs(tick) < 1e3)), cap = decimalCap(scaled, spec.decimals), largest = Math.max(0, maxOf(scaled.map((tick) => Math.abs(tick)))), noise = largest > 0 && largest < 1 ? largest : 1, tickSpec = { ...spec, autoMagnitude: void 0, wholeFrom: void 0, decimals: Math.max(0, maxOf(scaled.map((tick) => neededDecimals(tick, cap, noise, spec.decimals)))) }, finite = ticks.filter((tick) => Number.isFinite(tick)), distinct = () => new Set(finite.map((tick) => formatWithSpec(tick, tickSpec))).size === new Set(finite).size;
|
|
2462
|
+
for (; tickSpec.decimals < 20 && !distinct(); )
|
|
2463
|
+
tickSpec.decimals++, tickSpec.decimals > AUTO_MAX_DECIMALS && (tickSpec.automatic = !1);
|
|
2464
|
+
let scientific = finite.some((tick) => tick !== 0 && formatWithSpec(tick, tickSpec).includes("\xD7"));
|
|
2465
|
+
return (value) => formatWithSpec(value, (spec.autoMagnitude || scientific) && value === 0 ? { ...tickSpec, magnitude: "none", decimals: 0 } : tickSpec);
|
|
2466
|
+
}
|
|
2467
|
+
function thinAxisTicks(ticks, scale, orient, format, font, measure, labelX, keepEnds = !1) {
|
|
2468
|
+
if (ticks.length <= 2) return [...ticks];
|
|
2469
|
+
let itemsFor = (values) => values.map((tick, index) => {
|
|
2470
|
+
let size = measure(format(tick), font), pos = scale(tick), extent = orient === "x" ? size.width : size.height, start = orient === "x" ? labelX(pos, size.width, index, values.length) : pos - size.height / 2, endpoint = index === 0 || index === values.length - 1;
|
|
2471
|
+
return {
|
|
2472
|
+
start,
|
|
2473
|
+
size: extent,
|
|
2474
|
+
priority: endpoint ? 2 : tick === 0 ? 1 : 0
|
|
2475
|
+
};
|
|
2476
|
+
});
|
|
2477
|
+
if (!scale.log && !scale.break && !keepEnds) {
|
|
2478
|
+
let step = ticks[1] - ticks[0], regular = ticks.every((tick, index) => index === 0 || Math.abs(tick - ticks[index - 1] - step) <= Math.abs(step) * 1e-9) ? [...ticks] : scale.ticks();
|
|
2479
|
+
if (regular.length <= 2) return regular;
|
|
2480
|
+
let baseStep = Math.abs(regular[1] - regular[0]), origin = regular[0] - Math.round(regular[0] / baseStep) * baseStep;
|
|
2481
|
+
for (let stride = 1; stride <= regular.length; stride++) {
|
|
2482
|
+
let kept = regular.filter((tick) => Math.abs((tick - origin) / (baseStep * stride) - Math.round((tick - origin) / (baseStep * stride))) < 1e-9);
|
|
2483
|
+
if (kept.length > 0 && sweepHide(itemsFor(kept), 2).every(Boolean)) return kept;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
let keep = sweepHide(itemsFor(ticks), 2);
|
|
2487
|
+
return ticks.filter((_, index) => keep[index]);
|
|
2488
|
+
}
|
|
2489
|
+
function inferLinearYDomain(geometry) {
|
|
2490
|
+
let ticks = geometry.axes.find((axis) => axis.axis === "y")?.ticks.filter((tick) => typeof tick.at == "number");
|
|
2491
|
+
if (!ticks || ticks.length < 2) return null;
|
|
2492
|
+
let a = ticks[0], b = ticks.find((tick) => tick.pos !== a.pos);
|
|
2493
|
+
if (!b) return null;
|
|
2494
|
+
let valueAt = (position) => a.at + (position - a.pos) * (b.at - a.at) / (b.pos - a.pos), roundDomain = (value) => Math.round(value * 1e9) / 1e9, bounds = [valueAt(geometry.plot.y), valueAt(geometry.plot.y + geometry.plot.h)].map(roundDomain);
|
|
2495
|
+
return [Math.min(bounds[0], bounds[1]), Math.max(bounds[0], bounds[1])];
|
|
2496
|
+
}
|
|
2497
|
+
var BREAK_HALF_SEPARATION = 2;
|
|
2498
|
+
function categoryBreakGlyph(theme, center, orient, idPrefix) {
|
|
2499
|
+
let glyph = straightBreakGlyph(theme, center, idPrefix, {}, { token: "axis" }, "categoryBreak"), half = BREAK_HALF_SEPARATION / Math.sin(orient === "x" ? Math.PI / 3 : Math.PI / 6), knockout = {
|
|
2500
|
+
t: "line",
|
|
2501
|
+
id: `${idPrefix}:gap`,
|
|
2502
|
+
...orient === "x" ? { x1: center.x - half, y1: center.y, x2: center.x + half, y2: center.y } : { x1: center.x, y1: center.y - half, x2: center.x, y2: center.y + half },
|
|
2503
|
+
stroke: { token: "background" },
|
|
2504
|
+
width: strokeToken(theme, "casing"),
|
|
2505
|
+
owner: {},
|
|
2506
|
+
part: "categoryBreak"
|
|
2507
|
+
};
|
|
2508
|
+
return { ...glyph, nodes: [knockout, ...glyph.nodes] };
|
|
2509
|
+
}
|
|
2510
|
+
function straightBreakGlyph(theme, center, idPrefix, owner, stroke = { token: "axis" }, part = "axisBreak") {
|
|
2511
|
+
let direction = { x: 0.5, y: -Math.sqrt(3) / 2 }, normal = { x: -direction.y, y: direction.x }, halfSeparation = BREAK_HALF_SEPARATION, nodes = [], xs = [], ys = [];
|
|
2512
|
+
for (let [index, side] of [-1, 1].entries()) {
|
|
2513
|
+
let cx = center.x + normal.x * halfSeparation * side, cy = center.y + normal.y * halfSeparation * side, x1 = cx - direction.x * 5, y1 = cy - direction.y * 5, x2 = cx + direction.x * 5, y2 = cy + direction.y * 5;
|
|
2514
|
+
xs.push(x1, x2), ys.push(y1, y2), nodes.push({
|
|
2515
|
+
t: "line",
|
|
2516
|
+
id: `${idPrefix}:${index + 1}`,
|
|
2517
|
+
x1,
|
|
2518
|
+
y1,
|
|
2519
|
+
x2,
|
|
2520
|
+
y2,
|
|
2521
|
+
stroke,
|
|
2522
|
+
width: strokeToken(theme, "rule"),
|
|
2523
|
+
owner,
|
|
2524
|
+
part
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
let pad = 1, minX = Math.min(...xs) - pad, minY = Math.min(...ys) - pad, rect = {
|
|
2528
|
+
x: minX,
|
|
2529
|
+
y: minY,
|
|
2530
|
+
w: Math.max(...xs) - minX + pad,
|
|
2531
|
+
h: Math.max(...ys) - minY + pad
|
|
2532
|
+
};
|
|
2533
|
+
return { nodes, nodeIds: nodes.map((node) => node.id), rect };
|
|
2534
|
+
}
|
|
2535
|
+
var BAR_CUT_SPAN = 12;
|
|
2536
|
+
function barBreakCut(mark, axis, position, idPrefix, owner) {
|
|
2537
|
+
let thickness = axis === "x" ? mark.h : mark.w, lean = Math.min(thickness * Math.tan(Math.PI / 6), BAR_CUT_SPAN) / thickness, reach = thickness / 2 + 2, [x1, y1, x2, y2] = axis === "x" ? [position - reach * lean, mark.y + mark.h / 2 + reach, position + reach * lean, mark.y + mark.h / 2 - reach] : [mark.x + mark.w / 2 - reach, position + reach * lean, mark.x + mark.w / 2 + reach, position - reach * lean], width = 2 * BREAK_HALF_SEPARATION, node = { t: "line", id: `${idPrefix}:cut`, x1, y1, x2, y2, stroke: { token: "background" }, width, owner, part: "barBreak" }, rect = {
|
|
2538
|
+
x: Math.min(x1, x2) - width / 2,
|
|
2539
|
+
y: Math.min(y1, y2) - width / 2,
|
|
2540
|
+
w: Math.abs(x2 - x1) + width,
|
|
2541
|
+
h: Math.abs(y2 - y1) + width
|
|
2542
|
+
};
|
|
2543
|
+
return { nodes: [node], nodeIds: [node.id], rect };
|
|
2544
|
+
}
|
|
2545
|
+
function withoutRepeatedAxisBreaks(geometry) {
|
|
2546
|
+
let centre = (node) => ({ x: (node.x1 + node.x2) / 2, y: (node.y1 + node.y2) / 2 }), panel = (node) => `${node.tx ?? 0},${node.ty ?? 0}`;
|
|
2547
|
+
if (!geometry.axes.some((axis) => axis.break !== void 0)) return;
|
|
2548
|
+
let cuts = geometry.scene.filter((node) => node.t === "line" && node.part === "barBreak");
|
|
2549
|
+
if (cuts.length === 0) return;
|
|
2550
|
+
let drop = /* @__PURE__ */ new Set();
|
|
2551
|
+
for (let node of geometry.scene) {
|
|
2552
|
+
if (node.t !== "line" || node.part !== "axisBreak") continue;
|
|
2553
|
+
let orient = /axis:([xy]):break:\d+$/.exec(node.id)?.[1];
|
|
2554
|
+
if (!orient) continue;
|
|
2555
|
+
let at = centre(node)[orient];
|
|
2556
|
+
cuts.some((cut) => panel(cut) === panel(node) && Math.abs(centre(cut)[orient] - at) <= 3) && drop.add(node.id);
|
|
2557
|
+
}
|
|
2558
|
+
if (drop.size !== 0) {
|
|
2559
|
+
geometry.scene = geometry.scene.filter((node) => !drop.has(node.id));
|
|
2560
|
+
for (let axis of geometry.axes)
|
|
2561
|
+
axis.break && (axis.break = { ...axis.break, nodeIds: axis.break.nodeIds.filter((id) => !drop.has(id)) });
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
function layoutValueAxis(input, occupied) {
|
|
2565
|
+
let { scale, plot, orient, theme, measure } = input, font = secondaryFont(theme), requestedTicks = input.ticks ?? scale.ticks(input.tickCount ?? 5), nodes = [], axis = { axis: orient === "y" ? "y" : "x", ticks: [] }, reserved = 0, seq = 0, formatTick = input.formatSpec ? tickFormatter(input.formatSpec, requestedTicks) : input.format, labelX = (pos, width, index, count) => {
|
|
2566
|
+
let centred = pos - width / 2;
|
|
2567
|
+
if (!(count > 1 && (index === 0 || index === count - 1))) return centred;
|
|
2568
|
+
let box = { x: centred, y: plot.y + plot.h + 6, w: width, h: font.size * (font.lineHeight ?? 1.2) };
|
|
2569
|
+
return centred >= 0 && centred + width <= (input.canvasWidth ?? 1 / 0) && occupied.hitsWhich(box, 0).length === 0 ? centred : tickLabelX(pos, width, index, count, !0);
|
|
2570
|
+
}, ticks = thinAxisTicks(requestedTicks, scale, orient, formatTick, font, measure, labelX, input.keepEndTicks === !0);
|
|
2571
|
+
for (let t of ticks) {
|
|
2572
|
+
let pos = scale(t), text = formatTick(t), tsize = measure(text, font), gridId = input.gridlines && t !== 0 ? `axis:${orient}:grid:${seq}` : void 0;
|
|
2573
|
+
if (orient === "y") {
|
|
2574
|
+
gridId && nodes.push({
|
|
2575
|
+
t: "line",
|
|
2576
|
+
id: gridId,
|
|
2577
|
+
x1: plot.x,
|
|
2578
|
+
y1: pos,
|
|
2579
|
+
x2: plot.x + plot.w,
|
|
2580
|
+
y2: pos,
|
|
2581
|
+
stroke: { token: "grid" },
|
|
2582
|
+
width: strokeToken(theme, "hair"),
|
|
2583
|
+
...gridDash(theme),
|
|
2584
|
+
owner: {},
|
|
2585
|
+
part: "gridline"
|
|
2586
|
+
});
|
|
2587
|
+
let labelRect = {
|
|
2588
|
+
x: plot.x - tsize.width - 8,
|
|
2589
|
+
y: pos - tsize.height / 2,
|
|
2590
|
+
w: tsize.width,
|
|
2591
|
+
h: tsize.height
|
|
2592
|
+
}, labelId = `axis:${orient}:tick:${seq}`;
|
|
2593
|
+
nodes.push({
|
|
2594
|
+
t: "text",
|
|
2595
|
+
id: labelId,
|
|
2596
|
+
x: labelRect.x,
|
|
2597
|
+
y: labelRect.y,
|
|
2598
|
+
lines: [text],
|
|
2599
|
+
align: "start",
|
|
2600
|
+
font,
|
|
2601
|
+
ink: { token: "inkMuted" },
|
|
2602
|
+
owner: {},
|
|
2603
|
+
part: "tick",
|
|
2604
|
+
typeRole: "secondary"
|
|
2605
|
+
}), occupied.claim(labelRect, "axis", {}), reserved = Math.max(reserved, tsize.width + 8), axis.ticks.push({ at: t, pos, labelId, gridNodeId: gridId });
|
|
2606
|
+
} else {
|
|
2607
|
+
gridId && nodes.push({
|
|
2608
|
+
t: "line",
|
|
2609
|
+
id: gridId,
|
|
2610
|
+
x1: pos,
|
|
2611
|
+
y1: plot.y,
|
|
2612
|
+
x2: pos,
|
|
2613
|
+
y2: plot.y + plot.h,
|
|
2614
|
+
stroke: { token: "grid" },
|
|
2615
|
+
width: strokeToken(theme, "hair"),
|
|
2616
|
+
...gridDash(theme),
|
|
2617
|
+
owner: {},
|
|
2618
|
+
part: "gridline"
|
|
2619
|
+
});
|
|
2620
|
+
let labelRect = {
|
|
2621
|
+
x: labelX(pos, tsize.width, seq, ticks.length),
|
|
2622
|
+
y: plot.y + plot.h + 6,
|
|
2623
|
+
w: tsize.width,
|
|
2624
|
+
h: tsize.height
|
|
2625
|
+
}, labelId = `axis:${orient}:tick:${seq}`;
|
|
2626
|
+
nodes.push({
|
|
2627
|
+
t: "text",
|
|
2628
|
+
id: labelId,
|
|
2629
|
+
x: labelRect.x,
|
|
2630
|
+
y: labelRect.y,
|
|
2631
|
+
lines: [text],
|
|
2632
|
+
align: "start",
|
|
2633
|
+
font,
|
|
2634
|
+
ink: { token: "inkMuted" },
|
|
2635
|
+
owner: {},
|
|
2636
|
+
part: "tick",
|
|
2637
|
+
typeRole: "secondary"
|
|
2638
|
+
}), occupied.claim(labelRect, "axis", {}), reserved = Math.max(reserved, tsize.height + 6), axis.ticks.push({ at: t, pos, labelId, gridNodeId: gridId });
|
|
2639
|
+
}
|
|
2640
|
+
seq++;
|
|
2641
|
+
}
|
|
2642
|
+
if (scale.break) {
|
|
2643
|
+
let center = orient === "y" ? { x: plot.x, y: scale.break.position } : { x: scale.break.position, y: plot.y + plot.h }, glyph = straightBreakGlyph(theme, center, `axis:${orient}:break`, {}, { token: "axis" });
|
|
2644
|
+
nodes.push(...glyph.nodes), occupied.claim(glyph.rect, "axis", {}, "axisBreak"), axis.break = { rect: glyph.rect, style: "straight", nodeIds: glyph.nodeIds };
|
|
2645
|
+
}
|
|
2646
|
+
return orient === "y" && reserved > 8 && (occupied.tickColumns ??= []).push({ x: plot.x - reserved, y: plot.y, w: reserved - 8, h: plot.h }), { nodes, axis, reserved };
|
|
2647
|
+
}
|
|
2648
|
+
var AXIS_TITLE_GAP = 4;
|
|
2649
|
+
function valueAxisTitleText(theme, authored, chrome, unit) {
|
|
2650
|
+
if (authored) return authored;
|
|
2651
|
+
if (theme.valueAxis?.titles !== !0) return;
|
|
2652
|
+
let subtitle = resolveSubtitle(chrome.subtitle), measureName = subtitle?.measure?.trim();
|
|
2653
|
+
if (!(!measureName || !unit) && !(unit === chrome.unit && unitPrinted({ subtitle, unit: chrome.unit, unitShown: chrome.unitShown })))
|
|
2654
|
+
return `${measureName}, ${unit}`;
|
|
2655
|
+
}
|
|
2656
|
+
function valueAxisUnit(chartUnit, dataSeries, shares) {
|
|
2657
|
+
if (shares) return "%";
|
|
2658
|
+
if (chartUnit) return chartUnit;
|
|
2659
|
+
let units = new Set(dataSeries.map((series) => series.unit));
|
|
2660
|
+
return units.size === 1 ? [...units][0] : void 0;
|
|
2661
|
+
}
|
|
2662
|
+
function axisTitleAllowed(labels) {
|
|
2663
|
+
return labels !== !1 && labels?.axisTitle !== !1;
|
|
2664
|
+
}
|
|
2665
|
+
function planValueAxisTitle(text, theme, measure, maxWidth, maxLines = 2) {
|
|
2666
|
+
if (!text) return;
|
|
2667
|
+
let font = secondaryFont(theme), wrapped = wrapText(text, font, Math.max(1, maxWidth), maxLines, measure), lines = wrapped.lines.length > 0 ? wrapped.lines : [text], sizes = lines.map((line) => measure(line, font));
|
|
2668
|
+
return {
|
|
2669
|
+
text,
|
|
2670
|
+
line: lines[0],
|
|
2671
|
+
lines,
|
|
2672
|
+
truncated: wrapped.truncated,
|
|
2673
|
+
font,
|
|
2674
|
+
width: Math.max(...sizes.map((size) => size.width)),
|
|
2675
|
+
height: sizes.reduce((sum, size) => sum + size.height, 0)
|
|
2676
|
+
};
|
|
2677
|
+
}
|
|
2678
|
+
function valueAxisTitleBand(title, theme, measure, rowsBelow = 0) {
|
|
2679
|
+
if (!title) return 0;
|
|
2680
|
+
let tickHalf = measure("0", secondaryFont(theme)).height / 2;
|
|
2681
|
+
return title.height + Math.max(0, tickHalf - rowsBelow);
|
|
2682
|
+
}
|
|
2683
|
+
function valueAxisTitleRequest(title, at, align, id) {
|
|
2684
|
+
let rect = { x: align === "end" ? at.x - title.width : at.x, y: at.y, w: title.width, h: title.height };
|
|
2685
|
+
return {
|
|
2686
|
+
id,
|
|
2687
|
+
kind: "axisTitle",
|
|
2688
|
+
typeRole: "secondary",
|
|
2689
|
+
owner: {},
|
|
2690
|
+
text: title.text,
|
|
2691
|
+
lines: title.lines,
|
|
2692
|
+
font: title.font,
|
|
2693
|
+
fontStep: title.font,
|
|
2694
|
+
priority: PRIORITY.grandTotal,
|
|
2695
|
+
...title.truncated ? { title: title.text } : {},
|
|
2696
|
+
candidates: [{ slot: "axisTitle", rect, penalty: 0 }]
|
|
2697
|
+
};
|
|
2698
|
+
}
|
|
2699
|
+
var TICK_ROW_TITLE_GAP = 12;
|
|
2700
|
+
function tickRowTitleEnd(title, axis, left) {
|
|
2701
|
+
if (title.lines.length > 1) return;
|
|
2702
|
+
let font = secondaryFont(axis.theme), labels = layoutValueAxis(axis, createOccupiedIndex({ x: 0, y: 0, w: Number.MAX_VALUE, h: Number.MAX_VALUE })).nodes.flatMap((node) => node.t === "text" && node.part === "tick" ? [{ x: node.x, w: axis.measure(node.lines[0] ?? "", font).width }] : []), end = axis.plot.x + axis.plot.w, lastRight = Math.max(-1 / 0, maxOf(labels.map((label) => label.x + label.w)));
|
|
2703
|
+
if (end - title.width >= lastRight + TICK_ROW_TITLE_GAP) return end;
|
|
2704
|
+
let firstLeft = Math.min(end, minOf(labels.map((label) => label.x))) - TICK_ROW_TITLE_GAP;
|
|
2705
|
+
return firstLeft - title.width >= left ? firstLeft : void 0;
|
|
2706
|
+
}
|
|
2707
|
+
var VALUE_AXIS_TITLE_IDS = /* @__PURE__ */ new Set(["axis:y:title", "axis:x:title"]);
|
|
2708
|
+
function applyValueAxisTitleInk(labels) {
|
|
2709
|
+
for (let label of labels) label.kind === "axisTitle" && VALUE_AXIS_TITLE_IDS.has(label.id) && (label.ink = { token: "inkMuted" });
|
|
2710
|
+
}
|
|
2711
|
+
function measureValueAxisWidth(domain, format, theme, measure, tickCount = 5, formatSpec, explicitTicks) {
|
|
2712
|
+
let font = secondaryFont(theme), ticks = explicitTicks ? [...explicitTicks] : linearScale(domain, [0, 1]).ticks(tickCount), fmt = formatSpec ? tickFormatter(formatSpec, ticks) : format, values = explicitTicks ? ticks : [...ticks, ...domain];
|
|
2713
|
+
return maxOf(values.map((value) => measure(fmt(value), font).width)) + 8;
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
// src/core/themeGeometry.ts
|
|
2717
|
+
function themeGeometryTokens(theme, target) {
|
|
2718
|
+
return {
|
|
2719
|
+
...target === void 0 ? {} : { target },
|
|
2720
|
+
scenario: theme.scenario,
|
|
2721
|
+
pattern: { ...theme.pattern, hatchColor: theme.pattern.hatchColor ?? "segment" },
|
|
2722
|
+
stroke: theme.stroke,
|
|
2723
|
+
dash: theme.dash,
|
|
2724
|
+
type: theme.type,
|
|
2725
|
+
space: theme.space,
|
|
2726
|
+
surface: theme.surface,
|
|
2727
|
+
// Label ink and the grid dash are baked into the scene, so a switch relayouts as their siblings do.
|
|
2728
|
+
labels: theme.labels,
|
|
2729
|
+
valueAxis: theme.valueAxis,
|
|
2730
|
+
// The outline and edge switches are recomputed by a repaint (repaintSeparation, decideFillEdges);
|
|
2731
|
+
// every other mark key (marker, radius, tint, caret, bar label side) is baked into the layout.
|
|
2732
|
+
marks: theme.marks && (({ restOutline: _r, sliceOutline: _s, othersOutline: _o, contrastEdge: _c, ...rest }) => rest)(theme.marks),
|
|
2733
|
+
// Table sizes, pads, weights, rules and glyphs are geometry; its inks, rule ink and bar grounds are colour.
|
|
2734
|
+
table: theme.table && (({ inks: _inks, ruleInk: _ruleInk, bar: _bar, ...rest }) => rest)(theme.table),
|
|
2735
|
+
legend: theme.legend?.auto ?? !1,
|
|
2736
|
+
seriesOverflow: theme.color.seriesOverflow ?? "repeatLast",
|
|
2737
|
+
seriesCount: theme.color.series.length
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
function presentationInfo(geometry, target, inheritedClass, textScale = 1) {
|
|
2741
|
+
let floors = targetFloorsPx(target), minimumScale = 0.9;
|
|
2742
|
+
for (let node of geometry.scene) {
|
|
2743
|
+
if (node.t !== "text" || node.lines.every((line) => line.length === 0) || node.opacity === 0) continue;
|
|
2744
|
+
let tableHead = TABLE_HEAD_PARTS.has(node.part ?? "");
|
|
2745
|
+
minimumScale = Math.max(minimumScale, (tableHead ? tableHeadFloorPx(target) : floors[node.typeRole ?? "label"]) / node.font.size);
|
|
2746
|
+
}
|
|
2747
|
+
return {
|
|
2748
|
+
target,
|
|
2749
|
+
typeClass: geometry.type === "kpi" || geometry.type === "bullet" ? "M" : inheritedClass ?? typeWidthClass(geometry.size.width),
|
|
2750
|
+
naturalSize: naturalOutputSize(target, geometry.size),
|
|
2751
|
+
minDisplayWidth: geometry.size.width * minimumScale,
|
|
2752
|
+
...textScale === 1 ? {} : { textScale }
|
|
2753
|
+
};
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
// src/core/calendarData.ts
|
|
2757
|
+
function withCalendarLabels(data, language, label) {
|
|
2758
|
+
let categories = data?.categories;
|
|
2759
|
+
if (!Array.isArray(categories)) return data;
|
|
2760
|
+
let labelled = label(categories, language);
|
|
2761
|
+
return labelled ? { ...data, categories: labelled } : data;
|
|
2762
|
+
}
|
|
2763
|
+
function noteName(category) {
|
|
2764
|
+
return category.calendar?.named ?? category.label ?? category.id;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
// src/core/registry.ts
|
|
2768
|
+
function estimatedPlotAdvice(result, options) {
|
|
2769
|
+
let warning = result.warnings.find((w) => w.code === "plot-under-floor");
|
|
2770
|
+
if (!warning || isRefused(result) || result.refused) return;
|
|
2771
|
+
let height = Math.ceil(plotRepairHeight(result, options?.target ?? DEFAULT_TARGET) * 1.25), { fix: _fix, ...rest } = warning;
|
|
2772
|
+
result.warnings = result.warnings.map((w) => w === warning ? {
|
|
2773
|
+
...rest,
|
|
2774
|
+
message: `${rest.message.replace(/; (?:the chart needs|the estimated height is) .*$/, "")}; the estimated height is ${height} px; use measure for the exact verified size`,
|
|
2775
|
+
suggest: "Use measure for the exact verified size, or leave options.size.height out.",
|
|
2776
|
+
fix: [{ op: "replace", path: "/options/size", value: { width: result.size.width, height } }]
|
|
2777
|
+
} : w);
|
|
2778
|
+
}
|
|
2779
|
+
var registry = /* @__PURE__ */ new Map(), aliasIndex = /* @__PURE__ */ new Map(), schemaIndex = /* @__PURE__ */ new Map(), schemaAliasIndex = /* @__PURE__ */ new Map();
|
|
2780
|
+
function isDefinition(chart) {
|
|
2781
|
+
return typeof chart.normalize == "function" && chart.dataSchema !== void 0 && chart.optionsSchema !== void 0;
|
|
2782
|
+
}
|
|
2783
|
+
function registerChart(def) {
|
|
2784
|
+
let existing = registry.get(def.type), incomingIsDefinition = isDefinition(def);
|
|
2785
|
+
if (existing && isDefinition(existing)) {
|
|
2786
|
+
if (!incomingIsDefinition) return;
|
|
2787
|
+
throw new Error(`chart type '${def.type}' already registered`);
|
|
2788
|
+
}
|
|
2789
|
+
if (existing && !incomingIsDefinition) return;
|
|
2790
|
+
let typeAliasOwner = aliasIndex.get(def.type);
|
|
2791
|
+
if (typeAliasOwner && typeAliasOwner !== def.type)
|
|
2792
|
+
throw new Error(`chart type '${def.type}' conflicts with alias owned by '${typeAliasOwner}'`);
|
|
2793
|
+
let aliases = def.aliases ?? [], aliasesInDefinition = /* @__PURE__ */ new Set();
|
|
2794
|
+
for (let alias of aliases) {
|
|
2795
|
+
if (alias === def.type)
|
|
2796
|
+
throw new Error(`chart alias '${alias}' duplicates its own chart type`);
|
|
2797
|
+
if (aliasesInDefinition.has(alias))
|
|
2798
|
+
throw new Error(`chart alias '${alias}' is declared more than once on '${def.type}'`);
|
|
2799
|
+
if (aliasesInDefinition.add(alias), registry.has(alias) && alias !== def.type)
|
|
2800
|
+
throw new Error(`chart alias '${alias}' conflicts with registered chart type '${alias}'`);
|
|
2801
|
+
let aliasOwner = aliasIndex.get(alias);
|
|
2802
|
+
if (aliasOwner && aliasOwner !== def.type)
|
|
2803
|
+
throw new Error(`chart alias '${alias}' is already owned by '${aliasOwner}'`);
|
|
2804
|
+
}
|
|
2805
|
+
let sizing = def.sizing ?? chartSizing(def.type), supported = new Set(def.annotationKinds), prepareLayout = (data, authored) => {
|
|
2806
|
+
let annotations = prepareFractionAnnotations(authored?.annotations);
|
|
2807
|
+
annotations !== authored?.annotations && (authored = { ...authored, annotations });
|
|
2808
|
+
let target = authored?.target ?? DEFAULT_TARGET, removedNames = authored?.[REMOVED_NAMES] ?? removedNameWarnings(authored), textScale = textScaleOf(authored), textSize = textSizeOf(authored), theme = resolveTargetTheme(authored?.theme, target, textScale, textSize), ref = authored?.theme, localized = withNumberMarks(withLocaleStrings(footnoteSwitch(resolveCanvasOptions({
|
|
2809
|
+
...authored,
|
|
2810
|
+
target,
|
|
2811
|
+
theme: { preset: typeof ref == "string" ? ref : ref?.preset ?? "boardroom", overrides: theme }
|
|
2812
|
+
})))), prepared = def.defaultStrings ? withChartDefaultStrings(localized, def.defaultStrings(localized)) : localized;
|
|
2813
|
+
def.type === "grid" && (data = inheritGridTarget(data, target, textScale, textSize)), def.categoryLabels && (data = withCalendarLabels(data, authored?.locale?.language, def.categoryLabels));
|
|
2814
|
+
let origins = /* @__PURE__ */ new WeakMap(), legendLayout = prepareLegendLayout(def, data, origins), noteLayouts = /* @__PURE__ */ new WeakMap(), noteRuns = [], layoutBody = ((options) => {
|
|
2815
|
+
let sizeTarget = options?.size === void 0 && ["kpi", "bullet", "sparkline"].includes(def.type) && (target === "slide" || target === "print") ? "report" : target, resolved = panelTypeClass(prepared) !== void 0 && options?.size !== void 0 ? { sizePx: resolveSize(options.size, target), fixed: { width: !0, height: !0 } } : resolveTargetSize(sizeTarget, options?.size), frame = options, current = { ...prepared };
|
|
2816
|
+
for (let key of ["size", "mode", "belowMinimum", FORCE_COMPACT, WIDTH_PROBE, FIXED_SIZE_PROBE])
|
|
2817
|
+
frame && Object.hasOwn(frame, key) ? current[key] = frame[key] : delete current[key];
|
|
2818
|
+
options = {
|
|
2819
|
+
...current,
|
|
2820
|
+
size: resolved.fixed.height ? resolved.sizePx : { width: resolved.sizePx.width },
|
|
2821
|
+
[TARGET_SIZE]: resolved
|
|
2822
|
+
};
|
|
2823
|
+
let densityFixed = DENSITY_VALUES in options && resolved.fixed.height;
|
|
2824
|
+
densityFixed && (options = { ...options, [FIXED_SIZE_PROBE]: !0 });
|
|
2825
|
+
let anns = options?.annotations, dropped = anns?.filter((a) => !supported.has(a.kind)) ?? [], layoutOptions = dropped.length === 0 ? options : { ...options, annotations: anns.filter((a) => supported.has(a.kind)) }, pins = options?.labelPlacements, minimal = options?.labelDensity === "minimal", nested = panelTypeClass(options) !== void 0, lastGeometry, named = (runOptions, probeHeight = !0) => {
|
|
2826
|
+
let geo2 = legendLayout(runOptions);
|
|
2827
|
+
if (geo2.refused || nested) return { geo: geo2, noteRefused: !1 };
|
|
2828
|
+
lastGeometry = geo2;
|
|
2829
|
+
let first = geo2, noted = /* @__PURE__ */ new Map(), owed = owedHiddenLabels(geo2, data, pins, options?.annotations, minimal), previousOwed;
|
|
2830
|
+
for (let run = 0; owed.size > 0; run++) {
|
|
2831
|
+
let owedKey = [...owed.keys()].sort().join("\0"), stalled = owedKey === previousOwed && [...owed.keys()].every((id) => noted.has(id));
|
|
2832
|
+
if (previousOwed = owedKey, stalled || run === first.labels.length + 1) {
|
|
2833
|
+
let refusal = hiddenLabelRefusal(def.title, first, geo2), size = { width: refusal.sizing.minWidth, height: refusal.sizing.minHeight }, probe = probeHeight ? named(withoutForcedCompact({ ...runOptions, size }), !1).geo : void 0, names = /* @__PURE__ */ new Set([...noted.keys(), ...owed.keys()]), lost = probe && !probe.refused ? owedHiddenLabels({ ...probe, labels: probe.labels.map(({ noted: _noted, ...label }) => label) }, data, pins, options?.annotations, minimal) : void 0;
|
|
2834
|
+
if (probe && !probe.refused && !isRefused(probe) && ![...names].some((id) => lost.has(id)))
|
|
2835
|
+
return { geo: refusal, noteRefused: !0 };
|
|
2836
|
+
if (probeHeight) {
|
|
2837
|
+
let height = size.height;
|
|
2838
|
+
for (let step = 0; step < 3; step++) {
|
|
2839
|
+
height = Math.ceil(height * 1.25);
|
|
2840
|
+
let taller = named(withoutForcedCompact({ ...runOptions, size: { width: size.width, height } }), !1).geo;
|
|
2841
|
+
if (taller.refused || isRefused(taller)) continue;
|
|
2842
|
+
let missing = owedHiddenLabels({ ...taller, labels: taller.labels.map(({ noted: _noted, ...label }) => label) }, data, pins, options?.annotations, minimal), pageNotes = [...taller.frame?.notes ?? [], ...(taller.frame?.noteList ?? []).map((entry) => entry.text)];
|
|
2843
|
+
if ([...names].some((id) => missing.has(id) && !taller.labels.some((label) => label.id === id && label.noted && pageNotes.some((note) => note.includes(label.text) || label.noteCounted === !0 && note.length > 0)))) continue;
|
|
2844
|
+
let grown = sizeRefusal(def.type, def.title, refusal.size, { ...refusal.sizing, minHeight: height, measuredMinHeight: Math.min(refusal.sizing.measuredMinHeight, height) });
|
|
2845
|
+
return grown.warnings[0].message += "; at this size it hides labels its note line has no room to name", { geo: grown, noteRefused: !0 };
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
return geo2.sizing && geo2.sizing.minWidth > geo2.size.width + SIZE_TOLERANCE ? { geo: sizeRefusal(def.type, def.title, geo2.size, geo2.sizing), noteRefused: !0 } : { geo: hiddenLabelCollision(def.title, geo2, owed, [...owed.keys()].every((id) => noted.has(id))), noteRefused: !0 };
|
|
2849
|
+
}
|
|
2850
|
+
let byData = dataOrder(data, geo2.labels), merged = [...noted, ...owed].sort(([a], [b]) => byData(a, b));
|
|
2851
|
+
noted.clear();
|
|
2852
|
+
for (let [id, item] of merged) noted.set(id, item);
|
|
2853
|
+
let noteOptions = withHiddenLabelNote(runOptions ?? {}, noted, { data, labels: geo2.labels, annotations: options?.annotations }), next;
|
|
2854
|
+
if (def.type === "gantt") next = layoutWithLegendPolicy(def, data, noteOptions);
|
|
2855
|
+
else {
|
|
2856
|
+
let origin = origins.get(geo2) ?? geo2, variants = noteLayouts.get(origin);
|
|
2857
|
+
variants || noteLayouts.set(origin, variants = /* @__PURE__ */ new Map());
|
|
2858
|
+
let noteKey = JSON.stringify([...noted]), noteRun = variants.get(noteKey);
|
|
2859
|
+
noteRun || (noteRun = prepareLegendLayout(def, data, origins), variants.set(noteKey, noteRun), noteRuns.push(noteRun)), next = noteRun(noteOptions);
|
|
2860
|
+
}
|
|
2861
|
+
let moved = !staticFrame.pinned && (geo2.mode === "compact" || !resolved.fixed.height) && next.refused && next.warnings[0]?.code === "size-below-floor" ? withNoteInA11y(noteOptions) : void 0, movedLine = moved ? hiddenNoteLine(noteOptions) : void 0, inA11y = moved && movedLine ? { ...moved, footnotes: authoredNotes(moved).filter((note) => note !== movedLine) } : moved;
|
|
2862
|
+
if (inA11y) {
|
|
2863
|
+
let quiet = layoutWithLegendPolicy(def, data, inA11y);
|
|
2864
|
+
quiet.refused || (next = quiet);
|
|
2865
|
+
}
|
|
2866
|
+
if (!staticFrame.pinned && next.refused && resolved.fixed.height && [...noted.keys()].every((id) => first.labels.some((label) => label.id === id && label.hidden === "density")))
|
|
2867
|
+
return { geo: densityNoteInList(first, noteOptions, new Set(noted.keys())), noteRefused: !1 };
|
|
2868
|
+
if (next.refused) return { geo: next, noteRefused: !0 };
|
|
2869
|
+
markNotedLabels(next, new Set(noted.keys()), noteOptions), geo2 = next, lastGeometry = geo2, owed = owedHiddenLabels(geo2, data, pins, options?.annotations, minimal);
|
|
2870
|
+
}
|
|
2871
|
+
let freed = new Set(geo2.labels.filter((label) => label.hidden === "note").map((label) => label.id));
|
|
2872
|
+
if (freed.size > 0) {
|
|
2873
|
+
let kept = new Map([...noted].filter(([id]) => !freed.has(id))), keptOptions = withHiddenLabelNote(runOptions ?? {}, kept, { data, labels: geo2.labels, annotations: options?.annotations }), retry = layoutWithLegendPolicy(def, data, keptOptions);
|
|
2874
|
+
retry.refused || (markNotedLabels(retry, new Set(kept.keys()), keptOptions), owedHiddenLabels(retry, data, pins, options?.annotations, minimal).size === 0 && !retry.labels.some((label) => label.hidden === "note") && (geo2 = retry, lastGeometry = geo2));
|
|
2875
|
+
}
|
|
2876
|
+
return { geo: geo2, noteRefused: !1 };
|
|
2877
|
+
}, sClassMinimum = (minimum, size) => {
|
|
2878
|
+
if (nested || isWidthProbe(def.type, options) || minimum.aspect !== "content" || size.width < 720 || minimum.minWidth >= 720) return minimum;
|
|
2879
|
+
let at = Math.ceil(minimum.minWidth), probe;
|
|
2880
|
+
try {
|
|
2881
|
+
probe = legendLayout(withoutForcedCompact({
|
|
2882
|
+
...layoutOptions,
|
|
2883
|
+
[FIXED_SIZE_PROBE]: !0,
|
|
2884
|
+
...def.type === "gantt" && !resolved.fixed.height ? { [ACCEPTANCE_PROBE]: !0 } : {},
|
|
2885
|
+
size: resolved.fixed.height ? { width: at, height: Math.max(size.height, minimum.minHeight) } : { width: at }
|
|
2886
|
+
}));
|
|
2887
|
+
} catch (error) {
|
|
2888
|
+
if (error instanceof NormalizeError) return minimum;
|
|
2889
|
+
throw error;
|
|
2890
|
+
}
|
|
2891
|
+
return probe.refused && probe.warnings[0]?.code === "size-below-floor" && probe.sizing && probe.sizing.minWidth > minimum.minWidth ? { ...minimum, minWidth: Math.min(720, probe.sizing.minWidth) } : minimum;
|
|
2892
|
+
}, geo = named(layoutOptions).geo;
|
|
2893
|
+
if (geo.refused) {
|
|
2894
|
+
if (densityFixed || isWidthProbe(def.type, options) || options[FIXED_SIZE_PROBE] === !0 || compactReplacesRefusal(def, options, data)) return geo;
|
|
2895
|
+
if (!nested && geo.warnings[0]?.code === "size-below-floor") {
|
|
2896
|
+
let floor = geo.sizing, compactCall = compactFallbackApplies(def, options, data) && (options[FORCE_COMPACT] === !0 || !fitsSize(resolved.sizePx, declaredSizing(def, options))), hostView = (runOptions, probeHeight) => {
|
|
2897
|
+
let size = runOptions?.size;
|
|
2898
|
+
if (!compactCall || !fitsSize(size, declaredSizing(def, options))) return named(withoutForcedCompact(runOptions), probeHeight).geo;
|
|
2899
|
+
let compact = named({ ...runOptions, [FORCE_COMPACT]: !0 }, probeHeight).geo;
|
|
2900
|
+
if (!isRefused(compact)) return compact;
|
|
2901
|
+
let full = named(withoutForcedCompact(runOptions), probeHeight).geo;
|
|
2902
|
+
return isRefused(full) && compact.warnings[0]?.code === "size-below-floor" ? compact : full;
|
|
2903
|
+
}, probeAt = (width, height) => hostView({ ...layoutOptions, size: { width, height } });
|
|
2904
|
+
for (let pass = 0; pass < 6; pass++) {
|
|
2905
|
+
let width = Math.max(geo.size.width, floor.minWidth), probe = probeAt(width, Math.max(geo.size.height, floor.minHeight));
|
|
2906
|
+
if (!isRefused(probe) && floor.minHeight <= geo.size.height) return sizeRefusal(def.type, def.title, geo.size, sClassMinimum(floor, geo.size));
|
|
2907
|
+
if (!isRefused(probe)) {
|
|
2908
|
+
let low = geo.size.height, high = floor.minHeight, accepts = (height) => !isRefused(hostView({
|
|
2909
|
+
...layoutOptions,
|
|
2910
|
+
size: { width, height },
|
|
2911
|
+
[FIXED_SIZE_PROBE]: def.type !== "gantt",
|
|
2912
|
+
[ACCEPTANCE_PROBE]: !0
|
|
2913
|
+
}, def.type === "gantt"));
|
|
2914
|
+
for (!resolved.fixed.height && accepts(low + 1) && (high = low + 1); high - low > 1; ) {
|
|
2915
|
+
let mid = Math.floor((low + high) / 2);
|
|
2916
|
+
accepts(mid) ? high = mid : low = mid;
|
|
2917
|
+
}
|
|
2918
|
+
return sizeRefusal(def.type, def.title, geo.size, sClassMinimum({ ...floor, minHeight: high, measuredMinHeight: Math.min(floor.measuredMinHeight, high) }, geo.size));
|
|
2919
|
+
}
|
|
2920
|
+
if (probe.warnings.some((w) => w.severity === "error" && w.code !== "size-below-floor")) {
|
|
2921
|
+
if (!resolved.fixed.height && pass < 2) {
|
|
2922
|
+
floor = { ...floor, minHeight: Math.ceil(floor.minHeight * 1.25) };
|
|
2923
|
+
continue;
|
|
2924
|
+
}
|
|
2925
|
+
return { ...geo, warnings: [...chartRefusals(probe.warnings), ...probe.warnings.filter((w) => w.severity !== "error")] };
|
|
2926
|
+
}
|
|
2927
|
+
let next = probe.sizing;
|
|
2928
|
+
if (next.minWidth <= floor.minWidth && next.minHeight <= floor.minHeight) break;
|
|
2929
|
+
floor = { ...next, minWidth: Math.max(floor.minWidth, next.minWidth), minHeight: Math.max(floor.minHeight, next.minHeight) };
|
|
2930
|
+
}
|
|
2931
|
+
return lastGeometry ? { ...hiddenLabelCollision(
|
|
2932
|
+
def.title,
|
|
2933
|
+
lastGeometry,
|
|
2934
|
+
owedHiddenLabels(lastGeometry, data, pins, options?.annotations, minimal)
|
|
2935
|
+
), size: geo.size } : { ...geo, warnings: [{
|
|
2936
|
+
code: "label-collision",
|
|
2937
|
+
severity: "error",
|
|
2938
|
+
message: "The frame blocks the layout; no repair size passed the layout probe.",
|
|
2939
|
+
suggest: "Shorten or move the colliding labels, or remove the conflicting annotation."
|
|
2940
|
+
}] };
|
|
2941
|
+
}
|
|
2942
|
+
return geo;
|
|
2943
|
+
}
|
|
2944
|
+
let natural = geo.sizing?.naturalHeight;
|
|
2945
|
+
if (!nested && layoutOptions?.annotations?.length && geo.sizing?.fit === "content" && natural !== void 0 && natural < geo.size.height) {
|
|
2946
|
+
let probe = named(withoutForcedCompact({ ...layoutOptions, size: { width: geo.size.width, height: natural } })), need = probe.geo.refused ? probe.geo.sizing : void 0;
|
|
2947
|
+
probe.noteRefused && probe.geo.warnings[0]?.code === "size-below-floor" && need && need.minWidth <= geo.size.width && need.minHeight > natural && (geo.sizing = { ...geo.sizing, naturalHeight: need.minHeight });
|
|
2948
|
+
}
|
|
2949
|
+
geo.sizing && (geo.sizing = sClassMinimum(geo.sizing, geo.size)), fillEdges(geo, theme), geo.scene = groundEdges(geo.scene, () => theme, !1), labelsOnFills(geo), referenceLineClearance(geo), withoutOrphanAnnotationMarks(geo), withoutRepeatedAxisBreaks(geo), geo.scene = casingUnderFills(geo.scene), geo.scene = stampHatchLook(geo.scene, options?.hatchStrength);
|
|
2950
|
+
let bandPairs = marksOnBands(geo.scene);
|
|
2951
|
+
bandPairs.length > 0 && (geo.paintWarningRules = [...geo.paintWarningRules ?? [], { kind: "mark-lost-on-band", pairs: bandPairs, before: geo.warnings.length }], pushAll(geo.warnings, markLostOnBandWarnings(theme, bandPairs))), options?.a11y?.title !== void 0 && (geo.a11y.includeTitle = options.a11y.title);
|
|
2952
|
+
let frameWarnings = geo.frame.warnings ?? [];
|
|
2953
|
+
for (let warning of frameWarnings)
|
|
2954
|
+
geo.warnings.includes(warning) || geo.warnings.push(warning);
|
|
2955
|
+
frameWarnings.length > 0 && delete geo.frame.warnings;
|
|
2956
|
+
for (let a of dropped)
|
|
2957
|
+
geo.warnings.push({
|
|
2958
|
+
code: "unsupported-annotation",
|
|
2959
|
+
severity: "warn",
|
|
2960
|
+
message: `'${def.type}' does not support annotation kind '${a.kind}' \u2014 dropped`,
|
|
2961
|
+
suggest: def.annotationKinds.join(", ") || "none"
|
|
2962
|
+
});
|
|
2963
|
+
let empty = noPlottedValuesWarning(data);
|
|
2964
|
+
empty && geo.warnings.push(empty);
|
|
2965
|
+
let categoryCuts = new Set(geo.warnings.filter((w) => w.code === "category-labels-truncated").flatMap((w) => Array.isArray(w.detail?.cut) ? w.detail.cut : [])), truncated = geo.labels.filter((label) => !label.hidden && label.title !== void 0 && !(label.kind === "category" && categoryCuts.has(label.title)));
|
|
2966
|
+
return geo.warnings = geo.warnings.filter((warning) => warning.code !== "labels-truncated"), truncated.length > 0 && geo.warnings.push({
|
|
2967
|
+
code: "labels-truncated",
|
|
2968
|
+
severity: "warn",
|
|
2969
|
+
message: `${truncated.length} placed label(s) omit text; the reading lists their full text in labelsTruncated`,
|
|
2970
|
+
suggest: "give the labels more room or shorten their text"
|
|
2971
|
+
}), pushAll(geo.warnings, unmatchedIdWarnings(geo, data, options?.highlight, pins, nested)), geo.presentation = presentationInfo(geo, target, panelTypeClass(options), textScale), pushAll(geo.warnings, removedNames), geo;
|
|
2972
|
+
}), layout2 = ((options) => withSmallValues(prepared.smallValues, () => layoutBody(options)));
|
|
2973
|
+
return layout2.finish = () => {
|
|
2974
|
+
legendLayout.finish();
|
|
2975
|
+
for (let run of noteRuns) run.finish();
|
|
2976
|
+
noteRuns.length = 0, noteLayouts = /* @__PURE__ */ new WeakMap();
|
|
2977
|
+
}, layout2;
|
|
2978
|
+
}, lostCategoryNames = (geo) => geo.refused ? [] : geo.labels.filter((label) => label.kind === "category" && !!label.hidden && label.hidden !== "redundant" && label.hidden !== "density"), widerForNames = (full, options, layoutOnce) => {
|
|
2979
|
+
if (options?.[FIXED_SIZE_PROBE]) return;
|
|
2980
|
+
let height = options?.size?.height === void 0 ? void 0 : full.size.height, width = full.size.width;
|
|
2981
|
+
for (let step = 0; step < 3; step++) {
|
|
2982
|
+
width = Math.ceil(width * 1.15);
|
|
2983
|
+
let wider = layoutOnce({ ...options, size: height === void 0 ? { width } : { width, height } });
|
|
2984
|
+
if (!(isRefused(wider) || lostCategoryNames(wider).length > 0))
|
|
2985
|
+
return sizeRefusal(def.type, def.title, full.size, { ...full.sizing, minWidth: width, minHeight: Math.max(full.sizing.minHeight, wider.size.height) });
|
|
2986
|
+
}
|
|
2987
|
+
}, fullProbe = (options, layoutOnce) => {
|
|
2988
|
+
let full = layoutOnce(options);
|
|
2989
|
+
if (def.namesMustPrint !== !0 || full.refused || full.mode === "compact") return full;
|
|
2990
|
+
let lost = lostCategoryNames(full);
|
|
2991
|
+
return lost.length === 0 ? full : widerForNames(full, options, layoutOnce) ?? hiddenLabelCollision(
|
|
2992
|
+
def.title,
|
|
2993
|
+
full,
|
|
2994
|
+
new Map(lost.map((label) => [label.id, label.text]))
|
|
2995
|
+
);
|
|
2996
|
+
}, layoutFitted = (data, options, layoutOnce) => {
|
|
2997
|
+
let full = layoutOnce(options), lostNames = (geo) => geo.refused ? [] : geo.labels.filter((label) => label.kind === "category" && !!label.hidden && label.hidden !== "redundant" && label.hidden !== "density");
|
|
2998
|
+
if (def.namesMustPrint === !0 && !full.refused && full.mode !== "compact" && lostNames(full).length > 0) {
|
|
2999
|
+
let compact2 = compactFallbackApplies(def, options, data) ? layoutOnce({ ...options, [FORCE_COMPACT]: !0 }) : full;
|
|
3000
|
+
if (compact2 !== full && !isRefused(compact2) && lostNames(compact2).length === 0) return compact2;
|
|
3001
|
+
let wider = widerForNames(full, options, layoutOnce);
|
|
3002
|
+
return wider || hiddenLabelCollision(def.title, full, new Map(lostNames(full).map((label) => [label.id, label.text])));
|
|
3003
|
+
}
|
|
3004
|
+
if (!full.refused || full.warnings[0]?.code !== "size-below-floor") return full;
|
|
3005
|
+
if (staticFrame.pinned && staticFrame.countable && options?.notes?.maxListed !== 0) {
|
|
3006
|
+
let counted = { ...options, notes: { ...options?.notes, maxListed: 0 } }, run = prepareLayout(data, counted);
|
|
3007
|
+
try {
|
|
3008
|
+
let fitted = layoutFitted(data, counted, run);
|
|
3009
|
+
if (!fitted.refused || fitted.warnings[0]?.code === "size-below-floor") return fitted;
|
|
3010
|
+
} finally {
|
|
3011
|
+
run.finish();
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
if (!compactFallbackApplies(def, options, data)) return full;
|
|
3015
|
+
let requested = resolveTargetSize(options?.target ?? DEFAULT_TARGET, options?.size);
|
|
3016
|
+
if (requested.fixed.height && !fitsSize(requested.sizePx, declaredSizing(def, options))) return full;
|
|
3017
|
+
let compact = layoutOnce({ ...options, [FORCE_COMPACT]: !0 });
|
|
3018
|
+
return !isRefused(compact) || compact.warnings[0]?.code === "size-below-floor" ? compact : full;
|
|
3019
|
+
}, layoutBaseline = (data, options, layoutOnce, probe = !1) => {
|
|
3020
|
+
let geo = probe && !compactFallbackApplies(def, options, data) ? fullProbe(options, layoutOnce) : layoutFitted(data, options, layoutOnce);
|
|
3021
|
+
if (!geo.refused) return geo;
|
|
3022
|
+
let removed = options?.[REMOVED_NAMES] ?? removedNameWarnings(options);
|
|
3023
|
+
return removed.length ? { ...geo, warnings: [...geo.warnings, ...removed] } : geo;
|
|
3024
|
+
}, layoutPlain = (data, options, layoutOnce, probe = !1) => {
|
|
3025
|
+
let noteData = def.categoryLabels ? withCalendarLabels(data, options?.locale?.language, def.categoryLabels) : data;
|
|
3026
|
+
return withDensityNotes(noteData, options ?? {}, (next) => {
|
|
3027
|
+
if (!(DENSITY_VALUES in next)) return layoutBaseline(data, next, layoutOnce, probe);
|
|
3028
|
+
let notedLayout = prepareLayout(data, next);
|
|
3029
|
+
try {
|
|
3030
|
+
return layoutBaseline(data, next, notedLayout, probe);
|
|
3031
|
+
} finally {
|
|
3032
|
+
notedLayout.finish();
|
|
3033
|
+
}
|
|
3034
|
+
});
|
|
3035
|
+
}, createLayout = (data, authored) => {
|
|
3036
|
+
checkItemBudget(def.type, data, authored);
|
|
3037
|
+
let options = withDefaultTarget(authored), inherited = options?.[CARD_HEIGHT_MEMO], borrowed = inherited?.active && inherited.type === def.type, memo = borrowed ? inherited : { type: def.type, active: !0, heights: /* @__PURE__ */ new Map() }, labelled = def.categoryLabels ? withCalendarLabels(data, options?.locale?.language, def.categoryLabels) : data, layoutOnce = prepareLayout(labelled, { ...options, [CARD_HEIGHT_MEMO]: memo }), plain = (d, o) => {
|
|
3038
|
+
let run2 = prepareLayout(d, o);
|
|
3039
|
+
try {
|
|
3040
|
+
return layoutPlain(d, o, run2);
|
|
3041
|
+
} finally {
|
|
3042
|
+
run2.finish();
|
|
3043
|
+
}
|
|
3044
|
+
}, probes = /* @__PURE__ */ new Map(), run = ((runOptions) => withLayoutMemo(() => {
|
|
3045
|
+
let size = runOptions?.size, key = `${typeof size == "object" ? `${size?.width}x${size?.height}:${size?.unit}` : String(size)}:${String(runOptions?.mode)}:${runOptions?.belowMinimum}:${runOptions?.[FULL_LAYOUT_PROBE]}:${runOptions?.[FORCE_COMPACT]}:${runOptions?.[WIDTH_PROBE]}:${runOptions?.[FIXED_SIZE_PROBE]}`, cached = memo.active ? probes.get(key) : void 0;
|
|
3046
|
+
if (cached !== void 0) return cached;
|
|
3047
|
+
let fullProbe2 = runOptions?.[FULL_LAYOUT_PROBE] === !0, callOptions = { ...runOptions, [CARD_HEIGHT_MEMO]: memo }, geo = layoutPlain(labelled, callOptions, layoutOnce, fullProbe2), lost = !fullProbe2 && narrowShareApplies(def, runOptions) ? hiddenForSpace(geo) : 0;
|
|
3048
|
+
if (lost > 0) {
|
|
3049
|
+
let share = { [PLOT_SHARE]: PLOT_FLOOR_SHARE }, wideOnce = prepareLayout(labelled, { ...options, ...share, [CARD_HEIGHT_MEMO]: memo });
|
|
3050
|
+
try {
|
|
3051
|
+
let wide = layoutPlain(labelled, { ...callOptions, ...share }, wideOnce);
|
|
3052
|
+
hiddenForSpace(wide) < lost && (geo = wide);
|
|
3053
|
+
} finally {
|
|
3054
|
+
wideOnce.finish();
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
if (memo.active && !runOptions?.story && probes.set(key, geo), !runOptions?.story || isRefused(geo)) return geo;
|
|
3058
|
+
let story = loadedDeferred("story");
|
|
3059
|
+
return story ? story.applyStory(geo, data, runOptions, plain) : { ...geo, warnings: [...geo.warnings, { code: "story-layer-not-loaded", severity: "warn", message: "options.story draws only through withStory", suggest: "import { withStory } from 'boardplot/react/story'" }] };
|
|
3060
|
+
}));
|
|
3061
|
+
run.probe = (at) => run({ ...at, [FULL_LAYOUT_PROBE]: !0 }), run.finish = () => {
|
|
3062
|
+
probes.clear(), layoutOnce.finish(), borrowed || (memo.active = !1, memo.heights.clear(), memo.references = void 0);
|
|
3063
|
+
};
|
|
3064
|
+
let variable = /* @__PURE__ */ new Set(["size", "mode", "belowMinimum", LAYOUT_CALL, FULL_LAYOUT_PROBE, FORCE_COMPACT, WIDTH_PROBE, ACCEPTANCE_PROBE]);
|
|
3065
|
+
return run.accepts = (d, at) => d === data && [.../* @__PURE__ */ new Set([...Reflect.ownKeys(options ?? {}), ...Reflect.ownKeys(at ?? {})])].every((key) => variable.has(key) || options?.[key] === at?.[key]), run;
|
|
3066
|
+
}, layout = (data, options) => {
|
|
3067
|
+
let prepared = options?.[LAYOUT_CALL];
|
|
3068
|
+
if (prepared?.accepts(data, options)) return prepared(options);
|
|
3069
|
+
let run = createLayout(data, options);
|
|
3070
|
+
try {
|
|
3071
|
+
return run(options);
|
|
3072
|
+
} finally {
|
|
3073
|
+
run.finish();
|
|
3074
|
+
}
|
|
3075
|
+
}, layoutWithFooter = (data, authored) => {
|
|
3076
|
+
let options = withDefaultTarget(authored);
|
|
3077
|
+
return withLayoutMemo(() => {
|
|
3078
|
+
let withCuts = (data2, options2) => withCutLabelNotes(data2, options2 ?? {}, (next) => layout(data2, next)), geo = loadedDeferred("footer")?.(withCuts, data, options, def.type) ?? withCuts(data, options);
|
|
3079
|
+
return geo = verifiedDensityRefusal(geo, def.title, options ?? {}, (size) => layoutWithFooter(data, { ...authored, size, [ACCEPTANCE_PROBE]: !0 })), geo.refused || (finishCutLabelNotes(geo), reportLabelOmissions(geo, options, data)), !options[FULL_LAYOUT_PROBE] && !options[ACCEPTANCE_PROBE] && estimatedPlotAdvice(geo, options), geo.warnings.some((warning) => warning.fix) && (geo.warnings = geo.warnings.map((warning) => warning.fix ? { ...warning, fix: addWhereAbsent({ data, options: authored }, warning.fix) } : warning)), geo;
|
|
3080
|
+
});
|
|
3081
|
+
};
|
|
3082
|
+
registry.set(def.type, { ...def, sizing, layout: layoutWithFooter, [LAYOUT_CALL]: createLayout });
|
|
3083
|
+
for (let alias of aliases)
|
|
3084
|
+
aliasIndex.set(alias, def.type);
|
|
3085
|
+
}
|
|
3086
|
+
function verifiedDensityRefusal(geo, title, options, at) {
|
|
3087
|
+
let refusal = geo.warnings[0];
|
|
3088
|
+
if (!refusal || !UNVERIFIED_DENSITY_REFUSALS.has(refusal) || !isRefused(geo) || !geo.sizing) return geo;
|
|
3089
|
+
let probe = options;
|
|
3090
|
+
if (probe[ACCEPTANCE_PROBE] || probe[FULL_LAYOUT_PROBE] || probe[FIXED_SIZE_PROBE] || probe[WIDTH_PROBE]) return geo;
|
|
3091
|
+
let width = geo.size.width, low = Math.ceil(geo.size.height), height = Math.max(low + 1, Math.ceil(geo.sizing.minHeight));
|
|
3092
|
+
for (let pass = 0; ; pass++) {
|
|
3093
|
+
let taller = at({ width, height });
|
|
3094
|
+
if (!isRefused(taller)) break;
|
|
3095
|
+
if (pass === 7 || taller.warnings[0]?.code !== "size-below-floor" || !taller.sizing || taller.sizing.minWidth > width + SIZE_TOLERANCE) return geo;
|
|
3096
|
+
low = height, height = Math.max(height + 1, Math.ceil(taller.sizing.minHeight));
|
|
3097
|
+
}
|
|
3098
|
+
for (; height - low > 1; ) {
|
|
3099
|
+
let mid = Math.floor((low + height) / 2);
|
|
3100
|
+
isRefused(at({ width, height: mid })) ? low = mid : height = mid;
|
|
3101
|
+
}
|
|
3102
|
+
if (height === Math.ceil(geo.sizing.minHeight)) return geo;
|
|
3103
|
+
let verified = sizeRefusal(
|
|
3104
|
+
geo.type,
|
|
3105
|
+
title,
|
|
3106
|
+
geo.size,
|
|
3107
|
+
{ ...geo.sizing, minHeight: height, measuredMinHeight: Math.min(geo.sizing.measuredMinHeight, height) }
|
|
3108
|
+
);
|
|
3109
|
+
return { ...verified, warnings: [...verified.warnings, ...geo.warnings.slice(1)] };
|
|
3110
|
+
}
|
|
3111
|
+
function inheritGridTarget(data, target, textScale, textSize) {
|
|
3112
|
+
if (data === null || typeof data != "object" || Object.hasOwn(data, "measures") && Object.hasOwn(data, "categories")) return data;
|
|
3113
|
+
let panel = (value) => {
|
|
3114
|
+
if (value === null || typeof value != "object") return value;
|
|
3115
|
+
let entry = value;
|
|
3116
|
+
if (entry.type === "text" || entry.type === "legend") return entry;
|
|
3117
|
+
let { textScale: _own, textSize: ownSize, ...options } = entry.options ?? {};
|
|
3118
|
+
if (ownSize !== void 0 && ownSize !== textSize)
|
|
3119
|
+
throw new NormalizeError("grid-panel-text-size", "options.textSize", "a grid panel cannot set its own textSize", "set textSize once on the grid");
|
|
3120
|
+
return { ...entry, options: { ...options, target, ...textSize !== void 0 ? { textSize } : textScale === 1 ? {} : { textScale } } };
|
|
3121
|
+
}, grid = data;
|
|
3122
|
+
return {
|
|
3123
|
+
...data,
|
|
3124
|
+
...Array.isArray(grid.panels) ? { panels: grid.panels.map(panel) } : {},
|
|
3125
|
+
...grid.template ? { template: panel(grid.template) } : {}
|
|
3126
|
+
};
|
|
3127
|
+
}
|
|
3128
|
+
function hiddenLabelRefusal(title, first, last) {
|
|
3129
|
+
let sizing = last.sizing, height = last.size.height + Math.max(20, Math.ceil(first.plot.h - last.plot.h)), refusal = sizeRefusal(last.type, title, last.size, { ...sizing, minWidth: Math.max(sizing.minWidth, last.size.width), minHeight: Math.max(sizing.minHeight, height) });
|
|
3130
|
+
return refusal.warnings[0].message += "; at this size it hides labels its note line has no room to name", refusal;
|
|
3131
|
+
}
|
|
3132
|
+
function hiddenLabelCollision(title, geo, owed, noteMissing = !1) {
|
|
3133
|
+
let collisions = geo.labels.filter((label) => owed.has(label.id)).map((label) => {
|
|
3134
|
+
let blockers = geo.debug.occupied.filter((item) => rectsOverlap(item.rect, label.rect) && !(item.kind === "mark" && isOwnMark(item.owner, label.owner, label.kind, item.part))).map((item) => `${item.part ?? item.kind} ${Object.values(item.owner).join("/")}`);
|
|
3135
|
+
return `'${label.text}' (${label.id}) against ${[...new Set(blockers)].join(", ") || "the frame or canvas edge"}`;
|
|
3136
|
+
});
|
|
3137
|
+
return { refused: !0, type: geo.type, title, size: geo.size, sizing: geo.sizing, warnings: [{
|
|
3138
|
+
code: "label-collision",
|
|
3139
|
+
severity: "error",
|
|
3140
|
+
// A hidden label goes into the capped note and the chart draws. The refusal is left for a note that
|
|
3141
|
+
// cannot be drawn: its labels were handed to the note, and the note is not on the page.
|
|
3142
|
+
message: `${noteMissing ? "The note line that names the hidden labels is not drawn" : "More height did not resolve the hidden labels"}: ${collisions.join("; ") || "the note and chart frame compete for space"}`,
|
|
3143
|
+
suggest: "Shorten or move the named labels, or remove the colliding element."
|
|
3144
|
+
}] };
|
|
3145
|
+
}
|
|
3146
|
+
function unmatchedIdWarnings(geo, data, highlight, pins, nested) {
|
|
3147
|
+
let list = (ids) => {
|
|
3148
|
+
let all = [...new Set(ids)];
|
|
3149
|
+
return all.length > 20 ? `${all.slice(0, 20).join(", ")} and ${all.length - 20} more` : all.join(", ") || "none";
|
|
3150
|
+
}, warnings = [], asked = typeof highlight == "string" ? [highlight] : Array.isArray(highlight) ? highlight.filter((id) => typeof id == "string") : [];
|
|
3151
|
+
if (asked.length > 0 && !geo.warnings.some((warning) => warning.code === "highlight-unknown-id")) {
|
|
3152
|
+
let owned = geo.scene.flatMap((node) => [
|
|
3153
|
+
...node.id?.includes("/") ? [node.id.slice(0, node.id.indexOf("/"))] : [],
|
|
3154
|
+
...Object.values(node.owner ?? {}).filter((id) => typeof id == "string")
|
|
3155
|
+
]), points = data?.points;
|
|
3156
|
+
Array.isArray(points) && pushAll(owned, points.map((point) => point?.group).filter((id) => typeof id == "string"));
|
|
3157
|
+
let known = new Set(owned), unknown = asked.filter((id) => !known.has(id));
|
|
3158
|
+
unknown.length > 0 && warnings.push({
|
|
3159
|
+
code: "highlight-unknown-id",
|
|
3160
|
+
severity: "warn",
|
|
3161
|
+
message: `highlight names ${unknown.map((id) => `'${id}'`).join(", ")}, which no mark of this chart carries, so nothing is highlighted for it; ids here: ${list(owned)}`,
|
|
3162
|
+
suggest: "Name a series, category, point or row id of this chart.",
|
|
3163
|
+
// A grid panel's field is relative to the panel; the grid names the panel in the message.
|
|
3164
|
+
...nested ? {} : { field: ["options", "highlight"] }
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
let pinned = Object.keys(pins ?? {});
|
|
3168
|
+
if (pinned.length > 0) {
|
|
3169
|
+
let labels = [...geo.labels.map((label) => label.id), ...geo.debug.decisions.map((decision) => decision.labelId)], known = new Set(labels);
|
|
3170
|
+
for (let id of pinned.filter((key) => !known.has(key)))
|
|
3171
|
+
warnings.push({
|
|
3172
|
+
code: "unknown-label-pin",
|
|
3173
|
+
severity: "warn",
|
|
3174
|
+
message: `labelPlacements names label '${id}', which this chart does not draw, so the pin does nothing; label ids: ${list(labels)}`,
|
|
3175
|
+
suggest: "Use a label id from the list, or remove the pin.",
|
|
3176
|
+
...nested ? {} : { field: ["options", "labelPlacements", id] }
|
|
3177
|
+
});
|
|
3178
|
+
}
|
|
3179
|
+
return warnings;
|
|
3180
|
+
}
|
|
3181
|
+
function noPlottedValuesWarning(data) {
|
|
3182
|
+
let series = data?.series;
|
|
3183
|
+
if (!Array.isArray(series)) return null;
|
|
3184
|
+
let dataSeries = series.filter((s) => s?.role !== "reference"), present = (cell) => cell == null ? !1 : typeof cell == "object" && "categoryId" in cell ? present(cell.value) : !0;
|
|
3185
|
+
return dataSeries.length === 0 || dataSeries.some((s) => !Array.isArray(s?.values) || s.values.some(present)) ? null : {
|
|
3186
|
+
code: "no-plotted-values",
|
|
3187
|
+
severity: "warn",
|
|
3188
|
+
message: "every data value is missing (null), so the chart draws an empty frame",
|
|
3189
|
+
suggest: "supply the values, or leave the chart out until the data exists"
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
function getChart(typeOrAlias) {
|
|
3193
|
+
let chart = registry.get(typeOrAlias) ?? registry.get(aliasIndex.get(typeOrAlias) ?? ""), defaults = chart?.aliasDefaults?.[typeOrAlias];
|
|
3194
|
+
return !chart || !defaults ? chart : {
|
|
3195
|
+
...chart,
|
|
3196
|
+
defaults: { ...chart.defaults, ...defaults },
|
|
3197
|
+
layout: (data, options) => chart.layout(data, { ...defaults, ...options })
|
|
3198
|
+
};
|
|
3199
|
+
}
|
|
3200
|
+
function getChartDefinition(typeOrAlias) {
|
|
3201
|
+
let chart = getChart(typeOrAlias);
|
|
3202
|
+
if (chart) {
|
|
3203
|
+
if (!isDefinition(chart))
|
|
3204
|
+
throw new Error(
|
|
3205
|
+
`chart type '${chart.type}' is registered without its schema; import the chart's index module or \`boardplot/validate\``
|
|
3206
|
+
);
|
|
3207
|
+
return chart;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
function registerChartSchemas(schemas, aliases = []) {
|
|
3211
|
+
if (!schemaIndex.has(schemas.type)) {
|
|
3212
|
+
schemaIndex.set(schemas.type, schemas);
|
|
3213
|
+
for (let alias of aliases) schemaAliasIndex.set(alias, schemas.type);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
function getChartSchemas(typeOrAlias) {
|
|
3217
|
+
let chart = getChart(typeOrAlias);
|
|
3218
|
+
return chart && isDefinition(chart) ? chart : schemaIndex.get(typeOrAlias) ?? schemaIndex.get(schemaAliasIndex.get(typeOrAlias) ?? "");
|
|
3219
|
+
}
|
|
3220
|
+
function canonicalChartType(typeOrAlias) {
|
|
3221
|
+
return getChart(typeOrAlias)?.type ?? getChartSchemas(typeOrAlias)?.type;
|
|
3222
|
+
}
|
|
3223
|
+
function listCharts() {
|
|
3224
|
+
return [...registry.values()].map((d) => ({
|
|
3225
|
+
type: d.type,
|
|
3226
|
+
aliases: d.aliases ?? [],
|
|
3227
|
+
summary: d.summary,
|
|
3228
|
+
sizing: d.sizing
|
|
3229
|
+
}));
|
|
3230
|
+
}
|
|
3231
|
+
var unsupported = [
|
|
3232
|
+
{ name: "radar", use: null },
|
|
3233
|
+
{ name: "spider", use: null },
|
|
3234
|
+
{ name: "gauge", use: null },
|
|
3235
|
+
{ name: "control-chart", use: null },
|
|
3236
|
+
{ name: "tornado", use: { type: "bar", options: { variant: "tornado" } } },
|
|
3237
|
+
{ name: "ribbon", use: { type: "column", options: { variant: "stacked", ribbons: !0 } } },
|
|
3238
|
+
{ name: "alluvial", use: { type: "column", options: { variant: "stacked", ribbons: !0 } } },
|
|
3239
|
+
{ name: "bump", use: { type: "line", options: { variant: "bump" } } },
|
|
3240
|
+
{ name: "ranking", use: { type: "line", options: { variant: "bump" } } },
|
|
3241
|
+
{ name: "anomaly", use: { type: "column", options: { anomaly: { method: "mad" } } } },
|
|
3242
|
+
{ name: "outlier", use: { type: "column", options: { anomaly: { method: "mad" } } } },
|
|
3243
|
+
{
|
|
3244
|
+
name: "fan",
|
|
3245
|
+
use: { type: "line", options: { fan: { of: "<central series id>", bands: [{ low: "<low series id>", high: "<high series id>", label: "<what the interval means>" }] } } }
|
|
3246
|
+
},
|
|
3247
|
+
{
|
|
3248
|
+
name: "confidence-band",
|
|
3249
|
+
use: { type: "line", options: { fan: { of: "<central series id>", bands: [{ low: "<low series id>", high: "<high series id>", label: "<what the interval means>" }] } } }
|
|
3250
|
+
}
|
|
3251
|
+
];
|
|
3252
|
+
|
|
3253
|
+
export {
|
|
3254
|
+
themeGeometryTokens,
|
|
3255
|
+
presentationInfo,
|
|
3256
|
+
crowdedTailCut,
|
|
3257
|
+
typeDocLints,
|
|
3258
|
+
themeForDensity,
|
|
3259
|
+
AUTO_LEGEND,
|
|
3260
|
+
isAutomaticLegend,
|
|
3261
|
+
normalizedName,
|
|
3262
|
+
legendIsCovered,
|
|
3263
|
+
keysNeedNames,
|
|
3264
|
+
sweepHide,
|
|
3265
|
+
spread1D,
|
|
3266
|
+
spread1DResult,
|
|
3267
|
+
warnSpreadOverflow,
|
|
3268
|
+
MONTH_START,
|
|
3269
|
+
isDateNumericTickSequence,
|
|
3270
|
+
applyAxisBounds,
|
|
3271
|
+
niceStep,
|
|
3272
|
+
niceDomain,
|
|
3273
|
+
axisGrid,
|
|
3274
|
+
seatRoom,
|
|
3275
|
+
linearScale,
|
|
3276
|
+
brokenLinearScale,
|
|
3277
|
+
invalidLinearBreakReason,
|
|
3278
|
+
crossesLinearBreak,
|
|
3279
|
+
bandScale,
|
|
3280
|
+
niceBelow,
|
|
3281
|
+
tickFormatter,
|
|
3282
|
+
inferLinearYDomain,
|
|
3283
|
+
categoryBreakGlyph,
|
|
3284
|
+
straightBreakGlyph,
|
|
3285
|
+
barBreakCut,
|
|
3286
|
+
layoutValueAxis,
|
|
3287
|
+
AXIS_TITLE_GAP,
|
|
3288
|
+
valueAxisTitleText,
|
|
3289
|
+
valueAxisUnit,
|
|
3290
|
+
axisTitleAllowed,
|
|
3291
|
+
planValueAxisTitle,
|
|
3292
|
+
valueAxisTitleBand,
|
|
3293
|
+
valueAxisTitleRequest,
|
|
3294
|
+
tickRowTitleEnd,
|
|
3295
|
+
applyValueAxisTitleInk,
|
|
3296
|
+
measureValueAxisWidth,
|
|
3297
|
+
withCalendarLabels,
|
|
3298
|
+
noteName,
|
|
3299
|
+
registerChart,
|
|
3300
|
+
getChart,
|
|
3301
|
+
getChartDefinition,
|
|
3302
|
+
registerChartSchemas,
|
|
3303
|
+
getChartSchemas,
|
|
3304
|
+
canonicalChartType,
|
|
3305
|
+
listCharts,
|
|
3306
|
+
unsupported,
|
|
3307
|
+
VARIANCE_TIER,
|
|
3308
|
+
varianceTierWeights,
|
|
3309
|
+
isSingleVarianceTier,
|
|
3310
|
+
isVarianceTier,
|
|
3311
|
+
balanceVarianceTierPlots,
|
|
3312
|
+
dayUnit,
|
|
3313
|
+
calendarCategories,
|
|
3314
|
+
calendarNames,
|
|
3315
|
+
dateTickRow,
|
|
3316
|
+
dayCategories,
|
|
3317
|
+
longDayMonths,
|
|
3318
|
+
CATEGORY_ROW_FROM_END,
|
|
3319
|
+
CATEGORY_ROW_VERTICAL,
|
|
3320
|
+
yearRowRequests,
|
|
3321
|
+
categoryLineAlign,
|
|
3322
|
+
ROTATED_NAME_AIR,
|
|
3323
|
+
calendarLike,
|
|
3324
|
+
numberedSequence,
|
|
3325
|
+
hangingLabelReserve,
|
|
3326
|
+
categoryRowTop,
|
|
3327
|
+
planCategoryRow,
|
|
3328
|
+
categoryCutLint,
|
|
3329
|
+
rotatedClaimRect,
|
|
3330
|
+
rotatedLeftOverhang,
|
|
3331
|
+
verticalNameRect,
|
|
3332
|
+
CARD_MIN_WIDTH,
|
|
3333
|
+
CARD_CLASS_WIDTH,
|
|
3334
|
+
SIZE_TOLERANCE,
|
|
3335
|
+
HARD_COMPACT_PLOT,
|
|
3336
|
+
atHardMinimum,
|
|
3337
|
+
plotFloorRows,
|
|
3338
|
+
chartSizing,
|
|
3339
|
+
contentSized,
|
|
3340
|
+
heightOmitted,
|
|
3341
|
+
capPitch,
|
|
3342
|
+
hostlessHeight,
|
|
3343
|
+
PLOT_FLOOR_PX,
|
|
3344
|
+
NARROW_SHARE_WIDTH,
|
|
3345
|
+
plotFloorShare,
|
|
3346
|
+
DIGIT_SEAT,
|
|
3347
|
+
PLOT_FLOOR_RECT,
|
|
3348
|
+
CONTENT_PLOT_HEIGHT,
|
|
3349
|
+
plotFloorHeight,
|
|
3350
|
+
plotRepairHeight,
|
|
3351
|
+
autoPlotPx,
|
|
3352
|
+
stackedColumnPlotPx,
|
|
3353
|
+
resolveSizing,
|
|
3354
|
+
rowSizing,
|
|
3355
|
+
contentSizing,
|
|
3356
|
+
NATURAL_BAND_STEP,
|
|
3357
|
+
bandSizing,
|
|
3358
|
+
matrixWidths,
|
|
3359
|
+
fitsSize,
|
|
3360
|
+
sizeRefusal,
|
|
3361
|
+
verifiedSizeRepair,
|
|
3362
|
+
requireGeometry,
|
|
3363
|
+
declaredSizing,
|
|
3364
|
+
prepareFitLayout,
|
|
3365
|
+
furnitureShare,
|
|
3366
|
+
HARD_MINIMUM,
|
|
3367
|
+
LAYOUT_CALL,
|
|
3368
|
+
FULL_LAYOUT_PROBE,
|
|
3369
|
+
VERIFY_ADVICE,
|
|
3370
|
+
FORCE_COMPACT,
|
|
3371
|
+
WIDTH_PROBE,
|
|
3372
|
+
FIXED_SIZE_PROBE,
|
|
3373
|
+
ACCEPTANCE_PROBE,
|
|
3374
|
+
isWidthProbe,
|
|
3375
|
+
compactFallbackApplies,
|
|
3376
|
+
CARD_HEIGHT_MEMO,
|
|
3377
|
+
cardReferenceHeight
|
|
3378
|
+
};
|