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,2774 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compileIcon
|
|
3
|
+
} from "./chunk-BUPLB3EX.js";
|
|
4
|
+
import {
|
|
5
|
+
chartString
|
|
6
|
+
} from "./chunk-EHVESNLV.js";
|
|
7
|
+
import {
|
|
8
|
+
eventReading
|
|
9
|
+
} from "./chunk-ULTSSIOU.js";
|
|
10
|
+
import {
|
|
11
|
+
yearSpan,
|
|
12
|
+
yearSpanFromLabels
|
|
13
|
+
} from "./chunk-L3JWM7FR.js";
|
|
14
|
+
import {
|
|
15
|
+
SHARES_OF_ONE_WHOLE_FIX,
|
|
16
|
+
VALUELESS_ANCHOR_FIX
|
|
17
|
+
} from "./chunk-6KWIQ5KF.js";
|
|
18
|
+
import {
|
|
19
|
+
isCategoryAlongY,
|
|
20
|
+
valueLineHasTargetExtras
|
|
21
|
+
} from "./chunk-CDZHNLO6.js";
|
|
22
|
+
import {
|
|
23
|
+
indicator100LabelRect,
|
|
24
|
+
lineLabelGutterLines,
|
|
25
|
+
namedLineText,
|
|
26
|
+
pruneOrphanAnnotationArms
|
|
27
|
+
} from "./chunk-HZI56ASJ.js";
|
|
28
|
+
import {
|
|
29
|
+
parseTimeText
|
|
30
|
+
} from "./chunk-GDOW2KNP.js";
|
|
31
|
+
import {
|
|
32
|
+
PRIORITY,
|
|
33
|
+
arrowSeats,
|
|
34
|
+
composedTextRole,
|
|
35
|
+
computedTextRole,
|
|
36
|
+
defaultAnnotationId,
|
|
37
|
+
finishCalloutHeads,
|
|
38
|
+
formatDate,
|
|
39
|
+
leaderTerminus,
|
|
40
|
+
leadersOffAnchorValues,
|
|
41
|
+
rectsOverlap,
|
|
42
|
+
solveLabels,
|
|
43
|
+
unionRect
|
|
44
|
+
} from "./chunk-SS42FJVN.js";
|
|
45
|
+
import {
|
|
46
|
+
recordPartNeed,
|
|
47
|
+
wrapFootnote
|
|
48
|
+
} from "./chunk-BPKXEMRE.js";
|
|
49
|
+
import {
|
|
50
|
+
differenceExample,
|
|
51
|
+
exampleSpec,
|
|
52
|
+
formatWithSpec,
|
|
53
|
+
formatterFromExample,
|
|
54
|
+
neededDecimals,
|
|
55
|
+
parseFormatExample,
|
|
56
|
+
parseISODate,
|
|
57
|
+
roundedNumber,
|
|
58
|
+
specUnitKind,
|
|
59
|
+
withChartMarks
|
|
60
|
+
} from "./chunk-RGZGLKFB.js";
|
|
61
|
+
import {
|
|
62
|
+
PERCENTAGE_POINTS,
|
|
63
|
+
autoDecimals,
|
|
64
|
+
cagr,
|
|
65
|
+
chartStrings,
|
|
66
|
+
formatAutomaticNumber,
|
|
67
|
+
formatAutomaticPercent,
|
|
68
|
+
localeStrings,
|
|
69
|
+
roundHalfUp,
|
|
70
|
+
roundsToZero,
|
|
71
|
+
typicalDecimals
|
|
72
|
+
} from "./chunk-53OYF4ZT.js";
|
|
73
|
+
import {
|
|
74
|
+
arrowHeadPath,
|
|
75
|
+
arrowShaftEnd,
|
|
76
|
+
colorblindPaint,
|
|
77
|
+
dashToken,
|
|
78
|
+
emphasisWeight,
|
|
79
|
+
leaderPath,
|
|
80
|
+
microType,
|
|
81
|
+
signedFillPaint,
|
|
82
|
+
strokeToken,
|
|
83
|
+
typeWidthClass
|
|
84
|
+
} from "./chunk-CWDHCSL2.js";
|
|
85
|
+
import {
|
|
86
|
+
publishDeferred
|
|
87
|
+
} from "./chunk-HA4IPWMM.js";
|
|
88
|
+
import {
|
|
89
|
+
NormalizeError
|
|
90
|
+
} from "./chunk-SGD3ZHID.js";
|
|
91
|
+
import {
|
|
92
|
+
maxOf,
|
|
93
|
+
minOf,
|
|
94
|
+
pushAll
|
|
95
|
+
} from "./chunk-WYJEOMNY.js";
|
|
96
|
+
import {
|
|
97
|
+
wrapText
|
|
98
|
+
} from "./chunk-AG2CJ4JY.js";
|
|
99
|
+
|
|
100
|
+
// src/core/strings/annotate.ts
|
|
101
|
+
var EN = {
|
|
102
|
+
// reader-facing wording linked only by its consumers.
|
|
103
|
+
seriesSpan: "{v1} to {v2}",
|
|
104
|
+
// author-facing warning, the same on a category axis and a time axis.
|
|
105
|
+
cagrStartNotPositive: "cagr '{v1}': the start value is not positive, so no growth rate is defined"
|
|
106
|
+
}, DE = {
|
|
107
|
+
// reader-facing wording linked only by its consumers.
|
|
108
|
+
seriesSpan: "{v1} zu {v2}",
|
|
109
|
+
// author-facing warning, the same on a category axis and a time axis.
|
|
110
|
+
cagrStartNotPositive: "cagr '{v1}': Der Startwert ist nicht positiv, daher ist keine Wachstumsrate definiert"
|
|
111
|
+
}, { chartString: chartString2 } = chartStrings(EN, DE);
|
|
112
|
+
|
|
113
|
+
// src/core/annotateArms.ts
|
|
114
|
+
var ARM_CLEARANCE = 10, ARM_STEP = 8, MAX_LIFTS = 40, ARM_ARROW = 5, ARM_START_GAP = 12, ARM_END_GAP = 12, ARM_END_GAP_ON_ARM = 4, ON_ARM_CLEARANCE = 3, ON_ARM_TOP = 41, MIN_LEG = 16, INSET_ARM = 22, INSET_GAP = 6, INSET_MIN_LEG = 4, INSET_TIP_GAP = 4;
|
|
115
|
+
function ownAnchorMark(occupiedOwner, occupiedKind, occupiedPart, anchorOwner) {
|
|
116
|
+
let sameCategory = anchorOwner.categoryId !== void 0 && occupiedOwner.categoryId === anchorOwner.categoryId;
|
|
117
|
+
return occupiedKind === "mark" && sameCategory && (anchorOwner.seriesId === void 0 && occupiedOwner.seriesId === void 0 || (occupiedPart === "segment" || occupiedPart === "bar") && (anchorOwner.seriesId === void 0 || occupiedOwner.seriesId === anchorOwner.seriesId));
|
|
118
|
+
}
|
|
119
|
+
function claimSegment(occupied, annId, x0, y0, x1, y1, part) {
|
|
120
|
+
occupied.claim(
|
|
121
|
+
{
|
|
122
|
+
x: Math.min(x0, x1) - 3,
|
|
123
|
+
y: Math.min(y0, y1) - 3,
|
|
124
|
+
w: Math.abs(x1 - x0) + 6,
|
|
125
|
+
h: Math.abs(y1 - y0) + 6
|
|
126
|
+
},
|
|
127
|
+
"annotation",
|
|
128
|
+
{ annotationId: annId },
|
|
129
|
+
part
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
function claimArrowHead(occupied, annId, x, y) {
|
|
133
|
+
occupied.claim({ x: x - 5, y: y - 5, w: 10, h: 10 }, "annotation", { annotationId: annId }, "arrowHead");
|
|
134
|
+
}
|
|
135
|
+
function measureArmLabel(input, text) {
|
|
136
|
+
let font = { family: input.theme.type.family, ...input.theme.type.label, weight: emphasisWeight(input.theme) };
|
|
137
|
+
return { font, tsize: input.measure(text, font) };
|
|
138
|
+
}
|
|
139
|
+
function laneTop(occupied, plotY, x, anchorY, anchorOwner, ceiling = -1 / 0) {
|
|
140
|
+
let top = anchorY;
|
|
141
|
+
for (let o of occupied.snapshot()) {
|
|
142
|
+
let r = o.rect;
|
|
143
|
+
ownAnchorMark(o.owner, o.kind, o.part, anchorOwner) || o.kind !== "label" && r.y + r.h <= plotY || r.y + r.h <= ceiling || x >= r.x - 3 && x <= r.x + r.w + 3 && r.y < anchorY && (top = Math.min(top, r.y));
|
|
144
|
+
}
|
|
145
|
+
return top;
|
|
146
|
+
}
|
|
147
|
+
function buried(occupied, anchor) {
|
|
148
|
+
let own = anchor.series?.id;
|
|
149
|
+
return own !== void 0 && occupied.snapshot().some(({ kind, owner, rect }) => kind === "mark" && owner.seriesId !== void 0 && owner.seriesId !== own && anchor.x >= rect.x && anchor.x <= rect.x + rect.w && rect.y < anchor.y - 1);
|
|
150
|
+
}
|
|
151
|
+
function besideLabels(input, anchor, side) {
|
|
152
|
+
if (anchor.lineAnchored) return anchor.x;
|
|
153
|
+
let lane = input.occupied.snapshot().filter(({ rect }) => anchor.x >= rect.x - 1 && anchor.x <= rect.x + rect.w + 1 && rect.y < anchor.y - 1 && rect.y >= input.plot.y), labels = lane.filter(({ kind }) => kind === "label").map(({ rect }) => rect), column = lane.filter(({ kind, owner }) => kind === "mark" && owner.seriesId !== anchor.series?.id).map(({ rect }) => rect);
|
|
154
|
+
if (labels.length === 0 || column.length === 0) return anchor.x;
|
|
155
|
+
let x = side < 0 ? minOf(labels.map((r) => r.x)) - 4 : maxOf(labels.map((r) => r.x + r.w)) + 4;
|
|
156
|
+
return column.every((r) => x >= r.x + 3 && x <= r.x + r.w - 3) ? x : anchor.x;
|
|
157
|
+
}
|
|
158
|
+
function legRuns(occupied, x, top, bottom, anchor) {
|
|
159
|
+
let cuts = occupied.snapshot().filter(({ kind, owner, rect }) => (kind === "label" || anchor.lineAnchored === !0 && kind === "mark" && owner.seriesId !== anchor.series?.id) && x >= rect.x - 1 && x <= rect.x + rect.w + 1 && rect.y - 2 > top && rect.y < bottom).map(({ rect }) => [rect.y - 2, rect.y + rect.h + 2]).sort((p, q) => p[0] - q[0]), runs = [], y = top;
|
|
160
|
+
for (let [from, to] of cuts)
|
|
161
|
+
from > y && runs.push([y, Math.min(from, bottom)]), y = Math.max(y, to);
|
|
162
|
+
return y < bottom && runs.push([y, bottom]), runs;
|
|
163
|
+
}
|
|
164
|
+
function pushCagrPlacement(pass, annId, text, computed, font, candidates, nodeIds, derivation) {
|
|
165
|
+
pass.labelRequests.push({
|
|
166
|
+
id: `annotation:${annId}`,
|
|
167
|
+
kind: "annotation",
|
|
168
|
+
role: computedTextRole(text, computed),
|
|
169
|
+
owner: { annotationId: annId },
|
|
170
|
+
text,
|
|
171
|
+
lines: [text],
|
|
172
|
+
typeRole: "label",
|
|
173
|
+
font,
|
|
174
|
+
priority: pass.priority ?? PRIORITY.valueLine,
|
|
175
|
+
candidates
|
|
176
|
+
}), pass.placed.push({
|
|
177
|
+
id: annId,
|
|
178
|
+
kind: "cagr",
|
|
179
|
+
computedText: computed,
|
|
180
|
+
nodeIds,
|
|
181
|
+
labelId: `annotation:${annId}`,
|
|
182
|
+
...derivation ? { derivation } : {}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation) {
|
|
186
|
+
let { input, nodes, nid } = pass, { font, tsize } = measureArmLabel(input, text), buriedA = buried(input.occupied, a), buriedB = buried(input.occupied, b), outward = a.x <= b.x ? 1 : -1;
|
|
187
|
+
buriedA && (a = { ...a, x: besideLabels(input, a, -outward) }), buriedB && (b = { ...b, x: besideLabels(input, b, outward) });
|
|
188
|
+
let leftAnchor = a.x <= b.x ? a : b, rightAnchor = a.x <= b.x ? b : a, spanX0 = leftAnchor.x, spanX1 = rightAnchor.x, startY = laneTop(input.occupied, input.plot.y, spanX0, leftAnchor.y, leftAnchor.owner, input.laneCeiling), endY = laneTop(input.occupied, input.plot.y, spanX1, rightAnchor.y, rightAnchor.owner, input.laneCeiling), direction = a.x <= b.x ? 1 : -1, fromY = direction === 1 ? startY : endY, toY = direction === 1 ? endY : startY, onArm = input.cagrLabelOnArm === !0, endGap = onArm ? ARM_END_GAP_ON_ARM : ARM_END_GAP, endpointCeiling = Math.min(startY, endY) - ARM_CLEARANCE - 8, labelX = (spanX0 + spanX1) / 2 - tsize.width / 2, labelAt = (y) => onArm ? { x: labelX, y: y - tsize.height / 2, w: tsize.width, h: tsize.height } : { x: labelX, y: y - 4 - tsize.height, w: tsize.width, h: tsize.height }, armFloor = onArm ? Math.max(input.plot.y + tsize.height / 2 + 2, (input.bandCeiling ?? input.plot.y) + ON_ARM_TOP) : input.plot.y + tsize.height + 6, armY = Math.max(endpointCeiling, armFloor), bandOvershoot = 0;
|
|
189
|
+
for (let i = 0; i < MAX_LIFTS; i++) {
|
|
190
|
+
let armRect = { x: spanX0, y: armY - 3, w: spanX1 - spanX0, h: 6 }, labelRect = labelAt(armY), blocked = input.occupied.hits(armRect, 2) || input.occupied.hits(labelRect, 2);
|
|
191
|
+
if (armY <= endpointCeiling && !blocked) break;
|
|
192
|
+
blocked && bandOvershoot === 0 && labelRect.y < input.plot.y && (bandOvershoot = input.plot.y - labelRect.y), armY -= ARM_STEP;
|
|
193
|
+
}
|
|
194
|
+
bandOvershoot > 0 && labelAt(armY).y < input.plot.y && pass.addLegDeficit(bandOvershoot);
|
|
195
|
+
let stubs = a.lineAnchored && b.lineAnchored && (!a.series && !b.series || buriedA || buriedB);
|
|
196
|
+
if (!stubs) {
|
|
197
|
+
let legFloor = Math.min(fromY - ARM_START_GAP, toY - endGap - arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"))) - MIN_LEG;
|
|
198
|
+
if (armY > legFloor) {
|
|
199
|
+
let candidate = Math.max(legFloor, armFloor), candidateArm = { x: spanX0, y: candidate - 3, w: spanX1 - spanX0, h: 6 }, candidateLabel = labelAt(candidate);
|
|
200
|
+
candidate < armY && candidate <= endpointCeiling && !input.occupied.hits(candidateArm, 2) && !input.occupied.hits(candidateLabel, 2) && (armY = candidate), armY > legFloor && pass.addLegDeficit(armY - legFloor);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let pathId = nid("arm"), headId = nid("arrowHead");
|
|
204
|
+
if (stubs) {
|
|
205
|
+
let armEnd = b.x - direction * arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"));
|
|
206
|
+
nodes.push({
|
|
207
|
+
t: "path",
|
|
208
|
+
id: pathId,
|
|
209
|
+
d: `M${a.x} ${armY + 10}L${a.x} ${armY}L${armEnd} ${armY}`,
|
|
210
|
+
stroke: { token: "ink" },
|
|
211
|
+
width: strokeToken(input.theme, "rule"),
|
|
212
|
+
owner: { annotationId: annId },
|
|
213
|
+
part: "arm"
|
|
214
|
+
}), nodes.push({
|
|
215
|
+
t: "path",
|
|
216
|
+
id: headId,
|
|
217
|
+
d: arrowHeadPath({ x: b.x, y: armY }, direction === 1 ? 0 : Math.PI, ARM_ARROW),
|
|
218
|
+
fill: { token: "ink" },
|
|
219
|
+
owner: { annotationId: annId },
|
|
220
|
+
part: "arrowHead"
|
|
221
|
+
}), claimSegment(input.occupied, annId, a.x, armY + 10, a.x, armY, "leg"), claimSegment(input.occupied, annId, a.x, armY, armEnd, armY, "arm"), claimArrowHead(input.occupied, annId, b.x, armY);
|
|
222
|
+
} else {
|
|
223
|
+
let reach = (anchor) => anchor.y - (anchor.lineAnchored ? 6 : 4), legStartY = buriedA ? reach(a) : fromY - ARM_START_GAP, tipY = buriedB ? reach(b) : toY - endGap, legEndY = tipY - arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule")), up = legRuns(input.occupied, a.x, armY, legStartY, a).reverse().map(([top, bottom]) => `M${a.x} ${bottom}L${a.x} ${top}`).join(""), down = legRuns(input.occupied, b.x, armY, legEndY, b).map(([top, bottom], index) => `${index === 0 ? "" : `M${b.x} ${top}`}L${b.x} ${bottom}`).join("");
|
|
224
|
+
if (nodes.push({
|
|
225
|
+
t: "path",
|
|
226
|
+
id: pathId,
|
|
227
|
+
d: `${up}L${b.x} ${armY}${down}`,
|
|
228
|
+
stroke: { token: "ink" },
|
|
229
|
+
width: strokeToken(input.theme, "rule"),
|
|
230
|
+
owner: { annotationId: annId },
|
|
231
|
+
part: "arm"
|
|
232
|
+
}), nodes.push({
|
|
233
|
+
t: "path",
|
|
234
|
+
id: headId,
|
|
235
|
+
d: arrowHeadPath({ x: b.x, y: tipY }, Math.PI / 2, ARM_ARROW),
|
|
236
|
+
fill: { token: "ink" },
|
|
237
|
+
owner: { annotationId: annId },
|
|
238
|
+
part: "arrowHead"
|
|
239
|
+
}), claimSegment(input.occupied, annId, a.x, legStartY, a.x, armY, "leg"), onArm) {
|
|
240
|
+
let seat0 = labelX - ON_ARM_CLEARANCE, seat1 = labelX + tsize.width + ON_ARM_CLEARANCE;
|
|
241
|
+
seat0 > Math.min(a.x, b.x) && claimSegment(input.occupied, annId, Math.min(a.x, b.x), armY, seat0, armY, "arm"), seat1 < Math.max(a.x, b.x) && claimSegment(input.occupied, annId, seat1, armY, Math.max(a.x, b.x), armY, "arm");
|
|
242
|
+
} else claimSegment(input.occupied, annId, a.x, armY, b.x, armY, "arm");
|
|
243
|
+
claimSegment(input.occupied, annId, b.x, armY, b.x, legEndY, "leg"), onArm ? input.occupied.claim({ x: b.x - 3, y: tipY - 5, w: 6, h: 5 }, "annotation", { annotationId: annId }, "arrowHead") : claimArrowHead(input.occupied, annId, b.x, tipY);
|
|
244
|
+
}
|
|
245
|
+
pushCagrPlacement(pass, annId, text, computed, font, [
|
|
246
|
+
...onArm && !stubs ? [{ slot: "onArm", rect: labelAt(armY), penalty: 0 }] : [],
|
|
247
|
+
{ slot: "aboveArm", rect: { x: labelX, y: armY - 4 - tsize.height, w: tsize.width, h: tsize.height }, penalty: onArm ? 1 : 0 },
|
|
248
|
+
{ slot: "belowArm", rect: { x: labelX, y: armY + 4, w: tsize.width, h: tsize.height }, penalty: onArm ? 2 : 1 }
|
|
249
|
+
], [pathId, headId], derivation);
|
|
250
|
+
}
|
|
251
|
+
function pushInsetCagrPlacement(pass, annId, text, computed, font, armX, midY, parts, nodeIds, derivation, span) {
|
|
252
|
+
let { input } = pass, regular = { family: input.theme.type.family, ...input.theme.type.label }, lines = parts ? [parts.lead, parts.value] : [text], lineH = font.size * (font.lineHeight ?? 1.2), w = Math.max(...lines.map((line, i) => input.measure(line, parts && i === 0 ? regular : font).width)), h = lines.length === 1 ? input.measure(text, font).height : lines.length * lineH;
|
|
253
|
+
pass.labelRequests.push({
|
|
254
|
+
id: `annotation:${annId}`,
|
|
255
|
+
kind: "annotation",
|
|
256
|
+
role: computedTextRole(text, computed),
|
|
257
|
+
owner: { annotationId: annId },
|
|
258
|
+
text,
|
|
259
|
+
lines,
|
|
260
|
+
typeRole: "label",
|
|
261
|
+
font,
|
|
262
|
+
priority: pass.priority ?? PRIORITY.valueLine,
|
|
263
|
+
align: "end",
|
|
264
|
+
...parts ? { headLines: 1, headWeight: regular.weight, headInk: { token: "inkMuted" } } : {},
|
|
265
|
+
candidates: [
|
|
266
|
+
{ slot: "leftArm", rect: { x: armX - INSET_GAP - w, y: midY - h / 2, w, h }, penalty: 0 },
|
|
267
|
+
// Type steps: inside the arm the label may slide up or down to the gap between two rows.
|
|
268
|
+
...span ? [0.25, -0.25, 0.5, -0.5, 0.75, -0.75, 1, -1].flatMap((k, i) => {
|
|
269
|
+
let y = midY - h / 2 + k * h;
|
|
270
|
+
return y >= span[0] && y + h <= span[1] ? [{ slot: `leftArm:${i}`, rect: { x: armX - INSET_GAP - w, y, w, h }, penalty: 0.1 + i * 0.1 }] : [];
|
|
271
|
+
}) : [],
|
|
272
|
+
{ slot: "rightArm", rect: { x: armX + 4, y: midY - h / 2, w, h }, penalty: 1 }
|
|
273
|
+
]
|
|
274
|
+
}), pass.placed.push({
|
|
275
|
+
id: annId,
|
|
276
|
+
kind: "cagr",
|
|
277
|
+
computedText: computed,
|
|
278
|
+
nodeIds,
|
|
279
|
+
labelId: `annotation:${annId}`,
|
|
280
|
+
...derivation ? { derivation } : {}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function drawShiftedCagrArm(pass, a, b, text, annId, computed, derivation, parts) {
|
|
284
|
+
let { input, nodes, nid } = pass, inset = input.barInset !== void 0, { font, tsize } = measureArmLabel(input, text), startGap = inset ? INSET_GAP : ARM_START_GAP, endGap = inset ? INSET_GAP : ARM_END_GAP;
|
|
285
|
+
a.row && (a = { ...a, y: a.row.y + a.row.h / 2 }), b.row && (b = { ...b, y: b.row.y + b.row.h / 2 });
|
|
286
|
+
let topAnchor = a.y <= b.y ? a : b, botAnchor = a.y <= b.y ? b : a, spanY0 = topAnchor.y, spanY1 = botAnchor.y, plotRight = input.plot.x + input.plot.w, clearOfLane = (y, anchorX, anchorOwner) => {
|
|
287
|
+
let right = anchorX;
|
|
288
|
+
for (let o of input.occupied.snapshot()) {
|
|
289
|
+
let r = o.rect;
|
|
290
|
+
ownAnchorMark(o.owner, o.kind, o.part, anchorOwner) || o.kind !== "label" && r.x >= plotRight || y >= r.y - 3 && y <= r.y + r.h + 3 && r.x + r.w > anchorX && (right = Math.max(right, r.x + r.w));
|
|
291
|
+
}
|
|
292
|
+
return right;
|
|
293
|
+
}, startX = clearOfLane(spanY0, topAnchor.x, topAnchor.owner), endX = clearOfLane(spanY1, botAnchor.x, botAnchor.owner), fromX = a.y <= b.y ? startX : endX, toX = a.y <= b.y ? endX : startX, endpointFloor = Math.max(startX, endX) + (inset ? INSET_ARM : ARM_CLEARANCE + 8), armX = inset ? endpointFloor : Math.min(endpointFloor, plotRight - tsize.width - 6);
|
|
294
|
+
for (let i = 0; i < MAX_LIFTS; i++) {
|
|
295
|
+
let armRect = { x: armX - 3, y: spanY0, w: 6, h: Math.max(spanY1 - spanY0, 1) }, labelRect = {
|
|
296
|
+
x: armX + 4,
|
|
297
|
+
y: (spanY0 + spanY1) / 2 - tsize.height / 2,
|
|
298
|
+
w: tsize.width,
|
|
299
|
+
h: tsize.height
|
|
300
|
+
};
|
|
301
|
+
if (armX >= endpointFloor && !input.occupied.hits(armRect, 2) && (inset || !input.occupied.hits(labelRect, 2))) break;
|
|
302
|
+
armX += ARM_STEP;
|
|
303
|
+
}
|
|
304
|
+
let legFloor = Math.max(fromX + startGap, toX + endGap + arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"))) + (inset ? INSET_MIN_LEG : MIN_LEG);
|
|
305
|
+
if (armX < legFloor) {
|
|
306
|
+
let candidate = Math.min(legFloor, plotRight - 3), candidateArm = { x: candidate - 3, y: spanY0, w: 6, h: Math.max(spanY1 - spanY0, 1) }, labelAt = (x) => ({ x, y: (spanY0 + spanY1) / 2 - tsize.height / 2, w: tsize.width, h: tsize.height }), labelFree = (rect) => rect.x >= input.plot.x && rect.x + rect.w <= plotRight && !input.occupied.hits(rect, 2);
|
|
307
|
+
candidate > armX && candidate >= endpointFloor && !input.occupied.hits(candidateArm, 2) && (labelFree(labelAt(candidate + 4)) || labelFree(labelAt(candidate - 4 - tsize.width))) && (armX = candidate), armX < legFloor && pass.addLegDeficit(legFloor - armX);
|
|
308
|
+
}
|
|
309
|
+
let pathId = nid("arm"), headId = nid("arrowHead"), legEndX = toX + endGap + arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule")), d = `M${fromX + startGap} ${a.y}L${armX} ${a.y}L${armX} ${b.y}L${legEndX} ${b.y}`;
|
|
310
|
+
nodes.push({
|
|
311
|
+
t: "path",
|
|
312
|
+
id: pathId,
|
|
313
|
+
d,
|
|
314
|
+
stroke: { token: "ink" },
|
|
315
|
+
width: strokeToken(input.theme, "rule"),
|
|
316
|
+
owner: { annotationId: annId },
|
|
317
|
+
part: "arm"
|
|
318
|
+
}), nodes.push({
|
|
319
|
+
t: "path",
|
|
320
|
+
id: headId,
|
|
321
|
+
d: arrowHeadPath({ x: toX + endGap, y: b.y }, Math.PI, ARM_ARROW),
|
|
322
|
+
fill: { token: "ink" },
|
|
323
|
+
owner: { annotationId: annId },
|
|
324
|
+
part: "arrowHead"
|
|
325
|
+
}), claimSegment(input.occupied, annId, fromX + startGap, a.y, armX, a.y, "leg"), claimSegment(input.occupied, annId, armX, a.y, armX, b.y, "arm"), claimSegment(input.occupied, annId, armX, b.y, legEndX, b.y, "leg"), claimArrowHead(input.occupied, annId, toX + endGap, b.y);
|
|
326
|
+
let midY = (spanY0 + spanY1) / 2;
|
|
327
|
+
if (inset) {
|
|
328
|
+
pushInsetCagrPlacement(pass, annId, text, computed, font, armX, midY, parts, [pathId, headId], derivation, [spanY0, spanY1]);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
pushCagrPlacement(pass, annId, text, computed, font, [
|
|
332
|
+
{ slot: "rightArm", rect: { x: armX + 4, y: midY - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 0 },
|
|
333
|
+
{ slot: "leftArm", rect: { x: armX - 4 - tsize.width, y: midY - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 1 }
|
|
334
|
+
], [pathId, headId], derivation);
|
|
335
|
+
}
|
|
336
|
+
function drawVerticalLevelDiff(pass, a, b, text, annId, computed, derivation) {
|
|
337
|
+
let { input, nodes, labelRequests, placed, nid } = pass, y0 = a.y, y1 = b.y, gap = Math.max(14, input.plot.w * 0.05), candidatesX = [
|
|
338
|
+
(a.x + b.x) / 2,
|
|
339
|
+
Math.max(a.x, b.x) + gap,
|
|
340
|
+
Math.min(a.x, b.x) - gap,
|
|
341
|
+
input.plot.x + input.plot.w - 8
|
|
342
|
+
], stripFree = (sx) => input.occupied.hitsWhich(
|
|
343
|
+
{ x: sx - 3, y: Math.min(y0, y1), w: 6, h: Math.max(Math.abs(y1 - y0), 1) },
|
|
344
|
+
2
|
|
345
|
+
).every((claim) => [a, b].some(
|
|
346
|
+
(anchor) => anchor.lineAnchored && Math.abs(sx - anchor.x) < 0.5 && claim.kind === "mark" && !claim.polygon && claim.owner.seriesId === anchor.owner.seriesId && anchor.x >= claim.rect.x - 2 && anchor.x <= claim.rect.x + claim.rect.w + 2 && anchor.y >= claim.rect.y - 2 && anchor.y <= claim.rect.y + claim.rect.h + 2
|
|
347
|
+
)), x = candidatesX.find(stripFree) ?? (a.x + b.x) / 2, lineId = nid("diffLine");
|
|
348
|
+
pushGuide(pass, "leader0", annId, { x: a.x, y: y0 }, { x, y: y0 }), pushGuide(pass, "leader1", annId, { x: b.x, y: y1 }, { x, y: y1 });
|
|
349
|
+
let headTipY = y1 + (y1 > y0 ? -1 : 1), shaftEndY = headTipY + (y1 > y0 ? -1 : 1) * -arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"));
|
|
350
|
+
nodes.push({
|
|
351
|
+
t: "line",
|
|
352
|
+
id: lineId,
|
|
353
|
+
x1: x,
|
|
354
|
+
y1: y0,
|
|
355
|
+
x2: x,
|
|
356
|
+
y2: shaftEndY,
|
|
357
|
+
stroke: { token: "ink" },
|
|
358
|
+
width: strokeToken(input.theme, "rule"),
|
|
359
|
+
owner: { annotationId: annId },
|
|
360
|
+
part: "diffArrow"
|
|
361
|
+
});
|
|
362
|
+
let headId = nid("arrowHead"), angle = y1 > y0 ? Math.PI / 2 : -Math.PI / 2;
|
|
363
|
+
nodes.push({
|
|
364
|
+
t: "path",
|
|
365
|
+
id: headId,
|
|
366
|
+
d: arrowHeadPath({ x, y: headTipY }, angle, ARM_ARROW),
|
|
367
|
+
fill: { token: "ink" },
|
|
368
|
+
owner: { annotationId: annId },
|
|
369
|
+
part: "arrowHead"
|
|
370
|
+
}), input.occupied.claim(
|
|
371
|
+
{ x: x - 2, y: Math.min(y0, y1), w: 4, h: Math.abs(y1 - y0) },
|
|
372
|
+
"annotation",
|
|
373
|
+
{ annotationId: annId }
|
|
374
|
+
);
|
|
375
|
+
let { font, tsize } = measureArmLabel(input, text), midY = (y0 + y1) / 2;
|
|
376
|
+
labelRequests.push({
|
|
377
|
+
id: `annotation:${annId}`,
|
|
378
|
+
kind: "annotation",
|
|
379
|
+
role: computedTextRole(text, computed),
|
|
380
|
+
owner: { annotationId: annId },
|
|
381
|
+
text,
|
|
382
|
+
lines: [text],
|
|
383
|
+
typeRole: "label",
|
|
384
|
+
font,
|
|
385
|
+
priority: pass.priority ?? PRIORITY.valueLine,
|
|
386
|
+
candidates: [
|
|
387
|
+
{ slot: "right", rect: { x: x + 6, y: midY - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 0, needsBacking: !0 },
|
|
388
|
+
{ slot: "left", rect: { x: x - 6 - tsize.width, y: midY - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 1, needsBacking: !0 },
|
|
389
|
+
{ slot: "above", rect: { x: x - tsize.width / 2, y: Math.min(y0, y1) - tsize.height - 4, w: tsize.width, h: tsize.height }, penalty: 2 },
|
|
390
|
+
{ slot: "aboveLeft", rect: { x: x - 6 - tsize.width, y: Math.min(y0, y1) - tsize.height - 4, w: tsize.width, h: tsize.height }, penalty: 3 },
|
|
391
|
+
{ slot: "belowRight", rect: { x: x + 6, y: Math.max(y0, y1) + 4, w: tsize.width, h: tsize.height }, penalty: 4 }
|
|
392
|
+
]
|
|
393
|
+
}), placed.push({
|
|
394
|
+
id: annId,
|
|
395
|
+
kind: "diff",
|
|
396
|
+
computedText: computed,
|
|
397
|
+
tone: computed.startsWith("\u2212") || computed.startsWith("-") ? "bad" : "neutral",
|
|
398
|
+
nodeIds: [lineId, headId],
|
|
399
|
+
labelId: `annotation:${annId}`,
|
|
400
|
+
...derivation ? { derivation } : {}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
function guideRuns(occupied, p, q) {
|
|
404
|
+
let horizontal = Math.abs(q.y - p.y) < Math.abs(q.x - p.x), at = horizontal ? p.y : p.x, [lo, hi] = horizontal ? [Math.min(p.x, q.x), Math.max(p.x, q.x)] : [Math.min(p.y, q.y), Math.max(p.y, q.y)], cuts = occupied.snapshot().filter(({ kind, rect }) => kind === "label" && (horizontal ? at >= rect.y - 1 && at <= rect.y + rect.h + 1 : at >= rect.x - 1 && at <= rect.x + rect.w + 1)).map(({ rect }) => horizontal ? [rect.x - 2, rect.x + rect.w + 2] : [rect.y - 2, rect.y + rect.h + 2]).filter(([c0, c1]) => c1 > lo && c0 < hi).sort((u, v) => u[0] - v[0]), runs = [], from = lo;
|
|
405
|
+
for (let [c0, c1] of cuts)
|
|
406
|
+
c0 > from && runs.push([from, c0]), from = Math.max(from, c1);
|
|
407
|
+
from < hi && runs.push([from, hi]);
|
|
408
|
+
let forward = (horizontal ? p.x : p.y) <= (horizontal ? q.x : q.y), kept = runs.filter(([u, v]) => v - u >= 4).map(([u, v]) => forward ? [u, v] : [v, u]);
|
|
409
|
+
return (forward ? kept : kept.reverse()).map(([u, v]) => horizontal ? [{ x: u, y: at }, { x: v, y: at }] : [{ x: at, y: u }, { x: at, y: v }]);
|
|
410
|
+
}
|
|
411
|
+
function pushGuide(pass, key, annId, p, q) {
|
|
412
|
+
for (let [from, to] of guideRuns(pass.input.occupied, p, q))
|
|
413
|
+
pass.nodes.push({
|
|
414
|
+
t: "line",
|
|
415
|
+
id: pass.nid(key),
|
|
416
|
+
x1: from.x,
|
|
417
|
+
y1: from.y,
|
|
418
|
+
x2: to.x,
|
|
419
|
+
y2: to.y,
|
|
420
|
+
stroke: { token: "leader" },
|
|
421
|
+
width: strokeToken(pass.input.theme, "rule"),
|
|
422
|
+
dash: dashToken(pass.input.theme, "dotted"),
|
|
423
|
+
lineCap: "round",
|
|
424
|
+
owner: { annotationId: annId },
|
|
425
|
+
part: "leader"
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function trimAnnotationGuides(nodes, occupied) {
|
|
429
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
430
|
+
let node = nodes[i];
|
|
431
|
+
if (node.t !== "line" || node.part !== "leader" || !node.dash || !node.owner.annotationId) continue;
|
|
432
|
+
let pieces = guideRuns(occupied, { x: node.x1, y: node.y1 }, { x: node.x2, y: node.y2 }).map(([a, b], n) => ({ ...node, id: n === 0 ? node.id : `${node.id}:${n}`, x1: a.x, y1: a.y, x2: b.x, y2: b.y })), after = nodes.splice(i + 1);
|
|
433
|
+
nodes.length = i, pushAll(nodes, pieces), pushAll(nodes, after);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function drawHorizontalLevelDiff(pass, a, b, text, annId, computed, derivation) {
|
|
437
|
+
let { input, nodes, labelRequests, placed, nid } = pass, x0 = a.x, x1 = b.x, gap = Math.max(14, input.plot.h * 0.05), candidatesY = pass.diffHeights ?? [
|
|
438
|
+
(a.y + b.y) / 2,
|
|
439
|
+
Math.max(a.y, b.y) + gap,
|
|
440
|
+
Math.min(a.y, b.y) - gap,
|
|
441
|
+
input.plot.y + 8
|
|
442
|
+
], stripFree = (sy) => input.occupied.hitsWhich(
|
|
443
|
+
{ x: Math.min(x0, x1), y: sy - 3, w: Math.max(Math.abs(x1 - x0), 1), h: 6 },
|
|
444
|
+
2
|
|
445
|
+
).every((claim) => claim.part === "referenceLine"), y = candidatesY.find(stripFree) ?? (a.y + b.y) / 2, lineId = nid("diffLine");
|
|
446
|
+
pushGuide(pass, "leader0", annId, { x: x0, y: a.y }, { x: x0, y }), pushGuide(pass, "leader1", annId, { x: x1, y: b.y }, { x: x1, y });
|
|
447
|
+
let headTipX = x1 + (x1 > x0 ? -1 : 1), shaftEndX = headTipX + (x1 > x0 ? -1 : 1) * -arrowShaftEnd(ARM_ARROW, strokeToken(input.theme, "rule"));
|
|
448
|
+
nodes.push({
|
|
449
|
+
t: "line",
|
|
450
|
+
id: lineId,
|
|
451
|
+
x1: x0,
|
|
452
|
+
y1: y,
|
|
453
|
+
x2: shaftEndX,
|
|
454
|
+
y2: y,
|
|
455
|
+
stroke: { token: "ink" },
|
|
456
|
+
width: strokeToken(input.theme, "rule"),
|
|
457
|
+
owner: { annotationId: annId },
|
|
458
|
+
part: "diffArrow"
|
|
459
|
+
});
|
|
460
|
+
let headId = nid("arrowHead"), angle = x1 > x0 ? 0 : Math.PI;
|
|
461
|
+
nodes.push({
|
|
462
|
+
t: "path",
|
|
463
|
+
id: headId,
|
|
464
|
+
d: arrowHeadPath({ x: headTipX, y }, angle, ARM_ARROW),
|
|
465
|
+
fill: { token: "ink" },
|
|
466
|
+
owner: { annotationId: annId },
|
|
467
|
+
part: "arrowHead"
|
|
468
|
+
}), input.occupied.claim(
|
|
469
|
+
{ x: Math.min(x0, x1), y: y - 2, w: Math.abs(x1 - x0), h: 4 },
|
|
470
|
+
"annotation",
|
|
471
|
+
{ annotationId: annId }
|
|
472
|
+
);
|
|
473
|
+
let { font, tsize } = measureArmLabel(input, text), midX = (x0 + x1) / 2;
|
|
474
|
+
labelRequests.push({
|
|
475
|
+
id: `annotation:${annId}`,
|
|
476
|
+
kind: "annotation",
|
|
477
|
+
role: computedTextRole(text, computed),
|
|
478
|
+
owner: { annotationId: annId },
|
|
479
|
+
text,
|
|
480
|
+
lines: [text],
|
|
481
|
+
typeRole: "label",
|
|
482
|
+
font,
|
|
483
|
+
priority: pass.priority ?? PRIORITY.valueLine,
|
|
484
|
+
candidates: [
|
|
485
|
+
{ slot: "above", rect: { x: midX - tsize.width / 2, y: y - tsize.height - 6, w: tsize.width, h: tsize.height }, penalty: 0, needsBacking: !0 },
|
|
486
|
+
{ slot: "below", rect: { x: midX - tsize.width / 2, y: y + 6, w: tsize.width, h: tsize.height }, penalty: 1, needsBacking: !0 },
|
|
487
|
+
{ slot: "right", rect: { x: Math.max(x0, x1) + 6, y: y - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 2 }
|
|
488
|
+
]
|
|
489
|
+
}), placed.push({
|
|
490
|
+
id: annId,
|
|
491
|
+
kind: "diff",
|
|
492
|
+
computedText: computed,
|
|
493
|
+
tone: computed.startsWith("\u2212") || computed.startsWith("-") ? "bad" : "neutral",
|
|
494
|
+
nodeIds: [lineId, headId],
|
|
495
|
+
labelId: `annotation:${annId}`,
|
|
496
|
+
...derivation ? { derivation } : {}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function anchorBar(occupied, anchor) {
|
|
500
|
+
return occupied.snapshot().find(({ kind, owner, part, rect }) => kind === "mark" && part === "bar" && owner.categoryId === anchor.owner.categoryId && owner.seriesId === anchor.owner.seriesId && anchor.y >= rect.y - 0.5 && anchor.y <= rect.y + rect.h + 0.5)?.rect;
|
|
501
|
+
}
|
|
502
|
+
function drawInsetBarGap(pass, a, b, text, annId, computed, parts, derivation) {
|
|
503
|
+
let { input, nodes, labelRequests, placed, nid } = pass;
|
|
504
|
+
if (a.value < 0 || b.value < 0 || Math.abs(a.x - b.x) < 1) return !1;
|
|
505
|
+
let [short, long] = a.x < b.x ? [a, b] : [b, a], longBar = anchorBar(input.occupied, long), shortBar = anchorBar(input.occupied, short);
|
|
506
|
+
if (!longBar || !shortBar) return !1;
|
|
507
|
+
let y = short.y, dropFrom = long.y < y ? longBar.y + longBar.h : longBar.y, dropStrip = { x: long.x - 1, y: Math.min(dropFrom, y) + 1, w: 2, h: Math.max(Math.abs(y - dropFrom) - 2, 0) };
|
|
508
|
+
if (dropStrip.h > 0 && input.occupied.hitsWhich(dropStrip, 0).some((claim) => claim.kind === "mark" && claim.owner.seriesId !== short.owner.seriesId)) return !1;
|
|
509
|
+
let rule = strokeToken(input.theme, "rule"), tipX = short.x + INSET_TIP_GAP, regular = { family: input.theme.type.family, ...input.theme.type.label }, font = { ...regular, weight: emphasisWeight(input.theme) }, runs = [{ text: `${parts.lead}\xA0` }, { text: parts.value, weight: font.weight }], w = input.measure(`${parts.lead}\xA0`, regular).width + input.measure(parts.value, font).width, h = input.measure(text, font).height;
|
|
510
|
+
if (long.x - tipX < w + 4 * ARM_ARROW) return !1;
|
|
511
|
+
pushGuide(pass, "leader0", annId, { x: long.x, y: dropFrom }, { x: long.x, y });
|
|
512
|
+
let lineId = nid("diffLine");
|
|
513
|
+
nodes.push({
|
|
514
|
+
t: "line",
|
|
515
|
+
id: lineId,
|
|
516
|
+
x1: long.x,
|
|
517
|
+
y1: y,
|
|
518
|
+
x2: tipX + arrowShaftEnd(ARM_ARROW, rule),
|
|
519
|
+
y2: y,
|
|
520
|
+
stroke: { token: "ink" },
|
|
521
|
+
width: rule,
|
|
522
|
+
owner: { annotationId: annId },
|
|
523
|
+
part: "diffArrow"
|
|
524
|
+
});
|
|
525
|
+
let headId = nid("arrowHead");
|
|
526
|
+
nodes.push({
|
|
527
|
+
t: "path",
|
|
528
|
+
id: headId,
|
|
529
|
+
d: arrowHeadPath({ x: tipX, y }, Math.PI, ARM_ARROW),
|
|
530
|
+
fill: { token: "ink" },
|
|
531
|
+
owner: { annotationId: annId },
|
|
532
|
+
part: "arrowHead"
|
|
533
|
+
});
|
|
534
|
+
let seat = { x: (tipX + long.x) / 2 - w / 2, y: y - h / 2, w, h };
|
|
535
|
+
return input.occupied.claim({ x: tipX, y: y - 2, w: Math.max(seat.x - 2 - tipX, 0), h: 4 }, "annotation", { annotationId: annId }), input.occupied.claim({ x: seat.x + seat.w + 2, y: y - 2, w: Math.max(long.x - seat.x - seat.w - 2, 0), h: 4 }, "annotation", { annotationId: annId }), claimArrowHead(input.occupied, annId, tipX, y), labelRequests.push({
|
|
536
|
+
id: `annotation:${annId}`,
|
|
537
|
+
kind: "annotation",
|
|
538
|
+
role: computedTextRole(text, computed),
|
|
539
|
+
owner: { annotationId: annId },
|
|
540
|
+
text,
|
|
541
|
+
lines: [text],
|
|
542
|
+
runs,
|
|
543
|
+
typeRole: "label",
|
|
544
|
+
font: regular,
|
|
545
|
+
priority: pass.priority ?? PRIORITY.valueLine,
|
|
546
|
+
candidates: [
|
|
547
|
+
{ slot: "onArrow", rect: seat, penalty: 0, needsBacking: !0, contrast: "box" },
|
|
548
|
+
{ slot: "above", rect: { ...seat, y: y - h - 6 }, penalty: 1, needsBacking: !0 },
|
|
549
|
+
{ slot: "below", rect: { ...seat, y: y + 6 }, penalty: 2, needsBacking: !0 }
|
|
550
|
+
]
|
|
551
|
+
}), placed.push({
|
|
552
|
+
id: annId,
|
|
553
|
+
kind: "diff",
|
|
554
|
+
computedText: computed,
|
|
555
|
+
tone: parts.value.startsWith("\u2212") || parts.value.startsWith("-") ? "bad" : "neutral",
|
|
556
|
+
nodeIds: [lineId, headId],
|
|
557
|
+
labelId: `annotation:${annId}`,
|
|
558
|
+
...derivation ? { derivation } : {}
|
|
559
|
+
}), !0;
|
|
560
|
+
}
|
|
561
|
+
function drawCagrArm(pass, a, b, text, annId, computed, derivation, parts) {
|
|
562
|
+
if (pass.input.comparisonLayout) {
|
|
563
|
+
pass.input.comparisonLayout.draw(pass, a, b, text, annId, "cagr", computed, derivation);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (pass.input.valueAxis === "horizontal") {
|
|
567
|
+
drawShiftedCagrArm(pass, a, b, text, annId, computed, derivation, parts);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
drawLiftedCagrArm(pass, a, b, text, annId, computed, derivation);
|
|
571
|
+
}
|
|
572
|
+
function drawDiffArm(pass, a, b, text, annId, computed, derivation, parts) {
|
|
573
|
+
if (pass.input.comparisonLayout) {
|
|
574
|
+
pass.input.comparisonLayout.draw(pass, a, b, text, annId, "diff", computed, derivation);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (pass.input.valueAxis === "horizontal") {
|
|
578
|
+
if (parts && drawInsetBarGap(pass, a, b, text, annId, computed, parts, derivation)) return;
|
|
579
|
+
drawHorizontalLevelDiff(pass, a, b, text, annId, computed, derivation);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
drawVerticalLevelDiff(pass, a, b, text, annId, computed, derivation);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/core/annotateTargets.ts
|
|
586
|
+
function clipRect(rect, plot) {
|
|
587
|
+
let x = Math.max(rect.x, plot.x), y = Math.max(rect.y, plot.y), x2 = Math.min(rect.x + rect.w, plot.x + plot.w), y2 = Math.min(rect.y + rect.h, plot.y + plot.h);
|
|
588
|
+
return x2 <= x || y2 <= y ? null : { x, y, w: x2 - x, h: y2 - y };
|
|
589
|
+
}
|
|
590
|
+
function isCeilingClaim(o, ceilingRects) {
|
|
591
|
+
return !!(o.kind === "frame" || o.kind === "legend" || o.part === "axisTitle" || o.part === "axis:y:title" || o.kind === "label" && ceilingRects?.some((r) => rectsOverlap(o.rect, r, 1)));
|
|
592
|
+
}
|
|
593
|
+
function valueMapper(input) {
|
|
594
|
+
return input.yScale ? { scale: input.yScale, axis: "y" } : input.xScale ? { scale: input.xScale, axis: "x" } : null;
|
|
595
|
+
}
|
|
596
|
+
function categorySpanRect(from, to, plot) {
|
|
597
|
+
if (isCategoryAlongY(from) && isCategoryAlongY(to)) {
|
|
598
|
+
let y0 = Math.min(from.y, to.y), y1 = Math.max(from.y + from.h, to.y + to.h);
|
|
599
|
+
return { x: plot.x, y: y0, w: plot.w, h: Math.max(y1 - y0, 0) };
|
|
600
|
+
}
|
|
601
|
+
let a = from, b = to, x0 = Math.min(a.x, b.x), x1 = Math.max(a.x + a.w, b.x + b.w);
|
|
602
|
+
return { x: x0, y: plot.y, w: Math.max(x1 - x0, 0), h: plot.h };
|
|
603
|
+
}
|
|
604
|
+
function valueBandRect(span, low, high, mapper, plot) {
|
|
605
|
+
let a = mapper.scale(low), b = mapper.scale(high);
|
|
606
|
+
if (!Number.isFinite(a) || !Number.isFinite(b)) return null;
|
|
607
|
+
let rect = mapper.axis === "y" ? { x: span.x, y: Math.min(a, b), w: span.w, h: Math.abs(b - a) } : { x: Math.min(a, b), y: span.y, w: Math.abs(b - a), h: span.h };
|
|
608
|
+
return clipRect(rect, plot);
|
|
609
|
+
}
|
|
610
|
+
function valueLineStroke(plot, valuePx, axis) {
|
|
611
|
+
return axis === "x" ? { x1: valuePx, y1: plot.y, x2: valuePx, y2: plot.y + plot.h } : { x1: plot.x, y1: valuePx, x2: plot.x + plot.w, y2: valuePx };
|
|
612
|
+
}
|
|
613
|
+
function finitePair(low, high) {
|
|
614
|
+
return typeof low != "number" || typeof high != "number" || !Number.isFinite(low) || !Number.isFinite(high) || low === high ? null : { low, high };
|
|
615
|
+
}
|
|
616
|
+
function pushWarn(warnings, id, code, message) {
|
|
617
|
+
warnings.push({ code, severity: "warn", message, owner: { annotationId: id } });
|
|
618
|
+
}
|
|
619
|
+
function idsInSpan(ids, from, to) {
|
|
620
|
+
if (from === void 0 && to === void 0) return ids;
|
|
621
|
+
if (from === void 0 || to === void 0)
|
|
622
|
+
return "a category span needs both 'from' and 'to' (inclusive, like band)";
|
|
623
|
+
let i = ids.indexOf(from), j = ids.indexOf(to);
|
|
624
|
+
if (i < 0 || j < 0) return "unresolvable category span";
|
|
625
|
+
let a = Math.min(i, j), b = Math.max(i, j);
|
|
626
|
+
return ids.slice(a, b + 1);
|
|
627
|
+
}
|
|
628
|
+
var PLAN_CORRIDOR_TINT = 0.72;
|
|
629
|
+
function scenarioPaint(scenario) {
|
|
630
|
+
let used = scenario ?? "PL";
|
|
631
|
+
return used === "PL" ? {
|
|
632
|
+
// Outline renderers use fill as the border ink and supply the background.
|
|
633
|
+
fill: { token: "ink" },
|
|
634
|
+
pattern: "outline"
|
|
635
|
+
} : used === "FC" ? { fill: { token: "others" }, pattern: "hatch45" } : used === "PY" ? { fill: { token: "neutralLight" } } : { fill: { token: "others" } };
|
|
636
|
+
}
|
|
637
|
+
function overlapBand(ctx, rect) {
|
|
638
|
+
for (let prior of ctx.bandSpans) {
|
|
639
|
+
let overlap = Math.min(rect.x + rect.w, prior.rect.x + prior.rect.w) - Math.max(rect.x, prior.rect.x), yOverlap = Math.min(rect.y + rect.h, prior.rect.y + prior.rect.h) - Math.max(rect.y, prior.rect.y);
|
|
640
|
+
overlap > 0 && yOverlap > 0 && ctx.warnings.push({
|
|
641
|
+
code: "band-overlap",
|
|
642
|
+
severity: "warn",
|
|
643
|
+
message: `band '${ctx.id}' overlaps band '${prior.id}'`,
|
|
644
|
+
owner: { annotationId: ctx.id }
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
ctx.bandSpans.push({ id: ctx.id, rect });
|
|
648
|
+
}
|
|
649
|
+
function corridorLabel(ctx, ann, rect, nodeIds) {
|
|
650
|
+
let text = ann.label ?? "", labelId = text ? `annotation:${ctx.id}` : void 0;
|
|
651
|
+
if (text) {
|
|
652
|
+
let font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis }, size = ctx.input.measure(text, font), alongY = valueMapper(ctx.input)?.axis === "y", candidates = size.width + 8 <= rect.w && size.height + 8 <= rect.h ? [
|
|
653
|
+
{
|
|
654
|
+
slot: "topLeftInside",
|
|
655
|
+
rect: { x: rect.x + 4, y: rect.y + 4, w: size.width, h: size.height },
|
|
656
|
+
penalty: 0
|
|
657
|
+
}
|
|
658
|
+
] : alongY ? [
|
|
659
|
+
{
|
|
660
|
+
slot: "endOutside",
|
|
661
|
+
rect: {
|
|
662
|
+
x: rect.x + rect.w + 4,
|
|
663
|
+
y: rect.y + (rect.h - size.height) / 2,
|
|
664
|
+
w: size.width,
|
|
665
|
+
h: size.height
|
|
666
|
+
},
|
|
667
|
+
penalty: 0
|
|
668
|
+
}
|
|
669
|
+
] : [
|
|
670
|
+
{
|
|
671
|
+
slot: "above",
|
|
672
|
+
rect: {
|
|
673
|
+
x: rect.x + (rect.w - size.width) / 2,
|
|
674
|
+
y: rect.y - size.height - 4,
|
|
675
|
+
w: size.width,
|
|
676
|
+
h: size.height
|
|
677
|
+
},
|
|
678
|
+
penalty: 0
|
|
679
|
+
}
|
|
680
|
+
];
|
|
681
|
+
candidates.push({
|
|
682
|
+
slot: "above",
|
|
683
|
+
rect: { x: rect.x + (rect.w - size.width) / 2, y: rect.y - size.height - 4, w: size.width, h: size.height },
|
|
684
|
+
penalty: 1
|
|
685
|
+
}, {
|
|
686
|
+
slot: "bottomInside",
|
|
687
|
+
rect: { x: rect.x + 4, y: rect.y + rect.h - size.height - 4, w: size.width, h: size.height },
|
|
688
|
+
penalty: 2
|
|
689
|
+
}), ctx.labelRequests.push({
|
|
690
|
+
id: labelId,
|
|
691
|
+
kind: "annotation",
|
|
692
|
+
owner: { annotationId: ctx.id },
|
|
693
|
+
text,
|
|
694
|
+
lines: [text],
|
|
695
|
+
typeRole: "axis",
|
|
696
|
+
font,
|
|
697
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
698
|
+
candidates,
|
|
699
|
+
role: "note"
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
ctx.placed.push({ id: ctx.id, kind: "band", computedText: text, nodeIds, labelId });
|
|
703
|
+
}
|
|
704
|
+
function boundText(ctx, v) {
|
|
705
|
+
return ctx.input.format ? formatterFromExample(ctx.input.format, ctx.input.locale)(v) : formatAutomaticNumber(v, { locale: ctx.input.locale, decimals: autoDecimals(v) });
|
|
706
|
+
}
|
|
707
|
+
function boundLabels(ctx, rect, bounds, mapper, priority) {
|
|
708
|
+
let font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis };
|
|
709
|
+
for (let [end, value] of [["low", bounds.low], ["high", bounds.high]]) {
|
|
710
|
+
let text = boundText(ctx, value), size = ctx.input.measure(text, font), edge = mapper.scale(value), candidates = mapper.axis === "x" ? [
|
|
711
|
+
{ slot: "overEdge", rect: { x: edge - size.width / 2, y: rect.y - size.height - 4, w: size.width, h: size.height }, penalty: 0 },
|
|
712
|
+
{ slot: "insideEdge", rect: { x: edge < rect.x + rect.w / 2 ? edge + 3 : edge - 3 - size.width, y: rect.y + 4, w: size.width, h: size.height }, penalty: 1 }
|
|
713
|
+
] : [
|
|
714
|
+
{ slot: "insideEdgeRight", rect: { x: rect.x + rect.w - 4 - size.width, y: edge < rect.y + rect.h / 2 ? edge + 3 : edge - 3 - size.height, w: size.width, h: size.height }, penalty: 0 },
|
|
715
|
+
{ slot: "besideEdge", rect: { x: rect.x + rect.w + 4, y: edge - size.height / 2, w: size.width, h: size.height }, penalty: 1 },
|
|
716
|
+
{ slot: "insideEdgeLeft", rect: { x: rect.x + 4, y: edge < rect.y + rect.h / 2 ? edge + 3 : edge - 3 - size.height, w: size.width, h: size.height }, penalty: 2 }
|
|
717
|
+
];
|
|
718
|
+
ctx.labelRequests.push({
|
|
719
|
+
id: `annotation:${ctx.id}:${end}`,
|
|
720
|
+
kind: "annotation",
|
|
721
|
+
owner: { annotationId: ctx.id },
|
|
722
|
+
text,
|
|
723
|
+
lines: [text],
|
|
724
|
+
typeRole: "label",
|
|
725
|
+
font,
|
|
726
|
+
priority,
|
|
727
|
+
candidates,
|
|
728
|
+
role: "value"
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function edgeKnockouts(ctx, rect, axis) {
|
|
733
|
+
let nodes = [], edges = axis === "y" ? [rect.y, rect.y + rect.h] : [rect.x, rect.x + rect.w];
|
|
734
|
+
for (let claim of ctx.input.occupied.snapshot()) {
|
|
735
|
+
if (claim.kind !== "label") continue;
|
|
736
|
+
let r = claim.rect;
|
|
737
|
+
for (let edge of edges)
|
|
738
|
+
(axis === "y" ? r.y < edge && r.y + r.h > edge && r.x < rect.x + rect.w && r.x + r.w > rect.x : r.x < edge && r.x + r.w > edge && r.y < rect.y + rect.h && r.y + r.h > rect.y) && nodes.push({
|
|
739
|
+
t: "rect",
|
|
740
|
+
id: ctx.nid("edgeGap"),
|
|
741
|
+
fill: { token: "background" },
|
|
742
|
+
owner: { annotationId: ctx.id },
|
|
743
|
+
part: "band",
|
|
744
|
+
rect: axis === "y" ? { x: r.x - 1, y: edge - 2, w: r.w + 2, h: 4 } : { x: edge - 2, y: r.y - 1, w: 4, h: r.h + 2 }
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
return nodes;
|
|
748
|
+
}
|
|
749
|
+
function resolveSpan(ctx, from, to) {
|
|
750
|
+
let plot = ctx.input.bandPlot ?? ctx.input.plot;
|
|
751
|
+
if (from === void 0 && to === void 0) return plot;
|
|
752
|
+
if (!ctx.input.resolveCategoryBand)
|
|
753
|
+
return pushWarn(ctx.warnings, ctx.id, "unsupported", `band '${ctx.id}': chart has no category bands`), null;
|
|
754
|
+
if (from === void 0 || to === void 0)
|
|
755
|
+
return pushWarn(
|
|
756
|
+
ctx.warnings,
|
|
757
|
+
ctx.id,
|
|
758
|
+
"valueline-scope-invalid",
|
|
759
|
+
`band '${ctx.id}': a category span needs both 'from' and 'to' (inclusive, like band)`
|
|
760
|
+
), null;
|
|
761
|
+
let start = ctx.input.resolveCategoryBand(from), end = ctx.input.resolveCategoryBand(to);
|
|
762
|
+
return !start || !end ? (pushWarn(ctx.warnings, ctx.id, "bad-anchor", `band '${ctx.id}': unresolvable category span`), null) : categorySpanRect(start, end, plot);
|
|
763
|
+
}
|
|
764
|
+
function placeCorridorOrTolerance(ctx, ann, role) {
|
|
765
|
+
let mapper = valueMapper(ctx.input);
|
|
766
|
+
if (!mapper) {
|
|
767
|
+
pushWarn(ctx.warnings, ctx.id, "unsupported", `band '${ctx.id}': chart has no value scale`);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
let bounds = finitePair(ann.low, ann.high);
|
|
771
|
+
if (!bounds) {
|
|
772
|
+
pushWarn(
|
|
773
|
+
ctx.warnings,
|
|
774
|
+
ctx.id,
|
|
775
|
+
"band-bounds-invalid",
|
|
776
|
+
`band '${ctx.id}': ${role} needs finite, unequal 'low' and 'high'`
|
|
777
|
+
);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
let span = resolveSpan(ctx, ann.from, ann.to);
|
|
781
|
+
if (!span) return;
|
|
782
|
+
let plot = ctx.input.bandPlot ?? ctx.input.plot, rect = valueBandRect(span, bounds.low, bounds.high, mapper, plot);
|
|
783
|
+
if (!rect) {
|
|
784
|
+
pushWarn(
|
|
785
|
+
ctx.warnings,
|
|
786
|
+
ctx.id,
|
|
787
|
+
"band-bounds-offscale",
|
|
788
|
+
`band '${ctx.id}': ${role} ${bounds.low} to ${bounds.high} lies outside the value axis`
|
|
789
|
+
);
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
overlapBand(ctx, rect);
|
|
793
|
+
let bandId = ctx.nid("band"), paint = role === "corridor" ? scenarioPaint(ann.scenario) : { fill: { token: "others", tint: 0.45 } }, planRange = paint.pattern === "outline";
|
|
794
|
+
ctx.nodes.push({
|
|
795
|
+
t: "rect",
|
|
796
|
+
id: bandId,
|
|
797
|
+
rect,
|
|
798
|
+
...planRange ? { fill: { token: "others", tint: PLAN_CORRIDOR_TINT } } : paint,
|
|
799
|
+
owner: { annotationId: ctx.id },
|
|
800
|
+
part: "band"
|
|
801
|
+
});
|
|
802
|
+
let edges = planRange ? (mapper.axis === "y" ? [rect.y, rect.y + rect.h] : [rect.x, rect.x + rect.w]).map((at) => ({
|
|
803
|
+
t: "line",
|
|
804
|
+
id: ctx.nid("edge"),
|
|
805
|
+
...mapper.axis === "y" ? { x1: rect.x, x2: rect.x + rect.w, y1: at, y2: at } : { x1: at, x2: at, y1: rect.y, y2: rect.y + rect.h },
|
|
806
|
+
stroke: { token: "ink" },
|
|
807
|
+
width: strokeToken(ctx.input.theme, "hair"),
|
|
808
|
+
owner: { annotationId: ctx.id },
|
|
809
|
+
part: "band"
|
|
810
|
+
})) : [];
|
|
811
|
+
pushAll(ctx.nodes, edges);
|
|
812
|
+
let gaps = planRange ? edgeKnockouts(ctx, rect, mapper.axis) : [];
|
|
813
|
+
pushAll(ctx.nodes, gaps), corridorLabel(ctx, ann, rect, [bandId, ...edges.map((node) => node.id), ...gaps.map((node) => node.id)]), boundLabels(ctx, rect, bounds, mapper, ann.priority ?? PRIORITY.valueLine), ctx.placed[ctx.placed.length - 1].derivation = {
|
|
814
|
+
basis: "authored",
|
|
815
|
+
op: role === "corridor" ? "annotation-corridor@1" : "annotation-tolerance@1",
|
|
816
|
+
inputs: [
|
|
817
|
+
{ ref: `${ctx.id}.low`, value: bounds.low, state: "authored" },
|
|
818
|
+
{ ref: `${ctx.id}.high`, value: bounds.high, state: "authored" }
|
|
819
|
+
],
|
|
820
|
+
raw: bounds.high - bounds.low
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
function attainmentTone(actual, plan, direction) {
|
|
824
|
+
return actual === plan || actual > plan === (direction === "higherIsBetter") ? "good" : "bad";
|
|
825
|
+
}
|
|
826
|
+
function placeAttainmentBand(ctx, ann) {
|
|
827
|
+
let mapper = valueMapper(ctx.input);
|
|
828
|
+
if (!mapper) {
|
|
829
|
+
pushWarn(ctx.warnings, ctx.id, "unsupported", `band '${ctx.id}': chart has no value scale`);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
let plan = ann.value;
|
|
833
|
+
if (typeof plan != "number" || !Number.isFinite(plan)) {
|
|
834
|
+
pushWarn(
|
|
835
|
+
ctx.warnings,
|
|
836
|
+
ctx.id,
|
|
837
|
+
"band-bounds-invalid",
|
|
838
|
+
`band '${ctx.id}': attainment needs a finite plan 'value'`
|
|
839
|
+
);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
let ids = ctx.input.categoryIds;
|
|
843
|
+
if (!ids || ids.length === 0) {
|
|
844
|
+
pushWarn(ctx.warnings, ctx.id, "unsupported", `band '${ctx.id}': chart has no category list for attainment`);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
let spanIds = idsInSpan(ids, ann.from, ann.to);
|
|
848
|
+
if (typeof spanIds == "string") {
|
|
849
|
+
pushWarn(ctx.warnings, ctx.id, "bad-anchor", `band '${ctx.id}': ${spanIds}`);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
let direction = ann.direction ?? "higherIsBetter", plot = ctx.input.bandPlot ?? ctx.input.plot, nodeIds = [], lastActual = null, lastCategoryId = null, painted = 0, valueless2;
|
|
853
|
+
for (let categoryId of spanIds) {
|
|
854
|
+
let ref = ann.seriesId ? { categoryId, seriesId: ann.seriesId } : categoryId, actual = ctx.input.resolve(ref);
|
|
855
|
+
if (actual?.noValue !== void 0 && (valueless2 ??= actual.noValue), !actual || actual.noValue !== void 0) continue;
|
|
856
|
+
let band = ctx.input.resolveCategoryBand?.(categoryId);
|
|
857
|
+
if (!band) continue;
|
|
858
|
+
let span = categorySpanRect(band, band, plot), rect = valueBandRect(span, actual.value, plan, mapper, plot);
|
|
859
|
+
if (!rect) continue;
|
|
860
|
+
lastActual = actual.value, lastCategoryId = categoryId, painted += 1;
|
|
861
|
+
let tone = attainmentTone(actual.value, plan, direction), nodeId = ctx.nid(`attainment-${categoryId}`);
|
|
862
|
+
nodeIds.push(nodeId), ctx.nodes.push({
|
|
863
|
+
t: "rect",
|
|
864
|
+
id: nodeId,
|
|
865
|
+
rect,
|
|
866
|
+
// A band between the actual and the plan is a large signed fill.
|
|
867
|
+
fill: signedFillPaint(tone),
|
|
868
|
+
owner: { annotationId: ctx.id, categoryId, seriesId: ann.seriesId },
|
|
869
|
+
part: "attainment"
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
if (painted === 0 && valueless2 !== void 0) {
|
|
873
|
+
ctx.warnings.push({
|
|
874
|
+
code: "bad-anchor",
|
|
875
|
+
severity: "warn",
|
|
876
|
+
owner: { annotationId: ctx.id },
|
|
877
|
+
message: `band '${ctx.id}': ${valueless2}, so it prints no value there`,
|
|
878
|
+
suggest: VALUELESS_ANCHOR_FIX
|
|
879
|
+
});
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
if (painted === 0) {
|
|
883
|
+
pushWarn(
|
|
884
|
+
ctx.warnings,
|
|
885
|
+
ctx.id,
|
|
886
|
+
"band-attainment-empty",
|
|
887
|
+
`band '${ctx.id}': no drawable attainment cells \u2014 missing or suppressed values were skipped`
|
|
888
|
+
);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
let ratio = lastActual !== null && plan !== 0 ? lastActual / plan : null, text = ann.label ?? (ratio === null ? "" : formatAutomaticPercent(ratio * 100, 0, !1, ctx.input.locale)), labelId = text ? `annotation:${ctx.id}` : void 0;
|
|
892
|
+
if (text && labelId) {
|
|
893
|
+
let font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.label }, size = ctx.input.measure(text, font), last = ctx.nodes[ctx.nodes.length - 1], anchor = last && last.t === "rect" ? last.rect : plot;
|
|
894
|
+
ctx.labelRequests.push({
|
|
895
|
+
id: labelId,
|
|
896
|
+
kind: "annotation",
|
|
897
|
+
owner: { annotationId: ctx.id },
|
|
898
|
+
text,
|
|
899
|
+
lines: [text],
|
|
900
|
+
typeRole: "label",
|
|
901
|
+
font,
|
|
902
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
903
|
+
// An authored label is prose; the fallback prints the attainment percent.
|
|
904
|
+
role: ann.label ? "note" : "value",
|
|
905
|
+
candidates: [
|
|
906
|
+
{
|
|
907
|
+
slot: "end",
|
|
908
|
+
rect: {
|
|
909
|
+
x: mapper.axis === "y" ? anchor.x + anchor.w + 4 : anchor.x + (anchor.w - size.width) / 2,
|
|
910
|
+
y: mapper.axis === "y" ? anchor.y - size.height / 2 : anchor.y - size.height - 4,
|
|
911
|
+
w: size.width,
|
|
912
|
+
h: size.height
|
|
913
|
+
},
|
|
914
|
+
penalty: 0
|
|
915
|
+
}
|
|
916
|
+
]
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
let derivation = {
|
|
920
|
+
basis: "derived",
|
|
921
|
+
op: "annotation-attainment@1",
|
|
922
|
+
inputs: [
|
|
923
|
+
{ ref: lastCategoryId === null ? "actual" : `actual:${lastCategoryId}`, value: lastActual },
|
|
924
|
+
{ ref: `${ctx.id}.value`, value: plan, state: "authored" }
|
|
925
|
+
],
|
|
926
|
+
raw: ratio
|
|
927
|
+
};
|
|
928
|
+
ctx.placed.push({
|
|
929
|
+
id: ctx.id,
|
|
930
|
+
kind: "band",
|
|
931
|
+
computedText: text,
|
|
932
|
+
nodeIds,
|
|
933
|
+
labelId,
|
|
934
|
+
derivation
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
function refuseUnsupportedBand(ctx, ann, style) {
|
|
938
|
+
return ann.divider ? (pushWarn(
|
|
939
|
+
ctx.warnings,
|
|
940
|
+
ctx.id,
|
|
941
|
+
"band-combination-unsupported",
|
|
942
|
+
`band '${ctx.id}': divider applies only to bracket era bands, not ${style}`
|
|
943
|
+
), !0) : ann.tone !== void 0 && (style === "corridor" || style === "tolerance" || style === "attainment") ? (pushWarn(
|
|
944
|
+
ctx.warnings,
|
|
945
|
+
ctx.id,
|
|
946
|
+
"band-combination-unsupported",
|
|
947
|
+
`band '${ctx.id}': tone applies to era bands; ${style} uses scenario or good/bad tokens`
|
|
948
|
+
), !0) : style !== "attainment" && ann.seriesId !== void 0 ? (pushWarn(
|
|
949
|
+
ctx.warnings,
|
|
950
|
+
ctx.id,
|
|
951
|
+
"band-combination-unsupported",
|
|
952
|
+
`band '${ctx.id}': seriesId is used only with style 'attainment'`
|
|
953
|
+
), !0) : style === "attainment" && (ann.low !== void 0 || ann.high !== void 0) ? (pushWarn(
|
|
954
|
+
ctx.warnings,
|
|
955
|
+
ctx.id,
|
|
956
|
+
"band-combination-unsupported",
|
|
957
|
+
`band '${ctx.id}': attainment uses 'value' as the plan, not low/high`
|
|
958
|
+
), !0) : style !== "corridor" && ann.scenario !== void 0 ? (pushWarn(
|
|
959
|
+
ctx.warnings,
|
|
960
|
+
ctx.id,
|
|
961
|
+
"band-combination-unsupported",
|
|
962
|
+
`band '${ctx.id}': scenario notation applies to plan corridors`
|
|
963
|
+
), !0) : !1;
|
|
964
|
+
}
|
|
965
|
+
function placeTargetBand(ctx, ann) {
|
|
966
|
+
let style = ann.style;
|
|
967
|
+
return style !== "corridor" && style !== "tolerance" && style !== "attainment" ? !1 : (refuseUnsupportedBand(ctx, ann, style) || (style === "attainment" ? placeAttainmentBand(ctx, ann) : placeCorridorOrTolerance(ctx, ann, style)), !0);
|
|
968
|
+
}
|
|
969
|
+
function toleranceBounds(value, tolerance) {
|
|
970
|
+
if (typeof tolerance == "number")
|
|
971
|
+
return !Number.isFinite(tolerance) || tolerance <= 0 ? "tolerance must be a positive finite number" : { low: value - tolerance, high: value + tolerance };
|
|
972
|
+
let pair = finitePair(tolerance.low, tolerance.high);
|
|
973
|
+
return pair || "tolerance bounds need finite, unequal 'low' and 'high'";
|
|
974
|
+
}
|
|
975
|
+
function placeValueLineTargets(ctx, ann, value) {
|
|
976
|
+
let mapper = valueMapper(ctx.input);
|
|
977
|
+
if (!mapper) return;
|
|
978
|
+
if (ann.tolerance !== void 0) {
|
|
979
|
+
let bounds = toleranceBounds(value, ann.tolerance);
|
|
980
|
+
if (typeof bounds == "string")
|
|
981
|
+
pushWarn(ctx.warnings, ctx.id, "valueline-tolerance-invalid", `valueLine '${ctx.id}': ${bounds}`);
|
|
982
|
+
else {
|
|
983
|
+
let plot = ctx.input.bandPlot ?? ctx.input.plot, span = resolveSpan(ctx, ann.from, ann.to), rect = span ? valueBandRect(span, bounds.low, bounds.high, mapper, plot) : null;
|
|
984
|
+
if (rect) {
|
|
985
|
+
let bandId = ctx.nid("tolerance");
|
|
986
|
+
ctx.nodes.push({
|
|
987
|
+
t: "rect",
|
|
988
|
+
id: bandId,
|
|
989
|
+
rect,
|
|
990
|
+
fill: { token: "others", tint: 0.45 },
|
|
991
|
+
owner: { annotationId: ctx.id },
|
|
992
|
+
part: "band"
|
|
993
|
+
});
|
|
994
|
+
let placed = ctx.placed.find((item) => item.id === ctx.id), low = boundText(ctx, bounds.low), high = boundText(ctx, bounds.high);
|
|
995
|
+
placed && (placed.nodeIds = [bandId, ...placed.nodeIds], placed.toleranceText = { low, high });
|
|
996
|
+
let text = chartString({ locale: ctx.input.locale, strings: ctx.input.strings }, "valueLineRange", { v1: low, v2: high }), font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis }, size = ctx.input.measure(text, font), at = (x, y) => ({ x, y, w: size.width, h: size.height }), right = rect.x + rect.w - 4 - size.width;
|
|
997
|
+
ctx.labelRequests.push({
|
|
998
|
+
id: `annotation:${ctx.id}:tolerance`,
|
|
999
|
+
kind: "annotation",
|
|
1000
|
+
owner: { annotationId: ctx.id },
|
|
1001
|
+
text,
|
|
1002
|
+
lines: [text],
|
|
1003
|
+
typeRole: "footnote",
|
|
1004
|
+
font,
|
|
1005
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
1006
|
+
role: "note",
|
|
1007
|
+
candidates: mapper.axis === "y" ? [
|
|
1008
|
+
{ slot: "insideTopRight", rect: at(right, rect.y + 3), penalty: 0 },
|
|
1009
|
+
{ slot: "insideBottomRight", rect: at(right, rect.y + rect.h - 3 - size.height), penalty: 1 },
|
|
1010
|
+
{ slot: "insideTopLeft", rect: at(rect.x + 4, rect.y + 3), penalty: 2 }
|
|
1011
|
+
] : [
|
|
1012
|
+
{ slot: "above", rect: at(rect.x + (rect.w - size.width) / 2, rect.y - size.height - 4), penalty: 0 },
|
|
1013
|
+
{ slot: "insideTop", rect: at(rect.x + (rect.w - size.width) / 2, rect.y + 4), penalty: 1 }
|
|
1014
|
+
]
|
|
1015
|
+
});
|
|
1016
|
+
} else span && pushWarn(
|
|
1017
|
+
ctx.warnings,
|
|
1018
|
+
ctx.id,
|
|
1019
|
+
"band-bounds-offscale",
|
|
1020
|
+
`valueLine '${ctx.id}': tolerance band ${bounds.low} to ${bounds.high} lies outside the value axis`
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
if (ann.attainment === void 0 || ann.attainment === !1) return;
|
|
1025
|
+
let spec = ann.attainment === !0 ? {} : ann.attainment, fakeBand = {
|
|
1026
|
+
kind: "band",
|
|
1027
|
+
style: "attainment",
|
|
1028
|
+
value,
|
|
1029
|
+
seriesId: spec.seriesId,
|
|
1030
|
+
from: ann.from,
|
|
1031
|
+
to: ann.to,
|
|
1032
|
+
direction: spec.direction,
|
|
1033
|
+
label: typeof ann.label == "string" ? ann.label : void 0,
|
|
1034
|
+
priority: ann.priority
|
|
1035
|
+
}, inner = { ...ctx, id: ctx.id }, before = ctx.placed.length;
|
|
1036
|
+
if (placeAttainmentBand(inner, fakeBand), ctx.placed.length > before) {
|
|
1037
|
+
let extra = ctx.placed.pop(), host = ctx.placed.find((item) => item.id === ctx.id);
|
|
1038
|
+
host && (host.nodeIds = [...host.nodeIds, ...extra.nodeIds], host.derivation = extra.derivation, extra.computedText && !host.computedText && (host.computedText = extra.computedText));
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function placeEraBand(ctx, ann) {
|
|
1042
|
+
if (!ctx.input.resolveCategoryBand) {
|
|
1043
|
+
pushWarn(ctx.warnings, ctx.id, "unsupported", `band '${ctx.id}': chart has no category bands`);
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (ann.from === void 0 || ann.to === void 0) {
|
|
1047
|
+
pushWarn(ctx.warnings, ctx.id, "bad-anchor", `band '${ctx.id}': era band needs inclusive category from and to`);
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
let from = ctx.input.resolveCategoryBand(ann.from), to = ctx.input.resolveCategoryBand(ann.to);
|
|
1051
|
+
if (!from || !to) {
|
|
1052
|
+
pushWarn(ctx.warnings, ctx.id, "bad-anchor", `band '${ctx.id}': unresolvable category span`);
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
let bandPlot = ctx.input.bandPlot ?? ctx.input.plot, rect = categorySpanRect(from, to, bandPlot);
|
|
1056
|
+
if (rect.w < 0.5 && rect.h > 0 && !isCategoryAlongY(from) && !isCategoryAlongY(to) && from.x === to.x) {
|
|
1057
|
+
let slot = ctx.input.resolvePeriodSlot?.(ann.from);
|
|
1058
|
+
if (!slot || isCategoryAlongY(slot) || slot.w < 0.5) {
|
|
1059
|
+
pushWarn(
|
|
1060
|
+
ctx.warnings,
|
|
1061
|
+
ctx.id,
|
|
1062
|
+
"band-zero-width",
|
|
1063
|
+
`band '${ctx.id}': from and to are the same x (${String(ann.from)}) and no drawn period sits there, so the band has no width and is not drawn; give 'to' a later x`
|
|
1064
|
+
);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
rect = categorySpanRect(slot, slot, bandPlot);
|
|
1068
|
+
}
|
|
1069
|
+
overlapBand(ctx, rect), (ann.style ?? "shade") === "shade" ? placeEraShade(ctx, ann, rect) : placeEraBracket(ctx, ann, rect, bandPlot);
|
|
1070
|
+
}
|
|
1071
|
+
function placeEraShade(ctx, ann, rect) {
|
|
1072
|
+
let bandId = ctx.nid("band"), adjacent = ctx.nodes.filter((node) => node.t === "rect" && node.part === "band");
|
|
1073
|
+
for (let node of adjacent) {
|
|
1074
|
+
if (node.t !== "rect") continue;
|
|
1075
|
+
let other = node.rect, sameRows = Math.abs(other.y - rect.y) < 0.01 && Math.abs(other.h - rect.h) < 0.01, sameColumns = Math.abs(other.x - rect.x) < 0.01 && Math.abs(other.w - rect.w) < 0.01, x = Math.abs(other.x + other.w - rect.x) < 0.01 ? rect.x : Math.abs(rect.x + rect.w - other.x) < 0.01 ? other.x : void 0, y = Math.abs(other.y + other.h - rect.y) < 0.01 ? rect.y : Math.abs(rect.y + rect.h - other.y) < 0.01 ? other.y : void 0;
|
|
1076
|
+
(sameRows && x !== void 0 || sameColumns && y !== void 0) && ctx.nodes.push({
|
|
1077
|
+
t: "line",
|
|
1078
|
+
id: ctx.nid(`boundary:${node.id}`),
|
|
1079
|
+
...sameRows && x !== void 0 ? { x1: x, x2: x, y1: rect.y, y2: rect.y + rect.h } : { x1: rect.x, x2: rect.x + rect.w, y1: y, y2: y },
|
|
1080
|
+
stroke: { token: "inkMuted" },
|
|
1081
|
+
width: strokeToken(ctx.input.theme, "hair"),
|
|
1082
|
+
owner: { annotationId: ctx.id },
|
|
1083
|
+
part: "bandBoundary"
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
ctx.nodes.push({
|
|
1087
|
+
t: "rect",
|
|
1088
|
+
id: bandId,
|
|
1089
|
+
rect,
|
|
1090
|
+
fill: { token: "others" },
|
|
1091
|
+
owner: { annotationId: ctx.id },
|
|
1092
|
+
part: "band"
|
|
1093
|
+
});
|
|
1094
|
+
let text = ann.label ?? "", labelId = ann.label ? `annotation:${ctx.id}` : void 0;
|
|
1095
|
+
if (ann.label) {
|
|
1096
|
+
let font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis }, size = ctx.input.measure(text, font), candidates = size.width + 8 <= rect.w && size.height + 8 <= rect.h ? [
|
|
1097
|
+
{
|
|
1098
|
+
slot: "topCenterInside",
|
|
1099
|
+
rect: { x: rect.x + (rect.w - size.width) / 2, y: rect.y + 4, w: size.width, h: size.height },
|
|
1100
|
+
penalty: 0
|
|
1101
|
+
},
|
|
1102
|
+
{ slot: "topLeftInside", rect: { x: rect.x + 4, y: rect.y + 4, w: size.width, h: size.height }, penalty: 1 }
|
|
1103
|
+
] : [];
|
|
1104
|
+
size.width <= rect.w && candidates.push({
|
|
1105
|
+
slot: "aboveBand",
|
|
1106
|
+
rect: { x: rect.x + (rect.w - size.width) / 2, y: rect.y - size.height - 4, w: size.width, h: size.height },
|
|
1107
|
+
penalty: 2
|
|
1108
|
+
}), candidates.push(
|
|
1109
|
+
{ slot: "aboveBandEnd", rect: { x: rect.x + rect.w - size.width, y: rect.y - size.height - 4, w: size.width, h: size.height }, penalty: 3 },
|
|
1110
|
+
{ slot: "aboveBandStart", rect: { x: rect.x, y: rect.y - size.height - 4, w: size.width, h: size.height }, penalty: 4 }
|
|
1111
|
+
), ctx.labelRequests.push({
|
|
1112
|
+
id: labelId,
|
|
1113
|
+
kind: "annotation",
|
|
1114
|
+
owner: { annotationId: ctx.id },
|
|
1115
|
+
text,
|
|
1116
|
+
lines: [text],
|
|
1117
|
+
noteText: ann.label,
|
|
1118
|
+
typeRole: "axis",
|
|
1119
|
+
font,
|
|
1120
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
1121
|
+
candidates,
|
|
1122
|
+
role: "note"
|
|
1123
|
+
}), ctx.eraBands?.push({
|
|
1124
|
+
annotationId: ctx.id,
|
|
1125
|
+
labelId,
|
|
1126
|
+
text,
|
|
1127
|
+
noteText: ann.label,
|
|
1128
|
+
font,
|
|
1129
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
1130
|
+
rect,
|
|
1131
|
+
bandPlot: ctx.input.bandPlot ?? ctx.input.plot,
|
|
1132
|
+
style: "shade",
|
|
1133
|
+
baseCandidates: candidates
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
ctx.placed.push({ id: ctx.id, kind: "band", computedText: text, nodeIds: [bandId], labelId });
|
|
1137
|
+
}
|
|
1138
|
+
function placeEraBracket(ctx, ann, rect, bandPlot) {
|
|
1139
|
+
let text = ann.label ?? "", labelId = ann.label ? `annotation:${ctx.id}` : void 0, font = { family: ctx.input.theme.type.family, ...ctx.input.theme.type.axis }, size = ctx.input.measure(text || "X", font), bracketY = bandPlot.y - ctx.input.plot.y >= size.height + 12 ? bandPlot.y - 7 : bandPlot.y + size.height + 6, left = rect.x, right = rect.x + rect.w, arrowInset = Math.min(5, rect.w / 2), bracketIds = [], lineId = ctx.nid("bracket");
|
|
1140
|
+
bracketIds.push(lineId), ctx.nodes.push({
|
|
1141
|
+
t: "line",
|
|
1142
|
+
id: lineId,
|
|
1143
|
+
x1: left + arrowInset,
|
|
1144
|
+
y1: bracketY,
|
|
1145
|
+
x2: right - arrowInset,
|
|
1146
|
+
y2: bracketY,
|
|
1147
|
+
stroke: { token: "ink" },
|
|
1148
|
+
width: strokeToken(ctx.input.theme, "rule"),
|
|
1149
|
+
owner: { annotationId: ctx.id },
|
|
1150
|
+
part: "bandBracket"
|
|
1151
|
+
});
|
|
1152
|
+
for (let [edge, x, angle] of [
|
|
1153
|
+
["start", left, Math.PI],
|
|
1154
|
+
["end", right, 0]
|
|
1155
|
+
]) {
|
|
1156
|
+
let headId = ctx.nid(`bracketHead-${edge}`);
|
|
1157
|
+
bracketIds.push(headId), ctx.nodes.push({
|
|
1158
|
+
t: "path",
|
|
1159
|
+
id: headId,
|
|
1160
|
+
d: arrowHeadPath({ x, y: bracketY }, angle, 5),
|
|
1161
|
+
fill: { token: "ink" },
|
|
1162
|
+
owner: { annotationId: ctx.id },
|
|
1163
|
+
part: "bandArrowHead"
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
ctx.input.occupied.claim(
|
|
1167
|
+
{ x: left - 1, y: bracketY - 4, w: rect.w + 2, h: 8 },
|
|
1168
|
+
"annotation",
|
|
1169
|
+
{ annotationId: ctx.id },
|
|
1170
|
+
"bandBracket"
|
|
1171
|
+
);
|
|
1172
|
+
let divider = ann.divider ?? !1;
|
|
1173
|
+
if ((divider === "both" ? [left, right] : divider === "start" ? [left] : divider === "end" ? [right] : []).forEach((x, edgeIndex) => {
|
|
1174
|
+
let dividerId = ctx.nid(`divider-${edgeIndex}`);
|
|
1175
|
+
bracketIds.push(dividerId), ctx.nodes.push({
|
|
1176
|
+
t: "line",
|
|
1177
|
+
id: dividerId,
|
|
1178
|
+
x1: x,
|
|
1179
|
+
y1: bandPlot.y,
|
|
1180
|
+
x2: x,
|
|
1181
|
+
y2: bandPlot.y + bandPlot.h,
|
|
1182
|
+
stroke: { token: "leader" },
|
|
1183
|
+
width: strokeToken(ctx.input.theme, "rule"),
|
|
1184
|
+
dash: dashToken(ctx.input.theme, "reference"),
|
|
1185
|
+
owner: { annotationId: ctx.id },
|
|
1186
|
+
part: "bandDivider"
|
|
1187
|
+
}), ctx.input.occupied.claim({ x: x - 1.5, y: bandPlot.y, w: 3, h: bandPlot.h }, "annotation", { annotationId: ctx.id }, "bandDivider");
|
|
1188
|
+
}), ann.label) {
|
|
1189
|
+
let candidates = [
|
|
1190
|
+
{
|
|
1191
|
+
slot: "aboveBracket",
|
|
1192
|
+
rect: { x: rect.x + (rect.w - size.width) / 2, y: bracketY - size.height - 3, w: size.width, h: size.height },
|
|
1193
|
+
penalty: 0
|
|
1194
|
+
}
|
|
1195
|
+
];
|
|
1196
|
+
ctx.labelRequests.push({
|
|
1197
|
+
id: labelId,
|
|
1198
|
+
kind: "annotation",
|
|
1199
|
+
owner: { annotationId: ctx.id },
|
|
1200
|
+
text,
|
|
1201
|
+
lines: [text],
|
|
1202
|
+
noteText: ann.label,
|
|
1203
|
+
typeRole: "axis",
|
|
1204
|
+
font,
|
|
1205
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
1206
|
+
role: "note",
|
|
1207
|
+
candidates
|
|
1208
|
+
}), ctx.eraBands?.push({
|
|
1209
|
+
annotationId: ctx.id,
|
|
1210
|
+
labelId,
|
|
1211
|
+
text,
|
|
1212
|
+
noteText: ann.label,
|
|
1213
|
+
font,
|
|
1214
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
1215
|
+
rect,
|
|
1216
|
+
bandPlot,
|
|
1217
|
+
style: "bracket",
|
|
1218
|
+
bracketY,
|
|
1219
|
+
baseCandidates: candidates
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
ctx.placed.push({ id: ctx.id, kind: "band", computedText: text, nodeIds: bracketIds, labelId });
|
|
1223
|
+
}
|
|
1224
|
+
function twoLineWrap(text, font, measure, singleHeight) {
|
|
1225
|
+
let words = text.trim().split(/\s+/);
|
|
1226
|
+
if (words.length < 2) return null;
|
|
1227
|
+
let best = null;
|
|
1228
|
+
for (let i = 1; i < words.length; i++) {
|
|
1229
|
+
let l1 = words.slice(0, i).join(" "), l2 = words.slice(i).join(" "), s1 = measure(l1, font), s2 = measure(l2, font), w = Math.max(s1.width, s2.width);
|
|
1230
|
+
(!best || w < best.width) && (best = { lines: [l1, l2], width: w, height: singleHeight * 2 });
|
|
1231
|
+
}
|
|
1232
|
+
return best;
|
|
1233
|
+
}
|
|
1234
|
+
function buildExtendedEraBandCandidates(plan, input, forHeadroomEstimate = !1) {
|
|
1235
|
+
let out = [...plan.baseCandidates], seen = new Set(out.map((c) => `${Math.round(c.rect.x * 10)}:${Math.round(c.rect.y * 10)}:${Math.round(c.rect.w * 10)}:${Math.round(c.rect.h * 10)}`)), push = (cand) => {
|
|
1236
|
+
let key = `${Math.round(cand.rect.x * 10)}:${Math.round(cand.rect.y * 10)}:${Math.round(cand.rect.w * 10)}:${Math.round(cand.rect.h * 10)}`;
|
|
1237
|
+
seen.has(key) || (seen.add(key), out.push(cand));
|
|
1238
|
+
}, { rect, font, text, style, bandPlot } = plan, size = input.measure(text, font), wrapped = twoLineWrap(text, font, input.measure, size.height), isHorizontalBar = input.xScale !== void 0 && input.yScale === void 0, stepsBetween = (start, end) => end > start ? [start + (end - start) / 3, start + 2 * (end - start) / 3] : [], abovePositions = (w, centerSlot, endSlot, startSlot) => {
|
|
1239
|
+
let list = [
|
|
1240
|
+
{ slot: centerSlot, x: rect.x + (rect.w - w) / 2, pen: 0 },
|
|
1241
|
+
{ slot: endSlot, x: rect.x + rect.w - w, pen: 0.1 },
|
|
1242
|
+
{ slot: startSlot, x: rect.x, pen: 0.22 }
|
|
1243
|
+
], lo = w + 8 <= rect.w ? rect.x + 4 : rect.x + Math.min(0, rect.w - w), hi = w + 8 <= rect.w ? rect.x + rect.w - w - 4 : rect.x;
|
|
1244
|
+
for (let x of stepsBetween(lo, hi)) list.push({ slot: centerSlot, x, pen: 0.35 });
|
|
1245
|
+
return list;
|
|
1246
|
+
}, addLiftedAbove = (w, h, baseY, basePen, centerSlot, endSlot, startSlot, lines) => {
|
|
1247
|
+
let horiz = abovePositions(w, centerSlot, endSlot, startSlot);
|
|
1248
|
+
for (let { slot, x, pen } of horiz)
|
|
1249
|
+
push({ slot, rect: { x, y: baseY, w, h }, penalty: basePen + pen, ...lines ? { lines } : {} });
|
|
1250
|
+
let maxLift = size.height * 3 + 16;
|
|
1251
|
+
for (let { slot, x, pen } of horiz) {
|
|
1252
|
+
let curY = baseY;
|
|
1253
|
+
for (let step = 0; step < 3; step++) {
|
|
1254
|
+
let hits = input.occupied.hitsWhich(
|
|
1255
|
+
{ x, y: curY, w, h },
|
|
1256
|
+
2,
|
|
1257
|
+
(o) => isCeilingClaim(o, input.ceilingRects) || o.kind === "annotation" && o.owner.annotationId === plan.annotationId
|
|
1258
|
+
);
|
|
1259
|
+
if (hits.length === 0) break;
|
|
1260
|
+
let nextY = minOf(hits.map((o) => o.rect.y)) - h - 2.5;
|
|
1261
|
+
if (nextY >= curY - 0.5 || baseY - nextY > maxLift) break;
|
|
1262
|
+
curY = nextY, push({ slot, rect: { x, y: curY, w, h }, penalty: basePen + 3 + step + pen, ...lines ? { lines } : {} });
|
|
1263
|
+
}
|
|
1264
|
+
for (let [stepIdx, dy] of [
|
|
1265
|
+
[0, 9],
|
|
1266
|
+
[1, size.height + 3],
|
|
1267
|
+
[2, 2 * (size.height + 3)]
|
|
1268
|
+
]) {
|
|
1269
|
+
let nextY = baseY - dy;
|
|
1270
|
+
baseY - nextY <= maxLift && push({ slot, rect: { x, y: nextY, w, h }, penalty: basePen + 4 + stepIdx + pen, ...lines ? { lines } : {} });
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
if (style === "shade") {
|
|
1275
|
+
if (size.height + 8 <= rect.h)
|
|
1276
|
+
if (size.width + 8 <= rect.w) {
|
|
1277
|
+
push({ slot: "topRightInside", rect: { x: rect.x + rect.w - size.width - 4, y: rect.y + 4, w: size.width, h: size.height }, penalty: 5 });
|
|
1278
|
+
for (let x of stepsBetween(rect.x + 4, rect.x + rect.w - size.width - 4))
|
|
1279
|
+
push({ slot: "topCenterInside", rect: { x, y: rect.y + 4, w: size.width, h: size.height }, penalty: 5.2 });
|
|
1280
|
+
isHorizontalBar && (push({ slot: "bottomLeftInside", rect: { x: rect.x + 4, y: rect.y + rect.h - size.height - 4, w: size.width, h: size.height }, penalty: 5.5 }), push({ slot: "bottomRightInside", rect: { x: rect.x + rect.w - size.width - 4, y: rect.y + rect.h - size.height - 4, w: size.width, h: size.height }, penalty: 5.6 }));
|
|
1281
|
+
} else size.width <= rect.w && push({ slot: "topCenterInside", rect: { x: rect.x + (rect.w - size.width) / 2, y: rect.y + 4, w: size.width, h: size.height }, penalty: 5 });
|
|
1282
|
+
if (wrapped && wrapped.height + 8 <= rect.h)
|
|
1283
|
+
if (wrapped.width + 8 <= rect.w) {
|
|
1284
|
+
push({ slot: "topCenterInside", rect: { x: rect.x + (rect.w - wrapped.width) / 2, y: rect.y + 4, w: wrapped.width, h: wrapped.height }, penalty: 6, lines: wrapped.lines }), push({ slot: "topLeftInside", rect: { x: rect.x + 4, y: rect.y + 4, w: wrapped.width, h: wrapped.height }, penalty: 6.1, lines: wrapped.lines }), push({ slot: "topRightInside", rect: { x: rect.x + rect.w - wrapped.width - 4, y: rect.y + 4, w: wrapped.width, h: wrapped.height }, penalty: 6.2, lines: wrapped.lines });
|
|
1285
|
+
for (let x of stepsBetween(rect.x + 4, rect.x + rect.w - wrapped.width - 4))
|
|
1286
|
+
push({ slot: "topCenterInside", rect: { x, y: rect.y + 4, w: wrapped.width, h: wrapped.height }, penalty: 6.3, lines: wrapped.lines });
|
|
1287
|
+
} else wrapped.width <= rect.w && push({ slot: "topCenterInside", rect: { x: rect.x + (rect.w - wrapped.width) / 2, y: rect.y + 4, w: wrapped.width, h: wrapped.height }, penalty: 6.1, lines: wrapped.lines });
|
|
1288
|
+
addLiftedAbove(size.width, size.height, rect.y - size.height - 4, 7, "aboveBand", "aboveBandEnd", "aboveBandStart"), wrapped && addLiftedAbove(wrapped.width, wrapped.height, rect.y - wrapped.height - 4, 9, "aboveBand", "aboveBandEnd", "aboveBandStart", wrapped.lines);
|
|
1289
|
+
} else {
|
|
1290
|
+
let bracketY = plan.bracketY ?? bandPlot.y - 7;
|
|
1291
|
+
if ((bracketY <= bandPlot.y || !forHeadroomEstimate) && (addLiftedAbove(size.width, size.height, bracketY - size.height - 3, 5, "aboveBracket", "aboveBracketEnd", "aboveBracketStart"), wrapped && addLiftedAbove(wrapped.width, wrapped.height, bracketY - wrapped.height - 3, 7, "aboveBracket", "aboveBracketEnd", "aboveBracketStart", wrapped.lines)), forHeadroomEstimate && bracketY > bandPlot.y) {
|
|
1292
|
+
let aboveBracketY = bandPlot.y - 7;
|
|
1293
|
+
addLiftedAbove(size.width, size.height, aboveBracketY - size.height - 3, 9, "aboveBracket", "aboveBracketEnd", "aboveBracketStart"), wrapped && addLiftedAbove(wrapped.width, wrapped.height, aboveBracketY - wrapped.height - 3, 11, "aboveBracket", "aboveBracketEnd", "aboveBracketStart", wrapped.lines);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return out;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// src/core/annotate.ts
|
|
1300
|
+
function anchorRefLabel(ref) {
|
|
1301
|
+
if (typeof ref == "string") return ref;
|
|
1302
|
+
let parts = [];
|
|
1303
|
+
for (let key of ["categoryId", "seriesId", "segmentId", "edge", "pointId", "valueLineId"]) {
|
|
1304
|
+
let value = ref[key];
|
|
1305
|
+
typeof value == "string" && parts.push(`${key}=${escapeRefPart(value)}`);
|
|
1306
|
+
}
|
|
1307
|
+
return parts.join("/");
|
|
1308
|
+
}
|
|
1309
|
+
function escapeRefPart(value) {
|
|
1310
|
+
return value.replaceAll("%", "%25").replaceAll("/", "%2F");
|
|
1311
|
+
}
|
|
1312
|
+
function calloutRole(kind, text, computed) {
|
|
1313
|
+
return kind === "callout" || kind === "note" ? "note" : computedTextRole(text, computed);
|
|
1314
|
+
}
|
|
1315
|
+
function calloutAttachment(at, kind, glyph) {
|
|
1316
|
+
return kind !== "callout" && kind !== "note" || !at.calloutPoint ? at : (glyph && (glyph.anchor = at.calloutPoint), { ...at, ...at.calloutPoint });
|
|
1317
|
+
}
|
|
1318
|
+
function comparisonAnchor(anchor) {
|
|
1319
|
+
return anchor?.comparisonPoint ? { ...anchor, ...anchor.comparisonPoint } : anchor;
|
|
1320
|
+
}
|
|
1321
|
+
function runAnnotatePass(input) {
|
|
1322
|
+
let resolveAnchor = input.resolve, resolveCategoryBand = input.resolveCategoryBand, anchorErrors = [];
|
|
1323
|
+
input = { ...input, ...resolveCategoryBand ? { resolveCategoryBand: (id) => {
|
|
1324
|
+
let result = resolveCategoryBand(id);
|
|
1325
|
+
return result || anchorErrors.push(`unknown category '${id}'; valid category ids: ${(input.categoryIds ?? []).join(", ")}`), result;
|
|
1326
|
+
} } : {}, resolve: (ref) => {
|
|
1327
|
+
let valid = typeof ref == "string" || typeof ref == "object" && ref !== null, result = valid ? resolveAnchor(ref) : null;
|
|
1328
|
+
if (!result && valid) {
|
|
1329
|
+
let categoryId = typeof ref == "string" ? ref : "categoryId" in ref ? ref.categoryId : void 0;
|
|
1330
|
+
input.anchorError ? anchorErrors.push(input.anchorError(ref)) : categoryId !== void 0 && input.categoryIds && !input.categoryIds.includes(categoryId) && anchorErrors.push(`unknown category '${categoryId}'; valid category ids: ${input.categoryIds.join(", ")}`);
|
|
1331
|
+
}
|
|
1332
|
+
return result;
|
|
1333
|
+
} };
|
|
1334
|
+
let nodes = [], placed = [], labelRequests = [], warnings = [], { locale } = input, percent = input.format ? specUnitKind(parseFormatExample(input.format)) === "percent" : input.percentLevels === !0, plain = (suffix, signed) => (v) => formatAutomaticNumber(v, { locale, decimals: autoDecimals(v), suffix, signed }), fmt = input.format ? formatterFromExample(input.format, locale) : plain(percent ? "%" : "", !1), differenceFormat = input.differenceFormat ?? (input.format ? differenceExample(input.format) : void 0), differenceSpec = differenceFormat ? { ...exampleSpec(differenceFormat, locale), signed: !0 } : void 0, run = {
|
|
1335
|
+
fmt,
|
|
1336
|
+
fmtSigned: differenceSpec ? (v) => formatWithSpec(v, differenceSpec) : plain(percent ? PERCENTAGE_POINTS : "", !0),
|
|
1337
|
+
printsZero: differenceSpec ? (v) => roundedNumber(v, differenceSpec) === 0 : (v) => roundsToZero(v, autoDecimals(v)),
|
|
1338
|
+
calloutGlyphPlans: /* @__PURE__ */ new Map(),
|
|
1339
|
+
calloutHeads: /* @__PURE__ */ new Map(),
|
|
1340
|
+
gapBrackets: [],
|
|
1341
|
+
eraBands: [],
|
|
1342
|
+
seq: 0,
|
|
1343
|
+
legDeficit: 0
|
|
1344
|
+
}, bandSpans = [];
|
|
1345
|
+
return input.annotations.forEach((ann, n) => {
|
|
1346
|
+
let id = defaultAnnotationId(ann, n);
|
|
1347
|
+
anchorErrors.length = 0;
|
|
1348
|
+
let warningStart = warnings.length, secondaryLine = ann.kind === "valueLine" && ann.axis === "secondary", referenceFormat = secondaryLine ? input.secondaryFormat : input.format, anchorFormat = "at" in ann && ann.at !== void 0 ? input.resolve(ann.at)?.format : ann.kind === "diff" ? input.resolve(ann.to)?.format ?? input.resolve(ann.from)?.format : ann.kind === "valueLine" ? secondaryLine ? input.secondaryFormat : seriesMeanFormat(input, ann) : void 0, example = ann.format ?? anchorFormat, own = example === void 0 ? void 0 : exampleSpec(example, locale), signed = own ? { ...exampleSpec(ann.format ?? differenceExample(example), locale), signed: !0 } : void 0, referencePercent = ann.kind === "valueLine" ? (secondaryLine ? input.secondaryPercentLevels : input.valueLinePercentLevels) ?? percent : percent, referenceUnit = ann.kind === "valueLine" ? input.valueLineUnit : void 0, baseRun = referenceUnit ? { ...run, fmt: referenceFormat ? (v) => formatWithSpec(v, { ...exampleSpec(referenceFormat, locale), prefix: "", suffix: referenceUnit }) : plain(referenceUnit, !1) } : ann.kind === "valueLine" && !referenceFormat && (secondaryLine || referencePercent !== percent) ? { ...run, fmt: plain(referencePercent ? "%" : "", !1) } : run, scope = {
|
|
1349
|
+
input,
|
|
1350
|
+
nodes,
|
|
1351
|
+
labelRequests,
|
|
1352
|
+
placed,
|
|
1353
|
+
warnings,
|
|
1354
|
+
bandSpans,
|
|
1355
|
+
eraBands: run.eraBands,
|
|
1356
|
+
run: own ? {
|
|
1357
|
+
...baseRun,
|
|
1358
|
+
fmt: referenceUnit ? (v) => formatWithSpec(v, { ...own, prefix: "", suffix: referenceUnit }) : formatterFromExample(example, input.locale),
|
|
1359
|
+
fmtSigned: (v) => formatWithSpec(v, signed),
|
|
1360
|
+
printsZero: (v) => roundedNumber(v, signed) === 0
|
|
1361
|
+
} : ann.kind === "valueLine" && typeof ann.value == "number" && !id.startsWith("averageMarker") && !referenceFormat ? { ...baseRun, fmt: (v) => Number(roundHalfUp(Math.abs(v), autoDecimals(v))) === Math.abs(v) ? baseRun.fmt(v) : formatAutomaticNumber(v, { locale, decimals: Math.max(autoDecimals(v), neededDecimals(v)), suffix: referenceUnit ?? (referencePercent ? "%" : "") }) } : baseRun,
|
|
1362
|
+
id,
|
|
1363
|
+
nid: (part) => `ann:${id}:${part}:${run.seq++}`,
|
|
1364
|
+
priority: ann.priority ?? (ann.kind === "diff" ? PRIORITY.grandTotal : void 0),
|
|
1365
|
+
addLegDeficit: (pixels) => {
|
|
1366
|
+
run.legDeficit = Math.max(run.legDeficit, pixels);
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
if (scope.warn = (code, message, suggest) => warn(scope, code, message, suggest), placeAnnotation(scope, ann), anchorErrors.length) for (let warning of warnings.slice(warningStart))
|
|
1370
|
+
warning.code === "bad-anchor" && (warning.message += `: ${[...new Set(anchorErrors)].join("; ")}`);
|
|
1371
|
+
}), finishAnnotatePass(input, run, nodes, placed, labelRequests, warnings);
|
|
1372
|
+
}
|
|
1373
|
+
function seriesMeanFormat(input, ann) {
|
|
1374
|
+
if (ann.seriesId === void 0 || ann.value !== void 0 && ann.value !== "mean") return;
|
|
1375
|
+
let mean = input.meanValueFor?.({ seriesId: ann.seriesId, from: ann.from, to: ann.to });
|
|
1376
|
+
return mean && !("error" in mean) ? mean.format : void 0;
|
|
1377
|
+
}
|
|
1378
|
+
function placeAnnotation(s, ann) {
|
|
1379
|
+
switch (ann.kind) {
|
|
1380
|
+
case "cagr":
|
|
1381
|
+
return placeCagr(s, ann);
|
|
1382
|
+
case "diff":
|
|
1383
|
+
return placeDiff(s, ann);
|
|
1384
|
+
case "callout":
|
|
1385
|
+
case "note":
|
|
1386
|
+
return placeNote(s, ann);
|
|
1387
|
+
case "delta":
|
|
1388
|
+
return placeDelta(s, ann);
|
|
1389
|
+
case "valueLine":
|
|
1390
|
+
return placeValueLine(s, ann);
|
|
1391
|
+
case "indicator100":
|
|
1392
|
+
return placeIndicator100(s, ann);
|
|
1393
|
+
case "abs":
|
|
1394
|
+
return placeAbs(s, ann);
|
|
1395
|
+
case "band":
|
|
1396
|
+
placeTargetBand(s, ann) || placeEraBand(s, ann);
|
|
1397
|
+
return;
|
|
1398
|
+
case "event":
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function partialAnchors(s, ...anchors) {
|
|
1403
|
+
let partial = s.input.partialCategories;
|
|
1404
|
+
return anchors.flatMap((anchor) => {
|
|
1405
|
+
let categoryId = anchor?.owner.categoryId;
|
|
1406
|
+
return categoryId !== void 0 && partial?.has(categoryId) ? [`'${anchor.label ?? categoryId}'`] : [];
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
function warnPartialComparison(s, kind, partial) {
|
|
1410
|
+
partial.length !== 0 && warn(
|
|
1411
|
+
s,
|
|
1412
|
+
"partial-period-comparison",
|
|
1413
|
+
`${kind} '${s.id}' compares ${partial.join(" and ")}, a partial period, as if it were complete`,
|
|
1414
|
+
"compare aligned periods (month to date against the same days last year), or say in the title that the period is still running"
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
function warn(s, code, message, suggest) {
|
|
1418
|
+
s.warnings.push({
|
|
1419
|
+
code,
|
|
1420
|
+
severity: "warn",
|
|
1421
|
+
message,
|
|
1422
|
+
owner: { annotationId: s.id },
|
|
1423
|
+
...suggest === void 0 ? {} : { suggest }
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
function valueless(s, kind, anchors) {
|
|
1427
|
+
let reason = anchors.find((anchor) => anchor?.noValue !== void 0)?.noValue;
|
|
1428
|
+
return reason === void 0 ? !1 : (warn(s, "bad-anchor", `${kind} '${s.id}': ${reason}, so it prints no value there`, VALUELESS_ANCHOR_FIX), !0);
|
|
1429
|
+
}
|
|
1430
|
+
function authored(s, kind, computed, text, value = computed) {
|
|
1431
|
+
if (text === void 0 || text.trim() === computed.trim()) return { text: computed, computed };
|
|
1432
|
+
if (text.includes("${value}")) {
|
|
1433
|
+
let live = text.replace(/\$\{value\}/g, value);
|
|
1434
|
+
return { text: live, computed: live };
|
|
1435
|
+
}
|
|
1436
|
+
return s.warnings.push({
|
|
1437
|
+
code: "annotation-authored-override",
|
|
1438
|
+
severity: "warn",
|
|
1439
|
+
message: `${kind} '${s.id}': authored text ${JSON.stringify(text)} is displayed instead of the computed value ${JSON.stringify(computed)}`,
|
|
1440
|
+
owner: { annotationId: s.id },
|
|
1441
|
+
suggest: 'drop "text" to publish the computed value, write ${value} where the number goes, or keep it and the claim record marks this annotation as an authored override'
|
|
1442
|
+
}), { text, computed };
|
|
1443
|
+
}
|
|
1444
|
+
function placeCagr(s, ann) {
|
|
1445
|
+
let { input, id } = s, fromRef = ann.from ?? input.defaultSpan?.from, toRef = ann.to ?? input.defaultSpan?.to;
|
|
1446
|
+
if (!fromRef || !toRef) return warn(s, "cagr-no-span", "cagr needs from/to or a default span");
|
|
1447
|
+
let a = comparisonAnchor(input.resolve(fromRef)), b = comparisonAnchor(input.resolve(toRef));
|
|
1448
|
+
if (!a || !b) return warn(s, "bad-anchor", `cagr '${id}': unresolvable anchor`);
|
|
1449
|
+
if (valueless(s, "cagr", [a, b])) return;
|
|
1450
|
+
let partial = partialAnchors(s, a, b);
|
|
1451
|
+
if (partial.length > 0)
|
|
1452
|
+
return warn(
|
|
1453
|
+
s,
|
|
1454
|
+
"cagr-partial-period",
|
|
1455
|
+
`cagr '${id}': ${partial.join(" and ")} is a partial period, so an annual rate to it is not measured \u2014 CAGR omitted`,
|
|
1456
|
+
"anchor the CAGR on complete periods, or compare like-for-like periods with a diff"
|
|
1457
|
+
);
|
|
1458
|
+
if (!(a.value > 0))
|
|
1459
|
+
return warn(
|
|
1460
|
+
s,
|
|
1461
|
+
"cagr-undefined",
|
|
1462
|
+
chartString2({ locale: input.locale, strings: input.strings }, "cagrStartNotPositive", { v1: id }),
|
|
1463
|
+
"use {kind:'diff', mode:'absolute'} to report the change across the span, or a labelled note for a loss-reduction figure"
|
|
1464
|
+
);
|
|
1465
|
+
let years = input.elapsedYears?.(a, b) ?? yearSpan(a.date, b.date);
|
|
1466
|
+
if (years === null) {
|
|
1467
|
+
let inferred = yearSpanFromLabels(a.label, b.label);
|
|
1468
|
+
inferred !== null && (years = inferred, s.warnings.push({
|
|
1469
|
+
code: "cagr-span-from-labels",
|
|
1470
|
+
severity: "info",
|
|
1471
|
+
message: `cagr '${id}': period of ${formatYears(inferred)} read from the labels '${a.label}' and '${b.label}'`
|
|
1472
|
+
}));
|
|
1473
|
+
}
|
|
1474
|
+
if (years === null)
|
|
1475
|
+
return warn(
|
|
1476
|
+
s,
|
|
1477
|
+
"cagr-no-dates",
|
|
1478
|
+
`cagr '${id}': anchors carry no usable ISO date (YYYY-MM-DD) and their labels name no year \u2014 no per-annum rate can be computed`,
|
|
1479
|
+
`give the anchored categories/items a "date" of the form YYYY-MM-DD or a label with a year such as "FY24", or use {kind:'diff', mode:'relative'} to report total growth across the span`
|
|
1480
|
+
);
|
|
1481
|
+
if (years <= 0)
|
|
1482
|
+
return warn(s, "cagr-zero-span", `cagr '${id}': anchor dates span zero or negative time`);
|
|
1483
|
+
years < 1 && warn(
|
|
1484
|
+
s,
|
|
1485
|
+
"cagr-short-span",
|
|
1486
|
+
`cagr '${id}': the anchors span ${formatYears(years)}, under one year, so the per-annum rate extrapolates a shorter period`,
|
|
1487
|
+
"use {kind:'diff', mode:'relative'} to report the growth across the span itself"
|
|
1488
|
+
);
|
|
1489
|
+
let rate = cagr(a.value, b.value, years);
|
|
1490
|
+
if (rate === null || !Number.isFinite(rate)) return warn(s, "cagr-undefined", `cagr '${id}': ${rate === null ? "the end value is below zero" : "the span is too short for a finite annual rate"}`);
|
|
1491
|
+
let suffix = ann.suffix ?? "p.a.", rateText = `${ann.format ? s.run.fmtSigned(rate) : formatAutomaticPercent(rate, Math.max(1, typicalDecimals([rate])), !0, input.locale)} ${suffix}`.trim(), periodOn = ann.period ?? (input.comparisonLayout?.namesSpan === !0 || input.annotations.filter((other) => other.kind === "cagr").length > 1), lead = spanLead(s, a, b, periodOn), label = authored(s, "cagr", lead ? `${lead} ${rateText}` : rateText, ann.text, rateText), parts = lead && label.text === `${lead} ${rateText}` ? { lead, value: rateText } : void 0;
|
|
1492
|
+
drawCagrArm(s, a, b, label.text, id, label.computed, {
|
|
1493
|
+
basis: "derived",
|
|
1494
|
+
op: "annotation-cagr@1",
|
|
1495
|
+
// All three operands, because all three are needed: the two endpoint
|
|
1496
|
+
// values AND the span they are annualised over. A CAGR receipt
|
|
1497
|
+
// without the year span is not checkable — the same two endpoints
|
|
1498
|
+
// give a different rate over a different period.
|
|
1499
|
+
inputs: [
|
|
1500
|
+
{ ref: `from:${anchorRefLabel(fromRef)}`, value: a.value },
|
|
1501
|
+
{ ref: `to:${anchorRefLabel(toRef)}`, value: b.value },
|
|
1502
|
+
{ ref: "years", value: years, state: `${a.date ?? a.label} \u2192 ${b.date ?? b.label}` }
|
|
1503
|
+
],
|
|
1504
|
+
raw: rate
|
|
1505
|
+
}, parts);
|
|
1506
|
+
}
|
|
1507
|
+
function spanLead(s, a, b, periodOn, colon = !1) {
|
|
1508
|
+
let names = [...new Set([a.series?.label, b.series?.label].filter((name) => name !== void 0))], named = names.length === 2 ? chartString2({ locale: s.input.locale, strings: s.input.strings }, "seriesSpan", { v1: names[0], v2: names[1] }) : names[0] ?? "", period = periodOn && a.label && b.label && a.label !== b.label ? `${a.label}\u2013${b.label}` : "", lead = [named, period].filter(Boolean).join(" ");
|
|
1509
|
+
return lead && (period || colon) ? `${lead}:` : lead;
|
|
1510
|
+
}
|
|
1511
|
+
function placeDiff(s, ann) {
|
|
1512
|
+
let { input, id } = s, a = comparisonAnchor(input.resolve(ann.from)), b = comparisonAnchor(input.resolve(ann.to));
|
|
1513
|
+
if (!a || !b) return warn(s, "bad-anchor", `diff '${id}': unresolvable anchor`);
|
|
1514
|
+
if (valueless(s, "diff", [a, b])) return;
|
|
1515
|
+
warnPartialComparison(s, "diff", partialAnchors(s, a, b));
|
|
1516
|
+
let mode = ann.mode ?? "relative";
|
|
1517
|
+
if (mode !== "relative" && mode !== "reversed" && mode !== "absolute")
|
|
1518
|
+
return warn(
|
|
1519
|
+
s,
|
|
1520
|
+
"diff-mode-unimplemented",
|
|
1521
|
+
`diff '${id}': mode '${String(mode)}' is not implemented \u2014 nothing is drawn`,
|
|
1522
|
+
mode === "pctOf100" ? "use mode:'absolute' for the raw difference, or author the shares as data if the reader needs points of 100%" : "use 'relative', 'absolute' or 'reversed'"
|
|
1523
|
+
);
|
|
1524
|
+
let computed, derivation;
|
|
1525
|
+
if (mode === "relative" || mode === "reversed") {
|
|
1526
|
+
let [base, tip] = mode === "reversed" ? [b, a] : [a, b];
|
|
1527
|
+
if (base.value === 0) return warn(s, "ref-zero", `diff '${id}': zero base`);
|
|
1528
|
+
let pct = (tip.value - base.value) / Math.abs(base.value) * 100;
|
|
1529
|
+
computed = ann.format ? s.run.fmtSigned(pct) : formatAutomaticPercent(pct, typicalDecimals([pct]), !0, input.locale), derivation = {
|
|
1530
|
+
basis: "derived",
|
|
1531
|
+
op: "annotation-diff-relative@1",
|
|
1532
|
+
inputs: [
|
|
1533
|
+
{ ref: `base:${anchorRefLabel(mode === "reversed" ? ann.to : ann.from)}`, value: base.value },
|
|
1534
|
+
{ ref: `tip:${anchorRefLabel(mode === "reversed" ? ann.from : ann.to)}`, value: tip.value }
|
|
1535
|
+
],
|
|
1536
|
+
raw: pct
|
|
1537
|
+
}, base.value < 0 && warn(
|
|
1538
|
+
s,
|
|
1539
|
+
"diff-negative-base",
|
|
1540
|
+
`diff '${id}': percent change off a negative base (${base.value}) is measured against its magnitude, so the sign follows the direction of the change`,
|
|
1541
|
+
"use mode:'absolute' if the reader needs the raw difference instead of a ratio to a negative reference"
|
|
1542
|
+
);
|
|
1543
|
+
} else
|
|
1544
|
+
computed = s.run.fmtSigned(b.value - a.value), derivation = {
|
|
1545
|
+
basis: "derived",
|
|
1546
|
+
op: "annotation-diff-absolute@1",
|
|
1547
|
+
inputs: [
|
|
1548
|
+
{ ref: `from:${anchorRefLabel(ann.from)}`, value: a.value },
|
|
1549
|
+
{ ref: `to:${anchorRefLabel(ann.to)}`, value: b.value }
|
|
1550
|
+
],
|
|
1551
|
+
raw: b.value - a.value
|
|
1552
|
+
};
|
|
1553
|
+
if (gapPlacement(s, ann, a, b)) {
|
|
1554
|
+
let text = mode !== "absolute" ? computed : gapNumber(s, ann, a, b, b.value - a.value, computed), [tail, head] = mode === "reversed" ? [b, a] : [a, b];
|
|
1555
|
+
return drawGapBracket(s, ann, tail, head, authored(s, "diff", text, ann.text, text), derivation);
|
|
1556
|
+
}
|
|
1557
|
+
let lead = input.comparisonLayout?.namesSpan ? spanLead(s, a, b, !0, !0) : "", gapWord = input.barInset && !lead && ann.text === void 0 && a.owner.categoryId !== void 0 && a.owner.categoryId === b.owner.categoryId && a.owner.seriesId !== b.owner.seriesId ? input.barInset.gapWord : "", label = gapWord ? { text: `${gapWord}\xA0${computed}`, computed } : authored(s, "diff", lead ? `${lead} ${computed}` : computed, ann.text, computed);
|
|
1558
|
+
drawDiffArm(s, a, b, label.text, id, label.computed, derivation, gapWord ? { lead: gapWord, value: computed } : void 0);
|
|
1559
|
+
}
|
|
1560
|
+
function placeNote(s, ann) {
|
|
1561
|
+
let found = s.input.resolve(ann.at);
|
|
1562
|
+
if (!found) return warn(s, "bad-anchor", `${ann.kind} '${s.id}': unresolvable anchor`);
|
|
1563
|
+
if ([ann.text, ann.kind === "callout" ? ann.headline : void 0].some((text2) => text2?.includes("${value}")) && valueless(s, ann.kind, [found])) return;
|
|
1564
|
+
let value = s.run.fmt(found.value), repeats = found.printed?.text === value && (ann.text ?? "").includes("${value}"), at = repeats ? found : { ...found, printed: void 0 }, text = repeats ? ann.text.replace(/[\s:\u2013\u2014-]*\$\{value\}/g, "").replace(/[ \t]{2,}/g, " ").trim() : (ann.text ?? "").replace(/\$\{value\}/g, value), glyph = calloutGlyphOf(s, ann);
|
|
1565
|
+
if (repeats && !text && !glyph) return;
|
|
1566
|
+
let headline = ann.kind === "callout" && ann.headline !== void 0 ? ann.headline.replace(/\$\{value\}/g, value) : void 0, placedGlyph = glyph ? planCalloutGlyph(s, at, glyph, text) : void 0, lines = headline === void 0 ? text : `${headline}
|
|
1567
|
+
${text}`;
|
|
1568
|
+
calloutLabel(s, ann, at, lines, ann.kind, void 0, lines, {
|
|
1569
|
+
basis: "authored",
|
|
1570
|
+
op: `annotation-${ann.kind}@1`,
|
|
1571
|
+
inputs: [{ ref: `at:${anchorRefLabel(ann.at)}`, value: at.noValue === void 0 ? at.value : null, state: "anchor" }],
|
|
1572
|
+
raw: null
|
|
1573
|
+
}, placedGlyph);
|
|
1574
|
+
}
|
|
1575
|
+
function placeDelta(s, ann) {
|
|
1576
|
+
let { input, id } = s, at = input.resolve(ann.at);
|
|
1577
|
+
if (!at) return warn(s, "bad-anchor", `delta '${id}': unresolvable anchor`);
|
|
1578
|
+
let vsAnchor = typeof ann.vs == "number" ? null : input.resolve(ann.vs), vsValue = typeof ann.vs == "number" ? ann.vs : vsAnchor?.value ?? null;
|
|
1579
|
+
if (vsValue === null) return warn(s, "bad-anchor", `delta '${id}': unresolvable vs`);
|
|
1580
|
+
if (valueless(s, "delta", [at, vsAnchor])) return;
|
|
1581
|
+
warnPartialComparison(s, "delta", partialAnchors(s, at, vsAnchor));
|
|
1582
|
+
let d = at.value - vsValue, computed = s.run.fmtSigned(d), tone = s.run.printsZero(d) ? void 0 : d > 0 ? "good" : "bad", acrossRows = input.deltaAcrossRows === !0 && vsAnchor !== null && vsAnchor.owner.categoryId !== void 0 && vsAnchor.owner.categoryId !== at.owner.categoryId, derivation = {
|
|
1583
|
+
basis: "derived",
|
|
1584
|
+
op: "annotation-delta@1",
|
|
1585
|
+
inputs: [
|
|
1586
|
+
{ ref: `at:${anchorRefLabel(ann.at)}`, value: at.value },
|
|
1587
|
+
{ ref: typeof ann.vs == "number" ? "vs:literal" : `vs:${anchorRefLabel(ann.vs)}`, value: vsValue }
|
|
1588
|
+
],
|
|
1589
|
+
raw: d
|
|
1590
|
+
};
|
|
1591
|
+
if (gapPlacement(s, ann, at, vsAnchor)) {
|
|
1592
|
+
let text = gapNumber(s, ann, vsAnchor, at, d, computed);
|
|
1593
|
+
return drawGapBracket(s, ann, vsAnchor, at, authored(s, "delta", text, ann.text, text), derivation);
|
|
1594
|
+
}
|
|
1595
|
+
let label = authored(s, "delta", acrossRows && vsAnchor.label ? `${computed} vs ${vsAnchor.label}` : computed, ann.text, computed), seat = acrossRows ? { ...at, x: (at.x + vsAnchor.x) / 2 } : at;
|
|
1596
|
+
calloutLabel(s, ann, seat, label.text, "delta", tone, label.computed, derivation);
|
|
1597
|
+
}
|
|
1598
|
+
function gapPlacement(s, ann, a, b) {
|
|
1599
|
+
let refused = s.input.gapBracket?.refused?.includes(s.id) === !0, applies = !refused && s.input.gapBracket?.engine.applies(s.input.gapBracket, ann, a, b) === !0;
|
|
1600
|
+
if (refused)
|
|
1601
|
+
warn(
|
|
1602
|
+
s,
|
|
1603
|
+
"gap-bracket-unavailable",
|
|
1604
|
+
`${ann.kind} '${s.id}': the gap bracket's number found no free seat in the right margin; the label stays at the anchor`,
|
|
1605
|
+
"give the chart more height or width, or set placement: 'label'"
|
|
1606
|
+
);
|
|
1607
|
+
else if (!applies && ann.placement === "bracket") {
|
|
1608
|
+
let why = s.input.gapBracket?.unavailable;
|
|
1609
|
+
warn(
|
|
1610
|
+
s,
|
|
1611
|
+
"gap-bracket-unavailable",
|
|
1612
|
+
why ? `${ann.kind} '${s.id}': placement 'bracket' is unavailable because ${why}; the label stays at the anchor` : `${ann.kind} '${s.id}': placement 'bracket' needs two different series at the last category of a line chart; the label stays at the anchor`,
|
|
1613
|
+
why ? "drop placement, or use variant 'line' or 'area'" : "anchor both ends at the last category with a seriesId each, or drop placement"
|
|
1614
|
+
);
|
|
1615
|
+
}
|
|
1616
|
+
return !applies && ann.caption !== void 0 && warn(s, "gap-caption-ignored", `${ann.kind} '${s.id}': caption prints only under a gap bracket, so it is not drawn`, "drop caption, or anchor the annotation so it draws a gap bracket"), applies;
|
|
1617
|
+
}
|
|
1618
|
+
function gapNumber(s, ann, tail, head, raw, computed) {
|
|
1619
|
+
if (ann.format) return computed;
|
|
1620
|
+
let printed = [tail, head].map((end) => s.input.labelRequests?.find((request) => request.kind === "point" && !request.redundant && request.owner.seriesId === end.owner.seriesId && request.owner.categoryId === end.owner.categoryId)?.text);
|
|
1621
|
+
if (printed.some((text) => text === void 0)) return computed;
|
|
1622
|
+
try {
|
|
1623
|
+
let [first, second] = printed.map((text) => parseFormatExample(differenceExample(text)));
|
|
1624
|
+
return formatWithSpec(raw, withChartMarks({ ...second.decimals > first.decimals ? second : first, signed: !0 }, s.input.locale));
|
|
1625
|
+
} catch {
|
|
1626
|
+
return computed;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
function drawGapBracket(s, ann, tail, head, label, derivation) {
|
|
1630
|
+
s.run.gapBrackets.push(s.input.gapBracket.engine.plan(s, s.input.gapBracket, tail, head, label.text, label.computed, ann.caption, s.id, ann.kind, derivation));
|
|
1631
|
+
}
|
|
1632
|
+
function placeAbs(s, ann) {
|
|
1633
|
+
let at = s.input.resolve(ann.at);
|
|
1634
|
+
if (!at) return warn(s, "bad-anchor", `abs '${s.id}': unresolvable anchor`);
|
|
1635
|
+
if (valueless(s, "abs", [at])) return;
|
|
1636
|
+
let computed = s.run.fmt(at.value), label = authored(s, "abs", computed, ann.text);
|
|
1637
|
+
calloutLabel(s, ann, at, label.text, "abs", void 0, label.computed, {
|
|
1638
|
+
basis: "observed",
|
|
1639
|
+
op: "annotation-abs@1",
|
|
1640
|
+
inputs: [{ ref: `at:${anchorRefLabel(ann.at)}`, value: at.value, state: "anchor" }],
|
|
1641
|
+
raw: at.value
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
function valueLineMean(s, ann) {
|
|
1645
|
+
let { input, id } = s, onSecondary = ann.axis === "secondary";
|
|
1646
|
+
if (onSecondary && !input.ySecondaryScale) {
|
|
1647
|
+
warn(
|
|
1648
|
+
s,
|
|
1649
|
+
"valueline-axis-unsupported",
|
|
1650
|
+
`valueLine '${id}': axis 'secondary' needs an acknowledged secondary axis (a combo series on axis 'secondary' with options.secondaryAxis.acknowledge) \u2014 this chart has none`
|
|
1651
|
+
);
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
if (onSecondary && (ann.value === "mean" || ann.value === void 0)) {
|
|
1655
|
+
warn(
|
|
1656
|
+
s,
|
|
1657
|
+
"valueline-axis-unsupported",
|
|
1658
|
+
`valueLine '${id}': 'mean' is measured on the primary scale \u2014 give a numeric value for a secondary-axis line`
|
|
1659
|
+
);
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
let authoredValue = ann.value !== "mean" && ann.value !== void 0, clipSpan = valueLineHasTargetExtras(ann);
|
|
1663
|
+
if (authoredValue && ann.seriesId !== void 0) {
|
|
1664
|
+
warn(
|
|
1665
|
+
s,
|
|
1666
|
+
"valueline-scope-authored-value",
|
|
1667
|
+
`valueLine '${id}': seriesId scopes a MEASURED mean, but an authored value ${String(ann.value)} was also given \u2014 drop the value (the engine computes it) or drop seriesId (put a series on attainment if needed)`
|
|
1668
|
+
);
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
if (authoredValue && (ann.from !== void 0 || ann.to !== void 0) && !clipSpan) {
|
|
1672
|
+
warn(
|
|
1673
|
+
s,
|
|
1674
|
+
"valueline-scope-authored-value",
|
|
1675
|
+
`valueLine '${id}': from/to scope a MEASURED mean, but an authored value ${String(ann.value)} was also given \u2014 drop the value, drop the span, or keep from/to only as a tolerance/attainment clip`
|
|
1676
|
+
);
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
let scoped = !authoredValue && (ann.seriesId !== void 0 || ann.from !== void 0 || ann.to !== void 0), scopedMean;
|
|
1680
|
+
if (scoped) {
|
|
1681
|
+
if (ann.from === void 0 != (ann.to === void 0)) {
|
|
1682
|
+
warn(
|
|
1683
|
+
s,
|
|
1684
|
+
"valueline-scope-invalid",
|
|
1685
|
+
`valueLine '${id}': a category span needs both 'from' and 'to' (inclusive, like band)`
|
|
1686
|
+
);
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
if (!input.meanValueFor) {
|
|
1690
|
+
warn(
|
|
1691
|
+
s,
|
|
1692
|
+
"valueline-scope-unsupported",
|
|
1693
|
+
`valueLine '${id}': this chart does not measure scoped means \u2014 seriesId/from/to are supported on line charts`
|
|
1694
|
+
);
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
let resolved = input.meanValueFor({ seriesId: ann.seriesId, from: ann.from, to: ann.to });
|
|
1698
|
+
if ("error" in resolved) {
|
|
1699
|
+
warn(s, "valueline-scope-invalid", `valueLine '${id}': ${resolved.error}`);
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
scopedMean = resolved;
|
|
1703
|
+
}
|
|
1704
|
+
let v = scopedMean ? scopedMean.value : ann.value === "mean" || ann.value === void 0 ? input.meanValue : ann.value;
|
|
1705
|
+
if (v === void 0) {
|
|
1706
|
+
input.meanMissing !== void 0 ? warn(s, "no-mean", `valueLine '${id}': ${input.meanMissing}`, SHARES_OF_ONE_WHOLE_FIX) : warn(s, "no-mean", `valueLine '${id}': no mean available`);
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
return { v, scopedMean };
|
|
1710
|
+
}
|
|
1711
|
+
function valueAxisTickColumn(occupied, plotX) {
|
|
1712
|
+
let left = 1 / 0, right = -1 / 0;
|
|
1713
|
+
for (let claim of occupied.snapshot()) {
|
|
1714
|
+
if (claim.kind !== "axis") continue;
|
|
1715
|
+
let r = claim.rect;
|
|
1716
|
+
r.w <= 0 || r.h <= 0 || r.x + r.w > plotX + 0.5 || (left = Math.min(left, r.x), right = Math.max(right, r.x + r.w));
|
|
1717
|
+
}
|
|
1718
|
+
return right > left ? [left, right] : void 0;
|
|
1719
|
+
}
|
|
1720
|
+
var LINE_LABEL_GAP = 3, LINE_SEAT_STEP = 16, LINE_SEAT_MAX = 96, LINE_LABEL_AIR = 12;
|
|
1721
|
+
function rightLineSeats(input, text, font, size, y, rightSeat) {
|
|
1722
|
+
let { plot } = input, above = y - size.height - LINE_LABEL_GAP, below = y + LINE_LABEL_GAP, seat = (slot, x, top, penalty) => ({ slot, rect: { x, y: top, w: size.width, h: size.height }, penalty }), end = plot.x + plot.w - size.width, start = plot.x + 4, steps = Math.min(LINE_SEAT_MAX, Math.ceil((end - start) / LINE_SEAT_STEP)), along = steps > 1 ? Array.from({ length: steps - 1 }, (_, i) => end - (i + 1) * (end - start) / steps) : [], lines = lineLabelGutterLines(text, (t) => input.measure(t, font).width), wrappedW = Math.max(...lines.map((line) => input.measure(line, font).width)), wrappedH = size.height * lines.length;
|
|
1723
|
+
return [
|
|
1724
|
+
// One penalty for every seat on the line: the order below is the
|
|
1725
|
+
// preference, and a seat that crowds another owner's label
|
|
1726
|
+
// (LINE_LABEL_AIR) waits behind the clear ones.
|
|
1727
|
+
seat("insideEnd", end, above, 0),
|
|
1728
|
+
seat("insideEndLow", end, below, 0),
|
|
1729
|
+
seat("insideStart", start, above, 0),
|
|
1730
|
+
seat("insideStartLow", start, below, 0),
|
|
1731
|
+
...along.flatMap((x, i) => [seat(`insideAlong${i + 1}`, x, above, 0), seat(`insideAlong${i + 1}Low`, x, below, 0)]),
|
|
1732
|
+
seat("lineEnd", rightSeat, y - size.height / 2, 100),
|
|
1733
|
+
seat("lineEndShifted", rightSeat, above, 101),
|
|
1734
|
+
seat("lineEndLow", rightSeat, below, 102),
|
|
1735
|
+
...lines.length > 1 ? [{ slot: "lineEndWrapped", rect: { x: rightSeat, y: y - wrappedH / 2, w: wrappedW, h: wrappedH }, penalty: 103, lines }] : []
|
|
1736
|
+
];
|
|
1737
|
+
}
|
|
1738
|
+
function valueLineLabel(s, ann, v, y, axis) {
|
|
1739
|
+
let { input, id } = s, span = input.meanSpan?.({ from: ann.from, to: ann.to }), labelText = ann.label === !1 ? "" : ann.label !== void 0 ? namedLineText(ann.label, s.run.fmt(v), v, id) : ann.value === "mean" || ann.value === void 0 ? `${input.strings?.average ?? localeStrings(input.locale).average} ${s.run.fmt(v)}${span ? ` (${span})` : ""}` : s.run.fmt(v);
|
|
1740
|
+
if (!labelText) return labelText;
|
|
1741
|
+
let font = { family: input.theme.type.family, ...input.theme.type.label }, row = input.valueLineRows?.get(id);
|
|
1742
|
+
if (row) {
|
|
1743
|
+
let rowFont = { ...font, weight: emphasisWeight(input.theme) }, lines = wrapText(labelText, rowFont, row.w, Math.max(1, labelText.length), input.measure).lines;
|
|
1744
|
+
return s.labelRequests.push({
|
|
1745
|
+
id: `valueLine:${id}`,
|
|
1746
|
+
kind: "valueLine",
|
|
1747
|
+
role: composedTextRole(labelText),
|
|
1748
|
+
owner: { annotationId: id },
|
|
1749
|
+
text: labelText,
|
|
1750
|
+
lines,
|
|
1751
|
+
typeRole: "label",
|
|
1752
|
+
font: rowFont,
|
|
1753
|
+
fontStep: rowFont,
|
|
1754
|
+
priority: ann.priority ?? PRIORITY.reference,
|
|
1755
|
+
candidates: [{ slot: "aboveLineRow", rect: { ...row, w: Math.max(...lines.map((line) => input.measure(line, rowFont).width)) }, penalty: 0, outsidePlot: !0 }]
|
|
1756
|
+
}), labelText;
|
|
1757
|
+
}
|
|
1758
|
+
let size = input.measure(labelText, font), side = ann.side ?? "right", marginX = Math.max(0, input.plot.x - size.width - 4), tickColumn = valueAxisTickColumn(input.occupied, input.plot.x), marginInTickColumn = tickColumn !== void 0 && marginX < tickColumn[1] + 0.5 && marginX + size.width > tickColumn[0] - 0.5, marginTooNarrow = input.plot.x - size.width - 4 < 0, plotRight = input.plot.x + input.plot.w, rightTicks = input.occupied.snapshot().filter((claim) => claim.kind === "axis" && claim.rect.w > 0 && claim.rect.h > 0 && claim.rect.x >= plotRight - 0.5), rightSeat = Math.max(plotRight, maxOf(rightTicks.map((claim) => claim.rect.x + claim.rect.w))) + 4, x = marginInTickColumn || marginTooNarrow ? input.plot.x + 4 : marginX, candidates = axis === "x" ? [
|
|
1759
|
+
{
|
|
1760
|
+
slot: "aboveLine",
|
|
1761
|
+
rect: {
|
|
1762
|
+
x: y - size.width / 2,
|
|
1763
|
+
y: input.plot.y - size.height - 6,
|
|
1764
|
+
w: size.width,
|
|
1765
|
+
h: size.height
|
|
1766
|
+
},
|
|
1767
|
+
penalty: 0
|
|
1768
|
+
},
|
|
1769
|
+
{
|
|
1770
|
+
slot: "aboveLineLeft",
|
|
1771
|
+
rect: {
|
|
1772
|
+
x: y - size.width - 4,
|
|
1773
|
+
y: input.plot.y - size.height - 6,
|
|
1774
|
+
w: size.width,
|
|
1775
|
+
h: size.height
|
|
1776
|
+
},
|
|
1777
|
+
penalty: 1
|
|
1778
|
+
}
|
|
1779
|
+
] : side === "right" ? rightLineSeats(input, labelText, font, size, y, rightSeat) : [
|
|
1780
|
+
// Inside the plot the centred slot would sit on the label's own
|
|
1781
|
+
// dashed line (the solver ignores the annotation's own claims), so
|
|
1782
|
+
// a relocated left label takes the slots above and below the line.
|
|
1783
|
+
...x === marginX ? [{ slot: "lineEnd", rect: { x, y: y - size.height / 2, w: size.width, h: size.height }, penalty: 0 }] : [],
|
|
1784
|
+
{ slot: "lineEndShifted", rect: { x, y: y - size.height - LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 1 },
|
|
1785
|
+
{ slot: "lineEndLow", rect: { x, y: y + LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 2 },
|
|
1786
|
+
...x !== marginX ? [{ slot: "lineEndMargin", rect: { x: marginX, y: y - size.height / 2, w: size.width, h: size.height }, penalty: 3 }] : [],
|
|
1787
|
+
// A left label whose start is taken by the data steps to the line's right end, above or below it.
|
|
1788
|
+
{ slot: "insideEnd", rect: { x: input.plot.x + input.plot.w - size.width, y: y - size.height - LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 4 },
|
|
1789
|
+
{ slot: "insideEndLow", rect: { x: input.plot.x + input.plot.w - size.width, y: y + LINE_LABEL_GAP, w: size.width, h: size.height }, penalty: 5 }
|
|
1790
|
+
], tight = axis === "x" ? [] : candidates.flatMap((c) => Math.abs(c.rect.y + c.rect.h - (y - LINE_LABEL_GAP)) < 1e-6 || Math.abs(c.rect.y - (y + LINE_LABEL_GAP)) < 1e-6 ? [{ ...c, slot: `${c.slot}Tight`, rect: { ...c.rect, y: c.rect.y + (c.rect.y > y ? -1 : 1) }, penalty: c.penalty + 10 }] : []);
|
|
1791
|
+
return s.labelRequests.push({
|
|
1792
|
+
id: `valueLine:${id}`,
|
|
1793
|
+
kind: "valueLine",
|
|
1794
|
+
role: composedTextRole(labelText),
|
|
1795
|
+
owner: { annotationId: id },
|
|
1796
|
+
text: labelText,
|
|
1797
|
+
lines: [labelText],
|
|
1798
|
+
typeRole: "label",
|
|
1799
|
+
font,
|
|
1800
|
+
priority: ann.priority ?? PRIORITY.reference,
|
|
1801
|
+
...axis === "y" && side === "right" ? { labelGap: LINE_LABEL_AIR } : {},
|
|
1802
|
+
candidates: [...candidates, ...tight]
|
|
1803
|
+
}), labelText;
|
|
1804
|
+
}
|
|
1805
|
+
function placeValueLine(s, ann) {
|
|
1806
|
+
let { input, id } = s, mapper = valueMapper(input);
|
|
1807
|
+
if (!mapper) return warn(s, "unsupported", `valueLine '${id}': chart has no value scale`);
|
|
1808
|
+
let mean = valueLineMean(s, ann);
|
|
1809
|
+
if (!mean) return;
|
|
1810
|
+
let { v, scopedMean } = mean, onSecondary = ann.axis === "secondary", axis = onSecondary ? "y" : mapper.axis, y = onSecondary ? input.ySecondaryScale(v) : mapper.scale(v), lineId = s.nid("line"), from = scopedMean?.from === void 0 ? void 0 : input.resolveCategoryBand?.(scopedMean.from), to = scopedMean?.to === void 0 ? void 0 : input.resolveCategoryBand?.(scopedMean.to), span = from && to ? categorySpanRect(from, to, input.plot) : input.plot;
|
|
1811
|
+
s.nodes.push({
|
|
1812
|
+
t: "line",
|
|
1813
|
+
id: lineId,
|
|
1814
|
+
...valueLineStroke(span, y, axis),
|
|
1815
|
+
stroke: { token: "ink" },
|
|
1816
|
+
width: strokeToken(input.theme, "rule"),
|
|
1817
|
+
dash: dashToken(input.theme, "reference"),
|
|
1818
|
+
owner: { annotationId: id },
|
|
1819
|
+
part: "valueLine"
|
|
1820
|
+
}), input.occupied.claim(
|
|
1821
|
+
axis === "y" ? { x: span.x, y: y - 1, w: span.w, h: 2 } : { x: y - 1, y: span.y, w: 2, h: span.h },
|
|
1822
|
+
"annotation",
|
|
1823
|
+
{ annotationId: id },
|
|
1824
|
+
"referenceLine"
|
|
1825
|
+
);
|
|
1826
|
+
let labelText = valueLineLabel(span === input.plot ? s : { ...s, input: { ...input, plot: span } }, ann, v, y, axis), meanLine = ann.value === "mean" || ann.value === void 0;
|
|
1827
|
+
s.placed.push({
|
|
1828
|
+
id,
|
|
1829
|
+
kind: "valueLine",
|
|
1830
|
+
computedText: labelText || "",
|
|
1831
|
+
valueText: s.run.fmt(v),
|
|
1832
|
+
nodeIds: [lineId],
|
|
1833
|
+
labelId: labelText ? `valueLine:${id}` : void 0,
|
|
1834
|
+
// A mean is MEASURED over the plotted series (the observations are the
|
|
1835
|
+
// source rows, bound by sourceSha256, not copied into the record); an
|
|
1836
|
+
// explicit `value:` is a number the document typed. Two different
|
|
1837
|
+
// things that draw the identical dashed line, so the record has to
|
|
1838
|
+
// say which one it is.
|
|
1839
|
+
derivation: {
|
|
1840
|
+
basis: meanLine ? "observed" : "authored",
|
|
1841
|
+
op: meanLine ? "annotation-mean@1" : "annotation-valueLine@1",
|
|
1842
|
+
// A scoped mean names WHAT it measured (series + inclusive span,
|
|
1843
|
+
// escaped like every anchor ref); the whole-plot mean keeps its
|
|
1844
|
+
// original ref so existing receipts stay byte-identical.
|
|
1845
|
+
inputs: meanLine ? [
|
|
1846
|
+
{
|
|
1847
|
+
ref: scopedMean ? `series=${escapeRefPart(scopedMean.seriesId)}${scopedMean.from !== void 0 ? `/from=${escapeRefPart(scopedMean.from)}/to=${escapeRefPart(scopedMean.to)}` : ""}` : "plotted.values",
|
|
1848
|
+
value: null,
|
|
1849
|
+
state: "mean"
|
|
1850
|
+
}
|
|
1851
|
+
] : [{ ref: `${id}.value`, value: v, state: "authored" }],
|
|
1852
|
+
raw: v
|
|
1853
|
+
}
|
|
1854
|
+
}), placeValueLineTargets(s, ann, v);
|
|
1855
|
+
}
|
|
1856
|
+
function placeIndicator100(s, ann) {
|
|
1857
|
+
let { input, id } = s;
|
|
1858
|
+
if (!input.yScale) return warn(s, "unsupported", `indicator100 '${id}': no value scale`);
|
|
1859
|
+
let y = input.yScale(100), side = ann.side ?? "left", x = side === "left" ? input.plot.x - 6 : input.plot.x + input.plot.w + 6, lineId = s.nid("mark");
|
|
1860
|
+
s.nodes.push({
|
|
1861
|
+
t: "line",
|
|
1862
|
+
id: lineId,
|
|
1863
|
+
x1: x - 4,
|
|
1864
|
+
y1: y,
|
|
1865
|
+
x2: x + 4,
|
|
1866
|
+
y2: y,
|
|
1867
|
+
stroke: { token: "ink" },
|
|
1868
|
+
width: strokeToken(input.theme, "rule"),
|
|
1869
|
+
owner: { annotationId: id },
|
|
1870
|
+
part: "indicator100"
|
|
1871
|
+
});
|
|
1872
|
+
let font = { family: input.theme.type.family, ...input.theme.type.axis }, text = "100%", size = input.measure(text, font);
|
|
1873
|
+
s.labelRequests.push({
|
|
1874
|
+
id: `indicator100:${id}`,
|
|
1875
|
+
kind: "percentIndicator",
|
|
1876
|
+
owner: { annotationId: id },
|
|
1877
|
+
text,
|
|
1878
|
+
lines: [text],
|
|
1879
|
+
typeRole: "label",
|
|
1880
|
+
font,
|
|
1881
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
1882
|
+
candidates: [
|
|
1883
|
+
{
|
|
1884
|
+
slot: side,
|
|
1885
|
+
rect: indicator100LabelRect(input.plot, y, size, side),
|
|
1886
|
+
penalty: 0
|
|
1887
|
+
}
|
|
1888
|
+
]
|
|
1889
|
+
}), s.placed.push({
|
|
1890
|
+
id,
|
|
1891
|
+
kind: "indicator100",
|
|
1892
|
+
computedText: text,
|
|
1893
|
+
nodeIds: [lineId],
|
|
1894
|
+
labelId: `indicator100:${id}`,
|
|
1895
|
+
// A fixed 100% reference. Nothing was derived and nothing was
|
|
1896
|
+
// measured — the constant is the annotation.
|
|
1897
|
+
derivation: { basis: "authored", op: "annotation-indicator100@1", inputs: [{ ref: "reference", value: 100, state: "constant" }], raw: 100 }
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
function calloutLabel(s, ann, anchor, text, kind, tone, computed = text, derivation, glyph) {
|
|
1901
|
+
let { input, id: annId } = s, at = calloutAttachment(anchor, kind, glyph), font = { family: input.theme.type.family, ...input.theme.type.label }, head = kind === "callout" ? ann : {}, rowWidth = input.gridCallouts?.rows.get(annId)?.w ?? input.gridCallouts?.widths?.get(annId), headSourceLines = head.headline?.split(`
|
|
1902
|
+
`).length ?? 0, headlineLines = 0, lines = text.split(`
|
|
1903
|
+
`).flatMap((line, i) => {
|
|
1904
|
+
let face = i < headSourceLines ? { ...font, weight: emphasisWeight(input.theme) } : font, wrapped = rowWidth === void 0 ? [line] : wrapText(line, face, Math.max(1, rowWidth - (glyph ? glyph.radius * 2 + 7 : 0)), Math.max(1, line.length), input.measure).lines;
|
|
1905
|
+
return i < headSourceLines && (headlineLines += wrapped.length), wrapped;
|
|
1906
|
+
}), w = Math.max(...lines.map((line, i) => input.measure(line, i < headlineLines ? { ...font, weight: emphasisWeight(input.theme) } : font).width)), lineH = input.measure("X", font).height, h = lineH * lines.length, gap = glyph ? glyph.radius + 7 : 8, prefer = ann.preferSide, markBox = kind === "callout" || kind === "note" ? at.printed?.box ?? at.markBox : void 0, box = markBox ?? { x: at.x, y: at.y, w: 0, h: 0 }, [left, top, right, bottom] = [box.x, box.y, box.x + box.w, box.y + box.h], sideY = (kind === "callout" || kind === "note") && !at.printed && at.markBox ? top + box.h / 2 : at.y, round = markBox !== void 0 && !at.printed, edgeToward = (r) => {
|
|
1907
|
+
if (round) {
|
|
1908
|
+
let [cx, cy, rad] = [left + box.w / 2, top + box.h / 2, box.w / 2], tx = r.x >= cx ? r.x : r.x + r.w, ty = r.y + r.h / 2, len = Math.hypot(tx - cx, ty - cy) || 1;
|
|
1909
|
+
return { x: cx + (tx - cx) / len * rad, y: cy + (ty - cy) / len * rad };
|
|
1910
|
+
}
|
|
1911
|
+
return {
|
|
1912
|
+
x: Math.min(Math.max(r.x + r.w / 2, left), right),
|
|
1913
|
+
y: Math.min(Math.max(r.y + r.h / 2, top), bottom)
|
|
1914
|
+
};
|
|
1915
|
+
}, samePoint = (ref) => {
|
|
1916
|
+
let found = input.resolve(ref);
|
|
1917
|
+
return found !== null && Math.abs(found.x - anchor.x) < 0.5 && Math.abs(found.y - anchor.y) < 0.5;
|
|
1918
|
+
}, onPoint = glyph !== void 0 && box.w === 0 && !input.annotations.some((other) => other !== ann && ["callout", "note", "delta", "abs"].includes(other.kind) && "at" in other && other.at !== void 0 && samePoint(other.at)), mk = (slot, x, y, penalty, leader = !1) => {
|
|
1919
|
+
let labelRect = { x, y, w, h };
|
|
1920
|
+
if (glyph) {
|
|
1921
|
+
let chipCenter = {
|
|
1922
|
+
x: slot.startsWith("left") ? labelRect.x + labelRect.w + gap : labelRect.x - gap,
|
|
1923
|
+
y: labelRect.y + labelRect.h / 2
|
|
1924
|
+
}, chipRect = {
|
|
1925
|
+
x: chipCenter.x - glyph.radius,
|
|
1926
|
+
y: chipCenter.y - glyph.radius,
|
|
1927
|
+
w: glyph.radius * 2,
|
|
1928
|
+
h: glyph.radius * 2
|
|
1929
|
+
}, groupRect = unionRect(labelRect, chipRect), anchor2 = edgeToward(chipRect);
|
|
1930
|
+
return glyph.placements.set(slot, { groupRect, labelRect, chipCenter, anchor: anchor2 }), { slot, rect: groupRect, penalty, leaderLengthBound: Math.abs(chipCenter.x - anchor2.x) + Math.abs(chipCenter.y - anchor2.y) };
|
|
1931
|
+
}
|
|
1932
|
+
return { slot, rect: labelRect, penalty, ...leader ? { leaderFrom: edgeToward(labelRect) } : {} };
|
|
1933
|
+
}, all = [
|
|
1934
|
+
mk(
|
|
1935
|
+
"above",
|
|
1936
|
+
glyph ? at.x + gap : at.x - w / 2,
|
|
1937
|
+
top - h - gap,
|
|
1938
|
+
prefer === "above" ? -1 : 0,
|
|
1939
|
+
glyph !== void 0
|
|
1940
|
+
),
|
|
1941
|
+
// Beside a point anchor a glyph's disc sits centred on the point
|
|
1942
|
+
// it stands for, and its text beside the disc; beside a box it keeps off it.
|
|
1943
|
+
mk("right", right + gap * (onPoint ? 1 : 2), sideY - h / 2, prefer === "right" ? -1 : 1, !0),
|
|
1944
|
+
mk("left", left - w - gap * (onPoint ? 1 : 2), sideY - h / 2, prefer === "left" ? -1 : 2, !0),
|
|
1945
|
+
mk(
|
|
1946
|
+
"below",
|
|
1947
|
+
glyph ? at.x + gap : at.x - w / 2,
|
|
1948
|
+
bottom + gap,
|
|
1949
|
+
prefer === "below" ? -1 : 3,
|
|
1950
|
+
glyph !== void 0
|
|
1951
|
+
),
|
|
1952
|
+
// over or under the first point of a late-starting line, the
|
|
1953
|
+
// note may also end at the point, where its own line has not started. The centred seat
|
|
1954
|
+
// lost to the line's first climb, and the note moved to the side its author did not ask for.
|
|
1955
|
+
...at.lineStart && !glyph && !markBox ? [
|
|
1956
|
+
mk("aboveLeft", at.x - w - gap, top - h - gap, prefer === "above" ? -0.5 : 0.5),
|
|
1957
|
+
mk("belowLeft", at.x - w - gap, bottom + gap, prefer === "below" ? -0.5 : 3.05)
|
|
1958
|
+
] : [],
|
|
1959
|
+
// Beside a mark's box, a line under or over its centre: the seat next to
|
|
1960
|
+
// the point's own name, which takes the centre (scatter bubbles).
|
|
1961
|
+
// These seats sit off the mark's rim, so they lead back to it.
|
|
1962
|
+
...sideY !== at.y ? [
|
|
1963
|
+
mk("rightLower", right + gap, sideY + h / 2 + gap / 2, 3.1, !0),
|
|
1964
|
+
mk("rightUpper", right + gap, sideY - h * 1.5 - gap / 2, 3.2, !0),
|
|
1965
|
+
mk("leftLower", left - w - gap, sideY + h / 2 + gap / 2, 3.3, !0),
|
|
1966
|
+
mk("leftUpper", left - w - gap, sideY - h * 1.5 - gap / 2, 3.4, !0)
|
|
1967
|
+
] : [],
|
|
1968
|
+
// Beside the anchor, one step out from the slot below it, with no
|
|
1969
|
+
// leader: the arrow that took the column under the anchor (a funnel
|
|
1970
|
+
// diff's drop line) leaves exactly the space next to it, and a
|
|
1971
|
+
// label there is still adjacent to its own mark. Reached before the
|
|
1972
|
+
// escape ring, whose leader would bend around the drop line on its way
|
|
1973
|
+
// down to the band.
|
|
1974
|
+
mk("belowRight", right + gap, bottom + gap, 3.5),
|
|
1975
|
+
// escape ring: displaced diagonals with leaders, for crowded anchors
|
|
1976
|
+
mk("rightFar", right + gap * 5, top - h - gap * 3, 4, !0),
|
|
1977
|
+
mk("leftFar", left - w - gap * 5, top - h - gap * 3, 5, !0),
|
|
1978
|
+
mk("belowFar", right + gap * 4, bottom + h + gap * 3, 6, !0),
|
|
1979
|
+
mk("aboveFar", left - w - gap * 4, bottom + h + gap * 3, 7, !0)
|
|
1980
|
+
].sort((a, b) => a.penalty - b.penalty), gridRow = kind === "callout" || kind === "note" ? at.row : void 0, onRow = (rect) => gridRow !== void 0 && rect.y + rect.h / 2 >= gridRow.y && rect.y + rect.h / 2 <= gridRow.y + gridRow.h;
|
|
1981
|
+
gridRow?.end !== void 0 && (all = [
|
|
1982
|
+
mk("rowEnd", gridRow.end + gap * 2, sideY - h / 2, -2, !0),
|
|
1983
|
+
...all.map((candidate) => onRow(candidate.rect) || glyph ? candidate : { ...candidate, leaderFrom: candidate.leaderFrom ?? edgeToward(candidate.rect), leaderVertical: !0 })
|
|
1984
|
+
]);
|
|
1985
|
+
let freeSize = glyph ? { w: glyph.radius * 2 + 7 + w, h: Math.max(glyph.radius * 2, h) } : { w, h }, free = findFreeSpot(input.occupied, input.plot, at, freeSize.w, freeSize.h);
|
|
1986
|
+
if (free && all.push({
|
|
1987
|
+
...mk(
|
|
1988
|
+
"freeSpot",
|
|
1989
|
+
glyph ? free.x + glyph.radius * 2 + 7 : free.x,
|
|
1990
|
+
glyph ? free.y + (freeSize.h - h) / 2 : free.y,
|
|
1991
|
+
99,
|
|
1992
|
+
!0
|
|
1993
|
+
),
|
|
1994
|
+
leaderVertical: !0
|
|
1995
|
+
}), at.markBox) {
|
|
1996
|
+
let { y: plotTop, h: plotH } = input.plot;
|
|
1997
|
+
all = all.filter(({ rect }) => rect.y >= plotTop && rect.y + rect.h <= plotTop + plotH);
|
|
1998
|
+
}
|
|
1999
|
+
box.w > 0 && (all = all.filter((candidate) => {
|
|
2000
|
+
let placement = glyph?.placements.get(candidate.slot), ends = placement ? [placement.chipCenter, placement.anchor] : candidate.leaderFrom ? [candidate.leaderFrom, leaderTerminus(candidate.rect, candidate.leaderFrom)] : void 0;
|
|
2001
|
+
if (!ends) return !0;
|
|
2002
|
+
let [a, b] = ends, run = { x: Math.min(a.x, b.x), y: Math.min(a.y, b.y), w: Math.abs(a.x - b.x), h: Math.abs(a.y - b.y) };
|
|
2003
|
+
return !input.occupied.hitsWhich(run).some((claim) => claim.kind === "label");
|
|
2004
|
+
}));
|
|
2005
|
+
let arrow = head.arrow === !0 && !glyph ? { anchor: { x: at.x, y: at.y }, nodeIds: [s.nid("arrow"), s.nid("arrowHead")], owner: { annotationId: annId } } : void 0;
|
|
2006
|
+
if (arrow && (all = [...arrowSeats(arrow.anchor, w, h, lineH, prefer), ...all]), (arrow || head.headline !== void 0) && s.run.calloutHeads.set(`annotation:${annId}`, { font, headline: head.headline !== void 0, headlineLines, headlineWeight: emphasisWeight(input.theme), ...arrow ? { arrow } : {} }), input.gridCallouts && (kind === "callout" || kind === "note")) {
|
|
2007
|
+
let { rows, bounds, grid, sideLimit } = input.gridCallouts, row = rows.get(annId);
|
|
2008
|
+
row ? all = [{ ...mk(
|
|
2009
|
+
row.y >= grid.y + grid.h ? "belowRow" : "aboveRow",
|
|
2010
|
+
Math.max(row.x + (glyph ? glyph.radius * 2 + 7 : 0), Math.min(at.x - w / 2, row.x + row.w - w)),
|
|
2011
|
+
row.y + (row.h - h) / 2,
|
|
2012
|
+
-4,
|
|
2013
|
+
!0
|
|
2014
|
+
), outsidePlot: !0, leaderVertical: !0 }] : (all.push(mk("leftRow", grid.x - w - gap * 2, sideY - h / 2, -2, !0)), all = all.filter(({ rect }) => rect.x >= bounds.x && rect.x + rect.w <= bounds.x + bounds.w && rect.y >= bounds.y && rect.y + rect.h <= bounds.y + bounds.h && (rect.x + rect.w <= grid.x || rect.x >= grid.x + grid.w) && w + gap * 2 <= sideLimit), all = all.map((candidate) => candidate.slot.startsWith(prefer ?? "right") ? { ...candidate, penalty: -4 } : candidate), all.sort((a, b) => a.penalty - b.penalty));
|
|
2015
|
+
}
|
|
2016
|
+
let owner = glyph ? { ...at.owner, annotationId: annId } : { annotationId: annId };
|
|
2017
|
+
s.labelRequests.push({
|
|
2018
|
+
id: `annotation:${annId}`,
|
|
2019
|
+
kind: "annotation",
|
|
2020
|
+
owner,
|
|
2021
|
+
text,
|
|
2022
|
+
lines,
|
|
2023
|
+
typeRole: kind === "note" || kind === "callout" ? "footnote" : "label",
|
|
2024
|
+
font,
|
|
2025
|
+
// Authored priority reaches the solver: ann.priority is honoured, so
|
|
2026
|
+
// labelDensity:'minimal' keeps these labels at priority 1000 (the
|
|
2027
|
+
// AnnotationBase contract). Without one, the default band applies.
|
|
2028
|
+
priority: ann.priority ?? PRIORITY.extreme,
|
|
2029
|
+
maxLeaderLength: (kind === "callout" || kind === "note") && input.calloutLeaderWidths !== void 0 ? input.calloutLeaderWidths * w : void 0,
|
|
2030
|
+
candidates: all,
|
|
2031
|
+
role: calloutRole(kind, text, computed),
|
|
2032
|
+
...(kind === "callout" || kind === "note") && input.calloutLeaderClear ? { leaderClear: !0 } : {},
|
|
2033
|
+
// On a grid, a seat nearer another row's cell than its own is
|
|
2034
|
+
// ambiguous, and takes a leader from its cell if nothing else is free.
|
|
2035
|
+
...gridRow?.end !== void 0 ? { anchor: box } : {}
|
|
2036
|
+
}), glyph && s.run.calloutGlyphPlans.set(`annotation:${annId}`, glyph), s.placed.push({
|
|
2037
|
+
id: annId,
|
|
2038
|
+
kind,
|
|
2039
|
+
computedText: glyph ? `${glyph.meaning}: ${computed}` : computed,
|
|
2040
|
+
tone: tone ?? "neutral",
|
|
2041
|
+
nodeIds: glyph?.nodeIds ?? arrow?.nodeIds ?? [],
|
|
2042
|
+
labelId: `annotation:${annId}`,
|
|
2043
|
+
...derivation ? { derivation } : {}
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
function calloutGlyphOf(s, annotation) {
|
|
2047
|
+
let glyph = annotation;
|
|
2048
|
+
if (glyph.icon && glyph.status) {
|
|
2049
|
+
warn(
|
|
2050
|
+
s,
|
|
2051
|
+
"annotation-glyph-conflict",
|
|
2052
|
+
`${annotation.kind} '${s.id}' declares both icon and status \u2014 no glyph was drawn`,
|
|
2053
|
+
"declare exactly one glyph slot"
|
|
2054
|
+
);
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
if (glyph.icon) return { kind: "icon", name: glyph.icon };
|
|
2058
|
+
if (glyph.status) return { kind: "status", status: glyph.status };
|
|
2059
|
+
}
|
|
2060
|
+
function planCalloutGlyph(s, at, glyph, text) {
|
|
2061
|
+
let meaning = glyph.kind === "icon" ? `${glyph.name} icon` : `${glyph.status} status`, owner = { annotationId: s.id }, nodeIds = [s.nid("glyphChip")];
|
|
2062
|
+
if (glyph.kind === "status")
|
|
2063
|
+
nodeIds.push(s.nid("glyphStatus"));
|
|
2064
|
+
else
|
|
2065
|
+
for (let _ of compileIcon(glyph.name, { x: 0, y: 0, w: 16, h: 16 }))
|
|
2066
|
+
nodeIds.push(s.nid("glyphIcon"));
|
|
2067
|
+
return {
|
|
2068
|
+
glyph,
|
|
2069
|
+
nodeIds,
|
|
2070
|
+
meaning,
|
|
2071
|
+
radius: 11,
|
|
2072
|
+
text,
|
|
2073
|
+
owner,
|
|
2074
|
+
anchor: { x: at.x, y: at.y },
|
|
2075
|
+
placements: /* @__PURE__ */ new Map()
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
function finishAnnotatePass(input, run, nodes, placed, labelRequests, warnings) {
|
|
2079
|
+
let ranked = new Set(input.annotations.flatMap((annotation, index) => annotation.priority === void 0 ? [] : [defaultAnnotationId(annotation, index)]));
|
|
2080
|
+
for (let request of labelRequests) ranked.has(request.owner.annotationId ?? "") || (request.keepWhenDense ??= !0);
|
|
2081
|
+
let requests = [...labelRequests, ...input.labelRequests ?? []];
|
|
2082
|
+
if (input.target) for (let request of requests) request.fontStep ??= request.font;
|
|
2083
|
+
let { solved, bandNeed } = settleEraBands(input, run, requests);
|
|
2084
|
+
suppressRepeatedPointValues(input, solved), input.comparisonLayout && pushAll(nodes, input.comparisonLayout.emit(solved.placed)), input.gapBracket?.engine.finish(run.gapBrackets, solved.placed), input.annotations.forEach((annotation, index) => {
|
|
2085
|
+
if (annotation.kind !== "callout" || !annotation.preferSide) return;
|
|
2086
|
+
let id = defaultAnnotationId(annotation, index), label = solved.placed.find((entry) => entry.id === `annotation:${id}` && !entry.hidden), anchor = input.resolve(annotation.at);
|
|
2087
|
+
if (!label || !anchor) return;
|
|
2088
|
+
let dx = label.rect.x + label.rect.w / 2 - anchor.x, dy = label.rect.y + label.rect.h / 2 - anchor.y, slot = String(label.slot), side = ["left", "right", "above", "below"].find((side2) => slot.startsWith(side2)) ?? (slot === "rowEnd" ? "right" : label.rect.y + label.rect.h <= anchor.y ? "above" : label.rect.y >= anchor.y ? "below" : dx < 0 ? "left" : dx > 0 ? "right" : dy < 0 ? "above" : "below");
|
|
2089
|
+
side !== annotation.preferSide && warnings.push({
|
|
2090
|
+
code: "callout-side-changed",
|
|
2091
|
+
severity: "info",
|
|
2092
|
+
message: `Callout '${id}' uses side '${side}' instead of preferSide '${annotation.preferSide}'.`,
|
|
2093
|
+
owner: { annotationId: id }
|
|
2094
|
+
});
|
|
2095
|
+
});
|
|
2096
|
+
for (let label of solved.placed) {
|
|
2097
|
+
let glyph = run.calloutGlyphPlans.get(label.id);
|
|
2098
|
+
if (!glyph) continue;
|
|
2099
|
+
let placement = glyph.placements.get(String(label.slot));
|
|
2100
|
+
if (!placement) continue;
|
|
2101
|
+
if (label.rect = placement.labelRect, label.hidden) {
|
|
2102
|
+
glyph.nodeIds.splice(0);
|
|
2103
|
+
continue;
|
|
2104
|
+
}
|
|
2105
|
+
label.leader = calloutGlyphLeader(
|
|
2106
|
+
placement.chipCenter,
|
|
2107
|
+
placement.anchor,
|
|
2108
|
+
glyph.radius
|
|
2109
|
+
);
|
|
2110
|
+
let glyphNodes = calloutGlyphNodes(glyph, placement.chipCenter, input.theme);
|
|
2111
|
+
nodes.push(...glyphNodes);
|
|
2112
|
+
let chipRect = {
|
|
2113
|
+
x: placement.chipCenter.x - glyph.radius,
|
|
2114
|
+
y: placement.chipCenter.y - glyph.radius,
|
|
2115
|
+
w: glyph.radius * 2,
|
|
2116
|
+
h: glyph.radius * 2
|
|
2117
|
+
};
|
|
2118
|
+
input.occupied.claim(chipRect, "annotation", glyph.owner, "calloutGlyph");
|
|
2119
|
+
}
|
|
2120
|
+
finishCalloutHeads(input.theme, solved.placed, run.calloutHeads, nodes, input.occupied);
|
|
2121
|
+
let leaderAnchors = /* @__PURE__ */ new Map();
|
|
2122
|
+
input.annotations.forEach((annotation, index) => {
|
|
2123
|
+
if (annotation.kind !== "callout" && annotation.kind !== "note" && annotation.kind !== "abs" && annotation.kind !== "delta") return;
|
|
2124
|
+
let id = `annotation:${defaultAnnotationId(annotation, index)}`, owner = run.calloutGlyphPlans.has(id) ? void 0 : input.resolve(annotation.at)?.owner;
|
|
2125
|
+
owner && leaderAnchors.set(id, owner);
|
|
2126
|
+
}), leaderAnchors.size > 0 && leadersOffAnchorValues(solved.placed, leaderAnchors, input.occupied), trimAnnotationGuides(nodes, input.occupied), pruneOrphanAnnotationArms(nodes, placed, solved.placed);
|
|
2127
|
+
for (let annotation of placed)
|
|
2128
|
+
annotation.derivation || (annotation.derivation = {
|
|
2129
|
+
basis: "authored",
|
|
2130
|
+
op: `annotation-${annotation.kind}@1`,
|
|
2131
|
+
inputs: [],
|
|
2132
|
+
raw: null
|
|
2133
|
+
});
|
|
2134
|
+
return {
|
|
2135
|
+
nodes,
|
|
2136
|
+
placed,
|
|
2137
|
+
labels: solved.placed,
|
|
2138
|
+
decisions: solved.decisions,
|
|
2139
|
+
warnings: [...warnings, ...solved.warnings],
|
|
2140
|
+
legDeficit: run.legDeficit,
|
|
2141
|
+
bandNeed,
|
|
2142
|
+
gapBracketNeed: Math.max(0, maxOf(run.gapBrackets.map((plan) => plan.need))),
|
|
2143
|
+
gapBracketHidden: run.gapBrackets.filter((plan) => solved.placed.find((label) => label.id === plan.annotation.labelId)?.hidden).map((plan) => plan.annotation.id)
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
function suppressRepeatedPointValues(input, solved) {
|
|
2147
|
+
if (!input.annotations.some((annotation) => annotation.kind === "abs")) return;
|
|
2148
|
+
let labels = [...input.printedLabels ?? [], ...solved.placed];
|
|
2149
|
+
input.annotations.forEach((annotation, index) => {
|
|
2150
|
+
if (annotation.kind !== "abs") return;
|
|
2151
|
+
let id = defaultAnnotationId(annotation, index), value = solved.placed.find((label) => label.owner.annotationId === id), at = input.resolve(annotation.at);
|
|
2152
|
+
if (!value || !at) return;
|
|
2153
|
+
let texts = annotation.text === void 0 && at.pointValueText ? [value.text, at.pointValueText] : [value.text], samePoint = (owner) => owner.categoryId === at.owner.categoryId && owner.seriesId === at.owner.seriesId, printed = labels.find((label) => !label.hidden && (["point", "total", "grandTotal"].includes(label.kind) && samePoint(label.owner) && texts.includes(label.text) || label.printsFor?.some(samePoint) && texts.some((text) => label.text.endsWith(` ${text}`))));
|
|
2154
|
+
if (!printed) return;
|
|
2155
|
+
value.hidden = "redundant", value.printedIn = printed.id, delete value.leader;
|
|
2156
|
+
let decision = solved.decisions.find((entry) => entry.labelId === value.id);
|
|
2157
|
+
decision && (decision.chose = "hidden", decision.reason = `printed in label '${printed.id}'`), solved.warnings = solved.warnings.filter((warning) => warning.code !== "label-hidden" || warning.owner?.annotationId !== id);
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
function settleEraBands(input, run, requests) {
|
|
2161
|
+
if (run.eraBands.length === 0)
|
|
2162
|
+
return { solved: solveLabels(requests, input.occupied, input.solveCtx), bandNeed: 0 };
|
|
2163
|
+
for (let plan of run.eraBands) {
|
|
2164
|
+
let req = requests.find((r) => r.id === plan.labelId);
|
|
2165
|
+
req && (req.candidates = buildExtendedEraBandCandidates(plan, input, !1));
|
|
2166
|
+
}
|
|
2167
|
+
let solved = solveLabels(requests, input.occupied, input.solveCtx), stillHidden = run.eraBands.filter((plan) => solved.placed.find((l) => l.id === plan.labelId)?.hidden);
|
|
2168
|
+
if (stillHidden.length === 0)
|
|
2169
|
+
return { solved, bandNeed: 0 };
|
|
2170
|
+
let bounds = input.solveCtx.canvas ?? input.solveCtx.plot, bandLabelIds = new Set(run.eraBands.map((p) => p.labelId)), bandAnnotationIds = new Set(run.eraBands.map((p) => p.annotationId)), bandNeed = 0;
|
|
2171
|
+
for (let plan of stillHidden) {
|
|
2172
|
+
let estimateCandidates = buildExtendedEraBandCandidates(plan, input, !0), size = input.measure(plan.text || "X", plan.font), minBracketRoom = plan.style === "bracket" && (plan.bracketY ?? 0) > plan.bandPlot.y ? Math.ceil(size.height + 9 - (plan.bandPlot.y - input.plot.y)) : 0, planNeed = 1 / 0;
|
|
2173
|
+
for (let cand of estimateCandidates) {
|
|
2174
|
+
if (cand.rect.x < bounds.x || cand.rect.x + cand.rect.w > bounds.x + bounds.w || cand.rect.y + cand.rect.h > bounds.y + bounds.h) continue;
|
|
2175
|
+
let hits = input.occupied.hitsWhich(cand.rect, 2).filter(
|
|
2176
|
+
(o) => !(o.kind === "annotation" && o.owner.annotationId === plan.annotationId) && !(o.kind === "label" && o.owner.annotationId !== void 0 && bandAnnotationIds.has(o.owner.annotationId))
|
|
2177
|
+
), plotHits = hits.filter((o) => !isCeilingClaim(o, input.ceilingRects)), hitsPlotLabel = !1, ceilingLabels = [];
|
|
2178
|
+
for (let l of solved.placed)
|
|
2179
|
+
if (!(l.hidden || bandLabelIds.has(l.id)) && rectsOverlap(cand.rect, l.rect, 2))
|
|
2180
|
+
if (input.ceilingRects?.some((r) => rectsOverlap(l.rect, r, 1)))
|
|
2181
|
+
ceilingLabels.push(l.rect);
|
|
2182
|
+
else {
|
|
2183
|
+
hitsPlotLabel = !0;
|
|
2184
|
+
break;
|
|
2185
|
+
}
|
|
2186
|
+
if (plotHits.length > 0 || hitsPlotLabel) continue;
|
|
2187
|
+
let ceilingBottom = input.bandCeiling ?? bounds.y;
|
|
2188
|
+
for (let o of hits)
|
|
2189
|
+
ceilingBottom = Math.max(ceilingBottom, o.rect.y + o.rect.h + 2);
|
|
2190
|
+
for (let r of ceilingLabels)
|
|
2191
|
+
ceilingBottom = Math.max(ceilingBottom, r.y + r.h + 2);
|
|
2192
|
+
if (input.ceilingRects)
|
|
2193
|
+
for (let r of input.ceilingRects)
|
|
2194
|
+
cand.rect.x < r.x + r.w + 2 && cand.rect.x + cand.rect.w > r.x - 2 && (ceilingBottom = Math.max(ceilingBottom, r.y + r.h + 2));
|
|
2195
|
+
let needAboveBracket = plan.style === "bracket" && cand.rect.y < plan.bandPlot.y - 7 ? minBracketRoom : 0, need = Math.max(needAboveBracket, Math.ceil(ceilingBottom - cand.rect.y));
|
|
2196
|
+
need > 0 && need < planNeed && (planNeed = need);
|
|
2197
|
+
}
|
|
2198
|
+
Number.isFinite(planNeed) && (bandNeed = Math.max(bandNeed, planNeed));
|
|
2199
|
+
}
|
|
2200
|
+
return { solved, bandNeed };
|
|
2201
|
+
}
|
|
2202
|
+
function calloutGlyphLeader(chipCenter, anchor, radius) {
|
|
2203
|
+
let vx = anchor.x - chipCenter.x, vy = anchor.y - chipCenter.y, distance = Math.hypot(vx, vy);
|
|
2204
|
+
if (distance <= radius) return;
|
|
2205
|
+
let start = {
|
|
2206
|
+
x: chipCenter.x + vx / distance * radius,
|
|
2207
|
+
y: chipCenter.y + vy / distance * radius
|
|
2208
|
+
}, d = leaderPath(start, anchor);
|
|
2209
|
+
return { d, curved: d.includes("C") };
|
|
2210
|
+
}
|
|
2211
|
+
function calloutGlyphNodes(plan, center, _theme) {
|
|
2212
|
+
let tone = plan.glyph.kind === "status" ? plan.glyph.status : "info", paint = { token: tone === "info" ? "highlight" : tone }, description = `${plan.meaning}: ${plan.text}`, nodes = [{
|
|
2213
|
+
t: "circle",
|
|
2214
|
+
id: plan.nodeIds[0],
|
|
2215
|
+
cx: center.x,
|
|
2216
|
+
cy: center.y,
|
|
2217
|
+
r: plan.radius,
|
|
2218
|
+
fill: { token: "background" },
|
|
2219
|
+
stroke: paint,
|
|
2220
|
+
strokeWidth: strokeToken(_theme, "mark"),
|
|
2221
|
+
owner: plan.owner,
|
|
2222
|
+
part: "calloutGlyph",
|
|
2223
|
+
display: { state: description }
|
|
2224
|
+
}];
|
|
2225
|
+
if (plan.glyph.kind === "status")
|
|
2226
|
+
return nodes.push({
|
|
2227
|
+
t: "circle",
|
|
2228
|
+
id: plan.nodeIds[1],
|
|
2229
|
+
cx: center.x,
|
|
2230
|
+
cy: center.y,
|
|
2231
|
+
r: plan.radius * 0.45,
|
|
2232
|
+
fill: paint,
|
|
2233
|
+
owner: plan.owner,
|
|
2234
|
+
part: "calloutGlyph",
|
|
2235
|
+
display: { state: description }
|
|
2236
|
+
}), nodes;
|
|
2237
|
+
let iconInset = 3, iconRect = {
|
|
2238
|
+
x: center.x - plan.radius + iconInset,
|
|
2239
|
+
y: center.y - plan.radius + iconInset,
|
|
2240
|
+
w: plan.radius * 2 - iconInset * 2,
|
|
2241
|
+
h: plan.radius * 2 - iconInset * 2
|
|
2242
|
+
};
|
|
2243
|
+
return compileIcon(plan.glyph.name, iconRect).forEach((primitive, index) => {
|
|
2244
|
+
let id = plan.nodeIds[index + 1];
|
|
2245
|
+
nodes.push(
|
|
2246
|
+
primitive.kind === "path" ? {
|
|
2247
|
+
t: "path",
|
|
2248
|
+
id,
|
|
2249
|
+
d: primitive.d,
|
|
2250
|
+
stroke: paint,
|
|
2251
|
+
width: strokeToken(_theme, "rule"),
|
|
2252
|
+
owner: plan.owner,
|
|
2253
|
+
part: "calloutGlyph",
|
|
2254
|
+
display: { state: description }
|
|
2255
|
+
} : {
|
|
2256
|
+
t: "circle",
|
|
2257
|
+
id,
|
|
2258
|
+
cx: primitive.cx,
|
|
2259
|
+
cy: primitive.cy,
|
|
2260
|
+
r: primitive.r,
|
|
2261
|
+
fill: { token: "background" },
|
|
2262
|
+
stroke: paint,
|
|
2263
|
+
strokeWidth: strokeToken(_theme, "mark"),
|
|
2264
|
+
owner: plan.owner,
|
|
2265
|
+
part: "calloutGlyph",
|
|
2266
|
+
display: { state: description }
|
|
2267
|
+
}
|
|
2268
|
+
);
|
|
2269
|
+
}), nodes;
|
|
2270
|
+
}
|
|
2271
|
+
function findFreeSpot(occupied, plot, at, w, h) {
|
|
2272
|
+
let candidates = [];
|
|
2273
|
+
for (let gx = plot.x + 4; gx + w <= plot.x + plot.w - 4; gx += 22)
|
|
2274
|
+
for (let gy = plot.y + 4; gy + h <= plot.y + plot.h - 4; gy += 22) {
|
|
2275
|
+
let cx = gx + w / 2, cy = gy + h / 2;
|
|
2276
|
+
candidates.push({ x: gx, y: gy, d2: (cx - at.x) ** 2 + (cy - at.y) ** 2 });
|
|
2277
|
+
}
|
|
2278
|
+
candidates.sort((a, b) => a.d2 - b.d2 || a.x - b.x || a.y - b.y);
|
|
2279
|
+
for (let c of candidates.slice(0, 400))
|
|
2280
|
+
if (!occupied.hits({ x: c.x, y: c.y, w, h }, 3)) return { x: c.x, y: c.y };
|
|
2281
|
+
return null;
|
|
2282
|
+
}
|
|
2283
|
+
function formatYears(years) {
|
|
2284
|
+
return Number.isInteger(years) ? `${years} year${years === 1 ? "" : "s"}` : `${years >= 0.01 ? years.toFixed(2) : years.toPrecision(2)} years`;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
// src/core/strings/eventLane.ts
|
|
2288
|
+
var EN2 = {
|
|
2289
|
+
// reader-facing wording linked only by its consumers.
|
|
2290
|
+
eventPeriod: "{v1}, period"
|
|
2291
|
+
}, DE2 = {
|
|
2292
|
+
// reader-facing wording linked only by its consumers.
|
|
2293
|
+
eventPeriod: "{v1}, Zeitraum"
|
|
2294
|
+
}, { chartString: chartString3 } = chartStrings(EN2, DE2);
|
|
2295
|
+
|
|
2296
|
+
// src/core/eventLane.ts
|
|
2297
|
+
var GLYPHS = ["dot", "triangle", "diamond", "square"], DAY_MS = 864e5, byTime = (a, b) => a.pos - b.pos || a.order - b.order, shownTitle = (ev) => ev.more > 0 ? `${ev.title} +${ev.more}` : ev.title, plainTitle = (ev) => shownTitle(ev).replace(/\n/g, " "), detailLines = (detail) => detail === void 0 ? [] : Array.isArray(detail) ? detail : [detail];
|
|
2298
|
+
function resolveEvents(input) {
|
|
2299
|
+
let { categories: cats, warnings } = input, n = cats.length, catIndex = new Map(cats.map((c, i) => [c.id, i])), days = cats.map((c) => c.date ? parseISODate(c.date) : null), dated = n > 0 && days.every((d) => d !== null), dayOf = (d) => Math.round(d.getTime() / DAY_MS), catDays = dated ? days.map((d) => dayOf(d)) : [], spanEnd = dated ? catDays[n - 1] + (n > 1 ? catDays[n - 1] - catDays[n - 2] : 1) : 0, posOfDay = (day) => {
|
|
2300
|
+
if (day < catDays[0] || day >= spanEnd) return null;
|
|
2301
|
+
let ci = 0;
|
|
2302
|
+
for (let i = 0; i < n; i++) catDays[i] <= day && (ci = i);
|
|
2303
|
+
let next = ci < n - 1 ? catDays[ci + 1] : spanEnd;
|
|
2304
|
+
return ci + (day - catDays[ci]) / Math.max(1, next - catDays[ci]);
|
|
2305
|
+
}, groups = new Map((input.events?.groups ?? []).map((g, i) => [g.id, { ...g, glyph: g.glyph ?? GLYPHS[i % GLYPHS.length] }])), paintOf = (tone) => tone === "neutral" ? { token: "inkMuted" } : input.colorblindSafe ? colorblindPaint(tone) : { token: tone }, out = [];
|
|
2306
|
+
return input.annotations.forEach((annotation, index) => {
|
|
2307
|
+
if (annotation.kind !== "event") return;
|
|
2308
|
+
let ann = annotation, id = defaultAnnotationId(ann, index), warn2 = (code, message, suggest) => warnings.push({ code, severity: "warn", message, owner: { annotationId: id }, ...suggest ? { suggest } : {} }), pos, date, when, period;
|
|
2309
|
+
if (ann.date !== void 0 && input.scale) {
|
|
2310
|
+
let scale = input.scale, x = scale.read(ann.date, `options.annotations[${index}].date`, !1);
|
|
2311
|
+
if (x < scale.lo || x > scale.hi) {
|
|
2312
|
+
warn2("event-out-of-range", `event '${id}' at ${ann.date} lies outside the chart's x range \u2014 not drawn`);
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
if (pos = x, date = scale.short(x), when = { date: ann.date, dateText: scale.full(x) }, ann.end !== void 0) {
|
|
2316
|
+
let end = scale.read(ann.end, `options.annotations[${index}].end`, !0);
|
|
2317
|
+
end < x ? warn2("bad-anchor", `event '${id}': its end lies before its date \u2014 drawn without its period`) : period = { from: x, to: Math.min(scale.hi, end), open: end > scale.hi };
|
|
2318
|
+
}
|
|
2319
|
+
} else if (ann.date !== void 0) {
|
|
2320
|
+
if (!dated)
|
|
2321
|
+
throw new NormalizeError(
|
|
2322
|
+
"event-date-unresolvable",
|
|
2323
|
+
`options.annotations[${index}].date`,
|
|
2324
|
+
`event '${id}' has a date, but not every category carries an ISO date to place it by`,
|
|
2325
|
+
"give each category an ISO 'date', or anchor the event to a category with 'at'"
|
|
2326
|
+
);
|
|
2327
|
+
let parsed = parseISODate(ann.date);
|
|
2328
|
+
if (!parsed && parseTimeText(ann.date))
|
|
2329
|
+
throw new NormalizeError(
|
|
2330
|
+
"event-time-needs-x-axis",
|
|
2331
|
+
`options.annotations[${index}].date`,
|
|
2332
|
+
`event '${id}' gives a time of day, and the categories are days, so the time has no place`,
|
|
2333
|
+
"give the day only (yyyy-mm-dd), or draw the readings on a continuous axis: data.x with options.xAxis: { type: 'time' }"
|
|
2334
|
+
);
|
|
2335
|
+
let at = parsed ? posOfDay(dayOf(parsed)) : null;
|
|
2336
|
+
if (at === null) {
|
|
2337
|
+
warn2("event-out-of-range", `event '${id}' on ${ann.date} lies outside the chart's categories \u2014 not drawn`);
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
pos = at, date = formatDate(parsed, "d MMM", input.language), when = { date: ann.date, dateText: formatDate(parsed, "d MMM yyyy", input.language) };
|
|
2341
|
+
let end = ann.end ? parseISODate(ann.end) : null;
|
|
2342
|
+
if (end) {
|
|
2343
|
+
let endDay = dayOf(end) + 1;
|
|
2344
|
+
period = { from: pos, to: Math.min(n, posOfDay(endDay) ?? n), open: endDay > spanEnd };
|
|
2345
|
+
}
|
|
2346
|
+
} else {
|
|
2347
|
+
let catId = typeof ann.at == "string" ? ann.at : ann.at && "categoryId" in ann.at ? ann.at.categoryId : void 0, ci = catId === void 0 ? void 0 : catIndex.get(catId);
|
|
2348
|
+
if (ci === void 0) {
|
|
2349
|
+
warn2("bad-anchor", `event '${id}': unresolvable category`);
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
if (pos = ci, when = { place: (cats[ci].label ?? catId).replace(/\n/g, " ") }, ann.to !== void 0) {
|
|
2353
|
+
let to = catIndex.get(ann.to);
|
|
2354
|
+
to === void 0 || to < ci ? warn2("bad-anchor", `event '${id}': 'to' names no category at or after '${catId}' \u2014 drawn without its period`) : period = { from: ci, to: to + 1, open: !1 };
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
let group = ann.group === void 0 ? void 0 : groups.get(ann.group);
|
|
2358
|
+
ann.group !== void 0 && !group && warn2(
|
|
2359
|
+
"event-group-unknown",
|
|
2360
|
+
`event '${id}' names group '${ann.group}', which options.events.groups does not declare \u2014 drawn without a kind`,
|
|
2361
|
+
`declare { id: '${ann.group}', label } in options.events.groups`
|
|
2362
|
+
);
|
|
2363
|
+
let tone = ann.tone ?? group?.tone ?? "neutral", items = [{ label: ann.label, detail: ann.detail }, ...ann.items ?? []].map((item) => ({ title: item.label.replace(/\n/g, " "), detail: detailLines(item.detail) }));
|
|
2364
|
+
out.push({
|
|
2365
|
+
id,
|
|
2366
|
+
order: index,
|
|
2367
|
+
ci: input.scale ? pos : Math.floor(pos),
|
|
2368
|
+
pos,
|
|
2369
|
+
...date ? { date } : {},
|
|
2370
|
+
...group ? { group: group.label } : {},
|
|
2371
|
+
// An ungrouped event with a tone still shows it: a dot in the tone.
|
|
2372
|
+
...group ? { glyph: group.glyph } : tone !== "neutral" ? { glyph: "dot" } : {},
|
|
2373
|
+
paint: paintOf(tone),
|
|
2374
|
+
title: ann.label,
|
|
2375
|
+
detail: detailLines(ann.detail),
|
|
2376
|
+
more: ann.items?.length ?? 0,
|
|
2377
|
+
reading: { ...when, ...group ? { group: group.label } : {}, items },
|
|
2378
|
+
priority: ann.priority ?? 0,
|
|
2379
|
+
placement: input.inline && ann.labelPlacement === "inline" ? "inline" : ann.placement ?? input.events?.placement ?? "auto",
|
|
2380
|
+
...period ? { period } : {}
|
|
2381
|
+
});
|
|
2382
|
+
}), out;
|
|
2383
|
+
}
|
|
2384
|
+
var r2 = (v) => Math.round(v * 100) / 100;
|
|
2385
|
+
function eventGlyphNode(glyph, cx, cy, s, paint, id, owner, part) {
|
|
2386
|
+
if (glyph === "dot") return { t: "circle", id, cx: r2(cx), cy: r2(cy), r: r2(3.1 * s), fill: paint, owner, part };
|
|
2387
|
+
let d = `${(glyph === "triangle" ? [[-3.6, -2.6], [3.6, -2.6], [0, 3.4]] : glyph === "diamond" ? [[0, -3.8], [3.8, 0], [0, 3.8], [-3.8, 0]] : [[-3, -3], [3, -3], [3, 3], [-3, 3]]).map(([dx, dy], i) => `${i === 0 ? "M" : "L"}${r2(cx + dx * s)} ${r2(cy + dy * s)}`).join("")}Z`;
|
|
2388
|
+
return { t: "path", id, d, fill: paint, owner, part };
|
|
2389
|
+
}
|
|
2390
|
+
function eventRingNode(theme, cx, cy, r, paint, id, owner, part, title, focusStop) {
|
|
2391
|
+
return { t: "circle", id, cx: r2(cx), cy: r2(cy), r: r2(r), fill: { token: "background" }, stroke: paint, strokeWidth: strokeToken(theme, "mark"), ...title ? { title } : {}, ...focusStop ? { focusStop } : {}, owner, part };
|
|
2392
|
+
}
|
|
2393
|
+
var MARKER_GAP = 5;
|
|
2394
|
+
function eventFonts(theme) {
|
|
2395
|
+
let family = theme.type.family, note = { family, ...theme.type.footnote }, title = { family, ...theme.type.axis, weight: emphasisWeight(theme) }, num = { ...microType(theme) };
|
|
2396
|
+
return {
|
|
2397
|
+
note,
|
|
2398
|
+
noteBold: { ...note },
|
|
2399
|
+
title,
|
|
2400
|
+
num,
|
|
2401
|
+
noteLH: note.size * (note.lineHeight ?? 1.3),
|
|
2402
|
+
titleLH: title.size * (title.lineHeight ?? 1.2),
|
|
2403
|
+
glyphS: note.size / 9,
|
|
2404
|
+
ringR: num.size * 0.8125
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
var EVENT_TEXT_ASCENT = 0.88, KEY_COL_MIN = 380, KEY_COL_GAP = 28, KEY_PACK_MAX = 6, KEY_PACK_COL_MIN = 150, KEY_ENTRY_GAP = 4;
|
|
2408
|
+
function keyBand(key, x0, width2, theme, measure) {
|
|
2409
|
+
let f = eventFonts(theme), n = key.entries.length, half = (width2 - KEY_COL_GAP) / 2, oneLine = (e) => 2 * f.ringR + 5 + (e.date ? measure(e.date, f.note).width + 8 : 0) + (e.group ? measure(e.group, f.noteBold).width + 11 * f.glyphS + 8 : 0) + measure(e.title, f.title).width + (e.detail ? 6 + measure(e.detail, f.note).width : 0), firstH = Math.max(f.titleLH, 2 * f.ringR + 1), titleH = key.title ? f.noteLH + 2 : 0, build = (cols) => {
|
|
2410
|
+
let colW2 = (width2 - (cols - 1) * KEY_COL_GAP) / cols, perCol = Math.ceil(n / cols), columns2 = Array.from({ length: cols }, (_, c) => {
|
|
2411
|
+
let entries = key.entries.slice(c * perCol, (c + 1) * perCol), dateW = Math.max(0, maxOf(entries.map((e) => e.date ? measure(e.date, f.note).width : 0))), groupW = Math.max(0, maxOf(entries.map((e) => e.group ? measure(e.group, f.noteBold).width + (e.glyph ? 11 * f.glyphS : 0) : 0))), dateX = 2 * f.ringR + 5, groupX = dateX + (dateW > 0 ? dateW + 8 : 0), textX = groupX + (groupW > 0 ? groupW + 8 : 0), textW = Math.max(40, colW2 - textX), y = 0;
|
|
2412
|
+
return { rows: entries.map((e) => {
|
|
2413
|
+
let titleW = measure(e.title, f.title).width, titleLines = titleW <= textW ? [e.title] : wrapFootnote(e.title, f.title, textW, measure), first = "", rest = e.detail ?? "";
|
|
2414
|
+
if (rest && titleLines.length === 1) {
|
|
2415
|
+
let words = rest.split(" "), room = textW - titleW - 6, k = 0;
|
|
2416
|
+
for (; k < words.length && measure(words.slice(0, k + 1).join(" "), f.note).width <= room; ) k++;
|
|
2417
|
+
k === words.length - 1 && k > 1 && k--;
|
|
2418
|
+
let dot = k < words.length ? words.slice(0, k + 1).lastIndexOf("\xB7") : -1, cut = dot > 0 ? dot : k;
|
|
2419
|
+
first = words.slice(0, cut).join(" "), rest = words.slice(words[cut] === "\xB7" ? cut + 1 : cut).join(" ");
|
|
2420
|
+
}
|
|
2421
|
+
let restLines = rest ? wrapFootnote(rest, f.note, textW, measure) : [], h2 = firstH + (titleLines.length - 1) * f.titleLH + restLines.length * f.noteLH, row = { e, y, titleW, titleLines, first, restLines, h: h2 };
|
|
2422
|
+
return y += h2 + KEY_ENTRY_GAP, row;
|
|
2423
|
+
}), dateX, dateW, groupX, textX, h: Math.max(0, y - KEY_ENTRY_GAP) };
|
|
2424
|
+
});
|
|
2425
|
+
return { cols, colW: colW2, columns: columns2, h: titleH + Math.max(...columns2.map((column) => column.h)) };
|
|
2426
|
+
}, packed = key.dense ? Array.from({ length: Math.min(n, KEY_PACK_MAX) }, (_, i) => build(i + 1)).filter((layout) => layout.colW >= KEY_PACK_COL_MIN && layout.columns.every((column) => column.rows.every((row) => row.titleLines.length <= 2))).reduce((best, layout) => best === void 0 || layout.h < best.h ? layout : best, void 0) : void 0, { colW, columns, h } = packed ?? build(n > 1 && (width2 >= 2 * KEY_COL_MIN + KEY_COL_GAP || key.entries.every((e) => oneLine(e) <= half)) ? 2 : 1);
|
|
2427
|
+
return { h, draw: (top, nid) => {
|
|
2428
|
+
let nodes = [], text = (x, y, lines, font, ink, owner, align = "start", role = "note", title) => nodes.push({ t: "text", id: nid("eventKey"), x: r2(x), y: r2(y), lines, align, typeRole: font === f.num ? "micro" : font === f.title ? "axis" : "footnote", font, ink, ...title ? { title } : {}, owner, part: "eventKey", role });
|
|
2429
|
+
return key.title && text(x0, top, [key.title], f.noteBold, { token: "inkMuted" }, {}), columns.forEach((column, c) => {
|
|
2430
|
+
let cx0 = x0 + c * (colW + KEY_COL_GAP);
|
|
2431
|
+
for (let row of column.rows) {
|
|
2432
|
+
let owner = { annotationId: row.e.id }, rowTop = top + titleH + row.y, titleTop = rowTop + (firstH - f.titleLH) / 2, base = titleTop + f.title.size * EVENT_TEXT_ASCENT, at = (font) => base - font.size * EVENT_TEXT_ASCENT, midY = base - 0.35 * f.title.size;
|
|
2433
|
+
if (nodes.push(eventRingNode(theme, cx0 + f.ringR, midY, f.ringR, row.e.paint, nid("eventKey"), owner, "eventKey")), text(cx0 + f.ringR, midY - 0.53 * f.num.size, [String(row.e.n)], f.num, { token: "ink" }, owner, "middle", "value"), row.e.date && text(cx0 + column.dateX + column.dateW, at(f.note), [row.e.date], f.note, { token: "inkMuted" }, owner, "end"), row.e.group) {
|
|
2434
|
+
let gx = cx0 + column.groupX;
|
|
2435
|
+
row.e.glyph && (nodes.push(eventGlyphNode(row.e.glyph, gx + 3.6 * f.glyphS, base - 0.35 * f.note.size, f.glyphS, row.e.paint, nid("eventKey"), owner, "eventKey")), gx += 11 * f.glyphS), text(gx, at(f.noteBold), [row.e.group], f.noteBold, { token: "inkMuted" }, owner);
|
|
2436
|
+
}
|
|
2437
|
+
text(cx0 + column.textX, titleTop, row.titleLines, f.title, { token: "ink" }, owner, "start", "note", row.e.reading), row.first && text(cx0 + column.textX + row.titleW + 6, at(f.note), [row.first], f.note, { token: "inkMuted" }, owner), row.restLines.length && text(cx0 + column.textX, rowTop + firstH + (row.titleLines.length - 1) * f.titleLH, row.restLines, f.note, { token: "inkMuted" }, owner);
|
|
2438
|
+
}
|
|
2439
|
+
}), nodes;
|
|
2440
|
+
} };
|
|
2441
|
+
}
|
|
2442
|
+
function eventKeyBand(key, theme, measure, legend = [], yields = !1) {
|
|
2443
|
+
return { layout: (x, width2) => keyBand(key, x, width2, theme, measure), ...legend.length > 0 ? { legend, ...yields ? { legendYieldsToSeries: !0 } : {} } : {} };
|
|
2444
|
+
}
|
|
2445
|
+
function eventLegendItems(events, language) {
|
|
2446
|
+
let items = [], seen = /* @__PURE__ */ new Set();
|
|
2447
|
+
for (let ev of [...events].sort(byTime))
|
|
2448
|
+
ev.group && (seen.has(ev.group) || (seen.add(ev.group), items.push({ id: `__event:${ev.group}`, label: ev.group, paint: { token: "background" }, stroke: ev.paint, key: "marker" })), ev.period && !seen.has(`${ev.group}:period`) && (seen.add(`${ev.group}:period`), items.push({ id: `__eventPeriod:${ev.group}`, label: chartString3({ locale: { language } }, "eventPeriod", { v1: ev.group }), paint: ev.paint, key: "bracket", width: 2 })));
|
|
2449
|
+
return items;
|
|
2450
|
+
}
|
|
2451
|
+
var JOIN = "\u2060";
|
|
2452
|
+
function balancedWrap(text, font, maxW, maxLines, measure) {
|
|
2453
|
+
let joined = text.replace(/\([^()]*\)/g, (group) => measure(group, font).width <= maxW ? group.replace(/ /g, JOIN) : group), spaced = (t, f) => measure(t.replaceAll(JOIN, " "), f), wrap = (w) => {
|
|
2454
|
+
let r = wrapText(joined, font, w, maxLines, spaced);
|
|
2455
|
+
return { ...r, lines: r.lines.map((line) => line.replaceAll(JOIN, " ")) };
|
|
2456
|
+
}, first = wrap(maxW);
|
|
2457
|
+
if (first.truncated || first.lines.length < 2) return first;
|
|
2458
|
+
let lo = 0, hi = maxW;
|
|
2459
|
+
for (; hi - lo > 1; ) {
|
|
2460
|
+
let mid = (lo + hi) / 2, r = wrap(mid);
|
|
2461
|
+
!r.truncated && r.lines.length === first.lines.length ? hi = mid : lo = mid;
|
|
2462
|
+
}
|
|
2463
|
+
return wrap(hi);
|
|
2464
|
+
}
|
|
2465
|
+
var width = (lines, font, measure) => Math.max(0, ...lines.map((l) => measure(l, font).width));
|
|
2466
|
+
function headerRuns(ev) {
|
|
2467
|
+
let runs = [];
|
|
2468
|
+
return ev.group && runs.push({ text: ev.group }), ev.date && runs.push({ text: ev.group ? `\xA0\xB7 ${ev.date}` : ev.date }), runs;
|
|
2469
|
+
}
|
|
2470
|
+
function measureHeader(ev, f, measure) {
|
|
2471
|
+
let runs = headerRuns(ev);
|
|
2472
|
+
return runs.length === 0 ? 0 : (ev.glyph ? 11 * f.glyphS : 0) + runs.reduce((w, r) => w + measure(r.text, r.weight ? f.noteBold : f.note).width, 0);
|
|
2473
|
+
}
|
|
2474
|
+
function measureBlock(ev, maxW, f, measure) {
|
|
2475
|
+
let title = [];
|
|
2476
|
+
for (let line of shownTitle(ev).split(`
|
|
2477
|
+
`)) {
|
|
2478
|
+
let r = balancedWrap(line, f.title, maxW, 2 - title.length, measure);
|
|
2479
|
+
if (r.truncated) return null;
|
|
2480
|
+
title.push(...r.lines);
|
|
2481
|
+
}
|
|
2482
|
+
let detail = [];
|
|
2483
|
+
for (let line of ev.detail) {
|
|
2484
|
+
let r = balancedWrap(line, f.note, maxW, 3 - detail.length, measure);
|
|
2485
|
+
if (r.truncated) return null;
|
|
2486
|
+
detail.push(...r.lines);
|
|
2487
|
+
}
|
|
2488
|
+
let headerW = measureHeader(ev, f, measure), lead = headerW === 0 && ev.glyph ? 11 * f.glyphS : 0, titleW = width(title, f.title, measure) + lead, detailW = width(detail, f.note, measure);
|
|
2489
|
+
return {
|
|
2490
|
+
ev,
|
|
2491
|
+
headerW,
|
|
2492
|
+
lead,
|
|
2493
|
+
title,
|
|
2494
|
+
titleW,
|
|
2495
|
+
detail,
|
|
2496
|
+
detailW,
|
|
2497
|
+
w: Math.ceil(Math.max(headerW, titleW, detailW)),
|
|
2498
|
+
h: (headerW > 0 ? f.noteLH : 0) + title.length * f.titleLH + detail.length * f.noteLH
|
|
2499
|
+
};
|
|
2500
|
+
}
|
|
2501
|
+
function xAt(axis, pos, count) {
|
|
2502
|
+
let ci = Math.min(count - 1, Math.max(0, Math.floor(pos))), x = axis.continuous ? axis.x(pos) : axis.x(ci) + (pos - ci - 0.5) * axis.step;
|
|
2503
|
+
return Math.min(axis.plot.x + axis.plot.w, Math.max(axis.plot.x, x));
|
|
2504
|
+
}
|
|
2505
|
+
var TEXT_GAP = 4, GUTTER = 14, ROW_GAP = 6, TRACK = 6;
|
|
2506
|
+
function extent(p, x) {
|
|
2507
|
+
return p.side === "right" ? [x - 1, x + TEXT_GAP + p.block.w] : [x - TEXT_GAP - p.block.w, x + 1];
|
|
2508
|
+
}
|
|
2509
|
+
function planLane(events, axis, count, rows, bounds, f, measure, noKey = !1) {
|
|
2510
|
+
let maxW = Math.min(230, axis.plot.w / 3.6), placed = [], keyed = [], inline = [], poleAt = /* @__PURE__ */ new Set(), order = [...events].sort((a, b) => b.priority - a.priority || byTime(a, b));
|
|
2511
|
+
for (let ev of order) {
|
|
2512
|
+
let x = axis.x(ev.ci), block = ev.placement === "key" || ev.placement === "auto" && (rows === 0 || poleAt.has(ev.ci)) ? null : measureBlock(ev, maxW, f, measure);
|
|
2513
|
+
if (block && ev.placement === "inline") {
|
|
2514
|
+
inline.push(block);
|
|
2515
|
+
continue;
|
|
2516
|
+
}
|
|
2517
|
+
let done = !1;
|
|
2518
|
+
for (let row = 0; block && row < rows && !done; row++)
|
|
2519
|
+
for (let side of ["right", "left"]) {
|
|
2520
|
+
let [x0, x1] = extent({ block, side }, x);
|
|
2521
|
+
if (x0 < bounds[0] || x1 > bounds[1]) continue;
|
|
2522
|
+
if (!placed.some((p) => {
|
|
2523
|
+
let px = axis.x(p.block.ev.ci), [p0, p1] = extent(p, px);
|
|
2524
|
+
return p.row === row ? x0 < p1 + GUTTER && x1 + GUTTER > p0 : p.row > row ? px > x0 - 6 && px < x1 + 6 : x > p0 - 6 && x < p1 + 6;
|
|
2525
|
+
})) {
|
|
2526
|
+
placed.push({ block, row, side }), poleAt.add(ev.ci), done = !0;
|
|
2527
|
+
break;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
done || keyed.push(ev);
|
|
2531
|
+
}
|
|
2532
|
+
keyed.sort(byTime);
|
|
2533
|
+
let keyOff = noKey ? keyed.splice(0) : [], drawn = noKey ? events.filter((ev) => !keyOff.includes(ev)) : events, trackEnds = [], trackOf = /* @__PURE__ */ new Map();
|
|
2534
|
+
for (let ev of [...drawn].filter((e) => e.period).sort(byTime)) {
|
|
2535
|
+
let x0 = xAt(axis, ev.period.from, count), t = trackEnds.findIndex((end) => end + 3 < x0);
|
|
2536
|
+
t < 0 && (t = trackEnds.push(0) - 1), trackEnds[t] = xAt(axis, ev.period.to, count), trackOf.set(ev.id, t);
|
|
2537
|
+
}
|
|
2538
|
+
let usedRows = placed.length ? maxOf(placed.map((p) => p.row)) + 1 : 0, rowH = Math.max(0, maxOf(placed.map((p) => p.block.h))), tracks = trackEnds.length, markers = keyed.length > 0, height = usedRows * (rowH + ROW_GAP) + (tracks ? tracks * TRACK + 2 : 0) + (markers ? 2 * f.ringR + 5 : 0);
|
|
2539
|
+
return { events: drawn, count, rows: usedRows, rowH, placed, keyed, keyOff, inline, trackOf, tracks, height: height > 0 ? height + 2 : 0, fonts: f };
|
|
2540
|
+
}
|
|
2541
|
+
function keyInput(plan, form, title) {
|
|
2542
|
+
let { detail, group, dates, dense } = form;
|
|
2543
|
+
if (plan.keyed.length !== 0)
|
|
2544
|
+
return {
|
|
2545
|
+
entries: plan.keyed.map((ev, i) => ({
|
|
2546
|
+
id: ev.id,
|
|
2547
|
+
n: i + 1,
|
|
2548
|
+
paint: ev.paint,
|
|
2549
|
+
...dates && ev.date ? { date: ev.date } : {},
|
|
2550
|
+
...group && ev.group ? { group: ev.group, ...ev.glyph ? { glyph: ev.glyph } : {} } : {},
|
|
2551
|
+
title: plainTitle(ev),
|
|
2552
|
+
reading: eventReading(ev.reading),
|
|
2553
|
+
...detail && ev.detail.length ? { detail: ev.detail.join(" \xB7 ") } : {}
|
|
2554
|
+
})),
|
|
2555
|
+
...dense ? { dense } : {},
|
|
2556
|
+
...title ? { title } : {}
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
var LANE_PLOT_FLOOR = 0.4, COMPACT_PLOT_FLOOR = 80, KEY_BAND_FLOOR = 0.5;
|
|
2560
|
+
function settleEventLane(input) {
|
|
2561
|
+
let s = { ...input, events: resolveEvents(input), count: input.categories.length, options: input.events };
|
|
2562
|
+
if (s.events.length === 0) {
|
|
2563
|
+
let framed2 = s.solve(void 0, s.warnings);
|
|
2564
|
+
return { framed: framed2, area: s.area(framed2, s.warnings) };
|
|
2565
|
+
}
|
|
2566
|
+
let f = eventFonts(s.theme), firstWarnings = [], first = s.solve(void 0, firstWarnings), axis = s.axis(s.area(first, [])), band = first.frame.plot, bounds = [Math.max(band.x, axis.plot.x - 20), Math.min(band.x + band.w, axis.plot.x + axis.plot.w + 20)], lean = s.compact, rows = s.compact ? 0 : s.options?.rows ?? { S: 1, M: 1, L: 2 }[typeWidthClass(s.size.width)], detail = !s.compact, group = !s.compact, dates = !0, plan, framed = first, frameWarnings, dropped = [], compacted = [], fullBand;
|
|
2567
|
+
for (; ; ) {
|
|
2568
|
+
plan = planLane(s.events, axis, s.count, rows, bounds, f, s.measure, s.footnotesOff === !0);
|
|
2569
|
+
let key = keyInput(plan, { detail, group, dates, dense: lean }, s.options?.keyTitle);
|
|
2570
|
+
frameWarnings = key ? [] : firstWarnings, framed = key ? s.solve(eventKeyBand(key, s.theme, s.measure, group ? [] : eventLegendItems(plan.keyed, s.language), lean), frameWarnings) : first;
|
|
2571
|
+
let bandH = framed.frame.plot.h;
|
|
2572
|
+
if (plan.rows > 0 && bandH - plan.height < LANE_PLOT_FLOOR * s.size.height) {
|
|
2573
|
+
rows = plan.rows - 1;
|
|
2574
|
+
continue;
|
|
2575
|
+
}
|
|
2576
|
+
if (key && bandH < KEY_BAND_FLOOR * s.size.height) {
|
|
2577
|
+
let drop = detail && key.entries.some((entry) => entry.detail) ? "detail lines" : group && key.entries.some((entry) => entry.group) ? "kind labels" : void 0;
|
|
2578
|
+
if (drop) {
|
|
2579
|
+
fullBand ??= bandH, drop === "detail lines" ? detail = !1 : group = !1, dropped.push(drop);
|
|
2580
|
+
continue;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
let shiftedOf = () => plan.height > 0 ? { ...framed, frame: { ...framed.frame, plot: { ...framed.frame.plot, y: framed.frame.plot.y + plan.height, h: framed.frame.plot.h - plan.height } } } : framed;
|
|
2584
|
+
if (s.axis(s.area(shiftedOf(), [])).plot.h < COMPACT_PLOT_FLOOR && key && dates && key.entries.some((entry) => entry.date)) {
|
|
2585
|
+
dates = !1, compacted.push("dates");
|
|
2586
|
+
continue;
|
|
2587
|
+
}
|
|
2588
|
+
break;
|
|
2589
|
+
}
|
|
2590
|
+
if (compacted.length && s.warnings.push({
|
|
2591
|
+
code: "event-lane-compact",
|
|
2592
|
+
severity: "info",
|
|
2593
|
+
message: `the compact event key left out its ${compacted.join(" and ")}: with them the plot would fall under ${COMPACT_PLOT_FLOOR}px. Every event stays whole in the SVG title and description, the interaction records and the hover card`,
|
|
2594
|
+
suggest: "draw the chart taller, or set fewer events"
|
|
2595
|
+
}), dropped.length && s.warnings.push({
|
|
2596
|
+
code: "event-key-detail-omitted",
|
|
2597
|
+
severity: "info",
|
|
2598
|
+
message: `the event key left out its ${dropped.join(" and ")}: with them the plot band fell under ${KEY_BAND_FLOOR * 100}% of the canvas height. The full date, title and detail of every event stay in the SVG title and description, the interaction records and the hover card`,
|
|
2599
|
+
suggest: "draw the chart taller, or set fewer events"
|
|
2600
|
+
}), plan.keyOff.length) {
|
|
2601
|
+
let left = plan.keyOff.map((ev) => [ev.date, plainTitle(ev), ...ev.detail].filter(Boolean).join(" \xB7 ")).join(" | "), off = frameWarnings.find((warning) => warning.code === "footnotes-off");
|
|
2602
|
+
off ? off.message = `${off.message} | ${left}` : frameWarnings.push({ code: "footnotes-off", severity: "info", message: `footnotes: false left these notes off: ${left}` });
|
|
2603
|
+
}
|
|
2604
|
+
pushAll(s.warnings, frameWarnings);
|
|
2605
|
+
let top = framed.frame.plot.y, shifted = plan.height > 0 ? { ...framed, frame: { ...framed.frame, plot: { ...framed.frame.plot, y: top + plan.height, h: framed.frame.plot.h - plan.height } } } : framed;
|
|
2606
|
+
return fullBand !== void 0 && recordPartNeed(framed.frame.frame, Math.ceil((s.size.height - fullBand) / (1 - KEY_BAND_FLOOR) - 1e-6)), { framed: shifted, area: s.area(shifted, s.warnings), lane: { plan, top } };
|
|
2607
|
+
}
|
|
2608
|
+
function emitEventLane(theme, input) {
|
|
2609
|
+
let { plan, top, axis, occupied } = input, f = plan.fonts, laneBottom = top + plan.height, rowTop = (row) => top + (plan.rows - 1 - row) * (plan.rowH + ROW_GAP), tracksTop = top + plan.rows * (plan.rowH + ROW_GAP), stripY = tracksTop + (plan.tracks ? plan.tracks * TRACK + 2 : 0) + f.ringR + 1, stopAt = (x) => {
|
|
2610
|
+
if (input.mode === "through") return laneBottom;
|
|
2611
|
+
let hits = occupied.hitsWhich({ x: x - 1, y: laneBottom, w: 2, h: Math.max(0, input.baseline - laneBottom) }).filter((o) => o.kind === "mark" || o.kind === "label");
|
|
2612
|
+
return Math.min(input.baseline, minOf(hits.map((o) => o.rect.y))) - 3;
|
|
2613
|
+
}, requests = [], fixed = (id, evId, text2, lines, font, rect, slot, role = "note") => requests.push({ id, kind: "annotation", owner: { annotationId: evId }, text: text2, lines, typeRole: font === f.num ? "micro" : font === f.title ? "axis" : "footnote", font, priority: PRIORITY.valueLine, pad: 0, candidates: [{ slot, rect, penalty: 0 }], role });
|
|
2614
|
+
for (let p of plan.placed) {
|
|
2615
|
+
let slot = `lane-${p.row}-${p.side}`;
|
|
2616
|
+
for (let line of blockLines(p.block, axis.x(p.block.ev.ci), rowTop(p.row), p.side, f))
|
|
2617
|
+
fixed(line.id, p.block.ev.id, line.text, line.lines, line.font, line.rect, slot);
|
|
2618
|
+
}
|
|
2619
|
+
let number = new Map(plan.keyed.map((ev, i) => [ev.id, i + 1])), byCat = /* @__PURE__ */ new Map();
|
|
2620
|
+
for (let ev of plan.keyed) byCat.set(ev.ci, [...byCat.get(ev.ci) ?? [], ev]);
|
|
2621
|
+
let markerAt = /* @__PURE__ */ new Map();
|
|
2622
|
+
for (let [ci, list] of byCat)
|
|
2623
|
+
list.forEach((ev, k) => {
|
|
2624
|
+
let cx = axis.x(ci) + (k - (list.length - 1) / 2) * (2 * f.ringR + MARKER_GAP);
|
|
2625
|
+
markerAt.set(ev.id, cx);
|
|
2626
|
+
let text2 = String(number.get(ev.id)), w = input.solveCtx.measure(text2, f.num).width;
|
|
2627
|
+
fixed(
|
|
2628
|
+
`event:${ev.id}`,
|
|
2629
|
+
ev.id,
|
|
2630
|
+
`${text2} \u2014 ${plainTitle(ev)}`,
|
|
2631
|
+
[text2],
|
|
2632
|
+
f.num,
|
|
2633
|
+
{ x: cx - w / 2, y: stripY - f.ringR + 1.5, w, h: 2 * f.ringR - 3 },
|
|
2634
|
+
"marker",
|
|
2635
|
+
"value"
|
|
2636
|
+
);
|
|
2637
|
+
});
|
|
2638
|
+
for (let block of plan.inline) {
|
|
2639
|
+
let x = axis.x(block.ev.ci), candidates = [];
|
|
2640
|
+
[0.28, 0.5, 0.72].forEach((fraction, row) => {
|
|
2641
|
+
let y = axis.plot.y + axis.plot.h * fraction - block.h / 2;
|
|
2642
|
+
for (let side of ["right", "left"]) {
|
|
2643
|
+
let rect = { x: side === "right" ? x + TEXT_GAP : x - TEXT_GAP - block.w, y, w: block.w, h: block.h };
|
|
2644
|
+
rect.x >= axis.plot.x && rect.x + rect.w <= axis.plot.x + axis.plot.w && candidates.push({ slot: `inline-${side}-${row}`, rect, penalty: row + (side === "left" ? 0.5 : 0), needsBacking: !0 });
|
|
2645
|
+
}
|
|
2646
|
+
}), requests.push({
|
|
2647
|
+
id: `event:${block.ev.id}`,
|
|
2648
|
+
kind: "annotation",
|
|
2649
|
+
owner: { annotationId: block.ev.id },
|
|
2650
|
+
text: shownTitle(block.ev),
|
|
2651
|
+
lines: [...block.title, ...block.detail],
|
|
2652
|
+
typeRole: "axis",
|
|
2653
|
+
font: f.title,
|
|
2654
|
+
priority: PRIORITY.valueLine,
|
|
2655
|
+
candidates,
|
|
2656
|
+
role: "note"
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
let solved = solveLabels(requests, occupied, input.solveCtx), labelById = new Map(solved.placed.map((l) => [l.id, l])), shown = (id) => {
|
|
2660
|
+
let l = labelById.get(id);
|
|
2661
|
+
return l !== void 0 && l.hidden === void 0;
|
|
2662
|
+
}, nodes = [], behind = [], nodeIds = /* @__PURE__ */ new Map(), readingOf = new Map(plan.events.map((ev) => [ev.id, eventReading(ev.reading)])), anchorOf = /* @__PURE__ */ new Map(), anchorAdd = (evId, rect) => {
|
|
2663
|
+
let known = anchorOf.get(evId);
|
|
2664
|
+
anchorOf.set(evId, known ? { x: Math.min(known.x, rect.x), y: Math.min(known.y, rect.y), w: Math.max(known.x + known.w, rect.x + rect.w) - Math.min(known.x, rect.x), h: Math.max(known.y + known.h, rect.y + rect.h) - Math.min(known.y, rect.y) } : rect);
|
|
2665
|
+
}, own = (evId, node, back = !1) => {
|
|
2666
|
+
(back ? behind : nodes).push(node), nodeIds.set(evId, [...nodeIds.get(evId) ?? [], node.id]);
|
|
2667
|
+
}, pole = (ev, x, y1) => {
|
|
2668
|
+
let owner = { annotationId: ev.id }, y2 = stopAt(x);
|
|
2669
|
+
y2 > y1 && (own(ev.id, { t: "line", id: `ann:${ev.id}:pole`, x1: x, y1, x2: x, y2, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), owner, part: "eventPole" }), occupied.claim({ x: x - 1, y: y1, w: 2, h: y2 - y1 }, "annotation", owner, "eventPole")), input.mode === "through" && input.baseline > laneBottom && own(ev.id, { t: "line", id: `ann:${ev.id}:rule`, x1: x, y1: laneBottom, x2: x, y2: input.baseline, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "dotted"), lineCap: "round", owner, part: "eventRule" }, !0);
|
|
2670
|
+
}, text = (evId, id, line, halo) => {
|
|
2671
|
+
let owner = { annotationId: evId }, gs = line.glyph ? 11 * f.glyphS : 0;
|
|
2672
|
+
line.glyph && own(evId, eventGlyphNode(line.glyph.glyph, line.rect.x + 3.6 * f.glyphS, line.rect.y + line.font.size * (EVENT_TEXT_ASCENT - 0.35), f.glyphS, line.glyph.paint, `ann:${evId}:glyph`, owner, "eventGlyph"));
|
|
2673
|
+
let ev = line.header;
|
|
2674
|
+
if (anchorAdd(evId, line.rect), !ev) {
|
|
2675
|
+
let whole = line.id === `event:${evId}` ? { title: readingOf.get(evId), focusStop: !0 } : {};
|
|
2676
|
+
own(evId, { t: "text", id, x: line.align === "start" ? line.x + gs : line.x, y: line.rect.y, lines: line.lines, align: line.align, typeRole: line.font === f.title ? "axis" : "footnote", font: line.font, ink: line.ink, ...whole, ...halo ? { halo } : {}, owner, part: "annotation", role: "note" });
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
let runs = headerRuns(ev);
|
|
2680
|
+
own(evId, {
|
|
2681
|
+
t: "text",
|
|
2682
|
+
id,
|
|
2683
|
+
x: line.align === "start" ? line.x + gs : line.x,
|
|
2684
|
+
y: line.rect.y,
|
|
2685
|
+
lines: [runs.map((r) => r.text).join("")],
|
|
2686
|
+
runs,
|
|
2687
|
+
align: line.align,
|
|
2688
|
+
typeRole: "footnote",
|
|
2689
|
+
font: f.note,
|
|
2690
|
+
ink: line.ink,
|
|
2691
|
+
...halo ? { halo } : {},
|
|
2692
|
+
owner,
|
|
2693
|
+
part: "annotation",
|
|
2694
|
+
role: "note"
|
|
2695
|
+
});
|
|
2696
|
+
}, polesAt = /* @__PURE__ */ new Set();
|
|
2697
|
+
for (let p of plan.placed) {
|
|
2698
|
+
let ev = p.block.ev;
|
|
2699
|
+
if (!shown(`event:${ev.id}`)) continue;
|
|
2700
|
+
polesAt.add(ev.ci);
|
|
2701
|
+
let x = axis.x(ev.ci);
|
|
2702
|
+
pole(ev, x, rowTop(p.row) + 1);
|
|
2703
|
+
for (let line of blockLines(p.block, x, rowTop(p.row), p.side, f)) {
|
|
2704
|
+
let label = labelById.get(line.id);
|
|
2705
|
+
label.hidden || (label.nodeId = `label:${line.id}`, text(ev.id, label.nodeId, line, !1));
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
for (let [ci, list] of byCat) {
|
|
2709
|
+
let visible = list.filter((ev) => shown(`event:${ev.id}`));
|
|
2710
|
+
if (visible.length === 0) continue;
|
|
2711
|
+
let x = axis.x(ci), tieY = stripY + f.ringR, centres = visible.map((ev) => markerAt.get(ev.id)), [x0, x1] = [Math.min(x, minOf(centres)), Math.max(x, maxOf(centres))];
|
|
2712
|
+
if (x1 - x0 > 0.5) {
|
|
2713
|
+
let owner = { annotationId: visible[0].id };
|
|
2714
|
+
own(visible[0].id, { t: "line", id: `ann:${visible[0].id}:tie`, x1: x0, y1: tieY, x2: x1, y2: tieY, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), owner, part: "eventPole" }), occupied.claim({ x: x0, y: tieY - 1, w: x1 - x0, h: 2 }, "annotation", owner, "eventPole");
|
|
2715
|
+
}
|
|
2716
|
+
polesAt.has(ci) || pole(visible[0], x, tieY);
|
|
2717
|
+
for (let ev of visible) {
|
|
2718
|
+
let cx = markerAt.get(ev.id), owner = { annotationId: ev.id };
|
|
2719
|
+
own(ev.id, eventRingNode(theme, cx, stripY, f.ringR, ev.paint, `ann:${ev.id}:marker`, owner, "eventMarker", readingOf.get(ev.id), !0)), anchorAdd(ev.id, { x: cx - f.ringR, y: stripY - f.ringR, w: 2 * f.ringR, h: 2 * f.ringR }), occupied.claim({ x: cx - f.ringR, y: stripY - f.ringR, w: 2 * f.ringR, h: 2 * f.ringR }, "annotation", owner, "eventMarker");
|
|
2720
|
+
let label = labelById.get(`event:${ev.id}`);
|
|
2721
|
+
label.nodeId = `label:${label.id}`, own(ev.id, { t: "text", id: label.nodeId, x: cx, y: stripY - 0.53 * f.num.size, lines: label.lines, align: "middle", typeRole: "micro", font: f.num, ink: { token: "ink" }, owner, part: "annotation", role: "value" });
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
for (let block of plan.inline) {
|
|
2725
|
+
let ev = block.ev, label = labelById.get(`event:${ev.id}`);
|
|
2726
|
+
if (label.hidden) continue;
|
|
2727
|
+
let side = label.slot.includes("left") ? "left" : "right", x = axis.x(ev.ci);
|
|
2728
|
+
pole(ev, x, laneBottom);
|
|
2729
|
+
for (let line of blockLines(block, x, label.rect.y, side, f)) {
|
|
2730
|
+
let id = line.id === label.id ? `label:${label.id}` : `label:${line.id}`;
|
|
2731
|
+
line.id === label.id && (label.nodeId = id), text(ev.id, id, line, !0);
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
for (let ev of plan.events) {
|
|
2735
|
+
let t = plan.trackOf.get(ev.id);
|
|
2736
|
+
if (t === void 0) continue;
|
|
2737
|
+
let owner = { annotationId: ev.id }, y = tracksTop + t * TRACK + 3, x0 = xAt(axis, ev.period.from, plan.count), x1 = xAt(axis, ev.period.to, plan.count);
|
|
2738
|
+
own(ev.id, { t: "line", id: `ann:${ev.id}:period`, x1: x0, y1: y, x2: x1, y2: y, stroke: ev.paint, width: strokeToken(theme, "rule"), owner, part: "eventPeriod" }), own(ev.id, { t: "line", id: `ann:${ev.id}:period:start`, x1: x0, y1: y - 3, x2: x0, y2: y + 3, stroke: ev.paint, width: strokeToken(theme, "rule"), owner, part: "eventPeriod" }), ev.period.open || own(ev.id, { t: "line", id: `ann:${ev.id}:period:end`, x1, y1: y - 3, x2: x1, y2: y + 3, stroke: ev.paint, width: strokeToken(theme, "rule"), owner, part: "eventPeriod" }), occupied.claim({ x: x0, y: y - 3, w: Math.max(1, x1 - x0), h: 6 }, "annotation", owner, "eventPeriod");
|
|
2739
|
+
}
|
|
2740
|
+
let placed = [...plan.events].sort(byTime).map((ev) => {
|
|
2741
|
+
let n = number.get(ev.id);
|
|
2742
|
+
return {
|
|
2743
|
+
id: ev.id,
|
|
2744
|
+
kind: "event",
|
|
2745
|
+
computedText: n === void 0 ? shownTitle(ev) : `${n} \u2014 ${plainTitle(ev)}`,
|
|
2746
|
+
nodeIds: nodeIds.get(ev.id) ?? [],
|
|
2747
|
+
event: { ...ev.reading, ...anchorOf.has(ev.id) ? { anchor: anchorOf.get(ev.id) } : {} },
|
|
2748
|
+
labelId: `event:${ev.id}`,
|
|
2749
|
+
derivation: { basis: "authored", op: "annotation-event@1", inputs: [], raw: null }
|
|
2750
|
+
};
|
|
2751
|
+
});
|
|
2752
|
+
return { nodes, behind, labels: solved.placed, placed, warnings: solved.warnings };
|
|
2753
|
+
}
|
|
2754
|
+
function blockLines(block, pole, top, side, f) {
|
|
2755
|
+
let x = side === "right" ? pole + TEXT_GAP : pole - TEXT_GAP, align = side === "right" ? "start" : "end", rect = (y2, w, h) => ({ x: side === "right" ? x : x - w, y: y2, w, h }), ev = block.ev, out = [], y = top;
|
|
2756
|
+
if (block.headerW > 0) {
|
|
2757
|
+
let header = headerRuns(ev).map((r) => r.text).join("");
|
|
2758
|
+
out.push({ id: `event:${ev.id}:header`, text: header, lines: [header], font: f.note, ink: { token: "inkMuted" }, x, align, rect: rect(y, block.headerW, f.noteLH), header: ev, ...ev.glyph ? { glyph: ev } : {} }), y += f.noteLH;
|
|
2759
|
+
}
|
|
2760
|
+
return out.push({ id: `event:${ev.id}`, text: shownTitle(ev), lines: block.title, font: f.title, ink: { token: "ink" }, x, align, rect: rect(y, block.titleW, block.title.length * f.titleLH), ...block.lead ? { glyph: ev } : {} }), y += block.title.length * f.titleLH, block.detail.length && out.push({ id: `event:${ev.id}:detail`, text: block.detail.join(" "), lines: block.detail, font: f.note, ink: { token: "inkMuted" }, x, align, rect: rect(y, block.detailW, block.detail.length * f.noteLH) }), out;
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
// src/core/annotateEngine.ts
|
|
2764
|
+
function valueAnnotationLabels(labels, annotations) {
|
|
2765
|
+
return (Array.isArray(annotations) ? annotations : []).flatMap((item, i) => (item?.kind === "callout" || item?.kind === "note") && `${item.text}${item.headline}`.includes("${value}") ? labels.filter((label) => label.kind === "annotation" && !label.hidden && label.owner.annotationId === defaultAnnotationId(item, i)).map((label) => [label, typeof item.at == "string" ? { categoryId: item.at } : item.at ?? {}]) : []);
|
|
2766
|
+
}
|
|
2767
|
+
function linkAnnotateEngine() {
|
|
2768
|
+
publishDeferred("annotate", { runAnnotatePass, settleEventLane, emitEventLane, drawCagrArm, drawHorizontalLevelDiff, valueAnnotationLabels });
|
|
2769
|
+
}
|
|
2770
|
+
linkAnnotateEngine();
|
|
2771
|
+
|
|
2772
|
+
export {
|
|
2773
|
+
linkAnnotateEngine
|
|
2774
|
+
};
|