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,2806 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chosenValueIndices,
|
|
3
|
+
emitBarMark,
|
|
4
|
+
groupedOffsets,
|
|
5
|
+
pickedValues,
|
|
6
|
+
rangeWhisker,
|
|
7
|
+
signColorOverrides,
|
|
8
|
+
signPaint,
|
|
9
|
+
stackConnectors,
|
|
10
|
+
totalLabelCandidates,
|
|
11
|
+
withValueLabelDefaults
|
|
12
|
+
} from "./chunk-CAQ5P4VN.js";
|
|
13
|
+
import {
|
|
14
|
+
axisBreakHeightOrderWarning,
|
|
15
|
+
axisBreakInvalid,
|
|
16
|
+
breakStyleRefusal,
|
|
17
|
+
stackBreakReversesOrder
|
|
18
|
+
} from "./chunk-LIWLBLCT.js";
|
|
19
|
+
import {
|
|
20
|
+
REFERENCE_MARKER_R,
|
|
21
|
+
breakAxisScale,
|
|
22
|
+
rankValueLabels,
|
|
23
|
+
referenceCasing,
|
|
24
|
+
referenceMarkerKey,
|
|
25
|
+
referenceMarkerPaint,
|
|
26
|
+
referenceTickGeometry,
|
|
27
|
+
withBandValueNotes
|
|
28
|
+
} from "./chunk-KSJVENRU.js";
|
|
29
|
+
import {
|
|
30
|
+
restValueHiding,
|
|
31
|
+
restValuesHidden
|
|
32
|
+
} from "./chunk-EKQK5D6G.js";
|
|
33
|
+
import {
|
|
34
|
+
normalizeCategorySeries
|
|
35
|
+
} from "./chunk-S4QSJAGY.js";
|
|
36
|
+
import {
|
|
37
|
+
rangeMidUndrawn,
|
|
38
|
+
resolveCellRange
|
|
39
|
+
} from "./chunk-VDAZPGR2.js";
|
|
40
|
+
import {
|
|
41
|
+
INSIDE_MIN_H,
|
|
42
|
+
bandValueLabelUniformity,
|
|
43
|
+
compactValueLabelFont,
|
|
44
|
+
compactValueTextSize,
|
|
45
|
+
fitsInside,
|
|
46
|
+
groupedValueLabelPolicy,
|
|
47
|
+
keepValuesWithoutAxis,
|
|
48
|
+
segmentLabelCandidates,
|
|
49
|
+
segmentTooShort,
|
|
50
|
+
warnSliverLabels
|
|
51
|
+
} from "./chunk-27QADBDV.js";
|
|
52
|
+
import {
|
|
53
|
+
CAGR_INSET_ROOM,
|
|
54
|
+
CAGR_ROOM,
|
|
55
|
+
CAGR_TRIES,
|
|
56
|
+
CAT_BAND_GAP,
|
|
57
|
+
CAT_MAX_LINES,
|
|
58
|
+
CUT_NOTES,
|
|
59
|
+
DEFER_ADJACENT,
|
|
60
|
+
EXACT_DOMAIN,
|
|
61
|
+
LABEL_GAP,
|
|
62
|
+
NO_NAME_COLUMN,
|
|
63
|
+
OTHERS_ID,
|
|
64
|
+
RIGHT_ROOM,
|
|
65
|
+
TOTAL_COLUMN,
|
|
66
|
+
bandSteps,
|
|
67
|
+
barHalves,
|
|
68
|
+
cagrInset,
|
|
69
|
+
fixedBarRow
|
|
70
|
+
} from "./chunk-VABRPZVC.js";
|
|
71
|
+
import {
|
|
72
|
+
roundingUnavailable,
|
|
73
|
+
sumConsistentShares
|
|
74
|
+
} from "./chunk-24BHMKDD.js";
|
|
75
|
+
import {
|
|
76
|
+
accumulateStack,
|
|
77
|
+
averageMarkerLine,
|
|
78
|
+
averageOfUnaddedSums,
|
|
79
|
+
averageOfWholeShares,
|
|
80
|
+
compositionBasis,
|
|
81
|
+
grandTotalRequested,
|
|
82
|
+
mixedSignsWarning,
|
|
83
|
+
netLineName,
|
|
84
|
+
onePartDrawn,
|
|
85
|
+
overfullShareSum,
|
|
86
|
+
overfullWarning,
|
|
87
|
+
plottedMean,
|
|
88
|
+
printsValue,
|
|
89
|
+
sortSegments,
|
|
90
|
+
stackParts,
|
|
91
|
+
stackTotalFormatter,
|
|
92
|
+
warnIncompleteStacks
|
|
93
|
+
} from "./chunk-M4EUXOLU.js";
|
|
94
|
+
import {
|
|
95
|
+
isIncomplete,
|
|
96
|
+
warnShareRoundingDrift
|
|
97
|
+
} from "./chunk-5LGSRWFC.js";
|
|
98
|
+
import {
|
|
99
|
+
labelOn
|
|
100
|
+
} from "./chunk-VJ3FCGQF.js";
|
|
101
|
+
import {
|
|
102
|
+
percentCellsOnly,
|
|
103
|
+
percentLevels,
|
|
104
|
+
runAnnotatePass
|
|
105
|
+
} from "./chunk-KZS46KDY.js";
|
|
106
|
+
import {
|
|
107
|
+
rowLabelBand
|
|
108
|
+
} from "./chunk-X4YNDLVA.js";
|
|
109
|
+
import {
|
|
110
|
+
fittedLabel,
|
|
111
|
+
gutterBudget,
|
|
112
|
+
stepDownFont
|
|
113
|
+
} from "./chunk-ZQF34VPS.js";
|
|
114
|
+
import {
|
|
115
|
+
chartPalette,
|
|
116
|
+
chartTheme
|
|
117
|
+
} from "./chunk-3QWZAEW5.js";
|
|
118
|
+
import {
|
|
119
|
+
restLabel,
|
|
120
|
+
restSum,
|
|
121
|
+
topNCut
|
|
122
|
+
} from "./chunk-KDMKHR5A.js";
|
|
123
|
+
import {
|
|
124
|
+
NO_STACK_MEAN,
|
|
125
|
+
NO_STACK_TOTAL,
|
|
126
|
+
SHARES_OF_ONE_WHOLE_FIX,
|
|
127
|
+
stackAdds
|
|
128
|
+
} from "./chunk-6KWIQ5KF.js";
|
|
129
|
+
import {
|
|
130
|
+
categoryTargetFields,
|
|
131
|
+
spliceAnnotationNodes,
|
|
132
|
+
valueLineHasTargetExtras
|
|
133
|
+
} from "./chunk-CDZHNLO6.js";
|
|
134
|
+
import {
|
|
135
|
+
BAND_PAD,
|
|
136
|
+
namedLineText,
|
|
137
|
+
pruneOrphanAnnotationArms
|
|
138
|
+
} from "./chunk-HZI56ASJ.js";
|
|
139
|
+
import {
|
|
140
|
+
rowDrivenHeight
|
|
141
|
+
} from "./chunk-GZTNTHSW.js";
|
|
142
|
+
import {
|
|
143
|
+
structureCount
|
|
144
|
+
} from "./chunk-LFX7W4B7.js";
|
|
145
|
+
import {
|
|
146
|
+
emptyIdRecord
|
|
147
|
+
} from "./chunk-LINZPU5D.js";
|
|
148
|
+
import {
|
|
149
|
+
HARD_MINIMUM,
|
|
150
|
+
applyAxisBounds,
|
|
151
|
+
applyValueAxisTitleInk,
|
|
152
|
+
axisTitleAllowed,
|
|
153
|
+
bandScale,
|
|
154
|
+
brokenLinearScale,
|
|
155
|
+
categoryBreakGlyph,
|
|
156
|
+
categoryCutLint,
|
|
157
|
+
invalidLinearBreakReason,
|
|
158
|
+
layoutValueAxis,
|
|
159
|
+
linearScale,
|
|
160
|
+
niceDomain,
|
|
161
|
+
noteName,
|
|
162
|
+
planValueAxisTitle,
|
|
163
|
+
rowSizing,
|
|
164
|
+
tickRowTitleEnd,
|
|
165
|
+
valueAxisTitleRequest,
|
|
166
|
+
valueAxisTitleText,
|
|
167
|
+
valueAxisUnit
|
|
168
|
+
} from "./chunk-RL3NUWMY.js";
|
|
169
|
+
import {
|
|
170
|
+
PARTIAL_KEY,
|
|
171
|
+
PRIORITY,
|
|
172
|
+
SWATCH_RESERVE,
|
|
173
|
+
authoredFootnoteCount,
|
|
174
|
+
authoredNotes,
|
|
175
|
+
cappedItems,
|
|
176
|
+
composedTextRole,
|
|
177
|
+
createOccupiedIndex,
|
|
178
|
+
dedupeLegendKeys,
|
|
179
|
+
frameTextOptions,
|
|
180
|
+
labelCtx,
|
|
181
|
+
labelsToNodes,
|
|
182
|
+
normalizeLegendOption,
|
|
183
|
+
omittedKey,
|
|
184
|
+
partialAxisWords,
|
|
185
|
+
partialFootnotes,
|
|
186
|
+
partialIds,
|
|
187
|
+
partialKeyForced,
|
|
188
|
+
partialLegendKeys,
|
|
189
|
+
partialPattern,
|
|
190
|
+
plotHeightAfter,
|
|
191
|
+
rectContains,
|
|
192
|
+
rectSeriesAdjacentWarnings,
|
|
193
|
+
rectsOverlap,
|
|
194
|
+
rowLabelX,
|
|
195
|
+
saysToDate,
|
|
196
|
+
scenarioLegendKeys,
|
|
197
|
+
solveFrame,
|
|
198
|
+
solveLabels,
|
|
199
|
+
toDateLabel,
|
|
200
|
+
toDateRoom,
|
|
201
|
+
unionRect
|
|
202
|
+
} from "./chunk-SS42FJVN.js";
|
|
203
|
+
import {
|
|
204
|
+
disclosureNote,
|
|
205
|
+
disclosuresShown
|
|
206
|
+
} from "./chunk-BPKXEMRE.js";
|
|
207
|
+
import {
|
|
208
|
+
formatStatWithSpec,
|
|
209
|
+
formatterFromExample,
|
|
210
|
+
neededDecimals,
|
|
211
|
+
roundedNumber,
|
|
212
|
+
seriesRasterFormatter
|
|
213
|
+
} from "./chunk-RGZGLKFB.js";
|
|
214
|
+
import {
|
|
215
|
+
NOT_AVAILABLE,
|
|
216
|
+
autoDecimals,
|
|
217
|
+
chartString,
|
|
218
|
+
chartStrings,
|
|
219
|
+
formatAutomaticNumber,
|
|
220
|
+
formatAutomaticPercent,
|
|
221
|
+
formatShare,
|
|
222
|
+
notApplicableGlyph,
|
|
223
|
+
stringFields,
|
|
224
|
+
withLocaleStrings
|
|
225
|
+
} from "./chunk-53OYF4ZT.js";
|
|
226
|
+
import {
|
|
227
|
+
cellMeta,
|
|
228
|
+
cellValue,
|
|
229
|
+
isPctCell
|
|
230
|
+
} from "./chunk-O3VN6BTL.js";
|
|
231
|
+
import {
|
|
232
|
+
canvasMargin,
|
|
233
|
+
colorRolePaints,
|
|
234
|
+
dashToken,
|
|
235
|
+
effectiveFill,
|
|
236
|
+
emphasisWeight,
|
|
237
|
+
joinHatchPeers,
|
|
238
|
+
markRolePaint,
|
|
239
|
+
namesOnly,
|
|
240
|
+
paintColor,
|
|
241
|
+
panelTypeClass,
|
|
242
|
+
rampSlots,
|
|
243
|
+
recedingSeriesId,
|
|
244
|
+
resolveTheme,
|
|
245
|
+
separationStroke,
|
|
246
|
+
seriesPaint,
|
|
247
|
+
stackApartPaint,
|
|
248
|
+
stackRampPaint,
|
|
249
|
+
strokeToken,
|
|
250
|
+
textScaleOf,
|
|
251
|
+
themeForWidth,
|
|
252
|
+
typeWidthClass,
|
|
253
|
+
withSegmentSeams
|
|
254
|
+
} from "./chunk-CWDHCSL2.js";
|
|
255
|
+
import {
|
|
256
|
+
NormalizeError,
|
|
257
|
+
accessibleTitle,
|
|
258
|
+
normalizeCategory,
|
|
259
|
+
normalizeScenario,
|
|
260
|
+
normalizeSeriesValues,
|
|
261
|
+
resolveHighlight,
|
|
262
|
+
resolveSize
|
|
263
|
+
} from "./chunk-SGD3ZHID.js";
|
|
264
|
+
import {
|
|
265
|
+
maxOf,
|
|
266
|
+
minOf,
|
|
267
|
+
pushAll
|
|
268
|
+
} from "./chunk-WYJEOMNY.js";
|
|
269
|
+
import {
|
|
270
|
+
defaultMeasurer,
|
|
271
|
+
wrapText
|
|
272
|
+
} from "./chunk-AG2CJ4JY.js";
|
|
273
|
+
|
|
274
|
+
// src/core/strings/bar.ts
|
|
275
|
+
var EN = {
|
|
276
|
+
// reader-facing wording linked only by its consumers.
|
|
277
|
+
groupedCapital: "Grouped",
|
|
278
|
+
stackedCapital: "Stacked",
|
|
279
|
+
stacked100: "100% stacked",
|
|
280
|
+
barTitle: "Bar chart: {v1} categories",
|
|
281
|
+
barDesc: "{v1} horizontal bar chart with {v2} series.{v3}",
|
|
282
|
+
rangesClause: " Ranges: {v1}.",
|
|
283
|
+
namedRange: "{v1} {v2} to {v3}",
|
|
284
|
+
footballTitle: "Football-field valuation: {v1} methods",
|
|
285
|
+
footballDesc: "Football-field range chart. {v1}.",
|
|
286
|
+
currentValueSentence: " Current value {v1}.",
|
|
287
|
+
tornadoTitle: "Sensitivity tornado: {v1} drivers",
|
|
288
|
+
tornadoDescStart: "Sensitivity tornado, one-at-a-time: each driver is varied alone with every other driver held at its base input, ",
|
|
289
|
+
tornadoDescEffects: "so the swings do not sum to a total and interaction effects are not shown. ",
|
|
290
|
+
tornadoBaseDesc: "Base case {v1}. Drivers by swing: ",
|
|
291
|
+
tornadoDriverDesc: "{v1}, {v2} {v3}, {v4} {v5}, swing {v6}{v7}{v8}",
|
|
292
|
+
inverseClause: ", inverse",
|
|
293
|
+
baseOutsideClause: ", base outside the swing",
|
|
294
|
+
inverseDriversDesc: " {v1} of {v2} drivers are inverse: their high input produces the lower output.",
|
|
295
|
+
gapLead: "gap",
|
|
296
|
+
missingDriversDesc: " {v1} further driver{v2} \u2014 {v3} \u2014 {v4} not shown: not measurable, because a one-at-a-time swing needs both case outputs and {v5} missing."
|
|
297
|
+
}, DE = {
|
|
298
|
+
// reader-facing wording linked only by its consumers.
|
|
299
|
+
groupedCapital: "Gruppiert",
|
|
300
|
+
stackedCapital: "Gestapelt",
|
|
301
|
+
stacked100: "100 % gestapelt",
|
|
302
|
+
barTitle: "Balkendiagramm: {v1} {v1|Kategorie|Kategorien}",
|
|
303
|
+
barDesc: "Horizontales Balkendiagramm ({v1}) mit {v2} {v2|Reihe|Reihen}.{v3}",
|
|
304
|
+
rangesClause: " Spannen: {v1}.",
|
|
305
|
+
namedRange: "{v1} {v2} bis {v3}",
|
|
306
|
+
footballTitle: "Bewertung mit Spannendiagramm: {v1} {v1|Methode|Methoden}",
|
|
307
|
+
footballDesc: "Spannendiagramm f\xFCr Bewertungen. {v1}.",
|
|
308
|
+
currentValueSentence: " Aktueller Wert {v1}.",
|
|
309
|
+
tornadoTitle: "Sensitivit\xE4tstornado: {v1} Treiber",
|
|
310
|
+
tornadoDescStart: "Sensitivit\xE4tstornado: Jeder Treiber wird einzeln ge\xE4ndert. Alle anderen Treiber behalten ihren Basiswert. ",
|
|
311
|
+
tornadoDescEffects: "Die Spannen ergeben keine Gesamtsumme. Wechselwirkungen werden nicht gezeigt. ",
|
|
312
|
+
tornadoBaseDesc: "Basisfall {v1}. Treiber nach Spanne: ",
|
|
313
|
+
tornadoDriverDesc: "{v1}, {v2} {v3}, {v4} {v5}, Spanne {v6}{v7}{v8}",
|
|
314
|
+
inverseClause: ", invers",
|
|
315
|
+
baseOutsideClause: ", Basis au\xDFerhalb der Spanne",
|
|
316
|
+
inverseDriversDesc: " {v1} von {v2} {v2|Treiber|Treibern} {v1|ist|sind} invers: Der hohe Eingabewert ergibt den niedrigeren Ausgabewert.",
|
|
317
|
+
gapLead: "Abstand",
|
|
318
|
+
missingDriversDesc: " {v1} {v1|weiterer Treiber|weitere Treiber} \u2014 {v3} \u2014 nicht gezeigt: nicht messbar. Eine einzeln berechnete Spanne braucht beide Ergebnisse. Mindestens eines fehlt."
|
|
319
|
+
}, { chartString: chartString2 } = chartStrings(EN, DE);
|
|
320
|
+
|
|
321
|
+
// src/core/charts/bar/domain.ts
|
|
322
|
+
function toDateOnValues(domain) {
|
|
323
|
+
let ids = /* @__PURE__ */ new Set(), { options, cats, dataSeries, variant } = domain;
|
|
324
|
+
if (partialKeyForced(options) || !cats.some((c) => c.partial === !0)) return ids;
|
|
325
|
+
let words = options.strings?.toDate ?? chartString(options, "toDate"), grouped = variant === "grouped", segments = dataSeries.length > 1 && labelOn(options, "segment");
|
|
326
|
+
if (dataSeries.length === 0 || variant === "stacked100" || (grouped ? dataSeries.length > 1 || !labelOn(options, "point") : segments || !domain.grandTotalsOn)) return ids;
|
|
327
|
+
let only = dataSeries[0], picked = grouped && options.valueLabels !== void 0 ? chosenValueIndices(options.valueLabels, cats.map((_, ci) => only.cells[ci]?.v ?? null)) : void 0;
|
|
328
|
+
return cats.forEach((c, ci) => {
|
|
329
|
+
if (c.partial !== !0 || saysToDate(c.label ?? c.id, words) || domain.nmRows[ci] || domain.naRows[ci] || domain.incompleteRows.has(c.id)) return;
|
|
330
|
+
let values = dataSeries.map((s) => s.cells[ci]?.v ?? null).filter((v) => v !== null);
|
|
331
|
+
if (values.length === 0 || values.some((v) => v < 0)) return;
|
|
332
|
+
let meta = values.length === 1 ? dataSeries.find((s) => (s.cells[ci]?.v ?? null) !== null).cells[ci].meta : null;
|
|
333
|
+
grouped && picked && !picked.has(ci) && typeof meta?.label != "string" || meta?.label === !1 || typeof meta?.label == "string" && meta.label.trim() === "" || ids.add(c.id);
|
|
334
|
+
}), ids;
|
|
335
|
+
}
|
|
336
|
+
function partialNamedOnValues(domain) {
|
|
337
|
+
let named = toDateOnValues(domain);
|
|
338
|
+
return named.size > 0 && domain.cats.every((c, ci) => c.partial !== !0 || named.has(c.id) || domain.dataSeries.every((s) => (s.cells[ci]?.v ?? null) === null));
|
|
339
|
+
}
|
|
340
|
+
function textFor(domain, v, cell, pctVal, s, categoryId) {
|
|
341
|
+
let { meta } = cell;
|
|
342
|
+
if (meta?.label === !1) return null;
|
|
343
|
+
let base = displayFor(domain, v, cell, pctVal, s, categoryId);
|
|
344
|
+
return typeof meta?.label == "string" ? meta.label.replace(/\$\{value\}/g, base) : base;
|
|
345
|
+
}
|
|
346
|
+
function displayFor(domain, v, cell, pctVal, s, categoryId) {
|
|
347
|
+
let { meta } = cell;
|
|
348
|
+
return pctVal !== void 0 ? (s && categoryId !== void 0 ? domain.shareTexts.get(`${categoryId}\0${s.id}`) : void 0) ?? formatShare(pctVal, domain.options.locale?.language) : meta?.format ? formatterFromExample(meta.format, domain.options.locale?.language)(v) : (cell.isPct && !s?.format ? domain.valueSpec.fmtPercent : s ? domain.valueSpec.forSeries(s) : domain.fmt)(v);
|
|
349
|
+
}
|
|
350
|
+
function valueLineValue(a, meanValue) {
|
|
351
|
+
return a.value === void 0 || a.value === "mean" ? meanValue : a.value;
|
|
352
|
+
}
|
|
353
|
+
function normalizeBarSeries(data, warnings) {
|
|
354
|
+
let { cats, series } = normalizeCategorySeries("bar", data, (s, authored, rawCats) => ({
|
|
355
|
+
id: s.id,
|
|
356
|
+
label: s.label ?? s.id,
|
|
357
|
+
scenario: normalizeScenario(s.scenario, `series[${s.id}].scenario`),
|
|
358
|
+
direction: s.direction,
|
|
359
|
+
role: s.role ?? "data",
|
|
360
|
+
colorRole: s.colorRole,
|
|
361
|
+
fill: s.fill,
|
|
362
|
+
format: s.format,
|
|
363
|
+
unit: s.unit,
|
|
364
|
+
slot: 0,
|
|
365
|
+
cells: authored.map((c, ci) => ({
|
|
366
|
+
v: cellValue(c),
|
|
367
|
+
...isPctCell(c) ? { isPct: !0 } : {},
|
|
368
|
+
meta: cellMeta(c),
|
|
369
|
+
range: resolveCellRange(c, `series[${s.id}].values[${ci}]`, warnings, { seriesId: s.id, categoryId: rawCats[ci]?.id })
|
|
370
|
+
})),
|
|
371
|
+
...authored.some(isPctCell) ? { pctCells: !0 } : {}
|
|
372
|
+
}));
|
|
373
|
+
return { rawCats: cats, normSeries: series };
|
|
374
|
+
}
|
|
375
|
+
function orderBarCategories(options, rawCats, normSeries, dataSeries, warnings) {
|
|
376
|
+
let cats = rawCats.map((c) => ({
|
|
377
|
+
id: c.id,
|
|
378
|
+
label: c.label ?? c.id,
|
|
379
|
+
date: c.date,
|
|
380
|
+
total100: c.total100,
|
|
381
|
+
gapAfter: c.gapAfter,
|
|
382
|
+
breakAfter: c.breakAfter,
|
|
383
|
+
...c.partial === !0 ? { partial: !0 } : {},
|
|
384
|
+
...c.footnote !== void 0 ? { footnote: c.footnote } : {},
|
|
385
|
+
...c.calendar ? { calendar: c.calendar } : {}
|
|
386
|
+
})), totalOf = (ci) => dataSeries.reduce((a, s) => a + (s.cells[ci].v ?? 0), 0), catSort = options.sort?.categories ?? "sheet";
|
|
387
|
+
if (catSort !== "sheet") {
|
|
388
|
+
let idx = cats.map((_, i) => i), tot = cats.map((_, i) => totalOf(i));
|
|
389
|
+
catSort === "asc" ? idx.sort((a, b) => tot[a] - tot[b] || a - b) : catSort === "desc" ? idx.sort((a, b) => tot[b] - tot[a] || a - b) : idx.reverse(), cats = idx.map((i) => cats[i]);
|
|
390
|
+
for (let s of normSeries) s.cells = idx.map((i) => s.cells[i]);
|
|
391
|
+
}
|
|
392
|
+
if (options.topN) {
|
|
393
|
+
let t = options.topN, { kept: keptOrder, dropped } = topNCut(cats.map((_, i) => Math.abs(totalOf(i))), Math.max(1, t.n), t.threshold);
|
|
394
|
+
if (dropped.length > 0)
|
|
395
|
+
if (t.rest ?? !0) {
|
|
396
|
+
normSeries.some((series) => dropped.some((i) => series.cells[i].range)) && warnings.push({
|
|
397
|
+
code: "range-topn-omitted",
|
|
398
|
+
severity: "warn",
|
|
399
|
+
message: "topN Others aggregates values but not ranges; dropped-item ranges were omitted",
|
|
400
|
+
suggest: "set topN.rest to false or pre-aggregate a defensible range upstream"
|
|
401
|
+
});
|
|
402
|
+
for (let s of normSeries) {
|
|
403
|
+
let isPct = dropped.every((i) => s.cells[i].v === null || s.cells[i].isPct);
|
|
404
|
+
s.cells = [...keptOrder.map((i) => s.cells[i]), { v: restSum(dropped.map((i) => s.cells[i].v)), ...isPct ? { isPct: !0 } : {}, meta: null }];
|
|
405
|
+
}
|
|
406
|
+
cats = [...keptOrder.map((i) => cats[i]), { id: OTHERS_ID, label: restLabel(t, options.strings, dropped.length) }];
|
|
407
|
+
} else {
|
|
408
|
+
for (let s of normSeries) s.cells = keptOrder.map((i) => s.cells[i]);
|
|
409
|
+
cats = keptOrder.map((i) => cats[i]);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return cats;
|
|
413
|
+
}
|
|
414
|
+
function barBasis(variant, cats, dataSeries, warnings) {
|
|
415
|
+
let totals = cats.map((_, ci) => dataSeries.reduce((a, s) => a + (s.cells[ci].v ?? 0), 0)), nmRows = cats.map(() => !1), naRows = cats.map(() => !1), overfull = [], composition = cats.map((cat, ci) => compositionBasis(dataSeries.map((s) => s.cells[ci]), cat.total100)), basisByCat = composition.map((c) => variant === "stacked100" ? c.basis : 1), shares = cats.map((cat, ci) => {
|
|
416
|
+
if (variant !== "stacked100") return [];
|
|
417
|
+
if (composition[ci].nm)
|
|
418
|
+
return nmRows[ci] = !0, dataSeries.map(() => 0);
|
|
419
|
+
let basis = basisByCat[ci];
|
|
420
|
+
if (composition[ci].na)
|
|
421
|
+
return warnings.push({
|
|
422
|
+
code: "total100-nonpositive",
|
|
423
|
+
severity: "warn",
|
|
424
|
+
message: `category '${cat.id}': non-positive 100% basis \u2014 nothing to compose, row marked n/a`,
|
|
425
|
+
owner: { categoryId: cat.id }
|
|
426
|
+
}), naRows[ci] = !0, dataSeries.map(() => 0);
|
|
427
|
+
let cells = dataSeries.map((s) => s.cells[ci]), sum = overfullShareSum(cells, basis);
|
|
428
|
+
return sum !== void 0 ? (overfull.push({ id: cat.id, sum }), dataSeries.map(() => 0)) : cells.map((cell) => cell.isPct ? cell.v ?? 0 : basis > 0 ? (cell.v ?? 0) / basis * 100 : 0);
|
|
429
|
+
});
|
|
430
|
+
variant === "stacked100" && nmRows.some(Boolean) && warnings.push(mixedSignsWarning(cats.filter((_, ci) => nmRows[ci]).map((c) => c.id), cats.length));
|
|
431
|
+
for (let row of overfull) nmRows[cats.findIndex((c) => c.id === row.id)] = !0;
|
|
432
|
+
overfull.length > 0 && warnings.push(overfullWarning(overfull, nmRows.every((nm, ci) => nm || naRows[ci]), "give every part as a share of the same whole, or use variant 'grouped' for shares that overlap, such as answers to a multi-select question"));
|
|
433
|
+
let plotVal = (ci, si) => {
|
|
434
|
+
let v = dataSeries[si].cells[ci].v;
|
|
435
|
+
return v === null ? null : variant === "stacked100" ? shares[ci][si] : v;
|
|
436
|
+
}, stacks = cats.map(
|
|
437
|
+
(_, ci) => accumulateStack(dataSeries.map((_2, si) => plotVal(ci, si)))
|
|
438
|
+
), plotRange = (ci, si) => {
|
|
439
|
+
let range = dataSeries[si].cells[ci].range;
|
|
440
|
+
if (!range) return;
|
|
441
|
+
if (variant !== "stacked100" || dataSeries[si].cells[ci].isPct) return range;
|
|
442
|
+
let basis = basisByCat[ci];
|
|
443
|
+
if (basis <= 0) return;
|
|
444
|
+
let scale = (value) => value / basis * 100;
|
|
445
|
+
return {
|
|
446
|
+
low: scale(range.low),
|
|
447
|
+
high: scale(range.high),
|
|
448
|
+
...range.mid === void 0 ? {} : { mid: scale(range.mid) }
|
|
449
|
+
};
|
|
450
|
+
}, rowEnds = cats.map((_, ci) => {
|
|
451
|
+
if (variant !== "grouped") {
|
|
452
|
+
let stack = stacks[ci];
|
|
453
|
+
return { pos: stack.positive, neg: stack.negative };
|
|
454
|
+
}
|
|
455
|
+
let pos = 0, neg = 0;
|
|
456
|
+
return dataSeries.forEach((_2, si) => {
|
|
457
|
+
let v = plotVal(ci, si);
|
|
458
|
+
v !== null && (pos = Math.max(pos, v), neg = Math.min(neg, v));
|
|
459
|
+
}), { pos, neg };
|
|
460
|
+
}), empty = (ci) => dataSeries.every((s) => s.cells[ci].v === null);
|
|
461
|
+
variant !== "grouped" && cats.forEach((_, ci) => {
|
|
462
|
+
empty(ci) && (naRows[ci] = !0);
|
|
463
|
+
});
|
|
464
|
+
let incompleteRows = new Set(variant === "grouped" ? [] : cats.filter((_, ci) => !empty(ci) && isIncomplete(dataSeries.map((s) => s.cells[ci].v))).map((c) => c.id));
|
|
465
|
+
return { totals, nmRows, naRows, incompleteRows, shares, plotVal, plotRange, stacks, rowEnds };
|
|
466
|
+
}
|
|
467
|
+
function barNetLine(options, variant, dataSeries, warnings) {
|
|
468
|
+
let netLineRequested = options.netLine !== void 0 && options.netLine !== !1, netLineSeriesId = typeof options.netLine == "object" ? options.netLine.seriesId : void 0, netLineSeries = netLineSeriesId ? dataSeries.find((series) => series.id === netLineSeriesId) : void 0, netLineOn = netLineRequested && variant !== "grouped";
|
|
469
|
+
if (netLineRequested && variant === "grouped" && warnings.push({
|
|
470
|
+
code: "net-line-ignored",
|
|
471
|
+
severity: "warn",
|
|
472
|
+
message: "netLine applies only to stacked and stacked100 bar charts; ignored for grouped"
|
|
473
|
+
}), netLineOn && netLineSeriesId && !netLineSeries && (netLineOn = !1, warnings.push({
|
|
474
|
+
code: "net-line-series-missing",
|
|
475
|
+
severity: "warn",
|
|
476
|
+
message: `netLine seriesId '${netLineSeriesId}' is not a plotted data series; net line omitted`,
|
|
477
|
+
owner: { seriesId: netLineSeriesId }
|
|
478
|
+
})), netLineOn) {
|
|
479
|
+
let values = dataSeries.flatMap(
|
|
480
|
+
(series) => series.cells.flatMap((cell) => cell.v === null ? [] : [cell.v])
|
|
481
|
+
), hasPositive = values.some((value) => value > 0), hasNegative = values.some((value) => value < 0), outermost = netLineSeries ? dataSeries.at(-1)?.id === netLineSeries.id : hasPositive && !hasNegative;
|
|
482
|
+
hasPositive !== hasNegative && outermost && warnings.push({
|
|
483
|
+
code: "netline-redundant",
|
|
484
|
+
severity: "warn",
|
|
485
|
+
message: "netLine traces the visible outer edge of a single-signed stack and adds no information",
|
|
486
|
+
...netLineSeries ? { owner: { seriesId: netLineSeries.id } } : {},
|
|
487
|
+
suggest: "Pick an inner boundary series with netLine.seriesId, or drop netLine."
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
return { netLineOn, netLineSeries };
|
|
491
|
+
}
|
|
492
|
+
function barAnnotations(options, variant, averageMarkerValue, statFmt) {
|
|
493
|
+
let annotationInput = [...options.annotations ?? []];
|
|
494
|
+
averageMarkerValue !== void 0 && annotationInput.push(averageMarkerLine(annotationInput, averageMarkerValue, statFmt, void 0, options.strings?.average));
|
|
495
|
+
let annotationsAll = annotationInput.map((a, n) => ({ ...a, id: a.id ?? `${a.kind}-${n + 1}` })), localAnns = annotationsAll.filter((a) => a.kind === "indicator100" || a.kind === "valueLine" && !valueLineHasTargetExtras(a)), passAnns = annotationsAll.filter((a) => !localAnns.includes(a));
|
|
496
|
+
return variant === "stacked100" && labelOn(options, "percentIndicator") && !localAnns.some((a) => a.kind === "indicator100") && localAnns.push({ kind: "indicator100", id: "indicator100-auto", priority: PRIORITY.endpoint }), { localAnns, passAnns };
|
|
497
|
+
}
|
|
498
|
+
function barValueExtent(domain, warnings) {
|
|
499
|
+
let { options, variant, cats, dataSeries, refSeries, plotVal, plotRange, stacks, meanValue } = domain, rendered = [], lo = 0, hi = 0;
|
|
500
|
+
for (let e of domain.rowEnds)
|
|
501
|
+
lo = Math.min(lo, e.neg), hi = Math.max(hi, e.pos);
|
|
502
|
+
if (cats.forEach((_, ci) => {
|
|
503
|
+
let stack = stacks[ci];
|
|
504
|
+
dataSeries.forEach((_2, si) => {
|
|
505
|
+
let value = plotVal(ci, si);
|
|
506
|
+
if (value === null) return;
|
|
507
|
+
let start = variant === "grouped" ? 0 : stack.segments[si].start, range = plotRange(ci, si);
|
|
508
|
+
rendered.push(variant === "grouped" ? value : stack.segments[si].end), range && (lo = Math.min(lo, start + range.low, start + range.high), hi = Math.max(hi, start + range.low, start + range.high), rendered.push(start + range.low, start + range.high), range.mid !== void 0 && rendered.push(start + range.mid));
|
|
509
|
+
});
|
|
510
|
+
}), variant !== "stacked100")
|
|
511
|
+
for (let rs of refSeries)
|
|
512
|
+
for (let c of rs.cells)
|
|
513
|
+
c.v !== null && (rendered.push(c.v), lo = Math.min(lo, c.v), hi = Math.max(hi, c.v));
|
|
514
|
+
else refSeries.some((rs) => rs.cells.some((c) => c.v !== null)) && warnings.push({
|
|
515
|
+
code: "reference-unsupported-stacked100",
|
|
516
|
+
severity: "warn",
|
|
517
|
+
message: "reference series omitted: a 100% axis shows composition, not level \u2014 show plan/PY targets on the absolute companion chart"
|
|
518
|
+
});
|
|
519
|
+
for (let a of domain.localAnns)
|
|
520
|
+
if (a.kind === "valueLine") {
|
|
521
|
+
let v = valueLineValue(a, meanValue);
|
|
522
|
+
if (v === void 0) continue;
|
|
523
|
+
rendered.push(v), lo = Math.min(lo, v), hi = Math.max(hi, v);
|
|
524
|
+
} else
|
|
525
|
+
rendered.push(100), hi = Math.max(hi, 100);
|
|
526
|
+
return [lo, hi] = applyAxisBounds([lo, hi], [lo, hi], options.valueAxis, warnings), { lo, hi, rendered };
|
|
527
|
+
}
|
|
528
|
+
function resolveBarDomain(data, options, warnings) {
|
|
529
|
+
let size = resolveSize(options.size), theme = themeForWidth(resolveTheme(options.theme), panelTypeClass(options) ?? size.width), paletteRamp = chartPalette(theme, options.palette, warnings), variant = options.variant ?? "grouped", connectorsOn = options.connectors !== void 0 && options.connectors !== !1;
|
|
530
|
+
connectorsOn && variant === "grouped" && warnings.push({
|
|
531
|
+
code: "connectors-ignored",
|
|
532
|
+
severity: "warn",
|
|
533
|
+
message: "connectors apply only to stacked and stacked100 bar charts; ignored for grouped"
|
|
534
|
+
});
|
|
535
|
+
let connectorScope = typeof options.connectors == "object" ? options.connectors.scope ?? "all" : "all", { rawCats, normSeries } = normalizeBarSeries(data, warnings), dataSeries = sortSegments(normSeries.filter((s) => s.role === "data"), options.sort?.segments, (s) => s.cells.reduce((sum, cell) => sum + (cell.v ?? 0), 0)), refSeries = normSeries.filter((s) => s.role === "reference");
|
|
536
|
+
if (dataSeries.length === 0)
|
|
537
|
+
throw new NormalizeError("no-data-series", "series", "bar requires at least one data-role series");
|
|
538
|
+
let hostDeclaresPrecision = options.rasterFromValues === !1, valueSpec = seriesRasterFormatter(options.format, hostDeclaresPrecision ? [] : normSeries.flatMap(
|
|
539
|
+
(s) => s.cells.flatMap((cell) => [cell.v, cell.range?.low, cell.range?.high, cell.range?.mid])
|
|
540
|
+
), options.locale?.language, options.unit, options.target, void 0, variant !== "grouped"), statSpec = !options.format && (variant === "stacked100" || options.unit === "%" || percentLevels(dataSeries.map((series) => ({ vals: series.cells })))) ? { ...valueSpec.spec, suffix: "%" } : valueSpec.spec, statFmt = (v) => formatStatWithSpec(v, statSpec);
|
|
541
|
+
variant === "stacked100" && dataSeries.length === 1 && warnings.push({
|
|
542
|
+
code: "stacked100-single-series",
|
|
543
|
+
severity: "warn",
|
|
544
|
+
message: "a 100% composition of a single series is always 100% \u2014 use variant:'stacked' or 'grouped' to show the level"
|
|
545
|
+
});
|
|
546
|
+
let cats = orderBarCategories(options, rawCats, normSeries, dataSeries, warnings), uniformScenario = /* @__PURE__ */ new Map();
|
|
547
|
+
variant !== "grouped" && dataSeries.length > 1 && cats.forEach((cat, ci) => {
|
|
548
|
+
let scenarios = dataSeries.filter((s) => s.cells[ci].v !== null).map((s) => s.cells[ci].meta?.scenario ?? s.scenario), scenario = scenarios[0];
|
|
549
|
+
scenario !== void 0 && scenarios.every((candidate) => candidate === scenario) && uniformScenario.set(cat.id, scenario);
|
|
550
|
+
});
|
|
551
|
+
let highlights = new Set(resolveHighlight(options.highlight)), roles = colorRolePaints(dataSeries), slots = rampSlots(theme, dataSeries.map(
|
|
552
|
+
(s) => s.fill ? { css: s.fill } : s.colorRole ? roles.get(s.id) : highlights.has(s.id) ? { token: "focus" } : void 0
|
|
553
|
+
), paletteRamp ? options.palette : void 0, { labels: dataSeries.map((s) => s.label), warnings });
|
|
554
|
+
dataSeries.forEach((s, i) => s.slot = slots[i]);
|
|
555
|
+
let basis = barBasis(variant, cats, dataSeries, warnings), addsOver = (series) => variant !== "stacked" && variant !== "stacked100" || stackAdds(series, options.unit, options.sharesOfOneWhole), partsAdd = addsOver(dataSeries), meanValue = partsAdd ? plottedMean("all", variant !== "grouped", cats.length, dataSeries, (_, si, ci) => basis.plotVal(ci, si)) : void 0, averageMarkerScope = typeof options.averageMarker == "object" ? options.averageMarker.scope : "all", averageMarkerRequested = options.averageMarker !== void 0 && options.averageMarker !== !1 && !averageOfWholeShares(variant, averageMarkerScope, warnings) && !averageOfUnaddedSums(addsOver(averageMarkerScope === "all" ? dataSeries : dataSeries.filter((s) => averageMarkerScope.includes(s.id))), warnings), averageMarkerValue = averageMarkerRequested ? plottedMean(averageMarkerScope, variant !== "grouped", cats.length, dataSeries, (_, si, ci) => basis.plotVal(ci, si)) : void 0;
|
|
556
|
+
averageMarkerRequested && averageMarkerValue === void 0 && warnings.push({
|
|
557
|
+
code: "average-marker-empty",
|
|
558
|
+
severity: "warn",
|
|
559
|
+
message: "averageMarker scope has no plotted values; marker omitted"
|
|
560
|
+
});
|
|
561
|
+
let grandTotalsRequested = grandTotalRequested(options.grandTotalLabels, variant, warnings, partsAdd), grandTotalsOn = grandTotalsRequested && labelOn(options, "grandTotal");
|
|
562
|
+
options.grandTotalLabels === !0 && options.labels === !1 && grandTotalsRequested && warnings.push({
|
|
563
|
+
code: "grand-total-labels-off",
|
|
564
|
+
severity: "warn",
|
|
565
|
+
message: "grandTotalLabels is true, but labels: false turns the grand totals off. Use a labels setting that leaves grand totals on: omit labels, or set labels to an object that does not set grandTotal to false.",
|
|
566
|
+
suggest: "Omit labels, or set labels.grandTotal to true and turn other label kinds off by name."
|
|
567
|
+
});
|
|
568
|
+
let sharesOn = variant === "stacked100" && labelOn(options, "segment");
|
|
569
|
+
warnIncompleteStacks(variant, cats, basis.incompleteRows, grandTotalsOn, sharesOn, "bars", warnings, disclosuresShown(options));
|
|
570
|
+
let wholes = sharesOn ? cats.flatMap((c, ci) => basis.nmRows[ci] || basis.naRows[ci] || basis.incompleteRows.has(c.id) || c.total100 !== void 0 ? [] : [{ c, parts: dataSeries.flatMap((s, si) => s.cells[ci].v === null ? [] : [{ s, share: basis.shares[ci][si] }]) }]) : [], shareTexts = /* @__PURE__ */ new Map(), roundingAdjustments = [];
|
|
571
|
+
if (options.rounding !== "nearest")
|
|
572
|
+
for (let { c, parts } of wholes) {
|
|
573
|
+
let rounded = sumConsistentShares(parts.map((part) => part.share), options.locale?.language);
|
|
574
|
+
rounded?.warning ? warnings.push(roundingUnavailable(c.label, rounded.warning)) : rounded && parts.forEach((part, index) => {
|
|
575
|
+
shareTexts.set(`${c.id}\0${part.s.id}`, rounded.texts[index]), rounded.moved[index] && roundingAdjustments.push({
|
|
576
|
+
whole: c.label,
|
|
577
|
+
part: part.s.label,
|
|
578
|
+
share: Math.round(part.share * 1e4) / 1e4,
|
|
579
|
+
nearest: formatShare(part.share, options.locale?.language),
|
|
580
|
+
printed: rounded.texts[index]
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
else sharesOn && warnShareRoundingDrift(warnings, wholes.map(({ c, parts }) => ({ name: c.label, shares: parts.map((part) => part.share) })));
|
|
585
|
+
let domain = {
|
|
586
|
+
options,
|
|
587
|
+
theme,
|
|
588
|
+
palette: paletteRamp ? options.palette : void 0,
|
|
589
|
+
size,
|
|
590
|
+
measure: options.measure ?? defaultMeasurer,
|
|
591
|
+
highlights,
|
|
592
|
+
variant,
|
|
593
|
+
shareTexts,
|
|
594
|
+
roundingAdjustments,
|
|
595
|
+
referenceStyle: options.referenceStyle ?? "tick",
|
|
596
|
+
connectorsOn,
|
|
597
|
+
referenceTick: {
|
|
598
|
+
width: options.referenceTick?.width ?? strokeToken(theme, "rule"),
|
|
599
|
+
color: options.referenceTick?.color ?? "ink"
|
|
600
|
+
},
|
|
601
|
+
connectorDashed: typeof options.connectors == "object" && options.connectors.style === "dashed",
|
|
602
|
+
connectorSeries: connectorScope === "all" ? null : new Set(connectorScope),
|
|
603
|
+
// A 100 % stack has no total by default: every bar would end on the same
|
|
604
|
+
// number. An authored `grandTotalLabels: true` keeps the absolute total.
|
|
605
|
+
grandTotalsOn,
|
|
606
|
+
partsAdd,
|
|
607
|
+
...partsAdd ? {} : { meanMissing: NO_STACK_MEAN },
|
|
608
|
+
axisFmt: variant === "stacked100" ? { format: (v) => formatAutomaticPercent(v, 0, !1, options.locale?.language) } : percentCellsOnly(dataSeries.map((series) => ({ vals: series.cells.map((cell) => ({ ...cell, format: cell.meta?.format })), format: series.format }))) ? { format: valueSpec.fmtPercent, formatSpec: valueSpec.percentSpec } : { format: valueSpec.fmt, formatSpec: valueSpec.spec },
|
|
609
|
+
cats,
|
|
610
|
+
dataSeries,
|
|
611
|
+
refSeries,
|
|
612
|
+
valueSpec,
|
|
613
|
+
fmt: valueSpec.fmt,
|
|
614
|
+
totalFmt: stackTotalFormatter(variant, valueSpec.spec, valueSpec.fmt),
|
|
615
|
+
statFmt,
|
|
616
|
+
uniformScenario,
|
|
617
|
+
/**
|
|
618
|
+
* A category highlight on one series makes the named bars the
|
|
619
|
+
* subject. They take `highlight` and every other bar steps back to
|
|
620
|
+
* `neutralLight`, the rest role line context and box rows use (`others`
|
|
621
|
+
* sits below the mark floor on every preset and would need an outline
|
|
622
|
+
* that reads as PL). No row band then. With several series the colours
|
|
623
|
+
* carry series identity, so the band stays the one highlight channel
|
|
624
|
+
* there. A highlight without a body (null, or zero, drawn as a 0.5px
|
|
625
|
+
* hairline) recedes nothing, or the chart would be all rest and no subject.
|
|
626
|
+
*/
|
|
627
|
+
restRecedes: dataSeries.length === 1 && cats.some((cat, ci) => highlights.has(cat.id) && (dataSeries[0].cells[ci].v ?? 0) !== 0),
|
|
628
|
+
...basis,
|
|
629
|
+
meanValue,
|
|
630
|
+
...barNetLine(options, variant, dataSeries, warnings),
|
|
631
|
+
...barAnnotations(options, variant, averageMarkerValue, statFmt)
|
|
632
|
+
};
|
|
633
|
+
return { ...domain, ...barValueExtent(domain, warnings) };
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// src/core/charts/bar/annotations.ts
|
|
637
|
+
function layoutBarLocalAnnotations(domain, area, warnings) {
|
|
638
|
+
let { size, measure, fmt, statFmt, meanValue } = domain, { plot, x, strongFont } = area, out = {
|
|
639
|
+
nodes: [],
|
|
640
|
+
claims: createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }),
|
|
641
|
+
requests: [],
|
|
642
|
+
placed: []
|
|
643
|
+
}, { nodes, claims, requests, placed } = out, percent = domain.variant === "stacked100" || domain.options.unit === "%" || percentLevels(domain.dataSeries.map((series) => ({ vals: series.cells })));
|
|
644
|
+
for (let ann of domain.localAnns) {
|
|
645
|
+
let id = ann.id, annFmt = ann.format ? formatterFromExample(ann.format, domain.options.locale?.language) : fmt;
|
|
646
|
+
if (ann.kind === "valueLine") {
|
|
647
|
+
let v = valueLineValue(ann, meanValue);
|
|
648
|
+
if (v === void 0) {
|
|
649
|
+
warnings.push({
|
|
650
|
+
code: "no-mean",
|
|
651
|
+
severity: "warn",
|
|
652
|
+
message: `valueLine '${id}': ${domain.meanMissing ?? "no mean available"}`,
|
|
653
|
+
...domain.meanMissing ? { suggest: SHARES_OF_ONE_WHOLE_FIX } : {}
|
|
654
|
+
});
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
let vx = x(v), lineId = `ann:${id}:line`;
|
|
658
|
+
nodes.push({
|
|
659
|
+
t: "line",
|
|
660
|
+
id: lineId,
|
|
661
|
+
x1: vx,
|
|
662
|
+
y1: plot.y,
|
|
663
|
+
x2: vx,
|
|
664
|
+
y2: plot.y + plot.h,
|
|
665
|
+
stroke: { token: "ink" },
|
|
666
|
+
width: strokeToken(domain.theme, "rule"),
|
|
667
|
+
dash: dashToken(domain.theme, "reference"),
|
|
668
|
+
owner: { annotationId: id },
|
|
669
|
+
part: "valueLine"
|
|
670
|
+
}), claims.claim({ x: vx - 1, y: plot.y, w: 2, h: plot.h }, "annotation", { annotationId: id }, "referenceLine");
|
|
671
|
+
let isMean = ann.value === void 0 || ann.value === "mean", meanFmt = ann.format ? annFmt : statFmt, valueText = !isMean && !id.startsWith("averageMarker") && !ann.format && !domain.options.format && roundedNumber(v, domain.valueSpec.spec) !== v ? formatAutomaticNumber(v, { locale: domain.options.locale?.language, decimals: Math.max(autoDecimals(v), neededDecimals(v)), suffix: percent ? "%" : "" }) : isMean ? meanFmt(v) : percent && !ann.format && !domain.options.format ? domain.valueSpec.fmtPercent(v) : annFmt(v), labelText = ann.label === !1 ? "" : ann.label !== void 0 ? namedLineText(ann.label, valueText, v, id) : isMean ? `${domain.options.strings.average} ${valueText}` : valueText;
|
|
672
|
+
if (labelText) {
|
|
673
|
+
let lines = labelText.split(`
|
|
674
|
+
`), w = Math.max(...lines.map((l) => measure(l, strongFont).width)), h = lines.length * measure("X", strongFont).height;
|
|
675
|
+
requests.push({
|
|
676
|
+
id: `valueLine:${id}`,
|
|
677
|
+
kind: "valueLine",
|
|
678
|
+
role: composedTextRole(labelText),
|
|
679
|
+
owner: { annotationId: id },
|
|
680
|
+
text: labelText,
|
|
681
|
+
lines,
|
|
682
|
+
typeRole: "label",
|
|
683
|
+
font: strongFont,
|
|
684
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
685
|
+
candidates: [
|
|
686
|
+
{ slot: "aboveLine", rect: { x: vx - w / 2, y: plot.y - h - 6, w, h }, penalty: 0 },
|
|
687
|
+
{ slot: "aboveLineLeft", rect: { x: vx - w - 4, y: plot.y - h - 6, w, h }, penalty: 1 },
|
|
688
|
+
{ slot: "aboveLineRight", rect: { x: vx + 4, y: plot.y - h - 6, w, h }, penalty: 2 }
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
placed.push({
|
|
693
|
+
id,
|
|
694
|
+
kind: "valueLine",
|
|
695
|
+
computedText: labelText,
|
|
696
|
+
valueText,
|
|
697
|
+
nodeIds: [lineId],
|
|
698
|
+
labelId: labelText ? `valueLine:${id}` : void 0
|
|
699
|
+
});
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
indicator100(domain, area, ann, out);
|
|
703
|
+
}
|
|
704
|
+
return out;
|
|
705
|
+
}
|
|
706
|
+
function indicator100(domain, area, ann, out) {
|
|
707
|
+
let { measure } = domain, { plot, x, tickFont } = area, { nodes, claims, requests, placed } = out, id = ann.id, vx = x(100), tickId = `ann:${id}:tick`;
|
|
708
|
+
nodes.push({
|
|
709
|
+
t: "line",
|
|
710
|
+
id: tickId,
|
|
711
|
+
x1: vx,
|
|
712
|
+
y1: plot.y - 12,
|
|
713
|
+
x2: vx,
|
|
714
|
+
y2: plot.y - 4,
|
|
715
|
+
stroke: { token: "ink" },
|
|
716
|
+
width: strokeToken(domain.theme, "rule"),
|
|
717
|
+
owner: { annotationId: id },
|
|
718
|
+
part: "indicator100"
|
|
719
|
+
}), claims.claim({ x: vx - 1, y: plot.y - 12, w: 2, h: 8 }, "annotation", { annotationId: id });
|
|
720
|
+
let text = "100%", tsize = measure(text, tickFont), side = ann.side ?? "left", leftRect = {
|
|
721
|
+
x: vx - tsize.width - 5,
|
|
722
|
+
y: plot.y - tsize.height - 6,
|
|
723
|
+
w: tsize.width,
|
|
724
|
+
h: tsize.height
|
|
725
|
+
}, rightRect = { ...leftRect, x: vx + 5 };
|
|
726
|
+
requests.push({
|
|
727
|
+
id: `indicator100:${id}`,
|
|
728
|
+
kind: "percentIndicator",
|
|
729
|
+
owner: { annotationId: id },
|
|
730
|
+
text,
|
|
731
|
+
lines: [text],
|
|
732
|
+
typeRole: "label",
|
|
733
|
+
font: tickFont,
|
|
734
|
+
priority: ann.priority ?? PRIORITY.valueLine,
|
|
735
|
+
candidates: side === "left" ? [
|
|
736
|
+
{ slot: "left", rect: leftRect, penalty: 0 },
|
|
737
|
+
{ slot: "right", rect: rightRect, penalty: 1 }
|
|
738
|
+
] : [
|
|
739
|
+
{ slot: "right", rect: rightRect, penalty: 0 },
|
|
740
|
+
{ slot: "left", rect: leftRect, penalty: 1 }
|
|
741
|
+
]
|
|
742
|
+
}), placed.push({
|
|
743
|
+
id,
|
|
744
|
+
kind: "indicator100",
|
|
745
|
+
computedText: text,
|
|
746
|
+
nodeIds: [tickId],
|
|
747
|
+
labelId: `indicator100:${id}`
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// src/core/charts/bar/labels.ts
|
|
752
|
+
function emphasizedSeries(domain, s) {
|
|
753
|
+
return domain.variant !== "grouped" && domain.dataSeries.length > 1 && !s.fill && (s.colorRole === "highlight" || !s.colorRole && domain.highlights.has(s.id));
|
|
754
|
+
}
|
|
755
|
+
function endCandidates(area, rect, positive, tsize, fillCss, range, outsideOnly = !1) {
|
|
756
|
+
let { x } = area, cy = rect.y + rect.h / 2, fits = fitsInside(rect, { width: 0, height: 0 }) && tsize.width + 10 <= rect.w && tsize.height + 2 <= rect.h, inside = {
|
|
757
|
+
slot: "insideEnd",
|
|
758
|
+
rect: {
|
|
759
|
+
x: positive ? rect.x + rect.w - LABEL_GAP - tsize.width : rect.x + LABEL_GAP,
|
|
760
|
+
y: cy - tsize.height / 2,
|
|
761
|
+
w: tsize.width,
|
|
762
|
+
h: tsize.height
|
|
763
|
+
},
|
|
764
|
+
penalty: 0,
|
|
765
|
+
insideFill: fillCss
|
|
766
|
+
}, outside = {
|
|
767
|
+
slot: "outsideEnd",
|
|
768
|
+
rect: {
|
|
769
|
+
x: range ? positive ? Math.max(rect.x + rect.w, x(range.low), x(range.high)) + LABEL_GAP : Math.min(rect.x, x(range.low), x(range.high)) - LABEL_GAP - tsize.width : positive ? rect.x + rect.w + LABEL_GAP : area.negativeLabelsAcross ? area.x0 + LABEL_GAP : rect.x - LABEL_GAP - tsize.width,
|
|
770
|
+
y: cy - tsize.height / 2,
|
|
771
|
+
w: tsize.width,
|
|
772
|
+
h: tsize.height
|
|
773
|
+
},
|
|
774
|
+
penalty: 1
|
|
775
|
+
};
|
|
776
|
+
return outsideOnly || !fits ? [{ ...outside, penalty: 0 }] : [inside, outside];
|
|
777
|
+
}
|
|
778
|
+
function planBarLabels(domain, paints, area, scene, warnings) {
|
|
779
|
+
let { options, measure, highlights, cats, dataSeries, variant, totals, plotRange } = domain, { labelFont, strongFont, tickFont, pointFont, compact, band } = area, requests = [], slivers = [], maxTotal = maxOf(totals), minTotal = minOf(totals), bonus = (catId, seriesId) => highlights.has(catId) || seriesId !== void 0 && highlights.has(seriesId) ? PRIORITY.highlightBonus : 0, halves = barHalves(options), mode = variant === "grouped" ? options.valueLabels : void 0, chosen = mode === void 0 ? void 0 : new Map(dataSeries.map((s) => [s.id, chosenValueIndices(mode, cats.map((_, ci) => s.cells[ci]?.v ?? null))])), toDateIds = toDateOnValues(domain), toDate = options.strings?.toDate ?? chartString(options, "toDate");
|
|
780
|
+
return cats.forEach((cat, ci) => {
|
|
781
|
+
let part, partText, rowCenter = band.position(ci) + band.bandwidth / 2, outer = variant === "stacked" ? outerSegments(scene.bars[ci]) : [];
|
|
782
|
+
for (let { s, si, v, val, rect: own } of scene.bars[ci]) {
|
|
783
|
+
let twin = halves?.pos === s.id ? scene.bars[ci].find((bar) => bar.s.id === halves.neg)?.rect : void 0, rect = twin ? unionRect(twin, own) : own, cell = s.cells[ci], owner = { seriesId: s.id, categoryId: cat.id }, { paint, pattern } = paints.cell(s, cat, cell.meta, cell.v);
|
|
784
|
+
if (variant === "grouped") {
|
|
785
|
+
if (!labelOn(options, "point") || area.thinBars && si !== 0 && bonus(cat.id, s.id) === 0 || chosen && !chosen.get(s.id)?.has(ci) && typeof cell.meta?.label != "string") continue;
|
|
786
|
+
let text2 = textFor(domain, v, cell, void 0, s);
|
|
787
|
+
if (!text2) continue;
|
|
788
|
+
let valueFont = bonus(cat.id, s.id) > 0 ? { ...pointFont, weight: emphasisWeight(domain.theme) } : pointFont, words = toDateIds.has(cat.id) ? toDateLabel(text2, valueFont, toDate, domain.theme, measure) : void 0, measured = measure(text2, valueFont), tsize2 = words?.size ?? (compact ? compactValueTextSize("horizontal", measured, pointFont.size) : measured);
|
|
789
|
+
requests.push({
|
|
790
|
+
id: `point:${s.id}:${cat.id}`,
|
|
791
|
+
kind: "point",
|
|
792
|
+
markAnchored: !0,
|
|
793
|
+
owner,
|
|
794
|
+
text: text2,
|
|
795
|
+
lines: words?.lines ?? [text2],
|
|
796
|
+
...words?.request,
|
|
797
|
+
typeRole: "label",
|
|
798
|
+
font: pointFont,
|
|
799
|
+
...bonus(cat.id, s.id) > 0 ? { protect: !0, emphasis: !0 } : {},
|
|
800
|
+
...typeof cell.meta?.label == "string" ? { keepWhenDense: !0 } : {},
|
|
801
|
+
// An authored label prints the value only through its ${value} slot.
|
|
802
|
+
...namesOnly(void 0, cell.meta?.label),
|
|
803
|
+
// Thin bars: a compact label may touch its neighbour's slot edge to edge.
|
|
804
|
+
...compact ? { pad: 0 } : {},
|
|
805
|
+
priority: cell.meta?.priority ?? (ci === 0 || ci === cats.length - 1 ? PRIORITY.endpoint : totals[ci] === maxTotal || totals[ci] === minTotal ? PRIORITY.extreme : PRIORITY.interior + Math.min(99, Math.abs(v))) + bonus(cat.id, s.id),
|
|
806
|
+
candidates: endCandidates(area, rect, v >= 0, tsize2, paints.css(paint, pattern), plotRange(ci, si), domain.theme.marks?.barLabels === "outside" || words !== void 0).map((candidate) => ({ ...candidate, insidePaint: paint, insidePattern: pattern }))
|
|
807
|
+
});
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
810
|
+
if (!labelOn(options, "segment") || domain.nmRows[ci] || domain.naRows[ci] || v === 0 && typeof cell.meta?.label != "string") continue;
|
|
811
|
+
if (variant === "stacked100" && domain.incompleteRows.has(cat.id) && cat.total100 === void 0) {
|
|
812
|
+
let value = textFor(domain, v, cell, void 0, s);
|
|
813
|
+
value && !domain.nmRows[ci] && !domain.naRows[ci] && requests.push({
|
|
814
|
+
id: `segment:${s.id}:${cat.id}`,
|
|
815
|
+
kind: "segment",
|
|
816
|
+
owner,
|
|
817
|
+
text: value,
|
|
818
|
+
lines: [value],
|
|
819
|
+
typeRole: "label",
|
|
820
|
+
font: labelFont,
|
|
821
|
+
priority: PRIORITY.interior,
|
|
822
|
+
redundant: !0,
|
|
823
|
+
suppressedAs: "density",
|
|
824
|
+
owed: !0,
|
|
825
|
+
noteText: `${s.label} ${value} (${noteName(cat)})`,
|
|
826
|
+
candidates: []
|
|
827
|
+
});
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
let text = textFor(domain, v, cell, variant === "stacked100" ? val : void 0, s, cat.id);
|
|
831
|
+
if (!text) continue;
|
|
832
|
+
let segmentFont = emphasizedSeries(domain, s) ? strongFont : labelFont, tsize = measure(text, segmentFont), plain = bonus(cat.id, s.id) === 0, restHidden = typeof cell.meta?.label != "string" && plain && restValuesHidden(options, s.colorRole), sliver = !restHidden && plain && !fitsInside(rect, tsize, 0) && segmentTooShort(options.labelDensity ?? "smart", rect.w, tsize.width, options.labelPlacements?.[`segment:${s.id}:${cat.id}`]), onePart = variant === "stacked" && (typeof cell.meta?.label != "string" || printsValue(cell.meta.label)) && v !== 0 && onePartDrawn(dataSeries.map((x) => x.cells[ci].v)), endSeat = !restHidden && !twin && !onePart && !(dataSeries.length === 1 && domain.grandTotalsOn) && outer.includes(own) && options.labelDensity !== "minimal" && !fitsInside(rect, tsize, 0) ? stackEndSeat(own, v < 0, rowCenter, tsize) : void 0;
|
|
833
|
+
if (endSeat) {
|
|
834
|
+
requests.push({
|
|
835
|
+
id: `segment:${s.id}:${cat.id}`,
|
|
836
|
+
kind: "segment",
|
|
837
|
+
owner,
|
|
838
|
+
...namesOnly(void 0, cell.meta?.label),
|
|
839
|
+
text,
|
|
840
|
+
lines: [text],
|
|
841
|
+
typeRole: "label",
|
|
842
|
+
font: segmentFont,
|
|
843
|
+
...segmentFont !== labelFont ? { fontStep: segmentFont } : {},
|
|
844
|
+
...bonus(cat.id, s.id) > 0 ? { protect: !0 } : {},
|
|
845
|
+
swatch: paint,
|
|
846
|
+
priority: cell.meta?.priority ?? PRIORITY.interior + Math.min(99, Math.abs(val)) + bonus(cat.id, s.id),
|
|
847
|
+
pad: 3,
|
|
848
|
+
...sliver ? { quietWhenCrowded: !0, owed: !0 } : {},
|
|
849
|
+
noteText: `${s.label} ${text} (${noteName(cat)})`,
|
|
850
|
+
candidates: [endSeat]
|
|
851
|
+
});
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
sliver && variant === "stacked100" ? requests.push({ ...shareRowRequest(area, s.id, cat.id, ci, text, paint, labelFont, measure), ...namesOnly(void 0, cell.meta?.label) }) : sliver && !((dataSeries.length === 1 || onePart) && domain.grandTotalsOn) && slivers.push(`${s.label} in ${cat.label}`), onePart && (part = `segment:${s.id}:${cat.id}`, partText = typeof cell.meta?.label == "string" ? text : void 0), requests.push({
|
|
855
|
+
id: `segment:${s.id}:${cat.id}`,
|
|
856
|
+
kind: "segment",
|
|
857
|
+
owner,
|
|
858
|
+
...onePart ? { printedIn: `grandTotal:${cat.id}` } : {},
|
|
859
|
+
// A split neutral prints its full share once, over both halves.
|
|
860
|
+
...twin ? { printsFor: [owner, { seriesId: halves.neg, categoryId: cat.id }] } : {},
|
|
861
|
+
...namesOnly(void 0, cell.meta?.label),
|
|
862
|
+
text,
|
|
863
|
+
lines: [text],
|
|
864
|
+
typeRole: "label",
|
|
865
|
+
font: segmentFont,
|
|
866
|
+
...segmentFont !== labelFont ? { fontStep: segmentFont } : {},
|
|
867
|
+
...bonus(cat.id, s.id) > 0 ? { protect: !0 } : {},
|
|
868
|
+
priority: cell.meta?.priority ?? PRIORITY.interior + Math.min(99, Math.abs(val)) + bonus(cat.id, s.id),
|
|
869
|
+
// Inside its segment only, so the segment's own edges are its air:
|
|
870
|
+
// the theme's label pad (5 px in some house themes) against the
|
|
871
|
+
// neighbouring segment would blank a value that fits.
|
|
872
|
+
pad: 0,
|
|
873
|
+
// single-segment stacks never print value + identical total;
|
|
874
|
+
// a segment shorter than its label hides the value, unless it
|
|
875
|
+
// is the highlighted one, which the solver drops last
|
|
876
|
+
redundant: dataSeries.length === 1 && domain.grandTotalsOn || sliver,
|
|
877
|
+
// A sliver's value is lost on the canvas, so the note names it (an authored 'minimal' drops it by choice).
|
|
878
|
+
...sliver && variant !== "stacked100" && !(dataSeries.length === 1 && domain.grandTotalsOn) && options.labelDensity !== "minimal" ? { suppressedAs: "density", owed: !0, noteText: `${s.label} ${text} (${noteName(cat)})` } : {},
|
|
879
|
+
...restHidden ? restValueHiding(`${s.label} ${text} (${noteName(cat)})`) : {},
|
|
880
|
+
// Inside the segment only: past the bar end a value reads as the row's
|
|
881
|
+
// total, and on a 100 % bar it repeats one segment's share unnamed.
|
|
882
|
+
candidates: segmentLabelCandidates("horizontal", rect, tsize, paints.css(paint, pattern), { insidePaint: paint, insidePattern: pattern })
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
if (variant !== "grouped" && domain.grandTotalsOn && !domain.nmRows[ci] && !domain.naRows[ci] && !(variant === "stacked100" && domain.incompleteRows.has(cat.id))) {
|
|
886
|
+
let text = partText ?? domain.totalFmt(totals[ci]), second = toDateIds.has(cat.id) ? toDate : domain.incompleteRows.has(cat.id) && disclosuresShown(domain.options) ? domain.options.strings.incomplete : void 0, words = second ? toDateLabel(text, strongFont, second, domain.theme, measure) : void 0, tsize = words?.size ?? measure(text, strongFont), column = options[TOTAL_COLUMN], candidates = [
|
|
887
|
+
...column === void 0 || words ? [] : [{ slot: "column", rect: { x: column - tsize.width, y: rowCenter - tsize.height / 2, w: tsize.width, h: tsize.height }, penalty: 0 }],
|
|
888
|
+
...totalLabelCandidates("horizontal", { x: area.x(domain.rowEnds[ci].pos), y: rowCenter }, tsize).map((candidate) => column === void 0 || words ? candidate : { ...candidate, penalty: candidate.penalty + 1 })
|
|
889
|
+
], end = [...scene.bars[ci]].reverse().find((bar) => bar.v > 0);
|
|
890
|
+
if (!words && end && tsize.width + 10 <= end.rect.w && tsize.height + 2 <= end.rect.h) {
|
|
891
|
+
let cell = end.s.cells[ci], { paint, pattern } = paints.cell(end.s, cat, cell.meta, cell.v);
|
|
892
|
+
candidates.push({
|
|
893
|
+
slot: "insideEnd",
|
|
894
|
+
rect: { x: end.rect.x + end.rect.w - LABEL_GAP - tsize.width, y: rowCenter - tsize.height / 2, w: tsize.width, h: tsize.height },
|
|
895
|
+
penalty: 2,
|
|
896
|
+
insideFill: paints.css(paint, pattern),
|
|
897
|
+
insidePaint: paint,
|
|
898
|
+
insidePattern: pattern
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
requests.push({
|
|
902
|
+
id: `grandTotal:${cat.id}`,
|
|
903
|
+
kind: "grandTotal",
|
|
904
|
+
markAnchored: !0,
|
|
905
|
+
// The total prints the value alone: it names its one part back, so a pinned part placed first takes the value.
|
|
906
|
+
...part && !words ? { printedIn: part } : {},
|
|
907
|
+
owner: { categoryId: cat.id },
|
|
908
|
+
text,
|
|
909
|
+
lines: words?.lines ?? [text],
|
|
910
|
+
...words?.request,
|
|
911
|
+
typeRole: "label",
|
|
912
|
+
font: strongFont,
|
|
913
|
+
priority: PRIORITY.grandTotal + bonus(cat.id),
|
|
914
|
+
// A highlighted stack's total keeps the full ink under labels.ink 'muted'.
|
|
915
|
+
...bonus(cat.id) > 0 ? { emphasis: !0 } : {},
|
|
916
|
+
candidates
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
if (labelOn(options, "category")) {
|
|
920
|
+
let cl = area.catLines[ci];
|
|
921
|
+
requests.push({
|
|
922
|
+
id: `category:${cat.id}`,
|
|
923
|
+
kind: "category",
|
|
924
|
+
owner: { categoryId: cat.id },
|
|
925
|
+
text: cat.label,
|
|
926
|
+
...fittedLabel(cl, tickFont),
|
|
927
|
+
typeRole: "axis",
|
|
928
|
+
font: tickFont,
|
|
929
|
+
priority: PRIORITY.endpoint + bonus(cat.id),
|
|
930
|
+
candidates: [
|
|
931
|
+
{
|
|
932
|
+
slot: "left",
|
|
933
|
+
rect: {
|
|
934
|
+
// Row labels share ONE left edge by default; 'right' restores the
|
|
935
|
+
// block-against-the-plot behaviour (see rowLabelX).
|
|
936
|
+
x: rowLabelX(area.frame.plot.x, area.catBandW, cl.w, options.rowLabels?.align ?? "left"),
|
|
937
|
+
y: rowCenter - cl.h / 2,
|
|
938
|
+
w: cl.w,
|
|
939
|
+
h: cl.h
|
|
940
|
+
},
|
|
941
|
+
penalty: 0
|
|
942
|
+
}
|
|
943
|
+
]
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}), pushAll(requests, referenceLabels(domain, area)), warnSliverLabels(warnings, slivers, "widen the chart, or shorten the values with a coarser format"), rankValueLabels(requests, (request) => {
|
|
947
|
+
let ci = cats.findIndex((c) => c.id === request.owner.categoryId);
|
|
948
|
+
if (!(ci < 0))
|
|
949
|
+
return request.kind === "grandTotal" ? totals[ci] : dataSeries.find((s) => s.id === request.owner.seriesId)?.cells[ci]?.v;
|
|
950
|
+
}, options.labelDensity ?? "smart", options.labelPlacements, {
|
|
951
|
+
categories: cats.length,
|
|
952
|
+
pitch: band.step / (variant === "grouped" ? dataSeries.length : 1),
|
|
953
|
+
orientation: "horizontal",
|
|
954
|
+
measure
|
|
955
|
+
}), requests;
|
|
956
|
+
}
|
|
957
|
+
var SHARE_ROW_SWATCH = SWATCH_RESERVE;
|
|
958
|
+
function outerSegments(bars) {
|
|
959
|
+
let below = bars.filter((bar) => bar.v < 0).map((bar) => bar.rect), above = bars.filter((bar) => bar.v > 0).map((bar) => bar.rect);
|
|
960
|
+
return [
|
|
961
|
+
...below.length ? [below.reduce((a, b) => b.x < a.x ? b : a)] : [],
|
|
962
|
+
...above.length ? [above.reduce((a, b) => b.x + b.w > a.x + a.w ? b : a)] : []
|
|
963
|
+
];
|
|
964
|
+
}
|
|
965
|
+
function stackEndSeat(rect, below, rowCenter, tsize) {
|
|
966
|
+
let w = tsize.width + SHARE_ROW_SWATCH;
|
|
967
|
+
return { slot: "outsideEnd", rect: { x: below ? rect.x - STACK_END_GAP - w : rect.x + rect.w + STACK_END_GAP, y: rowCenter - tsize.height / 2, w, h: tsize.height }, penalty: 0 };
|
|
968
|
+
}
|
|
969
|
+
var STACK_END_GAP = 6;
|
|
970
|
+
function shareRowRequest(area, seriesId, catId, ci, text, paint, font, measure) {
|
|
971
|
+
let { band, x, plot } = area, size = measure(text, font), w = size.width + SHARE_ROW_SWATCH, cy = band.position(ci) + band.bandwidth / 2 - size.height / 2, right = plot.x + plot.w - w, seats = [];
|
|
972
|
+
for (let at = x(100) + 6, k = 0; at <= right + 0.5 && k < 40; at += 4, k++)
|
|
973
|
+
seats.push({ slot: k === 0 ? "shareRow" : `shareRow${k}`, rect: { x: Math.min(at, right), y: cy, w, h: size.height }, penalty: k / 100 });
|
|
974
|
+
return {
|
|
975
|
+
id: `share:${seriesId}:${catId}`,
|
|
976
|
+
kind: "segment",
|
|
977
|
+
owner: { seriesId, categoryId: catId },
|
|
978
|
+
text,
|
|
979
|
+
lines: [text],
|
|
980
|
+
typeRole: "label",
|
|
981
|
+
font,
|
|
982
|
+
swatch: paint,
|
|
983
|
+
priority: PRIORITY.interior,
|
|
984
|
+
pad: 3,
|
|
985
|
+
candidates: seats
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
function referenceLabelText(domain, s, v, cell) {
|
|
989
|
+
let value = textFor(domain, v, cell, void 0, s);
|
|
990
|
+
return value === null ? null : `${value} ${s.label}`;
|
|
991
|
+
}
|
|
992
|
+
function referenceLabels(domain, area) {
|
|
993
|
+
let { options, cats, refSeries, variant, measure } = domain;
|
|
994
|
+
if (variant === "stacked100" || !labelOn(options, "tick")) return [];
|
|
995
|
+
let { tickFont, band, x, plot } = area, requests = [];
|
|
996
|
+
for (let s of refSeries) cats.forEach((cat, ci) => {
|
|
997
|
+
let { v } = s.cells[ci];
|
|
998
|
+
if (v === null) return;
|
|
999
|
+
let text = referenceLabelText(domain, s, v, s.cells[ci]);
|
|
1000
|
+
if (!text) return;
|
|
1001
|
+
let size = measure(text, tickFont), cy = band.position(ci) + band.bandwidth / 2 - size.height / 2, rx = x(v), clear = domain.referenceStyle === "marker" ? REFERENCE_MARKER_R + 4 : 4, right = plot.x + plot.w - size.width, seats = [];
|
|
1002
|
+
for (let at = rx + clear, k = 0; at <= right + 0.5 && k < 60; at += 6, k++)
|
|
1003
|
+
seats.push({ slot: k === 0 ? "rightOfTick" : `rightOfTick${k}`, rect: { x: Math.min(at, right), y: cy, w: size.width, h: size.height }, penalty: k === 0 ? 0 : 1 + k / 100 });
|
|
1004
|
+
seats.push({ slot: "leftOfTick", rect: { x: rx - clear - size.width, y: cy, w: size.width, h: size.height }, penalty: 2 }), requests.push({
|
|
1005
|
+
id: `tick:${s.id}:${cat.id}`,
|
|
1006
|
+
kind: "tick",
|
|
1007
|
+
owner: { seriesId: s.id, categoryId: cat.id },
|
|
1008
|
+
text,
|
|
1009
|
+
lines: [text],
|
|
1010
|
+
typeRole: "label",
|
|
1011
|
+
font: tickFont,
|
|
1012
|
+
// After every value of the bars: a reference value takes the seat the bars leave.
|
|
1013
|
+
priority: PRIORITY.interior - 1,
|
|
1014
|
+
// A word's space from the bar's own value, so the two read as two numbers.
|
|
1015
|
+
pad: 6,
|
|
1016
|
+
candidates: seats
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
return requests;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// src/core/charts/bar/marks.ts
|
|
1023
|
+
function barAnchor(cat, x, y, value, owner) {
|
|
1024
|
+
return { x, y, value, date: cat.date, label: cat.label ?? cat.id, owner };
|
|
1025
|
+
}
|
|
1026
|
+
function barRow(domain, paints, area, ci, marks, nodes, claims, out) {
|
|
1027
|
+
let { cats, dataSeries, refSeries, variant, plotRange, stacks, rowEnds, referenceStyle } = domain, { x, band } = area, cat = cats[ci], rowY = band.position(ci), bw = band.bandwidth, rowCenter = rowY + bw / 2, places = [], rowBars = [], groupSlots = groupedOffsets(bw, dataSeries.length), grouped = variant === "grouped";
|
|
1028
|
+
dataSeries.forEach((s, si) => {
|
|
1029
|
+
let cell = s.cells[ci], v = cell.v;
|
|
1030
|
+
if (v === null) return;
|
|
1031
|
+
let segment = stacks[ci].segments[si], by = grouped ? rowY + groupSlots[si].offset : rowY, bh = grouped ? groupSlots[si].size : bw, start = grouped ? 0 : segment.start, end = grouped ? v : segment.end, xA = x(start), xB = x(end), rect = { x: Math.min(xA, xB), y: by, w: Math.max(Math.abs(xB - xA), 0.5), h: bh }, nodeId = `mark:${cat.id}:${s.id}`, owner = { seriesId: s.id, categoryId: cat.id }, { paint, pattern, outline } = paints.cell(s, cat, cell.meta, cell.v), val = grouped ? v : segment.value, halves = barHalves(domain.options);
|
|
1032
|
+
emitBarMark({ axis: "x", theme: domain.theme, scale: area.x, activeBreak: area.activeBreak, css: (paint2) => paints.css(paint2) }, nodes, claims, {
|
|
1033
|
+
nodeId,
|
|
1034
|
+
rect,
|
|
1035
|
+
start,
|
|
1036
|
+
end,
|
|
1037
|
+
fill: paint,
|
|
1038
|
+
pattern,
|
|
1039
|
+
outline,
|
|
1040
|
+
owner,
|
|
1041
|
+
...halves?.neg === s.id ? { claimOwner: { seriesId: halves.pos, categoryId: cat.id } } : {},
|
|
1042
|
+
part: grouped ? "bar" : "segment",
|
|
1043
|
+
displayValue: displayFor(domain, v, cell, variant === "stacked100" ? val : void 0, s, cat.id)
|
|
1044
|
+
}), rowBars.push({ seriesId: s.id, rect, nodeId });
|
|
1045
|
+
let range = plotRange(ci, si);
|
|
1046
|
+
if (range) {
|
|
1047
|
+
let whisker = rangeWhisker(domain.theme, { seriesId: s.id, categoryId: cat.id, axis: "x", center: by + bh / 2, markSize: bh, range, offset: start, scale: area.x, activeBreak: area.activeBreak, fmt: domain.fmt });
|
|
1048
|
+
out.rangeNodes.push(...whisker.nodes);
|
|
1049
|
+
for (let claim of whisker.claims) claims.claim(claim.rect, claim.kind, claim.owner, claim.part);
|
|
1050
|
+
out.rangeMarks.push(whisker.mark);
|
|
1051
|
+
}
|
|
1052
|
+
out.anchorBySeg.set(`${cat.id}:${s.id}`, barAnchor(cat, xB, by + bh / 2, v, owner)), places.push({ s, si, v, val, rect });
|
|
1053
|
+
}), (variant !== "stacked100" ? refSeries : []).forEach((rs) => {
|
|
1054
|
+
let refCell = rs.cells[ci], { v } = refCell;
|
|
1055
|
+
if (v === null) return;
|
|
1056
|
+
let rx = x(v), nodeId = `ref:${cat.id}:${rs.id}`, owner = { seriesId: rs.id, categoryId: cat.id }, tickGeometry = referenceTickGeometry("horizontal", rowY, rx, -2, bw + 2);
|
|
1057
|
+
referenceStyle !== "marker" && out.refTarget.push(referenceCasing(nodeId, tickGeometry.line, referenceStyle === "line" ? strokeToken(domain.theme, "rule") : domain.referenceTick.width, owner)), out.refTarget.push({
|
|
1058
|
+
id: nodeId,
|
|
1059
|
+
owner,
|
|
1060
|
+
display: { value: displayFor(domain, v, refCell, void 0, rs) },
|
|
1061
|
+
...referenceStyle === "marker" ? {
|
|
1062
|
+
t: "circle",
|
|
1063
|
+
cx: rx,
|
|
1064
|
+
cy: rowCenter,
|
|
1065
|
+
...referenceMarkerPaint(domain.theme, paints.reference()),
|
|
1066
|
+
part: "referenceMarker"
|
|
1067
|
+
} : {
|
|
1068
|
+
t: "line",
|
|
1069
|
+
...tickGeometry.line,
|
|
1070
|
+
stroke: paints.reference(),
|
|
1071
|
+
width: referenceStyle === "line" ? strokeToken(domain.theme, "rule") : domain.referenceTick.width,
|
|
1072
|
+
dash: referenceStyle === "line" ? dashToken(domain.theme, "dotted") : void 0,
|
|
1073
|
+
lineCap: "round",
|
|
1074
|
+
part: referenceStyle === "line" ? "referenceLine" : "referenceTick"
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
let mr = REFERENCE_MARKER_R + 1, claimTop = referenceStyle === "marker" ? Math.min(rowY - 2, rowCenter - mr) : rowY - 2, claimBottom = referenceStyle === "marker" ? Math.max(rowY + bw + 2, rowCenter + mr) : rowY + bw + 2;
|
|
1078
|
+
claims.claim(
|
|
1079
|
+
referenceStyle === "marker" ? { x: rx - mr, y: claimTop, w: 2 * mr, h: claimBottom - claimTop } : tickGeometry.claim,
|
|
1080
|
+
"mark",
|
|
1081
|
+
owner,
|
|
1082
|
+
...referenceStyle === "line" ? ["referenceLine"] : []
|
|
1083
|
+
), marks.referenceTicks.push({ seriesId: rs.id, categoryId: cat.id, nodeId }), out.anchorBySeg.set(`${cat.id}:${rs.id}`, barAnchor(cat, rx, rowCenter, v, owner));
|
|
1084
|
+
});
|
|
1085
|
+
let ends = rowEnds[ci];
|
|
1086
|
+
return marks.rows.push({ id: cat.id, rect: { x: x(ends.neg), y: rowY, w: Math.max(x(ends.pos) - x(ends.neg), 0.5), h: bw }, bars: rowBars }), out.anchorByCat.set(cat.id, barAnchor(cat, x(ends.pos > 0 ? ends.pos : ends.neg), rowCenter, domain.totals[ci], { categoryId: cat.id })), places;
|
|
1087
|
+
}
|
|
1088
|
+
function netLineMarks(domain, area, nodes, claims) {
|
|
1089
|
+
let { cats, dataSeries, stacks, netLineSeries, rowEnds } = domain, { x, band } = area, edgeValues = cats.map((_, ci) => {
|
|
1090
|
+
if (!netLineSeries) return rowEnds[ci].pos;
|
|
1091
|
+
let stack = stacks[ci];
|
|
1092
|
+
for (let si = 0; si < dataSeries.length; si++) {
|
|
1093
|
+
let series = dataSeries[si], segment = stack.segments[si];
|
|
1094
|
+
if (!segment) {
|
|
1095
|
+
if (series.id === netLineSeries.id) return;
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
if (series.id === netLineSeries.id) return segment.end;
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
edgeValues.forEach((value, ci) => {
|
|
1102
|
+
if (value === void 0) return;
|
|
1103
|
+
let xx = x(value), overhang = Math.max(0, Math.min(4, (band.step - band.bandwidth) / 2 - 1)), y1 = band.position(ci) - overhang, y2 = band.position(ci) + band.bandwidth + overhang;
|
|
1104
|
+
nodes.push({
|
|
1105
|
+
t: "line",
|
|
1106
|
+
id: `netLine:${cats[ci].id}:edge`,
|
|
1107
|
+
x1: xx,
|
|
1108
|
+
y1,
|
|
1109
|
+
x2: xx,
|
|
1110
|
+
y2,
|
|
1111
|
+
stroke: { token: "markInk" },
|
|
1112
|
+
width: strokeToken(domain.theme, "data"),
|
|
1113
|
+
owner: {
|
|
1114
|
+
...netLineSeries ? { seriesId: netLineSeries.id } : {},
|
|
1115
|
+
categoryId: cats[ci].id
|
|
1116
|
+
},
|
|
1117
|
+
part: "netLine"
|
|
1118
|
+
}), claims.claim({ x: xx - 0.7, y: y1, w: 1.4, h: Math.max(y2 - y1, 1) }, "mark", { annotationId: "netLine" }, "netLine");
|
|
1119
|
+
});
|
|
1120
|
+
let last = edgeValues.length - 1;
|
|
1121
|
+
for (; last >= 0 && edgeValues[last] === void 0; ) last--;
|
|
1122
|
+
return last >= 0 ? { x: x(edgeValues[last]), ci: last } : void 0;
|
|
1123
|
+
}
|
|
1124
|
+
var HALVES_RULE_INSET = 2;
|
|
1125
|
+
function layoutBarMarks(domain, paints, area) {
|
|
1126
|
+
let { options, theme, size, measure, highlights, restRecedes, cats, dataSeries } = domain, { frame, plot, x, x0, band } = area, claims = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), nodes = [...frame.nodes], marks = { rows: [], referenceTicks: [], rowTints: [] };
|
|
1127
|
+
cats.forEach((cat, ci) => {
|
|
1128
|
+
if (!highlights.has(cat.id) || restRecedes) return;
|
|
1129
|
+
let gapHalf = (band.step - band.bandwidth) / 2, nodeId = `rowTint:${cat.id}`;
|
|
1130
|
+
nodes.push({
|
|
1131
|
+
t: "rect",
|
|
1132
|
+
id: nodeId,
|
|
1133
|
+
rect: {
|
|
1134
|
+
x: plot.x,
|
|
1135
|
+
y: Math.max(plot.y, band.position(ci) - gapHalf),
|
|
1136
|
+
w: plot.w,
|
|
1137
|
+
h: Math.min(band.step, plot.y + plot.h - (band.position(ci) - gapHalf))
|
|
1138
|
+
},
|
|
1139
|
+
fill: { token: "others" },
|
|
1140
|
+
owner: { categoryId: cat.id },
|
|
1141
|
+
part: "rowTint"
|
|
1142
|
+
}), marks.rowTints.push({ categoryId: cat.id, nodeId });
|
|
1143
|
+
});
|
|
1144
|
+
let axes = [];
|
|
1145
|
+
if (options.valueAxis?.show) {
|
|
1146
|
+
let axisResult = layoutValueAxis(
|
|
1147
|
+
{
|
|
1148
|
+
scale: breakAxisScale(x),
|
|
1149
|
+
plot,
|
|
1150
|
+
orient: "x",
|
|
1151
|
+
gridlines: options.valueAxis.gridlines ?? !1,
|
|
1152
|
+
...domain.axisFmt,
|
|
1153
|
+
theme,
|
|
1154
|
+
measure,
|
|
1155
|
+
canvasWidth: size.width
|
|
1156
|
+
},
|
|
1157
|
+
claims
|
|
1158
|
+
);
|
|
1159
|
+
nodes.push(...axisResult.nodes), axes.push(axisResult.axis);
|
|
1160
|
+
}
|
|
1161
|
+
let baseline = (id) => ({
|
|
1162
|
+
t: "line",
|
|
1163
|
+
id,
|
|
1164
|
+
x1: x0,
|
|
1165
|
+
y1: plot.y,
|
|
1166
|
+
x2: x0,
|
|
1167
|
+
y2: plot.y + plot.h,
|
|
1168
|
+
stroke: { token: "axis" },
|
|
1169
|
+
width: strokeToken(theme, "rule"),
|
|
1170
|
+
owner: {},
|
|
1171
|
+
part: "baseline"
|
|
1172
|
+
});
|
|
1173
|
+
nodes.push(baseline("axis:baseline"));
|
|
1174
|
+
let halves = barHalves(options);
|
|
1175
|
+
domain.connectorsOn && domain.variant !== "grouped" && stackConnectors({ ...domain, axis: "x", scale: area.x, band: area.band }, nodes, claims);
|
|
1176
|
+
let referenceNodes = [], out = {
|
|
1177
|
+
rangeMarks: [],
|
|
1178
|
+
rangeNodes: [],
|
|
1179
|
+
refTarget: dataSeries.some((series) => series.cells.some((cell) => cell.range)) ? referenceNodes : nodes,
|
|
1180
|
+
anchorByCat: /* @__PURE__ */ new Map(),
|
|
1181
|
+
anchorBySeg: /* @__PURE__ */ new Map()
|
|
1182
|
+
}, bars = cats.map((_, ci) => barRow(domain, paints, area, ci, marks, nodes, claims, out)), from = plot.y;
|
|
1183
|
+
for (let row of halves ? marks.rows : [])
|
|
1184
|
+
row.bars.some((bar) => bar.seriesId === halves.neg) && (row.rect.y - HALVES_RULE_INSET > from && claims.claim({ x: x0 - 1, y: from, w: 2, h: row.rect.y - HALVES_RULE_INSET - from }, "axis", {}), from = Math.max(from, row.rect.y + row.rect.h + HALVES_RULE_INSET));
|
|
1185
|
+
plot.y + plot.h > from && claims.claim({ x: x0 - 1, y: from, w: 2, h: plot.y + plot.h - from }, "axis", {}), out.rangeNodes.length > 0 && (pushAll(nodes, out.rangeNodes), marks.ranges = out.rangeMarks), pushAll(nodes, referenceNodes), halves || nodes.push(baseline("axis:baseline:over")), cats.forEach((c, ci) => {
|
|
1186
|
+
if (!c.breakAfter || ci === cats.length - 1) return;
|
|
1187
|
+
let glyph = categoryBreakGlyph(theme, { x: x0, y: (area.band.position(ci) + area.band.bandwidth + area.band.position(ci + 1)) / 2 }, "y", `axis:y:categoryBreak:${c.id}`);
|
|
1188
|
+
nodes.push(...glyph.nodes), claims.claim(glyph.rect, "axis", {}, "categoryBreak");
|
|
1189
|
+
}), cats.forEach((cat, ci) => {
|
|
1190
|
+
let glyph = domain.nmRows[ci] ? "n.m." : domain.naRows[ci] ? notApplicableGlyph(options.strings) : null;
|
|
1191
|
+
if (!glyph) return;
|
|
1192
|
+
let font = { family: theme.type.family, ...theme.type.label }, glyphSize = measure(glyph, font), rowCenter = band.position(ci) + band.bandwidth / 2, rect = { x: x0 + 8, y: rowCenter - glyphSize.height / 2, w: glyphSize.width, h: glyphSize.height };
|
|
1193
|
+
nodes.push({
|
|
1194
|
+
t: "text",
|
|
1195
|
+
id: `nm:${cat.id}`,
|
|
1196
|
+
x: rect.x,
|
|
1197
|
+
y: rect.y,
|
|
1198
|
+
lines: [glyph],
|
|
1199
|
+
align: "start",
|
|
1200
|
+
typeRole: "label",
|
|
1201
|
+
font,
|
|
1202
|
+
ink: { token: "inkMuted" },
|
|
1203
|
+
owner: { categoryId: cat.id },
|
|
1204
|
+
part: "nmMarker"
|
|
1205
|
+
}), claims.claim(rect, "label", { categoryId: cat.id });
|
|
1206
|
+
});
|
|
1207
|
+
let netLineEnd = domain.netLineOn ? netLineMarks(domain, area, nodes, claims) : void 0, { rangeMarks, anchorByCat, anchorBySeg } = out;
|
|
1208
|
+
return { nodes, claims, axes, marks, rangeMarks, bars, anchorByCat, anchorBySeg, netLineEnd };
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
// src/core/charts/bar/paints.ts
|
|
1212
|
+
function barPaints(domain, warnings) {
|
|
1213
|
+
let { options, theme, palette, highlights, dataSeries, uniformScenario, restRecedes } = domain, signColor = options.signColor === !0;
|
|
1214
|
+
signColor && signColorOverrides(domain.cats, dataSeries, highlights, OTHERS_ID, (s, ci) => ({ v: s.cells[ci].v, fill: s.cells[ci].meta?.fill }), warnings);
|
|
1215
|
+
let receding = recedingSeriesId(dataSeries, highlights), netAt = domain.netLineOn && domain.netLineSeries ? dataSeries.findIndex((s) => s.id === domain.netLineSeries.id) : -1, highlighted = dataSeries.some((s) => !s.fill && (s.colorRole === "highlight" || !s.colorRole && highlights.has(s.id))), plainParts = dataSeries.filter((s) => !s.fill && !s.colorRole && !highlights.has(s.id)).map((s) => s.id), stackGreys = domain.variant !== "grouped" && highlighted && plainParts.length >= 2 ? plainParts : [], beyondNet = new Set(netAt >= 0 ? dataSeries.slice(netAt + 1).filter((s) => !s.fill && !s.colorRole && !highlights.has(s.id)).map((s) => s.id) : []), marked = highlighted || receding !== void 0 || beyondNet.size > 0 || dataSeries.some((s) => s.colorRole !== void 0 || highlights.has(s.id)), stackPlain = (domain.variant === "stacked" || domain.variant === "stacked100") && palette === void 0 && !marked ? dataSeries.filter((s) => !s.fill) : [], roles = colorRolePaints(dataSeries), ownPaints = dataSeries.map((s) => s.fill ? { css: s.fill } : s.colorRole ? roles.get(s.id) : highlights.has(s.id) ? { token: "focus" } : void 0), stackOwn = domain.variant !== "grouped" && ownPaints.some(Boolean) ? ownPaints : void 0, seriesIdentityPaint = (s, scenario = s.scenario) => {
|
|
1216
|
+
if (s.fill) return { css: s.fill };
|
|
1217
|
+
if (s.colorRole) return roles.get(s.id);
|
|
1218
|
+
if (highlights.has(s.id)) return { token: "focus" };
|
|
1219
|
+
if (s.id === receding) return { token: "neutralMark" };
|
|
1220
|
+
let grey = stackGreys.indexOf(s.id);
|
|
1221
|
+
return grey >= 0 ? grey % 2 === 0 ? { token: "neutralMark" } : { token: "rest" } : beyondNet.has(s.id) ? { token: "rest" } : dataSeries.length === 1 ? seriesPaint(s.slot, palette, scenario, !0) : stackPlain.length > 1 && stackPlain.includes(s) ? stackRampPaint(stackPlain.indexOf(s), stackPlain.length, s.slot) : stackOwn ? stackApartPaint(stackOwn, dataSeries.indexOf(s), s.slot, palette) : seriesPaint(s.slot, palette);
|
|
1222
|
+
}, barPaint = (s, catId, meta, v = null) => {
|
|
1223
|
+
let scen = meta?.scenario ?? s.scenario, preservesSeriesIdentity = uniformScenario.has(catId), pattern = scen === "FC" ? "hatch45" : scen === "PL" && !preservesSeriesIdentity ? "outline" : void 0, outline = preservesSeriesIdentity && scen === "PL" ? !0 : void 0;
|
|
1224
|
+
return meta?.fill ? { paint: { css: meta.fill }, pattern, outline } : signColor && catId !== OTHERS_ID && !highlights.has(s.id) && !highlights.has(catId) ? { paint: signPaint(s, v, options.colorblindSafe), pattern, outline } : s.fill ? { paint: { css: s.fill }, pattern, outline } : catId === OTHERS_ID ? { paint: { token: "othersMark" }, pattern, outline } : s.colorRole ? { paint: roles.get(s.id), pattern, outline } : highlights.has(s.id) ? { paint: { token: "focus" }, pattern, outline } : highlights.has(catId) && dataSeries.length === 1 ? { paint: { token: "focus" }, pattern, outline } : scen ? { paint: seriesIdentityPaint(s, scen), pattern, outline } : restRecedes ? { paint: { token: "rest" }, pattern, outline } : { paint: seriesIdentityPaint(s), pattern, outline };
|
|
1225
|
+
};
|
|
1226
|
+
return {
|
|
1227
|
+
cell: (s, cat, meta, v) => {
|
|
1228
|
+
let { paint, pattern, outline } = barPaint(s, cat.id, meta, v);
|
|
1229
|
+
return { paint, pattern: partialPattern(cat, pattern, outline), outline };
|
|
1230
|
+
},
|
|
1231
|
+
css: (paint, pattern) => effectiveFill(paintColor(theme, paint), pattern, theme),
|
|
1232
|
+
reference: () => domain.referenceStyle === "marker" ? { token: "neutralMark" } : domain.referenceStyle === "tick" && domain.referenceTick.color === "highlight" ? { token: "highlight" } : { token: "ink" },
|
|
1233
|
+
identity: (s) => seriesIdentityPaint(s),
|
|
1234
|
+
scenario: barPaint
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// src/core/charts/bar/plot.ts
|
|
1239
|
+
function buildLegend(domain, paints, warnings) {
|
|
1240
|
+
let { options, cats, dataSeries, refSeries, referenceStyle, uniformScenario } = domain, signColor = options.signColor === !0, referenceDrawn = domain.variant !== "stacked100" && panelTypeClass(options) === void 0 && refSeries.some((s) => s.cells.some((cell) => cell.v !== null));
|
|
1241
|
+
(signColor || referenceDrawn) && options.legend === "none" && warnings.push({
|
|
1242
|
+
code: "legend-suppressed-encoding",
|
|
1243
|
+
severity: "warn",
|
|
1244
|
+
message: `legend: 'none' suppressed the only key naming this exhibit's encodings (${signColor ? "sign colour" : "the reference mark"}), so the reader is left to infer them`,
|
|
1245
|
+
suggest: `drop legend: 'none', or drop ${signColor ? "signColor" : "the reference series"}`
|
|
1246
|
+
});
|
|
1247
|
+
let netLineKeyed = domain.netLineOn && panelTypeClass(options) === void 0, l = options.legend ?? (signColor || referenceDrawn || netLineKeyed ? "top" : void 0);
|
|
1248
|
+
if (!l || l === "none" || l === "auto") return;
|
|
1249
|
+
let legendOptions = normalizeLegendOption(l), seriesItems = signColor ? dataSeries.flatMap((s) => [!0, !1].map((above) => ({
|
|
1250
|
+
id: `${s.id}:${above ? "above" : "below"}`,
|
|
1251
|
+
label: stringFields(above ? options.strings.aboveZero : options.strings.belowZero, { series: s.label, meaning: above === (s.direction !== "lowerIsBetter") ? options.strings.better : options.strings.worse }),
|
|
1252
|
+
paint: signPaint(s, above ? 1 : -1, options.colorblindSafe)
|
|
1253
|
+
}))) : dataSeries.map((s) => {
|
|
1254
|
+
let looks = s.cells.flatMap((cell, ci) => cell.v === null ? [] : [paints.cell(s, cats[ci], cell.meta, cell.v)]), first = looks[0];
|
|
1255
|
+
if (first && looks.every((look) => look.pattern === first.pattern && look.outline === first.outline && paints.css(look.paint, look.pattern) === paints.css(first.paint, first.pattern)))
|
|
1256
|
+
return { id: s.id, label: s.label, paint: first.paint, pattern: first.pattern };
|
|
1257
|
+
if (uniformScenario.size > 0)
|
|
1258
|
+
return { id: s.id, label: s.label, paint: paints.identity(s) };
|
|
1259
|
+
let { paint, pattern } = paints.scenario(s, "", null);
|
|
1260
|
+
return { id: s.id, label: s.label, paint, pattern };
|
|
1261
|
+
}), paintedCellPatterns = dataSeries.flatMap(
|
|
1262
|
+
(s) => s.cells.flatMap(
|
|
1263
|
+
(cell, ci) => cell.v === null ? [] : [paints.scenario(s, cats[ci]?.id ?? "", cell.meta).pattern]
|
|
1264
|
+
)
|
|
1265
|
+
), planOutlined = dataSeries.some((s) => s.cells.some((cell, ci) => cell.v !== null && paints.scenario(s, cats[ci]?.id ?? "", cell.meta).outline === !0)), partialHatchPainted = dataSeries.some(
|
|
1266
|
+
(s) => s.cells.some((cell, ci) => {
|
|
1267
|
+
if (cell.v === null || !cats[ci]?.partial) return !1;
|
|
1268
|
+
let { pattern, outline } = paints.scenario(s, cats[ci].id, cell.meta);
|
|
1269
|
+
return partialPattern(cats[ci], pattern, outline) !== pattern;
|
|
1270
|
+
})
|
|
1271
|
+
), items = [
|
|
1272
|
+
...seriesItems,
|
|
1273
|
+
// In the subtitle's order, AC PY PL FC: the plan row before the forecast hatch.
|
|
1274
|
+
...domain.variant !== "stacked100" ? refSeries.map((s) => ({
|
|
1275
|
+
id: s.id,
|
|
1276
|
+
label: s.label,
|
|
1277
|
+
paint: paints.reference(),
|
|
1278
|
+
// The key draws the reference as the bar crosses it: a vertical tick, a dashed rule, a ringed dot.
|
|
1279
|
+
key: referenceStyle === "tick" ? "tick" : "line",
|
|
1280
|
+
...referenceStyle === "line" ? { dash: dashToken(domain.theme, "dotted"), lineCap: "round", width: strokeToken(domain.theme, "rule") } : {},
|
|
1281
|
+
...referenceStyle === "tick" ? { width: domain.referenceTick.width } : {},
|
|
1282
|
+
...referenceStyle === "marker" ? referenceMarkerKey(domain.theme, paints.reference()) : {}
|
|
1283
|
+
})) : [],
|
|
1284
|
+
...domain.netLineOn ? [{
|
|
1285
|
+
id: "__netLine",
|
|
1286
|
+
label: netLineName(dataSeries, domain.netLineSeries, domain.stacks, options.strings),
|
|
1287
|
+
paint: { token: "markInk" },
|
|
1288
|
+
key: "tick",
|
|
1289
|
+
width: strokeToken(domain.theme, "data")
|
|
1290
|
+
}] : [],
|
|
1291
|
+
...planOutlined ? [{ id: "__scenarioPLRow", label: options.strings.plan, paint: { token: "background" }, stroke: { token: "ink" }, width: domain.theme.pattern.outlineStrokeWidth }] : [],
|
|
1292
|
+
...scenarioLegendKeys({
|
|
1293
|
+
markPatterns: paintedCellPatterns,
|
|
1294
|
+
keyPatterns: seriesItems.map((item) => item.pattern),
|
|
1295
|
+
paint: { token: "neutralMark" },
|
|
1296
|
+
strings: domain.options.strings
|
|
1297
|
+
}),
|
|
1298
|
+
...partialLegendKeys(partialHatchPainted && !partialNamedOnValues(domain), options.strings, cats)
|
|
1299
|
+
];
|
|
1300
|
+
if (items = dedupeLegendKeys(items, (item) => paints.css(item.paint, item.pattern)).items, legendOptions.order) {
|
|
1301
|
+
let rank = new Map(legendOptions.order.map((id, i) => [id, i]));
|
|
1302
|
+
items = [...items].sort(
|
|
1303
|
+
(a, b) => (rank.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b.id) ?? Number.MAX_SAFE_INTEGER)
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
return { options: legendOptions, items };
|
|
1307
|
+
}
|
|
1308
|
+
function solveBarFrame(domain, paints, warnings) {
|
|
1309
|
+
let { options, theme, size, measure, cats } = domain, claims = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), legend = buildLegend(domain, paints, warnings);
|
|
1310
|
+
return { frame: solveFrame(
|
|
1311
|
+
{
|
|
1312
|
+
size,
|
|
1313
|
+
margin: { ...canvasMargin(theme, size.width), ...options.margin },
|
|
1314
|
+
...frameTextOptions(options),
|
|
1315
|
+
footnotes: [
|
|
1316
|
+
...partialFootnotes(cats, options.strings, legend?.items.some((item) => item.id === "__partial") || partialNamedOnValues(domain)),
|
|
1317
|
+
...domain.variant === "stacked" && domain.incompleteRows.size ? [disclosureNote(stringFields(options.strings.incompleteStacks, {
|
|
1318
|
+
categories: cappedItems(cats.filter((c) => domain.incompleteRows.has(c.id)).map((c) => c.label ?? c.id), options).join(", ")
|
|
1319
|
+
}))] : [],
|
|
1320
|
+
...domain.variant === "stacked100" && cats.some((c) => c.total100 === void 0 && domain.incompleteRows.has(c.id)) ? [disclosureNote(stringFields(options.strings.knownPartsShares, {
|
|
1321
|
+
categories: cappedItems(cats.filter((c) => c.total100 === void 0 && domain.incompleteRows.has(c.id)).map((c) => c.label ?? c.id), options).join(", ")
|
|
1322
|
+
}))] : [],
|
|
1323
|
+
...authoredNotes(options),
|
|
1324
|
+
...options[CUT_NOTES] ?? []
|
|
1325
|
+
],
|
|
1326
|
+
legend,
|
|
1327
|
+
theme,
|
|
1328
|
+
measure
|
|
1329
|
+
},
|
|
1330
|
+
claims
|
|
1331
|
+
), claims };
|
|
1332
|
+
}
|
|
1333
|
+
function outsideLabelWidths(domain, labelFont, strongFont) {
|
|
1334
|
+
let { options, measure, variant, cats, dataSeries, totalFmt, totals } = domain, maxPosW = 0, maxNegW = 0;
|
|
1335
|
+
if (variant === "grouped" && labelOn(options, "point")) {
|
|
1336
|
+
let boldFont = { ...labelFont, weight: strongFont.weight };
|
|
1337
|
+
cats.forEach((_, ci) => {
|
|
1338
|
+
dataSeries.forEach((s) => {
|
|
1339
|
+
let cell = s.cells[ci];
|
|
1340
|
+
if (cell.v === null) return;
|
|
1341
|
+
let text = textFor(domain, cell.v, cell, void 0, s);
|
|
1342
|
+
if (!text) return;
|
|
1343
|
+
let w = measure(text, dataSeries.length > 1 || domain.highlights.has(cats[ci].id) || domain.highlights.has(s.id) ? boldFont : labelFont).width;
|
|
1344
|
+
cell.v >= 0 ? maxPosW = Math.max(maxPosW, w) : maxNegW = Math.max(maxNegW, w);
|
|
1345
|
+
});
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
if (domain.grandTotalsOn && cats.forEach((_, ci) => {
|
|
1349
|
+
maxPosW = Math.max(maxPosW, measure(totalFmt(totals[ci]), strongFont).width);
|
|
1350
|
+
}), variant === "stacked100" && labelOn(options, "segment")) {
|
|
1351
|
+
let rowW = cats.map((_, ci) => dataSeries.reduce((w, s, si) => {
|
|
1352
|
+
let cell = s.cells[ci], share = cell.v === null ? null : domain.shares[ci]?.[si];
|
|
1353
|
+
if (share == null || share <= 0 || share >= 8) return w;
|
|
1354
|
+
let text = textFor(domain, cell.v, cell, share, s, cats[ci].id);
|
|
1355
|
+
return text ? w + measure(text, labelFont).width + SHARE_ROW_SWATCH + 6 : w;
|
|
1356
|
+
}, 0));
|
|
1357
|
+
maxPosW = Math.max(maxPosW, maxOf(rowW));
|
|
1358
|
+
}
|
|
1359
|
+
if (variant !== "stacked100" && labelOn(options, "tick")) {
|
|
1360
|
+
let tickFont = { family: domain.theme.type.family, ...domain.theme.type.axis }, refW = Math.max(0, maxOf(domain.refSeries.flatMap((s) => s.cells.map((cell) => {
|
|
1361
|
+
let text = cell.v === null ? null : referenceLabelText(domain, s, cell.v, cell);
|
|
1362
|
+
return text ? measure(text, tickFont).width : 0;
|
|
1363
|
+
}))));
|
|
1364
|
+
refW > 0 && (maxPosW += 10 + refW);
|
|
1365
|
+
}
|
|
1366
|
+
return { maxPosW, maxNegW };
|
|
1367
|
+
}
|
|
1368
|
+
function barAxisBreak(domain, dLo, dHi, warnings) {
|
|
1369
|
+
let requestedBreak = domain.options.valueAxis?.break;
|
|
1370
|
+
if (!requestedBreak) return;
|
|
1371
|
+
let reason = breakStyleRefusal(requestedBreak) ?? invalidLinearBreakReason([dLo, dHi], requestedBreak, domain.rendered);
|
|
1372
|
+
if (reason) {
|
|
1373
|
+
warnings.push(axisBreakInvalid("bar", reason));
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
return { from: requestedBreak.from, to: requestedBreak.to };
|
|
1377
|
+
}
|
|
1378
|
+
function barPlotArea(domain, frame, warnings) {
|
|
1379
|
+
let shared = [], area = barPlotAreaWith(domain, frame, shared, !1);
|
|
1380
|
+
return area ? (pushAll(warnings, shared), area) : barPlotAreaWith(domain, frame, warnings, !0);
|
|
1381
|
+
}
|
|
1382
|
+
function barPlotAreaWith(domain, frame, warnings, titleRow) {
|
|
1383
|
+
let { options, theme, size, measure, variant, cats, dataSeries, lo, hi } = domain, plot0 = frame.plot, tickFont = { family: theme.type.family, ...theme.type.axis }, normalLabelFont = { family: theme.type.family, ...theme.type.label }, labelFont = domain.incompleteRows.size > 0 && options.mode === "compact" && options[HARD_MINIMUM] ? compactValueLabelFont(normalLabelFont, theme.type.footnote, options.target, textScaleOf(options)) : normalLabelFont, strongFont = { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) }, { maxPosW, maxNegW } = outsideLabelWidths(domain, labelFont, strongFont), annPad = domain.localAnns.length > 0 ? 26 : 8, axisTitle = options.valueAxis?.show && axisTitleAllowed(options.labels) ? planValueAxisTitle(valueAxisTitleText(
|
|
1384
|
+
theme,
|
|
1385
|
+
options.axisTitles?.primary,
|
|
1386
|
+
options,
|
|
1387
|
+
valueAxisUnit(options.unit, dataSeries, variant === "stacked100")
|
|
1388
|
+
), theme, measure, plot0.w) : void 0, tickRowH = measure("0", tickFont).height, axisH = options.valueAxis?.show ? tickRowH + 8 + (axisTitle && titleRow ? axisTitle.height + 2 : 0) : 0, availH = plotHeightAfter(frame, size.height, plot0.h - annPad - axisH), lineH = tickFont.size * 1.2, stepEst = theme.space.barRow?.pitch ?? availH / cats.length, catMaxLines = Math.max(1, Math.min(CAT_MAX_LINES, Math.floor((stepEst - 4) / lineH))), capW = Math.max(24, plot0.w * 0.28), authored = authoredFootnoteCount(options), incompleteWord = options.strings.incomplete, partialName = !disclosuresShown(options) && domain.incompleteRows.size > 0, toDate = partialAxisWords(options.strings, options, frame.legend?.items.some((item) => item.id === "__partial") || partialNamedOnValues(domain)), named = (rows) => rows.map((cat) => partialName && domain.incompleteRows.has(cat.id) && variant === "stacked100" && cat.total100 === void 0 ? { ...cat, label: `${cat.label} ${incompleteWord}`, suffix: incompleteWord } : toDate !== void 0 && cat.partial === !0 && !saysToDate(cat.label ?? cat.id, toDate) ? { ...cat, label: `${cat.label ?? cat.id} ${toDate}`, suffix: toDate } : cat), band0 = (rows, refs) => rowLabelBand(named(rows), tickFont, capW, catMaxLines, lineH, measure, {
|
|
1389
|
+
wider: gutterBudget(24, plot0.w),
|
|
1390
|
+
target: options.target,
|
|
1391
|
+
textScale: textScaleOf(options),
|
|
1392
|
+
typeRole: "axis",
|
|
1393
|
+
shrink: stepDownFont(theme, tickFont, "axis", options.target, textScaleOf(options)),
|
|
1394
|
+
footnoteRefs: refs
|
|
1395
|
+
}), noNameColumn = options[NO_NAME_COLUMN] === !0, { labels: catLines, width: catBandW } = band0(cats, { count: authored, warnings });
|
|
1396
|
+
noNameColumn && (catLines = catLines.map((label) => ({ ...label, h: 0 })), catBandW = 0);
|
|
1397
|
+
let cut = panelTypeClass(options) === void 0 && !noNameColumn ? cats.flatMap((cat, i) => catLines[i].title !== void 0 && cat.footnote === void 0 ? [i] : []) : [], marked = disclosuresShown(options), cutNotes = cut.map((i, k) => disclosureNote(`${marked ? `${authored + k + 1}) ` : ""}${cats[i].label ?? cats[i].id}.`));
|
|
1398
|
+
cut.length > 0 && !marked && warnings.push(categoryCutLint(cut.map((i) => cats[i].label ?? cats[i].id), !0, "in the row-name column")), cut.length > 0 && marked && ({ labels: catLines, width: catBandW } = band0(cats.map((cat, i) => cut.includes(i) ? { ...cat, footnote: authored + cut.indexOf(i) + 1 } : cat), { count: authored + cut.length, warnings: [] }), warnings.push(categoryCutLint(cut.map((i) => cats[i].label ?? cats[i].id), !0, "in the row-name column")));
|
|
1399
|
+
let gapAfter = cats.map((cat) => {
|
|
1400
|
+
let gap = cat.gapAfter === !0 ? 0.5 : typeof cat.gapAfter == "number" ? Math.max(0, cat.gapAfter) : 0;
|
|
1401
|
+
return cat.breakAfter ? Math.max(gap, 0.5) : gap;
|
|
1402
|
+
}), segmentFloor = variant !== "grouped" && labelOn(options, "segment") ? Math.ceil(Math.max(INSIDE_MIN_H, measure("0", labelFont).height)) : 0, segmentBar = segmentFloor > 0 ? Math.max(segmentFloor, labelFont.size + 8) : segmentFloor, fixedRow = fixedBarRow(theme, catLines.map((label) => label.h), segmentFloor, options.bandFraction), fixedRowsH = fixedRow ? fixedRow.step * bandSteps(cats.length, gapAfter) : void 0, inset = cagrInset(domain) && domain.passAnns.some((a) => a.kind === "cagr"), nameGap = noNameColumn ? 0 : CAT_BAND_GAP, plotW = plot0.w - catBandW - nameGap - (options[RIGHT_ROOM] ?? (domain.passAnns.some((a) => a.kind === "cagr") ? inset ? CAGR_INSET_ROOM : CAGR_ROOM : 0)), rawBandPad = options[BAND_PAD] ?? 0, bandPad = rawBandPad > 0 ? Math.max(0, Math.min(rawBandPad, Math.floor(availH - 10))) : 0, plot = {
|
|
1403
|
+
x: plot0.x + catBandW + nameGap,
|
|
1404
|
+
y: plot0.y + annPad + bandPad,
|
|
1405
|
+
w: Math.max(10, plotW),
|
|
1406
|
+
// Fixed rows never stretch; a shorter canvas (a grid panel) packs them.
|
|
1407
|
+
h: fixedRowsH === void 0 ? availH - bandPad : Math.min(availH - bandPad, fixedRowsH)
|
|
1408
|
+
}, outsideOnly = theme.marks?.barLabels === "outside" && variant === "grouped", negativeLabelsAcross = outsideOnly && lo < 0 && hi > 0 && domain.localAnns.length === 0, fullBars = variant === "stacked100" && maxPosW === 0 && lo >= 0 && !options.valueAxis?.show && domain.localAnns.length === 0 && domain.passAnns.length === 0 && // An authored label on a zero part prints in the share row past the bar's end.
|
|
1409
|
+
!dataSeries.some((s) => s.cells.some((cell) => cell.v === 0 && typeof cell.meta?.label == "string")), callerExact = options[EXACT_DOMAIN] === !0 && !options.valueAxis?.show, exactDomain = outsideOnly && !options.valueAxis?.show || callerExact, fP = Math.min(0.35, (Math.max(maxPosW, negativeLabelsAcross ? maxNegW : 0) + LABEL_GAP + 8) / plot.w), fN = lo < 0 && !negativeLabelsAcross && !(callerExact && maxNegW === 0) ? Math.min(0.35, (maxNegW + LABEL_GAP + 8) / plot.w) : 0, span = hi - lo || 1, denom = Math.max(0.3, 1 - fP - fN), hiExt = hi + span * fP / denom, loExt = lo < 0 ? lo - span * fN / denom : 0, [dLo, dHi] = fullBars ? [0, hi || 100] : exactDomain ? [loExt, hiExt || 1] : niceDomain(loExt, hiExt || 1, 5, {
|
|
1410
|
+
dataExtent: [loExt, hiExt || 1],
|
|
1411
|
+
maxWasteFraction: 0.15
|
|
1412
|
+
}), activeBreak = barAxisBreak(domain, dLo, dHi, warnings);
|
|
1413
|
+
activeBreak && variant !== "grouped" && stackBreakReversesOrder(brokenLinearScale([dLo, dHi], [plot.x, plot.x + plot.w], activeBreak), domain.stacks) && (warnings.push(axisBreakHeightOrderWarning()), activeBreak = void 0);
|
|
1414
|
+
let x = activeBreak ? brokenLinearScale([dLo, dHi], [plot.x, plot.x + plot.w], activeBreak) : linearScale([dLo, dHi], [plot.x, plot.x + plot.w]), titleEnd = axisTitle && options.valueAxis?.show && !titleRow ? tickRowTitleEnd(axisTitle, { scale: x, plot, orient: "x", gridlines: !1, ...domain.axisFmt, theme, measure, canvasWidth: size.width }, plot0.x) : void 0;
|
|
1415
|
+
if (axisTitle && options.valueAxis?.show && !titleRow && titleEnd === void 0) return;
|
|
1416
|
+
let bandFraction = options.bandFraction ?? fixedRow?.fraction ?? 0.7, band = bandScale(cats.length, [plot.y, plot.y + plot.h], {
|
|
1417
|
+
paddingInner: 1 - bandFraction,
|
|
1418
|
+
paddingOuter: (1 - bandFraction) / 2,
|
|
1419
|
+
gapAfter
|
|
1420
|
+
}), compactLabelFont = compactValueLabelFont(labelFont, theme.type.footnote, options.target, textScaleOf(options)), groupSlots = groupedOffsets(band.bandwidth, dataSeries.length), policy = groupedValueLabelPolicy("horizontal", groupSlots[0]?.size ?? band.bandwidth, dataSeries.length, [], labelFont.size, compactLabelFont.size), thinBars = variant === "grouped" && policy.firstSeriesOnly, compact = variant === "grouped" && policy.compact;
|
|
1421
|
+
thinBars && labelOn(options, "point") && warnings.push({
|
|
1422
|
+
code: "value-labels-first-series-only",
|
|
1423
|
+
severity: "info",
|
|
1424
|
+
message: `bars are ${(groupSlots[0]?.size ?? 0).toFixed(1)}px thick, thinner than a value label; only '${dataSeries[0].label ?? dataSeries[0].id}' carries value labels${domain.highlights.size > 0 ? ", plus the highlighted values where they fit" : ""}`,
|
|
1425
|
+
suggest: "give the chart more height, or fewer categories, to label every series"
|
|
1426
|
+
});
|
|
1427
|
+
let scale = x;
|
|
1428
|
+
if (inset && !options.valueAxis?.show && !activeBreak && lo >= 0 && hi > 0 && domain.refSeries.length === 0) {
|
|
1429
|
+
let exact = linearScale([0, hi], [plot.x, plot.x + plot.w]), thick = groupSlots[0]?.size ?? band.bandwidth, valueFont = { ...compact ? compactLabelFont : labelFont, weight: emphasisWeight(theme) };
|
|
1430
|
+
(!labelOn(options, "point") || dataSeries.every((s) => s.cells.every((cell) => {
|
|
1431
|
+
if (cell.v === null) return !0;
|
|
1432
|
+
let text = textFor(domain, cell.v, cell, void 0, s);
|
|
1433
|
+
if (!text) return !0;
|
|
1434
|
+
let measured = measure(text, valueFont), size2 = compact ? compactValueTextSize("horizontal", measured, valueFont.size) : measured;
|
|
1435
|
+
return size2.width + 10 <= exact(cell.v) - exact(0) && size2.height + 2 <= thick;
|
|
1436
|
+
}))) && (scale = exact);
|
|
1437
|
+
}
|
|
1438
|
+
let groupedH = variant === "grouped" && labelOn(options, "point") ? dataSeries.length * measure("0", labelFont).height + Math.max(0, dataSeries.length - 1) * 4 : 0;
|
|
1439
|
+
return {
|
|
1440
|
+
frame,
|
|
1441
|
+
tickFont,
|
|
1442
|
+
labelFont,
|
|
1443
|
+
strongFont,
|
|
1444
|
+
// Grouped value labels print in the emphasis weight, so a value inside a
|
|
1445
|
+
// bar end reads at a glance.
|
|
1446
|
+
pointFont: { ...compact ? compactLabelFont : labelFont, ...variant === "grouped" && dataSeries.length > 1 ? { weight: emphasisWeight(theme) } : {} },
|
|
1447
|
+
compact,
|
|
1448
|
+
thinBars,
|
|
1449
|
+
availH,
|
|
1450
|
+
minWidth: size.width - plotW + 10,
|
|
1451
|
+
capW,
|
|
1452
|
+
catLines,
|
|
1453
|
+
cutNotes,
|
|
1454
|
+
catBandW,
|
|
1455
|
+
plot,
|
|
1456
|
+
axisTitle,
|
|
1457
|
+
activeBreak,
|
|
1458
|
+
x: scale,
|
|
1459
|
+
x0: scale(0),
|
|
1460
|
+
band,
|
|
1461
|
+
negativeLabelsAcross,
|
|
1462
|
+
...axisTitle ? { axisTitleAt: { x: titleEnd ?? plot.x + plot.w, y: plot.y + plot.h + 6 + (titleRow ? tickRowH + 2 : 0) } } : {},
|
|
1463
|
+
...fixedRowsH === void 0 ? {} : { fixedRowsH },
|
|
1464
|
+
segmentStep: Math.ceil(Math.max(segmentBar, groupedH) / bandFraction),
|
|
1465
|
+
segmentMinStep: Math.ceil(Math.max(segmentFloor, groupedH) / bandFraction)
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
// src/core/charts/bar/layout.ts
|
|
1470
|
+
function warnRangeBarIgnoredRanking(mode, options, warnings) {
|
|
1471
|
+
options.topN && warnings.push(
|
|
1472
|
+
mode === "football-field" ? {
|
|
1473
|
+
code: "football-field-topn-ignored",
|
|
1474
|
+
severity: "warn",
|
|
1475
|
+
message: "football-field does not aggregate method ranges with topN; all methods remain visible",
|
|
1476
|
+
suggest: "filter methods before layout instead of aggregating intervals"
|
|
1477
|
+
} : {
|
|
1478
|
+
code: "tornado-topn-ignored",
|
|
1479
|
+
severity: "warn",
|
|
1480
|
+
message: "tornado does not aggregate drivers with topN; all drivers remain visible",
|
|
1481
|
+
suggest: "drop the drivers you do not want before layout \u2014 an aggregated driver has no one-at-a-time swing"
|
|
1482
|
+
}
|
|
1483
|
+
), options.sort?.segments && options.sort.segments !== "sheet" && warnings.push({
|
|
1484
|
+
code: `${mode}-sort-segments-ignored`,
|
|
1485
|
+
severity: "warn",
|
|
1486
|
+
message: `${mode} has no stacked segments; sort.segments '${options.sort.segments}' was ignored`,
|
|
1487
|
+
suggest: "drop sort.segments, or use variant 'stacked' / 'grouped'"
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
var LABEL_PAD = 2, SPINE_CLAIM_HALF_WIDTH = 0.5;
|
|
1491
|
+
function layoutBar(data, options = {}, annotationPass) {
|
|
1492
|
+
options = withValueLabelDefaults(withLocaleStrings(options), "bar", options.variant);
|
|
1493
|
+
let layout = (next) => layoutBarSized(data, next, annotationPass), geo = withBandValueNotes(data, options, layout), natural = geo.sizing?.naturalHeight;
|
|
1494
|
+
if (natural !== void 0 && natural < geo.size.height) {
|
|
1495
|
+
let probe = withBandValueNotes(data, { ...options, size: { width: geo.size.width, height: natural } }, layout);
|
|
1496
|
+
probe.sizing && probe.sizing.minHeight > natural && (geo.sizing = { ...geo.sizing, naturalHeight: probe.sizing.minHeight });
|
|
1497
|
+
}
|
|
1498
|
+
return geo;
|
|
1499
|
+
}
|
|
1500
|
+
function layoutBarSized(data, options, annotationPass) {
|
|
1501
|
+
let first = layoutBarVariant(data, options, annotationPass);
|
|
1502
|
+
if (!resolveTheme(options.theme).space.barRow || first.sizing === void 0) return first;
|
|
1503
|
+
let relayout = (height) => layoutBarVariant(data, { ...options, size: { width: first.size.width, height } }, annotationPass), grow = rowDrivenHeight({
|
|
1504
|
+
options,
|
|
1505
|
+
width: first.size.width,
|
|
1506
|
+
height: first.size.height,
|
|
1507
|
+
chromeH: 0,
|
|
1508
|
+
rowsH: first.sizing.naturalHeight
|
|
1509
|
+
});
|
|
1510
|
+
return fixedRowsAtTop(grow === void 0 ? first : relayout(grow), relayout);
|
|
1511
|
+
}
|
|
1512
|
+
function fixedRowsAtTop(geometry, relayout) {
|
|
1513
|
+
let natural = geometry.sizing?.naturalHeight;
|
|
1514
|
+
return natural === void 0 || natural >= geometry.size.height ? geometry : { ...relayout(natural), size: geometry.size };
|
|
1515
|
+
}
|
|
1516
|
+
function layoutBarVariant(data, options, annotationPass) {
|
|
1517
|
+
if (refuseSignColor(data, options), options.variant === "tornado")
|
|
1518
|
+
return refuseTornadoDetails(data, options), layoutTornado(data, options);
|
|
1519
|
+
if (options.variant === "football-field") {
|
|
1520
|
+
let fieldGeometry = layoutFootballField(data, options);
|
|
1521
|
+
return options.baseValue !== void 0 && fieldGeometry.warnings.push(baseValueIgnored()), fieldGeometry;
|
|
1522
|
+
}
|
|
1523
|
+
let geometry = layoutStandardBar(data, options, annotationPass);
|
|
1524
|
+
return options.currentValue !== void 0 && geometry.warnings.push({
|
|
1525
|
+
code: "current-value-ignored",
|
|
1526
|
+
severity: "warn",
|
|
1527
|
+
message: "currentValue applies only to bar variant football-field and was ignored",
|
|
1528
|
+
suggest: "set variant: 'football-field' or remove currentValue"
|
|
1529
|
+
}), options.baseValue !== void 0 && geometry.warnings.push(baseValueIgnored()), geometry;
|
|
1530
|
+
}
|
|
1531
|
+
function refuseTornadoDetails(data, options) {
|
|
1532
|
+
let carries = data.series.some((series) => series.values.some((cell) => {
|
|
1533
|
+
let value = cell !== null && typeof cell == "object" && "value" in cell ? cell.value : cell;
|
|
1534
|
+
return value !== null && typeof value == "object" && "details" in value;
|
|
1535
|
+
}));
|
|
1536
|
+
if (!(!carries && options.detailFields === void 0))
|
|
1537
|
+
throw new NormalizeError(
|
|
1538
|
+
"details-variant",
|
|
1539
|
+
carries ? "series" : "options.detailFields",
|
|
1540
|
+
"cell details reach the hover card of one value; bar variant 'tornado' draws each row from two cases",
|
|
1541
|
+
"remove the details and detailFields, or draw the cases with variant 'grouped'"
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
function refuseSignColor(data, options) {
|
|
1545
|
+
if (options.signColor !== !0) return;
|
|
1546
|
+
let variant = options.variant ?? "grouped", dataSeries = data.series.filter((s) => s.role !== "reference").length;
|
|
1547
|
+
if (!(variant === "grouped" && dataSeries === 1))
|
|
1548
|
+
throw new NormalizeError(
|
|
1549
|
+
"sign-color-unsupported",
|
|
1550
|
+
"options.signColor",
|
|
1551
|
+
`signColor requires variant 'grouped' with exactly one data-role series; got variant '${variant}' with ${dataSeries} data-role series`,
|
|
1552
|
+
"drop signColor, or split the stack into one bar chart per measure"
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
function baseValueIgnored() {
|
|
1556
|
+
return {
|
|
1557
|
+
code: "base-value-ignored",
|
|
1558
|
+
severity: "warn",
|
|
1559
|
+
message: "baseValue applies only to bar variant tornado and was ignored",
|
|
1560
|
+
suggest: "set variant: 'tornado' (and options.tornado naming the two case series) or remove baseValue"
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
function barSizing(size, area, step, labels, naturalLabels = labels, fixedRowsH, segmentStep = 0, targetSizing = !1, textScale = 1, segmentMinStep = segmentStep, compactRows = !1) {
|
|
1564
|
+
let { availH, plot, minWidth } = area, floor = compactRows ? 0 : 28 * textScale, labelGap = targetSizing || compactRows ? 4 : 0, minimumRowsH = fixedRowsH ?? plot.h / step * Math.max(floor, targetSizing || compactRows ? segmentMinStep : 0, maxOf(labels.map((label) => label.h + labelGap)));
|
|
1565
|
+
return rowSizing("bar", size, {
|
|
1566
|
+
chromeH: size.height - availH,
|
|
1567
|
+
minWidth,
|
|
1568
|
+
minimumRowsH,
|
|
1569
|
+
// At its natural height a bar is thick enough for its segment labels.
|
|
1570
|
+
naturalRowsH: fixedRowsH ?? plot.h / step * Math.max(floor, segmentStep, maxOf(naturalLabels.map((label) => label.h + labelGap)))
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
function annotateBar(domain, area, scene, occupied, solveCtx, annotationPass) {
|
|
1574
|
+
let { cats } = domain, { plot, x0, band } = area, resolve = (ref) => {
|
|
1575
|
+
let norm = typeof ref == "string" ? { categoryId: ref, edge: "total" } : ref;
|
|
1576
|
+
if (!("categoryId" in norm)) return null;
|
|
1577
|
+
if (norm.seriesId) {
|
|
1578
|
+
let found2 = scene.anchorBySeg.get(`${norm.categoryId}:${norm.seriesId}`);
|
|
1579
|
+
if (!found2) return null;
|
|
1580
|
+
let named = [...domain.dataSeries, ...domain.refSeries].find((s) => s.id === norm.seriesId), seg = { ...found2, format: named?.format, ...named && domain.dataSeries.length > 1 ? { series: { id: named.id, label: named.label } } : {} };
|
|
1581
|
+
return norm.edge === "start" ? { ...seg, x: x0 } : seg;
|
|
1582
|
+
}
|
|
1583
|
+
if (domain.variant === "grouped" && domain.dataSeries.length > 1 && norm.edge !== "start") {
|
|
1584
|
+
let anchorSeries = domain.dataSeries.find((x) => domain.highlights.has(x.id)) ?? domain.dataSeries[0];
|
|
1585
|
+
return resolve({ categoryId: norm.categoryId, seriesId: anchorSeries.id });
|
|
1586
|
+
}
|
|
1587
|
+
let found = scene.anchorByCat.get(norm.categoryId);
|
|
1588
|
+
if (!found) return null;
|
|
1589
|
+
let cat = { ...found, format: domain.dataSeries.length === 1 ? domain.dataSeries[0].format : void 0 };
|
|
1590
|
+
return norm.edge === "start" ? { ...cat, x: x0, value: 0 } : domain.partsAdd ? cat : { ...cat, noValue: NO_STACK_TOTAL };
|
|
1591
|
+
}, passInput = {
|
|
1592
|
+
target: domain.options.target,
|
|
1593
|
+
annotations: domain.passAnns,
|
|
1594
|
+
resolve,
|
|
1595
|
+
defaultSpan: cats.length >= 2 ? { from: cats[0].id, to: cats[cats.length - 1].id } : void 0,
|
|
1596
|
+
occupied,
|
|
1597
|
+
plot,
|
|
1598
|
+
bandCeiling: area.frame.plot.y,
|
|
1599
|
+
theme: domain.theme,
|
|
1600
|
+
measure: domain.measure,
|
|
1601
|
+
format: domain.options.format,
|
|
1602
|
+
locale: domain.options.locale?.language,
|
|
1603
|
+
strings: domain.options.strings,
|
|
1604
|
+
valueLinePercentLevels: domain.variant === "stacked100" || domain.options.unit === "%" || percentLevels(domain.dataSeries.map((series) => ({ vals: series.cells }))),
|
|
1605
|
+
solveCtx,
|
|
1606
|
+
meanValue: domain.meanValue,
|
|
1607
|
+
...domain.meanMissing ? { meanMissing: domain.meanMissing } : {},
|
|
1608
|
+
xScale: area.x,
|
|
1609
|
+
...categoryTargetFields(cats.map((c) => c.id), plot, (i) => band.position(i) + band.bandwidth / 2, "y"),
|
|
1610
|
+
valueAxis: "horizontal",
|
|
1611
|
+
partialCategories: partialIds(cats),
|
|
1612
|
+
...!annotationPass && cagrInset(domain) ? { barInset: { gapWord: chartString2(domain.options, "gapLead") } } : {}
|
|
1613
|
+
};
|
|
1614
|
+
if (annotationPass) return runAnnotatePass(annotationPass(passInput, scene.marks));
|
|
1615
|
+
let room = area.frame.plot.x + area.frame.plot.w - (plot.x + plot.w);
|
|
1616
|
+
return runAnnotatePass(room > 0 ? { ...passInput, plot: { ...plot, w: plot.w + room } } : passInput);
|
|
1617
|
+
}
|
|
1618
|
+
function halvesOfOneBlock(halves) {
|
|
1619
|
+
if (halves !== void 0)
|
|
1620
|
+
return (a, b) => a.categoryId === b.categoryId && (a.seriesId === halves.neg && b.seriesId === halves.pos || a.seriesId === halves.pos && b.seriesId === halves.neg);
|
|
1621
|
+
}
|
|
1622
|
+
function assembleBarGeometry(domain, area, scene, solved, annotated, placedAnnotations, occupied, warnings) {
|
|
1623
|
+
let { options, theme, size, measure, variant, cats, dataSeries, fmt, totalFmt, totals, shares, meanValue } = domain, { tickFont, labelFont, strongFont, band } = area, { nodes } = scene, allLabels = [...solved.placed, ...annotated.labels];
|
|
1624
|
+
spliceAnnotationNodes(nodes, annotated.nodes), pushAll(
|
|
1625
|
+
nodes,
|
|
1626
|
+
labelsToNodes(
|
|
1627
|
+
theme,
|
|
1628
|
+
allLabels,
|
|
1629
|
+
(l) => l.kind === "grandTotal" || l.kind === "total" ? strongFont : l.kind === "category" || l.kind === "percentIndicator" || l.kind === "tick" ? tickFont : l.kind === "annotation" || l.kind === "valueLine" ? strongFont : l.kind === "point" ? area.pointFont : labelFont,
|
|
1630
|
+
nodes
|
|
1631
|
+
)
|
|
1632
|
+
);
|
|
1633
|
+
let paintWarningRules = [];
|
|
1634
|
+
pushAll(warnings, rectSeriesAdjacentWarnings(
|
|
1635
|
+
nodes,
|
|
1636
|
+
(paint) => paintColor(theme, paint),
|
|
1637
|
+
"horizontal",
|
|
1638
|
+
domain.highlights,
|
|
1639
|
+
theme,
|
|
1640
|
+
{ rules: paintWarningRules, before: warnings.filter((warning) => !["pie-ramp-crowded", "likert-ramp-invisible", "band-lightness-insufficient", "series-adjacent-similar", "highlight-reads-as-loss"].includes(warning.code)).length },
|
|
1641
|
+
options[DEFER_ADJACENT] !== !0
|
|
1642
|
+
));
|
|
1643
|
+
let totalsById = emptyIdRecord(), totalsAdd = dataSeries.length === 1 || variant !== "grouped" && domain.partsAdd;
|
|
1644
|
+
totalsAdd && cats.forEach((c, ci) => {
|
|
1645
|
+
domain.stacks[ci].hasValue && (totalsById[c.id] = totals[ci]);
|
|
1646
|
+
});
|
|
1647
|
+
let sharesById = variant === "stacked100" ? Object.fromEntries(
|
|
1648
|
+
cats.map((c, ci) => [
|
|
1649
|
+
c.id,
|
|
1650
|
+
// Shares are already scale-free percentages, so round2 is not a unit
|
|
1651
|
+
// hazard here — but it IS a receipt, and a receipt that disagrees with
|
|
1652
|
+
// the printed share on the third decimal is still a receipt that cannot
|
|
1653
|
+
// be recomputed. Raw for the same reason as the totals above.
|
|
1654
|
+
Object.fromEntries(dataSeries.map((s, si) => [s.id, shares[ci][si]]))
|
|
1655
|
+
])
|
|
1656
|
+
) : void 0, variantWord = variant === "grouped" ? chartString2(options, "groupedCapital") : variant === "stacked" ? chartString2(options, "stackedCapital") : chartString2(options, "stacked100"), oneValueText = (ci) => {
|
|
1657
|
+
let s = dataSeries.length === 1 ? dataSeries[0] : void 0, cell = s?.cells[ci];
|
|
1658
|
+
return !s || !cell || cell.v === null ? null : textFor(domain, cell.v, cell, void 0, s) ?? displayFor(domain, cell.v, cell, void 0, s);
|
|
1659
|
+
}, a11yDesc = cats.map(
|
|
1660
|
+
(c, ci) => domain.stacks[ci].hasValue ? variant === "stacked100" ? `${c.label} ${totalFmt(totals[ci])} (${dataSeries.map((s, si) => `${s.label} ${formatShare(shares[ci][si], options.locale?.language)}`).join(", ")})` : `${c.label} ${oneValueText(ci) ?? totalFmt(totals[ci])}` : `${c.label} ${NOT_AVAILABLE}`
|
|
1661
|
+
).join(", ");
|
|
1662
|
+
return {
|
|
1663
|
+
type: "bar",
|
|
1664
|
+
size,
|
|
1665
|
+
sizing: barSizing(
|
|
1666
|
+
size,
|
|
1667
|
+
area,
|
|
1668
|
+
band.step,
|
|
1669
|
+
area.catLines,
|
|
1670
|
+
naturalCategoryHeights(cats, tickFont, area.capW, measure),
|
|
1671
|
+
area.fixedRowsH,
|
|
1672
|
+
area.segmentStep,
|
|
1673
|
+
!options[HARD_MINIMUM],
|
|
1674
|
+
textScaleOf(options),
|
|
1675
|
+
area.segmentMinStep,
|
|
1676
|
+
domain.incompleteRows.size > 0 && options.mode === "compact" && options[HARD_MINIMUM] === !0
|
|
1677
|
+
),
|
|
1678
|
+
plot: area.plot,
|
|
1679
|
+
scene: withSegmentSeams(joinHatchPeers(nodes), theme, halvesOfOneBlock(barHalves(options))),
|
|
1680
|
+
labels: allLabels,
|
|
1681
|
+
axes: [
|
|
1682
|
+
{
|
|
1683
|
+
axis: "y",
|
|
1684
|
+
baselineNodeId: "axis:baseline",
|
|
1685
|
+
ticks: cats.map((c, i) => ({ at: c.id, pos: band.center(i), labelId: `category:${c.id}` }))
|
|
1686
|
+
},
|
|
1687
|
+
...scene.axes
|
|
1688
|
+
],
|
|
1689
|
+
annotations: [...placedAnnotations, ...annotated.placed],
|
|
1690
|
+
legend: area.frame.legend,
|
|
1691
|
+
frame: area.frame.frame,
|
|
1692
|
+
marks: scene.marks,
|
|
1693
|
+
derived: {
|
|
1694
|
+
totals: totalsById,
|
|
1695
|
+
stackParts: stackParts(totalsById, cats, dataSeries, (si, ci) => dataSeries[si].cells[ci].v),
|
|
1696
|
+
...sharesById ? { shares: sharesById } : {},
|
|
1697
|
+
...domain.roundingAdjustments.length > 0 ? { roundingAdjustments: domain.roundingAdjustments } : {},
|
|
1698
|
+
order: cats.map((c) => c.id),
|
|
1699
|
+
// Omitted rather than 0 when nothing is plotted: `derived` is a receipt
|
|
1700
|
+
// surface, and a fabricated 0 there is a number the engine certifies but
|
|
1701
|
+
// the data never produced.
|
|
1702
|
+
...meanValue === void 0 ? {} : { mean: meanValue }
|
|
1703
|
+
},
|
|
1704
|
+
a11y: {
|
|
1705
|
+
titleCounts: [structureCount("categories", cats.length, void 0, options)],
|
|
1706
|
+
title: accessibleTitle(options.title, chartString2(options, "barTitle", { v1: cats.length })),
|
|
1707
|
+
counts: [structureCount("series", dataSeries.length, void 0, options)],
|
|
1708
|
+
desc: chartString2(options, "barDesc", { v1: variantWord, v2: dataSeries.length, v3: totalsAdd ? ` ${a11yDesc}.` : "" }) + (scene.rangeMarks.length ? chartString2(options, "rangesClause", { v1: scene.rangeMarks.map((range) => chartString2(options, "namedRange", { v1: range.categoryId, v2: fmt(range.low), v3: fmt(range.high) })).join(", ") }) : "")
|
|
1709
|
+
},
|
|
1710
|
+
warnings,
|
|
1711
|
+
paintWarningRules,
|
|
1712
|
+
debug: {
|
|
1713
|
+
occupied: occupied.snapshot(),
|
|
1714
|
+
decisions: [...solved.decisions, ...annotated.decisions]
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
var BAND_TRIES = /* @__PURE__ */ Symbol("bandTries");
|
|
1719
|
+
function layoutStandardBar(data, options = {}, annotationPass) {
|
|
1720
|
+
let warnings = [], domain = resolveBarDomain(data, options, warnings), paints = barPaints(domain, warnings), framed = solveBarFrame(domain, paints, warnings), occupied = framed.claims, area = barPlotArea(domain, framed.frame, warnings);
|
|
1721
|
+
if (area.cutNotes.length > 0 && options[CUT_NOTES] === void 0)
|
|
1722
|
+
return layoutStandardBar(data, { ...options, [CUT_NOTES]: area.cutNotes }, annotationPass);
|
|
1723
|
+
let scene = layoutBarMarks(domain, paints, area), local = layoutBarLocalAnnotations(domain, area, warnings);
|
|
1724
|
+
pushAll(scene.nodes, local.nodes);
|
|
1725
|
+
for (let c of [...scene.claims.snapshot(), ...local.claims.snapshot()]) occupied.claim(c.rect, c.kind, c.owner, c.part);
|
|
1726
|
+
let { size, theme } = domain, solveCtx = labelCtx(theme, size, options, {
|
|
1727
|
+
measure: domain.measure,
|
|
1728
|
+
plot: area.plot,
|
|
1729
|
+
labelPad: 2,
|
|
1730
|
+
// values valueLabels picks are no scatter; each one that cannot sit goes to the note alone.
|
|
1731
|
+
seriesUniform: pickedValues(options) ? void 0 : bandValueLabelUniformity()
|
|
1732
|
+
}), titleRequests = area.axisTitle && area.axisTitleAt && options.valueAxis?.show ? [valueAxisTitleRequest(area.axisTitle, area.axisTitleAt, "end", "axis:x:title")] : [], values = keepValuesWithoutAxis(planBarLabels(domain, paints, area, scene, warnings), solveCtx.density, options.valueAxis?.show === !0), solved = solveLabels([...titleRequests, ...values, ...local.requests], occupied, solveCtx), toDate = toDateOnValues(domain), toDateRoomH = toDateRoom(area.band.bandwidth);
|
|
1733
|
+
if (toDate.size > 0 && solved.placed.some((l) => (l.kind === "grandTotal" || l.kind === "point") && toDate.has(l.owner.categoryId ?? "") && (l.hidden !== void 0 || l.rect.h > toDateRoomH)))
|
|
1734
|
+
return layoutStandardBar(data, { ...options, [PARTIAL_KEY]: !0 }, annotationPass);
|
|
1735
|
+
applyValueAxisTitleInk(solved.placed);
|
|
1736
|
+
for (let label of solved.placed) label.id.startsWith("tick:") && !label.hidden && (label.ink = { token: "inkMuted" });
|
|
1737
|
+
pushAll(warnings, solved.warnings), pruneOrphanAnnotationArms(scene.nodes, local.placed, solved.placed);
|
|
1738
|
+
let annotated = annotateBar(domain, area, scene, occupied, solveCtx, annotationPass), room = options;
|
|
1739
|
+
if (annotated.legDeficit > 0.5 && !annotationPass && (room[CAGR_TRIES] ?? 0) < 3 && (room[RIGHT_ROOM] === void 0 || room[CAGR_TRIES] !== void 0))
|
|
1740
|
+
return layoutStandardBar(data, {
|
|
1741
|
+
...options,
|
|
1742
|
+
[RIGHT_ROOM]: (room[RIGHT_ROOM] ?? (cagrInset(domain) ? CAGR_INSET_ROOM : CAGR_ROOM)) + Math.ceil(annotated.legDeficit) + 2,
|
|
1743
|
+
[CAGR_TRIES]: (room[CAGR_TRIES] ?? 0) + 1
|
|
1744
|
+
}, annotationPass);
|
|
1745
|
+
let cagrs = annotated.placed.filter((placed) => placed.kind === "cagr"), cagrHidden = cagrs.length > 0 && cagrs.every((placed) => annotated.labels.some((label) => label.id === placed.labelId && label.hidden));
|
|
1746
|
+
if (!annotationPass && cagrHidden && room[RIGHT_ROOM] !== 0 && (room[CAGR_TRIES] ?? 0) < 3 && cagrInset(domain)) {
|
|
1747
|
+
let wider = layoutStandardBar(data, { ...options, [RIGHT_ROOM]: (room[RIGHT_ROOM] ?? CAGR_INSET_ROOM) + 24, [CAGR_TRIES]: 3 }, annotationPass);
|
|
1748
|
+
if (!wider.refused && wider.labels.some((label) => cagrs.some((placed) => placed.labelId === label.id) && !label.hidden)) return wider;
|
|
1749
|
+
}
|
|
1750
|
+
return !annotationPass && room[RIGHT_ROOM] !== 0 && cagrHidden ? layoutStandardBar(data, { ...options, [RIGHT_ROOM]: 0, [CAGR_TRIES]: 3 }, annotationPass) : annotated.bandNeed > 0 && (room[BAND_TRIES] ?? 0) < 2 ? layoutStandardBar(data, {
|
|
1751
|
+
...options,
|
|
1752
|
+
[BAND_PAD]: (room[BAND_PAD] ?? 0) + Math.ceil(annotated.bandNeed),
|
|
1753
|
+
[BAND_TRIES]: (room[BAND_TRIES] ?? 0) + 1
|
|
1754
|
+
}, annotationPass) : (pushAll(warnings, annotated.warnings), assembleBarGeometry(domain, area, scene, solved, annotated, local.placed, occupied, warnings));
|
|
1755
|
+
}
|
|
1756
|
+
function outsideLaneCandidates(side, endpointX, textSize, rowCenter, occupied, currentRuleClaim, canvas, valueBody, rowLane) {
|
|
1757
|
+
let slot = side === "low" ? "outsideLow" : "outsideHigh", canonicalX = side === "low" ? endpointX - LABEL_GAP - textSize.width : endpointX + LABEL_GAP, lane = side === "low" ? { x: valueBody.x, y: rowLane.y, w: Math.max(0, endpointX - valueBody.x), h: rowLane.h } : {
|
|
1758
|
+
x: endpointX,
|
|
1759
|
+
y: rowLane.y,
|
|
1760
|
+
w: Math.max(0, valueBody.x + valueBody.w - endpointX),
|
|
1761
|
+
h: rowLane.h
|
|
1762
|
+
}, rectAt = (x) => ({
|
|
1763
|
+
x,
|
|
1764
|
+
y: rowCenter - textSize.height / 2,
|
|
1765
|
+
w: textSize.width,
|
|
1766
|
+
h: textSize.height
|
|
1767
|
+
}), rect = rectAt(canonicalX), candidates = [], contained = (candidate) => rectContains(canvas, candidate, 0) && rectContains(valueBody, candidate, 0) && rectContains(rowLane, candidate, 0) && rectContains(lane, candidate, 0) && (side === "low" ? candidate.x + candidate.w <= endpointX : candidate.x >= endpointX);
|
|
1768
|
+
for (; contained(rect); ) {
|
|
1769
|
+
candidates.push({ slot, rect, penalty: candidates.length });
|
|
1770
|
+
let blockerRects = occupied.hitsWhich(rect, LABEL_PAD).map((claim) => claim.rect);
|
|
1771
|
+
if (currentRuleClaim && rectsOverlap(currentRuleClaim, rect, LABEL_PAD) && blockerRects.push(currentRuleClaim), blockerRects.length === 0) break;
|
|
1772
|
+
let nextX = side === "low" ? minOf(blockerRects.map((blocker) => blocker.x - LABEL_PAD - textSize.width)) : maxOf(blockerRects.map((blocker) => blocker.x + blocker.w + LABEL_PAD)), boundedByLane = side === "low" ? Math.max(lane.x, nextX) : Math.min(lane.x + lane.w - textSize.width, nextX);
|
|
1773
|
+
if (!Number.isFinite(boundedByLane) || (side === "low" ? boundedByLane >= rect.x : boundedByLane <= rect.x)) break;
|
|
1774
|
+
let nextRect = rectAt(boundedByLane);
|
|
1775
|
+
if (!contained(nextRect)) break;
|
|
1776
|
+
rect = nextRect;
|
|
1777
|
+
}
|
|
1778
|
+
return candidates;
|
|
1779
|
+
}
|
|
1780
|
+
function layoutFootballField(data, options) {
|
|
1781
|
+
return layoutRowIntervals(data, options, "football-field");
|
|
1782
|
+
}
|
|
1783
|
+
function layoutTornado(data, options) {
|
|
1784
|
+
return layoutRowIntervals(data, options, "tornado");
|
|
1785
|
+
}
|
|
1786
|
+
function rowIntervalValues(data, options) {
|
|
1787
|
+
let cats = (data?.categories ?? []).map((category, index) => normalizeCategory(category, index)), spine = options.variant === "tornado" ? options.baseValue : options.currentValue;
|
|
1788
|
+
return [
|
|
1789
|
+
...(data?.series ?? []).filter((series) => series.role !== "reference").flatMap(
|
|
1790
|
+
(series, index) => normalizeSeriesValues(series, cats, index).flatMap((cell) => {
|
|
1791
|
+
let range = typeof cell == "object" && cell !== null && "range" in cell ? cell.range : void 0;
|
|
1792
|
+
return range ? [range.low, range.high, ...options.methodNote === !0 ? [range.mid] : []] : [cellValue(cell)];
|
|
1793
|
+
})
|
|
1794
|
+
),
|
|
1795
|
+
typeof spine == "number" ? spine : spine?.value
|
|
1796
|
+
];
|
|
1797
|
+
}
|
|
1798
|
+
var COMPACT_ROW_GAP = 8, TORNADO_ROW_GAP = 6, COMPACT_NAME_GAP = 3, COMPACT_RANGE_SUFFIX = ":range";
|
|
1799
|
+
function compactRowNames(cats, mode, font, boldFont, width, lineH, measure, options, warnings) {
|
|
1800
|
+
let fit = { target: options.target, textScale: textScaleOf(options), typeRole: "axis" }, rowsOf = (join) => cats.map((cat) => ({ id: cat.id, label: join ? (cat.label ?? cat.id).split(`
|
|
1801
|
+
`).join(" ") : cat.label ?? cat.id, footnote: cat.footnote })), joined = rowLabelBand(rowsOf(!0), font, width, CAT_MAX_LINES, lineH, measure, { ...fit, footnoteRefs: { count: authoredFootnoteCount(options), warnings } }), wrapped, names = cats.map((cat, i) => {
|
|
1802
|
+
let parts = (cat.label ?? cat.id).split(`
|
|
1803
|
+
`), headBold = mode === "tornado" && parts.length > 1, line = joined.labels[i];
|
|
1804
|
+
if (line.lines.length === 1 && line.title === void 0 && line.font === font) {
|
|
1805
|
+
let text = line.lines[0];
|
|
1806
|
+
if (!headBold) return { head: text, headBold };
|
|
1807
|
+
let head = parts[0], tail = text.slice(head.length + 1);
|
|
1808
|
+
if (measure(head, boldFont).width + measure(" ", font).width + measure(tail, font).width <= width) return { head, tail, headBold };
|
|
1809
|
+
}
|
|
1810
|
+
wrapped ??= rowLabelBand(rowsOf(!1), font, width, CAT_MAX_LINES, lineH, measure, { ...fit, footnoteRefs: { count: authoredFootnoteCount(options), warnings: [] } });
|
|
1811
|
+
let fitted = headBold ? wrapped.labels[i] : line;
|
|
1812
|
+
return { head: fitted.lines[0] ?? "", fitted, headBold };
|
|
1813
|
+
});
|
|
1814
|
+
return { names, nameBlock: maxOf(names.map((name) => name.fitted?.h ?? lineH)) };
|
|
1815
|
+
}
|
|
1816
|
+
function compactBand(count, plot, nameBlock, barNatural, rowGap) {
|
|
1817
|
+
let step = plot.h / Math.max(1, count), bandwidth = Math.max(4, Math.min(barNatural, step - rowGap - nameBlock - COMPACT_NAME_GAP)), position = (index) => plot.y + (index + 1) * step - bandwidth;
|
|
1818
|
+
return { position, center: (index) => position(index) + bandwidth / 2, bandwidth, step, count, range: [plot.y, plot.y + plot.h] };
|
|
1819
|
+
}
|
|
1820
|
+
function compactNameRight(name, x, font, boldWeight, measure) {
|
|
1821
|
+
if (name.fitted) return x + name.fitted.w;
|
|
1822
|
+
let head = measure(name.head, name.headBold ? { ...font, weight: boldWeight } : font).width;
|
|
1823
|
+
return x + head + (name.tail === void 0 ? 0 : measure(" ", font).width + measure(name.tail, font).width);
|
|
1824
|
+
}
|
|
1825
|
+
function compactNameRequests(name, cat, x, bottom, lineH, font, boldWeight, measure) {
|
|
1826
|
+
let base = { kind: "category", owner: { categoryId: cat.id }, typeRole: "axis", font, priority: PRIORITY.endpoint }, seat = (w, h, at = x) => [{ slot: "above", rect: { x: at, y: bottom - h, w, h }, penalty: 0, needsBacking: !0 }];
|
|
1827
|
+
if (name.fitted)
|
|
1828
|
+
return [{
|
|
1829
|
+
...base,
|
|
1830
|
+
id: `category:${cat.id}`,
|
|
1831
|
+
text: cat.label ?? cat.id,
|
|
1832
|
+
...fittedLabel(name.fitted, font),
|
|
1833
|
+
...name.headBold && name.fitted.lines.length > 1 ? { headLines: 1, headWeight: boldWeight, bodyInk: { token: "inkMuted" } } : {},
|
|
1834
|
+
candidates: seat(name.fitted.w, name.fitted.h)
|
|
1835
|
+
}];
|
|
1836
|
+
let headW = measure(name.head, name.headBold ? { ...font, weight: boldWeight } : font).width, requests = [{
|
|
1837
|
+
...base,
|
|
1838
|
+
id: `category:${cat.id}`,
|
|
1839
|
+
text: name.tail === void 0 ? cat.label ?? cat.id : name.head,
|
|
1840
|
+
lines: [name.head],
|
|
1841
|
+
...name.headBold ? { runs: [{ text: name.head, weight: boldWeight }] } : {},
|
|
1842
|
+
candidates: seat(headW, lineH)
|
|
1843
|
+
}];
|
|
1844
|
+
return name.tail !== void 0 && requests.push({
|
|
1845
|
+
...base,
|
|
1846
|
+
id: `category:${cat.id}${COMPACT_RANGE_SUFFIX}`,
|
|
1847
|
+
text: name.tail,
|
|
1848
|
+
lines: [name.tail],
|
|
1849
|
+
candidates: seat(measure(name.tail, font).width, lineH, x + headW + measure(" ", font).width)
|
|
1850
|
+
}), requests;
|
|
1851
|
+
}
|
|
1852
|
+
function layoutRowIntervals(data, options, mode) {
|
|
1853
|
+
let warnings = [], theme = chartTheme(options), size = resolveSize(options.size), paletteRamp = chartPalette(theme, options.palette, warnings), measure = options.measure ?? defaultMeasurer, valueSpec = seriesRasterFormatter(options.format, rowIntervalValues(data, options), options.locale?.language, options.unit, options.target), fmt = valueSpec.fmt, labelOn2 = (kind) => labelOn(options, kind, ["category", "valueLine"]), highlights = new Set(resolveHighlight(options.highlight)), ctx = { warnings, theme, paletteRamp, fmt, forSeries: valueSpec.forSeries, labelOn: labelOn2, highlights }, plan = mode === "football-field" ? planFootballField(data, options, ctx) : planTornado(data, options, ctx), cats = plan.cats, rows = plan.rows, spine = plan.spine, rowFmt = plan.valueFmt ?? fmt, rawLo = Math.min(
|
|
1854
|
+
minOf(rows.flatMap((row) => row.pieces.flatMap((piece) => [piece.from, piece.to]))),
|
|
1855
|
+
spine?.value ?? 1 / 0
|
|
1856
|
+
), rawHi = Math.max(
|
|
1857
|
+
maxOf(rows.flatMap((row) => row.pieces.flatMap((piece) => [piece.from, piece.to]))),
|
|
1858
|
+
spine?.value ?? -1 / 0
|
|
1859
|
+
);
|
|
1860
|
+
if ([rawLo, rawHi] = applyAxisBounds([rawLo, rawHi], [rawLo, rawHi], options.valueAxis, warnings), rawLo === rawHi) {
|
|
1861
|
+
let pad = Math.max(1, Math.abs(rawLo) * 0.1);
|
|
1862
|
+
rawLo -= pad, rawHi += pad;
|
|
1863
|
+
}
|
|
1864
|
+
let tickFont = { family: theme.type.family, ...theme.type.axis }, labelFont = { family: theme.type.family, ...theme.type.label }, strongFont = { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) }, maxLowWidth = maxOf(rows.map((row) => measure(row.leftText, labelFont).width)), maxHighWidth = maxOf(rows.map((row) => measure(row.rightText, labelFont).width)), occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frameResult = solveFrame(
|
|
1865
|
+
{
|
|
1866
|
+
size,
|
|
1867
|
+
margin: { ...canvasMargin(theme, size.width), ...options.margin },
|
|
1868
|
+
...frameTextOptions(options),
|
|
1869
|
+
// Engine-owned method notes come AFTER the author's, and the author
|
|
1870
|
+
// cannot delete them — the basis on which a mark is drawn is not an
|
|
1871
|
+
// authoring choice. (likert/layout.ts:766, pyramid/layout.ts:296.)
|
|
1872
|
+
footnotes: [...authoredNotes(options), ...plan.methodNotes ?? []],
|
|
1873
|
+
...plan.legend ? { legend: plan.legend } : {},
|
|
1874
|
+
theme,
|
|
1875
|
+
measure
|
|
1876
|
+
},
|
|
1877
|
+
occupied
|
|
1878
|
+
), plot0 = frameResult.plot, spineLabelPad = spine && labelOn2("valueLine") ? 26 : 8, currentPad = spineLabelPad, callerNames = options[NO_NAME_COLUMN] === !0, tornadoHead = (cat, label) => mode === "tornado" && label.lines.length > 1 && (cat.label ?? "").includes(`
|
|
1879
|
+
`), compactWidth = !callerNames && labelOn2("category") && (panelTypeClass(options) ?? typeWidthClass(size.width)) === "S" && options.rowLabels === void 0 && options.bandFraction === void 0 && !theme.space.barRow, nameLineH = tickFont.size * 1.2, compactPlan = compactWidth ? compactRowNames(cats, mode, tickFont, { ...tickFont, weight: emphasisWeight(theme) }, plot0.w, nameLineH, measure, options, warnings) : void 0, compactRowGap = mode === "tornado" ? TORNADO_ROW_GAP : COMPACT_ROW_GAP, spineLift = compactPlan && spine && labelOn2("valueLine") ? compactRowGap : 0;
|
|
1880
|
+
currentPad = spineLabelPad - spineLift;
|
|
1881
|
+
let compactBar = Math.ceil(measure("0", labelFont).height) + (mode === "tornado" ? 0 : 2), compactMinBar = Math.min(compactBar, Math.ceil(labelFont.size)), compactStep = (bar) => compactRowGap + (compactPlan?.nameBlock ?? 0) + COMPACT_NAME_GAP + bar, axisShown = options.valueAxis?.show ?? mode !== "tornado", axisTitle = axisShown && labelOn2("axisTitle") ? planValueAxisTitle(valueAxisTitleText(
|
|
1882
|
+
theme,
|
|
1883
|
+
options.axisTitles?.primary,
|
|
1884
|
+
options,
|
|
1885
|
+
valueAxisUnit(options.unit, (data.series ?? []).filter((series) => series.role !== "reference"), !1)
|
|
1886
|
+
), theme, measure, plot0.w) : void 0, tickRowH = measure("0", tickFont).height, targetSizing = !options[HARD_MINIMUM], rowsFor = (titleRow, rowWarnings, noNameColumn) => {
|
|
1887
|
+
let axisH = axisShown ? tickRowH + 8 + (axisTitle && titleRow ? axisTitle.height + 2 : 0) : 0, availH = plotHeightAfter(frameResult, size.height, plot0.h - currentPad - axisH), lineH = tickFont.size * 1.2, catCap2 = Math.max(24, plot0.w * 0.28), stepEst = theme.space.barRow?.pitch ?? availH / cats.length, fittedCats = rowLabelBand(
|
|
1888
|
+
cats.map((cat) => ({ id: cat.id, label: cat.label ?? cat.id, footnote: cat.footnote })),
|
|
1889
|
+
tickFont,
|
|
1890
|
+
catCap2,
|
|
1891
|
+
stepEst >= Math.max(30, 2 * lineH + (targetSizing ? 4 : 0)) ? 2 : 1,
|
|
1892
|
+
lineH,
|
|
1893
|
+
measure,
|
|
1894
|
+
{ target: options.target, textScale: textScaleOf(options), typeRole: "axis", wider: gutterBudget(24, plot0.w), shrink: stepDownFont(theme, tickFont, "axis", options.target, textScaleOf(options)), footnoteRefs: { count: authoredFootnoteCount(options), warnings: rowWarnings } }
|
|
1895
|
+
), catLines2 = fittedCats.labels.map((label, ci) => tornadoHead(cats[ci], label) ? { ...label, w: Math.max(label.w, measure(label.lines[0], { ...label.font, weight: emphasisWeight(theme) }).width) } : label), catBandW2 = Math.max(fittedCats.width, maxOf(catLines2.map((label) => label.w))), fixedRow2 = fixedBarRow(theme, catLines2.map((label) => label.h)), fixedRowsH2 = fixedRow2 ? fixedRow2.step * cats.length : void 0, nameW = noNameColumn ? 0 : catBandW2 + CAT_BAND_GAP, valueBody2 = {
|
|
1896
|
+
x: plot0.x + nameW,
|
|
1897
|
+
y: plot0.y + currentPad,
|
|
1898
|
+
w: Math.max(10, plot0.w - nameW),
|
|
1899
|
+
// Fixed rows never stretch; a shorter canvas (a grid panel) packs them.
|
|
1900
|
+
h: fixedRowsH2 === void 0 ? availH : Math.min(availH, fixedRowsH2)
|
|
1901
|
+
}, leftReserve = maxLowWidth + LABEL_GAP + 8, rightReserve = maxHighWidth + LABEL_GAP + 8, plot2 = {
|
|
1902
|
+
x: valueBody2.x + leftReserve,
|
|
1903
|
+
y: valueBody2.y,
|
|
1904
|
+
w: Math.max(10, valueBody2.w - leftReserve - rightReserve),
|
|
1905
|
+
h: valueBody2.h
|
|
1906
|
+
}, x2 = linearScale([dLo, dHi], [plot2.x, plot2.x + plot2.w]), titleEnd = axisTitle && !titleRow ? tickRowTitleEnd(axisTitle, { scale: x2, plot: plot2, orient: "x", gridlines: !1, format: fmt, formatSpec: valueSpec.spec, theme, measure, canvasWidth: size.width }, plot0.x) : void 0, minWidth = size.width - plot0.w + nameW + leftReserve + rightReserve + 10;
|
|
1907
|
+
return { availH, minWidth, catCap: catCap2, catLines: catLines2, catBandW: catBandW2, fixedRow: fixedRow2, fixedRowsH: fixedRowsH2, valueBody: valueBody2, plot: plot2, x: x2, titleEnd, titleRow };
|
|
1908
|
+
}, [dLo, dHi] = !axisShown || mode === "football-field" ? [rawLo, rawHi] : niceDomain(rawLo, rawHi, 5, {
|
|
1909
|
+
dataExtent: [rawLo, rawHi],
|
|
1910
|
+
maxWasteFraction: 0.15,
|
|
1911
|
+
preserveDataSideOfZero: !0
|
|
1912
|
+
}), planRows = (noNameColumn, out) => {
|
|
1913
|
+
let sharedWarnings = [], first = rowsFor(!1, sharedWarnings, noNameColumn);
|
|
1914
|
+
return axisShown && axisTitle && first.titleEnd === void 0 ? rowsFor(!0, out, noNameColumn) : (pushAll(out, sharedWarnings), first);
|
|
1915
|
+
}, rowPlan = planRows(callerNames || compactPlan !== void 0, warnings), compact = compactPlan && rowPlan.availH >= cats.length * compactStep(compactBar) ? compactPlan : void 0;
|
|
1916
|
+
compactPlan && !compact && (currentPad = spineLabelPad, rowPlan = planRows(!1, []));
|
|
1917
|
+
let labelDrop = compact ? spineLift : 0, spineTop = plot0.y + currentPad + (labelDrop > 0 ? labelDrop - 2 : 0), { catCap, catLines, catBandW, fixedRow, fixedRowsH, valueBody, plot, x } = rowPlan, bandFraction = options.bandFraction ?? fixedRow?.fraction ?? 0.56, band = compact ? compactBand(cats.length, plot, compact.nameBlock, compactBar, compactRowGap) : bandScale(cats.length, [plot.y, plot.y + plot.h], {
|
|
1918
|
+
paddingInner: 1 - bandFraction,
|
|
1919
|
+
paddingOuter: (1 - bandFraction) / 2
|
|
1920
|
+
}), nodes = [...frameResult.nodes], axes = [];
|
|
1921
|
+
if (axisShown) {
|
|
1922
|
+
let axis = layoutValueAxis(
|
|
1923
|
+
{
|
|
1924
|
+
scale: x,
|
|
1925
|
+
plot,
|
|
1926
|
+
orient: "x",
|
|
1927
|
+
gridlines: options.valueAxis?.gridlines ?? !1,
|
|
1928
|
+
format: fmt,
|
|
1929
|
+
formatSpec: valueSpec.spec,
|
|
1930
|
+
theme,
|
|
1931
|
+
measure,
|
|
1932
|
+
canvasWidth: size.width
|
|
1933
|
+
},
|
|
1934
|
+
occupied
|
|
1935
|
+
);
|
|
1936
|
+
nodes.push(...axis.nodes), axes.push(axis.axis);
|
|
1937
|
+
}
|
|
1938
|
+
let marks = { rows: [], referenceTicks: [], rowTints: [] }, labelRequests = axisShown && axisTitle ? [valueAxisTitleRequest(axisTitle, { x: rowPlan.titleEnd ?? plot.x + plot.w, y: plot.y + plot.h + 6 + (rowPlan.titleRow ? tickRowH + 2 : 0) }, "end", "axis:x:title")] : [], currentX = spine ? x(spine.value) : void 0, canvas = { x: 0, y: 0, w: size.width, h: size.height }, currentRuleClaim = mode === "football-field" && currentX !== void 0 && rectContains(canvas, plot, 0) ? { x: currentX - SPINE_CLAIM_HALF_WIDTH, y: plot.y, w: SPINE_CLAIM_HALF_WIDTH * 2, h: plot.h } : void 0;
|
|
1939
|
+
rows.forEach((row, ri) => {
|
|
1940
|
+
let cat = row.cat, rowY = band.position(ri), rowCenter = band.center(ri), gapHalf = (band.step - band.bandwidth) / 2, laneH = Math.max(band.bandwidth, measure("0", labelFont).height) + 6, rowLane = compact ? { x: valueBody.x, y: rowCenter - laneH / 2, w: valueBody.w, h: laneH } : {
|
|
1941
|
+
x: valueBody.x,
|
|
1942
|
+
y: Math.max(valueBody.y, band.position(ri) - gapHalf),
|
|
1943
|
+
w: valueBody.w,
|
|
1944
|
+
h: Math.min(band.step, valueBody.y + valueBody.h - (band.position(ri) - gapHalf))
|
|
1945
|
+
}, rowRect, bars = [];
|
|
1946
|
+
for (let piece of row.pieces) {
|
|
1947
|
+
let xFrom = x(piece.from), xTo = x(piece.to), rect = {
|
|
1948
|
+
x: Math.min(xFrom, xTo),
|
|
1949
|
+
y: rowY,
|
|
1950
|
+
// Floor: a zero-width interval is a FINDING (no sensitivity, or a
|
|
1951
|
+
// point estimate), and it has to stay visible as a hairline.
|
|
1952
|
+
w: Math.max(Math.abs(xTo - xFrom), 0.5),
|
|
1953
|
+
h: band.bandwidth
|
|
1954
|
+
}, owner = { seriesId: piece.seriesId, categoryId: cat.id }, plain = !piece.paint.pattern && !piece.paint.stroke, edge = plain ? separationStroke(paintColor(theme, piece.paint.fill), theme.color.background, theme) : void 0;
|
|
1955
|
+
nodes.push({
|
|
1956
|
+
t: "rect",
|
|
1957
|
+
id: piece.nodeId,
|
|
1958
|
+
rect,
|
|
1959
|
+
fill: piece.paint.fill,
|
|
1960
|
+
...piece.paint.pattern ? { pattern: piece.paint.pattern } : {},
|
|
1961
|
+
...piece.paint.stroke ? { stroke: piece.paint.stroke, strokeWidth: piece.paint.strokeWidth } : {},
|
|
1962
|
+
...edge ?? {},
|
|
1963
|
+
...plain ? { separation: { fill: piece.paint.fill, backing: { token: "background" } } } : {},
|
|
1964
|
+
owner,
|
|
1965
|
+
part: piece.part,
|
|
1966
|
+
...piece.display === void 0 ? {} : { display: { value: piece.display } }
|
|
1967
|
+
}), occupied.claim(rect, "mark", owner, "bar"), bars.push({ seriesId: piece.seriesId, rect, nodeId: piece.nodeId }), rowRect = rowRect === void 0 ? rect : unionRect(rowRect, rect);
|
|
1968
|
+
}
|
|
1969
|
+
if (row.mid) {
|
|
1970
|
+
let midX = x(row.mid.value);
|
|
1971
|
+
nodes.push({
|
|
1972
|
+
t: "line",
|
|
1973
|
+
id: row.mid.id,
|
|
1974
|
+
x1: midX,
|
|
1975
|
+
y1: rowY - 2,
|
|
1976
|
+
x2: midX,
|
|
1977
|
+
y2: rowY + band.bandwidth + 2,
|
|
1978
|
+
stroke: { token: "markInk" },
|
|
1979
|
+
width: strokeToken(theme, "mark"),
|
|
1980
|
+
owner: row.mid.owner,
|
|
1981
|
+
part: "rangeMid",
|
|
1982
|
+
display: { value: rowFmt(row.mid.value) }
|
|
1983
|
+
}), occupied.claim(
|
|
1984
|
+
{ x: midX - 1, y: rowY - 2, w: 2, h: band.bandwidth + 4 },
|
|
1985
|
+
"mark",
|
|
1986
|
+
{ seriesId: row.mid.claimSeriesId, categoryId: cat.id },
|
|
1987
|
+
"range"
|
|
1988
|
+
);
|
|
1989
|
+
}
|
|
1990
|
+
if (marks.rows.push({ id: cat.id, rect: rowRect, bars }), labelOn2("point"))
|
|
1991
|
+
for (let endpoint of row.endpoints) {
|
|
1992
|
+
let text = rowFmt(endpoint.value), textSize = measure(text, labelFont), at = x(endpoint.value), outsideCandidate = endpoint.side === "low" ? {
|
|
1993
|
+
slot: "outsideLow",
|
|
1994
|
+
rect: {
|
|
1995
|
+
x: at - LABEL_GAP - textSize.width,
|
|
1996
|
+
y: rowCenter - textSize.height / 2,
|
|
1997
|
+
w: textSize.width,
|
|
1998
|
+
h: textSize.height
|
|
1999
|
+
},
|
|
2000
|
+
penalty: 0
|
|
2001
|
+
} : {
|
|
2002
|
+
slot: "outsideHigh",
|
|
2003
|
+
rect: {
|
|
2004
|
+
x: at + LABEL_GAP,
|
|
2005
|
+
y: rowCenter - textSize.height / 2,
|
|
2006
|
+
w: textSize.width,
|
|
2007
|
+
h: textSize.height
|
|
2008
|
+
},
|
|
2009
|
+
penalty: 0
|
|
2010
|
+
}, piece = mode === "football-field" && endpoint.side === "low" && currentRuleClaim ? row.pieces.find((p) => Math.abs(x(Math.min(p.from, p.to)) - at) < 0.5) : void 0, pieceW = piece ? Math.abs(x(piece.to) - x(piece.from)) : 0, insideLow = piece && currentRuleClaim && at >= currentRuleClaim.x + currentRuleClaim.w && pieceW >= textSize.width + 2 * LABEL_GAP && band.bandwidth >= labelFont.size ? {
|
|
2011
|
+
slot: "insideLow",
|
|
2012
|
+
rect: { x: at + LABEL_GAP, y: rowCenter - textSize.height / 2, w: textSize.width, h: textSize.height },
|
|
2013
|
+
penalty: 0,
|
|
2014
|
+
insideFill: paintColor(theme, piece.paint.fill),
|
|
2015
|
+
insidePaint: piece.paint.fill
|
|
2016
|
+
} : void 0, candidates = insideLow ? [insideLow] : mode === "football-field" ? outsideLaneCandidates(
|
|
2017
|
+
endpoint.side,
|
|
2018
|
+
at,
|
|
2019
|
+
textSize,
|
|
2020
|
+
rowCenter,
|
|
2021
|
+
occupied,
|
|
2022
|
+
currentRuleClaim,
|
|
2023
|
+
canvas,
|
|
2024
|
+
valueBody,
|
|
2025
|
+
rowLane
|
|
2026
|
+
) : endpoint.side === "low" ? [
|
|
2027
|
+
outsideCandidate,
|
|
2028
|
+
{
|
|
2029
|
+
slot: "aboveLow",
|
|
2030
|
+
rect: {
|
|
2031
|
+
x: at - textSize.width / 2,
|
|
2032
|
+
y: rowY - textSize.height - 3,
|
|
2033
|
+
w: textSize.width,
|
|
2034
|
+
h: textSize.height
|
|
2035
|
+
},
|
|
2036
|
+
penalty: 1
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
slot: "belowLow",
|
|
2040
|
+
rect: {
|
|
2041
|
+
x: at - textSize.width / 2,
|
|
2042
|
+
y: rowY + band.bandwidth + 3,
|
|
2043
|
+
w: textSize.width,
|
|
2044
|
+
h: textSize.height
|
|
2045
|
+
},
|
|
2046
|
+
penalty: 2
|
|
2047
|
+
}
|
|
2048
|
+
] : [
|
|
2049
|
+
outsideCandidate,
|
|
2050
|
+
{
|
|
2051
|
+
slot: "aboveHigh",
|
|
2052
|
+
rect: {
|
|
2053
|
+
x: at - textSize.width / 2,
|
|
2054
|
+
y: rowY - textSize.height - 3,
|
|
2055
|
+
w: textSize.width,
|
|
2056
|
+
h: textSize.height
|
|
2057
|
+
},
|
|
2058
|
+
penalty: 1
|
|
2059
|
+
},
|
|
2060
|
+
{
|
|
2061
|
+
slot: "belowHigh",
|
|
2062
|
+
rect: {
|
|
2063
|
+
x: at - textSize.width / 2,
|
|
2064
|
+
y: rowY + band.bandwidth + 3,
|
|
2065
|
+
w: textSize.width,
|
|
2066
|
+
h: textSize.height
|
|
2067
|
+
},
|
|
2068
|
+
penalty: 2
|
|
2069
|
+
}
|
|
2070
|
+
];
|
|
2071
|
+
labelRequests.push({
|
|
2072
|
+
id: endpoint.id,
|
|
2073
|
+
kind: "point",
|
|
2074
|
+
owner: endpoint.owner,
|
|
2075
|
+
text,
|
|
2076
|
+
lines: [text],
|
|
2077
|
+
typeRole: "label",
|
|
2078
|
+
font: labelFont,
|
|
2079
|
+
priority: PRIORITY.endpoint,
|
|
2080
|
+
candidates
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
if (compact)
|
|
2084
|
+
pushAll(labelRequests, compactNameRequests(compact.names[ri], cat, plot0.x, band.position(ri) - COMPACT_NAME_GAP, nameLineH, tickFont, emphasisWeight(theme), measure));
|
|
2085
|
+
else if (labelOn2("category") && !callerNames) {
|
|
2086
|
+
let category = catLines[ri];
|
|
2087
|
+
labelRequests.push({
|
|
2088
|
+
id: `category:${cat.id}`,
|
|
2089
|
+
kind: "category",
|
|
2090
|
+
owner: { categoryId: cat.id },
|
|
2091
|
+
text: cat.label ?? cat.id,
|
|
2092
|
+
...fittedLabel(category, tickFont),
|
|
2093
|
+
...tornadoHead(cat, category) ? { headLines: 1, headWeight: emphasisWeight(theme), bodyInk: { token: "inkMuted" } } : {},
|
|
2094
|
+
typeRole: "axis",
|
|
2095
|
+
font: tickFont,
|
|
2096
|
+
priority: PRIORITY.endpoint,
|
|
2097
|
+
candidates: [
|
|
2098
|
+
{
|
|
2099
|
+
slot: "left",
|
|
2100
|
+
rect: {
|
|
2101
|
+
x: rowLabelX(plot0.x, catBandW, category.w, options.rowLabels?.align ?? "left"),
|
|
2102
|
+
y: rowCenter - category.h / 2,
|
|
2103
|
+
w: category.w,
|
|
2104
|
+
h: category.h
|
|
2105
|
+
},
|
|
2106
|
+
penalty: 0
|
|
2107
|
+
}
|
|
2108
|
+
]
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
}), plan.ranges && (marks.ranges = plan.ranges);
|
|
2112
|
+
let annotations = [];
|
|
2113
|
+
if (spine) {
|
|
2114
|
+
let currentX2 = x(spine.value), lineId = `ann:${spine.key}:line`, spineRuns = compact ? rows.map((_, ri) => ({ y1: band.position(ri), y2: band.position(ri) + band.bandwidth })) : [{ y1: plot.y, y2: plot.y + plot.h }];
|
|
2115
|
+
if (compact && spineRuns.length > 0) {
|
|
2116
|
+
let firstName = compactNameRight(compact.names[0], plot0.x, tickFont, emphasisWeight(theme), measure);
|
|
2117
|
+
mode === "tornado" && firstName + 4 < currentX2 && (spineRuns[0].y1 = spineTop);
|
|
2118
|
+
}
|
|
2119
|
+
let drawnRuns = compact ? mode === "football-field" ? [{ y1: spineTop, y2: plot.y + plot.h }] : spineRuns.map((run) => ({ y1: run.y1 === spineTop ? run.y1 : run.y1 - 3, y2: run.y2 + 3 })) : spineRuns, lineIds = drawnRuns.map((_, k) => k === 0 ? lineId : `${lineId}:${k}`);
|
|
2120
|
+
drawnRuns.forEach((run, k) => nodes.push({
|
|
2121
|
+
t: "line",
|
|
2122
|
+
id: lineIds[k],
|
|
2123
|
+
x1: currentX2,
|
|
2124
|
+
y1: run.y1,
|
|
2125
|
+
x2: currentX2,
|
|
2126
|
+
y2: run.y2,
|
|
2127
|
+
stroke: { token: "ink" },
|
|
2128
|
+
width: strokeToken(theme, "rule"),
|
|
2129
|
+
dash: dashToken(theme, "reference"),
|
|
2130
|
+
owner: { annotationId: spine.key },
|
|
2131
|
+
part: `${spine.key}Line`
|
|
2132
|
+
}));
|
|
2133
|
+
for (let run of spineRuns)
|
|
2134
|
+
occupied.claim(
|
|
2135
|
+
{ x: currentX2 - 0.5, y: run.y1, w: 1, h: run.y2 - run.y1 },
|
|
2136
|
+
"annotation",
|
|
2137
|
+
{ annotationId: spine.key },
|
|
2138
|
+
spine.key
|
|
2139
|
+
);
|
|
2140
|
+
let labelId = `valueLine:${spine.key}`, labelText = spine.text;
|
|
2141
|
+
if (labelOn2("valueLine")) {
|
|
2142
|
+
let labelSize = measure(labelText, strongFont);
|
|
2143
|
+
labelRequests.push({
|
|
2144
|
+
id: labelId,
|
|
2145
|
+
kind: "valueLine",
|
|
2146
|
+
role: composedTextRole(labelText),
|
|
2147
|
+
owner: { annotationId: spine.key },
|
|
2148
|
+
text: labelText,
|
|
2149
|
+
lines: [labelText],
|
|
2150
|
+
typeRole: "label",
|
|
2151
|
+
font: strongFont,
|
|
2152
|
+
priority: PRIORITY.valueLine,
|
|
2153
|
+
candidates: [
|
|
2154
|
+
{
|
|
2155
|
+
slot: "aboveLine",
|
|
2156
|
+
rect: {
|
|
2157
|
+
x: currentX2 - labelSize.width / 2,
|
|
2158
|
+
y: plot.y - labelSize.height - 6 + labelDrop,
|
|
2159
|
+
w: labelSize.width,
|
|
2160
|
+
h: labelSize.height
|
|
2161
|
+
},
|
|
2162
|
+
penalty: 0,
|
|
2163
|
+
needsBacking: mode === "football-field"
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
slot: "aboveLineLeft",
|
|
2167
|
+
rect: {
|
|
2168
|
+
x: currentX2 - labelSize.width - 4,
|
|
2169
|
+
y: plot.y - labelSize.height - 6 + labelDrop,
|
|
2170
|
+
w: labelSize.width,
|
|
2171
|
+
h: labelSize.height
|
|
2172
|
+
},
|
|
2173
|
+
penalty: 1,
|
|
2174
|
+
needsBacking: mode === "football-field"
|
|
2175
|
+
},
|
|
2176
|
+
{
|
|
2177
|
+
slot: "aboveLineRight",
|
|
2178
|
+
rect: {
|
|
2179
|
+
x: currentX2 + 4,
|
|
2180
|
+
y: plot.y - labelSize.height - 6 + labelDrop,
|
|
2181
|
+
w: labelSize.width,
|
|
2182
|
+
h: labelSize.height
|
|
2183
|
+
},
|
|
2184
|
+
penalty: 2,
|
|
2185
|
+
needsBacking: mode === "football-field"
|
|
2186
|
+
}
|
|
2187
|
+
]
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
annotations.push({
|
|
2191
|
+
id: spine.key,
|
|
2192
|
+
kind: "valueLine",
|
|
2193
|
+
// The ENGINE's answer, never the author's. When the author supplied a
|
|
2194
|
+
// label these differ, `annotationClaims` sees it and records
|
|
2195
|
+
// state:'authored-override' with the engine's own string in `inputs`.
|
|
2196
|
+
computedText: labelOn2("valueLine") ? spine.computedText : "",
|
|
2197
|
+
nodeIds: lineIds,
|
|
2198
|
+
...labelOn2("valueLine") ? { labelId } : {}
|
|
2199
|
+
}), marks[spine.key] = {
|
|
2200
|
+
value: spine.value,
|
|
2201
|
+
nodeId: lineId,
|
|
2202
|
+
...labelOn2("valueLine") ? { labelId } : {}
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
let solveCtx = labelCtx(theme, size, options, {
|
|
2206
|
+
measure,
|
|
2207
|
+
plot,
|
|
2208
|
+
labelPad: LABEL_PAD
|
|
2209
|
+
}), solved = solveLabels(labelRequests, occupied, solveCtx);
|
|
2210
|
+
applyValueAxisTitleInk(solved.placed);
|
|
2211
|
+
for (let label of solved.placed) label.id.endsWith(COMPACT_RANGE_SUFFIX) && (label.ink = { token: "inkMuted" });
|
|
2212
|
+
pushAll(warnings, solved.warnings), pushAll(
|
|
2213
|
+
nodes,
|
|
2214
|
+
labelsToNodes(
|
|
2215
|
+
theme,
|
|
2216
|
+
solved.placed,
|
|
2217
|
+
(label) => label.kind === "category" ? tickFont : label.kind === "valueLine" ? strongFont : labelFont,
|
|
2218
|
+
nodes
|
|
2219
|
+
)
|
|
2220
|
+
);
|
|
2221
|
+
let compactRowH = (bar) => cats.map(() => ({ h: compactStep(bar) - (targetSizing ? 4 : 0) })), compactSizing = compactPlan && barSizing(size, rowPlan, band.step, compactRowH(compactMinBar), compactRowH(compactBar), void 0, 0, targetSizing, textScaleOf(options)), fieldStep = mode === "football-field" && targetSizing && !fixedRowsH ? (size.width >= 960 ? 38 : 36) * textScaleOf(options) : 0, columnSizing = compact ? void 0 : barSizing(
|
|
2222
|
+
size,
|
|
2223
|
+
rowPlan,
|
|
2224
|
+
band.step,
|
|
2225
|
+
catLines,
|
|
2226
|
+
naturalCategoryHeights(cats, tickFont, catCap, measure),
|
|
2227
|
+
fixedRowsH,
|
|
2228
|
+
fieldStep,
|
|
2229
|
+
targetSizing,
|
|
2230
|
+
textScaleOf(options),
|
|
2231
|
+
0
|
|
2232
|
+
), fallbackPlan = compact ? planRows(!1, []) : void 0, fallbackFraction = options.bandFraction ?? fallbackPlan?.fixedRow?.fraction ?? 0.56, fallbackSizing = fallbackPlan && barSizing(
|
|
2233
|
+
size,
|
|
2234
|
+
fallbackPlan,
|
|
2235
|
+
bandScale(cats.length, [fallbackPlan.plot.y, fallbackPlan.plot.y + fallbackPlan.plot.h], { paddingInner: 1 - fallbackFraction, paddingOuter: (1 - fallbackFraction) / 2 }).step,
|
|
2236
|
+
fallbackPlan.catLines,
|
|
2237
|
+
naturalCategoryHeights(cats, tickFont, fallbackPlan.catCap, measure),
|
|
2238
|
+
fallbackPlan.fixedRowsH,
|
|
2239
|
+
0,
|
|
2240
|
+
targetSizing,
|
|
2241
|
+
textScaleOf(options)
|
|
2242
|
+
), compactOrFallback = compactSizing && fallbackSizing && fallbackSizing.minHeight < compactSizing.minHeight ? { ...compactSizing, minHeight: fallbackSizing.minHeight, measuredMinHeight: Math.min(compactSizing.measuredMinHeight, fallbackSizing.measuredMinHeight), comfortableHeight: fallbackSizing.comfortableHeight } : compactSizing;
|
|
2243
|
+
return {
|
|
2244
|
+
type: "bar",
|
|
2245
|
+
size,
|
|
2246
|
+
sizing: columnSizing === void 0 ? compactOrFallback : compactSizing ? { ...columnSizing, naturalHeight: Math.max(columnSizing.minHeight, compactSizing.naturalHeight) } : columnSizing,
|
|
2247
|
+
plot,
|
|
2248
|
+
scene: withSegmentSeams(nodes, theme),
|
|
2249
|
+
labels: solved.placed,
|
|
2250
|
+
axes: [
|
|
2251
|
+
{
|
|
2252
|
+
axis: "y",
|
|
2253
|
+
ticks: cats.map((cat, index) => ({
|
|
2254
|
+
at: cat.id,
|
|
2255
|
+
pos: band.center(index),
|
|
2256
|
+
labelId: labelOn2("category") ? `category:${cat.id}` : void 0
|
|
2257
|
+
}))
|
|
2258
|
+
},
|
|
2259
|
+
...axes
|
|
2260
|
+
],
|
|
2261
|
+
annotations,
|
|
2262
|
+
frame: frameResult.frame,
|
|
2263
|
+
// The row-interval engine (tornado, football-field) keeps the legend that
|
|
2264
|
+
// solveFrame returns for `plan.legend`, so `geometry.legend` lists the
|
|
2265
|
+
// swatches the scene paints, the hatch key included. Consumers that index
|
|
2266
|
+
// the legend through the geometry rather than by scanning the scene
|
|
2267
|
+
// (grid's panel-legend collection, the a11y and parity sweeps) read it
|
|
2268
|
+
// there. Twin of the main bar path at the top of this file.
|
|
2269
|
+
legend: frameResult.legend,
|
|
2270
|
+
marks,
|
|
2271
|
+
derived: plan.derived,
|
|
2272
|
+
a11y: {
|
|
2273
|
+
title: accessibleTitle(options.title, plan.a11yTitle),
|
|
2274
|
+
titleCounts: plan.a11yTitleCounts,
|
|
2275
|
+
desc: plan.a11yDesc
|
|
2276
|
+
},
|
|
2277
|
+
warnings,
|
|
2278
|
+
debug: {
|
|
2279
|
+
occupied: occupied.snapshot(),
|
|
2280
|
+
decisions: solved.decisions
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
function planFootballField(data, options, ctx) {
|
|
2285
|
+
let { warnings, labelOn: labelOn2, highlights } = ctx;
|
|
2286
|
+
if (!data || !Array.isArray(data.categories) || data.categories.length === 0)
|
|
2287
|
+
throw new NormalizeError("empty-data", "categories", "football-field requires at least one method");
|
|
2288
|
+
if (!Array.isArray(data.series) || data.series.length === 0)
|
|
2289
|
+
throw new NormalizeError("empty-data", "series", "football-field requires one data series");
|
|
2290
|
+
let cats = data.categories.map((category, index) => normalizeCategory(category, index)), sourceSeries = data.series.filter((series2) => (series2.role ?? "data") === "data");
|
|
2291
|
+
if (sourceSeries.length !== 1)
|
|
2292
|
+
throw new NormalizeError(
|
|
2293
|
+
"football-field-one-series",
|
|
2294
|
+
"series",
|
|
2295
|
+
`football-field requires exactly one data-role series, got ${sourceSeries.length}`
|
|
2296
|
+
);
|
|
2297
|
+
data.series.length !== sourceSeries.length && warnings.push({
|
|
2298
|
+
code: "football-field-reference-ignored",
|
|
2299
|
+
severity: "warn",
|
|
2300
|
+
message: "football-field ignores reference-role series; use currentValue for the vertical comparator",
|
|
2301
|
+
suggest: "remove reference series and set currentValue"
|
|
2302
|
+
}), options.annotations && options.annotations.length > 0 && warnings.push({
|
|
2303
|
+
code: "football-field-annotations-ignored",
|
|
2304
|
+
severity: "warn",
|
|
2305
|
+
message: "football-field does not support annotations; use currentValue for its authored marker"
|
|
2306
|
+
}), options.valueAxis?.break && warnings.push({
|
|
2307
|
+
code: "axis-break-unsupported",
|
|
2308
|
+
severity: "warn",
|
|
2309
|
+
message: "bar variant 'football-field' does not support valueAxis.break; the break was ignored"
|
|
2310
|
+
}), options.legend && warnings.push({
|
|
2311
|
+
code: "football-field-legend-ignored",
|
|
2312
|
+
severity: "warn",
|
|
2313
|
+
message: "football-field directly labels its single range series; the requested legend was ignored",
|
|
2314
|
+
suggest: "remove legend or use the series label in the subtitle/unit"
|
|
2315
|
+
});
|
|
2316
|
+
let series = sourceSeries[0], fmt = ctx.forSeries(series), cells = normalizeSeriesValues(series, cats, 0).map((cell, ci) => {
|
|
2317
|
+
let range = resolveCellRange(
|
|
2318
|
+
cell,
|
|
2319
|
+
`series[${series.id}].values[${ci}]`,
|
|
2320
|
+
warnings,
|
|
2321
|
+
{ seriesId: series.id, categoryId: cats[ci]?.id }
|
|
2322
|
+
);
|
|
2323
|
+
if (!range)
|
|
2324
|
+
throw new NormalizeError(
|
|
2325
|
+
"football-field-range-required",
|
|
2326
|
+
`series[${series.id}].values[${ci}].range`,
|
|
2327
|
+
`football-field method '${cats[ci].id}' requires a range`
|
|
2328
|
+
);
|
|
2329
|
+
return { value: cellValue(cell), meta: cellMeta(cell), range };
|
|
2330
|
+
}), order = cats.map((_, index) => index), sort = options.sort?.categories ?? "sheet";
|
|
2331
|
+
if (sort === "reverse") order.reverse();
|
|
2332
|
+
else if (sort === "asc" || sort === "desc") {
|
|
2333
|
+
let direction = sort === "asc" ? 1 : -1;
|
|
2334
|
+
order.sort((a, b) => {
|
|
2335
|
+
let ar = cells[a].range, br = cells[b].range, av = ar.mid ?? (ar.low + ar.high) / 2, bv = br.mid ?? (br.low + br.high) / 2;
|
|
2336
|
+
return (av - bv) * direction || a - b;
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
cats = order.map((index) => cats[index]), cells = order.map((index) => cells[index]), warnRangeBarIgnoredRanking("football-field", options, warnings), (options.netLine !== void 0 || options.averageMarker !== void 0 || options.connectors !== void 0 || options.grandTotalLabels !== void 0) && warnings.push({
|
|
2340
|
+
code: "football-field-option-ignored",
|
|
2341
|
+
severity: "warn",
|
|
2342
|
+
message: "stack/total connector options do not apply to football-field ranges"
|
|
2343
|
+
});
|
|
2344
|
+
let current = options.currentValue === void 0 ? void 0 : typeof options.currentValue == "number" ? { value: options.currentValue } : options.currentValue;
|
|
2345
|
+
current && !labelOn2("valueLine") && warnings.push({
|
|
2346
|
+
code: "label-hidden",
|
|
2347
|
+
severity: "warn",
|
|
2348
|
+
message: "currentValue label was explicitly suppressed while its authored marker remains visible",
|
|
2349
|
+
owner: { annotationId: "currentValue" },
|
|
2350
|
+
suggest: "enable labels.valueLine so the current-value marker is self-explanatory"
|
|
2351
|
+
});
|
|
2352
|
+
let rangePaint = (meta, highlighted) => {
|
|
2353
|
+
let scenario = meta?.scenario ?? series.scenario, authored = meta?.fill ? { css: meta.fill } : series.fill ? { css: series.fill } : series.colorRole ? markRolePaint(series.colorRole, !0) : highlighted ? { token: "focus" } : void 0, fill = authored ?? seriesPaint(1, options.palette);
|
|
2354
|
+
return scenario === "FC" ? { fill, pattern: "hatch45" } : scenario === "PL" ? { fill: authored ?? { token: "ink" }, pattern: "outline" } : { fill };
|
|
2355
|
+
}, ranges = [], rows = cats.map((cat, ci) => {
|
|
2356
|
+
let cell = cells[ci], owner = { seriesId: series.id, categoryId: cat.id }, nodeId = `footballRange:${series.id}:${cat.id}`, paint = rangePaint(cell.meta, highlights.has(cat.id)), nodeIds = [nodeId], mid;
|
|
2357
|
+
if (cell.range.mid !== void 0 && options.methodNote === !0) {
|
|
2358
|
+
let midId = `range:${series.id}:${cat.id}:mid`;
|
|
2359
|
+
mid = { value: cell.range.mid, id: midId, owner, claimSeriesId: `__range:${series.id}` }, nodeIds.push(midId);
|
|
2360
|
+
}
|
|
2361
|
+
return ranges.push({
|
|
2362
|
+
seriesId: series.id,
|
|
2363
|
+
categoryId: cat.id,
|
|
2364
|
+
low: cell.range.low,
|
|
2365
|
+
high: cell.range.high,
|
|
2366
|
+
...cell.range.mid === void 0 ? {} : { mid: cell.range.mid },
|
|
2367
|
+
nodeIds
|
|
2368
|
+
}), {
|
|
2369
|
+
cat,
|
|
2370
|
+
pieces: [
|
|
2371
|
+
{
|
|
2372
|
+
from: cell.range.low,
|
|
2373
|
+
to: cell.range.high,
|
|
2374
|
+
role: "span",
|
|
2375
|
+
seriesId: series.id,
|
|
2376
|
+
nodeId,
|
|
2377
|
+
part: "footballRange",
|
|
2378
|
+
paint,
|
|
2379
|
+
...cell.value === null ? {} : { display: fmt(cell.value) }
|
|
2380
|
+
}
|
|
2381
|
+
],
|
|
2382
|
+
endpoints: [
|
|
2383
|
+
{ id: `rangeLow:${series.id}:${cat.id}`, owner, value: cell.range.low, side: "low" },
|
|
2384
|
+
{ id: `rangeHigh:${series.id}:${cat.id}`, owner, value: cell.range.high, side: "high" }
|
|
2385
|
+
],
|
|
2386
|
+
...mid ? { mid } : {},
|
|
2387
|
+
leftText: fmt(cell.range.low),
|
|
2388
|
+
rightText: fmt(cell.range.high)
|
|
2389
|
+
};
|
|
2390
|
+
}), totals = Object.fromEntries(
|
|
2391
|
+
// Same rule as the tornado receipt beside it: strip representation noise,
|
|
2392
|
+
// never quantize. round2 here is an absolute 0.005 epsilon on a metric the
|
|
2393
|
+
// author chose the units of — a football field of per-share values in
|
|
2394
|
+
// cents, or of ratios, reports a midpoint that its own low and high do not
|
|
2395
|
+
// reconcile to. No decision reads these: the marks are drawn from the raw
|
|
2396
|
+
// cells, and `mean` below feeds only the receipt (the drawn mean valueLine
|
|
2397
|
+
// uses the unrounded `meanValue` in the grouped path). Shipped values carry
|
|
2398
|
+
// at most two decimals, so this is a no-op on every current fixture and a
|
|
2399
|
+
// correctness fix for the ones that come.
|
|
2400
|
+
cats.map((cat, ci) => [
|
|
2401
|
+
cat.id,
|
|
2402
|
+
cells[ci].value ?? (cells[ci].range.low + cells[ci].range.high) / 2
|
|
2403
|
+
])
|
|
2404
|
+
), mean = cells.reduce(
|
|
2405
|
+
(sum, cell) => sum + (cell.value ?? cell.range.mid ?? (cell.range.low + cell.range.high) / 2),
|
|
2406
|
+
0
|
|
2407
|
+
) / cells.length;
|
|
2408
|
+
return options.methodNote !== !0 && ranges.some((range) => range.mid !== void 0) && warnings.push(rangeMidUndrawn()), {
|
|
2409
|
+
cats,
|
|
2410
|
+
rows,
|
|
2411
|
+
...current ? {
|
|
2412
|
+
spine: {
|
|
2413
|
+
key: "currentValue",
|
|
2414
|
+
value: current.value,
|
|
2415
|
+
text: current.label ?? stringFields(options.strings.currentValue, { value: fmt(current.value) }),
|
|
2416
|
+
computedText: stringFields(options.strings.currentValue, { value: fmt(current.value) })
|
|
2417
|
+
}
|
|
2418
|
+
} : {},
|
|
2419
|
+
ranges,
|
|
2420
|
+
valueFmt: fmt,
|
|
2421
|
+
// A tick inside a range: a method note, printed on request.
|
|
2422
|
+
...options.methodNote === !0 && ranges.some((range) => range.mid !== void 0) ? { methodNotes: [disclosureNote(options.strings.rangeMidNote)] } : {},
|
|
2423
|
+
derived: {
|
|
2424
|
+
totals,
|
|
2425
|
+
order: cats.map((cat) => cat.id),
|
|
2426
|
+
mean: mean
|
|
2427
|
+
},
|
|
2428
|
+
a11yTitleCounts: [structureCount("methods", cats.length, void 0, options)],
|
|
2429
|
+
a11yTitle: chartString2(options, "footballTitle", { v1: cats.length }),
|
|
2430
|
+
a11yDesc: chartString2(options, "footballDesc", { v1: cats.map(
|
|
2431
|
+
(cat, ci) => chartString2(options, "namedRange", { v1: cat.label ?? cat.id, v2: fmt(cells[ci].range.low), v3: fmt(cells[ci].range.high) })
|
|
2432
|
+
).join("; ") }) + (current ? chartString2(options, "currentValueSentence", { v1: fmt(current.value) }) : "")
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
function planTornado(data, options, ctx) {
|
|
2436
|
+
let { warnings, paletteRamp, fmt, labelOn: labelOn2, highlights, theme } = ctx;
|
|
2437
|
+
if (!data || !Array.isArray(data.categories) || data.categories.length === 0)
|
|
2438
|
+
throw new NormalizeError("empty-data", "categories", "tornado requires at least one driver");
|
|
2439
|
+
if (!Array.isArray(data.series) || data.series.length === 0)
|
|
2440
|
+
throw new NormalizeError("empty-data", "series", "tornado requires two case series");
|
|
2441
|
+
let cats = data.categories.map((category, index) => normalizeCategory(category, index)), dataSeries = data.series.filter((series) => (series.role ?? "data") === "data");
|
|
2442
|
+
if (dataSeries.length !== 2)
|
|
2443
|
+
throw new NormalizeError(
|
|
2444
|
+
"tornado-two-series",
|
|
2445
|
+
"series",
|
|
2446
|
+
`tornado requires exactly two data-role series (the low-input case and the high-input case), got ${dataSeries.length}`
|
|
2447
|
+
);
|
|
2448
|
+
if (data.series.length !== dataSeries.length && warnings.push({
|
|
2449
|
+
code: "tornado-reference-ignored",
|
|
2450
|
+
severity: "warn",
|
|
2451
|
+
message: "tornado ignores reference-role series; the base case is the only comparator",
|
|
2452
|
+
suggest: "remove reference series and set options.baseValue"
|
|
2453
|
+
}), options.baseValue === void 0)
|
|
2454
|
+
throw new NormalizeError(
|
|
2455
|
+
"tornado-base-required",
|
|
2456
|
+
"options.baseValue",
|
|
2457
|
+
"tornado requires options.baseValue: the output metric computed with every driver at its base input"
|
|
2458
|
+
);
|
|
2459
|
+
let base = typeof options.baseValue == "number" ? { value: options.baseValue } : options.baseValue;
|
|
2460
|
+
if (!Number.isFinite(base.value))
|
|
2461
|
+
throw new NormalizeError(
|
|
2462
|
+
"tornado-base-required",
|
|
2463
|
+
"options.baseValue",
|
|
2464
|
+
"tornado baseValue must be a finite number in the same units as the case series"
|
|
2465
|
+
);
|
|
2466
|
+
let cases = options.tornado;
|
|
2467
|
+
if (!cases || cases.low === void 0 || cases.high === void 0)
|
|
2468
|
+
throw new NormalizeError(
|
|
2469
|
+
"tornado-cases-required",
|
|
2470
|
+
"options.tornado",
|
|
2471
|
+
"tornado requires options.tornado.low and options.tornado.high naming which series carries which case; case identity cannot be inferred from series order"
|
|
2472
|
+
);
|
|
2473
|
+
if (cases.low === cases.high)
|
|
2474
|
+
throw new NormalizeError(
|
|
2475
|
+
"tornado-cases-identical",
|
|
2476
|
+
"options.tornado",
|
|
2477
|
+
`tornado.low and tornado.high must name different series; both name '${cases.low}'`
|
|
2478
|
+
);
|
|
2479
|
+
let lowSeries = dataSeries.find((series) => series.id === cases.low), highSeries = dataSeries.find((series) => series.id === cases.high);
|
|
2480
|
+
if (!lowSeries)
|
|
2481
|
+
throw new NormalizeError(
|
|
2482
|
+
"tornado-case-unknown",
|
|
2483
|
+
"options.tornado.low",
|
|
2484
|
+
`tornado.low '${cases.low}' is not a data-role series; got ${dataSeries.map((s) => s.id).join(", ")}`
|
|
2485
|
+
);
|
|
2486
|
+
if (!highSeries)
|
|
2487
|
+
throw new NormalizeError(
|
|
2488
|
+
"tornado-case-unknown",
|
|
2489
|
+
"options.tornado.high",
|
|
2490
|
+
`tornado.high '${cases.high}' is not a data-role series; got ${dataSeries.map((s) => s.id).join(", ")}`
|
|
2491
|
+
);
|
|
2492
|
+
options.annotations && options.annotations.length > 0 && warnings.push({
|
|
2493
|
+
code: "tornado-annotations-ignored",
|
|
2494
|
+
severity: "warn",
|
|
2495
|
+
message: "tornado does not support annotations; the base-case spine is its authored marker",
|
|
2496
|
+
suggest: "remove annotations or move the statement into the title"
|
|
2497
|
+
}), options.valueAxis?.break && warnings.push({
|
|
2498
|
+
code: "axis-break-unsupported",
|
|
2499
|
+
severity: "warn",
|
|
2500
|
+
message: "bar variant 'tornado' does not support valueAxis.break; the break was ignored",
|
|
2501
|
+
suggest: "remove valueAxis.break; a broken output axis would misstate every swing width"
|
|
2502
|
+
}), warnRangeBarIgnoredRanking("tornado", options, warnings), (options.netLine !== void 0 || options.averageMarker !== void 0 || options.connectors !== void 0 || options.grandTotalLabels !== void 0) && warnings.push({
|
|
2503
|
+
code: "tornado-option-ignored",
|
|
2504
|
+
severity: "warn",
|
|
2505
|
+
message: "stack/total connector options do not apply to tornado swings",
|
|
2506
|
+
suggest: "remove netLine/averageMarker/connectors/grandTotalLabels; one-at-a-time swings do not sum"
|
|
2507
|
+
}), options.currentValue !== void 0 && warnings.push({
|
|
2508
|
+
code: "tornado-current-value-ignored",
|
|
2509
|
+
severity: "warn",
|
|
2510
|
+
message: "tornado anchors on the base case, not on a current-value comparator; currentValue was ignored",
|
|
2511
|
+
suggest: "use baseValue"
|
|
2512
|
+
});
|
|
2513
|
+
let lowCells = normalizeSeriesValues(lowSeries, cats, 0), highCells = normalizeSeriesValues(highSeries, cats, 1), derivedRows = [], droppedDrivers = [];
|
|
2514
|
+
if (cats.forEach((cat, index) => {
|
|
2515
|
+
let low = cellValue(lowCells[index]), high = cellValue(highCells[index]);
|
|
2516
|
+
if (low === null || high === null) {
|
|
2517
|
+
droppedDrivers.push((cat.label ?? cat.id).replace(/\s+/g, " ")), warnings.push({
|
|
2518
|
+
code: "tornado-row-incomplete",
|
|
2519
|
+
severity: "warn",
|
|
2520
|
+
message: `driver '${cat.label ?? cat.id}' is missing its ${low === null ? "low" : "high"}-case output and was dropped; a one-at-a-time swing needs both cases`,
|
|
2521
|
+
owner: { categoryId: cat.id },
|
|
2522
|
+
suggest: "supply both case outputs for the driver, or remove the driver"
|
|
2523
|
+
});
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2526
|
+
let lo = Math.min(low, high), hi = Math.max(low, high);
|
|
2527
|
+
derivedRows.push({
|
|
2528
|
+
index,
|
|
2529
|
+
cat,
|
|
2530
|
+
low,
|
|
2531
|
+
high,
|
|
2532
|
+
// RAW, and every decision below reads these raw.
|
|
2533
|
+
//
|
|
2534
|
+
// These three were round2'd, and the engine then FORKED on the rounded
|
|
2535
|
+
// number: `if (row.swing === 0)` printed "moves the output by 0" over a
|
|
2536
|
+
// 0.001 bar, `derived.tornado` published swing:0 next to its own raw low
|
|
2537
|
+
// and high, and the order comparator manufactured ties that the tie-break
|
|
2538
|
+
// then resolved on a different quantity — putting a smaller swing above a
|
|
2539
|
+
// larger one. round2's epsilon is 0.005 in whatever unit the numbers
|
|
2540
|
+
// happen to be counted in, so an output metric measured in EPS, ratios,
|
|
2541
|
+
// per-share amounts or percentages sat entirely underneath it.
|
|
2542
|
+
//
|
|
2543
|
+
// ROUND FOR DISPLAY, NEVER FOR DECISION: `fmt` is applied where the
|
|
2544
|
+
// number is printed, `cleanFloat` where it is serialised, and neither is
|
|
2545
|
+
// in the path of a threshold, a fork, a flag or an ordering.
|
|
2546
|
+
swing: hi - lo,
|
|
2547
|
+
down: lo - base.value,
|
|
2548
|
+
up: hi - base.value,
|
|
2549
|
+
// The fact `range` would have destroyed: the HIGH input produced the
|
|
2550
|
+
// LOWER output.
|
|
2551
|
+
inverse: high < low,
|
|
2552
|
+
straddles: lo <= base.value && base.value <= hi
|
|
2553
|
+
});
|
|
2554
|
+
}), derivedRows.length === 0)
|
|
2555
|
+
throw new NormalizeError(
|
|
2556
|
+
"empty-data",
|
|
2557
|
+
"series",
|
|
2558
|
+
"every tornado driver was dropped for a missing case output; nothing is left to plot"
|
|
2559
|
+
);
|
|
2560
|
+
let ordered = [...derivedRows].sort((a, b) => {
|
|
2561
|
+
if (b.swing !== a.swing) return b.swing - a.swing;
|
|
2562
|
+
let aFar = Math.max(Math.abs(a.low - base.value), Math.abs(a.high - base.value)), bFar = Math.max(Math.abs(b.low - base.value), Math.abs(b.high - base.value));
|
|
2563
|
+
return bFar !== aFar ? bFar - aFar : a.index - b.index;
|
|
2564
|
+
}), ties = [];
|
|
2565
|
+
for (let start = 0; start < ordered.length; ) {
|
|
2566
|
+
let end = start + 1;
|
|
2567
|
+
for (; end < ordered.length && formatDifference(fmt, ordered[end].swing) === formatDifference(fmt, ordered[start].swing); )
|
|
2568
|
+
end += 1;
|
|
2569
|
+
if (end - start >= 2) {
|
|
2570
|
+
let members = ordered.slice(start, end);
|
|
2571
|
+
ties.push({ rank: start + 1, categoryIds: members.map((row) => row.cat.id) }), warnings.push({
|
|
2572
|
+
code: "tornado-swing-tie",
|
|
2573
|
+
// INFO, not warn, and the distinction is load-bearing. `bump-rank-tie`
|
|
2574
|
+
// is a warn because there the entities genuinely SHARE a rank and one
|
|
2575
|
+
// is drawn on top of another. Here the ranking is correct and the bars
|
|
2576
|
+
// are faithful — what the reader cannot do is read the margin off the
|
|
2577
|
+
// page. That is a disclosure about printed precision, the same class as
|
|
2578
|
+
// `likert-rounding-drift`, and it must not scold an exhibit whose only
|
|
2579
|
+
// fault is that two of its drivers are genuinely close.
|
|
2580
|
+
severity: "info",
|
|
2581
|
+
message: `${members.map((row) => `'${row.cat.label ?? row.cat.id}'`).join(", ")} all print swing ${formatDifference(fmt, members[0].swing)}, so the printed numbers do not say why they are ranked ${start + 1} to ${end} in that order; the bars are drawn at their exact swings and the order follows those`,
|
|
2582
|
+
suggest: "raise the printed precision with options.format so the exhibit shows the difference its ranking rests on"
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
start = end;
|
|
2586
|
+
}
|
|
2587
|
+
let sort = options.sort?.categories ?? "sheet";
|
|
2588
|
+
sort === "reverse" ? ordered.reverse() : (sort === "asc" || sort === "desc") && warnings.push({
|
|
2589
|
+
code: "tornado-sort-ignored",
|
|
2590
|
+
severity: "warn",
|
|
2591
|
+
message: `sort.categories '${sort}' is ambiguous on a tornado (ascending in low case, high case or swing?); rows keep swing order`,
|
|
2592
|
+
suggest: "use sort.categories 'reverse' to put the smallest swing at the top"
|
|
2593
|
+
});
|
|
2594
|
+
let casePaint = (role) => {
|
|
2595
|
+
let series = role === "low" ? lowSeries : highSeries;
|
|
2596
|
+
return series.fill ? { fill: { css: series.fill } } : series.colorRole ? { fill: markRolePaint(series.colorRole, !0) } : paletteRamp ? {
|
|
2597
|
+
fill: role === "low" ? seriesPaint(0, options.palette, "PY", !0, !0) : seriesPaint(0, options.palette)
|
|
2598
|
+
} : role === "low" && !theme.color.casePair ? { fill: { token: "case-2", theme: { kind: "visible-tint", base: { token: "case-2" }, amount: 0.6, floor: 2 } } } : { fill: { token: role === "low" ? "case-1" : "case-2" } };
|
|
2599
|
+
}, detachedPaint = (role) => ({
|
|
2600
|
+
...casePaint(role),
|
|
2601
|
+
pattern: "hatch45"
|
|
2602
|
+
}), caseSeriesId = (role) => role === "low" ? lowSeries.id : highSeries.id, caseValue = (row, role) => role === "low" ? row.low : row.high, rows = ordered.map((row) => {
|
|
2603
|
+
let cat = row.cat, lo = Math.min(row.low, row.high), hi = Math.max(row.low, row.high), piece = (role, from, to, geo) => ({
|
|
2604
|
+
from,
|
|
2605
|
+
to,
|
|
2606
|
+
role: geo,
|
|
2607
|
+
seriesId: caseSeriesId(role),
|
|
2608
|
+
nodeId: `tornadoPiece:${caseSeriesId(role)}:${cat.id}`,
|
|
2609
|
+
part: "tornadoPiece",
|
|
2610
|
+
// EMPHASIS MUST NOT OVERWRITE A CHANNEL THAT IS CARRYING MEANING.
|
|
2611
|
+
//
|
|
2612
|
+
// A `highlight` fill on BOTH pieces would destroy the case identity of
|
|
2613
|
+
// the one row the author chose to emphasise, while the legend this
|
|
2614
|
+
// variant makes MANDATORY still says the two tones are the low case and
|
|
2615
|
+
// the high case. On a highlighted inverse driver that erases the headline
|
|
2616
|
+
// insight itself.
|
|
2617
|
+
//
|
|
2618
|
+
// The bar engine already draws this line: :1769 only lets `highlight`
|
|
2619
|
+
// take the fill when `dataSeries.length === 1`, i.e. when no series
|
|
2620
|
+
// identity is at stake. A tornado always has two NAMED case series, so
|
|
2621
|
+
// emphasis rides a channel the legend does not use — a highlight ring
|
|
2622
|
+
// around both pieces of the row, case tones intact.
|
|
2623
|
+
paint: highlights.has(cat.id) ? { ...casePaint(role), stroke: { token: "focus" }, strokeWidth: strokeToken(ctx.theme, "mark") } : casePaint(role),
|
|
2624
|
+
display: fmt(caseValue(row, role))
|
|
2625
|
+
}), pieces;
|
|
2626
|
+
if (row.swing === 0)
|
|
2627
|
+
warnings.push({
|
|
2628
|
+
code: "tornado-zero-swing",
|
|
2629
|
+
severity: "info",
|
|
2630
|
+
message: `driver '${cat.label ?? cat.id}' moves the output by 0 between its low and high case`,
|
|
2631
|
+
owner: { categoryId: cat.id }
|
|
2632
|
+
}), pieces = [piece("high", row.low, row.high, "span")];
|
|
2633
|
+
else if (row.straddles)
|
|
2634
|
+
pieces = [
|
|
2635
|
+
piece("low", base.value, row.low, "low"),
|
|
2636
|
+
piece("high", base.value, row.high, "high")
|
|
2637
|
+
];
|
|
2638
|
+
else {
|
|
2639
|
+
let farRole = Math.abs(row.low - base.value) > Math.abs(row.high - base.value) ? "low" : "high";
|
|
2640
|
+
pieces = [{ ...piece(farRole, lo, hi, "span"), paint: detachedPaint(farRole) }];
|
|
2641
|
+
}
|
|
2642
|
+
if (!row.straddles) {
|
|
2643
|
+
let collapsed = fmt(lo) === fmt(hi) || fmt(lo) === fmt(base.value) || fmt(hi) === fmt(base.value), say = (v) => collapsed ? String(v) : fmt(v);
|
|
2644
|
+
warnings.push({
|
|
2645
|
+
code: "tornado-base-outside-swing",
|
|
2646
|
+
severity: "warn",
|
|
2647
|
+
message: `driver '${cat.label ?? cat.id}' spans ${say(lo)} to ${say(hi)}, which does not contain the base case ${say(base.value)}; the bar is drawn detached from the spine`,
|
|
2648
|
+
owner: { categoryId: cat.id },
|
|
2649
|
+
suggest: "the base case should be reproduced by base inputs \u2014 check the model"
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
let endpoints = row.swing === 0 ? [
|
|
2653
|
+
{
|
|
2654
|
+
// Both cases land on the same number; printing it twice at one
|
|
2655
|
+
// point would guarantee a collision and a bogus label-hidden.
|
|
2656
|
+
id: `tornadoCase:${cat.id}`,
|
|
2657
|
+
owner: { seriesId: highSeries.id, categoryId: cat.id },
|
|
2658
|
+
value: row.high,
|
|
2659
|
+
side: "high"
|
|
2660
|
+
}
|
|
2661
|
+
] : [
|
|
2662
|
+
{
|
|
2663
|
+
id: `tornadoLow:${lowSeries.id}:${cat.id}`,
|
|
2664
|
+
owner: { seriesId: lowSeries.id, categoryId: cat.id },
|
|
2665
|
+
value: row.low,
|
|
2666
|
+
side: row.low < row.high ? "low" : "high"
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
id: `tornadoHigh:${highSeries.id}:${cat.id}`,
|
|
2670
|
+
owner: { seriesId: highSeries.id, categoryId: cat.id },
|
|
2671
|
+
value: row.high,
|
|
2672
|
+
side: row.high > row.low ? "high" : "low"
|
|
2673
|
+
}
|
|
2674
|
+
];
|
|
2675
|
+
return {
|
|
2676
|
+
cat,
|
|
2677
|
+
pieces,
|
|
2678
|
+
endpoints,
|
|
2679
|
+
leftText: fmt(lo),
|
|
2680
|
+
rightText: fmt(hi)
|
|
2681
|
+
};
|
|
2682
|
+
}), legendOption = options.legend, legend;
|
|
2683
|
+
legendOption === "none" ? warnings.push({
|
|
2684
|
+
code: "tornado-legend-suppressed",
|
|
2685
|
+
severity: "warn",
|
|
2686
|
+
message: "tornado legend suppressed: nothing on the exhibit then says which tone is the low-input case",
|
|
2687
|
+
suggest: "drop legend: 'none', or set legend to 'top' or 'bottom'"
|
|
2688
|
+
}) : legend = {
|
|
2689
|
+
options: normalizeLegendOption(legendOption, { position: "top" }),
|
|
2690
|
+
items: [
|
|
2691
|
+
{ id: lowSeries.id, label: lowSeries.label ?? lowSeries.id, paint: casePaint("low").fill },
|
|
2692
|
+
{ id: highSeries.id, label: highSeries.label ?? highSeries.id, paint: casePaint("high").fill },
|
|
2693
|
+
// The hatch is a mark on the canvas, so it gets a key. Without this the
|
|
2694
|
+
// legend would enumerate two solid tones for an exhibit that also draws
|
|
2695
|
+
// a third treatment — the legend describing a chart it does not cover.
|
|
2696
|
+
...ordered.some((row) => !row.straddles) ? [
|
|
2697
|
+
{
|
|
2698
|
+
id: "__tornadoDetached",
|
|
2699
|
+
label: options.strings.swingOutsideBase,
|
|
2700
|
+
paint: casePaint("high").fill,
|
|
2701
|
+
pattern: "hatch45"
|
|
2702
|
+
}
|
|
2703
|
+
] : [],
|
|
2704
|
+
// A driver with no swing draws no row; when its disclosure does not print, the key names it.
|
|
2705
|
+
...droppedDrivers.length > 0 && !disclosuresShown(options) ? [omittedKey("__tornadoDropped", stringFields(options.strings.missingSwingNote, { drivers: droppedDrivers.join(", ") }))] : []
|
|
2706
|
+
]
|
|
2707
|
+
}, labelOn2("valueLine") || warnings.push({
|
|
2708
|
+
code: "label-hidden",
|
|
2709
|
+
severity: "warn",
|
|
2710
|
+
message: "baseValue label was explicitly suppressed while its authored spine remains visible",
|
|
2711
|
+
owner: { annotationId: "baseValue" },
|
|
2712
|
+
suggest: "enable labels.valueLine so the base-case spine is self-explanatory"
|
|
2713
|
+
});
|
|
2714
|
+
let lowCaseLabel = lowSeries.label ?? lowSeries.id, highCaseLabel = highSeries.label ?? highSeries.id, inverseCount = ordered.filter((row) => row.inverse).length, spineComputedText = stringFields(options.strings.baseCase, { value: fmt(base.value) });
|
|
2715
|
+
if (base.label !== void 0 && base.label !== spineComputedText) {
|
|
2716
|
+
let engineNumber = fmt(base.value), statesANumber = /\d/.test(base.label), quotesTheEngineNumber = new RegExp(
|
|
2717
|
+
`(^|[^\\d.,])${engineNumber.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([^\\d.,]|$)`
|
|
2718
|
+
).test(base.label);
|
|
2719
|
+
statesANumber && !quotesTheEngineNumber && warnings.push({
|
|
2720
|
+
code: "tornado-base-label-mismatch",
|
|
2721
|
+
severity: "warn",
|
|
2722
|
+
message: `the spine is drawn at ${engineNumber} but its authored label reads '${base.label}'; every bar on this exhibit is measured from ${engineNumber}, so the printed base contradicts every swing on the page`,
|
|
2723
|
+
owner: { annotationId: "baseValue" },
|
|
2724
|
+
suggest: "omit baseValue.label and let the engine print the number it draws, or correct baseValue.value"
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
return {
|
|
2728
|
+
cats: ordered.map((row) => row.cat),
|
|
2729
|
+
rows,
|
|
2730
|
+
spine: {
|
|
2731
|
+
key: "baseValue",
|
|
2732
|
+
value: base.value,
|
|
2733
|
+
text: base.label ?? spineComputedText,
|
|
2734
|
+
computedText: spineComputedText
|
|
2735
|
+
},
|
|
2736
|
+
...legend ? { legend } : {},
|
|
2737
|
+
methodNotes: [
|
|
2738
|
+
...options.methodNote === !0 ? [options.strings.sensitivityNote] : [],
|
|
2739
|
+
...ordered.some((row) => !row.straddles) ? [disclosureNote(options.strings.hatchedBaseNote)] : [],
|
|
2740
|
+
...droppedDrivers.length > 0 ? [
|
|
2741
|
+
disclosureNote(stringFields(options.strings.missingSwingNote, { drivers: droppedDrivers.join(", ") }))
|
|
2742
|
+
] : []
|
|
2743
|
+
],
|
|
2744
|
+
derived: {
|
|
2745
|
+
// `totals` on a tornado is the row's swing — the magnitude the row
|
|
2746
|
+
// encodes. There is no total: OAT swings do not sum.
|
|
2747
|
+
//
|
|
2748
|
+
// Every number below is the RAW derivation, carried through `cleanFloat`
|
|
2749
|
+
// only to drop IEEE754 representation noise on the way into the receipt.
|
|
2750
|
+
// The swing is as raw as `low` and `high` beside it, so the receipt never
|
|
2751
|
+
// contradicts itself (swing:0 next to low 2.452, high 2.453) and stays
|
|
2752
|
+
// auditable.
|
|
2753
|
+
totals: Object.fromEntries(ordered.map((row) => [row.cat.id, row.swing])),
|
|
2754
|
+
order: ordered.map((row) => row.cat.id),
|
|
2755
|
+
mean: ordered.reduce((sum, row) => sum + row.swing, 0) / ordered.length,
|
|
2756
|
+
tornado: {
|
|
2757
|
+
baseValue: base.value,
|
|
2758
|
+
method: "one-at-a-time",
|
|
2759
|
+
// The rank groups the exhibit cannot visibly justify, named.
|
|
2760
|
+
ties,
|
|
2761
|
+
rows: ordered.map((row) => ({
|
|
2762
|
+
id: row.cat.id,
|
|
2763
|
+
low: row.low,
|
|
2764
|
+
high: row.high,
|
|
2765
|
+
swing: row.swing,
|
|
2766
|
+
down: row.down,
|
|
2767
|
+
up: row.up,
|
|
2768
|
+
inverse: row.inverse,
|
|
2769
|
+
straddles: row.straddles
|
|
2770
|
+
}))
|
|
2771
|
+
}
|
|
2772
|
+
},
|
|
2773
|
+
a11yTitleCounts: [structureCount("drivers", ordered.length, void 0, options)],
|
|
2774
|
+
a11yTitle: chartString2(options, "tornadoTitle", { v1: ordered.length }),
|
|
2775
|
+
a11yDesc: chartString2(options, "tornadoDescStart") + chartString2(options, "tornadoDescEffects") + chartString2(options, "tornadoBaseDesc", { v1: fmt(base.value) }) + ordered.map(
|
|
2776
|
+
(row) => (
|
|
2777
|
+
// Driver labels may carry an authored line break for the input
|
|
2778
|
+
// range echo; spoken text takes it as a space.
|
|
2779
|
+
// The two case outputs are LEVELS and keep the level format; the
|
|
2780
|
+
// swing is a DIFFERENCE, so on a percent metric it is spoken in
|
|
2781
|
+
// percentage points. "swing 9.0%" off a gross-margin tornado reads
|
|
2782
|
+
// as a 9% relative move and means 9pp — two different numbers.
|
|
2783
|
+
chartString2(options, "tornadoDriverDesc", { v1: (row.cat.label ?? row.cat.id).replace(/\s+/g, " "), v2: lowCaseLabel, v3: fmt(row.low), v4: highCaseLabel, v5: fmt(row.high), v6: formatDifference(fmt, row.swing), v7: row.inverse ? chartString2(options, "inverseClause") : "", v8: row.straddles ? "" : chartString2(options, "baseOutsideClause") })
|
|
2784
|
+
)
|
|
2785
|
+
).join("; ") + "." + (inverseCount > 0 ? chartString2(options, "inverseDriversDesc", { v1: inverseCount, v2: ordered.length }) : "") + // A driver dropped for a missing case output vanished from the canvas AND
|
|
2786
|
+
// from the spoken text; a reader handed either could not know it existed.
|
|
2787
|
+
// The row itself cannot be drawn — there is no interval — but its absence
|
|
2788
|
+
// is now stated, which is the repo's n.m. convention on the one channel
|
|
2789
|
+
// that can carry it.
|
|
2790
|
+
(droppedDrivers.length > 0 ? chartString2(options, "missingDriversDesc", { v1: droppedDrivers.length, v2: droppedDrivers.length === 1 ? "" : "s", v3: droppedDrivers.join(", "), v4: droppedDrivers.length === 1 ? "is" : "are", v5: droppedDrivers.length === 1 ? "one is" : "at least one is" }) : "")
|
|
2791
|
+
};
|
|
2792
|
+
}
|
|
2793
|
+
function formatDifference(fmt, v) {
|
|
2794
|
+
let level = fmt(v);
|
|
2795
|
+
return level.endsWith("%") ? `${level.slice(0, -1)} percentage points` : level;
|
|
2796
|
+
}
|
|
2797
|
+
function naturalCategoryHeights(cats, font, width, measure) {
|
|
2798
|
+
return cats.map((cat) => {
|
|
2799
|
+
let lines = wrapText(cat.label ?? cat.id, font, width, CAT_MAX_LINES, measure).lines.length;
|
|
2800
|
+
return { h: lines * font.size * 1.2 + (lines > 2 ? 4 : 0) };
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
export {
|
|
2805
|
+
layoutBar
|
|
2806
|
+
};
|