boardplot 0.0.0-stage → 0.52.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/NOTICE.md +180 -0
- package/README.md +208 -2
- package/THIRD_PARTY_NOTICES.md +1110 -0
- package/dist/DiagnosticDetails-UNYNYCAH.js +69 -0
- package/dist/ReaderBox-VUNSFKZY.js +137 -0
- package/dist/annotateEngine-H7OW4H3W.js +30 -0
- package/dist/build-identity.json +6 -0
- package/dist/chunk-24WB3HMB.js +621 -0
- package/dist/chunk-263SZKIL.js +8 -0
- package/dist/chunk-27QQEWNV.js +18 -0
- package/dist/chunk-2AKWCMS4.js +24 -0
- package/dist/chunk-2DHJJ2EN.js +24 -0
- package/dist/chunk-2EQE4E3I.js +22 -0
- package/dist/chunk-2GELJH37.js +88 -0
- package/dist/chunk-2JAWQ7VV.js +3874 -0
- package/dist/chunk-2LMCD3ZR.js +6 -0
- package/dist/chunk-2MTWKMEG.js +841 -0
- package/dist/chunk-2SGIHKKU.js +33 -0
- package/dist/chunk-2UVTHU7A.js +1146 -0
- package/dist/chunk-33CBPK5Q.js +2800 -0
- package/dist/chunk-33PLBIMA.js +176 -0
- package/dist/chunk-35DZP2R2.js +22 -0
- package/dist/chunk-3D3D3D23.js +25 -0
- package/dist/chunk-3EZRM4YM.js +92 -0
- package/dist/chunk-3GZECHOK.js +802 -0
- package/dist/chunk-3HHNQPAH.js +68 -0
- package/dist/chunk-3I6RANBJ.js +1058 -0
- package/dist/chunk-3SIRPKMP.js +12 -0
- package/dist/chunk-3W23F7EY.js +185 -0
- package/dist/chunk-3XQ635KD.js +24 -0
- package/dist/chunk-3ZCKEANJ.js +24 -0
- package/dist/chunk-4DNOEV3Q.js +25857 -0
- package/dist/chunk-4GB7TBY7.js +373 -0
- package/dist/chunk-4SM2ONUC.js +18 -0
- package/dist/chunk-5C7TWNYZ.js +79 -0
- package/dist/chunk-5DJXJXDE.js +58 -0
- package/dist/chunk-5ENRZX6I.js +687 -0
- package/dist/chunk-5KWXRYAT.js +294 -0
- package/dist/chunk-5T5YW52S.js +47 -0
- package/dist/chunk-627P6T25.js +936 -0
- package/dist/chunk-62FR4FYJ.js +23 -0
- package/dist/chunk-6JUJ2DU3.js +67 -0
- package/dist/chunk-6KWIQ5KF.js +18 -0
- package/dist/chunk-6UBEGKIQ.js +25 -0
- package/dist/chunk-6XE3GVGU.js +116 -0
- package/dist/chunk-76ANFJOI.js +227 -0
- package/dist/chunk-7IFLQMJL.js +160 -0
- package/dist/chunk-7JVAQX6C.js +28 -0
- package/dist/chunk-7QDAHY5M.js +63 -0
- package/dist/chunk-7VXZDB45.js +149 -0
- package/dist/chunk-7X65ZQN4.js +38 -0
- package/dist/chunk-A2FHZH7E.js +1410 -0
- package/dist/chunk-A372DLQX.js +54 -0
- package/dist/chunk-A3ULWR5N.js +76 -0
- package/dist/chunk-A4QZXLXF.js +7 -0
- package/dist/chunk-A5JWFZVU.js +1467 -0
- package/dist/chunk-A5LZUYK4.js +59 -0
- package/dist/chunk-A6XCAQ52.js +89 -0
- package/dist/chunk-A7A4PDG5.js +24 -0
- package/dist/chunk-A7IEVBYI.js +35 -0
- package/dist/chunk-ACXX2JNL.js +6 -0
- package/dist/chunk-AFK47A6O.js +25 -0
- package/dist/chunk-ALKTNXMR.js +3650 -0
- package/dist/chunk-AOQ6VF5H.js +6 -0
- package/dist/chunk-ASAON7G4.js +648 -0
- package/dist/chunk-ATTE3FYC.js +24 -0
- package/dist/chunk-AZOUSKZD.js +728 -0
- package/dist/chunk-B2EBEXIS.js +113 -0
- package/dist/chunk-B67K5X4M.js +58 -0
- package/dist/chunk-BBL3R5YZ.js +186 -0
- package/dist/chunk-BIDIGDGH.js +6 -0
- package/dist/chunk-BKYMLFUG.js +69 -0
- package/dist/chunk-BLFWUMTD.js +12 -0
- package/dist/chunk-BM6SFFWF.js +6 -0
- package/dist/chunk-BUPLB3EX.js +129 -0
- package/dist/chunk-BVWU6GOB.js +47 -0
- package/dist/chunk-BW5VLBSZ.js +15 -0
- package/dist/chunk-C64FBRJO.js +290 -0
- package/dist/chunk-CAE2HK2G.js +295 -0
- package/dist/chunk-CCQNL33L.js +446 -0
- package/dist/chunk-CDZHNLO6.js +42 -0
- package/dist/chunk-COKHNEJP.js +24 -0
- package/dist/chunk-COYPDRJK.js +21 -0
- package/dist/chunk-CRZKGHZ6.js +1810 -0
- package/dist/chunk-CS4DHFNG.js +128 -0
- package/dist/chunk-CYDZP5W6.js +1589 -0
- package/dist/chunk-D4BIV6WG.js +1072 -0
- package/dist/chunk-D4SOADBD.js +19 -0
- package/dist/chunk-DCCJRLAJ.js +422 -0
- package/dist/chunk-DFKTS6XJ.js +75 -0
- package/dist/chunk-DGDOGOTQ.js +25 -0
- package/dist/chunk-DLC23CKC.js +53 -0
- package/dist/chunk-DRTA6JG5.js +160 -0
- package/dist/chunk-DVKBU23L.js +97 -0
- package/dist/chunk-E2HEVF23.js +692 -0
- package/dist/chunk-EC2NAYPQ.js +24 -0
- package/dist/chunk-EKQK5D6G.js +14 -0
- package/dist/chunk-EKQMYG2B.js +2353 -0
- package/dist/chunk-ELYU6TRQ.js +98 -0
- package/dist/chunk-EQT3EPTB.js +203 -0
- package/dist/chunk-ERAIVAK5.js +1359 -0
- package/dist/chunk-ETHWK2RZ.js +16 -0
- package/dist/chunk-EWVKBRLV.js +72 -0
- package/dist/chunk-F77BNDAT.js +43 -0
- package/dist/chunk-FGAGGPFF.js +566 -0
- package/dist/chunk-FIANWJXX.js +19 -0
- package/dist/chunk-FIWNDOMO.js +6 -0
- package/dist/chunk-FOKEGVPB.js +24 -0
- package/dist/chunk-FT3F72C3.js +30 -0
- package/dist/chunk-FT47HQ5U.js +47 -0
- package/dist/chunk-GDOW2KNP.js +19 -0
- package/dist/chunk-GDQ3NGDZ.js +17 -0
- package/dist/chunk-GH3ZMBFX.js +563 -0
- package/dist/chunk-GQPESFAF.js +3378 -0
- package/dist/chunk-GQS46LC3.js +50 -0
- package/dist/chunk-GULJ6KVT.js +587 -0
- package/dist/chunk-GWQIXU37.js +2774 -0
- package/dist/chunk-GZ2VNM4L.js +24 -0
- package/dist/chunk-GZ4RHGIW.js +836 -0
- package/dist/chunk-H4H4O62O.js +46 -0
- package/dist/chunk-H57TJD3B.js +72 -0
- package/dist/chunk-H7UZZ7KP.js +24 -0
- package/dist/chunk-HAAUJDGB.js +83 -0
- package/dist/chunk-HFG76JTS.js +296 -0
- package/dist/chunk-HJXXFPOL.js +211 -0
- package/dist/chunk-HTYFQHRC.js +24 -0
- package/dist/chunk-HUF6TQ2J.js +24 -0
- package/dist/chunk-HUFCSX2Y.js +89 -0
- package/dist/chunk-HX3MQ3H4.js +26 -0
- package/dist/chunk-HZQEQ34U.js +296 -0
- package/dist/chunk-I322G5UG.js +888 -0
- package/dist/chunk-IDDA5INB.js +60 -0
- package/dist/chunk-IDTLHPTK.js +60 -0
- package/dist/chunk-II7652VA.js +2918 -0
- package/dist/chunk-IN4QT33I.js +38 -0
- package/dist/chunk-IV2UXZXX.js +16 -0
- package/dist/chunk-IXSZ7OKR.js +133 -0
- package/dist/chunk-IYEFEBRN.js +41 -0
- package/dist/chunk-IZ35GMGB.js +2543 -0
- package/dist/chunk-IZCOG3FS.js +28 -0
- package/dist/chunk-JA755JHN.js +379 -0
- package/dist/chunk-JETXFF3M.js +33 -0
- package/dist/chunk-JFBEAUJ6.js +24 -0
- package/dist/chunk-JFG4DHKQ.js +48 -0
- package/dist/chunk-JL5BRMDT.js +179 -0
- package/dist/chunk-JLCAWQ3H.js +195 -0
- package/dist/chunk-JLZM7XMZ.js +525 -0
- package/dist/chunk-JMH5MD5A.js +19 -0
- package/dist/chunk-JRPI64AQ.js +3066 -0
- package/dist/chunk-JSX3C6LL.js +344 -0
- package/dist/chunk-JY4R3GML.js +83 -0
- package/dist/chunk-JYBT2JNY.js +61 -0
- package/dist/chunk-K2HNV4LE.js +2008 -0
- package/dist/chunk-KAXJFL7N.js +43 -0
- package/dist/chunk-KDMKHR5A.js +32 -0
- package/dist/chunk-KFFNCDX6.js +19 -0
- package/dist/chunk-KKWZWP67.js +24 -0
- package/dist/chunk-KOJ5QETJ.js +8 -0
- package/dist/chunk-KPMGGE4W.js +51 -0
- package/dist/chunk-KS7DXCXH.js +27 -0
- package/dist/chunk-KSYVTEKR.js +24 -0
- package/dist/chunk-KU4YS6HN.js +61 -0
- package/dist/chunk-KYELSLDJ.js +40 -0
- package/dist/chunk-LC3PSQJJ.js +383 -0
- package/dist/chunk-LC6DYCTG.js +85 -0
- package/dist/chunk-LNKY5Z2X.js +23 -0
- package/dist/chunk-LO2DANS6.js +302 -0
- package/dist/chunk-M4SPKUZE.js +7 -0
- package/dist/chunk-M4YLED7M.js +17 -0
- package/dist/chunk-M6KTNAND.js +746 -0
- package/dist/chunk-MCOIEWW6.js +54 -0
- package/dist/chunk-MDYLOIS2.js +48 -0
- package/dist/chunk-MEISCROL.js +24 -0
- package/dist/chunk-MFLH5ZDQ.js +69 -0
- package/dist/chunk-MIXKQJ64.js +935 -0
- package/dist/chunk-MJMJEURO.js +359 -0
- package/dist/chunk-MNJ2DHU6.js +526 -0
- package/dist/chunk-NEVSQGOI.js +63 -0
- package/dist/chunk-NG5IGZXC.js +1179 -0
- package/dist/chunk-NLOMCLKI.js +3303 -0
- package/dist/chunk-NMCOUVN5.js +24 -0
- package/dist/chunk-NT3HAZYT.js +51 -0
- package/dist/chunk-NXNQQ3DS.js +382 -0
- package/dist/chunk-NYEY6W5R.js +569 -0
- package/dist/chunk-OAPCJO6W.js +23 -0
- package/dist/chunk-OH7FA4TF.js +251 -0
- package/dist/chunk-OLNORNCT.js +331 -0
- package/dist/chunk-OQEBOVUO.js +30 -0
- package/dist/chunk-ORUJI3VB.js +83 -0
- package/dist/chunk-PEN2DK7T.js +49 -0
- package/dist/chunk-PGIQMQRU.js +1650 -0
- package/dist/chunk-PTVOXB5T.js +39 -0
- package/dist/chunk-PUVGWJQ5.js +24 -0
- package/dist/chunk-PWROWDZS.js +137 -0
- package/dist/chunk-Q6XJOJTY.js +29 -0
- package/dist/chunk-QBR6IKIX.js +50 -0
- package/dist/chunk-QETGGFH2.js +30 -0
- package/dist/chunk-QG6MOQLI.js +2934 -0
- package/dist/chunk-QGCEHR6S.js +13 -0
- package/dist/chunk-QHFQHQDC.js +43 -0
- package/dist/chunk-QHRE2M6V.js +26 -0
- package/dist/chunk-QKL7IY42.js +38 -0
- package/dist/chunk-QN6JHMGU.js +44 -0
- package/dist/chunk-QNHZXFRA.js +347 -0
- package/dist/chunk-QPWRHDLZ.js +17 -0
- package/dist/chunk-QVABTUDS.js +80 -0
- package/dist/chunk-QXILAMAU.js +28 -0
- package/dist/chunk-QZAT46PP.js +95 -0
- package/dist/chunk-R3WI7ZLE.js +545 -0
- package/dist/chunk-R5SWC3EW.js +30 -0
- package/dist/chunk-RJQ5YS3Q.js +40 -0
- package/dist/chunk-RNOD2UWF.js +613 -0
- package/dist/chunk-RNXITK5M.js +24 -0
- package/dist/chunk-ROXO4R3J.js +16 -0
- package/dist/chunk-RQ5DNYLG.js +10 -0
- package/dist/chunk-RSWVH7DB.js +24 -0
- package/dist/chunk-RTJXOIIQ.js +12 -0
- package/dist/chunk-RZNYW7UP.js +133 -0
- package/dist/chunk-S4F27M7N.js +37 -0
- package/dist/chunk-S4ONWRJE.js +28 -0
- package/dist/chunk-S53OGZL6.js +168 -0
- package/dist/chunk-S5ADHIZK.js +2508 -0
- package/dist/chunk-S62M63LU.js +19 -0
- package/dist/chunk-S7VDRUED.js +62 -0
- package/dist/chunk-SGD3ZHID.js +250 -0
- package/dist/chunk-SGSPYHFE.js +40 -0
- package/dist/chunk-SLTMRTXV.js +597 -0
- package/dist/chunk-SXGTRZFN.js +26 -0
- package/dist/chunk-SZPTTNW7.js +16 -0
- package/dist/chunk-T3IGJARD.js +22 -0
- package/dist/chunk-TA3TFKYZ.js +86 -0
- package/dist/chunk-TNEHPP3H.js +18 -0
- package/dist/chunk-TPYV2FTV.js +25 -0
- package/dist/chunk-TPZB2YWR.js +25 -0
- package/dist/chunk-TSR5YDPS.js +1266 -0
- package/dist/chunk-TTR7EWNH.js +170 -0
- package/dist/chunk-TVHLKVUO.js +24 -0
- package/dist/chunk-TXINIAFL.js +198 -0
- package/dist/chunk-TXZBBZOG.js +58 -0
- package/dist/chunk-UEU46Q3D.js +300 -0
- package/dist/chunk-UMDEWWXT.js +33 -0
- package/dist/chunk-UQSVWO7Z.js +334 -0
- package/dist/chunk-UZF3G2FN.js +942 -0
- package/dist/chunk-V422EKLW.js +24 -0
- package/dist/chunk-V4DYVLOO.js +433 -0
- package/dist/chunk-V4VC25UL.js +128 -0
- package/dist/chunk-V667FCIJ.js +12 -0
- package/dist/chunk-VABRPZVC.js +43 -0
- package/dist/chunk-VB2MJLET.js +19 -0
- package/dist/chunk-VDAKTZQP.js +18 -0
- package/dist/chunk-VDAZPGR2.js +79 -0
- package/dist/chunk-VXZFQKBJ.js +21 -0
- package/dist/chunk-VYMGZ27S.js +133 -0
- package/dist/chunk-W2RGSGRR.js +131 -0
- package/dist/chunk-W7UZXD5D.js +1109 -0
- package/dist/chunk-WDUNR2VI.js +2718 -0
- package/dist/chunk-WHSTEAVP.js +229 -0
- package/dist/chunk-WJMUMN3I.js +127 -0
- package/dist/chunk-WLZ54FWG.js +120 -0
- package/dist/chunk-WMJPFLF3.js +2980 -0
- package/dist/chunk-WRHFBCVY.js +24 -0
- package/dist/chunk-WVSNSWBJ.js +47 -0
- package/dist/chunk-WYJEOMNY.js +31 -0
- package/dist/chunk-WYJMV62X.js +24 -0
- package/dist/chunk-WZGJSQKN.js +29 -0
- package/dist/chunk-WZL4EEBS.js +11 -0
- package/dist/chunk-X7TXGKRX.js +272 -0
- package/dist/chunk-XB4KZ6WO.js +81 -0
- package/dist/chunk-XDLQRSSH.js +266 -0
- package/dist/chunk-XDS4UZGR.js +113 -0
- package/dist/chunk-XEGRWWNO.js +30 -0
- package/dist/chunk-XO5ONLVM.js +420 -0
- package/dist/chunk-XPWRD424.js +24 -0
- package/dist/chunk-XTNV2YMB.js +50 -0
- package/dist/chunk-XW5J5JAX.js +42 -0
- package/dist/chunk-XY5O74BH.js +33 -0
- package/dist/chunk-XYONCO5Q.js +984 -0
- package/dist/chunk-Y4PXIJMD.js +829 -0
- package/dist/chunk-YAYRRKC7.js +24 -0
- package/dist/chunk-YEDYBMCW.js +210 -0
- package/dist/chunk-YFG4E3N2.js +1161 -0
- package/dist/chunk-YHTO46W2.js +2670 -0
- package/dist/chunk-YI2ZVTCB.js +38 -0
- package/dist/chunk-YKO3VCTF.js +24 -0
- package/dist/chunk-YP3I6W7T.js +24 -0
- package/dist/chunk-YQ2B3YVF.js +687 -0
- package/dist/chunk-YS6KMYM4.js +91 -0
- package/dist/chunk-YTSSXSZR.js +197 -0
- package/dist/chunk-Z256ACGC.js +27 -0
- package/dist/chunk-Z2MGTKDR.js +20 -0
- package/dist/chunk-Z5VSLLNY.js +23 -0
- package/dist/chunk-Z7X3RGGA.js +22 -0
- package/dist/chunk-ZF43WRG3.js +29 -0
- package/dist/chunk-ZJKOLOVF.js +1754 -0
- package/dist/chunk-ZQ4VFQID.js +76 -0
- package/dist/chunk-ZSLGN6CO.js +89 -0
- package/dist/chunk-ZVTFZF4V.js +542 -0
- package/dist/cli/index.js +9 -0
- package/dist/core-5Z6UW5DS.js +31 -0
- package/dist/core-6ANZ2OWO.js +40 -0
- package/dist/core-6LLJNZ4O.js +37 -0
- package/dist/core-CPN2HF75.js +33 -0
- package/dist/core-CS7AKNME.js +37 -0
- package/dist/core-DBRILYNB.js +38 -0
- package/dist/core-DU77ZYPR.js +34 -0
- package/dist/core-E6YD7VU4.js +32 -0
- package/dist/core-EE55P6XK.js +56 -0
- package/dist/core-FFLPH5XK.js +41 -0
- package/dist/core-IV26EL5C.js +32 -0
- package/dist/core-IZVZ2B7Y.js +34 -0
- package/dist/core-JQV7STNF.js +34 -0
- package/dist/core-KBH3EJZV.js +32 -0
- package/dist/core-KFBW5PRT.js +36 -0
- package/dist/core-KWGXHBJE.js +37 -0
- package/dist/core-MZMR2DF4.js +32 -0
- package/dist/core-OK2ZY5OJ.js +29 -0
- package/dist/core-OV5MPTZP.js +43 -0
- package/dist/core-OW5V74Q4.js +40 -0
- package/dist/core-PL64QPOH.js +57 -0
- package/dist/core-PVINU5JJ.js +33 -0
- package/dist/core-QUYSNTC7.js +34 -0
- package/dist/core-RE3L6YCM.js +29 -0
- package/dist/core-RUA3EWW3.js +39 -0
- package/dist/core-RY6IFRKM.js +35 -0
- package/dist/core-SCWEVNUY.js +34 -0
- package/dist/core-SE67HHFG.js +55 -0
- package/dist/core-T5Q4DSH2.js +32 -0
- package/dist/core-TJX3I7KH.js +37 -0
- package/dist/core-ULUA5ZB2.js +55 -0
- package/dist/core-WLVU2HWX.js +46 -0
- package/dist/core-WQPHNVNY.js +51 -0
- package/dist/core-XXIOJY2X.js +52 -0
- package/dist/core-ZH7XTJTD.js +39 -0
- package/dist/core-ZHE7N4NS.js +50 -0
- package/dist/core-ZJYLJWZQ.js +38 -0
- package/dist/dataTable-IL7HVDHL.js +58 -0
- package/dist/engine-MYLZI5VH.js +961 -0
- package/dist/fixtures.d.ts +1 -0
- package/dist/fixtures.js +40 -0
- package/dist/fontTables-ZYBUCJ5N.js +18 -0
- package/dist/fonts.d.ts +1 -0
- package/dist/fonts.js +19 -0
- package/dist/geo/dach.d.ts +1 -0
- package/dist/geo/dach.js +14 -0
- package/dist/geo/de-states.d.ts +1 -0
- package/dist/geo/de-states.js +14 -0
- package/dist/geo/eu27.d.ts +1 -0
- package/dist/geo/eu27.js +14 -0
- package/dist/geo/europe.d.ts +1 -0
- package/dist/geo/europe.js +14 -0
- package/dist/geo/index.d.ts +1 -0
- package/dist/geo/index.js +41 -0
- package/dist/geo/us-states.d.ts +1 -0
- package/dist/geo/us-states.js +14 -0
- package/dist/geo/world.d.ts +1 -0
- package/dist/geo/world.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +363 -0
- package/dist/main-ISJ53IS5.js +568 -0
- package/dist/mcp/server.js +1023 -0
- package/dist/module-SVEW5ZUE.js +137233 -0
- package/dist/react/bar.d.ts +1 -0
- package/dist/react/bar.js +80 -0
- package/dist/react/bartable.d.ts +1 -0
- package/dist/react/bartable.js +70 -0
- package/dist/react/box.d.ts +1 -0
- package/dist/react/box.js +64 -0
- package/dist/react/bullet.d.ts +1 -0
- package/dist/react/bullet.js +71 -0
- package/dist/react/butterfly.d.ts +1 -0
- package/dist/react/butterfly.js +65 -0
- package/dist/react/choropleth.d.ts +1 -0
- package/dist/react/choropleth.js +67 -0
- package/dist/react/cohort.d.ts +1 -0
- package/dist/react/cohort.js +69 -0
- package/dist/react/column.d.ts +1 -0
- package/dist/react/column.js +85 -0
- package/dist/react/combo.d.ts +1 -0
- package/dist/react/combo.js +85 -0
- package/dist/react/creative.d.ts +1 -0
- package/dist/react/creative.js +61 -0
- package/dist/react/diagram.d.ts +1 -0
- package/dist/react/diagram.js +60 -0
- package/dist/react/dimswitch.d.ts +1 -0
- package/dist/react/dimswitch.js +71 -0
- package/dist/react/dot.d.ts +1 -0
- package/dist/react/dot.js +69 -0
- package/dist/react/export.d.ts +1 -0
- package/dist/react/export.js +657 -0
- package/dist/react/funnel.d.ts +1 -0
- package/dist/react/funnel.js +62 -0
- package/dist/react/gantt.d.ts +1 -0
- package/dist/react/gantt.js +62 -0
- package/dist/react/grid.d.ts +1 -0
- package/dist/react/grid.js +66 -0
- package/dist/react/heatmap.d.ts +1 -0
- package/dist/react/heatmap.js +67 -0
- package/dist/react/histogram.d.ts +1 -0
- package/dist/react/histogram.js +85 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +503 -0
- package/dist/react/kpi.d.ts +1 -0
- package/dist/react/kpi.js +67 -0
- package/dist/react/likert.d.ts +1 -0
- package/dist/react/likert.js +82 -0
- package/dist/react/line.d.ts +1 -0
- package/dist/react/line.js +80 -0
- package/dist/react/mekko.d.ts +1 -0
- package/dist/react/mekko.js +70 -0
- package/dist/react/pareto.d.ts +1 -0
- package/dist/react/pareto.js +89 -0
- package/dist/react/pie.d.ts +1 -0
- package/dist/react/pie.js +63 -0
- package/dist/react/prepare.d.ts +1 -0
- package/dist/react/prepare.js +277 -0
- package/dist/react/pvm.d.ts +1 -0
- package/dist/react/pvm.js +67 -0
- package/dist/react/pyramid.d.ts +1 -0
- package/dist/react/pyramid.js +66 -0
- package/dist/react/sankey.d.ts +1 -0
- package/dist/react/sankey.js +59 -0
- package/dist/react/scatter.d.ts +1 -0
- package/dist/react/scatter.js +62 -0
- package/dist/react/slope.d.ts +1 -0
- package/dist/react/slope.js +63 -0
- package/dist/react/sparkline.d.ts +1 -0
- package/dist/react/sparkline.js +59 -0
- package/dist/react/spec.d.ts +1 -0
- package/dist/react/spec.js +370 -0
- package/dist/react/status.d.ts +1 -0
- package/dist/react/status.js +64 -0
- package/dist/react/story.d.ts +1 -0
- package/dist/react/story.js +140 -0
- package/dist/react/table.d.ts +1 -0
- package/dist/react/table.js +68 -0
- package/dist/react/theme.d.ts +1 -0
- package/dist/react/theme.js +53 -0
- package/dist/react/tilemap.d.ts +1 -0
- package/dist/react/tilemap.js +66 -0
- package/dist/react/treemap.d.ts +1 -0
- package/dist/react/treemap.js +61 -0
- package/dist/react/variance.d.ts +1 -0
- package/dist/react/variance.js +64 -0
- package/dist/react/waffle.d.ts +1 -0
- package/dist/react/waffle.js +62 -0
- package/dist/react/waterfall.d.ts +1 -0
- package/dist/react/waterfall.js +67 -0
- package/dist/resvg-ZOVDIZTV.js +23 -0
- package/dist/rows.d.ts +1 -0
- package/dist/rows.js +23 -0
- package/dist/rowsModule-3Y4I3M3E.js +27 -0
- package/dist/schema-2BMZOHXI.js +22 -0
- package/dist/schema-2GUBWOBC.js +26 -0
- package/dist/schema-34ZELWRQ.js +25 -0
- package/dist/schema-3BHL2B76.js +22 -0
- package/dist/schema-4735XAZX.js +29 -0
- package/dist/schema-5YTNQ6JY.js +22 -0
- package/dist/schema-7J3NAIN2.js +27 -0
- package/dist/schema-AOJJ7JZB.js +22 -0
- package/dist/schema-CVMV4LRA.js +22 -0
- package/dist/schema-D3RCMN3T.js +22 -0
- package/dist/schema-E2ISJ65D.js +23 -0
- package/dist/schema-E6YOSOWB.js +28 -0
- package/dist/schema-EQQB43AY.js +22 -0
- package/dist/schema-EVLLL5UF.js +22 -0
- package/dist/schema-EYQ5IBLF.js +23 -0
- package/dist/schema-EYZVD73N.js +22 -0
- package/dist/schema-G4KFMQBL.js +22 -0
- package/dist/schema-GH7IKSOU.js +23 -0
- package/dist/schema-IF5N3J56.js +42 -0
- package/dist/schema-IG7JIR4H.js +23 -0
- package/dist/schema-JJYJOQTT.js +23 -0
- package/dist/schema-KFC4WYH4.js +32 -0
- package/dist/schema-L7263JMT.js +25 -0
- package/dist/schema-MEAFRXVH.js +53 -0
- package/dist/schema-P63S63GE.js +23 -0
- package/dist/schema-P7LJFJAJ.js +22 -0
- package/dist/schema-PA2MXYY4.js +23 -0
- package/dist/schema-PDZ6256H.js +23 -0
- package/dist/schema-PNC3Z7AH.js +25 -0
- package/dist/schema-QEVSIMGO.js +22 -0
- package/dist/schema-QJJPRRE7.js +22 -0
- package/dist/schema-S3EQKVOT.js +23 -0
- package/dist/schema-STGL44TL.js +22 -0
- package/dist/schema-T4NE2EAO.js +22 -0
- package/dist/schema-TQYTESG3.js +22 -0
- package/dist/schema-W376PAJG.js +22 -0
- package/dist/schema-XYYDUUHS.js +26 -0
- package/dist/specValidation-NVBIZMEE.js +48 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +24 -0
- package/dist/themeShapeRules-5C2463YH.js +11 -0
- package/dist/types/core/a11y/accessibility.d.ts +43 -0
- package/dist/types/core/a11y/recordsShared.d.ts +44 -0
- package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
- package/dist/types/core/a11y/types.d.ts +116 -0
- package/dist/types/core/annotate.d.ts +300 -0
- package/dist/types/core/annotateArms.d.ts +37 -0
- package/dist/types/core/annotateFields.d.ts +30 -0
- package/dist/types/core/annotateGapBracket.d.ts +66 -0
- package/dist/types/core/annotateLinks.d.ts +47 -0
- package/dist/types/core/annotateTargets.d.ts +90 -0
- package/dist/types/core/axis.d.ts +179 -0
- package/dist/types/core/bandSelect.d.ts +10 -0
- package/dist/types/core/bands.d.ts +14 -0
- package/dist/types/core/calendarLabels.d.ts +101 -0
- package/dist/types/core/charts/band/stacks.d.ts +155 -0
- package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
- package/dist/types/core/charts/bar/layout.d.ts +95 -0
- package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
- package/dist/types/core/charts/bartable/types.d.ts +192 -0
- package/dist/types/core/charts/box/fixtures.d.ts +12 -0
- package/dist/types/core/charts/box/types.d.ts +110 -0
- package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
- package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
- package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
- package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
- package/dist/types/core/charts/choropleth/types.d.ts +117 -0
- package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
- package/dist/types/core/charts/cohort/types.d.ts +165 -0
- package/dist/types/core/charts/column/anomaly.d.ts +204 -0
- package/dist/types/core/charts/column/fixtures.d.ts +12 -0
- package/dist/types/core/charts/column/layout.d.ts +116 -0
- package/dist/types/core/charts/column/model.d.ts +295 -0
- package/dist/types/core/charts/column/types.d.ts +56 -0
- package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
- package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
- package/dist/types/core/charts/combo/layout.d.ts +48 -0
- package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
- package/dist/types/core/charts/creative/types.d.ts +73 -0
- package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
- package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
- package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
- package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
- package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
- package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
- package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
- package/dist/types/core/charts/gantt/layout.d.ts +56 -0
- package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
- package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
- package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
- package/dist/types/core/charts/grid/normalize.d.ts +99 -0
- package/dist/types/core/charts/grid/schema.d.ts +168 -0
- package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
- package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
- package/dist/types/core/charts/histogram/types.d.ts +98 -0
- package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
- package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
- package/dist/types/core/charts/likert/layout.d.ts +111 -0
- package/dist/types/core/charts/line/fixtures.d.ts +16 -0
- package/dist/types/core/charts/line/types.d.ts +6 -0
- package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
- package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
- package/dist/types/core/charts/pareto/layout.d.ts +68 -0
- package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
- package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
- package/dist/types/core/charts/pvm/types.d.ts +118 -0
- package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
- package/dist/types/core/charts/pyramid/types.d.ts +92 -0
- package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
- package/dist/types/core/charts/sankey/types.d.ts +116 -0
- package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
- package/dist/types/core/charts/scatter/types.d.ts +58 -0
- package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
- package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
- package/dist/types/core/charts/status/fixtures.d.ts +8 -0
- package/dist/types/core/charts/status/layout.d.ts +71 -0
- package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
- package/dist/types/core/charts/table/fixtures.d.ts +7 -0
- package/dist/types/core/charts/table/resolve.d.ts +72 -0
- package/dist/types/core/charts/table/view.d.ts +156 -0
- package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
- package/dist/types/core/charts/tilemap/types.d.ts +94 -0
- package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
- package/dist/types/core/charts/treemap/types.d.ts +78 -0
- package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
- package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
- package/dist/types/core/charts/waffle/types.d.ts +117 -0
- package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
- package/dist/types/core/claims/browser.d.ts +49 -0
- package/dist/types/core/claims/manifest.d.ts +22 -0
- package/dist/types/core/dateFormat.d.ts +39 -0
- package/dist/types/core/deferred.d.ts +121 -0
- package/dist/types/core/diagnostics/describe.d.ts +149 -0
- package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
- package/dist/types/core/doc/bareChart.d.ts +2 -0
- package/dist/types/core/doc/diagnostics.d.ts +124 -0
- package/dist/types/core/doc/docExpand.d.ts +39 -0
- package/dist/types/core/doc/document.d.ts +43 -0
- package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
- package/dist/types/core/doc/specError.d.ts +6 -0
- package/dist/types/core/emptyData.d.ts +27 -0
- package/dist/types/core/eventLane.d.ts +208 -0
- package/dist/types/core/fontMetrics/index.d.ts +47 -0
- package/dist/types/core/fontMetrics/injected.d.ts +40 -0
- package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
- package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
- package/dist/types/core/footer.d.ts +59 -0
- package/dist/types/core/format.d.ts +149 -0
- package/dist/types/core/formatPrecision.d.ts +136 -0
- package/dist/types/core/formatSpec.d.ts +302 -0
- package/dist/types/core/frame.d.ts +583 -0
- package/dist/types/core/geo/packs/all.d.ts +7 -0
- package/dist/types/core/geo/packs/dach.d.ts +16 -0
- package/dist/types/core/geo/packs/de-states.d.ts +16 -0
- package/dist/types/core/geo/packs/eu27.d.ts +16 -0
- package/dist/types/core/geo/packs/europe.d.ts +16 -0
- package/dist/types/core/geo/packs/index.d.ts +22 -0
- package/dist/types/core/geo/packs/registry.d.ts +37 -0
- package/dist/types/core/geo/packs/us-states.d.ts +16 -0
- package/dist/types/core/geo/packs/world.d.ts +16 -0
- package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
- package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
- package/dist/types/core/geo/tiles/index.d.ts +8 -0
- package/dist/types/core/geo/tiles/types.d.ts +36 -0
- package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
- package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
- package/dist/types/core/geo/types.d.ts +146 -0
- package/dist/types/core/geometry.d.ts +102 -0
- package/dist/types/core/grid/sharedScale.d.ts +82 -0
- package/dist/types/core/icons.d.ts +227 -0
- package/dist/types/core/inputError.d.ts +14 -0
- package/dist/types/core/isoDate.d.ts +2 -0
- package/dist/types/core/isoTime.d.ts +7 -0
- package/dist/types/core/label/categoryRow.d.ts +332 -0
- package/dist/types/core/label/occupied.d.ts +41 -0
- package/dist/types/core/label/ownership.d.ts +83 -0
- package/dist/types/core/label/solver.d.ts +380 -0
- package/dist/types/core/label/tickRow.d.ts +78 -0
- package/dist/types/core/live/types.d.ts +50 -0
- package/dist/types/core/normalize/shared.d.ts +56 -0
- package/dist/types/core/notes.d.ts +174 -0
- package/dist/types/core/othersShade.d.ts +9 -0
- package/dist/types/core/periodYears.d.ts +9 -0
- package/dist/types/core/polyline.d.ts +11 -0
- package/dist/types/core/rangeRules.d.ts +19 -0
- package/dist/types/core/ratioTier.d.ts +120 -0
- package/dist/types/core/readerStrings.d.ts +13 -0
- package/dist/types/core/reading.d.ts +120 -0
- package/dist/types/core/registry.d.ts +178 -0
- package/dist/types/core/repaintGeometry.d.ts +19 -0
- package/dist/types/core/request.d.ts +124 -0
- package/dist/types/core/rows.d.ts +45 -0
- package/dist/types/core/scale.d.ts +106 -0
- package/dist/types/core/schema/capability.d.ts +229 -0
- package/dist/types/core/schema/namedColumns.d.ts +45 -0
- package/dist/types/core/schema/reference.d.ts +31 -0
- package/dist/types/core/schema/refusals.d.ts +45 -0
- package/dist/types/core/schema/unknownKeys.d.ts +45 -0
- package/dist/types/core/seriesIdentity.d.ts +120 -0
- package/dist/types/core/shareRounding.d.ts +49 -0
- package/dist/types/core/sizing.d.ts +330 -0
- package/dist/types/core/staticFooter.d.ts +6 -0
- package/dist/types/core/story.d.ts +41 -0
- package/dist/types/core/structureCounts.d.ts +10 -0
- package/dist/types/core/svg/renderSvg.d.ts +51 -0
- package/dist/types/core/target.d.ts +89 -0
- package/dist/types/core/text.d.ts +113 -0
- package/dist/types/core/theme.d.ts +478 -0
- package/dist/types/core/themeFields.d.ts +11 -0
- package/dist/types/core/themeRules.d.ts +111 -0
- package/dist/types/core/themeShape.d.ts +87 -0
- package/dist/types/core/themeValidate.d.ts +15 -0
- package/dist/types/core/timeAxis.d.ts +106 -0
- package/dist/types/core/types/annotations.d.ts +223 -0
- package/dist/types/core/types/cell.d.ts +82 -0
- package/dist/types/core/types/data.d.ts +309 -0
- package/dist/types/core/types/diagram.d.ts +234 -0
- package/dist/types/core/types/index.d.ts +8 -0
- package/dist/types/core/types/options.d.ts +1583 -0
- package/dist/types/core/types/scene.d.ts +990 -0
- package/dist/types/core/types/sizing.d.ts +51 -0
- package/dist/types/core/types/table.d.ts +873 -0
- package/dist/types/core/types/theme.d.ts +806 -0
- package/dist/types/core/zoom.d.ts +106 -0
- package/dist/types/fixtures/index.d.ts +40 -0
- package/dist/types/fixtures/registry.d.ts +15 -0
- package/dist/types/fonts.d.ts +10 -0
- package/dist/types/index.d.ts +70 -0
- package/dist/types/react/BoardplotTheme.d.ts +9 -0
- package/dist/types/react/DimSwitchChart.d.ts +36 -0
- package/dist/types/react/ScaleGroup.d.ts +31 -0
- package/dist/types/react/SceneRenderer.d.ts +23 -0
- package/dist/types/react/SizePlaceholder.d.ts +51 -0
- package/dist/types/react/StoryFrame.d.ts +42 -0
- package/dist/types/react/TableChart.d.ts +220 -0
- package/dist/types/react/a11ySurface.d.ts +20 -0
- package/dist/types/react/barrelCharts.d.ts +1023 -0
- package/dist/types/react/charts/bar.d.ts +28 -0
- package/dist/types/react/charts/bartable.d.ts +27 -0
- package/dist/types/react/charts/box.d.ts +27 -0
- package/dist/types/react/charts/bullet.d.ts +28 -0
- package/dist/types/react/charts/butterfly.d.ts +28 -0
- package/dist/types/react/charts/choropleth.d.ts +27 -0
- package/dist/types/react/charts/cohort.d.ts +52 -0
- package/dist/types/react/charts/column.d.ts +27 -0
- package/dist/types/react/charts/combo.d.ts +7 -0
- package/dist/types/react/charts/creative.d.ts +27 -0
- package/dist/types/react/charts/diagram.d.ts +162 -0
- package/dist/types/react/charts/dimswitch.d.ts +6 -0
- package/dist/types/react/charts/dot.d.ts +28 -0
- package/dist/types/react/charts/funnel.d.ts +28 -0
- package/dist/types/react/charts/gantt.d.ts +28 -0
- package/dist/types/react/charts/grid.d.ts +29 -0
- package/dist/types/react/charts/heatmap.d.ts +28 -0
- package/dist/types/react/charts/histogram.d.ts +27 -0
- package/dist/types/react/charts/kpi.d.ts +28 -0
- package/dist/types/react/charts/likert.d.ts +27 -0
- package/dist/types/react/charts/line.d.ts +28 -0
- package/dist/types/react/charts/mekko.d.ts +28 -0
- package/dist/types/react/charts/pareto.d.ts +28 -0
- package/dist/types/react/charts/pie.d.ts +28 -0
- package/dist/types/react/charts/pvm.d.ts +27 -0
- package/dist/types/react/charts/pyramid.d.ts +27 -0
- package/dist/types/react/charts/sankey.d.ts +27 -0
- package/dist/types/react/charts/scatter.d.ts +28 -0
- package/dist/types/react/charts/slope.d.ts +28 -0
- package/dist/types/react/charts/sparkline.d.ts +28 -0
- package/dist/types/react/charts/status.d.ts +27 -0
- package/dist/types/react/charts/table.d.ts +6 -0
- package/dist/types/react/charts/tilemap.d.ts +27 -0
- package/dist/types/react/charts/treemap.d.ts +27 -0
- package/dist/types/react/charts/variance.d.ts +28 -0
- package/dist/types/react/charts/waffle.d.ts +28 -0
- package/dist/types/react/charts/waterfall.d.ts +28 -0
- package/dist/types/react/createChartComponent.d.ts +135 -0
- package/dist/types/react/export/clipboard.d.ts +8 -0
- package/dist/types/react/export/csv.d.ts +2 -0
- package/dist/types/react/export/frame.d.ts +35 -0
- package/dist/types/react/export/index.d.ts +7 -0
- package/dist/types/react/export/png.d.ts +14 -0
- package/dist/types/react/export/svg.d.ts +5 -0
- package/dist/types/react/export/types.d.ts +69 -0
- package/dist/types/react/export/useExport.d.ts +17 -0
- package/dist/types/react/exportLink.d.ts +49 -0
- package/dist/types/react/footerFrame.d.ts +25 -0
- package/dist/types/react/hover/dataTable.d.ts +13 -0
- package/dist/types/react/hover/engine.d.ts +210 -0
- package/dist/types/react/hover/keyboard.d.ts +44 -0
- package/dist/types/react/hover/labelCard.d.ts +170 -0
- package/dist/types/react/hover/placement.d.ts +49 -0
- package/dist/types/react/index.d.ts +16 -0
- package/dist/types/react/parseChartSpec.d.ts +16 -0
- package/dist/types/react/prepare.d.ts +32 -0
- package/dist/types/react/prepared.d.ts +53 -0
- package/dist/types/react/preparedTable.d.ts +15 -0
- package/dist/types/react/rowsInput.d.ts +55 -0
- package/dist/types/react/rowsModule.d.ts +18 -0
- package/dist/types/react/rowsStore.d.ts +50 -0
- package/dist/types/react/scale-group.d.ts +2 -0
- package/dist/types/react/scaleGroupContext.d.ts +22 -0
- package/dist/types/react/scenePaint.d.ts +10 -0
- package/dist/types/react/scrollState.d.ts +26 -0
- package/dist/types/react/spec.d.ts +65 -0
- package/dist/types/react/specValidation.d.ts +45 -0
- package/dist/types/react/story.d.ts +15 -0
- package/dist/types/react/theme.d.ts +9 -0
- package/dist/types/react/themeContext.d.ts +44 -0
- package/dist/types/react/useChartLayout.d.ts +22 -0
- package/dist/types/react/useContainerSize.d.ts +57 -0
- package/dist/types/react/useHover.d.ts +100 -0
- package/dist/types/react/useZoom.d.ts +50 -0
- package/dist/types/rows.d.ts +58 -0
- package/dist/types/tableLooks.d.ts +6 -0
- package/dist/types/theme.d.ts +3 -0
- package/dist/types/validate.d.ts +3 -0
- package/dist/validate.d.ts +1 -0
- package/dist/validate.js +222 -0
- package/docs/FONTS.md +68 -0
- package/docs/TELEMETRY.md +94 -0
- package/docs/manual.md +838 -0
- package/docs/reference/bar.md +222 -0
- package/docs/reference/bartable.md +143 -0
- package/docs/reference/box.md +93 -0
- package/docs/reference/bullet.md +118 -0
- package/docs/reference/butterfly.md +117 -0
- package/docs/reference/choropleth.md +148 -0
- package/docs/reference/cohort.md +149 -0
- package/docs/reference/column.md +275 -0
- package/docs/reference/combo.md +219 -0
- package/docs/reference/creative.md +147 -0
- package/docs/reference/diagram.md +191 -0
- package/docs/reference/dimswitch.md +1395 -0
- package/docs/reference/dot.md +117 -0
- package/docs/reference/fixtures.md +1088 -0
- package/docs/reference/funnel.md +121 -0
- package/docs/reference/gantt.md +132 -0
- package/docs/reference/grid.md +302 -0
- package/docs/reference/heatmap.md +127 -0
- package/docs/reference/histogram.md +77 -0
- package/docs/reference/kpi.md +115 -0
- package/docs/reference/likert.md +113 -0
- package/docs/reference/line.md +436 -0
- package/docs/reference/mekko.md +114 -0
- package/docs/reference/options.md +313 -0
- package/docs/reference/pareto.md +102 -0
- package/docs/reference/pie.md +114 -0
- package/docs/reference/pvm.md +114 -0
- package/docs/reference/pyramid.md +99 -0
- package/docs/reference/react.md +703 -0
- package/docs/reference/reading.md +28 -0
- package/docs/reference/sankey.md +110 -0
- package/docs/reference/scatter.md +211 -0
- package/docs/reference/slope.md +126 -0
- package/docs/reference/sparkline.md +74 -0
- package/docs/reference/status.md +107 -0
- package/docs/reference/table.md +673 -0
- package/docs/reference/theme.md +361 -0
- package/docs/reference/tilemap.md +121 -0
- package/docs/reference/treemap.md +86 -0
- package/docs/reference/variance.md +126 -0
- package/docs/reference/waffle.md +106 -0
- package/docs/reference/waterfall.md +164 -0
- package/llms.txt +57 -0
- package/package.json +437 -4
|
@@ -0,0 +1,2980 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addRatioTierRequests,
|
|
3
|
+
finalizeRatioTier,
|
|
4
|
+
prepareRatioTier,
|
|
5
|
+
ratioTierA11y,
|
|
6
|
+
ratioTierCanRender,
|
|
7
|
+
ratioTierMetrics,
|
|
8
|
+
ratioTierSpacingWarnings
|
|
9
|
+
} from "./chunk-JSX3C6LL.js";
|
|
10
|
+
import {
|
|
11
|
+
BUMP_FOLDED,
|
|
12
|
+
END_LABEL_KEY,
|
|
13
|
+
END_LABEL_WIDE,
|
|
14
|
+
INLINE_FALLBACK,
|
|
15
|
+
PLOT_END_AIR,
|
|
16
|
+
actualHeader,
|
|
17
|
+
backForecastAreaLabels,
|
|
18
|
+
bandHatch,
|
|
19
|
+
buildBumpStartLabels,
|
|
20
|
+
bumpMethodNote,
|
|
21
|
+
defaultValueContent,
|
|
22
|
+
deriveBumpRanks,
|
|
23
|
+
emitForecastDividers,
|
|
24
|
+
endUnitSuffix,
|
|
25
|
+
fanEdgeInKey,
|
|
26
|
+
fanGapNote,
|
|
27
|
+
fillShadingKinds,
|
|
28
|
+
fillShadings,
|
|
29
|
+
fitLineTrends,
|
|
30
|
+
flaggedPoints,
|
|
31
|
+
forecastBoundaries,
|
|
32
|
+
forecastBoundaryX,
|
|
33
|
+
forecastDividerAt,
|
|
34
|
+
gapFillPaint,
|
|
35
|
+
joinTieValues,
|
|
36
|
+
latestRingReach,
|
|
37
|
+
layoutLineMarks,
|
|
38
|
+
lineFocusFont,
|
|
39
|
+
lineLabelModes,
|
|
40
|
+
linePaints,
|
|
41
|
+
lineText,
|
|
42
|
+
lineToDateIds,
|
|
43
|
+
lineTrendKeys,
|
|
44
|
+
lineTrendLabel,
|
|
45
|
+
lineValueStats,
|
|
46
|
+
outerFanEdge,
|
|
47
|
+
placeBumpStartLabels,
|
|
48
|
+
placeBumpTieLabels,
|
|
49
|
+
placeCategoryLabels,
|
|
50
|
+
placeEndpointLabels,
|
|
51
|
+
placeInlineSeriesLabels,
|
|
52
|
+
placePointValueLabels,
|
|
53
|
+
planReferenceBandColumn,
|
|
54
|
+
pointLabelEndRoom,
|
|
55
|
+
pointLabelSelection,
|
|
56
|
+
pointValueWidths,
|
|
57
|
+
prepareBump,
|
|
58
|
+
prepareEndpointLabels,
|
|
59
|
+
rangeCut,
|
|
60
|
+
rangeRuns,
|
|
61
|
+
referenceBandsA11y,
|
|
62
|
+
regroundOnShadings,
|
|
63
|
+
resolveFan,
|
|
64
|
+
resolveGapFillSeries,
|
|
65
|
+
screenEdges,
|
|
66
|
+
seatValuesOnGround,
|
|
67
|
+
shadesFills,
|
|
68
|
+
trendTimeline,
|
|
69
|
+
usesEndLabelKey,
|
|
70
|
+
usesInlineFallback,
|
|
71
|
+
usesWideEndLabels,
|
|
72
|
+
valueUnit,
|
|
73
|
+
withoutEvents
|
|
74
|
+
} from "./chunk-JRPI64AQ.js";
|
|
75
|
+
import {
|
|
76
|
+
anomalyA11y,
|
|
77
|
+
anomalyCorridor,
|
|
78
|
+
anomalyLegendItems,
|
|
79
|
+
anomalyModel,
|
|
80
|
+
anomalyReceipt,
|
|
81
|
+
anomalyRuleLines,
|
|
82
|
+
anomalyRuleReserve,
|
|
83
|
+
columnCorridorPaint,
|
|
84
|
+
lineAnomalyFurniture,
|
|
85
|
+
refuseAnomalySpec,
|
|
86
|
+
seatFlaggedValues
|
|
87
|
+
} from "./chunk-V4DYVLOO.js";
|
|
88
|
+
import {
|
|
89
|
+
applyCategoryViewport,
|
|
90
|
+
liveWindowOptions,
|
|
91
|
+
viewportMeanSpan
|
|
92
|
+
} from "./chunk-EQT3EPTB.js";
|
|
93
|
+
import {
|
|
94
|
+
restValuesHidden
|
|
95
|
+
} from "./chunk-EKQK5D6G.js";
|
|
96
|
+
import {
|
|
97
|
+
cellFields,
|
|
98
|
+
normalizeCategorySeries
|
|
99
|
+
} from "./chunk-QN6JHMGU.js";
|
|
100
|
+
import {
|
|
101
|
+
roundWholes
|
|
102
|
+
} from "./chunk-HAAUJDGB.js";
|
|
103
|
+
import {
|
|
104
|
+
compositionBasis,
|
|
105
|
+
mixedSignsWarning,
|
|
106
|
+
overfullShareSum,
|
|
107
|
+
overfullWarning
|
|
108
|
+
} from "./chunk-TTR7EWNH.js";
|
|
109
|
+
import {
|
|
110
|
+
isIncomplete,
|
|
111
|
+
warnIncompleteComposition,
|
|
112
|
+
warnShareRoundingDrift
|
|
113
|
+
} from "./chunk-7QDAHY5M.js";
|
|
114
|
+
import {
|
|
115
|
+
emitEventLane,
|
|
116
|
+
percentLevels,
|
|
117
|
+
runAnnotatePass,
|
|
118
|
+
settleEventLane
|
|
119
|
+
} from "./chunk-GQS46LC3.js";
|
|
120
|
+
import {
|
|
121
|
+
stepDownFont
|
|
122
|
+
} from "./chunk-EWVKBRLV.js";
|
|
123
|
+
import {
|
|
124
|
+
breakUnsupported,
|
|
125
|
+
chartPalette,
|
|
126
|
+
chartTheme
|
|
127
|
+
} from "./chunk-SXGTRZFN.js";
|
|
128
|
+
import {
|
|
129
|
+
chartString as chartString2,
|
|
130
|
+
nearZeroTailNote
|
|
131
|
+
} from "./chunk-3W23F7EY.js";
|
|
132
|
+
import {
|
|
133
|
+
withEventsDescribed
|
|
134
|
+
} from "./chunk-IN4QT33I.js";
|
|
135
|
+
import {
|
|
136
|
+
categoryBandFromCenters,
|
|
137
|
+
categoryTargetFields,
|
|
138
|
+
spliceAnnotationNodes
|
|
139
|
+
} from "./chunk-CDZHNLO6.js";
|
|
140
|
+
import {
|
|
141
|
+
BAND_PAD,
|
|
142
|
+
GAP_BRACKET_REFUSED,
|
|
143
|
+
GAP_BRACKET_RESERVE,
|
|
144
|
+
VALUE_LINE_RESERVE,
|
|
145
|
+
gapBracketPairs,
|
|
146
|
+
hiddenValueLineReserve
|
|
147
|
+
} from "./chunk-5C7TWNYZ.js";
|
|
148
|
+
import {
|
|
149
|
+
structureCount
|
|
150
|
+
} from "./chunk-B2EBEXIS.js";
|
|
151
|
+
import {
|
|
152
|
+
authoredTimeStep,
|
|
153
|
+
formatTimePattern,
|
|
154
|
+
instantName,
|
|
155
|
+
offsetChanges,
|
|
156
|
+
offsetText,
|
|
157
|
+
resolveTimes,
|
|
158
|
+
timeAnnotationAnchors,
|
|
159
|
+
timeContextRow,
|
|
160
|
+
timeLadder,
|
|
161
|
+
timePrecision,
|
|
162
|
+
timeReadingUnit,
|
|
163
|
+
timeTickText,
|
|
164
|
+
timeTicks,
|
|
165
|
+
zoneClock,
|
|
166
|
+
zoneYearSpan
|
|
167
|
+
} from "./chunk-LC3PSQJJ.js";
|
|
168
|
+
import {
|
|
169
|
+
AXIS_TITLE_GAP,
|
|
170
|
+
NATURAL_BAND_STEP,
|
|
171
|
+
PLOT_FLOOR_RECT,
|
|
172
|
+
applyAxisBounds,
|
|
173
|
+
applyValueAxisTitleInk,
|
|
174
|
+
axisGrid,
|
|
175
|
+
calendarCategories,
|
|
176
|
+
chartSizing,
|
|
177
|
+
contentSized,
|
|
178
|
+
dateTickRow,
|
|
179
|
+
dayCategories,
|
|
180
|
+
furnitureShare,
|
|
181
|
+
heightOmitted,
|
|
182
|
+
linearScale,
|
|
183
|
+
measureValueAxisWidth,
|
|
184
|
+
niceDomain,
|
|
185
|
+
niceStep,
|
|
186
|
+
planCategoryRow,
|
|
187
|
+
planValueAxisTitle,
|
|
188
|
+
plotFloorRows,
|
|
189
|
+
plotFloorShare,
|
|
190
|
+
rotatedLeftOverhang,
|
|
191
|
+
seatRoom,
|
|
192
|
+
tickFormatter,
|
|
193
|
+
valueAxisTitleBand,
|
|
194
|
+
valueAxisTitleText,
|
|
195
|
+
valueAxisUnit
|
|
196
|
+
} from "./chunk-GQPESFAF.js";
|
|
197
|
+
import {
|
|
198
|
+
prepareFractionData
|
|
199
|
+
} from "./chunk-3EZRM4YM.js";
|
|
200
|
+
import {
|
|
201
|
+
HEIGHT_FLOOR_CLASSES,
|
|
202
|
+
NOTED_LABELS,
|
|
203
|
+
PARTIAL_KEY,
|
|
204
|
+
PRIORITY,
|
|
205
|
+
aspectClassFor,
|
|
206
|
+
authoredFootnoteCount,
|
|
207
|
+
authoredNotes,
|
|
208
|
+
categoryLabelsAndMarks,
|
|
209
|
+
computedTextRole,
|
|
210
|
+
createOccupiedIndex,
|
|
211
|
+
defaultAnnotationId,
|
|
212
|
+
frameTextOptions,
|
|
213
|
+
furnitureBudget,
|
|
214
|
+
furnitureScoped,
|
|
215
|
+
labelCtx,
|
|
216
|
+
labelsToNodes,
|
|
217
|
+
leaderPieces,
|
|
218
|
+
moreListedText,
|
|
219
|
+
normalizeLegendOption,
|
|
220
|
+
noteCap,
|
|
221
|
+
omittedKey,
|
|
222
|
+
onLadderStep,
|
|
223
|
+
partialAxisWords,
|
|
224
|
+
partialFootnotes,
|
|
225
|
+
partialIds,
|
|
226
|
+
plotHeightAfter,
|
|
227
|
+
round2,
|
|
228
|
+
saysToDate,
|
|
229
|
+
seatLeader,
|
|
230
|
+
solveFrame,
|
|
231
|
+
solveLabels,
|
|
232
|
+
toDateFits,
|
|
233
|
+
withCategoryNoteNames
|
|
234
|
+
} from "./chunk-2JAWQ7VV.js";
|
|
235
|
+
import {
|
|
236
|
+
disclosureNote,
|
|
237
|
+
disclosuresShown,
|
|
238
|
+
footerType
|
|
239
|
+
} from "./chunk-YTSSXSZR.js";
|
|
240
|
+
import {
|
|
241
|
+
formatStatWithSpec,
|
|
242
|
+
parseISODate,
|
|
243
|
+
seriesRasterFormatter
|
|
244
|
+
} from "./chunk-ASAON7G4.js";
|
|
245
|
+
import {
|
|
246
|
+
autoDecimals,
|
|
247
|
+
chartString,
|
|
248
|
+
formatAuthoredPercent,
|
|
249
|
+
formatAutomaticPercent,
|
|
250
|
+
formatShare,
|
|
251
|
+
notApplicableGlyph,
|
|
252
|
+
numberRange,
|
|
253
|
+
stringFields,
|
|
254
|
+
withLocaleStrings
|
|
255
|
+
} from "./chunk-YQ2B3YVF.js";
|
|
256
|
+
import {
|
|
257
|
+
arrowHeadPath,
|
|
258
|
+
arrowShaftEnd,
|
|
259
|
+
canvasMargin,
|
|
260
|
+
dashToken,
|
|
261
|
+
effectiveFill,
|
|
262
|
+
emphasisWeight,
|
|
263
|
+
resolveTheme,
|
|
264
|
+
secondaryFont,
|
|
265
|
+
seriesTextPaint,
|
|
266
|
+
spaceTokens,
|
|
267
|
+
strokeToken,
|
|
268
|
+
textScaleOf
|
|
269
|
+
} from "./chunk-II7652VA.js";
|
|
270
|
+
import {
|
|
271
|
+
DEFAULT_TARGET,
|
|
272
|
+
NormalizeError,
|
|
273
|
+
TARGET_SIZE,
|
|
274
|
+
accessibleTitle,
|
|
275
|
+
normalizeScenario,
|
|
276
|
+
resolveHighlight,
|
|
277
|
+
resolveSize,
|
|
278
|
+
targetFloorsPx
|
|
279
|
+
} from "./chunk-SGD3ZHID.js";
|
|
280
|
+
import {
|
|
281
|
+
maxOf,
|
|
282
|
+
minOf,
|
|
283
|
+
pushAll
|
|
284
|
+
} from "./chunk-WYJEOMNY.js";
|
|
285
|
+
import {
|
|
286
|
+
defaultMeasurer,
|
|
287
|
+
wrapText
|
|
288
|
+
} from "./chunk-TXINIAFL.js";
|
|
289
|
+
|
|
290
|
+
// src/core/annotateGapBracket.ts
|
|
291
|
+
var RING = 4, ARROW = 5, GAP = 6, CAPTION_SHARE = 0.16;
|
|
292
|
+
function gapBracketApplies(frame, ann, a, b) {
|
|
293
|
+
if (!frame || frame.unavailable || ann.placement === "label" || !b) return !1;
|
|
294
|
+
let [sa, sb] = [a.owner.seriesId, b.owner.seriesId];
|
|
295
|
+
return a.owner.categoryId === frame.categoryId && b.owner.categoryId === frame.categoryId && sa !== void 0 && sb !== void 0 && sa !== sb && Math.abs(a.y - b.y) >= 1 && (ann.placement === "bracket" || frame.washed?.includes(sa) === !0 && frame.washed.includes(sb));
|
|
296
|
+
}
|
|
297
|
+
function planGapBracket(pass, frame, tail, head, text, computed, caption, id, kind, derivation) {
|
|
298
|
+
let { input } = pass, { type } = input.theme, numberFont = { family: type.figure?.family ?? type.family, ...type.title, weight: type.figure?.weight ?? emphasisWeight(input.theme) }, captionFont = { family: type.family, ...type.axis }, number = input.measure(text, numberFont), spine = frame.spine - ARROW, numberX = spine - GAP - number.width, top = Math.min(tail.y, head.y), bottom = Math.max(tail.y, head.y), mid = (top + bottom) / 2, owner = { annotationId: id }, labelId = `annotation:${id}`, priority = pass.priority ?? PRIORITY.valueLine, fits2 = number.height <= bottom - top - 2, numberSeat = (y) => ({ x: numberX, y, w: number.width, h: number.height }), seats = fits2 ? [numberSeat(mid - number.height / 2), numberSeat(bottom + 3)] : [numberSeat(bottom + 3)];
|
|
299
|
+
pass.labelRequests.push({
|
|
300
|
+
id: labelId,
|
|
301
|
+
kind: "annotation",
|
|
302
|
+
role: computedTextRole(text, computed),
|
|
303
|
+
owner,
|
|
304
|
+
text,
|
|
305
|
+
lines: [text],
|
|
306
|
+
font: numberFont,
|
|
307
|
+
priority,
|
|
308
|
+
candidates: seats.map((rect, i) => ({ slot: i === 0 && fits2 ? "bracketMid" : "bracketBelow", rect, penalty: i }))
|
|
309
|
+
});
|
|
310
|
+
let columnLeft = numberX, columnBottom = bottom + number.height + 3, captionId;
|
|
311
|
+
if (caption) {
|
|
312
|
+
let longest = Math.max(...caption.split(/\s+/).map((word) => input.measure(word, captionFont).width)), width = Math.max(number.width + GAP, longest, Math.round(frame.width * CAPTION_SHARE)), lines = wrapText(caption, captionFont, width, 8, input.measure).lines, lineH = input.measure("X", captionFont).height, w = Math.max(...lines.map((line) => input.measure(line, captionFont).width)), x = spine - w;
|
|
313
|
+
columnLeft = Math.min(columnLeft, x), columnBottom = bottom + number.height + 6 + lineH * lines.length, captionId = `${labelId}:caption`;
|
|
314
|
+
let under = (y) => ({ x, y, w, h: lineH * lines.length });
|
|
315
|
+
pass.labelRequests.push({
|
|
316
|
+
id: captionId,
|
|
317
|
+
kind: "annotation",
|
|
318
|
+
role: "note",
|
|
319
|
+
owner,
|
|
320
|
+
text: lines.join(" "),
|
|
321
|
+
lines,
|
|
322
|
+
font: captionFont,
|
|
323
|
+
align: "end",
|
|
324
|
+
priority: priority - 1,
|
|
325
|
+
candidates: [
|
|
326
|
+
...fits2 ? [{ slot: "bracketCaption", rect: under(Math.max(bottom, mid + number.height / 2) + 4), penalty: 0 }] : [],
|
|
327
|
+
{ slot: "bracketCaptionLow", rect: under(bottom + number.height + 6), penalty: 1 }
|
|
328
|
+
]
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
let reach = input.occupied.hitsWhich(
|
|
332
|
+
{ x: head.x, y: top - number.height, w: spine - head.x, h: columnBottom - top + number.height },
|
|
333
|
+
0,
|
|
334
|
+
(claim) => claim.kind !== "label" || claim.owner.seriesId === void 0 || claim.rect.x + claim.rect.w <= head.x + 1
|
|
335
|
+
).reduce((right, claim) => Math.max(right, claim.rect.x + claim.rect.w), head.x + RING), need = Math.max(0, reach + 2 * GAP - columnLeft);
|
|
336
|
+
for (let end of [tail, head]) input.occupied.claim({ x: end.x - RING, y: end.y - RING, w: 2 * RING, h: 2 * RING }, "annotation", owner, "gapRing");
|
|
337
|
+
input.occupied.claim({ x: spine - 1, y: top - 1, w: ARROW + 2, h: bottom - top + 2 }, "annotation", owner, "bracket");
|
|
338
|
+
let base = `ann:${id}`, nodeIds = [], add = (node) => {
|
|
339
|
+
pass.nodes.push(node), nodeIds.push(node.id);
|
|
340
|
+
};
|
|
341
|
+
for (let [i, end] of [tail, head].entries())
|
|
342
|
+
add({ t: "line", id: `${base}:guide${i}`, x1: end.x + RING, y1: end.y, x2: spine, y2: end.y, stroke: { token: "leader" }, width: strokeToken(input.theme, "rule"), dash: dashToken(input.theme, "reference"), owner, part: "leader" });
|
|
343
|
+
let up = head.y < tail.y ? -1 : 1;
|
|
344
|
+
add({ t: "path", id: `${base}:bracket`, d: `M${spine} ${tail.y}L${spine} ${head.y - up * arrowShaftEnd(ARROW, strokeToken(input.theme, "rule"))}`, stroke: { token: "ink" }, width: strokeToken(input.theme, "rule"), owner, part: "bracket" }), add({ t: "path", id: `${base}:bracketHead`, d: arrowHeadPath({ x: spine, y: head.y }, up * Math.PI / 2, ARROW), fill: { token: "ink" }, owner, part: "arrowHead" });
|
|
345
|
+
for (let [i, end] of [tail, head].entries())
|
|
346
|
+
add({ t: "circle", id: `${base}:ring${i}`, cx: end.x, cy: end.y, r: RING, fill: { token: "background" }, stroke: { token: "ink" }, strokeWidth: strokeToken(input.theme, "mark"), owner, part: "gapRing" });
|
|
347
|
+
let annotation = { id, kind, computedText: computed, nodeIds, labelId, derivation };
|
|
348
|
+
return pass.placed.push(annotation), { annotation, need, ...captionId ? { captionId } : {} };
|
|
349
|
+
}
|
|
350
|
+
function finishGapBrackets(plans, labels) {
|
|
351
|
+
for (let { annotation, captionId } of plans) {
|
|
352
|
+
let caption = captionId ? labels.find((label) => label.id === captionId) : void 0;
|
|
353
|
+
caption && (labels.find((label) => label.id === annotation.labelId)?.hidden ? caption.hidden = "collision" : caption.hidden || (caption.ink = { token: "inkMuted" }));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
var gapBracketEngine = { applies: gapBracketApplies, plan: planGapBracket, finish: finishGapBrackets };
|
|
357
|
+
|
|
358
|
+
// src/core/charts/line/continuous.ts
|
|
359
|
+
var lowered = /* @__PURE__ */ new WeakMap(), LOWERED = /* @__PURE__ */ Symbol("lineX"), UNMATCHED_PARTIAL = /* @__PURE__ */ Symbol("lineXUnmatchedPartial");
|
|
360
|
+
function unmatchedPartial(data) {
|
|
361
|
+
return data[UNMATCHED_PARTIAL] ?? [];
|
|
362
|
+
}
|
|
363
|
+
function xId(type, x) {
|
|
364
|
+
return type === "time" ? new Date(x).toISOString() : String(x === 0 ? 0 : x);
|
|
365
|
+
}
|
|
366
|
+
function readNumber(value, path) {
|
|
367
|
+
let x = typeof value == "number" ? value : typeof value == "string" && value.trim() !== "" ? Number(value) : Number.NaN;
|
|
368
|
+
if (!Number.isFinite(x)) throw new NormalizeError("x-invalid", path, `x value ${JSON.stringify(value)} is not a finite number`, "give plain numbers on xAxis.type 'number'");
|
|
369
|
+
return x;
|
|
370
|
+
}
|
|
371
|
+
function lineXModel(options, cats) {
|
|
372
|
+
let axis = options.xAxis;
|
|
373
|
+
if (!axis) return;
|
|
374
|
+
let type = axis.type, clock = type === "time" ? zoneClock(axis.zone) : void 0, xs = cats ? cats.map((c) => type === "time" ? Date.parse(c.id) : Number(c.id)) : [], language = options.locale?.language, precision = clock ? timePrecision(xs, clock) : void 0, numberName = type === "number" ? seriesRasterFormatter(axis.format, xs, language).fmt : void 0;
|
|
375
|
+
return {
|
|
376
|
+
axis,
|
|
377
|
+
type,
|
|
378
|
+
clock,
|
|
379
|
+
xs,
|
|
380
|
+
precision,
|
|
381
|
+
language,
|
|
382
|
+
read: (value, path) => clock ? resolveTimes([value], clock, () => path)[0] : readNumber(value, path),
|
|
383
|
+
name: (x) => clock ? instantName(x, clock, precision, language) : numberName(x)
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function lowerLineX(data, options) {
|
|
387
|
+
if (data.x === void 0) {
|
|
388
|
+
if (options?.xAxis && !(LOWERED in data))
|
|
389
|
+
throw new NormalizeError(
|
|
390
|
+
"x-axis-needs-x",
|
|
391
|
+
"options.xAxis",
|
|
392
|
+
"xAxis places readings by value, and the data gives categories, which are ordered names; a continuous axis reads its readings from data.x",
|
|
393
|
+
"move the x values from data.categories to data.x, or drop xAxis for a category axis"
|
|
394
|
+
);
|
|
395
|
+
return data;
|
|
396
|
+
}
|
|
397
|
+
let axis = options?.xAxis;
|
|
398
|
+
if (!axis)
|
|
399
|
+
throw new NormalizeError(
|
|
400
|
+
"x-needs-axis",
|
|
401
|
+
"data.x",
|
|
402
|
+
"data.x gives continuous x values, and nothing says whether they are times or numbers",
|
|
403
|
+
"add options.xAxis: { type: 'time' } (with zone, such as 'Europe/Berlin') or { type: 'number' }",
|
|
404
|
+
[{ op: "add", path: "/options/xAxis", value: { type: "time" } }]
|
|
405
|
+
);
|
|
406
|
+
let key = JSON.stringify([axis.type, axis.zone ?? null, axis.format ?? null, options?.locale?.language ?? null]), cached = lowered.get(data);
|
|
407
|
+
if (cached?.key === key) return cached.data;
|
|
408
|
+
let clock = axis.type === "time" ? zoneClock(axis.zone) : void 0, xs = clock ? resolveTimes(data.x, clock, (i) => `data.x[${i}]`) : data.x.map((value, i) => readNumber(value, `data.x[${i}]`)), order = xs.map((_, i) => i).sort((a, b) => xs[a] - xs[b] || a - b);
|
|
409
|
+
for (let k = 1; k < order.length; k++)
|
|
410
|
+
if (xs[order[k]] === xs[order[k - 1]]) {
|
|
411
|
+
let a = Math.min(order[k - 1], order[k]), b = Math.max(order[k - 1], order[k]);
|
|
412
|
+
throw new NormalizeError(
|
|
413
|
+
"x-duplicate",
|
|
414
|
+
`data.x[${b}]`,
|
|
415
|
+
`data.x[${a}] and data.x[${b}] are the same x (${JSON.stringify(data.x[a])}, ${JSON.stringify(data.x[b])}); one x holds one reading per series`,
|
|
416
|
+
"drop or merge the repeated reading upstream"
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
data.series.forEach((series, si) => {
|
|
420
|
+
let values = series.values;
|
|
421
|
+
if (!Array.isArray(values) || values.length !== xs.length)
|
|
422
|
+
throw new NormalizeError(
|
|
423
|
+
"x-values-length",
|
|
424
|
+
`series[${series.id ?? si}].values`,
|
|
425
|
+
`series '${series.id}' has ${Array.isArray(values) ? values.length : 0} values for ${xs.length} x values; on a continuous axis each series gives one value per x, in the order of data.x`,
|
|
426
|
+
"give a value, or null for a missing reading, at every x"
|
|
427
|
+
);
|
|
428
|
+
values.forEach((value, vi) => {
|
|
429
|
+
if (typeof value == "object" && value !== null && "categoryId" in value)
|
|
430
|
+
throw new NormalizeError("x-values-keyed", `series[${series.id}].values[${vi}]`, "a keyed { categoryId, value } entry has no category to name on a continuous axis", "give the values in the order of data.x, with null where a series has no reading");
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
let sortedXs = order.map((i) => xs[i]), model = lineXModel({ xAxis: axis, locale: options?.locale }, void 0), precision = clock ? timePrecision(sortedXs, clock) : void 0, numberName = clock ? void 0 : seriesRasterFormatter(axis.format, sortedXs, options?.locale?.language).fmt, partial = /* @__PURE__ */ new Set(), unmatched = [];
|
|
434
|
+
data.partial?.forEach((value, i) => {
|
|
435
|
+
let x = model.read(value, `data.partial[${i}]`);
|
|
436
|
+
sortedXs.includes(x) ? partial.add(x) : unmatched.push(value);
|
|
437
|
+
});
|
|
438
|
+
let categories = sortedXs.map((x) => ({
|
|
439
|
+
id: xId(axis.type, x),
|
|
440
|
+
label: clock ? instantName(x, clock, precision, model.language) : numberName(x),
|
|
441
|
+
...partial.has(x) ? { partial: !0 } : {}
|
|
442
|
+
})), result = {
|
|
443
|
+
[LOWERED]: !0,
|
|
444
|
+
...unmatched.length ? { [UNMATCHED_PARTIAL]: unmatched } : {},
|
|
445
|
+
...data.valueKind ? { valueKind: data.valueKind } : {},
|
|
446
|
+
categories,
|
|
447
|
+
series: data.series.map((series, si) => ({
|
|
448
|
+
...series,
|
|
449
|
+
values: order.map((i) => series.values[i]),
|
|
450
|
+
// A series target names the x of one of its readings.
|
|
451
|
+
...series.targets ? { targets: series.targets.map((target, ti) => {
|
|
452
|
+
let path = `series[${series.id ?? si}].targets[${ti}].at`, x = model.read(target.at, path);
|
|
453
|
+
if (!sortedXs.includes(x)) throw new NormalizeError("x-anchor-no-reading", path, `target at ${JSON.stringify(target.at)} names an x with no reading`, "name the x of a reading exactly, as data.x gives it");
|
|
454
|
+
return { ...target, at: xId(axis.type, x) };
|
|
455
|
+
}) } : {}
|
|
456
|
+
}))
|
|
457
|
+
};
|
|
458
|
+
return lowered.set(data, { key, data: result }), result;
|
|
459
|
+
}
|
|
460
|
+
function resolveLineXOptions(options, model, cats, warnings) {
|
|
461
|
+
if (options.variant === "bump")
|
|
462
|
+
throw new NormalizeError(
|
|
463
|
+
"x-axis-unsupported",
|
|
464
|
+
"options.xAxis",
|
|
465
|
+
"variant 'bump' ranks the series at each category, and a continuous axis has readings at any x, not shared periods",
|
|
466
|
+
"drop xAxis and give the periods as data.categories, or draw the values with variant 'line'"
|
|
467
|
+
);
|
|
468
|
+
if (options.categoryAxis !== void 0)
|
|
469
|
+
throw new NormalizeError(
|
|
470
|
+
"x-axis-conflict",
|
|
471
|
+
"options.categoryAxis",
|
|
472
|
+
"categoryAxis sets a category row, and xAxis replaces that row with a continuous scale",
|
|
473
|
+
"drop categoryAxis; set ticks with xAxis.tickStep or xAxis.ticks",
|
|
474
|
+
[{ op: "remove", path: "/options/categoryAxis" }]
|
|
475
|
+
);
|
|
476
|
+
let xs = model.xs, ids = cats.map((c) => c.id), idSet = new Set(ids), byX = new Map(xs.map((x, i) => [x, ids[i]])), nearest = (x) => {
|
|
477
|
+
let k = 0;
|
|
478
|
+
for (; k < xs.length - 1 && xs[k + 1] <= x; ) k++;
|
|
479
|
+
return [.../* @__PURE__ */ new Set([cats[k], cats[Math.min(xs.length - 1, k + 1)]])].map((c) => `'${c.label ?? c.id}'`).join(" and ");
|
|
480
|
+
}, readingAt = (value, path) => typeof value == "string" && idSet.has(value) ? value : byX.get(model.read(value, path)), exact = (value, path, what) => {
|
|
481
|
+
let id = readingAt(value, path);
|
|
482
|
+
if (id !== void 0) return id;
|
|
483
|
+
throw new NormalizeError(
|
|
484
|
+
"x-anchor-no-reading",
|
|
485
|
+
path,
|
|
486
|
+
`${what} names x ${JSON.stringify(value)}, where no series has a reading; the nearest readings are ${nearest(model.read(value, path))}`,
|
|
487
|
+
"name the x of a reading exactly, as data.x gives it"
|
|
488
|
+
);
|
|
489
|
+
}, anchor = (value, path, what) => value === void 0 ? value : typeof value == "string" || typeof value == "number" ? exact(value, path, what) : typeof value == "object" && value.categoryId !== void 0 ? { ...value, categoryId: exact(value.categoryId, `${path}.categoryId`, what) } : value, bandEnds = /* @__PURE__ */ new Map(), authored = options.annotations?.flatMap((raw, index) => {
|
|
490
|
+
let a = model.clock ? timeAnnotationAnchors(raw) : raw, path = (key) => `options.annotations[${index}].${key}`, what = `annotation '${a.id ?? `${a.kind}-${index + 1}`}'`;
|
|
491
|
+
switch (a.kind) {
|
|
492
|
+
case "cagr":
|
|
493
|
+
return model.clock ? [{ ...a, ...a.from === void 0 ? {} : { from: anchor(a.from, path("from"), what) }, ...a.to === void 0 ? {} : { to: anchor(a.to, path("to"), what) } }] : (warnings.push({
|
|
494
|
+
code: "x-cagr-unsupported",
|
|
495
|
+
severity: "warn",
|
|
496
|
+
field: ["options", "annotations", index],
|
|
497
|
+
message: `${what}: a CAGR is a rate per year, and a number axis has no years, so it is not drawn`,
|
|
498
|
+
suggest: "use a 'diff' annotation between two readings for the change over the range"
|
|
499
|
+
}), []);
|
|
500
|
+
case "diff":
|
|
501
|
+
return [{ ...a, from: anchor(a.from, path("from"), what), to: anchor(a.to, path("to"), what) }];
|
|
502
|
+
case "delta":
|
|
503
|
+
return [{ ...a, at: anchor(a.at, path("at"), what), ...typeof a.vs == "number" ? {} : { vs: anchor(a.vs, path("vs"), what) } }];
|
|
504
|
+
case "abs":
|
|
505
|
+
case "note":
|
|
506
|
+
case "callout":
|
|
507
|
+
return [{ ...a, at: anchor(a.at, path("at"), what) }];
|
|
508
|
+
case "valueLine":
|
|
509
|
+
return [{ ...a, ...a.from === void 0 ? {} : { from: exact(a.from, path("from"), what) }, ...a.to === void 0 ? {} : { to: exact(a.to, path("to"), what) } }];
|
|
510
|
+
case "band": {
|
|
511
|
+
if (a.from === void 0 && a.to === void 0) return [a];
|
|
512
|
+
let band = { ...a };
|
|
513
|
+
return bandEnds.set(band, ["from", "to"].flatMap((key) => a[key] === void 0 ? [] : [model.read(a[key], path(key))])), [band];
|
|
514
|
+
}
|
|
515
|
+
case "event": {
|
|
516
|
+
if (a.at === void 0) return [a];
|
|
517
|
+
let at = typeof a.at == "object" ? a.at.categoryId : a.at, { at: _at, to, ...rest2 } = a;
|
|
518
|
+
return [{ ...rest2, date: String(at), ...to === void 0 ? {} : { end: String(to) } }];
|
|
519
|
+
}
|
|
520
|
+
default:
|
|
521
|
+
return [a];
|
|
522
|
+
}
|
|
523
|
+
}), targets = options.targets?.map((target, i) => ({ ...target, at: exact(target.at, `options.targets[${i}].at`, `target '${target.seriesId}'`) })), rebase100 = typeof options.rebase100 == "object" ? { ...options.rebase100, at: exact(options.rebase100.at, "options.rebase100.at", "rebase100") } : options.rebase100, phases = options.phases?.map((phase, i) => ({ ...phase, from: exact(phase.from, `options.phases[${i}].from`, `phase '${phase.id}'`), to: exact(phase.to, `options.phases[${i}].to`, `phase '${phase.id}'`) })), first = xs[0], last = xs[xs.length - 1], view = options.viewDomain?.x, lo = view ? model.read(view[0], "options.viewDomain.x[0]") : options.xAxis?.min !== void 0 ? model.read(options.xAxis.min, "options.xAxis.min") : first, hi = view ? model.read(view[1], "options.viewDomain.x[1]") : options.xAxis?.max !== void 0 ? model.read(options.xAxis.max, "options.xAxis.max") : last;
|
|
524
|
+
lo > hi && ([lo, hi] = [hi, lo]);
|
|
525
|
+
let inside = xs.flatMap((x, i) => x >= lo && x <= hi ? [i] : []);
|
|
526
|
+
if (inside.length === 0)
|
|
527
|
+
throw new NormalizeError(
|
|
528
|
+
"x-range-empty",
|
|
529
|
+
view ? "options.viewDomain.x" : "options.xAxis",
|
|
530
|
+
`no reading lies inside the x range ${model.name(lo)} to ${model.name(hi)}; the readings run from ${cats[0].label} to ${cats[cats.length - 1].label}`,
|
|
531
|
+
"widen the range, or drop xAxis.min and xAxis.max"
|
|
532
|
+
);
|
|
533
|
+
let annotations = authored?.filter((a) => {
|
|
534
|
+
let ends = bandEnds.get(a);
|
|
535
|
+
return !ends || !ends.every((x) => x < lo) && !ends.every((x) => x > hi);
|
|
536
|
+
}), cut = inside.length < xs.length;
|
|
537
|
+
if (cut && !view && warnings.push({
|
|
538
|
+
code: "x-range-cut",
|
|
539
|
+
severity: "info",
|
|
540
|
+
field: ["options", "xAxis"],
|
|
541
|
+
message: `${xs.length - inside.length} of ${xs.length} readings lie outside xAxis.min and xAxis.max and are not drawn`,
|
|
542
|
+
suggest: "widen xAxis.min and xAxis.max to draw every reading"
|
|
543
|
+
}), lo === hi) {
|
|
544
|
+
let pad = model.clock ? 36e5 : Math.abs(lo) / 10 || 1;
|
|
545
|
+
lo -= pad, hi += pad;
|
|
546
|
+
}
|
|
547
|
+
let { viewDomain: _view, ...rest } = options;
|
|
548
|
+
return {
|
|
549
|
+
options: {
|
|
550
|
+
...rest,
|
|
551
|
+
...cut ? { viewDomain: { x: [ids[inside[0]], ids[inside[inside.length - 1]]] } } : {},
|
|
552
|
+
...annotations ? { annotations } : {},
|
|
553
|
+
...targets ? { targets } : {},
|
|
554
|
+
...rebase100 !== void 0 ? { rebase100 } : {},
|
|
555
|
+
...phases ? { phases } : {}
|
|
556
|
+
},
|
|
557
|
+
lo,
|
|
558
|
+
hi
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
var DAY_ONLY = /^\s*(\d{4})-(\d{2})-(\d{2})\s*$/;
|
|
562
|
+
function laneScale(x) {
|
|
563
|
+
let { model, lo, hi } = x, clock = model.clock;
|
|
564
|
+
return {
|
|
565
|
+
lo,
|
|
566
|
+
hi,
|
|
567
|
+
read: (text, path, end) => {
|
|
568
|
+
let day = end && clock ? DAY_ONLY.exec(text) : null;
|
|
569
|
+
return day ? model.read(new Date(Date.UTC(Number(day[1]), Number(day[2]) - 1, Number(day[3]) + 1)).toISOString().slice(0, 10), path) : model.read(text, path);
|
|
570
|
+
},
|
|
571
|
+
short: (v) => clock ? formatTimePattern(v, clock, formatTimePattern(v, clock, "HH:mm") === "00:00" ? "d MMM" : "d MMM, HH:mm", model.language) : model.name(v),
|
|
572
|
+
full: (v) => model.name(v)
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// src/core/charts/line/live.ts
|
|
577
|
+
function projectLineViewport(input) {
|
|
578
|
+
let { indexes, categories, bump, fan, phases } = input, visible = new Set(indexes.map((index) => categories[index].id));
|
|
579
|
+
if (bump) {
|
|
580
|
+
for (let [id, row] of Object.entries(bump.ranks)) bump.ranks[id] = indexes.map((index) => row[index]);
|
|
581
|
+
bump.ties = bump.ties.filter((tie) => visible.has(tie.categoryId)), bump.participants = Object.fromEntries(Object.entries(bump.participants).filter(([id]) => visible.has(id)));
|
|
582
|
+
}
|
|
583
|
+
if (fan) {
|
|
584
|
+
for (let band of fan.bands) band.widths = indexes.map((index) => band.widths[index]);
|
|
585
|
+
fan.undeclaredAt = fan.undeclaredAt.filter((id) => visible.has(id));
|
|
586
|
+
}
|
|
587
|
+
if (phases) {
|
|
588
|
+
let sourceIndex = new Map(categories.map((category, index) => [category.id, index]));
|
|
589
|
+
phases.authored = phases.phases, phases.phases = phases.phases.flatMap((phase, index) => {
|
|
590
|
+
let from = sourceIndex.get(phase.from), to = sourceIndex.get(phase.to), kept = indexes.filter((at) => at >= from && at <= to);
|
|
591
|
+
return kept.length ? [{
|
|
592
|
+
...phase,
|
|
593
|
+
rank: phase.rank ?? index + 1,
|
|
594
|
+
from: categories[kept[0]].id,
|
|
595
|
+
to: categories[kept[kept.length - 1]].id
|
|
596
|
+
}] : [];
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function liveCategoryX(ci, count, between, plot, window) {
|
|
601
|
+
let n = window?.span ?? count, at = window?.positions[ci] ?? ci, step = between ? plot.w / n : n > 1 ? plot.w / (n - 1) : plot.w;
|
|
602
|
+
return between ? plot.x + (at + 0.5) * step : n > 1 ? plot.x + at * step : plot.x + plot.w / 2;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// src/core/charts/line/domain.ts
|
|
606
|
+
var DOMAIN_ECONOMY_FRACTION = 0.15;
|
|
607
|
+
function rebaseAtId(rebase100, cats) {
|
|
608
|
+
return typeof rebase100 == "object" ? rebase100.at : cats[0].id;
|
|
609
|
+
}
|
|
610
|
+
function resolveLineEnv(options, warnings) {
|
|
611
|
+
let isBump = options.variant === "bump";
|
|
612
|
+
breakUnsupported("line", options, warnings);
|
|
613
|
+
let theme = chartTheme(options), paletteRamp = chartPalette(theme, options.palette, warnings), highlights = new Set(resolveHighlight(options.highlight));
|
|
614
|
+
return {
|
|
615
|
+
isBump,
|
|
616
|
+
theme,
|
|
617
|
+
paletteRamp,
|
|
618
|
+
size: resolveSize(options.size),
|
|
619
|
+
measure: options.measure ?? defaultMeasurer,
|
|
620
|
+
pctFmt: (p) => formatShare(p, options.locale?.language),
|
|
621
|
+
authoredPctFmt: (p) => formatAuthoredPercent(p, options.locale?.language),
|
|
622
|
+
highlights,
|
|
623
|
+
anyHighlight: highlights.size > 0,
|
|
624
|
+
density: options.labelDensity ?? "smart"
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function normalizeLineData(data) {
|
|
628
|
+
let { cats, series } = normalizeCategorySeries("line", data, (s, cells) => ({
|
|
629
|
+
id: s.id,
|
|
630
|
+
label: s.label ?? s.id,
|
|
631
|
+
shortLabel: s.shortLabel,
|
|
632
|
+
role: s.role ?? "data",
|
|
633
|
+
scenario: normalizeScenario(s.scenario, `series[${s.id}].scenario`),
|
|
634
|
+
colorRole: s.colorRole,
|
|
635
|
+
fill: s.fill,
|
|
636
|
+
lineStyle: s.lineStyle,
|
|
637
|
+
marker: s.marker,
|
|
638
|
+
smooth: s.smooth,
|
|
639
|
+
interpolateGaps: s.interpolateGaps ?? !1,
|
|
640
|
+
targets: s.targets ?? [],
|
|
641
|
+
format: s.format,
|
|
642
|
+
unit: s.unit,
|
|
643
|
+
vals: cells.map((cell, ci) => cellFields(cell, `series[${s.id}].values[${ci}]`))
|
|
644
|
+
}));
|
|
645
|
+
return { cats, seriesNorm: series };
|
|
646
|
+
}
|
|
647
|
+
var YEAR_LABEL = /^(?:FY\s?)?(\d{4})\s?[A-Z]{0,2}$/;
|
|
648
|
+
function categoryTimeline(cats) {
|
|
649
|
+
let dated = cats.every((c) => c.date !== void 0), times = cats.map((c) => {
|
|
650
|
+
if (dated) return parseISODate(c.date)?.getTime() ?? null;
|
|
651
|
+
let year = YEAR_LABEL.exec((c.label ?? c.id).trim());
|
|
652
|
+
return year ? Number(year[1]) : null;
|
|
653
|
+
});
|
|
654
|
+
if (times.length < 3 || times.some((t) => t === null)) return;
|
|
655
|
+
let gaps = times.slice(1).map((t, i) => t - times[i]);
|
|
656
|
+
if (gaps.some((gap) => gap <= 0)) return;
|
|
657
|
+
let unit = minOf(gaps);
|
|
658
|
+
if (maxOf(gaps) / unit <= 1.5) return;
|
|
659
|
+
let positions = times.map((t) => (t - times[0]) / unit);
|
|
660
|
+
return { positions, span: positions[positions.length - 1] + 1 };
|
|
661
|
+
}
|
|
662
|
+
var AUTO_DECIMATE_MIN = 2e3;
|
|
663
|
+
function lineWindow(options, cats, variant, isBump, fan, width, warnings, continuous = !1) {
|
|
664
|
+
let authored = options.window;
|
|
665
|
+
if (authored?.decimate === "none") return authored.last === void 0 ? {} : { window: { last: authored.last } };
|
|
666
|
+
if (authored || options.viewDomain || isBump || fan) return { window: authored };
|
|
667
|
+
let budget = Math.max(AUTO_DECIMATE_MIN, 4 * Math.round(width));
|
|
668
|
+
if (cats.length <= budget || !continuous && (categoryTimeline(cats) || !datesIncrease(cats))) return {};
|
|
669
|
+
let maxPoints = 2 * Math.round(width);
|
|
670
|
+
return warnings.push({
|
|
671
|
+
code: "line-decimated",
|
|
672
|
+
severity: "info",
|
|
673
|
+
message: `${cats.length} categories exceed the point budget (${budget}): the ${variant === "line" ? "line" : "area"} keeps each series' minimum and maximum in ${maxPoints / 2} buckets, so dropped periods have no point, hover value or label, and a segment may join periods that are not neighbours`,
|
|
674
|
+
suggest: "set window: { decimate: 'none' } to draw every point, or aggregate the periods (weeks, months)"
|
|
675
|
+
}), { window: { decimate: "minmax", maxPoints }, ...continuous ? {} : { anchors: calendarStarts(cats, maxPoints) }, auto: !0 };
|
|
676
|
+
}
|
|
677
|
+
function valueTimeline(model, range, population, cats) {
|
|
678
|
+
let width = range.hi - range.lo;
|
|
679
|
+
return { positions: (population ? population.indexes.map((i) => model.xs[i]) : cats.map((_, i) => model.xs[i])).map((x) => (x - range.lo) / width), span: 2 };
|
|
680
|
+
}
|
|
681
|
+
function datesIncrease(cats) {
|
|
682
|
+
let previous;
|
|
683
|
+
for (let { date } of cats)
|
|
684
|
+
if (date !== void 0) {
|
|
685
|
+
if (previous !== void 0 && date <= previous) return !1;
|
|
686
|
+
previous = date;
|
|
687
|
+
}
|
|
688
|
+
return !0;
|
|
689
|
+
}
|
|
690
|
+
function calendarStarts(cats, limit) {
|
|
691
|
+
let isoOf = (c) => c.date ?? (/^\d{4}-\d{2}/.test(c.id) ? c.id : void 0);
|
|
692
|
+
if (cats.every((c) => isoOf(c) !== void 0))
|
|
693
|
+
for (let length of [7, 4]) {
|
|
694
|
+
let starts = [], previous;
|
|
695
|
+
for (let c of cats) {
|
|
696
|
+
let key = isoOf(c).slice(0, length);
|
|
697
|
+
key !== previous && starts.push(c.id), previous = key;
|
|
698
|
+
}
|
|
699
|
+
if (starts.length <= limit) return starts;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function collectTargets(seriesNorm, cats, options, warnings) {
|
|
703
|
+
let categoryIds = new Set(cats.map((category) => category.id)), seriesIds = new Set(seriesNorm.map((series) => series.id)), targets = [], targetSeq = 0, addTarget = (target) => {
|
|
704
|
+
let id = `target:${target.seriesId}:${target.at}:${targetSeq++}`, owner = { seriesId: target.seriesId, categoryId: target.at };
|
|
705
|
+
if (!seriesIds.has(target.seriesId)) {
|
|
706
|
+
warnings.push({ code: "target-unknown-series", severity: "error", message: `target '${id}' names unknown series '${target.seriesId}'`, owner });
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (!categoryIds.has(target.at)) {
|
|
710
|
+
warnings.push({ code: "target-unknown-category", severity: "error", message: `target '${id}' names unknown category '${target.at}'`, owner });
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
if (!Number.isFinite(target.value)) {
|
|
714
|
+
warnings.push({ code: "target-invalid-value", severity: "error", message: `target '${id}' requires a finite value`, owner });
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
targets.push({ ...target, id });
|
|
718
|
+
};
|
|
719
|
+
return seriesNorm.forEach((series) => {
|
|
720
|
+
series.targets.forEach((target) => addTarget({ ...target, seriesId: series.id }));
|
|
721
|
+
}), (options.targets ?? []).forEach(addTarget), targets;
|
|
722
|
+
}
|
|
723
|
+
function lineVariant(options, isBump, seriesNorm, warnings) {
|
|
724
|
+
let variant = isBump ? "line" : options.variant ?? "line";
|
|
725
|
+
if ((options.valueAxis ?? {}).percent) {
|
|
726
|
+
if (isBump)
|
|
727
|
+
throw new NormalizeError(
|
|
728
|
+
"bump-variant-conflict",
|
|
729
|
+
"valueAxis.percent",
|
|
730
|
+
"variant 'bump' plots derived ranks; valueAxis.percent promotes the chart to a 100% area composition, which ranks cannot form \u2014 drop one of the two"
|
|
731
|
+
);
|
|
732
|
+
variant !== "stacked100-area" && warnings.push({
|
|
733
|
+
code: "percent-axis-stacks-area",
|
|
734
|
+
severity: "warn",
|
|
735
|
+
message: `valueAxis.percent draws a 100% stacked area: each series becomes its share of the category sum, not its own value (variant '${variant}' ignored)`,
|
|
736
|
+
suggest: "For percent-formatted lines, remove valueAxis.percent and set data.valueKind: 'fraction' for fraction values, or a percent format such as '0%' for values already in percent. For a 100% composition, set variant: 'stacked100-area'."
|
|
737
|
+
}), variant = "stacked100-area";
|
|
738
|
+
}
|
|
739
|
+
let isStacked = variant === "stacked-area" || variant === "stacked100-area", chartInterpolation = options.interpolate ?? "linear", requestedInterpolationFor = (series) => series.smooth === !0 ? "monotone" : series.smooth === !1 ? "linear" : chartInterpolation, interpolationFor = (series) => {
|
|
740
|
+
let requested = requestedInterpolationFor(series);
|
|
741
|
+
return isBump && requested === "monotone" || isStacked && (requested === "step-after" || requested === "step-before") ? "linear" : requested;
|
|
742
|
+
};
|
|
743
|
+
return isStacked && seriesNorm.some((series) => {
|
|
744
|
+
let requested = requestedInterpolationFor(series);
|
|
745
|
+
return requested === "step-after" || requested === "step-before";
|
|
746
|
+
}) && warnings.push({
|
|
747
|
+
code: "step-composition-unsupported",
|
|
748
|
+
severity: "warn",
|
|
749
|
+
message: `${variant} does not support stepped interpolation \u2014 affected series rendered linearly`
|
|
750
|
+
}), isBump && seriesNorm.some((series) => requestedInterpolationFor(series) === "monotone") && warnings.push({
|
|
751
|
+
code: "bump-smooth-unsupported",
|
|
752
|
+
severity: "warn",
|
|
753
|
+
message: "variant 'bump' plots discrete derived ranks; monotone smoothing would imply fractional standings between periods \u2014 affected series rendered linearly",
|
|
754
|
+
suggest: "Drop smooth: true and interpolate: 'monotone' on a bump chart."
|
|
755
|
+
}), { variant, isArea: variant !== "line", isStacked, interpolationFor };
|
|
756
|
+
}
|
|
757
|
+
function percentBasis(cats, dataSeries, variant, warnings) {
|
|
758
|
+
let nmCats100 = /* @__PURE__ */ new Set(), naCats100 = /* @__PURE__ */ new Set(), basisByCat = cats.map((c, ci) => {
|
|
759
|
+
if (variant !== "stacked100-area") return 1;
|
|
760
|
+
let { basis, nm, na, direct: hasDirectShare } = compositionBasis(dataSeries.map((s) => s.vals[ci]), c.total100);
|
|
761
|
+
if (nm)
|
|
762
|
+
return nmCats100.add(c.id), 0;
|
|
763
|
+
if (!(basis <= 0)) return basis;
|
|
764
|
+
if (na) naCats100.add(c.id);
|
|
765
|
+
else if (dataSeries.every((s) => s.vals[ci].isPct || !s.vals[ci].v)) return 0;
|
|
766
|
+
return warnings.push({
|
|
767
|
+
code: "percent-basis-nonpositive",
|
|
768
|
+
severity: "warn",
|
|
769
|
+
message: hasDirectShare ? `category '${c.id}': non-positive 100% basis \u2014 percents set to 0` : `category '${c.id}': non-positive 100% basis \u2014 nothing to compose, category marked n/a`,
|
|
770
|
+
owner: { categoryId: c.id }
|
|
771
|
+
}), 0;
|
|
772
|
+
});
|
|
773
|
+
nmCats100.size > 0 && warnings.push(mixedSignsWarning([...nmCats100], cats.length, { tail: "", suggest: "use stacked columns (type 'column', variant 'stacked') or a waterfall for signed contributions" }));
|
|
774
|
+
let overfull = variant !== "stacked100-area" ? [] : cats.flatMap((c, ci) => {
|
|
775
|
+
if (nmCats100.has(c.id) || naCats100.has(c.id)) return [];
|
|
776
|
+
let sum = overfullShareSum(dataSeries.map((s) => s.vals[ci]), basisByCat[ci]);
|
|
777
|
+
return sum === void 0 ? [] : [{ id: c.id, sum }];
|
|
778
|
+
});
|
|
779
|
+
for (let row of overfull) nmCats100.add(row.id);
|
|
780
|
+
return overfull.length > 0 && warnings.push(overfullWarning(overfull, nmCats100.size + naCats100.size === cats.length, "give every part as a share of the same whole, or use variant 'line' for shares that overlap, such as answers to a multi-select question")), { nmCats100, overfullCats100: new Set(overfull.map((row) => row.id)), naCats100, basisByCat };
|
|
781
|
+
}
|
|
782
|
+
function stackedAreaSignWarnings(cats, dataSeries, variant) {
|
|
783
|
+
if (variant !== "stacked-area") return [];
|
|
784
|
+
let mixed = cats.filter((_, ci) => {
|
|
785
|
+
let values = dataSeries.flatMap((s) => s.vals[ci].v === null ? [] : [s.vals[ci].v]);
|
|
786
|
+
return values.some((v) => v > 0) && values.some((v) => v < 0);
|
|
787
|
+
});
|
|
788
|
+
return mixed.length === 0 ? [] : [{
|
|
789
|
+
code: "stacked-area-mixed-signs",
|
|
790
|
+
severity: "warn",
|
|
791
|
+
message: `stacked areas share one baseline, so a negative component folds its band over the band beneath; mixed signs in: ${mixed.map((c) => c.id).join(", ")}`,
|
|
792
|
+
suggest: "use stacked columns (type 'column', variant 'stacked'), which stack negatives below zero"
|
|
793
|
+
}];
|
|
794
|
+
}
|
|
795
|
+
function validatePhases(options, input, interpolationFor, warnings) {
|
|
796
|
+
if (!options.phases) return null;
|
|
797
|
+
let { cats, drawnSeries } = input, reject = (message, suggest) => (warnings.push({
|
|
798
|
+
code: "phases-invalid",
|
|
799
|
+
severity: "error",
|
|
800
|
+
message: `${message}, so the chart with phases is refused`,
|
|
801
|
+
...suggest ? { suggest } : {}
|
|
802
|
+
}), null);
|
|
803
|
+
if (input.isBump) return reject("variant 'bump' plots ranks rather than a continuous data curve", "drop phases or variant 'bump'");
|
|
804
|
+
if (input.variant === "stacked-area" || input.variant === "stacked100-area")
|
|
805
|
+
return reject(
|
|
806
|
+
`variant '${input.variant}' stacks bands of several series, and phases partition the area under one curve`,
|
|
807
|
+
"use variant 'area' or 'line' with one series; phases fill the area under it"
|
|
808
|
+
);
|
|
809
|
+
if (input.fan && input.fan.origin !== null) return reject("fan and phases are two wash systems with competing meanings", "split them into two exhibits");
|
|
810
|
+
if (options.gapFill) return reject("gapFill and phases are two wash systems with competing meanings", "split them into two exhibits");
|
|
811
|
+
if (options.rebase100) return reject("rebase100 can suppress a series after phase validation", "rebase the data before authoring phases");
|
|
812
|
+
if (drawnSeries.length !== 1)
|
|
813
|
+
return reject(
|
|
814
|
+
`phases require exactly one visible data series; ${drawnSeries.length} would be visible`,
|
|
815
|
+
"keep one data-role series or remove phases"
|
|
816
|
+
);
|
|
817
|
+
if (cats.length < 2) return reject("phases require at least two categories so the covered span has width");
|
|
818
|
+
let series = drawnSeries[0], interpolation = interpolationFor(series);
|
|
819
|
+
if (interpolation !== "linear" && interpolation !== "monotone")
|
|
820
|
+
return reject(`'${interpolation}' has a discontinuous phase-boundary value`, "use interpolate:'linear' or interpolate:'monotone'");
|
|
821
|
+
if (input.pv[input.rowOf.get(series)].some((value) => value === null))
|
|
822
|
+
return reject(
|
|
823
|
+
`series '${series.id}' contains a null, so there is no single continuous curve to partition`,
|
|
824
|
+
"supply every category value or remove phases"
|
|
825
|
+
);
|
|
826
|
+
let resolved = options.phases.map((phase) => ({
|
|
827
|
+
phase,
|
|
828
|
+
from: cats.findIndex((category) => category.id === phase.from),
|
|
829
|
+
to: cats.findIndex((category) => category.id === phase.to)
|
|
830
|
+
})), issue = resolved.find(({ from, to }) => from < 0 || to < 0)?.phase.id ?? resolved.find(({ from, to }) => from > to)?.phase.id;
|
|
831
|
+
if (issue) return reject(`phase '${issue}' has an unknown or reversed from/to category range`, "use ordered category ids from this chart");
|
|
832
|
+
if (resolved[0].from !== 0 || resolved[resolved.length - 1].to !== cats.length - 1)
|
|
833
|
+
return reject("phases do not cover the full first-to-last category span");
|
|
834
|
+
let discontinuity = resolved.findIndex((phase, index) => index > 0 && phase.from !== resolved[index - 1].to + 1);
|
|
835
|
+
return discontinuity !== -1 ? reject(
|
|
836
|
+
`phases '${resolved[discontinuity - 1].phase.id}' and '${resolved[discontinuity].phase.id}' overlap or leave a category gap`,
|
|
837
|
+
"make each next phase start at the category immediately after the previous phase ends"
|
|
838
|
+
) : { phases: options.phases, series, interpolation };
|
|
839
|
+
}
|
|
840
|
+
function applyRebase(options, variant, cats, seriesNorm, pv, rowOf, warnings, suppressed) {
|
|
841
|
+
if (!options.rebase100) return !1;
|
|
842
|
+
if (variant === "stacked100-area")
|
|
843
|
+
return warnings.push({ code: "rebase-ignored", severity: "warn", message: "rebase100 is ignored for stacked100-area (values are already percent-normalized)" }), !1;
|
|
844
|
+
let atId = rebaseAtId(options.rebase100, cats), baseIdx = cats.findIndex((c) => c.id === atId);
|
|
845
|
+
if (baseIdx === -1)
|
|
846
|
+
return warnings.push({ code: "rebase-unknown-category", severity: "warn", message: `rebase100.at '${atId}' is not a category id \u2014 rebase skipped` }), !1;
|
|
847
|
+
for (let s of seriesNorm) {
|
|
848
|
+
let row = pv[rowOf.get(s)], base = row[baseIdx];
|
|
849
|
+
if (base === null || base === 0) {
|
|
850
|
+
suppressed.push({ id: s.id, series: s.label, period: cats[baseIdx].label ?? atId, zero: base === 0 }), warnings.push({
|
|
851
|
+
code: "rebase-base-invalid",
|
|
852
|
+
severity: "warn",
|
|
853
|
+
message: `series '${s.id}': value at '${atId}' is ${base === 0 ? "zero" : "missing"} \u2014 series suppressed by rebase100`,
|
|
854
|
+
owner: { seriesId: s.id }
|
|
855
|
+
});
|
|
856
|
+
for (let ci = 0; ci < row.length; ci++) row[ci] = null;
|
|
857
|
+
} else
|
|
858
|
+
for (let ci = 0; ci < row.length; ci++) {
|
|
859
|
+
let v = row[ci];
|
|
860
|
+
row[ci] = v === null ? null : round2(v / base * 100);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return warnings.push({
|
|
864
|
+
code: "rebased",
|
|
865
|
+
severity: "info",
|
|
866
|
+
message: `series rebased to 100 at '${atId}' \u2014 indexed (${baseIdx === 0 ? "first period" : atId} = 100)`
|
|
867
|
+
}), !0;
|
|
868
|
+
}
|
|
869
|
+
function valueDomain(d, isBump, warnings, edges = []) {
|
|
870
|
+
let { options, cats, variant, pv, rowOf } = d, va = options.valueAxis ?? {}, lo = 1 / 0, hi = -1 / 0;
|
|
871
|
+
if (d.isStacked)
|
|
872
|
+
d.dataSeries.forEach((_, di) => {
|
|
873
|
+
cats.forEach((__, ci) => {
|
|
874
|
+
lo = Math.min(lo, d.cumBot[di][ci], d.cumTop[di][ci]), hi = Math.max(hi, d.cumBot[di][ci], d.cumTop[di][ci]);
|
|
875
|
+
});
|
|
876
|
+
});
|
|
877
|
+
else
|
|
878
|
+
for (let s of d.seriesNorm)
|
|
879
|
+
for (let v of pv[rowOf.get(s)])
|
|
880
|
+
v !== null && (lo = Math.min(lo, v), hi = Math.max(hi, v));
|
|
881
|
+
for (let value of edges)
|
|
882
|
+
lo = Math.min(lo, value), hi = Math.max(hi, value);
|
|
883
|
+
let plottedDataLo = lo, plottedDataHi = hi;
|
|
884
|
+
for (let target of d.targets)
|
|
885
|
+
lo = Math.min(lo, target.value), hi = Math.max(hi, target.value);
|
|
886
|
+
let domainExtendingValueLines = [];
|
|
887
|
+
for (let [annotationIndex, annotation] of (options.annotations ?? []).entries()) {
|
|
888
|
+
if (annotation.kind !== "valueLine" || annotation.axis === "secondary" || typeof annotation.value != "number" || !Number.isFinite(annotation.value) || annotation.seriesId !== void 0 || annotation.from !== void 0 || annotation.to !== void 0)
|
|
889
|
+
continue;
|
|
890
|
+
let annotationId = annotation.id ?? `valueLine-${annotationIndex + 1}`;
|
|
891
|
+
if (variant === "stacked100-area" && (annotation.value < 0 || annotation.value > 100))
|
|
892
|
+
throw new NormalizeError(
|
|
893
|
+
"value-line-composition-domain",
|
|
894
|
+
`annotations[${annotationIndex}]`,
|
|
895
|
+
`valueLine '${annotationId}' at ${annotation.value} is outside the fixed 0..100 composition axis`,
|
|
896
|
+
"keep the value line between 0 and 100; a reference line cannot rescale a 100% composition"
|
|
897
|
+
);
|
|
898
|
+
(annotation.value < lo || annotation.value > hi) && domainExtendingValueLines.push({ id: annotationId, value: annotation.value }), lo = Math.min(lo, annotation.value), hi = Math.max(hi, annotation.value);
|
|
899
|
+
}
|
|
900
|
+
for (let [bandIndex, band] of (options.referenceBands ?? []).entries()) {
|
|
901
|
+
let field = variant === "stacked100-area" ? ["value", "low", "high"].find((key) => band[key] !== void 0 && (band[key] < 0 || band[key] > 100)) : void 0;
|
|
902
|
+
if (field !== void 0) {
|
|
903
|
+
let level = band[field];
|
|
904
|
+
throw new NormalizeError(
|
|
905
|
+
"reference-band-composition-domain",
|
|
906
|
+
`options.referenceBands[${bandIndex}].${field}`,
|
|
907
|
+
`reference band '${band.label ?? band.id ?? bandIndex + 1}' at ${level} is outside the fixed 0..100 composition axis`,
|
|
908
|
+
"keep the band between 0 and 100; a reference band cannot rescale a 100% composition",
|
|
909
|
+
[{ op: "remove", path: `/options/referenceBands/${bandIndex}` }],
|
|
910
|
+
["options", "referenceBands", bandIndex, field]
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
lo = Math.min(lo, band.value ?? band.low ?? lo), hi = Math.max(hi, band.value ?? band.high ?? hi);
|
|
914
|
+
}
|
|
915
|
+
Number.isFinite(lo) || (lo = 0, hi = 1);
|
|
916
|
+
let dataLo = lo, dataHi = hi, dLo, dHi;
|
|
917
|
+
if (variant === "stacked100-area")
|
|
918
|
+
dLo = Math.min(0, lo), dHi = Math.max(100, hi);
|
|
919
|
+
else if (d.isArea || va.includeZero) {
|
|
920
|
+
let lo2 = Math.min(0, lo), hi2 = Math.max(0, hi > 0 ? hi * 1.06 : hi);
|
|
921
|
+
[dLo, dHi] = niceDomain(lo2, lo2 === hi2 ? hi2 + 1 : hi2, 5, { dataExtent: [lo2, Math.max(0, hi)], maxWasteFraction: DOMAIN_ECONOMY_FRACTION });
|
|
922
|
+
} else {
|
|
923
|
+
let span = hi - lo || Math.abs(hi) || 1;
|
|
924
|
+
[dLo, dHi] = niceDomain(lo - span * 0.08, hi + span * 0.08, 5, {
|
|
925
|
+
dataExtent: [dataLo, dataHi],
|
|
926
|
+
preserveDataSideOfZero: !0,
|
|
927
|
+
// Two-sided domain: the summed waste of both sides is bounded too, so the data fills at least 80% of the axis.
|
|
928
|
+
maxWasteFraction: DOMAIN_ECONOMY_FRACTION,
|
|
929
|
+
maxTotalWasteFraction: 0.2
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
let stepTicks, zeroBased = d.isArea || va.includeZero, grid = va.show === !0 && !isBump && !d.bumpDerived && variant !== "stacked100-area" && va.min === void 0 && va.max === void 0 && va.tickStep === void 0 ? axisGrid(zeroBased ? Math.min(0, lo) : lo, zeroBased ? Math.max(0, hi) : hi) : void 0;
|
|
933
|
+
grid && ([dLo, dHi] = grid.domain, stepTicks = grid.ticks);
|
|
934
|
+
let plottedDataSpan = plottedDataHi - plottedDataLo, plottedDataFraction = plottedDataSpan / (dHi - dLo);
|
|
935
|
+
if (!isBump && variant !== "stacked100-area" && plottedDataSpan > 0 && Number.isFinite(plottedDataFraction) && plottedDataFraction < DOMAIN_ECONOMY_FRACTION)
|
|
936
|
+
for (let annotation of domainExtendingValueLines)
|
|
937
|
+
warnings.push({
|
|
938
|
+
code: "value-line-data-span-collapsed",
|
|
939
|
+
severity: "warn",
|
|
940
|
+
message: `valueLine '${annotation.id}' at ${annotation.value} leaves the plotted data span at ${(plottedDataFraction * 100).toFixed(1)}% of the plot, below the ${(DOMAIN_ECONOMY_FRACTION * 100).toFixed(0)}% readability floor`,
|
|
941
|
+
suggest: "use a nearer reference value or move the distant reference to a separate exhibit"
|
|
942
|
+
});
|
|
943
|
+
[dLo, dHi] = applyAxisBounds([dLo, dHi], [lo, hi], va, isBump ? [] : warnings);
|
|
944
|
+
let tickStep = va.tickStep;
|
|
945
|
+
if (!d.bumpDerived && tickStep !== void 0 && tickStep > 0) {
|
|
946
|
+
let baseLo = va.min !== void 0 || variant === "stacked100-area" ? dLo : dLo <= 0 && dataLo >= 0 ? 0 : dataLo, baseHi = va.max !== void 0 || variant === "stacked100-area" ? dHi : dHi >= 0 && dataHi <= 0 ? 0 : dataHi, from = Math.floor(baseLo / tickStep + 1e-9), to = Math.ceil(baseHi / tickStep - 1e-9);
|
|
947
|
+
to - from >= 1 && to - from <= 20 ? (stepTicks = Array.from({ length: to - from + 1 }, (_, i) => Number(((from + i) * tickStep).toFixed(10))), dLo = stepTicks[0], dHi = stepTicks[stepTicks.length - 1]) : warnings.push({
|
|
948
|
+
code: "tick-step-ignored",
|
|
949
|
+
severity: "warn",
|
|
950
|
+
message: `valueAxis.tickStep ${tickStep} would draw ${to - from} intervals over the value domain; the nice ticks are drawn instead`,
|
|
951
|
+
suggest: "pick a step that gives 1 to 20 intervals"
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
let bumpLadderMax = d.bumpDerived?.maxRank ?? 1;
|
|
955
|
+
return d.bumpDerived && (dLo = 0.5, typeof options.scaleGroup?.y == "string" && va.max !== void 0 && (bumpLadderMax = Math.max(bumpLadderMax, Math.round(va.max - 0.5))), dHi = bumpLadderMax + 0.5), { dLo, dHi, domainExtendingValueLines, bumpLadderMax, stepTicks, ...grid ? { gridDataHi: dataHi } : {} };
|
|
956
|
+
}
|
|
957
|
+
function stackAndEndpoints(cats, dataSeries, drawnSeries, pv, rowOf, isStacked) {
|
|
958
|
+
let cumTop = dataSeries.map(() => []), cumBot = dataSeries.map(() => []);
|
|
959
|
+
isStacked && cats.forEach((_, ci) => {
|
|
960
|
+
let run = 0;
|
|
961
|
+
dataSeries.forEach((s, di) => {
|
|
962
|
+
let v = pv[rowOf.get(s)][ci] ?? 0;
|
|
963
|
+
cumBot[di][ci] = run, run += v, cumTop[di][ci] = run;
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
let endpoints = {}, lastIdxOf = /* @__PURE__ */ new Map();
|
|
967
|
+
return drawnSeries.forEach((s) => {
|
|
968
|
+
let row = pv[rowOf.get(s)];
|
|
969
|
+
for (let ci = row.length - 1; ci >= 0; ci--)
|
|
970
|
+
if (row[ci] !== null) {
|
|
971
|
+
lastIdxOf.set(s.id, ci), endpoints[s.id] = { categoryId: cats[ci].id, value: Number(row[ci].toPrecision(12)) };
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
}), { cumTop, cumBot, endpoints, lastIdxOf };
|
|
975
|
+
}
|
|
976
|
+
function namedSeries(modes, options, drawn, warnings) {
|
|
977
|
+
let gridLegend = options.gridEndpointIdentity === "legend";
|
|
978
|
+
return modes.series !== "none" || drawn < 2 || gridLegend || options.legend !== void 0 ? modes : (warnings.push({
|
|
979
|
+
code: "series-labels-key",
|
|
980
|
+
severity: "info",
|
|
981
|
+
message: `seriesLabels 'none' would leave ${drawn} drawn series told apart by colour alone, so the key row above the plot names them`,
|
|
982
|
+
suggest: "set seriesLabels to 'end', 'inline' or 'key', or legend to 'none' where the host names the series"
|
|
983
|
+
}), { ...modes, series: "key" });
|
|
984
|
+
}
|
|
985
|
+
function resolveLineDomain(data, input, env, warnings) {
|
|
986
|
+
let options = input, themeZero = env.theme.valueAxis?.includeZero;
|
|
987
|
+
themeZero !== void 0 && options.valueAxis?.includeZero === void 0 && (options = { ...options, valueAxis: { ...options.valueAxis, includeZero: themeZero } });
|
|
988
|
+
let { isBump } = env, { cats, seriesNorm } = normalizeLineData(data), xModel = lineXModel(options, cats), xRange = xModel ? resolveLineXOptions(options, xModel, cats, warnings) : void 0;
|
|
989
|
+
xRange && (options = xRange.options);
|
|
990
|
+
for (let value of unmatchedPartial(data))
|
|
991
|
+
warnings.push({
|
|
992
|
+
code: "x-partial-no-reading",
|
|
993
|
+
severity: "warn",
|
|
994
|
+
field: ["data", "partial"],
|
|
995
|
+
message: `data.partial names ${JSON.stringify(value)}, which is the x of no reading, so nothing is marked partial there`,
|
|
996
|
+
suggest: "name the x of a reading exactly, as data.x gives it"
|
|
997
|
+
});
|
|
998
|
+
let dataSeries = seriesNorm.filter((s) => s.role !== "reference"), refSeries = seriesNorm.filter((s) => s.role === "reference");
|
|
999
|
+
if (dataSeries.length === 0)
|
|
1000
|
+
throw new NormalizeError("empty-data", "series", "line requires at least one data-role series");
|
|
1001
|
+
let seriesById = new Map(seriesNorm.map((series) => [series.id, series])), targets = collectTargets(seriesNorm, cats, options, warnings), { variant, isArea, isStacked, interpolationFor } = lineVariant(options, isBump, seriesNorm, warnings), indexed = options.rebase100 && variant !== "stacked100-area" && cats.some((c) => c.id === rebaseAtId(options.rebase100, cats)), valueSpec = seriesRasterFormatter(options.format, seriesNorm.flatMap((s) => s.vals.map((val) => val.v)), options.locale?.language, indexed ? void 0 : options.unit, options.target, void 0, isStacked), bumpPrepared = prepareBump({
|
|
1002
|
+
isBump,
|
|
1003
|
+
options,
|
|
1004
|
+
valueAxis: options.valueAxis ?? {},
|
|
1005
|
+
targetsLength: targets.length,
|
|
1006
|
+
dataSeries,
|
|
1007
|
+
refSeries,
|
|
1008
|
+
seriesNorm,
|
|
1009
|
+
cats,
|
|
1010
|
+
warnings
|
|
1011
|
+
});
|
|
1012
|
+
dataSeries = bumpPrepared.dataSeries, refSeries = bumpPrepared.refSeries;
|
|
1013
|
+
let { nmCats100, overfullCats100, naCats100, basisByCat } = percentBasis(cats, dataSeries, variant, warnings), sharesWithheld = new Set(variant === "stacked100-area" ? cats.filter((c, ci) => c.total100 === void 0 && isIncomplete(dataSeries.map((s) => s.vals[ci].v))).map((c) => c.id) : []);
|
|
1014
|
+
warnIncompleteComposition(
|
|
1015
|
+
warnings,
|
|
1016
|
+
cats.filter((c) => sharesWithheld.has(c.id)).map((c) => c.label ?? c.id),
|
|
1017
|
+
"these categories are drawn as shares of their known parts only; their share labels are not printed"
|
|
1018
|
+
), pushAll(warnings, stackedAreaSignWarnings(cats, dataSeries, variant));
|
|
1019
|
+
let compositionInvalidAt = (ci) => variant === "stacked100-area" && (nmCats100.has(cats[ci].id) || naCats100.has(cats[ci].id)), absOf = (s, ci) => {
|
|
1020
|
+
let val = s.vals[ci];
|
|
1021
|
+
if (val.v === null) return null;
|
|
1022
|
+
if (!val.isPct || variant !== "stacked100-area") return val.v;
|
|
1023
|
+
let b = basisByCat[ci];
|
|
1024
|
+
return b > 0 ? val.v * b / 100 : null;
|
|
1025
|
+
}, pv = seriesNorm.map((s) => cats.map((_, ci) => {
|
|
1026
|
+
let val = s.vals[ci];
|
|
1027
|
+
if (val.v === null) return null;
|
|
1028
|
+
if (variant !== "stacked100-area") return val.v;
|
|
1029
|
+
if (compositionInvalidAt(ci)) return null;
|
|
1030
|
+
if (val.isPct) return val.v;
|
|
1031
|
+
let b = basisByCat[ci];
|
|
1032
|
+
return b > 0 ? val.v / b * 100 : 0;
|
|
1033
|
+
})), rowOf = new Map(seriesNorm.map((s, k) => [s, k])), rounded = variant === "stacked100-area" && options.rounding !== "nearest" ? roundWholes(cats.flatMap((category, ci) => compositionInvalidAt(ci) || dataSeries.some((s) => s.vals[ci].v === null || s.vals[ci].isPct) ? [] : [{
|
|
1034
|
+
id: category.id,
|
|
1035
|
+
name: category.label ?? category.id,
|
|
1036
|
+
parts: dataSeries.map((s) => ({ id: s.id, name: s.label, share: pv[rowOf.get(s)][ci] }))
|
|
1037
|
+
}]), options.locale?.language, void 0, !0) : void 0;
|
|
1038
|
+
rounded && pushAll(warnings, rounded.warnings);
|
|
1039
|
+
let printedValues = lineLabelModes(options, variant, 0).values;
|
|
1040
|
+
if (variant === "stacked100-area" && options.rounding === "nearest" && printedValues !== "none" && options.labels !== !1) {
|
|
1041
|
+
let printedAt = printedValues === "all" ? cats.map((_, ci) => ci) : printedValues === "last" ? [cats.length - 1] : [.../* @__PURE__ */ new Set([0, cats.length - 1])];
|
|
1042
|
+
warnShareRoundingDrift(warnings, printedAt.flatMap((ci) => {
|
|
1043
|
+
let c = cats[ci];
|
|
1044
|
+
return compositionInvalidAt(ci) || sharesWithheld.has(c.id) || c.total100 !== void 0 || dataSeries.some((s) => s.vals[ci].isPct) ? [] : [{ name: c.label ?? c.id, shares: dataSeries.flatMap((s) => pv[rowOf.get(s)][ci] ?? []) }];
|
|
1045
|
+
}));
|
|
1046
|
+
}
|
|
1047
|
+
let bumpDerived = deriveBumpRanks({
|
|
1048
|
+
isBump,
|
|
1049
|
+
direction: bumpPrepared.bumpDirection,
|
|
1050
|
+
dataSeries,
|
|
1051
|
+
cats,
|
|
1052
|
+
pv,
|
|
1053
|
+
rowOf,
|
|
1054
|
+
fmt: valueSpec.fmt,
|
|
1055
|
+
format: options.format,
|
|
1056
|
+
warnings
|
|
1057
|
+
}), gapFillSeries = resolveGapFillSeries({ gapFill: options.gapFill, seriesById, warnings }), fan = resolveFan({
|
|
1058
|
+
spec: options.fan,
|
|
1059
|
+
seriesById,
|
|
1060
|
+
seriesNorm,
|
|
1061
|
+
cats,
|
|
1062
|
+
variant,
|
|
1063
|
+
isArea,
|
|
1064
|
+
rebase100: options.rebase100,
|
|
1065
|
+
gapFill: options.gapFill,
|
|
1066
|
+
pv,
|
|
1067
|
+
rowOf,
|
|
1068
|
+
warnings
|
|
1069
|
+
}), bumpFocus = bumpFocusOf(isBump, options, dataSeries, bumpDerived, cats, warnings), drawnSeries = bumpFocus ? dataSeries.filter((s) => bumpFocus.has(s.id)) : fan && fan.origin !== null ? dataSeries.filter((s) => !fan.boundIds.has(s.id)) : dataSeries, bumpOmitted = bumpFocus ? dataSeries.filter((s) => !bumpFocus.has(s.id)) : [], resolvedModes = lineLabelModes(options, isBump ? "bump" : variant, drawnSeries.length), legendPosition = typeof options.legend == "object" ? options.legend.position : options.legend;
|
|
1070
|
+
isArea && options.seriesLabels === void 0 && options.labels !== !1 && options.labels?.series === void 0 && (legendPosition === "top" || legendPosition === "bottom" || legendPosition === "right") && (resolvedModes.series = "key");
|
|
1071
|
+
let labelModes = namedSeries(resolvedModes, options, drawnSeries.length, warnings), phases = validatePhases(options, { isBump, isArea, variant, fan, drawnSeries, cats, pv, rowOf }, interpolationFor, warnings), sourceNulls = new Set(variant === "stacked-area" ? cats.filter((_, ci) => dataSeries.some((s) => s.vals[ci].v === null)).map((c) => c.id) : []), rebaseSuppressed = [], rebased = applyRebase(options, variant, cats, seriesNorm, pv, rowOf, warnings, rebaseSuppressed);
|
|
1072
|
+
if (rebased && (valueSpec = seriesRasterFormatter(
|
|
1073
|
+
options.format,
|
|
1074
|
+
seriesNorm.flatMap((s) => pv[rowOf.get(s)].map((v) => v === null ? null : Math.round(v * 10) / 10)),
|
|
1075
|
+
options.locale?.language,
|
|
1076
|
+
void 0,
|
|
1077
|
+
options.target,
|
|
1078
|
+
void 0,
|
|
1079
|
+
isStacked
|
|
1080
|
+
)), fan) {
|
|
1081
|
+
let made = valueSpec, withBounds = { format: fan.of.format, unit: fan.of.unit, values: [fan.of, ...fan.bands.flatMap((band) => [band.low, band.high])].flatMap((s) => s.vals.map((val) => val.v)) };
|
|
1082
|
+
valueSpec = { ...made, forSeries: (series, cellFormat) => made.forSeries(series === fan.of ? withBounds : series, cellFormat) };
|
|
1083
|
+
}
|
|
1084
|
+
let statFmt = (v) => formatStatWithSpec(v, valueSpec.spec), anomalyRun = options.anomaly ? lineAnomalyModel(options.anomaly, { variant, isBump, drawnSeries, cats, pv, rowOf, fmt: valueSpec.fmt, statFmt, locale: options.locale?.language, strings: options.strings, warnings }) : void 0, live = lineWindow(options, cats, variant, isBump, !!fan, env.size.width, warnings, xModel !== void 0), population = applyCategoryViewport({
|
|
1085
|
+
domain: options.viewDomain,
|
|
1086
|
+
window: live.window,
|
|
1087
|
+
categories: cats,
|
|
1088
|
+
series: seriesNorm,
|
|
1089
|
+
...xModel ? { positions: xModel.xs } : {},
|
|
1090
|
+
plotted: pv,
|
|
1091
|
+
basis: basisByCat,
|
|
1092
|
+
targets,
|
|
1093
|
+
annotations: options.annotations,
|
|
1094
|
+
anchors: [...phases?.phases.flatMap((phase) => [phase.from, phase.to]) ?? [], ...live.anchors ?? []],
|
|
1095
|
+
samplingRows: [...isBump ? pv : [], ...isStacked ? stackBoundaries(dataSeries.map((s) => pv[rowOf.get(s)])) : [], ...fan?.bands.map((band) => band.widths) ?? []]
|
|
1096
|
+
});
|
|
1097
|
+
population && projectLineViewport({ ...population, bump: bumpDerived, fan, phases }), population && (options = liveWindowOptions({ ...options, annotations: population.annotations }, population.sampling));
|
|
1098
|
+
let labelPv = rounded ? seriesNorm.map((s, si) => cats.map((c, ci) => rounded.values.get(`${c.id}\0${s.id}`) ?? pv[si][ci])) : pv, shown = population ? population.categories.slice(population.indexes[0], population.indexes[population.indexes.length - 1] + 1) : cats, timeline = xModel ? valueTimeline(xModel, xRange, population, cats) : (options.trend ? trendTimeline(cats, shown) : void 0) ?? (population ? void 0 : categoryTimeline(cats));
|
|
1099
|
+
(options.trend || xModel) && population && timeline && Object.assign(population, timeline);
|
|
1100
|
+
let { cumTop, cumBot, endpoints, lastIdxOf } = stackAndEndpoints(cats, dataSeries, drawnSeries, pv, rowOf, isStacked), cut = xModel && population ? rangeCut(xModel.xs, population.indexes, xRange.lo, xRange.hi) : void 0, range = xModel && population && cut && (cut.lo || cut.hi) ? {
|
|
1101
|
+
lo: xRange.lo,
|
|
1102
|
+
hi: xRange.hi,
|
|
1103
|
+
cut,
|
|
1104
|
+
xs: xModel.xs,
|
|
1105
|
+
categories: population.categories,
|
|
1106
|
+
indexes: population.indexes,
|
|
1107
|
+
plotted: population.plotted,
|
|
1108
|
+
values: population.values,
|
|
1109
|
+
...stackAndEndpoints(population.categories, dataSeries, drawnSeries, population.plotted, rowOf, isStacked),
|
|
1110
|
+
invalid: new Set(population.categories.flatMap((c, i) => nmCats100.has(c.id) || naCats100.has(c.id) ? [i] : []))
|
|
1111
|
+
} : void 0, edgeValues = range ? seriesNorm.flatMap((s) => {
|
|
1112
|
+
let di = dataSeries.indexOf(s), row = range.plotted[rowOf.get(s)], rows = isStacked && di >= 0 ? [range.cumTop[di].map((v, i) => row[i] === null && (i <= range.indexes[0] || i >= range.indexes[range.indexes.length - 1]) ? null : v), range.cumBot[di]] : [row];
|
|
1113
|
+
return rangeRuns(range, rows, interpolationFor(s), s.interpolateGaps).flatMap((run) => run.flatMap((edge) => edge.points.flatMap((p) => p.x === range.lo || p.x === range.hi ? [p.y] : [])));
|
|
1114
|
+
}) : [], incompleteStack = variant === "stacked-area" ? cats.filter((c) => sourceNulls.has(c.id)) : [];
|
|
1115
|
+
incompleteStack.length > 0 && warnings.push({
|
|
1116
|
+
code: "incomplete-composition",
|
|
1117
|
+
severity: "warn",
|
|
1118
|
+
message: `missing value (null) in ${incompleteStack.map((c) => `'${c.label ?? c.id}'`).join(", ")}: missing values are drawn as zero in the stack; these stack heights are not complete totals`,
|
|
1119
|
+
suggest: "Supply each missing component value. Use 0 only when the source proves zero."
|
|
1120
|
+
});
|
|
1121
|
+
let core = { options, cats, seriesNorm, dataSeries, targets, variant, isArea, isStacked, pv, rowOf, bumpDerived }, values = valueDomain({ ...core, cumTop, cumBot }, isBump, warnings, edgeValues), anomaly = anomalyRun && {
|
|
1122
|
+
model: anomalyRun.anomaly,
|
|
1123
|
+
seriesId: anomalyRun.seriesId,
|
|
1124
|
+
statFmt,
|
|
1125
|
+
...anomalyCorridor(anomalyRun.anomaly, anomalyRun.values, values.dLo, values.dHi, statFmt, warnings, options.strings)
|
|
1126
|
+
}, resolved = {
|
|
1127
|
+
...core,
|
|
1128
|
+
refSeries,
|
|
1129
|
+
drawnSeries,
|
|
1130
|
+
bumpOmitted,
|
|
1131
|
+
valueSpec,
|
|
1132
|
+
fmt: valueSpec.fmt,
|
|
1133
|
+
interpolationFor,
|
|
1134
|
+
labelModes,
|
|
1135
|
+
labelOnly: labelModes.only,
|
|
1136
|
+
gapFillSeries,
|
|
1137
|
+
fan,
|
|
1138
|
+
phases,
|
|
1139
|
+
rebased,
|
|
1140
|
+
population,
|
|
1141
|
+
timeline,
|
|
1142
|
+
...xModel ? { x: { model: xModel, lo: xRange.lo, hi: xRange.hi, shown: population ? population.indexes.map((i) => xModel.xs[i]) : xModel.xs, ...range ? { range } : {} } } : {},
|
|
1143
|
+
autoSampled: live.auto === !0,
|
|
1144
|
+
absOf,
|
|
1145
|
+
compositionInvalidAt,
|
|
1146
|
+
nmCats100,
|
|
1147
|
+
overfullCats100,
|
|
1148
|
+
naCats100,
|
|
1149
|
+
sharesWithheld,
|
|
1150
|
+
incompleteStack,
|
|
1151
|
+
rebaseSuppressed,
|
|
1152
|
+
cumTop,
|
|
1153
|
+
cumBot,
|
|
1154
|
+
endpoints,
|
|
1155
|
+
lastIdxOf,
|
|
1156
|
+
labelPv,
|
|
1157
|
+
shareTexts: rounded?.texts ?? /* @__PURE__ */ new Map(),
|
|
1158
|
+
...rounded ? { roundingAdjustments: rounded.adjustments } : {},
|
|
1159
|
+
...values,
|
|
1160
|
+
anomaly
|
|
1161
|
+
};
|
|
1162
|
+
return { ...resolved, trends: fitLineTrends(resolved, warnings) };
|
|
1163
|
+
}
|
|
1164
|
+
function lineAnomalyModel(spec, d) {
|
|
1165
|
+
if (d.isBump || d.variant !== "line")
|
|
1166
|
+
throw new NormalizeError(
|
|
1167
|
+
"anomaly-composition-conflict",
|
|
1168
|
+
"options.anomaly",
|
|
1169
|
+
`anomaly needs the plain line variant; '${d.isBump ? "bump" : d.variant}' draws ${d.isBump ? "ranks" : "a composition"}, which have no deviation baseline`,
|
|
1170
|
+
"use variant 'line' on the values themselves"
|
|
1171
|
+
);
|
|
1172
|
+
if (d.drawnSeries.length !== 1)
|
|
1173
|
+
throw new NormalizeError(
|
|
1174
|
+
"anomaly-single-series",
|
|
1175
|
+
"options.anomaly",
|
|
1176
|
+
`anomaly needs exactly one drawn series; got ${d.drawnSeries.length} \u2014 a robust score across two different measures is meaningless`,
|
|
1177
|
+
"chart one measure per exhibit, or pre-compute the deviation upstream"
|
|
1178
|
+
);
|
|
1179
|
+
refuseAnomalySpec(spec);
|
|
1180
|
+
let series = d.drawnSeries[0], row = d.pv[d.rowOf.get(series)], present = d.cats.flatMap((c, ci) => {
|
|
1181
|
+
let value = row[ci];
|
|
1182
|
+
return value == null || !Number.isFinite(value) ? [] : [{ categoryId: c.id, value }];
|
|
1183
|
+
});
|
|
1184
|
+
return { ...anomalyModel(spec, present, d.fmt, d.statFmt, d.locale, d.warnings, d.strings), seriesId: series.id };
|
|
1185
|
+
}
|
|
1186
|
+
var BUMP_SERIES_LIMIT = 12;
|
|
1187
|
+
function bumpFocusOf(isBump, options, dataSeries, bump, cats, warnings) {
|
|
1188
|
+
if (!isBump || !bump) return;
|
|
1189
|
+
let focus = options.bump?.focus;
|
|
1190
|
+
if (focus) {
|
|
1191
|
+
let unknown = focus.filter((id) => !dataSeries.some((s) => s.id === id));
|
|
1192
|
+
if (unknown.length > 0) throw new NormalizeError("bump-focus-unknown", "options.bump.focus", `bump.focus names ${unknown.map((id) => `'${id}'`).join(", ")}, which are not ranked series; valid ids: ${dataSeries.map((s) => s.id).join(", ")}`);
|
|
1193
|
+
return new Set(focus);
|
|
1194
|
+
}
|
|
1195
|
+
if (dataSeries.length <= BUMP_SERIES_LIMIT) return;
|
|
1196
|
+
let last = cats.length - 1, best = [...dataSeries].filter((s) => bump.ranks[s.id]?.[last] !== null && bump.ranks[s.id]?.[last] !== void 0).sort((a, b) => bump.ranks[a.id][last] - bump.ranks[b.id][last]).slice(0, 5).map((s) => s.id);
|
|
1197
|
+
warnings.push({
|
|
1198
|
+
code: "bump-series-limit",
|
|
1199
|
+
severity: "error",
|
|
1200
|
+
message: `a bump chart draws at most ${BUMP_SERIES_LIMIT} entities, so each line can be followed; this one ranks ${dataSeries.length}`,
|
|
1201
|
+
suggest: `set bump.focus to the entities the exhibit is about (at most ${BUMP_SERIES_LIMIT}; the five best at the end are ${best.join(", ")}). Every entity is still ranked, and the others are named in a note and keep their values in the data table. The chosen lines and their names must fit the chart size; leave the height open or give them more room. Or show the ranks in a table.`,
|
|
1202
|
+
field: ["options", "bump", "focus"]
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
function stackBoundaries(rows) {
|
|
1206
|
+
let edges = [], below;
|
|
1207
|
+
for (let row of rows) {
|
|
1208
|
+
let edge = row.map((value, ci) => (below?.[ci] ?? 0) + (value ?? 0));
|
|
1209
|
+
edges.push(edge), below = edge;
|
|
1210
|
+
}
|
|
1211
|
+
return edges;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// src/core/charts/line/xTicks.ts
|
|
1215
|
+
var TICK_GAP = 12, ROW_GAP = 2, DEFAULT_MAX_TICKS = 10, DAY = 864e5, X_PARTIAL_ROW = /* @__PURE__ */ Symbol("boardplot.xPartialRow");
|
|
1216
|
+
function numberTicks(lo, hi, step) {
|
|
1217
|
+
let decimals = Math.max(0, -Math.floor(Math.log10(step)) + 1), out = [];
|
|
1218
|
+
for (let k = Math.ceil(lo / step - 1e-9); k <= Math.floor(hi / step + 1e-9) && out.length <= 1e3; k++)
|
|
1219
|
+
out.push(Number((k * step).toFixed(Math.min(20, decimals))));
|
|
1220
|
+
return out;
|
|
1221
|
+
}
|
|
1222
|
+
function impliedStep(values, model) {
|
|
1223
|
+
let clock = model.clock, wall = (ms) => new Date(ms + clock.offsetAt(ms));
|
|
1224
|
+
return values.some((v) => (v + clock.offsetAt(v)) % DAY !== 0) ? { unit: "hour", n: 1 } : values.some((v) => wall(v).getUTCDate() !== 1) ? { unit: "day", n: 1 } : values.some((v) => wall(v).getUTCMonth() !== 0) ? { unit: "month", n: 1 } : { unit: "year", n: 1 };
|
|
1225
|
+
}
|
|
1226
|
+
function labelOf(model, value, step, numberFmt) {
|
|
1227
|
+
return model.clock ? model.axis.format ? formatTimePattern(value, model.clock, model.axis.format, model.language) : timeTickText(value, step, model.clock, model.language) : numberFmt(value);
|
|
1228
|
+
}
|
|
1229
|
+
function fits(xs, widths, keep, left, right) {
|
|
1230
|
+
let previousEnd = Number.NEGATIVE_INFINITY;
|
|
1231
|
+
for (let i = 0; i < xs.length; i++) {
|
|
1232
|
+
if (!keep[i]) continue;
|
|
1233
|
+
let w = widths[i], x = Math.max(left, Math.min(xs[i] - w / 2, right - w));
|
|
1234
|
+
if (x < previousEnd + TICK_GAP) return !1;
|
|
1235
|
+
previousEnd = x + w;
|
|
1236
|
+
}
|
|
1237
|
+
return !0;
|
|
1238
|
+
}
|
|
1239
|
+
function thinned(xs, widths, left, right) {
|
|
1240
|
+
for (let stride = 1; stride <= xs.length; stride++) {
|
|
1241
|
+
let keep = xs.map((_, i) => i % stride === 0);
|
|
1242
|
+
if (fits(xs, widths, keep, left, right)) return { keep, stride };
|
|
1243
|
+
}
|
|
1244
|
+
return { keep: xs.map((_, i) => i === 0), stride: xs.length };
|
|
1245
|
+
}
|
|
1246
|
+
function planXTicks(input) {
|
|
1247
|
+
let { model, lo, hi, measure, font } = input, axis = model.axis, width = (text) => measure(text, font).width, lineH = font.size * (font.lineHeight ?? 1.2), maxTicks = axis.maxTicks ?? DEFAULT_MAX_TICKS, numberFmt = (values) => model.clock ? void 0 : seriesRasterFormatter(axis.format, values, model.language).fmt, build = (values, step, authoredLabels) => {
|
|
1248
|
+
let fmt = numberFmt(values);
|
|
1249
|
+
return { values, step, labels: values.map((v, i) => authoredLabels?.[i] ?? labelOf(model, v, step, fmt)) };
|
|
1250
|
+
}, row, authored = !1;
|
|
1251
|
+
if (axis.ticks) {
|
|
1252
|
+
authored = !0;
|
|
1253
|
+
let read = axis.ticks.map((tick, i) => {
|
|
1254
|
+
let value = typeof tick == "object" ? tick.value : tick;
|
|
1255
|
+
return { x: model.read(value, `options.xAxis.ticks[${i}]`), label: typeof tick == "object" ? tick.label : void 0 };
|
|
1256
|
+
}).filter((tick) => tick.x >= lo && tick.x <= hi).sort((a, b) => a.x - b.x), values = read.map((tick) => tick.x);
|
|
1257
|
+
row = build(values, model.clock && values.length ? impliedStep(values, model) : void 0, read.map((tick) => tick.label));
|
|
1258
|
+
} else if (axis.tickStep !== void 0)
|
|
1259
|
+
if (authored = !0, typeof axis.tickStep == "number") row = build(numberTicks(lo, hi, axis.tickStep), void 0);
|
|
1260
|
+
else {
|
|
1261
|
+
let step = authoredTimeStep(axis.tickStep);
|
|
1262
|
+
row = build(timeTicks(lo, hi, step, model.clock, input.weekStartsOn) ?? [], step);
|
|
1263
|
+
}
|
|
1264
|
+
else if (model.clock)
|
|
1265
|
+
for (let step of timeLadder(lo, hi, maxTicks, timeReadingUnit(model.xs, model.clock))) {
|
|
1266
|
+
let values = timeTicks(lo, hi, step, model.clock, input.weekStartsOn);
|
|
1267
|
+
if (!values || values.length > maxTicks || values.length === 0) continue;
|
|
1268
|
+
let candidate = build(values, step), keep2 = values.map(() => !0);
|
|
1269
|
+
if (row = candidate, fits(values.map(input.xOf), candidate.labels.map(width), keep2, input.left, input.right)) break;
|
|
1270
|
+
}
|
|
1271
|
+
else {
|
|
1272
|
+
let span = hi - lo || Math.abs(hi) || 1;
|
|
1273
|
+
for (let count = maxTicks; count >= 1; count--) {
|
|
1274
|
+
let values = numberTicks(lo, hi, niceStep(span / count));
|
|
1275
|
+
if (values.length > maxTicks || values.length === 0) continue;
|
|
1276
|
+
let candidate = build(values, void 0);
|
|
1277
|
+
if (row = candidate, fits(values.map(input.xOf), candidate.labels.map(width), values.map(() => !0), input.left, input.right)) break;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
row ??= { values: [], labels: [] };
|
|
1281
|
+
let xs = row.values.map(input.xOf), widths = row.labels.map(width), { keep, stride } = thinned(xs, widths, input.left, input.right);
|
|
1282
|
+
stride > 1 && authored && input.warnings.push({
|
|
1283
|
+
code: "x-ticks-thinned",
|
|
1284
|
+
severity: "info",
|
|
1285
|
+
field: ["options", "xAxis", axis.ticks ? "ticks" : "tickStep"],
|
|
1286
|
+
message: `the authored x ticks do not fit side by side at this width, so every ${stride === 2 ? "second" : `${stride}th`} tick prints its label`,
|
|
1287
|
+
suggest: "give a coarser tickStep or fewer ticks, a shorter xAxis.format, or more width"
|
|
1288
|
+
});
|
|
1289
|
+
let contextStep = row.step, context = model.clock && contextStep ? timeContextRow(lo, hi, contextStep, model.clock, row.values.filter((_, i) => keep[i]), model.language).map((item) => ({ ...item, w: width(item.text) })) : [], title = axis.title ? { text: axis.title, w: width(axis.title) } : void 0, rowHeight = (row.values.length ? lineH : 0) + (context.length ? ROW_GAP + lineH : 0) + (input.partialRow ? ROW_GAP + lineH : 0) + (title ? ROW_GAP + lineH : 0);
|
|
1290
|
+
return { values: row.values, labels: row.labels, widths, keep, context, title, font, lineH, rowHeight, ...input.partialRow ? { partialRow: !0 } : {} };
|
|
1291
|
+
}
|
|
1292
|
+
function placedContext(plan, xOf, left, right) {
|
|
1293
|
+
let placed = [];
|
|
1294
|
+
for (let item of plan.context) {
|
|
1295
|
+
let x = Math.max(left, Math.min(xOf(item.at), right - item.w)), last = placed[placed.length - 1];
|
|
1296
|
+
if (last && last.x + last.w + TICK_GAP > x) {
|
|
1297
|
+
placed[placed.length - 1] = { text: item.text, x, w: item.w };
|
|
1298
|
+
continue;
|
|
1299
|
+
}
|
|
1300
|
+
placed.push({ text: item.text, x, w: item.w });
|
|
1301
|
+
}
|
|
1302
|
+
return placed;
|
|
1303
|
+
}
|
|
1304
|
+
function tickLabelX(plan, index, xOf, left, right) {
|
|
1305
|
+
let w = plan.widths[index];
|
|
1306
|
+
return Math.max(left, Math.min(xOf(plan.values[index]) - w / 2, right - w));
|
|
1307
|
+
}
|
|
1308
|
+
function xTickRowPlan(plan) {
|
|
1309
|
+
return {
|
|
1310
|
+
dateNumeric: !1,
|
|
1311
|
+
typeRole: "secondary",
|
|
1312
|
+
font: plan.font,
|
|
1313
|
+
infos: plan.labels.map((label, i) => ({ lines: [label], w: plan.widths[i], h: plan.lineH, truncated: !1 })),
|
|
1314
|
+
keep: plan.keep,
|
|
1315
|
+
stride: 1,
|
|
1316
|
+
rotation: 0,
|
|
1317
|
+
maxLines: 1,
|
|
1318
|
+
rowHeight: plan.rowHeight,
|
|
1319
|
+
x: () => 0,
|
|
1320
|
+
anchor: () => 0,
|
|
1321
|
+
step: "fit",
|
|
1322
|
+
warnings: [],
|
|
1323
|
+
cutNotes: []
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
function placeXTickLabels(input) {
|
|
1327
|
+
if (!input.show) return !1;
|
|
1328
|
+
let { plan, xOf } = input, left = input.row.x, right = input.row.x + input.row.w, request = (id, text, x, y2, w) => ({
|
|
1329
|
+
id,
|
|
1330
|
+
kind: "category",
|
|
1331
|
+
owner: {},
|
|
1332
|
+
text,
|
|
1333
|
+
lines: [text],
|
|
1334
|
+
typeRole: "secondary",
|
|
1335
|
+
font: plan.font,
|
|
1336
|
+
priority: PRIORITY.endpoint,
|
|
1337
|
+
candidates: [{ slot: "below", rect: { x, y: y2, w, h: plan.lineH }, penalty: 0 }]
|
|
1338
|
+
}), y = input.bottom;
|
|
1339
|
+
plan.values.length && (plan.values.forEach((_, i) => {
|
|
1340
|
+
plan.keep[i] && input.labelRequests.push(request(`xtick:${i}`, plan.labels[i], tickLabelX(plan, i, xOf, left, right), y, plan.widths[i]));
|
|
1341
|
+
}), y += plan.lineH + ROW_GAP), plan.context.length && (placedContext(plan, xOf, left, right).forEach((item, k) => input.labelRequests.push(request(`xcontext:${k}`, item.text, item.x, y, item.w))), y += plan.lineH + ROW_GAP);
|
|
1342
|
+
let partialTop = y;
|
|
1343
|
+
plan.partialRow && (y += plan.lineH + ROW_GAP), plan.title && input.labelRequests.push(request("axis:x:title", plan.title.text, Math.max(left, input.plotRight - plan.title.w), y, plan.title.w));
|
|
1344
|
+
let partial = input.partial;
|
|
1345
|
+
if (partial) {
|
|
1346
|
+
let groups = [];
|
|
1347
|
+
partial.at.map((at, i) => ({ c: xOf(at), name: partial.names[i] })).sort((a, b) => a.c - b.c).forEach(({ c, name }) => {
|
|
1348
|
+
let last = groups[groups.length - 1];
|
|
1349
|
+
last && c - last.to < partial.w + TICK_GAP ? (last.to = c, last.names.push(name)) : groups.push({ from: c, to: c, names: [name] });
|
|
1350
|
+
}), partial.groups = groups.map((group) => group.names);
|
|
1351
|
+
let rows = plan.partialRow ? [partialTop] : [input.bottom, ...plan.values.length && plan.context.length ? [input.bottom + plan.lineH + ROW_GAP] : []];
|
|
1352
|
+
groups.forEach((group, k) => {
|
|
1353
|
+
let x = Math.max(left, Math.min((group.from + group.to) / 2 - partial.w / 2, right - partial.w));
|
|
1354
|
+
input.labelRequests.push({
|
|
1355
|
+
...request(`xpartial:${k}`, partial.text, x, input.bottom, partial.w),
|
|
1356
|
+
priority: PRIORITY.endpoint - 1,
|
|
1357
|
+
candidates: rows.map((top, r) => ({ slot: "below", rect: { x, y: top, w: partial.w, h: plan.lineH }, penalty: r }))
|
|
1358
|
+
});
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
return !0;
|
|
1362
|
+
}
|
|
1363
|
+
function timeZoneNote(domain, options) {
|
|
1364
|
+
let x = domain.x, clock = x?.model.clock;
|
|
1365
|
+
if (!x || !clock || !x.model.precision?.clock) return [];
|
|
1366
|
+
let changes = offsetChanges(x.lo, x.hi, clock), text = changes.length === 0 ? chartString2(options, "timeZoneNote", { v1: clock.zone }) : chartString2(options, "timeZoneChangeNote", { v1: clock.zone, v2: [changes[0].from, ...changes.map((c) => c.to)].map(offsetText).join(chartString2(options, "offsetThen")) });
|
|
1367
|
+
return [disclosureNote(text)];
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// src/core/charts/line/labelPlan.ts
|
|
1371
|
+
function planLineLabels(env, domain, area, paints, text, reserves, scene, warnings) {
|
|
1372
|
+
let { isBump, theme, size, measure, highlights } = env, { drawnSeries, cats, rowOf, isStacked, isArea, cumTop, cumBot, interpolationFor } = domain, { plot, y, xOf, categoryOrder } = area, { labelFont, labelH } = text, focusName = lineFocusFont(env, domain, text.nameFont, emphasisWeight(theme)), focusValue = lineFocusFont(env, domain, labelFont, emphasisWeight(theme)), { marks } = scene, { paintedAreaCats } = scene.rendered, labelRequests = [...scene.headerRequests], ratioTierRequestState = area.ratioTier ? addRatioTierRequests(area.ratioTier, labelRequests, {
|
|
1373
|
+
plot,
|
|
1374
|
+
categoryBandHeight: area.categoryBandHeight,
|
|
1375
|
+
categoryCenter: (categoryId) => xOf(categoryOrder.get(categoryId)),
|
|
1376
|
+
theme,
|
|
1377
|
+
measure
|
|
1378
|
+
}) : void 0;
|
|
1379
|
+
pushAll(labelRequests, scene.phaseRequests), pushAll(labelRequests, scene.targetRequests);
|
|
1380
|
+
let inlineNamesEnabled = reserves.endpoint.inlineNamesEnabled, last = cats.length - 1, forecastXs = area.forecast.map((boundary) => forecastBoundaryX(boundary, xOf, "point")), dividerXs = [...forecastXs, ...reserves.annList.flatMap((a) => {
|
|
1381
|
+
if (a.kind !== "band" || !a.divider || a.from === void 0 || a.to === void 0) return [];
|
|
1382
|
+
let from = categoryOrder.get(a.from), to = categoryOrder.get(a.to);
|
|
1383
|
+
return [
|
|
1384
|
+
...from !== void 0 && a.divider !== "end" ? [from === 0 ? plot.x : (xOf(from - 1) + xOf(from)) / 2] : [],
|
|
1385
|
+
...to !== void 0 && a.divider !== "start" ? [to === last ? plot.x + plot.w : (xOf(to) + xOf(to + 1)) / 2] : []
|
|
1386
|
+
];
|
|
1387
|
+
})];
|
|
1388
|
+
placeInlineSeriesLabels({
|
|
1389
|
+
enabled: inlineNamesEnabled,
|
|
1390
|
+
drawnSeries,
|
|
1391
|
+
marks,
|
|
1392
|
+
interpolationFor,
|
|
1393
|
+
categoryOrder,
|
|
1394
|
+
plot,
|
|
1395
|
+
measure,
|
|
1396
|
+
dividerXs,
|
|
1397
|
+
labelFont: text.nameFont,
|
|
1398
|
+
labelH,
|
|
1399
|
+
labelRequests,
|
|
1400
|
+
highlights,
|
|
1401
|
+
heroId: paints.heroId,
|
|
1402
|
+
beside: usesInlineFallback(domain.options),
|
|
1403
|
+
...focusName ? { focusFont: focusName } : {}
|
|
1404
|
+
});
|
|
1405
|
+
let outsideRankBand = (rect) => isBump && (rect.y < plot.y - 0.5 || rect.y + rect.h > plot.y + plot.h + 0.5), { endLabels, endSwatchReserve, endpointSwatches, columnGap } = reserves.endpoint, merged = /* @__PURE__ */ new Set(), bounded = !isBump && !isArea && !domain.fan ? { lineHeight: labelH, fallback: !1, wide: usesWideEndLabels(domain.options), widen: !1 } : void 0, endpointLeaderAnchors = placeEndpointLabels({
|
|
1406
|
+
endLabels,
|
|
1407
|
+
endSwatchReserve,
|
|
1408
|
+
endpointSwatches,
|
|
1409
|
+
// The names start just past the line ends, or past the plot edge (reserves.namesAtPlotEdge).
|
|
1410
|
+
columnX: (reserves.namesAtPlotEdge || cats.length === 0 ? plot.x + plot.w : xOf(cats.length - 1)) + columnGap,
|
|
1411
|
+
marks,
|
|
1412
|
+
paintedAreaCats,
|
|
1413
|
+
cats,
|
|
1414
|
+
plot,
|
|
1415
|
+
size,
|
|
1416
|
+
isStacked,
|
|
1417
|
+
isArea,
|
|
1418
|
+
y,
|
|
1419
|
+
cumTop,
|
|
1420
|
+
cumBot,
|
|
1421
|
+
outsideRankBand,
|
|
1422
|
+
warnings,
|
|
1423
|
+
labelRequests,
|
|
1424
|
+
labelFont: text.nameFont,
|
|
1425
|
+
highlights,
|
|
1426
|
+
keyPaint: paints.keyPaint,
|
|
1427
|
+
seriesPaint: paints.series,
|
|
1428
|
+
// A line that ends early is named at its own end unless the author asks for the gutter.
|
|
1429
|
+
atLineEnd: (domain.options.endLabelPlacement ?? env.theme.labels?.endLabelPlacement ?? "lineEnd") === "lineEnd",
|
|
1430
|
+
...!isBump && domain.labelModes.values !== "none" && text.contentOf("point", ["absolute"]) !== null ? { valuesAtEnd: { merged, measure } } : {},
|
|
1431
|
+
crowdedEnds: !isBump,
|
|
1432
|
+
// Under a grey highlight the names print in their
|
|
1433
|
+
// line's ink with the value beside them; a near-zero group keeps its shared label.
|
|
1434
|
+
joinEvery: domain.variant === "line" && env.anyHighlight && domain.options.highlightMode !== "fade" && !reserves.endpoint.nearZeroTail,
|
|
1435
|
+
rankLadder: isBump,
|
|
1436
|
+
...bounded ? { bounded } : {}
|
|
1437
|
+
}), lastCarried = /* @__PURE__ */ new Set([...merged, ...reserves.keyValues.keys()]), valueInput = {
|
|
1438
|
+
drawnEdges: scene.rendered.rangeEdges,
|
|
1439
|
+
valueLabels: domain.labelModes.values,
|
|
1440
|
+
firstWithheld: domain.x?.range && isArea && usesEndLabelKey(domain.options) && domain.labelModes.values === "ends" ? new Set(drawnSeries.filter((s) => {
|
|
1441
|
+
let first = domain.pv[rowOf.get(s)].findIndex((v) => v !== null);
|
|
1442
|
+
return first >= 0 && s.vals[first].labelOverride === void 0 && reserves.keyValues.has(s.id);
|
|
1443
|
+
}).map((s) => s.id)) : void 0,
|
|
1444
|
+
valueLabelsAuthored: domain.options.valueLabels !== void 0,
|
|
1445
|
+
labelOnly: domain.labelOnly,
|
|
1446
|
+
// A group that ends on one printed zero prints that value once.
|
|
1447
|
+
lastWithheld: /* @__PURE__ */ new Set([...reserves.endpoint.nearZeroTail?.seriesIds.slice(1) ?? [], ...lastCarried]),
|
|
1448
|
+
lastCarried,
|
|
1449
|
+
endNamed: /* @__PURE__ */ new Set([...endLabels.map((label) => label.s.id), ...reserves.endpoint.nearZeroTail?.mode === "shared" ? reserves.endpoint.nearZeroTail.seriesIds : []]),
|
|
1450
|
+
valueContent: defaultValueContent(domain.variant, domain.labelModes.seriesValueContent),
|
|
1451
|
+
...valueUnit(domain.options, isBump, domain.rebased),
|
|
1452
|
+
contentOf: text.contentOf,
|
|
1453
|
+
variant: domain.variant,
|
|
1454
|
+
drawnSeries,
|
|
1455
|
+
pv: domain.labelPv,
|
|
1456
|
+
rowOf,
|
|
1457
|
+
cats,
|
|
1458
|
+
rebased: domain.rebased,
|
|
1459
|
+
composeText: text.composeText,
|
|
1460
|
+
composeEndText: text.composeEndText,
|
|
1461
|
+
absOf: domain.absOf,
|
|
1462
|
+
measure,
|
|
1463
|
+
labelFont,
|
|
1464
|
+
highlights,
|
|
1465
|
+
isStacked,
|
|
1466
|
+
y,
|
|
1467
|
+
cumTop,
|
|
1468
|
+
cumBot,
|
|
1469
|
+
xOf,
|
|
1470
|
+
plot: area.forecastPlot,
|
|
1471
|
+
paintedAreaCats,
|
|
1472
|
+
areaFillPaint: paints.areaFill,
|
|
1473
|
+
paintCss: paints.css,
|
|
1474
|
+
labelH,
|
|
1475
|
+
step: area.step,
|
|
1476
|
+
density: env.density,
|
|
1477
|
+
labelRequests,
|
|
1478
|
+
restHidden: (series) => restValuesHidden(domain.options, series.colorRole),
|
|
1479
|
+
interpolationFor: domain.interpolationFor,
|
|
1480
|
+
sharesWithheld: domain.sharesWithheld,
|
|
1481
|
+
warnings,
|
|
1482
|
+
// Authored furniture that divides at a transition stands on the same split.
|
|
1483
|
+
dividers: area.forecast.map((boundary, index) => ({ x: forecastXs[index], ci: boundary.lastActualIndex })),
|
|
1484
|
+
...isBump ? { bump: { headroom: area.topPad, named: new Set([...endLabels, ...reserves.startLabels].map((label) => `${label.s.id}:${label.ci}`)) } } : {},
|
|
1485
|
+
flagged: flaggedPoints(domain),
|
|
1486
|
+
...focusValue ? { focusFont: focusValue } : {},
|
|
1487
|
+
toDate: { ids: lineToDateIds(env, domain, text), words: domain.options.strings?.toDate ?? chartString(domain.options, "toDate"), theme: env.theme, measure }
|
|
1488
|
+
}, valueWidths = isBump ? pointValueWidths(valueInput) : /* @__PURE__ */ new Map();
|
|
1489
|
+
placeBumpStartLabels({
|
|
1490
|
+
startLabels: reserves.startLabels,
|
|
1491
|
+
marks,
|
|
1492
|
+
cats,
|
|
1493
|
+
plot,
|
|
1494
|
+
size,
|
|
1495
|
+
leftMargin: area.leftMargin,
|
|
1496
|
+
outsideRankBand,
|
|
1497
|
+
endpointLeaderAnchors,
|
|
1498
|
+
labelRequests,
|
|
1499
|
+
labelFont: text.nameFont,
|
|
1500
|
+
highlights,
|
|
1501
|
+
warnings,
|
|
1502
|
+
valueWidth: (label) => valueWidths.get(`${label.s.id}:${label.ci}`) ?? 0
|
|
1503
|
+
}), placeBumpTieLabels({ strings: domain.options.strings, bump: domain.bumpDerived, marks, outsideRankBand, labelRequests, font: text.tickFont, measure }), placePointValueLabels(valueInput), isStacked || seatValuesOffGapGuides(domain, area, reserves.annList, labelRequests, labelH);
|
|
1504
|
+
let grounds = scene.rendered.areaOutlines.filter((outline) => !outline.stacked).map((outline) => ({ seriesId: outline.seriesId, ...screenEdges(outline.top, outline.bottom), paint: outline.paint, ...outline.forecast ? { pattern: "hatch45" } : {} }));
|
|
1505
|
+
seatValuesOnGround(labelRequests, grounds, 2, (ground) => ground.pattern ? effectiveFill(paints.css(ground.paint), ground.pattern, env.theme) : paints.css(ground.paint), !shadesFills(reserves.annList));
|
|
1506
|
+
for (let request of labelRequests) {
|
|
1507
|
+
if (request.kind !== "point") continue;
|
|
1508
|
+
let ci = domain.lastIdxOf.get(request.owner.seriesId ?? "");
|
|
1509
|
+
ci !== void 0 && request.owner.categoryId === cats[ci]?.id && (request.font = { ...request.font, weight: focusValue && highlights.has(request.owner.seriesId ?? "") ? focusValue.weight : labelFont.weight }, request.fontStep = request.font);
|
|
1510
|
+
}
|
|
1511
|
+
domain.labelModes.values !== "none" && text.contentOf("point", ["absolute"]) !== null && addFanEdgeLabels(domain, area, marks, labelFont, labelH, labelRequests, measure), joinTieValues({ bump: domain.bumpDerived, labelRequests, font: text.tickFont, measure });
|
|
1512
|
+
let xPartial = xPartialWords(env, domain, area, reserves, lineToDateIds(env, domain, text)), catLabelsShown = area.xTicks && area.xOfValue ? placeXTickLabels({
|
|
1513
|
+
show: area.showCategoryTickRow,
|
|
1514
|
+
plan: area.xTicks,
|
|
1515
|
+
xOf: area.xOfValue,
|
|
1516
|
+
row: area.frame.plot,
|
|
1517
|
+
bottom: plot.y + plot.h + area.categoryTickGap,
|
|
1518
|
+
plotRight: plot.x + plot.w,
|
|
1519
|
+
labelRequests,
|
|
1520
|
+
...xPartial
|
|
1521
|
+
}) : placeCategoryLabels({
|
|
1522
|
+
show: area.showCategoryTickRow,
|
|
1523
|
+
plan: area.catPlan,
|
|
1524
|
+
cats,
|
|
1525
|
+
xOf,
|
|
1526
|
+
plot: { ...plot, h: plot.h + area.categoryTickGap - 6 },
|
|
1527
|
+
labelRequests
|
|
1528
|
+
});
|
|
1529
|
+
return { labelRequests, ratioTierRequestState, endpointLeaderAnchors, catLabelsShown, xPartialGroups: xPartial.partial?.groups ?? [], endpointFallback: bounded?.fallback ?? !1, endpointWiden: bounded?.widen ?? !1 };
|
|
1530
|
+
}
|
|
1531
|
+
function xPartialWords(env, domain, area, reserves, onValues) {
|
|
1532
|
+
let { cats, options } = domain;
|
|
1533
|
+
if (!domain.x || !area.xTicks || disclosuresShown(options)) return {};
|
|
1534
|
+
let text = options.strings?.toDate ?? chartString(options, "toDate"), shown = cats.flatMap((c, ci) => c.partial === !0 && !onValues.has(c.id) && !saysToDate(c.label ?? c.id, text) && domain.drawnSeries.some((s) => (s.vals[ci]?.v ?? null) !== null && !(reserves.keyValues.has(s.id) && domain.lastIdxOf.get(s.id) === ci)) ? [{ at: domain.x.model.xs[ci], name: c.label ?? c.id }] : []);
|
|
1535
|
+
return shown.length ? { partial: { at: shown.map((item) => item.at), names: shown.map((item) => item.name), text, w: env.measure(text, area.xTicks.font).width } } : {};
|
|
1536
|
+
}
|
|
1537
|
+
function addFanEdgeLabels(domain, area, marks, font, labelH, labelRequests, measure) {
|
|
1538
|
+
if (!marks.fan?.length || fanEdgeInKey(domain)) return;
|
|
1539
|
+
let edge = outerFanEdge(domain, marks.fan);
|
|
1540
|
+
if (!edge) return;
|
|
1541
|
+
let outer = marks.fan[edge.index], { ci } = edge;
|
|
1542
|
+
for (let [id, value] of [[outer.high, edge.high], [outer.low, edge.low]]) {
|
|
1543
|
+
let text = domain.fmt(value), w = measure(text, font).width, px = area.xOf(ci), py = area.y(value), categoryId = domain.cats[ci].id;
|
|
1544
|
+
labelRequests.push({
|
|
1545
|
+
id: `fan-edge:${id}`,
|
|
1546
|
+
kind: "point",
|
|
1547
|
+
owner: { seriesId: id, categoryId },
|
|
1548
|
+
text,
|
|
1549
|
+
lines: [text],
|
|
1550
|
+
typeRole: "label",
|
|
1551
|
+
font,
|
|
1552
|
+
priority: PRIORITY.extreme,
|
|
1553
|
+
candidates: [
|
|
1554
|
+
{ slot: "right", rect: { x: px + 6, y: py - labelH / 2, w, h: labelH }, penalty: 0 },
|
|
1555
|
+
{ slot: id === outer.high ? "above" : "below", rect: { x: px - w / 2, y: id === outer.high ? py - labelH - 4 : py + 4, w, h: labelH }, penalty: 1 }
|
|
1556
|
+
],
|
|
1557
|
+
anchor: { x: px, y: py }
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
function seatValuesOffGapGuides(domain, area, annotations, labelRequests, labelH) {
|
|
1562
|
+
let last = domain.cats[domain.cats.length - 1];
|
|
1563
|
+
if (!last) return;
|
|
1564
|
+
let ci = domain.cats.length - 1;
|
|
1565
|
+
for (let pair of gapBracketPairs(annotations, last.id, domain.options.gapFill?.between, domain.options[GAP_BRACKET_REFUSED])) {
|
|
1566
|
+
let ends = pair.map((id) => {
|
|
1567
|
+
let series = domain.drawnSeries.find((s) => s.id === id), value = series ? domain.pv[domain.rowOf.get(series)][ci] : null;
|
|
1568
|
+
return series && value !== null && value !== void 0 ? { id, py: area.y(value) } : void 0;
|
|
1569
|
+
});
|
|
1570
|
+
if (!(!ends[0] || !ends[1] || Math.abs(ends[0].py - ends[1].py) < 1))
|
|
1571
|
+
for (let end of ends) {
|
|
1572
|
+
let request = labelRequests.find((r) => r.kind === "point" && r.owner.seriesId === end.id && r.owner.categoryId === last.id), w = request?.candidates[0]?.rect.w;
|
|
1573
|
+
if (!request || w === void 0) continue;
|
|
1574
|
+
let over = end.py < Math.max(ends[0].py, ends[1].py);
|
|
1575
|
+
request.candidates = [
|
|
1576
|
+
{ slot: over ? "overGuide" : "underGuide", rect: { x: area.xOf(ci) + 7, y: over ? end.py - labelH - 2 : end.py + 2, w, h: labelH }, penalty: -1 },
|
|
1577
|
+
...request.candidates
|
|
1578
|
+
];
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
// src/core/charts/line/footnotes.ts
|
|
1584
|
+
function lineFrameFootnotes(input) {
|
|
1585
|
+
let { fan, cats, bumpDerived, nearZeroTail, options } = input, mixed = input.mixedSign ?? [], rebase = (input.rebaseSuppressed ?? []).map((s) => stringFields(s.zero ? options.strings.rebaseZero : options.strings.rebaseMissing, { series: s.series, period: s.period }));
|
|
1586
|
+
return [
|
|
1587
|
+
...partialFootnotes(cats, options.strings, input.partialNamed),
|
|
1588
|
+
...missingStackNote(cats, input.incompleteStack ?? [], options, input.footer),
|
|
1589
|
+
...missingStackNote(cats, input.knownParts ?? [], options, input.footer, options.strings.knownPartsShares),
|
|
1590
|
+
...(options.mode === "compact" && rebase.length ? [rebase.join(" ")] : rebase).map(disclosureNote),
|
|
1591
|
+
// The n.m. at the baseline says what; this line says why.
|
|
1592
|
+
...mixed.length > 0 ? [disclosureNote(stringFields(options.strings.mixedShares, { categories: mixed.map((c) => c.label ?? c.id).join(", ") }))] : [],
|
|
1593
|
+
...fanGapNote(fan, cats, options.strings),
|
|
1594
|
+
...bumpOmittedNote(input.bumpOmitted ?? [], bumpDerived, cats, options),
|
|
1595
|
+
...options.methodNote === !0 ? bumpMethodNote(bumpDerived, options.format, options.strings) : [],
|
|
1596
|
+
...nearZeroTailNote(nearZeroTail),
|
|
1597
|
+
...authoredNotes(options)
|
|
1598
|
+
];
|
|
1599
|
+
}
|
|
1600
|
+
function missingStackNote(cats, incomplete, options, footer, template = options.strings.missingStack) {
|
|
1601
|
+
if (!incomplete.length) return [];
|
|
1602
|
+
let missing = new Set(incomplete.map((c) => c.id)), runs = [];
|
|
1603
|
+
for (let i = 0; i < cats.length; i++) {
|
|
1604
|
+
if (!missing.has(cats[i].id)) continue;
|
|
1605
|
+
let first = i;
|
|
1606
|
+
for (; i + 1 < cats.length && missing.has(cats[i + 1].id); ) i++;
|
|
1607
|
+
let name = (at) => cats[at].label ?? cats[at].id;
|
|
1608
|
+
runs.push({ text: first === i ? name(i) : `${name(first)}\u2013${name(i)}`, count: i - first + 1 });
|
|
1609
|
+
}
|
|
1610
|
+
let { width, font, measure } = footer, count = Math.min(runs.length, noteCap(options, runs.length)), sentence = () => {
|
|
1611
|
+
let shown = runs.slice(0, count), left = incomplete.length - shown.reduce((sum, run) => sum + run.count, 0), categories = [...shown.map((run) => run.text), ...left ? [moreListedText(left, options, shown.length === 0)] : []].join(", ");
|
|
1612
|
+
return stringFields(template, { categories });
|
|
1613
|
+
};
|
|
1614
|
+
for (; count > 1 && measure(sentence(), font).width > width; ) count--;
|
|
1615
|
+
return [disclosureNote(sentence())];
|
|
1616
|
+
}
|
|
1617
|
+
function bumpOmittedNote(omitted, bump, cats, options) {
|
|
1618
|
+
if (omitted.length === 0 || !bump) return [];
|
|
1619
|
+
let last = cats.length - 1, period = cats[last].label ?? cats[last].id, entries = omitted.map((s) => {
|
|
1620
|
+
let rank = bump.ranks[s.id]?.[last];
|
|
1621
|
+
return rank == null ? `${s.label} (${options.strings.noRank})` : `${s.label} ${rank}`;
|
|
1622
|
+
});
|
|
1623
|
+
return [disclosureNote(stringFields(options.strings.rankOmitted, { period, count: bump.participants[cats[last].id], entries: entries.join(", ") }))];
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
// src/core/charts/line/plot.ts
|
|
1627
|
+
var BUMP_MIN_STEP = NATURAL_BAND_STEP / 2;
|
|
1628
|
+
function sigRound(v, digits = 10) {
|
|
1629
|
+
if (v === null || !Number.isFinite(v) || v === 0) return v;
|
|
1630
|
+
let m = Math.pow(10, digits - 1 - Math.floor(Math.log10(Math.abs(v))));
|
|
1631
|
+
return Math.round(v * m) / m;
|
|
1632
|
+
}
|
|
1633
|
+
function lineReserves(env, domain, paints, text, warnings) {
|
|
1634
|
+
let { isBump, measure, size, highlights } = env, { options, variant, isArea, drawnSeries, cats, pv, rowOf, rebased, absOf, labelModes } = domain, { labelFont, labelH, composeText, printsZero } = text, valueContent = text.contentOf("point", defaultValueContent(variant, labelModes.seriesValueContent)) ?? [], keyValues = /* @__PURE__ */ new Map();
|
|
1635
|
+
if (usesEndLabelKey(options) && labelModes.values !== "none" && valueContent.length > 0)
|
|
1636
|
+
for (let s of drawnSeries) {
|
|
1637
|
+
let ci = domain.lastIdxOf.get(s.id);
|
|
1638
|
+
if (ci === void 0) continue;
|
|
1639
|
+
let cell = s.vals[ci];
|
|
1640
|
+
if (cell.labelOverride !== void 0) continue;
|
|
1641
|
+
let value = rebased ? pv[rowOf.get(s)][ci] : absOf(s, ci), source = rebased ? void 0 : cell.format ? { ...s, format: cell.format } : s, printed = text.composeEndText(
|
|
1642
|
+
valueContent,
|
|
1643
|
+
value,
|
|
1644
|
+
variant === "stacked100-area" && !domain.sharesWithheld.has(cats[ci].id) ? domain.labelPv[rowOf.get(s)][ci] : null,
|
|
1645
|
+
cats[ci].label ?? cats[ci].id,
|
|
1646
|
+
"",
|
|
1647
|
+
endUnitSuffix(options, rebased),
|
|
1648
|
+
cell.isPct,
|
|
1649
|
+
source,
|
|
1650
|
+
cats[ci].id
|
|
1651
|
+
);
|
|
1652
|
+
if (domain.x?.range && isArea && labelModes.values === "ends") {
|
|
1653
|
+
let first = pv[rowOf.get(s)].findIndex((value2) => value2 !== null);
|
|
1654
|
+
if (first >= 0 && first !== ci && s.vals[first].labelOverride === void 0) {
|
|
1655
|
+
let firstCell = s.vals[first], firstSource = rebased ? void 0 : firstCell.format ? { ...s, format: firstCell.format } : s, start = text.composeEndText(
|
|
1656
|
+
valueContent,
|
|
1657
|
+
rebased ? pv[rowOf.get(s)][first] : absOf(s, first),
|
|
1658
|
+
variant === "stacked100-area" && !domain.sharesWithheld.has(cats[first].id) ? domain.labelPv[rowOf.get(s)][first] : null,
|
|
1659
|
+
cats[first].label ?? cats[first].id,
|
|
1660
|
+
"",
|
|
1661
|
+
endUnitSuffix(options, rebased),
|
|
1662
|
+
firstCell.isPct,
|
|
1663
|
+
firstSource,
|
|
1664
|
+
cats[first].id
|
|
1665
|
+
);
|
|
1666
|
+
start && (printed = printed ? `${start} \u2192 ${printed}` : start);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
let words = options.strings?.toDate ?? chartString(options, "toDate");
|
|
1670
|
+
printed && keyValues.set(s.id, domain.x && cats[ci].partial === !0 && !saysToDate(cats[ci].label ?? cats[ci].id, words) ? `${printed} ${words}` : printed);
|
|
1671
|
+
}
|
|
1672
|
+
let categoryEndRoom = pointLabelEndRoom({
|
|
1673
|
+
valueLabels: labelModes.values,
|
|
1674
|
+
valueLabelsAuthored: options.valueLabels !== void 0,
|
|
1675
|
+
labelOnly: domain.labelOnly,
|
|
1676
|
+
lastWithheld: /* @__PURE__ */ new Set(),
|
|
1677
|
+
valueContent,
|
|
1678
|
+
variant,
|
|
1679
|
+
contentOf: text.contentOf,
|
|
1680
|
+
drawnSeries,
|
|
1681
|
+
pv,
|
|
1682
|
+
rowOf,
|
|
1683
|
+
cats,
|
|
1684
|
+
rebased,
|
|
1685
|
+
composeText,
|
|
1686
|
+
composeEndText: text.composeEndText,
|
|
1687
|
+
absOf,
|
|
1688
|
+
measure,
|
|
1689
|
+
labelFont,
|
|
1690
|
+
highlights,
|
|
1691
|
+
sharesWithheld: domain.sharesWithheld,
|
|
1692
|
+
...valueUnit(options, isBump, rebased),
|
|
1693
|
+
isStacked: domain.isStacked,
|
|
1694
|
+
flagged: flaggedPoints(domain),
|
|
1695
|
+
...domain.x ? { endToDate: { ids: lineToDateIds(env, domain, text), words: options.strings?.toDate ?? chartString(options, "toDate"), theme: env.theme, measure } } : {}
|
|
1696
|
+
});
|
|
1697
|
+
isArea && (categoryEndRoom.left = categoryEndRoom.right = 0), options.latestPoint !== void 0 && options.latestPoint !== "none" && (categoryEndRoom.right = Math.max(categoryEndRoom.right, latestRingReach(env.theme) + PLOT_END_AIR)), domain.x && (domain.x.shown[0] > domain.x.lo && (categoryEndRoom.left = 0), domain.x.shown[domain.x.shown.length - 1] < domain.x.hi && (categoryEndRoom.right = 0));
|
|
1698
|
+
let bumpFolded = options[BUMP_FOLDED], endpointInput = {
|
|
1699
|
+
options,
|
|
1700
|
+
names: labelModes.series,
|
|
1701
|
+
valueContent,
|
|
1702
|
+
endRoom: categoryEndRoom.right,
|
|
1703
|
+
labelOnly: domain.labelOnly,
|
|
1704
|
+
variant,
|
|
1705
|
+
isBump,
|
|
1706
|
+
isArea,
|
|
1707
|
+
drawnSeries,
|
|
1708
|
+
cats,
|
|
1709
|
+
mergeEndValues: labelModes.values !== "none" && text.contentOf("point", ["absolute"]) !== null,
|
|
1710
|
+
lastIdxOf: domain.lastIdxOf,
|
|
1711
|
+
pv: domain.labelPv,
|
|
1712
|
+
rowOf,
|
|
1713
|
+
rebased,
|
|
1714
|
+
absOf,
|
|
1715
|
+
composeText: text.composeEndText,
|
|
1716
|
+
printsZero,
|
|
1717
|
+
// The endpoint swatch tells lines apart; a lone fan centre needs none.
|
|
1718
|
+
heroMode: paints.heroMode && drawnSeries.length >= 2,
|
|
1719
|
+
anyHighlight: env.anyHighlight,
|
|
1720
|
+
size,
|
|
1721
|
+
labelFont: text.nameFont,
|
|
1722
|
+
labelH,
|
|
1723
|
+
measure,
|
|
1724
|
+
sharesWithheld: domain.sharesWithheld,
|
|
1725
|
+
// each name column keeps 8px to the canvas and 6px to its rank tick or line end.
|
|
1726
|
+
...isBump ? { bumpNameRoom: size.width - cats.length * NATURAL_BAND_STEP - measureValueAxisWidth([1, domain.bumpLadderMax], String, env.theme, measure, 5, void 0, [1, domain.bumpLadderMax]) - 28 } : {},
|
|
1727
|
+
...bumpFolded ? { bumpFolded } : {},
|
|
1728
|
+
// The story names print bold (assembleLineGeometry).
|
|
1729
|
+
// A grey-highlighted line chart names its focus series bold too.
|
|
1730
|
+
...isBump && env.anyHighlight && options.highlightMode !== "fade" || lineFocusFont(env, domain, text.nameFont, 0) ? { bumpStory: { ids: env.highlights, font: { ...text.nameFont, weight: emphasisWeight(env.theme) } } } : {}
|
|
1731
|
+
}, endpoint = prepareEndpointLabels(endpointInput), built = buildBumpStartLabels({
|
|
1732
|
+
// A focused bump names only the lines it draws; the note names the rest.
|
|
1733
|
+
isBump,
|
|
1734
|
+
endContent: endpoint.endContent,
|
|
1735
|
+
dataSeries: domain.drawnSeries,
|
|
1736
|
+
pv,
|
|
1737
|
+
rowOf,
|
|
1738
|
+
cats,
|
|
1739
|
+
composeText,
|
|
1740
|
+
nameBlock: endpoint.nameBlock,
|
|
1741
|
+
...bumpFolded ? { folded: bumpFolded } : {}
|
|
1742
|
+
}), bumpAxisW = isBump ? measureValueAxisWidth([1, domain.bumpLadderMax], String, env.theme, measure, 5, void 0, [1, domain.bumpLadderMax]) : 0, bumpStep = (size.width - built.startReserve - startColumnInset(options.margin?.left ?? canvasMargin(env.theme, size.width).left) - endpoint.endReserve - bumpAxisW - 28) / Math.max(1, cats.length - 1), shortOfRoom = built.startReserve > 0 && bumpStep < BUMP_MIN_STEP, startLabels = shortOfRoom ? built.startLabels.filter((label) => label.ci > 0) : built.startLabels, startReserve = shortOfRoom ? 0 : built.startReserve;
|
|
1743
|
+
shortOfRoom && (endpoint = prepareEndpointLabels({ ...endpointInput, bumpOneColumn: !0 }));
|
|
1744
|
+
let annList = options.annotations ?? [];
|
|
1745
|
+
if (isBump) {
|
|
1746
|
+
let supported = /* @__PURE__ */ new Set(["note", "callout", "event"]), dropped = annList.filter((a) => !supported.has(a.kind));
|
|
1747
|
+
dropped.length > 0 && (warnings.push({
|
|
1748
|
+
code: "bump-annotation-unsupported",
|
|
1749
|
+
severity: "warn",
|
|
1750
|
+
message: `annotation kind${dropped.length === 1 ? "" : "s"} ${[...new Set(dropped.map((a) => `'${a.kind}'`))].join(", ")} compute on values and have no meaning on a rank axis \u2014 dropped; 'note', 'callout' and 'event' are supported`
|
|
1751
|
+
}), annList = annList.filter((a) => supported.has(a.kind)));
|
|
1752
|
+
}
|
|
1753
|
+
let axisShown = options.valueAxis?.show ?? labelModes.values !== "all";
|
|
1754
|
+
variant === "stacked100-area" && text.kindSetting("percentIndicator") !== !1 && !axisShown && !annList.some((a) => a.kind === "indicator100") && (annList = [...annList, { kind: "indicator100", side: "left", id: "indicator100-auto", priority: PRIORITY.endpoint }]);
|
|
1755
|
+
let indicatorW = measure("100%", text.tickFont).width + 16, lastId = cats[cats.length - 1]?.id;
|
|
1756
|
+
return {
|
|
1757
|
+
endpoint,
|
|
1758
|
+
keyValues,
|
|
1759
|
+
categoryEndRoom,
|
|
1760
|
+
startLabels,
|
|
1761
|
+
startReserve,
|
|
1762
|
+
annList,
|
|
1763
|
+
namesAtPlotEdge: isBump || domain.x?.range?.cut.hi === !0 || annList.some((a) => a.kind === "band" && (a.divider === "end" || a.divider === "both") && a.to === lastId),
|
|
1764
|
+
indicatorLeftReserve: annList.some((a) => a.kind === "indicator100" && (a.side ?? "left") === "left") ? indicatorW : 0,
|
|
1765
|
+
indicatorRightReserve: annList.some((a) => a.kind === "indicator100" && a.side === "right") ? indicatorW : 0,
|
|
1766
|
+
referenceBands: planReferenceBandColumn(options.referenceBands, size.width, text.tickFont, measure)
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
var SIDE_KEY_MIN_WIDTH = 480, THIN_TOP_AIR = 6;
|
|
1770
|
+
function lineLegend(theme, domain, paints, _text, reserves, warnings, width) {
|
|
1771
|
+
let { options, labelModes, refSeries, drawnSeries, fan, isArea } = domain, { fanPaints, fanLadder } = paints, legendPosition = typeof options.legend == "object" ? options.legend.position : options.legend, boundedKey = usesEndLabelKey(options), anomalyKeys = domain.anomaly ? anomalyLegendItems(theme, domain.anomaly.model, domain.anomaly.corridorShown, domain.anomaly.statFmt, columnCorridorPaint(options.colorblindSafe), options.strings, options.locale?.language) : [], gapSeries = options.gapFill?.between ?? [], gapKeys = (labelModes.series === "end" || labelModes.series === "inline") && !boundedKey && !reserves.endpoint.endpointLegendFallback && gapSeries.every((id) => labelModes.only === void 0 || labelModes.only.has(id)) && (options.gapFill?.positiveTone ?? "good") === "neutral" && (options.gapFill?.negativeTone ?? "bad") === "neutral" ? [] : gapFillLegendItems(domain), trendKeys = lineTrendKeys(theme, domain, paints), droppedKeys = disclosuresShown(options) && !domain.rebaseCompact ? [] : domain.rebaseSuppressed.map((s) => omittedKey(s.id, stringFields(s.zero ? options.strings.rebaseZero : options.strings.rebaseMissing, { series: s.series, period: s.period }))), narrow = width <= SIDE_KEY_MIN_WIDTH, legendOption = boundedKey ? narrow || legendPosition === "none" || domain.x?.range && (isArea || fan) ? "top" : "right" : reserves.endpoint.endpointLegendFallback ? legendPosition === "top" || legendPosition === "bottom" ? legendPosition : "top" : labelModes.series === "key" && (legendPosition === void 0 || legendPosition === "none") ? "top" : options.legend ?? (fanPaints || anomalyKeys.length > 0 || gapKeys.length > 0 || trendKeys.length > 0 || droppedKeys.length > 0 && !domain.rebaseCompact ? "top" : void 0);
|
|
1772
|
+
if (trendKeys.length > 0 && (legendPosition === "none" || legendPosition === "auto") && warnings.push({
|
|
1773
|
+
code: "legend-suppressed-encoding",
|
|
1774
|
+
severity: "warn",
|
|
1775
|
+
field: ["options", "legend"],
|
|
1776
|
+
message: "the legend hides the trend names, slopes and r\xB2; set legend to top, bottom or right"
|
|
1777
|
+
}), anomalyKeys.length > 0 && legendOption === "none" && warnings.push({
|
|
1778
|
+
code: "legend-suppressed-encoding",
|
|
1779
|
+
severity: "warn",
|
|
1780
|
+
message: "legend: 'none' suppressed the only key naming this exhibit's encodings (the anomaly corridor and flag marker) \u2014 the reader is left to infer them",
|
|
1781
|
+
suggest: "drop legend: 'none', or drop anomaly"
|
|
1782
|
+
}), fanPaints && (legendOption === void 0 || legendOption === "none")) {
|
|
1783
|
+
let n = fan.bands.length;
|
|
1784
|
+
warnings.push({
|
|
1785
|
+
code: "fan-legend-suppressed",
|
|
1786
|
+
severity: "warn",
|
|
1787
|
+
message: `legend 'none' leaves ${n} uncertainty band${n === 1 ? "" : "s"} on the page with nothing saying what ${n === 1 ? "it means" : "they mean"} \u2014 '${fan.bands.map((b) => b.label).join("', '")}' are drawn identically to any other interval`,
|
|
1788
|
+
suggest: "set legend to 'top' (the default when a fan is present), or remove options.fan"
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
if (!legendOption || legendOption === "none" || legendOption === "auto") return;
|
|
1792
|
+
let legendOpts = normalizeLegendOption(legendOption), items = [
|
|
1793
|
+
...drawnSeries.flatMap((s, i) => {
|
|
1794
|
+
let dropped = droppedKeys.find((item) => item.id === s.id);
|
|
1795
|
+
if (dropped) return [dropped];
|
|
1796
|
+
let points = domain.pv[domain.rowOf.get(s)].flatMap((v, ci) => v === null ? [] : [ci]);
|
|
1797
|
+
if (!(points.some((ci, j) => j > 0 && (s.interpolateGaps || ci === points[j - 1] + 1)) || domain.x?.range && rangeRuns(domain.x.range, [domain.x.range.plotted[domain.rowOf.get(s)]], domain.interpolationFor(s), s.interpolateGaps).some((run) => run[0].points.length >= 2)) && !(isArea && domain.isStacked)) {
|
|
1798
|
+
let ci = points.find((ci2) => paints.markerOf(s, i, ci2) !== "none");
|
|
1799
|
+
if (ci === void 0) return [];
|
|
1800
|
+
let shape2 = paints.markerOf(s, i, ci), paint = paints.series(s, i), hollow = paints.hollowAt(s, ci);
|
|
1801
|
+
return [{
|
|
1802
|
+
id: s.id,
|
|
1803
|
+
label: s.label,
|
|
1804
|
+
paint: hollow ? { token: "background" } : paint,
|
|
1805
|
+
...hollow ? { stroke: paint } : {},
|
|
1806
|
+
key: shape2 === "square" ? "box" : shape2 === "triangle" || shape2 === "diamond" ? shape2 : "marker"
|
|
1807
|
+
}];
|
|
1808
|
+
}
|
|
1809
|
+
let full = isArea ? [] : points.filter((ci) => domain.cats[ci].partial !== !0 && paints.markerOf(s, i, ci) !== "none"), shape = full.length > 0 ? paints.markerOf(s, i, full[0]) : "none";
|
|
1810
|
+
return [{
|
|
1811
|
+
id: s.id,
|
|
1812
|
+
label: s.label,
|
|
1813
|
+
paint: paints.keyPaint(s, i),
|
|
1814
|
+
key: isArea ? "box" : "line",
|
|
1815
|
+
...isArea ? {} : { width: paints.lineWidthOf(s) },
|
|
1816
|
+
...shape !== "none" ? { marker: { shape, ...full.every((ci) => paints.hollowAt(s, ci)) ? { hollow: !0 } : {} } } : {},
|
|
1817
|
+
...paints.lineHollowOf(s) ? { hollow: !0, width: paints.lineWidthOf(s) } : {},
|
|
1818
|
+
...!isArea && paints.legendDashOf(s, i) ? { dash: paints.legendDashOf(s, i), lineCap: paints.legendDashOf(s, i)?.join(",") === dashToken(theme, "dotted").join(",") ? "round" : "butt" } : {}
|
|
1819
|
+
}];
|
|
1820
|
+
}),
|
|
1821
|
+
...refSeries.map((s) => ({ id: s.id, label: s.label, paint: paints.ref(s), key: "line", width: strokeToken(theme, "rule"), dash: dashToken(theme, "reference") })),
|
|
1822
|
+
// Band keys after the data series, outermost first, only for bands that
|
|
1823
|
+
// paint. The ladder is measured for a WASH; at 9x9px adjacent rungs read as
|
|
1824
|
+
// one smudge, so each chip gets an edge in the centre's own ink.
|
|
1825
|
+
...fanPaints ? fan.bands.map((band, bi) => ({ id: `fan:${bi}`, label: band.label, paint: fanLadder[bi].paint, key: "box", stroke: paints.fanCentrePaint })) : [],
|
|
1826
|
+
// ONE key for the bound hairlines, not 2n: every hairline means the same
|
|
1827
|
+
// thing, "a bound the author stated".
|
|
1828
|
+
...fanPaints && fan.showBounds ? [{ id: "fan:bounds", label: options.strings.declaredBounds, paint: fanLadder[fan.bands.length].paint, key: "line", width: strokeToken(theme, "rule"), dash: dashToken(theme, "dotted"), lineCap: "round" }] : [],
|
|
1829
|
+
...anomalyKeys,
|
|
1830
|
+
...gapKeys,
|
|
1831
|
+
...trendKeys,
|
|
1832
|
+
...droppedKeys.filter((item) => !drawnSeries.some((s) => s.id === item.id))
|
|
1833
|
+
];
|
|
1834
|
+
if (boundedKey) {
|
|
1835
|
+
let fanEdge = fanEdgeInKey(domain) && fanPaints ? outerFanEdge(domain, fan.bands.map((band) => ({ low: band.low.id, high: band.high.id }))) : void 0;
|
|
1836
|
+
items = items.filter((item) => !labelModes.only || labelModes.only.has(item.id) || !drawnSeries.some((s) => s.id === item.id)).map((item) => {
|
|
1837
|
+
if (fanEdge && item.id === `fan:${fanEdge.index}`) {
|
|
1838
|
+
let category2 = domain.cats[fanEdge.ci].label ?? domain.cats[fanEdge.ci].id;
|
|
1839
|
+
return { ...item, label: `${item.label}${fanEdge.ci < domain.cats.length - 1 ? ` (${category2})` : ""} ${numberRange(domain.fmt(fanEdge.low), domain.fmt(fanEdge.high))}` };
|
|
1840
|
+
}
|
|
1841
|
+
let s = drawnSeries.find((s2) => s2.id === item.id), ci = s && domain.lastIdxOf.get(s.id);
|
|
1842
|
+
if (!s || ci === void 0 || !reserves.keyValues.has(s.id)) return item;
|
|
1843
|
+
let content = _text.contentOf("point", defaultValueContent(domain.variant, domain.labelModes.seriesValueContent)) ?? [], category = domain.cats[ci].label ?? domain.cats[ci].id, printed = reserves.keyValues.get(s.id);
|
|
1844
|
+
return { ...item, label: `${item.label}${ci < domain.cats.length - 1 && !content.includes("category") ? ` (${category})` : ""}${printed ? ` ${printed}` : ""}` };
|
|
1845
|
+
}).sort((a, b) => (domain.endpoints[b.id]?.value ?? -1 / 0) - (domain.endpoints[a.id]?.value ?? -1 / 0));
|
|
1846
|
+
}
|
|
1847
|
+
if (legendOpts.order && !boundedKey) {
|
|
1848
|
+
let oi = (id) => {
|
|
1849
|
+
let k = legendOpts.order.indexOf(id);
|
|
1850
|
+
return k === -1 ? Number.MAX_SAFE_INTEGER : k;
|
|
1851
|
+
};
|
|
1852
|
+
items = [...items].sort((a, b) => oi(a.id) - oi(b.id));
|
|
1853
|
+
}
|
|
1854
|
+
if (options.legend === void 0 && !domain.bumpDerived && labelModes.series === "end" && !boundedKey) {
|
|
1855
|
+
let named = new Set(reserves.endpoint.endLabels.filter((label) => !label.shared).map((label) => label.s.id));
|
|
1856
|
+
items = items.filter((item) => !named.has(item.id));
|
|
1857
|
+
}
|
|
1858
|
+
return items.length > 0 ? { options: legendOpts, items } : void 0;
|
|
1859
|
+
}
|
|
1860
|
+
function gapFillLegendItems(domain) {
|
|
1861
|
+
let spec = domain.options.gapFill;
|
|
1862
|
+
if (!spec) return [];
|
|
1863
|
+
let a = domain.drawnSeries.find((series) => series.id === spec.between[0]), b = domain.drawnSeries.find((series) => series.id === spec.between[1]);
|
|
1864
|
+
if (!a || !b) return [];
|
|
1865
|
+
let rowA = domain.pv[domain.rowOf.get(a)], rowB = domain.pv[domain.rowOf.get(b)], sides = new Set(domain.cats.flatMap((_, ci) => {
|
|
1866
|
+
let [va, vb] = [rowA[ci], rowB[ci]];
|
|
1867
|
+
return va == null || vb === null || vb === void 0 || va === vb ? [] : [va > vb ? "positive" : "negative"];
|
|
1868
|
+
})), toneOf = (side) => side === "positive" ? spec.positiveTone ?? "good" : spec.negativeTone ?? "bad";
|
|
1869
|
+
if (sides.size === 2 && toneOf("positive") === toneOf("negative")) {
|
|
1870
|
+
let tone = toneOf("positive");
|
|
1871
|
+
return [{ id: "gap", label: stringFields(domain.options.strings.gapBetween, { first: a.label, second: b.label }), paint: gapFillPaint(tone), key: "box" }];
|
|
1872
|
+
}
|
|
1873
|
+
return ["positive", "negative"].filter((side) => sides.has(side)).map((side) => {
|
|
1874
|
+
let tone = toneOf(side);
|
|
1875
|
+
return {
|
|
1876
|
+
id: `gap:${side}`,
|
|
1877
|
+
label: stringFields(side === "positive" ? domain.options.strings.aboveSeries : domain.options.strings.belowSeries, { first: a.label, second: b.label }),
|
|
1878
|
+
// The same paint the gap region draws with (difference.ts addGapRegion).
|
|
1879
|
+
paint: gapFillPaint(tone),
|
|
1880
|
+
key: "box"
|
|
1881
|
+
};
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
var startColumnInset = (frameLeft) => Math.max(0, frameLeft - 8);
|
|
1885
|
+
function solveLineFrame(env, domain, paints, text, reserves, warnings, eventKey) {
|
|
1886
|
+
let { theme, size, isBump, measure } = env, { options, cats, seriesNorm } = domain, frameOptions = withCategoryNoteNames(options, cats), tokenMargin = canvasMargin(theme, size.width), authoredLeft = options.margin?.left ?? tokenMargin.left, leftMargin = Math.max(authoredLeft, reserves.indicatorLeftReserve, reserves.startReserve > 0 ? reserves.startReserve + startColumnInset(authoredLeft) : 0), margin = {
|
|
1887
|
+
top: tokenMargin.top,
|
|
1888
|
+
bottom: ratioTierCanRender(options.ratioTier, cats, seriesNorm) ? 3 : tokenMargin.bottom,
|
|
1889
|
+
...options.margin,
|
|
1890
|
+
left: authoredLeft,
|
|
1891
|
+
right: (options[GAP_BRACKET_RESERVE] ?? 0) + Math.max(
|
|
1892
|
+
options.margin?.right ?? tokenMargin.right,
|
|
1893
|
+
reserves.endpoint.endReserve,
|
|
1894
|
+
reserves.indicatorRightReserve,
|
|
1895
|
+
reserves.referenceBands?.reserve ?? 0,
|
|
1896
|
+
options[VALUE_LINE_RESERVE] ?? 0,
|
|
1897
|
+
// The anomaly rules carry their numbers right of the plot, as on column.
|
|
1898
|
+
domain.anomaly ? anomalyRuleReserve(anomalyRuleLines(theme, domain.anomaly.model, domain.anomaly.corridorShown, domain.anomaly.statFmt, { token: "warn" }, options.strings), text.labelFont, measure) : 0
|
|
1899
|
+
)
|
|
1900
|
+
}, legend = lineLegend(theme, domain, paints, text, reserves, warnings, size.width), claims = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height });
|
|
1901
|
+
return { frame: solveFrame(
|
|
1902
|
+
{
|
|
1903
|
+
size,
|
|
1904
|
+
margin,
|
|
1905
|
+
plotInset: { left: leftMargin - authoredLeft },
|
|
1906
|
+
...frameTextOptions(frameOptions),
|
|
1907
|
+
// Actually ignored, not merely warned about: `bump-unit-ignored` would
|
|
1908
|
+
// be a lie if the frame still printed "in EUR m" over a rank ladder.
|
|
1909
|
+
unit: isBump ? void 0 : options.unit,
|
|
1910
|
+
footnotes: [
|
|
1911
|
+
...lineFrameFootnotes({
|
|
1912
|
+
fan: domain.fan,
|
|
1913
|
+
cats,
|
|
1914
|
+
partialNamed: lineToDateIds(env, domain, text).size > 0,
|
|
1915
|
+
bumpDerived: domain.bumpDerived,
|
|
1916
|
+
nearZeroTail: reserves.endpoint.nearZeroTail,
|
|
1917
|
+
options: frameOptions,
|
|
1918
|
+
footer: { width: size.width - margin.left - margin.right, font: { family: theme.type.family, ...footerType(theme.type.footnote, options.target, textScaleOf(options)) }, measure },
|
|
1919
|
+
mixedSign: cats.filter((c) => domain.nmCats100.has(c.id) && !domain.overfullCats100.has(c.id)),
|
|
1920
|
+
incompleteStack: domain.incompleteStack,
|
|
1921
|
+
knownParts: cats.filter((c) => domain.sharesWithheld.has(c.id)),
|
|
1922
|
+
rebaseSuppressed: domain.rebaseCompact ? [] : domain.rebaseSuppressed,
|
|
1923
|
+
bumpOmitted: domain.bumpOmitted
|
|
1924
|
+
}),
|
|
1925
|
+
// The anomaly rule, stated on the exhibit (column prints it over the plot).
|
|
1926
|
+
...domain.anomaly ? [disclosureNote(`${domain.anomaly.model.rule}${domain.anomaly.corridorNote}`)] : [],
|
|
1927
|
+
...timeZoneNote(domain, options)
|
|
1928
|
+
],
|
|
1929
|
+
legend,
|
|
1930
|
+
...eventKey ? { eventKey } : {},
|
|
1931
|
+
theme,
|
|
1932
|
+
measure
|
|
1933
|
+
},
|
|
1934
|
+
claims
|
|
1935
|
+
), claims, margin, leftMargin };
|
|
1936
|
+
}
|
|
1937
|
+
function valueAxisTicks(env, domain, frame) {
|
|
1938
|
+
let { theme, measure, isBump } = env, { options, variant, dLo, dHi, bumpDerived } = domain, va = options.valueAxis ?? {}, baselineTolerance = Math.max(1, Math.abs(dHi - dLo)) * 1e-12, discloseNonzeroBaseline = !isBump && variant === "line" && dLo > baselineTolerance, axisShown = bumpDerived ? !0 : va.show ?? domain.labelModes.values !== "all", axisFmt = bumpDerived ? (v) => String(Math.round(v)) : variant === "stacked100-area" ? (v) => formatAutomaticPercent(v, 0, !1, options.locale?.language) : domain.fmt, axisTickSpec = bumpDerived || variant === "stacked100-area" ? void 0 : domain.valueSpec.spec, bumpTicks;
|
|
1939
|
+
if (bumpDerived) {
|
|
1940
|
+
let max = domain.bumpLadderMax, stride = max > 25 ? 5 : max > 12 ? 2 : 1;
|
|
1941
|
+
bumpTicks = [];
|
|
1942
|
+
for (let rank = 1; rank <= max; rank += stride) bumpTicks.push(rank);
|
|
1943
|
+
bumpTicks[bumpTicks.length - 1] !== max && bumpTicks.push(max);
|
|
1944
|
+
}
|
|
1945
|
+
let baselineValue = sigRound(va.reverse ? dHi : dLo), valueLineTicks = domain.domainExtendingValueLines.map(({ value }) => sigRound(value)).filter((value) => value !== null && Number.isFinite(value)), disclosedTicks, stepTicks = axisShown && !bumpDerived ? domain.stepTicks : void 0;
|
|
1946
|
+
if (!bumpDerived && (discloseNonzeroBaseline || valueLineTicks.length > 0)) {
|
|
1947
|
+
let ticks = axisShown ? [...stepTicks ?? linearScale([dLo, dHi], [0, 1]).ticks(5)] : [], addTick = (value) => {
|
|
1948
|
+
let tolerance = Math.max(1, Math.abs(value)) * 1e-12;
|
|
1949
|
+
ticks.some((tick) => Math.abs(tick - value) <= tolerance) || ticks.push(value);
|
|
1950
|
+
};
|
|
1951
|
+
discloseNonzeroBaseline && addTick(baselineValue);
|
|
1952
|
+
for (let value of valueLineTicks) addTick(value);
|
|
1953
|
+
disclosedTicks = ticks.sort((left, right) => left - right);
|
|
1954
|
+
}
|
|
1955
|
+
let fullValueAxisReserve = axisShown ? bumpTicks ? measureValueAxisWidth([bumpTicks[0], bumpTicks[bumpTicks.length - 1]], axisFmt, theme, measure) : measureValueAxisWidth([dLo, dHi], axisFmt, theme, measure, 5, axisTickSpec, disclosedTicks ?? stepTicks) : 0, disclosureReserve = !axisShown && disclosedTicks ? Math.max(0, measureValueAxisWidth([dLo, dHi], axisFmt, theme, measure, 5, axisTickSpec, disclosedTicks) - frame.plot.x) : 0;
|
|
1956
|
+
return {
|
|
1957
|
+
axisShown,
|
|
1958
|
+
axisFmt,
|
|
1959
|
+
axisTickSpec,
|
|
1960
|
+
bumpTicks,
|
|
1961
|
+
disclosedTicks,
|
|
1962
|
+
stepTicks,
|
|
1963
|
+
discloseNonzeroBaseline,
|
|
1964
|
+
baselineValue,
|
|
1965
|
+
valueAxisReserve: Math.max(fullValueAxisReserve, disclosureReserve)
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
function categoryRow(env, domain, text, reserves, frame, valueAxisReserve, warnings) {
|
|
1969
|
+
if (domain.x) return continuousRow(env, domain, domain.x, text, reserves, frame, valueAxisReserve, warnings);
|
|
1970
|
+
let { theme, measure } = env, { options, cats, population } = domain, n = cats.length, warningsBefore = warnings.length, sparseComposition = domain.variant === "stacked100-area" && n <= 3 && !cats.some((_, ci) => ci > 0 && !domain.compositionInvalidAt(ci - 1) && !domain.compositionInvalidAt(ci)), crossesBetween = options.categoryAxis?.crossesBetween ?? (!domain.isArea || sparseComposition), categoryPlotX = frame.plot.x + valueAxisReserve, categoryPlotWidth = Math.max(10, frame.plot.w - valueAxisReserve), grid = population ?? domain.timeline, spanOf = (x0, width) => categorySpan({ x: x0, w: width }, grid?.span ?? n, crossesBetween, reserves.categoryEndRoom), categoryStepFor = (x0, width) => categoryStep(spanOf(x0, width).w, population ? n : grid?.span ?? n, crossesBetween), categoryCentersFor = (x0, width) => cats.map((_, ci) => liveCategoryX(ci, n, crossesBetween, spanOf(x0, width), grid)), dateTicks = options.categoryAxis?.dateTicks, ticked = dateTicks ? dateTickRow(cats, dateTicks, options.locale?.language, options.locale?.weekStartsOn) : void 0;
|
|
1971
|
+
dateTicks && ticked.ticks === null ? warnings.push({
|
|
1972
|
+
code: "date-ticks-unsupported",
|
|
1973
|
+
severity: "info",
|
|
1974
|
+
message: `categoryAxis.dateTicks '${dateTicks}' was ignored: not every category carries an ISO date, so no calendar interval can be resolved`,
|
|
1975
|
+
suggest: "give each category an ISO 'date' or drop categoryAxis.dateTicks"
|
|
1976
|
+
}) : dateTicks && dateTicks !== "weeks" && options.locale?.weekStartsOn !== void 0 && warnings.push({
|
|
1977
|
+
code: "week-start-ignored",
|
|
1978
|
+
severity: "info",
|
|
1979
|
+
message: `locale.weekStartsOn was ignored: a week boundary only decides something for dateTicks 'weeks', and the requested interval is '${dateTicks}'`,
|
|
1980
|
+
suggest: "set categoryAxis.dateTicks to 'weeks' or drop locale.weekStartsOn"
|
|
1981
|
+
});
|
|
1982
|
+
let row = categoryLabelsAndMarks(cats, { count: authoredFootnoteCount(options), warnings }, partialAxisWords(options.strings, options, lineToDateIds(env, domain, text).size > 0));
|
|
1983
|
+
ticked?.name(row);
|
|
1984
|
+
let planWith = (x0, width, fonts) => planCategoryRow({
|
|
1985
|
+
target: options.target,
|
|
1986
|
+
textScale: textScaleOf(options),
|
|
1987
|
+
...row,
|
|
1988
|
+
ordered: !0,
|
|
1989
|
+
strideFromEnd: !0,
|
|
1990
|
+
centers: categoryCentersFor(x0, width),
|
|
1991
|
+
step: categoryStepFor(x0, width),
|
|
1992
|
+
fonts,
|
|
1993
|
+
secondary: secondaryFont(theme),
|
|
1994
|
+
periods: cats.length > 0 && cats.every((c) => c.date !== void 0),
|
|
1995
|
+
measure,
|
|
1996
|
+
plotHeight: frame.plot.h,
|
|
1997
|
+
reference: { x: frame.plot.x, width: frame.plot.w },
|
|
1998
|
+
...ticked?.plan,
|
|
1999
|
+
...!crossesBetween && !domain.isArea ? { edgeAnchored: !0 } : {}
|
|
2000
|
+
}), planRow = (x0, width) => {
|
|
2001
|
+
let down = stepDownFont(theme, text.tickFont, "axis", options.target, textScaleOf(options)) ?? { ...text.tickFont, size: targetFloorsPx(options.target ?? DEFAULT_TARGET, textScaleOf(options)).axis }, plan = planWith(x0, width, [text.tickFont, down]);
|
|
2002
|
+
if (plan.maxLines <= 2 || plan.rotation !== 0) return plan;
|
|
2003
|
+
let floor = stepDownFont(theme, text.tickFont, "axis", options.target, textScaleOf(options)) ?? text.tickFont, stepped = planWith(x0, width, [floor]);
|
|
2004
|
+
return stepped.maxLines <= 2 && stepped.step !== "stride" && !stepped.infos.some((info) => info.truncated) ? stepped : plan;
|
|
2005
|
+
}, catPlan = planRow(categoryPlotX, categoryPlotWidth), dated = dateTicks || catPlan.stride <= 28 ? void 0 : dayCategories(cats);
|
|
2006
|
+
if (dated) {
|
|
2007
|
+
warnings.length = warningsBefore;
|
|
2008
|
+
let months = { ...options, categoryAxis: { ...options.categoryAxis, dateTicks: "months" } };
|
|
2009
|
+
return categoryRow(env, { ...domain, cats: dated, options: months }, text, reserves, frame, valueAxisReserve, warnings);
|
|
2010
|
+
}
|
|
2011
|
+
let categoryOverhang = rotatedLeftOverhang(catPlan, categoryCentersFor(categoryPlotX, categoryPlotWidth), 4), categoryRightOverhang = 0;
|
|
2012
|
+
if (categoryOverhang > 0 && (categoryPlotX += categoryOverhang, categoryPlotWidth -= categoryOverhang, catPlan = planRow(categoryPlotX, categoryPlotWidth)), domain.isArea && !crossesBetween && catPlan.rotation === 0) {
|
|
2013
|
+
for (let pass = 0; pass < 3 && n > 0; pass++) {
|
|
2014
|
+
let left = Math.max(0, catPlan.infos[0].w / 2 + 2 - categoryPlotX), right = Math.max(0, catPlan.infos[n - 1].w / 2 + 2 - (env.size.width - categoryPlotX - categoryPlotWidth));
|
|
2015
|
+
if (left + right < 0.01) break;
|
|
2016
|
+
categoryOverhang += left, categoryRightOverhang += right, categoryPlotX += left, categoryPlotWidth = Math.max(10, categoryPlotWidth - left - right), catPlan = planRow(categoryPlotX, categoryPlotWidth);
|
|
2017
|
+
}
|
|
2018
|
+
let centers = categoryCentersFor(categoryPlotX, categoryPlotWidth), infos = catPlan.infos;
|
|
2019
|
+
catPlan = {
|
|
2020
|
+
...catPlan,
|
|
2021
|
+
x: (ci) => centers[ci] - infos[ci].w / 2,
|
|
2022
|
+
anchor: (ci, width) => centers[ci] - width / 2
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
return { catPlan, categoryOverhang, categoryRightOverhang, crossesBetween, intervalTicks: ticked?.ticks ?? void 0 };
|
|
2026
|
+
}
|
|
2027
|
+
function continuousRow(env, domain, x, text, reserves, frame, valueAxisReserve, warnings) {
|
|
2028
|
+
let plotX = frame.plot.x + valueAxisReserve, span = categorySpan({ x: plotX, w: Math.max(10, frame.plot.w - valueAxisReserve) }, 2, !1, reserves.categoryEndRoom), xTicks = planXTicks({
|
|
2029
|
+
model: x.model,
|
|
2030
|
+
lo: x.lo,
|
|
2031
|
+
hi: x.hi,
|
|
2032
|
+
xOf: (value) => span.x + (value - x.lo) / (x.hi - x.lo) * span.w,
|
|
2033
|
+
left: frame.plot.x,
|
|
2034
|
+
right: frame.plot.x + frame.plot.w,
|
|
2035
|
+
font: text.secondaryFont,
|
|
2036
|
+
measure: env.measure,
|
|
2037
|
+
weekStartsOn: domain.options.locale?.weekStartsOn,
|
|
2038
|
+
warnings,
|
|
2039
|
+
partialRow: domain.options[X_PARTIAL_ROW] === !0
|
|
2040
|
+
});
|
|
2041
|
+
return { catPlan: xTickRowPlan(xTicks), categoryOverhang: 0, categoryRightOverhang: 0, crossesBetween: !1, intervalTicks: void 0, xTicks };
|
|
2042
|
+
}
|
|
2043
|
+
function categoryStep(width, n, between) {
|
|
2044
|
+
return between ? width / n : n > 1 ? width / (n - 1) : width;
|
|
2045
|
+
}
|
|
2046
|
+
function categorySpan(plot, n, between, room) {
|
|
2047
|
+
let scale = Math.min(1, plot.w / 2 / Math.max(room.left + room.right, 1e-9)), left = 0, right = 0;
|
|
2048
|
+
for (let round = 0; round < 3; round++) {
|
|
2049
|
+
let half = between ? (plot.w - left - right) / (2 * n) : 0;
|
|
2050
|
+
left = Math.max(0, room.left * scale - half), right = Math.max(0, room.right * scale - half);
|
|
2051
|
+
}
|
|
2052
|
+
return { x: plot.x + left, w: plot.w - left - right };
|
|
2053
|
+
}
|
|
2054
|
+
function forecastHeaderClear(domain, forecast, xOf, plotRight, measure, font, header, actual, clearance, valueRow) {
|
|
2055
|
+
let fcW = measure(header, font).width, acW = actual ? measure(actual, font).width : 0, n = domain.cats.length, at = forecastDividerAt(domain);
|
|
2056
|
+
return forecast.filter((boundary) => !boundary.labelled).every((boundary) => {
|
|
2057
|
+
let x = forecastBoundaryX(boundary, xOf, at), lo = x - (acW > 0 ? acW + 8 : 0) - 2, hi = Math.min(plotRight, x + fcW + 10);
|
|
2058
|
+
return domain.drawnSeries.every((series) => {
|
|
2059
|
+
let row = domain.pv[domain.rowOf.get(series)] ?? [], split = row[boundary.lastActualIndex];
|
|
2060
|
+
if (split != null && split > domain.dHi - clearance - valueRow) return !1;
|
|
2061
|
+
for (let ci = 0; ci < n; ci += 1) {
|
|
2062
|
+
let v = row[ci];
|
|
2063
|
+
if (v == null) continue;
|
|
2064
|
+
let x0 = xOf(ci), next = ci + 1 < n ? row[ci + 1] : void 0, x1 = ci + 1 < n ? xOf(ci + 1) : x0;
|
|
2065
|
+
if (x0 >= lo && x0 <= hi && v > domain.dHi - clearance || next != null && x1 > lo && x0 < hi && x1 > x0 && Math.max(...[Math.max(lo, x0), Math.min(hi, x1)].map((px) => v + (next - v) * (px - x0) / (x1 - x0))) > domain.dHi - clearance)
|
|
2066
|
+
return !1;
|
|
2067
|
+
}
|
|
2068
|
+
return !0;
|
|
2069
|
+
});
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
function gridTopRoom(domain, reserves, text, plotH) {
|
|
2073
|
+
if (domain.gridDataHi === void 0) return 0;
|
|
2074
|
+
let room = (value, seat) => seatRoom(value, [domain.dLo, domain.dHi], seat, plotH), top = 0;
|
|
2075
|
+
for (let label of reserves.endpoint.endLabels) {
|
|
2076
|
+
let di = domain.dataSeries.indexOf(label.s), end = domain.isStacked && di >= 0 ? (domain.cumTop[di][label.ci] + domain.cumBot[di][label.ci]) / 2 : domain.pv[domain.rowOf.get(label.s)]?.[label.ci] ?? domain.gridDataHi;
|
|
2077
|
+
top = Math.max(top, room(end, (label.h + 2) / 2));
|
|
2078
|
+
}
|
|
2079
|
+
if (domain.isStacked) return top;
|
|
2080
|
+
let { labelModes } = domain, picks = pointLabelSelection({
|
|
2081
|
+
valueLabels: labelModes.values,
|
|
2082
|
+
valueLabelsAuthored: domain.options.valueLabels !== void 0,
|
|
2083
|
+
labelOnly: domain.labelOnly,
|
|
2084
|
+
lastWithheld: new Set(usesEndLabelKey(domain.options) ? domain.drawnSeries.map((series) => series.id) : []),
|
|
2085
|
+
contentOf: text.contentOf,
|
|
2086
|
+
valueContent: defaultValueContent(domain.variant, labelModes.seriesValueContent),
|
|
2087
|
+
drawnSeries: domain.drawnSeries,
|
|
2088
|
+
pv: domain.pv,
|
|
2089
|
+
rowOf: domain.rowOf,
|
|
2090
|
+
flagged: flaggedPoints(domain),
|
|
2091
|
+
variant: domain.variant
|
|
2092
|
+
});
|
|
2093
|
+
for (let { series, row, only } of picks)
|
|
2094
|
+
for (let ci of only) {
|
|
2095
|
+
if (series.vals[ci]?.labelOverride === !1) continue;
|
|
2096
|
+
let value = row[ci], climbs = (row[ci - 1] ?? -1 / 0) > value || (row[ci + 1] ?? -1 / 0) > value;
|
|
2097
|
+
top = Math.max(top, room(value, climbs ? 2 * text.labelH + 9 : text.labelH + 5));
|
|
2098
|
+
}
|
|
2099
|
+
return top;
|
|
2100
|
+
}
|
|
2101
|
+
var AXIS_TITLE_TOP = 4, TITLE_ROW_GAP = 8;
|
|
2102
|
+
function titleSharesForecastRow(title, x, row) {
|
|
2103
|
+
if (row.forecastHeaderHeight === 0 || row.phaseHeaderHeight > 0 || row.hasBracketBand) return !1;
|
|
2104
|
+
let fcWidth = row.measure(row.forecastHeader, row.tickFont).width, headers = row.forecast.filter((boundary) => !boundary.labelled).map((boundary) => Math.max(row.plotX, Math.min(forecastBoundaryX(boundary, row.xOf, row.forecastAt) + 4, row.plotX + row.plotW - fcWidth))), at = (ref, fallback) => {
|
|
2105
|
+
let id = typeof ref == "string" ? ref : ref?.categoryId, index = row.cats.findIndex((category) => category.id === id);
|
|
2106
|
+
return row.xOf(index >= 0 ? index : fallback);
|
|
2107
|
+
}, legs = row.annList.flatMap((annotation) => annotation.kind === "cagr" ? [at(annotation.from, 0), at(annotation.to, row.cats.length - 1)] : []);
|
|
2108
|
+
return x + title.width + TITLE_ROW_GAP <= Math.min(minOf(headers), minOf(legs));
|
|
2109
|
+
}
|
|
2110
|
+
function linePlotArea(env, domain, text, reserves, framed, warnings) {
|
|
2111
|
+
let { theme, measure, isBump, size } = env, { options, cats, seriesNorm, drawnSeries, phases, dLo, dHi } = domain, { frame } = framed, { annList } = reserves, axis = valueAxisTicks(env, domain, frame), peak = (id) => Math.max(0, maxOf((seriesNorm.find((s) => s.id === id)?.vals ?? []).map((cell) => Math.abs(cell.v ?? 0)))), flatNumerator = options.ratioTier !== void 0 && peak(options.ratioTier.numeratorSeriesId) < peak(options.ratioTier.denominatorSeriesId) / 5, ratioTierPrepared = prepareRatioTier(options.ratioTier, cats, seriesNorm, theme, measure, Math.max(10, frame.plot.w - axis.valueAxisReserve), flatNumerator ? domain.fmt : void 0, options.target, notApplicableGlyph(options.strings), options.locale?.language);
|
|
2112
|
+
warnings.push(...ratioTierPrepared.warnings);
|
|
2113
|
+
let row = categoryRow(env, domain, text, reserves, frame, axis.valueAxisReserve, warnings), { catPlan, categoryOverhang, categoryRightOverhang, crossesBetween, intervalTicks } = row, xTicks = "xTicks" in row ? row.xTicks : void 0, hasCagr = annList.some((a) => a.kind === "cagr"), hasBracketBand = annList.some((a) => a.kind === "band" && a.style === "bracket"), phaseHeaderHeight = phases ? text.labelH + 8 : 0, forecast = forecastBoundaries(drawnSeries, cats, annList, phases, domain.isStacked), forecastHeaderHeight = forecast.some((boundary) => !boundary.labelled) ? measure(options.strings.forecastHeader, text.secondaryFont).height + 8 : 0, axisTitle = axis.axisShown && !isBump && text.kindSetting("axisTitle") !== !1 ? planValueAxisTitle(valueAxisTitleText(
|
|
2114
|
+
theme,
|
|
2115
|
+
options.axisTitles?.primary,
|
|
2116
|
+
options,
|
|
2117
|
+
valueAxisUnit(options.unit, domain.dataSeries, domain.variant === "stacked100-area")
|
|
2118
|
+
), theme, measure, frame.plot.w) : void 0, plotX = frame.plot.x + (axis.axisShown || axis.disclosedTicks ? axis.valueAxisReserve : 0) + categoryOverhang, plotW = Math.max(10, frame.plot.w - (axis.axisShown || axis.disclosedTicks ? axis.valueAxisReserve : 0) - categoryOverhang - categoryRightOverhang), n = cats.length, grid = domain.population ?? domain.timeline, span = categorySpan({ x: plotX, w: plotW }, grid?.span ?? n, crossesBetween, reserves.categoryEndRoom), xOf = (ci) => domain.timeline && !domain.population || domain.x ? round2(liveCategoryX(ci, n, crossesBetween, span, grid)) : liveCategoryX(ci, n, crossesBetween, span, grid), top = domain.isStacked && domain.labelModes.values !== "none" ? drawnSeries[drawnSeries.length - 1] : void 0, topLast = top ? domain.lastIdxOf.get(top.id) ?? n - 1 : n - 1, topFirst = top ? Math.max(0, domain.pv[domain.rowOf.get(top)].findIndex((v) => v != null)) : 0, valueCats = domain.labelModes.values === "last" ? [topLast] : domain.labelModes.values === "ends" ? [topFirst, topLast] : cats.map((_, ci) => ci), estPlotH = frame.plot.h - catPlan.rowHeight - 8 - (8 + forecastHeaderHeight + phaseHeaderHeight + (hasCagr ? 30 : 0) + (hasBracketBand ? 30 : 0)), topValueRow = top !== void 0 && valueCats.some((ci) => {
|
|
2119
|
+
let value = domain.pv[domain.rowOf.get(top)][ci], total = drawnSeries.reduce((sum, series) => sum + Math.abs(domain.pv[domain.rowOf.get(series)][ci] ?? 0), 0);
|
|
2120
|
+
return value == null || total <= 0 || Math.abs(value) / total >= 0.15 ? !1 : !(dHi > dLo) || Math.abs(value) / (dHi - dLo) * estPlotH < text.labelH + 2 + THIN_TOP_AIR;
|
|
2121
|
+
}) ? text.labelH + 8 : 0, forecastHeaderInPlot = forecastHeaderHeight > 0 && domain.isArea && !domain.isStacked && phaseHeaderHeight === 0 && !hasCagr && !hasBracketBand && topValueRow === 0 && dHi > dLo && forecastHeaderClear(
|
|
2122
|
+
domain,
|
|
2123
|
+
forecast,
|
|
2124
|
+
xOf,
|
|
2125
|
+
plotX + plotW,
|
|
2126
|
+
measure,
|
|
2127
|
+
text.secondaryFont,
|
|
2128
|
+
options.strings.forecastHeader,
|
|
2129
|
+
actualHeader(domain),
|
|
2130
|
+
(dHi - dLo) * (forecastHeaderHeight + 4) / Math.max(1, estPlotH + forecastHeaderHeight),
|
|
2131
|
+
(dHi - dLo) * (text.labelH + 5) / Math.max(1, estPlotH + forecastHeaderHeight)
|
|
2132
|
+
), headerRows = (forecastHeaderInPlot ? 0 : forecastHeaderHeight) + phaseHeaderHeight + (hasCagr ? 30 : 0) + (hasBracketBand ? 30 : 0) + topValueRow, titleInRow = axisTitle !== void 0 && titleSharesForecastRow(axisTitle, frame.plot.x, {
|
|
2133
|
+
forecastHeader: options.strings.forecastHeader,
|
|
2134
|
+
forecast,
|
|
2135
|
+
forecastHeaderHeight: forecastHeaderInPlot ? 0 : forecastHeaderHeight,
|
|
2136
|
+
phaseHeaderHeight,
|
|
2137
|
+
hasBracketBand,
|
|
2138
|
+
forecastAt: forecastDividerAt(domain),
|
|
2139
|
+
annList,
|
|
2140
|
+
cats,
|
|
2141
|
+
xOf,
|
|
2142
|
+
plotX,
|
|
2143
|
+
plotW,
|
|
2144
|
+
tickFont: text.tickFont,
|
|
2145
|
+
measure
|
|
2146
|
+
}), axisTitleBand = titleInRow ? 0 : valueAxisTitleBand(axisTitle, theme, measure, headerRows), rawBandPad = options[BAND_PAD] ?? 0, baseTopPad = 8 + axisTitleBand + headerRows, headInPlot = frame.legend !== void 0 && frame.legend.rect.y + frame.legend.rect.h <= frame.plot.y, showCategoryTickRow = text.kindSetting("category") !== !1 && cats.length > 0;
|
|
2147
|
+
showCategoryTickRow && pushAll(warnings, catPlan.warnings);
|
|
2148
|
+
let categoryTickGap = domain.isArea && !crossesBetween && axis.axisShown ? Math.max(6, measure("0", text.secondaryFont).height / 2 + 4) : 6, categoryTickReserve = showCategoryTickRow ? catPlan.rowHeight + categoryTickGap + 2 : 0, categoryBandHeight = ratioTierPrepared.tier ? 6 + catPlan.rowHeight + ratioTierMetrics.categoryCaptionGap - theme.space.tierGap : categoryTickReserve, rawHNoBand = frame.plot.h - categoryBandHeight - (ratioTierPrepared.tier?.reserveHeight ?? 0) - (headInPlot ? 0 : baseTopPad), minRawH = Math.max(10, options.mode === "compact" ? 80 : 0), maxBandPad = Math.floor(headInPlot ? plotHeightAfter(frame, size.height, rawHNoBand) - baseTopPad - minRawH : rawHNoBand - minRawH), bandPad = rawBandPad > 0 ? Math.max(0, Math.min(rawBandPad, maxBandPad)) : 0, topPad = baseTopPad + bandPad, plot = {
|
|
2149
|
+
x: plotX,
|
|
2150
|
+
y: frame.plot.y + (headInPlot ? 0 : topPad),
|
|
2151
|
+
w: plotW,
|
|
2152
|
+
h: plotHeightAfter(frame, size.height, frame.plot.h - categoryBandHeight - (ratioTierPrepared.tier?.reserveHeight ?? 0) - (headInPlot ? 0 : topPad))
|
|
2153
|
+
}, endHeight = reserves.endpoint.endLabels.reduce((sum, label) => sum + label.h + 2, 0), minPlot = Math.max(plotFloorRows(options) * text.labelH + 8, endHeight, reserves.referenceBands?.minHeight ?? 0) + (headInPlot && axisTitleBand + headerRows > 0 ? baseTopPad : 0);
|
|
2154
|
+
frame.frame.plotMinHeight = Math.max(frame.frame.plotMinHeight ?? 0, size.height + (frame.deficit ?? 0) + minPlot - rawHNoBand);
|
|
2155
|
+
let axisTitleY = titleInRow ? frame.plot.y + baseTopPad - measure("0", text.secondaryFont).height / 2 - AXIS_TITLE_GAP - axisTitle.height : frame.plot.y + AXIS_TITLE_TOP, reverse = options.valueAxis?.reverse, legendGap = headInPlot ? frame.plot.y - frame.legend.rect.y - frame.legend.rect.h : 0, tickHead = headInPlot && axis.axisShown ? Math.max(0, measure("0", text.secondaryFont).height / 2 - legendGap) : 0, innerHead = headInPlot ? Math.min(Math.max(tickHead, topPad), plot.h) : 0, topRoom = innerHead + gridTopRoom(domain, reserves, text, plot.h - innerHead), yRange = isBump ? reverse ? [plot.y + plot.h, plot.y] : [plot.y, plot.y + plot.h] : reverse ? [plot.y + innerHead, plot.y + plot.h] : [plot.y + plot.h, plot.y + topRoom];
|
|
2156
|
+
return {
|
|
2157
|
+
...framed,
|
|
2158
|
+
...axis,
|
|
2159
|
+
ratioTier: ratioTierPrepared.tier,
|
|
2160
|
+
categoryOverhang,
|
|
2161
|
+
catPlan,
|
|
2162
|
+
...intervalTicks && showCategoryTickRow ? { intervalTicks } : {},
|
|
2163
|
+
showCategoryTickRow,
|
|
2164
|
+
categoryTickReserve,
|
|
2165
|
+
categoryTickGap,
|
|
2166
|
+
categoryBandHeight,
|
|
2167
|
+
forecast,
|
|
2168
|
+
forecastHeaderHeight,
|
|
2169
|
+
forecastHeaderInPlot,
|
|
2170
|
+
forecastPlot: headInPlot ? { ...plot, y: plot.y + innerHead, h: plot.h - innerHead } : plot,
|
|
2171
|
+
phaseHeaderHeight,
|
|
2172
|
+
axisTitle,
|
|
2173
|
+
axisTitleBand,
|
|
2174
|
+
axisTitleY,
|
|
2175
|
+
topPad,
|
|
2176
|
+
plot,
|
|
2177
|
+
y: linearScale([dLo, dHi], yRange),
|
|
2178
|
+
// Proportional positions land on 0.01 px, as the path coordinates drawn from them do.
|
|
2179
|
+
xOf,
|
|
2180
|
+
...domain.x && xTicks ? { xTicks, xOfValue: (value) => span.x + (value - domain.x.lo) / (domain.x.hi - domain.x.lo) * span.w } : {},
|
|
2181
|
+
// A continuous axis has no pitch: the mean spacing of its readings stands in where a step is read.
|
|
2182
|
+
step: domain.x ? span.w / Math.max(1, n - 1) : categoryStep(span.w, domain.population ? n : grid?.span ?? n, crossesBetween),
|
|
2183
|
+
categoryOrder: new Map(cats.map((category, index) => [category.id, index]))
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
// src/core/lint/space.ts
|
|
2188
|
+
var PLOT_H_FLOOR = 0.6, PLOT_H_FLOOR_STRIP = 0.45, PLOT_W_FLOOR = 0.72, PLOT_W_FLOOR_DEMOTED = 0.62, HEADROOM_MAX = 0.15, RESIDUAL_MAX_PX = 8, FLOOR_MAX_PX = 8, V_ENVELOPE_MIN = 0.8, H_ENVELOPE_MIN = 0.85, EPS = 2e-3, PX_EPS = 0.5;
|
|
2189
|
+
function verticalValueScope(cls, type, options) {
|
|
2190
|
+
return !(cls !== "standard-cartesian" && cls !== "wide-time" || type === "pie" || options?.variant === "horizontal" || options?.variant === "bump");
|
|
2191
|
+
}
|
|
2192
|
+
function mergeIntervals(intervals) {
|
|
2193
|
+
let sorted = intervals.filter((iv) => iv.to > iv.from).sort((a, b) => a.from - b.from), merged = [];
|
|
2194
|
+
for (let iv of sorted) {
|
|
2195
|
+
let last = merged[merged.length - 1];
|
|
2196
|
+
last && iv.from <= last.to ? last.to = Math.max(last.to, iv.to) : merged.push({ ...iv });
|
|
2197
|
+
}
|
|
2198
|
+
return merged;
|
|
2199
|
+
}
|
|
2200
|
+
function fmtRatio(v) {
|
|
2201
|
+
return (Math.round(v * 1e3) / 1e3).toString();
|
|
2202
|
+
}
|
|
2203
|
+
var REPAIR = {
|
|
2204
|
+
plotHeight: "Shorten the footer, drop the legend, or raise the canvas height.",
|
|
2205
|
+
plotWidth: "Shorten the side labels, widen the canvas, or put the legend in a horizontal band.",
|
|
2206
|
+
furniture: "Trim the footnote stack or raise the canvas height.",
|
|
2207
|
+
bracketResidual: "Lower the value-axis maximum so the annotation sits near the top of the plot.",
|
|
2208
|
+
headroom: "Lower the value-axis maximum towards the largest value.",
|
|
2209
|
+
floorBand: "Raise the value-axis minimum to zero, or remove the extra bottom padding.",
|
|
2210
|
+
envelope: "Narrow the value-axis range to the data.",
|
|
2211
|
+
span: "Narrow the x-axis range to the data.",
|
|
2212
|
+
deadBand: "Remove the margin you set, or lower the canvas height."
|
|
2213
|
+
};
|
|
2214
|
+
function furnitureFinding(type, furniture, budget, geo, legendRow, options) {
|
|
2215
|
+
let message = `'${type}' spends ${fmtRatio(furniture)} of its height on everything but the plot, over the ${budget} budget.`;
|
|
2216
|
+
if (type === "kpi") return [message, REPAIR.furniture];
|
|
2217
|
+
let tokens = spaceTokens(resolveTheme(options?.theme), geo.size.width), framePlot = geo.frame.plotRect ?? geo.plot, text = geo.scene.flatMap((node) => node.t === "text" && node.opacity !== 0 ? [node] : []), height = (parts) => {
|
|
2218
|
+
let nodes = text.filter((node) => parts.includes(node.part) && node.y < framePlot.y);
|
|
2219
|
+
return nodes.length === 0 ? 0 : maxOf(nodes.map((node) => node.y + node.lines.length * node.font.size * (node.font.lineHeight ?? 1.2))) - minOf(nodes.map((node) => node.y));
|
|
2220
|
+
}, footer = geo.frame.footerRect?.h ?? 0, eventKey = geo.frame.eventKeyRect, beforeFooter = eventKey ?? (legendRow && geo.legend && geo.legend.rect.y >= framePlot.y + framePlot.h ? geo.legend.rect : framePlot), footerGap = geo.frame.footerRect ? Math.max(0, geo.frame.footerRect.y - beforeFooter.y - beforeFooter.h) : 0, title = height(["title"]), subtitle = height(["subtitle"]), tickBand = geo.derived?.tickBand, rows = [
|
|
2221
|
+
["legend", legendRow && geo.legend ? geo.legend.rect.h + tokens.gapLegend : 0, "Set legend to 'none' or raise the canvas height."],
|
|
2222
|
+
["event key", eventKey && eventKey.h > 0 ? eventKey.h + tokens.gapAxisFootnote : 0, "Shorten the event text, increase events.rows, or raise the canvas height."],
|
|
2223
|
+
["footer", footer > 0 ? footer + footerGap : 0, "Shorten the notes or source line, or raise the canvas height."],
|
|
2224
|
+
[
|
|
2225
|
+
"title",
|
|
2226
|
+
title > 0 ? title + (subtitle > 0 ? tokens.gapTitleSubtitle : tokens.gapSubtitlePlot) : 0,
|
|
2227
|
+
(geo.frame.titleLines ?? 1) > 1 ? "Shorten the title to one line or raise the canvas height." : "Raise the canvas height."
|
|
2228
|
+
],
|
|
2229
|
+
["subtitle", subtitle > 0 ? subtitle + tokens.gapSubtitlePlot : 0, "Shorten or omit the subtitle, or raise the canvas height."],
|
|
2230
|
+
[
|
|
2231
|
+
"category labels",
|
|
2232
|
+
tickBand?.reserved ?? (tickBand?.measuredLines ?? 0) * (tickBand?.lineHeight ?? 0),
|
|
2233
|
+
(tickBand?.measuredLines ?? 1) > 1 ? "Shorten the category labels to one line or raise the canvas height." : "Raise the canvas height."
|
|
2234
|
+
]
|
|
2235
|
+
], [name, px, fix] = rows.reduce((a, b) => b[1] > a[1] ? b : a);
|
|
2236
|
+
return px <= 0 ? [`${message} Every row is at its minimum.`, "Raise the canvas height."] : [`${message} The ${name} row costs the most at ${Math.round(px)}px.`, fix];
|
|
2237
|
+
}
|
|
2238
|
+
function spaceDocLints(type, options, geo) {
|
|
2239
|
+
if (geo.warnings.some((w) => w.severity === "error")) return [];
|
|
2240
|
+
let cls = aspectClassFor(type, options, geo.marks);
|
|
2241
|
+
if (!cls) return [];
|
|
2242
|
+
let warnings = [], { width: W, height: H } = geo.size, plot = geo.plot, occupied = geo.debug.occupied, push = (code, message, suggest) => warnings.push({
|
|
2243
|
+
code,
|
|
2244
|
+
severity: "warn",
|
|
2245
|
+
message,
|
|
2246
|
+
...suggest ? { suggest } : {}
|
|
2247
|
+
}), footnoteLines = geo.scene.filter((n) => n.t === "text" && n.part === "footnote").reduce((sum, n) => sum + n.lines.length, 0), legendRect = geo.legend?.rect, legendHorizontal = legendRect !== void 0 && (legendRect.y + legendRect.h <= plot.y + PX_EPS || legendRect.y >= plot.y + plot.h - PX_EPS), legendRight = legendRect !== void 0 && !legendHorizontal, labelColumnRight = occupied.some(
|
|
2248
|
+
(o) => o.kind === "label" && o.rect.w > 0 && o.rect.x >= plot.x + plot.w - PX_EPS
|
|
2249
|
+
) || geo.labels.some((label) => label.kind === "series" && !label.hidden && label.rect.w > 0 && label.rect.x + label.rect.w > plot.x + plot.w + PX_EPS), framePlot = geo.frame.plotRect ?? plot, categoryYAxis = geo.axes.some(
|
|
2250
|
+
(a) => a.axis === "y" && a.ticks.length > 0 && a.ticks.some((t) => typeof t.at != "number")
|
|
2251
|
+
), matrixPitchDriven = cls === "matrix" && onLadderStep(geo.size) === null, kpiCard = cls === "card" && type === "kpi", proportioned = !contentSized(type, options, geo.sizing?.fit);
|
|
2252
|
+
if (proportioned && (HEIGHT_FLOOR_CLASSES.has(cls) && !matrixPitchDriven || cls === "card" && !kpiCard || cls === "strip")) {
|
|
2253
|
+
let PLOT_FLOOR_SHARE = plotFloorShare(W), hFloor = cls === "card" ? PLOT_FLOOR_SHARE : cls === "strip" ? PLOT_H_FLOOR_STRIP : W < 720 || legendHorizontal && footnoteLines >= 2 ? PLOT_FLOOR_SHARE : PLOT_H_FLOOR, hRatio = framePlot.h / H;
|
|
2254
|
+
hRatio < hFloor - EPS && push(
|
|
2255
|
+
"plot-ratio-under-floor",
|
|
2256
|
+
`'${type}' gives the plot ${fmtRatio(hRatio)} of the canvas height, under the ${hFloor} floor for this type. Title, legend and footnotes take the rest.`,
|
|
2257
|
+
REPAIR.plotHeight
|
|
2258
|
+
);
|
|
2259
|
+
let fewPeriodBump = geo.derived?.bump !== void 0 && (geo.axes.find((a) => a.axis === "x")?.ticks.length ?? 0) <= 3;
|
|
2260
|
+
if (HEIGHT_FLOOR_CLASSES.has(cls) && !categoryYAxis && !fewPeriodBump) {
|
|
2261
|
+
let wFloor = legendRight || labelColumnRight ? PLOT_W_FLOOR_DEMOTED : PLOT_W_FLOOR, wRatio = plot.w / W;
|
|
2262
|
+
wRatio < wFloor - EPS && push(
|
|
2263
|
+
"plot-ratio-under-floor",
|
|
2264
|
+
`'${type}' gives the plot ${fmtRatio(wRatio)} of the canvas width, under the ${wFloor} floor. Side labels and the legend take the rest.`,
|
|
2265
|
+
REPAIR.plotWidth
|
|
2266
|
+
);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
if (proportioned && furnitureScoped(cls, geo.size)) {
|
|
2270
|
+
let budget = furnitureBudget(W), furniture = furnitureShare(geo);
|
|
2271
|
+
furniture > budget + EPS && push("furniture-budget", ...furnitureFinding(type, furniture, budget, geo, legendHorizontal, options));
|
|
2272
|
+
}
|
|
2273
|
+
let analyticSpace = options?.zones !== void 0 || options?.quadrants !== void 0, comparisonPinnedYDomain = geo.derived?.comparisonPinnedYDomain === !0;
|
|
2274
|
+
if (verticalValueScope(cls, type, options) && !analyticSpace) {
|
|
2275
|
+
let dataRects = occupied.filter(
|
|
2276
|
+
(o) => (o.kind === "mark" || o.kind === "label") && o.owner.annotationId === void 0 && o.rect.w > 0 && o.rect.h > 0
|
|
2277
|
+
), markRects = dataRects.filter((o) => o.kind === "mark"), categoryY = geo.axes.some(
|
|
2278
|
+
(a) => a.axis === "y" && a.ticks.length > 0 && a.ticks.some((t) => typeof t.at != "number")
|
|
2279
|
+
);
|
|
2280
|
+
if (markRects.length > 0 && !categoryY) {
|
|
2281
|
+
let markTop = minOf(markRects.map((o) => o.rect.y)), markBottom = maxOf(markRects.map((o) => o.rect.y + o.rect.h)), degenerate = markBottom - markTop <= singleBody(markRects, "h") + PX_EPS, dataTop = minOf(dataRects.map((o) => o.rect.y)), dataBottom = maxOf(dataRects.map((o) => o.rect.y + o.rect.h)), annotationRects = occupied.filter(
|
|
2282
|
+
(o) => o.owner.annotationId !== void 0 && o.rect.w > 0 && o.rect.h > 0
|
|
2283
|
+
), annotationTop = annotationRects.length > 0 ? minOf(annotationRects.map((o) => o.rect.y)) : 1 / 0, armedIds = new Set(
|
|
2284
|
+
annotationRects.filter((o) => o.part === "arm").map((o) => o.owner.annotationId)
|
|
2285
|
+
), bracketRects = annotationRects.filter(
|
|
2286
|
+
(o) => armedIds.size > 0 && armedIds.has(o.owner.annotationId)
|
|
2287
|
+
), bracketTop = bracketRects.length > 0 ? minOf(bracketRects.map((o) => o.rect.y)) : 1 / 0, axisBreak = geo.axes.some((a) => a.break !== void 0);
|
|
2288
|
+
if (!degenerate && !comparisonPinnedYDomain) {
|
|
2289
|
+
if (bracketTop < dataTop) {
|
|
2290
|
+
let residual = bracketTop - plot.y;
|
|
2291
|
+
residual > RESIDUAL_MAX_PX + PX_EPS && push(
|
|
2292
|
+
"ink-envelope",
|
|
2293
|
+
`'${type}' leaves ${residual.toFixed(1)}px of empty space above its topmost bracket annotation, more than the ${RESIDUAL_MAX_PX}px allowed when that annotation is the highest thing drawn.`,
|
|
2294
|
+
REPAIR.bracketResidual
|
|
2295
|
+
);
|
|
2296
|
+
} else if (!axisBreak) {
|
|
2297
|
+
let headroom = (dataTop - plot.y) / plot.h;
|
|
2298
|
+
headroom > HEADROOM_MAX + EPS && push(
|
|
2299
|
+
"ink-envelope",
|
|
2300
|
+
`'${type}' leaves ${fmtRatio(headroom)} of the plot empty above the data, over the ${HEADROOM_MAX} cap. The value axis reaches further than the numbers do.`,
|
|
2301
|
+
REPAIR.headroom
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
let baselineY = zeroBaselineY(geo);
|
|
2305
|
+
if (baselineY !== null && markBottom <= baselineY + 1) {
|
|
2306
|
+
let floorGap = plot.y + plot.h - Math.max(baselineY, dataBottom);
|
|
2307
|
+
floorGap > FLOOR_MAX_PX + PX_EPS && push(
|
|
2308
|
+
"ink-envelope",
|
|
2309
|
+
`'${type}' leaves ${floorGap.toFixed(1)}px between the zero line and the bottom of the plot, more than the ${FLOOR_MAX_PX}px allowed on a chart that starts at zero.`,
|
|
2310
|
+
REPAIR.floorBand
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
let envTop = Math.max(plot.y, Math.min(dataTop, annotationTop)), coverage = (Math.min(plot.y + plot.h, dataBottom) - envTop) / plot.h;
|
|
2314
|
+
coverage < V_ENVELOPE_MIN - EPS && !tickBoundAxis(geo, "y", plot, dataTop, dataBottom) && push(
|
|
2315
|
+
"ink-envelope",
|
|
2316
|
+
`'${type}' data covers ${fmtRatio(coverage)} of the plot height, under the ${V_ENVELOPE_MIN} floor. Most of the plot is empty.`,
|
|
2317
|
+
REPAIR.envelope
|
|
2318
|
+
);
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
if (geo.axes.some(
|
|
2322
|
+
(a) => a.axis === "x" && a.ticks.length > 1 && a.ticks.every((t) => typeof t.at == "number")
|
|
2323
|
+
) && markRects.length > 0) {
|
|
2324
|
+
let floor = categoryY ? V_ENVELOPE_MIN : H_ENVELOPE_MIN, markLeft = minOf(markRects.map((o) => o.rect.x)), markRight = maxOf(markRects.map((o) => o.rect.x + o.rect.w)), span = (Math.min(plot.x + plot.w, markRight) - Math.max(plot.x, markLeft) + 8) / plot.w;
|
|
2325
|
+
markRight - markLeft > singleBody(markRects, "w") + PX_EPS && span < floor - EPS && !tickBoundAxis(geo, "x", plot, markLeft, markRight) && push(
|
|
2326
|
+
"ink-envelope",
|
|
2327
|
+
`'${type}' data covers ${fmtRatio(span)} of the plot width, under the ${floor} floor. Most of the plot is empty.`,
|
|
2328
|
+
REPAIR.span
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
{
|
|
2333
|
+
let block = geo.frame.plotRect ?? plot, intervals = [{ from: block.y, to: block.y + block.h }];
|
|
2334
|
+
for (let o of occupied)
|
|
2335
|
+
o.kind === "reserved" || o.rect.w <= 0 || o.rect.h <= 0 || intervals.push({ from: o.rect.y, to: o.rect.y + o.rect.h });
|
|
2336
|
+
let merged = mergeIntervals(intervals), threshold = Math.max(16, 0.06 * H), theme = resolveTheme(options?.theme), tokens = spaceTokens(theme, W), fixedRows = (type === "bar" || type === "likert") && theme.space.barRow !== void 0, gaps = [], cursor = 0;
|
|
2337
|
+
for (let iv of merged)
|
|
2338
|
+
iv.from > cursor && gaps.push({ from: cursor, to: Math.min(iv.from, H), where: cursor === 0 ? "canvas top" : "between blocks" }), cursor = Math.max(cursor, iv.to);
|
|
2339
|
+
cursor < H && gaps.push({ from: cursor, to: H, where: "canvas bottom" });
|
|
2340
|
+
for (let gap of gaps) {
|
|
2341
|
+
if (fixedRows && gap.where === "canvas bottom" && (geo.sizing?.naturalHeight ?? H) < H) continue;
|
|
2342
|
+
let allowance = gap.where === "canvas top" ? Math.max(threshold, tokens.margin.top + 2) : gap.where === "canvas bottom" ? Math.max(threshold, tokens.margin.bottom + 2) : threshold, extent = gap.to - gap.from;
|
|
2343
|
+
extent > allowance + PX_EPS && push(
|
|
2344
|
+
"dead-band",
|
|
2345
|
+
`'${type}' carries an empty band ${extent.toFixed(0)}px tall at the ${gap.where} (y ${gap.from.toFixed(0)} to ${gap.to.toFixed(0)}), over the ${allowance.toFixed(0)}px allowed there.`,
|
|
2346
|
+
REPAIR.deadBand
|
|
2347
|
+
);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
return warnings;
|
|
2351
|
+
}
|
|
2352
|
+
function singleBody(markRects, side) {
|
|
2353
|
+
let points = markRects.filter((o) => o.owner.pointId !== void 0);
|
|
2354
|
+
return points.length > 0 ? maxOf(points.map((o) => o.rect[side])) : 10;
|
|
2355
|
+
}
|
|
2356
|
+
function tickBoundAxis(geo, orient, plot, dataLo, dataHi) {
|
|
2357
|
+
let pos = (geo.axes.find((a) => a.axis === orient)?.ticks ?? []).filter((t) => typeof t.at == "number" && t.labelId !== void 0).map((t) => t.pos).sort((a, b) => a - b);
|
|
2358
|
+
if (pos.length < 3) return !1;
|
|
2359
|
+
let lo = orient === "x" ? plot.x : plot.y, hi = orient === "x" ? plot.x + plot.w : plot.y + plot.h;
|
|
2360
|
+
if (Math.abs(pos[0] - lo) > 1 || Math.abs(pos[pos.length - 1] - hi) > 1) return !1;
|
|
2361
|
+
let step = minOf(pos.slice(1).map((p, i) => p - pos[i]));
|
|
2362
|
+
return dataLo - lo < step && hi - dataHi < step;
|
|
2363
|
+
}
|
|
2364
|
+
function zeroBaselineY(geo) {
|
|
2365
|
+
for (let axis of geo.axes) {
|
|
2366
|
+
if (!axis.baselineNodeId) continue;
|
|
2367
|
+
let node = geo.scene.find((n) => n.id === axis.baselineNodeId);
|
|
2368
|
+
if (node && node.t === "line" && Math.abs(node.y1 - node.y2) < 0.01) return node.y1;
|
|
2369
|
+
}
|
|
2370
|
+
return null;
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
// src/core/charts/line/layout.ts
|
|
2374
|
+
function commitClaims(occupied, phase) {
|
|
2375
|
+
for (let c of phase.snapshot()) occupied.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
|
|
2376
|
+
phase.tickColumns && (occupied.tickColumns = phase.tickColumns);
|
|
2377
|
+
}
|
|
2378
|
+
function settleLineLabels(env, area, scene, plan, solved, occupied, warnings) {
|
|
2379
|
+
for (let label of solved.placed)
|
|
2380
|
+
!scene.targetLabelIds.has(label.id) || label.hidden !== "collision" || warnings.push({
|
|
2381
|
+
code: "target-label-hidden",
|
|
2382
|
+
severity: "warn",
|
|
2383
|
+
message: `authored target label '${label.id}' could not be placed without a collision`,
|
|
2384
|
+
owner: label.owner,
|
|
2385
|
+
suggest: "increase chart size, shorten the target label, or pin it to a free slot"
|
|
2386
|
+
});
|
|
2387
|
+
for (let label of solved.placed)
|
|
2388
|
+
if (!(label.hidden || !label.leader) && plan.endpointLeaderAnchors.get(label.id))
|
|
2389
|
+
for (let [a, b] of leaderPieces(label.leader.d, 64)) occupied.claim({
|
|
2390
|
+
x: Math.min(a.x, b.x) - 0.5,
|
|
2391
|
+
y: Math.min(a.y, b.y) - 0.5,
|
|
2392
|
+
w: Math.abs(a.x - b.x) + 1,
|
|
2393
|
+
h: Math.abs(a.y - b.y) + 1
|
|
2394
|
+
}, "label", label.owner, "endpointLeader");
|
|
2395
|
+
let ratioTierResult = plan.ratioTierRequestState ? finalizeRatioTier(plan.ratioTierRequestState, solved.placed, occupied, env.theme, env.measure) : void 0;
|
|
2396
|
+
return ratioTierResult && pushAll(scene.nodes, ratioTierResult.nodes), pushAll(warnings, ratioTierSpacingWarnings(area.ratioTier, solved.placed)), ratioTierResult;
|
|
2397
|
+
}
|
|
2398
|
+
function annotateLine(env, domain, area, reserves, scene, occupied, solveCtx, labelRequests, printedLabels) {
|
|
2399
|
+
let { options, cats, dataSeries, drawnSeries, refSeries, pv, rowOf, isStacked, cumTop, rebased, absOf } = domain, { plot, y, xOf, categoryOrder: catIndex } = area, anchorSeries = [...drawnSeries, ...refSeries.filter((s) => scene.nodes.some((node) => node.part === "referenceLine" && node.owner.seriesId === s.id))], anchorError = (ref) => {
|
|
2400
|
+
let norm = typeof ref == "string" ? { categoryId: ref } : ref, valid = `valid category ids: ${cats.map((c) => c.id).join(", ")}; valid series ids: ${anchorSeries.map((s) => s.id).join(", ")}`;
|
|
2401
|
+
return "categoryId" in norm ? catIndex.has(norm.categoryId) ? norm.seriesId && !anchorSeries.some((s) => s.id === norm.seriesId) ? `series '${norm.seriesId}' is not drawn; ${valid}` : `no drawn value at category '${norm.categoryId}' for series '${norm.seriesId ?? drawnSeries[0]?.id}'; ${valid}` : `unknown category '${norm.categoryId}'; ${valid}` : `line anchors need categoryId; ${valid}`;
|
|
2402
|
+
}, resolveAnchor = (ref) => {
|
|
2403
|
+
let norm = typeof ref == "string" ? { categoryId: ref, edge: "total" } : ref;
|
|
2404
|
+
if (!("categoryId" in norm)) return null;
|
|
2405
|
+
let ci = catIndex.get(norm.categoryId);
|
|
2406
|
+
if (ci === void 0) return null;
|
|
2407
|
+
let c = cats[ci], s = norm.seriesId ? anchorSeries.find((x) => x.id === norm.seriesId) : drawnSeries[0];
|
|
2408
|
+
if (!s) return null;
|
|
2409
|
+
let di = dataSeries.indexOf(s), v = pv[rowOf.get(s)][ci];
|
|
2410
|
+
if (v === null) return null;
|
|
2411
|
+
let py = isStacked && di >= 0 ? y(cumTop[di][ci]) : y(v), value = rebased ? v : absOf(s, ci) ?? v;
|
|
2412
|
+
return {
|
|
2413
|
+
x: xOf(ci),
|
|
2414
|
+
y: py,
|
|
2415
|
+
value,
|
|
2416
|
+
pointValueText: (rebased ? domain.fmt : domain.valueSpec.forSeries(s, s.vals[ci]?.format))(value),
|
|
2417
|
+
format: rebased ? void 0 : s.format,
|
|
2418
|
+
date: c.date,
|
|
2419
|
+
label: c.label ?? c.id,
|
|
2420
|
+
owner: { categoryId: c.id, seriesId: s.id },
|
|
2421
|
+
// A category anchor reads the first drawn series, so it is named too.
|
|
2422
|
+
...dataSeries.length > 1 ? { series: { id: s.id, label: s.label } } : {},
|
|
2423
|
+
lineAnchored: !0,
|
|
2424
|
+
...ci > 0 && pv[rowOf.get(s)].findIndex((value2) => value2 !== null) === ci ? { lineStart: !0 } : {}
|
|
2425
|
+
};
|
|
2426
|
+
}, centred = categoryBandFromCenters(cats.map((c) => c.id), plot, xOf, "x"), splits = area.forecast.map((boundary) => ({ boundary, x: forecastBoundaryX(boundary, xOf, "point") })), resolveCategoryBand = (categoryId) => {
|
|
2427
|
+
if (domain.x && area.xOfValue) {
|
|
2428
|
+
let x = domain.x.model.read(categoryId, "options.annotations");
|
|
2429
|
+
return { x: Math.min(plot.x + plot.w, Math.max(plot.x, area.xOfValue(x))), w: 0 };
|
|
2430
|
+
}
|
|
2431
|
+
let band = centred(categoryId), ci = catIndex.get(categoryId);
|
|
2432
|
+
if (!band || !("x" in band) || ci === void 0) return band;
|
|
2433
|
+
let left = band.x, right = band.x + band.w;
|
|
2434
|
+
for (let { boundary, x } of splits)
|
|
2435
|
+
ci === boundary.categoryIndex && (left = x), ci === boundary.categoryIndex - 1 && (right = x, left = Math.min(left, x));
|
|
2436
|
+
return { x: left, w: right - left };
|
|
2437
|
+
}, resolvePeriodSlot = (categoryId) => {
|
|
2438
|
+
if (!domain.x || !area.xOfValue) return null;
|
|
2439
|
+
let shown = domain.x.shown, at = shown.indexOf(domain.x.model.read(categoryId, "options.annotations"));
|
|
2440
|
+
if (at < 0 || shown.length < 2) return null;
|
|
2441
|
+
let px = (i) => area.xOfValue(shown[i]), x = px(at), before = at > 0 ? (x - px(at - 1)) / 2 : (px(at + 1) - x) / 2, after = at < shown.length - 1 ? (px(at + 1) - x) / 2 : before, left = Math.max(plot.x, x - before), right = Math.min(plot.x + plot.w, x + after);
|
|
2442
|
+
return right > left ? { x: left, w: right - left } : null;
|
|
2443
|
+
}, annPlot = {
|
|
2444
|
+
x: plot.x,
|
|
2445
|
+
y: area.forecastPlot.y - (area.topPad - 8 - area.axisTitleBand),
|
|
2446
|
+
w: plot.w,
|
|
2447
|
+
h: area.forecastPlot.h + (area.topPad - 8 - area.axisTitleBand)
|
|
2448
|
+
}, ceilingRects = area.axisTitle && area.axisShown ? [{ x: area.frame.plot.x, y: area.axisTitleY, w: area.axisTitle.width, h: area.axisTitle.height }] : [];
|
|
2449
|
+
return runAnnotatePass({
|
|
2450
|
+
target: domain.options.target,
|
|
2451
|
+
// Events belong to the event lane.
|
|
2452
|
+
annotations: withoutEvents(reserves.annList),
|
|
2453
|
+
resolve: resolveAnchor,
|
|
2454
|
+
anchorError,
|
|
2455
|
+
labelRequests,
|
|
2456
|
+
printedLabels,
|
|
2457
|
+
defaultSpan: cats.length >= 2 ? { from: cats[0].id, to: cats[cats.length - 1].id } : void 0,
|
|
2458
|
+
// A time axis reading's id is its ISO instant.
|
|
2459
|
+
...domain.x?.model.clock ? { elapsedYears: (from, to) => from.owner.categoryId === void 0 || to.owner.categoryId === void 0 ? void 0 : zoneYearSpan(Date.parse(from.owner.categoryId), Date.parse(to.owner.categoryId), domain.x.model.clock) } : {},
|
|
2460
|
+
occupied,
|
|
2461
|
+
plot: annPlot,
|
|
2462
|
+
laneCeiling: annPlot.y,
|
|
2463
|
+
bandCeiling: area.frame.plot.y,
|
|
2464
|
+
ceilingRects,
|
|
2465
|
+
theme: env.theme,
|
|
2466
|
+
measure: env.measure,
|
|
2467
|
+
format: options.format,
|
|
2468
|
+
locale: options.locale?.language,
|
|
2469
|
+
strings: options.strings,
|
|
2470
|
+
percentLevels: !rebased && percentLevels(dataSeries),
|
|
2471
|
+
valueLinePercentLevels: !rebased && (domain.variant === "stacked100-area" || domain.options.unit === "%" || percentLevels(dataSeries)),
|
|
2472
|
+
solveCtx,
|
|
2473
|
+
yScale: y,
|
|
2474
|
+
meanValue: scene.meanValue,
|
|
2475
|
+
meanValueFor: scene.meanValueFor,
|
|
2476
|
+
// A mean keeps every source period, and its label names them where the plot draws fewer.
|
|
2477
|
+
meanSpan: viewportMeanSpan(domain.population),
|
|
2478
|
+
...categoryTargetFields(cats.map((c) => c.id), area.forecastPlot, xOf, "x"),
|
|
2479
|
+
resolveCategoryBand,
|
|
2480
|
+
...domain.x ? { resolvePeriodSlot } : {},
|
|
2481
|
+
partialCategories: partialIds(cats),
|
|
2482
|
+
// A key beside the plot takes the margin the bracket stands in.
|
|
2483
|
+
...env.isBump || cats.length === 0 || occupied.snapshot().some((claim) => claim.kind === "legend" && claim.rect.x >= plot.x + plot.w) ? {} : { gapBracket: {
|
|
2484
|
+
engine: gapBracketEngine,
|
|
2485
|
+
categoryId: cats[cats.length - 1].id,
|
|
2486
|
+
spine: env.size.width - canvasMargin(env.theme, env.size.width).right,
|
|
2487
|
+
width: env.size.width,
|
|
2488
|
+
...options.gapFill ? { washed: options.gapFill.between } : {},
|
|
2489
|
+
refused: options[GAP_BRACKET_REFUSED],
|
|
2490
|
+
// Stacked ends sit at cumulative tops, so their distance is not the gap the number states.
|
|
2491
|
+
...isStacked ? { unavailable: "the series are stacked, so the end points sit at cumulative tops and not at the values" } : {}
|
|
2492
|
+
} }
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
function lineStandings(env, domain, text) {
|
|
2496
|
+
let { cats, dataSeries, bumpDerived, endpoints, variant, rebased, lastIdxOf } = domain, finalCi = cats.length - 1, bumpFinal = bumpDerived ? dataSeries.map((s) => ({ s, rank: bumpDerived.ranks[s.id]?.[finalCi] ?? null })) : [], bumpExited = bumpFinal.filter((entry) => entry.rank === null && endpoints[entry.s.id]), endpointDesc = env.isBump ? bumpFinal.filter((entry) => entry.rank !== null).sort((a, b) => a.rank - b.rank).map((entry) => chartString2(domain.options, "entityRank", { v1: entry.s.label, v2: entry.rank })).join(", ") : dataSeries.filter((s) => endpoints[s.id]).map((s) => {
|
|
2497
|
+
let shareText = domain.shareTexts.get(`${endpoints[s.id].categoryId}\0${s.id}`);
|
|
2498
|
+
if (shareText !== void 0) return `${s.label} ${shareText}`;
|
|
2499
|
+
let cell = s.vals[lastIdxOf.get(s.id)], source = rebased ? void 0 : cell.format ? { ...s, format: cell.format } : s;
|
|
2500
|
+
return `${s.label} ${text.composeEndText(variant === "stacked100-area" ? ["percent"] : ["absolute"], endpoints[s.id].value, endpoints[s.id].value, "", "", endUnitSuffix(domain.options, rebased), cell.isPct, source)}`;
|
|
2501
|
+
}).join(", "), lastRankedLabel = (id) => {
|
|
2502
|
+
let row = bumpDerived?.ranks[id] ?? [], at = -1;
|
|
2503
|
+
return row.forEach((rank, i) => {
|
|
2504
|
+
rank !== null && (at = i);
|
|
2505
|
+
}), at === -1 ? "no period" : cats[at].label ?? cats[at].id;
|
|
2506
|
+
}, bumpExitedDesc = bumpExited.length > 0 ? chartString2(domain.options, "bumpExitedDesc", { v1: cats[finalCi].label ?? cats[finalCi].id, v2: bumpExited.map(
|
|
2507
|
+
(entry) => chartString2(domain.options, "bumpLastRankDesc", { v1: entry.s.label, v2: lastRankedLabel(entry.s.id), v3: endpoints[entry.s.id].value })
|
|
2508
|
+
).join(", ") }) : "";
|
|
2509
|
+
return { endpointDesc, bumpExitedDesc };
|
|
2510
|
+
}
|
|
2511
|
+
function lineA11yDesc(env, domain, area, marks, variantName, text) {
|
|
2512
|
+
let { options, cats, drawnSeries, refSeries, interpolationFor, rebased, bumpDerived, fan, variant, nmCats100, naCats100 } = domain, { endpointDesc, bumpExitedDesc } = lineStandings(env, domain, text), finalCi = cats.length - 1, suppressedCompositionDesc = variant === "stacked100-area" && (nmCats100.size > 0 || naCats100.size > 0) ? chartString2(domain.options, "areaCompositionsDesc", { v1: cats.filter((category) => !nmCats100.has(category.id) && !naCats100.has(category.id)).map((category) => category.label ?? category.id).join(", ") || chartString2(domain.options, "none"), v2: cats.filter((category) => nmCats100.has(category.id) || naCats100.has(category.id)).map((category) => `${category.label ?? category.id} (${nmCats100.has(category.id) ? "n.m." : "n/a"})`).join(", ") }) : "", fanDesc = fan ? chartString2(domain.options, "fanDesc", { v1: fan.of.label, v2: fan.bands.map((band) => band.label).join(", ") }) + (fan.origin === null ? chartString2(domain.options, "fanZeroWidth") : chartString2(domain.options, "fanOrigin", { v1: cats.find((category) => category.id === fan.origin)?.label ?? fan.origin })) : "", effectiveInterpolationDesc = [...new Set(drawnSeries.map(interpolationFor))].filter(
|
|
2513
|
+
(mode) => mode !== "linear"
|
|
2514
|
+
);
|
|
2515
|
+
return chartString2(domain.options, "lineDescStart", { v1: variantName, v2: drawnSeries.length, v3: cats.length }) + fanDesc + (refSeries.length ? chartString2(domain.options, "referenceSeriesClause", { v1: refSeries.length }) : "") + (effectiveInterpolationDesc.length === 0 ? "" : chartString2(domain.options, "interpolationClause", { v1: effectiveInterpolationDesc.map((value) => chartString2(domain.options, { linear: "linearInterpolation", "step-after": "stepAfterInterpolation", "step-before": "stepBeforeInterpolation", monotone: "monotoneInterpolation" }[value])).join(" / ") })) + (marks.gapFills ? chartString2(domain.options, "lineDifferenceDesc", { v1: options.gapFill.between[0], v2: options.gapFill.between[1] }) : "") + (marks.targets ? chartString2(domain.options, "lineTargetsDesc", { v1: marks.targets.length, v2: marks.targets.length === 1 ? "" : "s" }) : "") + (marks.phases ? chartString2(domain.options, "linePhasesDesc", { v1: marks.phases.length }) : "") + (rebased ? chartString2(domain.options, "lineIndexed") : "") + (bumpDerived ? chartString2(domain.options, "lineRanksDesc", { v1: bumpDerived.maxRank, v2: chartString2(domain.options, bumpDerived.direction === "higherIsBetter" ? "higherBetter" : "lowerBetter") }) + (bumpDerived.ties.length > 0 ? chartString2(domain.options, "lineRankTies", { v1: bumpDerived.ties.length, v2: bumpDerived.ties.length === 1 ? "" : "s" }) : "") : "") + (endpointDesc ? chartString2(domain.options, "lineEndpointsDesc", { v1: env.isBump ? chartString2(domain.options, "standingsPeriod", { v1: cats[finalCi].label ?? cats[finalCi].id }) : chartString2(domain.options, "latestValues"), v2: endpointDesc }) : ".") + bumpExitedDesc + suppressedCompositionDesc + (domain.trends.length ? ` ${domain.trends.map((fit) => lineTrendLabel(domain, fit)).join(". ")}.` : "") + anomalyA11y(domain) + ratioTierA11y(area.ratioTier);
|
|
2516
|
+
}
|
|
2517
|
+
function lineAnomalyMarks(theme, domain, anomaly, area, text, scene, measure) {
|
|
2518
|
+
let series = domain.drawnSeries.find((s) => s.id === anomaly.seriesId), row = domain.pv[domain.rowOf.get(series)];
|
|
2519
|
+
return lineAnomalyFurniture(theme, {
|
|
2520
|
+
strings: domain.options.strings,
|
|
2521
|
+
anomaly: anomaly.model,
|
|
2522
|
+
corridorShown: anomaly.corridorShown,
|
|
2523
|
+
statFmt: anomaly.statFmt,
|
|
2524
|
+
fmt: domain.fmt,
|
|
2525
|
+
corridorPaint: columnCorridorPaint(domain.options.colorblindSafe),
|
|
2526
|
+
plot: area.forecastPlot,
|
|
2527
|
+
y: area.y,
|
|
2528
|
+
seriesId: series.id,
|
|
2529
|
+
// The rule numbers read in the right margin, which solveLineFrame reserves (anomalyRuleReserve).
|
|
2530
|
+
labelX: area.plot.x + area.plot.w + 4,
|
|
2531
|
+
points: domain.cats.flatMap((c, ci) => row[ci] === null ? [] : [{ categoryId: c.id, x: area.xOf(ci), y: area.y(row[ci]) }]),
|
|
2532
|
+
font: text.labelFont,
|
|
2533
|
+
measure,
|
|
2534
|
+
nodes: scene.nodes,
|
|
2535
|
+
claims: scene.claims
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
function lineDerived(domain, area, reserves, scene, ratioTierResult) {
|
|
2539
|
+
let { population, endpoints, bumpDerived, fan, rebased, drawnSeries, dLo, dHi } = domain, { endpointLabelEconomy, nearZeroTail } = reserves.endpoint, { catPlan } = area, categoryFont = catPlan.font, categoryTickMaxLines = catPlan.maxLines, domainEpsilon = Math.max(Math.abs(dLo), Math.abs(dHi), 1) * 1e-9;
|
|
2540
|
+
return {
|
|
2541
|
+
...population?.sampling ? { liveWindow: population.sampling } : {},
|
|
2542
|
+
endpoints,
|
|
2543
|
+
...domain.trends.length ? { trends: domain.trends } : {},
|
|
2544
|
+
...domain.roundingAdjustments ? { roundingAdjustments: domain.roundingAdjustments } : {},
|
|
2545
|
+
...domain.anomaly ? { anomaly: anomalyReceipt(domain.anomaly.model) } : {},
|
|
2546
|
+
...bumpDerived ? { bump: bumpDerived } : {},
|
|
2547
|
+
...fan ? {
|
|
2548
|
+
fan: {
|
|
2549
|
+
of: fan.of.id,
|
|
2550
|
+
origin: fan.origin,
|
|
2551
|
+
method: "declared-intervals",
|
|
2552
|
+
bands: fan.bands.map((band) => ({
|
|
2553
|
+
low: band.low.id,
|
|
2554
|
+
high: band.high.id,
|
|
2555
|
+
label: band.label,
|
|
2556
|
+
// DISPLAY-side quantization, and relative: the receipt must
|
|
2557
|
+
// read the same in units and in millions (see sigRound).
|
|
2558
|
+
widths: band.widths.map((w) => sigRound(w))
|
|
2559
|
+
}))
|
|
2560
|
+
}
|
|
2561
|
+
} : {},
|
|
2562
|
+
...scene.phaseDerived ? { phases: scene.phaseDerived } : {},
|
|
2563
|
+
...rebased ? { rebased: !0 } : {},
|
|
2564
|
+
...endpointLabelEconomy ? { endpointLabelEconomy } : {},
|
|
2565
|
+
...nearZeroTail ? { nearZeroTail } : {},
|
|
2566
|
+
seriesValueStats: lineValueStats(drawnSeries, domainEpsilon, population?.values),
|
|
2567
|
+
rightInset: area.margin.right,
|
|
2568
|
+
// The EFFECTIVE plot inset, not the authored margin: grid's two-pass
|
|
2569
|
+
// alignment compensates from "the margin the child actually applied",
|
|
2570
|
+
// and that is the reserve-widened value the plot honours.
|
|
2571
|
+
leftInset: area.leftMargin + area.categoryOverhang,
|
|
2572
|
+
...ratioTierResult ? { ratioTier: ratioTierResult.geometry } : {},
|
|
2573
|
+
...area.showCategoryTickRow ? {
|
|
2574
|
+
tickBand: {
|
|
2575
|
+
reserved: area.categoryTickReserve,
|
|
2576
|
+
measuredLines: categoryTickMaxLines,
|
|
2577
|
+
lineHeight: categoryFont.size * 1.2,
|
|
2578
|
+
extra: catPlan.rowHeight - categoryTickMaxLines * categoryFont.size * 1.2,
|
|
2579
|
+
dateNumeric: catPlan.dateNumeric,
|
|
2580
|
+
position: "below"
|
|
2581
|
+
}
|
|
2582
|
+
} : {}
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
function assembleLineGeometry(input) {
|
|
2586
|
+
let { env, domain, area, text, scene, plan, solved, annResult, warnings } = input, { isBump } = env, { options, cats, drawnSeries, variant } = domain, { plot, xOf } = area, { nodes, axes, marks } = scene, allLabels = [...solved.placed, ...annResult.labels], lineFocus = !isBump && !domain.isArea && variant === "line" && env.anyHighlight && options.highlightMode !== "fade", focusAbs = new Map(lineFocus ? input.reserves.annList.flatMap((a, n) => {
|
|
2587
|
+
let at = a.kind === "abs" && typeof a.at == "object" && "seriesId" in a.at ? a.at.seriesId : void 0;
|
|
2588
|
+
return at !== void 0 && env.highlights.has(at) ? [[`annotation:${defaultAnnotationId(a, n)}`, at]] : [];
|
|
2589
|
+
}) : []), focusSeriesOf = (label) => focusAbs.get(String(label.id)) ?? label.owner.seriesId, focusOf = (label) => {
|
|
2590
|
+
let id = focusSeriesOf(label);
|
|
2591
|
+
return lineFocus && id !== void 0 && env.highlights.has(id) && drawnSeries.some((s) => s.id === id);
|
|
2592
|
+
}, shared = new Set(input.reserves.endpoint.endLabels.filter((l) => l.shared).map((l) => l.id)), bumpStoryNames = isBump && env.anyHighlight && options.highlightMode !== "fade";
|
|
2593
|
+
for (let label of allLabels) {
|
|
2594
|
+
if (label.kind !== "series" || shared.has(label.id)) continue;
|
|
2595
|
+
let index = drawnSeries.findIndex((s) => s.id === label.owner.seriesId);
|
|
2596
|
+
if (index < 0) continue;
|
|
2597
|
+
let story = bumpStoryNames && env.highlights.has(label.owner.seriesId);
|
|
2598
|
+
label.ink = bumpStoryNames && !story ? { token: "inkMuted" } : seriesTextPaint(input.seriesPaint(drawnSeries[index], index)), label.font = { ...text.nameFont, ...label.font && label.font.size < text.nameFont.size ? { size: label.font.size } : {}, ...story || focusOf(label) ? { weight: emphasisWeight(env.theme) } : {} };
|
|
2599
|
+
}
|
|
2600
|
+
for (let label of allLabels) {
|
|
2601
|
+
if (label.kind === "series" || !focusOf(label) || label.kind !== "point" && !focusAbs.has(String(label.id))) continue;
|
|
2602
|
+
let index = drawnSeries.findIndex((s) => s.id === focusSeriesOf(label));
|
|
2603
|
+
label.ink = seriesTextPaint(input.seriesPaint(drawnSeries[index], index)), label.font = { ...label.font ?? text.labelFont, weight: emphasisWeight(env.theme) };
|
|
2604
|
+
}
|
|
2605
|
+
let backdrop = lineFocus || bumpStoryNames ? secondaryFont(env.theme) : void 0;
|
|
2606
|
+
if (backdrop) for (let label of allLabels) {
|
|
2607
|
+
if (label.kind !== "series" && label.kind !== "point" || shared.has(label.id)) continue;
|
|
2608
|
+
let id = label.owner.seriesId, index = drawnSeries.findIndex((s) => s.id === id);
|
|
2609
|
+
if (id === void 0 || index < 0 || env.highlights.has(id)) continue;
|
|
2610
|
+
let font = label.font ?? text.labelFont;
|
|
2611
|
+
backdrop.size >= font.size || (label.kind === "point" && "token" in label.ink && label.ink.token === "ink" && Object.keys(label.ink).length === 1 && (label.ink = seriesTextPaint(input.seriesPaint(drawnSeries[index], index))), shrinkPlacedLabel(label, font, { ...font, size: backdrop.size }));
|
|
2612
|
+
}
|
|
2613
|
+
spliceAnnotationNodes(nodes, annResult.nodes);
|
|
2614
|
+
let lane = input.lane;
|
|
2615
|
+
if (lane?.behind.length) {
|
|
2616
|
+
let lastGrid = nodes.map((node) => node.part).lastIndexOf("gridline"), firstMark = nodes.findIndex((node) => node.owner.seriesId !== void 0), tail = nodes.splice(lastGrid >= 0 ? lastGrid + 1 : firstMark >= 0 ? firstMark : nodes.length);
|
|
2617
|
+
pushAll(nodes, lane.behind), pushAll(nodes, tail);
|
|
2618
|
+
}
|
|
2619
|
+
if (domain.isArea) {
|
|
2620
|
+
let lastFill = nodes.reduce((at, node, i) => node.part === "area" || node.part === "forecastHatch" || node.part === "areaSeparator" ? i : at, -1);
|
|
2621
|
+
if (lastFill >= 0) {
|
|
2622
|
+
let shaded = fillShadings(nodes, scene.rendered.areaOutlines, fillShadingKinds(withoutEvents(input.reserves.annList)), plot, strokeToken(env.theme, "rule"), bandHatch(env.theme, options.hatchStrength)), seams = domain.isStacked && shaded.nodes.length > 0 ? nodes.slice(0, lastFill + 1).filter((node) => node.part === "line" && node.owner.seriesId !== void 0 || node.part === "areaSeparator") : [];
|
|
2623
|
+
nodes.splice(lastFill + 1, 0, ...shaded.nodes, ...seams);
|
|
2624
|
+
for (let seam of seams) nodes.splice(nodes.indexOf(seam), 1);
|
|
2625
|
+
regroundOnShadings(allLabels, shaded.grounds);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
emitForecastDividers(env.theme, area.forecast, xOf, area.forecastPlot, nodes, forecastDividerAt(domain)), domain.isArea && backForecastAreaLabels(allLabels, drawnSeries, cats, plot, input.areaFill, nodes);
|
|
2629
|
+
let bandLabelIds = new Set(
|
|
2630
|
+
annResult.placed.filter((ann) => ann.kind === "band").map((ann) => ann.labelId)
|
|
2631
|
+
), { tickFont, labelFont } = text, categoryFont = area.catPlan.font, labelNodes = labelsToNodes(
|
|
2632
|
+
env.theme,
|
|
2633
|
+
allLabels,
|
|
2634
|
+
(l) => plan.ratioTierRequestState?.fontByLabelId.get(l.id) ?? (l.id.startsWith("forecast:") ? text.secondaryFont : bandLabelIds.has(l.id) || l.id.startsWith("tieLabel:") ? tickFont : l.kind === "category" ? categoryFont : l.kind === "annotation" || l.kind === "valueLine" ? { ...labelFont, weight: emphasisWeight(env.theme) } : labelFont),
|
|
2635
|
+
nodes
|
|
2636
|
+
);
|
|
2637
|
+
for (let end of input.reserves.endpoint.endLabels) {
|
|
2638
|
+
if (!end.valueText || end.shared || end.text === end.s.label || !end.text.endsWith(` ${end.valueText}`)) continue;
|
|
2639
|
+
let node = labelNodes.find((n) => n.id === `label:${end.id}`);
|
|
2640
|
+
if (node?.t !== "text") continue;
|
|
2641
|
+
let endWeight = lineFocus && env.highlights.has(end.s.id) ? emphasisWeight(env.theme) : labelFont.weight;
|
|
2642
|
+
if (node.lines.length === 1) node.runs = [
|
|
2643
|
+
{ text: node.lines[0].slice(0, -end.valueText.length), weight: endWeight },
|
|
2644
|
+
{ text: end.valueText, weight: endWeight }
|
|
2645
|
+
];
|
|
2646
|
+
else {
|
|
2647
|
+
let nameLines = node.lines.slice(0, -1);
|
|
2648
|
+
labelNodes.push({
|
|
2649
|
+
...node,
|
|
2650
|
+
id: `${node.id}:value`,
|
|
2651
|
+
y: node.y + nameLines.length * text.labelH,
|
|
2652
|
+
lines: [end.valueText],
|
|
2653
|
+
font: { ...node.font, weight: endWeight },
|
|
2654
|
+
role: "value"
|
|
2655
|
+
}), node.lines = nameLines;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
if (!domain.isArea) {
|
|
2659
|
+
let earlyEndLeaders = new Set(input.reserves.endpoint.endLabels.filter((label) => label.ci < cats.length - 1).map((label) => `leader:${label.id}`));
|
|
2660
|
+
for (let node of labelNodes)
|
|
2661
|
+
node.t !== "path" || node.part !== "leader" || !plan.endpointLeaderAnchors.has(node.id.slice(7)) || (node.stroke = { token: "leader" }, earlyEndLeaders.has(node.id) && (node.stroke = { token: "inkMuted" }, node.dash = dashToken(env.theme, "dotted"), node.lineCap = "round"));
|
|
2662
|
+
}
|
|
2663
|
+
pushAll(nodes, labelNodes), lane && pushAll(nodes, lane.nodes), axes.unshift({
|
|
2664
|
+
axis: "x",
|
|
2665
|
+
baselineNodeId: scene.rendered.baselineId,
|
|
2666
|
+
ticks: cats.map((c, i) => ({
|
|
2667
|
+
at: c.id,
|
|
2668
|
+
pos: xOf(i),
|
|
2669
|
+
// A continuous axis labels its scale ticks, not its readings.
|
|
2670
|
+
labelId: plan.catLabelsShown && !area.xTicks ? `category:${c.id}` : void 0
|
|
2671
|
+
}))
|
|
2672
|
+
});
|
|
2673
|
+
let variantName = isBump ? chartString2(domain.options, "bumpVariant") : variant === "line" ? chartString2(domain.options, "lineName") : variant === "area" ? chartString2(domain.options, "areaName2") : variant === "stacked-area" ? chartString2(domain.options, "stackedArea") : chartString2(domain.options, "percentArea"), bandLevels = (input.reserves.referenceBands?.entries ?? []).flatMap((entry) => [entry.low, entry.high]), bandFmt = variant === "stacked100-area" ? (v) => formatAutomaticPercent(v, autoDecimals(v), !1, domain.options.locale?.language) : area.axisTickSpec ? tickFormatter(area.axisTickSpec, bandLevels) : area.axisFmt, a11yDesc = lineA11yDesc(env, domain, area, marks, variantName, text) + referenceBandsA11y(input.reserves.referenceBands, bandFmt, domain.options) + (usesEndLabelKey(options) ? chartString2(domain.options, "lineEndKeyDesc") : "");
|
|
2674
|
+
return {
|
|
2675
|
+
type: "line",
|
|
2676
|
+
size: env.size,
|
|
2677
|
+
plot,
|
|
2678
|
+
// The floor counts data height only, for an area as for a line: a header
|
|
2679
|
+
// or an annotation band above the data does not shrink the plot.
|
|
2680
|
+
...area.forecastPlot !== plot ? { [PLOT_FLOOR_RECT]: area.forecastPlot } : {},
|
|
2681
|
+
scene: nodes,
|
|
2682
|
+
labels: lane ? [...allLabels, ...lane.labels] : allLabels,
|
|
2683
|
+
axes,
|
|
2684
|
+
annotations: lane ? [...annResult.placed, ...lane.placed] : annResult.placed,
|
|
2685
|
+
legend: area.frame.legend,
|
|
2686
|
+
frame: area.frame.frame,
|
|
2687
|
+
marks,
|
|
2688
|
+
derived: lineDerived(domain, area, input.reserves, scene, input.ratioTierResult),
|
|
2689
|
+
a11y: {
|
|
2690
|
+
title: accessibleTitle(options.title, chartString2(domain.options, "lineTitle", { v1: variantName, v2: drawnSeries.map((s) => s.label).join(", "), v3: cats.length })),
|
|
2691
|
+
// The default title counts periods ("over 24 periods"); a grid reports that count when it prints the title.
|
|
2692
|
+
titleCounts: [structureCount("periods", cats.length, void 0, domain.options)],
|
|
2693
|
+
counts: [
|
|
2694
|
+
...domain.anomaly?.model?.counts ?? [],
|
|
2695
|
+
structureCount("series", domain.drawnSeries.length, void 0, domain.options),
|
|
2696
|
+
structureCount("categories", domain.cats.length, void 0, domain.options),
|
|
2697
|
+
...domain.refSeries.length ? [structureCount("reference-series", domain.refSeries.length, chartString2(domain.options, "referenceSeriesCount", { v1: domain.refSeries.length }))] : [],
|
|
2698
|
+
...marks.targets ? [structureCount("markers", marks.targets.length, chartString2(domain.options, "targetMarkersCount", { v1: marks.targets.length, v2: marks.targets.length === 1 ? "" : "s" }))] : [],
|
|
2699
|
+
...marks.phases ? [structureCount("phases", marks.phases.length, chartString2(domain.options, "lifecyclePhasesCount", { v1: marks.phases.length }))] : [],
|
|
2700
|
+
...domain.bumpDerived?.ties.length ? [structureCount("groups", domain.bumpDerived.ties.length, chartString2(domain.options, "tiedGroupsCount", { v1: domain.bumpDerived.ties.length, v2: domain.bumpDerived.ties.length === 1 ? "" : "s" }))] : []
|
|
2701
|
+
],
|
|
2702
|
+
desc: a11yDesc
|
|
2703
|
+
},
|
|
2704
|
+
warnings,
|
|
2705
|
+
paintWarningRules: scene.paintWarningRules,
|
|
2706
|
+
debug: {
|
|
2707
|
+
occupied: input.occupied.snapshot(),
|
|
2708
|
+
decisions: [...solved.decisions, ...annResult.decisions]
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
function firstLastFallback(domain, requests, solved, warnings) {
|
|
2713
|
+
if (domain.labelModes.values !== "extremes") return;
|
|
2714
|
+
let catIndex = new Map(domain.cats.map((category, index) => [category.id, index])), series = new Map(domain.drawnSeries.map((s) => [s.id, s])), endsOf = (id) => {
|
|
2715
|
+
let drawn = domain.pv[domain.rowOf.get(series.get(id))].flatMap((v, ci) => v === null ? [] : [ci]);
|
|
2716
|
+
return [drawn[0], drawn[drawn.length - 1]];
|
|
2717
|
+
}, lost = new Set(solved.placed.filter((label) => label.kind === "point" && label.hidden === "collision" && !solved.ownershipLimited?.has(label.id) && label.owner.seriesId !== void 0 && series.has(label.owner.seriesId) && !endsOf(label.owner.seriesId).includes(catIndex.get(label.owner.categoryId ?? ""))).map((label) => label.owner.seriesId));
|
|
2718
|
+
if (lost.size === 0) return;
|
|
2719
|
+
let ends = new Map([...lost].map((id) => [id, endsOf(id)]));
|
|
2720
|
+
for (let id of lost)
|
|
2721
|
+
warnings.push({
|
|
2722
|
+
code: "line-labels-first-last",
|
|
2723
|
+
severity: "info",
|
|
2724
|
+
owner: { seriesId: id },
|
|
2725
|
+
message: `series '${id}' labels its first and last point only: a point value collided with another label, a line or a mark`,
|
|
2726
|
+
suggest: "widen the chart, or label fewer points"
|
|
2727
|
+
});
|
|
2728
|
+
return requests.map((request) => {
|
|
2729
|
+
let id = request.owner.seriesId;
|
|
2730
|
+
if (request.kind !== "point" || id === void 0 || !lost.has(id)) return request;
|
|
2731
|
+
let ci = catIndex.get(request.owner.categoryId ?? "");
|
|
2732
|
+
return ci === void 0 || ends.get(id).includes(ci) || typeof series.get(id).vals[ci]?.labelOverride == "string" ? request : { ...request, redundant: !0, suppressedAs: "density" };
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
var laneAxis = (area, plot) => area.xOfValue ? { x: area.xOfValue, step: area.step, plot, continuous: !0 } : { x: area.xOf, step: area.step, plot };
|
|
2736
|
+
function layoutLine(data, authoredOptions = {}) {
|
|
2737
|
+
let options = withLocaleStrings(authoredOptions), geometry = layoutLinePass(data, options), widenForBracket = () => {
|
|
2738
|
+
let bracketNeed = Math.ceil(geometry[GAP_BRACKET_RESERVE] ?? 0);
|
|
2739
|
+
bracketNeed <= 0 || (options = { ...options, [GAP_BRACKET_RESERVE]: bracketNeed }, geometry = layoutLinePass(data, options));
|
|
2740
|
+
};
|
|
2741
|
+
widenForBracket();
|
|
2742
|
+
let refused = geometry[GAP_BRACKET_REFUSED];
|
|
2743
|
+
refused && (options = { ...options, [GAP_BRACKET_RESERVE]: 0, [GAP_BRACKET_REFUSED]: refused }, geometry = layoutLinePass(data, options), widenForBracket());
|
|
2744
|
+
let env = resolveLineEnv(options, []), labelFont = { family: env.theme.type.family, ...env.theme.type.label, weight: emphasisWeight(env.theme) }, valueLineReserve = hiddenValueLineReserve(geometry.labels, (text) => env.measure(text, labelFont).width, env.size.width);
|
|
2745
|
+
valueLineReserve > 0 && (options = { ...options, [VALUE_LINE_RESERVE]: valueLineReserve }, geometry = layoutLinePass(data, options));
|
|
2746
|
+
for (let step = 0; step < 2; step++) {
|
|
2747
|
+
let bandNeed = Math.ceil(geometry[BAND_PAD] ?? 0);
|
|
2748
|
+
if (bandNeed <= 0) break;
|
|
2749
|
+
let prevBandPad = options[BAND_PAD] ?? 0;
|
|
2750
|
+
options = { ...options, [BAND_PAD]: prevBandPad + bandNeed }, geometry = layoutLinePass(data, options);
|
|
2751
|
+
}
|
|
2752
|
+
if (options.variant === "bump") {
|
|
2753
|
+
let named = new Set(geometry.labels.filter((label) => label.kind === "series").map((label) => `${label.owner.seriesId}:${label.owner.categoryId}`)), noted2 = options[NOTED_LABELS], lost = (label) => label.hidden === "collision" || label.hidden === "density" && options.labelDensity !== "minimal", folded = new Map(geometry.labels.filter((label) => label.kind === "point" && lost(label) && !noted2?.has(label.id) && named.has(`${label.owner.seriesId}:${label.owner.categoryId}`)).map((label) => [label.id, label.text]));
|
|
2754
|
+
if (folded.size === 0) return geometry;
|
|
2755
|
+
let fold = (values) => layoutLinePass(data, { ...options, [BUMP_FOLDED]: values }), refolded = fold(folded), fixedHeight = options[TARGET_SIZE]?.fixed.height ?? !heightOmitted(options.size), floor = (g) => Math.max(g.frame.minHeight ?? 0, g.frame.plotMinHeight ?? 0), height = geometry.size.height;
|
|
2756
|
+
if (!fixedHeight || floor(refolded) <= height || floor(geometry) > height) return refolded;
|
|
2757
|
+
let lines = new Map(geometry.labels.map((label) => [label.id, label.lines.length])), before = folded.size;
|
|
2758
|
+
for (let label of refolded.labels)
|
|
2759
|
+
label.kind === "series" && label.lines.length > (lines.get(label.id) ?? 1) && folded.delete(`point:${label.owner.seriesId}:${label.owner.categoryId}`);
|
|
2760
|
+
if (folded.size === before || folded.size === 0) return geometry;
|
|
2761
|
+
let partial = fold(folded);
|
|
2762
|
+
return floor(partial) <= height ? partial : geometry;
|
|
2763
|
+
}
|
|
2764
|
+
if (options.valueAxis?.show !== void 0) return geometry;
|
|
2765
|
+
let ticks = geometry.axes.find((axis) => axis.axis === "y")?.ticks.filter((tick) => tick.labelId).length ?? 0, noted = options[NOTED_LABELS], hidden = geometry.labels.some((label) => label.kind === "point" && (label.hidden || noted?.has(label.id)) && label.owner.seriesId !== void 0);
|
|
2766
|
+
return ticks < 3 && hidden ? layoutLinePass(data, { ...options, valueAxis: { ...options.valueAxis, show: !0 } }) : geometry;
|
|
2767
|
+
}
|
|
2768
|
+
var INLINE_FALLBACK_MAX_WIDTH = 480;
|
|
2769
|
+
function inlineFallbackApplies(options, domain, env) {
|
|
2770
|
+
let legend = typeof options.legend == "object" ? options.legend.position : options.legend;
|
|
2771
|
+
return domain.variant === "line" && !env.isBump && !domain.fan && env.size.width <= INLINE_FALLBACK_MAX_WIDTH && domain.drawnSeries.length >= 2 && domain.drawnSeries.length <= 5 && options.seriesLabels === void 0 && options.labels !== !1 && options.labels?.series === void 0 && legend === void 0 && options[INLINE_FALLBACK] !== !0 && !usesEndLabelKey(options);
|
|
2772
|
+
}
|
|
2773
|
+
function endNameFallback(data, options, domain, env) {
|
|
2774
|
+
return inlineFallbackApplies(options, domain, env) ? layoutLinePass(data, { ...options, seriesLabels: "inline", [INLINE_FALLBACK]: !0 }) : layoutLinePass(data, { ...withoutInlineFallback(options), [END_LABEL_KEY]: !0 });
|
|
2775
|
+
}
|
|
2776
|
+
function withoutInlineFallback(options) {
|
|
2777
|
+
if (options[INLINE_FALLBACK] !== !0) return options;
|
|
2778
|
+
let { seriesLabels: _drop, ...rest } = options;
|
|
2779
|
+
return { ...rest, [INLINE_FALLBACK]: !1 };
|
|
2780
|
+
}
|
|
2781
|
+
var DIFF_FIRST = /* @__PURE__ */ Symbol("diffFirst");
|
|
2782
|
+
function layoutLinePass(data, options = {}) {
|
|
2783
|
+
let warnings = [], legendNone = (typeof options.legend == "object" ? options.legend.position : options.legend) === "none", replaced = options[END_LABEL_KEY] === "inline" ? "inline" : options.seriesLabels === "end" || options.seriesLabels === "inline" ? options.seriesLabels : void 0;
|
|
2784
|
+
options[END_LABEL_KEY] === "range" && !legendNone ? warnings.push({
|
|
2785
|
+
code: "line-end-label-key",
|
|
2786
|
+
severity: "info",
|
|
2787
|
+
message: "The range continues the fan past its last reading, so the key carries the last values of the centre line and the outer band."
|
|
2788
|
+
}) : usesEndLabelKey(options) && !legendNone && warnings.push(replaced ? {
|
|
2789
|
+
code: "line-end-label-key",
|
|
2790
|
+
severity: "warn",
|
|
2791
|
+
message: `seriesLabels: '${replaced}' was overridden: the ${replaced === "end" ? "end" : "inline"} names do not fit, so a key ordered by latest value names the lines`,
|
|
2792
|
+
suggest: "shorten the series labels or widen the chart so the names fit, or set seriesLabels: 'key'"
|
|
2793
|
+
} : {
|
|
2794
|
+
code: "line-end-label-key",
|
|
2795
|
+
severity: "info",
|
|
2796
|
+
message: "End labels use a key ordered by latest value because they cannot fit within three label line heights of their endpoints."
|
|
2797
|
+
}), usesEndLabelKey(options) && legendNone && warnings.push({
|
|
2798
|
+
code: "legend-none-overridden",
|
|
2799
|
+
severity: "warn",
|
|
2800
|
+
message: `legend: 'none'${replaced ? ` and seriesLabels: '${replaced}' were` : " was"} overridden: the ${replaced === "inline" ? "inline" : "end"} names do not fit beside the plot, so a key row names the lines`,
|
|
2801
|
+
suggest: "shorten the series labels or give the chart more room. To use a key, set seriesLabels: 'none' and legend: 'top'; point values can still need more room.",
|
|
2802
|
+
field: ["options", "legend"]
|
|
2803
|
+
});
|
|
2804
|
+
let env = resolveLineEnv(options, warnings), domain = resolveLineDomain(data, options, env, warnings), paints = linePaints(env, domain, warnings), text = lineText(env, domain);
|
|
2805
|
+
if (domain.fan && domain.x?.range?.cut.hi && !env.isBump && !usesEndLabelKey(options) && domain.labelModes.values !== "none")
|
|
2806
|
+
return layoutLinePass(data, { ...withoutInlineFallback(options), [END_LABEL_KEY]: "range" });
|
|
2807
|
+
let reserves = lineReserves(env, domain, paints, text, warnings);
|
|
2808
|
+
if (reserves.endpoint.endpointLegendFallback && inlineFallbackApplies(options, domain, env)) return endNameFallback(data, options, domain, env);
|
|
2809
|
+
let { size, theme, measure } = env, occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), settle = (held, sink) => settleEventLane({
|
|
2810
|
+
annotations: held.annList,
|
|
2811
|
+
categories: domain.cats,
|
|
2812
|
+
events: options.events,
|
|
2813
|
+
language: options.locale?.language,
|
|
2814
|
+
colorblindSafe: options.colorblindSafe,
|
|
2815
|
+
inline: !0,
|
|
2816
|
+
footnotesOff: options.footnotesOff,
|
|
2817
|
+
theme,
|
|
2818
|
+
measure,
|
|
2819
|
+
size,
|
|
2820
|
+
compact: options.mode === "compact",
|
|
2821
|
+
solve: (key, w) => ({ ...solveLineFrame(env, domain, paints, text, held, w, key), key }),
|
|
2822
|
+
area: (framed2, w) => {
|
|
2823
|
+
let count = w.length, area2 = linePlotArea(env, domain, text, held, framed2, w);
|
|
2824
|
+
if (options.mode !== "compact" || !domain.rebaseSuppressed.length || domain.rebaseCompact || area2.forecastPlot.h >= 80) return area2;
|
|
2825
|
+
domain.rebaseCompact = !0, w.length = count;
|
|
2826
|
+
let next = solveLineFrame(env, domain, paints, text, held, w, framed2.key);
|
|
2827
|
+
return Object.assign(framed2, next), linePlotArea(env, domain, text, held, framed2, w);
|
|
2828
|
+
},
|
|
2829
|
+
...domain.x ? { scale: laneScale(domain.x) } : {},
|
|
2830
|
+
axis: (area2) => laneAxis(area2, area2.plot),
|
|
2831
|
+
warnings: sink
|
|
2832
|
+
}), firstWarnings = [], settled = settle(reserves, firstWarnings), endpoint = reserves.endpoint, inset = settled.area.plot.x + settled.area.plot.w - settled.area.xOf(domain.cats.length - 1);
|
|
2833
|
+
if (!reserves.namesAtPlotEdge && endpoint.endLabels.length > 0 && inset > 0.5 && endpoint.endReserve >= settled.framed.margin.right - 0.5 ? (reserves = { ...reserves, endpoint: { ...endpoint, endReserve: Math.max(0, endpoint.endReserve - inset) } }, settled = settle(reserves, warnings)) : pushAll(warnings, firstWarnings), legendNone && !env.isBump && !usesEndLabelKey(options) && reserves.endpoint.endLabels.length > 0 && !reserves.endpoint.endLabels.some((label) => options.labelPlacements?.[label.id] !== void 0) && settled.area.plot.w / size.width < PLOT_W_FLOOR_DEMOTED)
|
|
2834
|
+
return layoutLinePass(data, { ...withoutInlineFallback(options), [END_LABEL_KEY]: !0 });
|
|
2835
|
+
let framed = settled.framed;
|
|
2836
|
+
commitClaims(occupied, framed.claims);
|
|
2837
|
+
let area = settled.area, scene = layoutLineMarks(env, domain, area, paints, text, reserves, warnings), anomalyMarks = domain.anomaly ? lineAnomalyMarks(theme, domain, domain.anomaly, area, text, scene, measure) : void 0;
|
|
2838
|
+
commitClaims(occupied, scene.claims);
|
|
2839
|
+
let plan = planLineLabels(env, domain, area, paints, text, reserves, scene, warnings);
|
|
2840
|
+
if (plan.endpointWiden) return layoutLinePass(data, { ...options, [END_LABEL_WIDE]: !0 });
|
|
2841
|
+
if (plan.endpointFallback && !usesEndLabelKey(options)) return endNameFallback(data, options, domain, env);
|
|
2842
|
+
anomalyMarks && seatFlaggedValues(plan.labelRequests, domain.anomaly.seriesId, anomalyMarks);
|
|
2843
|
+
let folded = options[BUMP_FOLDED], hosts = /* @__PURE__ */ new Map();
|
|
2844
|
+
for (let name of folded ? [...reserves.endpoint.endLabels, ...reserves.startLabels] : []) {
|
|
2845
|
+
let id = `point:${name.s.id}:${domain.cats[name.ci].id}`;
|
|
2846
|
+
folded.has(id) && name.lines.join(" ").includes(`\xB7 ${folded.get(id)}`) && hosts.set(id, name.id);
|
|
2847
|
+
}
|
|
2848
|
+
for (let request of plan.labelRequests) hosts.has(request.id) && Object.assign(request, { redundant: !0, suppressedAs: "redundant" });
|
|
2849
|
+
let solveCtx = labelCtx(theme, size, domain.options, {
|
|
2850
|
+
density: env.density,
|
|
2851
|
+
measure,
|
|
2852
|
+
plot: area.plot,
|
|
2853
|
+
labelPad: 2,
|
|
2854
|
+
...domain.labelModes.values === "all" && !domain.isStacked ? { valueRows: domain.drawnSeries.map((series) => ({
|
|
2855
|
+
ids: domain.cats.flatMap((category, ci) => typeof series.vals[ci]?.labelOverride == "string" ? [] : [`point:${series.id}:${category.id}`]),
|
|
2856
|
+
alternate: !0
|
|
2857
|
+
})) } : {},
|
|
2858
|
+
// A value reads as its own point's (label/ownership.ts); stacked values sit in their bands.
|
|
2859
|
+
...domain.isStacked ? {} : {
|
|
2860
|
+
pointOwnership: {
|
|
2861
|
+
points: scene.marks.series.flatMap((series) => series.points.map((p) => ({ seriesId: series.seriesId, categoryId: p.categoryId, x: p.x, y: p.y }))),
|
|
2862
|
+
categoryX: new Map(domain.cats.map((c, ci) => [c.id, area.xOf(ci)]))
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
}), joint = options[DIFF_FIRST] === !0, annResult, solve = (requests) => {
|
|
2866
|
+
if (!joint) return solveLabels(requests, occupied, solveCtx);
|
|
2867
|
+
annResult = annotateLine(env, domain, area, reserves, scene, occupied, solveCtx, requests);
|
|
2868
|
+
let ids = new Set(requests.map((request) => request.id)), placed = annResult.labels.filter((label) => ids.has(label.id));
|
|
2869
|
+
return annResult.labels = annResult.labels.filter((label) => !ids.has(label.id)), { placed, decisions: [], warnings: [] };
|
|
2870
|
+
}, solved = solve(plan.labelRequests);
|
|
2871
|
+
if (!env.isBump && (!domain.isArea || domain.x?.range) && !domain.fan && !usesEndLabelKey(options) && reserves.endpoint.endLabels.some((end) => solved.placed.some((label) => label.id === end.id && label.hidden === "collision")))
|
|
2872
|
+
return endNameFallback(data, options, domain, env);
|
|
2873
|
+
let legendShown = ["top", "right", "bottom"].includes((typeof options.legend == "object" ? options.legend.position : options.legend) ?? "none");
|
|
2874
|
+
if ((options[INLINE_FALLBACK] === !0 || options.seriesLabels === "inline" && !legendShown) && solved.placed.some((label) => label.kind === "series" && label.hidden !== void 0)) {
|
|
2875
|
+
let { seriesLabels: _names, ...keyed } = withoutInlineFallback(options);
|
|
2876
|
+
return layoutLinePass(data, { ...keyed, [END_LABEL_KEY]: usesInlineFallback(options) ? !0 : "inline" });
|
|
2877
|
+
}
|
|
2878
|
+
let fallback = firstLastFallback(domain, plan.labelRequests, solved, warnings);
|
|
2879
|
+
fallback && (occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), commitClaims(occupied, framed.claims), commitClaims(occupied, scene.claims), plan = { ...plan, labelRequests: fallback }, solved = solve(fallback));
|
|
2880
|
+
let toDate = lineToDateIds(env, domain, text);
|
|
2881
|
+
if (toDate.size > 0 && (!domain.x && !toDateFits(options.strings?.toDate ?? chartString2(options, "toDate"), env.theme, env.measure, area.step) || domain.cats.some((c, ci) => toDate.has(c.id) && domain.drawnSeries.some((s) => (s.vals[ci]?.v ?? null) !== null && !solved.placed.some((l) => l.id === `point:${s.id}:${c.id}` && l.hidden === void 0 && l.lines.length > 1)))))
|
|
2882
|
+
return layoutLinePass(data, { ...options, [PARTIAL_KEY]: !0 });
|
|
2883
|
+
let droppedWords = solved.placed.filter((l) => l.id.startsWith("xpartial:") && l.hidden !== void 0);
|
|
2884
|
+
if (domain.x && droppedWords.length && !options[X_PARTIAL_ROW])
|
|
2885
|
+
return layoutLinePass(data, { ...options, [X_PARTIAL_ROW]: !0 });
|
|
2886
|
+
for (let label of droppedWords) {
|
|
2887
|
+
let names = plan.xPartialGroups[Number(label.id.slice(9))] ?? [];
|
|
2888
|
+
warnings.push({
|
|
2889
|
+
code: "x-partial-words-dropped",
|
|
2890
|
+
severity: "warn",
|
|
2891
|
+
message: `"${label.text}" for the running reading${names.length === 1 ? "" : "s"} ${names.join(", ")} did not print: no seat under the axis is free. The hollow marker and the hover card still mark ${names.length === 1 ? "it" : "them"}`,
|
|
2892
|
+
suggest: "give the chart more width, or mark fewer readings in data.partial"
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
if (!env.isBump && (!domain.isArea || domain.x?.range) && !domain.fan && domain.drawnSeries.length <= 5 && !usesEndLabelKey(options) && options.seriesLabels !== "key" && options.seriesLabels !== "none" && solved.placed.some((label) => label.kind === "point" && label.hidden === "collision" && (label.owner.categoryId === domain.cats[domain.lastIdxOf.get(label.owner.seriesId ?? "") ?? -1]?.id || domain.x?.range && domain.isArea && label.owner.categoryId === domain.cats[0]?.id)))
|
|
2896
|
+
return layoutLinePass(data, { ...withoutInlineFallback(options), [END_LABEL_KEY]: !0 });
|
|
2897
|
+
keepEndValueOrder(solved.placed, plan.labelRequests, solveCtx.pins), applyValueAxisTitleInk(solved.placed);
|
|
2898
|
+
for (let label of solved.placed) hosts.has(label.id) && (label.printedIn = hosts.get(label.id));
|
|
2899
|
+
pushAll(warnings, solved.warnings);
|
|
2900
|
+
let ratioTierResult = settleLineLabels(env, area, scene, plan, solved, occupied, warnings);
|
|
2901
|
+
annResult ??= annotateLine(env, domain, area, reserves, scene, occupied, solveCtx, void 0, solved.placed);
|
|
2902
|
+
let diffHidden = annResult.placed.some((ann) => ann.kind === "diff" && annResult.labels.some((label) => label.id === ann.labelId && label.hidden === "collision"));
|
|
2903
|
+
if (!joint && diffHidden) return layoutLinePass(data, { ...options, [DIFF_FIRST]: !0 });
|
|
2904
|
+
pushAll(warnings, annResult.warnings);
|
|
2905
|
+
let lane = settled.lane ? emitEventLane(theme, {
|
|
2906
|
+
...settled.lane,
|
|
2907
|
+
axis: laneAxis(area, area.forecastPlot),
|
|
2908
|
+
mode: domain.isArea ? "stop" : "through",
|
|
2909
|
+
baseline: area.plot.y + area.plot.h,
|
|
2910
|
+
occupied,
|
|
2911
|
+
solveCtx
|
|
2912
|
+
}) : void 0;
|
|
2913
|
+
lane && pushAll(warnings, lane.warnings);
|
|
2914
|
+
let geometry = assembleLineGeometry({
|
|
2915
|
+
env,
|
|
2916
|
+
domain,
|
|
2917
|
+
area,
|
|
2918
|
+
text,
|
|
2919
|
+
reserves,
|
|
2920
|
+
scene,
|
|
2921
|
+
plan,
|
|
2922
|
+
solved,
|
|
2923
|
+
annResult,
|
|
2924
|
+
ratioTierResult,
|
|
2925
|
+
occupied,
|
|
2926
|
+
warnings,
|
|
2927
|
+
lane,
|
|
2928
|
+
areaFill: paints.areaFill,
|
|
2929
|
+
seriesPaint: paints.keyPaint
|
|
2930
|
+
});
|
|
2931
|
+
if (annResult.gapBracketNeed > 0 && Object.assign(geometry, { [GAP_BRACKET_RESERVE]: annResult.gapBracketNeed }), annResult.gapBracketHidden.length > 0 && Object.assign(geometry, { [GAP_BRACKET_REFUSED]: annResult.gapBracketHidden }), annResult.bandNeed > 0 && Object.assign(geometry, { [BAND_PAD]: annResult.bandNeed }), options.variant === "bump") {
|
|
2932
|
+
let tie = geometry.labels.find((label) => label.id.startsWith("tieLabel:") && label.hidden === "collision");
|
|
2933
|
+
if (tie) {
|
|
2934
|
+
let need = Math.ceil((tie.rect?.h ?? text.labelH) / 2) + 2;
|
|
2935
|
+
Object.assign(geometry, { [BAND_PAD]: Math.max(geometry[BAND_PAD] ?? 0, need) });
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
return geometry;
|
|
2939
|
+
}
|
|
2940
|
+
function keepEndValueOrder(placed, requests, pins) {
|
|
2941
|
+
let index = new Map(requests.map((request, i) => [request.id, i])), anchorOf = (label) => requests[index.get(label.id)]?.candidates.find((candidate) => candidate.slot === label.slot)?.leaderFrom ?? { x: label.rect.x - 7, y: label.rect.y + label.rect.h / 2 }, groups = /* @__PURE__ */ new Map();
|
|
2942
|
+
for (let label of placed)
|
|
2943
|
+
label.kind !== "point" || label.hidden !== void 0 || !index.has(label.id) || pins[label.id] !== void 0 || requests[index.get(label.id)]?.pinnedSlot !== void 0 || !(label.slot === "right" || label.slot.startsWith("rightStep")) || groups.set(label.owner.categoryId, [...groups.get(label.owner.categoryId) ?? [], label]);
|
|
2944
|
+
for (let group of groups.values()) {
|
|
2945
|
+
if (group.length < 2) continue;
|
|
2946
|
+
let anchors = new Map(group.map((label) => [label, anchorOf(label)])), seats = group.map((label) => ({ x: label.rect.x, y: label.rect.y, slot: label.slot })).sort((a, b) => a.y - b.y);
|
|
2947
|
+
[...group].sort((a, b) => anchors.get(a).y - anchors.get(b).y || index.get(a.id) - index.get(b.id)).forEach((label, i) => {
|
|
2948
|
+
let seat = seats[i];
|
|
2949
|
+
if (seat.y === label.rect.y) return;
|
|
2950
|
+
label.rect = { ...label.rect, x: seat.x, y: seat.y }, label.slot = seat.slot;
|
|
2951
|
+
let leader = seatLeader(label.rect, anchors.get(label));
|
|
2952
|
+
leader ? label.leader = leader : delete label.leader;
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
function shrinkPlacedLabel(label, old, font) {
|
|
2957
|
+
label.typeRole = "secondary";
|
|
2958
|
+
let dh = label.lines.length * (old.size - font.size) * (old.lineHeight ?? 1.2);
|
|
2959
|
+
label.font = font, dh > 0 && !label.rotate && label.capHeight === void 0 && (label.rect = { ...label.rect, y: label.rect.y + dh / 2, h: label.rect.h - dh });
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
// src/core/charts/line/core.ts
|
|
2963
|
+
var lineCore = {
|
|
2964
|
+
type: "line",
|
|
2965
|
+
sizing: chartSizing("line"),
|
|
2966
|
+
title: "Line / area",
|
|
2967
|
+
summary: "Time-series lines and areas: step interpolation, gap fills, target markers, event context, AC\u2192FC dashing, stacked and 100% variants",
|
|
2968
|
+
aliases: ["profile"],
|
|
2969
|
+
layout: (data, options) => withEventsDescribed(layoutLine(prepareFractionData(lowerLineX(data, options)), options), options),
|
|
2970
|
+
categoryLabels: (categories, language) => calendarCategories(categories, language, !0),
|
|
2971
|
+
// Without options (schema normalisation) data.x stays as authored; the request and the layout lower it.
|
|
2972
|
+
prepare: (data, options) => prepareFractionData(options ? lowerLineX(data, options) : data),
|
|
2973
|
+
defaults: { variant: "line" },
|
|
2974
|
+
annotationKinds: ["cagr", "diff", "delta", "note", "callout", "valueLine", "indicator100", "abs", "event", "band"]
|
|
2975
|
+
};
|
|
2976
|
+
|
|
2977
|
+
export {
|
|
2978
|
+
spaceDocLints,
|
|
2979
|
+
lineCore
|
|
2980
|
+
};
|