boardplot 0.0.0-stage → 0.53.0
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 +49 -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-VOJSJ66R.js +137 -0
- package/dist/annotateEngine-DLMFJZ67.js +30 -0
- package/dist/build-identity.json +6 -0
- package/dist/chunk-24BHMKDD.js +83 -0
- package/dist/chunk-263SZKIL.js +8 -0
- package/dist/chunk-27QADBDV.js +211 -0
- package/dist/chunk-2CVH5E57.js +128 -0
- package/dist/chunk-2DOR5SS6.js +446 -0
- package/dist/chunk-2EQE4E3I.js +22 -0
- package/dist/chunk-2FNNAPCI.js +24 -0
- package/dist/chunk-2L2Q53EP.js +251 -0
- package/dist/chunk-2LMCD3ZR.js +6 -0
- package/dist/chunk-2ND7ZITT.js +3069 -0
- package/dist/chunk-2QT5ZUHO.js +2937 -0
- package/dist/chunk-2RSG7JYI.js +24 -0
- package/dist/chunk-2V6CLH33.js +1392 -0
- package/dist/chunk-2VWJ5BGO.js +566 -0
- package/dist/chunk-2WNYRWHG.js +51 -0
- package/dist/chunk-323YZWYJ.js +548 -0
- package/dist/chunk-33PB4V6K.js +382 -0
- package/dist/chunk-33PLBIMA.js +176 -0
- package/dist/chunk-3A2IEBCN.js +195 -0
- package/dist/chunk-3D3D3D23.js +25 -0
- package/dist/chunk-3EZRM4YM.js +92 -0
- package/dist/chunk-3H2W76TB.js +2353 -0
- package/dist/chunk-3JEQGGVD.js +19 -0
- package/dist/chunk-3QWZAEW5.js +26 -0
- package/dist/chunk-3SIRPKMP.js +12 -0
- package/dist/chunk-3SQCCESO.js +1592 -0
- package/dist/chunk-3XHJHQWU.js +42 -0
- package/dist/chunk-4G2O2ZPJ.js +83 -0
- package/dist/chunk-4JLBVIGW.js +24 -0
- package/dist/chunk-4RRNJLCM.js +746 -0
- package/dist/chunk-4UVW5WU6.js +76 -0
- package/dist/chunk-4X66BTP5.js +344 -0
- package/dist/chunk-53OYF4ZT.js +687 -0
- package/dist/chunk-57ZGVAU3.js +179 -0
- package/dist/chunk-5HECRVXJ.js +62 -0
- package/dist/chunk-5LGSRWFC.js +63 -0
- package/dist/chunk-5LYXD6ME.js +1112 -0
- package/dist/chunk-66RFKRGO.js +28 -0
- package/dist/chunk-6KWIQ5KF.js +18 -0
- package/dist/chunk-6OCR6ITN.js +72 -0
- package/dist/chunk-6RBTTCQD.js +802 -0
- package/dist/chunk-6Y7EXYLR.js +563 -0
- package/dist/chunk-7CTKTIPF.js +613 -0
- package/dist/chunk-7EVIIADO.js +185 -0
- package/dist/chunk-7X2ZYVAX.js +89 -0
- package/dist/chunk-7X65ZQN4.js +38 -0
- package/dist/chunk-A4QZXLXF.js +7 -0
- package/dist/chunk-A6CQPJWR.js +49 -0
- package/dist/chunk-A7IEVBYI.js +35 -0
- package/dist/chunk-ACXX2JNL.js +6 -0
- package/dist/chunk-ADKCLH3Z.js +98 -0
- package/dist/chunk-ADWSGPH5.js +23 -0
- package/dist/chunk-AG2CJ4JY.js +203 -0
- package/dist/chunk-AHQ4L3BE.js +30 -0
- package/dist/chunk-AOQ6VF5H.js +6 -0
- package/dist/chunk-AQROQDLR.js +3303 -0
- package/dist/chunk-AWTG3RFF.js +85 -0
- package/dist/chunk-B54RN2FD.js +692 -0
- package/dist/chunk-B67K6OWJ.js +48 -0
- package/dist/chunk-B6GFKYBZ.js +40 -0
- package/dist/chunk-BBL3R5YZ.js +186 -0
- package/dist/chunk-BBRBCMNR.js +28 -0
- package/dist/chunk-BIDIGDGH.js +6 -0
- package/dist/chunk-BLFWUMTD.js +12 -0
- package/dist/chunk-BM6SFFWF.js +6 -0
- package/dist/chunk-BMRD6MAH.js +24 -0
- package/dist/chunk-BPKXEMRE.js +197 -0
- package/dist/chunk-BUPLB3EX.js +129 -0
- package/dist/chunk-BW5VLBSZ.js +15 -0
- package/dist/chunk-BWGRWGVA.js +295 -0
- package/dist/chunk-BWLOXQDV.js +131 -0
- package/dist/chunk-BWTX7LUG.js +203 -0
- package/dist/chunk-C54QLNE4.js +69 -0
- package/dist/chunk-CAQ5P4VN.js +296 -0
- package/dist/chunk-CCCEBIUZ.js +296 -0
- package/dist/chunk-CDZHNLO6.js +42 -0
- package/dist/chunk-CJGSJKPO.js +25 -0
- package/dist/chunk-CN7JRHST.js +25 -0
- package/dist/chunk-CNX7EGSU.js +266 -0
- package/dist/chunk-COYOTQC2.js +75 -0
- package/dist/chunk-CRNMNZJD.js +1161 -0
- package/dist/chunk-CUVUDK4O.js +68 -0
- package/dist/chunk-CWDHCSL2.js +2919 -0
- package/dist/chunk-CYOJZ3GQ.js +631 -0
- package/dist/chunk-D4SOADBD.js +19 -0
- package/dist/chunk-D7SHZDA3.js +1808 -0
- package/dist/chunk-DAVHGK27.js +657 -0
- package/dist/chunk-DCCJRLAJ.js +422 -0
- package/dist/chunk-DCTCUZ5L.js +51 -0
- package/dist/chunk-DDCB7ZA5.js +2511 -0
- package/dist/chunk-DDI2W4TR.js +149 -0
- package/dist/chunk-DIHUGBZO.js +61 -0
- package/dist/chunk-DJHIQWSG.js +25 -0
- package/dist/chunk-DO5OZJAO.js +302 -0
- package/dist/chunk-DOFYKPTC.js +18 -0
- package/dist/chunk-DRTA6JG5.js +160 -0
- package/dist/chunk-DRW6KGBK.js +1062 -0
- package/dist/chunk-DU4A5AOY.js +1156 -0
- package/dist/chunk-DYS7EIXY.js +294 -0
- package/dist/chunk-E4IQ6M4S.js +24 -0
- package/dist/chunk-EFUWFB64.js +24 -0
- package/dist/chunk-EHBB2Z4D.js +290 -0
- package/dist/chunk-EHVESNLV.js +30 -0
- package/dist/chunk-EJPVVGD7.js +67 -0
- package/dist/chunk-EKQK5D6G.js +14 -0
- package/dist/chunk-EUADDXAV.js +30 -0
- package/dist/chunk-F6CNPC4L.js +47 -0
- package/dist/chunk-FBAYZSFC.js +2806 -0
- package/dist/chunk-FBB4BWKN.js +30 -0
- package/dist/chunk-FF23FYQD.js +1269 -0
- package/dist/chunk-FG6EDGMI.js +53 -0
- package/dist/chunk-FHA3KMFC.js +43 -0
- package/dist/chunk-FIANWJXX.js +19 -0
- package/dist/chunk-FIWNDOMO.js +6 -0
- package/dist/chunk-FV3VF36K.js +2721 -0
- package/dist/chunk-G5FMTRG5.js +37 -0
- package/dist/chunk-GCBOHVDZ.js +229 -0
- package/dist/chunk-GDOW2KNP.js +19 -0
- package/dist/chunk-GTG3IGLF.js +2674 -0
- package/dist/chunk-GZTNTHSW.js +21 -0
- package/dist/chunk-H4H4O62O.js +46 -0
- package/dist/chunk-H5G7T35P.js +24 -0
- package/dist/chunk-H63XQ3OO.js +942 -0
- package/dist/chunk-H67RTX46.js +43 -0
- package/dist/chunk-HA4IPWMM.js +841 -0
- package/dist/chunk-HKYTOJLV.js +33 -0
- package/dist/chunk-HOAH5XBR.js +542 -0
- package/dist/chunk-HTYFQHRC.js +24 -0
- package/dist/chunk-HYY5V2KL.js +19 -0
- package/dist/chunk-HZI56ASJ.js +79 -0
- package/dist/chunk-I6VAWNNU.js +24 -0
- package/dist/chunk-IBXXZVG7.js +80 -0
- package/dist/chunk-IDDA5INB.js +60 -0
- package/dist/chunk-IK4BHOPZ.js +33 -0
- package/dist/chunk-IL5T7I2A.js +27 -0
- package/dist/chunk-ILSXT6KT.js +24 -0
- package/dist/chunk-IV2UXZXX.js +16 -0
- package/dist/chunk-IYEFEBRN.js +41 -0
- package/dist/chunk-IYMI7YI4.js +829 -0
- package/dist/chunk-J6I2YFJH.js +58 -0
- package/dist/chunk-JFBEAUJ6.js +24 -0
- package/dist/chunk-JR7Y5ONB.js +27 -0
- package/dist/chunk-JSEYUJUQ.js +836 -0
- package/dist/chunk-JYBT2JNY.js +61 -0
- package/dist/chunk-K3HSQPSM.js +24 -0
- package/dist/chunk-KAXJFL7N.js +43 -0
- package/dist/chunk-KDMKHR5A.js +32 -0
- package/dist/chunk-KKWZWP67.js +24 -0
- package/dist/chunk-KOJ5QETJ.js +8 -0
- package/dist/chunk-KPKXJYQH.js +19 -0
- package/dist/chunk-KSJVENRU.js +113 -0
- package/dist/chunk-KZJOV4QW.js +33 -0
- package/dist/chunk-KZS46KDY.js +58 -0
- package/dist/chunk-L3JWM7FR.js +50 -0
- package/dist/chunk-L4S6UFTL.js +26 -0
- package/dist/chunk-L6DJ4ZY5.js +2008 -0
- package/dist/chunk-L7RHB734.js +23 -0
- package/dist/chunk-LCWJS34U.js +38 -0
- package/dist/chunk-LFTAMH7I.js +24 -0
- package/dist/chunk-LFX7W4B7.js +113 -0
- package/dist/chunk-LINZPU5D.js +8 -0
- package/dist/chunk-LIWLBLCT.js +83 -0
- package/dist/chunk-LNKY5Z2X.js +23 -0
- package/dist/chunk-LS7HVBI7.js +24 -0
- package/dist/chunk-M4EUXOLU.js +170 -0
- package/dist/chunk-M4SPKUZE.js +7 -0
- package/dist/chunk-M4YLED7M.js +17 -0
- package/dist/chunk-MBKZYJRC.js +1424 -0
- package/dist/chunk-MCYM3RNF.js +227 -0
- package/dist/chunk-MF6IVSBJ.js +48 -0
- package/dist/chunk-MIAPBQCA.js +24 -0
- package/dist/chunk-MJZHFH5R.js +1075 -0
- package/dist/chunk-MQFCG4KS.js +1467 -0
- package/dist/chunk-MVV6RQMG.js +128 -0
- package/dist/chunk-MYMT5KJL.js +1182 -0
- package/dist/chunk-MZL6LGKO.js +587 -0
- package/dist/chunk-N23YFPPI.js +47 -0
- package/dist/chunk-N3G2FYDL.js +300 -0
- package/dist/chunk-N3TPMXS3.js +161 -0
- package/dist/chunk-N73IBH55.js +58 -0
- package/dist/chunk-N7J7CZS6.js +43 -0
- package/dist/chunk-NCB3YLHF.js +28 -0
- package/dist/chunk-NHQGRKEA.js +63 -0
- package/dist/chunk-NKIYLFXZ.js +2774 -0
- package/dist/chunk-NOSDEJ3K.js +25934 -0
- package/dist/chunk-NQDVMUHX.js +433 -0
- package/dist/chunk-NSSNYY6Y.js +58 -0
- package/dist/chunk-NY5NUFDZ.js +117 -0
- package/dist/chunk-O3S2KNIW.js +25 -0
- package/dist/chunk-O3VN6BTL.js +24 -0
- package/dist/chunk-ONZLC47B.js +88 -0
- package/dist/chunk-OQEBOVUO.js +30 -0
- package/dist/chunk-OUEGGWH7.js +24 -0
- package/dist/chunk-OURX73UJ.js +728 -0
- package/dist/chunk-P25VEGGX.js +24 -0
- package/dist/chunk-P26Z62UV.js +24 -0
- package/dist/chunk-P5RNWMZC.js +2984 -0
- package/dist/chunk-P6KZIZDV.js +987 -0
- package/dist/chunk-PEUSKIFV.js +168 -0
- package/dist/chunk-PFVTYFSL.js +24 -0
- package/dist/chunk-PWROWDZS.js +137 -0
- package/dist/chunk-Q3CV2JJ2.js +3650 -0
- package/dist/chunk-QBR6IKIX.js +50 -0
- package/dist/chunk-QGCEHR6S.js +13 -0
- package/dist/chunk-QHRE2M6V.js +26 -0
- package/dist/chunk-QKL7IY42.js +38 -0
- package/dist/chunk-QO6HEXIZ.js +272 -0
- package/dist/chunk-QOIVXZUF.js +24 -0
- package/dist/chunk-QPWRHDLZ.js +17 -0
- package/dist/chunk-QSXK6PJL.js +19 -0
- package/dist/chunk-QTZVVZ2A.js +54 -0
- package/dist/chunk-QWXWVPNE.js +18 -0
- package/dist/chunk-QY5ZKUWY.js +383 -0
- package/dist/chunk-QZAT46PP.js +95 -0
- package/dist/chunk-RA66JA3D.js +24 -0
- package/dist/chunk-REOPXBUR.js +600 -0
- package/dist/chunk-RGZGLKFB.js +648 -0
- package/dist/chunk-RL3NUWMY.js +3378 -0
- package/dist/chunk-RNOJSEES.js +16 -0
- package/dist/chunk-ROXO4R3J.js +16 -0
- package/dist/chunk-RPIW5T55.js +40 -0
- package/dist/chunk-RQ5DNYLG.js +10 -0
- package/dist/chunk-RZNYW7UP.js +133 -0
- package/dist/chunk-S32YYDIB.js +420 -0
- package/dist/chunk-S4QSJAGY.js +44 -0
- package/dist/chunk-S6UX7KB6.js +335 -0
- package/dist/chunk-SDSONLMZ.js +2546 -0
- package/dist/chunk-SGD3ZHID.js +250 -0
- package/dist/chunk-SKRSCTT5.js +28 -0
- package/dist/chunk-SMCDXUIO.js +24 -0
- package/dist/chunk-SPTPFY4S.js +528 -0
- package/dist/chunk-SREWFAAJ.js +90 -0
- package/dist/chunk-SS42FJVN.js +3875 -0
- package/dist/chunk-SVZDXFPX.js +891 -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-TBGUEF3M.js +939 -0
- package/dist/chunk-TGK6KUGN.js +331 -0
- package/dist/chunk-TJSND556.js +1783 -0
- package/dist/chunk-TKOJZQAJ.js +24 -0
- package/dist/chunk-TM4OC53S.js +97 -0
- package/dist/chunk-TNEHPP3H.js +18 -0
- package/dist/chunk-TWOREVKJ.js +1760 -0
- package/dist/chunk-TXS3U77A.js +60 -0
- package/dist/chunk-UB6ODJHO.js +134 -0
- package/dist/chunk-UBZXQIDR.js +24 -0
- package/dist/chunk-ULTSSIOU.js +38 -0
- package/dist/chunk-UMDEWWXT.js +33 -0
- package/dist/chunk-V6O6KVOA.js +347 -0
- package/dist/chunk-VABRPZVC.js +43 -0
- package/dist/chunk-VDAKTZQP.js +18 -0
- package/dist/chunk-VDAZPGR2.js +79 -0
- package/dist/chunk-VERLFNWR.js +25 -0
- package/dist/chunk-VH2UUU7K.js +24 -0
- package/dist/chunk-VJ3FCGQF.js +12 -0
- package/dist/chunk-VK5ZDV67.js +47 -0
- package/dist/chunk-VKQNDOAI.js +40 -0
- package/dist/chunk-VTEV3WVF.js +690 -0
- package/dist/chunk-VXZFQKBJ.js +21 -0
- package/dist/chunk-WI5ITCOH.js +22 -0
- package/dist/chunk-WLZ54FWG.js +120 -0
- package/dist/chunk-WYJEOMNY.js +31 -0
- package/dist/chunk-WZGJSQKN.js +29 -0
- package/dist/chunk-WZL4EEBS.js +11 -0
- package/dist/chunk-X4YNDLVA.js +54 -0
- package/dist/chunk-X6SUFTD7.js +17 -0
- package/dist/chunk-XB4KZ6WO.js +81 -0
- package/dist/chunk-XJI6SWFS.js +569 -0
- package/dist/chunk-XJP5DKIL.js +29 -0
- package/dist/chunk-XN4ARQ2W.js +47 -0
- package/dist/chunk-XN7MQO45.js +359 -0
- package/dist/chunk-XQCQZBGX.js +100 -0
- package/dist/chunk-XXOHXA3A.js +69 -0
- package/dist/chunk-XZOHR765.js +127 -0
- package/dist/chunk-YCNLQYTC.js +133 -0
- package/dist/chunk-YCRGWQBS.js +526 -0
- package/dist/chunk-YF2PYLC4.js +210 -0
- package/dist/chunk-YG5GUELW.js +935 -0
- package/dist/chunk-YS6KMYM4.js +91 -0
- package/dist/chunk-YWP7XFKD.js +12 -0
- package/dist/chunk-Z2MGTKDR.js +20 -0
- package/dist/chunk-Z6CL7AR6.js +24 -0
- package/dist/chunk-Z7X3RGGA.js +22 -0
- package/dist/chunk-ZF43WRG3.js +29 -0
- package/dist/chunk-ZMF7WEGG.js +60 -0
- package/dist/chunk-ZNHFLJSY.js +375 -0
- package/dist/chunk-ZQ4VFQID.js +76 -0
- package/dist/chunk-ZQF34VPS.js +72 -0
- package/dist/chunk-ZU425HNM.js +24 -0
- package/dist/chunk-ZZU5R5UU.js +24 -0
- package/dist/cli/index.js +9 -0
- package/dist/core-3VCCUFVX.js +32 -0
- package/dist/core-4BZQQSHS.js +33 -0
- package/dist/core-4VT4MHNB.js +38 -0
- package/dist/core-5535KXRD.js +40 -0
- package/dist/core-5HQBPCHL.js +35 -0
- package/dist/core-6RYHWUJO.js +35 -0
- package/dist/core-7BZJCIXN.js +35 -0
- package/dist/core-AJTVU6X7.js +37 -0
- package/dist/core-C6YUSTZI.js +57 -0
- package/dist/core-EEB7HTCL.js +33 -0
- package/dist/core-EFMVDWNH.js +38 -0
- package/dist/core-ETAGQBZO.js +34 -0
- package/dist/core-FVR3WZEC.js +36 -0
- package/dist/core-GCTFVYMH.js +29 -0
- package/dist/core-GES44OTS.js +33 -0
- package/dist/core-GGQREDSI.js +47 -0
- package/dist/core-HRYOV6QD.js +38 -0
- package/dist/core-IKD3EE3S.js +38 -0
- package/dist/core-JM4R426L.js +32 -0
- package/dist/core-KKQS3WI2.js +40 -0
- package/dist/core-LA6XDYG7.js +40 -0
- package/dist/core-MJ7JWQT5.js +37 -0
- package/dist/core-MLROKJ2M.js +53 -0
- package/dist/core-MR52YBRX.js +31 -0
- package/dist/core-NP4VHWXL.js +29 -0
- package/dist/core-NQLNZDX5.js +41 -0
- package/dist/core-NSIJEKLI.js +44 -0
- package/dist/core-OJUQLIQ5.js +35 -0
- package/dist/core-PB3VUQSS.js +32 -0
- package/dist/core-Q6VLFFYC.js +56 -0
- package/dist/core-QY7AVIKZ.js +51 -0
- package/dist/core-SBQMHWTA.js +52 -0
- package/dist/core-UHECQHJ2.js +38 -0
- package/dist/core-V5FV4NWL.js +56 -0
- package/dist/core-WGM4XUN3.js +58 -0
- package/dist/core-WUQVFARS.js +34 -0
- package/dist/core-Z2F3IGSR.js +42 -0
- package/dist/dataTable-3CPPIHB3.js +58 -0
- package/dist/engine-FXFBCWHB.js +961 -0
- package/dist/fixtures.d.ts +1 -0
- package/dist/fixtures.js +41 -0
- package/dist/fontTables-WYCZNRE7.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 +364 -0
- package/dist/main-YLKBTHJP.js +569 -0
- package/dist/mcp/server.js +1025 -0
- package/dist/module-SVEW5ZUE.js +137233 -0
- package/dist/react/bar.d.ts +1 -0
- package/dist/react/bar.js +81 -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 +65 -0
- package/dist/react/bullet.d.ts +1 -0
- package/dist/react/bullet.js +72 -0
- package/dist/react/butterfly.d.ts +1 -0
- package/dist/react/butterfly.js +66 -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 +70 -0
- package/dist/react/column.d.ts +1 -0
- package/dist/react/column.js +86 -0
- package/dist/react/combo.d.ts +1 -0
- package/dist/react/combo.js +86 -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 +72 -0
- package/dist/react/dot.d.ts +1 -0
- package/dist/react/dot.js +70 -0
- package/dist/react/export.d.ts +1 -0
- package/dist/react/export.js +658 -0
- package/dist/react/funnel.d.ts +1 -0
- package/dist/react/funnel.js +63 -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 +67 -0
- package/dist/react/heatmap.d.ts +1 -0
- package/dist/react/heatmap.js +68 -0
- package/dist/react/histogram.d.ts +1 -0
- package/dist/react/histogram.js +86 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +504 -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 +83 -0
- package/dist/react/line.d.ts +1 -0
- package/dist/react/line.js +81 -0
- package/dist/react/mekko.d.ts +1 -0
- package/dist/react/mekko.js +71 -0
- package/dist/react/pareto.d.ts +1 -0
- package/dist/react/pareto.js +90 -0
- package/dist/react/pie.d.ts +1 -0
- package/dist/react/pie.js +64 -0
- package/dist/react/prepare.d.ts +1 -0
- package/dist/react/prepare.js +278 -0
- package/dist/react/pvm.d.ts +1 -0
- package/dist/react/pvm.js +68 -0
- package/dist/react/pyramid.d.ts +1 -0
- package/dist/react/pyramid.js +67 -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 +63 -0
- package/dist/react/slope.d.ts +1 -0
- package/dist/react/slope.js +64 -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 +379 -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 +69 -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 +65 -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 +68 -0
- package/dist/resvg-ZOVDIZTV.js +23 -0
- package/dist/rows.d.ts +1 -0
- package/dist/rows.js +23 -0
- package/dist/rowsModule-YVLAROIP.js +27 -0
- package/dist/schema-2K6C3U24.js +23 -0
- package/dist/schema-2KIHLTYI.js +23 -0
- package/dist/schema-4HY2MWZC.js +30 -0
- package/dist/schema-4S5CXHAO.js +24 -0
- package/dist/schema-5BKQV56C.js +27 -0
- package/dist/schema-5HA5DSYN.js +24 -0
- package/dist/schema-5NKJPSBD.js +23 -0
- package/dist/schema-65FOKNHK.js +43 -0
- package/dist/schema-6OHZWHUI.js +23 -0
- package/dist/schema-6RYJS2GM.js +24 -0
- package/dist/schema-6W4M3WJ4.js +23 -0
- package/dist/schema-7TLSFG6M.js +24 -0
- package/dist/schema-AMFRKUFS.js +27 -0
- package/dist/schema-B7CZPPB4.js +28 -0
- package/dist/schema-BNRNHGHQ.js +26 -0
- package/dist/schema-E4MRCGPZ.js +24 -0
- package/dist/schema-F3WYTR65.js +26 -0
- package/dist/schema-FA6XIHTW.js +23 -0
- package/dist/schema-GZNOW4LX.js +23 -0
- package/dist/schema-HEIDGCSL.js +23 -0
- package/dist/schema-JB2H6KPA.js +23 -0
- package/dist/schema-MPXZNWV3.js +23 -0
- package/dist/schema-NHNQK6XO.js +23 -0
- package/dist/schema-NN6UPDPW.js +23 -0
- package/dist/schema-O4YNAGIY.js +23 -0
- package/dist/schema-O7AKK232.js +29 -0
- package/dist/schema-OJCML6LV.js +24 -0
- package/dist/schema-ORTRMYI6.js +24 -0
- package/dist/schema-PJ6P52BC.js +23 -0
- package/dist/schema-RTWES6NR.js +24 -0
- package/dist/schema-S36SRYGO.js +24 -0
- package/dist/schema-S3TCLTYD.js +23 -0
- package/dist/schema-SWWMOLOR.js +54 -0
- package/dist/schema-WOSEZNKG.js +26 -0
- package/dist/schema-Y6KBWUUR.js +23 -0
- package/dist/schema-YQYTLKSW.js +23 -0
- package/dist/schema-ZUUUY3QS.js +33 -0
- package/dist/specValidation-VNWIKLHH.js +49 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +24 -0
- package/dist/themeShapeRules-2D3KWSPQ.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 +63 -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 +304 -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 +384 -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 +47 -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 +227 -0
- package/dist/types/core/types/cell.d.ts +82 -0
- package/dist/types/core/types/data.d.ts +314 -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 +82 -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 +63 -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 +223 -0
- package/docs/FONTS.md +68 -0
- package/docs/TELEMETRY.md +94 -0
- package/docs/manual.md +850 -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 +1089 -0
- package/docs/reference/funnel.md +121 -0
- package/docs/reference/gantt.md +138 -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 +706 -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,3875 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPACT_OMITTED_NOTES,
|
|
3
|
+
LIVE_NOTE_SHOW,
|
|
4
|
+
chartNotes,
|
|
5
|
+
copyNote,
|
|
6
|
+
defaultNoteLines,
|
|
7
|
+
defaultNotePlacement,
|
|
8
|
+
disclosureNote,
|
|
9
|
+
disclosuresShown,
|
|
10
|
+
engineNote,
|
|
11
|
+
engineNoteMeta,
|
|
12
|
+
footerParts,
|
|
13
|
+
footerPlans,
|
|
14
|
+
footerType,
|
|
15
|
+
keepNoteMeta,
|
|
16
|
+
liveFooterExtra,
|
|
17
|
+
notesPointer,
|
|
18
|
+
recordFreedChrome,
|
|
19
|
+
shownNoteKinds,
|
|
20
|
+
sourceLine,
|
|
21
|
+
staticFrame,
|
|
22
|
+
valueNote,
|
|
23
|
+
wrapFootnote
|
|
24
|
+
} from "./chunk-BPKXEMRE.js";
|
|
25
|
+
import {
|
|
26
|
+
ENGINE_REV
|
|
27
|
+
} from "./chunk-X6SUFTD7.js";
|
|
28
|
+
import {
|
|
29
|
+
dateNames
|
|
30
|
+
} from "./chunk-QBR6IKIX.js";
|
|
31
|
+
import {
|
|
32
|
+
parseFormatExample,
|
|
33
|
+
parseISODate,
|
|
34
|
+
unitOfSpec
|
|
35
|
+
} from "./chunk-RGZGLKFB.js";
|
|
36
|
+
import {
|
|
37
|
+
chartString,
|
|
38
|
+
chartStrings,
|
|
39
|
+
currencySign,
|
|
40
|
+
localeStrings,
|
|
41
|
+
withLocaleStrings
|
|
42
|
+
} from "./chunk-53OYF4ZT.js";
|
|
43
|
+
import {
|
|
44
|
+
cellValue
|
|
45
|
+
} from "./chunk-O3VN6BTL.js";
|
|
46
|
+
import {
|
|
47
|
+
LABEL_PLATE_RADIUS,
|
|
48
|
+
PLAN_MUTED_PAINT,
|
|
49
|
+
POINTER_TRANSPARENT_PARTS,
|
|
50
|
+
WEIGHT_EMPHASIS,
|
|
51
|
+
WIDE_CANVAS_MIN_WIDTH,
|
|
52
|
+
arrowHeadPath,
|
|
53
|
+
arrowShaftEnd,
|
|
54
|
+
bulletBandPaints,
|
|
55
|
+
decideFillEdges,
|
|
56
|
+
effectiveFill,
|
|
57
|
+
emphasisWeight,
|
|
58
|
+
farGround,
|
|
59
|
+
fillEdgesOff,
|
|
60
|
+
focusColor,
|
|
61
|
+
haloHatchedInsideLabels,
|
|
62
|
+
harveyWedgePath,
|
|
63
|
+
hatchGapFactor,
|
|
64
|
+
hatchPaint,
|
|
65
|
+
hatchPatternId,
|
|
66
|
+
hatchStrokeWidthFor,
|
|
67
|
+
hatchTile,
|
|
68
|
+
isHatchPattern,
|
|
69
|
+
labelPlate,
|
|
70
|
+
leaderPath,
|
|
71
|
+
lineBandAuthoredWarnings,
|
|
72
|
+
marksOnBands,
|
|
73
|
+
paintColor,
|
|
74
|
+
paintTokenColor,
|
|
75
|
+
panelTypeClass,
|
|
76
|
+
pieRamp,
|
|
77
|
+
referenceCasings,
|
|
78
|
+
repaintSeparation,
|
|
79
|
+
resolvePalette,
|
|
80
|
+
resolveTargetTheme,
|
|
81
|
+
resolveTheme,
|
|
82
|
+
secondaryFont,
|
|
83
|
+
secondaryType,
|
|
84
|
+
seriesTextAlone,
|
|
85
|
+
smallestTitleSize,
|
|
86
|
+
solidMutedPlan,
|
|
87
|
+
spaceTokens,
|
|
88
|
+
strokeToken,
|
|
89
|
+
textScaleOf,
|
|
90
|
+
textSizeOf,
|
|
91
|
+
visibleTintAmount
|
|
92
|
+
} from "./chunk-CWDHCSL2.js";
|
|
93
|
+
import {
|
|
94
|
+
COLOR_FIX,
|
|
95
|
+
FILL_SEPARATION_FLOOR,
|
|
96
|
+
PALETTE_CVD_FLOOR,
|
|
97
|
+
PALETTE_NORMAL_FLOOR,
|
|
98
|
+
PALETTE_TRITAN_FLOOR,
|
|
99
|
+
contrastRatio,
|
|
100
|
+
literalColor,
|
|
101
|
+
loadedDeferred,
|
|
102
|
+
palettePerceptualDistance,
|
|
103
|
+
parseColor,
|
|
104
|
+
pickInk,
|
|
105
|
+
readsAsLoss
|
|
106
|
+
} from "./chunk-HA4IPWMM.js";
|
|
107
|
+
import {
|
|
108
|
+
DEFAULT_TARGET,
|
|
109
|
+
NormalizeError,
|
|
110
|
+
formatScenarios,
|
|
111
|
+
resolveSubtitle,
|
|
112
|
+
resolveTargetSize,
|
|
113
|
+
scaleTextAtFloor,
|
|
114
|
+
targetFloorsPx,
|
|
115
|
+
targetTypeSizesPx
|
|
116
|
+
} from "./chunk-SGD3ZHID.js";
|
|
117
|
+
import {
|
|
118
|
+
maxOf,
|
|
119
|
+
minOf,
|
|
120
|
+
pushAll
|
|
121
|
+
} from "./chunk-WYJEOMNY.js";
|
|
122
|
+
import {
|
|
123
|
+
ellipsize,
|
|
124
|
+
hasAuthoredTypeSize,
|
|
125
|
+
wrapText
|
|
126
|
+
} from "./chunk-AG2CJ4JY.js";
|
|
127
|
+
|
|
128
|
+
// src/core/geometry.ts
|
|
129
|
+
function rectsOverlap(a, b, pad = 0) {
|
|
130
|
+
return !(a.x + a.w + pad <= b.x || b.x + b.w + pad <= a.x || a.y + a.h + pad <= b.y || b.y + b.h + pad <= a.y);
|
|
131
|
+
}
|
|
132
|
+
function rectContains(outer, inner, pad = 0) {
|
|
133
|
+
return inner.x >= outer.x + pad && inner.y >= outer.y + pad && inner.x + inner.w <= outer.x + outer.w - pad && inner.y + inner.h <= outer.y + outer.h - pad;
|
|
134
|
+
}
|
|
135
|
+
function polylineYAt(line, x) {
|
|
136
|
+
if (x <= line[0].x) return line[0].y;
|
|
137
|
+
for (let i = 1; i < line.length; i++) {
|
|
138
|
+
let a = line[i - 1], b = line[i];
|
|
139
|
+
if (x <= b.x) return b.x === a.x ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
|
|
140
|
+
}
|
|
141
|
+
return line[line.length - 1].y;
|
|
142
|
+
}
|
|
143
|
+
function pointRectDistance(p, rect) {
|
|
144
|
+
return Math.hypot(Math.max(rect.x - p.x, 0, p.x - rect.x - rect.w), Math.max(rect.y - p.y, 0, p.y - rect.y - rect.h));
|
|
145
|
+
}
|
|
146
|
+
function pointSegmentDistance(x, y, a, b) {
|
|
147
|
+
let dx = b.x - a.x, dy = b.y - a.y, t = dx === 0 && dy === 0 ? 0 : Math.max(0, Math.min(1, ((x - a.x) * dx + (y - a.y) * dy) / (dx * dx + dy * dy)));
|
|
148
|
+
return Math.hypot(x - a.x - t * dx, y - a.y - t * dy);
|
|
149
|
+
}
|
|
150
|
+
function rectLineDistance(rect, line) {
|
|
151
|
+
if (line.length === 1) return pointRectDistance(line[0], rect);
|
|
152
|
+
let right = rect.x + rect.w, bottom = rect.y + rect.h, best = 1 / 0, previousDistance = 1 / 0;
|
|
153
|
+
for (let i = 1; i < line.length; i++) {
|
|
154
|
+
let a = line[i - 1], b = line[i];
|
|
155
|
+
if (segmentHitsRect(a, b, rect)) return 0;
|
|
156
|
+
i === 1 && (previousDistance = pointRectDistance(a, rect));
|
|
157
|
+
let nextDistance = pointRectDistance(b, rect);
|
|
158
|
+
best = Math.min(
|
|
159
|
+
best,
|
|
160
|
+
previousDistance,
|
|
161
|
+
nextDistance,
|
|
162
|
+
pointSegmentDistance(rect.x, rect.y, a, b),
|
|
163
|
+
pointSegmentDistance(right, rect.y, a, b),
|
|
164
|
+
pointSegmentDistance(rect.x, bottom, a, b),
|
|
165
|
+
pointSegmentDistance(right, bottom, a, b)
|
|
166
|
+
), previousDistance = nextDistance;
|
|
167
|
+
}
|
|
168
|
+
return best;
|
|
169
|
+
}
|
|
170
|
+
function sideAwayFrom(point, others) {
|
|
171
|
+
let above = 1 / 0, below = 1 / 0, any = !1;
|
|
172
|
+
for (let line of others) {
|
|
173
|
+
if (line.length === 0 || point.x < line[0].x || point.x > line[line.length - 1].x) continue;
|
|
174
|
+
any = !0;
|
|
175
|
+
let y = polylineYAt(line, point.x);
|
|
176
|
+
y < point.y ? above = Math.min(above, point.y - y) : y > point.y && (below = Math.min(below, y - point.y));
|
|
177
|
+
}
|
|
178
|
+
return any ? below > above ? "below" : "above" : void 0;
|
|
179
|
+
}
|
|
180
|
+
function segmentHitsRect(a, b, rect, pad = 0) {
|
|
181
|
+
let x0 = rect.x - pad, y0 = rect.y - pad, x1 = rect.x + rect.w + pad, y1 = rect.y + rect.h + pad, dx = b.x - a.x, dy = b.y - a.y, t0 = 0, t1 = 1;
|
|
182
|
+
for (let side = 0; side < 4; side++) {
|
|
183
|
+
let p = side === 0 ? -dx : side === 1 ? dx : side === 2 ? -dy : dy, q = side === 0 ? a.x - x0 : side === 1 ? x1 - a.x : side === 2 ? a.y - y0 : y1 - a.y;
|
|
184
|
+
if (p === 0) {
|
|
185
|
+
if (q < 0) return !1;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
let t = q / p;
|
|
189
|
+
if (p < 0 ? t0 = Math.max(t0, t) : t1 = Math.min(t1, t), t0 > t1) return !1;
|
|
190
|
+
}
|
|
191
|
+
return !0;
|
|
192
|
+
}
|
|
193
|
+
function rectHitsConvexPolygon(rect, polygon, pad = 0) {
|
|
194
|
+
let x0 = rect.x - pad, y0 = rect.y - pad, x1 = rect.x + rect.w + pad, y1 = rect.y + rect.h + pad, corners = [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }], axes = [{ x: 1, y: 0 }, { x: 0, y: 1 }];
|
|
195
|
+
return polygon.forEach((p, i) => {
|
|
196
|
+
let q = polygon[(i + 1) % polygon.length];
|
|
197
|
+
(p.x !== q.x || p.y !== q.y) && axes.push({ x: q.y - p.y, y: p.x - q.x });
|
|
198
|
+
}), axes.every((axis) => {
|
|
199
|
+
let a = corners.map((p) => p.x * axis.x + p.y * axis.y), b = polygon.map((p) => p.x * axis.x + p.y * axis.y);
|
|
200
|
+
return Math.max(...a) > minOf(b) && maxOf(b) > Math.min(...a);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function prepareConvexPolygon(polygon) {
|
|
204
|
+
let projected = [[1, 0], [0, 1], ...polygon.map((p, i) => {
|
|
205
|
+
let q = polygon[(i + 1) % polygon.length];
|
|
206
|
+
return [q.y - p.y, p.x - q.x];
|
|
207
|
+
})].filter(([x, y]) => x || y).map(([x, y]) => {
|
|
208
|
+
let values = polygon.map((point) => point.x * x + point.y * y);
|
|
209
|
+
return [x, y, minOf(values), maxOf(values)];
|
|
210
|
+
});
|
|
211
|
+
return (rect, pad) => {
|
|
212
|
+
let x0 = rect.x - pad, y0 = rect.y - pad, x1 = rect.x + rect.w + pad, y1 = rect.y + rect.h + pad;
|
|
213
|
+
return projected.every(([x, y, min, max]) => {
|
|
214
|
+
let a = x0 * x + y0 * y, b = x1 * x + y0 * y, c = x1 * x + y1 * y, d = x0 * x + y1 * y;
|
|
215
|
+
return Math.max(a, b, c, d) > min && max > Math.min(a, b, c, d);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
var deltaGap = (labelHeight) => Math.round(labelHeight);
|
|
220
|
+
function boxGap(a, b) {
|
|
221
|
+
return Math.hypot(Math.max(0, b.x - (a.x + a.w), a.x - (b.x + b.w)), Math.max(0, b.y - (a.y + a.h), a.y - (b.y + b.h)));
|
|
222
|
+
}
|
|
223
|
+
function rectCenter(r) {
|
|
224
|
+
return { x: r.x + r.w / 2, y: r.y + r.h / 2 };
|
|
225
|
+
}
|
|
226
|
+
function inflate(r, by) {
|
|
227
|
+
return { x: r.x - by, y: r.y - by, w: r.w + 2 * by, h: r.h + 2 * by };
|
|
228
|
+
}
|
|
229
|
+
function boundsOf(rects) {
|
|
230
|
+
if (rects.length === 0) return { x: 0, y: 0, w: 0, h: 0 };
|
|
231
|
+
let x0 = 1 / 0, y0 = 1 / 0, x1 = -1 / 0, y1 = -1 / 0;
|
|
232
|
+
for (let r of rects)
|
|
233
|
+
x0 = Math.min(x0, r.x), y0 = Math.min(y0, r.y), x1 = Math.max(x1, r.x + r.w), y1 = Math.max(y1, r.y + r.h);
|
|
234
|
+
return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
|
|
235
|
+
}
|
|
236
|
+
function unionRect(a, b) {
|
|
237
|
+
let x = Math.min(a.x, b.x), y = Math.min(a.y, b.y);
|
|
238
|
+
return {
|
|
239
|
+
x,
|
|
240
|
+
y,
|
|
241
|
+
w: Math.max(a.x + a.w, b.x + b.w) - x,
|
|
242
|
+
h: Math.max(a.y + a.h, b.y + b.h) - y
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function clamp(v, lo, hi) {
|
|
246
|
+
return v < lo ? lo : v > hi ? hi : v;
|
|
247
|
+
}
|
|
248
|
+
function round2(v) {
|
|
249
|
+
return Math.round(v * 100) / 100;
|
|
250
|
+
}
|
|
251
|
+
function strokeBoxPad(width, dx, dy) {
|
|
252
|
+
let r = width / 2, length = Math.hypot(dx, dy);
|
|
253
|
+
return length === 0 ? { x: r, y: r } : { x: r * Math.abs(dy) / length, y: r * Math.abs(dx) / length };
|
|
254
|
+
}
|
|
255
|
+
function rowLabelX(laneX, laneW, labelW, align) {
|
|
256
|
+
return align === "right" ? laneX + laneW - labelW : laneX;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/core/types/annotations.ts
|
|
260
|
+
function defaultAnnotationId(annotation, index) {
|
|
261
|
+
return annotation.id ?? `${annotation.kind}-${index + 1}`;
|
|
262
|
+
}
|
|
263
|
+
var ANNOTATION_KIND_PURPOSES = {
|
|
264
|
+
diff: "Draws a level-difference arrow between two anchors and computes either percent change or their signed value difference.",
|
|
265
|
+
cagr: "Draws a growth arrow between two anchored points and computes the compound annual growth rate from their values and ISO-date span.",
|
|
266
|
+
delta: "Computes the signed difference between an anchored value and another anchor or literal, then places a collision-managed label at the first anchor.",
|
|
267
|
+
abs: "Reads the anchored data value and places its formatted absolute value in a collision-managed label.",
|
|
268
|
+
note: "Places authored text at an anchored data element through collision avoidance, with an optional icon or status chip.",
|
|
269
|
+
callout: "Places authored free text at an anchored data element, routing a leader when displaced and honoring the preferred side.",
|
|
270
|
+
valueLine: "Draws a reference line at an authored value or an engine-computed mean, with optional tolerance shading and attainment fill between the line and resolved actuals.",
|
|
271
|
+
indicator100: "Maps 100 through the chart's value scale and draws a side tick with a 100% label.",
|
|
272
|
+
band: "Draws an inclusive category span as a shaded band or bracket, or a value-axis plan corridor, tolerance band or attainment fill, with a collision-managed label.",
|
|
273
|
+
event: "Places a dated event in the lane above the plot as a block with a pole to the data, or, when it does not fit, as a numbered marker with an entry in the event key below the plot; periods draw a thin bar."
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// src/core/adjacentSeries.ts
|
|
277
|
+
var ORDERED_STEP_FLOOR = 3, orderedRung = (sample, theme) => {
|
|
278
|
+
let kind = sample.paint !== void 0 && "theme" in sample.paint ? sample.paint.theme?.kind : void 0;
|
|
279
|
+
return kind === "ordered-ramp" || kind === "stack-ramp" && (theme.color.stack?.length ?? 0) >= 2;
|
|
280
|
+
}, sideOf = (paint) => paint && "theme" in paint && paint.theme?.kind === "visible-tint" && paint.theme.apart !== void 0 ? paint.theme.base : paint, sameSide = (first, second) => {
|
|
281
|
+
let a = sideOf(first.paint), b = sideOf(second.paint);
|
|
282
|
+
return a !== void 0 && (a !== first.paint || b !== second.paint) && JSON.stringify(a) === JSON.stringify(b);
|
|
283
|
+
};
|
|
284
|
+
function visibleStackSpans(samples) {
|
|
285
|
+
let visible = [];
|
|
286
|
+
for (let sample of samples) {
|
|
287
|
+
let remaining = [];
|
|
288
|
+
for (let earlier of visible)
|
|
289
|
+
earlier.to <= sample.from || earlier.from >= sample.to ? remaining.push(earlier) : (earlier.from < sample.from && remaining.push({ ...earlier, to: sample.from }), earlier.to > sample.to && remaining.push({ ...earlier, from: sample.to }));
|
|
290
|
+
visible = [...remaining, sample];
|
|
291
|
+
}
|
|
292
|
+
return visible;
|
|
293
|
+
}
|
|
294
|
+
function drawnSeries(id) {
|
|
295
|
+
return id.replace(/^(likert:.+):(?:neg|pos)$/, "$1");
|
|
296
|
+
}
|
|
297
|
+
function adjacentSeriesWarnings(samples, stacked, theme) {
|
|
298
|
+
let groups = /* @__PURE__ */ new Map();
|
|
299
|
+
for (let sample of samples) {
|
|
300
|
+
if (!Number.isFinite(sample.from) || !Number.isFinite(sample.to) || !parseColor(sample.css) || stacked && sample.from === sample.to) continue;
|
|
301
|
+
let group = groups.get(sample.categoryId) ?? [];
|
|
302
|
+
group.push({ ...sample, from: Math.min(sample.from, sample.to), to: Math.max(sample.from, sample.to) }), groups.set(sample.categoryId, group);
|
|
303
|
+
}
|
|
304
|
+
let pairs = /* @__PURE__ */ new Map();
|
|
305
|
+
for (let group of groups.values()) {
|
|
306
|
+
let displayed = stacked ? visibleStackSpans(group) : group;
|
|
307
|
+
displayed.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
308
|
+
for (let index = 1; index < displayed.length; index++) {
|
|
309
|
+
let first2 = displayed[index - 1], second = displayed[index];
|
|
310
|
+
if (drawnSeries(first2.seriesId) === drawnSeries(second.seriesId) || (stacked ? second.from > first2.to + 1e-6 : !first2.highlighted && !second.highlighted)) continue;
|
|
311
|
+
let pair = [first2, second].sort((a, b) => a.seriesId < b.seriesId ? -1 : 1), key = JSON.stringify(pair.map((sample) => [sample.seriesId, sample.css])), found = pairs.get(key);
|
|
312
|
+
if (found) {
|
|
313
|
+
found.categories.add(first2.categoryId);
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
let distances = similarPairDistances(first2, second, theme);
|
|
317
|
+
distances && pairs.set(key, { first: first2, second, categories: /* @__PURE__ */ new Set([first2.categoryId]), distances });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (pairs.size === 0) return [];
|
|
321
|
+
let affected = [...pairs.values()], categories = [...new Set(affected.flatMap((pair) => [...pair.categories]))], first = affected[0].first;
|
|
322
|
+
return [{
|
|
323
|
+
code: "series-adjacent-similar",
|
|
324
|
+
severity: "warn",
|
|
325
|
+
message: `Adjacent series colours fall below a palette distance floor in ${pairs.size} pair${pairs.size === 1 ? "" : "s"} across ${categories.length} categor${categories.length === 1 ? "y" : "ies"}: ${affected.map(({ first: first2, second }) => `'${first2.seriesId}' / '${second.seriesId}'`).join(", ")}.`,
|
|
326
|
+
owner: { seriesId: first.seriesId, categoryId: first.categoryId },
|
|
327
|
+
detail: { categories, pairs: affected.map(({ first: first2, second, categories: categories2, distances }) => ({
|
|
328
|
+
seriesIds: [first2.seriesId, second.seriesId],
|
|
329
|
+
colors: [first2.css, second.css],
|
|
330
|
+
categories: [...categories2],
|
|
331
|
+
...distances
|
|
332
|
+
})) },
|
|
333
|
+
suggest: "Choose more distinct authored colours or a palette whose adjacent ranks clear the distance floors."
|
|
334
|
+
}];
|
|
335
|
+
}
|
|
336
|
+
function similarPairDistances(first, second, theme) {
|
|
337
|
+
let normal = palettePerceptualDistance(first.css, second.css, "normal");
|
|
338
|
+
if ((orderedRung(first, theme) && orderedRung(second, theme) || sameSide(first, second)) && normal >= ORDERED_STEP_FLOOR) return;
|
|
339
|
+
let distances = {
|
|
340
|
+
normal,
|
|
341
|
+
protan: palettePerceptualDistance(first.css, second.css, "protan"),
|
|
342
|
+
deutan: palettePerceptualDistance(first.css, second.css, "deutan"),
|
|
343
|
+
tritan: palettePerceptualDistance(first.css, second.css, "tritan")
|
|
344
|
+
};
|
|
345
|
+
if (!(distances.normal >= PALETTE_NORMAL_FLOOR && distances.protan >= PALETTE_CVD_FLOOR && distances.deutan >= PALETTE_CVD_FLOOR && distances.tritan >= PALETTE_TRITAN_FLOOR))
|
|
346
|
+
return distances;
|
|
347
|
+
}
|
|
348
|
+
function identityColour(css, pattern, byStripe, theme) {
|
|
349
|
+
return byStripe && pattern === "hatch45" && theme.pattern.hatchColor !== "ink" ? css : effectiveFill(css, pattern, theme);
|
|
350
|
+
}
|
|
351
|
+
function resolveAdjacentSeriesWarningRule(rule, theme) {
|
|
352
|
+
return adjacentSeriesWarnings(rule.samples.map(({ paint, pattern, byStripe, ...sample }) => ({
|
|
353
|
+
...sample,
|
|
354
|
+
paint,
|
|
355
|
+
css: identityColour(paintColor(theme, paint), pattern, byStripe === !0, theme)
|
|
356
|
+
})), rule.stacked, theme);
|
|
357
|
+
}
|
|
358
|
+
function retainAdjacentWarningRule(samples, stacked, capture) {
|
|
359
|
+
capture && samples.length > 0 && capture.rules.push({
|
|
360
|
+
kind: "series-adjacent-similar",
|
|
361
|
+
stacked,
|
|
362
|
+
before: capture.before,
|
|
363
|
+
samples: samples.map(({ css: _css, ...sample }) => sample)
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function rectSeriesAdjacentWarnings(nodes, paintCss, orientation, highlights, theme, capture, resolve = !0) {
|
|
367
|
+
let stacks = [], groups = [];
|
|
368
|
+
for (let node of nodes) {
|
|
369
|
+
if (node.t !== "rect" || node.part !== "bar" && node.part !== "segment") continue;
|
|
370
|
+
let { seriesId, categoryId } = node.owner;
|
|
371
|
+
if (!seriesId || !categoryId || node.rect.w <= 0 || node.rect.h <= 0) continue;
|
|
372
|
+
let stacked = node.part === "segment", alongY = stacked === (orientation === "vertical"), from = alongY ? node.rect.y : node.rect.x, extent = alongY ? node.rect.h : node.rect.w, paint = (node.pattern === "outline" || node.pattern === "hollow") && node.stroke ? node.stroke : node.fill;
|
|
373
|
+
(stacked ? stacks : groups).push({
|
|
374
|
+
seriesId,
|
|
375
|
+
categoryId,
|
|
376
|
+
from,
|
|
377
|
+
to: from + extent,
|
|
378
|
+
paint,
|
|
379
|
+
...node.pattern === "hatch45" ? { pattern: "hatch45", byStripe: !0 } : {},
|
|
380
|
+
css: identityColour(paintCss(paint), node.pattern === "hatch45" ? "hatch45" : void 0, !0, theme),
|
|
381
|
+
highlighted: highlights.has(seriesId) || highlights.has(categoryId) || "token" in paint && (paint.token === "highlight" || paint.token === "focus")
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return retainAdjacentWarningRule(stacks, !0, capture), retainAdjacentWarningRule(groups, !1, capture), resolve ? [...adjacentSeriesWarnings(stacks, !0, theme), ...adjacentSeriesWarnings(groups, !1, theme)] : [];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/core/paintWarnings.ts
|
|
388
|
+
function highlightPaintWarnings(theme, chart) {
|
|
389
|
+
let focused = chart === "waterfall" && theme.color.focus !== void 0, paint = focused ? focusColor(theme) : theme.color.highlight, role = focused ? "focus colour" : "accent";
|
|
390
|
+
return readsAsLoss(paint) ? [{
|
|
391
|
+
code: "highlight-reads-as-loss",
|
|
392
|
+
severity: "warn",
|
|
393
|
+
message: `the theme ${role} ${paint} is a warm red or orange; a highlighted ${chart === "waterfall" ? "step" : "variance"} in that colour reads as a loss`,
|
|
394
|
+
suggest: chart === "waterfall" ? "use a theme with a cool accent (boardroom, studio) for bridges, or drop the highlight" : "use a theme with a cool accent for variance charts, or drop the highlight"
|
|
395
|
+
}] : [];
|
|
396
|
+
}
|
|
397
|
+
function othersShadeUnavailableWarnings(theme, base) {
|
|
398
|
+
let named = paintColor(theme, base), others = paintTokenColor(theme, "othersMark");
|
|
399
|
+
return contrastRatio(named, theme.color.background) > contrastRatio(others, theme.color.background) ? [] : [{
|
|
400
|
+
code: "others-shade-unavailable",
|
|
401
|
+
severity: "info",
|
|
402
|
+
message: `the Others colour '${others}' is stronger on the page than the first named step '${named}', so Others cannot be the quietest part; the ramp keeps the 'apart' shades`,
|
|
403
|
+
suggest: "use a quieter othersMark or othersShade: 'apart'"
|
|
404
|
+
}];
|
|
405
|
+
}
|
|
406
|
+
function markLostOnBandWarnings(theme, pairs) {
|
|
407
|
+
let visiblePaints = (pair) => isHatchPattern(pair.pattern) ? [
|
|
408
|
+
pair.hatchGround ?? { token: "background" },
|
|
409
|
+
...hatchStrokeWidthFor(theme, pair.hatch) > 0 ? [hatchPaint(pair.fill, theme, pair.hatchGround, pair.hatch)] : [],
|
|
410
|
+
...pair.hatchEdge !== !1 && strokeToken(theme, "hair") > 0 ? [pair.fill] : []
|
|
411
|
+
] : pair.pattern === "outline" && solidMutedPlan(theme) ? [PLAN_MUTED_PAINT] : pair.pattern === "outline" || pair.pattern === "hollow" ? [
|
|
412
|
+
{ token: "background" },
|
|
413
|
+
...theme.pattern.outlineStrokeWidth > 0 ? [pair.fill] : []
|
|
414
|
+
] : [pair.fill, ...pair.stroke && (pair.strokeWidth ?? strokeToken(theme, "mark")) > 0 ? [pair.stroke] : []];
|
|
415
|
+
return [...new Map(pairs.filter((pair) => visiblePaints(pair).every((paint) => contrastRatio(paintColor(theme, paint), paintColor(theme, pair.band)) < FILL_SEPARATION_FLOOR)).map((pair) => [pair.name, pair.owner]))].map(([name, owner]) => ({
|
|
416
|
+
code: "mark-lost-on-band",
|
|
417
|
+
severity: "warn",
|
|
418
|
+
message: `'${name}' has no visible contrast against the band behind it and disappears inside the band`,
|
|
419
|
+
suggest: "give the series a fill or colorRole that stands apart from the band, or move the band off its marks",
|
|
420
|
+
owner
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
function groundTextWarnings(theme, texts) {
|
|
424
|
+
let tones = /* @__PURE__ */ new Set(), unreadable = /* @__PURE__ */ new Map();
|
|
425
|
+
for (let text of texts) {
|
|
426
|
+
let source = "theme" in text ? text.theme : void 0;
|
|
427
|
+
if (source?.kind !== "ground-text") continue;
|
|
428
|
+
let far = farGround(theme, source.ground);
|
|
429
|
+
if (far === void 0) continue;
|
|
430
|
+
let tone = source.far !== void 0 && "token" in source.far && ["good", "bad", "warn"].includes(source.far.token) ? source.far.token : void 0;
|
|
431
|
+
tone !== void 0 && seriesTextAlone(paintColor(theme, source.far), far) === void 0 && tones.add(tone);
|
|
432
|
+
let ratio = contrastRatio(paintColor(theme, text), far);
|
|
433
|
+
ratio < 4.5 && unreadable.set(far, Math.min(ratio, unreadable.get(far) ?? 1 / 0));
|
|
434
|
+
}
|
|
435
|
+
return [
|
|
436
|
+
...tones.size > 0 ? [{
|
|
437
|
+
code: "table-tone-text-unreadable",
|
|
438
|
+
severity: "warn",
|
|
439
|
+
message: `no step of the ${[...tones].join(", ")} tone reads at 4.5:1 on an authored table ground on the other side of the page's lightness, so its toned text prints in the ground's readable ink`,
|
|
440
|
+
suggest: "choose table.grounds on the page side of lightness, or tone colours that stand apart from them"
|
|
441
|
+
}] : [],
|
|
442
|
+
...unreadable.size > 0 ? [{
|
|
443
|
+
code: "table-ground-text-unreadable",
|
|
444
|
+
severity: "warn",
|
|
445
|
+
message: `no ink reads at 4.5:1 on the authored table ground ${[...unreadable].map(([ground, ratio]) => `${ground} (${ratio.toFixed(2)}:1)`).join(", ")}, so its text prints in the ink that reads best`,
|
|
446
|
+
suggest: "choose table.grounds further from mid-grey, lighter or darker"
|
|
447
|
+
}] : []
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
function resolvePaintWarnings(theme, rules) {
|
|
451
|
+
return rules.flatMap((rule) => {
|
|
452
|
+
if (rule.kind === "series-adjacent-similar") return resolveAdjacentSeriesWarningRule(rule, theme);
|
|
453
|
+
if (rule.kind === "highlight-reads-as-loss") return highlightPaintWarnings(theme, rule.chart);
|
|
454
|
+
if (rule.kind === "bullet-band-lightness") {
|
|
455
|
+
let warnings = [];
|
|
456
|
+
return bulletBandPaints(theme, rule.count, rule.poor, rule.good, warnings, rule.light === !0), warnings;
|
|
457
|
+
}
|
|
458
|
+
if (rule.kind === "line-band-authored-contrast") return lineBandAuthoredWarnings(theme, rule.base, rule.seriesId, rule.authoredSource, rule.authored);
|
|
459
|
+
if (rule.kind === "others-shade-unavailable") return othersShadeUnavailableWarnings(theme, rule.base);
|
|
460
|
+
if (rule.kind === "mark-lost-on-band") return markLostOnBandWarnings(theme, rule.pairs);
|
|
461
|
+
if (rule.kind === "table-ground-text") return groundTextWarnings(theme, rule.texts);
|
|
462
|
+
if (rule.kind === "pie-ramp-crowded") {
|
|
463
|
+
let base = paintColor(theme, rule.base), ramp = pieRamp(base, theme.color.background, rule.count, rule.withOthers ? paintTokenColor(theme, "othersMark") : void 0, rule.othersShade !== "apart", theme.marks?.contrastEdge !== !0);
|
|
464
|
+
return ramp.distinguishableCount < rule.count ? [{
|
|
465
|
+
code: rule.kind,
|
|
466
|
+
severity: "warn",
|
|
467
|
+
message: `${rule.count} slices exceed the ${ramp.distinguishableCount} distinguishable tint steps of '${base}'; adjacent slices may read alike \u2014 group small slices into 'Others'`
|
|
468
|
+
}] : [];
|
|
469
|
+
}
|
|
470
|
+
let background = theme.color.background, floor = contrastRatio(background, "#FFFFFF") > contrastRatio(background, "#000000") ? 3 : 1.4, sunk = rule.options.flatMap((option) => {
|
|
471
|
+
let token = paintColor(theme, option.paint);
|
|
472
|
+
return visibleTintAmount(theme, {
|
|
473
|
+
kind: "visible-tint",
|
|
474
|
+
base: option.paint,
|
|
475
|
+
amount: option.amount,
|
|
476
|
+
floor: "mark"
|
|
477
|
+
}) === 0 && contrastRatio(token, background) < floor ? [`'${option.label}' (${token}, ${contrastRatio(token, background).toFixed(2)}:1)`] : [];
|
|
478
|
+
});
|
|
479
|
+
return sunk.length ? [{
|
|
480
|
+
code: rule.kind,
|
|
481
|
+
severity: "warn",
|
|
482
|
+
message: `the theme's tone for ${sunk.join(", ")} does not reach ${floor}:1 on the background '${background}', so it is drawn at full strength and may still be hard to see`,
|
|
483
|
+
suggest: "separate color.bad / color.good / color.neutral from color.background in the theme \u2014 a response option the reader cannot see is a missing mark, not a subtle one"
|
|
484
|
+
}] : [];
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
var managedCodes = (rules) => new Set(rules.flatMap((rule) => rule.kind === "bullet-band-lightness" ? ["band-lightness-insufficient"] : rule.kind === "table-ground-text" ? ["table-tone-text-unreadable", "table-ground-text-unreadable"] : [rule.kind]));
|
|
488
|
+
function dropWarnings(geo, keep) {
|
|
489
|
+
let rules = geo.paintWarningRules;
|
|
490
|
+
if (rules?.length) {
|
|
491
|
+
let managed = managedCodes(rules), ordinary = geo.warnings.filter((warning) => !managed.has(warning.code));
|
|
492
|
+
geo.paintWarningRules = rules.map((rule) => ({ ...rule, before: rule.before - ordinary.slice(0, rule.before).filter((warning) => !keep(warning)).length }));
|
|
493
|
+
}
|
|
494
|
+
geo.warnings = geo.warnings.filter(keep);
|
|
495
|
+
}
|
|
496
|
+
function refreshPaintWarnings(warnings, rules, theme) {
|
|
497
|
+
let managed = managedCodes(rules), ordinary = warnings.filter((warning) => !managed.has(warning.code)), result = [];
|
|
498
|
+
for (let i = 0; i <= ordinary.length; i++) {
|
|
499
|
+
for (let rule of rules)
|
|
500
|
+
Math.min(rule.before, ordinary.length) === i && result.push(...resolvePaintWarnings(theme, [rule]));
|
|
501
|
+
i < ordinary.length && result.push(ordinary[i]);
|
|
502
|
+
}
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/core/textRole.ts
|
|
507
|
+
function labelTypeRole(label) {
|
|
508
|
+
if (label.typeRole !== void 0) return label.typeRole;
|
|
509
|
+
switch (label.kind) {
|
|
510
|
+
case "title":
|
|
511
|
+
return "title";
|
|
512
|
+
case "subtitle":
|
|
513
|
+
return "subtitle";
|
|
514
|
+
case "source":
|
|
515
|
+
case "footnote":
|
|
516
|
+
return "footnote";
|
|
517
|
+
case "tick":
|
|
518
|
+
case "category":
|
|
519
|
+
case "axisTitle":
|
|
520
|
+
case "tableHeader":
|
|
521
|
+
case "tableHeaderSub":
|
|
522
|
+
case "tableGroupHeader":
|
|
523
|
+
return "axis";
|
|
524
|
+
default:
|
|
525
|
+
return "label";
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
var NAMED_PARTS = [
|
|
529
|
+
["note", "footnote tableCellNote annotation"],
|
|
530
|
+
["caption", "axisTitle panelTitle panelCaption tierCaption diagramCaption"],
|
|
531
|
+
["axis", "tick scale"],
|
|
532
|
+
["category", "category series legendLabel legendHeading activity item tableHeader tableHeaderSub tableGroupHeader diagramNode diagramSecondary diagramEdge diagramGroup diagramLane overlayLabel"]
|
|
533
|
+
], PART_ROLES = new Map(NAMED_PARTS.flatMap(([role, parts]) => parts.split(" ").map((part) => [part, role]))), ROLES = /* @__PURE__ */ new Set(["title", "subtitle", "value", "axis", "category", "caption", "note", "source"]);
|
|
534
|
+
function textRole(node) {
|
|
535
|
+
return node.role !== void 0 && ROLES.has(node.role) ? node.role : node.part === "title" || node.part === "subtitle" || node.part === "source" ? node.part : node.part === "credit" ? "source" : PART_ROLES.get(node.part) ?? "value";
|
|
536
|
+
}
|
|
537
|
+
var CURRENCY_SIGN = "$\u20AC\xA3\xA5\u20B9\u20BD\xA2\u20A9", CURRENCY_CODE = "EUR|USD|GBP|CHF|JPY|CNY|SEK|NOK|DKK|PLN|CZK|HUF|CAD|AUD|NZD|INR|BRL|MXN|ZAR|SGD|HKD|KRW", MAGNITUDE = "(?:k|K|m|M|bn|Bn|BN|b|B|t|T|Mio|Mrd)", CURRENCY = `(?:[${CURRENCY_SIGN}]|(?:${CURRENCY_CODE})\\b)`, DIGITS = "\\p{Nd}[\\p{Nd}.,'\u2019\xA0\u202F\u066B\u066C\u060C ]*", SIGN = "[+\\-\u2013\u2212\u061C\u200E\u200F]*", PERCENT = "(?:%|\u066A|\u2030|pp|x|\xD7)", ONE_NUMBER = `${SIGN}\\s?${CURRENCY}?\\s?${SIGN}${DIGITS}${MAGNITUDE}?\\s?${PERCENT}?[\u061C\u200E\u200F]?\\s?${CURRENCY}?\\s?${MAGNITUDE}?`, NUMBER_ALONE = new RegExp(
|
|
538
|
+
`^(?:${ONE_NUMBER}(?:\\s?\\(${ONE_NUMBER}\\))?|\\(${ONE_NUMBER}\\))$`,
|
|
539
|
+
"u"
|
|
540
|
+
), NUMBER_PLACEHOLDER = /^(?:n\/a|n\.m\.|[-–—])$/;
|
|
541
|
+
function isNumberAlone(text) {
|
|
542
|
+
let trimmed = text.replace(/\s+/g, " ").trim();
|
|
543
|
+
return trimmed === "" ? !0 : NUMBER_PLACEHOLDER.test(trimmed) || NUMBER_ALONE.test(trimmed);
|
|
544
|
+
}
|
|
545
|
+
function composedTextRole(text, prose = "caption") {
|
|
546
|
+
return isNumberAlone(text) ? "value" : prose;
|
|
547
|
+
}
|
|
548
|
+
function computedTextRole(text, computed) {
|
|
549
|
+
return text === computed && isNumberAlone(text) ? "value" : "note";
|
|
550
|
+
}
|
|
551
|
+
function isNumericRole(role) {
|
|
552
|
+
return role === "value" || role === "axis";
|
|
553
|
+
}
|
|
554
|
+
function numericVariant(role, theme) {
|
|
555
|
+
if (isNumericRole(role))
|
|
556
|
+
return theme.type.numeric === "proportional" ? "proportional-nums" : "tabular-nums";
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// src/core/label/occupied.ts
|
|
560
|
+
var CELL = 16;
|
|
561
|
+
function cellRange(rect, pad) {
|
|
562
|
+
let x0 = Math.floor((rect.x - pad) / CELL), x1 = Math.floor((rect.x + rect.w + pad) / CELL), y0 = Math.floor((rect.y - pad) / CELL), y1 = Math.floor((rect.y + rect.h + pad) / CELL);
|
|
563
|
+
if (x0 <= x1 && y0 <= y1 && (x1 - x0 + 1) * (y1 - y0 + 1) <= 256 && Math.max(-x0, x1, -y0, y1) < 32768)
|
|
564
|
+
return [x0, x1, y0, y1];
|
|
565
|
+
}
|
|
566
|
+
function createOccupiedIndex(_plot) {
|
|
567
|
+
let rects = [], cells = /* @__PURE__ */ new Map(), wide = [], polygonTests = [], hit = (index, rect, pad) => {
|
|
568
|
+
let claim = rects[index];
|
|
569
|
+
return rectsOverlap(claim.rect, rect, pad) && (claim.polygon === void 0 || (polygonTests[index] ??= prepareConvexPolygon(claim.polygon))(rect, pad));
|
|
570
|
+
}, seen = [], stamp = 0, visiting = !1, visitNear = (rect, pad, visit) => {
|
|
571
|
+
if (visiting) throw new Error("occupied index: a query ran inside another query's callback");
|
|
572
|
+
visiting = !0;
|
|
573
|
+
try {
|
|
574
|
+
return visitClaims(rect, pad, visit);
|
|
575
|
+
} finally {
|
|
576
|
+
visiting = !1;
|
|
577
|
+
}
|
|
578
|
+
}, visitClaims = (rect, pad, visit) => {
|
|
579
|
+
let range = cellRange(rect, pad);
|
|
580
|
+
if (range === void 0) {
|
|
581
|
+
for (let i = 0; i < rects.length; i++) if (visit(i)) return !0;
|
|
582
|
+
return !1;
|
|
583
|
+
}
|
|
584
|
+
stamp++;
|
|
585
|
+
for (let w = 0; w < wide.length; w++) if (visit(wide[w])) return !0;
|
|
586
|
+
let [x0, x1, y0, y1] = range;
|
|
587
|
+
for (let x = x0; x <= x1; x++)
|
|
588
|
+
for (let y = y0; y <= y1; y++) {
|
|
589
|
+
let cell = cells.get(x * 65536 + y);
|
|
590
|
+
if (cell !== void 0)
|
|
591
|
+
for (let c = 0; c < cell.length; c++) {
|
|
592
|
+
let i = cell[c];
|
|
593
|
+
if (seen[i] !== stamp && (seen[i] = stamp, visit(i)))
|
|
594
|
+
return !0;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return !1;
|
|
598
|
+
};
|
|
599
|
+
return {
|
|
600
|
+
claim(rect, kind, owner, part, polygon) {
|
|
601
|
+
let claimed = part === void 0 ? { rect: { ...rect }, kind, owner } : { rect: { ...rect }, kind, owner, part };
|
|
602
|
+
polygon !== void 0 && (claimed.polygon = polygon.map((point) => ({ ...point })));
|
|
603
|
+
let index = rects.push(claimed) - 1, range = cellRange(rect, 0);
|
|
604
|
+
if (range === void 0) wide.push(index);
|
|
605
|
+
else {
|
|
606
|
+
let [x0, x1, y0, y1] = range;
|
|
607
|
+
for (let x = x0; x <= x1; x++) for (let y = y0; y <= y1; y++) {
|
|
608
|
+
let key = x * 65536 + y, cell = cells.get(key);
|
|
609
|
+
cell === void 0 ? cells.set(key, [index]) : cell.push(index);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
hits(rect, pad = 0, skip) {
|
|
614
|
+
return visitNear(rect, pad, (i) => !skip?.(rects[i]) && hit(i, rect, pad));
|
|
615
|
+
},
|
|
616
|
+
some(rect, pad, test) {
|
|
617
|
+
return visitNear(rect, pad, (i) => hit(i, rect, pad) && test(rects[i]));
|
|
618
|
+
},
|
|
619
|
+
hitsWhich(rect, pad = 0, skip) {
|
|
620
|
+
let found = [];
|
|
621
|
+
return visitNear(rect, pad, (i) => (!skip?.(rects[i]) && hit(i, rect, pad) && found.push(i), !1)), found.sort((a, b) => a - b).map((i) => rects[i]);
|
|
622
|
+
},
|
|
623
|
+
snapshot() {
|
|
624
|
+
return rects.map((entry) => ({ ...entry, rect: { ...entry.rect } }));
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// src/core/label/ownership.ts
|
|
630
|
+
function circleGap(rect, m) {
|
|
631
|
+
let dx = Math.max(rect.x - m.cx, 0, m.cx - rect.x - rect.w), dy = Math.max(rect.y - m.cy, 0, m.cy - rect.y - rect.h);
|
|
632
|
+
return Math.max(0, Math.hypot(dx, dy) - m.r);
|
|
633
|
+
}
|
|
634
|
+
function segmentDistance(a, b, x, y) {
|
|
635
|
+
let vx = b.x - a.x, vy = b.y - a.y, len2 = vx * vx + vy * vy, t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((x - a.x) * vx + (y - a.y) * vy) / len2));
|
|
636
|
+
return Math.hypot(a.x + t * vx - x, a.y + t * vy - y);
|
|
637
|
+
}
|
|
638
|
+
function segmentEntersRect(a, b, r) {
|
|
639
|
+
for (let i = 0; i <= 8; i++) {
|
|
640
|
+
let x = a.x + (b.x - a.x) * i / 8, y = a.y + (b.y - a.y) * i / 8;
|
|
641
|
+
if (x > r.x && x < r.x + r.w && y > r.y && y < r.y + r.h) return !0;
|
|
642
|
+
}
|
|
643
|
+
return !1;
|
|
644
|
+
}
|
|
645
|
+
function somePathPiece(d, steps, hit) {
|
|
646
|
+
let n = d.trim().split(/[\s,A-Za-z]+/).filter(Boolean).map(Number);
|
|
647
|
+
if (n.length < 8) return hit({ x: n[0], y: n[1] }, { x: n[2], y: n[3] });
|
|
648
|
+
let at = (t) => {
|
|
649
|
+
let u = 1 - t, [a, b, c, e] = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t];
|
|
650
|
+
return { x: a * n[0] + b * n[2] + c * n[4] + e * n[6], y: a * n[1] + b * n[3] + c * n[5] + e * n[7] };
|
|
651
|
+
};
|
|
652
|
+
for (let i = 0; i < steps; i++) if (hit(at(i / steps), at((i + 1) / steps))) return !0;
|
|
653
|
+
return !1;
|
|
654
|
+
}
|
|
655
|
+
function nearestIsOwn(rect, own, marks) {
|
|
656
|
+
let mine = circleGap(rect, own);
|
|
657
|
+
return marks.every((m) => m.id === own.id || circleGap(rect, m) > mine);
|
|
658
|
+
}
|
|
659
|
+
function leaderCrosses(d, own, marks, texts = []) {
|
|
660
|
+
let nums = d.match(/-?\d+(?:\.\d+)?/g).map(Number), x0 = 1 / 0, y0 = 1 / 0, x1 = -1 / 0, y1 = -1 / 0;
|
|
661
|
+
for (let i = 0; i + 1 < nums.length; i += 2)
|
|
662
|
+
x0 = Math.min(x0, nums[i]), x1 = Math.max(x1, nums[i]), y0 = Math.min(y0, nums[i + 1]), y1 = Math.max(y1, nums[i + 1]);
|
|
663
|
+
let near = marks.filter((m) => m.id !== own.id && m.r > 0 && m.cx + m.r > x0 && m.cx - m.r < x1 && m.cy + m.r > y0 && m.cy - m.r < y1), nearTexts = texts.filter((t) => t.x < x1 && t.x + t.w > x0 && t.y < y1 && t.y + t.h > y0);
|
|
664
|
+
return near.length === 0 && nearTexts.length === 0 ? !1 : somePathPiece(d, 16, (a, b) => near.some((m) => segmentDistance(a, b, m.cx, m.cy) < m.r) || nearTexts.some((t) => segmentEntersRect(a, b, t)));
|
|
665
|
+
}
|
|
666
|
+
function inkBox(rect, fontSize) {
|
|
667
|
+
let inset = fontSize === void 0 ? 0 : Math.min(rect.h / 2, CAP_AIR * fontSize);
|
|
668
|
+
return { x: rect.x, y: rect.y + inset, w: rect.w, h: rect.h - inset };
|
|
669
|
+
}
|
|
670
|
+
var CAP_AIR = 0.25;
|
|
671
|
+
function pointOwnership(input) {
|
|
672
|
+
let byKey = new Map(input.points.map((p) => [`${p.seriesId}\0${p.categoryId}`, p])), xs = [...input.categoryX].sort((a, b) => a[1] - b[1]), bands = /* @__PURE__ */ new Map();
|
|
673
|
+
for (let i = 0; i < xs.length; i++) {
|
|
674
|
+
let [id, x] = xs[i], left = i > 0 ? (x - xs[i - 1][1]) / 2 : void 0, right = i + 1 < xs.length ? (xs[i + 1][1] - x) / 2 : void 0, half = (side, other) => side ?? other ?? 0;
|
|
675
|
+
bands.set(id, [x - half(left, right), x + half(right, left)]);
|
|
676
|
+
}
|
|
677
|
+
let byX = [...input.points].sort((a, b) => a.x - b.x), firstAtOrRight = (x) => {
|
|
678
|
+
let lo = 0, hi = byX.length;
|
|
679
|
+
for (; lo < hi; ) {
|
|
680
|
+
let mid = lo + hi >> 1;
|
|
681
|
+
byX[mid].x < x ? lo = mid + 1 : hi = mid;
|
|
682
|
+
}
|
|
683
|
+
return lo;
|
|
684
|
+
};
|
|
685
|
+
return {
|
|
686
|
+
pointsIn: (x0, x1) => {
|
|
687
|
+
let out = [];
|
|
688
|
+
for (let i = firstAtOrRight(x0); i < byX.length && byX[i].x <= x1; i++) out.push(byX[i]);
|
|
689
|
+
return out;
|
|
690
|
+
},
|
|
691
|
+
pointOf: (seriesId, categoryId) => seriesId === void 0 || categoryId === void 0 ? void 0 : byKey.get(`${seriesId}\0${categoryId}`),
|
|
692
|
+
points: input.points,
|
|
693
|
+
bands
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
var SAME_POINT = 0.5, NEARER_BY = 3, BAND_BY = 1, LEADER_POINT_R = 3;
|
|
697
|
+
function readsAsOwnPoint(rect, own, model, fontSize) {
|
|
698
|
+
let ink = inkBox(rect, fontSize), gap = (p) => Math.hypot(Math.max(ink.x - p.x, 0, p.x - ink.x - ink.w), Math.max(ink.y - p.y, 0, p.y - ink.y - ink.h)), mine = gap(own);
|
|
699
|
+
for (let p of model.pointsIn(ink.x - mine, ink.x + ink.w + mine))
|
|
700
|
+
if (!(p === own || Math.abs(p.x - own.x) < SAME_POINT && Math.abs(p.y - own.y) < SAME_POINT) && gap(p) + NEARER_BY < mine)
|
|
701
|
+
return !1;
|
|
702
|
+
if (ink.x <= own.x && own.x <= ink.x + ink.w) return !0;
|
|
703
|
+
let cover = (band) => Math.max(0, Math.min(ink.x + ink.w, band[1]) - Math.max(ink.x, band[0])), ownBand = model.bands.get(own.categoryId), mineCover = ownBand ? cover(ownBand) : 0;
|
|
704
|
+
for (let [id, band] of model.bands) if (id !== own.categoryId && cover(band) > mineCover + BAND_BY) return !1;
|
|
705
|
+
return !0;
|
|
706
|
+
}
|
|
707
|
+
function besideOtherPoint(rect, own, model, fontSize) {
|
|
708
|
+
let ink = inkBox(rect, fontSize), dx = (p) => Math.max(ink.x - p.x, 0, p.x - ink.x - ink.w), dy = (p) => Math.max(ink.y - p.y, 0, p.y - ink.y - ink.h), mine = Math.hypot(dx(own), dy(own));
|
|
709
|
+
return model.pointsIn(ink.x - mine, ink.x + ink.w + mine).some((p) => p !== own && !(Math.abs(p.x - own.x) < SAME_POINT && Math.abs(p.y - own.y) < SAME_POINT) && (dy(p) <= ALIGNED && dx(p) < rect.h || dx(p) <= ALIGNED && dy(p) < rect.h) && Math.hypot(dx(p), dy(p)) + NEARER_BY < mine);
|
|
710
|
+
}
|
|
711
|
+
var ALIGNED = 2;
|
|
712
|
+
function leaderReadsAsOwn(d, own, model) {
|
|
713
|
+
let ownMark = { id: own, cx: own.x, cy: own.y, r: LEADER_POINT_R }, xs = (d.match(/-?\d+(?:\.\d+)?/g) ?? []).map(Number).filter((_, i) => i % 2 === 0), marks = model.pointsIn(Math.min(...xs) - LEADER_POINT_R, Math.max(...xs) + LEADER_POINT_R).filter((p) => p !== own && !(Math.abs(p.x - own.x) < SAME_POINT && Math.abs(p.y - own.y) < SAME_POINT)).map((p) => ({ id: p, cx: p.x, cy: p.y, r: LEADER_POINT_R }));
|
|
714
|
+
return !leaderCrosses(d, ownMark, marks);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// src/core/label/solver.ts
|
|
718
|
+
var SERIES_VALUE_GAP = 6, TOTAL_KINDS = /* @__PURE__ */ new Set(["total", "grandTotal"]), TOTAL_PART = "totalValue", AREA_FILL_PART = "areaFill", PRIORITY = {
|
|
719
|
+
reference: 1500,
|
|
720
|
+
grandTotal: 900,
|
|
721
|
+
total: 800,
|
|
722
|
+
valueLine: 700,
|
|
723
|
+
endpoint: 600,
|
|
724
|
+
extreme: 500,
|
|
725
|
+
interior: 100,
|
|
726
|
+
highlightBonus: 250
|
|
727
|
+
}, focusBonus = PRIORITY.highlightBonus;
|
|
728
|
+
function focusMatches(owner, focus) {
|
|
729
|
+
let keys = Object.keys(focus.owner);
|
|
730
|
+
return keys.length > 0 && keys.every((key) => focus.owner[key] !== void 0 && focus.owner[key] === owner[key]);
|
|
731
|
+
}
|
|
732
|
+
function labelOrder(pinOf, focus, useOrder = !0) {
|
|
733
|
+
let boost = (request) => focus && focusMatches(request.owner, focus) ? focusBonus : 0;
|
|
734
|
+
return (a, b) => {
|
|
735
|
+
let pa = pinOf(a) ? 1 : 0, pb = pinOf(b) ? 1 : 0;
|
|
736
|
+
if (pa !== pb) return pb - pa;
|
|
737
|
+
let sa = a.priority + boost(a), sb = b.priority + boost(b);
|
|
738
|
+
return sa !== sb ? sb - sa : useOrder && a.order !== void 0 && b.order !== void 0 && a.order !== b.order ? a.order - b.order : a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function labelCtx(theme, size, options, rest) {
|
|
742
|
+
return {
|
|
743
|
+
focus: options.focus,
|
|
744
|
+
density: options.labelDensity ?? "smart",
|
|
745
|
+
pins: options.labelPlacements ?? {},
|
|
746
|
+
canvas: { x: 0, y: 0, w: size.width, h: size.height },
|
|
747
|
+
darkInk: theme.color.ink,
|
|
748
|
+
lightInk: theme.color.inkInverse,
|
|
749
|
+
...rest
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
var DENSITY_MIN_PRIORITY = PRIORITY.endpoint, REQUIRED_VALUE_PRIORITY = PRIORITY.valueLine;
|
|
753
|
+
function solveLabels(requests, occupied, ctx) {
|
|
754
|
+
if (!ctx.valueRows?.length) return solveLabelPass(requests, occupied, ctx);
|
|
755
|
+
let initial = occupied.snapshot(), pinned = new Set(requests.filter((req) => req.pinnedSlot ?? ctx.pins[req.id]).map((req) => req.id)), rows = ctx.valueRows.map((row) => ({ ...row, eligible: [], mode: "all", reason: "" })), dropped = /* @__PURE__ */ new Set();
|
|
756
|
+
if (rows.length === 1 && pinned.size === 0 && ctx.density !== "minimal" && !ctx.seriesUniform && !requests.some((req) => req.printedIn)) {
|
|
757
|
+
let row = rows[0], byId = new Map(requests.map((req) => [req.id, req]));
|
|
758
|
+
if (byId.size === requests.length && new Set(row.ids).size === row.ids.length)
|
|
759
|
+
for (row.eligible = row.ids.filter((id) => {
|
|
760
|
+
let req = byId.get(id);
|
|
761
|
+
return req && !(req.redundant && req.suppressedAs !== "density");
|
|
762
|
+
}); row.mode !== "none" && row.eligible.length >= 2; ) {
|
|
763
|
+
let unseated = row.eligible.find((id) => !dropped.has(id) && byId.get(id).candidates.length === 0);
|
|
764
|
+
if (unseated === void 0) break;
|
|
765
|
+
let skipped = row.mode;
|
|
766
|
+
row.mode = row.mode === "all" && row.alternate ? "alternate" : "none", row.reason = `computed row ${row.mode === "alternate" ? "uses alternate values from the end" : "omitted"}; skipped ${skipped}: no candidate for '${unseated}'`, row.eligible.forEach((id, index) => {
|
|
767
|
+
(row.mode === "none" || (row.eligible.length - 1 - index) % 2 !== 0) && dropped.add(id);
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
for (; ; ) {
|
|
772
|
+
let attempt2 = createOccupiedIndex(ctx.plot);
|
|
773
|
+
attempt2.tickColumns = occupied.tickColumns;
|
|
774
|
+
for (let claim of initial) attempt2.claim(claim.rect, claim.kind, claim.owner, claim.part, claim.polygon);
|
|
775
|
+
let result = solveLabelPass(requests.map((req) => dropped.has(req.id) ? { ...req, redundant: !0, suppressedAs: "density" } : req), attempt2, ctx), byId = new Map(result.placed.map((label) => [label.id, label])), retry = !1;
|
|
776
|
+
for (let row of rows) {
|
|
777
|
+
if (row.mode === "none") continue;
|
|
778
|
+
row.mode === "all" && (row.eligible = row.ids.filter((id) => {
|
|
779
|
+
let label = byId.get(id);
|
|
780
|
+
return label && label.hidden !== "redundant" && !label.printedIn;
|
|
781
|
+
}));
|
|
782
|
+
let failed = row.eligible.filter((id) => !dropped.has(id) && byId.get(id)?.hidden);
|
|
783
|
+
row.eligible.length < 2 || failed.length === 0 || (row.mode = row.mode === "all" && row.alternate ? "alternate" : "none", row.reason = `computed row ${row.mode === "alternate" ? "uses alternate values from the end" : "omitted"}; unplaced: ${failed.join(", ")}`, row.eligible.forEach((id, index) => {
|
|
784
|
+
!pinned.has(id) && (row.mode === "none" || (row.eligible.length - 1 - index) % 2 !== 0) && dropped.add(id);
|
|
785
|
+
}), retry = !0);
|
|
786
|
+
}
|
|
787
|
+
if (retry) continue;
|
|
788
|
+
let decisionById = /* @__PURE__ */ new Map();
|
|
789
|
+
if (dropped.size > 0) for (let decision of result.decisions)
|
|
790
|
+
decisionById.has(decision.labelId) || decisionById.set(decision.labelId, decision);
|
|
791
|
+
for (let row of rows) for (let id of row.eligible) if (dropped.has(id)) {
|
|
792
|
+
let decision = decisionById.get(id);
|
|
793
|
+
decision && (decision.reason = row.reason);
|
|
794
|
+
}
|
|
795
|
+
for (let claim of attempt2.snapshot().slice(initial.length)) occupied.claim(claim.rect, claim.kind, claim.owner, claim.part, claim.polygon);
|
|
796
|
+
return result;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function anyHit(occupied, rect, pad, test) {
|
|
800
|
+
return occupied.some ? occupied.some(rect, pad, test) : occupied.hitsWhich(rect, pad).some(test);
|
|
801
|
+
}
|
|
802
|
+
function solveLabelPass(requests, occupied, ctx) {
|
|
803
|
+
let placed = [], decisions = [], warnings = [], hiddenWarningByLabel = /* @__PURE__ */ new Map(), printedIn = new Map(requests.flatMap((req) => req.printedIn ? [[req.id, req.printedIn]] : [])), pad = ctx.labelPad ?? 2, darkInk = ctx.darkInk ?? "#111827", lightInk = ctx.lightInk ?? "#ffffff", pinOf = (r) => r.pinnedSlot ?? ctx.pins[r.id], ownership = ctx.pointOwnership ? pointOwnership(ctx.pointOwnership) : void 0, owned = ownership ? withOwnedSeats(requests, ownership, pinOf) : requests, ownedPoint = (req) => req.kind === "point" && ownership?.pointOf(req.owner.seriesId, req.owner.categoryId) !== void 0, ownershipLimited = new Set(owned.flatMap((req, i) => req !== requests[i] ? [req.id] : [])), order = [...owned].sort(labelOrder(pinOf, ctx.focus)), leaderRuns = [], keepOffLeader = (label, req) => {
|
|
804
|
+
req.leaderAvoidsLabels && label.leader && leaderRuns.push(...leaderPieces(label.leader.d, 64));
|
|
805
|
+
}, onLeader = (rect, padding) => leaderRuns.some(([a, b]) => segmentHitsRect(a, b, rect, padding));
|
|
806
|
+
for (let queued of order) {
|
|
807
|
+
let runClear = (from, to) => occupied.hitsWhich({ x: from.x - 0.5, y: Math.min(from.y, to) + 0.5, w: 1, h: Math.max(0, Math.abs(to - from.y) - 1) }, 0).every((o) => o.kind !== "mark" || isOwnMark(o.owner, queued.owner, queued.kind, o.part)), req = withLiftLeaders(queued, ownedPoint(queued), runClear), slots = req.candidates.map((c) => c.slot), first = req.candidates[0], markValue = isMarkValue(req), naturals = naturalSeats(req), withinMarkBand = (cand) => {
|
|
808
|
+
if (!markValue || cand.outsidePlot || req.kind === "point" && req.anchor && /^(right|left)(Step[+-]?\d+)?$/.test(cand.slot)) return !0;
|
|
809
|
+
let side = sideOf2(cand.slot), natural = side ? naturals.get(side) : void 0;
|
|
810
|
+
if (/Shifted|Step/.test(cand.slot)) {
|
|
811
|
+
let slack = 2 * (cand.rect.h + 4);
|
|
812
|
+
if (!(side === "side" ? cand.rect.y >= ctx.plot.y - slack && cand.rect.y + cand.rect.h <= ctx.plot.y + ctx.plot.h + slack : rectContains({ x: ctx.plot.x, y: ctx.plot.y - slack, w: ctx.plot.w, h: ctx.plot.h + 2 * slack }, cand.rect, 0))) return !1;
|
|
813
|
+
}
|
|
814
|
+
return !natural || Math.abs(cand.rect.y - natural.rect.y) <= (cand.reach ?? (cand.leaderFrom && cand.leaderVertical ? 2 : 1) * (natural.rect.h + 4)) + 1e-6;
|
|
815
|
+
}, selfAnn = req.owner.annotationId, blocks = /* @__PURE__ */ new Map(), crowdsSeriesValue = (cand) => cand.insideFill === void 0 ? crowdsSeries(cand.rect) : req.kind === "segment" && crowdsSeries(cand.rect, !0), marksTouch = (a, b) => {
|
|
816
|
+
let [left, right] = a.x <= b.x ? [a, b] : [b, a], x = (left.x + left.w + right.x) / 2, y = (Math.max(a.y, b.y) + Math.min(a.y + a.h, b.y + b.h)) / 2;
|
|
817
|
+
return anyHit(occupied, { x: x - 0.5, y: y - 0.5, w: 1, h: 1 }, 0, (o) => o.kind === "mark");
|
|
818
|
+
}, outsideSegment = (touching) => req.kind === "segment" && !touching, crowdsTotal = (rect) => TOTAL_KINDS.has(req.kind) && anyHit(occupied, rect, SERIES_VALUE_GAP, (o) => o.kind === "label" && o.part === TOTAL_PART && o.owner.seriesId === req.owner.seriesId && o.owner.categoryId !== void 0 && o.owner.categoryId !== req.owner.categoryId && Math.min(o.rect.y + o.rect.h, rect.y + rect.h) - Math.max(o.rect.y, rect.y) >= rect.h / Math.max(1, req.lines.length) / 2 - 0.1), crowdsSeries = (rect, touching = !1) => crowdsTotal(rect) || (req.kind === "point" || req.kind === "segment") && (req.owner.seriesId !== void 0 || req.valueRow === !0 || outsideSegment(touching)) && occupied.hitsWhich(rect, SERIES_VALUE_GAP).some((o) => o.kind === "label" && (outsideSegment(touching) || o.owner.seriesId === req.owner.seriesId) && o.owner.categoryId !== void 0 && o.owner.categoryId !== req.owner.categoryId && Math.min(o.rect.y + o.rect.h, rect.y + rect.h) > Math.max(o.rect.y, rect.y) && (!touching || marksTouch(rect, o.rect))), inTickColumn = (rect, air = 0) => ["point", "segment", "total", "grandTotal"].includes(req.kind) && (occupied.tickColumns?.some((column) => rectsOverlap(column, rect, air)) ?? !1), blockAt = (index, padding) => {
|
|
819
|
+
let key = `${index}:${padding}`, cached = blocks.get(key);
|
|
820
|
+
if (cached) return cached;
|
|
821
|
+
let { rect, overColumns, overRules, overLegend } = req.candidates[index], value = "free";
|
|
822
|
+
if (!withinMarkBand(req.candidates[index]) || ctx.canvas && !rectContains(ctx.canvas, rect, 0))
|
|
823
|
+
value = "hard";
|
|
824
|
+
else {
|
|
825
|
+
let sawLabel = !1;
|
|
826
|
+
anyHit(occupied, rect, padding, (o) => o.kind === "annotation" && selfAnn && o.owner.annotationId === selfAnn || overRules && (o.part === "referenceLine" || o.part === CROSSABLE_RULE_PART) || overLegend && o.kind === "legend" || o.kind === "mark" && (isOwnMark(o.owner, req.owner, req.kind, o.part) || overColumns && isColumnPart(o.part) && rectContains(o.rect, rect, 0)) || o.kind === "mark" && o.part === AREA_FILL_PART && req.candidates[index].onFill?.seriesId === o.owner.seriesId || req.ownStrokeClear && o.kind === "mark" && (o.part === void 0 || o.part === AREA_FILL_PART) && !o.polygon && o.owner.seriesId === req.owner.seriesId && !rectsOverlap(o.rect, rect) || o.kind === "mark" && req.owner.seriesId !== void 0 && o.owner.seriesId === req.owner.seriesId && req.candidates[index].slot.startsWith("inside") && (req.candidates[index].slot.startsWith("insideBand") || !rectsOverlap(o.rect, rect, 0)) || o.kind === "mark" && o.part === AREA_FILL_PART && (req.candidates[index].slot.startsWith("insideBand") || req.candidates[index].insideFill !== void 0) ? !1 : o.kind === "label" ? (sawLabel = !0, !1) : !0) ? value = "hard" : sawLabel && (value = "label"), value !== "hard" && inTickColumn(rect, req.candidates[index].tickAir) && (value = "hard");
|
|
827
|
+
let tickAir = req.candidates[index].tickAir;
|
|
828
|
+
value !== "hard" && tickAir && anyHit(occupied, rect, tickAir, (o) => o.kind === "axis" && o.rect.w > 2 && o.rect.h > 2) && (value = "hard"), value === "free" && onLeader(rect, padding) && (value = "label"), value === "free" && pinOf(req) !== req.candidates[index].slot && crowdsSeriesValue(req.candidates[index]) && (value = "label");
|
|
829
|
+
}
|
|
830
|
+
return blocks.set(key, value), value;
|
|
831
|
+
}, pinnableSlots = () => req.candidates.flatMap((c, i) => blockAt(i, 0) === "hard" ? [] : [c.slot]), base = {
|
|
832
|
+
id: req.id,
|
|
833
|
+
kind: req.kind,
|
|
834
|
+
typeRole: labelTypeRole(req),
|
|
835
|
+
owner: req.owner,
|
|
836
|
+
text: req.text,
|
|
837
|
+
lines: req.lines,
|
|
838
|
+
slots,
|
|
839
|
+
pinned: !1,
|
|
840
|
+
priority: req.priority,
|
|
841
|
+
...req.claimId ? { claimId: req.claimId, claimText: req.claimText } : {},
|
|
842
|
+
...req.noteText ? { noteText: req.noteText } : {},
|
|
843
|
+
...req.printsFor ? { printsFor: req.printsFor } : {},
|
|
844
|
+
...req.owed ? { owed: !0 } : {},
|
|
845
|
+
...req.swatch ? { swatch: req.swatch } : {},
|
|
846
|
+
...req.title ? { title: req.title } : {},
|
|
847
|
+
...req.fontStep ? { font: req.fontStep } : {},
|
|
848
|
+
...capHeightOf(req, ctx.measure),
|
|
849
|
+
...req.role ? { role: req.role } : {},
|
|
850
|
+
...req.align ? { align: req.align } : {},
|
|
851
|
+
...req.runs ? { runs: req.runs } : {},
|
|
852
|
+
...req.emphasis ? { emphasis: !0 } : {},
|
|
853
|
+
...req.headLines ? { headLines: req.headLines, headWeight: req.headWeight, ...req.headInk ? { headInk: req.headInk } : {}, ...req.bodyInk ? { bodyInk: req.bodyInk } : {}, ...req.bodyFont ? { bodyFont: req.bodyFont } : {} } : {}
|
|
854
|
+
}, hide = (hidden, why) => {
|
|
855
|
+
let quiet = hidden === "collision" && req.quietWhenCrowded === !0, reason = quiet ? "density" : hidden, decisionReason = quiet ? "density=smart: no free seat" : why;
|
|
856
|
+
if (placed.push({
|
|
857
|
+
...base,
|
|
858
|
+
rect: first ? first.rect : { x: 0, y: 0, w: 0, h: 0 },
|
|
859
|
+
slot: first ? first.slot : "none",
|
|
860
|
+
ink: { token: "ink" },
|
|
861
|
+
hidden: reason,
|
|
862
|
+
...markValue && reason === "collision" ? { owed: !0 } : {}
|
|
863
|
+
}), decisions.push({
|
|
864
|
+
labelId: req.id,
|
|
865
|
+
strategy: "candidatesOccupied",
|
|
866
|
+
tried: [],
|
|
867
|
+
chose: "hidden",
|
|
868
|
+
reason: decisionReason
|
|
869
|
+
}), reason === "collision") {
|
|
870
|
+
let pinnable = slots.length > 0 ? pinnableSlots() : [];
|
|
871
|
+
warnings.push({
|
|
872
|
+
code: "label-hidden",
|
|
873
|
+
severity: req.priority >= REQUIRED_VALUE_PRIORITY ? "warn" : "info",
|
|
874
|
+
message: `label '${req.id}' with text '${req.text}' (priority ${req.priority}, owner ${formatOwner(req.owner)}) was hidden: ${decisionReason}`,
|
|
875
|
+
owner: req.owner,
|
|
876
|
+
suggest: slots.length === 0 ? "increase chart size or provide a placement candidate" : pinnable.length > 0 ? `increase chart size, or pin '${req.id}' to a slot a pin can actually take (${pinnable.join(", ")})` + (pinnable.length < slots.length ? " \u2014 the other candidates are blocked by marks, annotations or the canvas edge, which pinning cannot move" : "") : `increase chart size or lower label density \u2014 every candidate slot (${slots.join(", ")}) is blocked by marks, annotations or the canvas edge, which pinning cannot move`
|
|
877
|
+
}), hiddenWarningByLabel.set(req.id, warnings[warnings.length - 1]);
|
|
878
|
+
}
|
|
879
|
+
}, replacement = printedIn.size > 0 && req.printedIn !== void 0 && placed.find((label) => !label.hidden && label.id === req.printedIn);
|
|
880
|
+
if (replacement) {
|
|
881
|
+
base.printedIn = replacement.id, hide("redundant", `printed in label '${replacement.id}'`);
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
let pin = pinOf(req), pinOverDensity = req.redundant === !0 && req.suppressedAs === "density" && !req.owed && pin !== void 0;
|
|
885
|
+
if (req.redundant && !pinOverDensity) {
|
|
886
|
+
let why = req.suppressedAs ?? "redundant";
|
|
887
|
+
hide(why, why === "density" ? "density gate" : "redundancy gate");
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
if (!pin && !req.protect && !req.keepWhenDense && ctx.density === "minimal" && req.priority < DENSITY_MIN_PRIORITY) {
|
|
891
|
+
hide("density", `density=minimal drops priority ${req.priority}`);
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
894
|
+
let refusedPin;
|
|
895
|
+
if (pin) {
|
|
896
|
+
let index = req.candidates.findIndex((c) => c.slot === pin), free = req.candidates.flatMap((c, i) => c.slot !== pin && blockAt(i, 0) === "free" ? [c.slot] : []), choice = `valid slots: ${slots.join(", ") || "none"}; free now: ${free.join(", ") || "none"}`;
|
|
897
|
+
if (index < 0)
|
|
898
|
+
warnings.push({
|
|
899
|
+
code: "unknown-slot",
|
|
900
|
+
severity: "warn",
|
|
901
|
+
message: `label '${req.id}': unknown slot '${pin}' \u2014 using automatic placement; ${choice}`,
|
|
902
|
+
owner: req.owner,
|
|
903
|
+
suggest: slots.join(", ")
|
|
904
|
+
});
|
|
905
|
+
else if (blockAt(index, 0) === "free" && (req.leaderClear !== "includingPins" || !leaderFor(req.candidates[index]) || !leaderPieces(leaderFor(req.candidates[index]).d).some(([a, b]) => occupied.hitsWhich(pieceBox(a, b), 0).some((o) => o.kind === "label" && segmentHitsRect(a, b, o.rect))))) {
|
|
906
|
+
let cand = req.candidates[index], label = finalize(base, req, cand, !0, darkInk, lightInk);
|
|
907
|
+
if (placed.push(label), occupied.claim(cand.rect, "label", req.owner, TOTAL_KINDS.has(req.kind) ? TOTAL_PART : void 0), req.leaderClear === "includingPins" && label.leader) for (let [a, b] of leaderPieces(label.leader.d)) occupied.claim(pieceBox(a, b), "label", req.owner);
|
|
908
|
+
keepOffLeader(label, req), decisions.push({
|
|
909
|
+
labelId: req.id,
|
|
910
|
+
strategy: "candidatesOccupied",
|
|
911
|
+
tried: [pin],
|
|
912
|
+
chose: pin,
|
|
913
|
+
reason: "pinned"
|
|
914
|
+
});
|
|
915
|
+
continue;
|
|
916
|
+
} else {
|
|
917
|
+
refusedPin = pin;
|
|
918
|
+
let blockers = describeBlockers(occupied.hitsWhich(req.candidates[index].rect, 0), req, selfAnn), alternatives = pinnableSlots().filter((slot) => slot !== pin);
|
|
919
|
+
warnings.push({
|
|
920
|
+
code: "pin-blocked",
|
|
921
|
+
severity: "warn",
|
|
922
|
+
message: `label '${req.id}': pinned slot '${pin}' is occupied (${blockers}) \u2014 the no-overlap guarantee outranks the pin, so it was not honoured; using automatic placement; ${choice}`,
|
|
923
|
+
owner: req.owner,
|
|
924
|
+
suggest: alternatives.length > 0 ? `pin '${req.id}' to ${alternatives.join(", ")} instead, or increase chart size` : "increase chart size or lower label density \u2014 no candidate slot for this label is free"
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
if (pinOverDensity) {
|
|
929
|
+
hide("density", `density gate; pin '${pin}' not placed`);
|
|
930
|
+
continue;
|
|
931
|
+
}
|
|
932
|
+
let note = (reason) => refusedPin === void 0 ? reason : `pin '${refusedPin}' blocked; ${reason}`, tried = [], done = !1, crossesLabel = (leader) => !!(req.leaderClear || req.leaderAvoidsLabels) && leader !== void 0 && leaderPieces(leader.d, req.leaderAvoidsLabels ? 64 : 8).some(([a, b]) => occupied.hitsWhich(pieceBox(a, b), 0).some((o) => (o.kind === "label" || req.leaderClearsAxis && o.kind === "axis") && segmentHitsRect(a, b, o.rect))), claimLeader = (label) => {
|
|
933
|
+
if (req.leaderClear && label.leader) for (let [a, b] of leaderPieces(label.leader.d)) occupied.claim(pieceBox(a, b), "label", req.owner);
|
|
934
|
+
keepOffLeader(label, req);
|
|
935
|
+
}, crowds = (cand) => req.labelGap !== void 0 && anyHit(occupied, cand.rect, req.labelGap, (o) => o.kind === "label" && !sameOwner(o.owner, req.owner)), indices = req.candidates.map((_, i) => i), crowded = indices.map((i) => crowds(req.candidates[i])), order2 = req.labelGap === void 0 ? indices : [...indices].sort((a, b) => req.candidates[a].penalty - req.candidates[b].penalty || Number(crowded[a]) - Number(crowded[b]) || a - b), ambiguous = [], place = (cand, reason, leader) => {
|
|
936
|
+
let label = finalize(base, req, cand, !1, darkInk, lightInk);
|
|
937
|
+
leader && (label.leader = leader), cand.overRules && anyHit(occupied, cand.rect, req.pad ?? pad, (o) => o.part === "referenceLine") && (label.halo = !0), placed.push(label), occupied.claim(cand.rect, "label", req.owner, TOTAL_KINDS.has(req.kind) ? TOTAL_PART : void 0), claimLeader(label), decisions.push({ labelId: req.id, strategy: "candidatesOccupied", tried, chose: cand.slot, reason: note(reason) });
|
|
938
|
+
}, crossing;
|
|
939
|
+
for (let i of order2) {
|
|
940
|
+
let cand = req.candidates[i];
|
|
941
|
+
if (tried.push(cand.slot), !(req.noLeader && cand.leaderFrom) && !(cand.penalty >= LAST_RESORT_PENALTY && ambiguous.length > 0) && !leaderExceedsLimit(req, cand) && blockAt(i, cand.pad ?? req.pad ?? pad) === "free") {
|
|
942
|
+
if (crossesLabel(leaderFor(cand))) {
|
|
943
|
+
crossing ??= cand;
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
if (req.anchor && nearerOtherMark(req, cand, occupied, ctx.pointOwnership !== void 0)) {
|
|
947
|
+
cand.onFill || ambiguous.push(cand);
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
place(cand, tried.length === 1 ? "first candidate free" : `candidate ${tried.length} free`), done = !0;
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
if (!done) {
|
|
955
|
+
if (crossing && req.leaderAvoidsLabels) {
|
|
956
|
+
place(crossing, "every free seat draws its leader across a label"), warnings.push({
|
|
957
|
+
code: "label-leader-crossing",
|
|
958
|
+
severity: "warn",
|
|
959
|
+
message: `label '${req.id}': every free seat draws its leader across a label`,
|
|
960
|
+
owner: req.owner,
|
|
961
|
+
suggest: "widen the chart or shorten the labels"
|
|
962
|
+
});
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (req.anchor && !req.noLeader && ambiguous.length > 0) {
|
|
966
|
+
let box = anchorBox(req.anchor), anchorFor = (rect) => ({ x: Math.max(box.x, Math.min(rect.x + rect.w / 2, box.x + box.w)), y: Math.max(box.y, Math.min(rect.y + rect.h / 2, box.y + box.h)) }), led = ambiguous.find((cand) => anchorLeader(cand.rect, anchorFor(cand.rect)) && !leaderExceedsLimit(req, { ...cand, leaderFrom: anchorFor(cand.rect) }) && !crossesLabel(anchorLeader(cand.rect, anchorFor(cand.rect))));
|
|
967
|
+
if (led) {
|
|
968
|
+
let leader = anchorLeader(led.rect, anchorFor(led.rect));
|
|
969
|
+
place(led, "nearer another mark: leader from its anchor", leader);
|
|
970
|
+
let [x, y] = leader.d.trim().split(/[\s,A-Za-z]+/).filter(Boolean).slice(-2).map(Number), reach = LEADER_GUTTER_RATIO * led.rect.h;
|
|
971
|
+
occupied.claim({ x: x - reach, y: y - reach, w: 2 * reach, h: 2 * reach }, "label", req.owner);
|
|
972
|
+
} else place(ambiguous[0], "nearer another mark; too close to its anchor for a leader");
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
{
|
|
976
|
+
let across = req.candidates.findIndex((cand) => (!req.noLeader || !cand.leaderFrom && (!req.anchor || !nearerOtherMark(req, cand, occupied, ctx.pointOwnership !== void 0))) && withinMarkBand(cand) && !cand.insideFill && !leaderExceedsLimit(req, cand) && !crossesLabel(leaderFor(cand)) && (!ctx.canvas || rectContains(ctx.canvas, cand.rect, 0)) && !onLeader(cand.rect, req.pad ?? pad) && !crowdsSeriesValue(cand) && !inTickColumn(cand.rect) && !anyHit(occupied, cand.rect, req.pad ?? pad, (o) => !(o.part === "trendLine" || o.part === "zeroLine" || req.protect === !0 && o.part === "referenceLine" || o.kind === "mark" && isOwnMark(o.owner, req.owner, req.kind, o.part))));
|
|
977
|
+
if (across >= 0) {
|
|
978
|
+
let cand = req.candidates[across], label = finalize(base, req, cand, !1, darkInk, lightInk);
|
|
979
|
+
label.halo = !0, placed.push(label), occupied.claim(cand.rect, "label", req.owner, TOTAL_KINDS.has(req.kind) ? TOTAL_PART : void 0), claimLeader(label), decisions.push({ labelId: req.id, strategy: "candidatesOccupied", tried, chose: cand.slot, reason: note(req.protect ? "highlighted value crosses a reference line" : "label crosses a trend or zero line") });
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
hide("collision", note(ownershipLimited.has(req.id) && req.candidates.length === 0 ? "no seat reads as its own point's value" : `all ${req.candidates.length} candidates collide${req.maxLeaderLength === void 0 ? "" : " or exceed the leader limit"}`));
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
if (ctx.seriesUniform) {
|
|
987
|
+
let kinds = new Set(ctx.seriesUniform.kinds), maxShare = ctx.seriesUniform.maxHiddenShare ?? 0.25, groups = /* @__PURE__ */ new Map();
|
|
988
|
+
for (let label of placed) {
|
|
989
|
+
let seriesId = label.owner.seriesId;
|
|
990
|
+
if (!kinds.has(label.kind) || seriesId === void 0 || label.owner.annotationId !== void 0) continue;
|
|
991
|
+
let list = groups.get(seriesId) ?? [];
|
|
992
|
+
list.push(label), groups.set(seriesId, list);
|
|
993
|
+
}
|
|
994
|
+
let emphasized = new Set(requests.filter((request) => request.protect).map((request) => request.id));
|
|
995
|
+
for (let [seriesId, labels] of groups) {
|
|
996
|
+
let collided = labels.filter((label) => label.hidden === "collision");
|
|
997
|
+
if (labels.length < 3 || collided.length === 0 || collided.length / labels.length <= maxShare) continue;
|
|
998
|
+
let dropped = /* @__PURE__ */ new Set();
|
|
999
|
+
for (let label of labels) {
|
|
1000
|
+
!label.hidden && !emphasized.has(label.id) && (label.hidden = "density");
|
|
1001
|
+
let trace = hiddenWarningByLabel.get(label.id);
|
|
1002
|
+
trace && dropped.add(trace);
|
|
1003
|
+
}
|
|
1004
|
+
for (let i = warnings.length - 1; i >= 0; i--) dropped.has(warnings[i]) && warnings.splice(i, 1);
|
|
1005
|
+
let kept = labels.filter((label) => !label.hidden).map((label) => `'${label.id}'`);
|
|
1006
|
+
warnings.push({
|
|
1007
|
+
code: "value-labels-dropped-series",
|
|
1008
|
+
severity: "warn",
|
|
1009
|
+
message: `value labels of series '${seriesId}' hidden: ${collided.length} of ${labels.length} could not be placed without overlap, so the series shows ${kept.length === 0 ? "none" : `only its highlighted value${kept.length > 1 ? "s" : ""} (${kept.join(", ")})`} instead of a scatter`,
|
|
1010
|
+
owner: { seriesId },
|
|
1011
|
+
suggest: 'widen the chart, set labelDensity to "minimal", or read the series from its axis'
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (owned.some((req) => req.order !== void 0)) {
|
|
1016
|
+
let rank = new Map([...owned].sort(labelOrder(pinOf, ctx.focus, !1)).map((req, i) => [req.id, i])), byRank = (a, b) => (rank.get(a) ?? 0) - (rank.get(b) ?? 0);
|
|
1017
|
+
placed.sort((a, b) => byRank(a.id, b.id)), decisions.sort((a, b) => byRank(a.labelId, b.labelId));
|
|
1018
|
+
}
|
|
1019
|
+
return { placed, decisions, warnings, ...ownershipLimited.size > 0 ? { ownershipLimited } : {} };
|
|
1020
|
+
}
|
|
1021
|
+
function isOtherOwners(mark, label, kind, part) {
|
|
1022
|
+
for (let key of kind === "series" ? ["seriesId"] : ["seriesId", "categoryId", "segmentId", "pointId"])
|
|
1023
|
+
if (mark[key] !== void 0 && label[key] !== void 0 && mark[key] !== label[key]) return !0;
|
|
1024
|
+
return (kind === "total" || kind === "grandTotal") && label.seriesId === void 0 && label.categoryId !== void 0 && mark.seriesId !== void 0 && mark.categoryId === label.categoryId && !isColumnPart(part);
|
|
1025
|
+
}
|
|
1026
|
+
function leaderPieces(d, steps = 8) {
|
|
1027
|
+
let n = d.trim().split(/[\s,A-Za-z]+/).filter(Boolean).map(Number);
|
|
1028
|
+
if (n.length < 8) return [[{ x: n[0], y: n[1] }, { x: n[2], y: n[3] }]];
|
|
1029
|
+
let at = (t) => {
|
|
1030
|
+
let u = 1 - t, [a, b, c, e] = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t];
|
|
1031
|
+
return { x: a * n[0] + b * n[2] + c * n[4] + e * n[6], y: a * n[1] + b * n[3] + c * n[5] + e * n[7] };
|
|
1032
|
+
};
|
|
1033
|
+
return Array.from({ length: steps }, (_, i) => [at(i / steps), at((i + 1) / steps)]);
|
|
1034
|
+
}
|
|
1035
|
+
function pieceBox(a, b) {
|
|
1036
|
+
let x = Math.min(a.x, b.x) - 0.5, y = Math.min(a.y, b.y) - 0.5;
|
|
1037
|
+
return { x, y, w: Math.abs(a.x - b.x) + 1, h: Math.abs(a.y - b.y) + 1 };
|
|
1038
|
+
}
|
|
1039
|
+
function anchorBox(anchor) {
|
|
1040
|
+
return { x: anchor.x, y: anchor.y, w: anchor.w ?? 0, h: anchor.h ?? 0 };
|
|
1041
|
+
}
|
|
1042
|
+
function nearerOtherMark(req, cand, occupied, ownsPoint = !1) {
|
|
1043
|
+
if (cand.leaderFrom && leaderFor(cand)) return !1;
|
|
1044
|
+
let anchor = anchorBox(req.anchor), ownLabels = req.owner.seriesId === void 0 ? [] : occupied.hitsWhich(cand.rect, 6).filter((o) => o.kind === "label" && o.owner.seriesId === req.owner.seriesId && o.owner.categoryId === req.owner.categoryId), own = Math.min(boxGap(cand.rect, anchor), ...ownLabels.map((o) => boxGap(cand.rect, o.rect)));
|
|
1045
|
+
return anyHit(occupied, cand.rect, Math.max(0, own - 1), (o) => o.kind === "mark" && !o.owner.seriesId?.startsWith("__") && // Point ownership already compares the actual points and category lanes.
|
|
1046
|
+
// A box around the same line's connecting stroke is not another value.
|
|
1047
|
+
!(ownsPoint && req.noLeader && req.kind === "point" && (o.part === void 0 || o.part === AREA_FILL_PART) && o.owner.seriesId === req.owner.seriesId) && // The fill a value sits on is its ground, not a rival value.
|
|
1048
|
+
!(o.part === AREA_FILL_PART && o.owner.seriesId === cand.onFill?.seriesId) && isOtherOwners(o.owner, req.owner, req.kind, o.part) && boxGap(o.rect, anchor) > 1.5 && boxGap(cand.rect, o.rect) + 1 < own);
|
|
1049
|
+
}
|
|
1050
|
+
function isMarkValue(req) {
|
|
1051
|
+
return ["point", "segment", "total", "grandTotal"].includes(req.kind) && req.role !== "category" && req.owner.annotationId === void 0 && req.markAnchored !== !1 && (req.markAnchored === !0 || req.anchor !== void 0 || req.candidates.some((c) => /^(above|below|inside|outsideTop|outsideBottom)/.test(c.slot)));
|
|
1052
|
+
}
|
|
1053
|
+
function sideOf2(slot) {
|
|
1054
|
+
return /^(above|outsideTop)/.test(slot) ? "up" : /^(below|outsideBottom)/.test(slot) ? "down" : /^(outside(Right|Left|End|High|Low)|right(?!Of)|left(?!Of))/.test(slot) ? "side" : void 0;
|
|
1055
|
+
}
|
|
1056
|
+
function naturalSeats(req) {
|
|
1057
|
+
let naturals = /* @__PURE__ */ new Map();
|
|
1058
|
+
for (let c of req.candidates) {
|
|
1059
|
+
let side = sideOf2(c.slot);
|
|
1060
|
+
side && !/Shifted|Step/.test(c.slot) && !naturals.has(side) && naturals.set(side, c);
|
|
1061
|
+
}
|
|
1062
|
+
return naturals;
|
|
1063
|
+
}
|
|
1064
|
+
var NATURAL_SEAT_GAP = 4;
|
|
1065
|
+
function withLiftLeaders(req, ownedPoint, runClear) {
|
|
1066
|
+
if (ownedPoint || req.noLeader || !isMarkValue(req)) return req;
|
|
1067
|
+
let naturals = naturalSeats(req), changed = !1, candidates = req.candidates.map((cand) => {
|
|
1068
|
+
let side = sideOf2(cand.slot), natural = side === "up" || side === "down" ? naturals.get(side) : void 0;
|
|
1069
|
+
if (!natural || natural === cand || cand.leaderFrom || cand.insideFill !== void 0) return cand;
|
|
1070
|
+
let up = side === "up", from = { x: natural.rect.x + natural.rect.w / 2, y: up ? natural.rect.y + natural.rect.h + NATURAL_SEAT_GAP : natural.rect.y - NATURAL_SEAT_GAP };
|
|
1071
|
+
if ((up ? cand.rect.y >= natural.rect.y : cand.rect.y <= natural.rect.y) || !runClear(from, up ? cand.rect.y + cand.rect.h : cand.rect.y)) return cand;
|
|
1072
|
+
changed = !0;
|
|
1073
|
+
let { onFill: _onFill, ...base } = cand;
|
|
1074
|
+
return { ...base, leaderFrom: from, leaderVertical: !0 };
|
|
1075
|
+
});
|
|
1076
|
+
return changed ? { ...req, candidates, ...req.leaderClear ? {} : { leaderClear: !0 } } : req;
|
|
1077
|
+
}
|
|
1078
|
+
var LED_PENALTY = 100, CROSSABLE_RULE_PART = "crossableRule", LAST_RESORT_PENALTY = 200;
|
|
1079
|
+
function withOwnedSeats(requests, model, pinOf) {
|
|
1080
|
+
return requests.map((req) => {
|
|
1081
|
+
if (req.kind !== "point" || req.owner.annotationId !== void 0 || req.rotate !== void 0) return req;
|
|
1082
|
+
let pin = pinOf(req);
|
|
1083
|
+
if (req.redundant && !(req.suppressedAs === "density" && !req.owed && pin !== void 0)) return req;
|
|
1084
|
+
let own = model.pointOf(req.owner.seriesId, req.owner.categoryId);
|
|
1085
|
+
if (!own) return req;
|
|
1086
|
+
let kept = [], led = [], changed = !1;
|
|
1087
|
+
for (let cand of req.candidates) {
|
|
1088
|
+
if (cand.insideFill !== void 0 || cand.slot === pin) {
|
|
1089
|
+
kept.push(cand);
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
let leader = cand.leaderFrom ? leaderFor(cand) : void 0;
|
|
1093
|
+
if (leader ? leaderReadsAsOwn(leader.d, own, model) && !besideOtherPoint(cand.rect, own, model, req.font.size) : readsAsOwnPoint(cand.rect, own, model, req.font.size)) {
|
|
1094
|
+
kept.push(cand);
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
if (changed = !0, leader || req.noLeader) continue;
|
|
1098
|
+
let from = cand.rect.x <= own.x && own.x <= cand.rect.x + cand.rect.w ? { x: own.x, y: own.y } : { x: own.x + (cand.rect.x + cand.rect.w / 2 < own.x ? -LED_FROM_R : LED_FROM_R), y: own.y }, { onFill: _onFill, ...base } = cand, withLeader = { ...base, slot: `${cand.slot}Led`, leaderFrom: from, leaderVertical: !0, penalty: cand.penalty + LED_PENALTY }, drawn = leaderFor(withLeader);
|
|
1099
|
+
drawn && leaderReadsAsOwn(drawn.d, own, model) && !besideOtherPoint(cand.rect, own, model, req.font.size) && led.push(withLeader);
|
|
1100
|
+
}
|
|
1101
|
+
let last = (cand) => cand.penalty >= LAST_RESORT_PENALTY;
|
|
1102
|
+
return changed ? { ...req, candidates: [...kept.filter((cand) => !last(cand)), ...led, ...kept.filter(last)], ...led.length > 0 && !req.leaderClear ? { leaderClear: !0 } : {} } : req;
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
var LED_FROM_R = 3;
|
|
1106
|
+
function describeBlockers(hits, req, selfAnn) {
|
|
1107
|
+
let parts = [];
|
|
1108
|
+
for (let o of hits) {
|
|
1109
|
+
if (o.kind === "annotation" && selfAnn && o.owner.annotationId === selfAnn || o.kind === "mark" && isOwnMark(o.owner, req.owner, req.kind, o.part)) continue;
|
|
1110
|
+
let label = `${o.kind}${o.part ? ` '${o.part}'` : ""} of ${formatOwner(o.owner)}`;
|
|
1111
|
+
parts.includes(label) || parts.push(label);
|
|
1112
|
+
}
|
|
1113
|
+
return parts.length > 0 ? parts.join("; ") : "the canvas edge";
|
|
1114
|
+
}
|
|
1115
|
+
function sameOwner(a, b) {
|
|
1116
|
+
return ["seriesId", "categoryId", "segmentId", "pointId", "annotationId"].every((key) => a[key] === b[key]);
|
|
1117
|
+
}
|
|
1118
|
+
function formatOwner(owner) {
|
|
1119
|
+
let parts = ["seriesId", "categoryId", "segmentId", "pointId", "valueLineId", "annotationId"].flatMap((key) => owner[key] === void 0 ? [] : [`${key}='${owner[key]}'`]);
|
|
1120
|
+
return parts.length > 0 ? parts.join(", ") : "unowned";
|
|
1121
|
+
}
|
|
1122
|
+
function isColumnPart(part) {
|
|
1123
|
+
return part === "segment" || part === "bar";
|
|
1124
|
+
}
|
|
1125
|
+
function isOwnMark(mark, label, kind, part) {
|
|
1126
|
+
if ((kind === "total" || kind === "grandTotal") && label.categoryId !== void 0 && label.seriesId === void 0 && mark.categoryId === label.categoryId && (part === "segment" || part === "bar"))
|
|
1127
|
+
return !0;
|
|
1128
|
+
let keys = ["seriesId", "categoryId", "segmentId", "pointId"], shared = 0;
|
|
1129
|
+
for (let k of keys)
|
|
1130
|
+
if (mark[k] !== void 0) {
|
|
1131
|
+
if (label[k] === void 0 || label[k] !== mark[k]) return !1;
|
|
1132
|
+
shared++;
|
|
1133
|
+
}
|
|
1134
|
+
return shared > 0;
|
|
1135
|
+
}
|
|
1136
|
+
var LEADER_GUTTER_RATIO = 0.4, LEADER_MIN_DRAWN_RATIO = 0.6;
|
|
1137
|
+
function leaderTerminus(rect, from) {
|
|
1138
|
+
let gutter = LEADER_GUTTER_RATIO * rect.h, approachesFromLeft = from.x <= rect.x, edgeX = approachesFromLeft ? rect.x : rect.x + rect.w;
|
|
1139
|
+
return {
|
|
1140
|
+
x: approachesFromLeft ? edgeX - gutter : edgeX + gutter,
|
|
1141
|
+
y: rect.y + rect.h / 2
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
function leaderExceedsLimit(req, cand) {
|
|
1145
|
+
if (req.maxLeaderLength === void 0) return !1;
|
|
1146
|
+
if (cand.leaderLengthBound !== void 0) return cand.leaderLengthBound > req.maxLeaderLength;
|
|
1147
|
+
if (!cand.leaderFrom || !leaderFor(cand)) return !1;
|
|
1148
|
+
let { rect, leaderFrom: from } = cand;
|
|
1149
|
+
if (from.x > rect.x && from.x < rect.x + rect.w) return Math.max(rect.y - from.y, from.y - rect.y - rect.h) > req.maxLeaderLength;
|
|
1150
|
+
let end = leaderTerminus(cand.rect, cand.leaderFrom), dx = Math.abs(end.x - cand.leaderFrom.x), dy = Math.abs(end.y - cand.leaderFrom.y);
|
|
1151
|
+
return (dx <= 8 || dy <= 8 ? Math.hypot(dx, dy) : dx + dy) > req.maxLeaderLength;
|
|
1152
|
+
}
|
|
1153
|
+
function leaderFor(cand) {
|
|
1154
|
+
let from = cand.leaderFrom;
|
|
1155
|
+
if (!from) return;
|
|
1156
|
+
let minimum = LEADER_MIN_DRAWN_RATIO * cand.rect.h, approachesFromLeft = from.x <= cand.rect.x, toEdge = leaderTerminus(cand.rect, from), dx = toEdge.x - from.x, dy = toEdge.y - from.y;
|
|
1157
|
+
if (approachesFromLeft ? dx <= 0 : dx >= 0) return cand.leaderVertical ? verticalLeader(cand.rect, from) : void 0;
|
|
1158
|
+
if (Math.hypot(dx, dy) < minimum) return;
|
|
1159
|
+
let d = leaderPath(from, toEdge);
|
|
1160
|
+
return { d, curved: d.includes("C") };
|
|
1161
|
+
}
|
|
1162
|
+
function seatLeader(rect, from) {
|
|
1163
|
+
return leaderFor({ slot: "seat", rect, penalty: 0, leaderFrom: from });
|
|
1164
|
+
}
|
|
1165
|
+
function verticalLeader(rect, from) {
|
|
1166
|
+
if (from.x < rect.x || from.x > rect.x + rect.w) return;
|
|
1167
|
+
let gutter = LEADER_GUTTER_RATIO * rect.h, y = from.y > rect.y + rect.h ? rect.y + rect.h + gutter : from.y < rect.y ? rect.y - gutter : from.y;
|
|
1168
|
+
return Math.abs(y - from.y) < LEADER_MIN_DRAWN_RATIO * rect.h ? void 0 : { d: leaderPath(from, { x: from.x, y }), curved: !1 };
|
|
1169
|
+
}
|
|
1170
|
+
function anchorLeader(rect, anchor) {
|
|
1171
|
+
return leaderFor({ slot: "anchor", rect, penalty: 0, leaderFrom: anchor, leaderVertical: !0 });
|
|
1172
|
+
}
|
|
1173
|
+
function capHeightOf(req, measure) {
|
|
1174
|
+
let capHeight = measure.capHeight?.(req.fontStep ?? req.font);
|
|
1175
|
+
return capHeight === void 0 ? {} : { capHeight };
|
|
1176
|
+
}
|
|
1177
|
+
function finalize(base, _req, cand, pinned, darkInk, lightInk) {
|
|
1178
|
+
let fill = cand.insideFill ?? cand.onFill?.fill, paint = cand.insidePaint ?? cand.onFill?.paint, pattern = cand.insidePattern ?? cand.onFill?.pattern, label = {
|
|
1179
|
+
...base,
|
|
1180
|
+
...cand.lines ? { lines: cand.lines } : {},
|
|
1181
|
+
...cand.swatch ? { swatch: cand.swatch } : {},
|
|
1182
|
+
pinned,
|
|
1183
|
+
rect: cand.rect,
|
|
1184
|
+
slot: cand.slot,
|
|
1185
|
+
..._req.rotate ? { rotate: _req.rotate } : {},
|
|
1186
|
+
// Halos and backing boxes use the page colour, so both need page ink.
|
|
1187
|
+
// Ordinary inside text chooses its ink against the mark itself.
|
|
1188
|
+
ink: { token: fill && !cand.needsBacking && pickInk(fill, darkInk, lightInk) === lightInk ? "inkInverse" : "ink" }
|
|
1189
|
+
};
|
|
1190
|
+
if (fill && paint && !cand.needsBacking && "token" in label.ink && (label.ink = {
|
|
1191
|
+
...label.ink,
|
|
1192
|
+
theme: {
|
|
1193
|
+
kind: "contrast-ink",
|
|
1194
|
+
fill: paint,
|
|
1195
|
+
...pattern ? { pattern } : {}
|
|
1196
|
+
}
|
|
1197
|
+
}), cand.needsBacking && (cand.contrast === "box" ? label.backing = inflate(cand.rect, 2) : label.halo = !0), cand.leaderFrom) {
|
|
1198
|
+
let leader = leaderFor(cand);
|
|
1199
|
+
leader && (label.leader = leader);
|
|
1200
|
+
}
|
|
1201
|
+
return label;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// src/core/annotateCallout.ts
|
|
1205
|
+
var CALLOUT_ARROW_REACH = 22, ARROW_HEAD = 4, TIP_GAP = 4, TAIL_GAP = 3;
|
|
1206
|
+
function arrowSeats(anchor, w, h, lineH, prefer) {
|
|
1207
|
+
let y = anchor.y - lineH / 2, vertical = prefer === "above" || prefer === "below";
|
|
1208
|
+
return [
|
|
1209
|
+
{ slot: "arrowRight", rect: { x: anchor.x + CALLOUT_ARROW_REACH, y, w, h }, penalty: vertical ? 0.5 : prefer === "left" ? -2.5 : -3 },
|
|
1210
|
+
{ slot: "arrowLeft", rect: { x: anchor.x - CALLOUT_ARROW_REACH - w, y, w, h }, penalty: vertical ? 0.6 : prefer === "left" ? -3 : -2.5 }
|
|
1211
|
+
];
|
|
1212
|
+
}
|
|
1213
|
+
function tail(rect, anchor) {
|
|
1214
|
+
let y = Math.min(Math.max(anchor.y, rect.y), rect.y + rect.h);
|
|
1215
|
+
return anchor.x < rect.x ? { x: rect.x - TAIL_GAP, y } : anchor.x > rect.x + rect.w ? { x: rect.x + rect.w + TAIL_GAP, y } : { x: anchor.x, y: anchor.y < rect.y ? rect.y - TAIL_GAP : rect.y + rect.h + TAIL_GAP };
|
|
1216
|
+
}
|
|
1217
|
+
function finishCalloutHeads(theme, labels, plans, nodes, occupied) {
|
|
1218
|
+
for (let label of labels) {
|
|
1219
|
+
let plan = plans.get(label.id);
|
|
1220
|
+
if (!plan) continue;
|
|
1221
|
+
if (label.hidden) {
|
|
1222
|
+
plan.arrow?.nodeIds.splice(0);
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
if (label.font = plan.font, plan.headline && (label.headLines = plan.headlineLines ?? 1, label.headWeight = plan.headlineWeight), !plan.arrow) continue;
|
|
1226
|
+
let { anchor, owner } = plan.arrow, from = tail(label.rect, anchor), length = Math.hypot(anchor.x - from.x, anchor.y - from.y);
|
|
1227
|
+
if (length <= TIP_GAP + ARROW_HEAD) {
|
|
1228
|
+
plan.arrow.nodeIds.splice(0);
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
1231
|
+
let ux = (anchor.x - from.x) / length, uy = (anchor.y - from.y) / length, tip = { x: anchor.x - ux * TIP_GAP, y: anchor.y - uy * TIP_GAP }, shaft = arrowShaftEnd(ARROW_HEAD, strokeToken(theme, "rule")), end = { x: tip.x - ux * shaft, y: tip.y - uy * shaft }, [shaftId, headId] = plan.arrow.nodeIds;
|
|
1232
|
+
delete label.leader, nodes.push(
|
|
1233
|
+
{ t: "path", id: shaftId, d: `M${from.x} ${from.y}L${end.x} ${end.y}`, stroke: { token: "ink" }, width: strokeToken(theme, "rule"), owner, part: "calloutArrow" },
|
|
1234
|
+
{ t: "path", id: headId, d: arrowHeadPath(tip, Math.atan2(uy, ux), ARROW_HEAD), fill: { token: "ink" }, owner, part: "calloutArrow" }
|
|
1235
|
+
), occupied.claim(
|
|
1236
|
+
{ x: Math.min(from.x, tip.x) - 0.5, y: Math.min(from.y, tip.y) - 0.5, w: Math.abs(tip.x - from.x) + 1, h: Math.abs(tip.y - from.y) + 1 },
|
|
1237
|
+
"annotation",
|
|
1238
|
+
owner,
|
|
1239
|
+
"calloutArrow"
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
var LEADER_LABEL_CLEARANCE = 3;
|
|
1244
|
+
function printsAnchor(claim, anchor) {
|
|
1245
|
+
if (claim.kind !== "label" || claim.owner.annotationId !== void 0) return !1;
|
|
1246
|
+
let keys = ["seriesId", "categoryId", "segmentId", "pointId", "valueLineId", "rowId", "colId"];
|
|
1247
|
+
return keys.some((key) => anchor[key] !== void 0) && keys.every((key) => claim.owner[key] === anchor[key]);
|
|
1248
|
+
}
|
|
1249
|
+
function leaderBox(pieces) {
|
|
1250
|
+
let xs = pieces.flatMap(([a, b]) => [a.x, b.x]), ys = pieces.flatMap(([a, b]) => [a.y, b.y]), x = Math.min(...xs), y = Math.min(...ys);
|
|
1251
|
+
return { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y };
|
|
1252
|
+
}
|
|
1253
|
+
function leadersOffAnchorValues(labels, anchors, occupied) {
|
|
1254
|
+
for (let label of labels) {
|
|
1255
|
+
let anchor = anchors.get(label.id);
|
|
1256
|
+
if (label.hidden || !label.leader || !anchor) continue;
|
|
1257
|
+
let pieces = leaderPieces(label.leader.d, 32), own = occupied.hitsWhich(leaderBox(pieces), 0).filter((claim) => printsAnchor(claim, anchor) && pieces.some(([a, b]) => segmentHitsRect(a, b, claim.rect)));
|
|
1258
|
+
if (own.length === 0) continue;
|
|
1259
|
+
let box = own.slice(1).reduce((u, { rect }) => unionRect(u, rect), own[0].rect), c = LEADER_LABEL_CLEARANCE, from = {
|
|
1260
|
+
x: Math.min(Math.max(label.rect.x + label.rect.w / 2, box.x - c), box.x + box.w + c),
|
|
1261
|
+
y: Math.min(Math.max(label.rect.y + label.rect.h / 2, box.y - c), box.y + box.h + c)
|
|
1262
|
+
}, leader = seatLeader(label.rect, from);
|
|
1263
|
+
if (!leader) continue;
|
|
1264
|
+
let next = leaderPieces(leader.d, 32);
|
|
1265
|
+
occupied.hitsWhich(leaderBox(next), 0).some((claim) => claim.kind === "label" && claim.owner.annotationId !== label.owner.annotationId && next.some(([a, b]) => segmentHitsRect(a, b, claim.rect))) || (label.leader = leader);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function haloLabelsUnderLeaders(labels) {
|
|
1269
|
+
let crossing = /* @__PURE__ */ new Set();
|
|
1270
|
+
for (let label of labels) {
|
|
1271
|
+
if (label.kind !== "annotation" || !label.leader || label.hidden) continue;
|
|
1272
|
+
let pieces = leaderPieces(label.leader.d, 32);
|
|
1273
|
+
for (let other of labels)
|
|
1274
|
+
other === label || other.hidden || !pieces.some(([a, b]) => segmentHitsRect(a, b, other.rect)) || (other.halo = !0, crossing.add(label.id));
|
|
1275
|
+
}
|
|
1276
|
+
return crossing;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// src/core/label/emit.ts
|
|
1280
|
+
var SWATCH_W = 8, SWATCH_GAP = 4, SWATCH_RESERVE = SWATCH_W + SWATCH_GAP, MUTED_SECONDARY_KINDS = /* @__PURE__ */ new Set(["category", "annotation", "axisTitle", "tick"]), MUTED_LABEL_KINDS = /* @__PURE__ */ new Set(["point", "segment", "category", "total", "grandTotal"]);
|
|
1281
|
+
function labelInk(theme, label) {
|
|
1282
|
+
return !("token" in label.ink && label.ink.token === "ink" && Object.keys(label.ink).length === 1) || label.emphasis ? label.ink : labelTypeRole(label) === "secondary" && MUTED_SECONDARY_KINDS.has(label.kind) || theme.labels?.ink === "muted" && MUTED_LABEL_KINDS.has(label.kind) ? { token: "inkMuted" } : label.ink;
|
|
1283
|
+
}
|
|
1284
|
+
var LOST_ON_GROUND = 1.4;
|
|
1285
|
+
function swatchHairline(theme, fill, ground) {
|
|
1286
|
+
let css = paintColor(theme, fill), edge = !fillEdgesOff(theme) && contrastRatio(css, theme.color.background) < 3;
|
|
1287
|
+
return { stroke: { token: "ink" }, strokeWidth: edge || lostOnGround(theme, fill, ground) ? strokeToken(theme, "hair") : 0 };
|
|
1288
|
+
}
|
|
1289
|
+
function lostOnGround(theme, fill, ground) {
|
|
1290
|
+
if (ground === void 0) return !1;
|
|
1291
|
+
let groundCss = paintColor(theme, ground);
|
|
1292
|
+
return groundCss !== theme.color.background && parseColor(groundCss) !== null && contrastRatio(paintColor(theme, fill), groundCss) < LOST_ON_GROUND;
|
|
1293
|
+
}
|
|
1294
|
+
function groundOf(scene, index, drawn) {
|
|
1295
|
+
let box = (node) => ({ x: node.rect.x + (node.tx ?? 0), y: node.rect.y + (node.ty ?? 0), w: node.rect.w, h: node.rect.h }), mark = box(scene[index]);
|
|
1296
|
+
for (let k = drawn ? drawn.length - 1 : index - 1; k >= 0; k--) {
|
|
1297
|
+
let i = drawn ? drawn[k] : k;
|
|
1298
|
+
if (i >= index) continue;
|
|
1299
|
+
let node = scene[i];
|
|
1300
|
+
if (node.t !== "rect" || node.pattern || node.part === "labelSwatch" || node.part === "labelPlate") continue;
|
|
1301
|
+
let r = box(node);
|
|
1302
|
+
if (r.x <= mark.x && r.y <= mark.y && r.x + r.w >= mark.x + mark.w && r.y + r.h >= mark.y + mark.h) return node.fill;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
function groundEdges(scene, themeOf, translated) {
|
|
1306
|
+
let tints = scene.flatMap((node, index) => node.t === "rect" && (node.part === "rowTint" || node.part === "highlightBand") ? [index] : []);
|
|
1307
|
+
return scene.map((node, index) => {
|
|
1308
|
+
if (node.t !== "rect" || !node.fill) return node;
|
|
1309
|
+
let swatch = node.part === "labelSwatch";
|
|
1310
|
+
if (!swatch && !((node.part === "segment" || node.part === "bar") && !node.pattern && tints.length > 0) || !translated && (node.tx !== void 0 || node.ty !== void 0)) return node;
|
|
1311
|
+
let theme = themeOf(node);
|
|
1312
|
+
if (swatch) return { ...node, ...swatchHairline(theme, node.fill, groundOf(scene, index)) };
|
|
1313
|
+
let ground = groundOf(scene, index, tints), ownStroke = node.stroke !== void 0 && !node.groundEdge;
|
|
1314
|
+
if (ground === void 0 || ownStroke || node.separation && (node.strokeWidth ?? 0) > 0) return node;
|
|
1315
|
+
let lost = lostOnGround(theme, node.fill, ground) && !splitHalf(scene, index);
|
|
1316
|
+
return { ...node, stroke: { token: "ink" }, strokeWidth: lost ? strokeToken(theme, "hair") : 0, groundEdge: !0 };
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
function splitHalf(scene, index) {
|
|
1320
|
+
let self = scene[index], key = JSON.stringify(self.fill), left = self.rect.x + (self.tx ?? 0), right = left + self.rect.w, top = self.rect.y + (self.ty ?? 0);
|
|
1321
|
+
return scene.some((other, i) => i !== index && other.t === "rect" && other.part === self.part && JSON.stringify(other.fill) === key && Math.abs(other.rect.y + (other.ty ?? 0) - top) < 0.01 && Math.abs(other.rect.h - self.rect.h) < 0.01 && other.rect.x + (other.tx ?? 0) <= right + 0.01 && other.rect.x + (other.tx ?? 0) + other.rect.w >= left - 0.01);
|
|
1322
|
+
}
|
|
1323
|
+
var TEXT_ASCENT = 0.88;
|
|
1324
|
+
function rightAlignedColumns(labels) {
|
|
1325
|
+
let columns = /* @__PURE__ */ new Map();
|
|
1326
|
+
for (let label of labels) {
|
|
1327
|
+
if (label.hidden || label.swatch || label.rotate || label.align !== void 0 || label.lines.length !== 1) continue;
|
|
1328
|
+
let key = `${label.kind}${Math.round((label.rect.x + label.rect.w) * 100)}`, column = columns.get(key);
|
|
1329
|
+
column ? column.push(label) : columns.set(key, [label]);
|
|
1330
|
+
}
|
|
1331
|
+
let flush = /* @__PURE__ */ new Set();
|
|
1332
|
+
for (let column of columns.values())
|
|
1333
|
+
if (new Set(column.map((label) => Math.round(label.rect.x * 100))).size > 1) for (let label of column) flush.add(label);
|
|
1334
|
+
return flush;
|
|
1335
|
+
}
|
|
1336
|
+
function labelsToNodes(theme, labels, fontOf, marks) {
|
|
1337
|
+
marks && haloHatchedInsideLabels(marks, labels);
|
|
1338
|
+
let crossing = haloLabelsUnderLeaders(labels), nodes = [], leaderOf = (label) => ({
|
|
1339
|
+
t: "path",
|
|
1340
|
+
id: `leader:${label.id}`,
|
|
1341
|
+
d: label.leader.d,
|
|
1342
|
+
stroke: { token: "leader" },
|
|
1343
|
+
width: strokeToken(theme, "rule"),
|
|
1344
|
+
owner: label.owner,
|
|
1345
|
+
part: "leader"
|
|
1346
|
+
});
|
|
1347
|
+
for (let label of labels) crossing.has(label.id) && nodes.push(leaderOf(label));
|
|
1348
|
+
let flushRight = rightAlignedColumns(labels);
|
|
1349
|
+
for (let label of labels) {
|
|
1350
|
+
if (label.hidden) continue;
|
|
1351
|
+
label.leader && !crossing.has(label.id) && nodes.push(leaderOf(label)), label.swatch && nodes.push({
|
|
1352
|
+
t: "rect",
|
|
1353
|
+
id: `swatch:${label.id}`,
|
|
1354
|
+
rect: {
|
|
1355
|
+
x: label.rect.x,
|
|
1356
|
+
y: label.rect.y + label.rect.h / 2 - SWATCH_W / 2,
|
|
1357
|
+
w: SWATCH_W,
|
|
1358
|
+
h: SWATCH_W
|
|
1359
|
+
},
|
|
1360
|
+
fill: label.swatch,
|
|
1361
|
+
...swatchHairline(theme, label.swatch),
|
|
1362
|
+
owner: label.owner,
|
|
1363
|
+
part: "labelSwatch"
|
|
1364
|
+
}), label.plate && nodes.push({ t: "rect", id: `plate:${label.id}`, rect: labelPlate(label.rect), fill: { token: "background" }, radius: LABEL_PLATE_RADIUS, owner: label.owner, part: "labelPlate" });
|
|
1365
|
+
let nodeId = `label:${label.id}`;
|
|
1366
|
+
label.nodeId = nodeId;
|
|
1367
|
+
let own = label.font ?? fontOf(label), font = label.emphasis ? { ...own, weight: emphasisWeight(theme) } : own, rotated = label.rotate !== void 0 && label.rotate !== 0, lineH = font.size * (font.lineHeight ?? 1.2), head = label.headLines !== void 0 && label.headLines < label.lines.length ? label.headLines : 0;
|
|
1368
|
+
nodes.push({
|
|
1369
|
+
t: "text",
|
|
1370
|
+
id: nodeId,
|
|
1371
|
+
x: rotated || flushRight.has(label) ? label.rect.x + label.rect.w : label.align === "middle" ? label.rect.x + label.rect.w / 2 : label.align === "end" ? label.rect.x + label.rect.w : label.rect.x + (label.swatch ? SWATCH_RESERVE : 0),
|
|
1372
|
+
y: rotated ? label.rect.y + lineH * Math.SQRT1_2 / 2 - font.size * TEXT_ASCENT : label.lines.length === 1 && label.capHeight !== void 0 ? label.rect.y + label.rect.h / 2 + label.capHeight / 2 - font.size * TEXT_ASCENT : label.rect.y,
|
|
1373
|
+
lines: head > 0 ? label.lines.slice(0, head) : label.lines,
|
|
1374
|
+
...label.runs && label.lines.length === 1 && !rotated ? { runs: label.runs } : {},
|
|
1375
|
+
...label.title ? { title: label.title } : {},
|
|
1376
|
+
align: rotated || flushRight.has(label) ? "end" : label.align ?? "start",
|
|
1377
|
+
font: head > 0 ? { ...font, weight: label.headWeight ?? WEIGHT_EMPHASIS } : font,
|
|
1378
|
+
ink: head > 0 && label.headInk ? label.headInk : labelInk(theme, label),
|
|
1379
|
+
halo: label.halo ?? label.leader !== void 0,
|
|
1380
|
+
backing: label.backing,
|
|
1381
|
+
...label.rotate ? { rotate: label.rotate } : {},
|
|
1382
|
+
owner: label.owner,
|
|
1383
|
+
part: label.kind,
|
|
1384
|
+
typeRole: labelTypeRole(label),
|
|
1385
|
+
// A headline such as "153" is a value over the words, whatever the label's role.
|
|
1386
|
+
...head > 0 ? { role: composedTextRole(label.lines.slice(0, head).join(" "), "note") } : label.role ? { role: label.role } : {}
|
|
1387
|
+
}), head > 0 && nodes.push({
|
|
1388
|
+
t: "text",
|
|
1389
|
+
id: `${nodeId}:body`,
|
|
1390
|
+
x: label.align === "middle" ? label.rect.x + label.rect.w / 2 : label.align === "end" ? label.rect.x + label.rect.w : label.rect.x,
|
|
1391
|
+
y: label.rect.y + head * lineH,
|
|
1392
|
+
lines: label.lines.slice(head),
|
|
1393
|
+
align: label.align ?? "start",
|
|
1394
|
+
font: label.bodyFont ?? font,
|
|
1395
|
+
ink: label.bodyInk ?? label.ink,
|
|
1396
|
+
halo: label.halo ?? label.leader !== void 0,
|
|
1397
|
+
owner: label.owner,
|
|
1398
|
+
part: label.kind,
|
|
1399
|
+
typeRole: labelTypeRole(label),
|
|
1400
|
+
...label.role ? { role: label.role } : {}
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
return nodes;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// src/core/repaintGeometry.ts
|
|
1407
|
+
function repaintGeometry(geometry, theme, options) {
|
|
1408
|
+
let scene = repaintScene(geometry.scene, theme, sceneThemeBindings(geometry)), warnings = geometry.paintWarningRules?.length ? refreshPaintWarnings(geometry.warnings, geometry.paintWarningRules.map((rule) => rule.kind === "mark-lost-on-band" ? { ...rule, pairs: marksOnBands(scene) } : rule), theme) : [...geometry.warnings];
|
|
1409
|
+
if (options?.palette && warnings.some((warning) => warning.code === "unknown-palette")) {
|
|
1410
|
+
let message = "";
|
|
1411
|
+
resolvePalette(theme, options.palette, (_code, text) => {
|
|
1412
|
+
message = text;
|
|
1413
|
+
}), warnings = warnings.flatMap((warning) => warning.code === "unknown-palette" ? message ? [{ ...warning, message }] : [] : [warning]);
|
|
1414
|
+
}
|
|
1415
|
+
if (geometry.type === "grid") {
|
|
1416
|
+
let panels = geometry.marks.panels;
|
|
1417
|
+
for (let panel of [...panels].reverse()) {
|
|
1418
|
+
let chart = panel.chart;
|
|
1419
|
+
if (!chart || chart.warningOffset === void 0) continue;
|
|
1420
|
+
let child = repaintGeometry(chart.geometry, chart.theme ? resolveTheme(chart.theme) : theme, chart.options);
|
|
1421
|
+
warnings.splice(
|
|
1422
|
+
chart.warningOffset,
|
|
1423
|
+
chart.geometry.warnings.length,
|
|
1424
|
+
...child.warnings.map((warning) => ({
|
|
1425
|
+
...warning,
|
|
1426
|
+
message: `[${panel.id}] ${warning.message}`,
|
|
1427
|
+
...chart.warningOwnerPrefix === void 0 ? {} : {
|
|
1428
|
+
owner: warning.owner ? {
|
|
1429
|
+
...warning.owner,
|
|
1430
|
+
...warning.owner.annotationId === void 0 ? {} : { annotationId: chart.warningOwnerPrefix + warning.owner.annotationId },
|
|
1431
|
+
...warning.owner.valueLineId === void 0 ? {} : { valueLineId: chart.warningOwnerPrefix + warning.owner.valueLineId }
|
|
1432
|
+
} : void 0
|
|
1433
|
+
}
|
|
1434
|
+
}))
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
return { ...geometry, scene, warnings };
|
|
1439
|
+
}
|
|
1440
|
+
function repaintScene(scene, theme, bindings = []) {
|
|
1441
|
+
let themes = bindings.map((binding) => ({ ...binding, theme: resolveTheme(binding.theme) })), themeOf = (node) => {
|
|
1442
|
+
let activeTheme = theme;
|
|
1443
|
+
for (let binding of themes) node.id.startsWith(binding.prefix) && (activeTheme = binding.theme);
|
|
1444
|
+
return activeTheme;
|
|
1445
|
+
};
|
|
1446
|
+
scene = referenceCasings(scene);
|
|
1447
|
+
let seen = /* @__PURE__ */ new Map(), check = (paint, activeTheme) => {
|
|
1448
|
+
if (!paint || !("token" in paint) || !paint.theme) return;
|
|
1449
|
+
let key = JSON.stringify(paint), checked = seen.get(activeTheme) ?? /* @__PURE__ */ new Set();
|
|
1450
|
+
checked.has(key) || (checked.add(key), seen.set(activeTheme, checked), paintColor(activeTheme, paint));
|
|
1451
|
+
}, repainted = scene.map((node) => {
|
|
1452
|
+
let activeTheme = themeOf(node);
|
|
1453
|
+
return "fill" in node && check(node.fill, activeTheme), "stroke" in node && check(node.stroke, activeTheme), node.t === "text" && check(node.ink, activeTheme), repaintSeparation(node, activeTheme);
|
|
1454
|
+
});
|
|
1455
|
+
return groundEdges(decideFillEdges(repainted, themeOf, !0), themeOf, !0);
|
|
1456
|
+
}
|
|
1457
|
+
function sceneThemeBindings(geometry, prefix = "", result = []) {
|
|
1458
|
+
if (geometry.type !== "grid") return result;
|
|
1459
|
+
for (let panel of geometry.marks.panels) {
|
|
1460
|
+
if (!panel.chart) continue;
|
|
1461
|
+
let childPrefix = `${prefix}${panel.id}/`;
|
|
1462
|
+
panel.chart.theme && result.push({ prefix: childPrefix, theme: panel.chart.theme }), sceneThemeBindings(panel.chart.geometry, childPrefix, result);
|
|
1463
|
+
}
|
|
1464
|
+
return result;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// src/core/image.ts
|
|
1468
|
+
function assertEmbeddedImage(src) {
|
|
1469
|
+
let match = typeof src == "string" && /^data:image\/(png|jpeg|webp);base64,([A-Za-z0-9+/]+={0,2})$/.exec(src);
|
|
1470
|
+
if (!match || match[2].length % 4 !== 0)
|
|
1471
|
+
throw new NormalizeError("unsupported-media", "media", "Use an embedded base64 PNG, JPEG or WebP image. External sources and SVG images are not supported.");
|
|
1472
|
+
let bytes = atob(match[2].slice(0, 24));
|
|
1473
|
+
if (!(match[1] === "png" ? bytes.startsWith(`\x89PNG\r
|
|
1474
|
+
|
|
1475
|
+
`) : match[1] === "jpeg" ? bytes.startsWith("\xFF\xD8\xFF") : bytes.startsWith("RIFF") && bytes.slice(8, 12) === "WEBP")) throw new NormalizeError("unsupported-media", "media", "The embedded image header does not match its declared format.");
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
// src/core/svg/paint.ts
|
|
1479
|
+
function isSafeSvgColor(value) {
|
|
1480
|
+
return literalColor(value) !== null;
|
|
1481
|
+
}
|
|
1482
|
+
function checkedColor(value) {
|
|
1483
|
+
let color = literalColor(value);
|
|
1484
|
+
if (color === null) throw new Error(`invalid SVG color '${value.slice(0, 120)}'. ${COLOR_FIX}`);
|
|
1485
|
+
return color;
|
|
1486
|
+
}
|
|
1487
|
+
var FIXED_PAINT_TOKENS = /* @__PURE__ */ new Set([
|
|
1488
|
+
"good",
|
|
1489
|
+
"bad",
|
|
1490
|
+
"warn",
|
|
1491
|
+
"neutral",
|
|
1492
|
+
"neutralLight",
|
|
1493
|
+
"neutralMark",
|
|
1494
|
+
"highlight",
|
|
1495
|
+
"total",
|
|
1496
|
+
"others",
|
|
1497
|
+
"ink",
|
|
1498
|
+
"inkInverse",
|
|
1499
|
+
"inkMuted",
|
|
1500
|
+
"axis",
|
|
1501
|
+
"grid",
|
|
1502
|
+
"leader",
|
|
1503
|
+
"case-1",
|
|
1504
|
+
"case-2",
|
|
1505
|
+
"background",
|
|
1506
|
+
"focus",
|
|
1507
|
+
"spark",
|
|
1508
|
+
"goodFill",
|
|
1509
|
+
"badFill",
|
|
1510
|
+
"warnFill",
|
|
1511
|
+
"inkMeta",
|
|
1512
|
+
"rest",
|
|
1513
|
+
"othersMark",
|
|
1514
|
+
"markInk",
|
|
1515
|
+
"heatTop",
|
|
1516
|
+
"heatTopInk",
|
|
1517
|
+
"rule",
|
|
1518
|
+
"reference"
|
|
1519
|
+
]);
|
|
1520
|
+
function assertPaintToken(token) {
|
|
1521
|
+
if (!FIXED_PAINT_TOKENS.has(token) && !/^series-[1-9]\d*$/.test(token) && !/^status-[A-Za-z0-9][A-Za-z0-9_-]*$/.test(token))
|
|
1522
|
+
throw new Error(`invalid SVG paint token '${token}'`);
|
|
1523
|
+
}
|
|
1524
|
+
function validateTint(value) {
|
|
1525
|
+
if (value !== void 0 && (!Number.isFinite(value) || value < 0 || value > 1))
|
|
1526
|
+
throw new Error(`invalid SVG paint tint '${String(value)}'`);
|
|
1527
|
+
}
|
|
1528
|
+
function resolvePaint(paint, theme) {
|
|
1529
|
+
return "css" in paint ? checkedColor(paint.css) : ("token" in paint && assertPaintToken(paint.token), validateTint(paint.tint), checkedColor(paintColor(theme, paint)));
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// src/core/haloPaint.ts
|
|
1533
|
+
function haloPaint(ink, theme) {
|
|
1534
|
+
let color = resolvePaint(ink, theme), token = "background", contrast = contrastRatio(color, theme.color.background);
|
|
1535
|
+
if (contrast >= 4.5) return { token };
|
|
1536
|
+
for (let candidate of ["ink", "inkInverse"]) {
|
|
1537
|
+
let next = contrastRatio(color, theme.color[candidate]);
|
|
1538
|
+
next > contrast && (token = candidate, contrast = next);
|
|
1539
|
+
}
|
|
1540
|
+
return { token };
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// src/core/svg/renderSvg.ts
|
|
1544
|
+
var ID_SCOPE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
1545
|
+
function xmlCharFault(value) {
|
|
1546
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
1547
|
+
let unit = value.charCodeAt(i);
|
|
1548
|
+
if (!(unit >= 32 && unit <= 55295) && !(unit === 9 || unit === 10 || unit === 13) && !(unit >= 57344 && unit <= 65533)) {
|
|
1549
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
1550
|
+
let low = value.charCodeAt(i + 1);
|
|
1551
|
+
if (low >= 56320 && low <= 57343) {
|
|
1552
|
+
i += 1;
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
return { index: i, unit };
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
var codePointName = (unit) => `U+${unit.toString(16).toUpperCase().padStart(4, "0")}`;
|
|
1561
|
+
function printable(value) {
|
|
1562
|
+
let out = "";
|
|
1563
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
1564
|
+
let unit = value.charCodeAt(i);
|
|
1565
|
+
out += unit >= 32 && unit <= 126 ? value[i] : `\\u${unit.toString(16).toUpperCase().padStart(4, "0")}`;
|
|
1566
|
+
}
|
|
1567
|
+
return out;
|
|
1568
|
+
}
|
|
1569
|
+
var XmlCharError = class extends Error {
|
|
1570
|
+
};
|
|
1571
|
+
function assertXmlText(value, channel) {
|
|
1572
|
+
let fault = xmlCharFault(value);
|
|
1573
|
+
if (!fault) return value;
|
|
1574
|
+
let kind = fault.unit >= 55296 && fault.unit <= 57343 ? "unpaired surrogate" : fault.unit === 65534 || fault.unit === 65535 ? "non-character" : "control character";
|
|
1575
|
+
throw new XmlCharError(
|
|
1576
|
+
`invalid XML character ${codePointName(fault.unit)} (${kind}) at index ${fault.index} of ${channel} '${printable(value)}': XML 1.0 cannot represent it, not even as a character reference \u2014 remove it from the source string`
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1579
|
+
var ESCAPABLE = /[&<>"\t\n\r]/, esc = (s, channel = "text") => ESCAPABLE.test(s) ? assertXmlText(s, channel).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\t/g, "	").replace(/\n/g, " ").replace(/\r/g, " ") : assertXmlText(s, channel);
|
|
1580
|
+
function colorAttr(value) {
|
|
1581
|
+
let color = checkedColor(value);
|
|
1582
|
+
return esc(color);
|
|
1583
|
+
}
|
|
1584
|
+
function validateNumber(label, value, minimum) {
|
|
1585
|
+
if (value !== void 0 && (!Number.isFinite(value) || minimum !== void 0 && value < minimum))
|
|
1586
|
+
throw new Error(`invalid SVG numeric ${label} '${String(value)}'`);
|
|
1587
|
+
}
|
|
1588
|
+
var VALID_LINE_CAPS = /* @__PURE__ */ new Set(["butt", "round", "square"]);
|
|
1589
|
+
function validateLineCap(label, value) {
|
|
1590
|
+
if (value !== void 0 && !VALID_LINE_CAPS.has(value))
|
|
1591
|
+
throw new Error(`invalid SVG lineCap ${label} '${value}'`);
|
|
1592
|
+
}
|
|
1593
|
+
var NON_FINITE_IN_PATH = /NaN|Infinity/;
|
|
1594
|
+
function validatePathData(label, d) {
|
|
1595
|
+
let nonFinite = NON_FINITE_IN_PATH.exec(d);
|
|
1596
|
+
if (nonFinite)
|
|
1597
|
+
throw new Error(
|
|
1598
|
+
`invalid SVG path ${label}: non-finite coordinate '${nonFinite[0]}' in '${d.slice(0, 60)}'`
|
|
1599
|
+
);
|
|
1600
|
+
}
|
|
1601
|
+
function validateRectNumbers(label, rect) {
|
|
1602
|
+
validateNumber(`${label}.x`, rect.x), validateNumber(`${label}.y`, rect.y), validateNumber(`${label}.w`, rect.w, 0), validateNumber(`${label}.h`, rect.h, 0);
|
|
1603
|
+
}
|
|
1604
|
+
function validateGeometryNumbers(geometry) {
|
|
1605
|
+
validateNumber("size.width", geometry.size.width, 0), validateNumber("size.height", geometry.size.height, 0);
|
|
1606
|
+
for (let node of geometry.scene) {
|
|
1607
|
+
if (validateNumber(`${node.id}.tx`, node.tx), node.opacity !== void 0 && (typeof node.opacity != "number" || !(node.opacity >= 0 && node.opacity <= 1))) throw new Error(`invalid geometry opacity ${node.id}`);
|
|
1608
|
+
if (validateNumber(`${node.id}.ty`, node.ty), node.t === "rect")
|
|
1609
|
+
validateRectNumbers(`${node.id}.rect`, node.rect), validateNumber(`${node.id}.strokeWidth`, node.strokeWidth, 0), validateNumber(`${node.id}.radius`, node.radius, 0);
|
|
1610
|
+
else if (node.t === "image")
|
|
1611
|
+
validateRectNumbers(`${node.id}.rect`, node.rect), assertEmbeddedImage(node.src);
|
|
1612
|
+
else if (node.t === "line")
|
|
1613
|
+
validateNumber(`${node.id}.x1`, node.x1), validateNumber(`${node.id}.y1`, node.y1), validateNumber(`${node.id}.x2`, node.x2), validateNumber(`${node.id}.y2`, node.y2), validateNumber(`${node.id}.width`, node.width, 0), node.dash?.forEach(
|
|
1614
|
+
(value, index) => validateNumber(`${node.id}.dash[${index}]`, value, 0)
|
|
1615
|
+
), validateLineCap(`${node.id}.lineCap`, node.lineCap);
|
|
1616
|
+
else if (node.t === "path")
|
|
1617
|
+
validatePathData(`${node.id}.d`, node.d), validateNumber(`${node.id}.width`, node.width, 0), node.dash?.forEach(
|
|
1618
|
+
(value, index) => validateNumber(`${node.id}.dash[${index}]`, value, 0)
|
|
1619
|
+
), validateLineCap(`${node.id}.lineCap`, node.lineCap);
|
|
1620
|
+
else if (node.t === "circle")
|
|
1621
|
+
validateNumber(`${node.id}.cx`, node.cx), validateNumber(`${node.id}.cy`, node.cy), validateNumber(`${node.id}.r`, node.r, 0);
|
|
1622
|
+
else {
|
|
1623
|
+
if (validateNumber(`${node.id}.x`, node.x), validateNumber(`${node.id}.y`, node.y), validateNumber(`${node.id}.font.size`, node.font.size, 0), validateNumber(`${node.id}.font.weight`, node.font.weight, 0), node.font.style !== void 0 && node.font.style !== "normal" && node.font.style !== "italic") throw new Error(`invalid SVG font style ${node.id}`);
|
|
1624
|
+
if (validateNumber(`${node.id}.font.lineHeight`, node.font.lineHeight, 0), validateNumber(`${node.id}.font.letterSpacing`, node.font.letterSpacing), node.runs !== void 0) {
|
|
1625
|
+
if (!Array.isArray(node.runs) || node.runs.length === 0)
|
|
1626
|
+
throw new Error(`invalid SVG text runs ${node.id} \u2014 expected a non-empty array`);
|
|
1627
|
+
for (let index = 0; index < node.runs.length; index++) {
|
|
1628
|
+
let run = node.runs[index];
|
|
1629
|
+
if (typeof run != "object" || run === null)
|
|
1630
|
+
throw new Error(`invalid SVG text run ${node.id}.runs[${index}] \u2014 expected an object`);
|
|
1631
|
+
let { text, weight } = run;
|
|
1632
|
+
if (typeof text != "string")
|
|
1633
|
+
throw new Error(`invalid SVG text run ${node.id}.runs[${index}].text \u2014 expected a string`);
|
|
1634
|
+
if (validateNumber(`${node.id}.runs[${index}].weight`, weight, 1), typeof weight == "number" && weight > 1e3)
|
|
1635
|
+
throw new Error(`invalid SVG numeric ${node.id}.runs[${index}].weight '${weight}' \u2014 above 1000`);
|
|
1636
|
+
}
|
|
1637
|
+
if (node.lines.length !== 1 || node.lines[0] !== node.runs.map((run) => run.text).join(""))
|
|
1638
|
+
throw new Error(
|
|
1639
|
+
`invalid SVG text runs ${node.id} \u2014 runs are single-line and lines[0] must equal the concatenated run texts`
|
|
1640
|
+
);
|
|
1641
|
+
}
|
|
1642
|
+
node.backing && validateRectNumbers(`${node.id}.backing`, node.backing);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
function validateThemeNumbers(theme) {
|
|
1647
|
+
validateNumber("theme.pattern.hatchGap", theme.pattern.hatchGap, Number.MIN_VALUE), validateNumber("theme.pattern.hatchStrokeWidth", theme.pattern.hatchStrokeWidth, 0), validateNumber("theme.pattern.hatchAngle", theme.pattern.hatchAngle), validateNumber("theme.pattern.outlineStrokeWidth", theme.pattern.outlineStrokeWidth, 0);
|
|
1648
|
+
}
|
|
1649
|
+
function validateThemeColors(theme) {
|
|
1650
|
+
let color = theme.color, values = [
|
|
1651
|
+
color.good,
|
|
1652
|
+
color.bad,
|
|
1653
|
+
color.warn,
|
|
1654
|
+
color.neutral,
|
|
1655
|
+
color.neutralLight,
|
|
1656
|
+
color.highlight,
|
|
1657
|
+
color.focus,
|
|
1658
|
+
color.spark,
|
|
1659
|
+
color.neutralMark,
|
|
1660
|
+
color.goodFill,
|
|
1661
|
+
color.badFill,
|
|
1662
|
+
color.warnFill,
|
|
1663
|
+
color.inkMeta,
|
|
1664
|
+
color.rest,
|
|
1665
|
+
color.othersMark,
|
|
1666
|
+
color.markInk,
|
|
1667
|
+
color.heatTop,
|
|
1668
|
+
color.heatTopInk,
|
|
1669
|
+
color.onFillInk,
|
|
1670
|
+
color.onFillLightInk,
|
|
1671
|
+
color.rule,
|
|
1672
|
+
color.reference,
|
|
1673
|
+
color.total,
|
|
1674
|
+
color.others,
|
|
1675
|
+
color.ink,
|
|
1676
|
+
color.inkInverse,
|
|
1677
|
+
color.inkMuted,
|
|
1678
|
+
color.axis,
|
|
1679
|
+
color.grid,
|
|
1680
|
+
color.leader,
|
|
1681
|
+
color.background,
|
|
1682
|
+
...color.series,
|
|
1683
|
+
...color.casePair ?? [],
|
|
1684
|
+
...color.stack ?? [],
|
|
1685
|
+
...Object.values(color.palettes ?? {}).flat(),
|
|
1686
|
+
...Object.values(color.status),
|
|
1687
|
+
color.colorblind.good,
|
|
1688
|
+
color.colorblind.bad
|
|
1689
|
+
];
|
|
1690
|
+
for (let value of values)
|
|
1691
|
+
value !== void 0 && checkedColor(value);
|
|
1692
|
+
}
|
|
1693
|
+
function paintFormatter(theme) {
|
|
1694
|
+
let attr = (paint) => "css" in paint ? colorAttr(paint.css) : ("token" in paint && assertPaintToken(paint.token), validateTint(paint.tint), colorAttr(resolvePaint(paint, theme)));
|
|
1695
|
+
return {
|
|
1696
|
+
attr,
|
|
1697
|
+
background: () => attr({ token: "background" }),
|
|
1698
|
+
halo: (ink) => attr(haloPaint(ink, theme))
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
var TEXT_ASCENT2 = 0.88, n2 = (v) => Number.isInteger(v) ? String(v) : v.toFixed(2), XLINK_NS = "http://www.w3.org/1999/xlink", ROOT_STYLE = "max-width:100%;height:auto;text-transform:none;letter-spacing:normal;word-spacing:normal;font-style:normal;font-variant:normal";
|
|
1702
|
+
function fillKey(node) {
|
|
1703
|
+
if (!(!node || !("fill" in node) || !node.fill))
|
|
1704
|
+
return `${JSON.stringify(node.fill)}${node.t === "rect" || node.t === "path" ? node.pattern ?? "" : ""}`;
|
|
1705
|
+
}
|
|
1706
|
+
function interactiveContext(geometry, claims) {
|
|
1707
|
+
let categoryLabels = /* @__PURE__ */ new Map();
|
|
1708
|
+
for (let label of geometry.labels)
|
|
1709
|
+
(label.kind === "category" || label.kind === "activity") && label.owner.categoryId && categoryLabels.set(label.owner.categoryId, label.text);
|
|
1710
|
+
let sceneById = new Map(geometry.scene.map((node) => [node.id, node])), legendKeysByNodeId = /* @__PURE__ */ new Map(), legendTriggerNodeIds = /* @__PURE__ */ new Set(), legendKeysByPaint = /* @__PURE__ */ new Map(), ambiguousLegendPaints = /* @__PURE__ */ new Set(), seriesLabels = /* @__PURE__ */ new Map();
|
|
1711
|
+
for (let item of geometry.legend?.items ?? []) {
|
|
1712
|
+
legendKeysByNodeId.set(item.swatchNodeId, item.id), legendKeysByNodeId.set(item.labelId, item.id), legendTriggerNodeIds.add(item.labelId);
|
|
1713
|
+
let swatchKey = fillKey(sceneById.get(item.swatchNodeId));
|
|
1714
|
+
if (swatchKey) {
|
|
1715
|
+
let existing = legendKeysByPaint.get(swatchKey);
|
|
1716
|
+
existing && existing !== item.id ? (legendKeysByPaint.delete(swatchKey), ambiguousLegendPaints.add(swatchKey)) : ambiguousLegendPaints.has(swatchKey) || legendKeysByPaint.set(swatchKey, item.id);
|
|
1717
|
+
}
|
|
1718
|
+
let labelNode = sceneById.get(item.labelId);
|
|
1719
|
+
labelNode?.t === "text" && seriesLabels.set(item.id, labelNode.lines.join(" "));
|
|
1720
|
+
}
|
|
1721
|
+
for (let label of geometry.labels)
|
|
1722
|
+
label.kind === "series" && label.owner.seriesId && !label.owner.categoryId && !seriesLabels.has(label.owner.seriesId) && seriesLabels.set(label.owner.seriesId, label.text);
|
|
1723
|
+
let claimsByNodeId = /* @__PURE__ */ new Map();
|
|
1724
|
+
for (let claim of claims ?? [])
|
|
1725
|
+
claim.nodeId && claimsByNodeId.set(claim.nodeId, claim.id);
|
|
1726
|
+
return {
|
|
1727
|
+
categoryLabels,
|
|
1728
|
+
seriesLabels,
|
|
1729
|
+
legendKeysByNodeId,
|
|
1730
|
+
legendTriggerNodeIds,
|
|
1731
|
+
legendKeysByPaint,
|
|
1732
|
+
claimsByNodeId
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
function renderSvgInternal(geometry, theme, opts) {
|
|
1736
|
+
validateThemeColors(theme), validateThemeNumbers(theme), validateGeometryNumbers(geometry);
|
|
1737
|
+
let formatter = paintFormatter(theme), bindings = sceneThemeBindings(geometry).map((binding) => {
|
|
1738
|
+
let childTheme = resolveTheme(binding.theme);
|
|
1739
|
+
return { prefix: binding.prefix, theme: childTheme, formatter: paintFormatter(childTheme) };
|
|
1740
|
+
}), contextFor = (node) => {
|
|
1741
|
+
let context = { theme, formatter };
|
|
1742
|
+
for (let binding of bindings) node.id.startsWith(binding.prefix) && (context = binding);
|
|
1743
|
+
return context;
|
|
1744
|
+
}, interactive = opts.interactive === !0, interaction = interactive ? interactiveContext(geometry, opts.claims) : void 0, idScope = opts.idScope;
|
|
1745
|
+
if (idScope !== void 0 && !ID_SCOPE_PATTERN.test(idScope))
|
|
1746
|
+
throw new Error(
|
|
1747
|
+
`renderSvg: idScope '${idScope}' must match ${ID_SCOPE_PATTERN.source} (it is pasted into an id)`
|
|
1748
|
+
);
|
|
1749
|
+
let { size } = geometry, natural = geometry.presentation?.naturalSize, dims = natural?.unit === "pt" ? `width="${n2(natural.width)}pt" height="${n2(natural.height)}pt"` : `width="${n2(size.width)}" height="${n2(size.height)}"`, out = [], titleId = scopedId("bp-title", idScope), descId = scopedId("bp-desc", idScope), xlink = geometry.scene.some((node) => node.t === "image") ? ` xmlns:xlink="${XLINK_NS}"` : "";
|
|
1750
|
+
out.push(
|
|
1751
|
+
`<svg xmlns="http://www.w3.org/2000/svg"${xlink} data-bp-engine="${ENGINE_REV}" viewBox="0 0 ${n2(size.width)} ${n2(size.height)}" ${dims} direction="ltr" style="${ROOT_STYLE}" preserveAspectRatio="xMidYMid meet" role="${interactive ? "graphics-document document" : "img"}" aria-label="${esc(geometry.a11y.title, "a11y.title")}" aria-describedby="${descId}" ${geometry.sizing ? `data-bp-sizing="${esc(JSON.stringify(geometry.sizing), "sizing")}" ` : ""}${geometry.mode ? `data-bp-mode="${geometry.mode}" ` : ""}font-family="${esc(theme.type.family, "theme.type.family")}"${interactive ? ` data-bp-interactive="" data-bp-chart="${esc(geometry.type, "geometry.type")}"` : ""}>`
|
|
1752
|
+
), geometry.a11y.includeTitle === !0 && out.push(`<title id="${titleId}">${esc(geometry.a11y.title, "a11y.title")}</title>`), out.push(`<desc id="${descId}">${esc(geometry.a11y.desc, "a11y.desc")}</desc>`);
|
|
1753
|
+
let patternDefs = /* @__PURE__ */ new Map();
|
|
1754
|
+
for (let node of geometry.scene)
|
|
1755
|
+
if ((node.t === "rect" || node.t === "path") && isHatchPattern(node.pattern) && node.fill) {
|
|
1756
|
+
let { theme: theme2, formatter: formatter2 } = contextFor(node), ground = node.t === "rect" ? node.hatchGround : void 0, { id, stroke, background: bg, gap, width } = resolvedHatchPattern(node.fill, theme2, formatter2, idScope, ground, node.hatch, node.pattern);
|
|
1757
|
+
if (!patternDefs.has(id)) {
|
|
1758
|
+
let tile = hatchTile(gap, width, node.pattern);
|
|
1759
|
+
patternDefs.set(
|
|
1760
|
+
id,
|
|
1761
|
+
`<pattern id="${esc(id, "pattern id")}" patternUnits="userSpaceOnUse" width="${tile.size}" height="${tile.size}"><rect width="${tile.size}" height="${tile.size}" fill="${bg}"/><path d="${tile.d}" fill="none" stroke="${stroke}" stroke-width="${tile.strokeWidth}"/></pattern>`
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
patternDefs.size > 0 && out.push(`<defs>${[...patternDefs.values()].join("")}</defs>`), opts.background !== !1 && out.push(
|
|
1766
|
+
`<rect x="0" y="0" width="${n2(size.width)}" height="${n2(size.height)}" fill="${formatter.background()}"/>`
|
|
1767
|
+
);
|
|
1768
|
+
for (let node of geometry.scene) {
|
|
1769
|
+
let context = contextFor(node);
|
|
1770
|
+
out.push(renderNode(node, context.theme, context.formatter, interaction, idScope, theme.type.family));
|
|
1771
|
+
}
|
|
1772
|
+
return out.push("</svg>"), out.join(`
|
|
1773
|
+
`);
|
|
1774
|
+
}
|
|
1775
|
+
function renderSvg(geometry, theme, opts = {}) {
|
|
1776
|
+
return renderSvgInternal(geometry, theme, opts);
|
|
1777
|
+
}
|
|
1778
|
+
function scopedId(id, scope) {
|
|
1779
|
+
return scope === void 0 ? id : `${id}-${scope}`;
|
|
1780
|
+
}
|
|
1781
|
+
function renderNode(node, theme, formatter, interaction, idScope, rootFontFamily = theme.type.family) {
|
|
1782
|
+
let tf = node.tx || node.ty ? ` transform="translate(${n2(node.tx ?? 0)},${n2(node.ty ?? 0)})"` : "";
|
|
1783
|
+
try {
|
|
1784
|
+
return renderNodeInner(node, theme, formatter, tf, interaction, idScope, rootFontFamily);
|
|
1785
|
+
} catch (error) {
|
|
1786
|
+
throw error instanceof XmlCharError ? new XmlCharError(
|
|
1787
|
+
`scene node '${printable(node.id)}' (part '${printable(node.part)}'): ${error.message}`
|
|
1788
|
+
) : error;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
function interactiveAttrs(node, context) {
|
|
1792
|
+
if (!context) return "";
|
|
1793
|
+
let attrs = [` data-bp-part="${esc(node.part, "node.part")}"`], { owner } = node;
|
|
1794
|
+
if (owner.seriesId) {
|
|
1795
|
+
attrs.push(` data-bp-series="${esc(owner.seriesId, "owner.seriesId")}"`);
|
|
1796
|
+
let label = context.seriesLabels.get(owner.seriesId);
|
|
1797
|
+
label && attrs.push(` data-bp-series-label="${esc(label, "series label")}"`);
|
|
1798
|
+
}
|
|
1799
|
+
if (owner.categoryId) {
|
|
1800
|
+
attrs.push(` data-bp-category="${esc(owner.categoryId, "owner.categoryId")}"`);
|
|
1801
|
+
let label = context.categoryLabels.get(owner.categoryId);
|
|
1802
|
+
label && attrs.push(` data-bp-category-label="${esc(label, "category label")}"`);
|
|
1803
|
+
}
|
|
1804
|
+
owner.rowId && attrs.push(` data-bp-row="${esc(owner.rowId, "owner.rowId")}"`), owner.colId && attrs.push(` data-bp-column="${esc(owner.colId, "owner.colId")}"`), node.display?.value !== void 0 && attrs.push(` data-bp-value="${esc(node.display.value, "display.value")}"`), node.display?.state !== void 0 && attrs.push(` data-bp-state="${esc(node.display.state, "display.state")}"`);
|
|
1805
|
+
let legendKey = context.legendKeysByNodeId.get(node.id), paintKey = context.legendKeysByPaint.get(fillKey(node) ?? ""), key = legendKey ?? paintKey ?? owner.seriesId ?? owner.segmentId ?? owner.pointId ?? owner.categoryId ?? owner.valueLineId ?? owner.annotationId ?? (owner.rowId || owner.colId ? `${owner.rowId ?? ""}:${owner.colId ?? ""}` : void 0);
|
|
1806
|
+
key && attrs.push(` data-bp-key="${esc(key, "interaction key")}"`), context.legendTriggerNodeIds.has(node.id) && attrs.push(' data-bp-legend=""');
|
|
1807
|
+
let claim = context.claimsByNodeId.get(node.id);
|
|
1808
|
+
return claim && attrs.push(` data-bp-claim-linked="${esc(claim, "claim id")}"`), (node.display?.value !== void 0 || node.display?.state !== void 0 || claim) && attrs.push(' data-bp-mark=""'), attrs.join("");
|
|
1809
|
+
}
|
|
1810
|
+
function resolvedHatchPattern(fill, theme, formatter, idScope, ground, look, pattern = "hatch45") {
|
|
1811
|
+
let stroke = formatter.attr(hatchPaint(fill, theme, ground, look)), background = ground ? formatter.attr(ground) : formatter.background(), { hatchAngle } = theme.pattern, width = hatchStrokeWidthFor(theme, look), gap = theme.pattern.hatchGap * hatchGapFactor(look);
|
|
1812
|
+
return { id: scopedId(hatchPatternId(stroke, background, hatchAngle, gap, width) + (pattern === "hatch45" ? "" : `-${pattern}`), idScope), stroke, background, gap, width };
|
|
1813
|
+
}
|
|
1814
|
+
function renderedPathFill(node, theme, formatter, idScope) {
|
|
1815
|
+
return node.fill ? isHatchPattern(node.pattern) ? `url(#${resolvedHatchPattern(node.fill, theme, formatter, idScope, void 0, node.hatch, node.pattern).id})` : formatter.attr(node.fill) : "none";
|
|
1816
|
+
}
|
|
1817
|
+
function renderNodeInner(node, theme, formatter, tf, interaction, idScope, rootFontFamily = theme.type.family) {
|
|
1818
|
+
let rc = interactiveAttrs(node, interaction) + (node.opacity === void 0 ? "" : ` opacity="${node.opacity}"`) + (POINTER_TRANSPARENT_PARTS.has(node.part) ? ' pointer-events="none"' : "");
|
|
1819
|
+
switch (node.t) {
|
|
1820
|
+
case "image": {
|
|
1821
|
+
let { rect } = node;
|
|
1822
|
+
return `<image${tf} data-id="${esc(node.id)}" data-part="${esc(node.part)}"${rc} x="${n2(rect.x)}" y="${n2(rect.y)}" width="${n2(rect.w)}" height="${n2(rect.h)}" href="${esc(node.src)}" xlink:href="${esc(node.src)}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${esc(node.alt)}"><title>${esc(node.alt)}</title></image>`;
|
|
1823
|
+
}
|
|
1824
|
+
case "rect": {
|
|
1825
|
+
let { rect } = node, fill, extra = "";
|
|
1826
|
+
if (isHatchPattern(node.pattern)) {
|
|
1827
|
+
let stroke = formatter.attr(node.fill);
|
|
1828
|
+
fill = `url(#${resolvedHatchPattern(node.fill, theme, formatter, idScope, node.hatchGround, node.hatch, node.pattern).id})`, extra = node.hatchEdge === !1 ? "" : ` stroke="${stroke}" stroke-width="${strokeToken(theme, "hair")}"`;
|
|
1829
|
+
} else node.pattern === "outline" && solidMutedPlan(theme) ? fill = formatter.attr(PLAN_MUTED_PAINT) : node.pattern === "outline" || node.pattern === "hollow" ? (fill = formatter.background(), extra = ` stroke="${formatter.attr(node.fill)}" stroke-width="${theme.pattern.outlineStrokeWidth}"`) : (fill = formatter.attr(node.fill), node.stroke && (extra = ` stroke="${formatter.attr(node.stroke)}" stroke-width="${node.strokeWidth ?? strokeToken(theme, "mark")}"`));
|
|
1830
|
+
let radius = node.radius ? ` rx="${n2(node.radius)}"` : "", open = `<rect${tf} data-id="${esc(node.id, "node.id")}" data-part="${esc(node.part, "node.part")}"${rc} x="${n2(rect.x)}" y="${n2(rect.y)}" width="${n2(rect.w)}" height="${n2(rect.h)}"${radius} fill="${fill}"${extra}`;
|
|
1831
|
+
return node.title === void 0 ? `${open}/>` : `${open} role="img" aria-label="${esc(node.title, "node.title")}"><title>${esc(node.title, "node.title")}</title></rect>`;
|
|
1832
|
+
}
|
|
1833
|
+
case "line": {
|
|
1834
|
+
let dash = node.dash ? ` stroke-dasharray="${node.dash.join(" ")}"` : "", lineCap = node.lineCap ? ` stroke-linecap="${esc(node.lineCap, "line.lineCap")}"` : "";
|
|
1835
|
+
return `<line${tf} data-id="${esc(node.id, "node.id")}" data-part="${esc(node.part, "node.part")}"${rc} x1="${n2(node.x1)}" y1="${n2(node.y1)}" x2="${n2(node.x2)}" y2="${n2(node.y2)}" stroke="${formatter.attr(node.stroke)}" stroke-width="${node.width}"${dash}${lineCap}/>`;
|
|
1836
|
+
}
|
|
1837
|
+
case "path": {
|
|
1838
|
+
let fill = renderedPathFill(node, theme, formatter, idScope), stroke = node.stroke ? ` stroke="${formatter.attr(node.stroke)}" stroke-width="${node.width ?? strokeToken(theme, "rule")}"` : "", dash = node.dash ? ` stroke-dasharray="${node.dash.join(" ")}"` : "", lineCap = node.lineCap ? ` stroke-linecap="${esc(node.lineCap, "path.lineCap")}"` : "";
|
|
1839
|
+
return `<path${tf} data-id="${esc(node.id)}" data-part="${esc(node.part)}"${rc} d="${esc(node.d)}" fill="${fill}"${stroke}${dash}${lineCap} stroke-linejoin="round"/>`;
|
|
1840
|
+
}
|
|
1841
|
+
case "circle": {
|
|
1842
|
+
let stroke = node.stroke ? ` stroke="${formatter.attr(node.stroke)}" stroke-width="${node.strokeWidth ?? strokeToken(theme, "mark")}"` : "";
|
|
1843
|
+
return `<circle${tf} data-id="${esc(node.id, "node.id")}" data-part="${esc(node.part, "node.part")}"${rc} cx="${n2(node.cx)}" cy="${n2(node.cy)}" r="${n2(node.r)}" fill="${formatter.attr(node.fill)}"${stroke}${node.title === void 0 ? "/>" : `><title>${esc(node.title, "node.title")}</title></circle>`}`;
|
|
1844
|
+
}
|
|
1845
|
+
case "text": {
|
|
1846
|
+
let anchor = node.align === "start" ? "start" : node.align === "end" ? "end" : "middle", font = node.font, lineH = font.size * (font.lineHeight ?? 1.2), ink = formatter.attr(node.ink), backing = node.backing ? `<rect x="${n2(node.backing.x)}" y="${n2(node.backing.y)}" width="${n2(node.backing.w)}" height="${n2(node.backing.h)}" fill="${formatter.background()}" opacity="0.92"/>` : "", ls = font.letterSpacing ?? 0, lsAttr = ls ? ` letter-spacing="${n2(ls)}"` : "", lsShift = ls ? node.align === "end" ? ls : node.align === "middle" ? ls / 2 : 0 : 0, tx0 = node.x + lsShift, spans = node.runs ? node.runs.map(
|
|
1847
|
+
(run, i) => `<tspan${run.weight !== void 0 && run.weight !== font.weight ? ` font-weight="${n2(run.weight)}"` : ""}>${esc(run.text, `text run ${i}`)}</tspan>`
|
|
1848
|
+
).join("") : node.lines.map(
|
|
1849
|
+
(line, i) => `<tspan x="${n2(tx0)}" dy="${i === 0 ? "0" : n2(lineH)}">${esc(line, `text line ${i}`)}</tspan>`
|
|
1850
|
+
).join(""), family = font.family && font.family !== rootFontFamily ? ` font-family="${esc(font.family, "font.family")}"` : "", baselineY = node.y + font.size * TEXT_ASCENT2, rotateAttr = node.rotate ? ` transform="rotate(${n2(node.rotate)} ${n2(tx0)} ${n2(baselineY)})"` : "", fullText = node.title ? `<title>${esc(node.title, "node.title")}</title>` : "", role = textRole(node), figures = numericVariant(role, theme), numeric = figures ? ` style="font-variant-numeric: ${figures}"` : "", placed = ` x="${n2(tx0)}" y="${n2(baselineY)}" text-anchor="${anchor}"${rotateAttr}${family} font-size="${font.size}" font-weight="${font.weight}"${font.style === void 0 ? "" : ` font-style="${font.style}"`}${lsAttr}`, halo = node.halo ? formatter.halo(node.ink) : "", haloText = halo ? `<text aria-hidden="true"${node.opacity === void 0 ? "" : ` opacity="${node.opacity}"`}${placed} fill="${halo}" stroke="${halo}" stroke-width="2.5" stroke-linejoin="round"${numeric}>${spans}</text>` : "", text = `<text data-id="${esc(node.id, "node.id")}" data-part="${esc(node.part, "node.part")}" data-bp-role="${role}"${rc}${placed} fill="${ink}"${numeric}>${fullText}${spans}</text>`;
|
|
1851
|
+
return tf ? `<g${tf}>${backing}${haloText}${text}</g>` : backing + haloText + text;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// src/core/aspect.ts
|
|
1857
|
+
var furnitureBudget = (width) => width < 720 ? 0.5 : 0.4, ASPECT_LADDER = [
|
|
1858
|
+
{ name: "strip", ratio: 4.5 },
|
|
1859
|
+
{ name: "band", ratio: 3.6 },
|
|
1860
|
+
{ name: "wide", ratio: 2.84 },
|
|
1861
|
+
{ name: "broad", ratio: 2.25 },
|
|
1862
|
+
{ name: "std", ratio: 1.78 },
|
|
1863
|
+
{ name: "a4", ratio: 1.41 },
|
|
1864
|
+
{ name: "tall", ratio: 1.33 }
|
|
1865
|
+
], LADDER_TOLERANCE = 0.02, ASPECT_CAPS = { flatAbsolute: 4.5, flatNonStrip: 3.6, tall: 1.33 };
|
|
1866
|
+
function ladderHeights(width) {
|
|
1867
|
+
return ASPECT_LADDER.map((s) => ({ name: s.name, height: Math.round(width / s.ratio) }));
|
|
1868
|
+
}
|
|
1869
|
+
function onLadderStep(size) {
|
|
1870
|
+
let best = null;
|
|
1871
|
+
for (let { name, height } of ladderHeights(size.width)) {
|
|
1872
|
+
let distance = Math.abs(size.height - height);
|
|
1873
|
+
distance <= LADDER_TOLERANCE * height && (!best || distance < best.distance) && (best = { name, distance });
|
|
1874
|
+
}
|
|
1875
|
+
return best?.name ?? null;
|
|
1876
|
+
}
|
|
1877
|
+
function nearestLadderStep(size) {
|
|
1878
|
+
return ladderHeights(size.width).reduce(
|
|
1879
|
+
(a, b) => Math.abs(size.height - b.height) < Math.abs(size.height - a.height) ? b : a
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
var HEIGHT_FLOOR_CLASSES = /* @__PURE__ */ new Set([
|
|
1883
|
+
"standard-cartesian",
|
|
1884
|
+
"wide-time",
|
|
1885
|
+
"tall",
|
|
1886
|
+
"matrix",
|
|
1887
|
+
"geo-free"
|
|
1888
|
+
]);
|
|
1889
|
+
function furnitureScoped(cls, size) {
|
|
1890
|
+
return HEIGHT_FLOOR_CLASSES.has(cls) && !(cls === "matrix" && onLadderStep(size) === null) || cls === "card" || cls === "strip";
|
|
1891
|
+
}
|
|
1892
|
+
var TYPE_ASPECT_PROFILE = {
|
|
1893
|
+
// card — kpi min 240×135; both specimens sit on the 1.78 ratio.
|
|
1894
|
+
kpi: { cls: "card", defaultStep: "std" },
|
|
1895
|
+
bullet: { cls: "card", defaultStep: "std" },
|
|
1896
|
+
// wide-time
|
|
1897
|
+
line: { cls: "wide-time", defaultStep: "wide" },
|
|
1898
|
+
combo: { cls: "wide-time", defaultStep: "wide" },
|
|
1899
|
+
// standard-cartesian — h.std, or h.broad in some embeds.
|
|
1900
|
+
column: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1901
|
+
waterfall: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1902
|
+
pvm: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1903
|
+
variance: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1904
|
+
pareto: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1905
|
+
mekko: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1906
|
+
histogram: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1907
|
+
scatter: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1908
|
+
slope: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1909
|
+
pie: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1910
|
+
box: { cls: "standard-cartesian", defaultStep: "std" },
|
|
1911
|
+
// row-driven — H = furniture + n_rows × rowPitch.
|
|
1912
|
+
bar: { cls: "row-driven", defaultStep: "std" },
|
|
1913
|
+
bartable: { cls: "row-driven", defaultStep: "std" },
|
|
1914
|
+
dot: { cls: "row-driven", defaultStep: "std" },
|
|
1915
|
+
likert: { cls: "row-driven", defaultStep: "std" },
|
|
1916
|
+
butterfly: { cls: "row-driven", defaultStep: "std" },
|
|
1917
|
+
pyramid: { cls: "row-driven", defaultStep: "std" },
|
|
1918
|
+
gantt: { cls: "row-driven", defaultStep: "std" },
|
|
1919
|
+
// matrix
|
|
1920
|
+
heatmap: { cls: "matrix", defaultStep: "tall" },
|
|
1921
|
+
status: { cls: "matrix", defaultStep: "tall" },
|
|
1922
|
+
cohort: { cls: "matrix", defaultStep: "tall" },
|
|
1923
|
+
table: { cls: "matrix", defaultStep: "tall" },
|
|
1924
|
+
grid: { cls: "matrix", defaultStep: "tall" },
|
|
1925
|
+
// tall — the centered funnel silhouette (the
|
|
1926
|
+
// engine-default stacked-row variant resolves to row-driven below).
|
|
1927
|
+
funnel: { cls: "tall", defaultStep: "tall" },
|
|
1928
|
+
// geo-free — both 1.78 and 1.33 permitted without counting as deviation;
|
|
1929
|
+
// the deterministic default is h.std.
|
|
1930
|
+
choropleth: { cls: "geo-free", defaultStep: "std" },
|
|
1931
|
+
tilemap: { cls: "geo-free", defaultStep: "std" },
|
|
1932
|
+
diagram: { cls: "geo-free", defaultStep: "std" }
|
|
1933
|
+
};
|
|
1934
|
+
function aspectClassFor(type, options, marks) {
|
|
1935
|
+
let profile = TYPE_ASPECT_PROFILE[type];
|
|
1936
|
+
if (!profile) return null;
|
|
1937
|
+
if (type === "funnel") return options?.variant === "centered" ? "tall" : "row-driven";
|
|
1938
|
+
if (type === "bullet" && options?.density === "compact") return null;
|
|
1939
|
+
if (type === "grid") {
|
|
1940
|
+
let panels = marks?.panels;
|
|
1941
|
+
if (Array.isArray(panels) && panels.length > 0 && panels.every((p) => TYPE_ASPECT_PROFILE[p.type ?? ""]?.cls === "card") && panels.every((p) => p.content?.y !== void 0 && p.content.y === panels[0].content?.y))
|
|
1942
|
+
return "strip";
|
|
1943
|
+
}
|
|
1944
|
+
return profile.cls;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// src/core/seriesIdentity.ts
|
|
1948
|
+
function omittedKey(id, label) {
|
|
1949
|
+
return { id, label: label.replace(/\.$/, ""), paint: { token: "inkMuted" }, pattern: "outline", hollow: !0 };
|
|
1950
|
+
}
|
|
1951
|
+
function identityAppearance(item, theme) {
|
|
1952
|
+
let color = (paint) => paint ? paintColor(theme, paint) : null;
|
|
1953
|
+
return JSON.stringify([
|
|
1954
|
+
item.key ?? "box",
|
|
1955
|
+
color(item.paint),
|
|
1956
|
+
color(item.stroke),
|
|
1957
|
+
item.pattern ?? null,
|
|
1958
|
+
item.hollow ?? !1,
|
|
1959
|
+
color(item.hatchGround),
|
|
1960
|
+
item.hatchEdge ?? !0,
|
|
1961
|
+
item.dash ?? [],
|
|
1962
|
+
item.lineCap ?? "butt",
|
|
1963
|
+
item.glyph ?? null,
|
|
1964
|
+
item.level ?? null,
|
|
1965
|
+
item.width ?? null,
|
|
1966
|
+
item.radius ?? null,
|
|
1967
|
+
item.radii ?? null,
|
|
1968
|
+
item.withLine ? [color(item.withLine.paint), item.withLine.dash ?? []] : null,
|
|
1969
|
+
item.marker ? [item.marker.shape, item.marker.hollow ?? !1] : null
|
|
1970
|
+
]);
|
|
1971
|
+
}
|
|
1972
|
+
function identityCollisionWarnings(items, theme) {
|
|
1973
|
+
let groups = /* @__PURE__ */ new Map();
|
|
1974
|
+
for (let item of items) {
|
|
1975
|
+
if (item.key === "heading") continue;
|
|
1976
|
+
let appearance = identityAppearance(item, theme), group = groups.get(appearance) ?? [];
|
|
1977
|
+
group.some((previous) => previous.label === item.label) || group.push(item), groups.set(appearance, group);
|
|
1978
|
+
}
|
|
1979
|
+
return [...groups.values()].filter((group) => group.length > 1).map((group) => ({
|
|
1980
|
+
code: "series-indistinguishable",
|
|
1981
|
+
severity: "warn",
|
|
1982
|
+
message: `Keys ${group.map((item) => `'${item.label}'`).join(", ")} have the same colour and shape`,
|
|
1983
|
+
suggest: "use distinct colours, shapes or patterns for distinct meanings; for series, group additive values into 'Other', use small multiples, or set distinct colorRole values or fills",
|
|
1984
|
+
owner: { seriesId: group.at(-1).id }
|
|
1985
|
+
}));
|
|
1986
|
+
}
|
|
1987
|
+
function distinguishSeries(items, explicit, alternatives, theme) {
|
|
1988
|
+
let resolved = /* @__PURE__ */ new Map(), seen = /* @__PURE__ */ new Map();
|
|
1989
|
+
for (let item of [...items.filter((i) => explicit.has(i.id)), ...items.filter((i) => !explicit.has(i.id))]) {
|
|
1990
|
+
let next = item;
|
|
1991
|
+
if (!explicit.has(item.id) && seen.has(identityAppearance(item, theme))) {
|
|
1992
|
+
let paint = alternatives.find((p) => !seen.has(identityAppearance({ ...item, paint: p }, theme)));
|
|
1993
|
+
paint && (next = { ...item, paint });
|
|
1994
|
+
}
|
|
1995
|
+
let appearance = identityAppearance(next, theme);
|
|
1996
|
+
seen.set(appearance, next), resolved.set(item.id, next);
|
|
1997
|
+
}
|
|
1998
|
+
return items.map((item) => resolved.get(item.id));
|
|
1999
|
+
}
|
|
2000
|
+
function keepsUnnamedSeriesKey(type) {
|
|
2001
|
+
return type === "grid";
|
|
2002
|
+
}
|
|
2003
|
+
function needsSeriesKey(type, data, options, geometry) {
|
|
2004
|
+
if (type === "bar" && options?.variant === "tornado") return !1;
|
|
2005
|
+
if (type === "scatter" || type === "bubble") return scatterGroupIdentities(data, geometry).length > 1;
|
|
2006
|
+
if (["butterfly", "pyramid", "heatmap", "status"].includes(type) || !["column", "bar", "combo", "dot", "cleveland", "dumbbell"].includes(type) && options?.labels !== !1) return !1;
|
|
2007
|
+
let series = data?.series;
|
|
2008
|
+
return Array.isArray(series) && series.filter((s) => s.role !== "reference" && s.values?.some((entry) => {
|
|
2009
|
+
let cell = entry !== null && typeof entry == "object" && "categoryId" in entry && "value" in entry ? entry.value : entry;
|
|
2010
|
+
return cellValue(cell) !== null;
|
|
2011
|
+
})).length > 1;
|
|
2012
|
+
}
|
|
2013
|
+
function scatterGroupIdentities(data, geometry, prefix = "") {
|
|
2014
|
+
let source = data;
|
|
2015
|
+
if (!Array.isArray(source?.points)) return [];
|
|
2016
|
+
let declared = new Map((Array.isArray(source.groups) ? source.groups : []).map((group) => [group.id, group])), groups = /* @__PURE__ */ new Map(), drawn = geometry && new Set(geometry.scene.flatMap((node) => node.t !== "text" && node.part === "point" && node.owner.pointId && node.id.startsWith(prefix) ? [node.owner.pointId] : []));
|
|
2017
|
+
for (let point of source.points) {
|
|
2018
|
+
if (!point?.group) continue;
|
|
2019
|
+
let group = declared.get(point.group);
|
|
2020
|
+
if (drawn ? !drawn.has(prefix + point.id) && !drawn.has(point.id) : cellValue(point.x) === null || cellValue(point.y) === null || (point.marker ?? group?.marker) === "none") continue;
|
|
2021
|
+
let identity = groups.get(point.group) ?? { id: point.group, label: group?.label ?? point.group, pointIds: [] };
|
|
2022
|
+
identity.pointIds.push(point.id), groups.set(point.group, identity);
|
|
2023
|
+
}
|
|
2024
|
+
return [...groups.values()];
|
|
2025
|
+
}
|
|
2026
|
+
function scatterGroupNameIsDrawn(geometry, group, prefix = "") {
|
|
2027
|
+
return nameIsDrawn(geometry, group.label, prefix + group.id) || geometry.scene.some((node) => node.part === "point" && node.id.startsWith(prefix) && group.pointIds.some((id) => node.owner.pointId === prefix + id || node.owner.pointId === id) && textNames(node, group.label));
|
|
2028
|
+
}
|
|
2029
|
+
var COLLECT_IDENTITIES = /* @__PURE__ */ Symbol("collectSeriesIdentities");
|
|
2030
|
+
function identityCollector(options) {
|
|
2031
|
+
let collect = options[COLLECT_IDENTITIES];
|
|
2032
|
+
return collect ? { [COLLECT_IDENTITIES]: collect } : {};
|
|
2033
|
+
}
|
|
2034
|
+
function collectSeriesIdentities(layout, data, options) {
|
|
2035
|
+
let stop = {}, identities = [];
|
|
2036
|
+
try {
|
|
2037
|
+
layout(data, { ...options, legend: "top", [COLLECT_IDENTITIES]: (items) => {
|
|
2038
|
+
throw identities = items, stop;
|
|
2039
|
+
} });
|
|
2040
|
+
} catch (error) {
|
|
2041
|
+
if (error !== stop) throw error;
|
|
2042
|
+
}
|
|
2043
|
+
return identities;
|
|
2044
|
+
}
|
|
2045
|
+
function textNames(node, name) {
|
|
2046
|
+
if (node.t !== "text" || !name.trim()) return !1;
|
|
2047
|
+
let escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2048
|
+
return new RegExp(`(?<![\\p{L}\\p{N}_])${escaped}(?![\\p{L}\\p{N}_])`, "iu").test(node.lines.join(" "));
|
|
2049
|
+
}
|
|
2050
|
+
function nameIsDrawn(geometry, name, id) {
|
|
2051
|
+
return geometry.scene.some((node) => {
|
|
2052
|
+
if (node.part === "subtitle" || node.part === "footnote" || !(["legendLabel", "series", "legendHeading", "eventKey"].includes(node.part) || id && node.owner.seriesId === id)) return !1;
|
|
2053
|
+
if (textNames(node, name)) return !0;
|
|
2054
|
+
if (node.t !== "text" || node.part !== "legendLabel" || node.opacity === 0 || node.title !== name || !id || !geometry.legend?.items.some((item) => item.id === id && item.labelId === node.id)) return !1;
|
|
2055
|
+
let text = node.lines.join(" ").trim();
|
|
2056
|
+
return text.length > 0 && text !== "\u2026" && !geometry.scene.some((other) => other.t === "text" && other.part === "legendLabel" && other.id !== node.id && other.title !== node.title && other.lines.join(" ").trim() === text);
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
// src/core/label/legendFidelity.ts
|
|
2061
|
+
var SCENARIO_KEY = {
|
|
2062
|
+
hatch45: { id: "__scenarioFC" },
|
|
2063
|
+
outline: { id: "__scenarioPL" }
|
|
2064
|
+
}, SCENARIO_ORDER = ["outline", "hatch45"];
|
|
2065
|
+
function scenarioLegendKeys(input) {
|
|
2066
|
+
let painted = /* @__PURE__ */ new Set();
|
|
2067
|
+
for (let pattern of input.markPatterns) (pattern === "hatch45" || pattern === "outline") && painted.add(pattern);
|
|
2068
|
+
for (let pattern of input.keyPatterns) (pattern === "hatch45" || pattern === "outline") && painted.delete(pattern);
|
|
2069
|
+
return SCENARIO_ORDER.filter((pattern) => painted.has(pattern)).map((pattern) => ({
|
|
2070
|
+
id: SCENARIO_KEY[pattern].id,
|
|
2071
|
+
label: (pattern === "hatch45" ? input.strings?.forecast : input.strings?.plan) ?? (pattern === "hatch45" ? localeStrings().forecast : localeStrings().plan),
|
|
2072
|
+
paint: input.paint,
|
|
2073
|
+
pattern
|
|
2074
|
+
}));
|
|
2075
|
+
}
|
|
2076
|
+
var UNIT_SEPARATOR = "";
|
|
2077
|
+
function dedupeLegendKeys(items, appearance) {
|
|
2078
|
+
let seen = /* @__PURE__ */ new Set(), kept = [], dropped = [];
|
|
2079
|
+
for (let item of items) {
|
|
2080
|
+
let signature = [
|
|
2081
|
+
appearance(item),
|
|
2082
|
+
item.pattern ?? "",
|
|
2083
|
+
item.key ?? "box",
|
|
2084
|
+
(item.dash ?? []).join(","),
|
|
2085
|
+
item.label
|
|
2086
|
+
].join(UNIT_SEPARATOR);
|
|
2087
|
+
seen.has(signature) ? dropped.push(item) : (seen.add(signature), kept.push(item));
|
|
2088
|
+
}
|
|
2089
|
+
return { items: kept, dropped };
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
// src/core/label/fitText.ts
|
|
2093
|
+
function lineBox(font) {
|
|
2094
|
+
return font.size * (font.lineHeight ?? 1.2);
|
|
2095
|
+
}
|
|
2096
|
+
function attempt(text, font, width, maxLines, measure, typeRole, breakAfter = !1) {
|
|
2097
|
+
let wrapped = wrapText(text, font, Math.max(1, width), maxLines, measure, breakAfter), lines = wrapped.lines;
|
|
2098
|
+
return {
|
|
2099
|
+
fitted: {
|
|
2100
|
+
...typeRole !== void 0 ? { typeRole } : {},
|
|
2101
|
+
lines,
|
|
2102
|
+
w: Math.max(1, ...lines.map((line) => measure(line, font).width)),
|
|
2103
|
+
h: lines.length * lineBox(font),
|
|
2104
|
+
font
|
|
2105
|
+
},
|
|
2106
|
+
cut: wrapped.truncated
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
function shrinkFont(font, options) {
|
|
2110
|
+
let step = options.shrink;
|
|
2111
|
+
if (!(!step || step.size >= font.size))
|
|
2112
|
+
return step.size >= targetFloorsPx(options.target ?? DEFAULT_TARGET, options.textScale)[options.typeRole ?? "label"] ? step : void 0;
|
|
2113
|
+
}
|
|
2114
|
+
function fitText(text, font, maxWidth, maxLines, measure, options = {}) {
|
|
2115
|
+
let widths = options.wider !== void 0 && options.wider > maxWidth ? [maxWidth, options.wider] : [maxWidth], joined = text.includes(`
|
|
2116
|
+
`) ? text.replace(/\s*\n\s*/g, " ") : text, texts = joined === text ? [text] : [text, joined];
|
|
2117
|
+
for (let width2 of widths)
|
|
2118
|
+
for (let candidate of texts) {
|
|
2119
|
+
let tried = attempt(candidate, font, width2, maxLines, measure, options.typeRole, options.breakAfter);
|
|
2120
|
+
if (!tried.cut) return tried.fitted;
|
|
2121
|
+
}
|
|
2122
|
+
let step = shrinkFont(font, options);
|
|
2123
|
+
if (step)
|
|
2124
|
+
for (let width2 of widths)
|
|
2125
|
+
for (let candidate of texts) {
|
|
2126
|
+
let tried = attempt(candidate, step, width2, maxLines, measure, options.typeRole, options.breakAfter);
|
|
2127
|
+
if (!tried.cut) return tried.fitted;
|
|
2128
|
+
}
|
|
2129
|
+
let width = widths[widths.length - 1], last = attempt(joined, step ?? font, width, maxLines, measure, options.typeRole, options.breakAfter).fitted, end = last.lines.length - 1;
|
|
2130
|
+
if (end >= 0 && !last.lines.some((line) => line.endsWith("\u2026"))) {
|
|
2131
|
+
let lines = [...last.lines];
|
|
2132
|
+
return lines[end] = ellipsize(`${lines[end].trimEnd()}\u2026`, last.font, width, measure).text, { ...last, lines, w: Math.max(1, ...lines.map((line) => measure(line, last.font).width)), title: text };
|
|
2133
|
+
}
|
|
2134
|
+
return { ...last, title: text };
|
|
2135
|
+
}
|
|
2136
|
+
function distinctCut(text, lines, others, font, width, measure, breakAfter = !1) {
|
|
2137
|
+
let glue = breakAfter && !text.startsWith(lines.join(" ").replace(/…$/, "").trimEnd()) ? "" : " ", visible = lines.join(glue).replace(/…$/, "").trimEnd();
|
|
2138
|
+
if (!text.startsWith(visible)) return;
|
|
2139
|
+
let alike = others.filter((other) => other !== text && other.startsWith(visible));
|
|
2140
|
+
if (alike.length === 0) return;
|
|
2141
|
+
let parts = text.length;
|
|
2142
|
+
for (let other of alike) {
|
|
2143
|
+
let common = 0;
|
|
2144
|
+
for (; common < text.length && text[common] === other[common]; ) common++;
|
|
2145
|
+
parts = Math.min(parts, common);
|
|
2146
|
+
}
|
|
2147
|
+
let lastStart = lines.slice(0, -1).join(glue).length + (lines.length > 1 ? glue.length : 0), from = Math.min(parts, text.length - 1), tailStart = Math.max(text.lastIndexOf(" ", from), ...breakAfter ? ["_", "-", "/", "."].map((mark) => text.lastIndexOf(mark, from - 1)) : []) + 1;
|
|
2148
|
+
if (tailStart <= lastStart) return;
|
|
2149
|
+
let tail2 = text.slice(tailStart), budget = width - measure(tail2, font).width;
|
|
2150
|
+
if (budget < measure("\u2026", font).width) return;
|
|
2151
|
+
let head = ellipsize(text.slice(lastStart, tailStart).trimEnd(), font, budget, measure).text;
|
|
2152
|
+
return head.endsWith("\u2026") ? `${head}${tail2}` : void 0;
|
|
2153
|
+
}
|
|
2154
|
+
function cutWithTitle(text, font, maxWidth, measure) {
|
|
2155
|
+
let cut = ellipsize(text, font, maxWidth, measure);
|
|
2156
|
+
return cut.truncated ? { text: cut.text, title: text } : { text: cut.text };
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
// src/core/label/omissions.ts
|
|
2160
|
+
var words = (text) => text.replace(/\s+/g, " ").trim(), ownerKey = (owner) => JSON.stringify([owner.seriesId, owner.categoryId, owner.segmentId, owner.pointId, owner.valueLineId, owner.annotationId, owner.rowId, owner.colId]);
|
|
2161
|
+
function containsText(hay, needle) {
|
|
2162
|
+
for (let at = needle ? hay.indexOf(needle) : -1; at >= 0; at = hay.indexOf(needle, at + 1))
|
|
2163
|
+
if (!/[\p{L}\p{N}.,+\-−]$/u.test(hay.slice(0, at)) && !/^([\p{L}\p{N}]|[.,]\p{N})/u.test(hay.slice(at + needle.length))) return !0;
|
|
2164
|
+
return !1;
|
|
2165
|
+
}
|
|
2166
|
+
function readableLabelDestination(geo) {
|
|
2167
|
+
let index, prepare = () => {
|
|
2168
|
+
if (index) return index;
|
|
2169
|
+
index = { nodes: /* @__PURE__ */ new Map(), text: /* @__PURE__ */ new Map(), owner: /* @__PURE__ */ new Map(), labels: new Map(geo.labels.map((label) => [label.id, label])), painted: /* @__PURE__ */ new Map(), exact: /* @__PURE__ */ new Map(), owners: /* @__PURE__ */ new Map(), notes: [] };
|
|
2170
|
+
let append = (map, key, node) => {
|
|
2171
|
+
let list = map.get(key);
|
|
2172
|
+
list ? list.push(node) : map.set(key, [node]);
|
|
2173
|
+
};
|
|
2174
|
+
for (let node of geo.scene) node.t === "text" && node.opacity !== 0 && words(node.lines.join(" ")) && index.nodes.set(node.id, node);
|
|
2175
|
+
for (let node of index.nodes.values()) {
|
|
2176
|
+
let body = index.nodes.get(`${node.id}:body`), printed = body ? { ...node, lines: [...node.lines, ...body.lines] } : node, text = words(printed.lines.join(" ")), owner = ownerKey(node.origin?.owner ?? node.owner);
|
|
2177
|
+
index.text.set(node.id, text), index.owner.set(node.id, owner), append(index.exact, text, printed), append(index.owners, owner, printed), (textRole(node) === "note" || textRole(node) === "source") && index.notes.push(printed);
|
|
2178
|
+
}
|
|
2179
|
+
for (let label of geo.labels) if (!label.hidden) {
|
|
2180
|
+
let node = index.nodes.get(label.nodeId ?? `label:${label.id}`);
|
|
2181
|
+
if (node) {
|
|
2182
|
+
index.painted.set(node.id, label), index.nodes.has(`${node.id}:body`) && index.painted.set(`${node.id}:body`, label);
|
|
2183
|
+
for (let owner of label.printsFor ?? []) append(index.owners, ownerKey(owner), node);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
return index;
|
|
2187
|
+
};
|
|
2188
|
+
return (id, text, owner = {}, kind, qualifiedText = text) => {
|
|
2189
|
+
let { nodes, text: printedText, owner: nodeOwners, labels, painted, exact, owners, notes } = prepare(), normalized = words(text), label = labels.get(id), scope = geo.marks.panels ? omissionScope(geo, void 0, id) : void 0, local = scope?.id ?? id, prefix = id.slice(0, id.length - local.length);
|
|
2190
|
+
if (label?.printedIn) {
|
|
2191
|
+
let hostId = prefix + label.printedIn, host = labels.get(hostId), node = nodes.get(host?.nodeId ?? `label:${hostId}`) ?? nodes.get(hostId), printed = node ? printedText.get(node.id) : "";
|
|
2192
|
+
if (node && (containsText(printed, words(host?.text ?? text)) || containsText(printed, normalized))) return `label:${hostId}`;
|
|
2193
|
+
}
|
|
2194
|
+
let named = kind === "series" || kind === "category" || kind === "restSeries" || kind === "source", numeric = ["point", "segment", "total", "grandTotal", "insidePie", "outsidePie", "growth"].includes(kind ?? "") && label?.role !== "category" && label?.printsFor?.length !== 0, own = ownerKey(owner), scoped = (node) => !prefix || node.id.startsWith(prefix) || node.origin?.panels.some((panel) => prefix.startsWith(`${panel}/`)), sameOwner2 = (node) => Object.keys(owner).length > 0 && nodeOwners.get(node.id) === own, sameQuantity = (node) => !numeric || textRole(node) === "value" && (painted.get(node.id)?.kind === kind || label?.claimId !== void 0 && painted.get(node.id)?.claimId === label.claimId || owner.rowId !== void 0 && owner.colId !== void 0), match = (exact.get(normalized) ?? []).find((node) => scoped(node) && (sameOwner2(node) && sameQuantity(node) || named && !["value", "axis"].includes(textRole(node))));
|
|
2195
|
+
if (match) return `scene:${match.id}`;
|
|
2196
|
+
let shared = Object.keys(owner).length ? owners.get(own)?.find((node) => scoped(node) && containsText(printedText.get(node.id), normalized) && (sameOwner2(node) ? named : !0)) : void 0;
|
|
2197
|
+
if (shared) return `scene:${shared.id}`;
|
|
2198
|
+
let geometry = scope?.geometry ?? geo;
|
|
2199
|
+
if (geometry.type === "line" && owner.seriesId && owner.categoryId) {
|
|
2200
|
+
let value = geometry.derived.endpoints?.[owner.seriesId]?.categoryId === owner.categoryId ? (owners.get(ownerKey({ seriesId: owner.seriesId })) ?? []).find((node) => scoped(node) && node.part === "legendValue" && printedText.get(node.id) === normalized) : void 0;
|
|
2201
|
+
if (value) return `scene:${value.id}`;
|
|
2202
|
+
}
|
|
2203
|
+
let noteText = words(qualifiedText), note = /\p{L}/u.test(noteText) || kind === "source" ? notes.find((node) => scoped(node) && containsText(printedText.get(node.id), noteText)) : void 0;
|
|
2204
|
+
return note ? `scene:${note.id}` : void 0;
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
function omissionScope(geo, options, id, data) {
|
|
2208
|
+
let panel = geo.marks.panels?.find((panel2) => id.startsWith(`${panel2.id}/`) && panel2.chart), sourcePanel = data?.panels?.find((source) => source.id === panel?.id);
|
|
2209
|
+
return panel?.chart ? omissionScope(panel.chart.geometry, panel.chart.options, id.slice(panel.id.length + 1), sourcePanel?.data) : { geometry: geo, options, id, data };
|
|
2210
|
+
}
|
|
2211
|
+
function intentionalOmission(geo, options, data, omission, labelFor) {
|
|
2212
|
+
let scope = omissionScope(geo, options, omission.labelId, data), settings = typeof scope.options?.labels == "object" && scope.options.labels !== null ? scope.options.labels : void 0;
|
|
2213
|
+
if (scope.options?.labelDensity !== "minimal" && scope.options?.labels !== !1 && !Object.values(settings ?? {}).includes(!1)) return !1;
|
|
2214
|
+
let label = labelFor(omission.labelId), kind = label?.kind ?? scope.id.split(":")[0], setting = settings?.[kind];
|
|
2215
|
+
if (scope.options?.labelDensity !== "minimal" && scope.options?.labels !== !1 && setting !== !1 && settings?.restSeries !== !1 || setting === !0 || Array.isArray(setting) && setting.length > 0 || scope.options?.labelPlacements?.[scope.id] !== void 0 || (kind === "point" || kind === "segment") && scope.options?.valueLabels !== void 0 && scope.options.valueLabels !== "none" || (kind === "series" || kind === "restSeries") && scope.options?.seriesLabels !== void 0 && scope.options.seriesLabels !== "none" || kind === "annotation" || kind === "axisTitle" || kind === "valueLine") return !1;
|
|
2216
|
+
if (scope.options?.labels === !1 || setting === !1) return !0;
|
|
2217
|
+
let series = scope.data?.series;
|
|
2218
|
+
return settings?.restSeries === !1 && series?.some((series2) => series2.id === label?.owner.seriesId && series2.colorRole === "others") ? !0 : scope.options?.labelDensity === "minimal" && (label?.hidden === "density" || omission.reason === "density");
|
|
2219
|
+
}
|
|
2220
|
+
function cutLabels(geo) {
|
|
2221
|
+
let labels, cuts = /* @__PURE__ */ new Map();
|
|
2222
|
+
for (let node of geo.scene) {
|
|
2223
|
+
if (node.t !== "text" || node.opacity === 0 || !node.title || node.part === "storyTitle" || node.part === "storyBody" || node.focusStop || node.part === "eventKey") continue;
|
|
2224
|
+
let displayed = node.lines.join(" ");
|
|
2225
|
+
if (words(displayed) === words(node.title)) continue;
|
|
2226
|
+
labels ??= new Map(geo.labels.map((label2) => [label2.nodeId ?? `label:${label2.id}`, label2]));
|
|
2227
|
+
let labelId = labels.get(node.id)?.id ?? node.id;
|
|
2228
|
+
cuts.set(labelId, { labelId, text: node.title, displayed });
|
|
2229
|
+
}
|
|
2230
|
+
for (let step of geo.story?.steps ?? []) for (let field of ["title", "body"]) {
|
|
2231
|
+
let text = step[field];
|
|
2232
|
+
if (!text) continue;
|
|
2233
|
+
let displayed = step.nodes.filter((node) => node.t === "text" && node.part === (field === "title" ? "storyTitle" : "storyBody")).flatMap((node) => node.t === "text" ? node.lines : []).join(" ");
|
|
2234
|
+
if (words(displayed) !== words(text)) {
|
|
2235
|
+
let labelId = `story:${step.id}:${field}`;
|
|
2236
|
+
cuts.set(labelId, { labelId, text, displayed });
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
return [...cuts.values()];
|
|
2240
|
+
}
|
|
2241
|
+
function axisLabelText(data, at, labelId) {
|
|
2242
|
+
if (typeof data != "object" || data === null) return String(at);
|
|
2243
|
+
let source = data;
|
|
2244
|
+
if (Array.isArray(source.panels)) {
|
|
2245
|
+
let panel = source.panels.find((panel2) => typeof panel2?.id == "string" && labelId.startsWith(`${panel2.id}/`));
|
|
2246
|
+
if (panel) return axisLabelText(panel.data, at, labelId.slice(panel.id.length + 1));
|
|
2247
|
+
}
|
|
2248
|
+
let keys = /(?:^|[:/])category:/.test(labelId) ? ["categories", "columns"] : ["series", "rows"];
|
|
2249
|
+
for (let key of keys) {
|
|
2250
|
+
let list = source[key];
|
|
2251
|
+
if (!Array.isArray(list)) continue;
|
|
2252
|
+
let item = list.find((item2) => (typeof item2 == "object" && item2 !== null ? item2.id : item2) === at);
|
|
2253
|
+
if (item !== void 0) return String(typeof item == "object" && item !== null ? item.label ?? at : item);
|
|
2254
|
+
}
|
|
2255
|
+
return String(at);
|
|
2256
|
+
}
|
|
2257
|
+
function labelOmissions(geo, options, data) {
|
|
2258
|
+
let omissions = [], destinationOf = readableLabelDestination(geo);
|
|
2259
|
+
for (let cut of cutLabels(geo)) omissions.push({
|
|
2260
|
+
labelId: cut.labelId,
|
|
2261
|
+
text: cut.text,
|
|
2262
|
+
reason: "truncated",
|
|
2263
|
+
destination: destinationOf(cut.labelId, cut.text) ?? "reading.omissions"
|
|
2264
|
+
});
|
|
2265
|
+
let labels = /* @__PURE__ */ new Set();
|
|
2266
|
+
for (let label of geo.labels)
|
|
2267
|
+
labels.add(label.id), label.hidden !== void 0 && omissions.push({
|
|
2268
|
+
labelId: label.id,
|
|
2269
|
+
text: label.noteText ?? label.text,
|
|
2270
|
+
reason: label.noted ? "note" : label.hidden,
|
|
2271
|
+
destination: destinationOf(label.id, label.text, label.owner, label.kind, label.noteText) ?? label.noteLocation ?? (label.printedIn ? `label:${label.printedIn}` : "reading.omissions")
|
|
2272
|
+
});
|
|
2273
|
+
let drawn;
|
|
2274
|
+
for (let axis of geo.axes) for (let tick of axis.ticks) {
|
|
2275
|
+
if (!tick.labelId || labels.has(tick.labelId) || (drawn ??= new Set(geo.scene.flatMap((node) => node.t === "text" && node.opacity !== 0 && node.lines.some((line) => line.trim() !== "") ? [node.id] : [])), drawn.has(tick.labelId) || drawn.has(`label:${tick.labelId}`))) continue;
|
|
2276
|
+
labels.add(tick.labelId);
|
|
2277
|
+
let kind = /(?:^|[:/])category:/.test(tick.labelId) ? "category" : "series", choice = omissionScope(geo, options, tick.labelId).options?.labels, disabled = choice === !1 || typeof choice == "object" && choice !== null && choice[kind] === !1, text = axisLabelText(data, tick.at, tick.labelId);
|
|
2278
|
+
omissions.push({ labelId: tick.labelId, text, reason: disabled ? "disabled" : "density", destination: destinationOf(tick.labelId, text, {}, kind) ?? "reading.omissions" });
|
|
2279
|
+
}
|
|
2280
|
+
let named = new Set(omissions.map((omission) => omission.text));
|
|
2281
|
+
for (let note of chartNotes(geo))
|
|
2282
|
+
(engineNoteMeta(note)?.values ?? []).forEach((text, index) => {
|
|
2283
|
+
if (named.has(text)) return;
|
|
2284
|
+
named.add(text);
|
|
2285
|
+
let labelId = `note:${note.n}:value:${index}`;
|
|
2286
|
+
omissions.push({ labelId, text, reason: "note", destination: destinationOf(labelId, text) ?? `notes[${note.n - 1}]` });
|
|
2287
|
+
});
|
|
2288
|
+
return omissions;
|
|
2289
|
+
}
|
|
2290
|
+
function reportLabelOmissions(geo, options, data) {
|
|
2291
|
+
let placed, labelFor = (id) => (placed ??= new Map(geo.labels.map((label) => [label.id, label])), placed.get(id)), hidden = labelOmissions(geo, options, data).filter((omission) => omission.reason === "truncated" || omission.reason === "redundant" || omission.reason === "disabled" || omission.destination.startsWith("scene:") ? !1 : !intentionalOmission(geo, options, data, omission, labelFor));
|
|
2292
|
+
if (hidden.some((omission) => omission.destination.startsWith("label:"))) {
|
|
2293
|
+
let printed = new Set(geo.labels.filter((label) => !label.hidden).map((label) => `label:${label.id}`));
|
|
2294
|
+
hidden = hidden.filter((omission) => !printed.has(omission.destination));
|
|
2295
|
+
}
|
|
2296
|
+
dropWarnings(geo, (warning) => warning.code !== "label-hidden" || warning.severity === "error"), hidden.length !== 0 && geo.warnings.push({
|
|
2297
|
+
code: "label-hidden",
|
|
2298
|
+
severity: "warn",
|
|
2299
|
+
message: `${hidden.length} label${hidden.length === 1 ? " is" : "s are"} not drawn; reading.omissions names each label and its destination`,
|
|
2300
|
+
suggest: "increase chart size to give labels more room",
|
|
2301
|
+
detail: { hidden: hidden.map((omission) => omission.labelId) }
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
// src/core/partialPeriod.ts
|
|
2306
|
+
function partialPattern(category, pattern, outlined = !1) {
|
|
2307
|
+
return pattern ?? (category?.partial === !0 && !outlined ? "hatch45" : void 0);
|
|
2308
|
+
}
|
|
2309
|
+
function partialFootnotes(categories, strings, keyed = !1) {
|
|
2310
|
+
let labels = categories.filter((category) => category.partial === !0).map((category) => (category.label ?? category.id).replace(/\s*\n\s*/g, " "));
|
|
2311
|
+
return labels.length === 0 || keyed ? [] : [disclosureNote(`${labels.join(", ")} ${strings?.toDate ?? localeStrings().toDate}`)];
|
|
2312
|
+
}
|
|
2313
|
+
function partialAxisWords(strings, options, keyed = !1) {
|
|
2314
|
+
return keyed || disclosuresShown(options) ? void 0 : strings?.toDate ?? localeStrings().toDate;
|
|
2315
|
+
}
|
|
2316
|
+
var TO_DATE_EN = /\bto[\s-]date\b|\b[WMQY]TD\b/i;
|
|
2317
|
+
function saysToDate(words2, toDate) {
|
|
2318
|
+
return words2.toLowerCase().includes(toDate.toLowerCase()) || TO_DATE_EN.test(words2);
|
|
2319
|
+
}
|
|
2320
|
+
function partialIds(categories) {
|
|
2321
|
+
return new Set(categories.filter((category) => category.partial === !0).map((category) => category.id));
|
|
2322
|
+
}
|
|
2323
|
+
function partialLegendKeys(painted, strings, categories = []) {
|
|
2324
|
+
let labels = categories.filter((c) => c.partial).map((c) => (c.label ?? c.id).replace(/\s*\n\s*/g, " ")), label = labels.length > 0 ? `${labels.join(", ")} ${strings?.toDate ?? localeStrings().toDate}` : strings?.partial ?? localeStrings().partial;
|
|
2325
|
+
return painted ? [{ id: "__partial", label, paint: { token: "markInk" }, pattern: "hatch45" }] : [];
|
|
2326
|
+
}
|
|
2327
|
+
var PARTIAL_KEY = /* @__PURE__ */ Symbol("boardplot.partialKey");
|
|
2328
|
+
function partialKeyForced(options) {
|
|
2329
|
+
return options[PARTIAL_KEY] === !0;
|
|
2330
|
+
}
|
|
2331
|
+
function toDateFont(theme) {
|
|
2332
|
+
return { ...secondaryFont(theme), weight: theme.type.label.weight };
|
|
2333
|
+
}
|
|
2334
|
+
function toDateFits(words2, theme, measure, room) {
|
|
2335
|
+
return measure(words2, toDateFont(theme)).width + 4 <= room;
|
|
2336
|
+
}
|
|
2337
|
+
function toDateRoom(mark) {
|
|
2338
|
+
return 2 * mark;
|
|
2339
|
+
}
|
|
2340
|
+
function toDateLabel(text, font, words2, theme, measure) {
|
|
2341
|
+
let wordsFont = toDateFont(theme), head = measure(text, font), body = measure(words2, wordsFont);
|
|
2342
|
+
return {
|
|
2343
|
+
lines: [text, words2],
|
|
2344
|
+
size: { width: Math.max(head.width, body.width), height: head.height + body.height },
|
|
2345
|
+
request: { keepWhenDense: !0, align: "middle", headLines: 1, headWeight: font.weight, bodyFont: wordsFont, bodyInk: { token: "inkMuted" } }
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
// src/core/footnoteMark.ts
|
|
2350
|
+
function footnoteMark(footnote) {
|
|
2351
|
+
return `${footnote})`;
|
|
2352
|
+
}
|
|
2353
|
+
function referenceDrawn(footnote, owner, refs) {
|
|
2354
|
+
return refs === void 0 || Number.isInteger(footnote) && footnote >= 1 && footnote <= refs.count ? !0 : (refs.warnings.some((warning) => warning.code === "footnote-reference-unknown" && warning.owner?.categoryId === owner) || refs.warnings.push({
|
|
2355
|
+
code: "footnote-reference-unknown",
|
|
2356
|
+
severity: "warn",
|
|
2357
|
+
message: refs.count === 0 ? `category '${owner}' references footnote ${footnote}, and this chart has no authored footnotes \u2014 no mark drawn` : `category '${owner}' references footnote ${footnote}, outside the ${refs.count} authored footnote${refs.count === 1 ? "" : "s"} \u2014 no mark drawn`,
|
|
2358
|
+
owner: { categoryId: owner },
|
|
2359
|
+
suggest: refs.count === 0 ? "add the note to options.footnotes, or drop the reference" : `use a number from 1 to ${refs.count}, the 1-based position of the note in options.footnotes`
|
|
2360
|
+
}), !1);
|
|
2361
|
+
}
|
|
2362
|
+
function withCategoryNoteNames(options, categories) {
|
|
2363
|
+
let authored = options.authoredFootnotes ?? options.footnotes;
|
|
2364
|
+
if (!authored || !categories.some((category) => category.footnote !== void 0)) return options;
|
|
2365
|
+
let names = /* @__PURE__ */ new Map();
|
|
2366
|
+
for (let category of categories) {
|
|
2367
|
+
if (category.footnote === void 0) continue;
|
|
2368
|
+
let list = names.get(category.footnote) ?? [];
|
|
2369
|
+
list.push(category.label ?? category.id), names.set(category.footnote, list);
|
|
2370
|
+
}
|
|
2371
|
+
let named = authored.map((note, i) => names.has(i + 1) ? `${names.get(i + 1).join(", ")}: ${note}` : note), replace = (note) => {
|
|
2372
|
+
let i = authored.indexOf(note);
|
|
2373
|
+
return i >= 0 ? named[i] : note;
|
|
2374
|
+
};
|
|
2375
|
+
return { ...options, footnotes: options.footnotes === !1 ? !1 : options.footnotes?.map(replace), authoredFootnotes: named };
|
|
2376
|
+
}
|
|
2377
|
+
function markedLabel(label, footnote, owner = label, refs) {
|
|
2378
|
+
return `${label}${footnoteSuffix(footnote, owner, refs)}`;
|
|
2379
|
+
}
|
|
2380
|
+
function footnoteSuffix(footnote, owner, refs) {
|
|
2381
|
+
return footnote === void 0 || !referenceDrawn(footnote, owner, refs) ? "" : ` ${footnoteMark(footnote)}`;
|
|
2382
|
+
}
|
|
2383
|
+
function categoryLabelsAndMarks(categories, refs, toDate) {
|
|
2384
|
+
let under = categories.map((category) => toDate !== void 0 && category.partial === !0 && !saysToDate(category.label ?? category.id, toDate) ? toDate : void 0);
|
|
2385
|
+
return {
|
|
2386
|
+
labels: categories.map((category) => category.label ?? category.id),
|
|
2387
|
+
// The ISO date of each category, else its id: the row's tick rule reads the calendar from it.
|
|
2388
|
+
dates: categories.map((category) => category.date ?? String(category.id)),
|
|
2389
|
+
suffixes: categories.map((category) => footnoteSuffix(category.footnote, category.id, refs)),
|
|
2390
|
+
...under.some(Boolean) ? { under } : {},
|
|
2391
|
+
...categories.some((category) => category.calendar) ? { calendar: categories.map((category) => category.calendar) } : {}
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
// src/core/types/sizing.ts
|
|
2396
|
+
var HEIGHT_STRUCTURE = /* @__PURE__ */ Symbol("heightStructure"), VALUE_SELECTION = /* @__PURE__ */ Symbol("valueSelection");
|
|
2397
|
+
|
|
2398
|
+
// src/core/strings/frame.ts
|
|
2399
|
+
var EN = {
|
|
2400
|
+
// reader-facing wording linked only by its consumers.
|
|
2401
|
+
cutLabels: "Full text of shortened labels",
|
|
2402
|
+
listedInNote: "Listed in note {n}",
|
|
2403
|
+
countedInNote: "Counted in note {n}; the value is not listed there",
|
|
2404
|
+
countedInNotes: "Not shown on the chart; counted in the notes list",
|
|
2405
|
+
listedInNotes: "Full text is in the notes list"
|
|
2406
|
+
}, DE = {
|
|
2407
|
+
// reader-facing wording linked only by its consumers.
|
|
2408
|
+
cutLabels: "Vollst\xE4ndiger Text gek\xFCrzter Beschriftungen",
|
|
2409
|
+
listedInNote: "In Anmerkung {n} aufgef\xFChrt",
|
|
2410
|
+
countedInNote: "In Anmerkung {n} gez\xE4hlt; der Wert ist dort nicht aufgef\xFChrt",
|
|
2411
|
+
countedInNotes: "Nicht im Diagramm gezeigt; in der Anmerkungsliste gez\xE4hlt",
|
|
2412
|
+
listedInNotes: "Vollst\xE4ndiger Text steht in der Anmerkungsliste"
|
|
2413
|
+
}, { chartString: chartString2, localeStrings: localeStrings2 } = chartStrings(EN, DE);
|
|
2414
|
+
|
|
2415
|
+
// src/core/frame.ts
|
|
2416
|
+
function legendRequired(option, warnings, chartType, theme, reason = "the mapped range and no-data encoding must remain explicit") {
|
|
2417
|
+
let position = theme?.legend?.required ?? "top";
|
|
2418
|
+
return option === "none" ? (warnings.push({
|
|
2419
|
+
code: `${chartType}-legend-required`,
|
|
2420
|
+
severity: "info",
|
|
2421
|
+
message: `${chartType} legend cannot be hidden because ${reason}`
|
|
2422
|
+
}), { position }) : normalizeLegendOption(option, { position });
|
|
2423
|
+
}
|
|
2424
|
+
function legendOff(warnings, chartType, labels) {
|
|
2425
|
+
labels.length > 0 && warnings.push({ code: "legend-off", severity: "info", message: `legend: 'none' left the ${chartType} key off: ${labels.join(" | ")}` });
|
|
2426
|
+
}
|
|
2427
|
+
function normalizeLegendOption(option, defaultOptions) {
|
|
2428
|
+
if (option !== "none")
|
|
2429
|
+
return option === void 0 || option === "auto" ? defaultOptions : typeof option == "string" ? { position: option } : option;
|
|
2430
|
+
}
|
|
2431
|
+
var COMPACT_SOURCE_LINES = /* @__PURE__ */ Symbol("compactSourceLines"), LEGEND_HEIGHT = /* @__PURE__ */ Symbol("legendHeight"), CUT_LABEL_NOTES = /* @__PURE__ */ Symbol("cutLabelNotes"), CUT_LABEL_LIST = /* @__PURE__ */ Symbol("cutLabelList");
|
|
2432
|
+
function authoredNotes(options) {
|
|
2433
|
+
return options.footnotes === !1 ? [] : options.footnotes ?? [];
|
|
2434
|
+
}
|
|
2435
|
+
function footnoteSwitch(options) {
|
|
2436
|
+
return options.footnotes !== !1 ? options : { ...options, footnotes: [], footnotesOff: !0 };
|
|
2437
|
+
}
|
|
2438
|
+
function withAuthoredFootnotes(options, footnotes, authored) {
|
|
2439
|
+
return { ...options, footnotes, authoredFootnotes: authoredNotes({ footnotes: authored }) };
|
|
2440
|
+
}
|
|
2441
|
+
function authoredFootnoteCount(options) {
|
|
2442
|
+
return (options.authoredFootnotes ?? authoredNotes(options)).length;
|
|
2443
|
+
}
|
|
2444
|
+
function numberedFootnotesWith(options, referenced) {
|
|
2445
|
+
return [...options.authoredFootnotes ?? authoredNotes(options), ...referenced];
|
|
2446
|
+
}
|
|
2447
|
+
var UNIT_LINE = /* @__PURE__ */ Symbol("unitLine"), FOOTNOTE_REFS = /* @__PURE__ */ Symbol("footnoteRefs"), POINTED_NOTES = /* @__PURE__ */ Symbol("pointedNotes");
|
|
2448
|
+
function unitLineSubtitle(options) {
|
|
2449
|
+
let measure = options[UNIT_LINE];
|
|
2450
|
+
if (!(measure === void 0 || !options.unit?.trim()))
|
|
2451
|
+
return { measure: measure || options.unit.trim() };
|
|
2452
|
+
}
|
|
2453
|
+
function unreferenced(options) {
|
|
2454
|
+
let refs = options[FOOTNOTE_REFS], composed = options[POINTED_NOTES] ?? [], notes = options.authoredFootnotes ?? authoredNotes(options), positions = refs ? notes.flatMap((_, i) => refs.has(i + 1) ? [] : [i + 1]) : [], pointed = [...refs ? notes.filter((_, i) => refs.has(i + 1)) : [], ...composed];
|
|
2455
|
+
return { ...positions.length > 0 ? { unreferencedNotes: positions } : {}, ...pointed.length > 0 ? { pointedNotes: pointed } : {} };
|
|
2456
|
+
}
|
|
2457
|
+
function frameTextOptions(options) {
|
|
2458
|
+
let mode = options.mode === "full" || options.mode === "compact" ? options.mode : void 0, unitLine = resolveSubtitle(options.subtitle) === void 0 ? unitLineSubtitle(options) : void 0;
|
|
2459
|
+
return {
|
|
2460
|
+
...identityCollector(options),
|
|
2461
|
+
...options[LEGEND_HEIGHT] !== void 0 ? { [LEGEND_HEIGHT]: options[LEGEND_HEIGHT] } : {},
|
|
2462
|
+
...options[CUT_LABEL_NOTES] ? { [CUT_LABEL_NOTES]: options[CUT_LABEL_NOTES] } : {},
|
|
2463
|
+
target: options.target,
|
|
2464
|
+
...options.textScale === void 0 && options.textSize === void 0 ? {} : { textScale: textScaleOf(options) },
|
|
2465
|
+
title: options.title,
|
|
2466
|
+
subtitle: resolveSubtitle(options.subtitle) ?? unitLine,
|
|
2467
|
+
// A measure that already carries the unit ("Retained customers" in
|
|
2468
|
+
// customers, or the unit itself) prints it once.
|
|
2469
|
+
unit: unitLine && squeezeUnit(unitLine.measure).includes(squeezeUnit(options.unit)) ? void 0 : options.unit,
|
|
2470
|
+
source: options.source,
|
|
2471
|
+
...options[COMPACT_SOURCE_LINES] !== void 0 ? { [COMPACT_SOURCE_LINES]: options[COMPACT_SOURCE_LINES] } : {},
|
|
2472
|
+
...options[COMPACT_OMITTED_NOTES] ? { [COMPACT_OMITTED_NOTES]: options[COMPACT_OMITTED_NOTES] } : {},
|
|
2473
|
+
...options[LIVE_NOTE_SHOW] ? { [LIVE_NOTE_SHOW]: options[LIVE_NOTE_SHOW] } : {},
|
|
2474
|
+
strings: options.strings,
|
|
2475
|
+
...options.notes !== void 0 || shownNoteKinds(options) !== void 0 ? { notes: { ...options.notes, show: shownNoteKinds(options) } } : {},
|
|
2476
|
+
footnotes: options.footnotes === !1 ? [] : options.footnotes,
|
|
2477
|
+
...options.footnotesOff === !0 || options.footnotes === !1 ? { footnotesOff: !0 } : {},
|
|
2478
|
+
numberedFootnotes: options.authoredFootnotes ?? authoredNotes(options),
|
|
2479
|
+
...unreferenced(options),
|
|
2480
|
+
mode,
|
|
2481
|
+
...mode === "compact" ? { compactTitleSize: smallestTitleSize(resolveTargetTheme(options.theme, options.target ?? DEFAULT_TARGET, textScaleOf(options), textSizeOf(options))) } : {},
|
|
2482
|
+
// Compact keeps its key and may shrink it: the key takes the footnote size
|
|
2483
|
+
// (12 px), or the secondary step where that is smaller (11 px on a report card); a full
|
|
2484
|
+
// chart's automatic key prints at the key size (13 px).
|
|
2485
|
+
...mode === "compact" ? { legendFont: "compact" } : {}
|
|
2486
|
+
};
|
|
2487
|
+
}
|
|
2488
|
+
var NOTE_HIT_PX = 24;
|
|
2489
|
+
function htmlFooterHeight(input, parts, sourceText, font, width, lineH, measure) {
|
|
2490
|
+
let height = (text) => wrapFootnote(text, font, width, measure).length * lineH, total = 0;
|
|
2491
|
+
for (let note of parts.shown)
|
|
2492
|
+
total += height(`${note.ref ? `${footnoteMark(note.ref)} ` : ""}${note.kind === "method" || note.kind === "disclosure" ? note.short ?? note.text : note.text}`);
|
|
2493
|
+
let credit = parts.credit && `${chartString2(input, "mapCredit")}: ${parts.credit.text}`, label = parts.panel.length === 0 ? void 0 : parts.info ? `${chartString(input, "notesAndSources")} (${parts.panel.length})` : notesPointer(parts.panel.length, input.strings), items = [
|
|
2494
|
+
...parts.source && sourceText ? [{ w: measure(sourceText, font).width, text: sourceText }] : [],
|
|
2495
|
+
...credit && parts.info ? [{ w: measure(credit, font).width, text: credit }] : [],
|
|
2496
|
+
...label ? [{ w: Math.max(NOTE_HIT_PX, measure(label, font).width), h: Math.max(NOTE_HIT_PX, lineH) }] : []
|
|
2497
|
+
], used = -1, line = 0;
|
|
2498
|
+
for (let item of items) {
|
|
2499
|
+
let h = item.text === void 0 ? item.h : item.w > width ? height(item.text) : lineH;
|
|
2500
|
+
if (used >= 0 && used + 0.75 * font.size + item.w <= width) {
|
|
2501
|
+
used += 0.75 * font.size + item.w, line = Math.max(line, h);
|
|
2502
|
+
continue;
|
|
2503
|
+
}
|
|
2504
|
+
used >= 0 && (total += line + 2), used = Math.min(item.w, width), line = h;
|
|
2505
|
+
}
|
|
2506
|
+
return items.length > 0 && (total += line + (parts.shown.length > 0 ? 4 : 0)), credit && !parts.info && (total += height(credit)), total;
|
|
2507
|
+
}
|
|
2508
|
+
var frameChrome = /* @__PURE__ */ new WeakMap(), plotChromeFloor = /* @__PURE__ */ new WeakMap(), settledAutoHeight = /* @__PURE__ */ new WeakSet(), REFERENCE_SUBTITLE_PLOT_GAP = 12, REFERENCE_FOOTER_GAP = 12;
|
|
2509
|
+
function fixedPlotChrome(result, reserve = 0) {
|
|
2510
|
+
let chrome = frameChrome.get(result.frame);
|
|
2511
|
+
chrome !== void 0 && plotChromeFloor.set(result.frame, chrome + reserve);
|
|
2512
|
+
}
|
|
2513
|
+
var SWATCH = 12, TITLE_LINES = 3, LINE_SWATCH = 18, MARKER_LINE_SWATCH = 16, lineSwatch = (item) => item.marker ? MARKER_LINE_SWATCH : LINE_SWATCH, SWATCH_GAP2 = 5, ITEM_GAP = 14, MIN_PLOT_H = 10;
|
|
2514
|
+
function plotHeightAfter(frameResult, canvasH, h) {
|
|
2515
|
+
let { frame } = frameResult;
|
|
2516
|
+
return frame.plotMinHeight = Math.max(frame.plotMinHeight ?? 0, canvasH + (frameResult.deficit ?? 0) + MIN_PLOT_H - h), Math.max(MIN_PLOT_H, h);
|
|
2517
|
+
}
|
|
2518
|
+
function legendKeyNodes(theme, item, id, x, y, lineH, font) {
|
|
2519
|
+
let nodes = shapeKeyNodes(theme, item, id, x, y, lineH, font);
|
|
2520
|
+
return item.key === "line" && item.marker ? [...nodes, lineKeyMarker(theme, item, item.marker, `${id}:marker`, x + MARKER_LINE_SWATCH / 2, y + lineH / 2)] : nodes;
|
|
2521
|
+
}
|
|
2522
|
+
function lineKeyMarker(theme, item, marker, id, cx, cy) {
|
|
2523
|
+
let r = (v) => Math.round(v * 100) / 100, { shape, hollow } = marker, fill = hollow ? { token: "background" } : item.paint, owner = { seriesId: item.id }, ringWidth = strokeToken(theme, "mark");
|
|
2524
|
+
if (shape === "circle") return { t: "circle", id, cx, cy, r: 2.5, fill, ...hollow ? { stroke: item.paint, strokeWidth: ringWidth } : {}, owner, part: "swatch" };
|
|
2525
|
+
if (shape === "square") return { t: "rect", id, rect: { x: cx - 2.5, y: cy - 2.5, w: 5, h: 5 }, fill, ...hollow ? { stroke: item.paint, strokeWidth: ringWidth } : {}, owner, part: "swatch" };
|
|
2526
|
+
let d = shape === "triangle" ? `M ${r(cx)} ${r(cy - 3)} L ${r(cx + 3)} ${r(cy + 2.5)} L ${r(cx - 3)} ${r(cy + 2.5)} Z` : `M ${r(cx)} ${r(cy - 3.5)} L ${r(cx + 3.5)} ${r(cy)} L ${r(cx)} ${r(cy + 3.5)} L ${r(cx - 3.5)} ${r(cy)} Z`;
|
|
2527
|
+
return { t: "path", id, d, fill, ...hollow ? { stroke: item.paint, width: ringWidth } : {}, owner, part: "swatch" };
|
|
2528
|
+
}
|
|
2529
|
+
function shapeKeyNodes(theme, item, id, x, y, lineH, font) {
|
|
2530
|
+
if (item.key === "heading") return [];
|
|
2531
|
+
let cy = y + lineH / 2;
|
|
2532
|
+
if (item.key === "glyph" && font) {
|
|
2533
|
+
let textH = font.size * (font.lineHeight ?? 1.2);
|
|
2534
|
+
return [{ t: "text", id, x: x + SWATCH / 2, y: y + (lineH - textH) / 2, lines: [item.glyph ?? ""], align: "middle", font, ink: item.paint, owner: { seriesId: item.id }, part: "swatch", typeRole: "axis" }];
|
|
2535
|
+
}
|
|
2536
|
+
if (item.key === "line" && item.hollow) {
|
|
2537
|
+
let outer = legendKeyNode(theme, item, id, x, y, lineH);
|
|
2538
|
+
return [outer, { ...outer, id: `${id}:inner`, stroke: { token: "background" }, width: strokeToken(theme, "hair") }];
|
|
2539
|
+
}
|
|
2540
|
+
if (item.key === "line" && item.caps) {
|
|
2541
|
+
let caps = item.caps, cap = (end, cx) => ({
|
|
2542
|
+
t: "line",
|
|
2543
|
+
id: `${id}:${end}`,
|
|
2544
|
+
x1: cx,
|
|
2545
|
+
y1: cy - caps.half,
|
|
2546
|
+
x2: cx,
|
|
2547
|
+
y2: cy + caps.half,
|
|
2548
|
+
stroke: caps.paint,
|
|
2549
|
+
width: caps.width ?? strokeToken(theme, "mark"),
|
|
2550
|
+
owner: { seriesId: item.id },
|
|
2551
|
+
part: "swatch"
|
|
2552
|
+
});
|
|
2553
|
+
return [legendKeyNode(theme, item, id, x, y, lineH), cap("low", x), cap("high", x + lineSwatch(item))];
|
|
2554
|
+
}
|
|
2555
|
+
if (item.withLine) {
|
|
2556
|
+
let lx = x + SWATCH + WITH_LINE_GAP;
|
|
2557
|
+
return [legendKeyNode(theme, item, id, x, y, lineH), {
|
|
2558
|
+
t: "line",
|
|
2559
|
+
id: `${id}:line`,
|
|
2560
|
+
x1: lx,
|
|
2561
|
+
y1: cy,
|
|
2562
|
+
x2: lx + LINE_SWATCH,
|
|
2563
|
+
y2: cy,
|
|
2564
|
+
stroke: item.withLine.paint,
|
|
2565
|
+
width: item.withLine.width ?? strokeToken(theme, "data"),
|
|
2566
|
+
...item.withLine.dash ? { dash: item.withLine.dash, lineCap: item.withLine.lineCap } : {},
|
|
2567
|
+
owner: { seriesId: item.id },
|
|
2568
|
+
part: "swatch"
|
|
2569
|
+
}];
|
|
2570
|
+
}
|
|
2571
|
+
if (item.key === "harvey") {
|
|
2572
|
+
let cx = x + SWATCH / 2, r = SWATCH / 2 - 0.5, level = Math.max(0, Math.min(4, Math.round(item.level ?? 0))), owner = { seriesId: item.id }, ring = { t: "circle", id, cx, cy, r, fill: { token: "background" }, stroke: { token: "neutralMark" }, strokeWidth: strokeToken(theme, "mark"), owner, part: "swatch" };
|
|
2573
|
+
return level === 0 ? [ring] : [ring, level === 4 ? { t: "circle", id: `${id}:fill`, cx, cy, r, fill: item.paint, owner, part: "swatch" } : { t: "path", id: `${id}:fill`, d: harveyWedgePath(cx, cy, r, level), fill: item.paint, owner, part: "swatch" }];
|
|
2574
|
+
}
|
|
2575
|
+
if (item.key === "sizes") {
|
|
2576
|
+
let radii = sizeKeyRadii(item, lineH), outer = radii[0] ?? SWATCH / 2, bottom = cy + Math.min(lineH / 2, outer), owner = { seriesId: item.id };
|
|
2577
|
+
return radii.map((r, i) => ({
|
|
2578
|
+
t: "circle",
|
|
2579
|
+
id: i === 0 ? id : `${id}:size${i}`,
|
|
2580
|
+
cx: x + outer,
|
|
2581
|
+
cy: bottom - r,
|
|
2582
|
+
r,
|
|
2583
|
+
fill: { token: "background" },
|
|
2584
|
+
stroke: item.paint,
|
|
2585
|
+
strokeWidth: strokeToken(theme, "mark"),
|
|
2586
|
+
owner,
|
|
2587
|
+
part: "swatch"
|
|
2588
|
+
}));
|
|
2589
|
+
}
|
|
2590
|
+
if (item.key === "whisker") {
|
|
2591
|
+
let cx = x + SWATCH / 2, top = cy - SWATCH / 2, bottom = cy + SWATCH / 2, stroke = { stroke: item.paint, width: item.width ?? strokeToken(theme, "rule"), owner: { seriesId: item.id }, part: "swatch" };
|
|
2592
|
+
return [
|
|
2593
|
+
{ t: "line", id, x1: cx, y1: top, x2: cx, y2: bottom, ...stroke },
|
|
2594
|
+
{ t: "line", id: `${id}:capTop`, x1: cx - 3, y1: top, x2: cx + 3, y2: top, ...stroke },
|
|
2595
|
+
{ t: "line", id: `${id}:capBottom`, x1: cx - 3, y1: bottom, x2: cx + 3, y2: bottom, ...stroke }
|
|
2596
|
+
];
|
|
2597
|
+
}
|
|
2598
|
+
return [legendKeyNode(theme, item, id, x, y, lineH)];
|
|
2599
|
+
}
|
|
2600
|
+
function legendKeyNode(theme, item, id, x, y, lineH) {
|
|
2601
|
+
let cy = y + lineH / 2;
|
|
2602
|
+
if (item.key === "line")
|
|
2603
|
+
return {
|
|
2604
|
+
t: "line",
|
|
2605
|
+
id,
|
|
2606
|
+
x1: x,
|
|
2607
|
+
y1: cy,
|
|
2608
|
+
x2: x + lineSwatch(item),
|
|
2609
|
+
y2: cy,
|
|
2610
|
+
stroke: item.paint,
|
|
2611
|
+
width: item.width ?? strokeToken(theme, "data"),
|
|
2612
|
+
...item.dash ? { dash: item.dash, lineCap: item.lineCap } : {},
|
|
2613
|
+
owner: { seriesId: item.id },
|
|
2614
|
+
part: "swatch"
|
|
2615
|
+
};
|
|
2616
|
+
if (item.key === "tick") {
|
|
2617
|
+
let cx = x + SWATCH / 2;
|
|
2618
|
+
return {
|
|
2619
|
+
t: "line",
|
|
2620
|
+
id,
|
|
2621
|
+
x1: cx,
|
|
2622
|
+
y1: cy - SWATCH / 2,
|
|
2623
|
+
x2: cx,
|
|
2624
|
+
y2: cy + SWATCH / 2,
|
|
2625
|
+
stroke: item.paint,
|
|
2626
|
+
width: item.width ?? strokeToken(theme, "mark"),
|
|
2627
|
+
owner: { seriesId: item.id },
|
|
2628
|
+
part: "swatch"
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
if (item.key === "bracket")
|
|
2632
|
+
return {
|
|
2633
|
+
t: "path",
|
|
2634
|
+
id,
|
|
2635
|
+
d: bracketPath(x, cy),
|
|
2636
|
+
stroke: item.paint,
|
|
2637
|
+
width: item.width ?? strokeToken(theme, "mark"),
|
|
2638
|
+
owner: { seriesId: item.id },
|
|
2639
|
+
part: "swatch"
|
|
2640
|
+
};
|
|
2641
|
+
if (item.key === "diamond")
|
|
2642
|
+
return {
|
|
2643
|
+
t: "path",
|
|
2644
|
+
id,
|
|
2645
|
+
d: diamondPath(x + SWATCH / 2, cy),
|
|
2646
|
+
fill: item.paint,
|
|
2647
|
+
...item.separation ? { separation: item.separation } : {},
|
|
2648
|
+
...item.stroke ? { stroke: item.stroke, width: item.width ?? strokeToken(theme, "mark") } : {},
|
|
2649
|
+
owner: { seriesId: item.id },
|
|
2650
|
+
part: "swatch"
|
|
2651
|
+
};
|
|
2652
|
+
if (item.key === "triangle") {
|
|
2653
|
+
let cx = x + SWATCH / 2;
|
|
2654
|
+
return {
|
|
2655
|
+
t: "path",
|
|
2656
|
+
id,
|
|
2657
|
+
d: trianglePath(cx, cy),
|
|
2658
|
+
fill: item.paint,
|
|
2659
|
+
...item.stroke ? { stroke: item.stroke, width: item.width ?? strokeToken(theme, "mark") } : {},
|
|
2660
|
+
owner: { seriesId: item.id },
|
|
2661
|
+
part: "swatch"
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
return item.key === "marker" ? {
|
|
2665
|
+
t: "circle",
|
|
2666
|
+
id,
|
|
2667
|
+
cx: x + SWATCH / 2,
|
|
2668
|
+
cy,
|
|
2669
|
+
r: item.radius ?? SWATCH / 2,
|
|
2670
|
+
fill: item.paint,
|
|
2671
|
+
...item.stroke ? { stroke: item.stroke, strokeWidth: item.width ?? strokeToken(theme, "mark") } : {},
|
|
2672
|
+
owner: { seriesId: item.id },
|
|
2673
|
+
part: "swatch"
|
|
2674
|
+
} : {
|
|
2675
|
+
t: "rect",
|
|
2676
|
+
id,
|
|
2677
|
+
rect: { x, y: y + (lineH - SWATCH) / 2, w: SWATCH, h: SWATCH },
|
|
2678
|
+
fill: item.paint,
|
|
2679
|
+
pattern: item.hollow ? "hollow" : item.pattern,
|
|
2680
|
+
...item.separation ? { separation: item.separation } : {},
|
|
2681
|
+
...item.hatchGround && item.pattern === "hatch45" ? { hatchGround: item.hatchGround } : {},
|
|
2682
|
+
...item.hatchEdge === !1 && item.pattern === "hatch45" ? { hatchEdge: !1 } : {},
|
|
2683
|
+
...item.stroke ? { stroke: item.stroke, strokeWidth: item.width ?? strokeToken(theme, "mark") } : {},
|
|
2684
|
+
owner: { seriesId: item.id },
|
|
2685
|
+
part: "swatch"
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
function sizeKeyRadii(item, lineH) {
|
|
2689
|
+
return (item.radii ?? []).map((r) => Math.min(Math.max(0.5, r), lineH / 2)).sort((a, b) => b - a);
|
|
2690
|
+
}
|
|
2691
|
+
function keyWidth(item, lineH) {
|
|
2692
|
+
return item.key === "heading" ? -SWATCH_GAP2 : item.withLine ? SWATCH + WITH_LINE_GAP + LINE_SWATCH : item.key === "line" ? lineSwatch(item) : item.key === "sizes" ? 2 * (sizeKeyRadii(item, lineH)[0] ?? SWATCH / 2) : SWATCH;
|
|
2693
|
+
}
|
|
2694
|
+
var WITH_LINE_GAP = 3;
|
|
2695
|
+
function bracketPath(x, cy) {
|
|
2696
|
+
let r = (v) => Math.round(v * 100) / 100;
|
|
2697
|
+
return `M ${r(x)} ${r(cy + 3)} L ${r(x)} ${r(cy - 3)} L ${r(x + SWATCH)} ${r(cy - 3)} L ${r(x + SWATCH)} ${r(cy + 3)}`;
|
|
2698
|
+
}
|
|
2699
|
+
function diamondPath(cx, cy) {
|
|
2700
|
+
let r = (v) => Math.round(v * 100) / 100;
|
|
2701
|
+
return `M ${r(cx)} ${r(cy - 5)} L ${r(cx + 5)} ${r(cy)} L ${r(cx)} ${r(cy + 5)} L ${r(cx - 5)} ${r(cy)} Z`;
|
|
2702
|
+
}
|
|
2703
|
+
function trianglePath(cx, cy) {
|
|
2704
|
+
let r = (v) => Math.round(v * 100) / 100;
|
|
2705
|
+
return `M ${r(cx - 5)} ${r(cy + 3.75)} L ${r(cx + 5)} ${r(cy + 3.75)} L ${r(cx)} ${r(cy - 3.75)} Z`;
|
|
2706
|
+
}
|
|
2707
|
+
function shiftLegendKeyY(node, dy) {
|
|
2708
|
+
if (node.t === "rect") node.rect.y += dy;
|
|
2709
|
+
else if (node.t === "line")
|
|
2710
|
+
node.y1 += dy, node.y2 += dy;
|
|
2711
|
+
else if (node.t === "circle") node.cy += dy;
|
|
2712
|
+
else if (node.t === "text") node.y += dy;
|
|
2713
|
+
else if (node.t === "path") {
|
|
2714
|
+
let numbers = node.d.match(/-?[\d.]+/g).map(Number);
|
|
2715
|
+
if (numbers.length === 6) node.d = trianglePath((numbers[0] + numbers[2]) / 2, numbers[1] - 3.75 + dy);
|
|
2716
|
+
else {
|
|
2717
|
+
let k = 0;
|
|
2718
|
+
node.d = node.d.replace(/-?[\d.]+/g, (n) => k++ % 2 === 1 ? String(Math.round((Number(n) + dy) * 100) / 100) : n);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
function measureNamesUnit(unit, measure) {
|
|
2723
|
+
let escaped = unit.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\s+/g, "\\s+");
|
|
2724
|
+
return escaped.length > 0 && new RegExp(`(?<![\\p{L}\\p{N}_])${escaped}(?![\\p{L}\\p{N}_])`, "iu").test(measure);
|
|
2725
|
+
}
|
|
2726
|
+
function subtitleUnitClause(unit, measure) {
|
|
2727
|
+
let normalized = unit.trim().toLowerCase();
|
|
2728
|
+
return normalized === "x" || normalized === "\xD7" || normalized === "ratio" ? /\bper\b/i.test(measure) ? "" : /\bratio\b/i.test(measure) ? " (\xD7)" : " ratio (\xD7)" : measureNamesUnit(unit, measure) ? "" : ` in ${unit}`;
|
|
2729
|
+
}
|
|
2730
|
+
function frameRendersUnit(input) {
|
|
2731
|
+
return !!(input.subtitle && input.unit && (measureNamesUnit(input.unit, input.subtitle.measure) || subtitleUnitClause(input.unit, input.subtitle.measure).length > 0));
|
|
2732
|
+
}
|
|
2733
|
+
function unitPrinted(input) {
|
|
2734
|
+
return !!(input.unitShown && input.unit) || frameRendersUnit(input);
|
|
2735
|
+
}
|
|
2736
|
+
function unitNotShownLints(options, geo) {
|
|
2737
|
+
if (!unitMissing(options, geo)) return [];
|
|
2738
|
+
let unit = options.unit.trim();
|
|
2739
|
+
return [{
|
|
2740
|
+
code: "unit-not-shown",
|
|
2741
|
+
severity: "warn",
|
|
2742
|
+
message: `options.unit '${unit}' is printed nowhere on the chart: no subtitle measure, axis title or value label carries it`,
|
|
2743
|
+
suggest: `name the measure in the subtitle (subtitle: { measure: 'Revenue' } prints "Revenue in ${unit}"), or title the value axis with the unit; set unitShown: true when the host prints the unit beside the chart`,
|
|
2744
|
+
field: ["options", "unit"]
|
|
2745
|
+
}];
|
|
2746
|
+
}
|
|
2747
|
+
function unitInFormatLints(options, at = []) {
|
|
2748
|
+
let unit = typeof options?.unit == "string" ? options.unit.trim() : "", format = typeof options?.format == "string" ? options.format : "";
|
|
2749
|
+
if (!unit || !format) return [];
|
|
2750
|
+
let spec = parseFormatExample(format), printed = unitOfSpec(spec), [unitSign, formatSign] = [currencySign(unit), currencySign(`${spec.prefix} ${spec.suffix}`)], field = [...at, "options", "unit"];
|
|
2751
|
+
return unit === "%" && spec.suffix.includes("%") ? [{
|
|
2752
|
+
code: "unit-format-conflict",
|
|
2753
|
+
severity: "warn",
|
|
2754
|
+
message: `options.unit '%' repeats the percent sign in format '${format}'; line labels print the sign once`,
|
|
2755
|
+
suggest: "remove options.unit; the format already prints %",
|
|
2756
|
+
field,
|
|
2757
|
+
fix: [{ op: "remove", path: `/${field.join("/")}` }]
|
|
2758
|
+
}] : printed ? unitSign && formatSign && unitSign !== formatSign ? [{
|
|
2759
|
+
code: "unit-format-conflict",
|
|
2760
|
+
severity: "warn",
|
|
2761
|
+
message: `options.unit '${unit}' names another currency than format '${format}', which prints ${formatSign} on every value`,
|
|
2762
|
+
suggest: `use one currency: set a format that prints the currency of '${unit}', or set options.unit to the currency of ${formatSign}`,
|
|
2763
|
+
field
|
|
2764
|
+
}] : !textCarriesUnit(printed, unit) && !(unitSign && formatSign) ? [] : [{
|
|
2765
|
+
code: "unit-in-format",
|
|
2766
|
+
severity: "warn",
|
|
2767
|
+
message: `options.unit '${unit}' repeats the ${printed} that format '${format}' prints on every value, so a label can read it twice`,
|
|
2768
|
+
suggest: `remove options.unit; the format already prints ${printed}`,
|
|
2769
|
+
field,
|
|
2770
|
+
fix: [{ op: "remove", path: `/${field.join("/")}` }]
|
|
2771
|
+
}] : [];
|
|
2772
|
+
}
|
|
2773
|
+
function noteLine(lead, items, options, total) {
|
|
2774
|
+
return items.length === 0 ? [] : [engineNote(
|
|
2775
|
+
listText(lead, options === void 0 ? items : cappedItems(items, options, total)),
|
|
2776
|
+
"disclosure",
|
|
2777
|
+
void 0,
|
|
2778
|
+
void 0,
|
|
2779
|
+
// unless the author set notes.maxListed, the frame names as many items as fit two lines.
|
|
2780
|
+
options?.notes?.maxListed === void 0 && options ? { lead, items, total, options } : void 0
|
|
2781
|
+
)];
|
|
2782
|
+
}
|
|
2783
|
+
var listText = (lead, items) => `${lead}: ${items.join(", ").replace(/\.$/, "")}.`;
|
|
2784
|
+
function fittedNote(list, fits) {
|
|
2785
|
+
let at = (k) => listedNoteText(list, k), low = 0, high = Math.min(list.items.length, noteCap(list.options, list.items.length));
|
|
2786
|
+
if (fits(at(high))) return at(high);
|
|
2787
|
+
for (; high - low > 1; ) {
|
|
2788
|
+
let mid = low + high >> 1;
|
|
2789
|
+
fits(at(mid)) ? low = mid : high = mid;
|
|
2790
|
+
}
|
|
2791
|
+
return at(low);
|
|
2792
|
+
}
|
|
2793
|
+
function listedNoteText({ lead, items, total, options }, k) {
|
|
2794
|
+
let n = items.length;
|
|
2795
|
+
return k === 0 ? listText(lead, [total !== void 0 && total >= n ? countedValuesText(n, total, options) : moreListedText(n, options, !0)]) : listText(lead, k < n ? [...items.slice(0, k), moreListedText(n - k, options)] : items);
|
|
2796
|
+
}
|
|
2797
|
+
function namedInDrawnNote(list, drawn) {
|
|
2798
|
+
let flat = (text) => text.replace(/\s+/g, ""), target = flat(drawn);
|
|
2799
|
+
for (let k = Math.min(list.items.length, noteCap(list.options, list.items.length)); k >= 0; k--) if (flat(listedNoteText(list, k)) === target) return k;
|
|
2800
|
+
}
|
|
2801
|
+
function valueNoteLine(lead, items, options, total) {
|
|
2802
|
+
return noteLine(lead, items, options, total).map((line) => valueNote(line, items));
|
|
2803
|
+
}
|
|
2804
|
+
var DEFAULT_NOTE_LIMIT = 8;
|
|
2805
|
+
function noteCap(options, count = 0) {
|
|
2806
|
+
let max = options?.notes?.maxListed, cap = max === "all" ? 1 / 0 : typeof max == "number" && max >= 0 ? Math.floor(max) : DEFAULT_NOTE_LIMIT;
|
|
2807
|
+
return cap && count === cap + 1 ? count : cap;
|
|
2808
|
+
}
|
|
2809
|
+
function moreListedText(count, options, alone = !1) {
|
|
2810
|
+
return alone ? chartString2(options, "countedItems", { count }) : (options?.strings?.moreListed ?? "and {count} more").replace("{count}", String(count));
|
|
2811
|
+
}
|
|
2812
|
+
function countedValuesText(count, total, options) {
|
|
2813
|
+
return chartString2(options, "countedValues", { count, total });
|
|
2814
|
+
}
|
|
2815
|
+
function cappedItems(items, options, total) {
|
|
2816
|
+
let cap = noteCap(options, items.length);
|
|
2817
|
+
return items.length <= cap ? [...items] : cap === 0 && total !== void 0 && total >= items.length ? [countedValuesText(items.length, total, options)] : [...items.slice(0, cap), moreListedText(items.length - cap, options, cap === 0)];
|
|
2818
|
+
}
|
|
2819
|
+
var HIDDEN_LABEL_LEAD = "Not labelled on the chart";
|
|
2820
|
+
function withCutLabelNotes(data, options, layout) {
|
|
2821
|
+
let first = layout(options);
|
|
2822
|
+
if (first.refused) return first;
|
|
2823
|
+
let cuts = cutLabels(first);
|
|
2824
|
+
if (!cuts.length || first.warnings.some((warning) => warning.severity === "error")) return first;
|
|
2825
|
+
let warn = (geo) => (geo.warnings = [...geo.warnings.filter((warning) => warning.code !== "label-truncated"), {
|
|
2826
|
+
code: "label-truncated",
|
|
2827
|
+
severity: "warn",
|
|
2828
|
+
message: `${cuts.length} shortened labels have their full text in the notes list and reading.omissions.`,
|
|
2829
|
+
detail: { labels: cuts.map((cut) => cut.labelId) }
|
|
2830
|
+
}], geo), existing = chartNotes(first).map((note) => note.text.replace(/\s+/g, " ").trim()), unlisted = cuts.filter((cut) => isNumberAlone(cut.text) || !existing.some((note) => containsText(note, cut.text.replace(/\s+/g, " ").trim())));
|
|
2831
|
+
if (!unlisted.length) return warn(first);
|
|
2832
|
+
let items = [...new Set(unlisted.map((cut) => {
|
|
2833
|
+
let owner = first.scene.find((node2) => node2.t === "text" && (node2.id === cut.labelId || node2.id === `label:${cut.labelId}`))?.owner, source = data, row = source?.rows?.find((row2) => row2.id === owner?.rowId)?.label, column = source?.columns?.find((column2) => column2.id === owner?.colId)?.label, place = [row, row ? column : void 0].filter(Boolean).join(" \u2014 ");
|
|
2834
|
+
return place ? `${place}: ${cut.text.trim()}` : cut.text.trim();
|
|
2835
|
+
}))], lead = chartString2(options, "cutLabels"), short = noteLine(lead, items, options)[0], full = engineNote(`${lead}: ${items.join("; ").replace(/\.$/, "")}.`, "disclosure", short, void 0, engineNoteMeta(short)?.list ?? null), planned = { ...options, [CUT_LABEL_NOTES]: [...options[CUT_LABEL_NOTES] ?? [], full] }, next = options.notes?.show?.includes("disclosure") ? layout(planned) : first, need = (geo) => geo.refused ? 0 : Math.max(geo.frame.minHeight ?? 0, geo.frame.plotMinHeight ?? 0, geo.sizing?.measuredMinHeight ?? 0);
|
|
2836
|
+
if ((next.refused || resolveTargetSize(options.target ?? DEFAULT_TARGET, options.size).fixed.height && (next.size.height > first.size.height || need(next) > Math.max(next.size.height, need(first)))) && (next = first), next !== first) {
|
|
2837
|
+
let original = new Map(cuts.map((cut) => [cut.labelId, cut.displayed])), visible = new Set(first.labels.filter((label) => !label.hidden).map((label) => label.id));
|
|
2838
|
+
(cutLabels(next).some((cut) => !original.has(cut.labelId) || cut.displayed.length < original.get(cut.labelId).length) || next.labels.some((label) => label.hidden && visible.has(label.id))) && (next = first);
|
|
2839
|
+
}
|
|
2840
|
+
return next[CUT_LABEL_LIST] = keepNoteMeta({ n: 0, kind: "disclosure", text: full, short, inFrame: !1 }, engineNoteMeta(full)), warn(next);
|
|
2841
|
+
}
|
|
2842
|
+
function finishCutLabelNotes(geo) {
|
|
2843
|
+
let note = geo[CUT_LABEL_LIST];
|
|
2844
|
+
if (!note || geo.frame.noteList?.some((entry) => entry.text === note.text)) return;
|
|
2845
|
+
let notes = geo.frame.noteList ?? [], at = notes.findIndex((entry) => entry.kind === "source" || entry.kind === "credit"), cut = at < 0 ? notes.length : at;
|
|
2846
|
+
geo.frame.noteList = [...notes.slice(0, cut), note, ...notes.slice(cut)].map((entry, i) => copyNote(entry, { n: i + 1 }));
|
|
2847
|
+
}
|
|
2848
|
+
var DEFER_DENSITY_NOTES = /* @__PURE__ */ Symbol("deferDensityNotes"), DENSITY_VALUES = /* @__PURE__ */ Symbol("densityValues"), UNVERIFIED_DENSITY_REFUSALS = /* @__PURE__ */ new WeakSet(), DENSITY_LAYOUT_OPTIONS = /* @__PURE__ */ Symbol("densityLayoutOptions"), OWED_KINDS = /* @__PURE__ */ new Set(["point", "series", "valueLine", "annotation", "item", "diagramSecondary"]), BRIDGE_OWED_KINDS = /* @__PURE__ */ new Set(["total", "segment", "category"]);
|
|
2849
|
+
function owedHiddenLabels(geo, data, pins = {}, annotations, minimal = !1) {
|
|
2850
|
+
let drawn = new Map(geo.scene.flatMap((node) => node.t === "text" ? [[node.id, node.lines.join(" ")]] : [])), idOf = (item) => typeof item == "object" && item !== null ? item.id : item, indexes = /* @__PURE__ */ new Map(), nameIn = (list, id) => {
|
|
2851
|
+
if (!Array.isArray(list) || id === void 0) return;
|
|
2852
|
+
let index = indexes.get(list);
|
|
2853
|
+
if (index === void 0) {
|
|
2854
|
+
index = /* @__PURE__ */ new Map();
|
|
2855
|
+
for (let i = 0; i < list.length; i++) {
|
|
2856
|
+
let item = list[i], key = idOf(item);
|
|
2857
|
+
key === key && !index.has(key) && index.set(key, item);
|
|
2858
|
+
}
|
|
2859
|
+
indexes.set(list, index);
|
|
2860
|
+
}
|
|
2861
|
+
let hit = index.get(id);
|
|
2862
|
+
if (hit !== void 0)
|
|
2863
|
+
return String(typeof hit == "object" && hit !== null ? hit.calendar?.named ?? hit.label ?? id : hit);
|
|
2864
|
+
}, legendName = (id) => {
|
|
2865
|
+
let item = id === void 0 ? void 0 : geo.legend?.items.find((entry) => entry.id === id);
|
|
2866
|
+
return item ? drawn.get(`label:${item.labelId}`) ?? drawn.get(item.labelId) ?? geo.labels.find((l) => l.id === item.labelId)?.text : id && geo.labels.find((l) => l.kind === "axisTitle" && l.owner.seriesId === id)?.text;
|
|
2867
|
+
}, { series, categories, rows, items, cases } = data ?? {}, valueCallouts = loadedDeferred("annotate")?.valueAnnotationLabels(geo.labels, annotations) ?? [], entries = geo.labels.flatMap((label) => {
|
|
2868
|
+
if (label.hidden === void 0 || label.noted || label[LEFT_OUT_OF_NOTE] || (minimal || geo[DEFER_DENSITY_NOTES]) && label.hidden === "density" || !label.text) return [];
|
|
2869
|
+
let callout = valueCallouts.find(([own, at]) => holdsToken(own.text, label.text) && Object.entries(at).every(([key, id]) => key === "edge" || label.owner[key] === id));
|
|
2870
|
+
if (callout)
|
|
2871
|
+
return label.printedIn = callout[0].id, [];
|
|
2872
|
+
if (label.kind === "series" && label.owner.seriesId !== void 0 && geo.labels.some((other) => other !== label && other.kind === "series" && other.hidden === void 0 && other.owner.seriesId === label.owner.seriesId)) return [];
|
|
2873
|
+
if (label.hidden === "redundant") {
|
|
2874
|
+
if (label.printedIn !== void 0) {
|
|
2875
|
+
let host = geo.labels.find((other) => other.id === label.printedIn);
|
|
2876
|
+
if (holdsToken(drawn.get(`label:${label.printedIn}`), label.text) || host?.text && holdsToken(drawn.get(`label:${label.printedIn}`), host.text)) return [];
|
|
2877
|
+
} else if (minimal || !["segment", "total"].includes(label.kind) || geo.labels.some((other) => other !== label && other.hidden === void 0 && holdsToken(other.text, label.text) && (label.owner.categoryId !== void 0 ? other.owner.categoryId === label.owner.categoryId : other.owner.seriesId === label.owner.seriesId))) return [];
|
|
2878
|
+
}
|
|
2879
|
+
let bridgeValue = ["waterfall", "pvm", "variance"].includes(geo.type ?? "") && BRIDGE_OWED_KINDS.has(label.kind), extraValue = label.kind === "tick" && label.owner.seriesId !== void 0 || label.kind === "segment" && ["funnel", "mekko"].includes(geo.type ?? "") || label.kind === "total" || label.kind === "category" && geo.type === "choropleth", densityValue = label.hidden === "density" && ["point", "grandTotal"].includes(label.kind);
|
|
2880
|
+
if (!OWED_KINDS.has(label.kind) && !bridgeValue && !extraValue && !densityValue && !label.owed && pins[label.id] === void 0) return [];
|
|
2881
|
+
if (label.noteText) return [[label.id, label.noteText]];
|
|
2882
|
+
if (label.kind === "annotation") {
|
|
2883
|
+
let hit = (Array.isArray(annotations) ? annotations : []).find((item, i) => item !== null && typeof item == "object" && defaultAnnotationId(item, i) === label.owner.annotationId), a = hit && (typeof hit.label == "string" ? hit.label : typeof hit.text == "string" ? void 0 : hit.id), same = typeof a == "string" && label.text.toLowerCase().includes(a.toLowerCase());
|
|
2884
|
+
return [[label.id, a && !same ? `${a} ${label.text}` : same && label.text.toLowerCase() === a.toLowerCase() ? a : label.text]];
|
|
2885
|
+
}
|
|
2886
|
+
if (label.kind === "item") {
|
|
2887
|
+
let row = nameIn(rows, label.owner.categoryId);
|
|
2888
|
+
return [[label.id, `${label.text}${row ? ` (${row})` : ""}`]];
|
|
2889
|
+
}
|
|
2890
|
+
if ((bridgeValue || extraValue || label.kind === "grandTotal") && label.kind !== "category") {
|
|
2891
|
+
let name = nameIn(categories, label.owner.categoryId) ?? nameIn(items, label.owner.categoryId) ?? nameIn(rows, label.owner.categoryId) ?? geo.labels.find((candidate) => candidate.kind === "category" && candidate.owner.categoryId === label.owner.categoryId)?.text ?? label.owner.categoryId, itemSegments = Array.isArray(items) ? items.flatMap((item) => item?.segments ?? []) : [], segment = nameBeforeValue(nameIn(series, label.owner.seriesId) ?? nameIn(cases, label.owner.seriesId) ?? nameIn(itemSegments, label.owner.segmentId) ?? label.owner.segmentId, label.text);
|
|
2892
|
+
return [[label.id, `${segment && !label.text.includes(segment) ? `${segment} ` : ""}${label.text}${name ? ` (${name})` : ""}`]];
|
|
2893
|
+
}
|
|
2894
|
+
if (label.kind !== "point") return [[label.id, label.text]];
|
|
2895
|
+
let s = nameBeforeValue(nameIn(series, label.owner.seriesId) ?? legendName(label.owner.seriesId), label.text), c = nameIn(categories, label.owner.categoryId) ?? nameIn(items, label.owner.categoryId) ?? nameIn(rows, label.owner.categoryId) ?? (densityValue ? geo.labels.find((candidate) => candidate.kind === "category" && candidate.owner.categoryId === label.owner.categoryId)?.text : void 0);
|
|
2896
|
+
return [[label.id, `${s && !label.text.includes(s) ? `${s} ` : ""}${label.text}${c ? ` (${c})` : ""}`]];
|
|
2897
|
+
}), byData = dataOrder(data, geo.labels);
|
|
2898
|
+
return new Map(entries.sort(([a], [b]) => byData(a, b)));
|
|
2899
|
+
}
|
|
2900
|
+
var LEFT_OUT_OF_NOTE = /* @__PURE__ */ Symbol();
|
|
2901
|
+
function panelNoteTexts(geo, data, options, annotations) {
|
|
2902
|
+
let minimal = options?.labelDensity === "minimal";
|
|
2903
|
+
if (!geo.labels.some((label) => label.hidden !== void 0 && (minimal || !label.noteText))) return { texts: /* @__PURE__ */ new Map(), leftOut: /* @__PURE__ */ new Set() };
|
|
2904
|
+
let pins = typeof options?.labelPlacements == "object" && options.labelPlacements !== null ? options.labelPlacements : {}, notes = annotations ?? options?.annotations, named = owedHiddenLabels({ ...geo, [DEFER_DENSITY_NOTES]: !1 }, data, pins, notes), leftOut = /* @__PURE__ */ new Set();
|
|
2905
|
+
if (minimal) {
|
|
2906
|
+
let kept = owedHiddenLabels({ ...geo, [DEFER_DENSITY_NOTES]: !1 }, data, pins, notes, !0);
|
|
2907
|
+
for (let id of named.keys()) kept.has(id) || (leftOut.add(id), named.delete(id));
|
|
2908
|
+
}
|
|
2909
|
+
for (let label of geo.labels) label.noteText && named.delete(label.id);
|
|
2910
|
+
return { texts: named, leftOut };
|
|
2911
|
+
}
|
|
2912
|
+
function nameBeforeValue(name, value) {
|
|
2913
|
+
if (name === void 0) return;
|
|
2914
|
+
let match = /^(.*?\S)\s*(?:,\s*([^\s,()]{1,4})|\(\s*([^\s()]{1,4})\s*\)|\s([%$€£¥]))$/u.exec(name), unit = match?.[2] ?? match?.[3] ?? match?.[4];
|
|
2915
|
+
if (!match || unit === void 0 || /^\d/.test(unit)) return name;
|
|
2916
|
+
let symbols = value.replace(/[\d\s.,'’+\-−–]/gu, "");
|
|
2917
|
+
return value.includes(unit) || symbols === unit ? match[1] : name;
|
|
2918
|
+
}
|
|
2919
|
+
function dataOrder(data, labels, annotations) {
|
|
2920
|
+
let { series: authoredSeries, groups, categories: authoredCategories, rows, items } = data ?? {}, series = Array.isArray(authoredSeries) ? authoredSeries : groups, categories = Array.isArray(authoredCategories) ? authoredCategories : Array.isArray(rows) ? rows : items, rankIn = (list) => {
|
|
2921
|
+
let rank = /* @__PURE__ */ new Map();
|
|
2922
|
+
return Array.isArray(list) && list.forEach((item, i) => {
|
|
2923
|
+
let id = typeof item == "object" && item !== null ? item.id : item;
|
|
2924
|
+
rank.has(id) || rank.set(id, i);
|
|
2925
|
+
}), rank;
|
|
2926
|
+
}, seriesRank = rankIn(series), categoryRank = rankIn(categories), annotationRank = /* @__PURE__ */ new Map();
|
|
2927
|
+
Array.isArray(annotations) && annotations.forEach((item, i) => {
|
|
2928
|
+
item !== null && typeof item == "object" && annotationRank.set(defaultAnnotationId(item, i), i);
|
|
2929
|
+
});
|
|
2930
|
+
let owners = new Map(labels.map((label) => [label.id, label.owner])), at = (id, rank, key) => rank.get(owners.get(id)?.[key]) ?? -1;
|
|
2931
|
+
return (a, b) => at(a, seriesRank, "seriesId") - at(b, seriesRank, "seriesId") || at(a, categoryRank, "categoryId") - at(b, categoryRank, "categoryId") || at(a, annotationRank, "annotationId") - at(b, annotationRank, "annotationId");
|
|
2932
|
+
}
|
|
2933
|
+
function withDensityNotes(data, options, layout) {
|
|
2934
|
+
let first = layout({ ...options, [VALUE_SELECTION]: !0 });
|
|
2935
|
+
if (first.refused || !first[DEFER_DENSITY_NOTES] || options[VALUE_SELECTION] || options.labelDensity === "minimal" || panelTypeClass(options) !== void 0) return first;
|
|
2936
|
+
let labels = first.labels.map((label) => ({ ...label, noted: void 0 })), owed = owedHiddenLabels({ ...first, labels, [DEFER_DENSITY_NOTES]: !1 }, data, options.labelPlacements, options.annotations), density = new Map(labels.flatMap((label) => label.hidden === "density" && ["point", "grandTotal"].includes(label.kind) && owed.has(label.id) ? [[label.id, owed.get(label.id)]] : []));
|
|
2937
|
+
if (density.size === 0) return first;
|
|
2938
|
+
for (let [id, text] of owed) density.set(id, text);
|
|
2939
|
+
let fixed = resolveTargetSize(options.target ?? "report", options.size).fixed.height, visible = new Set(first.labels.filter((label) => !label.hidden && ["point", "grandTotal"].includes(label.kind)).map((label) => label.id)), misfit = (run2) => run2.refused ? fixed : run2.labels.some((label) => visible.has(label.id) && label.hidden), run = (from2, values = density) => {
|
|
2940
|
+
let planned2 = withHiddenLabelNote(withLocaleStrings(from2), values, { data, labels: first.labels, annotations: options.annotations });
|
|
2941
|
+
return { planned: planned2, next: layout({ ...planned2, ...first[DENSITY_LAYOUT_OPTIONS] ?? {}, [DENSITY_VALUES]: new Set(values.keys()) }) };
|
|
2942
|
+
}, from = options, { planned, next } = run(from);
|
|
2943
|
+
if (fixed && options.notes?.maxListed === void 0 && misfit(next)) {
|
|
2944
|
+
let countedFrom = { ...options, notes: { ...options.notes, maxListed: 0 } }, counted = run(countedFrom);
|
|
2945
|
+
counted.next.refused || ({ planned, next, from } = { ...counted, from: countedFrom });
|
|
2946
|
+
}
|
|
2947
|
+
for (let pass = 0; fixed && !next.refused && pass < 3; pass++) {
|
|
2948
|
+
let shown = next, owedNext = owedHiddenLabels(
|
|
2949
|
+
{ ...shown, labels: shown.labels.map((label) => ({ ...label, noted: void 0 })), [DEFER_DENSITY_NOTES]: !1 },
|
|
2950
|
+
data,
|
|
2951
|
+
options.labelPlacements,
|
|
2952
|
+
options.annotations
|
|
2953
|
+
), more = shown.labels.filter((label) => label.hidden === "density" && ["point", "grandTotal"].includes(label.kind) && !density.has(label.id) && owedNext.has(label.id));
|
|
2954
|
+
if (more.length === 0) break;
|
|
2955
|
+
let wider = new Map(density);
|
|
2956
|
+
for (let label of more) wider.set(label.id, owedNext.get(label.id));
|
|
2957
|
+
let again = run(from, wider);
|
|
2958
|
+
if (again.next.refused) break;
|
|
2959
|
+
for (let label of more) density.set(label.id, wider.get(label.id));
|
|
2960
|
+
({ planned, next } = again);
|
|
2961
|
+
}
|
|
2962
|
+
if (!fixed && misfit(next))
|
|
2963
|
+
return densityNoteInList(first, planned, new Set(density.keys()));
|
|
2964
|
+
if (next.refused)
|
|
2965
|
+
fixed && next.warnings[0]?.code === "size-below-floor" && UNVERIFIED_DENSITY_REFUSALS.add(next.warnings[0]);
|
|
2966
|
+
else {
|
|
2967
|
+
for (let label of next.labels) density.has(label.id) && (label.noted = void 0, label.noteCounted = void 0);
|
|
2968
|
+
markNotedLabels(next, new Set(density.keys()), planned);
|
|
2969
|
+
}
|
|
2970
|
+
return next;
|
|
2971
|
+
}
|
|
2972
|
+
function densityNoteInList(first, planned, ids) {
|
|
2973
|
+
let line = planned[NOTE_LINE], heading = planned.strings?.hiddenLabels ?? HIDDEN_LABEL_LEAD, prior = (text) => text.replace(/\s/g, "").startsWith(`${heading}:`.replace(/\s/g, "")), priorIds = new Set(first.scene.flatMap((node) => node.t === "text" && first.frame.footnoteNodeIds?.includes(node.id) && prior(node.lines.join(" ")) ? [node.id] : []));
|
|
2974
|
+
first.scene = first.scene.filter((node) => !priorIds.has(node.id)), first.frame.footnoteNodeIds = first.frame.footnoteNodeIds?.filter((id) => !priorIds.has(id)), first.frame.notes = [...(first.frame.notes ?? []).filter((text) => !prior(text)), line];
|
|
2975
|
+
let entries = (first.frame.noteList ?? []).filter((entry) => !prior(entry.text)), at = entries.findIndex((entry) => entry.kind !== "note");
|
|
2976
|
+
entries.splice(at < 0 ? entries.length : at, 0, keepNoteMeta({ n: 0, kind: "disclosure", text: line, inFrame: !1 }, engineNoteMeta(line))), first.frame.noteList = entries.map((entry, i) => copyNote(entry, { n: i + 1 })), first.a11y.desc += ` ${line}`, first.warnings.push({ code: "compact-notes-omitted", severity: "info", message: `the frame leaves this note in the notes list and accessible description: ${line}` });
|
|
2977
|
+
for (let label of first.labels) ids.has(label.id) && (label.noted = void 0, label.noteCounted = void 0);
|
|
2978
|
+
return markNotedLabels(first, ids, planned), first;
|
|
2979
|
+
}
|
|
2980
|
+
var NOTED_LABELS = /* @__PURE__ */ Symbol("notedLabels"), NOTE_ITEMS = /* @__PURE__ */ Symbol("noteItems"), NOTE_LINE = /* @__PURE__ */ Symbol("noteLine"), NOTE_CONTEXT = /* @__PURE__ */ Symbol("noteContext"), NOTE_COUNTED = /* @__PURE__ */ Symbol("noteCounted");
|
|
2981
|
+
function leadsNote(item) {
|
|
2982
|
+
let label = item.label;
|
|
2983
|
+
return label !== void 0 && (["valueLine", "annotation", "series"].includes(label.kind) || label.kind === "point" && label.priority >= PRIORITY.endpoint);
|
|
2984
|
+
}
|
|
2985
|
+
function withHiddenLabelNote(options, noted, context) {
|
|
2986
|
+
let own = options, byId = new Map(context.labels.map((label) => [label.id, label])), items = new Map(own[NOTE_ITEMS]), picked = (label) => label && { id: label.id, owner: label.owner, kind: label.kind, priority: label.priority };
|
|
2987
|
+
for (let [id, text] of noted) items.set(id, { text, label: picked(byId.get(id)) ?? items.get(id)?.label });
|
|
2988
|
+
let kindCounts = labelKindCounts(context.labels, own[NOTE_CONTEXT]?.kindCounts), plan = planNote(items, { ...context, kindCounts }, own), others = authoredNotes(own).filter((note) => note !== own[NOTE_LINE]);
|
|
2989
|
+
return {
|
|
2990
|
+
...withAuthoredFootnotes(own, [...others, ...plan.line ? [plan.line] : []], own.authoredFootnotes ?? authoredNotes(own)),
|
|
2991
|
+
[NOTED_LABELS]: new Set(items.keys()),
|
|
2992
|
+
[NOTE_ITEMS]: items,
|
|
2993
|
+
[NOTE_CONTEXT]: { data: context.data, annotations: context.annotations, kindCounts },
|
|
2994
|
+
[NOTE_LINE]: plan.line,
|
|
2995
|
+
[NOTE_COUNTED]: plan.counted
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
function hiddenNoteLine(options) {
|
|
2999
|
+
let own = options, line = own[NOTE_LINE];
|
|
3000
|
+
return !line || !own[NOTE_TO_A11Y] ? line || void 0 : own[NOTE_ITEMS] && [...own[NOTE_ITEMS].values()].some((item) => (item.label?.kind === "annotation" || item.label?.kind === "valueLine") && item.label.owner.annotationId !== void 0) ? line : void 0;
|
|
3001
|
+
}
|
|
3002
|
+
var NOTE_TO_A11Y = /* @__PURE__ */ Symbol("noteToA11y");
|
|
3003
|
+
function withNoteInA11y(options) {
|
|
3004
|
+
let marked = { ...options, [NOTE_TO_A11Y]: !0 };
|
|
3005
|
+
return hiddenNoteLine(options) !== void 0 && hiddenNoteLine(marked) === void 0 ? marked : void 0;
|
|
3006
|
+
}
|
|
3007
|
+
function holdsToken(hay, needle) {
|
|
3008
|
+
for (let at = needle ? hay?.indexOf(needle) ?? -1 : -1; hay !== void 0 && at >= 0; at = hay.indexOf(needle, at + 1)) {
|
|
3009
|
+
let after = hay.slice(at + needle.length);
|
|
3010
|
+
if (!/[\p{L}\p{N}.,+\-−]$/u.test(hay.slice(0, at)) && !/^([\p{L}\p{N}]|[.,]\p{N})/u.test(after)) return !0;
|
|
3011
|
+
}
|
|
3012
|
+
return !1;
|
|
3013
|
+
}
|
|
3014
|
+
var COUNTED_KINDS = /* @__PURE__ */ new Set(["point", "segment", "total", "grandTotal"]);
|
|
3015
|
+
function labelKindCounts(labels, prior) {
|
|
3016
|
+
let counts = { ...prior }, own = {};
|
|
3017
|
+
for (let label of labels) own[label.kind] = (own[label.kind] ?? 0) + 1;
|
|
3018
|
+
for (let [kind, n] of Object.entries(own)) counts[kind] = Math.max(counts[kind] ?? 0, n);
|
|
3019
|
+
return counts;
|
|
3020
|
+
}
|
|
3021
|
+
function heldValues(data) {
|
|
3022
|
+
let { series, panels } = data ?? {};
|
|
3023
|
+
return (Array.isArray(panels) ? panels.reduce((n, panel) => n + (heldValues(panel?.data) ?? NaN), 0) : series?.reduce((n, item) => n + (item?.values?.filter((cell) => cell != null && cell.number !== null).length ?? 0), 0)) || void 0;
|
|
3024
|
+
}
|
|
3025
|
+
function planNote(items, context, cap) {
|
|
3026
|
+
let known = [...items.values()].flatMap((item) => item.label ? [item.label] : []), byData = dataOrder(context.data, known, context.annotations), ownerKey2 = (item) => item.label?.owner.annotationId === void 0 && (item.label?.owner.seriesId !== void 0 || item.label?.owner.categoryId !== void 0) ? `${item.label.owner.seriesId ?? ""}|${item.label.owner.categoryId ?? ""}` : void 0, byOwner = /* @__PURE__ */ new Map();
|
|
3027
|
+
for (let item of items.values()) {
|
|
3028
|
+
let key = ownerKey2(item);
|
|
3029
|
+
if (key === void 0) continue;
|
|
3030
|
+
let group = byOwner.get(key);
|
|
3031
|
+
group ? group.push(item) : byOwner.set(key, [item]);
|
|
3032
|
+
}
|
|
3033
|
+
let ranked = [...items].map(([id, item]) => {
|
|
3034
|
+
let key = ownerKey2(item), cover = key === void 0 ? void 0 : byOwner.get(key).find((other) => other !== item && other.label?.kind !== item.label?.kind && other.text.length > item.text.length && holdsToken(other.text, item.text));
|
|
3035
|
+
return [id, cover ? { ...item, text: cover.text, label: cover.label } : item];
|
|
3036
|
+
}).sort(([a, x], [b, y]) => Number(leadsNote(y)) - Number(leadsNote(x)) || byData(a, b)), described = new Set(ranked.filter(([, item]) => item.label?.kind === "diagramSecondary").map(([, item]) => item.text)), texts = [...new Set(ranked.map(([, item]) => item.text))], listed = new Set(texts.filter((text) => described.has(text))), countOnly = cap.notes?.maxListed === 0, values = ranked.filter(([, item]) => !leadsNote(item) && !described.has(item.text)), valueKinds = new Set(values.map(([, item]) => item.label?.kind)), countable = context.kindCounts !== void 0 && ![...valueKinds].some((kind) => kind === void 0 || !COUNTED_KINDS.has(kind)), held = countable ? heldValues(context.data) : void 0, allValues = countable ? held ?? [...valueKinds].reduce((sum, kind) => sum + (context.kindCounts[kind] ?? 0), 0) : void 0, total = countOnly ? allValues : void 0, countValues = total !== void 0 && total >= new Set(values.map(([, item]) => item.text)).size;
|
|
3037
|
+
if (countValues)
|
|
3038
|
+
for (let [, item] of ranked) leadsNote(item) && listed.add(item.text);
|
|
3039
|
+
else {
|
|
3040
|
+
let limit = noteCap(cap, texts.length - described.size);
|
|
3041
|
+
for (let text of texts) listed.size - described.size < limit && listed.add(text);
|
|
3042
|
+
}
|
|
3043
|
+
let counted = new Set(ranked.filter(([, item]) => !listed.has(item.text)).map(([id]) => id)), rest = texts.length - listed.size, unlabelled = rest + Math.max(0, (held ?? 0) - [...COUNTED_KINDS].reduce((sum, kind) => sum + (context.kindCounts?.[kind] ?? 0), 0)), tail2 = counted.size === 0 ? [] : countValues ? [countedValuesText(unlabelled, total, cap)] : [moreListedText(rest, cap, listed.size === 0)], lead = cap.strings?.hiddenLabels ?? HIDDEN_LABEL_LEAD, line = noteLine(lead, [...texts.filter((text) => listed.has(text)), ...tail2])[0];
|
|
3044
|
+
return line && !countOnly && !countValues && described.size === 0 && cap.notes?.maxListed === void 0 && engineNote(line, "disclosure", void 0, void 0, { lead, items: texts, total: values.length === ranked.length ? allValues : void 0, options: cap }), { line, counted };
|
|
3045
|
+
}
|
|
3046
|
+
function hiddenNoteWith(options, extras) {
|
|
3047
|
+
let own = options, items = new Map(own[NOTE_ITEMS]);
|
|
3048
|
+
for (let { id, text } of extras) items.set(id, { text });
|
|
3049
|
+
let plan = planNote(items, own[NOTE_CONTEXT] ?? { data: void 0 }, own);
|
|
3050
|
+
return { footnotes: authoredNotes(own).filter((note) => note !== own[NOTE_LINE]), line: plan.line ? [plan.line] : [], ids: new Set(items.keys()), counted: plan.counted };
|
|
3051
|
+
}
|
|
3052
|
+
function markNotedLabels(geo, noted, from) {
|
|
3053
|
+
let ids = new Set(geo.frame.footnoteNodeIds ?? []), notes = [
|
|
3054
|
+
...geo.scene.flatMap((node) => node.t === "text" && ids.has(node.id) ? [node.lines.join(" ")] : []),
|
|
3055
|
+
...geo.frame.notes ?? [],
|
|
3056
|
+
...geo.a11y.compactNotes ?? []
|
|
3057
|
+
], heading = from?.strings?.hiddenLabels ?? HIDDEN_LABEL_LEAD, leads = (text) => text.replace(/\s+/g, "").includes(`${heading}:`.replace(/\s+/g, "")), destination = notes.find(leads);
|
|
3058
|
+
if (!destination) return;
|
|
3059
|
+
let own = from instanceof Set ? void 0 : from, list = own?.[NOTE_LINE] ? engineNoteMeta(own[NOTE_LINE])?.list : void 0, named = list && own?.[NOTE_ITEMS] ? namedInDrawnNote(list, destination) : void 0, listed = named === void 0 ? void 0 : new Set(list.items.slice(0, named)), counted = from instanceof Set ? from : listed ? new Set([...own[NOTE_ITEMS]].filter(([, item]) => !listed.has(item.text)).map(([id]) => id)) : own?.[NOTE_COUNTED], gone = /* @__PURE__ */ new Set();
|
|
3060
|
+
for (let label of geo.labels) {
|
|
3061
|
+
if (!noted.has(label.id) || label.noted) continue;
|
|
3062
|
+
if (!label.hidden) {
|
|
3063
|
+
label.hidden = "note";
|
|
3064
|
+
for (let id of [`label:${label.id}`, `label:${label.id}:body`, `leader:${label.id}`, `swatch:${label.id}`]) gone.add(id);
|
|
3065
|
+
}
|
|
3066
|
+
label.noted = !0, label.noteText ??= own?.[NOTE_ITEMS]?.get(label.id)?.text, counted?.has(label.id) && (label.noteCounted = !0);
|
|
3067
|
+
let node = geo.scene.find((node2) => node2.t === "text" && ids.has(node2.id) && leads(node2.lines.join(" "))), note = geo.frame.noteList?.find((note2) => leads(note2.text));
|
|
3068
|
+
label.noteLocation = chartString2(from, node && note ? counted?.has(label.id) ? "countedInNote" : "listedInNote" : counted?.has(label.id) ? "countedInNotes" : "listedInNotes", { n: note?.n ?? 1 });
|
|
3069
|
+
}
|
|
3070
|
+
gone.size > 0 && (geo.scene = geo.scene.filter((node) => !gone.has(node.id)));
|
|
3071
|
+
}
|
|
3072
|
+
function unitMissing(options, geo) {
|
|
3073
|
+
let unit = typeof options?.unit == "string" ? options.unit.trim() : "";
|
|
3074
|
+
if (!unit || options?.unitShown === !0 || geo.warnings.some((w) => w.severity === "error") || geo.type === "variance" && options?.variant === "relative") return !1;
|
|
3075
|
+
let subtitle = resolveSubtitle(options?.subtitle);
|
|
3076
|
+
if (subtitle && subtitleUnitClause(unit, subtitle.measure) === "" || !squeezeUnit(unit)) return !1;
|
|
3077
|
+
let subtitleText = geo.scene.flatMap((node) => node.t === "text" && node.id.startsWith("frame:subtitle") ? node.lines : []).join(" "), carriesUnit = geo.type === "cohort" ? textCarriesCohortUnit : textCarriesUnit;
|
|
3078
|
+
return !carriesUnit(subtitleText, unit) && !geo.scene.some((node) => node.t === "text" && carriesUnit(node.lines.join(" "), unit));
|
|
3079
|
+
}
|
|
3080
|
+
var PERCENT_UNIT = /^(?:%|percent|per\s*cent|pct|percentage)(?!\p{L})/iu;
|
|
3081
|
+
function shareUnitLints(options, geo) {
|
|
3082
|
+
let unit = typeof options?.unit == "string" ? options.unit.trim() : "";
|
|
3083
|
+
if (!unit || PERCENT_UNIT.test(unit) || !["stacked100", "stacked100-area"].includes(options?.variant)) return [];
|
|
3084
|
+
if (geo.warnings.some((w) => w.severity === "error")) return [];
|
|
3085
|
+
let measure = resolveSubtitle(options?.subtitle)?.measure ?? "", subtitleText = geo.scene.flatMap((node) => node.t === "text" && node.id.startsWith("frame:subtitle") ? node.lines : []).join(" ");
|
|
3086
|
+
if (!measure || !textCarriesUnit(subtitleText, unit)) return [];
|
|
3087
|
+
let composed = subtitleUnitClause(unit, measure) !== "", escaped = unit.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\s+/g, "\\s+"), authored = !composed && new RegExp(`(?:\\bin|,|\\()\\s*${escaped}\\s*\\)?\\s*$`, "iu").test(measure);
|
|
3088
|
+
return !composed && !authored ? [] : [{
|
|
3089
|
+
code: "share-unit-conflict",
|
|
3090
|
+
severity: "warn",
|
|
3091
|
+
message: `variant '${options.variant}' plots shares in %, but the subtitle names the unit '${unit}' of the raw values`,
|
|
3092
|
+
suggest: composed ? "remove options.unit, or name the base in the measure (subtitle: { measure: 'Share of generation' })" : `remove the unit clause from the subtitle measure '${measure}', or name the base instead ('Share of generation')`,
|
|
3093
|
+
field: composed ? ["options", "unit"] : ["options", "subtitle"],
|
|
3094
|
+
...composed ? { fix: [{ op: "remove", path: "/options/unit" }] } : {}
|
|
3095
|
+
}];
|
|
3096
|
+
}
|
|
3097
|
+
var UNIT_SIGNS = [
|
|
3098
|
+
[/\b(?:EUR|euros?)\b/gi, "\u20AC"],
|
|
3099
|
+
[/\bUSD\b/gi, "$"],
|
|
3100
|
+
[/\bGBP\b/gi, "\xA3"],
|
|
3101
|
+
[/\bJPY\b/gi, "\xA5"],
|
|
3102
|
+
[/\b(?:percent|pct)\b/gi, "%"]
|
|
3103
|
+
], signedUnit = (text) => squeezeUnit(UNIT_SIGNS.reduce((out, [code, sign]) => out.replace(code, sign), text));
|
|
3104
|
+
function textCarriesUnit(text, unit) {
|
|
3105
|
+
let needle = signedUnit(unit);
|
|
3106
|
+
if (needle === "") return !1;
|
|
3107
|
+
if (needle.replace(/[^\p{L}]/gu, "").length > 2) return signedUnit(text).includes(needle);
|
|
3108
|
+
let between = String.raw`[\d\s.,'’+\-−]*`, pattern = [...needle].map((char) => char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(between);
|
|
3109
|
+
return new RegExp(String.raw`(?<!\p{L})${pattern}(?!\p{L})`, "iu").test(UNIT_SIGNS.reduce((out, [code, sign]) => out.replace(code, sign), text));
|
|
3110
|
+
}
|
|
3111
|
+
function textCarriesCohortUnit(text, unit) {
|
|
3112
|
+
let words2 = /\b(?:percentages?|per\s+cent|prozent)\b/gi;
|
|
3113
|
+
return textCarriesUnit(text.replace(words2, "percent").replace(/×/g, "x"), unit.replace(words2, "percent").replace(/×/g, "x"));
|
|
3114
|
+
}
|
|
3115
|
+
function stringsIn(value) {
|
|
3116
|
+
return typeof value == "string" ? [value] : Array.isArray(value) ? value.flatMap(stringsIn) : value !== null && typeof value == "object" ? Object.values(value).flatMap(stringsIn) : [];
|
|
3117
|
+
}
|
|
3118
|
+
function squeezeUnit(text) {
|
|
3119
|
+
return text.replace(/[\d\s.,'’+\-−]/g, "").toLowerCase();
|
|
3120
|
+
}
|
|
3121
|
+
function subtitleLine(sub) {
|
|
3122
|
+
return [sub.company, sub.measure, sub.period, sub.scenarios?.length ? formatScenarios(sub.scenarios) : void 0].filter(Boolean).join(" \xB7 ");
|
|
3123
|
+
}
|
|
3124
|
+
function measureUnitTail(measure, unit) {
|
|
3125
|
+
let at = measure.lastIndexOf(", ");
|
|
3126
|
+
if (at <= 0) return "";
|
|
3127
|
+
let tail2 = measure.slice(at + 2);
|
|
3128
|
+
return /^(%|in\s|per\s|[$€£¥]|(?:EUR|USD|CHF|GBP|JPY|US\$)(?![\p{L}])|index\b|score\b|share of\b|# )/iu.test(tail2) || unit !== void 0 && unit.trim() !== "" && tail2.trim().toLowerCase() === unit.trim().toLowerCase() ? measure.slice(at + 1) : "";
|
|
3129
|
+
}
|
|
3130
|
+
function measureSubtitle(input, x, y, id, nextId, contentW) {
|
|
3131
|
+
let sub = input.subtitle, font = { family: input.theme.type.family, ...input.theme.type.subtitle }, boldFont = { ...font, weight: emphasisWeight(input.theme) }, trailing = "";
|
|
3132
|
+
frameRendersUnit(input) && (trailing += subtitleUnitClause(input.unit, sub.measure)), sub.period && (trailing += ` \xB7 ${sub.period}`), sub.scenarios && sub.scenarios.length > 0 && (trailing += ` \xB7 ${formatScenarios(sub.scenarios)}`);
|
|
3133
|
+
let segments = [];
|
|
3134
|
+
sub.company && segments.push({ text: `${sub.company} \xB7 `, bold: !1 });
|
|
3135
|
+
let unitTail = measureUnitTail(sub.measure, input.unit), lone = !sub.company && !unitTail && !trailing;
|
|
3136
|
+
segments.push({ text: sub.measure.slice(0, sub.measure.length - unitTail.length), bold: !lone }), (unitTail || trailing) && segments.push({ text: unitTail + trailing, bold: !1 });
|
|
3137
|
+
let lineH = font.size * (font.lineHeight ?? 1.3), runs = segments.map((seg) => ({
|
|
3138
|
+
text: seg.text.replace(/^ /, "\xA0").replace(/ $/, "\xA0"),
|
|
3139
|
+
...seg.bold ? { weight: boldFont.weight } : {}
|
|
3140
|
+
})), width = runsWidth(runs, font, boldFont, input.measure), maxLines = 1 / 0, scenarios = sub.scenarios && sub.scenarios.length > 0 ? formatScenarios(sub.scenarios) : void 0;
|
|
3141
|
+
return width > contentW ? wrapSubtitle(segments, { x, y, id, nextId, contentW, lineH, font, boldFont, measure: input.measure, maxLines, scenarios, period: sub.period }) : { nodes: [{
|
|
3142
|
+
t: "text",
|
|
3143
|
+
id,
|
|
3144
|
+
x,
|
|
3145
|
+
y,
|
|
3146
|
+
lines: [runs.map((run) => run.text).join("")],
|
|
3147
|
+
runs,
|
|
3148
|
+
align: "start",
|
|
3149
|
+
font,
|
|
3150
|
+
ink: { token: "ink" },
|
|
3151
|
+
owner: {},
|
|
3152
|
+
part: "subtitle",
|
|
3153
|
+
typeRole: "subtitle"
|
|
3154
|
+
}], rect: { x, y, w: width, h: lineH } };
|
|
3155
|
+
}
|
|
3156
|
+
function runsWidth(runs, font, boldFont, measure) {
|
|
3157
|
+
return runs.reduce((w, run) => w + measure(run.text, run.weight ? boldFont : font).width, 0) + // measure() counts n−1 tracking gaps WITHIN each run; the renderer
|
|
3158
|
+
// tracks the continuous line, which adds one more gap per run boundary.
|
|
3159
|
+
// The subtitle font ships without tracking today — this keeps the
|
|
3160
|
+
// occupied claim honest the day a theme adds letterSpacing to it.
|
|
3161
|
+
(font.letterSpacing ? font.letterSpacing * (runs.length - 1) : 0);
|
|
3162
|
+
}
|
|
3163
|
+
function runsOf(words2, boldWeight) {
|
|
3164
|
+
let runs = [];
|
|
3165
|
+
return words2.forEach((word, i) => {
|
|
3166
|
+
i > 0 && words2[i - 1].bold === word.bold ? runs[runs.length - 1].text += ` ${word.text}` : runs.push({ text: i > 0 ? `\xA0${word.text}` : word.text, ...word.bold ? { weight: boldWeight } : {} });
|
|
3167
|
+
}), runs;
|
|
3168
|
+
}
|
|
3169
|
+
function balancedLines(text, font, maxWidth, lines, measure) {
|
|
3170
|
+
let filled = filledLines(text, font, maxWidth, lines, measure);
|
|
3171
|
+
if (text.includes(`
|
|
3172
|
+
`) || lines.some((line) => line.endsWith("\u2026")) || lines.join(" ").split(/[^\S\u00a0\u202f]+/).filter(Boolean).join(" ") !== text.split(/[^\S\u00a0\u202f]+/).filter(Boolean).join(" ") || filled.length < 2 || filled.length > 3) return filled;
|
|
3173
|
+
let units = filled.join(" ").split(" ").reduce((out, word) => (out.length > 0 && /^p\.a\.[,;:]?$/i.test(word) ? out[out.length - 1] += ` ${word}` : out.push(word), out), []);
|
|
3174
|
+
if (units.length > 40) return filled;
|
|
3175
|
+
let n = filled.length, best, consider = (cuts) => {
|
|
3176
|
+
let bounds = [0, ...cuts, units.length], parts = bounds.slice(1).map((to, i) => units.slice(bounds[i], to).join(" ")), widths = parts.map((part) => measure(part, font).width);
|
|
3177
|
+
if (widths.some((w) => w > maxWidth) || units.length >= 4 && units.length - bounds[bounds.length - 2] < 2) return;
|
|
3178
|
+
let widest = Math.max(...widths), cost = n === 2 ? widest + 0.25 * Math.max(0, widths[1] - widths[0]) : widths.slice(0, -1).reduce((sum, w) => sum + (widest - w) ** 2, 0);
|
|
3179
|
+
(!best || cost < best.cost - 1e-9) && (best = { cost, lines: parts });
|
|
3180
|
+
};
|
|
3181
|
+
if (n === 2) for (let a = 1; a < units.length; a++) consider([a]);
|
|
3182
|
+
else for (let a = 1; a < units.length - 1; a++) for (let b = a + 1; b < units.length; b++) consider([a, b]);
|
|
3183
|
+
return best?.lines ?? filled;
|
|
3184
|
+
}
|
|
3185
|
+
function filledLines(text, font, maxWidth, lines, measure) {
|
|
3186
|
+
if (text.includes(`
|
|
3187
|
+
`) || lines.some((line) => line.endsWith("\u2026")) || lines.length < 2) return [...lines];
|
|
3188
|
+
let split = (line) => line.split(/[^\S\u00a0\u202f]+/).filter(Boolean), words2 = split(text);
|
|
3189
|
+
if (lines.flatMap(split).join(" ") !== words2.join(" ")) return [...lines];
|
|
3190
|
+
let units = (line) => split(line).reduce((out2, word) => (out2.length > 0 && /^p\.a\.[,;:]?$/i.test(word) ? out2[out2.length - 1] += ` ${word}` : out2.push(word), out2), []), out = lines.map(units);
|
|
3191
|
+
for (let i = 1; i < out.length; i++)
|
|
3192
|
+
if (/^p\.a\.[,;:]?$/i.test(out[i][0] ?? "") && out[i - 1].length > 1) {
|
|
3193
|
+
let rate = out[i - 1].pop();
|
|
3194
|
+
out[i][0] = `${rate} ${out[i][0]}`;
|
|
3195
|
+
}
|
|
3196
|
+
let last = out[out.length - 1], before = out[out.length - 2];
|
|
3197
|
+
if (last.length === 1 && before.length >= 2) {
|
|
3198
|
+
let moved = before[before.length - 1];
|
|
3199
|
+
measure(`${moved} ${last[0]}`, font).width <= maxWidth && (before.pop(), last.unshift(moved));
|
|
3200
|
+
}
|
|
3201
|
+
let joined = out.map((line) => line.join(" "));
|
|
3202
|
+
return joined.every((line) => line.length > 0 && measure(line, font).width <= maxWidth) ? joined : [...lines];
|
|
3203
|
+
}
|
|
3204
|
+
function keepLastLineCompany(broken, words2, widthOf, maxWidth, scenarios, period) {
|
|
3205
|
+
if (broken.length < 2 || words2.filter((word) => word.text !== "\xB7").length < 4) return;
|
|
3206
|
+
let pairWord = scenarios !== void 0 && scenarios.split(" ").length <= 3 ? scenarios : void 0, periodWord = period !== void 0 && period.trim().split(/\s+/).length <= 3 ? period.trim().split(/\s+/).join(" ") : void 0, lone = (line) => {
|
|
3207
|
+
let text = line.filter((word) => word.text !== "\xB7").map((word) => word.text).join(" ");
|
|
3208
|
+
return line.filter((word) => word.text !== "\xB7").length < 2 || text === pairWord || text === periodWord;
|
|
3209
|
+
};
|
|
3210
|
+
if (!lone(broken[broken.length - 1])) return;
|
|
3211
|
+
let start = broken.slice(0, -2).reduce((at, line) => {
|
|
3212
|
+
let next = at + line.length;
|
|
3213
|
+
return words2[next]?.text === "\xB7" ? next + 1 : next;
|
|
3214
|
+
}, 0), pair = words2.slice(start), trim = (line) => {
|
|
3215
|
+
let from = 0, to = line.length;
|
|
3216
|
+
for (; from < to && line[from].text === "\xB7"; ) from++;
|
|
3217
|
+
for (; to > from && line[to - 1].text === "\xB7"; ) to--;
|
|
3218
|
+
return line.slice(from, to);
|
|
3219
|
+
}, boundary = (cut) => pair[cut].text === "\xB7" || pair[cut - 1].text === "\xB7" || pair[cut].bold !== pair[cut - 1].bold, binds = (cut) => /^(in|of|by|vs\.?|per|to|and|or|the|a|an|for|from|at|on|[$€£¥]|US\$|Q[1-4]|H[12])$/i.test(pair[cut - 1].text), tiers = [boundary, (cut) => !binds(cut), () => !0];
|
|
3220
|
+
for (let allowed of tiers)
|
|
3221
|
+
for (let cut = broken[broken.length - 2].length - 1; cut >= 1; cut--) {
|
|
3222
|
+
if (!allowed(cut)) continue;
|
|
3223
|
+
let first = trim(pair.slice(0, cut)), last = trim(pair.slice(cut));
|
|
3224
|
+
if (!(first.length === 0 || lone(last) || widthOf(first) > maxWidth || widthOf(last) > maxWidth)) {
|
|
3225
|
+
broken.splice(broken.length - 2, 2, first, last);
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
function wrapSubtitle(segments, ctx) {
|
|
3231
|
+
let words2 = segments.flatMap((seg) => seg.text.split(" ").filter(Boolean).map((text) => ({ text, bold: seg.bold }))), widthOf = (list) => runsWidth(runsOf(list, ctx.boldFont.weight), ctx.font, ctx.boldFont, ctx.measure), broken = [], rest = words2;
|
|
3232
|
+
for (; rest.length > 0 && broken.length < ctx.maxLines - 1 && widthOf(rest) > ctx.contentW; ) {
|
|
3233
|
+
let split = 1;
|
|
3234
|
+
for (; split < rest.length && widthOf(rest.slice(0, split + 1)) <= ctx.contentW; ) split++;
|
|
3235
|
+
let dot = rest.slice(0, split + 1).map((word) => word.text).lastIndexOf("\xB7");
|
|
3236
|
+
dot > 0 && widthOf(rest.slice(0, dot)) >= ctx.contentW / 2 && (split = dot), broken.push(rest.slice(0, split)), rest = rest.slice(rest[split]?.text === "\xB7" ? split + 1 : split);
|
|
3237
|
+
}
|
|
3238
|
+
rest.length > 0 && broken.push(rest), ctx.maxLines === 1 / 0 && keepLastLineCompany(broken, words2, widthOf, ctx.contentW, ctx.scenarios, ctx.period);
|
|
3239
|
+
let withEllipsis = (list) => [...list.slice(0, -1), { ...list[list.length - 1], text: `${list[list.length - 1].text}\u2026` }], cutLine = (line) => {
|
|
3240
|
+
for (; widthOf(withEllipsis(line)) > ctx.contentW && (line.length > 1 || line[0].text.length > 1); ) {
|
|
3241
|
+
let last = line[line.length - 1], kept = Array.from(last.text).slice(0, -1).join("").trimEnd();
|
|
3242
|
+
line = kept ? [...line.slice(0, -1), { ...last, text: kept }] : line.slice(0, -1);
|
|
3243
|
+
}
|
|
3244
|
+
return withEllipsis(line);
|
|
3245
|
+
}, title = words2.map((word) => word.text).join(" "), lines = broken.map((line) => widthOf(line) > ctx.contentW ? { line: cutLine(line), cut: !0 } : { line, cut: !1 });
|
|
3246
|
+
return { nodes: lines.map(({ line, cut }, index) => {
|
|
3247
|
+
let runs = runsOf(line, ctx.boldFont.weight);
|
|
3248
|
+
return {
|
|
3249
|
+
t: "text",
|
|
3250
|
+
id: index === 0 ? ctx.id : ctx.nextId(),
|
|
3251
|
+
x: ctx.x,
|
|
3252
|
+
y: ctx.y + index * ctx.lineH,
|
|
3253
|
+
lines: [runs.map((run) => run.text).join("")],
|
|
3254
|
+
runs,
|
|
3255
|
+
...cut ? { title } : {},
|
|
3256
|
+
align: "start",
|
|
3257
|
+
font: ctx.font,
|
|
3258
|
+
ink: { token: "ink" },
|
|
3259
|
+
owner: {},
|
|
3260
|
+
part: "subtitle",
|
|
3261
|
+
typeRole: "subtitle"
|
|
3262
|
+
};
|
|
3263
|
+
}), rect: { x: ctx.x, y: ctx.y, w: Math.max(...lines.map(({ line }) => widthOf(line))), h: lines.length * ctx.lineH } };
|
|
3264
|
+
}
|
|
3265
|
+
function keyRowStarts(widths, headings, rowW) {
|
|
3266
|
+
let starts = widths.map(() => !1), x = 0;
|
|
3267
|
+
widths.forEach((w, i) => {
|
|
3268
|
+
i > 0 && x + w > rowW && x > 0 && (starts[i] = !0, x = 0), x += w + ITEM_GAP;
|
|
3269
|
+
});
|
|
3270
|
+
let rows = starts.filter(Boolean).length + 1, lastStart = starts.lastIndexOf(!0);
|
|
3271
|
+
if (rows < 2 || lastStart !== widths.length - 1 || widths.length < 2 * rows || widths.length > 16) return starts;
|
|
3272
|
+
let span = (from, to) => widths.slice(from, to).reduce((sum, w) => sum + w, 0) + ITEM_GAP * (to - from - 1), best, walk = (from, left, cuts, widest) => {
|
|
3273
|
+
if (!(best && widest >= best.widest)) {
|
|
3274
|
+
if (left === 1) {
|
|
3275
|
+
let w = span(from, widths.length);
|
|
3276
|
+
widths.length - from >= 2 && w <= rowW && Math.max(widest, w) < (best?.widest ?? 1 / 0) && (best = { widest: Math.max(widest, w), cuts });
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
for (let to = from + 2; to <= widths.length - 2 * (left - 1); to++) {
|
|
3280
|
+
let w = span(from, to);
|
|
3281
|
+
if (w > rowW) break;
|
|
3282
|
+
headings[to - 1] || walk(to, left - 1, [...cuts, to], Math.max(widest, w));
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
return walk(0, rows, [], 0), best ? widths.map((_, i) => best.cuts.includes(i)) : starts;
|
|
3287
|
+
}
|
|
3288
|
+
var KEY_NOTE_GAP = 8;
|
|
3289
|
+
function solveFrame(input, occupied) {
|
|
3290
|
+
input[CUT_LABEL_NOTES]?.length && (input = { ...input, footnotes: [...input.footnotes ?? [], ...input[CUT_LABEL_NOTES]] });
|
|
3291
|
+
let destination = occupied;
|
|
3292
|
+
input.autoHeight && (occupied = createOccupiedIndex({ x: 0, y: 0, w: input.size.width, h: input.size.height })), input[COLLECT_IDENTITIES]?.([...input.legend?.items ?? [], ...input.eventKey?.legend ?? []]);
|
|
3293
|
+
let { size, margin, theme, measure } = input, tokens = input.cardGaps ? (
|
|
3294
|
+
// The compact card frame's own gaps (see FrameInput.cardGaps).
|
|
3295
|
+
{
|
|
3296
|
+
...spaceTokens(theme, size.width),
|
|
3297
|
+
gapSubtitlePlot: 8,
|
|
3298
|
+
gapAxisFootnote: 8,
|
|
3299
|
+
gapKeyFootnote: 8,
|
|
3300
|
+
gapFootnoteSource: 0,
|
|
3301
|
+
gapLegend: 8
|
|
3302
|
+
}
|
|
3303
|
+
) : spaceTokens(theme, size.width), nodes = [], frame = {}, warnings = [], contentX = margin.left, contentW = size.width - margin.left - margin.right, headerW = size.width - margin.left - Math.min(margin.right, Math.max(0, tokens.margin.right)), topY = margin.top, bottomY = size.height - margin.bottom, seq = 0, nid = (part) => `frame:${part}:${seq++}`, bottomBlocks = [], drawBottomLegend, withFamily = (f) => ({ family: theme.type.family, ...f }), bottomKey = input.legend?.options.position === "bottom" && ((input.legend.items.length ?? 0) > 0 || (input.eventKey?.legend?.length ?? 0) > 0), footGap = bottomKey ? tokens.gapKeyFootnote : tokens.gapAxisFootnote;
|
|
3304
|
+
if (input.title) {
|
|
3305
|
+
let titleFont = theme.type.title, compactSize = input.mode === "compact" ? input.compactTitleSize ?? titleFont.size : titleFont.size, baseFont = withFamily(titleFont), fitOptions = {
|
|
3306
|
+
target: input.target,
|
|
3307
|
+
textScale: input.textScale,
|
|
3308
|
+
typeRole: "title",
|
|
3309
|
+
shrink: { ...baseFont, size: Math.max(targetFloorsPx(input.target ?? DEFAULT_TARGET, input.textScale).title, compactSize) }
|
|
3310
|
+
}, wrapped = fitText(input.title, baseFont, headerW, TITLE_LINES, measure, fitOptions);
|
|
3311
|
+
wrapped.title !== void 0 && (wrapped = fitText(input.title, wrapped.font, headerW, Number.MAX_SAFE_INTEGER, measure, { ...fitOptions, shrink: void 0 }));
|
|
3312
|
+
let font = wrapped.font, lines = wrapped.title === void 0 && wrapped.lines.length >= 2 ? balancedLines(input.title, font, headerW, wrapped.lines, measure) : wrapped.lines;
|
|
3313
|
+
wrapped.title !== void 0 && warnings.push({
|
|
3314
|
+
code: "frame-title-truncated",
|
|
3315
|
+
severity: "warn",
|
|
3316
|
+
message: `the title does not fit on ${TITLE_LINES} lines at the ${headerW}px content width and was cut`,
|
|
3317
|
+
suggest: "Shorten the title, or draw the chart wider."
|
|
3318
|
+
});
|
|
3319
|
+
let lineH = font.size * (font.lineHeight ?? 1.25), id = nid("title");
|
|
3320
|
+
nodes.push({
|
|
3321
|
+
t: "text",
|
|
3322
|
+
id,
|
|
3323
|
+
x: contentX,
|
|
3324
|
+
y: topY,
|
|
3325
|
+
lines,
|
|
3326
|
+
// A cut title keeps its full text for the reader.
|
|
3327
|
+
...wrapped.title !== void 0 ? { title: wrapped.title } : {},
|
|
3328
|
+
align: "start",
|
|
3329
|
+
font,
|
|
3330
|
+
ink: { token: "ink" },
|
|
3331
|
+
owner: {},
|
|
3332
|
+
part: "title",
|
|
3333
|
+
typeRole: "title"
|
|
3334
|
+
});
|
|
3335
|
+
let h = lines.length * lineH;
|
|
3336
|
+
occupied.claim({ x: contentX, y: topY, w: headerW, h }, "frame", {}), frame.titleNodeId = id, frame.titleLines = lines.length, topY += h + tokens.gapTitleSubtitle;
|
|
3337
|
+
}
|
|
3338
|
+
if (input.subtitle) {
|
|
3339
|
+
let subtitle = measureSubtitle(input, contentX, topY, nid("subtitle"), () => nid("subtitle"), headerW);
|
|
3340
|
+
nodes.push(...subtitle.nodes), occupied.claim(subtitle.rect, "frame", {}), frame.subtitleNodeId = subtitle.nodes[0].id, topY += subtitle.rect.h + tokens.gapSubtitlePlot;
|
|
3341
|
+
} else input.title && (topY += input.cardGaps ? 8 : tokens.gapSubtitlePlot - tokens.gapTitleSubtitle);
|
|
3342
|
+
!input.cardGaps && (input.subtitle || input.title) && theme.space.gap?.subtitlePlot === void 0 && size.width < WIDE_CANVAS_MIN_WIDTH && recordFreedChrome(frame, "header-gap", REFERENCE_SUBTITLE_PLOT_GAP - tokens.gapSubtitlePlot);
|
|
3343
|
+
let footFont = withFamily(footerType(theme.type.footnote, input.target, input.textScale)), liveFooterH = 0, footLineH = footFont.size * (footFont.lineHeight ?? 1.3), footInset = Math.max(0, Math.min(input.footerInset ?? 0, (contentW - 1) / 2)), footX = contentX + footInset, footW = contentW - 2 * footInset, fullStatic = staticFrame.pinned, placement = fullStatic ? "frame" : input.notes?.placement ?? defaultNotePlacement(input.target), hitRoom = (y) => placement === "info" ? Math.min(y, size.height - NOTE_HIT_PX) : y, budget = fullStatic ? 1 / 0 : input.notes?.maxLines ?? defaultNoteLines(input.target, size.width), shown = new Set(input.notes?.show ?? ["note"]), pointerOn = !fullStatic && !input.footnotesOff && input.notes?.pointer !== !1, entries = [];
|
|
3344
|
+
{
|
|
3345
|
+
let notes = input.footnotes ?? [], numbered = input.numberedFootnotes ?? notes, unreferencedNotes = new Set(input.unreferencedNotes ?? []), next = 0, referenced = !1, unmarked = [];
|
|
3346
|
+
for (let f of notes) {
|
|
3347
|
+
let numberedHere = next < numbered.length && numbered[next] === f && !f.startsWith(`${HIDDEN_LABEL_LEAD}:`), numberedDisclosure = numberedHere && (input.numberedDisclosures?.includes(next + 1) ?? !1), marker = numberedHere && !unreferencedNotes.has(next + 1) ? `${footnoteMark(next + 1)} ` : "";
|
|
3348
|
+
marker && (referenced = !0), numberedHere && marker === "" && unmarked.push(next + 1), numberedHere && (next += 1);
|
|
3349
|
+
let meta = numberedHere ? void 0 : engineNoteMeta(f);
|
|
3350
|
+
if (fullStatic && meta?.list && (staticFrame.countable = !0), meta?.list) {
|
|
3351
|
+
let fitted = fittedNote(meta.list, (text) => wrapFootnote(text, footFont, footW, measure).length <= 2);
|
|
3352
|
+
f = meta.short ? engineNote(f, "disclosure", fitted, meta.values, meta.list) : engineNote(fitted, "disclosure", void 0, meta.values, meta.list);
|
|
3353
|
+
}
|
|
3354
|
+
let kind = numberedDisclosure ? "disclosure" : numberedHere ? "note" : meta?.kind ?? "method", fittedShort = engineNoteMeta(f)?.short ?? meta?.short, short = fittedShort && (kind !== "disclosure" || input.notes?.maxListed !== void 0 || measure(fittedShort, footFont).width < measure(f, footFont).width) ? fittedShort : void 0, storedMeta = meta ? { ...meta, ...engineNoteMeta(f), ...meta.ranks ? { ranks: !0 } : {} } : void 0;
|
|
3355
|
+
entries.push(keepNoteMeta({ kind, text: f, ...short ? { short } : {}, drawn: `${marker}${kind === "disclosure" || kind === "method" && !fullStatic ? short ?? f : f}`, ...marker ? { ref: next } : {}, ...meta?.ranks ? { ranks: !0 } : {} }, storedMeta));
|
|
3356
|
+
}
|
|
3357
|
+
!input.footnotesOff && unmarked.length > 0 && referenced && warnings.push({
|
|
3358
|
+
code: "footnote-unreferenced",
|
|
3359
|
+
severity: "info",
|
|
3360
|
+
message: `${unmarked.length === 1 ? "note" : "notes"} ${unmarked.join(", ")} ${unmarked.length === 1 ? "has" : "have"} no category or cell pointing at ${unmarked.length === 1 ? "it" : "them"} (footnote: n), so ${unmarked.length === 1 ? "it prints" : "they print"} without a number`,
|
|
3361
|
+
suggest: "set footnote: n on the category or cell the note explains, or keep it as a note about the whole exhibit"
|
|
3362
|
+
});
|
|
3363
|
+
}
|
|
3364
|
+
let rank = { note: 0, disclosure: 1, method: 2, source: 3, credit: 4 };
|
|
3365
|
+
entries.sort((a, b) => rank[a.kind] - rank[b.kind]);
|
|
3366
|
+
let credit = input.credit, creditInFrame = credit !== void 0 && (credit.required || fullStatic), sourceText = input.source ? sourceLine(input.source, input.strings?.source ?? localeStrings2().source) : void 0, sourceOff = sourceText !== void 0 && !fullStatic && input[COMPACT_SOURCE_LINES] === 0;
|
|
3367
|
+
sourceOff && (frame.source = input.source, warnings.push({ code: "footnotes-off", severity: "info", message: `compact frame has no room for the source line: ${sourceText}` }));
|
|
3368
|
+
let pointed = new Set(input.pointedNotes ?? []), kept = entries.filter((entry) => entry.kind === "disclosure" ? shown.has("disclosure") || entry.ranks === !0 && shown.has("ranks") : !input.footnotesOff && pointed.has(entry.text)), candidates = input.footnotesOff || placement === "list" ? [] : entries.filter((entry) => !kept.includes(entry) && shown.has(entry.kind)), infoPanel = staticFrame.live && placement === "info", listed = (k2) => infoPanel ? entries.filter((entry) => !kept.includes(entry) && !candidates.slice(0, k2).includes(entry)).length + (credit && !creditInFrame ? 1 : 0) : entries.filter((entry) => shown.has(entry.kind) && !kept.includes(entry)).length - k2 + (credit && !creditInFrame ? 1 : 0), sourcePara = (k2) => {
|
|
3369
|
+
let hidden = listed(k2), pointer = pointerOn && hidden > 0 ? notesPointer(hidden, input.strings) : void 0, source = sourceOff ? void 0 : sourceText;
|
|
3370
|
+
return source === void 0 ? pointer : pointer === void 0 ? source : `${source}${/[.!?]$/.test(source) ? "" : "."} ${pointer}`;
|
|
3371
|
+
}, sourceFit = (text) => !fullStatic && input[COMPACT_SOURCE_LINES] === 1 ? fitText(text, footFont, footW, 1, measure) : void 0, sourceLines = (text) => sourceFit(text)?.lines ?? wrapFootnote(text, footFont, footW, measure), noteLines = candidates.map((entry) => wrapFootnote(entry.drawn, footFont, footW, measure)), k = candidates.length;
|
|
3372
|
+
for (; k > 0; k--) {
|
|
3373
|
+
let para = sourcePara(k);
|
|
3374
|
+
if (noteLines.slice(0, k).reduce((sum, lines) => sum + lines.length, 0) + (para ? sourceLines(para).length : 0) <= budget) break;
|
|
3375
|
+
}
|
|
3376
|
+
let visible = /* @__PURE__ */ new Set([...candidates.slice(0, k), ...kept]), sourceBlock = sourcePara(k);
|
|
3377
|
+
if (input.footnotesOff) {
|
|
3378
|
+
let leftOff = entries.filter((entry) => !kept.includes(entry)).map((entry) => entry.text);
|
|
3379
|
+
leftOff.length && warnings.push({ code: "footnotes-off", severity: "info", message: `footnotes: false left these notes off: ${leftOff.join(" | ")}` });
|
|
3380
|
+
}
|
|
3381
|
+
let unprinted = entries.filter((entry) => !visible.has(entry)).map((entry) => entry.text);
|
|
3382
|
+
unprinted.length > 0 && (frame.notes = unprinted);
|
|
3383
|
+
let noteList = [
|
|
3384
|
+
...entries.map((entry) => keepNoteMeta({ kind: entry.kind, text: entry.text, ...entry.short ? { short: entry.short } : {}, inFrame: visible.has(entry), ...entry.ref ? { ref: entry.ref } : {} }, engineNoteMeta(entry))),
|
|
3385
|
+
...input.source ? [{ kind: "source", text: input.source, inFrame: !sourceOff }] : [],
|
|
3386
|
+
...credit ? [{ kind: "credit", text: credit.text, short: credit.short, ...credit.links.length ? { links: credit.links.map((link) => ({ ...link })) } : {}, inFrame: creditInFrame }] : []
|
|
3387
|
+
].map((entry, i) => keepNoteMeta({ n: i + 1, ...entry }, engineNoteMeta(entry)));
|
|
3388
|
+
noteList.length > 0 && (frame.noteList = noteList), frame.notePlacement = placement;
|
|
3389
|
+
let footParts = [
|
|
3390
|
+
...entries.filter((entry) => visible.has(entry)).map((entry) => {
|
|
3391
|
+
let at = candidates.indexOf(entry);
|
|
3392
|
+
return { text: entry.drawn, kind: "footnote", lines: at >= 0 ? noteLines[at] : wrapFootnote(entry.drawn, footFont, footW, measure) };
|
|
3393
|
+
}),
|
|
3394
|
+
...sourceBlock ? [{ text: sourceBlock, kind: "source" }] : [],
|
|
3395
|
+
...credit && creditInFrame ? [{ text: `${chartString2(input, "mapCredit")}: ${credit.text}`, kind: "credit" }] : []
|
|
3396
|
+
], footLines = 0, omitted = Array.from({ length: input[COMPACT_OMITTED_NOTES] ?? 0 }, () => ({ n: 0, kind: "note", text: "", inFrame: !1 }));
|
|
3397
|
+
if (liveFooterH = staticFrame.live && !fullStatic ? Math.max(0, htmlFooterHeight(
|
|
3398
|
+
input,
|
|
3399
|
+
footerParts([...noteList, ...omitted], placement, input[LIVE_NOTE_SHOW] ?? input.notes?.show, pointerOn),
|
|
3400
|
+
sourceText,
|
|
3401
|
+
footFont,
|
|
3402
|
+
contentW,
|
|
3403
|
+
footLineH,
|
|
3404
|
+
measure
|
|
3405
|
+
) - (placement === "info" ? margin.bottom : 0)) : 0, footParts.length > 0 || liveFooterH > 0) {
|
|
3406
|
+
frame.footnoteNodeIds = [];
|
|
3407
|
+
for (let i = footParts.length - 1; i >= 0; i--) {
|
|
3408
|
+
let p = footParts[i], fitted = p.kind === "source" ? sourceFit(p.text) : void 0, lines = p.lines ?? (p.kind === "source" ? sourceLines(p.text) : wrapFootnote(p.text, footFont, footW, measure));
|
|
3409
|
+
bottomY -= footLineH * lines.length, footLines += lines.length;
|
|
3410
|
+
let id = nid(p.kind);
|
|
3411
|
+
nodes.push({
|
|
3412
|
+
t: "text",
|
|
3413
|
+
id,
|
|
3414
|
+
x: footX,
|
|
3415
|
+
y: bottomY,
|
|
3416
|
+
lines,
|
|
3417
|
+
...fitted?.title ? { title: fitted.title } : {},
|
|
3418
|
+
align: "start",
|
|
3419
|
+
font: footFont,
|
|
3420
|
+
ink: { token: p.kind === "footnote" ? input.footnoteInk ?? "inkMuted" : "inkMuted" },
|
|
3421
|
+
owner: {},
|
|
3422
|
+
part: p.kind,
|
|
3423
|
+
typeRole: "footnote"
|
|
3424
|
+
}), occupied.claim({ x: footX, y: bottomY, w: footW, h: footLineH * lines.length }, "frame", {}), input.autoHeight && bottomBlocks.push({
|
|
3425
|
+
node: nodes[nodes.length - 1],
|
|
3426
|
+
height: footLineH * lines.length,
|
|
3427
|
+
gap: i > 0 && (p.kind === "source" || p.kind === "credit" && footParts[i - 1].kind === "footnote") ? tokens.gapFootnoteSource : 0
|
|
3428
|
+
}), p.kind === "credit" ? (frame.creditNodeId = id, i > 0 && footParts[i - 1].kind === "footnote" && (bottomY -= tokens.gapFootnoteSource)) : p.kind === "source" ? (frame.sourceNodeId = id, i > 0 && (bottomY -= tokens.gapFootnoteSource)) : frame.footnoteNodeIds.unshift(id);
|
|
3429
|
+
}
|
|
3430
|
+
liveFooterH > size.height - margin.bottom - bottomY + 0.01 && (liveFooterExtra.set(frame, liveFooterH - (size.height - margin.bottom - bottomY) + (footParts.length === 0 ? input.eventKey ? KEY_NOTE_GAP : footGap : 0)), bottomY = size.height - margin.bottom - liveFooterH), bottomY = hitRoom(bottomY), frame.footerRect = { x: contentX, y: bottomY, w: contentW, h: size.height - margin.bottom - bottomY }, bottomY -= input.eventKey ? KEY_NOTE_GAP : footGap, recordFreedChrome(frame, "footer-text", footLines * (withFamily(theme.type.footnote).size - footFont.size) * (footFont.lineHeight ?? 1.3)), !input.cardGaps && !input.eventKey && bottomKey && theme.space.gap?.axisFootnote === void 0 && size.width < WIDE_CANVAS_MIN_WIDTH && recordFreedChrome(frame, "key-footer-gap", REFERENCE_FOOTER_GAP - tokens.gapKeyFootnote);
|
|
3431
|
+
}
|
|
3432
|
+
if (footerPlans.set(frame, fullStatic ? { ...input, fullStaticFooter: !0 } : input), credit?.required && frame.creditNodeId === void 0 && warnings.push({ code: "credit-hidden", severity: "warn", message: `the map credit the licence requires is not drawn: ${credit.text}`, suggest: "Keep the credit visible under the chart, linked on a web page." }), input.eventKey) {
|
|
3433
|
+
let key = input.eventKey.layout(contentX, contentW);
|
|
3434
|
+
bottomY -= key.h, pushAll(nodes, key.draw(bottomY, nid)), frame.eventKeyRect = { x: contentX, y: bottomY, w: contentW, h: key.h }, occupied.claim(frame.eventKeyRect, "frame", {}), bottomY -= tokens.gapAxisFootnote;
|
|
3435
|
+
}
|
|
3436
|
+
let legendGeom, legendBand = 0, rightLegendBottom = 0, plotRight = size.width - margin.right, bandKeys = input.eventKey?.legendYieldsToSeries && (input.legend?.items.length ?? 0) > 0 ? [] : input.eventKey?.legend ?? [], legendInput = bandKeys.length > 0 ? { options: input.legend?.options ?? { position: "top" }, items: [...input.legend?.items ?? [], ...bandKeys] } : input.legend;
|
|
3437
|
+
if (legendInput && legendInput.items.length > 0) {
|
|
3438
|
+
let { options } = legendInput, { items } = dedupeLegendKeys(legendInput.items, (item) => identityAppearance(item, theme));
|
|
3439
|
+
pushAll(warnings, identityCollisionWarnings(items, theme));
|
|
3440
|
+
let footKey = input.legendFont === "footnote" || input.legendFont === "compact" && theme.type.footnote.size <= secondaryType(theme).size, keyCap = footKey ? 1 / 0 : scaleTextAtFloor(targetTypeSizesPx(input.target ?? DEFAULT_TARGET, "S").axis, input.textScale ?? 1, targetFloorsPx(input.target ?? DEFAULT_TARGET).secondary), keyRole = footKey ? theme.type.footnote : secondaryType(theme), font = withFamily(!hasAuthoredTypeSize(keyRole) && keyRole.size > keyCap ? { ...keyRole, size: keyCap } : keyRole), lineH = Math.max(SWATCH, font.size * (font.lineHeight ?? 1.2)), typeRole = footKey ? "footnote" : "secondary", labelBudget = options.position === "right" ? contentW * 0.45 : contentW, ringH = (it) => it.key === "sizes" ? Math.max(it.ringRow ?? 0, Math.ceil(2 * Math.max(0.5, ...it.radii ?? []))) : 0, maxKeyW = maxOf(items.map((it) => keyWidth(it, Math.max(lineH, ringH(it))))), wrappedKeys = new Map(items.map((it) => [it, wrapFootnote(it.label, font, Math.max(1, labelBudget - maxKeyW - SWATCH_GAP2), measure)])), keyTextH = (it) => Math.max(1, wrappedKeys.get(it).length) * lineH, valueFont = { ...font, weight: emphasisWeight(theme) }, textWOf = (it) => Math.max(0, ...wrappedKeys.get(it).map((line) => measure(line, font).width)), itemTextW = (it) => textWOf(it) + (it.value ? SWATCH_GAP2 + measure(it.value, valueFont).width : 0), valueNode = (it, lbId, x, y) => ({
|
|
3441
|
+
t: "text",
|
|
3442
|
+
id: `${lbId}:value`,
|
|
3443
|
+
x: x + textWOf(it) + SWATCH_GAP2,
|
|
3444
|
+
y,
|
|
3445
|
+
lines: [it.value],
|
|
3446
|
+
typeRole,
|
|
3447
|
+
align: "start",
|
|
3448
|
+
font: valueFont,
|
|
3449
|
+
ink: { token: "ink" },
|
|
3450
|
+
owner: { seriesId: it.id },
|
|
3451
|
+
part: "legendValue"
|
|
3452
|
+
}), keyNodes = (it, id, x, y, height2) => legendKeyNodes(theme, it, id, x, y, height2, font).map((node) => node.t === "text" ? { ...node, typeRole } : node), capMidBelowTop = font.size * TEXT_ASCENT2 - (measure.capHeight?.(font) ?? font.size * 0.72) / 2, keyTopAt = (textTop, height2) => textTop + capMidBelowTop - height2 / 2, onLabelLine = (keys, textTop) => keys.map((node) => node.t === "text" && node.part === "swatch" ? { ...node, y: textTop } : node);
|
|
3453
|
+
if (options.position === "right") {
|
|
3454
|
+
let keyW = maxOf(items.map((it) => keyWidth(it, Math.max(lineH, ringH(it))))), maxLabelW = maxOf(items.map(itemTextW)), legendW = keyW + SWATCH_GAP2 + maxLabelW, legendX = size.width - margin.right - legendW, y = topY, legendItems = [];
|
|
3455
|
+
for (let it of items) {
|
|
3456
|
+
let swId = nid("swatch"), lbId = nid("legendLabel"), sideKeyH = Math.max(lineH, ringH(it));
|
|
3457
|
+
nodes.push(...onLabelLine(keyNodes(it, swId, legendX, keyTopAt(y, sideKeyH), sideKeyH), y)), nodes.push({
|
|
3458
|
+
t: "text",
|
|
3459
|
+
id: lbId,
|
|
3460
|
+
x: legendX + keyW + SWATCH_GAP2,
|
|
3461
|
+
y,
|
|
3462
|
+
lines: wrappedKeys.get(it),
|
|
3463
|
+
typeRole,
|
|
3464
|
+
align: "start",
|
|
3465
|
+
font,
|
|
3466
|
+
ink: { token: "inkMuted" },
|
|
3467
|
+
owner: { seriesId: it.id },
|
|
3468
|
+
part: it.key === "heading" ? "legendHeading" : "legendLabel"
|
|
3469
|
+
}), it.value && nodes.push(valueNode(it, lbId, legendX + keyW + SWATCH_GAP2, y)), it.key !== "heading" && legendItems.push({ id: it.id, swatchNodeId: swId, labelId: lbId }), y += Math.max(keyTextH(it), ringH(it)) + 4;
|
|
3470
|
+
}
|
|
3471
|
+
let rect = { x: legendX, y: topY, w: legendW, h: y - topY - 4 };
|
|
3472
|
+
rightLegendBottom = y - 4, occupied.claim(rect, "legend", {}), legendGeom = { rect, items: legendItems }, plotRight = legendX - 16, warnings.push({
|
|
3473
|
+
code: "legend-beside-plot",
|
|
3474
|
+
severity: "info",
|
|
3475
|
+
message: `the key stands beside the plot and takes ${Math.round(size.width - margin.right - plotRight)} px of its width; 'top' keeps the plot full width`
|
|
3476
|
+
});
|
|
3477
|
+
} else {
|
|
3478
|
+
let keyH = lineH, titles = /* @__PURE__ */ new Map(), plainRowH = Math.max(tokens.legendRowH, lineH, maxOf(items.map(ringH))) + (input.cardGaps ? 4 : 0), budget2 = input[LEGEND_HEIGHT], available = budget2?.height === "auto" ? size.height * furnitureBudget(size.width) - (size.height - bottomY + topY) - tokens.gapLegend : budget2?.height ?? 1 / 0, fullBlockH;
|
|
3479
|
+
if (Number.isFinite(available) && available >= plainRowH && items.every((it) => budget2?.names.get(it.id) === it.label && it.key !== "heading" && ringH(it) <= keyH)) {
|
|
3480
|
+
let widths = items.map((it) => keyWidth(it, keyH) + SWATCH_GAP2 + itemTextW(it));
|
|
3481
|
+
if (fullBlockH = (1 + keyRowStarts(widths, items.map(() => !1), contentW).filter(Boolean).length) * (Math.max(tokens.legendRowH, maxOf(items.map(keyTextH))) + (input.cardGaps ? 4 : 0)) - (input.cardGaps ? 4 : 0), fullBlockH > available) {
|
|
3482
|
+
let perRow = Math.ceil(items.length / Math.floor(available / plainRowH)), entryWidth = (contentW - ITEM_GAP * (perRow - 1)) / perRow, fitted = items.map((it) => fitText(
|
|
3483
|
+
it.label,
|
|
3484
|
+
font,
|
|
3485
|
+
entryWidth - keyWidth(it, Math.max(keyH, ringH(it))) - SWATCH_GAP2 - (it.value ? SWATCH_GAP2 + measure(it.value, valueFont).width : 0),
|
|
3486
|
+
1,
|
|
3487
|
+
measure,
|
|
3488
|
+
{ target: input.target, typeRole }
|
|
3489
|
+
)), texts = fitted.map((fit) => fit.lines.join("")), seen = /* @__PURE__ */ new Map();
|
|
3490
|
+
texts.every((text, i) => {
|
|
3491
|
+
if (!text || text === "\u2026" || seen.has(text) && seen.get(text) !== items[i].label) return !1;
|
|
3492
|
+
seen.set(text, items[i].label);
|
|
3493
|
+
let stem = text.endsWith("\u2026") ? text.slice(0, -1) : void 0;
|
|
3494
|
+
return stem === void 0 || !texts.some((other, j) => j !== i && items[j].label !== items[i].label && other.startsWith(stem));
|
|
3495
|
+
}) && items.forEach((it, i) => {
|
|
3496
|
+
wrappedKeys.set(it, fitted[i].lines), fitted[i].title && titles.set(it, it.label);
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
let rowH = Math.max(tokens.legendRowH, maxOf(items.map(keyTextH)), maxOf(items.map(ringH))) + (input.cardGaps ? 4 : 0), inRow = (rowY, h, height2 = rowH) => input.cardGaps ? rowY : rowY + (height2 - h) / 2, rowY0 = options.position === "top" ? topY : bottomY, x = contentX, y = 0, legendItems = [], extraKeys = /* @__PURE__ */ new Map(), itemW = (it) => keyWidth(it, Math.max(keyH, ringH(it))) + SWATCH_GAP2 + itemTextW(it), rowStarts = keyRowStarts(items.map(itemW), items.map((it) => it.key === "heading"), contentW), rowHs = [];
|
|
3501
|
+
{
|
|
3502
|
+
let textRowH = Math.max(tokens.legendRowH, maxOf(items.map(keyTextH))) + (input.cardGaps ? 4 : 0);
|
|
3503
|
+
items.forEach((it, i) => {
|
|
3504
|
+
(rowStarts[i] || !rowHs.length) && rowHs.push(textRowH), rowHs[rowHs.length - 1] = Math.max(rowHs[rowHs.length - 1], ringH(it) + (input.cardGaps ? 4 : 0));
|
|
3505
|
+
});
|
|
3506
|
+
}
|
|
3507
|
+
let row = 0;
|
|
3508
|
+
for (let [i, it] of items.entries()) {
|
|
3509
|
+
let itemKeyH = Math.max(keyH, ringH(it)), w = itemW(it);
|
|
3510
|
+
rowStarts[i] && (x = contentX, y += rowHs[row], row++);
|
|
3511
|
+
let thisRowH = rowHs[row] ?? rowH, swId = nid("swatch"), lbId = nid("legendLabel"), textY = inRow(y, keyTextH(it), thisRowH), keyY = keyTopAt(textY, itemKeyH), keys = onLabelLine(keyNodes(it, swId, x, keyY, itemKeyH), textY);
|
|
3512
|
+
pushAll(nodes, keys);
|
|
3513
|
+
for (let extra of keys.slice(1)) extraKeys.set(extra.id, { item: it, swId, x, y: keyY, h: itemKeyH });
|
|
3514
|
+
nodes.push({
|
|
3515
|
+
t: "text",
|
|
3516
|
+
id: lbId,
|
|
3517
|
+
x: x + keyWidth(it, itemKeyH) + SWATCH_GAP2,
|
|
3518
|
+
y: textY,
|
|
3519
|
+
lines: wrappedKeys.get(it),
|
|
3520
|
+
...titles.has(it) ? { title: titles.get(it) } : {},
|
|
3521
|
+
typeRole,
|
|
3522
|
+
align: "start",
|
|
3523
|
+
font,
|
|
3524
|
+
ink: { token: "inkMuted" },
|
|
3525
|
+
owner: { seriesId: it.id },
|
|
3526
|
+
part: it.key === "heading" ? "legendHeading" : "legendLabel"
|
|
3527
|
+
}), it.value && nodes.push(valueNode(it, lbId, x + keyWidth(it, itemKeyH) + SWATCH_GAP2, inRow(y, lineH, thisRowH))), it.key !== "heading" && legendItems.push({ id: it.id, swatchNodeId: swId, labelId: lbId }), x += w + ITEM_GAP;
|
|
3528
|
+
}
|
|
3529
|
+
let lastRow = rowHs[row] ?? rowH, blockH = y + (input.cardGaps ? lastRow - 4 : lastRow);
|
|
3530
|
+
fullBlockH !== void 0 && recordFreedChrome(frame, "legend", fullBlockH - blockH);
|
|
3531
|
+
let yAbs = options.position === "top" ? rowY0 : rowY0 - blockH, swatchIds = new Set(legendItems.map((item) => item.swatchNodeId));
|
|
3532
|
+
if (input.autoHeight && options.position === "bottom") {
|
|
3533
|
+
let relative = nodes.filter((node) => swatchIds.has(node.id) || extraKeys.has(node.id) || ["legendHeading", "legendValue", "legendLabel"].includes(node.part)).map((node) => ({ node, original: node.t === "rect" ? { ...node, rect: { ...node.rect } } : { ...node } }));
|
|
3534
|
+
drawBottomLegend = (bottom) => {
|
|
3535
|
+
let yAbs2 = bottom - blockH;
|
|
3536
|
+
for (let { node, original } of relative) {
|
|
3537
|
+
let shifted = original.t === "rect" ? { ...original, rect: { ...original.rect } } : { ...original };
|
|
3538
|
+
shiftLegendKeyY(shifted, yAbs2);
|
|
3539
|
+
let extra = extraKeys.get(node.id);
|
|
3540
|
+
extra && Object.assign(shifted, keyNodes(extra.item, extra.swId, extra.x, extra.y + yAbs2, extra.h).find((key) => key.id === node.id)), Object.assign(node, shifted);
|
|
3541
|
+
}
|
|
3542
|
+
};
|
|
3543
|
+
}
|
|
3544
|
+
for (let n of nodes) {
|
|
3545
|
+
swatchIds.has(n.id) && shiftLegendKeyY(n, yAbs);
|
|
3546
|
+
let extra = extraKeys.get(n.id);
|
|
3547
|
+
extra && Object.assign(n, keyNodes(extra.item, extra.swId, extra.x, extra.y + yAbs, extra.h).find((key) => key.id === n.id)), (n.part === "legendHeading" || n.part === "legendValue" || n.part === "legendLabel" && legendItems.some((li) => li.labelId === n.id)) && n.t === "text" && (n.y += yAbs);
|
|
3548
|
+
}
|
|
3549
|
+
let rect = { x: contentX, y: yAbs, w: contentW, h: blockH };
|
|
3550
|
+
occupied.claim(rect, "legend", {}), legendGeom = { rect, items: legendItems }, legendBand = blockH + tokens.gapLegend, options.position === "top" ? topY += legendBand : bottomY -= legendBand;
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
let plotInsetLeft = Math.max(0, input.plotInset?.left ?? 0), plot = {
|
|
3554
|
+
x: contentX + plotInsetLeft,
|
|
3555
|
+
y: topY,
|
|
3556
|
+
w: Math.max(10, plotRight - contentX - plotInsetLeft),
|
|
3557
|
+
h: Math.max(MIN_PLOT_H, bottomY - topY)
|
|
3558
|
+
}, height = bottomY - topY >= MIN_PLOT_H && rightLegendBottom === 0 && !input.eventKey ? input.autoHeight?.(plot) : void 0, dy = height === void 0 ? 0 : height - size.height, moved = /* @__PURE__ */ new Map(), legendY = legendGeom?.rect.y;
|
|
3559
|
+
if (dy !== 0) {
|
|
3560
|
+
size.height = height, bottomY = size.height - margin.bottom;
|
|
3561
|
+
for (let block of bottomBlocks)
|
|
3562
|
+
bottomY -= block.height, moved.set(block.node.y, bottomY), block.node.y = bottomY, bottomY -= block.gap;
|
|
3563
|
+
frame.footerRect && (liveFooterH > size.height - margin.bottom - bottomY + 0.01 && (bottomY = size.height - margin.bottom - liveFooterH), bottomY = hitRoom(bottomY), frame.footerRect.y = bottomY, frame.footerRect.h = size.height - margin.bottom - bottomY, bottomY -= footGap), legendGeom && legendInput?.options.position === "bottom" && (drawBottomLegend(bottomY), legendGeom.rect.y = bottomY - legendGeom.rect.h, bottomY -= legendBand), plot.h = Math.max(MIN_PLOT_H, bottomY - topY);
|
|
3564
|
+
}
|
|
3565
|
+
if (input.autoHeight) for (let claim of occupied.snapshot())
|
|
3566
|
+
dy !== 0 && claim.kind === "frame" && moved.has(claim.rect.y) && (claim.rect.y = moved.get(claim.rect.y)), dy !== 0 && claim.kind === "legend" && legendInput?.options.position === "bottom" && claim.rect.y === legendY && (claim.rect.y = legendGeom.rect.y), destination.claim(claim.rect, claim.kind, claim.owner, claim.part, claim.polygon);
|
|
3567
|
+
frame.plotRect = { ...plot }, frameChrome.set(frame, topY + size.height - bottomY);
|
|
3568
|
+
let deficit = Math.max(MIN_PLOT_H - (bottomY - topY), rightLegendBottom > 0 ? rightLegendBottom - bottomY : -1 / 0);
|
|
3569
|
+
return frame.minHeight = size.height + deficit, warnings.length > 0 && (frame.warnings = warnings), { plot, nodes, frame, legend: legendGeom, ...deficit > 0 ? { deficit } : {}, ...legendBand > 0 ? { legendBand } : {} };
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
// src/core/dateFormat.ts
|
|
3573
|
+
function isoWeek(date) {
|
|
3574
|
+
let d = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())), dayNum = d.getUTCDay() || 7;
|
|
3575
|
+
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
|
3576
|
+
let yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
3577
|
+
return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
|
|
3578
|
+
}
|
|
3579
|
+
function quarterOf(date) {
|
|
3580
|
+
return Math.floor(date.getUTCMonth() / 3) + 1;
|
|
3581
|
+
}
|
|
3582
|
+
var TOKEN_RE = /('[^']*')|dddd|ddd|dd|d|MMMMM|MMMM|MMM|MM|M|QQQ|QQ|Q|ww|w|yyyy|yy/g;
|
|
3583
|
+
function formatDate(date, pattern, language) {
|
|
3584
|
+
let names = dateNames(language);
|
|
3585
|
+
return pattern.replace(TOKEN_RE, (tok) => {
|
|
3586
|
+
if (tok.startsWith("'")) return tok.slice(1, -1);
|
|
3587
|
+
switch (tok) {
|
|
3588
|
+
case "d":
|
|
3589
|
+
return String(date.getUTCDate());
|
|
3590
|
+
case "dd":
|
|
3591
|
+
return String(date.getUTCDate()).padStart(2, "0");
|
|
3592
|
+
case "ddd":
|
|
3593
|
+
return names.daysShort[date.getUTCDay()];
|
|
3594
|
+
case "dddd":
|
|
3595
|
+
return names.days[date.getUTCDay()];
|
|
3596
|
+
case "M":
|
|
3597
|
+
return String(date.getUTCMonth() + 1);
|
|
3598
|
+
case "MM":
|
|
3599
|
+
return String(date.getUTCMonth() + 1).padStart(2, "0");
|
|
3600
|
+
case "MMM":
|
|
3601
|
+
return names.monthsShort[date.getUTCMonth()];
|
|
3602
|
+
case "MMMM":
|
|
3603
|
+
return names.months[date.getUTCMonth()];
|
|
3604
|
+
case "MMMMM":
|
|
3605
|
+
return names.months[date.getUTCMonth()][0];
|
|
3606
|
+
case "Q":
|
|
3607
|
+
return String(quarterOf(date));
|
|
3608
|
+
case "QQ":
|
|
3609
|
+
return `Q${quarterOf(date)}`;
|
|
3610
|
+
case "QQQ":
|
|
3611
|
+
return `Quarter ${quarterOf(date)}`;
|
|
3612
|
+
case "w":
|
|
3613
|
+
return String(isoWeek(date));
|
|
3614
|
+
case "ww":
|
|
3615
|
+
return String(isoWeek(date)).padStart(2, "0");
|
|
3616
|
+
case "yy":
|
|
3617
|
+
return String(date.getUTCFullYear() % 100).padStart(2, "0");
|
|
3618
|
+
case "yyyy":
|
|
3619
|
+
return String(date.getUTCFullYear()).padStart(4, "0");
|
|
3620
|
+
default:
|
|
3621
|
+
return tok;
|
|
3622
|
+
}
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
3625
|
+
function weekOrdinal(date, weekStartsOn) {
|
|
3626
|
+
let days = Math.floor(date.getTime() / 864e5);
|
|
3627
|
+
return Math.floor((days + (weekStartsOn === 1 ? 3 : 4)) / 7);
|
|
3628
|
+
}
|
|
3629
|
+
function intervalOrdinal(date, interval, weekStartsOn) {
|
|
3630
|
+
let year = date.getUTCFullYear();
|
|
3631
|
+
switch (interval) {
|
|
3632
|
+
case "years":
|
|
3633
|
+
return year;
|
|
3634
|
+
case "quarters":
|
|
3635
|
+
return year * 4 + quarterOf(date) - 1;
|
|
3636
|
+
case "months":
|
|
3637
|
+
return year * 12 + date.getUTCMonth();
|
|
3638
|
+
case "weeks":
|
|
3639
|
+
return weekOrdinal(date, weekStartsOn);
|
|
3640
|
+
case "days":
|
|
3641
|
+
return Math.floor(date.getTime() / 864e5);
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
var DATE_TICK_STRIDES = {
|
|
3645
|
+
years: [2, 5, 10, 20, 25, 50, 100],
|
|
3646
|
+
quarters: [2, 4, 8, 20, 40],
|
|
3647
|
+
months: [2, 3, 6, 12, 24, 60, 120],
|
|
3648
|
+
weeks: [2, 4, 13, 26, 52],
|
|
3649
|
+
days: [2, 7, 14, 28]
|
|
3650
|
+
};
|
|
3651
|
+
function dateTickOrdinals(dates, interval, weekStartsOn) {
|
|
3652
|
+
let start = weekStartsOn === 0 ? 0 : 1, ordinals = [];
|
|
3653
|
+
for (let raw of dates) {
|
|
3654
|
+
let date = raw === void 0 ? null : parseISODate(raw);
|
|
3655
|
+
if (!date) return null;
|
|
3656
|
+
ordinals.push(intervalOrdinal(date, interval, start));
|
|
3657
|
+
}
|
|
3658
|
+
return ordinals.length === 0 ? null : ordinals;
|
|
3659
|
+
}
|
|
3660
|
+
function dateTickKeep(dates, interval, weekStartsOn, fromEnd = !1) {
|
|
3661
|
+
if (fromEnd) {
|
|
3662
|
+
let parsed = dates.map((raw) => raw === void 0 ? null : parseISODate(raw)), latest = parsed.at(-1);
|
|
3663
|
+
if (!latest || parsed.some((date) => !date)) return null;
|
|
3664
|
+
let monthEnd = (date) => {
|
|
3665
|
+
let end = new Date(date);
|
|
3666
|
+
return end.setUTCMonth(date.getUTCMonth() + 1, 0), end.getUTCDate();
|
|
3667
|
+
}, atMonthEnd = latest.getUTCDate() === monthEnd(latest), ordinals = dateTickOrdinals(dates, interval, weekStartsOn), lastOrdinal = ordinals.at(-1), keep = dates.map(() => !1), group, target = 0, best = -1;
|
|
3668
|
+
for (let i = 0; i < parsed.length; i++) {
|
|
3669
|
+
let ordinal = ordinals[i];
|
|
3670
|
+
if (ordinal !== group) {
|
|
3671
|
+
group = ordinal, best = -1;
|
|
3672
|
+
let back = lastOrdinal - ordinal, date = new Date(latest);
|
|
3673
|
+
interval === "days" || interval === "weeks" ? date.setUTCDate(latest.getUTCDate() - back * (interval === "weeks" ? 7 : 1)) : (date.setUTCDate(1), date.setUTCMonth(latest.getUTCMonth() - back * (interval === "years" ? 12 : interval === "quarters" ? 3 : 1)), date.setUTCDate(atMonthEnd ? monthEnd(date) : Math.min(latest.getUTCDate(), monthEnd(date)))), target = date.getTime();
|
|
3674
|
+
}
|
|
3675
|
+
target < parsed[0].getTime() || (best < 0 || Math.abs(parsed[i].getTime() - target) < Math.abs(parsed[best].getTime() - target)) && (best >= 0 && (keep[best] = !1), best = i, keep[i] = !0);
|
|
3676
|
+
}
|
|
3677
|
+
return keep;
|
|
3678
|
+
}
|
|
3679
|
+
return dateTickOrdinals(dates, interval, weekStartsOn)?.map((ordinal, i, all) => i === 0 || ordinal !== all[i - 1]) ?? null;
|
|
3680
|
+
}
|
|
3681
|
+
function dateTickKeepCalendar(dates, interval) {
|
|
3682
|
+
let keep = dateTickKeep(dates, interval);
|
|
3683
|
+
if (!keep?.[0]) return keep;
|
|
3684
|
+
let parsed = dates.map((raw) => raw === void 0 ? null : parseISODate(raw));
|
|
3685
|
+
if (parsed.some((date) => !date)) return keep;
|
|
3686
|
+
let first = parsed[0], months = interval === "years" ? 12 : interval === "quarters" ? 3 : 1, start = new Date(first);
|
|
3687
|
+
start.setUTCDate(1), start.setUTCMonth(Math.floor(first.getUTCMonth() / months) * months);
|
|
3688
|
+
let gap = 1 / 0;
|
|
3689
|
+
for (let i = 1; i < parsed.length; i++) gap = Math.min(gap, (parsed[i].getTime() - parsed[i - 1].getTime()) / 864e5);
|
|
3690
|
+
return (first.getTime() - start.getTime()) / 864e5 > gap && (keep[0] = !1), keep;
|
|
3691
|
+
}
|
|
3692
|
+
function datePatternFromExample(example) {
|
|
3693
|
+
return example ? /^\d{4}-\d{2}-\d{2}$/.test(example) ? "yyyy-MM-dd" : /^[A-Za-z]{3}-\d{2}$/.test(example) ? "MMM-yy" : /^\d{1,2} [A-Za-z]{3} \d{4}$/.test(example) ? "d MMM yyyy" : /^[A-Za-z]{3} \d{4}$/.test(example) ? "MMM yyyy" : /^Q\d \d{4}$/.test(example) ? "QQ yyyy" : "d MMM yyyy" : "d MMM yyyy";
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
export {
|
|
3697
|
+
rectsOverlap,
|
|
3698
|
+
rectContains,
|
|
3699
|
+
polylineYAt,
|
|
3700
|
+
rectLineDistance,
|
|
3701
|
+
sideAwayFrom,
|
|
3702
|
+
segmentHitsRect,
|
|
3703
|
+
rectHitsConvexPolygon,
|
|
3704
|
+
deltaGap,
|
|
3705
|
+
boxGap,
|
|
3706
|
+
rectCenter,
|
|
3707
|
+
inflate,
|
|
3708
|
+
boundsOf,
|
|
3709
|
+
unionRect,
|
|
3710
|
+
clamp,
|
|
3711
|
+
round2,
|
|
3712
|
+
strokeBoxPad,
|
|
3713
|
+
rowLabelX,
|
|
3714
|
+
chartString2 as chartString,
|
|
3715
|
+
localeStrings2 as localeStrings,
|
|
3716
|
+
furnitureBudget,
|
|
3717
|
+
ASPECT_LADDER,
|
|
3718
|
+
LADDER_TOLERANCE,
|
|
3719
|
+
ASPECT_CAPS,
|
|
3720
|
+
ladderHeights,
|
|
3721
|
+
onLadderStep,
|
|
3722
|
+
nearestLadderStep,
|
|
3723
|
+
HEIGHT_FLOOR_CLASSES,
|
|
3724
|
+
furnitureScoped,
|
|
3725
|
+
aspectClassFor,
|
|
3726
|
+
omittedKey,
|
|
3727
|
+
identityAppearance,
|
|
3728
|
+
distinguishSeries,
|
|
3729
|
+
keepsUnnamedSeriesKey,
|
|
3730
|
+
needsSeriesKey,
|
|
3731
|
+
scatterGroupIdentities,
|
|
3732
|
+
scatterGroupNameIsDrawn,
|
|
3733
|
+
collectSeriesIdentities,
|
|
3734
|
+
textNames,
|
|
3735
|
+
nameIsDrawn,
|
|
3736
|
+
scenarioLegendKeys,
|
|
3737
|
+
dedupeLegendKeys,
|
|
3738
|
+
lineBox,
|
|
3739
|
+
shrinkFont,
|
|
3740
|
+
fitText,
|
|
3741
|
+
distinctCut,
|
|
3742
|
+
cutWithTitle,
|
|
3743
|
+
textRole,
|
|
3744
|
+
isNumberAlone,
|
|
3745
|
+
composedTextRole,
|
|
3746
|
+
computedTextRole,
|
|
3747
|
+
numericVariant,
|
|
3748
|
+
adjacentSeriesWarnings,
|
|
3749
|
+
retainAdjacentWarningRule,
|
|
3750
|
+
rectSeriesAdjacentWarnings,
|
|
3751
|
+
highlightPaintWarnings,
|
|
3752
|
+
othersShadeUnavailableWarnings,
|
|
3753
|
+
markLostOnBandWarnings,
|
|
3754
|
+
groundTextWarnings,
|
|
3755
|
+
resolvePaintWarnings,
|
|
3756
|
+
refreshPaintWarnings,
|
|
3757
|
+
readableLabelDestination,
|
|
3758
|
+
omissionScope,
|
|
3759
|
+
cutLabels,
|
|
3760
|
+
labelOmissions,
|
|
3761
|
+
reportLabelOmissions,
|
|
3762
|
+
createOccupiedIndex,
|
|
3763
|
+
nearestIsOwn,
|
|
3764
|
+
leaderCrosses,
|
|
3765
|
+
inkBox,
|
|
3766
|
+
SERIES_VALUE_GAP,
|
|
3767
|
+
AREA_FILL_PART,
|
|
3768
|
+
PRIORITY,
|
|
3769
|
+
labelCtx,
|
|
3770
|
+
solveLabels,
|
|
3771
|
+
leaderPieces,
|
|
3772
|
+
CROSSABLE_RULE_PART,
|
|
3773
|
+
LAST_RESORT_PENALTY,
|
|
3774
|
+
isOwnMark,
|
|
3775
|
+
leaderTerminus,
|
|
3776
|
+
seatLeader,
|
|
3777
|
+
partialPattern,
|
|
3778
|
+
partialFootnotes,
|
|
3779
|
+
partialAxisWords,
|
|
3780
|
+
saysToDate,
|
|
3781
|
+
partialIds,
|
|
3782
|
+
partialLegendKeys,
|
|
3783
|
+
PARTIAL_KEY,
|
|
3784
|
+
partialKeyForced,
|
|
3785
|
+
toDateFont,
|
|
3786
|
+
toDateFits,
|
|
3787
|
+
toDateRoom,
|
|
3788
|
+
toDateLabel,
|
|
3789
|
+
footnoteMark,
|
|
3790
|
+
withCategoryNoteNames,
|
|
3791
|
+
markedLabel,
|
|
3792
|
+
footnoteSuffix,
|
|
3793
|
+
categoryLabelsAndMarks,
|
|
3794
|
+
defaultAnnotationId,
|
|
3795
|
+
ANNOTATION_KIND_PURPOSES,
|
|
3796
|
+
HEIGHT_STRUCTURE,
|
|
3797
|
+
assertEmbeddedImage,
|
|
3798
|
+
arrowSeats,
|
|
3799
|
+
finishCalloutHeads,
|
|
3800
|
+
leadersOffAnchorValues,
|
|
3801
|
+
SWATCH_RESERVE,
|
|
3802
|
+
groundEdges,
|
|
3803
|
+
labelsToNodes,
|
|
3804
|
+
repaintGeometry,
|
|
3805
|
+
repaintScene,
|
|
3806
|
+
sceneThemeBindings,
|
|
3807
|
+
isSafeSvgColor,
|
|
3808
|
+
resolvePaint,
|
|
3809
|
+
haloPaint,
|
|
3810
|
+
XmlCharError,
|
|
3811
|
+
TEXT_ASCENT2 as TEXT_ASCENT,
|
|
3812
|
+
renderSvg,
|
|
3813
|
+
legendRequired,
|
|
3814
|
+
legendOff,
|
|
3815
|
+
normalizeLegendOption,
|
|
3816
|
+
COMPACT_SOURCE_LINES,
|
|
3817
|
+
LEGEND_HEIGHT,
|
|
3818
|
+
authoredNotes,
|
|
3819
|
+
footnoteSwitch,
|
|
3820
|
+
withAuthoredFootnotes,
|
|
3821
|
+
authoredFootnoteCount,
|
|
3822
|
+
numberedFootnotesWith,
|
|
3823
|
+
UNIT_LINE,
|
|
3824
|
+
FOOTNOTE_REFS,
|
|
3825
|
+
POINTED_NOTES,
|
|
3826
|
+
frameTextOptions,
|
|
3827
|
+
plotChromeFloor,
|
|
3828
|
+
settledAutoHeight,
|
|
3829
|
+
fixedPlotChrome,
|
|
3830
|
+
plotHeightAfter,
|
|
3831
|
+
subtitleUnitClause,
|
|
3832
|
+
frameRendersUnit,
|
|
3833
|
+
unitPrinted,
|
|
3834
|
+
unitNotShownLints,
|
|
3835
|
+
unitInFormatLints,
|
|
3836
|
+
noteLine,
|
|
3837
|
+
fittedNote,
|
|
3838
|
+
valueNoteLine,
|
|
3839
|
+
DEFAULT_NOTE_LIMIT,
|
|
3840
|
+
noteCap,
|
|
3841
|
+
moreListedText,
|
|
3842
|
+
cappedItems,
|
|
3843
|
+
HIDDEN_LABEL_LEAD,
|
|
3844
|
+
withCutLabelNotes,
|
|
3845
|
+
finishCutLabelNotes,
|
|
3846
|
+
DEFER_DENSITY_NOTES,
|
|
3847
|
+
DENSITY_VALUES,
|
|
3848
|
+
UNVERIFIED_DENSITY_REFUSALS,
|
|
3849
|
+
DENSITY_LAYOUT_OPTIONS,
|
|
3850
|
+
owedHiddenLabels,
|
|
3851
|
+
LEFT_OUT_OF_NOTE,
|
|
3852
|
+
panelNoteTexts,
|
|
3853
|
+
dataOrder,
|
|
3854
|
+
withDensityNotes,
|
|
3855
|
+
densityNoteInList,
|
|
3856
|
+
NOTED_LABELS,
|
|
3857
|
+
withHiddenLabelNote,
|
|
3858
|
+
hiddenNoteLine,
|
|
3859
|
+
withNoteInA11y,
|
|
3860
|
+
hiddenNoteWith,
|
|
3861
|
+
markNotedLabels,
|
|
3862
|
+
unitMissing,
|
|
3863
|
+
shareUnitLints,
|
|
3864
|
+
textCarriesUnit,
|
|
3865
|
+
textCarriesCohortUnit,
|
|
3866
|
+
stringsIn,
|
|
3867
|
+
subtitleLine,
|
|
3868
|
+
solveFrame,
|
|
3869
|
+
formatDate,
|
|
3870
|
+
DATE_TICK_STRIDES,
|
|
3871
|
+
dateTickOrdinals,
|
|
3872
|
+
dateTickKeep,
|
|
3873
|
+
dateTickKeepCalendar,
|
|
3874
|
+
datePatternFromExample
|
|
3875
|
+
};
|