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,3650 @@
|
|
|
1
|
+
import {
|
|
2
|
+
glyphFallbackFamily,
|
|
3
|
+
hasArrowFallback,
|
|
4
|
+
installedFamilies,
|
|
5
|
+
loadResvg,
|
|
6
|
+
rasterFamily,
|
|
7
|
+
rasterizeWithResvg
|
|
8
|
+
} from "./chunk-DRTA6JG5.js";
|
|
9
|
+
import {
|
|
10
|
+
crc32,
|
|
11
|
+
withPhysicalSize
|
|
12
|
+
} from "./chunk-2WNYRWHG.js";
|
|
13
|
+
import {
|
|
14
|
+
themeFieldReference
|
|
15
|
+
} from "./chunk-MQFCG4KS.js";
|
|
16
|
+
import {
|
|
17
|
+
createMetricTablesMeasurer,
|
|
18
|
+
measurableFamilies
|
|
19
|
+
} from "./chunk-C54QLNE4.js";
|
|
20
|
+
import {
|
|
21
|
+
parseFontMetricTables
|
|
22
|
+
} from "./chunk-TA3TFKYZ.js";
|
|
23
|
+
import {
|
|
24
|
+
getFixtures
|
|
25
|
+
} from "./chunk-NOSDEJ3K.js";
|
|
26
|
+
import {
|
|
27
|
+
gridFormOf
|
|
28
|
+
} from "./chunk-FV3VF36K.js";
|
|
29
|
+
import {
|
|
30
|
+
spaceDocLints
|
|
31
|
+
} from "./chunk-P5RNWMZC.js";
|
|
32
|
+
import {
|
|
33
|
+
comboDrawsSecondaryAxis
|
|
34
|
+
} from "./chunk-DDCB7ZA5.js";
|
|
35
|
+
import {
|
|
36
|
+
lineLabelModes
|
|
37
|
+
} from "./chunk-2ND7ZITT.js";
|
|
38
|
+
import {
|
|
39
|
+
resolveSharedScale
|
|
40
|
+
} from "./chunk-CCCEBIUZ.js";
|
|
41
|
+
import {
|
|
42
|
+
getTilePack
|
|
43
|
+
} from "./chunk-QHRE2M6V.js";
|
|
44
|
+
import {
|
|
45
|
+
BARE_CHART_NAME,
|
|
46
|
+
DocumentSchemaError,
|
|
47
|
+
NAME_RULE,
|
|
48
|
+
adoptThemeObject,
|
|
49
|
+
bareFinding,
|
|
50
|
+
canonicalJson,
|
|
51
|
+
isThemeObject,
|
|
52
|
+
parseDocumentInput,
|
|
53
|
+
rootContextErrors
|
|
54
|
+
} from "./chunk-DYS7EIXY.js";
|
|
55
|
+
import {
|
|
56
|
+
completeChartDiagnostic,
|
|
57
|
+
completeDiagnostic,
|
|
58
|
+
completeDocumentDiagnostic,
|
|
59
|
+
gridPanelOptionTargets,
|
|
60
|
+
unsupportedSuggestion,
|
|
61
|
+
validateChartInput
|
|
62
|
+
} from "./chunk-CYOJZ3GQ.js";
|
|
63
|
+
import {
|
|
64
|
+
baseOptionsSchema,
|
|
65
|
+
renderTargetSchema
|
|
66
|
+
} from "./chunk-2V6CLH33.js";
|
|
67
|
+
import {
|
|
68
|
+
InputError,
|
|
69
|
+
adaptRows,
|
|
70
|
+
assertSpecObject,
|
|
71
|
+
rewriteRowsDiagnostics
|
|
72
|
+
} from "./chunk-DAVHGK27.js";
|
|
73
|
+
import {
|
|
74
|
+
isBareChart
|
|
75
|
+
} from "./chunk-YWP7XFKD.js";
|
|
76
|
+
import {
|
|
77
|
+
CLAIM_KIND_GROUPS,
|
|
78
|
+
claimsForChart
|
|
79
|
+
} from "./chunk-OURX73UJ.js";
|
|
80
|
+
import {
|
|
81
|
+
interactionRecords,
|
|
82
|
+
interactionValueText
|
|
83
|
+
} from "./chunk-D7SHZDA3.js";
|
|
84
|
+
import {
|
|
85
|
+
layoutResolvedRequest,
|
|
86
|
+
measureLayout,
|
|
87
|
+
resolveChartRequest
|
|
88
|
+
} from "./chunk-4RRNJLCM.js";
|
|
89
|
+
import {
|
|
90
|
+
ownedDocumentCopy
|
|
91
|
+
} from "./chunk-BW5VLBSZ.js";
|
|
92
|
+
import {
|
|
93
|
+
statedInPercent
|
|
94
|
+
} from "./chunk-6KWIQ5KF.js";
|
|
95
|
+
import {
|
|
96
|
+
STRUCTURE_COUNT_KINDS
|
|
97
|
+
} from "./chunk-LFX7W4B7.js";
|
|
98
|
+
import {
|
|
99
|
+
WORDING_KEYS
|
|
100
|
+
} from "./chunk-XB4KZ6WO.js";
|
|
101
|
+
import {
|
|
102
|
+
asRecord,
|
|
103
|
+
categoriesOf,
|
|
104
|
+
cellNumber,
|
|
105
|
+
cellsOfSeries,
|
|
106
|
+
chartOptions,
|
|
107
|
+
formatValuePairs,
|
|
108
|
+
hasAuthoredFootnote,
|
|
109
|
+
hasFormatOrUnit,
|
|
110
|
+
isRecord,
|
|
111
|
+
labelOf,
|
|
112
|
+
legendEnabled,
|
|
113
|
+
numericDataValues,
|
|
114
|
+
records,
|
|
115
|
+
scenarioCodes,
|
|
116
|
+
seriesOf,
|
|
117
|
+
warning
|
|
118
|
+
} from "./chunk-MCYM3RNF.js";
|
|
119
|
+
import {
|
|
120
|
+
VERIFY_ADVICE,
|
|
121
|
+
canonicalChartType,
|
|
122
|
+
contentSized,
|
|
123
|
+
getChart,
|
|
124
|
+
getChartDefinition,
|
|
125
|
+
getChartSchemas,
|
|
126
|
+
heightOmitted,
|
|
127
|
+
listCharts,
|
|
128
|
+
requireGeometry,
|
|
129
|
+
typeDocLints,
|
|
130
|
+
unsupported,
|
|
131
|
+
verifiedSizeRepair
|
|
132
|
+
} from "./chunk-RL3NUWMY.js";
|
|
133
|
+
import {
|
|
134
|
+
ANNOTATION_KIND_PURPOSES,
|
|
135
|
+
ASPECT_CAPS,
|
|
136
|
+
ASPECT_LADDER,
|
|
137
|
+
LADDER_TOLERANCE,
|
|
138
|
+
XmlCharError,
|
|
139
|
+
aspectClassFor,
|
|
140
|
+
cutLabels,
|
|
141
|
+
dataOrder,
|
|
142
|
+
keepsUnnamedSeriesKey,
|
|
143
|
+
labelOmissions,
|
|
144
|
+
ladderHeights,
|
|
145
|
+
nameIsDrawn,
|
|
146
|
+
nearestLadderStep,
|
|
147
|
+
needsSeriesKey,
|
|
148
|
+
omissionScope,
|
|
149
|
+
onLadderStep,
|
|
150
|
+
readableLabelDestination,
|
|
151
|
+
renderSvg,
|
|
152
|
+
scatterGroupIdentities,
|
|
153
|
+
scatterGroupNameIsDrawn,
|
|
154
|
+
sceneThemeBindings,
|
|
155
|
+
shareUnitLints,
|
|
156
|
+
textNames,
|
|
157
|
+
unitInFormatLints,
|
|
158
|
+
unitNotShownLints
|
|
159
|
+
} from "./chunk-SS42FJVN.js";
|
|
160
|
+
import {
|
|
161
|
+
chartNotes
|
|
162
|
+
} from "./chunk-BPKXEMRE.js";
|
|
163
|
+
import {
|
|
164
|
+
ENGINE_REV,
|
|
165
|
+
version
|
|
166
|
+
} from "./chunk-X6SUFTD7.js";
|
|
167
|
+
import {
|
|
168
|
+
chartRefusals
|
|
169
|
+
} from "./chunk-DCCJRLAJ.js";
|
|
170
|
+
import {
|
|
171
|
+
formatExampleProblem,
|
|
172
|
+
parseFormatExample,
|
|
173
|
+
unscaledFormatLint
|
|
174
|
+
} from "./chunk-RGZGLKFB.js";
|
|
175
|
+
import {
|
|
176
|
+
resolveTheme,
|
|
177
|
+
resolvedPaintToken,
|
|
178
|
+
seriesColorIndex,
|
|
179
|
+
themes
|
|
180
|
+
} from "./chunk-CWDHCSL2.js";
|
|
181
|
+
import {
|
|
182
|
+
validateTheme
|
|
183
|
+
} from "./chunk-HA4IPWMM.js";
|
|
184
|
+
import {
|
|
185
|
+
patchApplies,
|
|
186
|
+
readJsonPointer,
|
|
187
|
+
toJsonPointer
|
|
188
|
+
} from "./chunk-ZQ4VFQID.js";
|
|
189
|
+
import {
|
|
190
|
+
DEFAULT_TARGET,
|
|
191
|
+
normalizeCategory,
|
|
192
|
+
normalizeSeriesValues,
|
|
193
|
+
resolveSize,
|
|
194
|
+
toLayoutPx
|
|
195
|
+
} from "./chunk-SGD3ZHID.js";
|
|
196
|
+
import {
|
|
197
|
+
maxOf,
|
|
198
|
+
minOf,
|
|
199
|
+
pushAll
|
|
200
|
+
} from "./chunk-WYJEOMNY.js";
|
|
201
|
+
import {
|
|
202
|
+
compareText
|
|
203
|
+
} from "./chunk-AG2CJ4JY.js";
|
|
204
|
+
import {
|
|
205
|
+
familiesOf,
|
|
206
|
+
resolveFace
|
|
207
|
+
} from "./chunk-QZAT46PP.js";
|
|
208
|
+
|
|
209
|
+
// src/cli/result.ts
|
|
210
|
+
var MAX_ERRORS = 10;
|
|
211
|
+
var ToolFailure = class extends Error {
|
|
212
|
+
constructor(code, message, details) {
|
|
213
|
+
super(message);
|
|
214
|
+
this.code = code;
|
|
215
|
+
this.details = details;
|
|
216
|
+
this.name = "ToolFailure";
|
|
217
|
+
}
|
|
218
|
+
code;
|
|
219
|
+
details;
|
|
220
|
+
};
|
|
221
|
+
function finalizeErrors(errors) {
|
|
222
|
+
let sorted = errors.map((error, index) => ({ error, index })).sort((left, right) => {
|
|
223
|
+
let a = left.error.path ?? "", b = right.error.path ?? "";
|
|
224
|
+
return a < b ? -1 : a > b ? 1 : left.index - right.index;
|
|
225
|
+
}).map(({ error }) => error);
|
|
226
|
+
if (sorted.length <= MAX_ERRORS) return sorted;
|
|
227
|
+
let rest = sorted.length - MAX_ERRORS;
|
|
228
|
+
return [...sorted.slice(0, MAX_ERRORS), { code: "more-errors", message: `${rest} more; fix the above first` }];
|
|
229
|
+
}
|
|
230
|
+
function ok(body, images) {
|
|
231
|
+
return { exit: 0, body: { ok: !0, ...body, engineRev: ENGINE_REV }, ...images?.length ? { images } : {} };
|
|
232
|
+
}
|
|
233
|
+
function rejected(errors, warnings = []) {
|
|
234
|
+
return { exit: 1, body: { ok: !1, errors: finalizeErrors(errors), warnings: [...warnings], engineRev: ENGINE_REV } };
|
|
235
|
+
}
|
|
236
|
+
function rejectedInput(error, input) {
|
|
237
|
+
let suggest = error.details.suggest;
|
|
238
|
+
return rejected([completeDiagnostic({
|
|
239
|
+
code: error.code,
|
|
240
|
+
message: error.message,
|
|
241
|
+
...error.details,
|
|
242
|
+
...suggest ? { suggest } : {}
|
|
243
|
+
}, input, [], error.details.docs ?? "docs/manual.md#the-spec")]);
|
|
244
|
+
}
|
|
245
|
+
function internalError(error) {
|
|
246
|
+
let raw = error instanceof Error ? error.message : String(error);
|
|
247
|
+
return {
|
|
248
|
+
exit: 2,
|
|
249
|
+
body: { ok: !1, errors: [{ code: "internal-error", message: error instanceof TypeError && /read only property/.test(raw) ? `the JavaScript environment defines a conflicting non-removable property on Object.prototype and processing cannot proceed (${raw}); run the CLI in a clean Node process` : raw, path: "" }], warnings: [], engineRev: ENGINE_REV }
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function runVerb(work) {
|
|
253
|
+
try {
|
|
254
|
+
return work();
|
|
255
|
+
} catch (error) {
|
|
256
|
+
return error instanceof InputError ? rejectedInput(error) : error instanceof ToolFailure ? {
|
|
257
|
+
exit: 2,
|
|
258
|
+
body: { ok: !1, errors: [{ code: error.code, message: error.message, ...error.details }], warnings: [], engineRev: ENGINE_REV }
|
|
259
|
+
} : internalError(error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/cli/activeFontTables.ts
|
|
264
|
+
import { readFileSync, statSync } from "fs";
|
|
265
|
+
import { resolve } from "path";
|
|
266
|
+
var FONT_TABLES_ENV = "BOARDPLOT_FONT_TABLES", loaded = /* @__PURE__ */ new Map(), scoped;
|
|
267
|
+
function loadFontTables(path, source) {
|
|
268
|
+
let file = resolve(path), key, raw;
|
|
269
|
+
try {
|
|
270
|
+
let stat = statSync(file);
|
|
271
|
+
key = `${file}|${stat.mtimeMs}|${stat.size}`;
|
|
272
|
+
let cached = loaded.get(key);
|
|
273
|
+
if (cached) return cached;
|
|
274
|
+
raw = readFileSync(file, "utf8");
|
|
275
|
+
} catch (error) {
|
|
276
|
+
throw new InputError("font-tables-unreadable", `cannot read the font tables file ${path} (${source}): ${error instanceof Error ? error.message : error}`, {
|
|
277
|
+
suggest: "Pass the file that `boardplot fonts build <font-dir> -o <file>` wrote.",
|
|
278
|
+
docs: "docs/FONTS.md"
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
let tables;
|
|
282
|
+
try {
|
|
283
|
+
tables = parseFontMetricTables(JSON.parse(raw.replace(/^/, "")));
|
|
284
|
+
} catch (error) {
|
|
285
|
+
throw new InputError("invalid-font-tables", `${path} (${source}) is not a font tables file: ${error instanceof Error ? error.message : error}`, {
|
|
286
|
+
suggest: "Build the file with `boardplot fonts build <font-dir> -o <file>`.",
|
|
287
|
+
docs: "docs/FONTS.md"
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
let families = measurableFamilies(tables);
|
|
291
|
+
if (families.length === 0)
|
|
292
|
+
throw new InputError("invalid-font-tables", `${path} (${source}) has no normal face, so it cannot measure any text`, {
|
|
293
|
+
suggest: "Build the tables from a directory that holds the regular and bold font files.",
|
|
294
|
+
docs: "docs/FONTS.md"
|
|
295
|
+
});
|
|
296
|
+
let active = {
|
|
297
|
+
file,
|
|
298
|
+
families,
|
|
299
|
+
faces: tables.faces.length,
|
|
300
|
+
measure: createMetricTablesMeasurer(tables, { bundledFallback: !0 })
|
|
301
|
+
};
|
|
302
|
+
return loaded.clear(), loaded.set(key, active), active;
|
|
303
|
+
}
|
|
304
|
+
function requestedFontTables(flag2) {
|
|
305
|
+
if (flag2 !== void 0) return loadFontTables(flag2, "--font-tables");
|
|
306
|
+
let env = process.env[FONT_TABLES_ENV];
|
|
307
|
+
return env === void 0 || env === "" ? void 0 : loadFontTables(env, FONT_TABLES_ENV);
|
|
308
|
+
}
|
|
309
|
+
function withFontTables(flag2, work) {
|
|
310
|
+
let requested = requestedFontTables(flag2), before = scoped;
|
|
311
|
+
scoped = requested;
|
|
312
|
+
try {
|
|
313
|
+
return work();
|
|
314
|
+
} finally {
|
|
315
|
+
scoped = before;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function activeFontTables() {
|
|
319
|
+
return scoped;
|
|
320
|
+
}
|
|
321
|
+
function fontTablesSummary(active) {
|
|
322
|
+
return active ? { families: active.families, faces: active.faces } : void 0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/core/claims/sha256.ts
|
|
326
|
+
var K = new Uint32Array([
|
|
327
|
+
1116352408,
|
|
328
|
+
1899447441,
|
|
329
|
+
3049323471,
|
|
330
|
+
3921009573,
|
|
331
|
+
961987163,
|
|
332
|
+
1508970993,
|
|
333
|
+
2453635748,
|
|
334
|
+
2870763221,
|
|
335
|
+
3624381080,
|
|
336
|
+
310598401,
|
|
337
|
+
607225278,
|
|
338
|
+
1426881987,
|
|
339
|
+
1925078388,
|
|
340
|
+
2162078206,
|
|
341
|
+
2614888103,
|
|
342
|
+
3248222580,
|
|
343
|
+
3835390401,
|
|
344
|
+
4022224774,
|
|
345
|
+
264347078,
|
|
346
|
+
604807628,
|
|
347
|
+
770255983,
|
|
348
|
+
1249150122,
|
|
349
|
+
1555081692,
|
|
350
|
+
1996064986,
|
|
351
|
+
2554220882,
|
|
352
|
+
2821834349,
|
|
353
|
+
2952996808,
|
|
354
|
+
3210313671,
|
|
355
|
+
3336571891,
|
|
356
|
+
3584528711,
|
|
357
|
+
113926993,
|
|
358
|
+
338241895,
|
|
359
|
+
666307205,
|
|
360
|
+
773529912,
|
|
361
|
+
1294757372,
|
|
362
|
+
1396182291,
|
|
363
|
+
1695183700,
|
|
364
|
+
1986661051,
|
|
365
|
+
2177026350,
|
|
366
|
+
2456956037,
|
|
367
|
+
2730485921,
|
|
368
|
+
2820302411,
|
|
369
|
+
3259730800,
|
|
370
|
+
3345764771,
|
|
371
|
+
3516065817,
|
|
372
|
+
3600352804,
|
|
373
|
+
4094571909,
|
|
374
|
+
275423344,
|
|
375
|
+
430227734,
|
|
376
|
+
506948616,
|
|
377
|
+
659060556,
|
|
378
|
+
883997877,
|
|
379
|
+
958139571,
|
|
380
|
+
1322822218,
|
|
381
|
+
1537002063,
|
|
382
|
+
1747873779,
|
|
383
|
+
1955562222,
|
|
384
|
+
2024104815,
|
|
385
|
+
2227730452,
|
|
386
|
+
2361852424,
|
|
387
|
+
2428436474,
|
|
388
|
+
2756734187,
|
|
389
|
+
3204031479,
|
|
390
|
+
3329325298
|
|
391
|
+
]), rotate = (x, n) => x >>> n | x << 32 - n;
|
|
392
|
+
function digest(bytes) {
|
|
393
|
+
let padded = new Uint8Array(Math.ceil((bytes.length + 9) / 64) * 64);
|
|
394
|
+
padded.set(bytes), padded[bytes.length] = 128;
|
|
395
|
+
let view = new DataView(padded.buffer), bits = bytes.length * 8;
|
|
396
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296)), view.setUint32(padded.length - 4, bits >>> 0);
|
|
397
|
+
let h = new Uint32Array([
|
|
398
|
+
1779033703,
|
|
399
|
+
3144134277,
|
|
400
|
+
1013904242,
|
|
401
|
+
2773480762,
|
|
402
|
+
1359893119,
|
|
403
|
+
2600822924,
|
|
404
|
+
528734635,
|
|
405
|
+
1541459225
|
|
406
|
+
]), w = new Uint32Array(64);
|
|
407
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
408
|
+
for (let i = 0; i < 16; i++) w[i] = view.getUint32(offset + i * 4);
|
|
409
|
+
for (let i = 16; i < 64; i++) {
|
|
410
|
+
let x = w[i - 15], y = w[i - 2];
|
|
411
|
+
w[i] = (rotate(x, 7) ^ rotate(x, 18) ^ x >>> 3) + w[i - 16] + (rotate(y, 17) ^ rotate(y, 19) ^ y >>> 10) + w[i - 7];
|
|
412
|
+
}
|
|
413
|
+
let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], z5 = h[7];
|
|
414
|
+
for (let i = 0; i < 64; i++) {
|
|
415
|
+
let t1 = z5 + (rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25)) + (e & f ^ ~e & g) + K[i] + w[i] | 0, t2 = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
416
|
+
z5 = g, g = f, f = e, e = d + t1 | 0, d = c, c = b, b = a, a = t1 + t2 | 0;
|
|
417
|
+
}
|
|
418
|
+
h[0] = h[0] + a | 0, h[1] = h[1] + b | 0, h[2] = h[2] + c | 0, h[3] = h[3] + d | 0, h[4] = h[4] + e | 0, h[5] = h[5] + f | 0, h[6] = h[6] + g | 0, h[7] = h[7] + z5 | 0;
|
|
419
|
+
}
|
|
420
|
+
return Array.from(h, (v) => (v >>> 0).toString(16).padStart(8, "0")).join("");
|
|
421
|
+
}
|
|
422
|
+
function sha256(input) {
|
|
423
|
+
let bytes = typeof input == "string" ? new TextEncoder().encode(input) : input;
|
|
424
|
+
return digest(bytes);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/cli/spec.ts
|
|
428
|
+
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
429
|
+
import { resolve as resolve3 } from "path";
|
|
430
|
+
import { isatty } from "tty";
|
|
431
|
+
import { isDeepStrictEqual } from "util";
|
|
432
|
+
|
|
433
|
+
// src/core/lint/honesty.ts
|
|
434
|
+
var ISO_PERIOD = /^\d{4}-(?:\d{2}(?:-\d{2})?|Q[1-4]|W\d{2})$/;
|
|
435
|
+
function cellAt(series, categoryId, index) {
|
|
436
|
+
let values = Array.isArray(series.values) ? series.values : [], isKeyed = (entry) => entry !== null && typeof entry == "object" && "categoryId" in entry;
|
|
437
|
+
if (!values.some(isKeyed)) return cellNumber(values[index]);
|
|
438
|
+
let keyed = values.find((entry) => isKeyed(entry) && entry.categoryId === categoryId);
|
|
439
|
+
return keyed === void 0 ? null : cellNumber(keyed.value);
|
|
440
|
+
}
|
|
441
|
+
var PARTIAL_PERIOD = /\b(?:YTD|H1|Q1\s*[\u2013\u2014-]\s*3)\b/i, FULL_PERIOD = /\b(?:FY(?:\s*(?:20)?\d{2})?|20\d{2})\b/i, BASIS_CHANGE = /\b(?:restated|pro\s+forma|adjusted|rebased)\b/i;
|
|
442
|
+
function runHonestyLints(charts) {
|
|
443
|
+
let warnings = [];
|
|
444
|
+
for (let chart of charts) {
|
|
445
|
+
let labels = comparisonLabels(chart), hasPartial = labels.some((label) => PARTIAL_PERIOD.test(label)), hasFull = labels.some((label) => !PARTIAL_PERIOD.test(label) && FULL_PERIOD.test(label));
|
|
446
|
+
hasPartial && hasFull && !hasAuthoredFootnote(chart) && warnings.push(
|
|
447
|
+
warning(
|
|
448
|
+
chart,
|
|
449
|
+
"partial-period-pairing",
|
|
450
|
+
"warn",
|
|
451
|
+
"partial period compared to full period - footnote the basis or align periods",
|
|
452
|
+
"add an explanatory footnote or compare like-for-like periods"
|
|
453
|
+
)
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
for (let chart of charts) {
|
|
457
|
+
if (hasAuthoredFootnote(chart)) continue;
|
|
458
|
+
let changed = seriesOf(chart).filter((series) => BASIS_CHANGE.test(labelOf(series) ?? ""));
|
|
459
|
+
changed.length > 0 && warnings.push(
|
|
460
|
+
warning(
|
|
461
|
+
chart,
|
|
462
|
+
"basis-change",
|
|
463
|
+
"warn",
|
|
464
|
+
`series '${changed.map((series) => labelOf(series)).join("', '")}' changes the comparison basis without a footnote`,
|
|
465
|
+
"footnote what was restated, pro forma, adjusted, or rebased",
|
|
466
|
+
changed.length === 1 && typeof changed[0].id == "string" ? { seriesId: changed[0].id } : void 0
|
|
467
|
+
)
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
for (let chart of charts) {
|
|
471
|
+
let options = chart.options ?? {};
|
|
472
|
+
if (chart.type !== "column" && chart.type !== "bar" || options.variant !== "stacked" && options.variant !== "stacked100")
|
|
473
|
+
continue;
|
|
474
|
+
let unitOf = (series) => typeof series.unit == "string" ? series.unit : typeof options.unit == "string" ? options.unit : "", stacked = seriesOf(chart).filter((series) => series.role !== "reference");
|
|
475
|
+
if (options.sharesOfOneWhole === !0) {
|
|
476
|
+
let over = categoriesOf(chart).filter((category, index) => stacked.reduce((sum, series) => sum + (cellAt(series, category.id, index) ?? 0), 0) > 100.5);
|
|
477
|
+
over.length > 0 && warnings.push(
|
|
478
|
+
warning(
|
|
479
|
+
chart,
|
|
480
|
+
"non-additive-stack",
|
|
481
|
+
"warn",
|
|
482
|
+
`series declared sharesOfOneWhole add to more than 100 in '${over.map((category) => labelOf(category)).join("', '")}' - shares of one whole cannot`,
|
|
483
|
+
"check the shares, or remove sharesOfOneWhole if they are shares of different wholes",
|
|
484
|
+
over.length === 1 && typeof over[0].id == "string" ? { categoryId: over[0].id } : void 0
|
|
485
|
+
)
|
|
486
|
+
);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
let offending = stacked.filter((series) => statedInPercent(
|
|
490
|
+
labelOf(series) ?? "",
|
|
491
|
+
unitOf(series),
|
|
492
|
+
cellsOfSeries(series).some((cell) => cell !== null && typeof cell == "object" && "pct" in cell)
|
|
493
|
+
));
|
|
494
|
+
offending.length !== 0 && warnings.push(
|
|
495
|
+
warning(
|
|
496
|
+
chart,
|
|
497
|
+
"non-additive-stack",
|
|
498
|
+
"warn",
|
|
499
|
+
`non-additive series '${offending.map((series) => labelOf(series)).join("', '")}' is stacked - percentages do not stack unless they are shares of one whole (options.sharesOfOneWhole)`,
|
|
500
|
+
"use grouped columns/bars or a line instead, or set sharesOfOneWhole: true when every series is a share of the same whole",
|
|
501
|
+
offending.length === 1 && typeof offending[0].id == "string" ? { seriesId: offending[0].id } : void 0
|
|
502
|
+
)
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
for (let chart of charts) {
|
|
506
|
+
let counts = /* @__PURE__ */ new Map(), datesByLabel = /* @__PURE__ */ new Map(), categories = categoriesOf(chart), data = asRecord(chart.data), periods = chart.type === "grid" && asRecord(chart.options).stack && Array.isArray(data.measures) ? records(data.periods) : [];
|
|
507
|
+
for (let [index, category] of categories.entries()) {
|
|
508
|
+
let period = periods.find((p) => {
|
|
509
|
+
let from = categories.findIndex((c) => c.id === p.from), to = categories.findIndex((c) => c.id === p.to);
|
|
510
|
+
return from >= 0 && index >= from && index <= to;
|
|
511
|
+
}), label = period ? `${String(period.label)} / ${labelOf(category)}` : labelOf(category);
|
|
512
|
+
if (label !== null && label.trim() !== "") {
|
|
513
|
+
counts.set(label, (counts.get(label) ?? 0) + 1);
|
|
514
|
+
let date = typeof category.date == "string" ? category.date : typeof category.id == "string" && ISO_PERIOD.test(category.id) ? category.id : void 0, dates = datesByLabel.get(label) ?? [];
|
|
515
|
+
dates.push(date), datesByLabel.set(label, dates);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
let duplicates = [...counts].filter(([label, count]) => {
|
|
519
|
+
if (count < 2) return !1;
|
|
520
|
+
let dates = datesByLabel.get(label);
|
|
521
|
+
return !(dates.every((date) => date !== void 0) && new Set(dates).size === dates.length);
|
|
522
|
+
}).map(([label]) => label);
|
|
523
|
+
duplicates.length > 0 && warnings.push(
|
|
524
|
+
warning(
|
|
525
|
+
chart,
|
|
526
|
+
"duplicate-category-labels",
|
|
527
|
+
"warn",
|
|
528
|
+
`duplicate category label${duplicates.length === 1 ? "" : "s"}: ${duplicates.join(", ")}`,
|
|
529
|
+
"use unique category labels and check for copy-paste artifacts"
|
|
530
|
+
)
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
for (let chart of charts) {
|
|
534
|
+
let offending = formatValuePairs(chart).find(
|
|
535
|
+
// A format the schema refused already has its finding; it judges nothing here.
|
|
536
|
+
({ format, value }) => Math.abs(value) >= 1e3 && !formatExampleProblem(format) && parseFormatExample(format).decimals >= 3
|
|
537
|
+
);
|
|
538
|
+
offending && warnings.push(
|
|
539
|
+
warning(
|
|
540
|
+
chart,
|
|
541
|
+
"spurious-precision",
|
|
542
|
+
"warn",
|
|
543
|
+
`format example '${offending.format}' shows at least 3 decimals for values at or above 1000`,
|
|
544
|
+
"round large values to a decision-useful precision"
|
|
545
|
+
)
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
return warnings;
|
|
549
|
+
}
|
|
550
|
+
function comparisonLabels(chart) {
|
|
551
|
+
return chart.type === "table" ? records(chart.data?.columns).map(labelOf).filter((label) => label !== null) : seriesOf(chart).map(labelOf).filter((label) => label !== null);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/core/lint/partner.ts
|
|
555
|
+
function runPartnerLints(charts) {
|
|
556
|
+
let warnings = [];
|
|
557
|
+
for (let chart of charts) {
|
|
558
|
+
if (!chart.requireMessageTitle || chart.type === "kpi") continue;
|
|
559
|
+
let title = chartOptions(chart).title;
|
|
560
|
+
title !== !1 && (typeof title != "string" || title.trim() === "" || isGenericTitle(title, [chart.type, chart.authoredType, chart.typeTitle])) && warnings.push(
|
|
561
|
+
warning(
|
|
562
|
+
chart,
|
|
563
|
+
"missing-message-title",
|
|
564
|
+
"warn",
|
|
565
|
+
"consulting titles carry the message; this title is missing or generic",
|
|
566
|
+
"state the decision-relevant takeaway in options.title"
|
|
567
|
+
)
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
for (let chart of charts) {
|
|
571
|
+
let options = chartOptions(chart);
|
|
572
|
+
if (!(chart.type === "line" && options.variant !== "bump" || chart.type === "column" && (options.variant === void 0 || options.variant === "grouped"))) continue;
|
|
573
|
+
let series = seriesOf(chart).filter((item) => item.role !== "reference");
|
|
574
|
+
series.length > 6 && warnings.push(
|
|
575
|
+
warning(
|
|
576
|
+
chart,
|
|
577
|
+
"series-overload",
|
|
578
|
+
"warn",
|
|
579
|
+
`${series.length} data series exceed the 6-series readability limit`,
|
|
580
|
+
"show the top series or facet the comparison"
|
|
581
|
+
)
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
for (let chart of charts) {
|
|
585
|
+
if (chart.type !== "column") continue;
|
|
586
|
+
let options = chartOptions(chart), labels = isRecord(options.labels) ? options.labels : {}, valueAxis = isRecord(options.valueAxis) ? options.valueAxis : {}, series = seriesOf(chart), pyReferences = series.filter(
|
|
587
|
+
(item) => item.role === "reference" && typeof item.scenario == "string" && item.scenario.toUpperCase() === "PY"
|
|
588
|
+
);
|
|
589
|
+
if (!(options.variant === "stacked" && valueAxis.percent !== !0 && (options.referenceStyle === void 0 || options.referenceStyle === "tick") && options.grandTotalLabels !== !1 && options.labels !== !1 && labels.grandTotal !== !1 && labels.annotation !== !1 && labels.tick !== !1 && pyReferences.length === 1)) continue;
|
|
590
|
+
let periods = categoriesOf(chart).length, components = series.filter((item) => item.role !== "reference").length;
|
|
591
|
+
periods <= 6 && components <= 4 || warnings.push(
|
|
592
|
+
warning(
|
|
593
|
+
chart,
|
|
594
|
+
"integrated-stacked-variance-overload",
|
|
595
|
+
"info",
|
|
596
|
+
`integrated stacked variance has ${periods} periods and ${components} components; the readable maximum is 6 periods and 4 components`,
|
|
597
|
+
"reduce periods/components or use the explicit dual-tier relative-variance grid"
|
|
598
|
+
)
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
for (let chart of charts) {
|
|
602
|
+
if (chart.type !== "pie") continue;
|
|
603
|
+
let categories = categoriesOf(chart), options = chartOptions(chart), topN = typeof options.topN == "object" && options.topN !== null ? options.topN : { n: 5, rest: !0 }, n = typeof topN.n == "number" && topN.n > 0 ? Math.floor(topN.n) : null, effectiveCount = categories.length, isOthers = (s) => /^others?$/i.test((s ?? "").trim()), hasOthers = categories.some(
|
|
604
|
+
(category) => isOthers(labelOf(category)) || typeof category.id == "string" && isOthers(category.id)
|
|
605
|
+
);
|
|
606
|
+
n !== null && categories.length > n && (effectiveCount = topN.rest === !1 ? n : n + 1, topN.rest !== !1 && (hasOthers = !0)), effectiveCount > 6 && !hasOthers && warnings.push(
|
|
607
|
+
warning(
|
|
608
|
+
chart,
|
|
609
|
+
"pie-too-many-slices",
|
|
610
|
+
"warn",
|
|
611
|
+
`${effectiveCount} pie slices without an 'Others' slice exceed the 6-slice readability limit`,
|
|
612
|
+
"aggregate small slices into 'Others' or switch to a bar chart"
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
for (let chart of charts) {
|
|
617
|
+
let options = chartOptions(chart), legend = options.legend;
|
|
618
|
+
if (chart.type === "pie" || legend === "auto" || !legendEnabled(legend)) continue;
|
|
619
|
+
let series = seriesOf(chart);
|
|
620
|
+
if (series.length === 1 && !(chart.type === "line" && lineDirectlyNamesSeries(options, series[0], categoriesOf(chart), 1))) {
|
|
621
|
+
warnings.push(
|
|
622
|
+
warning(
|
|
623
|
+
chart,
|
|
624
|
+
"legend-redundant",
|
|
625
|
+
"warn",
|
|
626
|
+
"a forced legend repeats the only series",
|
|
627
|
+
"turn the legend off and label the series directly",
|
|
628
|
+
typeof series[0].id == "string" ? { seriesId: series[0].id } : void 0
|
|
629
|
+
)
|
|
630
|
+
);
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
let dataSeries = series.filter((item) => item.role !== "reference"), categories = categoriesOf(chart);
|
|
634
|
+
chart.type === "line" && dataSeries.length === series.length && dataSeries.length > 0 && dataSeries.every((item) => lineDirectlyNamesSeries(options, item, categories, dataSeries.length)) && warnings.push(
|
|
635
|
+
{ ...warning(
|
|
636
|
+
chart,
|
|
637
|
+
"legend-redundant",
|
|
638
|
+
"info",
|
|
639
|
+
`options.legend repeats series names requested by ${options.seriesLabels !== void 0 ? "options.seriesLabels" : "options.labels (or its default)"}`,
|
|
640
|
+
"remove options.legend to use the direct names without the repeated key"
|
|
641
|
+
), fix: [{ op: "remove", path: `${chart.path ?? ""}/options/legend` }] }
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
if (!charts.some(hasFormatOrUnit)) {
|
|
645
|
+
let chart = charts.find((candidate) => numericDataValues(candidate).some((value) => Math.abs(value) >= 1e3));
|
|
646
|
+
chart && warnings.push(
|
|
647
|
+
warning(
|
|
648
|
+
chart,
|
|
649
|
+
"unlabeled-units",
|
|
650
|
+
"warn",
|
|
651
|
+
"values at or above 1000 have no format or unit anywhere in the document; readers must not guess magnitudes",
|
|
652
|
+
"declare options.unit or a format-by-example"
|
|
653
|
+
)
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
for (let chart of charts) {
|
|
657
|
+
if (!["column", "bar", "combo", "line", "dot", "scatter"].includes(chart.type)) continue;
|
|
658
|
+
let options = chartOptions(chart), scatterGroups = chart.type === "scatter" ? scatterGroupIdentities(chart.data, chart.geometry, chart.geometryPrefix) : void 0;
|
|
659
|
+
if (chart.geometry) {
|
|
660
|
+
let geometry = chart.geometry, prefix = chart.geometryPrefix ?? "", drawn2 = scatterGroups ? scatterGroups.map((group) => ({ ...group })) : seriesOf(chart).filter((s) => geometry.scene.some((node2) => node2.t !== "text" && node2.part !== "swatch" && (node2.owner.seriesId === prefix + s.id || node2.owner.seriesId === s.id && node2.id.startsWith(prefix)))), unnamed = drawn2.filter((s) => {
|
|
661
|
+
let group = scatterGroups?.find((group2) => group2.id === s.id);
|
|
662
|
+
return group ? !scatterGroupNameIsDrawn(geometry, group, prefix) : !nameIsDrawn(geometry, labelOf(s) ?? "", prefix + s.id);
|
|
663
|
+
});
|
|
664
|
+
(drawn2.length > 1 && unnamed.length > 0 || unnamed.some((s) => s.role === "reference")) && warnings.push(warning(
|
|
665
|
+
chart,
|
|
666
|
+
"series-unexplained",
|
|
667
|
+
"warn",
|
|
668
|
+
`Drawn series ${unnamed.map((s) => labelOf(s)).join(", ")} have no visible name`,
|
|
669
|
+
"set options.legend to top, or show a direct label for each series"
|
|
670
|
+
));
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
if (legendEnabled(options.legend) || legendEnabled(chart.parentLegend) || drawsRequiredKey(chart) || options.variant === "tornado") continue;
|
|
674
|
+
let series = scatterGroups ? scatterGroups.map((group) => ({ ...group })) : seriesOf(chart), categories = categoriesOf(chart), dataSeries = series.filter((s) => s.role !== "reference").filter((s) => chart.type !== "line" || lineSeriesRenders(options, s, categories)), refSeries = series.filter((s) => s.role === "reference").filter((s) => chart.type !== "line" || effectiveLineValues(options, s, categories).filter((v) => v !== null).length >= 2), rawSubtitle = JSON.stringify(options.subtitle ?? ""), canonicalScenario = (v) => {
|
|
675
|
+
if (typeof v != "string") return null;
|
|
676
|
+
let u = v.toUpperCase();
|
|
677
|
+
return u === "FCST" ? "FC" : u === "BUD" ? "PL" : u;
|
|
678
|
+
}, scenarioIdentified = (s) => {
|
|
679
|
+
let code = canonicalScenario(s.scenario);
|
|
680
|
+
return code === null ? !1 : code === "FC" || code === "PL" ? !0 : new RegExp(`\\b${code}\\b`).test(rawSubtitle);
|
|
681
|
+
}, endpointLabeled = (s) => {
|
|
682
|
+
if (chart.type === "line") {
|
|
683
|
+
let names2 = lineLabelModes(options, lineVariantOf(options), dataSeries.length).series;
|
|
684
|
+
return names2 === "key" || names2 === "none" && dataSeries.length >= 2 && (options.legend === void 0 || options.legend === "auto") || lineDirectlyNamesSeries(options, s, categories, dataSeries.length);
|
|
685
|
+
}
|
|
686
|
+
if (chart.type === "combo")
|
|
687
|
+
return (s.kind === "line" || s.kind === "area") && kindKeepsSeriesNames(options, "point", !1);
|
|
688
|
+
if (chart.type === "column" && (options.variant === "stacked" || options.variant === "stacked100")) {
|
|
689
|
+
let seriesLabels = options.seriesLabels;
|
|
690
|
+
return seriesLabels === void 0 ? !1 : !Array.isArray(seriesLabels.only) || seriesLabels.only.includes(s.id);
|
|
691
|
+
}
|
|
692
|
+
return !1;
|
|
693
|
+
}, scenarioCount = /* @__PURE__ */ new Map();
|
|
694
|
+
for (let s of dataSeries) scenarioCount.set(canonicalScenario(s.scenario), (scenarioCount.get(canonicalScenario(s.scenario)) ?? 0) + 1);
|
|
695
|
+
let identified = (s) => endpointLabeled(s) || scenarioIdentified(s) && scenarioCount.get(canonicalScenario(s.scenario)) === 1, unidentifiedData = dataSeries.filter((s) => !identified(s)), unexplainedRefs = refSeries.filter((s) => !scenarioIdentified(s)), ambiguousData = unidentifiedData.length >= 2 ? unidentifiedData : [];
|
|
696
|
+
if (ambiguousData.length === 0 && unexplainedRefs.length === 0) continue;
|
|
697
|
+
let subject = ambiguousData.length ? `${ambiguousData.length} series${unexplainedRefs.length ? " and a reference marker" : ""} are visually distinguished but never identified` : "a reference marker is drawn as a bare stroke with nothing naming it", isGridPanel = chart.displayName.includes("/");
|
|
698
|
+
warnings.push(
|
|
699
|
+
warning(
|
|
700
|
+
chart,
|
|
701
|
+
"series-unexplained",
|
|
702
|
+
"warn",
|
|
703
|
+
`${subject} \u2014 no legend, no direct labels`,
|
|
704
|
+
isGridPanel ? "enable legend on the grid options (one exhibit-level legend) or on this panel, or show direct series names" : "enable options.legend, or show direct series names"
|
|
705
|
+
)
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
for (let chart of charts) {
|
|
709
|
+
let scenarios = scenarioCodes(chart);
|
|
710
|
+
if (chart.geometry) {
|
|
711
|
+
let names2 = { AC: "actual", PY: "prior year", PL: "plan", FC: "forecast" }, geometry = chart.geometry, missing = [...scenarios].filter((code) => nameIsDrawn(geometry, code) || nameIsDrawn(geometry, names2[code] ?? code) || geometry.scene.some((node2) => (node2.part === "subtitle" || node2.part === "footnote") && (textNames(node2, code) || textNames(node2, names2[code] ?? code))) ? !1 : !seriesOf(chart).some((series) => {
|
|
712
|
+
let scenario = typeof series.scenario == "string" ? series.scenario.toUpperCase() : "";
|
|
713
|
+
if (scenario !== code && scenario !== (code === "PL" ? "BUD" : "FCST")) return !1;
|
|
714
|
+
let ids = [series.id, `${chart.geometryPrefix ?? ""}${series.id}`];
|
|
715
|
+
return geometry.scene.some((node2) => node2.part === "legendLabel" && ids.includes(node2.owner.seriesId) && textNames(node2, labelOf(series) ?? "")) && geometry.scene.some((node2) => node2.part === "swatch" && ids.includes(node2.owner.seriesId));
|
|
716
|
+
}));
|
|
717
|
+
missing.length > 0 && warnings.push(warning(
|
|
718
|
+
chart,
|
|
719
|
+
"scenario-unexplained",
|
|
720
|
+
"info",
|
|
721
|
+
`${missing.join("/")} scenario styling has no visible explanation`,
|
|
722
|
+
"name the scenario in the key, subtitle or footnote"
|
|
723
|
+
));
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
let legendOff = !legendEnabled(chartOptions(chart).legend) && !legendEnabled(chart.parentLegend) && !drawsRequiredKey(chart), subtitle = JSON.stringify(chartOptions(chart).subtitle ?? ""), subtitleExplains = scenarios.size > 0 && [...scenarios].every((code) => subtitle.includes(code));
|
|
727
|
+
scenarios.size > 0 && legendOff && !subtitleExplains && !hasAuthoredFootnote(chart) && warnings.push(
|
|
728
|
+
warning(
|
|
729
|
+
chart,
|
|
730
|
+
"scenario-unexplained",
|
|
731
|
+
"info",
|
|
732
|
+
`${[...scenarios].sort().join("/")} scenario styling is used with no legend or explanatory footnote`,
|
|
733
|
+
"enable the legend or explain the scenario abbreviation in a footnote"
|
|
734
|
+
)
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
return warnings;
|
|
738
|
+
}
|
|
739
|
+
function drawsRequiredKey(chart) {
|
|
740
|
+
return chart.displayName.includes("/") ? chart.parentLegend === "none" : chart.type === "waterfall" || chart.type === "variance" && chartOptions(chart).variant === "integrated";
|
|
741
|
+
}
|
|
742
|
+
function kindKeepsSeriesNames(options, kind, namesByDefault = !0) {
|
|
743
|
+
let labels = options.labels;
|
|
744
|
+
if (labels === !1) return !1;
|
|
745
|
+
if (typeof labels != "object" || labels === null) return namesByDefault;
|
|
746
|
+
let value = labels[kind];
|
|
747
|
+
return value === !1 ? !1 : Array.isArray(value) ? value.includes("series") : namesByDefault;
|
|
748
|
+
}
|
|
749
|
+
function lineVariantOf(options) {
|
|
750
|
+
let variant = (isRecord(options.valueAxis) ? options.valueAxis : {}).percent === !0 ? "stacked100-area" : options.variant;
|
|
751
|
+
return variant === "area" || variant === "stacked-area" || variant === "stacked100-area" || variant === "bump" ? variant : "line";
|
|
752
|
+
}
|
|
753
|
+
function lineDirectlyNamesSeries(options, series, categories, count) {
|
|
754
|
+
if (!effectiveLineValues(options, series, categories).some((value) => value !== null)) return !1;
|
|
755
|
+
let modes = lineLabelModes(options, lineVariantOf(options), count);
|
|
756
|
+
return (modes.series === "end" || modes.series === "inline") && (modes.only === void 0 || modes.only.has(series.id)) ? !0 : modes.values !== "none" && kindKeepsSeriesNames(options, "point", !1);
|
|
757
|
+
}
|
|
758
|
+
function lineSeriesRenders(options, series, categories) {
|
|
759
|
+
let variant = (isRecord(options.valueAxis) ? options.valueAxis : {}).percent === !0 ? "stacked100-area" : options.variant ?? "line";
|
|
760
|
+
return variant === "stacked-area" || variant === "stacked100-area" ? categories.length >= 2 : effectiveLineValues(options, series, categories).some((value) => value !== null);
|
|
761
|
+
}
|
|
762
|
+
function effectiveLineValues(options, series, categories) {
|
|
763
|
+
let entries = Array.isArray(series.values) ? series.values : [], pointKeyed = entries.length > 0 && entries.every((entry) => isRecord(entry) && "categoryId" in entry), values = categories.map((category, index) => {
|
|
764
|
+
let entry = pointKeyed ? entries.find((candidate) => isRecord(candidate) && candidate.categoryId === category.id) : entries[index];
|
|
765
|
+
return cellNumber(isRecord(entry) && "value" in entry ? entry.value : entry);
|
|
766
|
+
}), rebase = options.rebase100;
|
|
767
|
+
if (rebase === void 0 || rebase === !1) return values;
|
|
768
|
+
let at = isRecord(rebase) && typeof rebase.at == "string" ? rebase.at : categories[0]?.id, baseIndex = categories.findIndex((category) => category.id === at);
|
|
769
|
+
if (baseIndex < 0) return values;
|
|
770
|
+
let base = values[baseIndex];
|
|
771
|
+
return base === null || base === 0 ? values.map(() => null) : values;
|
|
772
|
+
}
|
|
773
|
+
function isGenericTitle(title, typeNames) {
|
|
774
|
+
let normalized = title.trim().toLowerCase();
|
|
775
|
+
return /^(?:chart|figure|untitled)\b/.test(normalized) ? !0 : typeNames.some((typeName) => {
|
|
776
|
+
if (!typeName) return !1;
|
|
777
|
+
let exact = typeName.trim().toLowerCase();
|
|
778
|
+
if (normalized === exact) return !0;
|
|
779
|
+
let escapedType = exact.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
780
|
+
return new RegExp(
|
|
781
|
+
`^${escapedType}(?:(?:\\s+(?:chart|plot|figure|card|\\d+))|(?:\\s*\\([^)]*\\))|(?:\\s*/\\s*[a-z0-9 /()-]+))?$`,
|
|
782
|
+
"i"
|
|
783
|
+
).test(normalized);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/core/catalog.ts
|
|
788
|
+
import * as z from "zod";
|
|
789
|
+
|
|
790
|
+
// src/core/schema/reference.ts
|
|
791
|
+
function object(value) {
|
|
792
|
+
return value !== null && typeof value == "object" && !Array.isArray(value) ? value : void 0;
|
|
793
|
+
}
|
|
794
|
+
function resolve2(schema, root, refs = /* @__PURE__ */ new Set()) {
|
|
795
|
+
if (typeof schema.$ref != "string") return schema;
|
|
796
|
+
if (refs.has(schema.$ref)) return { ...schema, $ref: void 0 };
|
|
797
|
+
if (!schema.$ref.startsWith("#/")) throw new Error(`Unsupported schema reference: ${schema.$ref}`);
|
|
798
|
+
let target = root;
|
|
799
|
+
for (let key of schema.$ref.slice(2).split("/"))
|
|
800
|
+
target = object(target)?.[key.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
801
|
+
if (!object(target)) throw new Error(`Missing schema reference: ${schema.$ref}`);
|
|
802
|
+
return { ...resolve2(object(target), root, /* @__PURE__ */ new Set([...refs, schema.$ref])), ...schema, $ref: void 0 };
|
|
803
|
+
}
|
|
804
|
+
function alternatives(schema) {
|
|
805
|
+
return ["anyOf", "oneOf", "allOf"].flatMap((key) => {
|
|
806
|
+
let branches = schema[key];
|
|
807
|
+
return Array.isArray(branches) ? branches.map(object).filter((branch) => branch !== void 0) : [];
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
function allowed(schema, root, refs = /* @__PURE__ */ new Set()) {
|
|
811
|
+
if (typeof schema.$ref == "string") {
|
|
812
|
+
if (refs.has(schema.$ref)) return;
|
|
813
|
+
refs = /* @__PURE__ */ new Set([...refs, schema.$ref]);
|
|
814
|
+
}
|
|
815
|
+
let field = resolve2(schema, root);
|
|
816
|
+
if (Array.isArray(field.enum)) return { values: field.enum, exhaustive: !0 };
|
|
817
|
+
if (Object.hasOwn(field, "const")) return { values: [field.const], exhaustive: !0 };
|
|
818
|
+
if (field.allOf) return;
|
|
819
|
+
let branches = alternatives(field).filter((branch) => !branch["x-boardplot-retiring"]).map((branch) => allowed(branch, root, refs)), values = [...new Set(branches.flatMap((branch) => branch?.values ?? []))];
|
|
820
|
+
return values.length ? { values, exhaustive: branches.every((branch) => branch?.exhaustive) } : void 0;
|
|
821
|
+
}
|
|
822
|
+
function fieldType(schema, root, refs = /* @__PURE__ */ new Set()) {
|
|
823
|
+
if (typeof schema.$ref == "string") {
|
|
824
|
+
if (refs.has(schema.$ref)) return "recursive";
|
|
825
|
+
refs = /* @__PURE__ */ new Set([...refs, schema.$ref]);
|
|
826
|
+
}
|
|
827
|
+
let field = resolve2(schema, root);
|
|
828
|
+
if (object(field.not) && !Object.keys(object(field.not)).length) return "never";
|
|
829
|
+
if (typeof field.const == "boolean") return String(field.const);
|
|
830
|
+
if (Array.isArray(field.type)) return field.type.join(" | ");
|
|
831
|
+
if (typeof field.type == "string") return field.type;
|
|
832
|
+
if (Object.hasOwn(field, "const")) return field.const === null ? "null" : typeof field.const;
|
|
833
|
+
let branches = alternatives(field);
|
|
834
|
+
return branches.length ? [...new Set(branches.map((branch) => fieldType(branch, root, refs)))].join(field.allOf ? " & " : " | ") : "unknown";
|
|
835
|
+
}
|
|
836
|
+
function defaultAt(defaults, path) {
|
|
837
|
+
let value = defaults;
|
|
838
|
+
for (let key of path) {
|
|
839
|
+
let record = object(value);
|
|
840
|
+
if (!record || !Object.hasOwn(record, key)) return;
|
|
841
|
+
value = record[key];
|
|
842
|
+
}
|
|
843
|
+
return value;
|
|
844
|
+
}
|
|
845
|
+
function schemaReference(schema, defaults) {
|
|
846
|
+
let fields2 = [], missing = /* @__PURE__ */ new Set(), visit2 = (input, path, refs, branch) => {
|
|
847
|
+
if (typeof input.$ref == "string") {
|
|
848
|
+
if (refs.has(input.$ref)) return;
|
|
849
|
+
refs = /* @__PURE__ */ new Set([...refs, input.$ref]);
|
|
850
|
+
}
|
|
851
|
+
let node2 = resolve2(input, schema), properties = object(node2.properties) ?? {};
|
|
852
|
+
for (let [key, raw] of Object.entries(properties)) {
|
|
853
|
+
if (!object(raw)) continue;
|
|
854
|
+
let child = resolve2(object(raw), schema), parts = [...path, key], description = typeof child.description == "string" ? child.description.trim() : "";
|
|
855
|
+
description || missing.add(parts.join("."));
|
|
856
|
+
let value = Object.hasOwn(child, "default") ? child.default : defaultAt(defaults, parts), dependsOn = Array.isArray(child["x-boardplot-defaultDependsOn"]) ? child["x-boardplot-defaultDependsOn"].map(String) : void 0, items = child.type === "array" ? object(child.items) : void 0, itemValues = items ? allowed(items, schema) : void 0, values = allowed(object(raw), schema) ?? itemValues;
|
|
857
|
+
fields2.push({
|
|
858
|
+
path: parts.join("."),
|
|
859
|
+
type: itemValues && items ? `${fieldType(items, schema)}[]` : fieldType(object(raw), schema),
|
|
860
|
+
required: Array.isArray(node2.required) && node2.required.includes(key),
|
|
861
|
+
description,
|
|
862
|
+
...values ? { values: values.values, valuesExhaustive: values.exhaustive } : {},
|
|
863
|
+
...value !== void 0 ? { default: value } : dependsOn ? { defaultDependsOn: dependsOn } : {},
|
|
864
|
+
...Object.hasOwn(child, "default") ? { defaultInSchema: !0 } : {},
|
|
865
|
+
...branch ? { branch } : {}
|
|
866
|
+
}), visit2(object(raw), parts, refs, branch);
|
|
867
|
+
}
|
|
868
|
+
let choices = alternatives(node2), objectUnion = !node2.allOf && choices.filter((choice) => object(resolve2(choice, schema).properties)).length > 1;
|
|
869
|
+
choices.forEach((choice, index) => visit2(choice, path, refs, objectUnion ? [branch, `${path.join(".")} branch ${index + 1}`].filter(Boolean).join("; ") : branch)), object(node2.items) && visit2(object(node2.items), [...path.slice(0, -1), `${path.at(-1) ?? ""}[]`], refs, branch), Array.isArray(node2.prefixItems) && node2.prefixItems.forEach((item, index) => {
|
|
870
|
+
object(item) && visit2(object(item), [...path.slice(0, -1), `${path.at(-1) ?? ""}[${index}]`], refs, branch);
|
|
871
|
+
}), object(node2.additionalProperties) && visit2(object(node2.additionalProperties), [...path, "*"], refs, branch);
|
|
872
|
+
};
|
|
873
|
+
if (visit2(schema, [], /* @__PURE__ */ new Set()), missing.size) throw new Error(`Schema fields need descriptions: ${[...missing].join(", ")}`);
|
|
874
|
+
return fields2;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// src/core/catalog.ts
|
|
878
|
+
var CATALOG = {
|
|
879
|
+
bar: { summary: "Horizontal bars per item", useCases: ["Ranking items", "Tornado or football-field ranges", "Values with long category names"] },
|
|
880
|
+
bartable: { summary: "Table rows with stacked bars, one panel per measure", useCases: ["One measure per row as a stacked bar beside number columns: one panel", "The same split in two units side by side, $bn and % of EBITDA: two panels", "Impact ranges by sector with a Total row", "Share of a total over 2 to 4 periods, such as category revenue share by year: cascade"] },
|
|
881
|
+
box: { summary: "Box plots of raw observations; rows category,value[,categoryLabel,date]", useCases: ["Spread per group", "Outliers by team or region", "Response times by service"] },
|
|
882
|
+
bullet: { summary: "KPI rows with bands and target", useCases: ["KPIs against target", "Plan attainment per unit", "Scorecard of several metrics"] },
|
|
883
|
+
butterfly: { summary: "Two mirrored bar panes", useCases: ["Two measures per category", "Before and after by segment", "Imports and exports by country"] },
|
|
884
|
+
choropleth: { summary: "Region map coloured by value", useCases: ["A value per country or state", "Regional penetration", "Growth rate by region"] },
|
|
885
|
+
cohort: { summary: "Retention by cohort and period", useCases: ["Retention by signup cohort", "Repeat purchase by first month", "Subscription churn by start month"] },
|
|
886
|
+
column: { summary: "Vertical bars, grouped or stacked", useCases: ["Revenue by year or quarter", "Segment mix over time", "Monthly actuals against plan", "Rank change of a few players between periods (ribbons)"] },
|
|
887
|
+
combo: { summary: "Columns with line or area overlays", useCases: ["Volume with a rate line", "Revenue and margin on two axes", "Orders with average order value"] },
|
|
888
|
+
creative: { summary: "Ad-creative review card (early alpha)", useCases: ["Ad-creative review (early alpha)", "Creative metrics against account medians", "Daily trend per creative"] },
|
|
889
|
+
diagram: { summary: "Node and edge diagrams", useCases: ["Process or organisation flow", "Driver tree or value chain", "Organisation chart"] },
|
|
890
|
+
dot: { summary: "Dots, dumbbells or lollipops", useCases: ["Gap between two values", "Many items on one scale", "Before and after per item"] },
|
|
891
|
+
funnel: { summary: "Stage funnel with conversion rates", useCases: ["Sales funnel conversion", "Drop-off between steps", "Recruiting pipeline"] },
|
|
892
|
+
gantt: { summary: "Timeline with spans and events", useCases: ["Project plan with milestones", "Rollout by workstream", "Campaign calendar"] },
|
|
893
|
+
grid: { summary: "Facets and metric stacks on one category axis", useCases: ["Small multiples per region", "Actuals with a variance tier", "Metric stacks with computed readouts"] },
|
|
894
|
+
heatmap: { summary: "Row by column matrix", useCases: ["A value by row and column", "Harvey-ball scoring", "Sales by weekday and hour"] },
|
|
895
|
+
histogram: { summary: "Equal-width bins of raw values; rows value", useCases: ["Order value distribution", "Spread of lead times", "Deal size distribution"] },
|
|
896
|
+
kpi: { summary: "Single-metric card", useCases: ["Headline metric with trend", "Metric against PY and plan", "Dashboard tile"] },
|
|
897
|
+
likert: { summary: "Diverging bars for survey scales", useCases: ["Agreement by statement", "Net sentiment per question", "Employee survey results"] },
|
|
898
|
+
line: { summary: "Lines and areas over time", useCases: ["Trend over time", "Actual against forecast", "Indexed growth of several series"] },
|
|
899
|
+
mekko: { summary: "Variable-width stacked columns", useCases: ["Market size and share", "Profit pool by segment", "Share of wallet by customer size"] },
|
|
900
|
+
pareto: { summary: "Sorted columns with cumulative curve", useCases: ["Few causes, most volume", "Customer concentration", "Defect causes by count"] },
|
|
901
|
+
pie: { summary: "Pie or doughnut of shares", useCases: ["Share of a whole, few parts", "Doughnut with a centre total", "Revenue mix by channel"] },
|
|
902
|
+
pvm: { summary: "Price, volume and mix bridge", useCases: ["Revenue change by price, volume, mix", "New and lost business", "Price effect per product"] },
|
|
903
|
+
pyramid: { summary: "Mirrored bands on one scale", useCases: ["Population by age and sex", "Mirrored distribution", "Customer age by gender"] },
|
|
904
|
+
sankey: { summary: "Flows from sources to targets in stages; rows source,target,value", useCases: ["Channel to landing page to purchase", "Budget to departments", "Customers moving between segments month to month"] },
|
|
905
|
+
scatter: { summary: "XY/bubble; rows x,y[,size,label,group]", useCases: ["Related measures", "Portfolio", "Price against volume per product"] },
|
|
906
|
+
slope: { summary: "Two-point slope lines", useCases: ["Change between two dates", "Rank shift", "Market share start to end", "Survey shares by group, two waves"] },
|
|
907
|
+
sparkline: { summary: "One series as a mini line", useCases: ["Trend inside a KPI card", "Shape beside a table row", "A strip of metrics on one board"] },
|
|
908
|
+
status: { summary: "Entity by period state matrix", useCases: ["Project status by period", "RAG matrix", "Milestone tracking"] },
|
|
909
|
+
dimswitch: { summary: "KPIs by one dimension and period, from sums", useCases: ["Weekly KPIs by channel", "Channels by KPI with changes", "Changes judged against the period before"] },
|
|
910
|
+
table: { summary: "Management table with totals; rows [label,id]", useCases: ["Table with totals", "P&L with variances", "Ranked list with status chips"] },
|
|
911
|
+
tilemap: { summary: "Equal-size region tiles", useCases: ["A value per state", "Regions without area bias", "Results by US state"] },
|
|
912
|
+
treemap: { summary: "Part of a whole as nested areas", useCases: ["Many parts of one total, in groups", "A few items take most of the total"] },
|
|
913
|
+
variance: { summary: "Variance tier against PY, PL or FC", useCases: ["Actual against plan or PY", "Variance in value and percent", "Budget deviation by cost centre"] },
|
|
914
|
+
waffle: { summary: "Share of a whole as a grid of cells", useCases: ["One share of 100%, such as 30% of customers", "Several shares side by side with one baseline", "Stacked segments of one whole"] },
|
|
915
|
+
waterfall: { summary: "Bridge; rows label,value[,type]", useCases: ["EBIT or cash", "Change contributions", "Budget to actual walk"] }
|
|
916
|
+
}, DESIGN_CARDS = {
|
|
917
|
+
bar: {
|
|
918
|
+
message: "How items rank or compare on one measure.",
|
|
919
|
+
use: "Categories without a natural order, or names too long to fit under a column.",
|
|
920
|
+
notWhen: "The categories are periods (column or line); a few parts of one whole (pie or waffle); two measures per item (dot or butterfly).",
|
|
921
|
+
rules: [
|
|
922
|
+
{ id: "design-bar-sort", check: "engine", text: "Sort unordered bars by value, largest first, so the ranking reads from the top." },
|
|
923
|
+
{ id: "design-bar-one-colour", check: "describe", text: "Give one measure one colour and mark only the item the title names with options.highlight; a colour per bar is a code the reader must learn." },
|
|
924
|
+
{ id: "design-bar-many", check: "engine", text: "Show at most 15 bars; fold the tail into one Others bar so the items that matter stay readable." },
|
|
925
|
+
{ id: "design-bar-zero", check: "describe", text: "Start the value axis at zero: a bar's length is its value, so a cut axis overstates the differences." },
|
|
926
|
+
{ id: "design-bar-stack-limit", check: "describe", text: "Keep a stacked bar to about five segments: only the first segment and the total share a baseline, so the middle segments are hard to compare." },
|
|
927
|
+
{ id: "design-bar-title", check: "describe", text: 'Write the finding in the title, such as "North sells 30% more than South", not the name of the measure.' }
|
|
928
|
+
]
|
|
929
|
+
},
|
|
930
|
+
line: {
|
|
931
|
+
message: "How a measure moves over time: trend, turning points, and where series part.",
|
|
932
|
+
use: "Ordered periods on the x axis, from about five points up; several series compared on their shape.",
|
|
933
|
+
notWhen: "The categories have no order (bar); two points only (slope); few periods where each value matters more than the shape (column); parts of one total over time (column stacked).",
|
|
934
|
+
rules: [
|
|
935
|
+
{ id: "design-line-direct-labels", check: "engine", text: "Name the lines at their ends, not in a legend, so the eye does not travel between key and line." },
|
|
936
|
+
{ id: "design-line-series-limit", check: "describe", text: "Draw at most five lines; grey the others with options.highlight, or split them into small multiples with grid." },
|
|
937
|
+
{ id: "design-line-label-points", check: "engine", text: "Print the last value, or the first and the last, not every point: a line shows the shape, and a table shows exact values." },
|
|
938
|
+
{ id: "design-line-forecast", check: "describe", text: "Mark forecast and plan periods with series[].scenario FC or PL, so the reader sees where the actuals end." },
|
|
939
|
+
{ id: "design-line-gaps", check: "describe", text: "Keep periods in time order at equal spacing, and give a missing period null, so the gap shows instead of a line across it." },
|
|
940
|
+
{ id: "design-line-straight", check: "describe", text: "Draw straight segments for measured data: a smoothed curve shows values between periods that nobody measured. Keep smoothing for concept curves." },
|
|
941
|
+
{ id: "design-line-zero", check: "describe", text: "A line may start above zero; an area must start at zero, because its filled height reads as the value." }
|
|
942
|
+
]
|
|
943
|
+
},
|
|
944
|
+
waterfall: {
|
|
945
|
+
message: "What moved a number from A to B: the steps between an opening and a closing total.",
|
|
946
|
+
use: "An opening and a closing value exist and the steps add up to the change, such as an EBIT bridge, a cash walk or budget to actual.",
|
|
947
|
+
notWhen: "The steps are shares of different wholes (column stacked100); two values only (column with a diff annotation); the steps have no business order (bar sorted by value).",
|
|
948
|
+
rules: [
|
|
949
|
+
{ id: "design-waterfall-closing-total", check: "engine", text: "End the bridge on a total, so the reader does not have to add up the steps." },
|
|
950
|
+
{ id: "design-waterfall-order", check: "describe", text: "Keep the steps in their business order, such as the P&L order; sort by size only when the message is a ranking." },
|
|
951
|
+
{ id: "design-waterfall-horizontal", check: "engine", text: "Turn the bridge horizontal when the step names do not fit upright under the columns: rotated, cut or skipped names are hard to read." },
|
|
952
|
+
{ id: "design-waterfall-cost-direction", check: "describe", text: "In a cost bridge, set items[].direction to lowerIsBetter, so a rising cost paints bad." },
|
|
953
|
+
{ id: "design-waterfall-few-steps", check: "describe", text: "Show about eight steps or fewer; fold the small ones into one Other step at a place that keeps the business order." },
|
|
954
|
+
{ id: "design-waterfall-subtotals", check: "describe", text: "Add a subtotal where the business reads one, such as gross profit before overheads, so a long bridge reads in parts." }
|
|
955
|
+
]
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
function designCardTypes() {
|
|
959
|
+
return Object.keys(DESIGN_CARDS);
|
|
960
|
+
}
|
|
961
|
+
function designCardFor(type) {
|
|
962
|
+
return DESIGN_CARDS[type];
|
|
963
|
+
}
|
|
964
|
+
function designRuleText(id) {
|
|
965
|
+
for (let card of Object.values(DESIGN_CARDS)) {
|
|
966
|
+
let rule = card.rules.find((candidate) => candidate.id === id && candidate.check === "engine");
|
|
967
|
+
if (rule) return rule.text;
|
|
968
|
+
}
|
|
969
|
+
throw new Error(`no engine design rule '${id}'`);
|
|
970
|
+
}
|
|
971
|
+
function compactDesignCard(type) {
|
|
972
|
+
let card = DESIGN_CARDS[type];
|
|
973
|
+
if (card)
|
|
974
|
+
return {
|
|
975
|
+
message: card.message,
|
|
976
|
+
use: card.use,
|
|
977
|
+
notWhen: card.notWhen,
|
|
978
|
+
rules: card.rules.slice(0, 2).map((rule) => `${rule.text} (${rule.check === "engine" ? `engine: ${rule.id}` : "judgment"})`),
|
|
979
|
+
more: `path design returns all ${card.rules.length} rules`
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
function shortSummaryFor(type, fallback) {
|
|
983
|
+
return CATALOG[type]?.summary ?? fallback;
|
|
984
|
+
}
|
|
985
|
+
function useCasesFor(type, detail = "compact") {
|
|
986
|
+
let all = CATALOG[type]?.useCases ?? [];
|
|
987
|
+
return detail === "full" ? [...all] : all.slice(0, 2);
|
|
988
|
+
}
|
|
989
|
+
function variantsFor(type) {
|
|
990
|
+
if (!getChartDefinition(type)) return [];
|
|
991
|
+
let variant = optionFields(type).find((field) => field.path === "variant");
|
|
992
|
+
return variant?.values ? variant.values.map(String) : [];
|
|
993
|
+
}
|
|
994
|
+
var DERIVED_FORMS = {
|
|
995
|
+
pie: ["pie", "doughnut"],
|
|
996
|
+
scatter: ["points", "bubbles", "quadrants", "matrix"],
|
|
997
|
+
combo: ["overlay", "dual-axis"],
|
|
998
|
+
grid: ["panels", "tiers", "facets", "metric-stack"]
|
|
999
|
+
}, IMPLIED_VARIANT = { funnel: "rows", slope: "lines", bartable: "panels" };
|
|
1000
|
+
function derivedForm(type, data, options) {
|
|
1001
|
+
if (type === "pie") return Number(options?.doughnut ?? 0) > 0 ? "doughnut" : "pie";
|
|
1002
|
+
if (type === "scatter")
|
|
1003
|
+
return options?.zones ? "matrix" : options?.quadrants ? "quadrants" : (data?.points ?? []).some((point) => point?.size != null) ? "bubbles" : "points";
|
|
1004
|
+
if (type === "combo") return comboDrawsSecondaryAxis(data, options ?? {}) ? "dual-axis" : "overlay";
|
|
1005
|
+
if (type === "grid") return gridFormOf(data, options ?? {});
|
|
1006
|
+
}
|
|
1007
|
+
function chartIds(type) {
|
|
1008
|
+
return (DERIVED_FORMS[type] ?? variantsFor(type)).map((form) => `${type}.${form}`);
|
|
1009
|
+
}
|
|
1010
|
+
function variantDefault(type) {
|
|
1011
|
+
if (!getChartDefinition(type)) return;
|
|
1012
|
+
let value = optionFields(type).find((field) => field.path === "variant")?.default;
|
|
1013
|
+
return value === void 0 ? void 0 : String(value);
|
|
1014
|
+
}
|
|
1015
|
+
function chartIdOf(type, data, options) {
|
|
1016
|
+
let opts = options, form = derivedForm(type, data, opts) ?? opts?.variant ?? variantDefault(type) ?? IMPLIED_VARIANT[type];
|
|
1017
|
+
return form === void 0 ? type : `${type}.${form}`;
|
|
1018
|
+
}
|
|
1019
|
+
var optionFieldCache = /* @__PURE__ */ new Map();
|
|
1020
|
+
function optionFields(type) {
|
|
1021
|
+
let cached = optionFieldCache.get(type);
|
|
1022
|
+
if (cached) return cached;
|
|
1023
|
+
let definition = getChartDefinition(type);
|
|
1024
|
+
if (!definition) throw new Error(`unknown chart type '${type}'`);
|
|
1025
|
+
let fields2 = schemaReference(z.toJSONSchema(definition.optionsSchema, { io: "input" }), definition.defaults);
|
|
1026
|
+
return optionFieldCache.set(type, fields2), fields2;
|
|
1027
|
+
}
|
|
1028
|
+
var sharedCache;
|
|
1029
|
+
function sharedOptionFields() {
|
|
1030
|
+
return sharedCache ??= schemaReference(z.toJSONSchema(baseOptionsSchema, { io: "input" })), sharedCache;
|
|
1031
|
+
}
|
|
1032
|
+
var PRESET_THEME_NAMES = Object.freeze(Object.keys(themes)), CLAUSE_MAX = 80;
|
|
1033
|
+
function firstClause(text) {
|
|
1034
|
+
let trimmed = text.trim(), depth = 0, end = trimmed.length;
|
|
1035
|
+
for (let index = 0; index < trimmed.length; index++) {
|
|
1036
|
+
let char = trimmed[index];
|
|
1037
|
+
if (char === "(") depth++;
|
|
1038
|
+
else if (char === ")") depth = Math.max(0, depth - 1);
|
|
1039
|
+
else if (depth === 0 && (char === "." || char === ";") && (index + 1 === trimmed.length || trimmed[index + 1] === " ") && !/\b(?:e\.g|i\.e|etc|vs)$/.test(trimmed.slice(0, index))) {
|
|
1040
|
+
end = index;
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
let clause = trimmed.slice(0, end);
|
|
1045
|
+
if (clause.length > CLAUSE_MAX) {
|
|
1046
|
+
let commas = [], level = 0;
|
|
1047
|
+
for (let index = 0; index < clause.length; index++) {
|
|
1048
|
+
let char = clause[index];
|
|
1049
|
+
char === "(" ? level++ : char === ")" ? level = Math.max(0, level - 1) : level === 0 && char === "," && clause[index + 1] === " " && commas.push(index);
|
|
1050
|
+
}
|
|
1051
|
+
let comma = Math.max(-1, ...commas.filter((index) => index <= CLAUSE_MAX));
|
|
1052
|
+
comma <= 30 && (comma = commas.find((index) => index >= CLAUSE_MAX) ?? -1), comma > 30 && comma <= CLAUSE_MAX * 1.5 && (clause = clause.slice(0, comma));
|
|
1053
|
+
}
|
|
1054
|
+
return clause === trimmed.replace(/\.$/, "") ? `${clause}.` : `${clause}\u2026`;
|
|
1055
|
+
}
|
|
1056
|
+
function valueText(value) {
|
|
1057
|
+
return typeof value == "string" ? value : JSON.stringify(value);
|
|
1058
|
+
}
|
|
1059
|
+
function fieldLine(field, meaning, options = {}) {
|
|
1060
|
+
let type = options.type ?? field.type, parts = [type];
|
|
1061
|
+
if (options.required && parts.push("required"), field.values) {
|
|
1062
|
+
let members = new Set(type.split(" | ")), named = (value) => members.has(valueText(value)), values = field.valuesExhaustive === !1 ? field.values.filter((value) => !named(value)) : field.values.every(named) ? [] : field.values;
|
|
1063
|
+
values.length && parts.push(`${field.valuesExhaustive === !1 ? "accepts" : "one of"} ${values.map(valueText).join(" | ")}`);
|
|
1064
|
+
}
|
|
1065
|
+
let scalarDefault = field.default === null || typeof field.default != "object" || Array.isArray(field.default);
|
|
1066
|
+
return Object.hasOwn(field, "default") && field.default !== void 0 && scalarDefault && !field.defaultInSchema && parts.push(`default ${valueText(field.default)}`), `${parts.join(", ")}. ${meaning}`;
|
|
1067
|
+
}
|
|
1068
|
+
var ANCHOR_FORM = "An annotation anchor is a category or item id string, or an object with categoryId plus optional seriesId, segmentId and edge (start, end, total); pointId addresses a scatter point. Category anchors, including from/to, take category ids, not category labels.", CELL_CONTRACT = "A number, null (missing), or an object with one of number, pct (50.5 means 50.5%) or date (ISO 8601), plus optional fill, format, label (text or false), priority, scenario (AC|PY|PL|FC), footnote and, on range types, range {low, high, mid}.";
|
|
1069
|
+
function sharedOptionsSummary() {
|
|
1070
|
+
let fields2 = sharedOptionFields(), rows = {};
|
|
1071
|
+
for (let field of fields2) {
|
|
1072
|
+
if (field.path.includes(".") || field.path.includes("[") || field.type === "never" || /^Reserved\b/.test(field.description)) continue;
|
|
1073
|
+
let keys = [...new Set(fields2.filter((child) => child.path.startsWith(`${field.path}.`) && !child.path.slice(field.path.length + 1).includes(".")).map((child) => child.path.slice(field.path.length + 1)))], type = WORDING_KEYS.has(field.path) ? `${field.type} {${keys.length} label keys}` : keys.length ? `${field.type} {${keys.join(", ")}}` : field.type;
|
|
1074
|
+
rows[field.path] = fieldLine(field, firstClause(field.description), { type });
|
|
1075
|
+
}
|
|
1076
|
+
return rows;
|
|
1077
|
+
}
|
|
1078
|
+
var UNSUPPORTED_REQUIRES = {
|
|
1079
|
+
tornado: ["options.baseValue", "options.tornado.low", "options.tornado.high"]
|
|
1080
|
+
}, TYPE_ORDER = [
|
|
1081
|
+
"column",
|
|
1082
|
+
"bar",
|
|
1083
|
+
"line",
|
|
1084
|
+
"dimswitch",
|
|
1085
|
+
"table",
|
|
1086
|
+
"waterfall",
|
|
1087
|
+
"kpi",
|
|
1088
|
+
"combo",
|
|
1089
|
+
"variance",
|
|
1090
|
+
"bullet",
|
|
1091
|
+
"bartable",
|
|
1092
|
+
"pvm",
|
|
1093
|
+
"pie",
|
|
1094
|
+
"status",
|
|
1095
|
+
"heatmap",
|
|
1096
|
+
"gantt",
|
|
1097
|
+
"scatter",
|
|
1098
|
+
"funnel",
|
|
1099
|
+
"pareto",
|
|
1100
|
+
"mekko",
|
|
1101
|
+
"sparkline",
|
|
1102
|
+
"treemap",
|
|
1103
|
+
"sankey",
|
|
1104
|
+
"grid",
|
|
1105
|
+
"slope",
|
|
1106
|
+
"dot",
|
|
1107
|
+
"cohort",
|
|
1108
|
+
"choropleth",
|
|
1109
|
+
"butterfly",
|
|
1110
|
+
"likert",
|
|
1111
|
+
"histogram",
|
|
1112
|
+
"box",
|
|
1113
|
+
"waffle",
|
|
1114
|
+
"pyramid",
|
|
1115
|
+
"diagram",
|
|
1116
|
+
"tilemap",
|
|
1117
|
+
"creative"
|
|
1118
|
+
];
|
|
1119
|
+
function byTypeOrder(left, right) {
|
|
1120
|
+
let rank = (type) => {
|
|
1121
|
+
let at = TYPE_ORDER.indexOf(type);
|
|
1122
|
+
return at === -1 ? TYPE_ORDER.length : at;
|
|
1123
|
+
};
|
|
1124
|
+
return rank(left) - rank(right) || (left < right ? -1 : left > right ? 1 : 0);
|
|
1125
|
+
}
|
|
1126
|
+
function buildCatalog() {
|
|
1127
|
+
let types = listCharts().slice().sort((left, right) => byTypeOrder(left.type, right.type)).map((chart) => {
|
|
1128
|
+
let ids = chartIds(chart.type);
|
|
1129
|
+
return {
|
|
1130
|
+
type: chart.type,
|
|
1131
|
+
summary: shortSummaryFor(chart.type, chart.summary),
|
|
1132
|
+
useCases: useCasesFor(chart.type),
|
|
1133
|
+
...ids.length ? { ids } : {},
|
|
1134
|
+
...chart.aliases.length ? { aliases: chart.aliases } : {},
|
|
1135
|
+
minWidth: chart.sizing.minWidth,
|
|
1136
|
+
minHeight: chart.sizing.minHeight,
|
|
1137
|
+
fit: chart.sizing.fit
|
|
1138
|
+
};
|
|
1139
|
+
});
|
|
1140
|
+
return {
|
|
1141
|
+
engine: version,
|
|
1142
|
+
types,
|
|
1143
|
+
sharedOptions: sharedOptionsSummary(),
|
|
1144
|
+
cell: CELL_CONTRACT,
|
|
1145
|
+
anchor: ANCHOR_FORM,
|
|
1146
|
+
themes: { presets: [...PRESET_THEME_NAMES], contract: "boardplot_describe with type theme" },
|
|
1147
|
+
unsupported: unsupported.map((entry) => ({
|
|
1148
|
+
name: entry.name,
|
|
1149
|
+
use: entry.use === null ? null : {
|
|
1150
|
+
...entry.use,
|
|
1151
|
+
...UNSUPPORTED_REQUIRES[entry.name] ? { requires: [...UNSUPPORTED_REQUIRES[entry.name]] } : {}
|
|
1152
|
+
}
|
|
1153
|
+
})),
|
|
1154
|
+
forms: { drawn: ["svg", "png"], notDrawn: ["html report", "slide deck", "pdf", "scrolling dashboard"] },
|
|
1155
|
+
limits: { requestBytes: 10 * 1024 * 1024, errorsPerResponse: 10, fixturesPerPage: 25, pngScaleMax: 8 }
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// src/core/lint/design.ts
|
|
1160
|
+
var DOCS = {
|
|
1161
|
+
"design-bar-sort": "docs/reference/bar.md#design-bar-sort",
|
|
1162
|
+
"design-bar-many": "docs/reference/bar.md#design-bar-many",
|
|
1163
|
+
"design-line-direct-labels": "docs/reference/line.md#design-line-direct-labels",
|
|
1164
|
+
"design-line-label-points": "docs/reference/line.md#design-line-label-points",
|
|
1165
|
+
"design-waterfall-closing-total": "docs/reference/waterfall.md#design-waterfall-closing-total",
|
|
1166
|
+
"design-waterfall-horizontal": "docs/reference/waterfall.md#design-waterfall-horizontal"
|
|
1167
|
+
}, ADVICE_PER_RENDER = 3, BARS_MAX = 15, BARS_KEPT = 10, LABELLED_POINTS_MAX = 12, LINES_MAX = 6, ORDERED_NAME = /\d|\b(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?|mon(?:day)?|tue(?:sday)?|wed(?:nesday)?|thu(?:rsday)?|fri(?:day)?|sat(?:urday)?|sun(?:day)?|very|strongly|somewhat|low|medium|mid|high|small|large|first|second|third|last|before|after|early|late|stage|phase|step)\b/i, PINNED_NAME = /^(?:total|others?|rest|average|avg|all|overall)\b/i;
|
|
1168
|
+
function runDesignLints(charts) {
|
|
1169
|
+
let found = [];
|
|
1170
|
+
for (let chart of charts)
|
|
1171
|
+
!chart.requireMessageTitle || !chart.geometry || (chart.type === "bar" ? found.push(...barAdvice(chart)) : chart.type === "line" ? found.push(...lineAdvice(chart)) : chart.type === "waterfall" && found.push(...waterfallAdvice(chart)));
|
|
1172
|
+
return found.slice(0, ADVICE_PER_RENDER);
|
|
1173
|
+
}
|
|
1174
|
+
function advice(chart, code, field, suggest, fix, drawn2) {
|
|
1175
|
+
let base = chart.path;
|
|
1176
|
+
return {
|
|
1177
|
+
code,
|
|
1178
|
+
severity: "advice",
|
|
1179
|
+
message: `chart '${chart.displayName}'${drawn2 ? ` (${drawn2})` : ""}: ${designRuleText(code)}`,
|
|
1180
|
+
suggest,
|
|
1181
|
+
docs: DOCS[code],
|
|
1182
|
+
...base === void 0 ? {} : {
|
|
1183
|
+
path: `${base}${field}`,
|
|
1184
|
+
fix: fix.map((operation) => ({ ...operation, path: `${base}${operation.path}` }))
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
function valuesInOrder(series, categories) {
|
|
1189
|
+
let entries = Array.isArray(series.values) ? series.values : [], keyed = entries.length > 0 && entries.every((entry) => isRecord(entry) && "categoryId" in entry);
|
|
1190
|
+
return categories.map((category, index) => {
|
|
1191
|
+
let entry = keyed ? entries.find((candidate) => isRecord(candidate) && candidate.categoryId === category.id) : entries[index];
|
|
1192
|
+
return cellNumber(isRecord(entry) && "categoryId" in entry ? entry.value : entry);
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
function largestFirst(values) {
|
|
1196
|
+
return values.every((value, index) => index === 0 || value <= values[index - 1]);
|
|
1197
|
+
}
|
|
1198
|
+
function rankable(categories) {
|
|
1199
|
+
return categories.every((category) => {
|
|
1200
|
+
let name = labelOf(category) ?? "";
|
|
1201
|
+
return category.date === void 0 && !category.gapAfter && !category.breakAfter && !ORDERED_NAME.test(name) && !PINNED_NAME.test(name.trim());
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
function drawnBars(chart) {
|
|
1205
|
+
let ids = /* @__PURE__ */ new Set();
|
|
1206
|
+
for (let node2 of chart.geometry?.scene ?? [])
|
|
1207
|
+
node2.t === "rect" && node2.part === "bar" && node2.owner.categoryId && ids.add(node2.owner.categoryId);
|
|
1208
|
+
return ids.size || void 0;
|
|
1209
|
+
}
|
|
1210
|
+
function barAdvice(chart) {
|
|
1211
|
+
let options = chartOptions(chart), variant = options.variant ?? "grouped";
|
|
1212
|
+
if (variant === "tornado" || variant === "football-field") return [];
|
|
1213
|
+
let categories = categoriesOf(chart), found = [], dataSeries = seriesOf(chart).filter((series) => series.role !== "reference");
|
|
1214
|
+
if (!rankable(categories)) return [];
|
|
1215
|
+
if (variant === "grouped" && options.sort === void 0 && options.topN === void 0 && dataSeries.length === 1 && categories.length >= 5 && categories.length <= BARS_MAX) {
|
|
1216
|
+
let values = valuesInOrder(dataSeries[0], categories);
|
|
1217
|
+
values.every((value) => value !== null) && !largestFirst(values) && found.push(advice(
|
|
1218
|
+
chart,
|
|
1219
|
+
"design-bar-sort",
|
|
1220
|
+
"/options/sort",
|
|
1221
|
+
"set options.sort.categories to desc",
|
|
1222
|
+
[{ op: "replace", path: "/options/sort", value: { categories: "desc" } }]
|
|
1223
|
+
));
|
|
1224
|
+
}
|
|
1225
|
+
let topN = isRecord(options.topN) && typeof options.topN.n == "number" ? options.topN : void 0, cut = topN && categories.length > topN.n ? topN.n + (topN.rest === !1 ? 0 : 1) : categories.length, drawn2 = drawnBars(chart) ?? cut;
|
|
1226
|
+
if (drawn2 > BARS_MAX) {
|
|
1227
|
+
let fix = isRecord(options.topN) ? [{ op: "replace", path: "/options/topN/n", value: BARS_KEPT }] : [{ op: "replace", path: "/options/topN", value: { n: BARS_KEPT, rest: !0 } }];
|
|
1228
|
+
found.push(advice(chart, "design-bar-many", "/options/topN", `keep the top ${BARS_KEPT} with options.topN and fold the rest into Others`, fix, `${drawn2} bars drawn`));
|
|
1229
|
+
}
|
|
1230
|
+
return found;
|
|
1231
|
+
}
|
|
1232
|
+
function legendPosition(legend) {
|
|
1233
|
+
return isRecord(legend) ? legend.position : legend;
|
|
1234
|
+
}
|
|
1235
|
+
function between(count, low, high) {
|
|
1236
|
+
return count >= low && count <= high;
|
|
1237
|
+
}
|
|
1238
|
+
function drawnLines(chart) {
|
|
1239
|
+
let ids = /* @__PURE__ */ new Set();
|
|
1240
|
+
for (let node2 of chart.geometry?.scene ?? [])
|
|
1241
|
+
node2.t === "path" && node2.part === "line" && node2.owner.seriesId && ids.add(node2.owner.seriesId);
|
|
1242
|
+
return ids.size || void 0;
|
|
1243
|
+
}
|
|
1244
|
+
function drawnPeriods(chart, options) {
|
|
1245
|
+
let live = chart.geometry?.derived?.liveWindow;
|
|
1246
|
+
if (Array.isArray(live?.displayedCategoryIds)) return live.displayedCategoryIds.length;
|
|
1247
|
+
let categories = categoriesOf(chart), zoom = isRecord(options.viewDomain) && Array.isArray(options.viewDomain.x) ? options.viewDomain.x : void 0;
|
|
1248
|
+
if (zoom) {
|
|
1249
|
+
let [from, to] = zoom.map((id) => categories.findIndex((category) => category.id === id));
|
|
1250
|
+
if (from !== void 0 && to !== void 0 && from >= 0 && to >= 0) return Math.abs(to - from) + 1;
|
|
1251
|
+
}
|
|
1252
|
+
return categories.length;
|
|
1253
|
+
}
|
|
1254
|
+
function lineAdvice(chart) {
|
|
1255
|
+
let options = chartOptions(chart), found = [], series = seriesOf(chart), dataSeries = series.filter((item) => item.role !== "reference"), plainLines = (options.variant ?? "line") === "line" && options.fan === void 0 && dataSeries.length === series.length && between(drawnLines(chart) ?? dataSeries.length, 2, LINES_MAX) && dataSeries.every((item) => item.scenario === void 0 || String(item.scenario).toUpperCase().startsWith("AC")), position = legendPosition(options.legend), namedOnLines = options.seriesLabels !== "key" && options.seriesLabels !== "none";
|
|
1256
|
+
plainLines && (position === "top" || position === "bottom") && !namedOnLines && chart.drawsWith?.({ legend: "none", seriesLabels: "end" }) !== !1 && found.push(advice(chart, "design-line-direct-labels", "/options/legend", "set options.legend to none and options.seriesLabels to end", [
|
|
1257
|
+
{ op: "replace", path: "/options/legend", value: "none" },
|
|
1258
|
+
{ op: "replace", path: "/options/seriesLabels", value: "end" }
|
|
1259
|
+
]));
|
|
1260
|
+
let periods = drawnPeriods(chart, options);
|
|
1261
|
+
return options.valueLabels === "all" && periods > LABELLED_POINTS_MAX && found.push(advice(
|
|
1262
|
+
chart,
|
|
1263
|
+
"design-line-label-points",
|
|
1264
|
+
"/options/valueLabels",
|
|
1265
|
+
"remove options.valueLabels for the default, or set it to last or ends",
|
|
1266
|
+
[{ op: "remove", path: "/options/valueLabels" }],
|
|
1267
|
+
`${periods} periods drawn`
|
|
1268
|
+
)), found;
|
|
1269
|
+
}
|
|
1270
|
+
var CROWDED_NAMES = /* @__PURE__ */ new Set(["category-labels-rotated", "category-labels-truncated", "category-stride"]);
|
|
1271
|
+
function waterfallAdvice(chart) {
|
|
1272
|
+
let options = chartOptions(chart), items = records(isRecord(chart.data) ? chart.data.items : void 0), found = [], last = items.at(-1);
|
|
1273
|
+
if (items.length >= 2 && last && last.type !== "total" && last.type !== "subtotal") {
|
|
1274
|
+
let ids = new Set(items.map((item) => item.id)), id = "total";
|
|
1275
|
+
for (let suffix = 2; ids.has(id); suffix++) id = `total-${suffix}`;
|
|
1276
|
+
found.push(advice(
|
|
1277
|
+
chart,
|
|
1278
|
+
"design-waterfall-closing-total",
|
|
1279
|
+
"/data/items",
|
|
1280
|
+
"add a last item with type total (with rows, a last row whose type is total); Boardplot sums the steps",
|
|
1281
|
+
[{ op: "add", path: "/data/items/-", value: { id, label: "Total", type: "total" } }]
|
|
1282
|
+
));
|
|
1283
|
+
}
|
|
1284
|
+
return (options.variant ?? "vertical") === "vertical" && chart.geometry.warnings.some((warning2) => CROWDED_NAMES.has(warning2.code)) && chart.drawsWith?.({ variant: "horizontal" }) !== !1 && found.push(advice(
|
|
1285
|
+
chart,
|
|
1286
|
+
"design-waterfall-horizontal",
|
|
1287
|
+
"/options/variant",
|
|
1288
|
+
"set options.variant to horizontal; the names then read in a column left of the bars",
|
|
1289
|
+
[{ op: "replace", path: "/options/variant", value: "horizontal" }]
|
|
1290
|
+
)), found;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/core/lint/index.ts
|
|
1294
|
+
var lintCodes = [
|
|
1295
|
+
"partial-period-pairing",
|
|
1296
|
+
"basis-change",
|
|
1297
|
+
"non-additive-stack",
|
|
1298
|
+
"duplicate-category-labels",
|
|
1299
|
+
"spurious-precision",
|
|
1300
|
+
"missing-message-title",
|
|
1301
|
+
"series-overload",
|
|
1302
|
+
"integrated-stacked-variance-overload",
|
|
1303
|
+
"pie-too-many-slices",
|
|
1304
|
+
"legend-redundant",
|
|
1305
|
+
"unlabeled-units",
|
|
1306
|
+
"scenario-unexplained",
|
|
1307
|
+
"series-unexplained"
|
|
1308
|
+
];
|
|
1309
|
+
function runDocLints(doc, includePaths = !1) {
|
|
1310
|
+
let charts = flattenCharts(doc.charts, includePaths);
|
|
1311
|
+
return [...runHonestyLints(charts), ...runPartnerLints(charts)];
|
|
1312
|
+
}
|
|
1313
|
+
function runDocAdvice(doc, includePaths = !1) {
|
|
1314
|
+
return runDesignLints(flattenCharts(doc.charts, includePaths));
|
|
1315
|
+
}
|
|
1316
|
+
function flattenCharts(charts, includePaths) {
|
|
1317
|
+
let flattened = [];
|
|
1318
|
+
return charts.forEach((chart, index) => {
|
|
1319
|
+
let displayName = chart.name?.trim() || `${chart.type}-${index + 1}`;
|
|
1320
|
+
visit(chart, displayName, !0, flattened, void 0, includePaths ? `/charts/${index}` : void 0);
|
|
1321
|
+
}), flattened;
|
|
1322
|
+
}
|
|
1323
|
+
function visit(chart, displayName, requireMessageTitle, output, parentLegend, path, dataPath = path === void 0 ? void 0 : `${path}/data`) {
|
|
1324
|
+
let definition = getChart(chart.type), canonicalChart = {
|
|
1325
|
+
...chart,
|
|
1326
|
+
type: definition?.type ?? chart.type,
|
|
1327
|
+
options: requireMessageTitle ? automaticLegendOptions(chart.options, chart.type, chart.data) : chart.options
|
|
1328
|
+
};
|
|
1329
|
+
if (output.push({
|
|
1330
|
+
...canonicalChart,
|
|
1331
|
+
displayName,
|
|
1332
|
+
requireMessageTitle,
|
|
1333
|
+
authoredType: chart.type,
|
|
1334
|
+
typeTitle: definition?.title,
|
|
1335
|
+
parentLegend,
|
|
1336
|
+
path
|
|
1337
|
+
}), canonicalChart.type !== "grid") return;
|
|
1338
|
+
let data = asRecord(canonicalChart.data), parentFootnotes = Array.isArray(canonicalChart.options?.footnotes) ? canonicalChart.options.footnotes : void 0, parentSubtitle = canonicalChart.options?.subtitle, parentPalette = canonicalChart.options?.palette, gridLegend = canonicalChart.options?.legend;
|
|
1339
|
+
if (Array.isArray(data.panels)) {
|
|
1340
|
+
let recordIndex = -1;
|
|
1341
|
+
data.panels.forEach((panel, index) => {
|
|
1342
|
+
if (!isRecord(panel) || (recordIndex += 1, typeof panel.type != "string")) return;
|
|
1343
|
+
let id = typeof panel.id == "string" ? panel.id : `panel-${recordIndex + 1}`;
|
|
1344
|
+
visit(
|
|
1345
|
+
{
|
|
1346
|
+
name: id,
|
|
1347
|
+
geometry: chart.geometry,
|
|
1348
|
+
geometryPrefix: `${chart.geometryPrefix ?? ""}${id}/`,
|
|
1349
|
+
type: panel.type,
|
|
1350
|
+
data: panel.data,
|
|
1351
|
+
options: inheritExplanations(panel.options, parentFootnotes, parentSubtitle, parentPalette),
|
|
1352
|
+
annotations: Array.isArray(panel.annotations) ? panel.annotations : void 0
|
|
1353
|
+
},
|
|
1354
|
+
`${displayName}/${id}`,
|
|
1355
|
+
!1,
|
|
1356
|
+
output,
|
|
1357
|
+
gridLegend,
|
|
1358
|
+
dataPath === void 0 ? void 0 : `${dataPath}/panels/${index}`
|
|
1359
|
+
);
|
|
1360
|
+
});
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
let repeat = asRecord(data.repeat), template = asRecord(data.template), bySlice = asRecord(asRecord(template.data).bySlice);
|
|
1364
|
+
typeof template.type != "string" || !Array.isArray(repeat.values) || repeat.values.forEach((value, index) => {
|
|
1365
|
+
if (typeof value != "string" || !(value in bySlice)) return;
|
|
1366
|
+
let slicePath = dataPath === void 0 ? void 0 : `${dataPath}/template/data/bySlice${toJsonPointer([value])}`, id = typeof template.id == "string" ? template.id.split(`$${repeat.dimension}`).join(value) : value;
|
|
1367
|
+
visit(
|
|
1368
|
+
{
|
|
1369
|
+
name: id,
|
|
1370
|
+
geometry: chart.geometry,
|
|
1371
|
+
geometryPrefix: `${chart.geometryPrefix ?? ""}${id}/`,
|
|
1372
|
+
type: template.type,
|
|
1373
|
+
data: bySlice[value],
|
|
1374
|
+
options: inheritExplanations(template.options, parentFootnotes, parentSubtitle, parentPalette),
|
|
1375
|
+
annotations: Array.isArray(template.annotations) ? template.annotations : void 0
|
|
1376
|
+
},
|
|
1377
|
+
`${displayName}/${value || index + 1}`,
|
|
1378
|
+
!1,
|
|
1379
|
+
output,
|
|
1380
|
+
gridLegend,
|
|
1381
|
+
slicePath,
|
|
1382
|
+
slicePath
|
|
1383
|
+
);
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
function automaticLegendOptions(options, type, data) {
|
|
1387
|
+
if (options?.legend === "none" && keepsUnnamedSeriesKey(type)) return { ...options, legend: "auto" };
|
|
1388
|
+
if (options?.legend !== void 0) return options;
|
|
1389
|
+
try {
|
|
1390
|
+
return needsSeriesKey(type, data, options) || resolveTheme(options?.theme).legend?.auto === !0 ? { ...options, legend: "auto" } : options;
|
|
1391
|
+
} catch {
|
|
1392
|
+
return options;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
function inheritExplanations(options, parentFootnotes, parentSubtitle, parentPalette) {
|
|
1396
|
+
let authored = isRecord(options) ? options : void 0, merged = authored;
|
|
1397
|
+
return authored?.footnotes === void 0 && parentFootnotes !== void 0 && (merged = { ...merged ?? {}, footnotes: parentFootnotes }), authored?.subtitle === void 0 && parentSubtitle !== void 0 && (merged = { ...merged ?? {}, subtitle: parentSubtitle }), authored?.palette === void 0 && typeof parentPalette == "string" && (merged = { ...merged ?? {}, palette: parentPalette }), merged;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// src/core/lint/aspect.ts
|
|
1401
|
+
var PLOT_MIN = { cartesianH: 120, cartesianW: 320, cardH: 40, appliesFromWidth: 720 };
|
|
1402
|
+
function legalSteps(cls) {
|
|
1403
|
+
return ASPECT_LADDER.filter((s) => cls === "strip" ? !0 : s.ratio <= ASPECT_CAPS.flatNonStrip);
|
|
1404
|
+
}
|
|
1405
|
+
function nextStepUp(width, minHeight, cls) {
|
|
1406
|
+
for (let { name, ratio } of legalSteps(cls)) {
|
|
1407
|
+
let height = Math.round(width / ratio);
|
|
1408
|
+
if (height >= minHeight) return { name, height };
|
|
1409
|
+
}
|
|
1410
|
+
return null;
|
|
1411
|
+
}
|
|
1412
|
+
function hostSlot(options) {
|
|
1413
|
+
let size = options?.size;
|
|
1414
|
+
return size === "a4-landscape-content" || size === "a4-portrait-content" ? !0 : size === void 0 ? options?.target === "slide" || options?.target === "print" : typeof size == "object" && size !== null && "height" in size && typeof size.height == "number" && "unit" in size && (size.unit === "pt" || size.unit === "mm");
|
|
1415
|
+
}
|
|
1416
|
+
function aspectDocLints(type, options, geo) {
|
|
1417
|
+
let cls = aspectClassFor(type, options, geo.marks);
|
|
1418
|
+
if (!cls) return [];
|
|
1419
|
+
if (contentSized(type, options, geo.sizing?.fit)) return [];
|
|
1420
|
+
if (hostSlot(options)) return [];
|
|
1421
|
+
let warnings = [], { width, height } = geo.size, canvas = `${width}x${height}`, ratio = width / height, rowDriven = cls === "row-driven" || cls === "matrix" || type === "bullet", fixedRows = (type === "bar" || type === "likert") && resolveTheme(options?.theme).space.barRow !== void 0, flatCapRatio = cls === "strip" ? ASPECT_CAPS.flatAbsolute : ASPECT_CAPS.flatNonStrip, flatMinHeight = Math.round(width / flatCapRatio), tallMaxHeight = Math.round(width / ASPECT_CAPS.tall), minHeight = geo.sizing?.minHeight ?? 0, automaticTall = height > tallMaxHeight && heightOmitted(options?.size);
|
|
1422
|
+
if (type !== "table" && height < flatMinHeight * (1 - LADDER_TOLERANCE))
|
|
1423
|
+
warnings.push({
|
|
1424
|
+
code: "aspect-cap",
|
|
1425
|
+
severity: "warn",
|
|
1426
|
+
message: `'${type}' canvas ${canvas} is ${ratio.toFixed(2)}:1, flatter than the ${flatCapRatio.toFixed(2)}:1 limit this type allows. At width ${width} the height has to be at least ${flatMinHeight}px.`,
|
|
1427
|
+
suggest: `Raise the height to ${flatMinHeight}px.`,
|
|
1428
|
+
field: ["options", "size"],
|
|
1429
|
+
fix: [{ op: "replace", path: "/options/size", value: { width, height: flatMinHeight } }]
|
|
1430
|
+
});
|
|
1431
|
+
else if (!rowDriven && !automaticTall && height > tallMaxHeight * (1 + LADDER_TOLERANCE)) {
|
|
1432
|
+
let canLower = tallMaxHeight >= minHeight;
|
|
1433
|
+
warnings.push({
|
|
1434
|
+
code: "aspect-cap",
|
|
1435
|
+
severity: "warn",
|
|
1436
|
+
message: `'${type}' canvas ${canvas} is ${ratio.toFixed(2)}:1, taller than the ${ASPECT_CAPS.tall.toFixed(2)}:1 limit. Only charts whose height comes from their row count go above it. At width ${width} the height has to be at most ${tallMaxHeight}px.`,
|
|
1437
|
+
suggest: canLower ? `Lower the height to ${tallMaxHeight}px.` : "Shorten the chart content or use a wider canvas.",
|
|
1438
|
+
field: ["options", "size"],
|
|
1439
|
+
...canLower ? { fix: [{ op: "replace", path: "/options/size", value: { width, height: tallMaxHeight } }] } : {}
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
if (onLadderStep(geo.size) === null && !automaticTall && !heightOmitted(options?.size)) {
|
|
1443
|
+
let nearest = nearestLadderStep(geo.size);
|
|
1444
|
+
if (rowDriven)
|
|
1445
|
+
warnings.push({
|
|
1446
|
+
code: "height-off-ladder:row-driven",
|
|
1447
|
+
severity: "info",
|
|
1448
|
+
message: `'${type}' canvas ${canvas} is off the standard height steps. ${fixedRows ? "The theme fixes the row pitch, and the authored height only adds space under the rows" : type === "table" ? "A table takes its height from its rows, and the authored height only adds space under them" : "This type takes its natural height from its rows, and the authored height stretches them to fill the canvas"}, so this is an observation only. The nearest step is ${nearest.name} at ${width}x${nearest.height}.`
|
|
1449
|
+
});
|
|
1450
|
+
else {
|
|
1451
|
+
let canSnap = nearest.height >= minHeight;
|
|
1452
|
+
warnings.push({
|
|
1453
|
+
code: "height-off-ladder",
|
|
1454
|
+
severity: "warn",
|
|
1455
|
+
message: `'${type}' canvas ${canvas} is off the standard height steps for width ${width}. The nearest step is ${nearest.name} at ${width}x${nearest.height}.`,
|
|
1456
|
+
suggest: canSnap ? `Use height ${nearest.height}px at width ${width}.` : "Shorten the chart content or use a wider canvas.",
|
|
1457
|
+
field: ["options", "size"],
|
|
1458
|
+
...canSnap ? { fix: [{ op: "replace", path: "/options/size", value: { width, height: nearest.height } }] } : {}
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
let cartesian = cls === "standard-cartesian" || cls === "wide-time", plotW = Math.round(geo.plot.w), plotH = Math.round(geo.plot.h);
|
|
1463
|
+
if (cartesian && width >= PLOT_MIN.appliesFromWidth && (plotH < PLOT_MIN.cartesianH || plotW < PLOT_MIN.cartesianW)) {
|
|
1464
|
+
let deficit = Math.max(0, PLOT_MIN.cartesianH - plotH), step = nextStepUp(width, height + deficit, cls), roomy = step && plotW >= PLOT_MIN.cartesianW, remedy = roomy ? `Raise the height to ${step.height}px, or present the figures as a table.` : "Present the figures as a table.";
|
|
1465
|
+
warnings.push({
|
|
1466
|
+
code: "plot-under-min",
|
|
1467
|
+
severity: "warn",
|
|
1468
|
+
message: `'${type}' leaves only ${plotW}x${plotH}px for the plot itself, under the ${PLOT_MIN.cartesianW}x${PLOT_MIN.cartesianH}px floor. ${remedy}`,
|
|
1469
|
+
suggest: remedy,
|
|
1470
|
+
field: ["options", "size"],
|
|
1471
|
+
...roomy ? { fix: [{ op: "replace", path: "/options/size", value: { width, height: step.height } }] } : {}
|
|
1472
|
+
});
|
|
1473
|
+
} else if (cls === "card" && plotH < PLOT_MIN.cardH) {
|
|
1474
|
+
let step = nextStepUp(width, height + (PLOT_MIN.cardH - plotH), cls);
|
|
1475
|
+
warnings.push({
|
|
1476
|
+
code: "plot-under-min",
|
|
1477
|
+
severity: "warn",
|
|
1478
|
+
message: `'${type}' card plot is ${plotH}px high, under the ${PLOT_MIN.cardH}px floor. ${step ? `Raise the height to ${step.height}px, or present the figures as a table.` : "Present the figures as a table."}`,
|
|
1479
|
+
suggest: step ? `Raise the height to ${step.height}px.` : "Present the figures as a table.",
|
|
1480
|
+
field: ["options", "size"],
|
|
1481
|
+
...step ? { fix: [{ op: "replace", path: "/options/size", value: { width, height: step.height } }] } : {}
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
return warnings;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
// src/core/lint/lineIntegrity.ts
|
|
1488
|
+
var LINE_SERIES_SPAN_MIN_FRACTION = 0.05, LINE_SERIES_SPAN_MIN_EFFECTIVE_PX = 12, LINE_SERIES_CONTEXT_MIN_FRACTION = 0.25, LINE_SERIES_VALUE_VARIATION_MIN_RATIO = 0.25;
|
|
1489
|
+
function effectiveScale(options, geometry) {
|
|
1490
|
+
let embed = options?.embed;
|
|
1491
|
+
return typeof embed?.width == "number" && embed.width > 0 ? embed.width / geometry.size.width : 1;
|
|
1492
|
+
}
|
|
1493
|
+
function percent(value) {
|
|
1494
|
+
return `${(value * 100).toFixed(1)}%`;
|
|
1495
|
+
}
|
|
1496
|
+
function lineIntegrityDocLints(type, options, geometry) {
|
|
1497
|
+
if (type !== "line" || geometry.warnings.some((warning2) => warning2.severity === "error")) return [];
|
|
1498
|
+
let findings = [], economy = geometry.derived.endpointLabelEconomy;
|
|
1499
|
+
if (economy?.overflow) {
|
|
1500
|
+
let legendPosition2 = options?.legend && typeof options.legend == "object" && !Array.isArray(options.legend) ? options.legend.position : options?.legend, repairs = legendPosition2 !== "none" && legendPosition2 !== "right" && (!options?.labelPlacements || Object.keys(options.labelPlacements).length === 0) ? "Set series.shortLabel, move the legend to a horizontal band, or widen the canvas." : legendPosition2 === "none" ? "Shorten the series labels, drop legend: 'none' so a legend carries the names, or widen the canvas." : "Set series.shortLabel, or widen the canvas.";
|
|
1501
|
+
findings.push({
|
|
1502
|
+
code: "label-gutter-over-budget",
|
|
1503
|
+
severity: "warn",
|
|
1504
|
+
message: `The end labels need ${economy.effectiveRequiredGutter.toFixed(1)} effective px of gutter, over the ${economy.effectiveBudget.toFixed(1)} px budget (${(economy.maxGutterFraction * 100).toFixed(0)}% of the width). ` + repairs,
|
|
1505
|
+
suggest: repairs
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
let variant = typeof options?.variant == "string" ? options.variant : "line";
|
|
1509
|
+
if (variant !== "line" && variant !== "area" || geometry.plot.h <= 0) return findings;
|
|
1510
|
+
let scale = effectiveScale(options, geometry), spans = geometry.marks.series.flatMap((series) => {
|
|
1511
|
+
if (series.points.length < 2) return [];
|
|
1512
|
+
let ys = series.points.map((point) => point.y), spanSvg = maxOf(ys) - minOf(ys);
|
|
1513
|
+
return [{
|
|
1514
|
+
id: series.seriesId,
|
|
1515
|
+
fraction: spanSvg / geometry.plot.h,
|
|
1516
|
+
effectivePx: spanSvg * scale,
|
|
1517
|
+
relativeRange: geometry.derived.seriesValueStats[series.seriesId]?.relativeRange ?? 0
|
|
1518
|
+
}];
|
|
1519
|
+
}), collapsed = spans.flatMap((series) => {
|
|
1520
|
+
if (series.effectivePx >= LINE_SERIES_SPAN_MIN_EFFECTIVE_PX && series.fraction >= LINE_SERIES_SPAN_MIN_FRACTION) return [];
|
|
1521
|
+
if (series.relativeRange < LINE_SERIES_VALUE_VARIATION_MIN_RATIO) return [];
|
|
1522
|
+
let contextSeries = spans.filter((candidate) => candidate.id !== series.id).sort((a, b) => b.fraction - a.fraction || compareText(a.id, b.id))[0];
|
|
1523
|
+
return !contextSeries || contextSeries.fraction < LINE_SERIES_CONTEXT_MIN_FRACTION ? [] : [{ series, contextSeries }];
|
|
1524
|
+
});
|
|
1525
|
+
return collapsed.length > 0 && findings.push({
|
|
1526
|
+
code: "series-span-collapsed",
|
|
1527
|
+
severity: "warn",
|
|
1528
|
+
message: collapsed.map(
|
|
1529
|
+
({ series, contextSeries }) => `Series '${series.id}' spans ${series.effectivePx.toFixed(1)} effective px and ${percent(series.fraction)} of the plot (collapse thresholds: ${LINE_SERIES_SPAN_MIN_EFFECTIVE_PX} effective px or ${percent(LINE_SERIES_SPAN_MIN_FRACTION)}), while its values vary by ${percent(series.relativeRange)} of |mean| and '${contextSeries.id}' spans ${percent(contextSeries.fraction)} (context threshold ${percent(LINE_SERIES_CONTEXT_MIN_FRACTION)}).`
|
|
1530
|
+
).join(" ") + " Split unlike magnitudes into separate panels with 'grid', or mark the flat line with role 'reference'.",
|
|
1531
|
+
suggest: "Split unlike magnitudes into separate panels with 'grid', or mark the flat line with role 'reference'."
|
|
1532
|
+
}), findings;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// src/cli/spec.ts
|
|
1536
|
+
function readSpecFile(path) {
|
|
1537
|
+
if (!path) throw new InputError("missing-spec", "pass the spec file path, or - to read the spec from stdin");
|
|
1538
|
+
let raw;
|
|
1539
|
+
path === "-" && isatty(0) && process.stderr.write(`Reading the spec from stdin (end with Ctrl-D).
|
|
1540
|
+
`);
|
|
1541
|
+
try {
|
|
1542
|
+
raw = path === "-" ? readFileSync2(0, "utf8") : readFileSync2(realpathSync(resolve3(path)), "utf8");
|
|
1543
|
+
} catch (error) {
|
|
1544
|
+
throw new InputError("spec-unreadable", `cannot read ${path}: ${error instanceof Error ? error.message : error}`);
|
|
1545
|
+
}
|
|
1546
|
+
try {
|
|
1547
|
+
return ownedDocumentCopy(JSON.parse(raw.replace(/^\uFEFF/, "")));
|
|
1548
|
+
} catch (error) {
|
|
1549
|
+
throw new InputError("invalid-json", `${path} is not valid JSON: ${error instanceof Error ? error.message : error}`, {
|
|
1550
|
+
suggest: "Write the spec as one JSON object."
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
function passedFamilies() {
|
|
1555
|
+
return activeFontTables()?.families;
|
|
1556
|
+
}
|
|
1557
|
+
function withHostMeasure(options) {
|
|
1558
|
+
let tables = activeFontTables();
|
|
1559
|
+
return tables ? { ...options, measure: tables.measure } : options;
|
|
1560
|
+
}
|
|
1561
|
+
function registerThemeObject(doc, envelope) {
|
|
1562
|
+
if (!isThemeObject(doc.theme)) return !1;
|
|
1563
|
+
let adopted = adoptThemeObject(doc.theme, (theme) => validateTheme(
|
|
1564
|
+
theme,
|
|
1565
|
+
themeUsage(doc, doc.charts.filter((chart) => chart.options?.theme === void 0), theme),
|
|
1566
|
+
passedFamilies()
|
|
1567
|
+
));
|
|
1568
|
+
if (!adopted.ok)
|
|
1569
|
+
throw new InputError(adopted.code, adopted.message, { path: "/theme", suggest: adopted.suggest, fix: adopted.fix, docs: "docs/reference/theme.md#theme" });
|
|
1570
|
+
return pushAll(envelope.warnings, adopted.warnings.map((warning2) => completeDiagnostic(warning2, doc, ["theme"], "docs/reference/theme.md#theme"))), doc.theme = adopted.ref, !0;
|
|
1571
|
+
}
|
|
1572
|
+
function judgeTheme(doc, ref, segments, envelope, charts, geometry) {
|
|
1573
|
+
if (ref === null || typeof ref != "object" || !Object.hasOwn(ref, "preset")) return [];
|
|
1574
|
+
let resolved, base;
|
|
1575
|
+
try {
|
|
1576
|
+
resolved = resolveTheme(ref), base = resolveTheme(ref.preset);
|
|
1577
|
+
} catch {
|
|
1578
|
+
return [];
|
|
1579
|
+
}
|
|
1580
|
+
if (isDeepStrictEqual(resolved, base)) return [];
|
|
1581
|
+
let key = (warning2) => `${warning2.code}\0${warning2.message}`, usage = geometry ? geometryThemeUsage(geometry, resolved) : themeUsage(doc, charts, resolved), inherited = new Set(validateTheme(base, usage, passedFamilies()).map(key)), findings = validateTheme(resolved, usage, passedFamilies()).filter((warning2) => !inherited.has(key(warning2))).map((warning2) => completeDiagnostic({
|
|
1582
|
+
...warning2,
|
|
1583
|
+
suggest: warning2.suggest ?? "Change the theme token the message names."
|
|
1584
|
+
}, doc, segments, "docs/reference/theme.md#theme"));
|
|
1585
|
+
return pushAll(envelope.warnings, findings.filter((finding) => finding.severity !== "error")), findings.filter((finding) => finding.severity === "error");
|
|
1586
|
+
}
|
|
1587
|
+
function judgeThemes(doc, envelope, rootJudged) {
|
|
1588
|
+
let panelFindings = [], warningStart = envelope.warnings.length, panels = (geometry, data, path) => {
|
|
1589
|
+
if (geometry.type !== "grid") return;
|
|
1590
|
+
let input = data;
|
|
1591
|
+
for (let panel of geometry.marks.panels) {
|
|
1592
|
+
if (!panel.chart) continue;
|
|
1593
|
+
let index = input.panels?.findIndex((item) => item.id === panel.id) ?? -1, panelPath = index >= 0 ? [...path, "data", "panels", index] : [...path, "data", "template"];
|
|
1594
|
+
panel.chart.theme && pushAll(panelFindings, judgeTheme(doc, panel.chart.theme, [...panelPath, "options", "theme"], envelope, [], panel.chart.geometry)), panels(panel.chart.geometry, index >= 0 ? input.panels[index].data : input.template?.data, panelPath);
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
for (let [index, chart] of doc.charts.entries())
|
|
1598
|
+
if (gridPanelOptionTargets(chart.type, chart.data, "").some((panel) => panel.options.theme !== void 0))
|
|
1599
|
+
try {
|
|
1600
|
+
let geometry = themeGeometry(doc, chart, resolveTheme(chart.options?.theme ?? doc.theme));
|
|
1601
|
+
geometry && panels(geometry, chart.data, ["charts", index]);
|
|
1602
|
+
} catch {
|
|
1603
|
+
}
|
|
1604
|
+
let seen = /* @__PURE__ */ new Set(), panelWarnings = envelope.warnings.slice(warningStart).filter((finding) => {
|
|
1605
|
+
let key = JSON.stringify([finding.path, finding.code, finding.message]);
|
|
1606
|
+
return seen.has(key) ? !1 : (seen.add(key), !0);
|
|
1607
|
+
});
|
|
1608
|
+
return envelope.warnings.length = warningStart, pushAll(envelope.warnings, panelWarnings), [
|
|
1609
|
+
...rootJudged ? [] : judgeTheme(doc, doc.theme, ["theme"], envelope, doc.charts.filter((chart) => chart.options?.theme === void 0)),
|
|
1610
|
+
...doc.charts.flatMap((chart, index) => judgeTheme(doc, chart.options?.theme, ["charts", index, "options", "theme"], envelope, [chart])),
|
|
1611
|
+
...panelFindings.filter((finding, index, all) => all.findIndex((other) => other.path === finding.path && other.code === finding.code && other.message === finding.message) === index)
|
|
1612
|
+
];
|
|
1613
|
+
}
|
|
1614
|
+
function geometryThemeUsage(geometry, theme) {
|
|
1615
|
+
let roles = /* @__PURE__ */ new Set(["background"]), types = /* @__PURE__ */ new Set(), visited = /* @__PURE__ */ new WeakSet(), series = /* @__PURE__ */ new Map(), seriesId, role = (key) => {
|
|
1616
|
+
if (roles.add(key), seriesId) {
|
|
1617
|
+
let names2 = series.get(key) ?? /* @__PURE__ */ new Set();
|
|
1618
|
+
names2.add(seriesId), series.set(key, names2);
|
|
1619
|
+
}
|
|
1620
|
+
}, add = (token) => {
|
|
1621
|
+
role(token.replace(/^status-/, "status.")), token = resolvedPaintToken(theme, token);
|
|
1622
|
+
let series2 = /^series-(\d+)$/.exec(token);
|
|
1623
|
+
role(series2 ? `series[${seriesColorIndex(theme, Number(series2[1]) - 1)}]` : token.replace(/^status-/, "status."));
|
|
1624
|
+
}, visit2 = (value) => {
|
|
1625
|
+
if (!value || typeof value != "object" || visited.has(value)) return;
|
|
1626
|
+
visited.add(value);
|
|
1627
|
+
let object2 = value;
|
|
1628
|
+
typeof object2.type == "string" && types.add(object2.type);
|
|
1629
|
+
let source = object2.theme;
|
|
1630
|
+
if (typeof object2.token == "string" && source?.kind !== "series" && source?.kind !== "colorblind" && add(object2.token), object2.kind === "series" && typeof object2.index == "number") {
|
|
1631
|
+
let palette = typeof object2.palette == "string" ? object2.palette : void 0, ramp = palette === void 0 ? void 0 : theme.color.palettes?.[palette], index = seriesColorIndex(theme, object2.index, ramp);
|
|
1632
|
+
roles.add(ramp?.length ? `palettes.${palette}[${index}]` : `series[${index}]`), object2.scenario && roles.add(`scenario.${object2.scenario}`);
|
|
1633
|
+
}
|
|
1634
|
+
object2.kind === "colorblind" && typeof object2.role == "string" && roles.add(`colorblind.${object2.role}`);
|
|
1635
|
+
for (let child of Object.values(object2)) visit2(child);
|
|
1636
|
+
}, bindings = sceneThemeBindings(geometry);
|
|
1637
|
+
for (let node2 of geometry.scene)
|
|
1638
|
+
bindings.some((binding) => node2.id.startsWith(binding.prefix)) || (visited = /* @__PURE__ */ new WeakSet(), seriesId = node2.owner?.seriesId, "fill" in node2 && visit2(node2.fill), "stroke" in node2 && visit2(node2.stroke), node2.t === "text" && visit2(node2.ink), node2.t === "rect" && visit2(node2.hatchGround));
|
|
1639
|
+
let addTypes = (current) => {
|
|
1640
|
+
if (types.add(current.type), current.type === "grid")
|
|
1641
|
+
for (let panel of current.marks.panels)
|
|
1642
|
+
panel.chart && !panel.chart.theme && addTypes(panel.chart.geometry);
|
|
1643
|
+
};
|
|
1644
|
+
return addTypes(geometry), { roles, types, series };
|
|
1645
|
+
}
|
|
1646
|
+
function themeGeometry(doc, chart, theme) {
|
|
1647
|
+
let probe = { ...chart, options: { ...chart.options, theme: { preset: "standard", overrides: theme } } }, valid = validateChartInput({ ...doc, theme: "standard" }, probe, { ok: !0, errors: [], warnings: [] });
|
|
1648
|
+
if (!valid) return;
|
|
1649
|
+
let request = resolveChartRequest({ type: valid.definition.type, data: valid.data, options: withHostMeasure(valid.options), annotations: valid.chart.annotations }), layout = layoutResolvedRequest(request);
|
|
1650
|
+
return layout.refused && layout.warnings[0]?.code === "size-below-floor" ? null : requireGeometry(layout);
|
|
1651
|
+
}
|
|
1652
|
+
function themeUsage(doc, charts, theme) {
|
|
1653
|
+
let roles = /* @__PURE__ */ new Set(["background"]), types = /* @__PURE__ */ new Set(), series = /* @__PURE__ */ new Map();
|
|
1654
|
+
for (let chart of charts)
|
|
1655
|
+
try {
|
|
1656
|
+
let geometry = themeGeometry(doc, chart, theme);
|
|
1657
|
+
if (geometry === null || !geometry) continue;
|
|
1658
|
+
let usage = geometryThemeUsage(geometry, theme);
|
|
1659
|
+
for (let role of usage.roles) roles.add(role);
|
|
1660
|
+
for (let type of usage.types) types.add(type);
|
|
1661
|
+
for (let [role, names2] of usage.series ?? []) {
|
|
1662
|
+
let all = series.get(role) ?? /* @__PURE__ */ new Set();
|
|
1663
|
+
for (let name of names2) all.add(name);
|
|
1664
|
+
series.set(role, all);
|
|
1665
|
+
}
|
|
1666
|
+
} catch {
|
|
1667
|
+
continue;
|
|
1668
|
+
}
|
|
1669
|
+
return { roles, types, series };
|
|
1670
|
+
}
|
|
1671
|
+
function loadSpec(spec) {
|
|
1672
|
+
assertSpecObject(spec);
|
|
1673
|
+
let bare = isBareChart(spec);
|
|
1674
|
+
try {
|
|
1675
|
+
let { doc, envelope } = parseDocumentInput(ownedDocumentCopy(spec)), rootJudged = registerThemeObject(doc, envelope), rootErrors = rootContextErrors(doc).map((finding) => completeDiagnostic(finding, doc));
|
|
1676
|
+
if (rootErrors.length) return { errors: rootErrors, bare };
|
|
1677
|
+
let themeErrors = judgeThemes(doc, envelope, rootJudged);
|
|
1678
|
+
return themeErrors.length ? { errors: themeErrors, bare } : { doc, envelope, bare };
|
|
1679
|
+
} catch (error) {
|
|
1680
|
+
if (error instanceof DocumentSchemaError) return { errors: error.envelopeErrors, bare };
|
|
1681
|
+
throw error;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
function shareScaleGroups({ doc, envelope, bare }) {
|
|
1685
|
+
if (bare) return;
|
|
1686
|
+
let groups = /* @__PURE__ */ new Map();
|
|
1687
|
+
for (let chart of doc.charts) {
|
|
1688
|
+
let group = chart.options?.scaleGroup?.y;
|
|
1689
|
+
typeof group == "string" && groups.set(group, [...groups.get(group) ?? [], chart]);
|
|
1690
|
+
}
|
|
1691
|
+
for (let [group, charts] of groups) {
|
|
1692
|
+
if (charts.length < 2) continue;
|
|
1693
|
+
let scratch = { ok: !0, errors: [], warnings: [] }, members = charts.map((chart) => ({ chart, valid: validateChartInput(doc, chart, scratch) }));
|
|
1694
|
+
if (members.some((member) => !member.valid)) continue;
|
|
1695
|
+
let plan = resolveSharedScale(group, members.map(({ chart, valid }) => ({
|
|
1696
|
+
id: chart.name,
|
|
1697
|
+
type: valid.definition.type,
|
|
1698
|
+
data: valid.data,
|
|
1699
|
+
options: valid.options,
|
|
1700
|
+
...chart.annotations ? { annotations: chart.annotations } : {}
|
|
1701
|
+
})));
|
|
1702
|
+
for (let refusal2 of plan.refusals)
|
|
1703
|
+
for (let chart of charts.filter((candidate) => refusal2.memberId === null || candidate.name === refusal2.memberId))
|
|
1704
|
+
envelope.errors.push(completeChartDiagnostic(doc, chart, {
|
|
1705
|
+
code: refusal2.code,
|
|
1706
|
+
message: `chart '${chart.name}': ${refusal2.message}`,
|
|
1707
|
+
suggest: `Remove scaleGroup from '${chart.name}' so it keeps its own scale, or change what the message names.`,
|
|
1708
|
+
field: ["options", "scaleGroup", "y"],
|
|
1709
|
+
fix: [{ op: "remove", path: "/options/scaleGroup" }]
|
|
1710
|
+
}));
|
|
1711
|
+
if (!plan.refusals.length)
|
|
1712
|
+
for (let pin of plan.members) {
|
|
1713
|
+
let chart = charts.find((candidate) => candidate.name === pin.id);
|
|
1714
|
+
chart.options = { ...chart.options, valueAxis: pin.options.valueAxis };
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
function asSent(findings, bare) {
|
|
1719
|
+
return bare ? findings.map((finding) => bareFinding(finding)) : [...findings];
|
|
1720
|
+
}
|
|
1721
|
+
function hiddenLabelId(label) {
|
|
1722
|
+
return label.kind === "category" && label.owner.categoryId ? label.owner.categoryId : label.kind === "series" && label.owner.seriesId ? label.owner.seriesId : label.kind === "segment" && label.owner.segmentId ? label.owner.segmentId : label.kind === "point" && label.owner.pointId ? label.owner.pointId : label.id;
|
|
1723
|
+
}
|
|
1724
|
+
function collapseLabelHiddenWarnings(geo, warnings) {
|
|
1725
|
+
let passthrough = [], groups = /* @__PURE__ */ new Map(), labelsById = new Map(geo.labels.map((label) => [label.id, label]));
|
|
1726
|
+
for (let warning2 of warnings) {
|
|
1727
|
+
let id = warning2.code === "label-hidden" ? /^label '([^']+)'/.exec(warning2.message)?.[1] : void 0, label = id ? labelsById.get(id) : void 0;
|
|
1728
|
+
if (!label) {
|
|
1729
|
+
passthrough.push(warning2);
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
let seriesId = label.owner.seriesId, key = `${label.kind}\0${seriesId ?? ""}`, group = groups.get(key) ?? { kind: label.kind, ...seriesId ? { seriesId } : {}, labels: [], warnings: [] };
|
|
1733
|
+
group.labels.push(label), group.warnings.push(warning2), groups.set(key, group);
|
|
1734
|
+
}
|
|
1735
|
+
for (let group of groups.values()) {
|
|
1736
|
+
let hidden = geo.labels.filter((label) => label.hidden !== void 0 && label.kind === group.kind && label.owner.seriesId === group.seriesId).map(hiddenLabelId), total = geo.labels.filter((label) => label.kind === group.kind && label.owner.seriesId === group.seriesId).length, shown = hidden.slice(0, 5), suffix = hidden.length > shown.length ? ", ..." : "";
|
|
1737
|
+
passthrough.push({
|
|
1738
|
+
code: "label-hidden",
|
|
1739
|
+
severity: group.warnings.some((warning2) => warning2.severity === "warn") ? "warn" : "info",
|
|
1740
|
+
message: `${group.kind} labels: ${hidden.length} of ${total} hidden (${shown.join(", ")}${suffix})`,
|
|
1741
|
+
...group.seriesId ? { owner: { seriesId: group.seriesId } } : {},
|
|
1742
|
+
detail: { kind: group.kind, ...group.seriesId ? { seriesId: group.seriesId } : {}, hidden, total }
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
return passthrough;
|
|
1746
|
+
}
|
|
1747
|
+
function panelUnitLints(data, geo, base = ["data"]) {
|
|
1748
|
+
let panels = geo.type === "grid" ? geo.marks?.panels ?? [] : [], authored = isRecord(data) && Array.isArray(data.panels) ? data.panels : void 0, owns = (nodeId, panelId) => nodeId.startsWith(`${panelId}/`) || nodeId.includes(`panel:${panelId}:`);
|
|
1749
|
+
return panels.flatMap((panel) => {
|
|
1750
|
+
if (!panel.chart) return [];
|
|
1751
|
+
let index = authored?.findIndex((item) => isRecord(item) && item.id === panel.id) ?? -1, own = index >= 0 ? [...base, "panels", index] : [...base, "template"], child = panel.chart.geometry, scene = geo.scene.filter((node2) => owns(node2.id, panel.id) || !panels.some((other) => owns(node2.id, other.id)));
|
|
1752
|
+
return [
|
|
1753
|
+
...unitNotShownLints(panel.chart.options, { type: child.type, scene, warnings: child.warnings }).map((warning2) => ({ ...warning2, message: `[${panel.id}] ${warning2.message}`, field: [...own, "options", "unit"] })),
|
|
1754
|
+
...unitInFormatLints(panel.chart.options, own).map((warning2) => ({ ...warning2, message: `[${panel.id}] ${warning2.message}` })),
|
|
1755
|
+
...panelUnitLints(index >= 0 ? authored[index].data : void 0, child, [...own, "data"])
|
|
1756
|
+
];
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
function normLints(type, options, geo, data) {
|
|
1760
|
+
let found = [...aspectDocLints(type, options, geo)];
|
|
1761
|
+
pushAll(geo.warnings, found);
|
|
1762
|
+
let rest = [
|
|
1763
|
+
...spaceDocLints(type, options, geo),
|
|
1764
|
+
...typeDocLints(type, options, geo),
|
|
1765
|
+
...lineIntegrityDocLints(type, options, geo),
|
|
1766
|
+
...unitNotShownLints(options, geo),
|
|
1767
|
+
...shareUnitLints(options, geo),
|
|
1768
|
+
...unitInFormatLints(options),
|
|
1769
|
+
...unscaledFormatLint(options, data, geo),
|
|
1770
|
+
...panelUnitLints(data, geo)
|
|
1771
|
+
];
|
|
1772
|
+
return pushAll(geo.warnings, rest), geo.warnings;
|
|
1773
|
+
}
|
|
1774
|
+
function layoutFailure(chart, error) {
|
|
1775
|
+
process.env.BOARDPLOT_DEBUG_STACK === "1" && console.error(error.stack);
|
|
1776
|
+
let failure = error, field = failure.segments ?? (failure.path && !/[[\]]/.test(failure.path) ? failure.path.split(".") : void 0);
|
|
1777
|
+
return {
|
|
1778
|
+
code: failure.code ?? "layout-error",
|
|
1779
|
+
message: failure.message,
|
|
1780
|
+
path: `charts[${chart.name}]${failure.path ? `.${failure.path}` : ""}`,
|
|
1781
|
+
...failure.suggest ? { suggest: failure.suggest } : {},
|
|
1782
|
+
...field ? { field } : {},
|
|
1783
|
+
...failure.fix ? { fix: failure.fix } : {},
|
|
1784
|
+
...failure.expected ? { expected: failure.expected } : {}
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
function resolveRequest(doc, chart, envelope, target) {
|
|
1788
|
+
let validated = validateChartInput(doc, chart, envelope);
|
|
1789
|
+
if (!validated) return null;
|
|
1790
|
+
let request = resolveChartRequest({
|
|
1791
|
+
type: validated.definition.type,
|
|
1792
|
+
data: validated.data,
|
|
1793
|
+
options: withHostMeasure(validated.options),
|
|
1794
|
+
annotations: validated.chart.annotations,
|
|
1795
|
+
...target === void 0 ? {} : { target }
|
|
1796
|
+
}, { theme: doc.theme, locale: typeof doc.locale == "string" ? doc.locale : void 0 });
|
|
1797
|
+
return { validated, request };
|
|
1798
|
+
}
|
|
1799
|
+
function drawn(doc, chart, envelope, write = {}, target) {
|
|
1800
|
+
let resolved = resolveRequest(doc, chart, envelope, target);
|
|
1801
|
+
return resolved ? judged(chart, resolved, requireGeometry(layoutResolvedRequest(resolved.request)), envelope, !0, write) : null;
|
|
1802
|
+
}
|
|
1803
|
+
function judged(chart, { validated, request }, geo, envelope, reportWarnings, write = {}) {
|
|
1804
|
+
let def = validated.definition, options = request.options, claims = claimsForChart(def.type, geo), theme = resolveTheme(options.theme), svg;
|
|
1805
|
+
try {
|
|
1806
|
+
svg = renderSvg(geo, theme, { interactive: options.interactive === !0, claims, ...write });
|
|
1807
|
+
} catch (error) {
|
|
1808
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
1809
|
+
return envelope.errors.push(error instanceof XmlCharError ? { code: "unrepresentable-text", message: `chart '${chart.name}': ${message}`, path: `charts[${chart.name}]` } : {
|
|
1810
|
+
code: error.code ?? "unserializable-chart",
|
|
1811
|
+
message: `chart '${chart.name}': ${message}`,
|
|
1812
|
+
path: `charts[${chart.name}]`,
|
|
1813
|
+
suggest: "Correct the value the message names."
|
|
1814
|
+
}), null;
|
|
1815
|
+
}
|
|
1816
|
+
let warnings = normLints(def.type, options, geo, validated.data), refusals = chartRefusals(warnings);
|
|
1817
|
+
reportWarnings && pushAll(envelope.warnings, collapseLabelHiddenWarnings(geo, warnings.filter((warning2) => warning2.severity !== "error")));
|
|
1818
|
+
for (let refusal2 of refusals)
|
|
1819
|
+
envelope.errors.push({
|
|
1820
|
+
code: refusal2.code,
|
|
1821
|
+
message: `chart '${chart.name}': ${refusal2.message}`,
|
|
1822
|
+
path: `charts[${chart.name}]`,
|
|
1823
|
+
...refusal2.suggest ? { suggest: refusal2.suggest } : {},
|
|
1824
|
+
...refusal2.field ? { field: refusal2.field, displayPath: `charts[${chart.name}].${refusal2.field.join(".")}` } : {},
|
|
1825
|
+
...refusal2.fix ? { fix: refusal2.fix } : {}
|
|
1826
|
+
});
|
|
1827
|
+
return refusals.length ? null : { def, geo, options, claims, request, svg, fontFamily: theme.type.family };
|
|
1828
|
+
}
|
|
1829
|
+
function verifySizeAdvice(doc, chart, findings, target) {
|
|
1830
|
+
for (let finding of findings) {
|
|
1831
|
+
let operation = finding.fix?.find((op) => op.op !== "test" && op.path.endsWith("/options/size"));
|
|
1832
|
+
if (!operation || !("value" in operation)) continue;
|
|
1833
|
+
let value = operation.value, repair = verifiedSizeRepair(value, (size) => {
|
|
1834
|
+
let scratch = { ok: !0, errors: [], warnings: [] };
|
|
1835
|
+
try {
|
|
1836
|
+
return drawn(doc, { ...chart, options: { ...chart.options, size: { ...value, ...size } } }, scratch, {}, target) !== null && scratch.errors.length === 0 && !scratch.warnings.some((w) => w.code === finding.code || w.code === "plot-under-floor" || w.code === "size-below-floor");
|
|
1837
|
+
} catch {
|
|
1838
|
+
return !1;
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
if (repair.size) {
|
|
1842
|
+
(repair.size.width !== value.width || repair.size.height !== value.height) && (operation.value = { ...value, ...repair.size }, finding.expected = { ...finding.expected, minimum: operation.value }, finding.message = `The chart needs at least ${repair.size.width} \xD7 ${repair.size.height}${value.unit ?? "px"}.`);
|
|
1843
|
+
continue;
|
|
1844
|
+
}
|
|
1845
|
+
delete finding.fix, finding.suggest = `No size could be verified within ${repair.limit.width} \xD7 ${repair.limit.height}${value.unit ?? "px"}. Reduce the content or change the chart settings.`, finding.expected = { condition: finding.suggest };
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
function completing(doc, chart, envelope, work) {
|
|
1849
|
+
let errors = envelope.errors.length, warnings = envelope.warnings.length;
|
|
1850
|
+
try {
|
|
1851
|
+
return work();
|
|
1852
|
+
} catch (error) {
|
|
1853
|
+
return envelope.errors.push(layoutFailure(chart, error)), null;
|
|
1854
|
+
} finally {
|
|
1855
|
+
for (let index = errors; index < envelope.errors.length; index++)
|
|
1856
|
+
envelope.errors[index] = completeChartDiagnostic(doc, chart, envelope.errors[index]);
|
|
1857
|
+
for (let index = warnings; index < envelope.warnings.length; index++)
|
|
1858
|
+
envelope.warnings[index] = completeChartDiagnostic(doc, chart, envelope.warnings[index]);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
function drawsWithOptions(doc, chart, changed, drawnCodes, target) {
|
|
1862
|
+
let scratch = { ok: !0, errors: [], warnings: [] };
|
|
1863
|
+
return layoutChart(doc, { ...chart, options: { ...chart.options, ...changed } }, scratch, {}, target) !== null && scratch.errors.length === 0 && scratch.warnings.every((warning2) => drawnCodes.has(warning2.code));
|
|
1864
|
+
}
|
|
1865
|
+
function layoutChart(doc, chart, envelope, write = {}, target) {
|
|
1866
|
+
return completing(doc, chart, envelope, () => drawn(doc, chart, envelope, write, target));
|
|
1867
|
+
}
|
|
1868
|
+
function measureChart(doc, chart, envelope, target) {
|
|
1869
|
+
return completing(doc, chart, envelope, () => {
|
|
1870
|
+
let resolved = resolveRequest(doc, chart, envelope, target);
|
|
1871
|
+
if (!resolved) return null;
|
|
1872
|
+
let request = { ...resolved.request, options: { ...resolved.request.options, [VERIFY_ADVICE]: !0 } }, layout = layoutResolvedRequest(request), measured = measureLayout(request, layout);
|
|
1873
|
+
return measured.refused && verifySizeAdvice(doc, chart, measured.refused.warnings, target), pushAll(envelope.warnings, measured.warnings.filter((warning2) => warning2.severity !== "error")), !layout.refused && !judged(chart, resolved, layout, envelope, !1) ? null : { ...measured, target: resolved.request.target };
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
function addDocumentLints(doc, envelope, drawn2 = []) {
|
|
1877
|
+
let central = new Set(lintCodes), variables = /* @__PURE__ */ new Set();
|
|
1878
|
+
envelope.warnings = envelope.warnings.filter((warning2) => !central.has(warning2.code) && (warning2.code !== "css-var-fallback-used" || !variables.has(`${warning2.path}\0${warning2.message}`) && !!variables.add(`${warning2.path}\0${warning2.message}`)));
|
|
1879
|
+
let lintDoc = { ...doc, charts: doc.charts.map((chart) => {
|
|
1880
|
+
let entry = drawn2.find((candidate) => candidate.name === chart.name);
|
|
1881
|
+
return { ...chart, geometry: entry?.chart.geo, ...entry?.drawsWith ? { drawsWith: entry.drawsWith } : {} };
|
|
1882
|
+
}) };
|
|
1883
|
+
pushAll(envelope.warnings, runDocLints(lintDoc, !0).map((warning2) => completeDocumentDiagnostic(doc, warning2))), envelope.errors.length || pushAll(envelope.warnings, runDocAdvice(lintDoc, !0).map((warning2) => completeDocumentDiagnostic(doc, warning2)));
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
// src/cli/list.ts
|
|
1887
|
+
function list() {
|
|
1888
|
+
return ok(buildCatalog());
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
// src/core/schema/reading.ts
|
|
1892
|
+
var readingCountsSchema = {
|
|
1893
|
+
type: "array",
|
|
1894
|
+
description: "Structural counts from the layout. text is the exact phrase in the accessible description. Empty when the description has no count phrase.",
|
|
1895
|
+
items: {
|
|
1896
|
+
type: "object",
|
|
1897
|
+
required: ["what", "n", "text"],
|
|
1898
|
+
additionalProperties: !1,
|
|
1899
|
+
properties: {
|
|
1900
|
+
what: { type: "string", enum: STRUCTURE_COUNT_KINDS },
|
|
1901
|
+
n: { type: "integer", minimum: 0 },
|
|
1902
|
+
text: { type: "string" }
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}, readingMetricStackSchema = {
|
|
1906
|
+
type: "object",
|
|
1907
|
+
description: "Metric stacks only: readouts with method, grain, category windows, rounded headline and span values, and claims carrying source and intermediate operands.",
|
|
1908
|
+
properties: { readouts: { type: "array", items: { type: "object", required: ["panelId", "method", "grain"], properties: {
|
|
1909
|
+
panelId: { type: "string" },
|
|
1910
|
+
method: { type: "string", enum: ["average-change", "rounded-rate-change", "weighted-rate"] },
|
|
1911
|
+
grain: { type: "string", enum: ["day", "week", "month", "quarter", "year", "category"], description: "Category grain from windows.grain or explicit category ids; category when neither identifies a time grain." },
|
|
1912
|
+
categoryIds: { type: "object" },
|
|
1913
|
+
headline: { type: ["number", "null"] },
|
|
1914
|
+
before: { type: ["number", "null"] },
|
|
1915
|
+
after: { type: ["number", "null"] },
|
|
1916
|
+
headlineText: { type: "string" },
|
|
1917
|
+
spanText: { type: "string" },
|
|
1918
|
+
claims: { type: "array", items: { type: "object" }, description: "Each claim has op, inputs (ref, value), and output (raw, state, displayed)." }
|
|
1919
|
+
} } } }
|
|
1920
|
+
};
|
|
1921
|
+
|
|
1922
|
+
// src/core/discovery.ts
|
|
1923
|
+
import * as z2 from "zod";
|
|
1924
|
+
var BARE_NAME_FIELD = {
|
|
1925
|
+
path: "name",
|
|
1926
|
+
type: "string",
|
|
1927
|
+
default: BARE_CHART_NAME,
|
|
1928
|
+
description: `Output file name and chart identity of a bare chart: ${NAME_RULE}. A taken file name gets -2; an existing file is never replaced.`
|
|
1929
|
+
}, LANE_TYPES = ["column", "combo", "line"], GAP_BRACKET_FIELDS = {
|
|
1930
|
+
placement: {
|
|
1931
|
+
meaning: "auto | label | bracket, default auto. With both ends on two different series at the last category, bracket draws the gap bracket in the right margin: an open ring on each end point, a dashed guide from each ring to the margin, a bracket with an arrowhead toward the measured end, and the gap as a large number beside it; the end values sit just over and under their guides. auto draws the bracket where gapFill washes the same two series and the label elsewhere. label keeps the label at the anchor. bracket on other anchors, or on stacked variants (stacked-area, stacked100-area), warns gap-bracket-unavailable and keeps the label.",
|
|
1932
|
+
types: ["line"]
|
|
1933
|
+
},
|
|
1934
|
+
caption: {
|
|
1935
|
+
meaning: "string. A short line under the bracket number that says what it measures, right-aligned in muted ink. Only a gap bracket prints it; elsewhere it warns gap-caption-ignored.",
|
|
1936
|
+
types: ["line"]
|
|
1937
|
+
}
|
|
1938
|
+
}, ANNOTATION_OPTIONAL = {
|
|
1939
|
+
diff: { mode: "relative | absolute | reversed, default relative. relative prints the percent change from 'from' to 'to', reversed the change from 'to' to 'from', absolute the value difference.", ...GAP_BRACKET_FIELDS },
|
|
1940
|
+
delta: GAP_BRACKET_FIELDS,
|
|
1941
|
+
cagr: {
|
|
1942
|
+
suffix: "string, default 'p.a.'. Text after the rate.",
|
|
1943
|
+
period: "boolean. Print the period before the rate from the anchors' category labels, '2014\u20132019: +5.8% p.a.'. Default true when the chart carries two or more CAGRs, so nested brackets are told apart by their text, false otherwise."
|
|
1944
|
+
},
|
|
1945
|
+
callout: {
|
|
1946
|
+
preferSide: "left | right | above | below. Side the solver tries first; the label keeps a leader when it moves.",
|
|
1947
|
+
headline: 'string. A bold first line over the text, which then prints in plain type; ${value} in it prints the anchored value from the data. Example: "headline": "${value}", "text": "Peak in handheld-loom demand" prints 153 in bold over the words.',
|
|
1948
|
+
arrow: 'boolean, default false. A thin arrow from the text to the anchored point; the first line sits level with the point, right or left of it, where there is room. Not with icon or status. Example: "arrow": true.'
|
|
1949
|
+
},
|
|
1950
|
+
valueLine: {
|
|
1951
|
+
value: "number | 'mean', default mean. A number draws the line there; mean has the engine compute it.",
|
|
1952
|
+
valueKind: "'fraction'. Multiply a numeric value and its tolerance by 100 before layout: 0.35 draws at 35%. Independent of data.valueKind. Omit it for values already in percent points; not valid with mean.",
|
|
1953
|
+
seriesId: { meaning: "string. Series whose mean is measured.", types: ["line"] },
|
|
1954
|
+
label: "string | false. Name plus value; ${value} sets its position. A number already in the name is kept once. false hides it.",
|
|
1955
|
+
side: {
|
|
1956
|
+
meaning: "left | right, default right. Side of the plot the label sits on.",
|
|
1957
|
+
types: ["column", "combo", "line", "mekko", "pvm", "scatter", "variance", "waterfall"]
|
|
1958
|
+
},
|
|
1959
|
+
axis: { meaning: "primary | secondary, default primary. Scale of value; secondary needs an acknowledged secondary axis.", types: ["combo"] },
|
|
1960
|
+
tolerance: {
|
|
1961
|
+
meaning: "number | { low, high }. A number shades that distance on both sides of the line; low and high shade an authored corridor.",
|
|
1962
|
+
types: ["bar", "bullet", "column", "combo", "line", "mekko", "pvm", "scatter", "slope", "variance", "waterfall"]
|
|
1963
|
+
},
|
|
1964
|
+
attainment: { meaning: "boolean | { seriesId, direction }. Shades each category between its actual and the line.", types: ["bar", "bullet", "column", "line"] }
|
|
1965
|
+
},
|
|
1966
|
+
indicator100: { side: "left | right, default left. Side of the plot the 100% mark sits on." },
|
|
1967
|
+
event: {
|
|
1968
|
+
date: { meaning: "ISO date yyyy-mm-dd, in place of at: the event sits at the last category whose date is on or before it, and the block header and the key print it as d MMM. Every category needs an ISO date; a date outside the categories warns event-out-of-range.", types: LANE_TYPES },
|
|
1969
|
+
end: { meaning: "ISO date, with date: the event is a period, drawn as a thin bar to the end of that day.", types: LANE_TYPES },
|
|
1970
|
+
to: { meaning: "Category id, with at: the event is a period to the end of that category.", types: LANE_TYPES },
|
|
1971
|
+
group: { meaning: "Id of a group in options.events.groups, which gives the kind label, tone and glyph.", types: LANE_TYPES },
|
|
1972
|
+
detail: { meaning: "string | string[]. Authored lines under the title, at most three in the lane; nothing is cut, a longer block moves to the key.", types: LANE_TYPES },
|
|
1973
|
+
items: { meaning: "{ label, detail? }[]. More changes on the same date, after this event's own label and detail. The lane and the key draw a compact +N after the title; the hover card, the SVG title and description, and the interaction records list every item in full.", types: LANE_TYPES },
|
|
1974
|
+
placement: { meaning: "auto | key, default options.events.placement. key numbers this event into the key below the plot.", types: LANE_TYPES },
|
|
1975
|
+
tone: "neutral | bad | good, default the group tone, else neutral. Column, combo and line paint the glyph, the marker ring and the period bar in it; gantt paints a bad rule.",
|
|
1976
|
+
labelPlacement: { meaning: "top | inline | badge, default top. inline (line) sets the block beside its rule inside the plot. badge (gantt) draws the label, at most 3 characters, in a filled circle at the top of its rule; badge events never go to the numbered key.", types: ["line", "gantt"] }
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
function optionalFields(kind, type) {
|
|
1980
|
+
let fields2 = {};
|
|
1981
|
+
for (let [name, field] of Object.entries(ANNOTATION_OPTIONAL[kind] ?? {}))
|
|
1982
|
+
typeof field == "string" ? fields2[name] = field : field.types.includes(type) && (fields2[name] = field.meaning);
|
|
1983
|
+
return fields2;
|
|
1984
|
+
}
|
|
1985
|
+
function describeAnnotation(kind, type) {
|
|
1986
|
+
let anchors = [], requiredFields = [], notes = [];
|
|
1987
|
+
switch (kind) {
|
|
1988
|
+
case "diff":
|
|
1989
|
+
case "cagr":
|
|
1990
|
+
anchors = ["from", "to"].map((field) => ({ field, type: "AnchorRef", required: kind === "diff" })), notes = kind === "diff" ? ["Mode defaults to relative. Relative and reversed changes need a nonzero base; negative bases use its absolute magnitude and emit a warning. Absolute mode reports the raw value difference. A hidden label removes its arm."] : ['Omitted endpoints span the first to the last category, or the first to the last total on a waterfall. Resolved endpoints need a positive date interval from ISO dates or year-bearing labels and a positive start value; an end of zero reads -100%, and a start at or below zero or a negative end omits the rate and warns cagr-undefined. On a continuous time axis the years are the exact span between the two readings. An anchor on one series of several (seriesId, or a line category, which reads the first drawn series) names that series in the label, "Product B +10.1% p.a.", and the arm runs from that series\' segment or point. In text, ${value} prints the rate with its suffix, so "CAGR 2014\u20132019: ${value}" keeps the computed number.'];
|
|
1991
|
+
break;
|
|
1992
|
+
case "delta":
|
|
1993
|
+
anchors = [{ field: "at", type: "AnchorRef", required: !0 }, { field: "vs", type: "AnchorRef | number", required: !0 }];
|
|
1994
|
+
break;
|
|
1995
|
+
case "abs":
|
|
1996
|
+
case "note":
|
|
1997
|
+
case "callout":
|
|
1998
|
+
anchors = [{ field: "at", type: "AnchorRef", required: !0 }], (kind === "note" || kind === "callout") && (requiredFields = ["text"]);
|
|
1999
|
+
break;
|
|
2000
|
+
case "event":
|
|
2001
|
+
type === "gantt" ? (anchors = [{ field: "at", type: "AnchorRef", required: !0 }], notes = ["An ISO date or a schedule item id positions the rule. Above three events the labels move to numbered footnotes."]) : (anchors = [{ field: "at", type: "categoryId", required: !1 }], notes = [
|
|
2002
|
+
`Exactly one of at (a category id) and date (an ISO date) places the event; end or to makes it a period. The event lane above the plot sets a block of group and date, title and detail with a thin pole to the data; an event that does not fit, a second event on one category and every event under options.events.placement 'key' get a numbered marker and an entry in the key below the plot, numbered in time order; under footnotes: false they are left off and listed in the footnotes-off lint. The full date, title and detail of every event stay in the SVG title and description, the interaction records and the hover card, whether or not the lane or the key prints the detail. In compact mode the lane is one row of numbered markers and the key packs "n date title" into as few lines as the width allows; where the plot would still fall under 80px the key keeps "n title" and the info lint event-lane-compact says so. options.events.rows sets the lane rows (default by canvas width: 1 under 1080px, 2 from 1080px); a row gives way while the plot band left under the lane would keep less than 40% of the canvas height.`
|
|
2003
|
+
]), requiredFields = ["label"];
|
|
2004
|
+
break;
|
|
2005
|
+
case "band":
|
|
2006
|
+
anchors = ["from", "to"].map((field) => ({ field, type: "categoryId", required: !1 })), notes = ["Era shade/bracket needs inclusive category IDs. Corridor and tolerance use finite low/high on the value scale, with optional from/to as a category clip. Attainment needs a plan value and shades each resolved actual; missing cells are skipped. Divider applies only to bracket bands. Scenario AC/PY/PL/FC paints a plan corridor (default PL)."];
|
|
2007
|
+
break;
|
|
2008
|
+
case "valueLine":
|
|
2009
|
+
anchors = ["from", "to"].map((field) => ({ field, type: "categoryId", required: !1 })), notes = ["No anchor is required. Value defaults to mean. Scoped means are line-only: seriesId and paired from/to compute a primary-axis mean and limit its stroke to those bands; other types refuse scope fields for a mean. Numeric values cannot use scope fields except as a category clip with tolerance or attainment. A secondary-axis line needs an acknowledged secondary scale and an explicit numeric value. Optional tolerance shades a value-axis band; optional attainment fills between the line and resolved actuals."];
|
|
2010
|
+
break;
|
|
2011
|
+
case "indicator100":
|
|
2012
|
+
notes = ["No anchor is required. The chart needs a value scale that can represent 100."];
|
|
2013
|
+
break;
|
|
2014
|
+
}
|
|
2015
|
+
return kind === "diff" && type === "line" && notes.push("Diff labels precede point and end labels. Same-category arms attach there; anchored strokes do not displace them."), kind === "diff" && type === "dot" && notes.push("The arm follows the horizontal value axis and clears the connector."), ["diff", "cagr", "delta", "abs", "note", "callout"].includes(kind) && ["line", "bar", "column", "combo"].includes(type) && notes.push(`Drawn reference series accept anchors.${type === "line" ? " Bad anchors report the cause and valid ids." : ""}`), {
|
|
2016
|
+
kind,
|
|
2017
|
+
use: ANNOTATION_KIND_PURPOSES[kind],
|
|
2018
|
+
anchors,
|
|
2019
|
+
requiredFields: [...anchors.filter((anchor) => anchor.required).map((anchor) => anchor.field), ...requiredFields],
|
|
2020
|
+
optional: optionalFields(kind, type),
|
|
2021
|
+
notes
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
function childKeys(fields2, prefix) {
|
|
2025
|
+
return new Set(fields2.filter((field) => field.path.startsWith(prefix)).map((field) => field.path.slice(prefix.length).split(/[.[]/)[0]));
|
|
2026
|
+
}
|
|
2027
|
+
function cellType(fields2, path) {
|
|
2028
|
+
let isCell = (keys) => keys.has("number") && keys.has("pct") && keys.has("date");
|
|
2029
|
+
if (isCell(childKeys(fields2, `${path}.`))) return "cell";
|
|
2030
|
+
let items = childKeys(fields2, `${path}[].`);
|
|
2031
|
+
if (isCell(items))
|
|
2032
|
+
return items.has("categoryId") ? "(cell | { categoryId, value: cell })[]" : "cell[]";
|
|
2033
|
+
}
|
|
2034
|
+
function mergeAlternatives(fields2) {
|
|
2035
|
+
let byPath = /* @__PURE__ */ new Map();
|
|
2036
|
+
for (let field of fields2) {
|
|
2037
|
+
if (field.type === "never") continue;
|
|
2038
|
+
let key = `${field.path}\0${field.branch ?? ""}`, branches = byPath.get(key);
|
|
2039
|
+
branches ? branches.push(field) : byPath.set(key, [field]);
|
|
2040
|
+
}
|
|
2041
|
+
return [...byPath.values()].map((branches) => {
|
|
2042
|
+
let [first] = branches;
|
|
2043
|
+
if (branches.length === 1) return first;
|
|
2044
|
+
let descriptions = [...new Set(branches.map((branch) => branch.description))], selects = descriptions.length > 1 && branches.every((branch) => branch.values?.length), values = [...new Set(branches.flatMap((branch) => branch.values ?? []))], withDefault = branches.find((branch) => Object.hasOwn(branch, "default"));
|
|
2045
|
+
return {
|
|
2046
|
+
path: first.path,
|
|
2047
|
+
...first.branch ? { branch: first.branch } : {},
|
|
2048
|
+
type: [...new Set(branches.flatMap((branch) => branch.type.split(" | ")))].join(" | "),
|
|
2049
|
+
required: branches.every((branch) => branch.required),
|
|
2050
|
+
description: selects ? branches.map((branch) => `${branch.values.map(String).join(", ")}: ${branch.description}`).join(" ") : descriptions.join(" "),
|
|
2051
|
+
...values.length ? { values } : {},
|
|
2052
|
+
...values.length && !branches.every((branch) => branch.values?.length && branch.valuesExhaustive !== !1) ? { valuesExhaustive: !1 } : {},
|
|
2053
|
+
...withDefault ? { default: withDefault.default, ...withDefault.defaultInSchema ? { defaultInSchema: !0 } : {} } : {},
|
|
2054
|
+
...!withDefault && first.defaultDependsOn ? { defaultDependsOn: first.defaultDependsOn } : {},
|
|
2055
|
+
...selects ? { selects: !0 } : {}
|
|
2056
|
+
};
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
function isReserved(field) {
|
|
2060
|
+
return /^(Reserved|Deprecated)\b/.test(field.description);
|
|
2061
|
+
}
|
|
2062
|
+
function compactFields(all) {
|
|
2063
|
+
let fields2 = mergeAlternatives(all), rows = [], folded = [];
|
|
2064
|
+
for (let field of fields2) {
|
|
2065
|
+
if (isReserved(field) || folded.some((prefix) => field.path.startsWith(`${prefix}.`) || field.path.startsWith(`${prefix}[]`))) continue;
|
|
2066
|
+
let declaredValues = field.description.match(/\bOne of .*/)?.[0], meaning = field.selects ? "Selects which fields this entry takes." : firstClause(field.description) + (declaredValues ? ` ${declaredValues}` : ""), cell = cellType(fields2, field.path);
|
|
2067
|
+
if (cell) {
|
|
2068
|
+
folded.push(field.path), rows.push({ field, type: cell, meaning });
|
|
2069
|
+
continue;
|
|
2070
|
+
}
|
|
2071
|
+
rows.push({ field, meaning });
|
|
2072
|
+
}
|
|
2073
|
+
return rows;
|
|
2074
|
+
}
|
|
2075
|
+
function fieldLines(fields2, withRequired = !1) {
|
|
2076
|
+
let lines = {}, first = /* @__PURE__ */ new Map(), grouped = /* @__PURE__ */ new Map();
|
|
2077
|
+
for (let row of compactFields(fields2)) {
|
|
2078
|
+
let { branch, ...facts } = row.field, tag = branch?.match(/branch (\d+)/g)?.map((value) => value.slice(7)).join("/"), key = JSON.stringify([facts.path, facts.type, facts.required, facts.values, facts.valuesExhaustive, facts.default, row.type, row.meaning]), earlier = grouped.get(key);
|
|
2079
|
+
earlier && tag ? earlier.field.branch += `|${tag}` : grouped.set(key, { ...row, field: { ...facts, ...tag ? { branch: tag } : {} } });
|
|
2080
|
+
}
|
|
2081
|
+
for (let row of grouped.values()) {
|
|
2082
|
+
let earlier = first.get(row.meaning), reference = earlier && earlier !== row.field.path ? `See ${earlier}.` : void 0, meaning = reference && reference.length < row.meaning.length ? reference : row.meaning;
|
|
2083
|
+
earlier || first.set(row.meaning, row.field.path);
|
|
2084
|
+
let literal2 = !row.type && row.field.type === "string" && !!row.field.values?.length && row.field.values.length <= 3 && row.field.valuesExhaustive !== !1, line = fieldLine(literal2 ? { ...row.field, values: void 0 } : row.field, meaning, {
|
|
2085
|
+
required: withRequired && row.field.required,
|
|
2086
|
+
...literal2 ? { type: row.field.values.map((value) => JSON.stringify(value)).join(" | ") } : row.type ? { type: row.type } : {}
|
|
2087
|
+
}).replace(/\. $/, ""), fact = row.field.branch ? `branch ${row.field.branch}: ${line}` : line;
|
|
2088
|
+
lines[row.field.path] = lines[row.field.path] ? `${lines[row.field.path]}; ${fact}` : fact;
|
|
2089
|
+
}
|
|
2090
|
+
return lines;
|
|
2091
|
+
}
|
|
2092
|
+
function fieldRows(fields2, withRequired = !1) {
|
|
2093
|
+
return mergeAlternatives(fields2).map((field) => ({
|
|
2094
|
+
path: field.path,
|
|
2095
|
+
...field.branch ? { branch: field.branch } : {},
|
|
2096
|
+
type: field.type,
|
|
2097
|
+
...withRequired && field.required ? { required: !0 } : {},
|
|
2098
|
+
...field.values ? { values: field.values } : {},
|
|
2099
|
+
...field.values && field.valuesExhaustive === !1 ? { valuesOpen: !0 } : {},
|
|
2100
|
+
...Object.hasOwn(field, "default") ? { default: field.default } : {},
|
|
2101
|
+
...field.defaultDependsOn ? { defaultDependsOn: field.defaultDependsOn } : {},
|
|
2102
|
+
description: field.description
|
|
2103
|
+
}));
|
|
2104
|
+
}
|
|
2105
|
+
var COMPACT_FIXTURES = 5;
|
|
2106
|
+
function typeOptions(type) {
|
|
2107
|
+
let base = /* @__PURE__ */ new Map();
|
|
2108
|
+
for (let field of sharedOptionFields()) base.has(field.path) || base.set(field.path, field);
|
|
2109
|
+
let all = optionFields(type), firstByPath = /* @__PURE__ */ new Map();
|
|
2110
|
+
for (let field of all) firstByPath.has(field.path) || firstByPath.set(field.path, field);
|
|
2111
|
+
let contract = (field) => fieldLine(field, firstClause(field.description)), own = all.filter((field) => {
|
|
2112
|
+
let shared = base.get(field.path);
|
|
2113
|
+
return shared ? field.path === "annotations" || field.path.startsWith("annotations[") ? !1 : field.type !== "never" && contract(field) !== contract(shared) : !0;
|
|
2114
|
+
}), advertised = [...base.values()].filter((field) => (!/[.[]/.test(field.path) || /^valueAxis\.\w+$/.test(field.path)) && field.type !== "never" && !isReserved(field)), refused = (path) => {
|
|
2115
|
+
let here = firstByPath.get(path);
|
|
2116
|
+
return !here || here.type === "never";
|
|
2117
|
+
}, notAccepted = advertised.filter((field) => refused(field.path) && !(field.path.startsWith("valueAxis.") && refused("valueAxis"))).map((field) => field.path), refusedOwn = [...firstByPath.values()].filter((field) => field.type === "never" && !base.has(field.path) && !/[.[]/.test(field.path));
|
|
2118
|
+
return { own, notAccepted: [...notAccepted, ...refusedOwn.map((field) => field.path)] };
|
|
2119
|
+
}
|
|
2120
|
+
function fields(schema, defaults) {
|
|
2121
|
+
return schemaReference(z2.toJSONSchema(schema, { io: "input" }), defaults);
|
|
2122
|
+
}
|
|
2123
|
+
function describeType(type, detail = "compact") {
|
|
2124
|
+
let definition = getChartDefinition(type);
|
|
2125
|
+
if (!definition) throw new Error(`unknown chart type '${type}'`);
|
|
2126
|
+
let full = detail === "full", { own, notAccepted } = typeOptions(definition.type), dataFields = fields(definition.dataSchema), fixtures2 = getFixtures(definition.type), shown = full ? fixtures2 : fixtures2.filter((fixture) => fixture.kind === "example").slice(0, COMPACT_FIXTURES), sizing = definition.sizing, example = definition.discovery?.example, ids = chartIds(definition.type);
|
|
2127
|
+
return {
|
|
2128
|
+
type: definition.type,
|
|
2129
|
+
summary: full ? definition.summary : shortSummaryFor(definition.type, definition.summary),
|
|
2130
|
+
...full ? { reading: { counts: readingCountsSchema, ...definition.type === "grid" ? { metricStack: readingMetricStackSchema } : {} } } : {},
|
|
2131
|
+
useCases: useCasesFor(definition.type, detail),
|
|
2132
|
+
...designCardFor(definition.type) ? { design: full ? structuredClone(designCardFor(definition.type)) : compactDesignCard(definition.type) } : {},
|
|
2133
|
+
...ids.length ? { ids } : {},
|
|
2134
|
+
...definition.aliases?.length ? { aliases: [...definition.aliases] } : {},
|
|
2135
|
+
...full && definition.discovery?.notFor ? { notFor: definition.discovery.notFor } : {},
|
|
2136
|
+
...full && definition.discovery?.densities ? { densities: structuredClone(definition.discovery.densities) } : {},
|
|
2137
|
+
example: example ? { type: definition.type, ...structuredClone(example) } : null,
|
|
2138
|
+
data: full ? fieldRows(dataFields, !0) : fieldLines(dataFields, !0),
|
|
2139
|
+
options: full ? fieldRows(own, !0) : fieldLines(own, !0),
|
|
2140
|
+
sharedOptions: "plus boardplot_list sharedOptions, which a path here replaces. \u2026 ends a cut row: describe its path for the rest",
|
|
2141
|
+
...notAccepted.length ? { notAccepted } : {},
|
|
2142
|
+
sizing: {
|
|
2143
|
+
minWidth: sizing.minWidth,
|
|
2144
|
+
minHeight: sizing.minHeight,
|
|
2145
|
+
fit: sizing.fit,
|
|
2146
|
+
...definition.type === "waffle" ? { contentFloor: "Static floors are for one default panel. The renderer measures the floor from the grid, panel row, text and required key." } : {},
|
|
2147
|
+
...sizing.compactFloor ? { compactFloor: sizing.compactFloor } : {},
|
|
2148
|
+
...["treemap", "kpi", "bullet", "status"].includes(definition.type) ? { requirement: "Static floors. Text, row count and label gutters can raise the measured size." } : {}
|
|
2149
|
+
},
|
|
2150
|
+
annotations: full ? definition.annotationKinds.map((kind) => {
|
|
2151
|
+
let described = describeAnnotation(kind, definition.type);
|
|
2152
|
+
return { kind, required: described.requiredFields, anchors: described.anchors, optional: described.optional, use: described.use, notes: described.notes };
|
|
2153
|
+
}) : Object.fromEntries(definition.annotationKinds.map((kind) => [kind, describeAnnotation(kind, definition.type).requiredFields])),
|
|
2154
|
+
fixtures: full ? shown.map((fixture) => ({ id: fixture.id, chart: chartIdOf(definition.type, fixture.data, fixture.options), useCase: fixture.title, kind: fixture.kind })) : Object.fromEntries(shown.map((fixture) => [fixture.id, fixture.title])),
|
|
2155
|
+
...!full && fixtures2.length > shown.length ? { moreFixtures: fixtures2.length - shown.length } : {}
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
function pathKey(path) {
|
|
2159
|
+
return path.replace(/\[\d*\]/g, "").replace(/^\.+|\.+$/g, "");
|
|
2160
|
+
}
|
|
2161
|
+
function describeField(type, path) {
|
|
2162
|
+
let definition = getChartDefinition(type);
|
|
2163
|
+
if (!definition) throw new Error(`unknown chart type '${type}'`);
|
|
2164
|
+
if (path === "design") {
|
|
2165
|
+
let card = designCardFor(definition.type);
|
|
2166
|
+
return card ? { type: definition.type, part: "design", path: "design", design: structuredClone(card) } : null;
|
|
2167
|
+
}
|
|
2168
|
+
let [, part, rest] = /^(data|options)\.(.*)$/.exec(path) ?? [], key = pathKey(rest ?? path);
|
|
2169
|
+
if (part !== "data" && (key === "annotations" || key.startsWith("annotations."))) {
|
|
2170
|
+
let kinds = definition.annotationKinds.filter((kind) => key === "annotations" || key === `annotations.${kind}`);
|
|
2171
|
+
if (kinds.length) return {
|
|
2172
|
+
type: definition.type,
|
|
2173
|
+
part: "options",
|
|
2174
|
+
path: key,
|
|
2175
|
+
fields: fieldRows(optionFields(definition.type).filter((field) => pathKey(field.path) === key || pathKey(field.path).startsWith(`${key}.`))),
|
|
2176
|
+
annotations: kinds.map((kind) => describeAnnotation(kind, definition.type))
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
let halves = part === "data" ? ["data"] : part === "options" ? ["options"] : ["options", "data"];
|
|
2180
|
+
for (let half of halves) {
|
|
2181
|
+
let matches = (half === "data" ? fields(definition.dataSchema) : optionFields(definition.type)).filter((field) => pathKey(field.path) === key || pathKey(field.path).startsWith(`${key}.`));
|
|
2182
|
+
if (!matches.length) continue;
|
|
2183
|
+
let named = matches.find((field) => pathKey(field.path) === key)?.path ?? key, refused = matches.find((field) => field.type === "never" && pathKey(field.path) === key);
|
|
2184
|
+
return refused ? { type: definition.type, part: half, path: named, refused: refused.description } : { type: definition.type, part: half, path: named, fields: fieldRows(matches, half === "data") };
|
|
2185
|
+
}
|
|
2186
|
+
return !part && key === "name" ? { type: definition.type, part: "spec", path: "name", fields: [{ ...BARE_NAME_FIELD }] } : null;
|
|
2187
|
+
}
|
|
2188
|
+
function topLevelFields(type) {
|
|
2189
|
+
let definition = getChartDefinition(type), top = (list2) => [...new Set(list2.filter((field) => field.type !== "never" && !/[.[]/.test(field.path)).map((field) => field.path))];
|
|
2190
|
+
return { data: top(fields(definition.dataSchema)), options: top(optionFields(definition.type)) };
|
|
2191
|
+
}
|
|
2192
|
+
function matchingFieldPaths(type, leaf) {
|
|
2193
|
+
let definition = getChartDefinition(type), matches = (part, all) => all.filter((field) => field.type !== "never" && field.path.split(".").at(-1)?.replace(/\[\]/g, "") === leaf).map((field) => `${part}.${field.path}`);
|
|
2194
|
+
return {
|
|
2195
|
+
paths: [.../* @__PURE__ */ new Set([...matches("data", fields(definition.dataSchema)), ...matches("options", optionFields(definition.type))])],
|
|
2196
|
+
example: describeType(type).example
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
function describeSchema(type, part) {
|
|
2200
|
+
let definition = getChartDefinition(type);
|
|
2201
|
+
if (!definition) throw new Error(`unknown chart type '${type}'`);
|
|
2202
|
+
return {
|
|
2203
|
+
type: definition.type,
|
|
2204
|
+
part,
|
|
2205
|
+
schema: part === "data" ? z2.toJSONSchema(definition.dataSchema, { io: "input" }) : z2.toJSONSchema(definition.optionsSchema, { io: "input", override: ({ jsonSchema }) => {
|
|
2206
|
+
jsonSchema.type === "object" && jsonSchema.properties && jsonSchema.additionalProperties === void 0 && (jsonSchema.additionalProperties = !1);
|
|
2207
|
+
} })
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
var THEME_ERRORS = {
|
|
2211
|
+
"unknown-theme": "the preset name is not registered",
|
|
2212
|
+
"invalid-theme": "a token is unknown or has the wrong type",
|
|
2213
|
+
"invalid-theme-override": "overrides produce a structurally invalid theme",
|
|
2214
|
+
"theme-name-reserved": "a full theme object uses a preset name",
|
|
2215
|
+
"unparseable-color": "a colour is unsupported; use hex, rgb(), hsl(), oklch() or var() with a literal fallback",
|
|
2216
|
+
"contrast-ink": "ink on background is below 4.5:1",
|
|
2217
|
+
"contrast-ink-muted": "inkMuted on background is below 3:1",
|
|
2218
|
+
"contrast-inside-label": "a label inside a fill is below its contrast floor",
|
|
2219
|
+
"semantic-equals-background": "good, bad or highlight equals the background",
|
|
2220
|
+
"good-bad-similar": "good and bad are nearly identical",
|
|
2221
|
+
"family-outside-metric-class": "warning: the leading family of a type stack is not Inter, Geist, Helvetica, Helvetica Neue, Arial or a metric clone, so text can render wider than measured; pass tables built by `boardplot fonts build`, see docs/FONTS.md"
|
|
2222
|
+
}, BRAND_THEME_EXAMPLE = {
|
|
2223
|
+
preset: "standard",
|
|
2224
|
+
overrides: { color: { highlight: "#0B5CAD", series: ["#0B5CAD", "#5B8DB8", "#A9C1D9"] } }
|
|
2225
|
+
};
|
|
2226
|
+
function describeTheme(detail = "compact") {
|
|
2227
|
+
let tokenFields = themeFieldReference(themes.standard);
|
|
2228
|
+
return {
|
|
2229
|
+
type: "theme",
|
|
2230
|
+
summary: "The theme token contract. A spec takes theme as a preset name, as { preset, overrides } or as a full token object with its own name; defaults below are the standard preset.",
|
|
2231
|
+
presets: [...PRESET_THEME_NAMES],
|
|
2232
|
+
example: BRAND_THEME_EXAMPLE,
|
|
2233
|
+
tokens: detail === "full" ? fieldRows(tokenFields, !0) : fieldLines(tokenFields, !0),
|
|
2234
|
+
errorCodes: { ...THEME_ERRORS }
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// src/cli/describe.ts
|
|
2239
|
+
function describeTypes() {
|
|
2240
|
+
return [...listCharts().map((chart) => chart.type).sort(), "theme"];
|
|
2241
|
+
}
|
|
2242
|
+
function unknownType(type, path = "/type") {
|
|
2243
|
+
return new InputError("unknown-type", `unknown chart type '${type}'`, {
|
|
2244
|
+
path,
|
|
2245
|
+
expected: { values: describeTypes().filter((value) => value !== "theme") },
|
|
2246
|
+
suggest: unsupportedSuggestion(type) ?? "Call boardplot_list for the types Boardplot draws."
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
function describe(input) {
|
|
2250
|
+
let detail = input.detail ?? "compact";
|
|
2251
|
+
if (detail !== "compact" && detail !== "full")
|
|
2252
|
+
throw new InputError("invalid-argument", "detail must be compact or full", {
|
|
2253
|
+
path: "/detail",
|
|
2254
|
+
expected: { values: ["compact", "full"] },
|
|
2255
|
+
suggest: "Omit detail, or pass full.",
|
|
2256
|
+
fix: [{ op: "replace", path: "/detail", value: "compact" }]
|
|
2257
|
+
});
|
|
2258
|
+
if (typeof input.type != "string" || input.type === "")
|
|
2259
|
+
throw new InputError("missing-type", "describe needs a chart type or theme", {
|
|
2260
|
+
path: "/type",
|
|
2261
|
+
expected: { values: describeTypes() },
|
|
2262
|
+
suggest: "Pass a type from boardplot_list, or theme."
|
|
2263
|
+
});
|
|
2264
|
+
let narrowed = input.path !== void 0 ? "/path" : input.schema !== void 0 ? "/schema" : void 0;
|
|
2265
|
+
if (input.type === "theme") {
|
|
2266
|
+
if (narrowed)
|
|
2267
|
+
throw new InputError("invalid-argument", "path and schema describe a chart type; describe theme lists every token", {
|
|
2268
|
+
path: narrowed,
|
|
2269
|
+
suggest: "Describe theme without path or schema.",
|
|
2270
|
+
fix: [{ op: "remove", path: narrowed }]
|
|
2271
|
+
});
|
|
2272
|
+
return ok(describeTheme(detail));
|
|
2273
|
+
}
|
|
2274
|
+
if (!getChartDefinition(input.type)) throw unknownType(input.type);
|
|
2275
|
+
if (input.path !== void 0 && input.schema !== void 0)
|
|
2276
|
+
throw new InputError("invalid-argument", "pass path or schema, not both", {
|
|
2277
|
+
path: "/schema",
|
|
2278
|
+
suggest: "Ask for one field with path, or for the whole schema with schema.",
|
|
2279
|
+
fix: [{ op: "remove", path: "/schema" }]
|
|
2280
|
+
});
|
|
2281
|
+
if (input.schema !== void 0) {
|
|
2282
|
+
if (input.schema !== "data" && input.schema !== "options")
|
|
2283
|
+
throw new InputError("invalid-argument", "schema must be data or options", {
|
|
2284
|
+
path: "/schema",
|
|
2285
|
+
expected: { values: ["data", "options"] },
|
|
2286
|
+
suggest: "Pass schema data or options."
|
|
2287
|
+
});
|
|
2288
|
+
return ok(describeSchema(input.type, input.schema));
|
|
2289
|
+
}
|
|
2290
|
+
if (input.path !== void 0) {
|
|
2291
|
+
if (typeof input.path != "string" || input.path.trim() === "")
|
|
2292
|
+
throw new InputError("invalid-argument", "path must be a field path such as valueAxis.break", { path: "/path", expected: { types: ["string"] } });
|
|
2293
|
+
let field = describeField(input.type, input.path.trim());
|
|
2294
|
+
if (field) return ok(field);
|
|
2295
|
+
if (input.path.trim() === "design")
|
|
2296
|
+
throw new InputError("unknown-field", `'${input.type}' has no design card yet`, {
|
|
2297
|
+
path: "/path",
|
|
2298
|
+
expected: { values: designCardTypes() },
|
|
2299
|
+
suggest: `Design cards exist for ${designCardTypes().join(", ")}. Describe ${input.type} without path for its use cases.`
|
|
2300
|
+
});
|
|
2301
|
+
let top = topLevelFields(input.type), matches = matchingFieldPaths(input.type, input.path.trim().split(".").at(-1));
|
|
2302
|
+
throw new InputError("unknown-field", `'${input.type}' has no field '${input.path}'`, {
|
|
2303
|
+
path: "/path",
|
|
2304
|
+
expected: {
|
|
2305
|
+
values: matches.paths.length ? matches.paths : [...top.options, ...top.data.map((name) => `data.${name}`)],
|
|
2306
|
+
...matches.paths.length ? { example: matches.example } : {}
|
|
2307
|
+
},
|
|
2308
|
+
suggest: matches.paths.length ? `Use ${matches.paths.join(" or ")}. Example: boardplot describe ${input.type} --path ${matches.paths[0]}.` : "Pass one of the listed fields, or a path below one, such as valueAxis.break or data.series[].values."
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
return ok(describeType(input.type, detail));
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
// src/cli/fixtures.ts
|
|
2315
|
+
var FIXTURES_PER_PAGE = 25, KINDS = ["example", "torture", "all"];
|
|
2316
|
+
function specOf(type, fixture) {
|
|
2317
|
+
return {
|
|
2318
|
+
type,
|
|
2319
|
+
data: structuredClone(fixture.data),
|
|
2320
|
+
...fixture.options ? { options: structuredClone(fixture.options) } : {},
|
|
2321
|
+
...fixture.annotations ? { annotations: structuredClone(fixture.annotations) } : {}
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
function optionalString(name, value) {
|
|
2325
|
+
if (value !== void 0) {
|
|
2326
|
+
if (typeof value != "string" || value === "")
|
|
2327
|
+
throw new InputError("invalid-argument", `${name} must be a non-empty string`, { path: `/${name}`, expected: { types: ["string"] } });
|
|
2328
|
+
return value;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
function cursorOf(value) {
|
|
2332
|
+
if (value === void 0) return 0;
|
|
2333
|
+
let offset = Number(value);
|
|
2334
|
+
if (!Number.isInteger(offset) || offset < 0)
|
|
2335
|
+
throw new InputError("invalid-argument", "cursor must be a nextCursor value from an earlier call", { path: "/cursor" });
|
|
2336
|
+
return offset;
|
|
2337
|
+
}
|
|
2338
|
+
function candidates(type) {
|
|
2339
|
+
if (type !== void 0 && !getChart(type)) throw unknownType(type);
|
|
2340
|
+
return (type === void 0 ? listCharts().map((chart) => chart.type).sort() : [getChart(type).type]).flatMap((owner) => getFixtures(owner).map((fixture) => ({ fixture, type: owner })));
|
|
2341
|
+
}
|
|
2342
|
+
function kindOf(value) {
|
|
2343
|
+
let kind = value ?? "example";
|
|
2344
|
+
if (!KINDS.includes(kind))
|
|
2345
|
+
throw new InputError("invalid-argument", "kind must be example, torture or all", {
|
|
2346
|
+
path: "/kind",
|
|
2347
|
+
expected: { values: [...KINDS] },
|
|
2348
|
+
fix: [{ op: "replace", path: "/kind", value: "example" }]
|
|
2349
|
+
});
|
|
2350
|
+
return kind;
|
|
2351
|
+
}
|
|
2352
|
+
function fixtures(input, perPage = FIXTURES_PER_PAGE) {
|
|
2353
|
+
let type = optionalString("type", input.type), id = optionalString("id", input.id), kind = kindOf(input.kind), matched = candidates(type);
|
|
2354
|
+
if (id !== void 0) {
|
|
2355
|
+
if (matched = matched.filter((entry) => entry.fixture.id === id), !matched.length)
|
|
2356
|
+
throw new InputError("unknown-fixture", `no fixture with id '${id}'${type ? ` for type '${type}'` : ""}`, {
|
|
2357
|
+
path: "/id",
|
|
2358
|
+
suggest: "Call boardplot_fixtures without id, or boardplot_describe for the ids of one type."
|
|
2359
|
+
});
|
|
2360
|
+
if (matched.length > 1) {
|
|
2361
|
+
let types = matched.map((entry) => entry.type);
|
|
2362
|
+
throw new InputError("ambiguous-fixture", `fixture id '${id}' exists for ${types.join(" and ")}; pass type as well`, {
|
|
2363
|
+
path: "/type",
|
|
2364
|
+
expected: { values: types },
|
|
2365
|
+
suggest: types.map((type2) => `CLI: boardplot fixtures --type ${type2} --id ${id}. MCP: boardplot_fixtures ${JSON.stringify({ type: type2, id })}.`).join(" ")
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
} else kind !== "all" && (matched = matched.filter((entry) => entry.fixture.kind === kind));
|
|
2369
|
+
let offset = cursorOf(input.cursor), page = matched.slice(offset, offset + perPage), next = offset + perPage < matched.length ? String(offset + perPage) : void 0;
|
|
2370
|
+
return ok({
|
|
2371
|
+
fixtures: page.map(({ fixture, type: owner }) => ({
|
|
2372
|
+
id: fixture.id,
|
|
2373
|
+
type: owner,
|
|
2374
|
+
chart: chartIdOf(owner, fixture.data, fixture.options),
|
|
2375
|
+
kind: fixture.kind,
|
|
2376
|
+
useCase: fixture.title,
|
|
2377
|
+
spec: specOf(owner, fixture)
|
|
2378
|
+
})),
|
|
2379
|
+
...next ? { nextCursor: next, note: `${matched.length} fixtures match; narrow with type or kind, or pass cursor ${next}` } : {}
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
// src/cli/render.ts
|
|
2384
|
+
import { closeSync, constants, lstatSync, mkdirSync, openSync, readdirSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
2385
|
+
import { basename, dirname, extname as extname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve4 } from "path";
|
|
2386
|
+
|
|
2387
|
+
// src/core/reading.ts
|
|
2388
|
+
function operationWords(op) {
|
|
2389
|
+
return op.replace(/@\d+$/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter(Boolean).map((word) => word.toLowerCase()).join(" ");
|
|
2390
|
+
}
|
|
2391
|
+
function isDerivation(kind) {
|
|
2392
|
+
return CLAIM_KIND_GROUPS.derivations.includes(kind);
|
|
2393
|
+
}
|
|
2394
|
+
function reportableNumber(record) {
|
|
2395
|
+
return record.state === "value" && typeof record.raw == "number" && Number.isFinite(record.raw) ? record.raw : null;
|
|
2396
|
+
}
|
|
2397
|
+
function explainClaims(claims) {
|
|
2398
|
+
let derivations = claims.filter((claim) => isDerivation(claim.kind)).length, observed = claims.filter((claim) => claim.kind === "observed").length, authored = claims.filter((claim) => claim.kind === "authored").length, states = [...new Set(claims.map((claim) => claim.output.state))].sort(), summary = [
|
|
2399
|
+
`${claims.length} claim ${claims.length === 1 ? "record" : "records"} for this chart: ${derivations} engine ${derivations === 1 ? "derivation" : "derivations"} and ${claims.length - derivations} that ${claims.length - derivations === 1 ? "promises" : "promise"} no arithmetic.`
|
|
2400
|
+
];
|
|
2401
|
+
if (claims.length - derivations > 0) {
|
|
2402
|
+
let parts = [];
|
|
2403
|
+
observed > 0 && parts.push(`${observed} ${observed === 1 ? "was" : "were"} measured from the source sample`), authored > 0 && parts.push(`${authored} came from the document`), parts.length > 0 && summary.push(`Of the records without arithmetic, ${parts.join(" and ")}.`);
|
|
2404
|
+
}
|
|
2405
|
+
return states.some((state) => state !== "value") && summary.push(`Claim states in this chart: ${states.join(", ")}.`), {
|
|
2406
|
+
total: claims.length,
|
|
2407
|
+
derivations,
|
|
2408
|
+
nonDerivations: claims.length - derivations,
|
|
2409
|
+
observed,
|
|
2410
|
+
authored,
|
|
2411
|
+
states,
|
|
2412
|
+
summary
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
function derivedNumbers(claims) {
|
|
2416
|
+
return claims.filter((claim) => isDerivation(claim.kind)).map((claim) => ({
|
|
2417
|
+
claimId: claim.id,
|
|
2418
|
+
...claim.id.startsWith("stack:") ? { inputs: claim.inputs.map((input) => ({ ...input })) } : {},
|
|
2419
|
+
op: claim.op,
|
|
2420
|
+
operation: operationWords(claim.op),
|
|
2421
|
+
displayed: claim.output.displayed || "Not displayed",
|
|
2422
|
+
visible: claim.output.displayed.length > 0,
|
|
2423
|
+
...claim.noteLocation ? { noteLocation: claim.noteLocation } : {},
|
|
2424
|
+
...claim.drawn === !1 ? { drawn: !1 } : {},
|
|
2425
|
+
value: reportableNumber(claim.output),
|
|
2426
|
+
state: claim.output.state
|
|
2427
|
+
}));
|
|
2428
|
+
}
|
|
2429
|
+
var VALUE_NOTE_LIMIT = 10;
|
|
2430
|
+
function valuesSummary(records2, unavailableNote) {
|
|
2431
|
+
if (records2 === null) {
|
|
2432
|
+
let note = unavailableNote ?? "No interaction record adapter covers this chart type.";
|
|
2433
|
+
return {
|
|
2434
|
+
source: "unavailable",
|
|
2435
|
+
note,
|
|
2436
|
+
total: 0,
|
|
2437
|
+
numbers: 0,
|
|
2438
|
+
byState: {},
|
|
2439
|
+
byKind: {},
|
|
2440
|
+
suppressed: [],
|
|
2441
|
+
withoutNumber: [],
|
|
2442
|
+
summary: [`${note} No per-value description is reported.`]
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
let byState = {}, byKind = {}, suppressed = [], withoutNumber = [], numbers = 0;
|
|
2446
|
+
for (let record of records2) {
|
|
2447
|
+
let { state, kind } = record.value;
|
|
2448
|
+
byState[state] = (byState[state] ?? 0) + 1, byKind[kind] = (byKind[kind] ?? 0) + 1, kind === "number" && state === "value" && (numbers += 1);
|
|
2449
|
+
let note = { recordId: record.id, label: record.label, state, reason: record.value.reason ?? null };
|
|
2450
|
+
state === "suppressed" ? suppressed.length < VALUE_NOTE_LIMIT && suppressed.push(note) : state !== "value" && withoutNumber.length < VALUE_NOTE_LIMIT && withoutNumber.push(note);
|
|
2451
|
+
}
|
|
2452
|
+
let textOrDate = (byKind.text ?? 0) + (byKind.date ?? 0), summary = [
|
|
2453
|
+
`The records describe ${records2.length} ${records2.length === 1 ? "value" : "values"}, ${numbers} of them a plain number${textOrDate > 0 ? ` and ${textOrDate} text or date` : ""}.`
|
|
2454
|
+
], withheld = byState.suppressed ?? 0;
|
|
2455
|
+
withheld > 0 && summary.push(
|
|
2456
|
+
`${withheld} ${withheld === 1 ? "value is" : "values are"} withheld, so no raw number is reported for them.`
|
|
2457
|
+
);
|
|
2458
|
+
let other = Object.entries(byState).filter(([state]) => state !== "value" && state !== "suppressed"), otherCount = other.reduce((sum, [, count]) => sum + count, 0);
|
|
2459
|
+
return otherCount > 0 && summary.push(
|
|
2460
|
+
`${otherCount} ${otherCount === 1 ? "value is" : "values are"} neither present nor withheld: ${other.map(([state]) => state).sort().join(", ")}.`
|
|
2461
|
+
), { source: "interaction-records", total: records2.length, numbers, byState, byKind, suppressed, withoutNumber, summary };
|
|
2462
|
+
}
|
|
2463
|
+
function recordsFor(input) {
|
|
2464
|
+
try {
|
|
2465
|
+
return {
|
|
2466
|
+
records: interactionRecords({
|
|
2467
|
+
request: input.request,
|
|
2468
|
+
geometry: input.geometry,
|
|
2469
|
+
scope: input.request.scope,
|
|
2470
|
+
claims: input.claims
|
|
2471
|
+
// An event of the event lane or a value line is an annotation, not a value the chart plots.
|
|
2472
|
+
}).filter((record) => record.target.owner.annotationId === void 0)
|
|
2473
|
+
};
|
|
2474
|
+
} catch (error) {
|
|
2475
|
+
return {
|
|
2476
|
+
records: null,
|
|
2477
|
+
note: `No interaction record adapter covers this chart type: ${error instanceof Error ? error.message : String(error)}`
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
function unrequestedLabelOmissions(input, records2, omissions) {
|
|
2482
|
+
let named = new Set(omissions.map((item) => item.labelId)), destinationOf = readableLabelDestination(input.geometry), add = (labelId, text, reason, owner = {}, kind, printedText = text) => {
|
|
2483
|
+
named.has(labelId) || (named.add(labelId), !destinationOf(labelId, printedText, owner, kind, text) && omissions.push({ labelId, text, reason, destination: "reading.omissions" }));
|
|
2484
|
+
}, valueKey = (owner) => JSON.stringify([owner.seriesId, owner.categoryId, owner.pointId]), buildContext = (prefix) => {
|
|
2485
|
+
let scope = omissionScope(input.geometry, input.request.options, `${prefix}point`, input.request.data), data = scope.data ?? {}, labels = scope.geometry.labels, categories = (Array.isArray(data.categories) ? data.categories : []).map(normalizeCategory), seriesById = new Map((Array.isArray(data.series) ? data.series : []).filter((series) => series.values !== void 0).map((series, index) => [series.id, { ...series, values: normalizeSeriesValues(series, categories, index) }])), options = scope.options ?? {}, geometry = scope.geometry, order = geometry.type === "bar" ? geometry.derived.order : void 0, visibleCategories = new Set(order ?? geometry.axes.flatMap((axis) => axis.ticks.filter((tick) => tick.labelId && /(?:^|[:/])category:/.test(tick.labelId)).map((tick) => String(tick.at)))), topN = options.topN, topNCut = typeof topN?.n == "number" && topN.n > 0 && (categories.length > topN.n || typeof topN.threshold == "number" && topN.threshold > 0) && !options.window && !options.viewDomain;
|
|
2486
|
+
return {
|
|
2487
|
+
categories,
|
|
2488
|
+
seriesById,
|
|
2489
|
+
geometry,
|
|
2490
|
+
data,
|
|
2491
|
+
options,
|
|
2492
|
+
visibleCategories,
|
|
2493
|
+
topNCut,
|
|
2494
|
+
plottedPoints: new Set((geometry.type === "scatter" ? geometry.marks.points ?? [] : []).map((point) => point.id)),
|
|
2495
|
+
capApplied: geometry.type === "scatter" && geometry.warnings.some((warning2) => warning2.code === "labels-auto-off"),
|
|
2496
|
+
requestedValues: new Set(labels.filter((label) => ["point", "segment", "insidePie", "outsidePie"].includes(label.kind)).map((label) => valueKey(label.owner))),
|
|
2497
|
+
drawnSeries: new Set(labels.filter((label) => label.kind === "series" && !label.hidden).map((label) => label.owner.seriesId)),
|
|
2498
|
+
drawnCategories: new Set(labels.filter((label) => label.kind === "category" && !label.hidden).map((label) => label.owner.categoryId)),
|
|
2499
|
+
keptCategories: new Set(visibleCategories.size ? visibleCategories : labels.map((label) => label.owner.categoryId))
|
|
2500
|
+
};
|
|
2501
|
+
}, contexts = /* @__PURE__ */ new Map();
|
|
2502
|
+
for (let record of records2) {
|
|
2503
|
+
let prefix = record.target.panel ? `${record.target.panel}/` : "", context = contexts.get(prefix);
|
|
2504
|
+
context || (context = buildContext(prefix), contexts.set(prefix, context));
|
|
2505
|
+
let { categories, seriesById, options } = context, settings = options.labels, disabled = (kind) => {
|
|
2506
|
+
let setting = typeof settings == "object" && settings !== null ? settings[kind] : void 0;
|
|
2507
|
+
return settings === !1 || setting === !1 || Array.isArray(setting) && setting.length === 0;
|
|
2508
|
+
}, owner = record.target.owner;
|
|
2509
|
+
if (context.geometry.type === "scatter" && owner.pointId !== void 0 && !context.plottedPoints.has(owner.pointId) || (options.window || options.viewDomain) && owner.categoryId !== void 0 && context.visibleCategories.size && !context.visibleCategories.has(owner.categoryId)) continue;
|
|
2510
|
+
context.keptCategories.add(owner.categoryId);
|
|
2511
|
+
let series = owner.seriesId === void 0 ? void 0 : seriesById.get(owner.seriesId), categoryIndex = categories.findIndex((category) => category.id === owner.categoryId), cell = series?.values[categoryIndex], cellLabel = typeof cell == "object" && cell !== null && "label" in cell ? cell.label : void 0, only = typeof options.seriesLabels == "object" && options.seriesLabels !== null ? options.seriesLabels.only : void 0, excludedSeries = only !== void 0 && owner.seriesId !== void 0 && !only.includes(owner.seriesId), excludedValues = excludedSeries && context.geometry.type === "line", hasValueRequest = context.requestedValues.has(valueKey(owner)), valueKind = context.geometry.type !== "line" && typeof options.variant == "string" && options.variant.startsWith("stacked") ? "segment" : "point", selectiveValues = typeof options.valueLabels == "string" && options.valueLabels !== "all";
|
|
2512
|
+
if (!hasValueRequest && owner.categoryId !== void 0 && record.value.state === "value" && (disabled(valueKind) || cellLabel === !1 || excludedValues || selectiveValues)) {
|
|
2513
|
+
let reason = cellLabel === !1 ? "cell-label-disabled" : excludedValues ? "seriesLabels.only" : disabled(valueKind) ? "disabled" : `valueLabels:${options.valueLabels}`, value = typeof cellLabel == "string" ? cellLabel : interactionValueText(record.value, input.request.locale?.language);
|
|
2514
|
+
add(`${prefix}${valueKind}:${owner.seriesId ?? ""}:${owner.categoryId}`, `${record.label} ${value}`, reason, owner, valueKind, value);
|
|
2515
|
+
}
|
|
2516
|
+
context.geometry.type === "scatter" && owner.pointId !== void 0 && !hasValueRequest && (disabled("point") || context.capApplied) && add(`${prefix}point:${owner.pointId}`, record.label, disabled("point") ? "disabled" : "maxPointLabels", owner, "category");
|
|
2517
|
+
let seriesSetting = typeof settings == "object" && settings !== null ? settings.series : void 0;
|
|
2518
|
+
if (owner.seriesId !== void 0 && record.seriesLabel !== void 0 && (disabled("series") || options.seriesLabels === "none" || excludedSeries || Array.isArray(seriesSetting) && !seriesSetting.includes("series")) && !context.drawnSeries.has(owner.seriesId) && add(`${prefix}series:${owner.seriesId}`, record.seriesLabel, disabled("series") ? "disabled" : "seriesLabels", { seriesId: owner.seriesId }, "series"), disabled("category") && owner.categoryId !== void 0 && record.categoryLabel !== void 0 && !context.drawnCategories.has(owner.categoryId) && add(`${prefix}category:${owner.categoryId}`, record.categoryLabel, "disabled", { categoryId: owner.categoryId }, "category"), context.topNCut && owner.categoryId !== void 0 && !categories.some((category) => category.id === owner.categoryId)) for (let member of record.members ?? []) {
|
|
2519
|
+
let category = categories.find((category2) => category2.id === member.categoryId);
|
|
2520
|
+
category && add(`${prefix}category:${category.id}`, category.label ?? category.id, "topN", { categoryId: category.id }, "category");
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
for (let [prefix, context] of contexts) if (context.topNCut && context.options.topN?.rest === !1)
|
|
2524
|
+
for (let category of context.categories) context.keptCategories.has(category.id) || add(`${prefix}category:${category.id}`, category.label ?? category.id, "topN", { categoryId: category.id }, "category");
|
|
2525
|
+
for (let [prefix, context] of contexts) {
|
|
2526
|
+
let { options, geometry } = context, settings = typeof options.labels == "object" && options.labels !== null ? options.labels : void 0;
|
|
2527
|
+
if (options.grandTotalLabels === !1 || options.labels === !1 || settings?.grandTotal === !1) {
|
|
2528
|
+
let totals = geometry.derived.stackTotals ?? geometry.derived.totals ?? {};
|
|
2529
|
+
if (["column", "bar", "combo"].includes(geometry.type)) for (let [id, raw] of Object.entries(totals)) {
|
|
2530
|
+
if (!Number.isFinite(raw) || geometry.labels.some((label) => label.id === `grandTotal:${id}`)) continue;
|
|
2531
|
+
let category = context.categories.find((category2) => category2.id === id), value = interactionValueText({
|
|
2532
|
+
kind: "number",
|
|
2533
|
+
state: "value",
|
|
2534
|
+
raw,
|
|
2535
|
+
derived: "number",
|
|
2536
|
+
...typeof options.unit == "string" ? { unit: options.unit } : {},
|
|
2537
|
+
...typeof options.format == "string" ? { format: options.format } : {}
|
|
2538
|
+
}, input.request.locale?.language);
|
|
2539
|
+
add(`${prefix}grandTotal:${id}`, `${category?.label ?? id} ${value}`, "disabled", { categoryId: id }, "grandTotal", value);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
if (geometry.type === "sparkline") {
|
|
2543
|
+
let names2 = context.data.labels;
|
|
2544
|
+
if (options.endLabels === "none" && names2?.length) for (let [end, index] of [["first", 0], ["last", names2.length - 1]])
|
|
2545
|
+
add(`${prefix}spark:label:${end}`, names2[index], "endLabels:none", {}, "category");
|
|
2546
|
+
if (options.valueLabel === "none") {
|
|
2547
|
+
let last = records2.filter((record) => (record.target.panel ? `${record.target.panel}/` : "") === prefix && record.value.state === "value").at(-1);
|
|
2548
|
+
if (last) {
|
|
2549
|
+
let value = interactionValueText(last.value, input.request.locale?.language);
|
|
2550
|
+
add(`${prefix}spark:last`, `${last.label} ${value}`, "valueLabel:none", last.target.owner, "point", value);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
function chartReading(input) {
|
|
2557
|
+
let { records: records2, note } = recordsFor(input), title = input.request.options.title, byData = dataOrder(input.request.data, input.geometry.labels), omissions = labelOmissions(input.geometry, input.request.options, input.request.data);
|
|
2558
|
+
unrequestedLabelOmissions(input, records2 ?? [], omissions);
|
|
2559
|
+
let dropped = input.geometry.labels.filter((label) => label.hidden !== void 0).sort((a, b) => byData(a.id, b.id)), labelsDroppedBy = {};
|
|
2560
|
+
for (let label of dropped) {
|
|
2561
|
+
let reason = label.noted ? "note" : label.hidden;
|
|
2562
|
+
labelsDroppedBy[reason] = (labelsDroppedBy[reason] ?? 0) + 1;
|
|
2563
|
+
}
|
|
2564
|
+
let series = [...new Set((records2 ?? []).flatMap((record) => record.seriesLabel === void 0 ? [] : [record.seriesLabel]))], rounding = input.geometry.derived?.roundingAdjustments, source = input.geometry.frame.source, fittedSource = input.geometry.scene.find((node2) => node2.id === input.geometry.frame.sourceNodeId && node2.t === "text"), sourceDrawn = source && (fittedSource?.t === "text" && fittedSource.opacity !== 0 && fittedSource.lines.join(" ").replace(/\s+/g, " ").trim() === source.replace(/\s+/g, " ").trim() || readableLabelDestination(input.geometry)("frame:source", source, {}, "source"));
|
|
2565
|
+
return {
|
|
2566
|
+
name: input.name,
|
|
2567
|
+
type: input.type,
|
|
2568
|
+
counts: (input.geometry.a11y.counts ?? []).map((count) => ({ ...count })),
|
|
2569
|
+
title: typeof title == "string" && title.trim() !== "" ? title : null,
|
|
2570
|
+
size: { width: input.geometry.size.width, height: input.geometry.size.height },
|
|
2571
|
+
mode: input.geometry.mode ?? "full",
|
|
2572
|
+
titleLines: input.geometry.frame.titleLines ?? 0,
|
|
2573
|
+
series,
|
|
2574
|
+
labelsPlaced: input.geometry.labels.length - dropped.length,
|
|
2575
|
+
labelsTruncated: cutLabels(input.geometry),
|
|
2576
|
+
labelsDropped: dropped.length,
|
|
2577
|
+
labelsDroppedBy,
|
|
2578
|
+
omissions: [
|
|
2579
|
+
...omissions.sort((a, b) => byData(a.labelId, b.labelId)),
|
|
2580
|
+
...source && !sourceDrawn ? [{ labelId: "frame:source", text: source, reason: fittedSource ? "truncated" : "not-drawn", destination: "frame.source" }] : []
|
|
2581
|
+
],
|
|
2582
|
+
derived: derivedNumbers(input.claims),
|
|
2583
|
+
...input.geometry.derived.metricStack ? { metricStack: { readouts: input.geometry.derived.metricStack.readouts } } : {},
|
|
2584
|
+
claims: explainClaims(input.claims),
|
|
2585
|
+
values: valuesSummary(records2, note),
|
|
2586
|
+
notes: chartNotes(input.geometry),
|
|
2587
|
+
...rounding ? { rounding: rounding.map((adjustment) => ({ ...adjustment })) } : {}
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
// src/cli/size.ts
|
|
2592
|
+
function pixels(name, value) {
|
|
2593
|
+
if (value === void 0) return;
|
|
2594
|
+
let number2 = typeof value == "string" ? Number(value) : value;
|
|
2595
|
+
if (typeof number2 != "number" || !Number.isFinite(number2) || number2 <= 0)
|
|
2596
|
+
throw new InputError("invalid-argument", `${name} must be a positive number of pixels`, {
|
|
2597
|
+
path: `/${name}`,
|
|
2598
|
+
expected: { types: ["number"], minimum: 0, inclusive: !1 },
|
|
2599
|
+
suggest: `Pass ${name} as a number such as 960.`
|
|
2600
|
+
});
|
|
2601
|
+
return number2;
|
|
2602
|
+
}
|
|
2603
|
+
var TARGETS = renderTargetSchema.options;
|
|
2604
|
+
function targetArgument(value) {
|
|
2605
|
+
if (value !== void 0) {
|
|
2606
|
+
if (!TARGETS.includes(value))
|
|
2607
|
+
throw new InputError("invalid-argument", `target must be one of ${TARGETS.join(", ")}`, {
|
|
2608
|
+
path: "/target",
|
|
2609
|
+
expected: { values: [...TARGETS] },
|
|
2610
|
+
received: { type: typeof value, value },
|
|
2611
|
+
suggest: "Pass target report (the default), dashboard, slide or print.",
|
|
2612
|
+
fix: [{ op: "replace", path: "/target", value: DEFAULT_TARGET }]
|
|
2613
|
+
});
|
|
2614
|
+
return value;
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
function length(name, value) {
|
|
2618
|
+
if (value === void 0) return;
|
|
2619
|
+
let text = typeof value == "string" ? value.trim() : void 0, unit = text === void 0 ? void 0 : /(px|pt|mm)$/.exec(text)?.[1], number2 = text === void 0 ? value : Number(unit ? text.slice(0, -2) : text);
|
|
2620
|
+
if (typeof number2 != "number" || !Number.isFinite(number2) || number2 <= 0)
|
|
2621
|
+
throw new InputError("invalid-argument", `${name} must be a positive length: a number of px, or one ending in px, pt or mm`, {
|
|
2622
|
+
path: `/${name}`,
|
|
2623
|
+
expected: { types: ["number"], minimum: 0, inclusive: !1 },
|
|
2624
|
+
received: { type: typeof value, value },
|
|
2625
|
+
suggest: `Pass ${name} as px such as 960, or with a unit such as 660pt or 180mm.`
|
|
2626
|
+
});
|
|
2627
|
+
return { value: number2, unit: unit ?? "px" };
|
|
2628
|
+
}
|
|
2629
|
+
var px = (length2) => toLayoutPx(length2.value, length2.unit);
|
|
2630
|
+
function sizeIn(unit, width, height) {
|
|
2631
|
+
return { width, ...height === void 0 ? {} : { height }, ...unit === "px" ? {} : { unit } };
|
|
2632
|
+
}
|
|
2633
|
+
function inUnit(valuePx, unit, up) {
|
|
2634
|
+
let exact = valuePx / toLayoutPx(1, unit) * 100;
|
|
2635
|
+
return (up ? Math.ceil(exact - 1e-6) : Math.floor(exact + 1e-6)) / 100;
|
|
2636
|
+
}
|
|
2637
|
+
function withSize(chart, width, height, target = DEFAULT_TARGET) {
|
|
2638
|
+
if (!width && !height) return chart;
|
|
2639
|
+
let sized = (size) => ({ ...chart, options: { ...chart.options ?? {}, size } }), authored = chart.options?.size, object2 = typeof authored == "object" && authored !== null ? authored : void 0;
|
|
2640
|
+
if (width && !height && (authored === void 0 || object2 !== void 0 && object2.height === void 0)) return sized(sizeIn(width.unit, width.value));
|
|
2641
|
+
let base;
|
|
2642
|
+
try {
|
|
2643
|
+
base = resolveSize(authored, target);
|
|
2644
|
+
} catch {
|
|
2645
|
+
return chart;
|
|
2646
|
+
}
|
|
2647
|
+
if (width && !height && typeof authored == "string") return sized({ width: px(width), height: presetHeight(base, px(width)) });
|
|
2648
|
+
let unit = (width ?? height).unit, kept = width ? height ? void 0 : object2?.height : object2?.width;
|
|
2649
|
+
return (!width || width.unit === unit) && (!height || height.unit === unit) && (width && height ? !0 : typeof kept == "number" && (object2?.unit ?? "px") === unit) ? sized(sizeIn(unit, width?.value ?? kept, height?.value ?? kept)) : sized({ width: width ? px(width) : base.width, height: height ? px(height) : base.height });
|
|
2650
|
+
}
|
|
2651
|
+
function presetHeight(preset, width) {
|
|
2652
|
+
let step = onLadderStep(preset);
|
|
2653
|
+
return step ? ladderHeights(width).find((entry) => entry.name === step).height : Math.round(width * preset.height / preset.width);
|
|
2654
|
+
}
|
|
2655
|
+
var SIZE_FIXES = ["size-below-floor", "height-off-ladder", "plot-under-min", "aspect-cap"];
|
|
2656
|
+
function attributeSizeOverride(findings, width, height, spec, target) {
|
|
2657
|
+
if (!width && !height) return findings;
|
|
2658
|
+
let args = { width, height };
|
|
2659
|
+
return findings.map((finding) => {
|
|
2660
|
+
if (!SIZE_FIXES.includes(finding.code) || !finding.path?.endsWith("/options/size")) return finding;
|
|
2661
|
+
let operation = finding.fix?.find((operation2) => operation2.op === "replace" || operation2.op === "add");
|
|
2662
|
+
if (!operation || !("value" in operation)) return finding;
|
|
2663
|
+
let needed = operation.path.endsWith("/options") ? operation.value.size : operation.value, short = ["width", "height"].filter((side2) => args[side2] && needed?.[side2] !== void 0 && Math.abs(needed[side2] - px(args[side2])) > 1e-6);
|
|
2664
|
+
if (!short.length) return finding;
|
|
2665
|
+
let side = short[0], original = readJsonPointer(spec, finding.path), authored = original.found ? original.value : void 0, own = readJsonPointer(spec, finding.path.replace(/size$/, "target")), actual = resolveSize(authored, target ?? (own.found ? own.value : DEFAULT_TARGET)), kept = { ...actual, ...typeof authored == "string" && args.width && !args.height ? { height: presetHeight(actual, needed.width) } : {} };
|
|
2666
|
+
if (finding.code === "size-below-floor") for (let name of ["width", "height"]) {
|
|
2667
|
+
let automatic = name === "height" && (authored === void 0 || typeof authored == "object" && authored !== null && !("height" in authored));
|
|
2668
|
+
!args[name] && !automatic && needed[name] > kept[name] && short.push(name);
|
|
2669
|
+
}
|
|
2670
|
+
let value = (name) => {
|
|
2671
|
+
let arg = args[name];
|
|
2672
|
+
return !arg || arg.unit === "px" ? needed[name] : `${inUnit(needed[name], arg.unit, needed[name] > px(arg))}${arg.unit}`;
|
|
2673
|
+
}, received = args[side];
|
|
2674
|
+
return {
|
|
2675
|
+
...finding,
|
|
2676
|
+
path: `/${side}`,
|
|
2677
|
+
displayPath: side,
|
|
2678
|
+
received: received.unit === "px" ? { type: "number", value: received.value } : { type: "string", value: `${received.value}${received.unit}` },
|
|
2679
|
+
suggest: `Pass ${short.map((name) => `${name} ${value(name)}`).join(" and ")}.`,
|
|
2680
|
+
fix: short.map((name) => ({ op: args[name] ? "replace" : "add", path: `/${name}`, value: value(name) }))
|
|
2681
|
+
};
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
function keepSizeUnit(findings, spec) {
|
|
2685
|
+
return findings.map((finding) => {
|
|
2686
|
+
if (!finding.fix?.some((operation) => operation.op === "replace" && operation.path.endsWith("/options/size"))) return finding;
|
|
2687
|
+
let fix = finding.fix.map((operation) => {
|
|
2688
|
+
if (operation.op !== "replace" || !operation.path.endsWith("/options/size")) return operation;
|
|
2689
|
+
let needed = operation.value, found = readJsonPointer(spec, operation.path), authored = found.found ? found.value : void 0, unit = typeof authored == "object" && authored !== null ? authored.unit : void 0;
|
|
2690
|
+
if (unit !== "pt" && unit !== "mm" || typeof needed?.width != "number" || typeof needed.height != "number") return operation;
|
|
2691
|
+
let side = (name) => {
|
|
2692
|
+
let was = authored[name], wasPx = typeof was == "number" ? toLayoutPx(was, unit) : void 0;
|
|
2693
|
+
return wasPx !== void 0 && Math.abs(wasPx - needed[name]) <= 1e-6 ? was : inUnit(needed[name], unit, wasPx === void 0 || needed[name] > wasPx);
|
|
2694
|
+
};
|
|
2695
|
+
return { ...operation, value: { width: side("width"), height: side("height"), unit } };
|
|
2696
|
+
});
|
|
2697
|
+
return { ...finding, fix };
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
// src/cli/raster.ts
|
|
2702
|
+
import { spawnSync } from "child_process";
|
|
2703
|
+
import { existsSync, mkdtempSync, readFileSync as readFileSync3, rmSync, writeFileSync } from "fs";
|
|
2704
|
+
import { tmpdir } from "os";
|
|
2705
|
+
import { join } from "path";
|
|
2706
|
+
var CHROME_CANDIDATES = [
|
|
2707
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
2708
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
2709
|
+
"/usr/bin/google-chrome",
|
|
2710
|
+
"/usr/bin/google-chrome-stable",
|
|
2711
|
+
"/usr/bin/chromium",
|
|
2712
|
+
"/usr/bin/chromium-browser",
|
|
2713
|
+
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
|
|
2714
|
+
];
|
|
2715
|
+
function findChrome() {
|
|
2716
|
+
let override = process.env.BOARDPLOT_CHROME_PATH;
|
|
2717
|
+
return override ? existsSync(override) ? override : null : CHROME_CANDIDATES.find((candidate) => existsSync(candidate)) ?? null;
|
|
2718
|
+
}
|
|
2719
|
+
var CHROME_TIMEOUT_MS = 6e4;
|
|
2720
|
+
function rasterizeSvg(svg, width, height, scale, chromePath) {
|
|
2721
|
+
let dir = mkdtempSync(join(tmpdir(), "boardplot-png-"));
|
|
2722
|
+
try {
|
|
2723
|
+
let html = join(dir, "chart.html");
|
|
2724
|
+
writeFileSync(
|
|
2725
|
+
html,
|
|
2726
|
+
`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent}svg{display:block;width:${Math.round(width)}px;height:${Math.round(height)}px}</style></head><body>${svg}</body></html>`
|
|
2727
|
+
);
|
|
2728
|
+
let expected = { width: Math.round(Math.round(width) * scale), height: Math.round(Math.round(height) * scale) }, causes = [];
|
|
2729
|
+
for (let attempt of [1, 2]) {
|
|
2730
|
+
let png = join(dir, `chart-${attempt}.png`), run = spawnSync(
|
|
2731
|
+
chromePath,
|
|
2732
|
+
[
|
|
2733
|
+
"--headless=new",
|
|
2734
|
+
"--disable-gpu",
|
|
2735
|
+
"--hide-scrollbars",
|
|
2736
|
+
"--no-first-run",
|
|
2737
|
+
"--no-default-browser-check",
|
|
2738
|
+
"--default-background-color=00000000",
|
|
2739
|
+
`--force-device-scale-factor=${scale}`,
|
|
2740
|
+
`--window-size=${Math.round(width)},${Math.round(height)}`,
|
|
2741
|
+
`--screenshot=${png}`,
|
|
2742
|
+
`file://${html}`
|
|
2743
|
+
],
|
|
2744
|
+
{ stdio: ["ignore", "ignore", "pipe"], timeout: CHROME_TIMEOUT_MS, encoding: "utf8" }
|
|
2745
|
+
), written = existsSync(png) ? readFileSync3(png) : null;
|
|
2746
|
+
if (written && completePng(written, expected)) return written;
|
|
2747
|
+
causes.push(chromeFailure(run, chromePath, written));
|
|
2748
|
+
}
|
|
2749
|
+
throw new ToolFailure("png-export-failed", `headless Chrome drew no complete PNG in two runs: ${causes.join("; then ")}`, {
|
|
2750
|
+
path: "/format",
|
|
2751
|
+
suggest: "Retry when the machine is less busy, render --format svg, or install @resvg/resvg-js to draw PNGs without Chrome."
|
|
2752
|
+
});
|
|
2753
|
+
} finally {
|
|
2754
|
+
rmSync(dir, { recursive: !0, force: !0 });
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
function chromeFailure(run, chromePath, written) {
|
|
2758
|
+
let lastLine = String(run.stderr ?? "").trim().split(`
|
|
2759
|
+
`).pop()?.trim().slice(0, 200), said = lastLine ? ` (Chrome said: ${lastLine})` : "", code = run.error?.code;
|
|
2760
|
+
return code === "ENOENT" || code === "EACCES" ? `the browser at ${chromePath} could not be started (${code})` : code === "ETIMEDOUT" ? `timed out after ${CHROME_TIMEOUT_MS / 1e3} s${said}` : run.signal ? `crashed with ${run.signal}${said}` : written ? `wrote an incomplete or wrongly sized PNG (exit code ${run.status})${said}` : run.error ? `failed to run (${run.error.message})` : `exited with code ${run.status} without writing the PNG${said}`;
|
|
2761
|
+
}
|
|
2762
|
+
function completePng(buffer, size) {
|
|
2763
|
+
let header = pngSize(buffer);
|
|
2764
|
+
if (!header || Math.abs(header.width - size.width) > 1 || Math.abs(header.height - size.height) > 1) return !1;
|
|
2765
|
+
let images = 0;
|
|
2766
|
+
for (let at = 8; at + 12 <= buffer.length; ) {
|
|
2767
|
+
let end = at + 8 + buffer.readUInt32BE(at);
|
|
2768
|
+
if (end + 4 > buffer.length || crc32(buffer.subarray(at + 4, end)) !== buffer.readUInt32BE(end)) return !1;
|
|
2769
|
+
let type = buffer.toString("ascii", at + 4, at + 8);
|
|
2770
|
+
if (type === "IEND") return images > 0;
|
|
2771
|
+
type === "IDAT" && (images += 1), at = end + 4;
|
|
2772
|
+
}
|
|
2773
|
+
return !1;
|
|
2774
|
+
}
|
|
2775
|
+
function pngSize(buffer) {
|
|
2776
|
+
return buffer.length < 24 || buffer.toString("ascii", 1, 4) !== "PNG" ? null : { width: buffer.readUInt32BE(16), height: buffer.readUInt32BE(20) };
|
|
2777
|
+
}
|
|
2778
|
+
function rasterizerMissingWarning() {
|
|
2779
|
+
return {
|
|
2780
|
+
code: "no-rasterizer",
|
|
2781
|
+
severity: "warn",
|
|
2782
|
+
message: "PNG needs @resvg/resvg-js (npm i @resvg/resvg-js) or Chrome; returning SVG only",
|
|
2783
|
+
path: "/format"
|
|
2784
|
+
};
|
|
2785
|
+
}
|
|
2786
|
+
function availableRasterizer() {
|
|
2787
|
+
return loadResvg() ? "resvg" : findChrome() ? "chrome" : null;
|
|
2788
|
+
}
|
|
2789
|
+
function rasterFontsMissingWarning() {
|
|
2790
|
+
return {
|
|
2791
|
+
code: "raster-fonts-missing",
|
|
2792
|
+
severity: "warn",
|
|
2793
|
+
message: "PNG needs one of the theme fonts or Liberation Sans, Arimo, Nimbus Sans, DejaVu Sans or Noto Sans installed, or Chrome; returning SVG only",
|
|
2794
|
+
path: "/format"
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2797
|
+
function uncoveredCharacters(text, fontFamily) {
|
|
2798
|
+
let faces = familiesOf(fontFamily).flatMap((family) => {
|
|
2799
|
+
let face = resolveFace(family, 400);
|
|
2800
|
+
return face ? [face] : [];
|
|
2801
|
+
});
|
|
2802
|
+
if (!faces.length) return [];
|
|
2803
|
+
let installed = installedFamilies(), missing = [...new Set([...text].filter((character) => {
|
|
2804
|
+
let cp = character.codePointAt(0);
|
|
2805
|
+
return !/\s/u.test(character) && faces.every((face) => face.advance(cp) === void 0 || face.borrowed?.has(cp)) && !glyphFallbackFamily(cp, installed);
|
|
2806
|
+
}))], arrow = (character) => "\u2190\u2191\u2192\u2193\u2197\u2198".includes(character);
|
|
2807
|
+
return missing.some(arrow) && hasArrowFallback(installed) ? missing.filter((character) => !arrow(character)) : missing;
|
|
2808
|
+
}
|
|
2809
|
+
function glyphCoverageWarning(name, characters) {
|
|
2810
|
+
let listed = characters.slice(0, 5).map((character) => `'${character}'`).join(", "), more = characters.length > 5 ? ` and ${characters.length - 5} more` : "";
|
|
2811
|
+
return {
|
|
2812
|
+
code: "png-glyph-coverage",
|
|
2813
|
+
severity: "warn",
|
|
2814
|
+
message: `chart '${name}': the theme font has no glyph for ${listed}${more}; the PNG draws them as boxes or leaves them out. The SVG shows them in a browser.`,
|
|
2815
|
+
path: "/format",
|
|
2816
|
+
suggest: "Deliver the SVG, or leave these characters out of labels meant for the PNG."
|
|
2817
|
+
};
|
|
2818
|
+
}
|
|
2819
|
+
function rasterize(drawings, scale, rasterizer = availableRasterizer()) {
|
|
2820
|
+
let resvg = rasterizer === "resvg" ? loadResvg() : null, chrome = rasterizer === "chrome" ? findChrome() : null;
|
|
2821
|
+
if (resvg) {
|
|
2822
|
+
let installed = installedFamilies(), families = drawings.map((drawing) => rasterFamily(drawing.fontFamily, installed));
|
|
2823
|
+
if (families.every((family) => family !== null)) {
|
|
2824
|
+
let warnings = drawings.flatMap((drawing) => {
|
|
2825
|
+
let lost = uncoveredCharacters(drawing.text ?? "", drawing.fontFamily);
|
|
2826
|
+
return lost.length ? [glyphCoverageWarning(drawing.name ?? "chart", lost)] : [];
|
|
2827
|
+
});
|
|
2828
|
+
return { pngs: drawings.map((drawing, index) => Buffer.from(withPhysicalSize(rasterizeWithResvg(resvg, drawing.svg, drawing.size.width, scale, families[index]), scale))), warnings };
|
|
2829
|
+
}
|
|
2830
|
+
if (chrome = findChrome(), !chrome) return { pngs: null, warnings: [rasterFontsMissingWarning()] };
|
|
2831
|
+
}
|
|
2832
|
+
if (!chrome) return { pngs: null, warnings: [rasterizerMissingWarning()] };
|
|
2833
|
+
let browser = chrome;
|
|
2834
|
+
return { pngs: drawings.map((drawing) => Buffer.from(withPhysicalSize(rasterizeSvg(drawing.svg, drawing.size.width, drawing.size.height, scale, browser), scale))), warnings: [] };
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
// src/cli/rows.ts
|
|
2838
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2, statSync as statSync2 } from "fs";
|
|
2839
|
+
import { extname, isAbsolute } from "path";
|
|
2840
|
+
var MAX_ROWS_FILE_BYTES = 2 * 1024 * 1024;
|
|
2841
|
+
function csvDelimiter(body) {
|
|
2842
|
+
let commas = 0, semicolons = 0, quoted = !1;
|
|
2843
|
+
for (let char of body)
|
|
2844
|
+
if (char === '"') quoted = !quoted;
|
|
2845
|
+
else {
|
|
2846
|
+
if (!quoted && (char === `
|
|
2847
|
+
` || char === "\r")) break;
|
|
2848
|
+
!quoted && char === "," ? commas++ : !quoted && char === ";" && semicolons++;
|
|
2849
|
+
}
|
|
2850
|
+
return semicolons > commas ? ";" : ",";
|
|
2851
|
+
}
|
|
2852
|
+
function parseCsv(text) {
|
|
2853
|
+
let records2 = [], record = [], field = "", quoted = !1, started = !1, body = text.charCodeAt(0) === 65279 ? text.slice(1) : text, delimiter = csvDelimiter(body);
|
|
2854
|
+
for (let index = 0; index < body.length; index++) {
|
|
2855
|
+
let char = body[index];
|
|
2856
|
+
quoted ? char === '"' && body[index + 1] === '"' ? (field += '"', index++) : char === '"' ? quoted = !1 : field += char : char === '"' && field === "" ? (quoted = !0, started = !0) : char === delimiter ? (record.push(field), field = "", started = !0) : char === `
|
|
2857
|
+
` || char === "\r" ? (char === "\r" && body[index + 1] === `
|
|
2858
|
+
` && index++, (started || field !== "") && record.push(field), record.length && records2.push(record), record = [], field = "", started = !1) : (field += char, started = !0);
|
|
2859
|
+
}
|
|
2860
|
+
if (quoted) throw new InputError("invalid-rows", "the CSV ends inside a quoted field", { path: "/rowsFile" });
|
|
2861
|
+
(started || field !== "") && record.push(field), record.length && records2.push(record);
|
|
2862
|
+
let [header, ...lines] = records2;
|
|
2863
|
+
if (!header) throw new InputError("invalid-rows", "the CSV has no header row", { path: "/rowsFile" });
|
|
2864
|
+
return {
|
|
2865
|
+
delimiter,
|
|
2866
|
+
rows: lines.map((line, index) => {
|
|
2867
|
+
if (line.length !== header.length)
|
|
2868
|
+
throw new InputError("invalid-rows", `CSV row ${index + 1} has ${line.length} fields, the header has ${header.length}`, { path: "/rowsFile" });
|
|
2869
|
+
return Object.fromEntries(header.map((name, column) => [name, line[column]]));
|
|
2870
|
+
})
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
function readRowsFile(path) {
|
|
2874
|
+
if (typeof path != "string" || !isAbsolute(path))
|
|
2875
|
+
throw new InputError("invalid-argument", "rowsFile must be an absolute path", {
|
|
2876
|
+
path: "/rowsFile",
|
|
2877
|
+
expected: { condition: "an absolute path to a .json or .csv file" },
|
|
2878
|
+
suggest: "Pass the absolute path of the file."
|
|
2879
|
+
});
|
|
2880
|
+
let real, size;
|
|
2881
|
+
try {
|
|
2882
|
+
real = realpathSync2(path);
|
|
2883
|
+
let stat = statSync2(real);
|
|
2884
|
+
if (!stat.isFile()) throw new Error("not a regular file");
|
|
2885
|
+
size = stat.size;
|
|
2886
|
+
} catch (error) {
|
|
2887
|
+
throw new InputError("rows-unreadable", `cannot read ${path}: ${error instanceof Error ? error.message : error}`, { path: "/rowsFile" });
|
|
2888
|
+
}
|
|
2889
|
+
let kind = extname(real).toLowerCase();
|
|
2890
|
+
if (kind !== ".json" && kind !== ".csv")
|
|
2891
|
+
throw new InputError("rows-unreadable", `rowsFile must be a .json or .csv file, not '${kind || "no extension"}'`, { path: "/rowsFile" });
|
|
2892
|
+
if (size > MAX_ROWS_FILE_BYTES)
|
|
2893
|
+
throw new InputError("rows-too-large", `${path} has ${size} bytes; a rows file holds at most ${MAX_ROWS_FILE_BYTES}`, {
|
|
2894
|
+
path: "/rowsFile",
|
|
2895
|
+
suggest: "Aggregate the rows to what the chart draws before passing the file."
|
|
2896
|
+
});
|
|
2897
|
+
let bytes = readFileSync4(real), text = bytes.toString("utf8");
|
|
2898
|
+
if (kind === ".csv") {
|
|
2899
|
+
let { rows, delimiter } = parseCsv(text);
|
|
2900
|
+
return { rows, bytes, source: path, decimalComma: delimiter === ";" };
|
|
2901
|
+
}
|
|
2902
|
+
try {
|
|
2903
|
+
return { rows: JSON.parse(text.replace(/^\uFEFF/, "")), bytes, source: path };
|
|
2904
|
+
} catch (error) {
|
|
2905
|
+
throw new InputError("invalid-json", `${path} is not valid JSON: ${error instanceof Error ? error.message : error}`, { path: "/rowsFile" });
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
function applyRows(spec, input) {
|
|
2909
|
+
if (input.rows === void 0 && input.rowsFile === void 0 && input.columns === void 0) return { spec };
|
|
2910
|
+
if (input.rows !== void 0 && input.rowsFile !== void 0)
|
|
2911
|
+
throw new InputError("invalid-argument", "pass rows or rowsFile, not both", { path: "/rowsFile", fix: [{ op: "remove", path: "/rowsFile" }] });
|
|
2912
|
+
if (input.rows === void 0 && input.rowsFile === void 0)
|
|
2913
|
+
throw new InputError("invalid-argument", "columns maps rows, and no rows or rowsFile was given", { path: "/columns", suggest: "Pass rows inline or rowsFile with the path of a .json or .csv file." });
|
|
2914
|
+
let loaded2, adapted = adaptRows(spec, input.columns, {
|
|
2915
|
+
argument: input.rows !== void 0 ? "/rows" : "/rowsFile",
|
|
2916
|
+
load: () => loaded2 = input.rows !== void 0 ? { rows: input.rows, source: "inline" } : readRowsFile(input.rowsFile),
|
|
2917
|
+
tilePack: getTilePack
|
|
2918
|
+
});
|
|
2919
|
+
return {
|
|
2920
|
+
spec: adapted.spec,
|
|
2921
|
+
pathMap: adapted.pathMap,
|
|
2922
|
+
data: {
|
|
2923
|
+
rows: adapted.rows,
|
|
2924
|
+
sha256: sha256(loaded2.bytes ?? canonicalJson(loaded2.rows)),
|
|
2925
|
+
source: loaded2.source,
|
|
2926
|
+
ignoredColumns: adapted.ignoredColumns,
|
|
2927
|
+
states: adapted.states
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
// src/cli/render.ts
|
|
2933
|
+
var RETURNS = ["svg", "reading"];
|
|
2934
|
+
function renderOptions(input) {
|
|
2935
|
+
if (input.overwrite !== void 0 && typeof input.overwrite != "boolean")
|
|
2936
|
+
throw new InputError("invalid-argument", "overwrite must be a boolean", { path: "/overwrite" });
|
|
2937
|
+
let format = input.format ?? "svg";
|
|
2938
|
+
if (format !== "svg" && format !== "png")
|
|
2939
|
+
throw new InputError("invalid-argument", "format must be svg or png", {
|
|
2940
|
+
path: "/format",
|
|
2941
|
+
expected: { values: ["svg", "png"] },
|
|
2942
|
+
suggest: "Pass format svg, or png for an image.",
|
|
2943
|
+
fix: [{ op: "replace", path: "/format", value: "svg" }]
|
|
2944
|
+
});
|
|
2945
|
+
let returned = input.return ?? ["reading"], unknown = returned.filter((entry) => !RETURNS.includes(entry));
|
|
2946
|
+
if (unknown.length)
|
|
2947
|
+
throw new InputError("invalid-argument", `return takes svg and reading, not ${unknown.join(", ")}`, {
|
|
2948
|
+
path: "/return",
|
|
2949
|
+
expected: { values: [...RETURNS] },
|
|
2950
|
+
suggest: "Pass return as a list of svg and reading."
|
|
2951
|
+
});
|
|
2952
|
+
let scale = pixels("scale", input.scale) ?? 2;
|
|
2953
|
+
if (scale > 8)
|
|
2954
|
+
throw new InputError("invalid-argument", "scale must be at most 8", {
|
|
2955
|
+
path: "/scale",
|
|
2956
|
+
expected: { maximum: 8 },
|
|
2957
|
+
suggest: "Pass a scale between 1 and 8.",
|
|
2958
|
+
fix: [{ op: "replace", path: "/scale", value: 8 }]
|
|
2959
|
+
});
|
|
2960
|
+
let background = input.background ?? "theme";
|
|
2961
|
+
if (background !== "theme" && background !== "transparent")
|
|
2962
|
+
throw new InputError("invalid-argument", "background must be theme or transparent", {
|
|
2963
|
+
path: "/background",
|
|
2964
|
+
expected: { values: ["theme", "transparent"] },
|
|
2965
|
+
suggest: "Pass background theme, or transparent to leave the canvas out.",
|
|
2966
|
+
fix: [{ op: "replace", path: "/background", value: "theme" }]
|
|
2967
|
+
});
|
|
2968
|
+
return {
|
|
2969
|
+
format,
|
|
2970
|
+
returned,
|
|
2971
|
+
scale,
|
|
2972
|
+
background,
|
|
2973
|
+
target: targetArgument(input.target),
|
|
2974
|
+
width: length("width", input.width),
|
|
2975
|
+
height: length("height", input.height)
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
function presentation({ geo, request }) {
|
|
2979
|
+
let info = geo.presentation;
|
|
2980
|
+
return { target: info?.target ?? request.target, ...info ? { naturalSize: info.naturalSize, minDisplayWidth: info.minDisplayWidth } : {} };
|
|
2981
|
+
}
|
|
2982
|
+
function safeName(name) {
|
|
2983
|
+
return name.replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+/, "_") || "chart";
|
|
2984
|
+
}
|
|
2985
|
+
function writeFreshFiles(directory, files, extension, overwrite) {
|
|
2986
|
+
let existing = new Map(readdirSync(directory).map((entry) => [entry.toLowerCase(), entry])), taken = new Set(overwrite ? [] : existing.keys());
|
|
2987
|
+
return files.map(({ name: base, body }) => {
|
|
2988
|
+
for (let suffix = 1; ; suffix++) {
|
|
2989
|
+
let candidate = `${suffix === 1 ? base : `${base}-${suffix}`}${extension}`;
|
|
2990
|
+
if (taken.has(candidate.toLowerCase())) continue;
|
|
2991
|
+
taken.add(candidate.toLowerCase());
|
|
2992
|
+
let path = join2(directory, overwrite ? existing.get(candidate.toLowerCase()) ?? candidate : candidate), symlink = () => new InputError("out-is-symlink", `${path} is a symlink; overwrite does not write through it`, { path: "/outDir", suggest: "Remove the link, or write to another outDir." });
|
|
2993
|
+
if (overwrite && lstatSync(path, { throwIfNoEntry: !1 })?.isSymbolicLink()) throw symlink();
|
|
2994
|
+
try {
|
|
2995
|
+
let fd = openSync(path, overwrite ? constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | constants.O_NOFOLLOW : "wx");
|
|
2996
|
+
try {
|
|
2997
|
+
writeFileSync2(fd, body);
|
|
2998
|
+
} finally {
|
|
2999
|
+
closeSync(fd);
|
|
3000
|
+
}
|
|
3001
|
+
return path;
|
|
3002
|
+
} catch (error) {
|
|
3003
|
+
let code = error.code;
|
|
3004
|
+
if (overwrite && code === "ELOOP") throw symlink();
|
|
3005
|
+
if (code !== "EEXIST") throw error;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
function outDirectory(outDir) {
|
|
3011
|
+
if (outDir !== void 0) {
|
|
3012
|
+
if (typeof outDir != "string" || outDir === "")
|
|
3013
|
+
throw new InputError("invalid-argument", "outDir must be a directory path", { path: "/outDir", suggest: "Pass an absolute directory path." });
|
|
3014
|
+
return resolve4(outDir);
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
function outFileExtension(outDir, out) {
|
|
3018
|
+
if (outDir === void 0 || out === void 0 || /[\\/]$/.test(outDir) || isFolder(out)) return;
|
|
3019
|
+
let extension = extname2(out).toLowerCase();
|
|
3020
|
+
return extension === ".png" || extension === ".svg" ? extension : void 0;
|
|
3021
|
+
}
|
|
3022
|
+
function isFolder(path) {
|
|
3023
|
+
try {
|
|
3024
|
+
return statSync3(path, { throwIfNoEntry: !1 })?.isDirectory() ?? !1;
|
|
3025
|
+
} catch {
|
|
3026
|
+
return !1;
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
function render(input) {
|
|
3030
|
+
return withFontTables(input.fontTables, () => renderWithTables(input));
|
|
3031
|
+
}
|
|
3032
|
+
function renderWithTables(input) {
|
|
3033
|
+
let out = outDirectory(input.outDir), fileExtension = outFileExtension(input.outDir, out), options = renderOptions({ ...input, format: input.format ?? fileExtension?.slice(1) });
|
|
3034
|
+
if (fileExtension && fileExtension !== `.${options.format}`)
|
|
3035
|
+
throw new InputError("invalid-argument", `--out ${basename(out)} ends in ${fileExtension}, but the format is ${options.format}`, {
|
|
3036
|
+
path: "/outDir",
|
|
3037
|
+
suggest: `Pass --format ${fileExtension.slice(1)}, or end --out in .${options.format}.`
|
|
3038
|
+
});
|
|
3039
|
+
let rows = applyRows(input.spec, input), loaded2 = loadSpec(rows.spec);
|
|
3040
|
+
if ("errors" in loaded2) return rejected(rewriteRowsDiagnostics(asSent(loaded2.errors, loaded2.bare), rows.pathMap));
|
|
3041
|
+
if (fileExtension && loaded2.doc.charts.length > 1)
|
|
3042
|
+
throw new InputError("invalid-argument", `--out names a folder when the spec draws several charts; this spec draws ${loaded2.doc.charts.length}, so --out ${basename(out)} would become a folder`, {
|
|
3043
|
+
path: "/outDir",
|
|
3044
|
+
suggest: `Pass --out with a folder path, or render one chart to write ${basename(out)}.`
|
|
3045
|
+
});
|
|
3046
|
+
shareScaleGroups(loaded2);
|
|
3047
|
+
let { doc, envelope, bare } = loaded2, laid = [], scopeUses = /* @__PURE__ */ new Map();
|
|
3048
|
+
for (let chart of doc.charts) {
|
|
3049
|
+
let sized = withSize(chart, options.width, options.height, options.target ?? chart.options?.target), { name: _name, ...drawing } = sized, hashed = sha256(canonicalJson({ drawing, locale: doc.locale ?? null, theme: resolveTheme(doc.theme), ...options.target ? { target: options.target } : {} })).slice(0, 10), uses = (scopeUses.get(hashed) ?? 0) + 1;
|
|
3050
|
+
scopeUses.set(hashed, uses);
|
|
3051
|
+
let idScope = uses === 1 ? hashed : `${hashed}-${uses}`, before = envelope.warnings.length, drawn2 = layoutChart(doc, sized, envelope, {
|
|
3052
|
+
idScope,
|
|
3053
|
+
...options.background === "transparent" ? { background: !1 } : {}
|
|
3054
|
+
}, options.target), drawnCodes = new Set(envelope.warnings.slice(before).map((warning2) => warning2.code));
|
|
3055
|
+
drawn2 && laid.push({ name: chart.name, chart: drawn2, drawsWith: (changed) => drawsWithOptions(doc, sized, changed, drawnCodes, options.target) });
|
|
3056
|
+
}
|
|
3057
|
+
addDocumentLints(doc, envelope, laid);
|
|
3058
|
+
let sent = (findings) => keepSizeUnit(attributeSizeOverride(
|
|
3059
|
+
rewriteRowsDiagnostics(asSent(findings, bare), rows.pathMap),
|
|
3060
|
+
options.width,
|
|
3061
|
+
options.height,
|
|
3062
|
+
rows.spec,
|
|
3063
|
+
options.target
|
|
3064
|
+
), rows.spec), fontWarning, fontMessages = /* @__PURE__ */ new Set(), warnings = sent(envelope.warnings).map((warning2) => {
|
|
3065
|
+
if (warning2.severity !== "advice" || !warning2.fix || patchApplies(input.spec, warning2.fix)) return warning2;
|
|
3066
|
+
let { fix: _fix, ...rest } = warning2;
|
|
3067
|
+
return rest;
|
|
3068
|
+
}).filter((warning2) => warning2.code !== "family-outside-metric-class" ? !0 : fontWarning ? (fontMessages.has(warning2.message) || (fontMessages.add(warning2.message), fontWarning.message += `; ${warning2.path}: ${warning2.message}`), !1) : (fontWarning = warning2, fontMessages.add(warning2.message), !0));
|
|
3069
|
+
if (envelope.errors.length) return rejected(sent(envelope.errors), warnings);
|
|
3070
|
+
let drawings = laid.map(({ name, chart }) => ({ name, chart, svg: chart.svg, fontFamily: chart.fontFamily })), format = options.format;
|
|
3071
|
+
if (format === "png") {
|
|
3072
|
+
let rasterized = rasterize(drawings.map((drawing) => ({
|
|
3073
|
+
svg: drawing.svg,
|
|
3074
|
+
size: drawing.chart.geo.size,
|
|
3075
|
+
fontFamily: drawing.fontFamily,
|
|
3076
|
+
name: drawing.name,
|
|
3077
|
+
text: drawing.chart.geo.scene.flatMap((node2) => node2.t === "text" ? node2.lines : []).join(`
|
|
3078
|
+
`)
|
|
3079
|
+
})), options.scale);
|
|
3080
|
+
pushAll(warnings, rasterized.warnings.map((warning2) => completeDiagnostic(warning2, void 0, [], "docs/manual.md#getting-a-chart-with-mcp"))), rasterized.pngs ? rasterized.pngs.forEach((png, index) => {
|
|
3081
|
+
drawings[index].png = png;
|
|
3082
|
+
}) : format = "svg";
|
|
3083
|
+
}
|
|
3084
|
+
let returnSvg = options.returned.includes("svg") || options.format === "png" && format === "svg", outputs = out ? writeOutputs(out, drawings, format, fileExtension !== void 0, warnings, input.overwrite === !0) : void 0, charts = drawings.map((drawing) => ({
|
|
3085
|
+
size: { width: drawing.chart.geo.size.width, height: drawing.chart.geo.size.height },
|
|
3086
|
+
...presentation(drawing.chart),
|
|
3087
|
+
...returnSvg ? { svg: drawing.svg } : {},
|
|
3088
|
+
// The notes list, so a host can build an appendix (footer rule).
|
|
3089
|
+
notes: chartNotes(drawing.chart.geo),
|
|
3090
|
+
...options.returned.includes("reading") ? {
|
|
3091
|
+
reading: {
|
|
3092
|
+
...chartReading({
|
|
3093
|
+
name: drawing.name,
|
|
3094
|
+
type: drawing.chart.def.type,
|
|
3095
|
+
request: drawing.chart.request,
|
|
3096
|
+
geometry: drawing.chart.geo,
|
|
3097
|
+
claims: drawing.chart.claims
|
|
3098
|
+
}),
|
|
3099
|
+
...rows.data ? { data: rows.data } : {}
|
|
3100
|
+
}
|
|
3101
|
+
} : {}
|
|
3102
|
+
})), images = drawings.flatMap((drawing) => drawing.png ? [drawing.png] : []), body = charts.length === 1 && bare ? { ...charts[0], warnings } : { charts: charts.map((chart, index) => ({ name: drawings[index].name, ...chart })), warnings }, fontTables = fontTablesSummary(activeFontTables());
|
|
3103
|
+
return ok({ errors: [], ...body, ...outputs ? { outputs } : {}, ...fontTables ? { fontTables } : {} }, images);
|
|
3104
|
+
}
|
|
3105
|
+
function writeOutputs(out, drawings, format, asFile, warnings, overwrite) {
|
|
3106
|
+
if (!isAbsolute2(out)) throw new InputError("invalid-argument", "outDir must be absolute", { path: "/outDir" });
|
|
3107
|
+
let directory = asFile ? dirname(out) : out, extension = asFile && extname2(out).toLowerCase() === `.${format}` ? extname2(out) : `.${format}`;
|
|
3108
|
+
try {
|
|
3109
|
+
mkdirSync(directory, { recursive: !0 });
|
|
3110
|
+
let files = drawings.map((drawing) => ({
|
|
3111
|
+
name: asFile ? basename(out, extname2(out)) : safeName(drawing.name),
|
|
3112
|
+
body: format === "png" ? drawing.png : drawing.svg
|
|
3113
|
+
})), written = writeFreshFiles(directory, files, extension, overwrite);
|
|
3114
|
+
return written.forEach((path, index) => {
|
|
3115
|
+
let requested = join2(directory, `${files[index].name}${extension}`);
|
|
3116
|
+
if (path === requested || overwrite && path.toLowerCase() === requested.toLowerCase()) return;
|
|
3117
|
+
let sibling = written.slice(0, index).findIndex((earlier) => earlier.toLowerCase() === requested.toLowerCase());
|
|
3118
|
+
warnings.push(completeDiagnostic(sibling >= 0 ? {
|
|
3119
|
+
code: "out-name-taken",
|
|
3120
|
+
severity: "warn",
|
|
3121
|
+
message: `charts '${drawings[sibling].name}' and '${drawings[index].name}' both give the file name ${requested}; this render wrote the first there and this one to ${path}`,
|
|
3122
|
+
suggest: "Give the charts names that differ in letters and digits."
|
|
3123
|
+
} : {
|
|
3124
|
+
code: "out-name-taken",
|
|
3125
|
+
severity: "warn",
|
|
3126
|
+
message: `${requested} already exists, so this render wrote ${path}; the existing file is unchanged`,
|
|
3127
|
+
suggest: `Read ${path}, or pass --overwrite (overwrite: true) to replace the existing file.`
|
|
3128
|
+
}, void 0, [], "docs/manual.md#getting-a-chart-with-the-cli"));
|
|
3129
|
+
}), written;
|
|
3130
|
+
} catch (error) {
|
|
3131
|
+
let cause = OUT_CAUSES[error.code ?? ""];
|
|
3132
|
+
throw cause ? new InputError("out-unwritable", `cannot write to ${directory}: ${cause}`, {
|
|
3133
|
+
path: "/outDir",
|
|
3134
|
+
suggest: "Pass --out with a folder you can write to, or a new path."
|
|
3135
|
+
}) : error;
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
var OUT_CAUSES = {
|
|
3139
|
+
EEXIST: "it is a file, not a folder",
|
|
3140
|
+
ENOTDIR: "part of the path is a file, not a folder",
|
|
3141
|
+
EACCES: "permission denied",
|
|
3142
|
+
EPERM: "permission denied",
|
|
3143
|
+
EROFS: "the file system is read-only"
|
|
3144
|
+
};
|
|
3145
|
+
|
|
3146
|
+
// src/cli/measure.ts
|
|
3147
|
+
function refusal(measured) {
|
|
3148
|
+
if (!measured.refused) return null;
|
|
3149
|
+
let cause = measured.refused.warnings.find((warning2) => warning2.severity === "error") ?? measured.refused.warnings[0];
|
|
3150
|
+
return {
|
|
3151
|
+
code: cause?.code ?? "size-below-floor",
|
|
3152
|
+
message: cause?.message ?? "the chart does not fit the requested size",
|
|
3153
|
+
...cause?.fix && cause.expected?.minimum ? { required: cause.expected.minimum } : {},
|
|
3154
|
+
...cause?.suggest ? { suggest: cause.suggest } : {}
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
function dimensions(measured) {
|
|
3158
|
+
let presentation2 = measured.geometry?.presentation, drawn2 = measured.geometry ? measured.drawnHeight ?? measured.geometry.size.height : void 0;
|
|
3159
|
+
return {
|
|
3160
|
+
target: measured.target,
|
|
3161
|
+
// The layout this measure made at the requested width, as tall as the chart draws it: a pinned
|
|
3162
|
+
// frame taller than the drawing (a circle is bound by its width) leaves empty bands a host
|
|
3163
|
+
// would reserve. The natural output size follows, as the footer frame scales it.
|
|
3164
|
+
...measured.geometry ? { size: { width: measured.geometry.size.width, height: drawn2 } } : {},
|
|
3165
|
+
...presentation2 ? {
|
|
3166
|
+
naturalSize: drawn2 < measured.geometry.size.height ? { ...presentation2.naturalSize, height: presentation2.naturalSize.height * drawn2 / measured.geometry.size.height } : presentation2.naturalSize,
|
|
3167
|
+
minDisplayWidth: presentation2.minDisplayWidth
|
|
3168
|
+
} : {},
|
|
3169
|
+
minWidth: measured.minWidth,
|
|
3170
|
+
minHeight: measured.minHeight,
|
|
3171
|
+
minHeightAtWidth: measured.minHeightAtWidth,
|
|
3172
|
+
naturalWidth: measured.naturalWidth,
|
|
3173
|
+
naturalHeight: measured.naturalHeight,
|
|
3174
|
+
comfortableWidth: measured.comfortableWidth,
|
|
3175
|
+
comfortableHeight: measured.comfortableHeight,
|
|
3176
|
+
fit: measured.fit,
|
|
3177
|
+
...measured.compactFloor ? { compactFloor: measured.compactFloor } : {},
|
|
3178
|
+
...measured.mode ? { mode: measured.mode } : {},
|
|
3179
|
+
titleLines: measured.titleLines ?? null,
|
|
3180
|
+
refused: refusal(measured)
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3183
|
+
function measure(input) {
|
|
3184
|
+
return withFontTables(input.fontTables, () => measureWithTables(input));
|
|
3185
|
+
}
|
|
3186
|
+
function measureWithTables(input) {
|
|
3187
|
+
let width = length("width", input.width), target = targetArgument(input.target), rows = applyRows(input.spec, input), loaded2 = loadSpec(rows.spec);
|
|
3188
|
+
if ("errors" in loaded2) return rejected(rewriteRowsDiagnostics(asSent(loaded2.errors, loaded2.bare), rows.pathMap));
|
|
3189
|
+
shareScaleGroups(loaded2);
|
|
3190
|
+
let { doc, envelope, bare } = loaded2, measured = [];
|
|
3191
|
+
for (let chart of doc.charts) {
|
|
3192
|
+
let result = measureChart(doc, withSize(chart, width, void 0, target ?? chart.options?.target), envelope, target);
|
|
3193
|
+
result && measured.push({ name: chart.name, result });
|
|
3194
|
+
}
|
|
3195
|
+
let sent = (findings) => keepSizeUnit(rewriteRowsDiagnostics(asSent(findings, bare), rows.pathMap), rows.spec);
|
|
3196
|
+
if (envelope.errors.length) return rejected(sent(envelope.errors), sent(envelope.warnings));
|
|
3197
|
+
let warnings = sent(envelope.warnings), fontTables = fontTablesSummary(activeFontTables());
|
|
3198
|
+
return ok({
|
|
3199
|
+
errors: [],
|
|
3200
|
+
...fontTables ? { fontTables } : {},
|
|
3201
|
+
...measured.length === 1 && bare ? { ...dimensions(measured[0].result), warnings } : { charts: measured.map(({ name, result }) => ({ name, ...dimensions(result) })), warnings },
|
|
3202
|
+
...rows.data ? { data: rows.data } : {}
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
// src/telemetry/event.ts
|
|
3207
|
+
import { platform } from "os";
|
|
3208
|
+
import * as z4 from "zod";
|
|
3209
|
+
|
|
3210
|
+
// src/telemetry/schema.ts
|
|
3211
|
+
import * as z3 from "zod";
|
|
3212
|
+
var TYPE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/, OPTION_KEY_PATTERN = /^[a-zA-Z][a-zA-Z0-9]{0,39}$/, CODE_PATTERN = /^[a-z][a-z0-9-]{0,63}$/, COMMANDS = ["list", "describe", "fixtures", "render", "measure", "fonts", "feedback"], OS_FAMILIES = ["darwin", "linux", "win32", "other"], HOSTS = ["claude-code", "claude-app", "codex", "cursor", "vscode", "gemini", "other", "none"], FORMATS = ["svg", "png", "none"], FEEDBACK_CATEGORIES = ["bug", "friction", "docs"], SUMMARY_MAX = 280, surface = z3.enum(["cli", "mcp"]), version2 = z3.string().regex(/^\d{1,4}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z.-]{1,32})?$/), os = z3.enum(OS_FAMILIES), node = z3.number().int().min(0).max(99), optionKeys = z3.array(z3.string().regex(OPTION_KEY_PATTERN)).max(64), codes = z3.array(z3.string().regex(CODE_PATTERN)).max(32), usageEventSchema = z3.strictObject({
|
|
3213
|
+
v: z3.literal(1),
|
|
3214
|
+
/** A random UUID, replaced each calendar month; `telemetry off` deletes it. */
|
|
3215
|
+
install: z3.uuid({ version: "v4" }),
|
|
3216
|
+
version: version2,
|
|
3217
|
+
surface,
|
|
3218
|
+
command: z3.enum(COMMANDS),
|
|
3219
|
+
types: z3.array(z3.string().regex(TYPE_PATTERN)).max(20),
|
|
3220
|
+
optionKeys,
|
|
3221
|
+
codes,
|
|
3222
|
+
ok: z3.boolean(),
|
|
3223
|
+
/** The render output format; none for every other command. */
|
|
3224
|
+
format: z3.enum(FORMATS),
|
|
3225
|
+
host: z3.enum(HOSTS),
|
|
3226
|
+
os,
|
|
3227
|
+
node
|
|
3228
|
+
}), feedbackReportSchema = z3.strictObject({
|
|
3229
|
+
v: z3.literal(1),
|
|
3230
|
+
version: version2,
|
|
3231
|
+
surface,
|
|
3232
|
+
os,
|
|
3233
|
+
node,
|
|
3234
|
+
category: z3.enum(FEEDBACK_CATEGORIES),
|
|
3235
|
+
type: z3.string().regex(TYPE_PATTERN).optional(),
|
|
3236
|
+
optionKeys,
|
|
3237
|
+
codes,
|
|
3238
|
+
summary: z3.string().trim().min(1).refine((text) => [...text].length <= SUMMARY_MAX && !/[\u0000-\u001f\u007f]/.test(text), {
|
|
3239
|
+
message: `summary is one line of plain text of at most ${SUMMARY_MAX} characters`
|
|
3240
|
+
})
|
|
3241
|
+
});
|
|
3242
|
+
|
|
3243
|
+
// src/telemetry/event.ts
|
|
3244
|
+
function isRecord2(value) {
|
|
3245
|
+
return value !== null && typeof value == "object" && !Array.isArray(value);
|
|
3246
|
+
}
|
|
3247
|
+
var declaredKeys = /* @__PURE__ */ new Map();
|
|
3248
|
+
function optionKeysOf(type) {
|
|
3249
|
+
let keys = declaredKeys.get(type);
|
|
3250
|
+
if (keys) return keys;
|
|
3251
|
+
keys = /* @__PURE__ */ new Set();
|
|
3252
|
+
try {
|
|
3253
|
+
let schema = getChartSchemas(type)?.optionsSchema, json = schema ? z4.toJSONSchema(schema, { io: "input", unrepresentable: "any" }) : void 0, collect = (node2) => {
|
|
3254
|
+
if (isRecord2(node2)) {
|
|
3255
|
+
if (isRecord2(node2.properties)) for (let key of Object.keys(node2.properties)) keys.add(key);
|
|
3256
|
+
for (let branch of ["anyOf", "oneOf", "allOf"]) Array.isArray(node2[branch]) && node2[branch].forEach(collect);
|
|
3257
|
+
}
|
|
3258
|
+
};
|
|
3259
|
+
collect(json);
|
|
3260
|
+
} catch {
|
|
3261
|
+
}
|
|
3262
|
+
return declaredKeys.set(type, keys), keys;
|
|
3263
|
+
}
|
|
3264
|
+
function chartsOf(spec) {
|
|
3265
|
+
return isRecord2(spec) ? Array.isArray(spec.charts) ? spec.charts.filter(isRecord2).slice(0, 20) : [spec] : [];
|
|
3266
|
+
}
|
|
3267
|
+
function codesOf(body) {
|
|
3268
|
+
let codes2 = /* @__PURE__ */ new Set(), take = (list2) => {
|
|
3269
|
+
if (Array.isArray(list2))
|
|
3270
|
+
for (let entry of list2) isRecord2(entry) && typeof entry.code == "string" && CODE_PATTERN.test(entry.code) && codes2.add(entry.code);
|
|
3271
|
+
};
|
|
3272
|
+
if (take(body.errors), take(body.warnings), Array.isArray(body.charts)) for (let chart of body.charts) isRecord2(chart) && (take(chart.errors), take(chart.warnings));
|
|
3273
|
+
return [...codes2].sort().slice(0, 32);
|
|
3274
|
+
}
|
|
3275
|
+
function osFamily() {
|
|
3276
|
+
let os2 = platform();
|
|
3277
|
+
return os2 === "darwin" || os2 === "linux" || os2 === "win32" ? os2 : "other";
|
|
3278
|
+
}
|
|
3279
|
+
function nodeMajor() {
|
|
3280
|
+
return Number(process.versions.node.split(".")[0]) || 0;
|
|
3281
|
+
}
|
|
3282
|
+
function releaseVersion() {
|
|
3283
|
+
return version;
|
|
3284
|
+
}
|
|
3285
|
+
function hostFromEnv(env = process.env) {
|
|
3286
|
+
return env.CLAUDECODE ? "claude-code" : env.CODEX_THREAD_ID || env.CODEX_SANDBOX ? "codex" : env.CURSOR_AGENT || env.CURSOR_TRACE_ID ? "cursor" : env.GEMINI_CLI ? "gemini" : env.TERM_PROGRAM === "vscode" ? "vscode" : "none";
|
|
3287
|
+
}
|
|
3288
|
+
function hostFromClient(name) {
|
|
3289
|
+
if (typeof name != "string") return "other";
|
|
3290
|
+
let lower = name.toLowerCase();
|
|
3291
|
+
return lower.includes("claude-code") || lower.includes("claude code") ? "claude-code" : lower.includes("claude") ? "claude-app" : lower.includes("codex") ? "codex" : lower.includes("cursor") ? "cursor" : lower.includes("visual studio code") || lower.includes("vscode") || lower.includes("copilot") ? "vscode" : lower.includes("gemini") ? "gemini" : "other";
|
|
3292
|
+
}
|
|
3293
|
+
function usageEvent(input) {
|
|
3294
|
+
let command = input.command.replace(/^boardplot_/, "");
|
|
3295
|
+
if (!COMMANDS.includes(command) || command === "feedback") return;
|
|
3296
|
+
let types = /* @__PURE__ */ new Set(), optionKeys2 = /* @__PURE__ */ new Set(), named = typeof input.type == "string" ? [input.type] : [];
|
|
3297
|
+
for (let chart of chartsOf(input.spec)) {
|
|
3298
|
+
typeof chart.type == "string" && named.push(chart.type);
|
|
3299
|
+
let type = typeof chart.type == "string" ? canonicalChartType(chart.type) : void 0;
|
|
3300
|
+
if (type && isRecord2(chart.options)) {
|
|
3301
|
+
let declared = optionKeysOf(type);
|
|
3302
|
+
for (let key of Object.keys(chart.options)) declared.has(key) && OPTION_KEY_PATTERN.test(key) && optionKeys2.add(key);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
for (let name of named) types.add(name === "theme" ? "theme" : canonicalChartType(name) ?? "other");
|
|
3306
|
+
let event = {
|
|
3307
|
+
v: 1,
|
|
3308
|
+
install: input.install,
|
|
3309
|
+
version: releaseVersion(),
|
|
3310
|
+
surface: input.surface,
|
|
3311
|
+
command,
|
|
3312
|
+
types: [...types].sort().slice(0, 20),
|
|
3313
|
+
optionKeys: [...optionKeys2].sort().slice(0, 64),
|
|
3314
|
+
codes: codesOf(input.body),
|
|
3315
|
+
ok: input.body.ok === !0,
|
|
3316
|
+
format: command !== "render" ? "none" : input.format === "png" ? "png" : "svg",
|
|
3317
|
+
host: input.host,
|
|
3318
|
+
os: osFamily(),
|
|
3319
|
+
node: nodeMajor()
|
|
3320
|
+
}, parsed = usageEventSchema.safeParse(event);
|
|
3321
|
+
return parsed.success ? parsed.data : void 0;
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
// src/telemetry/state.ts
|
|
3325
|
+
import { randomUUID } from "crypto";
|
|
3326
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
3327
|
+
import { homedir } from "os";
|
|
3328
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
3329
|
+
var TELEMETRY_ENDPOINT = "", CONSENT_VERSION = 1;
|
|
3330
|
+
function telemetryFile(env = process.env) {
|
|
3331
|
+
let base = env.XDG_CONFIG_HOME || process.platform === "win32" && env.APPDATA || "";
|
|
3332
|
+
try {
|
|
3333
|
+
base ||= join3(homedir(), ".config");
|
|
3334
|
+
} catch {
|
|
3335
|
+
return "";
|
|
3336
|
+
}
|
|
3337
|
+
return join3(base, "boardplot", "telemetry.json");
|
|
3338
|
+
}
|
|
3339
|
+
var queueFile = (file) => join3(dirname2(file), "telemetry-queue.jsonl"), deliveryFile = (file) => join3(dirname2(file), "telemetry-delivery.json");
|
|
3340
|
+
function flag(value) {
|
|
3341
|
+
return value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
3342
|
+
}
|
|
3343
|
+
var CI_VARS = ["CI", "CONTINUOUS_INTEGRATION", "BUILD_NUMBER", "RUN_ID", "GITHUB_ACTIONS", "GITLAB_CI", "CIRCLECI", "BUILDKITE", "TF_BUILD", "JENKINS_URL", "CODEBUILD_BUILD_ID", "TEAMCITY_VERSION", "BITBUCKET_BUILD_NUMBER"];
|
|
3344
|
+
function inCi(env = process.env) {
|
|
3345
|
+
return CI_VARS.some((name) => flag(env[name]));
|
|
3346
|
+
}
|
|
3347
|
+
function readJson(file) {
|
|
3348
|
+
if (file === "") return {};
|
|
3349
|
+
try {
|
|
3350
|
+
let parsed = JSON.parse(readFileSync5(file, "utf8"));
|
|
3351
|
+
return parsed !== null && typeof parsed == "object" && !Array.isArray(parsed) ? parsed : {};
|
|
3352
|
+
} catch {
|
|
3353
|
+
return {};
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
function writeChoice(file, stored) {
|
|
3357
|
+
if (file === "") throw new Error("Boardplot found no config folder: set XDG_CONFIG_HOME or HOME.");
|
|
3358
|
+
mkdirSync2(dirname2(file), { recursive: !0 });
|
|
3359
|
+
let temporary = `${file}.${process.pid}.tmp`;
|
|
3360
|
+
writeFileSync3(temporary, `${JSON.stringify(stored, null, 2)}
|
|
3361
|
+
`), renameSync(temporary, file);
|
|
3362
|
+
}
|
|
3363
|
+
function endpointFor(env = process.env, compiled = TELEMETRY_ENDPOINT) {
|
|
3364
|
+
return compiled === "" ? "" : env.BOARDPLOT_TELEMETRY_ENDPOINT || compiled;
|
|
3365
|
+
}
|
|
3366
|
+
function telemetryState(env = process.env, compiled = TELEMETRY_ENDPOINT) {
|
|
3367
|
+
let file = telemetryFile(env), stored = readJson(file), endpoint = endpointFor(env, compiled), reason = flag(env.DO_NOT_TRACK) ? "do-not-track" : env.BOARDPLOT_TELEMETRY === "0" || env.BOARDPLOT_TELEMETRY?.toLowerCase() === "false" ? "env-off" : inCi(env) ? "ci" : endpoint === "" ? "no-endpoint" : file === "" ? "not-chosen" : stored.choice === "off" ? "turned-off" : stored.choice === "on" && stored.consentVersion === CONSENT_VERSION ? "on" : "not-chosen";
|
|
3368
|
+
return { enabled: reason === "on", reason, endpoint, file, stored };
|
|
3369
|
+
}
|
|
3370
|
+
var today = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), thisMonth = () => today().slice(0, 7);
|
|
3371
|
+
function currentInstall(state) {
|
|
3372
|
+
let month = thisMonth();
|
|
3373
|
+
if (state.stored.install && state.stored.installMonth === month) return state.stored.install;
|
|
3374
|
+
state.stored = { ...state.stored, install: randomUUID(), installMonth: month };
|
|
3375
|
+
try {
|
|
3376
|
+
writeChoice(state.file, state.stored);
|
|
3377
|
+
} catch {
|
|
3378
|
+
}
|
|
3379
|
+
return state.stored.install;
|
|
3380
|
+
}
|
|
3381
|
+
function turnOn(env = process.env) {
|
|
3382
|
+
let file = telemetryFile(env), { noticeShown, agentNoticeShown } = readJson(file), stored = { choice: "on", consentVersion: CONSENT_VERSION, decidedAt: today(), ...noticeShown ? { noticeShown } : {}, ...agentNoticeShown ? { agentNoticeShown } : {} };
|
|
3383
|
+
return writeChoice(file, stored), stored;
|
|
3384
|
+
}
|
|
3385
|
+
function turnOff(env = process.env) {
|
|
3386
|
+
let file = telemetryFile(env), stored = { choice: "off", decidedAt: today() };
|
|
3387
|
+
return writeChoice(file, stored), rmSync2(queueFile(file), { force: !0 }), stored;
|
|
3388
|
+
}
|
|
3389
|
+
|
|
3390
|
+
// src/telemetry/send.ts
|
|
3391
|
+
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
3392
|
+
import { appendFileSync, statSync as statSync4, utimesSync, writeFileSync as writeFileSync4 } from "fs";
|
|
3393
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
3394
|
+
var TIMEOUT_MS = 3e3, FLUSH_INTERVAL_MS = 6e4, BATCH = 50, POST = `const [url, body, wait] = process.argv.slice(1);
|
|
3395
|
+
fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body, signal: AbortSignal.timeout(Number(wait)) })
|
|
3396
|
+
.then(async (r) => { process.stdout.write(JSON.stringify({ status: r.status, body: await r.text() })); })
|
|
3397
|
+
.catch(() => process.stdout.write(JSON.stringify({ status: 0 })));`, FLUSH = `const fs = require('node:fs');
|
|
3398
|
+
const [queue, url, delivery, wait] = process.argv.slice(1);
|
|
3399
|
+
const taken = queue + '.' + process.pid + '.sending';
|
|
3400
|
+
(async () => {
|
|
3401
|
+
try { fs.renameSync(queue, taken); } catch { return; }
|
|
3402
|
+
try {
|
|
3403
|
+
const events = fs.readFileSync(taken, 'utf8').split('\\n').filter(Boolean).map((line) => JSON.parse(line));
|
|
3404
|
+
let status = 204;
|
|
3405
|
+
for (let at = 0; at < events.length; at += ${BATCH}) {
|
|
3406
|
+
const r = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ events: events.slice(at, at + ${BATCH}) }), signal: AbortSignal.timeout(Number(wait)) }).catch(() => ({ status: 0 }));
|
|
3407
|
+
if (r.status !== 204) status = r.status;
|
|
3408
|
+
}
|
|
3409
|
+
fs.writeFileSync(delivery, JSON.stringify({ day: new Date().toISOString().slice(0, 10), events: events.length, status }) + '\\n');
|
|
3410
|
+
} catch {} finally { fs.rmSync(taken, { force: true }); }
|
|
3411
|
+
})();`, NOTICE = "Boardplot can send usage counts to its maintainers: chart types, option names, warning and error codes, OS and Node version, with a random install ID that changes each month. Never chart data, text, values or paths. It is off until you turn it on with `boardplot telemetry on`. Details: https://github.com/boardplot/boardplot/blob/main/docs/TELEMETRY.md";
|
|
3412
|
+
function url(endpoint, path) {
|
|
3413
|
+
return `${endpoint.replace(/\/+$/, "")}${path}`;
|
|
3414
|
+
}
|
|
3415
|
+
function remember(state, event) {
|
|
3416
|
+
try {
|
|
3417
|
+
writeChoice(state.file, { ...state.stored, lastEvent: event });
|
|
3418
|
+
} catch {
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
function lockFile(state) {
|
|
3422
|
+
return join4(dirname3(state.file), "telemetry-flush.lock");
|
|
3423
|
+
}
|
|
3424
|
+
function claimFlush(state, now = Date.now()) {
|
|
3425
|
+
let lock = lockFile(state);
|
|
3426
|
+
try {
|
|
3427
|
+
if (now - statSync4(lock).mtimeMs < FLUSH_INTERVAL_MS) return !1;
|
|
3428
|
+
utimesSync(lock, now / 1e3, now / 1e3);
|
|
3429
|
+
} catch {
|
|
3430
|
+
try {
|
|
3431
|
+
writeFileSync4(lock, "");
|
|
3432
|
+
} catch {
|
|
3433
|
+
return !1;
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
return !0;
|
|
3437
|
+
}
|
|
3438
|
+
function recordCliUsage(input, state = telemetryState()) {
|
|
3439
|
+
if (!state.enabled) return;
|
|
3440
|
+
let event = usageEvent({ ...input, surface: "cli", install: currentInstall(state) });
|
|
3441
|
+
if (event) {
|
|
3442
|
+
try {
|
|
3443
|
+
appendFileSync(queueFile(state.file), `${JSON.stringify(event)}
|
|
3444
|
+
`);
|
|
3445
|
+
} catch {
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
if (remember(state, event), !!claimFlush(state))
|
|
3449
|
+
try {
|
|
3450
|
+
spawn(process.execPath, ["-e", FLUSH, queueFile(state.file), url(state.endpoint, "/v1/events"), deliveryFile(state.file), String(TIMEOUT_MS)], {
|
|
3451
|
+
detached: !0,
|
|
3452
|
+
stdio: "ignore",
|
|
3453
|
+
windowsHide: !0
|
|
3454
|
+
}).unref();
|
|
3455
|
+
} catch {
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
function cliNotice(state = telemetryState()) {
|
|
3460
|
+
if (!(state.reason !== "not-chosen" || state.file === "" || state.stored.noticeShown || !process.stderr.isTTY || !process.stdin.isTTY)) {
|
|
3461
|
+
process.stderr.write(`${NOTICE}
|
|
3462
|
+
`);
|
|
3463
|
+
try {
|
|
3464
|
+
writeChoice(state.file, { ...state.stored, noticeShown: !0 });
|
|
3465
|
+
} catch {
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
function mcpNotice(cli, state = telemetryState()) {
|
|
3470
|
+
if (!(state.reason !== "not-chosen" || state.file === "" || state.stored.agentNoticeShown)) {
|
|
3471
|
+
try {
|
|
3472
|
+
writeChoice(state.file, { ...state.stored, agentNoticeShown: !0 });
|
|
3473
|
+
} catch {
|
|
3474
|
+
}
|
|
3475
|
+
return `${NOTICE.replace("`boardplot telemetry on`", `\`${cli} telemetry on\``)} Tell the user this once, in your own words. Run the command only when the user asks you to.`;
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
function mcpReporter() {
|
|
3479
|
+
let queue = [], timer, flush = () => {
|
|
3480
|
+
timer && clearTimeout(timer), timer = void 0;
|
|
3481
|
+
let state = telemetryState();
|
|
3482
|
+
if (!queue.length || !state.enabled) {
|
|
3483
|
+
queue = [];
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3486
|
+
let events = queue;
|
|
3487
|
+
queue = [], remember(state, events[events.length - 1]), fetch(url(state.endpoint, "/v1/events"), {
|
|
3488
|
+
method: "POST",
|
|
3489
|
+
headers: { "content-type": "application/json" },
|
|
3490
|
+
body: JSON.stringify({ events }),
|
|
3491
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
3492
|
+
}).then((response) => {
|
|
3493
|
+
try {
|
|
3494
|
+
writeFileSync4(deliveryFile(state.file), `${JSON.stringify({ day: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), events: events.length, status: response.status })}
|
|
3495
|
+
`);
|
|
3496
|
+
} catch {
|
|
3497
|
+
}
|
|
3498
|
+
}, () => {
|
|
3499
|
+
});
|
|
3500
|
+
};
|
|
3501
|
+
return {
|
|
3502
|
+
record(input) {
|
|
3503
|
+
let state = telemetryState();
|
|
3504
|
+
if (!state.enabled) {
|
|
3505
|
+
queue = [];
|
|
3506
|
+
return;
|
|
3507
|
+
}
|
|
3508
|
+
let event = usageEvent({ ...input, surface: "mcp", install: currentInstall(state) });
|
|
3509
|
+
event && (queue.push(event), queue.length >= 20 ? flush() : timer || (timer = setTimeout(flush, 3e4), timer.unref?.()));
|
|
3510
|
+
},
|
|
3511
|
+
flush
|
|
3512
|
+
};
|
|
3513
|
+
}
|
|
3514
|
+
function post(endpoint, path, body) {
|
|
3515
|
+
if (endpoint === "") return { status: -1 };
|
|
3516
|
+
let child = spawnSync2(process.execPath, ["-e", POST, url(endpoint, path), JSON.stringify(body), String(TIMEOUT_MS * 2)], {
|
|
3517
|
+
encoding: "utf8",
|
|
3518
|
+
timeout: TIMEOUT_MS * 3,
|
|
3519
|
+
windowsHide: !0
|
|
3520
|
+
});
|
|
3521
|
+
try {
|
|
3522
|
+
return JSON.parse(child.stdout);
|
|
3523
|
+
} catch {
|
|
3524
|
+
return { status: 0 };
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
function requestErasure(state) {
|
|
3528
|
+
state.endpoint === "" || !state.stored.install || post(state.endpoint, "/v1/forget", { install: state.stored.install });
|
|
3529
|
+
}
|
|
3530
|
+
function sendFeedback(report, state = telemetryState()) {
|
|
3531
|
+
let answer = post(state.endpoint, "/v1/feedback", { report });
|
|
3532
|
+
if (answer.status === -1) return { sent: !1, reason: "no-collector" };
|
|
3533
|
+
if (answer.status !== 201) return { sent: !1, reason: answer.status === 0 ? "network" : "refused" };
|
|
3534
|
+
try {
|
|
3535
|
+
let id = JSON.parse(answer.body ?? "{}").id;
|
|
3536
|
+
return { sent: !0, ...typeof id == "string" ? { id } : {} };
|
|
3537
|
+
} catch {
|
|
3538
|
+
return { sent: !0 };
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
// src/telemetry/feedback.ts
|
|
3543
|
+
var ISSUES_URL = "https://github.com/boardplot/boardplot/issues/new";
|
|
3544
|
+
function names(value, pattern, field) {
|
|
3545
|
+
if (value === void 0) return [];
|
|
3546
|
+
let list2 = typeof value == "string" ? value.split(",").map((entry) => entry.trim()).filter(Boolean) : value;
|
|
3547
|
+
if (!Array.isArray(list2) || !list2.every((entry) => typeof entry == "string" && pattern.test(entry)))
|
|
3548
|
+
throw new InputError("invalid-argument", `${field} takes names as Boardplot spells them (${pattern}), not text`, {
|
|
3549
|
+
path: `/${field}`,
|
|
3550
|
+
suggest: `Pass only ${field === "codes" ? "warning and error codes such as label-dropped" : "option key names such as valueAxis"}.`
|
|
3551
|
+
});
|
|
3552
|
+
return [...new Set(list2)].sort();
|
|
3553
|
+
}
|
|
3554
|
+
function feedbackReport(args) {
|
|
3555
|
+
if (typeof args.category != "string" || !FEEDBACK_CATEGORIES.includes(args.category))
|
|
3556
|
+
throw new InputError("invalid-argument", `category must be one of ${FEEDBACK_CATEGORIES.join(", ")}`, { path: "/category", suggest: "Pass --category bug, friction or docs." });
|
|
3557
|
+
if (typeof args.summary != "string" || !args.summary.trim())
|
|
3558
|
+
throw new InputError("invalid-argument", "summary is required: one line on what went wrong", { path: "/summary", suggest: "Describe the Boardplot problem without client names, numbers, labels or paths." });
|
|
3559
|
+
let type;
|
|
3560
|
+
if (args.type !== void 0 && (type = typeof args.type == "string" ? canonicalChartType(args.type) : void 0, !type))
|
|
3561
|
+
throw new InputError("invalid-argument", "type must be a chart type from boardplot list", { path: "/type" });
|
|
3562
|
+
let report = {
|
|
3563
|
+
v: 1,
|
|
3564
|
+
version: releaseVersion(),
|
|
3565
|
+
surface: args.surface,
|
|
3566
|
+
os: osFamily(),
|
|
3567
|
+
node: nodeMajor(),
|
|
3568
|
+
category: args.category,
|
|
3569
|
+
...type ? { type } : {},
|
|
3570
|
+
optionKeys: names(args.optionKeys, OPTION_KEY_PATTERN, "optionKeys"),
|
|
3571
|
+
codes: names(args.codes, CODE_PATTERN, "codes"),
|
|
3572
|
+
summary: args.summary.trim()
|
|
3573
|
+
}, parsed = feedbackReportSchema.safeParse(report);
|
|
3574
|
+
if (!parsed.success)
|
|
3575
|
+
throw new InputError("invalid-argument", `summary must be one line of plain text of at most ${SUMMARY_MAX} characters`, { path: "/summary" });
|
|
3576
|
+
return parsed.data;
|
|
3577
|
+
}
|
|
3578
|
+
function issueUrl(report) {
|
|
3579
|
+
let title = `${report.category}: ${[...report.summary].slice(0, 80).join("")}`, body = [
|
|
3580
|
+
report.summary,
|
|
3581
|
+
"",
|
|
3582
|
+
`- Version: ${report.version} (${report.surface})`,
|
|
3583
|
+
`- OS: ${report.os}, Node ${report.node}`,
|
|
3584
|
+
...report.type ? [`- Chart type: ${report.type}`] : [],
|
|
3585
|
+
...report.optionKeys.length ? [`- Options: ${report.optionKeys.join(", ")}`] : [],
|
|
3586
|
+
...report.codes.length ? [`- Codes: ${report.codes.join(", ")}`] : [],
|
|
3587
|
+
"",
|
|
3588
|
+
"Sent with boardplot feedback. Add a spec with invented data if it helps reproduce the problem."
|
|
3589
|
+
].join(`
|
|
3590
|
+
`);
|
|
3591
|
+
return `${ISSUES_URL}?${new URLSearchParams({ title, body }).toString()}`;
|
|
3592
|
+
}
|
|
3593
|
+
function feedback(args) {
|
|
3594
|
+
let report = feedbackReport(args), link = issueUrl(report);
|
|
3595
|
+
if (args.surface === "mcp")
|
|
3596
|
+
return ok({
|
|
3597
|
+
sent: !1,
|
|
3598
|
+
report,
|
|
3599
|
+
issueUrl: link,
|
|
3600
|
+
next: "Show the user the report and issueUrl. The user opens the link, checks the text and submits the issue on GitHub; GitHub issues are public."
|
|
3601
|
+
});
|
|
3602
|
+
if (args.send !== !0)
|
|
3603
|
+
return ok({
|
|
3604
|
+
sent: !1,
|
|
3605
|
+
report,
|
|
3606
|
+
issueUrl: link,
|
|
3607
|
+
next: "Show the user the report. Run the command again with --send only after the user says yes to this exact text, or give the user issueUrl to submit on GitHub."
|
|
3608
|
+
});
|
|
3609
|
+
let sent = sendFeedback(report);
|
|
3610
|
+
return ok(sent.sent ? { sent: !0, report, ...sent.id ? { id: sent.id } : {} } : {
|
|
3611
|
+
sent: !1,
|
|
3612
|
+
reason: sent.reason,
|
|
3613
|
+
report,
|
|
3614
|
+
issueUrl: link,
|
|
3615
|
+
next: sent.reason === "no-collector" ? "This build has no feedback collector. Give the user issueUrl to submit the report on GitHub." : "Sending failed. Give the user issueUrl to submit the report on GitHub."
|
|
3616
|
+
});
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3619
|
+
export {
|
|
3620
|
+
ok,
|
|
3621
|
+
rejectedInput,
|
|
3622
|
+
runVerb,
|
|
3623
|
+
requestedFontTables,
|
|
3624
|
+
fontTablesSummary,
|
|
3625
|
+
sha256,
|
|
3626
|
+
readSpecFile,
|
|
3627
|
+
list,
|
|
3628
|
+
readingCountsSchema,
|
|
3629
|
+
readingMetricStackSchema,
|
|
3630
|
+
describe,
|
|
3631
|
+
fixtures,
|
|
3632
|
+
TARGETS,
|
|
3633
|
+
render,
|
|
3634
|
+
measure,
|
|
3635
|
+
FEEDBACK_CATEGORIES,
|
|
3636
|
+
SUMMARY_MAX,
|
|
3637
|
+
hostFromEnv,
|
|
3638
|
+
hostFromClient,
|
|
3639
|
+
deliveryFile,
|
|
3640
|
+
readJson,
|
|
3641
|
+
telemetryState,
|
|
3642
|
+
turnOn,
|
|
3643
|
+
turnOff,
|
|
3644
|
+
recordCliUsage,
|
|
3645
|
+
cliNotice,
|
|
3646
|
+
mcpNotice,
|
|
3647
|
+
mcpReporter,
|
|
3648
|
+
requestErasure,
|
|
3649
|
+
feedback
|
|
3650
|
+
};
|