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,2934 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clipTrendToDomain,
|
|
3
|
+
olsFit,
|
|
4
|
+
olsMoments
|
|
5
|
+
} from "./chunk-7X65ZQN4.js";
|
|
6
|
+
import {
|
|
7
|
+
numericViewportRange
|
|
8
|
+
} from "./chunk-EQT3EPTB.js";
|
|
9
|
+
import {
|
|
10
|
+
runAnnotatePass
|
|
11
|
+
} from "./chunk-GQS46LC3.js";
|
|
12
|
+
import {
|
|
13
|
+
breakUnsupported,
|
|
14
|
+
chartPalette,
|
|
15
|
+
chartTheme
|
|
16
|
+
} from "./chunk-SXGTRZFN.js";
|
|
17
|
+
import {
|
|
18
|
+
structureCount
|
|
19
|
+
} from "./chunk-B2EBEXIS.js";
|
|
20
|
+
import {
|
|
21
|
+
HARD_COMPACT_PLOT,
|
|
22
|
+
applyAxisBounds,
|
|
23
|
+
atHardMinimum,
|
|
24
|
+
chartSizing,
|
|
25
|
+
layoutValueAxis,
|
|
26
|
+
linearScale,
|
|
27
|
+
measureValueAxisWidth,
|
|
28
|
+
niceDomain,
|
|
29
|
+
plotFloorRows,
|
|
30
|
+
sweepHide
|
|
31
|
+
} from "./chunk-GQPESFAF.js";
|
|
32
|
+
import {
|
|
33
|
+
PRIORITY,
|
|
34
|
+
authoredNotes,
|
|
35
|
+
composedTextRole,
|
|
36
|
+
createOccupiedIndex,
|
|
37
|
+
defaultAnnotationId,
|
|
38
|
+
frameTextOptions,
|
|
39
|
+
hiddenNoteWith,
|
|
40
|
+
inkBox,
|
|
41
|
+
labelCtx,
|
|
42
|
+
labelsToNodes,
|
|
43
|
+
leaderCrosses,
|
|
44
|
+
leaderPieces,
|
|
45
|
+
markNotedLabels,
|
|
46
|
+
nearestIsOwn,
|
|
47
|
+
normalizeLegendOption,
|
|
48
|
+
noteLine,
|
|
49
|
+
omittedKey,
|
|
50
|
+
plotHeightAfter,
|
|
51
|
+
rectContains,
|
|
52
|
+
rectsOverlap,
|
|
53
|
+
seatLeader,
|
|
54
|
+
solveFrame,
|
|
55
|
+
solveLabels
|
|
56
|
+
} from "./chunk-2JAWQ7VV.js";
|
|
57
|
+
import {
|
|
58
|
+
disclosureNote,
|
|
59
|
+
disclosuresShown
|
|
60
|
+
} from "./chunk-YTSSXSZR.js";
|
|
61
|
+
import {
|
|
62
|
+
MAGNITUDE_DIVISOR,
|
|
63
|
+
exampleSpec,
|
|
64
|
+
formatWithSpec,
|
|
65
|
+
formatterFromExample,
|
|
66
|
+
neededDecimals,
|
|
67
|
+
roundedNumber,
|
|
68
|
+
trendRateFormatter
|
|
69
|
+
} from "./chunk-ASAON7G4.js";
|
|
70
|
+
import {
|
|
71
|
+
autoDecimals,
|
|
72
|
+
chartStrings,
|
|
73
|
+
formatAutomaticNumber,
|
|
74
|
+
numberRange,
|
|
75
|
+
roundHalfUp,
|
|
76
|
+
seriesValueFormatter
|
|
77
|
+
} from "./chunk-YQ2B3YVF.js";
|
|
78
|
+
import {
|
|
79
|
+
cellMeta,
|
|
80
|
+
cellValue,
|
|
81
|
+
isDateCell,
|
|
82
|
+
isPctCell
|
|
83
|
+
} from "./chunk-OAPCJO6W.js";
|
|
84
|
+
import {
|
|
85
|
+
canvasMargin,
|
|
86
|
+
dashToken,
|
|
87
|
+
emphasisWeight,
|
|
88
|
+
markRolePaint,
|
|
89
|
+
mutedMarkPaint,
|
|
90
|
+
paintColor,
|
|
91
|
+
panelTypeClass,
|
|
92
|
+
secondaryFont,
|
|
93
|
+
seriesPaint,
|
|
94
|
+
spaceTokens,
|
|
95
|
+
strokeToken
|
|
96
|
+
} from "./chunk-II7652VA.js";
|
|
97
|
+
import {
|
|
98
|
+
PALETTE_NORMAL_FLOOR
|
|
99
|
+
} from "./chunk-2MTWKMEG.js";
|
|
100
|
+
import {
|
|
101
|
+
cubicPoint,
|
|
102
|
+
fmtPathNumber,
|
|
103
|
+
monotoneSegments
|
|
104
|
+
} from "./chunk-WLZ54FWG.js";
|
|
105
|
+
import {
|
|
106
|
+
NormalizeError,
|
|
107
|
+
TARGET_SIZE,
|
|
108
|
+
accessibleTitle,
|
|
109
|
+
normalizeCell,
|
|
110
|
+
normalizeScenario,
|
|
111
|
+
resolveHighlight,
|
|
112
|
+
resolveSize
|
|
113
|
+
} from "./chunk-SGD3ZHID.js";
|
|
114
|
+
import {
|
|
115
|
+
maxOf,
|
|
116
|
+
minOf,
|
|
117
|
+
pushAll
|
|
118
|
+
} from "./chunk-WYJEOMNY.js";
|
|
119
|
+
import {
|
|
120
|
+
defaultMeasurer,
|
|
121
|
+
wrapText
|
|
122
|
+
} from "./chunk-TXINIAFL.js";
|
|
123
|
+
|
|
124
|
+
// src/core/strings/scatter.ts
|
|
125
|
+
var EN = {
|
|
126
|
+
// reader-facing wording linked only by its consumers.
|
|
127
|
+
medianName: "Median",
|
|
128
|
+
lower: "lower",
|
|
129
|
+
higher: "higher",
|
|
130
|
+
axesNonzero: "Axes do not start at zero ({v1}).",
|
|
131
|
+
scatterTitle: "{v1} chart: {v2} points",
|
|
132
|
+
bubbleName: "Bubble",
|
|
133
|
+
scatterName: "Scatter",
|
|
134
|
+
groupsCount: "{v1} group{v2}",
|
|
135
|
+
gridCellsCount: "{v1} grid cells",
|
|
136
|
+
authoredRegionsCount: "{v1} authored regions",
|
|
137
|
+
pointsCount: "{v1} point{v2}",
|
|
138
|
+
paretoLine: "Pareto line",
|
|
139
|
+
trendFitLabel: "{v1}{v2}: slope {v3}, r\xB2 {v4}",
|
|
140
|
+
axesUntitled: "Axes without a title",
|
|
141
|
+
horizontal: "horizontal",
|
|
142
|
+
vertical: "vertical",
|
|
143
|
+
notDrawnScale: "Not drawn to scale: {v1}.",
|
|
144
|
+
pointLabelsOff: "Labels off beyond {v1} points.",
|
|
145
|
+
bottom: "bottom",
|
|
146
|
+
middle: "middle",
|
|
147
|
+
top: "top",
|
|
148
|
+
rowCount: "row {v1}",
|
|
149
|
+
left: "left",
|
|
150
|
+
right: "right",
|
|
151
|
+
columnCount: "column {v1}",
|
|
152
|
+
quadrantEquality: "A unit exactly on a cut point is counted to the right of it and above it.",
|
|
153
|
+
quadrantWeights: "Computed cut points weight every unit equally; bubble size does not enter them.",
|
|
154
|
+
quadrantOutsideRange: "The {v1} cut point ({v2}) does not fall strictly inside the plotted range {v3} to {v4}: no divider is drawn on that axis and the exhibit is a 1x2, not a 2x2.",
|
|
155
|
+
quadrantOnThreshold: "{v1} exactly on a cut point ({v2}).",
|
|
156
|
+
oneUnitSits: "One unit sits",
|
|
157
|
+
unitsSit: "{v1} units sit",
|
|
158
|
+
quadrantAllUnits: "All {v1} units fall in the {v2} box; the other three are empty.",
|
|
159
|
+
zoneDesc: "{v1}: X {v2} to {v3}, Y {v4} to {v5}",
|
|
160
|
+
zoneName: "Zone {v1}, {v2}",
|
|
161
|
+
regionBoundaryDesc: "{v1}: strategy region spanning {v2} boundary points",
|
|
162
|
+
scatterDescStart: "{v1} chart with {v2} points",
|
|
163
|
+
scatterGroupDesc: " in {v1} group{v2} ({v3})",
|
|
164
|
+
scatterAxesDesc: ". X from {v1} to {v2}{v3}, Y from {v4} to {v5}{v6}.",
|
|
165
|
+
logScaleClause: " on a log scale",
|
|
166
|
+
bubbleSizeDesc: " Bubble {v1} encodes size; largest: {v2} ({v3}).",
|
|
167
|
+
areaName: "area",
|
|
168
|
+
diameterName: "diameter",
|
|
169
|
+
quadrantDesc: " Quadrants: horizontal cut at {v1} ({v2}), vertical cut at {v3} ({v4}); ",
|
|
170
|
+
strategyZonesDesc: " Strategy zones: {v1}. {v2}",
|
|
171
|
+
trendLineDesc: " A dashed least-squares trend line {v1} across {v2} points{v3}.",
|
|
172
|
+
fallsLower: "falls",
|
|
173
|
+
risesLower: "rises",
|
|
174
|
+
runsFlat: "runs flat",
|
|
175
|
+
ofGroupClause: " of {v1}",
|
|
176
|
+
frontierDesc: " A dotted Pareto line joins the {v1} points no other point beats on both axes ({v2} x and {v3} y are better): {v4}.",
|
|
177
|
+
linearTrend: "Linear trend",
|
|
178
|
+
sizeZeroRing: "a ring is size 0",
|
|
179
|
+
sizeAbsentPlus: "a plus has no size",
|
|
180
|
+
sizeInvalidCross: "a cross has a size that is not a non-negative number, read as 0",
|
|
181
|
+
minimumDotSize: "the smallest dot is larger than its size",
|
|
182
|
+
quadrantCutX: "Quadrant cut points: horizontal axis at {v1} ({v2}), ",
|
|
183
|
+
// The short method line, with authored axis names.
|
|
184
|
+
quadrantCutShort: "Cuts: {v1} at {v2} and {v3} at {v4}; a point on a cut counts right and above.",
|
|
185
|
+
quadrantCutY: "vertical axis at {v1} ({v2}). ",
|
|
186
|
+
cutProvenance: "{v1} of the {v2} plotted values",
|
|
187
|
+
declaredLower: "declared",
|
|
188
|
+
andMore: "{v1} and {v2} more",
|
|
189
|
+
clippedPointsNote: "{v1} clipped at {v2} ({v3}).",
|
|
190
|
+
droppedPointsNote: "{v1} with a count below {v2} dropped: {v3}.",
|
|
191
|
+
noPositionNote: "{v1} with no x or y not drawn: {v2}.",
|
|
192
|
+
clippedPointsDesc: " {v1} {v2} {v3} drawn at the ",
|
|
193
|
+
clippedPointsEdge: "{v1} edge: {v2}{v3}.",
|
|
194
|
+
moreInTable: ", and {v1} more in the data table",
|
|
195
|
+
clipBelow: "below",
|
|
196
|
+
clipAbove: "above",
|
|
197
|
+
clipLeftOf: "left of",
|
|
198
|
+
clipRightOf: "right of",
|
|
199
|
+
clipBottom: "bottom",
|
|
200
|
+
clipTop: "top",
|
|
201
|
+
clipLeft: "left",
|
|
202
|
+
clipRight: "right",
|
|
203
|
+
topLeft: "top-left",
|
|
204
|
+
topRight: "top-right",
|
|
205
|
+
bottomLeft: "bottom-left",
|
|
206
|
+
bottomRight: "bottom-right",
|
|
207
|
+
cutMedian: "median",
|
|
208
|
+
cutMean: "mean",
|
|
209
|
+
cutAt: "Cut at",
|
|
210
|
+
cutMeanCapital: "Mean",
|
|
211
|
+
pointsCountRight: ", points on it count right",
|
|
212
|
+
pointsCountAbove: ", points on it count above"
|
|
213
|
+
}, DE = {
|
|
214
|
+
// reader-facing wording linked only by its consumers.
|
|
215
|
+
medianName: "Median",
|
|
216
|
+
lower: "niedriger",
|
|
217
|
+
higher: "h\xF6her",
|
|
218
|
+
axesNonzero: "Achsen beginnen nicht bei null ({v1}).",
|
|
219
|
+
scatterTitle: "{v1}diagramm: {v2} {v2|Punkt|Punkte}",
|
|
220
|
+
bubbleName: "Blasen",
|
|
221
|
+
scatterName: "Streu",
|
|
222
|
+
groupsCount: "{v1} {v1|Gruppe|Gruppen}",
|
|
223
|
+
gridCellsCount: "{v1} {v1|Rasterzelle|Rasterzellen}",
|
|
224
|
+
authoredRegionsCount: "{v1} {v1|angegebener Bereich|angegebene Bereiche}",
|
|
225
|
+
pointsCount: "{v1} {v1|Punkt|Punkte}",
|
|
226
|
+
paretoLine: "Pareto-Linie",
|
|
227
|
+
trendFitLabel: "{v1}{v2}: Steigung {v3}, r\xB2 {v4}",
|
|
228
|
+
axesUntitled: "Achsen ohne Titel",
|
|
229
|
+
horizontal: "horizontal",
|
|
230
|
+
vertical: "vertikal",
|
|
231
|
+
notDrawnScale: "Nicht ma\xDFstabsgetreu: {v1}.",
|
|
232
|
+
pointLabelsOff: "Beschriftungen ab mehr als {v1} {v1|Punkt|Punkten} aus.",
|
|
233
|
+
bottom: "unten",
|
|
234
|
+
middle: "Mitte",
|
|
235
|
+
top: "oben",
|
|
236
|
+
rowCount: "Zeile {v1}",
|
|
237
|
+
left: "links",
|
|
238
|
+
right: "rechts",
|
|
239
|
+
columnCount: "Spalte {v1}",
|
|
240
|
+
quadrantEquality: "Eine Einheit genau auf einem Trennpunkt z\xE4hlt rechts davon und dar\xFCber.",
|
|
241
|
+
quadrantWeights: "Berechnete Trennpunkte gewichten jede Einheit gleich. Die Blasengr\xF6\xDFe z\xE4hlt dabei nicht.",
|
|
242
|
+
quadrantOutsideRange: "Der Trennpunkt auf {v1} ({v2}) liegt nicht strikt in der Spanne {v3} bis {v4}. Auf dieser Achse wird keine Trennlinie gezeichnet. Die Darstellung hat 1\xD72 Felder statt 2\xD72.",
|
|
243
|
+
quadrantOnThreshold: "{v1} genau auf einem Trennpunkt ({v2}).",
|
|
244
|
+
oneUnitSits: "Eine Einheit liegt",
|
|
245
|
+
unitsSit: "{v1} {v1|Einheit|Einheiten} {v1|liegt|liegen}",
|
|
246
|
+
quadrantAllUnits: "{v1|Die|Alle} {v1} {v1|Einheit|Einheiten} {v1|liegt|liegen} im Feld {v2}. Die anderen drei sind leer.",
|
|
247
|
+
zoneDesc: "{v1}: X {v2} bis {v3}, Y {v4} bis {v5}",
|
|
248
|
+
zoneName: "Bereich {v1}, {v2}",
|
|
249
|
+
regionBoundaryDesc: "{v1}: Strategiebereich mit {v2} {v2|Grenzpunkt|Grenzpunkten}",
|
|
250
|
+
scatterDescStart: "{v1}diagramm mit {v2} {v2|Punkt|Punkten}",
|
|
251
|
+
scatterGroupDesc: " in {v1} {v1|Gruppe|Gruppen} ({v3})",
|
|
252
|
+
scatterAxesDesc: ". X von {v1} bis {v2}{v3}, Y von {v4} bis {v5}{v6}.",
|
|
253
|
+
logScaleClause: " auf logarithmischer Skala",
|
|
254
|
+
bubbleSizeDesc: " {v1} der Blasen zeigt die Gr\xF6\xDFe; gr\xF6\xDFte: {v2} ({v3}).",
|
|
255
|
+
areaName: "Fl\xE4che",
|
|
256
|
+
diameterName: "Durchmesser",
|
|
257
|
+
quadrantDesc: " Quadranten: horizontaler Trennpunkt {v1} ({v2}), vertikaler Trennpunkt {v3} ({v4}); ",
|
|
258
|
+
strategyZonesDesc: " Strategiebereiche: {v1}. {v2}",
|
|
259
|
+
trendLineDesc: " Eine gestrichelte Trendlinie nach kleinsten Quadraten {v1} \xFCber {v2} {v2|Punkt|Punkte}{v3}.",
|
|
260
|
+
fallsLower: "f\xE4llt",
|
|
261
|
+
risesLower: "steigt",
|
|
262
|
+
runsFlat: "bleibt gleich",
|
|
263
|
+
ofGroupClause: " von {v1}",
|
|
264
|
+
frontierDesc: " Eine gepunktete Pareto-Linie verbindet {v1} {v1|Punkt|Punkte}, {v1|den|die} kein anderer Punkt auf beiden Achsen \xFCbertrifft ({v2} x und {v3} y sind besser): {v4}.",
|
|
265
|
+
linearTrend: "Linearer Verlauf",
|
|
266
|
+
sizeZeroRing: "ein Ring hat Gr\xF6\xDFe 0",
|
|
267
|
+
sizeAbsentPlus: "ein Plus hat keine Gr\xF6\xDFe",
|
|
268
|
+
sizeInvalidCross: "ein Kreuz hat keine g\xFCltige nichtnegative Gr\xF6\xDFe; als 0 gelesen",
|
|
269
|
+
minimumDotSize: "der kleinste Punkt ist gr\xF6\xDFer als sein Wert",
|
|
270
|
+
quadrantCutX: "Quadranten-Trennpunkte: horizontale Achse bei {v1} ({v2}), ",
|
|
271
|
+
// The short method line, with authored axis names.
|
|
272
|
+
quadrantCutShort: "Trennpunkte: {v1} bei {v2} und {v3} bei {v4}; ein Punkt auf einem Trennpunkt z\xE4hlt rechts und oben.",
|
|
273
|
+
quadrantCutY: "vertikale Achse bei {v1} ({v2}). ",
|
|
274
|
+
cutProvenance: "{v1} der {v2} gezeichneten Werte",
|
|
275
|
+
declaredLower: "angegeben",
|
|
276
|
+
andMore: "{v1} und {v2} weitere",
|
|
277
|
+
clippedPointsNote: "{v1} bei {v2} begrenzt ({v3}).",
|
|
278
|
+
droppedPointsNote: "{v1} mit einer Anzahl unter {v2} entfernt: {v3}.",
|
|
279
|
+
noPositionNote: "{v1} ohne x oder y nicht gezeichnet: {v2}.",
|
|
280
|
+
clippedPointsDesc: " {v1} {v2} {v3} am Rand ",
|
|
281
|
+
clippedPointsEdge: "{v1} gezeichnet: {v2}{v3}.",
|
|
282
|
+
moreInTable: ", und {v1} weitere in der Datentabelle",
|
|
283
|
+
clipBelow: "unter",
|
|
284
|
+
clipAbove: "\xFCber",
|
|
285
|
+
clipLeftOf: "links von",
|
|
286
|
+
clipRightOf: "rechts von",
|
|
287
|
+
clipBottom: "unten",
|
|
288
|
+
clipTop: "oben",
|
|
289
|
+
clipLeft: "links",
|
|
290
|
+
clipRight: "rechts",
|
|
291
|
+
topLeft: "oben links",
|
|
292
|
+
topRight: "oben rechts",
|
|
293
|
+
bottomLeft: "unten links",
|
|
294
|
+
bottomRight: "unten rechts",
|
|
295
|
+
cutMedian: "Median",
|
|
296
|
+
cutMean: "Mittelwert",
|
|
297
|
+
cutAt: "Trennpunkt bei",
|
|
298
|
+
cutMeanCapital: "Mittelwert",
|
|
299
|
+
pointsCountRight: ", Punkte darauf z\xE4hlen rechts",
|
|
300
|
+
pointsCountAbove: ", Punkte darauf z\xE4hlen oben"
|
|
301
|
+
}, { chartString } = chartStrings(EN, DE);
|
|
302
|
+
|
|
303
|
+
// src/core/charts/scatter/clamp.ts
|
|
304
|
+
var plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
305
|
+
function axisName(axis, titles) {
|
|
306
|
+
return titles[axis] ?? axis;
|
|
307
|
+
}
|
|
308
|
+
function readClampBounds(clamp) {
|
|
309
|
+
let bare = {
|
|
310
|
+
...typeof clamp.min == "number" ? { min: clamp.min } : {},
|
|
311
|
+
...typeof clamp.max == "number" ? { max: clamp.max } : {}
|
|
312
|
+
}, named = (axis) => clamp[axis] ?? {};
|
|
313
|
+
if (Object.keys(bare).length > 0 && Object.keys(named("y")).length > 0)
|
|
314
|
+
throw new NormalizeError(
|
|
315
|
+
"clamp-ambiguous",
|
|
316
|
+
"options.valueAxis.clamp",
|
|
317
|
+
"valueAxis.clamp states the vertical bound twice, once as clamp.min/clamp.max and once as clamp.y",
|
|
318
|
+
"keep one of the two: clamp.min and clamp.max are the y axis on a scatter, and clamp.y says the same thing explicitly",
|
|
319
|
+
void 0,
|
|
320
|
+
["options", "valueAxis", "clamp"]
|
|
321
|
+
);
|
|
322
|
+
return { x: named("x"), y: Object.keys(bare).length > 0 ? bare : named("y") };
|
|
323
|
+
}
|
|
324
|
+
function refuseClampConflicts(bounds, input) {
|
|
325
|
+
if (input.hasViewDomain)
|
|
326
|
+
throw new NormalizeError(
|
|
327
|
+
"clamp-view-domain-conflict",
|
|
328
|
+
"options.valueAxis.clamp",
|
|
329
|
+
"valueAxis.clamp and viewDomain both narrow the scatter domain, and they treat the points outside it differently: viewDomain leaves them out, clamp draws them at the edge and counts them",
|
|
330
|
+
"use viewDomain to zoom, or valueAxis.clamp to cap the axis and mark the outliers, not both",
|
|
331
|
+
void 0,
|
|
332
|
+
["options", "valueAxis", "clamp"]
|
|
333
|
+
);
|
|
334
|
+
for (let bound of ["min", "max"])
|
|
335
|
+
if (bounds.y[bound] !== void 0 && input.valueAxisBounds[bound] !== void 0)
|
|
336
|
+
throw new NormalizeError(
|
|
337
|
+
"clamp-bound-conflict",
|
|
338
|
+
`options.valueAxis.clamp.${bound}`,
|
|
339
|
+
`valueAxis.${bound} widens the vertical domain so nothing is cut off, and valueAxis.clamp.${bound} caps it so outliers are cut off at ${input.valueAxisBounds[bound]}; one of the two has to go`,
|
|
340
|
+
`drop valueAxis.${bound} to cap the axis, or drop valueAxis.clamp.${bound} to keep every point at its own position`,
|
|
341
|
+
void 0,
|
|
342
|
+
["options", "valueAxis", "clamp", bound]
|
|
343
|
+
);
|
|
344
|
+
for (let axis of ["x", "y"]) {
|
|
345
|
+
let { min, max } = bounds[axis];
|
|
346
|
+
if (min !== void 0 && max !== void 0 && min >= max)
|
|
347
|
+
throw new NormalizeError(
|
|
348
|
+
"clamp-empty-range",
|
|
349
|
+
`options.valueAxis.clamp${axis === "y" ? "" : ".x"}`,
|
|
350
|
+
`the ${axis} clamp keeps values from ${min} up to ${max}, which is an empty range`,
|
|
351
|
+
"set the lower bound below the upper one",
|
|
352
|
+
void 0,
|
|
353
|
+
["options", "valueAxis", "clamp"]
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function clippedAt(points, axis, bound, limit) {
|
|
358
|
+
return points.filter((point) => bound === "max" ? point[axis] > limit : point[axis] < limit).map((point) => ({ id: point.id, label: point.label, value: point[axis] }));
|
|
359
|
+
}
|
|
360
|
+
function planScatterClamp(points, input, disclose) {
|
|
361
|
+
if (!input.clamp || typeof input.clamp != "object") return;
|
|
362
|
+
let bounds = readClampBounds(input.clamp);
|
|
363
|
+
refuseClampConflicts(bounds, input);
|
|
364
|
+
let applied = { x: {}, y: {} }, edges = { x: {}, y: {} }, clipped = /* @__PURE__ */ new Set(), records = [];
|
|
365
|
+
for (let axis of ["x", "y"])
|
|
366
|
+
for (let bound of ["min", "max"]) {
|
|
367
|
+
let raw = bounds[axis][bound];
|
|
368
|
+
if (raw === void 0) continue;
|
|
369
|
+
let { value: limit, text: limitText } = disclose(raw, axis);
|
|
370
|
+
applied[axis][bound] = limit;
|
|
371
|
+
let beyond = clippedAt(points, axis, bound, limit);
|
|
372
|
+
if (beyond.length !== 0) {
|
|
373
|
+
edges[axis][bound] = limit;
|
|
374
|
+
for (let point of beyond) clipped.add(point.id);
|
|
375
|
+
records.push({
|
|
376
|
+
axis,
|
|
377
|
+
bound,
|
|
378
|
+
limit,
|
|
379
|
+
limitText,
|
|
380
|
+
count: beyond.length,
|
|
381
|
+
points: beyond,
|
|
382
|
+
note: disclosureNote(chartString(input.options, "clippedPointsNote", { v1: chartString(input.options, "pointsCount", { v1: beyond.length, v2: beyond.length === 1 ? "" : "s" }), v2: limitText, v3: axisName(axis, input.axisTitles) }))
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
let project = (axis) => (value) => {
|
|
387
|
+
let { min, max } = applied[axis];
|
|
388
|
+
return max !== void 0 && value > max ? max : min !== void 0 && value < min ? min : value;
|
|
389
|
+
};
|
|
390
|
+
return {
|
|
391
|
+
project: { x: project("x"), y: project("y") },
|
|
392
|
+
clipped,
|
|
393
|
+
records,
|
|
394
|
+
edges,
|
|
395
|
+
applied,
|
|
396
|
+
axisNames: { x: axisName("x", input.axisTitles), y: axisName("y", input.axisTitles) },
|
|
397
|
+
notes: records.map((record) => record.note)
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function applyMinCount(points, minCount, discloseCount, options) {
|
|
401
|
+
if (minCount === void 0) return { kept: points };
|
|
402
|
+
let counted = points.filter((point) => point.count !== null);
|
|
403
|
+
if (counted.length === 0)
|
|
404
|
+
throw new NormalizeError(
|
|
405
|
+
"min-count-unsupported",
|
|
406
|
+
"options.minCount",
|
|
407
|
+
"options.minCount filters on points[].count, and no point carries one",
|
|
408
|
+
"add count to the points this threshold should filter, or drop options.minCount",
|
|
409
|
+
void 0,
|
|
410
|
+
["options", "minCount"]
|
|
411
|
+
);
|
|
412
|
+
if (counted.length < points.length) {
|
|
413
|
+
let missing = points.filter((point) => point.count === null), named = missing.slice(0, 3).map((point) => `'${point.id}'`).join(", ");
|
|
414
|
+
throw new NormalizeError(
|
|
415
|
+
"min-count-partial",
|
|
416
|
+
"points",
|
|
417
|
+
`options.minCount filters on points[].count, and ${plural(missing.length, "point")} carry none (${named}${missing.length > 3 ? ", \u2026" : ""}); the engine cannot tell whether they are above or below the threshold`,
|
|
418
|
+
"give every point a count, or drop options.minCount",
|
|
419
|
+
void 0,
|
|
420
|
+
["data", "points"]
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
let { value: threshold, text: thresholdText } = discloseCount(minCount), kept = points.filter((point) => point.count >= threshold), dropped = points.filter((point) => point.count < threshold);
|
|
424
|
+
if (kept.length === 0)
|
|
425
|
+
throw new NormalizeError(
|
|
426
|
+
"min-count-empty",
|
|
427
|
+
"options.minCount",
|
|
428
|
+
`options.minCount is ${minCount} and every one of the ${points.length} points is below it, so there is nothing left to plot`,
|
|
429
|
+
"lower options.minCount below the largest count in the data",
|
|
430
|
+
void 0,
|
|
431
|
+
["options", "minCount"]
|
|
432
|
+
);
|
|
433
|
+
return dropped.length === 0 ? { kept } : {
|
|
434
|
+
kept,
|
|
435
|
+
record: {
|
|
436
|
+
minCount: threshold,
|
|
437
|
+
count: dropped.length,
|
|
438
|
+
points: dropped.map((point) => ({ id: point.id, label: point.label, count: point.count })),
|
|
439
|
+
// The note names the points it dropped.
|
|
440
|
+
note: disclosureNote(chartString(options, "droppedPointsNote", { v1: chartString(options, "pointsCount", { v1: dropped.length, v2: dropped.length === 1 ? "" : "s" }), v2: thresholdText, v3: dropped.map((point) => point.label).join(", ") }))
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function clampSeed(plan, axis, lo, hi) {
|
|
445
|
+
if (!plan) return [lo, hi];
|
|
446
|
+
let { min, max } = plan.applied[axis], into = (value) => max !== void 0 && value > max ? max : min !== void 0 && value < min ? min : value;
|
|
447
|
+
return [into(lo), into(hi)];
|
|
448
|
+
}
|
|
449
|
+
function clampStateOf(plan, id) {
|
|
450
|
+
if (!plan?.clipped.has(id)) return;
|
|
451
|
+
let records = plan.records.filter((entry) => entry.points.some((point) => point.id === id));
|
|
452
|
+
return records.length === 1 ? `clipped at ${records[0].limitText}` : `clipped at ${records.map((record) => `${record.limitText} (${plan.axisNames[record.axis]})`).join(" and at ")}`;
|
|
453
|
+
}
|
|
454
|
+
function boundBeyond(plan, axis, value) {
|
|
455
|
+
let { min, max } = plan.applied[axis];
|
|
456
|
+
if (max !== void 0 && value > max) return { bound: "max", limit: max };
|
|
457
|
+
if (min !== void 0 && value < min) return { bound: "min", limit: min };
|
|
458
|
+
}
|
|
459
|
+
var clampPath = (axis, bound) => `valueAxis.clamp.${axis === "y" ? "" : "x."}${bound}`;
|
|
460
|
+
function refuseClampedRegions(plan, regions) {
|
|
461
|
+
if (!(!plan || !regions))
|
|
462
|
+
for (let region of regions)
|
|
463
|
+
for (let vertex of region.points)
|
|
464
|
+
for (let axis of ["x", "y"]) {
|
|
465
|
+
let beyond = boundBeyond(plan, axis, vertex[axis]);
|
|
466
|
+
if (beyond)
|
|
467
|
+
throw new NormalizeError(
|
|
468
|
+
"clamp-zone-conflict",
|
|
469
|
+
"options.zones.regions",
|
|
470
|
+
`strategy region '${region.id}' reaches ${axis} ${vertex[axis]}, beyond ${clampPath(axis, beyond.bound)} ${beyond.limit}, so it would be drawn past the end of the axis`,
|
|
471
|
+
`keep the region inside the clamped range, or move ${clampPath(axis, beyond.bound)} past the region`,
|
|
472
|
+
void 0,
|
|
473
|
+
["options", "zones", "regions"]
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function refuseClampedValueLines(plan, lines, format) {
|
|
478
|
+
if (plan)
|
|
479
|
+
for (let line of lines) {
|
|
480
|
+
let beyond = boundBeyond(plan, "y", line.value);
|
|
481
|
+
if (!beyond) continue;
|
|
482
|
+
let what = line.isMean ? `the mean of the plotted points (${format(line.value)})` : `its value ${format(line.value)}`;
|
|
483
|
+
throw new NormalizeError(
|
|
484
|
+
"clamp-value-line-conflict",
|
|
485
|
+
`annotations[${line.index}]`,
|
|
486
|
+
`valueLine '${line.id}' sits at ${what}, beyond ${clampPath("y", beyond.bound)} ${beyond.limit}, so the line would be drawn outside the plot`,
|
|
487
|
+
`move ${clampPath("y", beyond.bound)} past the line, or drop the value line`,
|
|
488
|
+
void 0,
|
|
489
|
+
["annotations", line.index]
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function refuseClampedQuadrants(plan, points, cuts) {
|
|
494
|
+
if (!(!plan || !cuts))
|
|
495
|
+
for (let axis of ["x", "y"]) {
|
|
496
|
+
let cut = cuts[axis], { min, max } = plan.edges[axis], hidden = max !== void 0 && cut >= max ? points.filter((point) => point[axis] >= cut) : min !== void 0 && cut <= min ? points.filter((point) => point[axis] < cut) : [];
|
|
497
|
+
if (hidden.length === 0) continue;
|
|
498
|
+
let bound = max !== void 0 && cut >= max ? "max" : "min";
|
|
499
|
+
throw new NormalizeError(
|
|
500
|
+
"clamp-quadrant-conflict",
|
|
501
|
+
"options.quadrants",
|
|
502
|
+
`the ${axis} cut point ${axis === "x" ? cuts.xText : cuts.yText} lies on or beyond ${clampPath(axis, bound)} ${plan.edges[axis][bound]}, and ${plural(hidden.length, "point")} counted on its far side ${hidden.length === 1 ? "is" : "are"} drawn at the edge on its near side`,
|
|
503
|
+
`declare the cut point inside the clamped range, or move ${clampPath(axis, bound)} past it`,
|
|
504
|
+
void 0,
|
|
505
|
+
["options", "quadrants", axis]
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function clampDescription(records, format, reversedY, options) {
|
|
510
|
+
return records.map((record) => {
|
|
511
|
+
let flip = reversedY && record.axis === "y", side = chartString(options, { "x.min": "clipLeftOf", "x.max": "clipRightOf", "y.min": "clipBelow", "y.max": "clipAbove" }[`${record.axis}.${record.bound}`]), drawnBound = flip ? record.bound === "min" ? "max" : "min" : record.bound, edge = chartString(options, { "x.min": "clipLeft", "x.max": "clipRight", "y.min": "clipBottom", "y.max": "clipTop" }[`${record.axis}.${drawnBound}`]), named = record.points.slice(0, 5).map((point) => `${point.label} (${format[record.axis](point.value)})`).join(", "), rest = record.points.length - 5;
|
|
512
|
+
return chartString(options, "clippedPointsDesc", { v1: chartString(options, "pointsCount", { v1: record.count, v2: record.count === 1 ? "" : "s" }), v2: side, v3: record.limitText }) + chartString(options, "clippedPointsEdge", { v1: edge, v2: named, v3: rest > 0 ? chartString(options, "moreInTable", { v1: rest }) : "" });
|
|
513
|
+
}).join("");
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// src/core/charts/scatter/valueLines.ts
|
|
517
|
+
function drawnValueLines(annotations, meanY) {
|
|
518
|
+
let lines = [];
|
|
519
|
+
return (annotations ?? []).forEach((ann, index) => {
|
|
520
|
+
if (ann.kind !== "valueLine" || ann.axis === "secondary") return;
|
|
521
|
+
let spanned = ann.from !== void 0 || ann.to !== void 0, isMean = ann.value === "mean" || ann.value === void 0;
|
|
522
|
+
if (isMean && (ann.seriesId !== void 0 || spanned) || !isMean && ann.seriesId !== void 0 || !isMean && spanned && ann.tolerance === void 0 && ann.attainment === void 0) return;
|
|
523
|
+
let value = isMean ? meanY : ann.value;
|
|
524
|
+
Number.isFinite(value) && lines.push({ index, id: defaultAnnotationId(ann, index), value, isMean });
|
|
525
|
+
}), lines;
|
|
526
|
+
}
|
|
527
|
+
function withValueLines(lines, lo, hi) {
|
|
528
|
+
return lines.reduce(([a, b], line) => [Math.min(a, line.value), Math.max(b, line.value)], [lo, hi]);
|
|
529
|
+
}
|
|
530
|
+
function refuseValueLinesOutsideAxis(lines, domain, bounds, format) {
|
|
531
|
+
for (let line of lines) {
|
|
532
|
+
let bound = line.value > domain[1] ? "max" : line.value < domain[0] ? "min" : void 0;
|
|
533
|
+
if (!bound || bounds[bound] === void 0) continue;
|
|
534
|
+
let what = line.isMean ? `the mean of the plotted points (${format(line.value)})` : format(line.value);
|
|
535
|
+
throw new NormalizeError(
|
|
536
|
+
"value-line-outside-axis",
|
|
537
|
+
`annotations[${line.index}]`,
|
|
538
|
+
`valueLine '${line.id}' sits at ${what}, ${bound === "max" ? "above" : "below"} the vertical axis, which valueAxis.${bound} ends at ${format(domain[bound === "max" ? 1 : 0])}, so the line would be drawn outside the plot`,
|
|
539
|
+
`move valueAxis.${bound} past ${format(line.value)}, or drop valueAxis.${bound} and let the axis extend to the line`,
|
|
540
|
+
void 0,
|
|
541
|
+
["annotations", line.index]
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function valueLinesInView(annotations, lines, window, warnings, format) {
|
|
546
|
+
let all = annotations ?? [];
|
|
547
|
+
if (!window) return [...all];
|
|
548
|
+
let outside = new Set(
|
|
549
|
+
lines.filter((line) => line.value < window[0] || line.value > window[1]).map((line) => line.index)
|
|
550
|
+
);
|
|
551
|
+
if (outside.size === 0) return [...all];
|
|
552
|
+
for (let line of lines)
|
|
553
|
+
outside.has(line.index) && warnings.push({
|
|
554
|
+
code: "value-line-outside-view",
|
|
555
|
+
severity: "warn",
|
|
556
|
+
message: `valueLine '${line.id}' at ${format(line.value)} lies outside the vertical viewDomain ${format(window[0])} to ${format(window[1])}, so it is not drawn`,
|
|
557
|
+
suggest: "widen viewDomain.y to include the line, or drop viewDomain to show the whole range"
|
|
558
|
+
});
|
|
559
|
+
return all.map((ann, index) => ({ ...ann, id: defaultAnnotationId(ann, index) })).filter((_, index) => !outside.has(index));
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/core/charts/scatter/logAxis.ts
|
|
563
|
+
function logScale(domain, range) {
|
|
564
|
+
let [d0, d1] = domain, [r0, r1] = range, l0 = Math.log10(d0), dl = Math.log10(d1) - l0 || 1, scale = ((value) => r0 + (Math.log10(value) - l0) / dl * (r1 - r0));
|
|
565
|
+
return scale.domain = [d0, d1], scale.range = [r0, r1], scale.log = !0, scale.invert = (px) => 10 ** (l0 + (px - r0) / (r1 - r0 || 1) * dl), scale.ticks = () => logTickTiers(Math.min(d0, d1), Math.max(d0, d1))[0], scale;
|
|
566
|
+
}
|
|
567
|
+
function decimal(m, e) {
|
|
568
|
+
return +`${m}e${e}`;
|
|
569
|
+
}
|
|
570
|
+
function logRung(v, dir, strict = !1) {
|
|
571
|
+
let e = Math.floor(Math.log10(v)), m = v / 10 ** e;
|
|
572
|
+
m >= 10 - 1e-9 && (e += 1, m /= 10);
|
|
573
|
+
let k = dir === "down" ? Math.floor(m + 1e-9) : Math.ceil(m - 1e-9);
|
|
574
|
+
return strict && Math.abs(k - m) < 1e-9 && (k += dir === "down" ? -1 : 1), k < 1 ? decimal(9, e - 1) : k > 9 ? decimal(1, e + 1) : decimal(k, e);
|
|
575
|
+
}
|
|
576
|
+
function logTickTiers(lo, hi) {
|
|
577
|
+
if (!(lo > 0) || !(hi > lo) || !Number.isFinite(hi)) return [[lo, hi].filter((v) => Number.isFinite(v))];
|
|
578
|
+
let e0 = Math.floor(Math.log10(lo)), e1 = Math.ceil(Math.log10(hi)), ladder = (mantissas, every = 1) => {
|
|
579
|
+
let inside = [];
|
|
580
|
+
for (let e = e0; e <= e1; e++)
|
|
581
|
+
if ((e - e0) % every === 0)
|
|
582
|
+
for (let m of mantissas) {
|
|
583
|
+
let v = decimal(m, e);
|
|
584
|
+
v > lo * (1 + 1e-9) && v < hi * (1 - 1e-9) && inside.push(v);
|
|
585
|
+
}
|
|
586
|
+
return [lo, ...inside, hi];
|
|
587
|
+
}, tiers = Math.log10(hi / lo) < 1 ? [ladder([1, 2, 3, 4, 5, 6, 8])] : [];
|
|
588
|
+
tiers.push(ladder([1, 2, 5]), ladder([1]));
|
|
589
|
+
for (let every = 2; every < e1 - e0; every++) tiers.push(ladder([1], every));
|
|
590
|
+
return tiers;
|
|
591
|
+
}
|
|
592
|
+
function logAxesOf(log) {
|
|
593
|
+
return { x: log === "x" || log === "both", y: log === !0 || log === "y" || log === "both" };
|
|
594
|
+
}
|
|
595
|
+
var LOG_EDGE = 5e-3;
|
|
596
|
+
function logDomain(min, max) {
|
|
597
|
+
let lo = logRung(min, "down"), hi = logRung(max, "up"), span = Math.log10(max / min);
|
|
598
|
+
return Math.log10(min / lo) < LOG_EDGE * span && (lo = logRung(lo, "down", !0)), Math.log10(hi / max) < LOG_EDGE * span && (hi = logRung(hi, "up", !0)), hi > lo ? [lo, hi] : [logRung(lo, "down", !0), logRung(hi, "up", !0)];
|
|
599
|
+
}
|
|
600
|
+
function logSpecFormat(spec) {
|
|
601
|
+
let divisor = MAGNITUDE_DIVISOR[spec.magnitude];
|
|
602
|
+
return (value) => formatWithSpec(value, { ...spec, wholeFrom: void 0, decimals: neededDecimals(value / divisor, 12) });
|
|
603
|
+
}
|
|
604
|
+
function fitLogTicks(scale, orient, format, font, measure, gap = 4) {
|
|
605
|
+
let [lo, hi] = [Math.min(...scale.domain), Math.max(...scale.domain)], tiers = logTickTiers(lo, hi);
|
|
606
|
+
for (let ticks of tiers) {
|
|
607
|
+
let items = ticks.map((tick, index) => {
|
|
608
|
+
let size = measure(format(tick), font), pos = scale(tick), extent = orient === "x" ? size.width : size.height;
|
|
609
|
+
return { start: orient === "y" ? pos - extent / 2 : index === 0 ? pos : index === ticks.length - 1 ? pos - extent : pos - extent / 2, size: extent, priority: 0 };
|
|
610
|
+
}), ends = [items[0], items[items.length - 1]], clears = (a, b) => a.start >= b.start + b.size + gap || b.start >= a.start + a.size + gap, inner = items.slice(1, -1).filter((item) => ends.every((end) => clears(item, end)));
|
|
611
|
+
if (sweepHide(inner, gap).every(Boolean)) return ticks;
|
|
612
|
+
}
|
|
613
|
+
return tiers[tiers.length - 1];
|
|
614
|
+
}
|
|
615
|
+
function dropLogFix(log, axis) {
|
|
616
|
+
return log === "both" ? [{ op: "replace", path: "/options/valueAxis/log", value: axis === "x" ? "y" : "x" }] : [{ op: "remove", path: "/options/valueAxis/log" }];
|
|
617
|
+
}
|
|
618
|
+
function refuseNonPositiveOnLog(options, axes, pts) {
|
|
619
|
+
if (!axes.x && !axes.y) return;
|
|
620
|
+
let log = options.valueAxis?.log, side = (axis) => axis === "x" ? "horizontal" : "vertical", refuse = (axis, what, value, segments, remove) => {
|
|
621
|
+
let keep = log === "both" ? ` (log: '${axis === "x" ? "y" : "x"}' keeps the ${side(axis === "x" ? "y" : "x")} axis on a log scale)` : "";
|
|
622
|
+
throw new NormalizeError(
|
|
623
|
+
"log-nonpositive",
|
|
624
|
+
what,
|
|
625
|
+
`${what} is ${value}, and the ${side(axis)} axis is on a log scale, which has no place for zero or a negative value`,
|
|
626
|
+
`${remove}, or drop valueAxis.log${keep}`,
|
|
627
|
+
dropLogFix(log, axis),
|
|
628
|
+
segments
|
|
629
|
+
);
|
|
630
|
+
};
|
|
631
|
+
for (let axis of ["x", "y"]) {
|
|
632
|
+
if (!axes[axis]) continue;
|
|
633
|
+
for (let p of pts)
|
|
634
|
+
p[axis] <= 0 && refuse(axis, `points[${p.id}].${axis}`, p[axis], ["data", "points", p.idx, axis], "remove the point");
|
|
635
|
+
let view = options.viewDomain?.[axis];
|
|
636
|
+
view && Math.min(...view) <= 0 && refuse(axis, `options.viewDomain.${axis}`, `[${view.join(", ")}]`, ["options", "viewDomain", axis], `start viewDomain.${axis} above zero`);
|
|
637
|
+
let clamp = options.valueAxis?.clamp, bounds = axis === "y" ? { min: clamp?.min, max: clamp?.max, ...clamp?.y } : { ...clamp?.x };
|
|
638
|
+
for (let bound of ["min", "max"]) {
|
|
639
|
+
let value = bounds[bound];
|
|
640
|
+
value !== void 0 && value <= 0 && refuse(axis, `options.valueAxis.clamp.${axis}.${bound}`, value, ["options", "valueAxis", "clamp"], "clamp at a value above zero");
|
|
641
|
+
}
|
|
642
|
+
for (let [index, region] of (options.zones?.regions ?? []).entries()) {
|
|
643
|
+
let at = region.points.findIndex((point) => point[axis] <= 0);
|
|
644
|
+
at >= 0 && refuse(axis, `options.zones.regions[${index}].points[${at}].${axis}`, region.points[at][axis], ["options", "zones", "regions", index, "points", at, axis], "move the region above zero");
|
|
645
|
+
}
|
|
646
|
+
let cut = options.quadrants?.[axis];
|
|
647
|
+
typeof cut == "number" && cut <= 0 && refuse(axis, `options.quadrants.${axis}`, cut, ["options", "quadrants", axis], "cut above zero");
|
|
648
|
+
}
|
|
649
|
+
if (!axes.y) return;
|
|
650
|
+
let va = options.valueAxis ?? {};
|
|
651
|
+
for (let bound of ["min", "max"]) {
|
|
652
|
+
let value = va[bound];
|
|
653
|
+
value !== void 0 && value <= 0 && refuse("y", `options.valueAxis.${bound}`, value, ["options", "valueAxis", bound], `drop valueAxis.${bound}`);
|
|
654
|
+
}
|
|
655
|
+
va.includeZero && refuse("y", "options.valueAxis.includeZero", "true", ["options", "valueAxis", "includeZero"], "drop valueAxis.includeZero");
|
|
656
|
+
let meanY = pts.reduce((sum, p) => sum + p.y, 0) / pts.length;
|
|
657
|
+
for (let line of drawnValueLines(options.annotations, meanY)) {
|
|
658
|
+
let ann = options.annotations[line.index], low = typeof ann.tolerance == "number" ? line.value - ann.tolerance : ann.tolerance?.low ?? line.value;
|
|
659
|
+
Math.min(line.value, low) <= 0 && refuse("y", `annotations[${line.index}]`, Math.min(line.value, low), ["annotations", line.index], "move the value line and its band above zero");
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// src/core/charts/scatter/model.ts
|
|
664
|
+
var QUADRANT_BOXES = ["tl", "tr", "bl", "br"], QUADRANT_BOX_NAME = {
|
|
665
|
+
tl: "top-left",
|
|
666
|
+
tr: "top-right",
|
|
667
|
+
bl: "bottom-left",
|
|
668
|
+
br: "bottom-right"
|
|
669
|
+
};
|
|
670
|
+
function quadrantBoxName(box, options) {
|
|
671
|
+
return chartString(options, { tl: "topLeft", tr: "topRight", bl: "bottomLeft", br: "bottomRight" }[box]);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// src/core/charts/scatter/quadrants.ts
|
|
675
|
+
function quadrantMedian(values) {
|
|
676
|
+
let sorted = [...values].sort((a, b) => a - b), n = sorted.length, mid = n >> 1;
|
|
677
|
+
return n % 2 === 1 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
678
|
+
}
|
|
679
|
+
function resolveCut(threshold, axis, values, warnings) {
|
|
680
|
+
let nonfinite = (value2) => {
|
|
681
|
+
warnings.push({
|
|
682
|
+
code: "quadrant-threshold-nonfinite",
|
|
683
|
+
severity: "error",
|
|
684
|
+
message: `the ${axis} quadrant cut point resolved to ${String(value2)} \u2014 no dividers, no assignment and no claims were produced. A non-finite threshold cannot classify anything, and publishing a box count against it would be an invented number.`,
|
|
685
|
+
suggest: `declare quadrants.${axis} as a finite number`
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
if (typeof threshold == "number")
|
|
689
|
+
return Number.isFinite(threshold) ? { value: threshold, source: "declared" } : (nonfinite(threshold), null);
|
|
690
|
+
if (values.length < 3)
|
|
691
|
+
return warnings.push({
|
|
692
|
+
code: "quadrant-stat-underpowered",
|
|
693
|
+
severity: "error",
|
|
694
|
+
message: `quadrants.${axis} asks for the ${threshold.stat} of ${values.length} plotted point(s) \u2014 refused. A median of two points is the midpoint of the two: it reads as analysis and is not.`,
|
|
695
|
+
suggest: `plot at least 3 points, or declare quadrants.${axis} as a number`
|
|
696
|
+
}), null;
|
|
697
|
+
let value = threshold.stat === "median" ? quadrantMedian(values) : values.reduce((a, v) => a + v, 0) / values.length;
|
|
698
|
+
return Number.isFinite(value) ? { value, source: threshold.stat } : (nonfinite(value), null);
|
|
699
|
+
}
|
|
700
|
+
function resolveCuts(pts, env, warnings) {
|
|
701
|
+
let qOpt = env.options.quadrants, rawX = resolveCut(qOpt.x, "x", pts.map((p) => p.x), warnings), rawY = resolveCut(qOpt.y, "y", pts.map((p) => p.y), warnings), cutX = rawX ? { ...rawX, ...env.discloseCut(rawX.value, "x") } : void 0, cutY = rawY ? { ...rawY, ...env.discloseCut(rawY.value, "y") } : void 0;
|
|
702
|
+
for (let [axis, raw, disclosed] of [
|
|
703
|
+
["horizontal", rawX, cutX],
|
|
704
|
+
["vertical", rawY, cutY]
|
|
705
|
+
])
|
|
706
|
+
!raw || !disclosed || disclosed.exact || warnings.push({
|
|
707
|
+
code: "quadrant-threshold-unprintable",
|
|
708
|
+
severity: "warn",
|
|
709
|
+
message: `the ${axis} cut point cannot be printed exactly at any decimal count, so it was applied at the value the exhibit prints (${disclosed.text}) rather than at ${String(raw.value)} \u2014 classifying at a number no reader can see would file points against a boundary the exhibit does not state.`,
|
|
710
|
+
suggest: `declare the ${axis} cut point at a magnitude the chart format can print`
|
|
711
|
+
});
|
|
712
|
+
return cutX && cutY ? { x: cutX, y: cutY } : null;
|
|
713
|
+
}
|
|
714
|
+
function classifyQuadrants(pts, cutX, cutY) {
|
|
715
|
+
let counts = { tl: 0, tr: 0, bl: 0, br: 0 }, assignment = {}, onThreshold = [];
|
|
716
|
+
for (let p of pts) {
|
|
717
|
+
let right = p.x >= cutX.value, box = p.y >= cutY.value ? right ? "tr" : "tl" : right ? "br" : "bl";
|
|
718
|
+
assignment[p.id] = box, counts[box] += 1, (p.x === cutX.value || p.y === cutY.value) && onThreshold.push(p);
|
|
719
|
+
}
|
|
720
|
+
return { derived: {
|
|
721
|
+
x: cutX.value,
|
|
722
|
+
y: cutY.value,
|
|
723
|
+
xText: cutX.text,
|
|
724
|
+
yText: cutY.text,
|
|
725
|
+
xSource: cutX.source,
|
|
726
|
+
ySource: cutY.source,
|
|
727
|
+
counts,
|
|
728
|
+
assignment
|
|
729
|
+
}, onThreshold };
|
|
730
|
+
}
|
|
731
|
+
function quadrantMethodNotes(cutX, cutY, pointCount, bubbleMode, env, notes, warnings) {
|
|
732
|
+
let provenance = (source) => source === "declared" ? chartString(env.options, "declaredLower") : chartString(env.options, "cutProvenance", { v1: source, v2: pointCount }), names = env.options.quadrants?.axisNames;
|
|
733
|
+
names?.x && names.y && cutX.source === "declared" && cutY.source === "declared" ? notes.push(chartString(env.options, "quadrantCutShort", { v1: names.x, v2: cutX.text, v3: names.y, v4: cutY.text })) : notes.push(
|
|
734
|
+
chartString(env.options, "quadrantCutX", { v1: cutX.text, v2: provenance(cutX.source) }) + chartString(env.options, "quadrantCutY", { v1: cutY.text, v2: provenance(cutY.source) }) + chartString(env.options, "quadrantEquality")
|
|
735
|
+
), bubbleMode && (cutX.source !== "declared" || cutY.source !== "declared") && (notes.push(chartString(env.options, "quadrantWeights")), warnings.push({
|
|
736
|
+
code: "quadrant-stat-unweighted",
|
|
737
|
+
severity: "info",
|
|
738
|
+
message: "points carry a size channel, but the computed cut point weights every unit equally \u2014 with a size channel present an unweighted statistic is a choice, not a default. No size-weighted statistic is offered: a weighted median needs declared weight semantics and there is no honest default.",
|
|
739
|
+
suggest: "declare the cut point as a number if a size-weighted threshold is intended"
|
|
740
|
+
}));
|
|
741
|
+
}
|
|
742
|
+
function quadrantsOffDomain(cuts, plan, dx, dy, env, warnings) {
|
|
743
|
+
let voided = /* @__PURE__ */ new Set();
|
|
744
|
+
for (let [axis, key, cut, cutLabel, isDrawn, lo, hi] of [
|
|
745
|
+
["horizontal", "x", cuts.x.value, cuts.x.text, plan.drawX, dx[0], dx[1]],
|
|
746
|
+
["vertical", "y", cuts.y.value, cuts.y.text, plan.drawY, dy[0], dy[1]]
|
|
747
|
+
]) {
|
|
748
|
+
if (isDrawn) continue;
|
|
749
|
+
let loLabel = env.discloseCut(lo, key).text, hiLabel = env.discloseCut(hi, key).text;
|
|
750
|
+
warnings.push({
|
|
751
|
+
code: "quadrant-divider-outside-domain",
|
|
752
|
+
severity: "warn",
|
|
753
|
+
message: `the ${axis} cut point ${cutLabel} does not fall strictly inside the plotted domain ${loLabel} to ${hiLabel} \u2014 no divider is drawn on that axis, so the exhibit is a 1x2, not a 2x2: every plotted unit sits on one side of that cut point.`,
|
|
754
|
+
suggest: `move the ${axis} cut point strictly inside the plotted range, or drop it`
|
|
755
|
+
}), plan.notes.push(
|
|
756
|
+
chartString(env.options, "quadrantOutsideRange", { v1: axis, v2: cutLabel, v3: loLabel, v4: hiLabel })
|
|
757
|
+
), (axis === "horizontal" ? cut > hi ? ["tr", "br"] : ["tl", "bl"] : cut > hi ? ["tl", "tr"] : ["bl", "br"]).forEach((box) => voided.add(box));
|
|
758
|
+
}
|
|
759
|
+
return voided;
|
|
760
|
+
}
|
|
761
|
+
function quadrantEdgeCases(derived, onThreshold, pts, env, notes, warnings) {
|
|
762
|
+
if (onThreshold.length > 0) {
|
|
763
|
+
let named = onThreshold.slice(0, 3).map((p) => p.label).join(", "), rest = onThreshold.length - Math.min(3, onThreshold.length), list = rest > 0 ? chartString(env.options, "andMore", { v1: named, v2: rest }) : named;
|
|
764
|
+
warnings.push({
|
|
765
|
+
code: "quadrant-on-threshold",
|
|
766
|
+
severity: "info",
|
|
767
|
+
message: `${onThreshold.length} point(s) sit exactly on a cut point (${onThreshold.map((p) => p.id).join(", ")}) \u2014 the half-open rule counts them to the right and above; a different tie rule would move them`
|
|
768
|
+
}), notes.push(chartString(env.options, "quadrantOnThreshold", { v1: onThreshold.length === 1 ? chartString(env.options, "oneUnitSits") : chartString(env.options, "unitsSit", { v1: onThreshold.length }), v2: list }));
|
|
769
|
+
}
|
|
770
|
+
env.va.show === !1 && warnings.push({
|
|
771
|
+
code: "quadrant-axes-hidden",
|
|
772
|
+
severity: "warn",
|
|
773
|
+
message: "valueAxis.show is false while quadrants are drawn: the cut points are tagged, but without ticks a reader cannot check where either axis starts, so the box sizes and every unit position become unverifiable",
|
|
774
|
+
suggest: "show the value axes (the scatter default) whenever quadrants are on"
|
|
775
|
+
});
|
|
776
|
+
let soleBox = QUADRANT_BOXES.find((box) => derived.counts[box] === pts.length);
|
|
777
|
+
soleBox && (warnings.push({
|
|
778
|
+
code: "quadrant-degenerate",
|
|
779
|
+
severity: "info",
|
|
780
|
+
message: `all ${pts.length} plotted points fall in the ${QUADRANT_BOX_NAME[soleBox]} box; the other three are empty \u2014 an empty-box result is a finding, not a rendering fault`
|
|
781
|
+
}), notes.push(chartString(env.options, "quadrantAllUnits", { v1: pts.length, v2: quadrantBoxName(soleBox, env.options) })));
|
|
782
|
+
}
|
|
783
|
+
function quadrantRefusal(env) {
|
|
784
|
+
let qOpt = env.options.quadrants, missing = [...qOpt.x === void 0 ? ["x"] : [], ...qOpt.y === void 0 ? ["y"] : []];
|
|
785
|
+
if (missing.length > 0)
|
|
786
|
+
return {
|
|
787
|
+
code: "quadrant-threshold-undeclared",
|
|
788
|
+
severity: "error",
|
|
789
|
+
message: `options.quadrants is missing ${missing.join(" and ")} \u2014 no quadrants were derived. Where the dividing lines go decides which unit is a star and which is a dog, so a guessed cut point silently re-sorts the whole portfolio; the engine refuses to guess one.`,
|
|
790
|
+
suggest: missing.map(
|
|
791
|
+
(axis) => `declare quadrants.${axis} as a number (e.g. { ${axis}: 1 }) or as a statistic over the plotted points (e.g. { ${axis}: { stat: 'median' } }, also { stat: 'mean' })`
|
|
792
|
+
).join("; ")
|
|
793
|
+
};
|
|
794
|
+
if (env.va.reverse)
|
|
795
|
+
return {
|
|
796
|
+
code: "quadrant-scale-unsupported",
|
|
797
|
+
severity: "error",
|
|
798
|
+
message: "options.quadrants supports non-reversed axes only; valueAxis.reverse was requested \u2014 no quadrants were derived. Quadrant MEMBERSHIP is scale-invariant: reversing an axis cannot move a point across a cut point, so the answer would not change \u2014 only the geometry would, and the boxes would swap sides.",
|
|
799
|
+
suggest: "remove valueAxis.reverse, or drop options.quadrants"
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function deriveQuadrants(pts, bubbleMode, dx, dy, env, warnings) {
|
|
803
|
+
let plan = { notes: [], voidBoxes: /* @__PURE__ */ new Set(), drawX: !1, drawY: !1 };
|
|
804
|
+
if (!env.options.quadrants) return plan;
|
|
805
|
+
let refusal = quadrantRefusal(env);
|
|
806
|
+
if (refusal)
|
|
807
|
+
return warnings.push(refusal), plan;
|
|
808
|
+
let cuts = resolveCuts(pts, env, warnings);
|
|
809
|
+
if (!cuts) return plan;
|
|
810
|
+
let { derived, onThreshold } = classifyQuadrants(pts, cuts.x, cuts.y);
|
|
811
|
+
return plan.derived = derived, plan.drawX = cuts.x.value > dx[0] && cuts.x.value < dx[1], plan.drawY = cuts.y.value > dy[0] && cuts.y.value < dy[1], quadrantMethodNotes(cuts.x, cuts.y, pts.length, bubbleMode, env, plan.notes, warnings), plan.voidBoxes = quadrantsOffDomain(cuts, plan, dx, dy, env, warnings), quadrantEdgeCases(derived, onThreshold, pts, env, plan.notes, warnings), plan;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// src/core/charts/scatter/frontier.ts
|
|
815
|
+
var FRONTIER_EXTEND = 24;
|
|
816
|
+
function paretoFront(points, better) {
|
|
817
|
+
let sx = better.x === "min" ? -1 : 1, sy = better.y === "min" ? -1 : 1, beats = (q, p) => sx * q.x >= sx * p.x && sy * q.y >= sy * p.y && (sx * q.x > sx * p.x || sy * q.y > sy * p.y);
|
|
818
|
+
return points.filter((p) => !points.some((q) => beats(q, p))).sort((a, b) => a.x - b.x || a.y - b.y);
|
|
819
|
+
}
|
|
820
|
+
function planFrontier(env, drawn, warnings) {
|
|
821
|
+
let frontier = env.options.frontier;
|
|
822
|
+
if (!frontier) return;
|
|
823
|
+
let groups = frontier.groups === void 0 || frontier.groups === "all" ? void 0 : new Set(frontier.groups), missing = groups ? [...groups].filter((id) => !drawn.some((p) => p.group === id)) : [];
|
|
824
|
+
missing.length && warnings.push({
|
|
825
|
+
code: "frontier-group-empty",
|
|
826
|
+
severity: "warn",
|
|
827
|
+
message: `the Pareto line skips group${missing.length === 1 ? "" : "s"} ${missing.map((id) => `'${id}'`).join(", ")}: no drawn point belongs to ${missing.length === 1 ? "it" : "them"}`,
|
|
828
|
+
suggest: "correct the group id in frontier.groups, or drop it",
|
|
829
|
+
field: ["options", "frontier", "groups"]
|
|
830
|
+
});
|
|
831
|
+
let front = paretoFront(groups ? drawn.filter((p) => p.group !== void 0 && groups.has(p.group)) : drawn, frontier);
|
|
832
|
+
if (front.length < 2) {
|
|
833
|
+
warnings.push({
|
|
834
|
+
code: "frontier-single-point",
|
|
835
|
+
severity: "warn",
|
|
836
|
+
message: front.length ? `no Pareto line: '${front[0].label}' beats every other point on both axes, so the frontier is that one point` : "no Pareto line: no drawn point to run it through",
|
|
837
|
+
field: ["options", "frontier"]
|
|
838
|
+
});
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
return { x: frontier.x, y: frontier.y, ids: front.map((p) => p.id) };
|
|
842
|
+
}
|
|
843
|
+
function reachInside(from, dir, plot, max) {
|
|
844
|
+
let along = (pos, d, lo, hi) => d > 0 ? (hi - pos) / d : d < 0 ? (lo - pos) / d : 1 / 0;
|
|
845
|
+
return Math.max(0, Math.min(max, along(from.x, dir.x, plot.x, plot.x + plot.w), along(from.y, dir.y, plot.y, plot.y + plot.h)));
|
|
846
|
+
}
|
|
847
|
+
function extendPast(prev, end, plot) {
|
|
848
|
+
let len = Math.hypot(end.x - prev.x, end.y - prev.y);
|
|
849
|
+
if (len === 0) return end;
|
|
850
|
+
let dir = { x: (end.x - prev.x) / len, y: (end.y - prev.y) / len }, t = reachInside(end, dir, plot, FRONTIER_EXTEND);
|
|
851
|
+
return { x: end.x + dir.x * t, y: end.y + dir.y * t };
|
|
852
|
+
}
|
|
853
|
+
function drawFrontier(plan, env, pts, clamp, area, nodes, claims) {
|
|
854
|
+
if (!plan) return;
|
|
855
|
+
let byId = new Map(pts.map((p) => [p.id, p])), at = (p) => ({ x: area.x(clamp ? clamp.project.x(p.x) : p.x), y: area.y(clamp ? clamp.project.y(p.y) : p.y) }), path = plan.ids.map((id) => at(byId.get(id)));
|
|
856
|
+
env.options.frontier?.extend && (path.unshift(extendPast(path[1], path[0], area.plot)), path.push(extendPast(path[path.length - 2], path[path.length - 1], area.plot)));
|
|
857
|
+
let d = path.map((pt, k) => `${k === 0 ? "M" : "L"}${fmtPathNumber(pt.x)} ${fmtPathNumber(pt.y)}`).join("");
|
|
858
|
+
nodes.push({ t: "path", id: "frontier", d, stroke: { token: "ink" }, width: strokeToken(env.theme, "rule"), dash: dashToken(env.theme, "dotted"), lineCap: "round", owner: {}, part: "frontierLine" });
|
|
859
|
+
for (let k = 1; k < path.length; k++) {
|
|
860
|
+
let from = path[k - 1], to = path[k], slices = Math.max(1, Math.ceil(Math.hypot(to.x - from.x, to.y - from.y) / 8));
|
|
861
|
+
for (let s = 0; s < slices; s++) {
|
|
862
|
+
let x0 = from.x + (to.x - from.x) * s / slices, x1 = from.x + (to.x - from.x) * (s + 1) / slices, y0 = from.y + (to.y - from.y) * s / slices, y1 = from.y + (to.y - from.y) * (s + 1) / slices;
|
|
863
|
+
claims.claim({ x: Math.min(x0, x1) - 1, y: Math.min(y0, y1) - 1, w: Math.abs(x1 - x0) + 2, h: Math.abs(y1 - y0) + 2 }, "annotation", { annotationId: "frontier" }, "trendLine");
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// src/core/charts/scatter/trend.ts
|
|
869
|
+
var CURVE_SAMPLES = 24;
|
|
870
|
+
function fitScatterTrends(env, drawn, groupOrder, warnings) {
|
|
871
|
+
let trend = env.options.trend;
|
|
872
|
+
if (!trend) return [];
|
|
873
|
+
let groups = trend === !0 ? "all" : trend.groups ?? "all", buckets = groups === "all" ? [["all", void 0, [...drawn]]] : (groups === "each" ? eachGroup(drawn, groupOrder) : groups).map((group) => [
|
|
874
|
+
group ?? "ungrouped",
|
|
875
|
+
group,
|
|
876
|
+
drawn.filter((p) => p.group === group)
|
|
877
|
+
]), fits = [];
|
|
878
|
+
for (let [id, group, points] of buckets) {
|
|
879
|
+
let moments = olsMoments(points), fit = moments.n >= 3 ? olsFit(moments) : null;
|
|
880
|
+
if (!fit) {
|
|
881
|
+
warnings.push({
|
|
882
|
+
code: "trend-undefined",
|
|
883
|
+
severity: "warn",
|
|
884
|
+
message: `no trend line for ${group === void 0 ? "the points" : `group '${group}'`}: ${moments.n < 3 ? `a fit needs at least 3 drawn points, it has ${moments.n}` : "every drawn point has the same x"}`,
|
|
885
|
+
field: ["options", "trend"]
|
|
886
|
+
});
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
let xs = points.map((p) => p.x);
|
|
890
|
+
fits.push({ id, ...group === void 0 ? {} : { group }, ...moments, ...fit, x0: minOf(xs), x1: maxOf(xs) });
|
|
891
|
+
}
|
|
892
|
+
return fits;
|
|
893
|
+
}
|
|
894
|
+
function eachGroup(drawn, groupOrder) {
|
|
895
|
+
let present = new Set(drawn.map((p) => p.group));
|
|
896
|
+
return [...groupOrder.filter((id) => present.has(id)), ...present.has(void 0) ? [void 0] : []];
|
|
897
|
+
}
|
|
898
|
+
function drawScatterTrends(theme, fits, domain, area, paints, nodes, claims) {
|
|
899
|
+
let lines = [];
|
|
900
|
+
for (let fit of fits) {
|
|
901
|
+
let span = clipTrendToDomain(fit, domain.dx, domain.dy);
|
|
902
|
+
if (!span) continue;
|
|
903
|
+
let at = (x) => ({ x: area.x(x), y: area.y(fit.intercept + fit.slope * x) }), from = at(span[0]), to = at(span[1]), nodeId = `trend:${fit.id}`, stroke = fit.group === void 0 ? { token: "ink" } : paints.group(fit.group), curved = area.x.log === !0 || area.y.log === !0, yAt = curved ? (px) => area.y(fit.intercept + fit.slope * area.x.invert(px)) : (px) => from.y + (to.y - from.y) * (px - from.x) / (to.x - from.x || 1), slices = curved ? CURVE_SAMPLES : 12, vertices = Array.from({ length: slices + 1 }, (_, k) => {
|
|
904
|
+
if (curved && (k === 0 || k === slices)) return k === 0 ? from : to;
|
|
905
|
+
let px = from.x + (to.x - from.x) * k / slices;
|
|
906
|
+
return { x: px, y: curved ? yAt(px) : from.y + (to.y - from.y) * k / slices };
|
|
907
|
+
});
|
|
908
|
+
nodes.push(curved ? { t: "path", id: nodeId, d: vertices.map((v, k) => `${k === 0 ? "M" : "L"}${fmtPathNumber(v.x)} ${fmtPathNumber(v.y)}`).join(""), stroke, width: strokeToken(theme, "data"), dash: dashToken(theme, "reference"), owner: {}, part: "trendLine" } : { t: "line", id: nodeId, x1: from.x, y1: from.y, x2: to.x, y2: to.y, stroke, width: strokeToken(theme, "data"), dash: dashToken(theme, "reference"), owner: {}, part: "trendLine" });
|
|
909
|
+
for (let k = 0; k < slices; k++) {
|
|
910
|
+
let { x: x0, y: y0 } = vertices[k], { x: x1, y: y1 } = vertices[k + 1];
|
|
911
|
+
claims.claim({ x: Math.min(x0, x1), y: Math.min(y0, y1) - 1.5, w: Math.max(Math.abs(x1 - x0), 1), h: Math.abs(y1 - y0) + 3 }, "annotation", { annotationId: nodeId }, "trendLine");
|
|
912
|
+
}
|
|
913
|
+
lines.push({ fit, nodeId, from, to, yAt });
|
|
914
|
+
}
|
|
915
|
+
return lines;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// src/core/charts/scatter/zones.ts
|
|
919
|
+
var ZONE_BAND_GAP = 5, CELL_GAP = 2;
|
|
920
|
+
function gridZones(options) {
|
|
921
|
+
return options.zones !== void 0 && "grid" in options.zones && options.zones.grid !== void 0;
|
|
922
|
+
}
|
|
923
|
+
function bandedAxes(env, domain) {
|
|
924
|
+
let zones = env.options.zones, grid = zones && "grid" in zones ? zones.grid : void 0;
|
|
925
|
+
return {
|
|
926
|
+
x: (grid?.xLabels?.length ?? 0) > 0 && domain.evenGrid?.x === !0,
|
|
927
|
+
y: (grid?.yLabels?.length ?? 0) > 0 && domain.evenGrid?.y === !0
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function refuseUnkeyableZone(zone, path) {
|
|
931
|
+
if ((zone.labelAt ?? "plot") !== "plot" && (!zone.label || zone.tone === "none"))
|
|
932
|
+
throw new NormalizeError(
|
|
933
|
+
"zone-key-unkeyable",
|
|
934
|
+
`${path}.labelAt`,
|
|
935
|
+
`strategy zone '${zone.id}' is keyed in the legend (labelAt '${zone.labelAt}') ${zone.label ? "with tone 'none', so its swatch would be empty" : "without a label to key it by"}`,
|
|
936
|
+
zone.label ? "give the zone a tone, or keep labelAt 'plot'" : "add a label, or keep labelAt 'plot'"
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
function validateStrategyZones(options) {
|
|
940
|
+
let zones = options.zones;
|
|
941
|
+
if (!zones) return;
|
|
942
|
+
if (zones.grid) {
|
|
943
|
+
let { grid } = zones;
|
|
944
|
+
for (let axis of ["x", "y"]) {
|
|
945
|
+
if (!Array.isArray(grid[axis]) || grid[axis].length === 0)
|
|
946
|
+
throw new NormalizeError(
|
|
947
|
+
"zone-thresholds-empty",
|
|
948
|
+
`options.zones.grid.${axis}`,
|
|
949
|
+
`strategy-zone ${axis} thresholds require at least one value`
|
|
950
|
+
);
|
|
951
|
+
grid[axis].forEach((value, index) => {
|
|
952
|
+
if (!Number.isFinite(value))
|
|
953
|
+
throw new NormalizeError(
|
|
954
|
+
"zone-threshold-nonfinite",
|
|
955
|
+
`options.zones.grid.${axis}[${index}]`,
|
|
956
|
+
"strategy-zone thresholds must be finite"
|
|
957
|
+
);
|
|
958
|
+
if (index > 0 && !(value > grid[axis][index - 1]))
|
|
959
|
+
throw new NormalizeError(
|
|
960
|
+
"zone-threshold-order",
|
|
961
|
+
`options.zones.grid.${axis}[${index}]`,
|
|
962
|
+
"strategy-zone thresholds must be strictly increasing"
|
|
963
|
+
);
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
for (let [axis, labels, expected] of [
|
|
967
|
+
["x", grid.xLabels, grid.x.length + 1],
|
|
968
|
+
["y", grid.yLabels, grid.y.length + 1]
|
|
969
|
+
])
|
|
970
|
+
if (labels && labels.length !== expected)
|
|
971
|
+
throw new NormalizeError(
|
|
972
|
+
"zone-band-label-count",
|
|
973
|
+
`options.zones.grid.${axis}Labels`,
|
|
974
|
+
`strategy-zone ${axis} band labels require exactly ${expected} entries`
|
|
975
|
+
);
|
|
976
|
+
let ids2 = /* @__PURE__ */ new Set(), positions = /* @__PURE__ */ new Set();
|
|
977
|
+
for (let [index, cell] of (grid.cells ?? []).entries()) {
|
|
978
|
+
if (ids2.has(cell.id))
|
|
979
|
+
throw new NormalizeError(
|
|
980
|
+
"duplicate-id",
|
|
981
|
+
`options.zones.grid.cells[${index}]`,
|
|
982
|
+
`duplicate strategy-zone cell id '${cell.id}'`
|
|
983
|
+
);
|
|
984
|
+
if (ids2.add(cell.id), cell.column > grid.x.length || cell.row > grid.y.length)
|
|
985
|
+
throw new NormalizeError(
|
|
986
|
+
"zone-cell-outside-grid",
|
|
987
|
+
`options.zones.grid.cells[${index}]`,
|
|
988
|
+
`strategy-zone cell '${cell.id}' addresses row ${cell.row}, column ${cell.column} outside the derived grid`
|
|
989
|
+
);
|
|
990
|
+
let position = `${cell.column}:${cell.row}`;
|
|
991
|
+
if (positions.has(position))
|
|
992
|
+
throw new NormalizeError(
|
|
993
|
+
"zone-cell-duplicate-position",
|
|
994
|
+
`options.zones.grid.cells[${index}]`,
|
|
995
|
+
`more than one strategy-zone cell addresses row ${cell.row}, column ${cell.column}`
|
|
996
|
+
);
|
|
997
|
+
positions.add(position), refuseUnkeyableZone(cell, `options.zones.grid.cells[${index}]`);
|
|
998
|
+
}
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (!Array.isArray(zones.regions) || zones.regions.length === 0)
|
|
1002
|
+
throw new NormalizeError(
|
|
1003
|
+
"zone-regions-empty",
|
|
1004
|
+
"options.zones.regions",
|
|
1005
|
+
"strategy zones require at least one region"
|
|
1006
|
+
);
|
|
1007
|
+
let ids = /* @__PURE__ */ new Set();
|
|
1008
|
+
for (let [index, region] of zones.regions.entries()) {
|
|
1009
|
+
if (validateZoneRegion(region, index), refuseUnkeyableZone(region, `options.zones.regions[${index}]`), ids.has(region.id))
|
|
1010
|
+
throw new NormalizeError(
|
|
1011
|
+
"duplicate-id",
|
|
1012
|
+
`options.zones.regions[${index}]`,
|
|
1013
|
+
`duplicate strategy-zone region id '${region.id}'`
|
|
1014
|
+
);
|
|
1015
|
+
ids.add(region.id);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
function validateZoneRegion(region, index) {
|
|
1019
|
+
if (!region.id)
|
|
1020
|
+
throw new NormalizeError(
|
|
1021
|
+
"missing-id",
|
|
1022
|
+
`options.zones.regions[${index}]`,
|
|
1023
|
+
"strategy-zone region requires an id"
|
|
1024
|
+
);
|
|
1025
|
+
if (!Array.isArray(region.points) || region.points.length < 3)
|
|
1026
|
+
throw new NormalizeError(
|
|
1027
|
+
"zone-region-too-short",
|
|
1028
|
+
`options.zones.regions[${index}].points`,
|
|
1029
|
+
"strategy-zone polygon requires at least three points"
|
|
1030
|
+
);
|
|
1031
|
+
region.points.forEach((point, pointIndex) => {
|
|
1032
|
+
if (!Number.isFinite(point.x) || !Number.isFinite(point.y))
|
|
1033
|
+
throw new NormalizeError(
|
|
1034
|
+
"zone-region-nonfinite",
|
|
1035
|
+
`options.zones.regions[${index}].points[${pointIndex}]`,
|
|
1036
|
+
"strategy-zone polygon points must be finite"
|
|
1037
|
+
);
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
function zoneToneToken(tone, fill = !1) {
|
|
1041
|
+
return tone === "good" ? fill ? "goodFill" : "good" : tone === "bad" ? fill ? "badFill" : "bad" : tone === "warn" ? fill ? "warnFill" : "warn" : tone === "info" ? "focus" : "neutral";
|
|
1042
|
+
}
|
|
1043
|
+
var neutralWash = { token: "neutral", theme: { kind: "visible-tint", base: { token: "neutral" }, amount: 0.91, floor: 1.1 } }, zoneFill = (tone) => {
|
|
1044
|
+
if (tone === "none") return;
|
|
1045
|
+
if (tone === void 0 || tone === "neutral") return neutralWash;
|
|
1046
|
+
let token = zoneToneToken(tone, !0);
|
|
1047
|
+
return { token, theme: { kind: "visible-tint", base: { token }, amount: 0.91, floor: 1.1, darkApartFrom: { paint: neutralWash, distance: PALETTE_NORMAL_FLOOR } } };
|
|
1048
|
+
};
|
|
1049
|
+
function zoneKeyItems(options) {
|
|
1050
|
+
let zones = options.zones;
|
|
1051
|
+
return [...zones?.grid?.cells ?? [], ...zones?.regions ?? []].filter((zone) => (zone.labelAt ?? "plot") !== "plot" && zone.label).map((zone) => ({ id: `zone:${zone.id}`, label: zone.label, paint: zoneFill(zone.tone) ?? neutralWash, key: "box" }));
|
|
1052
|
+
}
|
|
1053
|
+
var captionedInPlot = (zone) => zone?.label !== void 0 && (zone.labelAt ?? "plot") !== "key", zoneStroke = (tone) => ({
|
|
1054
|
+
token: zoneToneToken(tone),
|
|
1055
|
+
tint: 0.55
|
|
1056
|
+
});
|
|
1057
|
+
function gridZoneCells(grid, bounds, area, fmt, nodes, out, options) {
|
|
1058
|
+
let { x, y } = area, { x: xBounds, y: yBounds } = bounds, cellByPosition = new Map((grid.cells ?? []).map((cell) => [`${cell.column}:${cell.row}`, cell]));
|
|
1059
|
+
for (let row = 0; row < yBounds.length - 1; row++)
|
|
1060
|
+
for (let column = 0; column < xBounds.length - 1; column++) {
|
|
1061
|
+
let authored = cellByPosition.get(`${column}:${row}`), id = authored?.id ?? `r${row + 1}-c${column + 1}`, left = x(xBounds[column]), right = x(xBounds[column + 1]), top = y(yBounds[row + 1]), bottom = y(yBounds[row]), rect = {
|
|
1062
|
+
x: Math.min(left, right),
|
|
1063
|
+
y: Math.min(top, bottom),
|
|
1064
|
+
w: Math.abs(right - left),
|
|
1065
|
+
h: Math.abs(bottom - top)
|
|
1066
|
+
}, nodeId = `zone:cell:${id}`, description = authored?.a11y ?? chartString(options, "zoneDesc", { v1: authored?.label ?? chartString(options, "zoneName", { v1: row + 1, v2: column + 1 }), v2: fmt.x(xBounds[column]), v3: fmt.x(xBounds[column + 1]), v4: fmt.y(yBounds[row]), v5: fmt.y(yBounds[row + 1]) }), fill = zoneFill(authored?.tone);
|
|
1067
|
+
fill && nodes.push({
|
|
1068
|
+
t: "rect",
|
|
1069
|
+
id: nodeId,
|
|
1070
|
+
rect,
|
|
1071
|
+
fill,
|
|
1072
|
+
owner: { categoryId: `zone:${id}` },
|
|
1073
|
+
part: "strategyZoneCell",
|
|
1074
|
+
display: { state: description }
|
|
1075
|
+
});
|
|
1076
|
+
let captioned = captionedInPlot(authored);
|
|
1077
|
+
out.marks.push({
|
|
1078
|
+
id,
|
|
1079
|
+
kind: "cell",
|
|
1080
|
+
...fill ? { nodeId } : {},
|
|
1081
|
+
...captioned ? { labelId: `zone:label:${id}` } : {},
|
|
1082
|
+
description
|
|
1083
|
+
}), out.descriptions.push(description), captioned && out.labels.push({ kind: "cell", id: `zone:label:${id}`, text: authored.label, box: rect });
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
function gridZoneRules(grid, bounds, area, nodes, labels) {
|
|
1087
|
+
let { x, y, plot } = area;
|
|
1088
|
+
for (let threshold of grid.x) {
|
|
1089
|
+
let px = x(threshold);
|
|
1090
|
+
nodes.push({
|
|
1091
|
+
t: "line",
|
|
1092
|
+
id: `zone:grid:x:${threshold}`,
|
|
1093
|
+
x1: px,
|
|
1094
|
+
y1: plot.y,
|
|
1095
|
+
x2: px,
|
|
1096
|
+
y2: plot.y + plot.h,
|
|
1097
|
+
// A page-colour rule leaves a gap between the tinted cells (scatter.matrix).
|
|
1098
|
+
stroke: { token: "background" },
|
|
1099
|
+
width: CELL_GAP,
|
|
1100
|
+
owner: {},
|
|
1101
|
+
part: "strategyZoneBoundary"
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
for (let threshold of grid.y) {
|
|
1105
|
+
let py = y(threshold);
|
|
1106
|
+
nodes.push({
|
|
1107
|
+
t: "line",
|
|
1108
|
+
id: `zone:grid:y:${threshold}`,
|
|
1109
|
+
x1: plot.x,
|
|
1110
|
+
y1: py,
|
|
1111
|
+
x2: plot.x + plot.w,
|
|
1112
|
+
y2: py,
|
|
1113
|
+
stroke: { token: "background" },
|
|
1114
|
+
width: CELL_GAP,
|
|
1115
|
+
owner: {},
|
|
1116
|
+
part: "strategyZoneBoundary"
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
grid.xLabels?.forEach((text, column) => {
|
|
1120
|
+
let left = x(bounds.x[column]), right = x(bounds.x[column + 1]);
|
|
1121
|
+
labels.push({
|
|
1122
|
+
kind: "xBand",
|
|
1123
|
+
id: `zone:x-band:${column}`,
|
|
1124
|
+
text,
|
|
1125
|
+
...area.xBandLines?.[column] ? { lines: area.xBandLines[column] } : {},
|
|
1126
|
+
box: { x: Math.min(left, right), y: plot.y + plot.h + area.xAxisH, w: Math.abs(right - left), h: area.xBandH }
|
|
1127
|
+
});
|
|
1128
|
+
}), grid.yLabels?.forEach((text, row) => {
|
|
1129
|
+
let top = y(bounds.y[row + 1]), bottom = y(bounds.y[row]);
|
|
1130
|
+
labels.push({
|
|
1131
|
+
kind: "yBand",
|
|
1132
|
+
id: `zone:y-band:${row}`,
|
|
1133
|
+
text,
|
|
1134
|
+
...area.yBandLines?.[row] ? { lines: area.yBandLines[row] } : {},
|
|
1135
|
+
box: { x: area.inner.x, y: Math.min(top, bottom), w: area.yBandW, h: Math.abs(bottom - top) }
|
|
1136
|
+
});
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
function regionZones(theme, regions, area, nodes, claims, out, options) {
|
|
1140
|
+
for (let region of regions) {
|
|
1141
|
+
let points = region.points.map((point) => ({ x: area.x(point.x), y: area.y(point.y) })), d = region.smooth ? smoothClosedZonePath(points) : polygonPath(points), nodeId = `zone:region:${region.id}`, description = region.a11y ?? chartString(options, "regionBoundaryDesc", { v1: region.label ?? region.id, v2: region.points.length }), fill = zoneFill(region.tone);
|
|
1142
|
+
nodes.push({
|
|
1143
|
+
t: "path",
|
|
1144
|
+
id: nodeId,
|
|
1145
|
+
d,
|
|
1146
|
+
...fill ? { fill } : {},
|
|
1147
|
+
stroke: zoneStroke(region.tone),
|
|
1148
|
+
width: strokeToken(theme, "rule"),
|
|
1149
|
+
owner: { categoryId: `zone:${region.id}` },
|
|
1150
|
+
part: "strategyZoneRegion",
|
|
1151
|
+
display: { state: description }
|
|
1152
|
+
}), claimZoneBoundary(points, region.smooth ?? !1, claims, { categoryId: `zone:${region.id}` }), out.marks.push({
|
|
1153
|
+
id: region.id,
|
|
1154
|
+
kind: "region",
|
|
1155
|
+
nodeId,
|
|
1156
|
+
...captionedInPlot(region) ? { labelId: `zone:label:${region.id}` } : {},
|
|
1157
|
+
description
|
|
1158
|
+
}), out.descriptions.push(description), captionedInPlot(region) && out.labels.push({ kind: "region", id: `zone:label:${region.id}`, text: region.label, box: pointBounds(points) });
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
function layoutScatterZones(env, domain, area, nodes, claims) {
|
|
1162
|
+
let zones = env.options.zones, out = { marks: [], descriptions: [], labels: [] };
|
|
1163
|
+
if (zones && "grid" in zones && zones.grid) {
|
|
1164
|
+
let grid = zones.grid, bounds = { x: [domain.dx[0], ...grid.x, domain.dx[1]], y: [domain.dy[0], ...grid.y, domain.dy[1]] };
|
|
1165
|
+
gridZoneCells(grid, bounds, area, env.axisFmt, nodes, out, env.options), gridZoneRules(grid, bounds, area, nodes, out.labels), out.derived = { kind: "grid", descriptions: out.descriptions, cellCount: out.marks.length };
|
|
1166
|
+
} else zones?.regions && (regionZones(env.theme, zones.regions, area, nodes, claims, out, env.options), out.derived = { kind: "regions", descriptions: out.descriptions, regionCount: out.marks.length });
|
|
1167
|
+
return out;
|
|
1168
|
+
}
|
|
1169
|
+
function pointBounds(points) {
|
|
1170
|
+
let xs = points.map((point) => point.x), ys = points.map((point) => point.y), x = minOf(xs), y = minOf(ys);
|
|
1171
|
+
return {
|
|
1172
|
+
x,
|
|
1173
|
+
y,
|
|
1174
|
+
w: maxOf(xs) - x,
|
|
1175
|
+
h: maxOf(ys) - y
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function polygonPath(points) {
|
|
1179
|
+
return `${points.map((point, index) => `${index === 0 ? "M" : "L"}${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join("")}Z`;
|
|
1180
|
+
}
|
|
1181
|
+
function claimZoneBoundary(points, smooth, occupied, owner) {
|
|
1182
|
+
let cubics = smooth ? smoothClosedZoneSegments(points) : [], samples = cubics.length ? cubics.flatMap(
|
|
1183
|
+
(segment) => Array.from({ length: 9 }, (_, index) => cubicPoint(segment, index / 8))
|
|
1184
|
+
) : points.flatMap((point, index) => {
|
|
1185
|
+
let next = points[(index + 1) % points.length];
|
|
1186
|
+
return Array.from({ length: 9 }, (_, sample) => ({
|
|
1187
|
+
x: point.x + (next.x - point.x) * sample / 8,
|
|
1188
|
+
y: point.y + (next.y - point.y) * sample / 8
|
|
1189
|
+
}));
|
|
1190
|
+
});
|
|
1191
|
+
for (let index = 1; index < samples.length; index += 1) {
|
|
1192
|
+
let from = samples[index - 1], to = samples[index];
|
|
1193
|
+
occupied.claim(
|
|
1194
|
+
{
|
|
1195
|
+
x: Math.min(from.x, to.x) - 0.5,
|
|
1196
|
+
y: Math.min(from.y, to.y) - 0.5,
|
|
1197
|
+
w: Math.abs(to.x - from.x) + 1,
|
|
1198
|
+
h: Math.abs(to.y - from.y) + 1
|
|
1199
|
+
},
|
|
1200
|
+
"axis",
|
|
1201
|
+
owner,
|
|
1202
|
+
"strategyZoneBoundary"
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
function smoothClosedZonePath(points) {
|
|
1207
|
+
if (points.length < 3) return polygonPath(points);
|
|
1208
|
+
let segments = smoothClosedZoneSegments(points);
|
|
1209
|
+
return `M${fmtPathNumber(points[0].x)} ${fmtPathNumber(points[0].y)}` + segments.map(
|
|
1210
|
+
(segment) => `C${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.to.x)} ${fmtPathNumber(segment.to.y)}`
|
|
1211
|
+
).join("") + "Z";
|
|
1212
|
+
}
|
|
1213
|
+
function smoothClosedZoneSegments(points) {
|
|
1214
|
+
let cyclic = [points[points.length - 1], ...points, points[0], points[1]], xSeries = cyclic.map((point, index) => ({ x: index - 1, y: point.x })), ySeries = cyclic.map((point, index) => ({ x: index - 1, y: point.y })), xSegments = monotoneSegments(xSeries).slice(1, points.length + 1), ySegments = monotoneSegments(ySeries).slice(1, points.length + 1);
|
|
1215
|
+
return xSegments.map((segment, index) => {
|
|
1216
|
+
let ySegment = ySegments[index];
|
|
1217
|
+
return {
|
|
1218
|
+
from: { x: segment.from.y, y: ySegment.from.y },
|
|
1219
|
+
c1: { x: segment.c1.y, y: ySegment.c1.y },
|
|
1220
|
+
c2: { x: segment.c2.y, y: ySegment.c2.y },
|
|
1221
|
+
to: { x: segment.to.y, y: ySegment.to.y }
|
|
1222
|
+
};
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// src/core/charts/scatter/domain.ts
|
|
1227
|
+
function scatterFormatter(options, format = options.format) {
|
|
1228
|
+
let decimalsOf = options.valueAxis?.log ? (v) => v !== 0 && Math.abs(v) < 1 ? Math.max(1, neededDecimals(v, 1 - Math.floor(Math.log10(Math.abs(v))))) : autoDecimals(v) : autoDecimals, formatValue = format ? formatterFromExample(format, options.locale?.language) : (v) => formatAutomaticNumber(v, { locale: options.locale?.language, decimals: decimalsOf(v) }), formattedValues = /* @__PURE__ */ new Map();
|
|
1229
|
+
return (value) => {
|
|
1230
|
+
let text = formattedValues.get(value);
|
|
1231
|
+
return text === void 0 && (text = formatValue(value), formattedValues.set(value, text)), text;
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
var MAX_DISCLOSED_DECIMALS = 20;
|
|
1235
|
+
function plainNumberSpec(locale) {
|
|
1236
|
+
return {
|
|
1237
|
+
decimals: 0,
|
|
1238
|
+
locale,
|
|
1239
|
+
thousandsSep: ",",
|
|
1240
|
+
decimalSep: ".",
|
|
1241
|
+
magnitude: "none",
|
|
1242
|
+
prefix: "",
|
|
1243
|
+
suffix: "",
|
|
1244
|
+
negative: "minus",
|
|
1245
|
+
signed: !1
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
function discloseNumber(raw, spec, authoredFormat) {
|
|
1249
|
+
let scaled = Math.abs(raw / MAGNITUDE_DIVISOR[spec.magnitude]), base = authoredFormat ? spec.decimals : autoDecimals(raw), decimals = base;
|
|
1250
|
+
for (; decimals < MAX_DISCLOSED_DECIMALS && Number(scaled.toFixed(decimals)) !== scaled; )
|
|
1251
|
+
decimals += 1;
|
|
1252
|
+
let exact = Number(scaled.toFixed(decimals)) === scaled, applied = { ...spec, decimals: exact ? decimals : base }, value = exact ? raw : roundedNumber(raw, applied);
|
|
1253
|
+
return { value, text: formatWithSpec(value, applied), exact };
|
|
1254
|
+
}
|
|
1255
|
+
function resolveScatterEnv(options, warnings) {
|
|
1256
|
+
if (options.zones && options.quadrants)
|
|
1257
|
+
throw new NormalizeError(
|
|
1258
|
+
"zones-quadrants-conflict",
|
|
1259
|
+
"options.zones",
|
|
1260
|
+
"scatter strategy zones and quadrants are mutually exclusive"
|
|
1261
|
+
);
|
|
1262
|
+
breakUnsupported("scatter", options, warnings);
|
|
1263
|
+
let theme = chartTheme(options), paletteRamp = chartPalette(theme, options.palette, warnings), size = resolveSize(options.size), measure = options.measure ?? defaultMeasurer, fmt = scatterFormatter(options), axisFormat = { x: options.axisFormat?.x ?? options.format, y: options.axisFormat?.y ?? options.format }, axisFmt = {
|
|
1264
|
+
x: options.axisFormat?.x ? scatterFormatter(options, axisFormat.x) : fmt,
|
|
1265
|
+
y: options.axisFormat?.y ? scatterFormatter(options, axisFormat.y) : fmt
|
|
1266
|
+
}, countSpec = plainNumberSpec(options.locale?.language), axisSpecOf = (format) => format ? exampleSpec(format, options.locale?.language) : countSpec, axisSpec = { x: axisSpecOf(axisFormat.x), y: axisSpecOf(axisFormat.y) };
|
|
1267
|
+
return {
|
|
1268
|
+
options,
|
|
1269
|
+
theme,
|
|
1270
|
+
palette: paletteRamp ? options.palette : void 0,
|
|
1271
|
+
size,
|
|
1272
|
+
measure,
|
|
1273
|
+
fmt,
|
|
1274
|
+
axisFmt,
|
|
1275
|
+
axisSpec,
|
|
1276
|
+
discloseCut: (raw, axis) => discloseNumber(raw, axisSpec[axis], axisFormat[axis] !== void 0),
|
|
1277
|
+
discloseCount: (raw) => discloseNumber(raw, countSpec, !1),
|
|
1278
|
+
highlights: new Set(resolveHighlight(options.highlight)),
|
|
1279
|
+
va: options.valueAxis ?? {},
|
|
1280
|
+
log: logAxesOf(options.valueAxis?.log)
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
function normalizePoint(raw, i, seenIds, groupMap, warnings, hasAuthoredLabels) {
|
|
1284
|
+
if (!raw?.id) throw new NormalizeError("missing-id", `points[${i}]`, "point requires an id");
|
|
1285
|
+
if (seenIds.has(raw.id))
|
|
1286
|
+
throw new NormalizeError("duplicate-id", `points[${raw.id}]`, `duplicate point id '${raw.id}'`);
|
|
1287
|
+
seenIds.add(raw.id);
|
|
1288
|
+
let path = `points[${raw.id}]`, xCell = normalizeCell(raw.x, `${path}.x`), yCell = normalizeCell(raw.y, `${path}.y`);
|
|
1289
|
+
if (xCell !== null && isDateCell(xCell) || yCell !== null && isDateCell(yCell))
|
|
1290
|
+
return warnings.push({
|
|
1291
|
+
code: "date-axis-unsupported",
|
|
1292
|
+
severity: "warn",
|
|
1293
|
+
message: `point '${raw.id}': date cells on scatter axes are not supported in v1 \u2014 point dropped`,
|
|
1294
|
+
owner: { pointId: raw.id }
|
|
1295
|
+
}), null;
|
|
1296
|
+
for (let [axis, cell] of [["x", xCell], ["y", yCell]])
|
|
1297
|
+
cellMeta(cell)?.label !== void 0 && warnings.push({
|
|
1298
|
+
code: "cell-label-unsupported",
|
|
1299
|
+
severity: "warn",
|
|
1300
|
+
message: `point '${raw.id}': ${axis}.label is ignored \u2014 a scatter point's drawn label is points[].label`,
|
|
1301
|
+
owner: { pointId: raw.id },
|
|
1302
|
+
suggest: `set label on the point itself: { id: '${raw.id}', label: '\u2026', ${axis}: \u2026 }`
|
|
1303
|
+
});
|
|
1304
|
+
let xv = cellValue(xCell), yv = cellValue(yCell);
|
|
1305
|
+
if (xv === null || yv === null)
|
|
1306
|
+
return warnings.push({
|
|
1307
|
+
code: "missing-value",
|
|
1308
|
+
severity: "info",
|
|
1309
|
+
message: `point '${raw.id}': missing x or y \u2014 point dropped`,
|
|
1310
|
+
owner: { pointId: raw.id }
|
|
1311
|
+
}), null;
|
|
1312
|
+
raw.group !== void 0 && !groupMap.has(raw.group) && groupMap.set(raw.group, { id: raw.group, label: raw.group, idx: groupMap.size });
|
|
1313
|
+
let sizeVal = raw.size ?? null;
|
|
1314
|
+
sizeVal !== null && (!Number.isFinite(sizeVal) || sizeVal < 0) && (warnings.push({
|
|
1315
|
+
code: "size-invalid",
|
|
1316
|
+
severity: "warn",
|
|
1317
|
+
message: `point '${raw.id}': size ${sizeVal} is not a non-negative number \u2014 treated as 0`,
|
|
1318
|
+
owner: { pointId: raw.id }
|
|
1319
|
+
}), sizeVal = 0);
|
|
1320
|
+
let sizeInvalid = raw.size !== void 0 && raw.size !== null && (!Number.isFinite(raw.size) || raw.size < 0), group = raw.group !== void 0 ? groupMap.get(raw.group) : void 0;
|
|
1321
|
+
return {
|
|
1322
|
+
id: raw.id,
|
|
1323
|
+
group: raw.group,
|
|
1324
|
+
label: raw.label ?? (hasAuthoredLabels ? "" : raw.id),
|
|
1325
|
+
x: xv,
|
|
1326
|
+
y: yv,
|
|
1327
|
+
...isPctCell(yCell) ? { yIsPct: !0 } : {},
|
|
1328
|
+
size: sizeVal,
|
|
1329
|
+
...sizeInvalid ? { sizeInvalid: !0 } : {},
|
|
1330
|
+
fill: raw.fill,
|
|
1331
|
+
marker: raw.marker ?? group?.marker ?? "circle",
|
|
1332
|
+
scenario: normalizeScenario(raw.scenario, `${path}.scenario`),
|
|
1333
|
+
count: raw.count ?? null,
|
|
1334
|
+
idx: i
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
function normalizeScatterData(data, warnings) {
|
|
1338
|
+
if (!data || !Array.isArray(data.points) || data.points.length === 0)
|
|
1339
|
+
throw new NormalizeError("empty-data", "points", "scatter requires at least one point");
|
|
1340
|
+
let groupMap = /* @__PURE__ */ new Map();
|
|
1341
|
+
(data.groups ?? []).forEach((g, i) => {
|
|
1342
|
+
if (!g?.id) throw new NormalizeError("missing-id", `groups[${i}]`, "group requires an id");
|
|
1343
|
+
if (groupMap.has(g.id))
|
|
1344
|
+
throw new NormalizeError("duplicate-id", `groups[${g.id}]`, `duplicate group id '${g.id}'`);
|
|
1345
|
+
groupMap.set(g.id, {
|
|
1346
|
+
id: g.id,
|
|
1347
|
+
label: g.label ?? g.id,
|
|
1348
|
+
colorRole: g.colorRole,
|
|
1349
|
+
marker: g.marker,
|
|
1350
|
+
idx: groupMap.size
|
|
1351
|
+
});
|
|
1352
|
+
});
|
|
1353
|
+
let seenIds = /* @__PURE__ */ new Set(), plottable = [], hasAuthoredLabels = data.points.some((point) => typeof point?.label == "string"), noPosition = [];
|
|
1354
|
+
if (data.points.forEach((raw, i) => {
|
|
1355
|
+
let p = normalizePoint(raw, i, seenIds, groupMap, warnings, hasAuthoredLabels);
|
|
1356
|
+
p ? plottable.push(p) : raw?.id !== void 0 && (cellValue(normalizeCell(raw.x, `points[${raw.id}].x`)) === null || cellValue(normalizeCell(raw.y, `points[${raw.id}].y`)) === null) && noPosition.push(raw.label ?? raw.id);
|
|
1357
|
+
}), plottable.length === 0)
|
|
1358
|
+
throw new NormalizeError("empty-data", "points", "scatter has no plottable points (all x/y missing)");
|
|
1359
|
+
let declared = new Set((data.groups ?? []).map((g) => g.id)), undeclared = [...groupMap.keys()].filter((id) => !declared.has(id));
|
|
1360
|
+
return declared.size > 0 && undeclared.length > 0 && warnings.push({
|
|
1361
|
+
code: "group-undeclared",
|
|
1362
|
+
severity: "warn",
|
|
1363
|
+
message: `points name group${undeclared.length === 1 ? "" : "s"} ${undeclared.map((id) => `'${id}'`).join(", ")} missing from data.groups; each is keyed under its id`,
|
|
1364
|
+
suggest: "declare the group in data.groups, or correct the point's group id"
|
|
1365
|
+
}), { groupMap, plottable, noPosition };
|
|
1366
|
+
}
|
|
1367
|
+
function pointExtents(pts) {
|
|
1368
|
+
let xMin = 1 / 0, xMax = -1 / 0, yMin = 1 / 0, yMax = -1 / 0;
|
|
1369
|
+
for (let p of pts)
|
|
1370
|
+
xMin = Math.min(xMin, p.x), xMax = Math.max(xMax, p.x), yMin = Math.min(yMin, p.y), yMax = Math.max(yMax, p.y);
|
|
1371
|
+
return { xMin, xMax, yMin, yMax };
|
|
1372
|
+
}
|
|
1373
|
+
function scatterAxisDomain(input, env, warnings) {
|
|
1374
|
+
let { options, va } = env, fmt = env.axisFmt.y, { clamp, valueLines } = input, domainXMin = input.xMin, domainXMax = input.xMax, domainYMin = input.yMin, domainYMax = input.yMax;
|
|
1375
|
+
if (options.zones?.regions)
|
|
1376
|
+
for (let region of options.zones.regions)
|
|
1377
|
+
for (let point of region.points)
|
|
1378
|
+
domainXMin = Math.min(domainXMin, point.x), domainXMax = Math.max(domainXMax, point.x), domainYMin = Math.min(domainYMin, point.y), domainYMax = Math.max(domainYMax, point.y);
|
|
1379
|
+
let padFrac = input.bubbleMode ? 0.08 : 0.05, padOf = (lo, hi) => {
|
|
1380
|
+
let span = hi - lo;
|
|
1381
|
+
return span > 0 ? span * padFrac : Math.abs(hi) > 0 ? Math.abs(hi) * padFrac : 1;
|
|
1382
|
+
}, pyBound = padOf(...clampSeed(clamp, "y", domainYMin, domainYMax));
|
|
1383
|
+
[domainYMin, domainYMax] = withValueLines(valueLines, domainYMin, domainYMax), [domainXMin, domainXMax] = clampSeed(clamp, "x", domainXMin, domainXMax), [domainYMin, domainYMax] = clampSeed(clamp, "y", domainYMin, domainYMax);
|
|
1384
|
+
let px = padOf(domainXMin, domainXMax), py = padOf(domainYMin, domainYMax), [dxLo, dxHi] = env.log.x ? logDomain(domainXMin, domainXMax) : niceDomain(domainXMin - px, domainXMax + px, 5, {
|
|
1385
|
+
dataExtent: [domainXMin, domainXMax],
|
|
1386
|
+
preserveDataSideOfZero: !0,
|
|
1387
|
+
maxWasteFraction: 0.15,
|
|
1388
|
+
maxTotalWasteFraction: 0.15
|
|
1389
|
+
}), [dyLo, dyHi] = env.log.y ? logDomain(domainYMin, domainYMax) : niceDomain(domainYMin - py, domainYMax + py, 5, {
|
|
1390
|
+
dataExtent: [domainYMin, domainYMax],
|
|
1391
|
+
preserveDataSideOfZero: !0,
|
|
1392
|
+
maxWasteFraction: 0.15,
|
|
1393
|
+
maxTotalWasteFraction: 0.2
|
|
1394
|
+
});
|
|
1395
|
+
[dyLo, dyHi] = applyAxisBounds([dyLo, dyHi], [env.log.y ? input.yMin : input.yMin - pyBound, env.log.y ? input.yMax : input.yMax + pyBound], va, warnings), va.includeZero && (dyLo = Math.min(dyLo, 0), dyHi = Math.max(dyHi, 0));
|
|
1396
|
+
let ticks, evenGrid;
|
|
1397
|
+
if (plainDotAxes(input, env)) {
|
|
1398
|
+
let ax = tickAlignedAxis(domainXMin, domainXMax), ay = tickAlignedAxis(va.includeZero ? Math.min(domainYMin, 0) : domainYMin, va.includeZero ? Math.max(domainYMax, 0) : domainYMax);
|
|
1399
|
+
ax && ay && ([dxLo, dxHi] = ax.domain, [dyLo, dyHi] = ay.domain, ticks = { x: ax.ticks, y: ay.ticks });
|
|
1400
|
+
} else if (gridAxes(input, env)) {
|
|
1401
|
+
let grid = options.zones.grid, ex = evenGridDomain(grid.x, input.xMin, input.xMax), ey = evenGridDomain(grid.y, input.yMin, input.yMax);
|
|
1402
|
+
ex && ([dxLo, dxHi] = ex), ey && ([dyLo, dyHi] = ey), evenGrid = { x: ex !== void 0, y: ey !== void 0 };
|
|
1403
|
+
} else if (quadrantAxes(input, env)) {
|
|
1404
|
+
let pad = input.bubbleMode ? BUBBLE_TICK_END_PAD : TICK_END_PAD, from = (lo, hi) => lo >= 0 && lo < ZERO_START_SHARE * hi ? 0 : lo, ax = tickAlignedAxis(from(domainXMin, domainXMax), domainXMax, pad), ay = tickAlignedAxis(from(domainYMin, domainYMax), domainYMax, pad);
|
|
1405
|
+
ax && ay && ([dxLo, dxHi] = ax.domain, [dyLo, dyHi] = ay.domain, ticks = { x: ax.ticks, y: ay.ticks });
|
|
1406
|
+
}
|
|
1407
|
+
[dxLo, dxHi] = numericViewportRange(options.viewDomain?.x, [dxLo, dxHi]), [dyLo, dyHi] = numericViewportRange(options.viewDomain?.y, [dyLo, dyHi]), clamp?.edges.x.min !== void 0 && (dxLo = clamp.edges.x.min), clamp?.edges.x.max !== void 0 && (dxHi = clamp.edges.x.max), clamp?.edges.y.min !== void 0 && (dyLo = clamp.edges.y.min), clamp?.edges.y.max !== void 0 && (dyHi = clamp.edges.y.max);
|
|
1408
|
+
let viewY = options.viewDomain?.y ? [dyLo, dyHi] : void 0;
|
|
1409
|
+
refuseValueLinesOutsideAxis(valueLines, [dyLo, dyHi], viewY ? {} : { min: va.min, max: va.max }, fmt);
|
|
1410
|
+
let annotations = valueLinesInView(options.annotations, valueLines, viewY, warnings, fmt);
|
|
1411
|
+
return { dx: [dxLo, dxHi], dy: [dyLo, dyHi], annotations, ...ticks ? { ticks } : {}, ...evenGrid ? { evenGrid } : {} };
|
|
1412
|
+
}
|
|
1413
|
+
function plainDotAxes(input, env) {
|
|
1414
|
+
let { options, va } = env;
|
|
1415
|
+
return !input.bubbleMode && !(input.clamp && input.clamp.clipped.size > 0) && !env.log.x && !env.log.y && options.viewDomain === void 0 && va.min === void 0 && va.max === void 0 && options.zones === void 0 && options.quadrants === void 0 && options.qualitativeAxes !== !0;
|
|
1416
|
+
}
|
|
1417
|
+
function quadrantAxes(input, env) {
|
|
1418
|
+
let { options, va } = env;
|
|
1419
|
+
return options.quadrants !== void 0 && !(input.clamp && input.clamp.clipped.size > 0) && !env.log.x && !env.log.y && options.viewDomain === void 0 && va.min === void 0 && va.max === void 0 && !va.reverse && options.qualitativeAxes !== !0;
|
|
1420
|
+
}
|
|
1421
|
+
function gridAxes(input, env) {
|
|
1422
|
+
let { options, va } = env;
|
|
1423
|
+
return options.zones !== void 0 && "grid" in options.zones && options.zones.grid !== void 0 && !(input.clamp && input.clamp.clipped.size > 0) && !env.log.x && !env.log.y && options.viewDomain === void 0 && va.min === void 0 && va.max === void 0 && !va.reverse;
|
|
1424
|
+
}
|
|
1425
|
+
var EVEN_CUT_TOLERANCE = 0.02;
|
|
1426
|
+
function evenGridDomain(cuts, dataLo, dataHi) {
|
|
1427
|
+
if (cuts.length === 0) return;
|
|
1428
|
+
let sorted = [...cuts].sort((a, b) => a - b), steps = sorted.slice(1).map((c, i) => c - sorted[i]), step = steps.length ? steps.reduce((a, b) => a + b, 0) / steps.length : void 0;
|
|
1429
|
+
if (step === void 0 || !(step > 0) || steps.some((d) => Math.abs(d - step) > EVEN_CUT_TOLERANCE * step)) return;
|
|
1430
|
+
let unit = 10 ** Math.floor(Math.log10(step)), snap = (v) => {
|
|
1431
|
+
let round = Math.round(v / unit) * unit;
|
|
1432
|
+
return Math.abs(round - v) <= EVEN_CUT_TOLERANCE * step ? Number(round.toPrecision(12)) : v;
|
|
1433
|
+
}, lo = snap(sorted[0] - step), hi = snap(sorted[sorted.length - 1] + step);
|
|
1434
|
+
return dataLo >= lo && dataHi <= hi ? [lo, hi] : void 0;
|
|
1435
|
+
}
|
|
1436
|
+
var ZERO_START_SHARE = 0.2, BUBBLE_TICK_END_PAD = 0.08, TICK_STEP_MANTISSAS = [1, 2, 5], TICK_STEP_COST = 0.01, TICK_END_PAD = 0.03;
|
|
1437
|
+
function tickAlignedAxis(lo, hi, padShare = TICK_END_PAD) {
|
|
1438
|
+
let span = hi - lo;
|
|
1439
|
+
if (!(span > 0) || !Number.isFinite(span)) return;
|
|
1440
|
+
let pad = span * padShare, a = lo >= 0 ? Math.max(0, lo - pad) : lo - pad, b = hi <= 0 ? Math.min(0, hi + pad) : hi + pad, decade = Math.floor(Math.log10(span)), best;
|
|
1441
|
+
for (let e = decade - 2; e <= decade + 1; e++)
|
|
1442
|
+
for (let m of TICK_STEP_MANTISSAS) {
|
|
1443
|
+
let step = m * 10 ** e, sLo = Math.floor(a / step + 1e-9) * step, sHi = Math.ceil(b / step - 1e-9) * step, steps = Math.round((sHi - sLo) / step);
|
|
1444
|
+
if (steps < 5 || steps > 10) continue;
|
|
1445
|
+
let waste = 1 - span / (sHi - sLo) + TICK_STEP_COST * (steps - 5);
|
|
1446
|
+
(!best || waste < best.waste - 1e-9 || Math.abs(waste - best.waste) <= 1e-9 && step > best.step) && (best = { lo: sLo, hi: sHi, step, waste });
|
|
1447
|
+
}
|
|
1448
|
+
if (!best) return;
|
|
1449
|
+
let digits = Math.max(0, -Math.floor(Math.log10(best.step)) + 2), round = (v) => Number(v.toFixed(digits)), count = Math.round((best.hi - best.lo) / best.step);
|
|
1450
|
+
return { domain: [round(best.lo), round(best.hi)], ticks: Array.from({ length: count + 1 }, (_, i) => round(best.lo + i * best.step)) };
|
|
1451
|
+
}
|
|
1452
|
+
function zeroBaselineNotes(dx, dy, fmt, log, options) {
|
|
1453
|
+
let [dxLo, dxHi] = dx, [dyLo, dyHi] = dy, baselineNotes = [], horizontalNonZero = !log.x && (dxLo > 0 || dxHi < 0), verticalNonZero = !log.y && (dyLo > 0 || dyHi < 0);
|
|
1454
|
+
if (horizontalNonZero || verticalNonZero) {
|
|
1455
|
+
let axes = [
|
|
1456
|
+
...horizontalNonZero ? [`x ${numberRange(fmt.x(dxLo), fmt.x(dxHi))}`] : [],
|
|
1457
|
+
...verticalNonZero ? [`y ${numberRange(fmt.y(dyLo), fmt.y(dyHi))}`] : []
|
|
1458
|
+
];
|
|
1459
|
+
baselineNotes.push(disclosureNote(chartString(options, "axesNonzero", { v1: axes.join(", ") })));
|
|
1460
|
+
}
|
|
1461
|
+
return baselineNotes;
|
|
1462
|
+
}
|
|
1463
|
+
function refuseZoneThresholdsOutsideDomain(options, dx, dy) {
|
|
1464
|
+
if (options.zones?.grid) {
|
|
1465
|
+
for (let [axis, thresholds, lo, hi] of [
|
|
1466
|
+
["x", options.zones.grid.x, dx[0], dx[1]],
|
|
1467
|
+
["y", options.zones.grid.y, dy[0], dy[1]]
|
|
1468
|
+
])
|
|
1469
|
+
for (let threshold of thresholds)
|
|
1470
|
+
if (threshold <= lo || threshold >= hi)
|
|
1471
|
+
throw new NormalizeError(
|
|
1472
|
+
"zone-threshold-outside-domain",
|
|
1473
|
+
`options.zones.grid.${axis}`,
|
|
1474
|
+
`strategy-zone threshold ${threshold} must fall strictly inside the plotted ${axis} domain ${lo} to ${hi}`
|
|
1475
|
+
);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function resolveScatterDomain(data, env, warnings) {
|
|
1479
|
+
let { options } = env, { groupMap, plottable, noPosition } = normalizeScatterData(data, warnings), { kept: pts, record: dropped } = applyMinCount(plottable, options.minCount, env.discloseCount, options);
|
|
1480
|
+
refuseNonPositiveOnLog(options, env.log, pts);
|
|
1481
|
+
let clamp = planScatterClamp(
|
|
1482
|
+
pts,
|
|
1483
|
+
{
|
|
1484
|
+
options,
|
|
1485
|
+
clamp: options.valueAxis?.clamp,
|
|
1486
|
+
axisTitles: options.axisTitles ?? {},
|
|
1487
|
+
valueAxisBounds: { min: options.valueAxis?.min, max: options.valueAxis?.max },
|
|
1488
|
+
hasViewDomain: options.viewDomain !== void 0
|
|
1489
|
+
},
|
|
1490
|
+
env.discloseCut
|
|
1491
|
+
), meanY = pts.reduce((a, p) => a + p.y, 0) / pts.length, valueLines = drawnValueLines(options.annotations, meanY);
|
|
1492
|
+
refuseClampedValueLines(clamp, valueLines, env.axisFmt.y);
|
|
1493
|
+
let noPositionNote = noPosition.length === 0 ? void 0 : disclosureNote(chartString(options, "noPositionNote", { v1: chartString(options, "pointsCount", { v1: noPosition.length, v2: noPosition.length === 1 ? "" : "s" }), v2: noPosition.join(", ") })), omitted = [...dropped ? [dropped.note] : [], ...noPositionNote ? [noPositionNote] : []], derivedNotes = [...omitted, ...clamp?.notes ?? []], keptGroups = new Set(pts.map((p) => p.group)), emptied = new Set(dropped ? plottable.map((p) => p.group).filter((g) => !keptGroups.has(g)) : []), shownGroups = [...groupMap.values()].filter((g) => !emptied.has(g.id)), { xMin, xMax, yMin, yMax } = pointExtents(pts), bubbleMode = pts.some((p) => p.size !== null), sizeMax = bubbleMode ? pts.reduce((a, p) => Math.max(a, p.size ?? 0), 0) : void 0, sizeless = bubbleMode ? pts.filter((p) => p.size === null) : [];
|
|
1494
|
+
if (sizeless.length > 0 && warnings.push({
|
|
1495
|
+
code: "size-missing",
|
|
1496
|
+
severity: "warn",
|
|
1497
|
+
message: `bubble chart: point${sizeless.length === 1 ? "" : "s"} ${sizeless.map((p) => `'${p.id}'`).join(", ")} carr${sizeless.length === 1 ? "ies" : "y"} no size and ${sizeless.length === 1 ? "is" : "are"} drawn at the smallest bubble, which reads as a small value`,
|
|
1498
|
+
owner: { pointId: sizeless[0].id },
|
|
1499
|
+
suggest: "give every point a size, or drop size from all points for a plain scatter"
|
|
1500
|
+
}), refuseSizeLegend(options, sizeMax, warnings), validateStrategyZones(options), refuseClampedRegions(clamp, options.zones?.regions), options.zones && options.valueAxis?.reverse)
|
|
1501
|
+
throw new NormalizeError(
|
|
1502
|
+
"zone-scale-unsupported",
|
|
1503
|
+
"options.zones",
|
|
1504
|
+
"strategy zones require non-reversed scatter axes"
|
|
1505
|
+
);
|
|
1506
|
+
let axes = scatterAxisDomain({ xMin, xMax, yMin, yMax, bubbleMode, clamp, valueLines }, env, warnings), baselineNotes = zeroBaselineNotes(axes.dx, axes.dy, env.axisFmt, env.log, env.options);
|
|
1507
|
+
refuseZoneThresholdsOutsideDomain(options, axes.dx, axes.dy);
|
|
1508
|
+
let quadrants = deriveQuadrants(pts, bubbleMode, axes.dx, axes.dy, env, warnings);
|
|
1509
|
+
refuseClampedQuadrants(clamp, pts, quadrants.derived);
|
|
1510
|
+
let q = quadrants.derived, ticks = axes.ticks && q ? {
|
|
1511
|
+
x: withCutTick(axes.ticks.x, quadrants.drawX && q.xSource === "declared" ? q.x : void 0),
|
|
1512
|
+
y: withCutTick(axes.ticks.y, quadrants.drawY && q.ySource === "declared" ? q.y : void 0)
|
|
1513
|
+
} : axes.ticks, drawn = pts.filter((p) => inView(options, axes.dx, axes.dy, p)), trends = fitScatterTrends(env, drawn, shownGroups.map((g) => g.id), warnings), frontier = planFrontier(env, drawn, warnings);
|
|
1514
|
+
return {
|
|
1515
|
+
pts,
|
|
1516
|
+
groups: groupMap,
|
|
1517
|
+
shownGroups,
|
|
1518
|
+
dropped,
|
|
1519
|
+
clamp,
|
|
1520
|
+
meanY,
|
|
1521
|
+
xMin,
|
|
1522
|
+
xMax,
|
|
1523
|
+
yMin,
|
|
1524
|
+
yMax,
|
|
1525
|
+
bubbleMode,
|
|
1526
|
+
sizeMax,
|
|
1527
|
+
dx: axes.dx,
|
|
1528
|
+
dy: axes.dy,
|
|
1529
|
+
...ticks ? { ticks } : {},
|
|
1530
|
+
...axes.evenGrid ? { evenGrid: axes.evenGrid } : {},
|
|
1531
|
+
annotations: axes.annotations,
|
|
1532
|
+
baselineNotes,
|
|
1533
|
+
derivedNotes,
|
|
1534
|
+
omitted,
|
|
1535
|
+
quadrants,
|
|
1536
|
+
trends,
|
|
1537
|
+
...frontier ? { frontier } : {}
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
function withCutTick(ticks, cut) {
|
|
1541
|
+
return cut === void 0 || ticks.some((t) => Math.abs(t - cut) < 1e-9) ? ticks : [...ticks, cut].sort((a, b) => a - b);
|
|
1542
|
+
}
|
|
1543
|
+
function refuseSizeLegend(options, sizeMax, warnings) {
|
|
1544
|
+
if (options.sizeLegend !== !1) {
|
|
1545
|
+
if (sizeMax === void 0 || sizeMax <= 0) {
|
|
1546
|
+
if (!options.sizeLegend) return;
|
|
1547
|
+
throw new NormalizeError(
|
|
1548
|
+
"size-legend-without-sizes",
|
|
1549
|
+
"options.sizeLegend",
|
|
1550
|
+
"options.sizeLegend keys bubble sizes, and no point carries a positive size",
|
|
1551
|
+
"add size to the points, or drop options.sizeLegend",
|
|
1552
|
+
void 0,
|
|
1553
|
+
["options", "sizeLegend"]
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
(typeof options.sizeLegend != "object" || !options.sizeLegend.label) && warnings.push({
|
|
1557
|
+
code: "size-legend-unnamed",
|
|
1558
|
+
severity: "info",
|
|
1559
|
+
message: "the size key shows bubble sizes but not what they measure",
|
|
1560
|
+
suggest: "name the measure with sizeLegend.label, e.g. { label: 'Revenue, \u20ACbn' }",
|
|
1561
|
+
field: ["options", "sizeLegend"]
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
function inView(options, dx, dy, p) {
|
|
1566
|
+
return !options.viewDomain || p.x >= dx[0] && p.x <= dx[1] && p.y >= dy[0] && p.y <= dy[1];
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// src/core/charts/scatter/nameReading.ts
|
|
1570
|
+
function nameReadsAsOwn(rect, leader, own, marks, texts = [], fontSize) {
|
|
1571
|
+
return leader !== void 0 ? !leaderCrosses(leader, own, marks, texts) : nearestIsOwn(inkBox(rect, fontSize), own, marks);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// src/core/charts/scatter/plot.ts
|
|
1575
|
+
var DOT_R = 3.5, DOT_R_SPARSE = 4.5, DOT_R_WIDE = 5.5, WIDE_CARD = 720, DOT_DENSE_COUNT = 20, KEY_DOT_R = 5, MIN_R = 2, MAX_R_FRACTION = 0.065, MAX_R_FRACTION_NARROW = 0.055, SPARSE_BUBBLES = 8, SPARSE_R_FLOOR = 17, SPARSE_R_CAP = 0.08, SPARSE_R_CAP_NARROW_GRID = 0.06, NARROW_PLOT = 420, GRID_ROW_PAD = 10, Y_BAND_SHARE = 0.2;
|
|
1576
|
+
function bandLines(labels, font, measure, maxW) {
|
|
1577
|
+
if (labels.every((label) => measure(label, font).width <= maxW)) return labels.map((label) => [label]);
|
|
1578
|
+
let word = maxOf(labels.flatMap((label) => label.split(/\s+/)).map((w) => measure(w, font).width));
|
|
1579
|
+
return labels.map((label) => {
|
|
1580
|
+
let wrapped = wrapText(label, font, Math.max(word, maxW), 2, measure);
|
|
1581
|
+
return wrapped.truncated ? [label] : wrapped.lines;
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
var CAPTION_TRACKING = 0.5, AXIS_TITLE_RESERVE = 2;
|
|
1585
|
+
function yTitleBand(title, ends, titleFont, tickFont, measure) {
|
|
1586
|
+
let tickH = Math.max(...ends.map((text) => measure(text, tickFont).height));
|
|
1587
|
+
return measure(title, titleFont).height + tickH / 2 + AXIS_TITLE_RESERVE;
|
|
1588
|
+
}
|
|
1589
|
+
function scatterDotRadius(env, domain) {
|
|
1590
|
+
return domain.ticks && domain.pts.length <= DOT_DENSE_COUNT ? env.size.width >= WIDE_CARD ? DOT_R_WIDE : DOT_R_SPARSE : DOT_R;
|
|
1591
|
+
}
|
|
1592
|
+
var LARGE_MARK = 12;
|
|
1593
|
+
function markerSide(marker, r) {
|
|
1594
|
+
return marker === "circle" ? 2 * r : marker === "square" ? 1.8 * r : marker === "triangle" ? 2.2 * r : marker === "diamond" ? 2.6 * r : 0;
|
|
1595
|
+
}
|
|
1596
|
+
function scatterPaints(env, groups, pts = [], dotR) {
|
|
1597
|
+
let { theme, palette, highlights } = env, large = (p) => dotR !== void 0 && p.scenario !== "PL" && p.scenario !== "FC" && markerSide(p.marker, dotR) >= LARGE_MARK, groupLarge = /* @__PURE__ */ new Map();
|
|
1598
|
+
for (let gid of groups.keys()) {
|
|
1599
|
+
let drawn = pts.filter((p) => p.group === gid && p.marker !== "none");
|
|
1600
|
+
groupLarge.set(gid, drawn.length > 0 && drawn.every(large));
|
|
1601
|
+
}
|
|
1602
|
+
let rolePaint = (gid, fill) => {
|
|
1603
|
+
let g = groups.get(gid);
|
|
1604
|
+
return g.colorRole === "others" ? mutedMarkPaint() : g.colorRole ? markRolePaint(g.colorRole, fill) : void 0;
|
|
1605
|
+
}, group = (gid) => {
|
|
1606
|
+
if (gid === void 0) return seriesPaint(0, palette);
|
|
1607
|
+
let g = groups.get(gid);
|
|
1608
|
+
return rolePaint(gid, groupLarge.get(gid) ?? !1) ?? seriesPaint(g.idx, palette);
|
|
1609
|
+
}, highlighted = (p) => highlights.has(p.id) || p.group !== void 0 && highlights.has(p.group), point = (p) => p.fill ? { css: p.fill } : p.group !== void 0 ? (large(p) ? rolePaint(p.group, !0) : void 0) ?? group(p.group) : !p.scenario && groups.size > 0 ? { token: "neutralMark" } : p.scenario ? seriesPaint(0, palette, p.scenario) : group(p.group), hollow = (p) => p.scenario === "PL" || p.scenario === "FC", insideFill = (p) => hollow(p) ? theme.color.background : paintColor(theme, point(p)), recipe = { kind: "focus-apart", apartFrom: [...new Map(pts.map((p) => [JSON.stringify(point(p)), point(p)])).values()] }, ring = { token: paintColor(theme, { token: "ink", theme: recipe }) === theme.color.ink ? "ink" : "focus", theme: recipe };
|
|
1610
|
+
return { group, point, hollow, insideFill, highlighted, ring };
|
|
1611
|
+
}
|
|
1612
|
+
function valueLineLabelRight(env, domain) {
|
|
1613
|
+
let format = env.options.axisFormat?.y ?? env.options.format, fmt = format ? formatterFromExample(format, env.options.locale?.language) : (v) => formatAutomaticNumber(v), font = { family: env.theme.type.family, ...env.theme.type.label }, width = 0;
|
|
1614
|
+
for (let line of drawnValueLines(domain.annotations, domain.meanY)) {
|
|
1615
|
+
let ann = domain.annotations[line.index];
|
|
1616
|
+
if (ann.kind !== "valueLine" || ann.label === !1 || (ann.side ?? "right") !== "right") continue;
|
|
1617
|
+
let text = ann.label ?? (line.isMean ? `\xD8 ${fmt(line.value)}` : fmt(line.value));
|
|
1618
|
+
text && (width = Math.max(width, env.measure(text, font).width + 8));
|
|
1619
|
+
}
|
|
1620
|
+
return width;
|
|
1621
|
+
}
|
|
1622
|
+
function groupKeyShape(domain, gid) {
|
|
1623
|
+
let members = domain.pts.filter((p) => p.group === gid), marker = groupMarker(domain, gid), hollow = members.length > 0 && members.every((p) => p.scenario === "PL" || p.scenario === "FC");
|
|
1624
|
+
return markerKeyShape(marker, hollow);
|
|
1625
|
+
}
|
|
1626
|
+
var groupMarker = (domain, gid) => {
|
|
1627
|
+
let own = domain.groups.get(gid)?.marker;
|
|
1628
|
+
if (own !== void 0 && own !== "none") return own;
|
|
1629
|
+
let members = domain.pts.filter((p) => p.group === gid);
|
|
1630
|
+
return members.length === 0 ? own ?? "circle" : members.find((p) => p.marker !== "none")?.marker ?? "none";
|
|
1631
|
+
};
|
|
1632
|
+
function markerKeyShape(marker, hollow) {
|
|
1633
|
+
return marker === "circle" ? { key: "marker", radius: KEY_DOT_R } : marker === "triangle" ? { key: "triangle" } : marker === "diamond" ? { key: "diamond" } : hollow ? { hollow: !0 } : {};
|
|
1634
|
+
}
|
|
1635
|
+
function pointKeyItems(domain, paints) {
|
|
1636
|
+
let drawn = domain.pts.filter((p) => p.marker !== "none"), odd = drawn.filter((p) => p.group !== void 0 && p.marker !== (domain.groups.get(p.group)?.marker ?? "circle")), loose = drawn.filter((p) => p.group === void 0), item = (p, label) => ({
|
|
1637
|
+
id: `point:${p.id}`,
|
|
1638
|
+
label,
|
|
1639
|
+
paint: paints.point(p),
|
|
1640
|
+
...markerKeyShape(p.marker, paints.hollow(p))
|
|
1641
|
+
});
|
|
1642
|
+
return [
|
|
1643
|
+
...odd.map((p) => item(p, `${domain.groups.get(p.group)?.label ?? p.group}: ${p.label}`)),
|
|
1644
|
+
...loose.length <= 3 ? loose.map((p) => item(p, p.label)) : [item(loose[0], `Without a group: ${loose.map((p) => p.label).join(", ")}`)]
|
|
1645
|
+
];
|
|
1646
|
+
}
|
|
1647
|
+
var UNPINNED_PLOT_BASE = 175, UNPINNED_PLOT_SHARE = 0.225, UNPINNED_PLOT_CAP = 280;
|
|
1648
|
+
function solveScatterFrame(env, domain, paints, keyItems = [], lateNotes = [], hiddenNote) {
|
|
1649
|
+
let { options, theme, size } = env, tokenMargin = canvasMargin(theme, size.width), margin = {
|
|
1650
|
+
...tokenMargin,
|
|
1651
|
+
right: Math.max(tokenMargin.right, valueLineLabelRight(env, domain)),
|
|
1652
|
+
...options.margin
|
|
1653
|
+
}, legendInput, named = options.legend !== void 0, keyedGroups = domain.shownGroups.filter((g) => groupMarker(domain, g.id) !== "none"), groupsKeyed = named && options.legend !== "none" && keyedGroups.length > 0;
|
|
1654
|
+
if (options.legend !== "none" && (groupsKeyed || keyItems.length > 0)) {
|
|
1655
|
+
let legendOpts = (named ? normalizeLegendOption(options.legend) : void 0) ?? { position: "top" }, items = groupsKeyed ? [...keyedGroups.map((g) => ({
|
|
1656
|
+
id: g.id,
|
|
1657
|
+
label: g.label,
|
|
1658
|
+
paint: paints.group(g.id),
|
|
1659
|
+
...groupKeyShape(domain, g.id)
|
|
1660
|
+
})), ...pointKeyItems(domain, paints)] : [];
|
|
1661
|
+
if (legendOpts.order) {
|
|
1662
|
+
let oi = (id) => {
|
|
1663
|
+
let k = legendOpts.order.indexOf(id);
|
|
1664
|
+
return k === -1 ? Number.MAX_SAFE_INTEGER : k;
|
|
1665
|
+
};
|
|
1666
|
+
items = [...items].sort((a, b) => oi(a.id) - oi(b.id));
|
|
1667
|
+
}
|
|
1668
|
+
legendInput = { options: legendOpts, items: [...items, ...keyItems] };
|
|
1669
|
+
}
|
|
1670
|
+
let claims = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height });
|
|
1671
|
+
return { frame: solveFrame(
|
|
1672
|
+
{
|
|
1673
|
+
size,
|
|
1674
|
+
margin,
|
|
1675
|
+
...frameTextOptions(options),
|
|
1676
|
+
footnotes: [
|
|
1677
|
+
...options.methodNote === !0 ? [...domain.baselineNotes, ...domain.quadrants.notes] : [],
|
|
1678
|
+
...domain.derivedNotes,
|
|
1679
|
+
...lateNotes,
|
|
1680
|
+
...hiddenNote?.footnotes ?? authoredNotes(options),
|
|
1681
|
+
...hiddenNote?.line ?? []
|
|
1682
|
+
],
|
|
1683
|
+
legend: legendInput,
|
|
1684
|
+
theme,
|
|
1685
|
+
measure: env.measure
|
|
1686
|
+
},
|
|
1687
|
+
claims
|
|
1688
|
+
), claims };
|
|
1689
|
+
}
|
|
1690
|
+
var QUALITATIVE_GAP = 8;
|
|
1691
|
+
function qualitativeColumn(env, fonts, plotW) {
|
|
1692
|
+
let strings = env.options.strings, low = strings?.axisLow ?? "Lower", high = strings?.axisHigh ?? "Higher", bold = fonts.axisTitle, ends = Math.max(env.measure(low, fonts.tick).width, env.measure(high, fonts.tick).width), title = env.options.axisTitles?.y ?? "", width = Math.max(ends, Math.min(env.measure(title, bold).width, Math.max(ends, plotW * 0.1))), lines = title ? wrapText(title, bold, width, 4, env.measure).lines : [];
|
|
1693
|
+
return { width: Math.max(width, ...lines.map((line) => env.measure(line, bold).width)), lines, low, high };
|
|
1694
|
+
}
|
|
1695
|
+
function scatterFonts(theme) {
|
|
1696
|
+
return {
|
|
1697
|
+
tick: { family: theme.type.family, ...theme.type.axis },
|
|
1698
|
+
label: {
|
|
1699
|
+
family: theme.type.family,
|
|
1700
|
+
...theme.type.label
|
|
1701
|
+
},
|
|
1702
|
+
// A quadrant caption names a REGION of the plot; a point label names one
|
|
1703
|
+
// unit. Set in the same face they were indistinguishable, and a reader counts
|
|
1704
|
+
// "Stars" as a sixth company. So the caption takes the repo's region-furniture
|
|
1705
|
+
// register — the same one band annotations already use (`annotate.ts`
|
|
1706
|
+
// uppercase at axis size) and table headers use (uppercase, regular, tracked):
|
|
1707
|
+
// uppercase, axis size, regular, tracked, muted ink. Four signals, each
|
|
1708
|
+
// legible on its own at 96 dpi, none of them a color a reader must decode.
|
|
1709
|
+
caption: {
|
|
1710
|
+
family: theme.type.family,
|
|
1711
|
+
...theme.type.axis,
|
|
1712
|
+
weight: theme.type.axis.weight,
|
|
1713
|
+
letterSpacing: CAPTION_TRACKING
|
|
1714
|
+
},
|
|
1715
|
+
// Axis titles: the x title sits centred under the tick row, the y title
|
|
1716
|
+
// reads horizontally above the axis column (no rotated text on an exhibit).
|
|
1717
|
+
axisTitle: { family: theme.type.family, ...theme.type.axis }
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
function scatterPlotArea(env, domain, frame, warnings) {
|
|
1721
|
+
let { options, theme, measure, va } = env, fmt = env.axisFmt.y, [dxLo, dxHi] = domain.dx, [dyLo, dyHi] = domain.dy, fonts = scatterFonts(theme), showAxes = va.show ?? !0, tickH = measure("0", fonts.tick).height, zoneGrid = options.zones && "grid" in options.zones ? options.zones.grid : void 0, banded = bandedAxes(env, domain), yBandLines = zoneGrid?.yLabels?.length ? bandLines(zoneGrid.yLabels, fonts.tick, measure, Y_BAND_SHARE * frame.plot.w) : void 0, yBandW = yBandLines ? maxOf(yBandLines.flat().map((line) => measure(line, fonts.tick).width)) + ZONE_BAND_GAP : 0, yFmt = env.log.y ? logSpecFormat(env.axisSpec.y) : fmt, axisTitles = options.axisTitles ?? {}, qualitative = showAxes && options.qualitativeAxes === !0, yAxisW = qualitative ? qualitativeColumn(env, fonts, frame.plot.w).width + QUALITATIVE_GAP : showAxes && !banded.y ? measureValueAxisWidth([dyLo, dyHi], yFmt, theme, measure, 5, env.log.y ? void 0 : env.axisSpec.y, env.log.y ? logTickTiers(dyLo, dyHi)[0] : void 0) : 0, xAxisH = showAxes && !banded.x ? tickH + 6 : 0, xTitleH = showAxes && axisTitles.x && !qualitative ? tickH + 4 : 0, yTitleH = showAxes && axisTitles.y && !qualitative ? banded.y ? measure(axisTitles.y, fonts.axisTitle).height + AXIS_TITLE_RESERVE : yTitleBand(axisTitles.y, ["0", yFmt(dyLo), yFmt(dyHi)], fonts.axisTitle, fonts.tick, measure) : 0;
|
|
1722
|
+
showAxes && (!axisTitles.x || !axisTitles.y) && warnings.push({
|
|
1723
|
+
code: "scatter-axis-untitled",
|
|
1724
|
+
severity: "warn",
|
|
1725
|
+
message: "scatter axes without titles: the reader has to guess which axis is which",
|
|
1726
|
+
suggest: "set axisTitles: { x: '...', y: '...' } (the subtitle measure names the pair, not the sides)"
|
|
1727
|
+
});
|
|
1728
|
+
for (let axis of ["x", "y"]) {
|
|
1729
|
+
let title = axisTitles[axis];
|
|
1730
|
+
!showAxes || !env.log[axis] || !title || /\blog/i.test(title) || warnings.push({
|
|
1731
|
+
code: "log-axis-unnamed",
|
|
1732
|
+
severity: "info",
|
|
1733
|
+
message: `the ${axis === "x" ? "horizontal" : "vertical"} axis is on a log scale and its title does not say so`,
|
|
1734
|
+
suggest: `add it to the title, e.g. axisTitles.${axis}: '${title}, log scale'`,
|
|
1735
|
+
field: ["options", "axisTitles", axis]
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
let plotX = frame.plot.x + yBandW + yAxisW, plotW = Math.max(10, frame.plot.w - yBandW - yAxisW), x = (env.log.x ? logScale : linearScale)([dxLo, dxHi], [plotX, plotX + plotW]), xBounds = zoneGrid ? [dxLo, ...zoneGrid.x, dxHi] : [], xBandLines = zoneGrid?.xLabels?.length ? zoneGrid.xLabels.map((label, i) => bandLines([label], fonts.tick, measure, Math.abs(x(xBounds[i + 1] ?? dxHi) - x(xBounds[i] ?? dxLo)) - 2 * ZONE_BAND_GAP)[0]) : void 0, xBandH = xBandLines ? maxOf(xBandLines.map((lines) => lines.length)) * tickH + ZONE_BAND_GAP : 0, plot = {
|
|
1739
|
+
x: plotX,
|
|
1740
|
+
y: frame.plot.y + 8 + yTitleH,
|
|
1741
|
+
w: plotW,
|
|
1742
|
+
h: plotHeightAfter(frame, env.size.height, frame.plot.h - 8 - yTitleH - xAxisH - xTitleH - xBandH)
|
|
1743
|
+
}, yScale = env.log.y ? logScale : linearScale, y = va.reverse ? yScale([dyLo, dyHi], [plot.y, plot.y + plot.h]) : yScale([dyLo, dyHi], [plot.y + plot.h, plot.y]), labelH = measure("0", fonts.label).height, minPlot = Math.max(plotFloorRows(options) * labelH + 8, atHardMinimum(options) ? HARD_COMPACT_PLOT : 0);
|
|
1744
|
+
if (domain.quadrants.derived && options.quadrants?.labels) {
|
|
1745
|
+
let split = yScale([dyLo, dyHi], [0, 1])(domain.quadrants.derived.y), shares = [split, 1 - split].filter((share) => share > 0 && share < 1);
|
|
1746
|
+
shares.length && (minPlot = Math.max(
|
|
1747
|
+
minPlot,
|
|
1748
|
+
(2 * fonts.caption.size * (fonts.caption.lineHeight ?? 1.2) + 12 + labelH + 4) / Math.min(...shares)
|
|
1749
|
+
));
|
|
1750
|
+
}
|
|
1751
|
+
if (zoneGrid) {
|
|
1752
|
+
let captionH = fonts.caption.size * (fonts.caption.lineHeight ?? 1.2);
|
|
1753
|
+
minPlot = Math.max(minPlot, (zoneGrid.y.length + 1) * (captionH + labelH + GRID_ROW_PAD));
|
|
1754
|
+
}
|
|
1755
|
+
let rawHeight = frame.plot.h - 8 - yTitleH - xAxisH - xTitleH - xBandH, wish = Math.min(UNPINNED_PLOT_CAP, Math.round(UNPINNED_PLOT_BASE + UNPINNED_PLOT_SHARE * plotW));
|
|
1756
|
+
options[TARGET_SIZE]?.fixed.height === !1 && panelTypeClass(options) === void 0 && rawHeight < wish && (minPlot = Math.max(minPlot, wish)), frame.frame.plotMinHeight = Math.max(
|
|
1757
|
+
frame.frame.plotMinHeight ?? 0,
|
|
1758
|
+
env.size.height + (frame.deficit ?? 0) + minPlot - rawHeight
|
|
1759
|
+
);
|
|
1760
|
+
let rFraction = plot.w < NARROW_PLOT ? MAX_R_FRACTION_NARROW : MAX_R_FRACTION, { bubbleMode, sizeMax } = domain, plotMin = Math.min(plot.w, plot.h), boxGrid = domain.quadrants.derived !== void 0 || zoneGrid !== void 0, cap = zoneGrid !== void 0 && plot.w < NARROW_PLOT ? SPARSE_R_CAP_NARROW_GRID : SPARSE_R_CAP, sparseFloor = bubbleMode && boxGrid && domain.pts.length <= SPARSE_BUBBLES ? Math.min(SPARSE_R_FLOOR, cap * plotMin) : 0, rMax = Math.max(MIN_R + 2, rFraction * plotMin, sparseFloor), sizeBy = options.sizeBy ?? "area", dotR = scatterDotRadius(env, domain), radiusOf = (p) => {
|
|
1761
|
+
if (!bubbleMode) return dotR;
|
|
1762
|
+
if (p.size === null || sizeMax === void 0 || sizeMax <= 0) return MIN_R + 0.5;
|
|
1763
|
+
let frac = p.size / sizeMax;
|
|
1764
|
+
return frac <= 0 ? MIN_R : Math.max(MIN_R, sizeBy === "diameter" ? frac * rMax : Math.sqrt(frac) * rMax);
|
|
1765
|
+
};
|
|
1766
|
+
return {
|
|
1767
|
+
plot,
|
|
1768
|
+
inner: frame.plot,
|
|
1769
|
+
fonts,
|
|
1770
|
+
showAxes,
|
|
1771
|
+
qualitative,
|
|
1772
|
+
axisTitles,
|
|
1773
|
+
xAxisH,
|
|
1774
|
+
yAxisW,
|
|
1775
|
+
xBandH,
|
|
1776
|
+
yBandW,
|
|
1777
|
+
...xBandLines ? { xBandLines } : {},
|
|
1778
|
+
...yBandLines ? { yBandLines } : {},
|
|
1779
|
+
x,
|
|
1780
|
+
y,
|
|
1781
|
+
radiusOf
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
// src/core/charts/scatter/marks.ts
|
|
1786
|
+
var HIGHLIGHT_RING_GAP = 4, BUBBLE_RING_GAP = 3, BUBBLE_X_TICKS = 8, X_TICK_MARK = 4, BUBBLE_OUTLINE_MIN_R = 8;
|
|
1787
|
+
function sizeMarkerOf(p) {
|
|
1788
|
+
return p.sizeInvalid ? "invalid" : p.size === null ? "missing" : p.size === 0 ? "zero" : void 0;
|
|
1789
|
+
}
|
|
1790
|
+
function sizeMarkerNode(theme, kind, input) {
|
|
1791
|
+
let { id, cx, cy, owner, display, paint } = input, r = Math.max(3.5, input.r + 1);
|
|
1792
|
+
if (kind === "zero") return { t: "circle", id, cx, cy, r, fill: { token: "background" }, stroke: paint, strokeWidth: strokeToken(theme, "mark"), owner, part: "point", display };
|
|
1793
|
+
let k = kind === "invalid" ? r * Math.SQRT1_2 : r, d = kind === "invalid" ? `M${fmtPathNumber(cx - k)} ${fmtPathNumber(cy - k)}L${fmtPathNumber(cx + k)} ${fmtPathNumber(cy + k)}M${fmtPathNumber(cx - k)} ${fmtPathNumber(cy + k)}L${fmtPathNumber(cx + k)} ${fmtPathNumber(cy - k)}` : `M${fmtPathNumber(cx - k)} ${fmtPathNumber(cy)}H${fmtPathNumber(cx + k)}M${fmtPathNumber(cx)} ${fmtPathNumber(cy - k)}V${fmtPathNumber(cy + k)}`;
|
|
1794
|
+
return { t: "path", id, d, stroke: paint, width: strokeToken(theme, "mark"), owner, part: "point", display };
|
|
1795
|
+
}
|
|
1796
|
+
function pointMarkNode(theme, input) {
|
|
1797
|
+
let { id, marker, cx, cy, r, owner, display } = input, shared = { id, owner, part: "point", display }, side = r * 1.8, d = marker === "circle" ? `M${fmtPathNumber(cx - r)} ${fmtPathNumber(cy)}A${fmtPathNumber(r)} ${fmtPathNumber(r)} 0 1 0 ${fmtPathNumber(cx + r)} ${fmtPathNumber(cy)}A${fmtPathNumber(r)} ${fmtPathNumber(r)} 0 1 0 ${fmtPathNumber(cx - r)} ${fmtPathNumber(cy)}Z` : marker === "square" ? `M${fmtPathNumber(cx - side / 2)} ${fmtPathNumber(cy - side / 2)}H${fmtPathNumber(cx + side / 2)}V${fmtPathNumber(cy + side / 2)}H${fmtPathNumber(cx - side / 2)}Z` : marker === "triangle" ? `M${fmtPathNumber(cx)} ${fmtPathNumber(cy - r * 1.2)}L${fmtPathNumber(cx + r * 1.15)} ${fmtPathNumber(cy + r)}L${fmtPathNumber(cx - r * 1.15)} ${fmtPathNumber(cy + r)}Z` : `M${fmtPathNumber(cx)} ${fmtPathNumber(cy - r * 1.3)}L${fmtPathNumber(cx + r * 1.3)} ${fmtPathNumber(cy)}L${fmtPathNumber(cx)} ${fmtPathNumber(cy + r * 1.3)}L${fmtPathNumber(cx - r * 1.3)} ${fmtPathNumber(cy)}Z`;
|
|
1798
|
+
if (input.clipped)
|
|
1799
|
+
return { t: "path", ...shared, d, stroke: input.paint, width: strokeToken(theme, "mark"), dash: dashToken(theme, "dotted"), lineCap: "round" };
|
|
1800
|
+
let fill = input.hollow ? { token: "background" } : input.paint, stroke = input.hollow ? input.paint : void 0;
|
|
1801
|
+
return marker === "circle" ? { t: "circle", ...shared, cx, cy, r, fill, ...stroke ? { stroke, strokeWidth: strokeToken(theme, "mark") } : { stroke: { token: "background" }, strokeWidth: strokeToken(theme, "rule") } } : marker === "square" ? {
|
|
1802
|
+
t: "rect",
|
|
1803
|
+
...shared,
|
|
1804
|
+
rect: { x: cx - side / 2, y: cy - side / 2, w: side, h: side },
|
|
1805
|
+
...input.hollow ? { fill: input.paint, pattern: "hollow" } : { fill }
|
|
1806
|
+
} : { t: "path", ...shared, d, fill, ...stroke ? { stroke, width: strokeToken(theme, "mark") } : {} };
|
|
1807
|
+
}
|
|
1808
|
+
function scatterAxes(env, domain, area, nodes, claims) {
|
|
1809
|
+
let { theme, measure, axisFmt, va } = env, { plot, x, y, axisTitles, fonts } = area, axes = [];
|
|
1810
|
+
if (!area.showAxes) return axes;
|
|
1811
|
+
if (area.qualitative)
|
|
1812
|
+
return qualitativeAxes(env, area, nodes, claims), axes;
|
|
1813
|
+
let ticksOf = (scale, orient) => {
|
|
1814
|
+
let spec = env.axisSpec[orient];
|
|
1815
|
+
if (!scale.log) return { format: axisFmt[orient], formatSpec: spec, ...domain.ticks ? { ticks: domain.ticks[orient], ...domain.quadrants.derived ? { keepEndTicks: !0 } : {} } : {} };
|
|
1816
|
+
let tickFmt = logSpecFormat(spec);
|
|
1817
|
+
return { format: tickFmt, ticks: fitLogTicks(scale, orient, tickFmt, fonts.tick, measure) };
|
|
1818
|
+
}, banded = bandedAxes(env, domain), bandless = (axis, orient) => {
|
|
1819
|
+
if (!banded[orient]) return axis;
|
|
1820
|
+
let labels = new Set(axis.axis.ticks.map((t) => t.labelId));
|
|
1821
|
+
return { ...axis, nodes: axis.nodes.filter((n) => !(n.t === "text" && labels.has(n.id))), axis: { ...axis.axis, ticks: axis.axis.ticks.map(({ labelId: _label, ...t }) => t) } };
|
|
1822
|
+
}, scratch = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), yAxis = bandless(layoutValueAxis(
|
|
1823
|
+
// A dot scatter whose axes end on ticks draws a light rule at each y tick.
|
|
1824
|
+
{ scale: y, plot, orient: "y", gridlines: va.gridlines ?? tickGrid(domain), ...ticksOf(y, "y"), theme, measure },
|
|
1825
|
+
banded.y ? scratch : claims
|
|
1826
|
+
), "y");
|
|
1827
|
+
nodes.push(...yAxis.nodes), axes.push(yAxis.axis);
|
|
1828
|
+
let grid = env.options.zones !== void 0 && "grid" in env.options.zones, xAxis = bandless(layoutValueAxis(
|
|
1829
|
+
{ scale: x, plot, orient: "x", gridlines: va.gridlines ?? !1, ...ticksOf(x, "x"), ...domain.bubbleMode && !grid ? { tickCount: BUBBLE_X_TICKS } : {}, theme, measure, canvasWidth: env.size.width },
|
|
1830
|
+
banded.x ? scratch : claims
|
|
1831
|
+
), "x");
|
|
1832
|
+
if (nodes.push(...xAxis.nodes), axes.push(xAxis.axis), axisTitles.x) {
|
|
1833
|
+
let size = measure(axisTitles.x, fonts.axisTitle), rect = { x: plot.x + plot.w / 2 - size.width / 2, y: plot.y + plot.h + area.xAxisH + area.xBandH + 2, w: size.width, h: size.height };
|
|
1834
|
+
nodes.push({ t: "text", id: "axis:x:title", x: plot.x + plot.w / 2, y: rect.y, lines: [axisTitles.x], align: "middle", typeRole: "secondary", font: secondaryFont(env.theme), ink: { token: "ink" }, owner: {}, part: "axisTitle" }), claims.claim(rect, "axis", {}, "axisTitle");
|
|
1835
|
+
}
|
|
1836
|
+
if (axisTitles.y) {
|
|
1837
|
+
let size = measure(axisTitles.y, fonts.axisTitle), rect = { x: plot.x - area.yAxisW - (banded.y ? area.yBandW : 0), y: area.inner.y + 8, w: size.width, h: size.height };
|
|
1838
|
+
nodes.push({ t: "text", id: "axis:y:title", x: rect.x, y: rect.y, lines: [axisTitles.y], align: "start", typeRole: "secondary", font: secondaryFont(env.theme), ink: { token: "ink" }, owner: {}, part: "axisTitle" }), claims.claim(rect, "axis", {}, "axisTitle");
|
|
1839
|
+
}
|
|
1840
|
+
let axisInk = grid ? { token: "axis" } : { token: "inkMuted" }, frameLine = (id, x1, y1, x2, y2) => ({ t: "line", id, x1, y1, x2, y2, stroke: axisInk, width: strokeToken(theme, "rule"), owner: {}, part: "axisLine" });
|
|
1841
|
+
if (banded.x || (nodes.push(frameLine("axis:x:line", plot.x, plot.y + plot.h, plot.x + plot.w, plot.y + plot.h)), claims.claim({ x: plot.x, y: plot.y + plot.h - 1, w: plot.w, h: 2 }, "axis", {})), !grid)
|
|
1842
|
+
for (let tick of xAxis.axis.ticks)
|
|
1843
|
+
typeof tick.at == "number" && nodes.push({ t: "line", id: `axis:x:tickMark:${tick.at}`, x1: tick.pos, y1: plot.y + plot.h, x2: tick.pos, y2: plot.y + plot.h + X_TICK_MARK, stroke: axisInk, width: strokeToken(theme, "rule"), owner: {}, part: "tickMark" });
|
|
1844
|
+
return !banded.y && !(tickGrid(domain) && (va.gridlines ?? !0)) && (nodes.push(frameLine("axis:y:line", plot.x, plot.y, plot.x, plot.y + plot.h)), claims.claim({ x: plot.x - 1, y: plot.y, w: 2, h: plot.h }, "axis", {})), axes;
|
|
1845
|
+
}
|
|
1846
|
+
function tickGrid(domain) {
|
|
1847
|
+
return domain.ticks !== void 0 && domain.quadrants.derived === void 0;
|
|
1848
|
+
}
|
|
1849
|
+
function cutTickLabels(env, domain, axes, nodes) {
|
|
1850
|
+
let decimal2 = formatAutomaticNumber(1.5, { locale: env.options.locale?.language, decimals: 1 }).replace(/\d/g, ""), q = domain.quadrants.derived;
|
|
1851
|
+
if (!q || !domain.ticks) return {};
|
|
1852
|
+
let found = {};
|
|
1853
|
+
for (let axis of axes) {
|
|
1854
|
+
let orient = axis.axis === "x" ? "x" : "y", drawn = orient === "x" ? domain.quadrants.drawX : domain.quadrants.drawY, source = orient === "x" ? q.xSource : q.ySource;
|
|
1855
|
+
if (!drawn || source !== "declared") continue;
|
|
1856
|
+
let cut = q[orient], tick = axis.ticks.find((t) => typeof t.at == "number" && Math.abs(t.at - cut) < 1e-9), node = tick?.labelId === void 0 ? void 0 : nodes.find((n) => n.t === "text" && n.id === tick.labelId);
|
|
1857
|
+
node?.t === "text" && node.lines.length === 1 && samePrintedNumber(node.lines[0], orient === "x" ? q.xText : q.yText, decimal2) && (found[orient] = node.id);
|
|
1858
|
+
}
|
|
1859
|
+
return found;
|
|
1860
|
+
}
|
|
1861
|
+
function samePrintedNumber(a, b, decimal2) {
|
|
1862
|
+
let mark = decimal2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), trim = (text) => text.replace(new RegExp(`(${mark}\\d*?)0+(?!\\d)`, "g"), "$1").replace(new RegExp(`${mark}(?!\\d)`, "g"), "");
|
|
1863
|
+
return a === b || decimal2.length === 1 && trim(a) === trim(b);
|
|
1864
|
+
}
|
|
1865
|
+
function boldCutTicks(env, domain, axes, nodes) {
|
|
1866
|
+
let found = cutTickLabels(env, domain, axes, nodes), ids = new Set(Object.values(found));
|
|
1867
|
+
return nodes.forEach((node, i) => {
|
|
1868
|
+
node.t === "text" && ids.has(node.id) && (nodes[i] = { ...node, font: { ...node.font, weight: emphasisWeight(env.theme) } });
|
|
1869
|
+
}), { x: found.x !== void 0, y: found.y !== void 0 };
|
|
1870
|
+
}
|
|
1871
|
+
function arrow(theme, id, x1, y1, x2, y2) {
|
|
1872
|
+
let len = Math.hypot(x2 - x1, y2 - y1);
|
|
1873
|
+
if (len < ARROW_HEAD * 2) return [];
|
|
1874
|
+
let ux = (x2 - x1) / len, uy = (y2 - y1) / len, bx = x2 - ux * ARROW_HEAD, by = y2 - uy * ARROW_HEAD, half = ARROW_HEAD * 0.55;
|
|
1875
|
+
return [
|
|
1876
|
+
{ t: "line", id, x1, y1, x2: bx, y2: by, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner: {}, part: "axisArrow" },
|
|
1877
|
+
{ t: "path", id: `${id}:head`, d: `M${fmtPathNumber(x2)} ${fmtPathNumber(y2)}L${fmtPathNumber(bx - uy * half)} ${fmtPathNumber(by + ux * half)}L${fmtPathNumber(bx + uy * half)} ${fmtPathNumber(by - ux * half)}Z`, fill: { token: "axis" }, owner: {}, part: "axisArrow" }
|
|
1878
|
+
];
|
|
1879
|
+
}
|
|
1880
|
+
var ARROW_HEAD = 7;
|
|
1881
|
+
function qualitativeAxes(env, area, nodes, claims) {
|
|
1882
|
+
let { measure } = env, { plot, fonts, axisTitles } = area, column = qualitativeColumn(env, fonts, area.inner.w), bold = fonts.axisTitle, gap = env.theme.space.labelPad * 2, text = (id, x, y, lines, align, font) => {
|
|
1883
|
+
let w = Math.max(...lines.map((line) => measure(line, font).width)), h = lines.length * font.size * (font.lineHeight ?? 1.2);
|
|
1884
|
+
nodes.push({ t: "text", id, x, y, lines, align, typeRole: "axis", font, ink: { token: "ink" }, owner: {}, ...id.endsWith(":title") ? { part: "axisTitle" } : { part: "axisEnd", role: "axis" } }), claims.claim({ x: align === "start" ? x : align === "end" ? x - w : x - w / 2, y, w, h }, "axis", {}, "axisTitle");
|
|
1885
|
+
}, lineH = (font) => font.size * (font.lineHeight ?? 1.2), rowY = plot.y + plot.h + 6, midY = rowY + lineH(fonts.tick) / 2, lowW = measure(column.low, fonts.tick).width, highW = measure(column.high, fonts.tick).width, cx = plot.x + plot.w / 2;
|
|
1886
|
+
text("axis:x:low", plot.x, rowY, [column.low], "start", fonts.tick), text("axis:x:high", plot.x + plot.w, rowY, [column.high], "end", fonts.tick);
|
|
1887
|
+
let titleW = axisTitles.x ? measure(axisTitles.x, bold).width : 0;
|
|
1888
|
+
axisTitles.x && text("axis:x:title", cx, rowY, [axisTitles.x], "middle", bold), nodes.push(...arrow(env.theme, "axis:x:arrow-low", cx - titleW / 2 - gap, midY, plot.x + lowW + gap, midY)), nodes.push(...arrow(env.theme, "axis:x:arrow-high", cx + titleW / 2 + gap, midY, plot.x + plot.w - highW - gap, midY));
|
|
1889
|
+
let colX = plot.x - QUALITATIVE_GAP - column.width / 2, tickH = lineH(fonts.tick), topY = plot.y, bottomY = plot.y + plot.h - tickH, [highY, lowY] = env.va.reverse ? [bottomY, topY] : [topY, bottomY];
|
|
1890
|
+
text("axis:y:high", colX, highY, [column.high], "middle", fonts.tick), text("axis:y:low", colX, lowY, [column.low], "middle", fonts.tick);
|
|
1891
|
+
let titleH = column.lines.length * lineH(bold), titleY = plot.y + plot.h / 2 - titleH / 2;
|
|
1892
|
+
column.lines.length && text("axis:y:title", colX, titleY, column.lines, "middle", bold);
|
|
1893
|
+
let toTop = arrow(env.theme, env.va.reverse ? "axis:y:arrow-low" : "axis:y:arrow-high", colX, titleY - gap, colX, plot.y + tickH + gap), toBottom = arrow(env.theme, env.va.reverse ? "axis:y:arrow-high" : "axis:y:arrow-low", colX, titleY + titleH + gap, colX, plot.y + plot.h - tickH - gap);
|
|
1894
|
+
nodes.push(...toTop, ...toBottom);
|
|
1895
|
+
let frameLine = (id, x1, y1, x2, y2) => ({ t: "line", id, x1, y1, x2, y2, stroke: { token: "axis" }, width: strokeToken(env.theme, "rule"), owner: {}, part: "axisLine" });
|
|
1896
|
+
nodes.push(
|
|
1897
|
+
frameLine("axis:x:line", plot.x, plot.y + plot.h, plot.x + plot.w, plot.y + plot.h),
|
|
1898
|
+
frameLine("axis:y:line", plot.x, plot.y, plot.x, plot.y + plot.h),
|
|
1899
|
+
frameLine("axis:top:line", plot.x, plot.y, plot.x + plot.w, plot.y),
|
|
1900
|
+
frameLine("axis:right:line", plot.x + plot.w, plot.y, plot.x + plot.w, plot.y + plot.h)
|
|
1901
|
+
), claims.claim({ x: plot.x, y: plot.y + plot.h - 1, w: plot.w, h: 2 }, "axis", {}), claims.claim({ x: plot.x - 1, y: plot.y, w: 2, h: plot.h }, "axis", {}), claims.claim({ x: plot.x, y: plot.y - 1, w: plot.w, h: 2 }, "axis", {}), claims.claim({ x: plot.x + plot.w - 1, y: plot.y, w: 2, h: plot.h }, "axis", {});
|
|
1902
|
+
}
|
|
1903
|
+
function quadrantBoxRect(box, plot, split) {
|
|
1904
|
+
return {
|
|
1905
|
+
x: box === "tl" || box === "bl" ? plot.x : split.x,
|
|
1906
|
+
y: box === "tl" || box === "tr" ? plot.y : split.y,
|
|
1907
|
+
w: box === "tl" || box === "bl" ? split.x - plot.x : plot.x + plot.w - split.x,
|
|
1908
|
+
h: box === "tl" || box === "tr" ? split.y - plot.y : plot.y + plot.h - split.y
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
var QUADRANT_TINT = 0.65, DIVIDER_TINT = 0.12;
|
|
1912
|
+
function quadrantTint(plot, split, nodes) {
|
|
1913
|
+
let wash = { token: "neutralLight", tint: QUADRANT_TINT };
|
|
1914
|
+
for (let box of ["tl", "br"]) {
|
|
1915
|
+
let rect = quadrantBoxRect(box, plot, split);
|
|
1916
|
+
rect.w <= 0 || rect.h <= 0 || nodes.push({ t: "rect", id: `quadrant:tint:${box}`, rect, fill: wash, owner: {}, part: "quadrantTint" });
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
function zeroLines(theme, domain, area, nodes, claims) {
|
|
1920
|
+
let { plot, x, y } = area, q = domain.quadrants, [dxLo, dxHi] = domain.dx, [dyLo, dyHi] = domain.dy, rule = (id, x1, y1, x2, y2) => (
|
|
1921
|
+
// Solid and light: a zero line is scaffolding, apart from the dashed reference lines (value lines, trends).
|
|
1922
|
+
{ t: "line", id, x1, y1, x2, y2, stroke: { token: "neutralLight" }, width: strokeToken(theme, "rule"), owner: {}, part: "zeroLine" }
|
|
1923
|
+
);
|
|
1924
|
+
if (dxLo < 0 && dxHi > 0 && !(q.drawX && q.derived.x === 0)) {
|
|
1925
|
+
let zx = x(0);
|
|
1926
|
+
nodes.push(rule("axis:x:zero", zx, plot.y, zx, plot.y + plot.h)), claims.claim({ x: zx - 1, y: plot.y, w: 2, h: plot.h }, "axis", {}, "referenceLine");
|
|
1927
|
+
}
|
|
1928
|
+
if (dyLo < 0 && dyHi > 0 && !(q.drawY && q.derived.y === 0)) {
|
|
1929
|
+
let zy = y(0);
|
|
1930
|
+
nodes.push(rule("axis:y:zero", plot.x, zy, plot.x + plot.w, zy)), claims.claim({ x: plot.x, y: zy - 1, w: plot.w, h: 2 }, "axis", {}, "referenceLine");
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
var DENSE_POINTS = 5e3, DENSE_ROW = 8;
|
|
1934
|
+
function denseDots(theme, domain, paints, drawOrder) {
|
|
1935
|
+
if (domain.bubbleMode || drawOrder.length <= DENSE_POINTS) return;
|
|
1936
|
+
let runs = /* @__PURE__ */ new Map(), drawn = /* @__PURE__ */ new Map(), halo = strokeToken(theme, "rule") / 2;
|
|
1937
|
+
for (let { p, cx, cy, r } of drawOrder) {
|
|
1938
|
+
if (p.marker !== "circle" || paints.hollow(p) || paints.highlighted(p) || clampStateOf(domain.clamp, p.id) !== void 0) continue;
|
|
1939
|
+
let paint = paints.point(p), key = `${JSON.stringify(paint)}\0${r}`, run = runs.get(key);
|
|
1940
|
+
run || runs.set(key, run = { paint, r: Math.max(r - halo, 0.5), dots: [] }), run.dots.push({ x: Math.round((cx - run.r) * 100), y: Math.round(cy * 100), idx: p.idx, p });
|
|
1941
|
+
}
|
|
1942
|
+
return runs.size === 0 ? void 0 : { nodes: [...runs.values()].sort((a, b) => b.dots.length - a.dots.length).map(({ paint, r, dots }, k) => {
|
|
1943
|
+
let row = (y2) => Math.floor(y2 / (DENSE_ROW * 100));
|
|
1944
|
+
dots.sort((a, b) => row(a.y) - row(b.y) || (row(a.y) % 2 === 0 ? a.x - b.x : b.x - a.x) || a.y - b.y || a.idx - b.idx);
|
|
1945
|
+
let rr = fmtPathNumber(r), dd = fmtPathNumber(2 * r), circle = `a${rr} ${rr} 0 1 0 ${dd} 0a${rr} ${rr} 0 1 0-${dd} 0`, parts = [], x = 0, y = 0;
|
|
1946
|
+
for (let dot of dots)
|
|
1947
|
+
parts.push(parts.length === 0 ? `M${hundredths(dot.x)} ${hundredths(dot.y)}` : `m${hundredths(dot.x - x)}${dot.y - y < 0 ? "" : " "}${hundredths(dot.y - y)}`, circle), x = dot.x, y = dot.y;
|
|
1948
|
+
let id = `mark:dense:${k + 1}`;
|
|
1949
|
+
for (let dot of dots) drawn.set(dot.p, id);
|
|
1950
|
+
return { t: "path", id, d: parts.join(""), fill: paint, owner: {}, part: "point" };
|
|
1951
|
+
}), drawn };
|
|
1952
|
+
}
|
|
1953
|
+
function hundredths(v) {
|
|
1954
|
+
let sign = v < 0 ? "-" : "", a = Math.abs(v), whole = Math.floor(a / 100), frac = a % 100;
|
|
1955
|
+
return frac === 0 ? `${sign}${whole}` : `${sign}${whole}.${frac < 10 ? `0${frac}` : String(frac).replace(/0$/, "")}`;
|
|
1956
|
+
}
|
|
1957
|
+
function pointMarks(env, domain, area, paints, nodes, claims) {
|
|
1958
|
+
let { options, fmt, axisFmt } = env, { clamp } = domain, { x, y } = area, placed = domain.pts.filter((p) => inView(options, domain.dx, domain.dy, p)).map((p) => ({ p, cx: x(clamp ? clamp.project.x(p.x) : p.x), cy: y(clamp ? clamp.project.y(p.y) : p.y), r: area.radiusOf(p) })), drawOrder = [...placed].sort((a, b) => b.r - a.r || a.p.idx - b.p.idx), ringGap = domain.bubbleMode ? BUBBLE_RING_GAP : HIGHLIGHT_RING_GAP, nodeIdOf = /* @__PURE__ */ new Map(), dense = denseDots(env.theme, domain, paints, drawOrder);
|
|
1959
|
+
dense && pushAll(nodes, dense.nodes);
|
|
1960
|
+
for (let { p, cx, cy, r } of drawOrder) {
|
|
1961
|
+
let denseId = dense?.drawn.get(p);
|
|
1962
|
+
if (denseId) {
|
|
1963
|
+
nodeIdOf.set(p.id, denseId), claims.claim({ x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, "mark", { pointId: p.id });
|
|
1964
|
+
continue;
|
|
1965
|
+
}
|
|
1966
|
+
if (p.marker === "none") continue;
|
|
1967
|
+
let nodeId = `mark:${p.id}`;
|
|
1968
|
+
nodeIdOf.set(p.id, nodeId);
|
|
1969
|
+
let owner = { pointId: p.id }, clippedAt2 = clampStateOf(clamp, p.id), display = {
|
|
1970
|
+
// The REAL coordinates, on a clipped point too: the mark moved, the
|
|
1971
|
+
// value did not, and this string is what the hover card and the
|
|
1972
|
+
// accessible data table read.
|
|
1973
|
+
value: [
|
|
1974
|
+
`X ${axisFmt.x(p.x)}`,
|
|
1975
|
+
`Y ${axisFmt.y(p.y)}`,
|
|
1976
|
+
...p.size === null ? [] : [`Size ${fmt(p.size)}`]
|
|
1977
|
+
].join(", "),
|
|
1978
|
+
...clippedAt2 ? { state: clippedAt2 } : {}
|
|
1979
|
+
}, odd = domain.bubbleMode ? sizeMarkerOf(p) : void 0;
|
|
1980
|
+
if (nodes.push(odd ? sizeMarkerNode(env.theme, odd, { id: nodeId, cx, cy, r, paint: paints.point(p), owner, display }) : pointMarkNode(env.theme, {
|
|
1981
|
+
id: nodeId,
|
|
1982
|
+
marker: p.marker,
|
|
1983
|
+
cx,
|
|
1984
|
+
cy,
|
|
1985
|
+
r,
|
|
1986
|
+
paint: paints.point(p),
|
|
1987
|
+
hollow: paints.hollow(p),
|
|
1988
|
+
clipped: clippedAt2 !== void 0,
|
|
1989
|
+
owner,
|
|
1990
|
+
display
|
|
1991
|
+
})), paints.highlighted(p)) {
|
|
1992
|
+
let rr = r + ringGap;
|
|
1993
|
+
nodes.push({ t: "path", id: `${nodeId}:ring`, d: `M${fmtPathNumber(cx - rr)} ${fmtPathNumber(cy)}A${fmtPathNumber(rr)} ${fmtPathNumber(rr)} 0 1 0 ${fmtPathNumber(cx + rr)} ${fmtPathNumber(cy)}A${fmtPathNumber(rr)} ${fmtPathNumber(rr)} 0 1 0 ${fmtPathNumber(cx - rr)} ${fmtPathNumber(cy)}Z`, stroke: paints.ring, width: strokeToken(env.theme, "mark"), owner, part: "highlightRing" });
|
|
1994
|
+
}
|
|
1995
|
+
let reach = r + (paints.highlighted(p) ? ringGap + strokeToken(env.theme, "mark") : 0), outline = domain.bubbleMode && !odd && reach >= BUBBLE_OUTLINE_MIN_R ? Array.from({ length: 32 }, (_, k) => ({ x: cx + reach / Math.cos(Math.PI / 32) * Math.cos(k * Math.PI / 16), y: cy + reach / Math.cos(Math.PI / 32) * Math.sin(k * Math.PI / 16) })) : void 0;
|
|
1996
|
+
claims.claim({ x: cx - reach, y: cy - reach, w: 2 * reach, h: 2 * reach }, "mark", owner, void 0, outline);
|
|
1997
|
+
}
|
|
1998
|
+
return { placed, nodeIdOf, densePoints: dense?.drawn.size ?? 0 };
|
|
1999
|
+
}
|
|
2000
|
+
function quadrantDividers(theme, q, drawn, area, nodes, claims) {
|
|
2001
|
+
let { plot } = area, divider = (axis, x1, y1, x2, y2) => ({ t: "line", id: `quadrant:divider:${axis}`, x1, y1, x2, y2, stroke: { token: "neutral", tint: DIVIDER_TINT }, width: strokeToken(theme, "rule"), owner: {}, part: "quadrantDivider" });
|
|
2002
|
+
if (drawn.drawX) {
|
|
2003
|
+
let qx = area.x(q.x);
|
|
2004
|
+
nodes.push(divider("x", qx, plot.y, qx, plot.y + plot.h)), claims.claim({ x: qx - 1, y: plot.y, w: 2, h: plot.h }, "axis", {});
|
|
2005
|
+
}
|
|
2006
|
+
if (drawn.drawY) {
|
|
2007
|
+
let qy = area.y(q.y);
|
|
2008
|
+
nodes.push(divider("y", plot.x, qy, plot.x + plot.w, qy)), claims.claim({ x: plot.x, y: qy - 1, w: plot.w, h: 2 }, "axis", {});
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
function claimValueLines(domain, area, claims) {
|
|
2012
|
+
let ys = [];
|
|
2013
|
+
return domain.annotations.forEach((ann, n) => {
|
|
2014
|
+
if (ann.kind !== "valueLine") return;
|
|
2015
|
+
let annId = ann.id ?? `valueLine-${n + 1}`, v = ann.value === "mean" || ann.value === void 0 ? domain.meanY : ann.value;
|
|
2016
|
+
v !== void 0 && (ys.push(area.y(v)), claims.claim({ x: area.plot.x, y: area.y(v) - 1, w: area.plot.w, h: 2 }, "annotation", { annotationId: annId }, "referenceLine"));
|
|
2017
|
+
}), ys;
|
|
2018
|
+
}
|
|
2019
|
+
function layoutScatterMarks(env, domain, area, paints) {
|
|
2020
|
+
let { plot } = area, q = domain.quadrants.derived, nodes = [], claims = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), zones = layoutScatterZones(env, domain, area, nodes, claims), axes = scatterAxes(env, domain, area, nodes, claims), cutTicks = boldCutTicks(env, domain, axes, nodes), split = {
|
|
2021
|
+
x: q ? Math.min(Math.max(area.x(q.x), plot.x), plot.x + plot.w) : 0,
|
|
2022
|
+
y: q ? Math.min(Math.max(area.y(q.y), plot.y), plot.y + plot.h) : 0
|
|
2023
|
+
};
|
|
2024
|
+
q && (env.options.quadrants?.tint ?? "none") === "alternating" && quadrantTint(plot, split, nodes), zeroLines(env.theme, domain, area, nodes, claims);
|
|
2025
|
+
let trendLines = drawScatterTrends(env.theme, domain.trends, domain, area, paints, nodes, claims);
|
|
2026
|
+
drawFrontier(domain.frontier, env, domain.pts, domain.clamp, area, nodes, claims);
|
|
2027
|
+
let { placed, nodeIdOf, densePoints } = pointMarks(env, domain, area, paints, nodes, claims);
|
|
2028
|
+
q && quadrantDividers(env.theme, q, domain.quadrants, area, nodes, claims);
|
|
2029
|
+
let valueLineYs = claimValueLines(domain, area, claims), rules = { x: [], y: valueLineYs };
|
|
2030
|
+
for (let node of nodes)
|
|
2031
|
+
node.t !== "line" || node.part !== "zeroLine" && node.part !== "quadrantDivider" || (node.x1 === node.x2 ? rules.x.push(node.x1) : rules.y.push(node.y1));
|
|
2032
|
+
let marks = {
|
|
2033
|
+
points: placed.map(({ p, cx, cy, r }) => ({
|
|
2034
|
+
id: p.id,
|
|
2035
|
+
cx,
|
|
2036
|
+
cy,
|
|
2037
|
+
r: p.marker === "none" ? 0 : r,
|
|
2038
|
+
...nodeIdOf.has(p.id) ? { nodeId: nodeIdOf.get(p.id) } : {},
|
|
2039
|
+
...domain.clamp?.clipped.has(p.id) ? { clipped: !0 } : {}
|
|
2040
|
+
})),
|
|
2041
|
+
...zones.marks.length ? { zones: zones.marks } : {}
|
|
2042
|
+
};
|
|
2043
|
+
return { nodes, claims, axes, zones, placed, marks, split, trendLines, rules, cutTicks, ...densePoints > 0 ? { densePoints } : {} };
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
// src/core/charts/scatter/labels.ts
|
|
2047
|
+
var RING1_GAP = 4, NAME_GAP = 6, RULE_GAP = 4, RING2_GAP = 16, RING3_GAP = 30, RING4_GAP = 46, CAPTION_PAD = 6, DIVIDER_TAG_GAP = 4, PRIORITY_DIVIDER_TAG = PRIORITY.grandTotal + 60, PRIORITY_QUADRANT_CAPTION = PRIORITY.grandTotal;
|
|
2048
|
+
function dividerTagCandidates(tsize, rectAt, leaderTo) {
|
|
2049
|
+
let stations = [
|
|
2050
|
+
["End", 0],
|
|
2051
|
+
["Quarter", 0.25],
|
|
2052
|
+
["Mid", 0.5],
|
|
2053
|
+
["ThreeQuarter", 0.75],
|
|
2054
|
+
["FarEnd", 1]
|
|
2055
|
+
], out = [];
|
|
2056
|
+
for (let standoff of [0, 1, 2, 3])
|
|
2057
|
+
for (let [station, along] of stations)
|
|
2058
|
+
for (let side of ["near", "far"]) {
|
|
2059
|
+
let rect = rectAt(side, along, standoff * (tsize.height + 5));
|
|
2060
|
+
out.push({
|
|
2061
|
+
slot: `${side}${station}${standoff ? `Standoff${standoff}` : ""}`,
|
|
2062
|
+
rect,
|
|
2063
|
+
penalty: out.length,
|
|
2064
|
+
...standoff >= 2 ? { leaderFrom: leaderTo(rect) } : {}
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
return out;
|
|
2068
|
+
}
|
|
2069
|
+
function spiralCandidates(cx, cy, r, tsize, insideFill, fine = !1, slide = !1) {
|
|
2070
|
+
let w = tsize.width, h = tsize.height, out = [], penalty = 0;
|
|
2071
|
+
insideFill !== void 0 && w <= 2 * r * 0.85 && h <= 1.4 * r && out.push({
|
|
2072
|
+
slot: "insideCenter",
|
|
2073
|
+
rect: { x: cx - w / 2, y: cy - h / 2, w, h },
|
|
2074
|
+
penalty: penalty++,
|
|
2075
|
+
insideFill
|
|
2076
|
+
});
|
|
2077
|
+
let diag = Math.SQRT1_2, dirs = [
|
|
2078
|
+
["right", 1, 0],
|
|
2079
|
+
["left", -1, 0],
|
|
2080
|
+
["above", 0, -1],
|
|
2081
|
+
["below", 0, 1],
|
|
2082
|
+
["aboveRight", diag, -diag],
|
|
2083
|
+
["aboveLeft", -diag, -diag],
|
|
2084
|
+
["belowRight", diag, diag],
|
|
2085
|
+
["belowLeft", -diag, diag]
|
|
2086
|
+
], rectFor = (ux, uy, dist) => {
|
|
2087
|
+
let ax = cx + ux * dist, ay = cy + uy * dist, rx = ux > 0.01 ? ax : ux < -0.01 ? ax - w : ax - w / 2, ry = uy > 0.01 ? ay : uy < -0.01 ? ay - h : ay - h / 2;
|
|
2088
|
+
return { x: rx, y: ry, w, h };
|
|
2089
|
+
};
|
|
2090
|
+
for (let [slot, ux, uy] of dirs)
|
|
2091
|
+
out.push({ slot, rect: rectFor(ux, uy, r + RING1_GAP), penalty: penalty++ });
|
|
2092
|
+
if (slide && w > 2 * r)
|
|
2093
|
+
for (let [slot, uy] of [["above", -1], ["below", 1]]) {
|
|
2094
|
+
let base = rectFor(0, uy, r + RING1_GAP);
|
|
2095
|
+
for (let [side, dx] of [["Left", -(w / 2)], ["Right", w / 2]])
|
|
2096
|
+
out.push({ slot: `${slot}Slide${side}`, rect: { ...base, x: base.x + dx }, penalty: penalty++ });
|
|
2097
|
+
}
|
|
2098
|
+
let [c, s] = [Math.cos(Math.PI / 8), Math.sin(Math.PI / 8)], fineDirs = fine ? [["rightHigh", c, -s], ["rightLow", c, s], ["leftHigh", -c, -s], ["leftLow", -c, s]] : [];
|
|
2099
|
+
for (let [ring, baseGap] of [["Far", RING2_GAP], ["Far3", RING3_GAP], ["Far4", RING4_GAP]])
|
|
2100
|
+
for (let [slot, ux, uy] of [...dirs.filter(([, ux2]) => ux2 !== 0), ...fineDirs]) {
|
|
2101
|
+
let gap = Math.max(baseGap, (h + 1) / Math.abs(ux));
|
|
2102
|
+
out.push({
|
|
2103
|
+
slot: `${slot}${ring}`,
|
|
2104
|
+
rect: rectFor(ux, uy, r + gap),
|
|
2105
|
+
penalty: penalty++,
|
|
2106
|
+
leaderFrom: { x: cx + ux * r, y: cy + uy * r }
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
return out;
|
|
2110
|
+
}
|
|
2111
|
+
var CELL_CAPTION_PAD = 6, CELL_CAPTION_BOTTOM_PAD = 1;
|
|
2112
|
+
function zoneLabelCandidates(site, area, env, placed = []) {
|
|
2113
|
+
let { box } = site;
|
|
2114
|
+
if (site.kind === "xBand" || site.kind === "yBand") {
|
|
2115
|
+
let lines = site.lines ?? [site.text], lineH = env.measure("0", area.fonts.tick).height, measured2 = { width: Math.max(...lines.map((line) => env.measure(line, area.fonts.tick).width)), height: lines.length * lineH };
|
|
2116
|
+
return [{ slot: "axisBand", rect: site.kind === "xBand" ? { x: box.x + (box.w - measured2.width) / 2, y: box.y + ZONE_BAND_GAP, w: measured2.width, h: measured2.height } : { x: box.x + box.w - ZONE_BAND_GAP - measured2.width, y: box.y + (box.h - measured2.height) / 2, w: measured2.width, h: measured2.height }, penalty: 0 }];
|
|
2117
|
+
}
|
|
2118
|
+
let measured = env.measure(site.text, area.fonts.caption);
|
|
2119
|
+
if (site.kind === "cell") {
|
|
2120
|
+
let pad = CELL_CAPTION_PAD, bottomPad = box.y + box.h < area.plot.y + area.plot.h - 0.5 ? CELL_CAPTION_BOTTOM_PAD : pad, clear = (rect) => placed.every((m) => Math.hypot(Math.max(rect.x - m.cx, 0, m.cx - rect.x - rect.w), Math.max(rect.y - m.cy, 0, m.cy - rect.y - rect.h)) >= m.r), at2 = (slot, rx, ry) => {
|
|
2121
|
+
let rect = { x: rx, y: ry, w: measured.width, h: measured.height };
|
|
2122
|
+
return { slot, rect, penalty: 0, ...placed.length > 0 && clear(rect) ? { pad: 0 } : {} };
|
|
2123
|
+
};
|
|
2124
|
+
return [
|
|
2125
|
+
at2("topLeft", box.x + pad, box.y + pad),
|
|
2126
|
+
at2("bottomLeft", box.x + pad, box.y + box.h - bottomPad - measured.height),
|
|
2127
|
+
at2("bottomRight", box.x + box.w - pad - measured.width, box.y + box.h - bottomPad - measured.height),
|
|
2128
|
+
at2("topRight", box.x + box.w - pad - measured.width, box.y + pad),
|
|
2129
|
+
at2("centre", box.x + (box.w - measured.width) / 2, box.y + (box.h - measured.height) / 2)
|
|
2130
|
+
].map((candidate, index) => ({ ...candidate, penalty: index }));
|
|
2131
|
+
}
|
|
2132
|
+
let at = (slot, xFraction, yFraction, penalty) => ({
|
|
2133
|
+
slot,
|
|
2134
|
+
rect: {
|
|
2135
|
+
x: box.x + box.w * xFraction - measured.width / 2,
|
|
2136
|
+
y: box.y + box.h * yFraction - measured.height / 2,
|
|
2137
|
+
w: measured.width,
|
|
2138
|
+
h: measured.height
|
|
2139
|
+
},
|
|
2140
|
+
penalty
|
|
2141
|
+
});
|
|
2142
|
+
return [
|
|
2143
|
+
at("centre", 0.5, 0.5, 0),
|
|
2144
|
+
at("upperCentre", 0.5, 0.25, 1),
|
|
2145
|
+
at("lowerCentre", 0.5, 0.75, 2),
|
|
2146
|
+
at("centreLeft", 0.25, 0.5, 3),
|
|
2147
|
+
at("centreRight", 0.75, 0.5, 4),
|
|
2148
|
+
at("upperLeft", 0.25, 0.25, 5),
|
|
2149
|
+
at("upperRight", 0.75, 0.25, 6),
|
|
2150
|
+
at("lowerLeft", 0.25, 0.75, 7),
|
|
2151
|
+
at("lowerRight", 0.75, 0.75, 8)
|
|
2152
|
+
];
|
|
2153
|
+
}
|
|
2154
|
+
function zoneLabelRequests(sites, area, env, placed = []) {
|
|
2155
|
+
return sites.map((site) => ({
|
|
2156
|
+
id: site.id,
|
|
2157
|
+
kind: "category",
|
|
2158
|
+
owner: { categoryId: String(site.id) },
|
|
2159
|
+
text: site.text,
|
|
2160
|
+
// A cell caption prints as written.
|
|
2161
|
+
lines: site.lines ?? [site.text],
|
|
2162
|
+
...site.kind === "yBand" ? { align: "end" } : site.kind === "xBand" ? { align: "middle" } : {},
|
|
2163
|
+
typeRole: "axis",
|
|
2164
|
+
font: area.fonts.caption,
|
|
2165
|
+
priority: site.kind === "xBand" || site.kind === "yBand" ? PRIORITY.valueLine : PRIORITY.total,
|
|
2166
|
+
candidates: zoneLabelCandidates(site, area, env, placed).filter((candidate) => rectContains(site.box, candidate.rect, 0))
|
|
2167
|
+
}));
|
|
2168
|
+
}
|
|
2169
|
+
function dividerTagRequests(q, area, env, requests, pts, printed) {
|
|
2170
|
+
let quadrants = q.derived, { plot } = area, font = { ...area.fonts.label, weight: emphasisWeight(env.theme) }, tie = {
|
|
2171
|
+
x: pts.some((p) => p.x === quadrants.x) ? chartString(env.options, "pointsCountRight") : "",
|
|
2172
|
+
y: pts.some((p) => p.y === quadrants.y) ? chartString(env.options, "pointsCountAbove") : ""
|
|
2173
|
+
}, tag = (id, source, text, candidates) => {
|
|
2174
|
+
let line = `${chartString(env.options, source === "declared" ? "cutAt" : source === "median" ? "medianName" : "cutMeanCapital")} ${text}${tie[id]}`;
|
|
2175
|
+
return {
|
|
2176
|
+
id: `quadrant:cut:${id}`,
|
|
2177
|
+
kind: "valueLine",
|
|
2178
|
+
role: composedTextRole(line),
|
|
2179
|
+
owner: { valueLineId: `quadrant:${id}` },
|
|
2180
|
+
text: line,
|
|
2181
|
+
lines: [line],
|
|
2182
|
+
typeRole: "label",
|
|
2183
|
+
font,
|
|
2184
|
+
priority: PRIORITY_DIVIDER_TAG,
|
|
2185
|
+
candidates: candidates(env.measure(line, font))
|
|
2186
|
+
};
|
|
2187
|
+
}, tagged = { x: !printed.x || tie.x !== "", y: !printed.y || tie.y !== "" };
|
|
2188
|
+
if (q.drawX && tagged.x) {
|
|
2189
|
+
let qx = area.x(quadrants.x);
|
|
2190
|
+
requests.push(tag("x", quadrants.xSource, quadrants.xText, (tsize) => dividerTagCandidates(
|
|
2191
|
+
tsize,
|
|
2192
|
+
(side, along, offset) => ({
|
|
2193
|
+
x: side === "near" ? qx + DIVIDER_TAG_GAP + offset : qx - DIVIDER_TAG_GAP - offset - tsize.width,
|
|
2194
|
+
y: Math.min(plot.y + plot.h - 2 - tsize.height, plot.y + 2 + along * (plot.h - 4 - tsize.height)),
|
|
2195
|
+
w: tsize.width,
|
|
2196
|
+
h: tsize.height
|
|
2197
|
+
}),
|
|
2198
|
+
(rect) => ({ x: qx, y: rect.y + rect.h / 2 })
|
|
2199
|
+
)));
|
|
2200
|
+
}
|
|
2201
|
+
if (q.drawY && tagged.y) {
|
|
2202
|
+
let qy = area.y(quadrants.y);
|
|
2203
|
+
requests.push(tag("y", quadrants.ySource, quadrants.yText, (tsize) => dividerTagCandidates(
|
|
2204
|
+
tsize,
|
|
2205
|
+
(side, along, offset) => ({
|
|
2206
|
+
x: Math.max(plot.x + 2, plot.x + plot.w - 2 - tsize.width - along * (plot.w - 4 - tsize.width)),
|
|
2207
|
+
y: side === "near" ? qy - DIVIDER_TAG_GAP - offset - tsize.height : qy + DIVIDER_TAG_GAP + offset,
|
|
2208
|
+
w: tsize.width,
|
|
2209
|
+
h: tsize.height
|
|
2210
|
+
}),
|
|
2211
|
+
(rect) => ({ x: rect.x + rect.w / 2, y: qy })
|
|
2212
|
+
)));
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
function quadrantCaptionRequests(env, domain, area, split, requests, warnings, placed = []) {
|
|
2216
|
+
let quadrants = domain.quadrants.derived, captionFont = area.fonts.caption, captions = env.options.quadrants?.labels ?? {}, centreFirst = (env.options.quadrants?.captionPlacement ?? "corner") === "centre";
|
|
2217
|
+
for (let box of QUADRANT_BOXES) {
|
|
2218
|
+
let authored = captions[box];
|
|
2219
|
+
if (authored === void 0 || authored === "") continue;
|
|
2220
|
+
if (domain.quadrants.voidBoxes.has(box)) {
|
|
2221
|
+
warnings.push({
|
|
2222
|
+
code: "quadrant-caption-void-box",
|
|
2223
|
+
severity: "info",
|
|
2224
|
+
message: `caption '${authored}' for the ${QUADRANT_BOX_NAME[box]} box was not placed: a cut point outside the plotted domain leaves that box no area, and it holds 0 of ${domain.pts.length} units. The footnote states the collapse.`
|
|
2225
|
+
});
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
let rect = quadrantBoxRect(box, area.plot, split), wrapped = wrapText(authored, captionFont, Math.max(1, rect.w - 2 * CAPTION_PAD), 2, env.measure), lines = [
|
|
2229
|
+
...wrapped.truncated ? [authored] : wrapped.lines,
|
|
2230
|
+
`n = ${formatAutomaticNumber(quadrants.counts[box], { locale: env.options.locale?.language, decimals: 0 })}`
|
|
2231
|
+
], w = Math.max(...lines.map((l) => env.measure(l, captionFont).width)), lineH = captionFont.size * (captionFont.lineHeight ?? 1.2), h = lineH * lines.length, left = rect.x + CAPTION_PAD, right = rect.x + rect.w - CAPTION_PAD - w, top = rect.y + CAPTION_PAD, bottom = rect.y + rect.h - CAPTION_PAD - h, cx = rect.x + rect.w / 2 - w / 2, cy = rect.y + rect.h / 2 - h / 2, corners = box === "tl" ? [["topLeft", left, top], ["bottomLeft", left, bottom], ["topRight", right, top]] : box === "tr" ? [["topRight", right, top], ["bottomRight", right, bottom], ["topLeft", left, top]] : box === "bl" ? [["topLeft", left, top], ["bottomLeft", left, bottom], ["bottomRight", right, bottom]] : [["topRight", right, top], ["bottomRight", right, bottom], ["bottomLeft", left, bottom]], ordered = centreFirst ? [["centre", cx, cy], ...corners] : [...corners, ["centre", cx, cy]], candidates = [], endAligned = box === "tr" || box === "br", clearOfBubbles = (x, y) => lines.every((line, i) => {
|
|
2232
|
+
let lw = env.measure(line, captionFont).width, lr = { x: endAligned ? x + w - lw : x, y: y + i * lineH, w: lw, h: lineH };
|
|
2233
|
+
return placed.every((m) => Math.hypot(Math.max(lr.x - m.cx, 0, m.cx - lr.x - lr.w), Math.max(lr.y - m.cy, 0, m.cy - lr.y - lr.h)) >= m.r + CAPTION_PAD);
|
|
2234
|
+
});
|
|
2235
|
+
ordered.forEach(([slot, rx, ry]) => {
|
|
2236
|
+
let candidate = { x: rx, y: ry, w, h };
|
|
2237
|
+
rectContains(rect, candidate, 0) && candidates.push({ slot, rect: candidate, penalty: candidates.length, ...placed.length > 0 && clearOfBubbles(rx, ry) ? { pad: 0 } : {} });
|
|
2238
|
+
}), requests.push({
|
|
2239
|
+
id: `quadrant:caption:${box}`,
|
|
2240
|
+
kind: "category",
|
|
2241
|
+
owner: { categoryId: `quadrant:${box}` },
|
|
2242
|
+
text: lines.join(" "),
|
|
2243
|
+
lines,
|
|
2244
|
+
typeRole: "axis",
|
|
2245
|
+
font: captionFont,
|
|
2246
|
+
// A right-hand box sets its caption flush right, on the box's outer edge.
|
|
2247
|
+
...box === "tr" || box === "br" ? { align: "end" } : {},
|
|
2248
|
+
priority: PRIORITY_QUADRANT_CAPTION,
|
|
2249
|
+
candidates
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
var groupFormats = /* @__PURE__ */ new WeakMap();
|
|
2254
|
+
function pointValueText(env, domain, p, field) {
|
|
2255
|
+
let value = p[field];
|
|
2256
|
+
if (value === null) return;
|
|
2257
|
+
if (field === "y" && (env.options.format || env.options.axisFormat?.y || env.log.y)) return env.axisFmt.y(value);
|
|
2258
|
+
let byGroup = groupFormats.get(domain.pts);
|
|
2259
|
+
byGroup || groupFormats.set(domain.pts, byGroup = /* @__PURE__ */ new Map());
|
|
2260
|
+
let key = `${field}\0${p.group ?? ""}`, fmt = byGroup.get(key);
|
|
2261
|
+
return fmt || byGroup.set(key, fmt = seriesValueFormatter(domain.pts.filter((q) => q.group === p.group).map((q) => q[field]), env.options.locale?.language)), fmt(value);
|
|
2262
|
+
}
|
|
2263
|
+
function pointLabelRequests(env, domain, area, placed, rules, paints, requests, warnings, seatMemo = /* @__PURE__ */ new Map(), paintMemo = /* @__PURE__ */ new Map()) {
|
|
2264
|
+
let { options, highlights } = env, { bubbleMode, sizeMax } = domain, maxPointLabels = options.maxPointLabels ?? 300, pointLabelsOn = options.labels !== !1 && options.labels?.point !== !1, field = options.labels !== !1 && options.labels?.value === !0 ? bubbleMode ? "size" : "y" : void 0;
|
|
2265
|
+
if ((pointLabelsOn || field) && placed.length > maxPointLabels) {
|
|
2266
|
+
warnings.push({
|
|
2267
|
+
code: "labels-auto-off",
|
|
2268
|
+
severity: "info",
|
|
2269
|
+
message: `point labels auto-disabled: ${domain.pts.length} points exceed maxPointLabels (${maxPointLabels})`
|
|
2270
|
+
});
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
if (!pointLabelsOn && !field) return;
|
|
2274
|
+
let q = domain.quadrants, zeroRules = {
|
|
2275
|
+
x: domain.dx[0] < 0 && domain.dx[1] > 0 && !(q.drawX && q.derived?.x === 0) ? [area.x(0)] : [],
|
|
2276
|
+
y: domain.dy[0] < 0 && domain.dy[1] > 0 && !(q.drawY && q.derived?.y === 0) ? [area.y(0)] : []
|
|
2277
|
+
}, dividerY = q.drawY && q.derived ? area.y(q.derived.y) : void 0, valueLineYs = rules.y.filter((ry) => !zeroRules.y.includes(ry) && ry !== dividerY), marks = placed.map(({ p, cx, cy, r }) => ({ id: p.id, cx, cy, r }));
|
|
2278
|
+
for (let { p, cx, cy, r } of placed) {
|
|
2279
|
+
let extreme = p.x === domain.xMin || p.x === domain.xMax || p.y === domain.yMin || p.y === domain.yMax, sizeBonus = bubbleMode && sizeMax && sizeMax > 0 && p.size !== null ? Math.min(99, Math.round(99 * p.size / sizeMax)) : 0, hl = highlights.has(p.id) || p.group !== void 0 && highlights.has(p.group), priority = (extreme ? PRIORITY.extreme : PRIORITY.interior) + sizeBonus + (hl ? PRIORITY.highlightBonus : 0), value = field ? pointValueText(env, domain, p, field) : void 0, reach = hl && !bubbleMode ? r + HIGHLIGHT_RING_GAP + strokeToken(env.theme, "mark") : r, ownMark = { id: p.id, cx, cy, r: reach }, pointPaint = paintMemo.get(p.id);
|
|
2280
|
+
pointPaint || paintMemo.set(p.id, pointPaint = {});
|
|
2281
|
+
let memo = pointPaint, insidePaint = () => memo.inside ??= paints.hollow(p) ? { token: "background" } : paints.point(p), insideFill = () => (memo.fillKnown || (memo.fill = paints.insideFill(p), memo.fillKnown = !0), memo.fill), nameFont = hl && (!bubbleMode || gridZones(options)) ? { ...area.fonts.label, weight: emphasisWeight(env.theme) } : area.fonts.label, boxSideWidth = (box) => {
|
|
2282
|
+
let qx = q.drawX && q.derived ? area.x(q.derived.x) : void 0;
|
|
2283
|
+
return qx === void 0 ? area.plot.w : box === "tr" || box === "br" ? area.plot.x + area.plot.w - qx : qx - area.plot.x;
|
|
2284
|
+
}, boxedSeats = (raw) => {
|
|
2285
|
+
if (!q.derived) return raw;
|
|
2286
|
+
let box = q.derived.assignment[p.id], qx = q.drawX ? area.x(q.derived.x) : void 0, onRight = box === "tr" || box === "br", lo = onRight && qx !== void 0 ? qx + RULE_GAP : area.plot.x + RULE_GAP, hi = !onRight && qx !== void 0 ? qx - RULE_GAP : area.plot.x + area.plot.w - RULE_GAP, own = { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r };
|
|
2287
|
+
return raw.flatMap((c) => {
|
|
2288
|
+
let { rect } = c;
|
|
2289
|
+
if (c.insideFill !== void 0 || c.leaderFrom !== void 0 || rect.w > hi - lo || rect.x >= lo && rect.x + rect.w <= hi) return [c];
|
|
2290
|
+
let x = Math.min(Math.max(rect.x, lo), hi - rect.w), moved = { ...rect, x };
|
|
2291
|
+
return Math.abs(x - rect.x) > rect.w / 2 || rectsOverlap(moved, own) ? [c] : [c, { ...c, slot: `${c.slot}Boxed`, rect: moved }];
|
|
2292
|
+
});
|
|
2293
|
+
}, seats = (text, insideFill2, fine = !1, font = area.fonts.label, block, name = !1) => {
|
|
2294
|
+
let key = `${String(p.id)}\0${text}\0${insideFill2}\0${fine}\0${font.size}/${font.weight}\0${block ? `${block.width}x${block.height}` : ""}\0${name}`, known = seatMemo.get(key);
|
|
2295
|
+
if (known) return [...known];
|
|
2296
|
+
let built = buildSeats(text, insideFill2, fine, font, block).filter((c) => !name || nameReadsAsOwn(c.rect, c.leaderFrom ? seatLeader(c.rect, c.leaderFrom)?.d : void 0, ownMark, marks, [], font.size));
|
|
2297
|
+
return seatMemo.set(key, built), [...built];
|
|
2298
|
+
}, buildSeats = (text, insideFill2, fine, font, block) => {
|
|
2299
|
+
let plotSlid = (c) => c.slot.includes("Slide") ? { ...c, rect: { ...c.rect, x: Math.min(Math.max(c.rect.x, area.plot.x + RULE_GAP), area.plot.x + area.plot.w - RULE_GAP - c.rect.w) } } : c, candidates = boxedSeats(spiralCandidates(cx, cy, reach, block ?? env.measure(text, font), insideFill2, fine, bubbleMode).map(plotSlid)).filter((candidate) => rectContains(area.inner, candidate.rect) && candidate.rect.y + candidate.rect.h <= area.plot.y + area.plot.h && candidate.rect.x >= area.plot.x).map((candidate) => ({ ...candidate, insidePaint: insidePaint() })), across = (rect) => rules.x.some((rx) => Math.abs(cx - rx) > r && (cx < rx ? rect.x + rect.w > rx : rect.x < rx)) || rules.y.some((ry) => Math.abs(cy - ry) > r && (cy < ry ? rect.y + rect.h > ry : rect.y < ry)), slid = (c) => {
|
|
2300
|
+
let { rect } = c;
|
|
2301
|
+
for (let rx of rules.x) {
|
|
2302
|
+
if (Math.abs(cx - rx) <= r || rect.x >= rx + RULE_GAP || rect.x + rect.w <= rx - RULE_GAP) continue;
|
|
2303
|
+
let x = cx < rx ? rx - RULE_GAP - rect.w : rx + RULE_GAP;
|
|
2304
|
+
if (Math.abs(x - rect.x) <= rect.w / 2) return [{ ...c, slot: `${c.slot}Slid`, rect: { ...rect, x } }];
|
|
2305
|
+
}
|
|
2306
|
+
for (let ry of rules.y) {
|
|
2307
|
+
if (Math.abs(cy - ry) <= r || rect.y >= ry + RULE_GAP || rect.y + rect.h <= ry - RULE_GAP) continue;
|
|
2308
|
+
let y = cy < ry ? ry - RULE_GAP - rect.h : ry + RULE_GAP;
|
|
2309
|
+
if (Math.abs(y - rect.y) <= rect.h / 2) return [{ ...c, slot: `${c.slot}Slid`, rect: { ...rect, y } }];
|
|
2310
|
+
}
|
|
2311
|
+
return [];
|
|
2312
|
+
}, own = { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, kept = candidates.flatMap((c) => [c, ...slid(c).filter((s) => rectContains(area.inner, s.rect) && !rectsOverlap(s.rect, own))]);
|
|
2313
|
+
if (q.derived) {
|
|
2314
|
+
let box = q.derived.assignment[p.id], onRight = box === "tr" || box === "br", onTop = box === "tl" || box === "tr", qx = area.x(q.derived.x), qy = area.y(q.derived.y);
|
|
2315
|
+
kept = kept.filter((c) => !(q.drawX && (onRight ? c.rect.x < qx : c.rect.x + c.rect.w > qx) || q.drawY && (onTop ? c.rect.y + c.rect.h > qy : c.rect.y < qy)));
|
|
2316
|
+
}
|
|
2317
|
+
let ownLines = valueLineYs.filter((ry) => Math.abs(cy - ry) <= r), onZero = (rect) => zeroRules.x.some((rx) => rx > rect.x && rx < rect.x + rect.w) || [...zeroRules.y, ...ownLines].some((ry) => ry > rect.y && ry < rect.y + rect.h), over = kept.filter((c) => c.insideFill === void 0 && onZero(c.rect)).map((c) => ({ ...c, slot: `${c.slot}Over`, overRules: !0 })), all = [...kept, ...over], tier = (c) => c.overRules ? c.leaderFrom ? 5 : 2 : (c.leaderFrom ? 3 : 0) + (across(c.rect) ? 1 : 0);
|
|
2318
|
+
return [0, 1, 2, 3, 4, 5].flatMap((t) => all.filter((c) => tier(c) === t)).map((candidate) => ({ ...candidate, penalty: tier(candidate) }));
|
|
2319
|
+
}, named = pointLabelsOn && !!p.label, valueSize = value !== void 0 && bubbleMode && insideFill() !== void 0 ? env.measure(value, area.fonts.label) : void 0, inside = valueSize && valueSize.width <= 2 * r * 0.85 && valueSize.height <= 1.4 * r ? { x: cx - valueSize.width / 2, y: cy - valueSize.height / 2, w: valueSize.width, h: valueSize.height } : void 0, covered = (rect) => placed.some((o) => o.p.id !== p.id && o.r > 0 && Math.hypot(Math.max(rect.x - o.cx, 0, o.cx - rect.x - rect.w), Math.max(rect.y - o.cy, 0, o.cy - rect.y - rect.h)) < o.r), hiddenBehind = (offset, along, from, to) => {
|
|
2320
|
+
let half = Math.sqrt(Math.max(0, r * r - offset * offset));
|
|
2321
|
+
return bubbleMode && half > 0 && from >= along - half && to <= along + half;
|
|
2322
|
+
}, fitsInside = inside !== void 0 && !rules.x.some((rx) => rx > inside.x - RULE_GAP && rx < inside.x + inside.w + RULE_GAP && !(zeroRules.x.includes(rx) && hiddenBehind(rx - cx, cy, inside.y, inside.y + inside.h))) && !rules.y.some((ry) => ry > inside.y - RULE_GAP && ry < inside.y + inside.h + RULE_GAP && !(zeroRules.y.includes(ry) && hiddenBehind(ry - cy, cx, inside.x, inside.x + inside.w))) && !covered(inside), behindZero = fitsInside && (zeroRules.x.some((rx) => rx > inside.x - RULE_GAP && rx < inside.x + inside.w + RULE_GAP) || zeroRules.y.some((ry) => ry > inside.y - RULE_GAP && ry < inside.y + inside.h + RULE_GAP)), dropped = bubbleMode && ((env.valueTier === 1 || env.valueInsideOnly?.has(p.id) === !0) && !fitsInside || env.valueTier === 2), joined = named && value !== void 0 && !fitsInside && !dropped ? value : void 0;
|
|
2323
|
+
if (named) {
|
|
2324
|
+
let box = q.derived?.assignment[p.id], straddles = box !== void 0 && (q.drawX && Math.abs(cx - area.x(q.derived.x)) < r || q.drawY && Math.abs(cy - area.y(q.derived.y)) < r), clipped = (domain.clamp?.records ?? []).filter((record) => record.points.some((point) => point.id === p.id)), real = clipped.length ? ` ${[...new Set(clipped.map((record) => record.axis))].map((axis) => env.axisFmt[axis](p[axis])).join(", ")}` : "", plain = straddles ? `${p.label}${real} (${options.quadrants?.labels?.[box] ?? QUADRANT_BOX_NAME[box]})` : `${p.label}${real}`, name = joined === void 0 ? plain : `${plain} ${joined}`, room = box === void 0 ? 1 / 0 : boxSideWidth(box) - 2 * RULE_GAP, wrapped = env.measure(name, nameFont).width > room ? wrapText(name, nameFont, room, 2, env.measure) : void 0, nameLines = wrapped && !wrapped.truncated && wrapped.lines.length === 2 ? wrapped.lines : [name], callout = nameLines.length === 1 ? env.callouts?.get(p.id) : void 0, boldFont = { ...area.fonts.label, weight: emphasisWeight(env.theme) }, nameW = env.measure(name, nameFont).width, wrappedCallout = callout !== void 0 && env.calloutWrap ? wrapText(callout, boldFont, Math.max(nameW, ...callout.split(/\s+/).map((word) => env.measure(word, boldFont).width)), 3, env.measure) : void 0, calloutLines = callout === void 0 ? [] : wrappedCallout && !wrappedCallout.truncated ? wrappedCallout.lines : [callout], lines = callout === void 0 ? nameLines : [name, ...calloutLines], font = callout === void 0 ? nameFont : boldFont, lineH = nameFont.size * (nameFont.lineHeight ?? 1.2), block = callout !== void 0 ? { width: Math.max(nameW, ...calloutLines.map((line) => env.measure(line, boldFont).width)), height: lines.length * lineH } : lines.length > 1 ? { width: Math.max(...lines.map((line) => env.measure(line, nameFont).width)), height: lines.length * lineH } : void 0;
|
|
2325
|
+
requests.push({
|
|
2326
|
+
id: `point:${p.id}`,
|
|
2327
|
+
kind: "point",
|
|
2328
|
+
owner: { pointId: p.id },
|
|
2329
|
+
text: callout === void 0 ? name : `${name} ${callout}`,
|
|
2330
|
+
lines,
|
|
2331
|
+
typeRole: "label",
|
|
2332
|
+
font,
|
|
2333
|
+
...callout !== void 0 ? { headLines: 1, headWeight: nameFont.weight } : {},
|
|
2334
|
+
// An authored callout outranks the plain names.
|
|
2335
|
+
priority: callout === void 0 ? priority : priority + PRIORITY.highlightBonus,
|
|
2336
|
+
// With a value printed, the bubble's centre is the value's seat.
|
|
2337
|
+
candidates: seats(name, bubbleMode && value === void 0 && !block ? insideFill() : void 0, !1, nameFont, block, !0),
|
|
2338
|
+
labelGap: NAME_GAP,
|
|
2339
|
+
// The authored point name, not a value.
|
|
2340
|
+
role: "category",
|
|
2341
|
+
// The nearest-mark rule: a seat nearer another point waits, or
|
|
2342
|
+
// takes a leader from this one.
|
|
2343
|
+
anchor: { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r },
|
|
2344
|
+
// A bubble's leader crosses no other label; no name's leader does either.
|
|
2345
|
+
leaderClear: !0
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
if (value === void 0 || joined !== void 0) continue;
|
|
2349
|
+
let valueSeats = dropped ? [] : seats(value, bubbleMode ? insideFill() : void 0, bubbleMode).filter((candidate) => bubbleMode ? candidate.insideFill !== void 0 || !named && candidate.leaderFrom !== void 0 : candidate.leaderFrom === void 0).map((candidate) => fitsInside && candidate.slot === "insideCenter" ? { ...candidate, pad: 0, ...behindZero ? { overRules: !0 } : {} } : candidate);
|
|
2350
|
+
requests.push({
|
|
2351
|
+
id: `value:${p.id}`,
|
|
2352
|
+
kind: "point",
|
|
2353
|
+
owner: { pointId: p.id },
|
|
2354
|
+
text: value,
|
|
2355
|
+
lines: [value],
|
|
2356
|
+
typeRole: "label",
|
|
2357
|
+
font: area.fonts.label,
|
|
2358
|
+
// Names go before values. A value ranks below every name, so a
|
|
2359
|
+
// small point keeps its name before a large one prints its number; a
|
|
2360
|
+
// highlighted point's value keeps its rank.
|
|
2361
|
+
priority: hl ? priority - 1 : priority - 1 - PRIORITY.extreme,
|
|
2362
|
+
candidates: valueSeats,
|
|
2363
|
+
labelGap: NAME_GAP,
|
|
2364
|
+
role: "value",
|
|
2365
|
+
...bubbleMode ? { anchor: { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, leaderClear: !0 } : {}
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
function planScatterLabels(env, domain, area, geometry, paints, warnings) {
|
|
2370
|
+
let bubbles = domain.bubbleMode ? geometry.placed : [], requests = zoneLabelRequests(geometry.zones.labels, area, env, bubbles);
|
|
2371
|
+
return domain.quadrants.derived && (dividerTagRequests(domain.quadrants, area, env, requests, domain.pts, geometry.cutTicks), quadrantCaptionRequests(env, domain, area, geometry.split, requests, warnings, bubbles)), pointLabelRequests(env, domain, area, geometry.placed, geometry.rules, paints, requests, warnings, geometry.seatMemo ??= /* @__PURE__ */ new Map(), geometry.paintMemo ??= /* @__PURE__ */ new Map()), trendLabelRequest(env, area, geometry, requests), requests;
|
|
2372
|
+
}
|
|
2373
|
+
function trendLabelRequest(env, area, geometry, requests) {
|
|
2374
|
+
let trend = env.options.trend, text = typeof trend == "object" ? trend.label : void 0, line = geometry.trendLines[0];
|
|
2375
|
+
if (!text || !line) return;
|
|
2376
|
+
let font = { ...area.fonts.label, weight: emphasisWeight(env.theme) }, { width: w, height: h } = env.measure(text, font), { from, to, yAt } = line, GAP = 4, onLine = (x0, side) => {
|
|
2377
|
+
let lo = Math.max(x0, from.x), hi = Math.min(x0 + w, to.x), ys = lo <= hi ? [yAt(lo), yAt(hi)] : [x0 + w < from.x ? from.y : to.y];
|
|
2378
|
+
return { x: x0, y: side === "above" ? Math.min(...ys) - GAP - h : Math.max(...ys) + GAP, w, h };
|
|
2379
|
+
}, seats = [
|
|
2380
|
+
["endRight", { x: to.x + GAP + 2, y: to.y - h / 2, w, h }],
|
|
2381
|
+
["endAbove", onLine(to.x - w, "above")],
|
|
2382
|
+
["endBelow", onLine(to.x - w, "below")],
|
|
2383
|
+
["endAboveCentre", onLine(to.x - w / 2, "above")],
|
|
2384
|
+
["endBelowCentre", onLine(to.x - w / 2, "below")],
|
|
2385
|
+
["startLeft", { x: from.x - GAP - 2 - w, y: from.y - h / 2, w, h }],
|
|
2386
|
+
["startAbove", onLine(from.x, "above")],
|
|
2387
|
+
["startBelow", onLine(from.x, "below")],
|
|
2388
|
+
...[0.75, 0.5, 0.25].flatMap((t) => {
|
|
2389
|
+
let x0 = from.x + (to.x - from.x) * t - w / 2;
|
|
2390
|
+
return [[`above${t * 100}`, onLine(x0, "above")], [`below${t * 100}`, onLine(x0, "below")]];
|
|
2391
|
+
})
|
|
2392
|
+
], clear = (rect) => geometry.placed.every(({ cx, cy, r }) => !rectsOverlap(rect, { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r }, 8)), candidates = [...seats.filter(([, rect]) => clear(rect)), ...seats.filter(([, rect]) => !clear(rect))].map(([slot, rect], penalty) => ({ slot, rect, penalty }));
|
|
2393
|
+
requests.push({
|
|
2394
|
+
id: `trend:${line.fit.id}`,
|
|
2395
|
+
kind: "valueLine",
|
|
2396
|
+
owner: { annotationId: line.nodeId },
|
|
2397
|
+
text,
|
|
2398
|
+
lines: [text],
|
|
2399
|
+
typeRole: "label",
|
|
2400
|
+
font,
|
|
2401
|
+
// Before the interior point names, so an end seat is still free; the
|
|
2402
|
+
// extreme points, which usually sit at the line's ends, keep theirs.
|
|
2403
|
+
priority: PRIORITY.extreme - 1,
|
|
2404
|
+
role: "note",
|
|
2405
|
+
candidates: candidates.filter((candidate) => rectContains(area.plot, candidate.rect))
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
function scatterSolveCtx(env, area) {
|
|
2409
|
+
let { options, size, theme } = env;
|
|
2410
|
+
return labelCtx(theme, size, options, {
|
|
2411
|
+
measure: env.measure,
|
|
2412
|
+
plot: area.plot,
|
|
2413
|
+
labelPad: 2
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
// src/core/charts/scatter/sizeKey.ts
|
|
2418
|
+
function sizeKeyValues(env, sizeMin, sizeMax, fits, warnings, nested = !1) {
|
|
2419
|
+
let authored = typeof env.options.sizeLegend == "object" ? env.options.sizeLegend.values : void 0, kept = authored?.filter((value) => value <= sizeMax && fits(value)) ?? [], above = authored?.filter((value) => value > sizeMax) ?? [], tooLarge = authored?.filter((value) => value <= sizeMax && !fits(value)) ?? [], below = kept.filter((value) => value < sizeMin), are = (values) => `${values.join(", ")} ${values.length === 1 ? "is" : "are"}`, warn = (severity, message, suggest) => {
|
|
2420
|
+
warnings.push({ code: "size-legend-value-out-of-range", severity, message, suggest, field: ["options", "sizeLegend", "values"] });
|
|
2421
|
+
};
|
|
2422
|
+
if (above.length && warn(
|
|
2423
|
+
"warn",
|
|
2424
|
+
`sizeLegend.values ${are(above)} above the largest bubble (${sizeMax}), so the key leaves ${above.length === 1 ? "it" : "them"} out${kept.length ? "" : " and shows its default sizes"}`,
|
|
2425
|
+
`key sizes up to ${sizeMax}, or drop sizeLegend.values for the default`
|
|
2426
|
+
), tooLarge.length) {
|
|
2427
|
+
let largestFit = roundBelow(sizeMax).find(fits);
|
|
2428
|
+
warn(
|
|
2429
|
+
"warn",
|
|
2430
|
+
`sizeLegend.values ${are(tooLarge)} larger than the key row can draw at scale${largestFit === void 0 ? "" : `; the largest round size it draws is ${largestFit}`}, so the key leaves ${tooLarge.length === 1 ? "it" : "them"} out${kept.length ? "" : " and shows its default sizes"}`,
|
|
2431
|
+
largestFit === void 0 ? "drop sizeLegend.values for the default" : `key sizes up to ${largestFit}, or drop sizeLegend.values for the default`
|
|
2432
|
+
);
|
|
2433
|
+
}
|
|
2434
|
+
if (below.length && warn(
|
|
2435
|
+
"info",
|
|
2436
|
+
`sizeLegend.values ${are(below)} below the smallest bubble (${sizeMin}); the key draws ${below.length === 1 ? "it" : "them"} at scale`,
|
|
2437
|
+
`key sizes from ${sizeMin} to ${sizeMax} to show the bubbles' own range`
|
|
2438
|
+
), kept.length) return [...kept].sort((a, b) => b - a);
|
|
2439
|
+
let large = roundBelow(sizeMax).filter((value) => value >= sizeMin).find(fits) ?? sizeMax, small = roundBelow(large / (nested ? 4 : 2)).find((value) => value >= sizeMin);
|
|
2440
|
+
return small !== void 0 && small < large ? [large, small] : [large];
|
|
2441
|
+
}
|
|
2442
|
+
function roundBelow(v) {
|
|
2443
|
+
let out = [];
|
|
2444
|
+
for (let power = 10 ** Math.floor(Math.log10(v)), k = 0; k < 8; k++, power /= 10)
|
|
2445
|
+
for (let digit = 9; digit >= 1; digit--) digit * power <= v * (1 + 1e-9) && out.push(Number((digit * power).toPrecision(1)));
|
|
2446
|
+
return out;
|
|
2447
|
+
}
|
|
2448
|
+
function sizeKeyItems(env, sizeMin, sizeMax, radiusOf, maxRadius, warnings) {
|
|
2449
|
+
let title = typeof env.options.sizeLegend == "object" ? env.options.sizeLegend.label : void 0, values = sizeKeyValues(env, sizeMin, sizeMax, (size) => radiusOf(size) <= maxRadius, warnings), heading = title !== void 0, rings = values.map((value, index) => {
|
|
2450
|
+
let decimals = 0;
|
|
2451
|
+
for (; decimals < 20 && Math.abs(Number(roundHalfUp(value, decimals)) - value) > value * 1e-12; ) decimals++;
|
|
2452
|
+
let text = formatAutomaticNumber(value, { locale: env.options.locale?.language, decimals });
|
|
2453
|
+
return {
|
|
2454
|
+
id: `size:${index}`,
|
|
2455
|
+
label: index === 0 && title && !heading ? `${title}: ${text}` : text,
|
|
2456
|
+
paint: { token: "inkMuted" },
|
|
2457
|
+
key: "sizes",
|
|
2458
|
+
radii: [radiusOf(value)]
|
|
2459
|
+
};
|
|
2460
|
+
});
|
|
2461
|
+
return heading ? [{ id: "size:title", label: title, paint: { token: "ink" }, key: "heading" }, ...rings] : rings;
|
|
2462
|
+
}
|
|
2463
|
+
var KEY_INSET = 4, KEY_TICK_PAST = 8, KEY_TEXT_GAP = 3;
|
|
2464
|
+
function keyText(env, value) {
|
|
2465
|
+
let decimals = 0;
|
|
2466
|
+
for (; decimals < 20 && Math.abs(Number(roundHalfUp(value, decimals)) - value) > value * 1e-12; ) decimals++;
|
|
2467
|
+
return formatAutomaticNumber(value, { locale: env.options.locale?.language, decimals });
|
|
2468
|
+
}
|
|
2469
|
+
function plotSizeKey(env, area, sizeMin, sizeMax, claims, warnings, boxes = []) {
|
|
2470
|
+
let { plot, fonts } = area, values = sizeKeyValues(env, sizeMin, sizeMax, () => !0, warnings, !0), radii = values.map((size) => area.radiusOf({ size })), R = Math.max(...radii), texts = values.map((value) => keyText(env, value)), font = fonts.tick, textW = Math.max(...texts.map((text) => env.measure(text, font).width)), textH = env.measure("0", font).height, title = typeof env.options.sizeLegend == "object" ? env.options.sizeLegend.label : void 0, titleSize = title ? env.measure(title, font) : { width: 0, height: 0 }, ringsW = 2 * R + KEY_TICK_PAST + KEY_TEXT_GAP + textW, ringsH = textH / 2 + 2 * R, titleGap = 3, w = Math.max(ringsW, titleSize.width);
|
|
2471
|
+
if (!boxes.length && (w + 2 * KEY_INSET > plot.w / 2 || ringsH + titleSize.height + titleGap + 2 * KEY_INSET > plot.h / 2)) return;
|
|
2472
|
+
let snapshot = claims.snapshot(), rule = (c) => c.kind === "annotation" || c.part === "referenceLine" || c.part === "quadrantDivider", blocked = snapshot.filter((c) => c.kind === "mark" || rule(c)), free = (box) => !blocked.some((c) => rectsOverlap(c.rect, { x: box.x - KEY_INSET, y: box.y - KEY_INSET, w: box.w + 2 * KEY_INSET, h: box.h + 2 * KEY_INSET })), place = (side, edge, region = plot) => {
|
|
2473
|
+
if (region !== plot && (w + 2 * KEY_INSET > region.w || ringsH + titleSize.height + titleGap + 2 * KEY_INSET > region.h)) return;
|
|
2474
|
+
let r = side === "right" ? region.x + region.w - KEY_INSET : region.x + KEY_INSET + w, ringsTop = edge === "bottom" ? region.y + region.h - KEY_INSET - ringsH : region.y + KEY_INSET + (title ? titleSize.height + titleGap : 0), rings = { x: r - ringsW, y: ringsTop, w: ringsW, h: ringsH };
|
|
2475
|
+
for (let tries = 0; tries < 2 && edge === "bottom"; tries++) {
|
|
2476
|
+
let hit = blocked.find((c) => rule(c) && c.rect.w > c.rect.h && rectsOverlap(c.rect, { x: rings.x - KEY_INSET, y: rings.y - KEY_INSET, w: rings.w + 2 * KEY_INSET, h: rings.h + 2 * KEY_INSET }));
|
|
2477
|
+
if (!hit) break;
|
|
2478
|
+
let y = hit.rect.y - KEY_INSET - ringsH - 0.5;
|
|
2479
|
+
if (y < region.y + region.h / 2) return;
|
|
2480
|
+
rings = { ...rings, y };
|
|
2481
|
+
}
|
|
2482
|
+
if (!free(rings)) return;
|
|
2483
|
+
let ringsTopAt = rings.y;
|
|
2484
|
+
if (!title) return { rings };
|
|
2485
|
+
let box = { x: r - titleSize.width, y: ringsTopAt - titleGap - titleSize.height, w: titleSize.width, h: titleSize.height };
|
|
2486
|
+
for (let tries = 0; tries < 3 && box.y >= region.y; tries++) {
|
|
2487
|
+
let hit = blocked.find((c) => rectsOverlap(c.rect, { x: box.x - KEY_INSET, y: box.y - KEY_INSET, w: box.w + 2 * KEY_INSET, h: box.h + 2 * KEY_INSET }));
|
|
2488
|
+
if (!hit) return { rings, title: box };
|
|
2489
|
+
if (!rule(hit) || hit.rect.w < hit.rect.h || edge === "top") return;
|
|
2490
|
+
box = { ...box, y: hit.rect.y - KEY_INSET - titleSize.height - 0.5 };
|
|
2491
|
+
}
|
|
2492
|
+
}, inBox = boxes.reduce((found, box) => found ?? place(box.x + box.w / 2 >= plot.x + plot.w / 2 ? "right" : "left", "bottom", box), void 0), at = boxes.length ? inBox : place("right", "bottom") ?? place("right", "top") ?? place("left", "top") ?? place("left", "bottom");
|
|
2493
|
+
if (!at) return;
|
|
2494
|
+
let cx = at.rings.x + ringsW - ringsW + R, bottom = at.rings.y + ringsH, owner = {}, nodes = [];
|
|
2495
|
+
title && at.title && nodes.push({ t: "text", id: "sizeKey:title", x: at.title.x + at.title.w, y: at.title.y, lines: [title], align: "end", typeRole: "axis", role: "caption", font, ink: { token: "inkMuted" }, owner, part: "sizeKeyTitle" }), radii.forEach((r, i) => {
|
|
2496
|
+
nodes.push({ t: "circle", id: `sizeKey:ring:${i}`, cx, cy: bottom - r, r, fill: { token: "background" }, stroke: { token: "inkMuted" }, strokeWidth: strokeToken(env.theme, "rule"), owner, part: "sizeKeyRing" });
|
|
2497
|
+
}), radii.forEach((r, i) => {
|
|
2498
|
+
let top = bottom - 2 * r, tickEnd = cx + R + KEY_TICK_PAST;
|
|
2499
|
+
nodes.push({ t: "line", id: `sizeKey:tick:${i}`, x1: cx, y1: top, x2: tickEnd, y2: top, stroke: { token: "inkMuted" }, width: strokeToken(env.theme, "hair"), owner, part: "sizeKeyTick" }), nodes.push({ t: "text", id: `sizeKey:value:${i}`, x: tickEnd + KEY_TEXT_GAP, y: top - textH / 2, lines: [texts[i]], align: "start", typeRole: "axis", font, ink: { token: "inkMuted" }, owner, part: "sizeKeyValue" });
|
|
2500
|
+
});
|
|
2501
|
+
let rects = [at.rings, ...at.title ? [at.title] : []];
|
|
2502
|
+
return { nodes, rects };
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
// src/core/charts/scatter/layout.ts
|
|
2506
|
+
function scatterDescription(input) {
|
|
2507
|
+
let { fmt, axisFmt, extent, quadrants, zones, options } = input;
|
|
2508
|
+
return chartString(options, "scatterDescStart", { v1: chartString(options, input.bubbleMode ? "bubbleName" : "scatterName"), v2: input.pointCount }) + (input.groupNames.length ? chartString(options, "scatterGroupDesc", { v1: input.groupNames.length, v2: input.groupNames.length === 1 ? "" : "s", v3: input.groupNames.join(", ") }) : "") + chartString(options, "scatterAxesDesc", { v1: axisFmt.x(extent.xMin), v2: axisFmt.x(extent.xMax), v3: input.log.x ? chartString(options, "logScaleClause") : "", v4: axisFmt.y(extent.yMin), v5: axisFmt.y(extent.yMax), v6: input.log.y ? chartString(options, "logScaleClause") : "" }) + (input.biggest ? chartString(options, "bubbleSizeDesc", { v1: input.sizeBy === "area" ? chartString(options, "areaName") : chartString(options, "diameterName"), v2: input.biggest.label, v3: fmt(input.biggest.size) }) : "") + (quadrants ? chartString(options, "quadrantDesc", { v1: quadrants.xText, v2: chartString(options, quadrants.xSource === "declared" ? "declaredLower" : quadrants.xSource === "median" ? "cutMedian" : "cutMean"), v3: quadrants.yText, v4: chartString(options, quadrants.ySource === "declared" ? "declaredLower" : quadrants.ySource === "median" ? "cutMedian" : "cutMean") }) + QUADRANT_BOXES.map((box) => `${quadrantBoxName(box, options)} ${quadrants.counts[box]}`).join(", ") + "." : "") + (zones ? chartString(options, "strategyZonesDesc", { v1: zones.kind === "grid" ? chartString(options, "gridCellsCount", { v1: zones.cellCount }) : chartString(options, "authoredRegionsCount", { v1: zones.regionCount }), v2: input.zoneDescriptions.join(" ") }) : "") + clampDescription(input.clipped, axisFmt, input.reversedY, options) + (input.dropped ? ` ${input.dropped.note}` : "") + input.trends.map((fit) => chartString(options, "trendLineDesc", { v1: fit.slope < 0 ? chartString(options, "fallsLower") : fit.slope > 0 ? chartString(options, "risesLower") : chartString(options, "runsFlat"), v2: fit.n, v3: fit.group === void 0 ? "" : chartString(options, "ofGroupClause", { v1: input.groupLabel(fit.group) }) })).join("") + (input.frontier ? chartString(options, "frontierDesc", { v1: input.frontier.ids.length, v2: chartString(options, input.frontier.x === "min" ? "lower" : "higher"), v3: chartString(options, input.frontier.y === "min" ? "lower" : "higher"), v4: input.frontier.ids.map(input.pointLabel).join(", ") }) : "");
|
|
2509
|
+
}
|
|
2510
|
+
function nameCallouts(env, domain, geometry) {
|
|
2511
|
+
let callouts = /* @__PURE__ */ new Map(), { options } = env;
|
|
2512
|
+
if (options.labels === !1 || options.labels?.point === !1) return { callouts, annotations: domain.annotations };
|
|
2513
|
+
let named = new Set(geometry.placed.filter((e) => !!e.p.label).map((e) => e.p.id)), annotations = domain.annotations.flatMap((ann, index) => {
|
|
2514
|
+
if (ann.kind === "callout" && !ann.headline && !ann.arrow && !ann.icon && !ann.status && ann.text && !ann.text.includes("${")) {
|
|
2515
|
+
let at = typeof ann.at == "string" ? ann.at : "pointId" in ann.at ? ann.at.pointId : void 0;
|
|
2516
|
+
if (at !== void 0 && named.has(at) && !callouts.has(at))
|
|
2517
|
+
return callouts.set(at, ann.text), [];
|
|
2518
|
+
}
|
|
2519
|
+
return [{ ...ann, id: defaultAnnotationId(ann, index) }];
|
|
2520
|
+
});
|
|
2521
|
+
return callouts.size ? { callouts, annotations } : { callouts, annotations: domain.annotations };
|
|
2522
|
+
}
|
|
2523
|
+
function annotateScatter(env, domain, area, geometry, occupied, solveCtx) {
|
|
2524
|
+
let ptById = new Map(geometry.placed.map((e) => [e.p.id, e])), resolveAnchor = (ref) => {
|
|
2525
|
+
let norm = typeof ref == "string" ? { pointId: ref } : ref;
|
|
2526
|
+
if (!("pointId" in norm)) return null;
|
|
2527
|
+
let e = ptById.get(norm.pointId);
|
|
2528
|
+
return e ? {
|
|
2529
|
+
x: e.cx,
|
|
2530
|
+
y: e.cy - e.r - 1,
|
|
2531
|
+
value: e.p.y,
|
|
2532
|
+
owner: { pointId: e.p.id },
|
|
2533
|
+
markBox: { x: e.cx - e.r, y: e.cy - e.r, w: 2 * e.r, h: 2 * e.r }
|
|
2534
|
+
} : null;
|
|
2535
|
+
};
|
|
2536
|
+
return runAnnotatePass({
|
|
2537
|
+
target: env.options.target,
|
|
2538
|
+
annotations: domain.annotations,
|
|
2539
|
+
resolve: resolveAnchor,
|
|
2540
|
+
occupied,
|
|
2541
|
+
plot: area.plot,
|
|
2542
|
+
theme: env.theme,
|
|
2543
|
+
measure: env.measure,
|
|
2544
|
+
format: env.options.axisFormat?.y ?? env.options.format,
|
|
2545
|
+
locale: env.options.locale?.language,
|
|
2546
|
+
strings: env.options.strings,
|
|
2547
|
+
valueLinePercentLevels: env.options.unit === "%" || domain.pts.length > 0 && domain.pts.every((point) => point.yIsPct),
|
|
2548
|
+
solveCtx,
|
|
2549
|
+
yScale: area.y,
|
|
2550
|
+
meanValue: domain.meanY,
|
|
2551
|
+
calloutLeaderClear: !0
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
function scatterLabels(theme, area, solved, annotated, boldIds = /* @__PURE__ */ new Set()) {
|
|
2555
|
+
let { fonts } = area, isQuadrantCaption = (id) => String(id).startsWith("quadrant:caption:"), isZoneLabel = (id) => String(id).startsWith("zone:"), isZoneBandLabel = (id) => String(id).startsWith("zone:x-band:") || String(id).startsWith("zone:y-band:"), labels = [
|
|
2556
|
+
...solved.placed.map(
|
|
2557
|
+
(l) => isQuadrantCaption(l.id) || isZoneLabel(l.id) ? { ...l, ink: { token: "inkMuted" } } : l
|
|
2558
|
+
),
|
|
2559
|
+
...annotated.labels
|
|
2560
|
+
], nodes = labelsToNodes(
|
|
2561
|
+
theme,
|
|
2562
|
+
labels,
|
|
2563
|
+
(l) => isQuadrantCaption(l.id) ? fonts.caption : isZoneBandLabel(l.id) ? fonts.tick : isZoneLabel(l.id) ? fonts.caption : l.kind === "annotation" || l.kind === "valueLine" || boldIds.has(l.id) || l.headLines !== void 0 ? { ...fonts.label, weight: emphasisWeight(theme) } : fonts.label
|
|
2564
|
+
);
|
|
2565
|
+
return { labels, nodes };
|
|
2566
|
+
}
|
|
2567
|
+
function assembleScatterGeometry(input) {
|
|
2568
|
+
let { env, domain, frame, geometry, solved, annotated } = input, { bubbleMode, pts, xMin, xMax, yMin, yMax, sizeMax, clamp, dropped } = domain, quadrants = domain.quadrants.derived, zonesDerived = geometry.zones.derived, boldIds = new Set(bubbleMode && !gridZones(env.options) ? [] : pts.filter((p) => env.highlights.has(p.id) || p.group !== void 0 && env.highlights.has(p.group)).map((p) => `point:${p.id}`)), emitted = scatterLabels(input.env.theme, input.area, solved, annotated, boldIds), biggest = bubbleMode ? [...geometry.placed].sort((a, b) => (b.p.size ?? 0) - (a.p.size ?? 0) || a.p.idx - b.p.idx)[0] : void 0, a11yDesc = scatterDescription({
|
|
2569
|
+
options: env.options,
|
|
2570
|
+
bubbleMode,
|
|
2571
|
+
pointCount: pts.length,
|
|
2572
|
+
groupNames: domain.shownGroups.map((g) => g.label),
|
|
2573
|
+
extent: { xMin, xMax, yMin, yMax },
|
|
2574
|
+
log: env.log,
|
|
2575
|
+
fmt: env.fmt,
|
|
2576
|
+
axisFmt: env.axisFmt,
|
|
2577
|
+
sizeBy: env.options.sizeBy ?? "area",
|
|
2578
|
+
...bubbleMode && biggest ? { biggest: { label: biggest.p.label, size: biggest.p.size ?? 0 } } : {},
|
|
2579
|
+
quadrants,
|
|
2580
|
+
zones: zonesDerived,
|
|
2581
|
+
zoneDescriptions: geometry.zones.descriptions,
|
|
2582
|
+
clipped: clamp?.records ?? [],
|
|
2583
|
+
reversedY: env.va.reverse === !0,
|
|
2584
|
+
dropped,
|
|
2585
|
+
trends: domain.trends,
|
|
2586
|
+
frontier: domain.frontier,
|
|
2587
|
+
pointLabel: (id) => pts.find((p) => p.id === id)?.label ?? id,
|
|
2588
|
+
groupLabel: (id) => domain.groups.get(id)?.label ?? id
|
|
2589
|
+
});
|
|
2590
|
+
return {
|
|
2591
|
+
type: "scatter",
|
|
2592
|
+
size: env.size,
|
|
2593
|
+
plot: input.area.plot,
|
|
2594
|
+
scene: [...frame.nodes, ...geometry.nodes, ...annotated.nodes, ...emitted.nodes],
|
|
2595
|
+
labels: emitted.labels,
|
|
2596
|
+
axes: geometry.axes,
|
|
2597
|
+
annotations: annotated.placed,
|
|
2598
|
+
legend: frame.legend,
|
|
2599
|
+
frame: frame.frame,
|
|
2600
|
+
marks: geometry.marks,
|
|
2601
|
+
derived: {
|
|
2602
|
+
xExtent: [xMin, xMax],
|
|
2603
|
+
yExtent: [yMin, yMax],
|
|
2604
|
+
...sizeMax !== void 0 ? { sizeMax } : {},
|
|
2605
|
+
...quadrants ? { quadrants } : {},
|
|
2606
|
+
...zonesDerived ? { zones: zonesDerived } : {},
|
|
2607
|
+
...clamp && clamp.records.length > 0 ? { clipped: clamp.records } : {},
|
|
2608
|
+
...dropped ? { dropped } : {},
|
|
2609
|
+
...domain.trends.length > 0 ? { trends: domain.trends } : {},
|
|
2610
|
+
...domain.frontier ? { frontier: domain.frontier } : {}
|
|
2611
|
+
},
|
|
2612
|
+
a11y: {
|
|
2613
|
+
title: accessibleTitle(env.options.title, chartString(env.options, "scatterTitle", { v1: bubbleMode ? chartString(env.options, "bubbleName") : chartString(env.options, "scatterName"), v2: pts.length })),
|
|
2614
|
+
counts: [
|
|
2615
|
+
structureCount("points", pts.length, void 0, env.options),
|
|
2616
|
+
...domain.shownGroups.length ? [structureCount("groups", domain.shownGroups.length, chartString(env.options, "groupsCount", { v1: domain.shownGroups.length, v2: domain.shownGroups.length === 1 ? "" : "s" }))] : [],
|
|
2617
|
+
...quadrants ? QUADRANT_BOXES.map((box) => structureCount("points", quadrants.counts[box], `${quadrantBoxName(box, env.options)} ${quadrants.counts[box]}`)) : [],
|
|
2618
|
+
...zonesDerived ? [zonesDerived.kind === "grid" ? structureCount("cells", zonesDerived.cellCount, chartString(env.options, "gridCellsCount", { v1: zonesDerived.cellCount })) : structureCount("regions", zonesDerived.regionCount, chartString(env.options, "authoredRegionsCount", { v1: zonesDerived.regionCount }))] : [],
|
|
2619
|
+
...(clamp?.records ?? []).map((record) => structureCount("points", record.count, chartString(env.options, "pointsCount", { v1: record.count, v2: record.count === 1 ? "" : "s" }))),
|
|
2620
|
+
...dropped ? [structureCount("points", dropped.count, chartString(env.options, "pointsCount", { v1: dropped.count, v2: dropped.count === 1 ? "" : "s" }))] : [],
|
|
2621
|
+
...domain.trends.map((fit) => structureCount("points", fit.n, void 0, env.options)),
|
|
2622
|
+
...domain.frontier ? [structureCount("points", domain.frontier.ids.length, void 0, env.options)] : []
|
|
2623
|
+
],
|
|
2624
|
+
desc: a11yDesc
|
|
2625
|
+
},
|
|
2626
|
+
warnings: input.warnings,
|
|
2627
|
+
debug: {
|
|
2628
|
+
occupied: input.occupied.snapshot(),
|
|
2629
|
+
decisions: [...solved.decisions, ...annotated.decisions]
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
function notListed(geometry) {
|
|
2634
|
+
let text = geometry.scene.flatMap((node) => node.t === "text" && node.part === "footnote" ? node.lines : []).join(" ");
|
|
2635
|
+
return geometry.labels.some((label) => label.hidden && /^(point|value):/.test(String(label.id)) && !text.includes(label.text));
|
|
2636
|
+
}
|
|
2637
|
+
var NAME_APART_ROUNDS = 3;
|
|
2638
|
+
function readsAsOne(a, b) {
|
|
2639
|
+
let h = Math.min(a.h, b.h), sameLine = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y) > h / 2, gap = Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w));
|
|
2640
|
+
return sameLine && gap < 2 * h;
|
|
2641
|
+
}
|
|
2642
|
+
function probeSolveOn(requests, occupied, ctx, size) {
|
|
2643
|
+
let index = copyOccupied(occupied, size);
|
|
2644
|
+
return { result: solveLabels(requests, index, ctx), index };
|
|
2645
|
+
}
|
|
2646
|
+
function keepNamesApart(requests, occupied, ctx, size, first) {
|
|
2647
|
+
let names = new Map(requests.filter((r) => String(r.id).startsWith("point:")).map((r) => [r.id, r])), start = first ?? probeSolveOn(requests, occupied, ctx, size);
|
|
2648
|
+
if (names.size < 2) return start;
|
|
2649
|
+
let original = /* @__PURE__ */ new Map(), probeSolve = () => probeSolveOn(requests, occupied, ctx, size).result.placed.filter((l) => names.has(l.id)), all = start.result.placed.filter((l) => names.has(l.id)), hiddenAtStart = all.filter((l) => l.hidden).length;
|
|
2650
|
+
for (let round = 0; round < NAME_APART_ROUNDS; round++) {
|
|
2651
|
+
let placed = all.filter((l) => !l.hidden), losers = /* @__PURE__ */ new Set();
|
|
2652
|
+
for (let i = 0; i < placed.length; i++)
|
|
2653
|
+
for (let j = i + 1; j < placed.length; j++) {
|
|
2654
|
+
let a = placed[i], b = placed[j];
|
|
2655
|
+
if (!readsAsOne(a.rect, b.rect)) continue;
|
|
2656
|
+
let ra = names.get(a.id), rb = names.get(b.id), [label, request, other] = ra.priority < rb.priority || ra.priority === rb.priority && a.id > b.id ? [a, ra, b] : [b, rb, a];
|
|
2657
|
+
losers.has(label.id) || request.candidates.length < 2 || (losers.add(label.id), original.has(label.id) || original.set(label.id, request.candidates), request.candidates = request.candidates.filter((c) => c.slot !== label.slot && !readsAsOne(c.rect, other.rect)));
|
|
2658
|
+
}
|
|
2659
|
+
if (losers.size === 0) break;
|
|
2660
|
+
all = probeSolve();
|
|
2661
|
+
}
|
|
2662
|
+
if (original.size === 0) return start;
|
|
2663
|
+
if (all.filter((l) => l.hidden).length > hiddenAtStart) {
|
|
2664
|
+
for (let [id, candidates] of original) names.get(id).candidates = candidates;
|
|
2665
|
+
return start;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
function seatLostNames(requests, occupied, ctx, size, first, dots = !1) {
|
|
2669
|
+
let names = new Map(requests.filter((r) => String(r.id).startsWith("point:")).map((r) => [r.id, r])), all = first, seated;
|
|
2670
|
+
if (names.size < 2 || seatProbe.left <= 0) return;
|
|
2671
|
+
let pad = ctx.labelPad ?? 2, lostNames = (placed) => placed.filter((l) => l.hidden && names.has(l.id));
|
|
2672
|
+
lost: for (let lost of lostNames(all)) {
|
|
2673
|
+
let request = names.get(lost.id), hiddenBefore = lostNames(all).length;
|
|
2674
|
+
for (let seat of request.candidates) {
|
|
2675
|
+
if (occupied.hitsWhich(seat.rect, seat.pad ?? pad).some((o) => !(seat.overRules && o.part === "referenceLine") && !(o.kind === "mark" && o.owner.pointId === request.owner.pointId))) continue;
|
|
2676
|
+
let blockers = all.filter((l) => !l.hidden && names.has(l.id) && l.id !== lost.id && rectsOverlap(l.rect, seat.rect, pad));
|
|
2677
|
+
if (blockers.length === 0 || blockers.length > 2) continue;
|
|
2678
|
+
let saved = blockers.map((l) => [names.get(l.id), names.get(l.id).candidates]);
|
|
2679
|
+
for (let [other] of saved) other.candidates = other.candidates.filter((c) => !rectsOverlap(c.rect, seat.rect, pad));
|
|
2680
|
+
let free = (other) => other.candidates.some((c) => !occupied.hitsWhich(c.rect, c.pad ?? pad).some((o) => !(o.kind === "mark" && o.owner.pointId === other.owner.pointId)) && !all.some((l) => !l.hidden && names.has(l.id) && l.id !== other.id && rectsOverlap(l.rect, c.rect, pad)));
|
|
2681
|
+
if (saved.every(([other]) => other.candidates.length > 0 && (!dots || free(other)))) {
|
|
2682
|
+
if (seatProbe.left <= 0) {
|
|
2683
|
+
for (let [other, candidates] of saved) other.candidates = candidates;
|
|
2684
|
+
break lost;
|
|
2685
|
+
}
|
|
2686
|
+
seatProbe.left--;
|
|
2687
|
+
let probe = probeSolveOn(requests, occupied, ctx, size), next = probe.result.placed;
|
|
2688
|
+
if (lostNames(next).length < hiddenBefore && !next.find((l) => l.id === lost.id)?.hidden) {
|
|
2689
|
+
all = next, seated = probe;
|
|
2690
|
+
break;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
for (let [other, candidates] of saved) other.candidates = candidates;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
return seated;
|
|
2697
|
+
}
|
|
2698
|
+
function commitClaims(occupied, phase) {
|
|
2699
|
+
for (let c of phase.snapshot()) occupied.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
|
|
2700
|
+
}
|
|
2701
|
+
function copyOccupied(occupied, size) {
|
|
2702
|
+
let copy = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height });
|
|
2703
|
+
return commitClaims(copy, occupied), occupied.tickColumns && (copy.tickColumns = [...occupied.tickColumns]), copy;
|
|
2704
|
+
}
|
|
2705
|
+
var SIZE_KEY_MAX_SHARE = 0.125;
|
|
2706
|
+
function scatterKeyItems(env, domain, paints, area, warnings, sizesInRow = !0) {
|
|
2707
|
+
let items = [];
|
|
2708
|
+
items.push(...zoneKeyItems(env.options)), domain.frontier && items.push({ id: "frontier", label: env.options.frontier?.label ?? chartString(env.options, "paretoLine"), paint: { token: "ink" }, key: "line", dash: dashToken(env.theme, "dotted"), lineCap: "round", width: strokeToken(env.theme, "rule") });
|
|
2709
|
+
let trend = env.options.trend, named = typeof trend == "object" && trend.label ? trend.label : chartString(env.options, "linearTrend"), rate = trendRateFormatter(
|
|
2710
|
+
env.options.axisFormat?.y ?? env.options.format,
|
|
2711
|
+
env.options.locale?.language,
|
|
2712
|
+
domain.pts.some((p) => p.yIsPct) ? "%" : env.options.unit
|
|
2713
|
+
);
|
|
2714
|
+
for (let fit of domain.trends) {
|
|
2715
|
+
let group = fit.group === void 0 ? "" : `, ${domain.groups.get(fit.group)?.label ?? fit.group}`, slope = rate(fit.slope), r2 = fit.r2 === null ? "undefined" : formatAutomaticNumber(fit.r2, { locale: env.options.locale?.language, decimals: 2 });
|
|
2716
|
+
items.push({
|
|
2717
|
+
id: `trend:${fit.id}`,
|
|
2718
|
+
// The fit's own numbers, printed where the line is keyed.
|
|
2719
|
+
label: chartString(env.options, "trendFitLabel", { v1: named, v2: group, v3: slope, v4: r2 }),
|
|
2720
|
+
paint: fit.group === void 0 ? { token: "ink" } : paints.group(fit.group),
|
|
2721
|
+
key: "line",
|
|
2722
|
+
dash: dashToken(env.theme, "reference"),
|
|
2723
|
+
width: strokeToken(env.theme, "rule")
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
if (domain.omitted.length > 0 && !disclosuresShown(env.options) && items.push(omittedKey("__omitted", domain.omitted.join(" "))), sizesInRow && area && domain.bubbleMode && domain.sizeMax && env.options.sizeLegend !== !1) {
|
|
2727
|
+
let rowH = spaceTokens(env.theme, env.size.width).legendRowH, maxRadius = Math.max(rowH, SIZE_KEY_MAX_SHARE * env.size.height) / 2, sizeMin = domain.pts.reduce((min, p) => p.size !== null && p.size > 0 ? Math.min(min, p.size) : min, 1 / 0);
|
|
2728
|
+
items.push(...sizeKeyItems(env, sizeMin, domain.sizeMax, (size) => area.radiusOf({ size }), maxRadius, warnings));
|
|
2729
|
+
}
|
|
2730
|
+
return items;
|
|
2731
|
+
}
|
|
2732
|
+
function sizeKeyInPlot(env, domain) {
|
|
2733
|
+
let { options } = env;
|
|
2734
|
+
return domain.bubbleMode && domain.sizeMax !== void 0 && domain.sizeMax > 0 && options.sizeLegend !== !1 && options.legend !== "none" && options.zones === void 0;
|
|
2735
|
+
}
|
|
2736
|
+
function scatterLateNotes(env, domain, area) {
|
|
2737
|
+
let notes = [], titles = env.options.axisTitles ?? {};
|
|
2738
|
+
if (area.showAxes && notes.push(...noteLine(chartString(env.options, "axesUntitled"), [...titles.x ? [] : [chartString(env.options, "horizontal")], ...titles.y ? [] : [chartString(env.options, "vertical")]])), domain.bubbleMode) {
|
|
2739
|
+
let drawn = domain.pts.filter((p) => inView(env.options, domain.dx, domain.dy, p) && p.marker !== "none"), names = (pick) => drawn.filter(pick).map((p) => p.label).join(", "), parts = [
|
|
2740
|
+
[chartString(env.options, "sizeZeroRing"), names((p) => sizeMarkerOf(p) === "zero")],
|
|
2741
|
+
[chartString(env.options, "sizeAbsentPlus"), names((p) => sizeMarkerOf(p) === "missing")],
|
|
2742
|
+
[chartString(env.options, "sizeInvalidCross"), names((p) => sizeMarkerOf(p) === "invalid")],
|
|
2743
|
+
[chartString(env.options, "minimumDotSize"), names((p) => sizeMarkerOf(p) === void 0 && (p.size ?? 0) > 0 && area.radiusOf(p) <= area.radiusOf({ size: 0 }) + 1e-9)]
|
|
2744
|
+
].filter(([, who]) => who).map(([what, who]) => `${what} (${who})`);
|
|
2745
|
+
parts.length && notes.push(disclosureNote(chartString(env.options, "notDrawnScale", { v1: parts.join("; ") })));
|
|
2746
|
+
}
|
|
2747
|
+
let maxPointLabels = env.options.maxPointLabels ?? 300;
|
|
2748
|
+
return env.options.labels !== !1 && (env.options.labels?.point !== !1 || env.options.labels?.value === !0) && domain.pts.filter((p) => inView(env.options, domain.dx, domain.dy, p)).length > maxPointLabels && notes.push(disclosureNote(chartString(env.options, "pointLabelsOff", { v1: maxPointLabels }))), notes;
|
|
2749
|
+
}
|
|
2750
|
+
var KEY_LABEL_GAP = 12;
|
|
2751
|
+
function rectGap(a, b) {
|
|
2752
|
+
let dx = Math.max(0, a.x - (b.x + b.w), b.x - (a.x + a.w)), dy = Math.max(0, a.y - (b.y + b.h), b.y - (a.y + a.h));
|
|
2753
|
+
return Math.hypot(dx, dy);
|
|
2754
|
+
}
|
|
2755
|
+
var SEAT_PROBE_BUDGET = 8, DOT_SEAT_PROBES = 1, seatProbe = { left: SEAT_PROBE_BUDGET, dotLeft: DOT_SEAT_PROBES, depth: 0 };
|
|
2756
|
+
function layoutScatter(...args) {
|
|
2757
|
+
seatProbe.depth === 0 && (seatProbe.left = SEAT_PROBE_BUDGET, seatProbe.dotLeft = DOT_SEAT_PROBES), seatProbe.depth++;
|
|
2758
|
+
try {
|
|
2759
|
+
return layoutScatterRun(...args);
|
|
2760
|
+
} finally {
|
|
2761
|
+
seatProbe.depth--;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
function layoutScatterRun(data, options = {}, hiddenNames, run = 0, hideListed = !1, valueTier = 0, sizeKeyInRow = !1, calloutMode = "line", valueInsideOnly, keepKeyInPlot = !1) {
|
|
2765
|
+
let warnings = [], hiddenNote = hiddenNoteWith(options, (hiddenNames ?? []).map((text, i) => ({ id: `scatter:${i}`, text }))), env = { ...resolveScatterEnv(options, warnings), valueTier, valueInsideOnly }, domain = resolveScatterDomain(data, env, warnings);
|
|
2766
|
+
if (env.options.legend === "none" && domain.bubbleMode && domain.sizeMax && env.options.sizeLegend !== !1) {
|
|
2767
|
+
let sizeKey = typeof env.options.sizeLegend == "object" && env.options.sizeLegend.label ? env.options.sizeLegend.label : "bubble size";
|
|
2768
|
+
warnings.push({
|
|
2769
|
+
code: "legend-off",
|
|
2770
|
+
severity: "info",
|
|
2771
|
+
message: `legend: 'none' left the size key off: ${sizeKey}. Set legend to a value that shows it, or set sizeLegend: false to drop it on purpose.`
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
let paints = scatterPaints(env, domain.groups, domain.pts, domain.bubbleMode ? void 0 : scatterDotRadius(env, domain)), occupied = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), area, solvedFrame, ringRow = 0, keyInPlot = !sizeKeyInRow && sizeKeyInPlot(env, domain);
|
|
2775
|
+
for (let pass = 0; pass < 6; pass++) {
|
|
2776
|
+
let passWarnings = [], keyed = scatterKeyItems(env, domain, paints, area, passWarnings, !keyInPlot);
|
|
2777
|
+
ringRow = Math.max(pass >= 2 ? ringRow : 0, maxOf(keyed.map((item) => item.key === "sizes" ? Math.ceil(2 * Math.max(0.5, ...item.radii ?? [])) : 0)));
|
|
2778
|
+
let items = keyed.map((item) => item.key === "sizes" ? { ...item, ringRow } : item);
|
|
2779
|
+
solvedFrame = solveScatterFrame(env, domain, paints, items, area ? scatterLateNotes(env, domain, area) : [], hiddenNote);
|
|
2780
|
+
let next = scatterPlotArea(env, domain, solvedFrame.frame, passWarnings), stable = area !== void 0 && next.plot.w === area.plot.w && next.plot.h === area.plot.h;
|
|
2781
|
+
if (area = next, stable || pass === 5) {
|
|
2782
|
+
pushAll(warnings, passWarnings);
|
|
2783
|
+
break;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
let { frame, claims } = solvedFrame;
|
|
2787
|
+
commitClaims(occupied, claims);
|
|
2788
|
+
let geometry = layoutScatterMarks(env, domain, area, paints);
|
|
2789
|
+
geometry.densePoints && warnings.push({
|
|
2790
|
+
code: "scatter-dense-paths",
|
|
2791
|
+
severity: "info",
|
|
2792
|
+
message: `${geometry.densePoints} of ${geometry.placed.length} points are drawn as one path per colour (more than ${DENSE_POINTS}): dots carry no outline, so overlaps cannot be counted, and these points have no SVG element of their own`,
|
|
2793
|
+
suggest: "aggregate the points (a heatmap or histogram of the two values) where the reader must see how many overlap"
|
|
2794
|
+
});
|
|
2795
|
+
let plotKey;
|
|
2796
|
+
if (keyInPlot) {
|
|
2797
|
+
let sizeMin = domain.pts.reduce((min, p) => p.size !== null && p.size > 0 ? Math.min(min, p.size) : min, 1 / 0), boxes = domain.quadrants.derived ? ["tr", "br", "tl", "bl"].filter((box) => !domain.quadrants.voidBoxes.has(box)).map((box) => quadrantBoxRect(box, area.plot, geometry.split)) : [];
|
|
2798
|
+
if (plotKey = plotSizeKey(env, area, sizeMin, domain.sizeMax, geometry.claims, warnings, boxes), !plotKey) return layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, !0, calloutMode, valueInsideOnly);
|
|
2799
|
+
if (run === 0 && !hideListed && domain.quadrants.derived) {
|
|
2800
|
+
let lostWith = (rects) => {
|
|
2801
|
+
let probe = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height });
|
|
2802
|
+
commitClaims(probe, occupied), commitClaims(probe, geometry.claims);
|
|
2803
|
+
for (let rect of rects) probe.claim(rect, "legend", {}, "sizeKey");
|
|
2804
|
+
return occupied.tickColumns && (probe.tickColumns = [...occupied.tickColumns]), solveLabels(planScatterLabels(env, domain, area, geometry, paints, []), probe, scatterSolveCtx(env, area)).placed.filter((label) => label.hidden && String(label.id).startsWith("point:")).length;
|
|
2805
|
+
};
|
|
2806
|
+
if (lostWith(plotKey.rects) > lostWith([])) return layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, !0, calloutMode, valueInsideOnly);
|
|
2807
|
+
}
|
|
2808
|
+
geometry.nodes.push(...plotKey.nodes);
|
|
2809
|
+
for (let rect of plotKey.rects) geometry.claims.claim(rect, "legend", {}, "sizeKey");
|
|
2810
|
+
}
|
|
2811
|
+
commitClaims(occupied, geometry.claims);
|
|
2812
|
+
let solveCtx = scatterSolveCtx(env, area), merged = calloutMode !== "off" ? nameCallouts(env, domain, geometry) : { callouts: /* @__PURE__ */ new Map(), annotations: domain.annotations };
|
|
2813
|
+
env.callouts = merged.callouts, env.calloutWrap = calloutMode === "wrap";
|
|
2814
|
+
let isZero = (c) => c.kind === "axis" && c.part === "referenceLine", annIndex = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height });
|
|
2815
|
+
for (let c of occupied.snapshot()) isZero(c) || annIndex.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
|
|
2816
|
+
occupied.tickColumns && (annIndex.tickColumns = [...occupied.tickColumns]);
|
|
2817
|
+
let claimedBefore = annIndex.snapshot().length, annotated = annotateScatter(env, { ...domain, annotations: merged.annotations }, area, geometry, annIndex, solveCtx);
|
|
2818
|
+
for (let c of annIndex.snapshot().slice(claimedBefore)) occupied.claim(c.rect, c.kind, c.owner, c.part, c.polygon);
|
|
2819
|
+
let zeros = occupied.snapshot().filter(isZero);
|
|
2820
|
+
for (let label of annotated.labels) !label.hidden && zeros.some((z) => rectsOverlap(z.rect, label.rect)) && (label.halo = !0);
|
|
2821
|
+
for (let label of annotated.labels)
|
|
2822
|
+
if (!(label.hidden || !label.leader))
|
|
2823
|
+
for (let [a, b] of leaderPieces(label.leader.d, 16))
|
|
2824
|
+
occupied.claim({ x: Math.min(a.x, b.x) - 1, y: Math.min(a.y, b.y) - 1, w: Math.abs(b.x - a.x) + 2, h: Math.abs(b.y - a.y) + 2 }, "annotation", label.owner, "leader");
|
|
2825
|
+
let probes = /* @__PURE__ */ new Map(), probeKey = (tier, insideOnly) => `${tier}|${[...insideOnly ?? []].map(String).sort().join("\0")}`, probeAt = (tier, insideOnly) => {
|
|
2826
|
+
let key = probeKey(tier, insideOnly), probe = probes.get(key);
|
|
2827
|
+
return probe || (probe = probeSolveOn(planScatterLabels({ ...env, valueTier: tier, valueInsideOnly: insideOnly }, domain, area, geometry, paints, []), occupied, solveCtx, env.size), probes.set(key, probe)), probe.result.placed;
|
|
2828
|
+
}, seatless = (label) => label.hidden !== void 0 && label.slot === "none" && String(label.id).startsWith("point:"), demoteValues = (start) => {
|
|
2829
|
+
let insideOnly = new Set(start);
|
|
2830
|
+
for (let round = 0; round < 4; round++) {
|
|
2831
|
+
let before2 = insideOnly.size;
|
|
2832
|
+
for (let label of probeAt(0, insideOnly)) {
|
|
2833
|
+
let id = label.owner.pointId;
|
|
2834
|
+
!label.hidden || id === void 0 || !/^(point|value):/.test(String(label.id)) || seatless(label) || insideOnly.add(id);
|
|
2835
|
+
}
|
|
2836
|
+
if (insideOnly.size === before2) break;
|
|
2837
|
+
}
|
|
2838
|
+
return insideOnly;
|
|
2839
|
+
};
|
|
2840
|
+
if (run === 0 && !hideListed && valueTier < 2 && domain.bubbleMode && options.labels !== !1 && options.labels?.value === !0) {
|
|
2841
|
+
let lostAt = (tier, insideOnly) => {
|
|
2842
|
+
let placed = probeAt(tier, insideOnly), hidden = (prefix) => placed.filter((label) => label.hidden && String(label.id).startsWith(prefix) && !seatless(label)).length;
|
|
2843
|
+
return 1e3 * hidden("point:") + hidden("value:");
|
|
2844
|
+
}, best = { tier: valueTier, lost: lostAt(valueTier, valueInsideOnly), insideOnly: valueInsideOnly };
|
|
2845
|
+
if (valueTier === 0 && best.lost > 0) {
|
|
2846
|
+
let insideOnly = demoteValues(valueInsideOnly), lost2 = lostAt(0, insideOnly);
|
|
2847
|
+
lost2 < best.lost && (best = { tier: 0, lost: lost2, insideOnly });
|
|
2848
|
+
}
|
|
2849
|
+
for (let tier = valueTier + 1; tier <= 2 && best.lost > 0; tier++) {
|
|
2850
|
+
let lost2 = lostAt(tier);
|
|
2851
|
+
lost2 <= best.lost && (best = { tier, lost: lost2 });
|
|
2852
|
+
}
|
|
2853
|
+
env.valueTier = best.tier, env.valueInsideOnly = best.insideOnly;
|
|
2854
|
+
}
|
|
2855
|
+
let requests = planScatterLabels(env, domain, area, geometry, paints, warnings), byId = new Map(domain.pts.map((p) => [p.id, p])), valueText = new Map(requests.flatMap((request) => request.id.startsWith("value:") && request.owner.pointId !== void 0 ? [[request.owner.pointId, request.text]] : []));
|
|
2856
|
+
if (domain.bubbleMode && options.labels !== !1 && options.labels?.value === !0)
|
|
2857
|
+
for (let p of domain.pts) !valueText.has(p.id) && p.size !== null && valueText.set(p.id, pointValueText(env, domain, p, "size"));
|
|
2858
|
+
let listed = new Set(hiddenNames ?? []), named = new Set(requests.flatMap((request) => request.id.startsWith("point:") && request.owner.pointId !== void 0 ? [request.owner.pointId] : [])), noteText = (id, owner, text) => {
|
|
2859
|
+
let box = String(id).replace(/^quadrant:caption:/, "");
|
|
2860
|
+
if (String(id).startsWith("quadrant:caption:")) return { idx: -1, text: `${text} (${quadrantBoxName(box, env.options)})` };
|
|
2861
|
+
if (String(id).startsWith("zone:")) {
|
|
2862
|
+
let grid = options.zones?.grid, cell = grid?.cells?.find((cell2) => String(id) === `zone:label:${cell2.id}`);
|
|
2863
|
+
return { idx: -1, text: cell ? `${text} (${grid.y.length === 2 ? [chartString(env.options, "bottom"), chartString(env.options, "middle"), chartString(env.options, "top")][cell.row] : chartString(env.options, "rowCount", { v1: cell.row + 1 })} ${grid.x.length === 2 ? [chartString(env.options, "left"), chartString(env.options, "middle"), chartString(env.options, "right")][cell.column] : chartString(env.options, "columnCount", { v1: cell.column + 1 })})` : text };
|
|
2864
|
+
}
|
|
2865
|
+
let p = /^(point|value):/.test(String(id)) ? byId.get(owner.pointId) : void 0;
|
|
2866
|
+
if (!p) return;
|
|
2867
|
+
let value = valueText.get(p.id);
|
|
2868
|
+
if (String(id).startsWith("value:") && named.has(p.id) && value !== void 0)
|
|
2869
|
+
return { idx: p.idx, text: `${p.label}\xA0${value}`, valueFor: p.id };
|
|
2870
|
+
let sp = "\xA0";
|
|
2871
|
+
return { idx: p.idx, text: `${p.label}${sp}(${env.axisFmt.x(p.x)},${sp}${env.axisFmt.y(p.y)})${value !== void 0 && domain.bubbleMode ? `${sp}${value}` : ""}` };
|
|
2872
|
+
};
|
|
2873
|
+
if (hideListed)
|
|
2874
|
+
for (let request of requests) {
|
|
2875
|
+
let pointText = request.id.startsWith("value:") ? noteText(`point:${request.owner.pointId}`, request.owner, request.text)?.text : void 0;
|
|
2876
|
+
!listed.has(noteText(request.id, request.owner, request.text)?.text ?? "") && !(pointText !== void 0 && listed.has(pointText)) || (request.redundant = !0, request.suppressedAs = "density");
|
|
2877
|
+
}
|
|
2878
|
+
let unmoved = keepNamesApart(requests, occupied, solveCtx, env.size, hideListed ? void 0 : probes.get(probeKey(env.valueTier ?? 0, env.valueInsideOnly))), before = occupied, solved;
|
|
2879
|
+
unmoved ? (solved = unmoved.result, occupied = unmoved.index) : (occupied = copyOccupied(before, env.size), solved = solveLabels(requests, occupied, solveCtx));
|
|
2880
|
+
let lostPoints = solved.placed.filter((label) => label.hidden && String(label.id).startsWith("point:")).length, spare = domain.bubbleMode ? 0 : Math.max(0, seatProbe.left - seatProbe.dotLeft);
|
|
2881
|
+
seatProbe.left -= spare;
|
|
2882
|
+
let leftBefore = seatProbe.left, seated = lostPoints > 0 && (domain.bubbleMode || lostPoints === 1) ? seatLostNames(requests, before, solveCtx, env.size, solved.placed, !domain.bubbleMode) : void 0;
|
|
2883
|
+
domain.bubbleMode || (seatProbe.dotLeft -= leftBefore - seatProbe.left), seatProbe.left += spare, seated && (solved = seated.result, occupied = seated.index);
|
|
2884
|
+
let lostIn = (labels) => labels.reduce((sum, label) => sum + (label.hidden ? String(label.id).startsWith("point:") ? 1e3 : String(label.id).startsWith("value:") ? 1 : 0 : 0), 0), rowAlternative;
|
|
2885
|
+
if (plotKey && !sizeKeyInRow && !keepKeyInPlot && run === 0 && !hideListed && solved.placed.some((label) => !label.hidden && String(label.id).startsWith("point:") && plotKey.rects.some((rect) => rectGap(rect, label.rect) < KEY_LABEL_GAP))) {
|
|
2886
|
+
let inRow = layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, !0, calloutMode, valueInsideOnly);
|
|
2887
|
+
if (!domain.bubbleMode || domain.quadrants.derived || lostIn(inRow.labels) < 1e3) return inRow;
|
|
2888
|
+
rowAlternative = { geo: inRow, lost: lostIn(inRow.labels) };
|
|
2889
|
+
}
|
|
2890
|
+
let keepKey = keepKeyInPlot || rowAlternative !== void 0, pick = (inPlot) => !rowAlternative || lostIn(inPlot.labels) < rowAlternative.lost ? inPlot : rowAlternative.geo;
|
|
2891
|
+
if (merged.callouts.size > 0 && solved.placed.some((label) => label.hidden && String(label.id).startsWith("point:") && merged.callouts.has(label.owner.pointId)))
|
|
2892
|
+
return pick(layoutScatter(data, options, hiddenNames, run, hideListed, valueTier, sizeKeyInRow, calloutMode === "line" ? "wrap" : "off", valueInsideOnly, keepKey));
|
|
2893
|
+
let lostNames = new Set(solved.placed.filter((label) => label.hidden && String(label.id).startsWith("point:")).map((label) => label.owner.pointId)), entryFor = (label) => {
|
|
2894
|
+
let entry = noteText(label.id, label.owner, label.text);
|
|
2895
|
+
return entry?.valueFor !== void 0 && lostNames.has(entry.valueFor) ? noteText(`point:${entry.valueFor}`, label.owner, label.text) : entry;
|
|
2896
|
+
}, lost = solved.placed.flatMap((label) => {
|
|
2897
|
+
let entry = label.hidden ? entryFor(label) : void 0;
|
|
2898
|
+
return entry ? [entry] : [];
|
|
2899
|
+
}), lostTexts = [...new Set(lost.sort((a, b) => a.idx - b.idx).map((entry) => entry.text))], complete = lostTexts.every((text) => listed.has(text)), exact = complete && lostTexts.length === listed.size;
|
|
2900
|
+
if (!exact && run < 4 && (lostTexts.length > 0 || listed.size > 0)) {
|
|
2901
|
+
let next = complete ? lostTexts : run === 3 ? [.../* @__PURE__ */ new Set([...listed, ...lostTexts])] : lostTexts;
|
|
2902
|
+
if (next.length !== listed.size || next.some((text) => !listed.has(text))) {
|
|
2903
|
+
let attempt = layoutScatter(data, options, next, run + 1, hideListed, env.valueTier, sizeKeyInRow, calloutMode, env.valueInsideOnly, keepKey);
|
|
2904
|
+
if (!complete || !notListed(attempt)) return pick(attempt);
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
if (complete && !exact && !hideListed) return pick(layoutScatter(data, options, hiddenNames, run, !0, env.valueTier, sizeKeyInRow, calloutMode, env.valueInsideOnly, keepKey));
|
|
2908
|
+
let own = solved.placed.filter((label) => label.hidden && listed.has(entryFor(label)?.text ?? "")), notedIds = new Set([...solved.placed.filter((label) => label.noted), ...own].map((label) => label.id));
|
|
2909
|
+
pushAll(warnings, solved.warnings.map((warning) => warning.code === "label-hidden" && notedIds.has(warning.message.match(/label '([^']+)'/)?.[1] ?? "") ? { ...warning, severity: "info" } : warning)), pushAll(warnings, annotated.warnings);
|
|
2910
|
+
let drawn = assembleScatterGeometry({ env, domain, frame, area, geometry, solved, annotated, occupied, warnings }), names = [...hiddenNames ?? []], counted = new Set([...hiddenNote.counted].filter((id) => !id.startsWith("scatter:")));
|
|
2911
|
+
for (let label of own) {
|
|
2912
|
+
let at = names.indexOf(entryFor(label)?.text ?? "");
|
|
2913
|
+
hiddenNote.counted.has(`scatter:${at}`) && counted.add(label.id);
|
|
2914
|
+
}
|
|
2915
|
+
markNotedLabels(drawn, new Set([...hiddenNote.ids].filter((id) => !id.startsWith("scatter:")).concat(own.map((label) => label.id))), counted);
|
|
2916
|
+
for (let label of own) label.noted = !0;
|
|
2917
|
+
return pick(drawn);
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
// src/core/charts/scatter/core.ts
|
|
2921
|
+
var scatterCore = {
|
|
2922
|
+
type: "scatter",
|
|
2923
|
+
sizing: chartSizing("scatter"),
|
|
2924
|
+
title: "Scatter / bubble",
|
|
2925
|
+
summary: "XY point cloud with group colors, spiral point labels, and area-true bubbles",
|
|
2926
|
+
aliases: ["bubble"],
|
|
2927
|
+
layout: layoutScatter,
|
|
2928
|
+
defaults: { sizeBy: "area", maxPointLabels: 300 },
|
|
2929
|
+
annotationKinds: ["diff", "delta", "abs", "note", "callout", "valueLine"]
|
|
2930
|
+
};
|
|
2931
|
+
|
|
2932
|
+
export {
|
|
2933
|
+
scatterCore
|
|
2934
|
+
};
|