@diagrammo/dgmo 0.53.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/dist/advanced.d.ts +112 -9
  2. package/dist/advanced.js +188 -160
  3. package/dist/auto.js +147 -132
  4. package/dist/auto.mjs +2352 -746
  5. package/dist/block.js +65 -62
  6. package/dist/chart-meta.js +52 -49
  7. package/dist/{charts-d3-DH2XA45I.js → charts-d3-KZ6V4OP2.js} +10 -8
  8. package/dist/chunk-2CW5ZTNH.js +58 -0
  9. package/dist/{chunk-MA3HJZHB.js → chunk-2HX6ZGY7.js} +7 -7
  10. package/dist/{chunk-YG2BEIQU.js → chunk-2R6HG6D5.js} +11 -11
  11. package/dist/{chunk-65V6IRFN.js → chunk-2ZJXKJSI.js} +106 -60
  12. package/dist/{chunk-PYO4TJJ3.js → chunk-32HUNA33.js} +60 -18
  13. package/dist/{chunk-UK6DKJLD.js → chunk-3BFXELBL.js} +51 -4
  14. package/dist/{chunk-RW5PEJ7D.js → chunk-3BZJ5KD5.js} +7 -3
  15. package/dist/{chunk-FT7TPPZ5.js → chunk-3FUTFYSP.js} +65 -26
  16. package/dist/{chunk-QAALSCKI.js → chunk-4MZCJV4M.js} +12 -12
  17. package/dist/{chunk-ZXUAPTCK.js → chunk-4R5KIPNX.js} +2 -2
  18. package/dist/{chunk-QWIBT6DS.js → chunk-5D5VHDJM.js} +49 -14
  19. package/dist/{chunk-U7NKYLX2.js → chunk-5H5GWWA4.js} +55 -19
  20. package/dist/{chunk-P3H7QVDH.js → chunk-5K5XBEXT.js} +11 -6
  21. package/dist/{chunk-PT4SW76W.js → chunk-6NJWBMJV.js} +49 -14
  22. package/dist/{chunk-I46X5VUA.js → chunk-7TF3QOOD.js} +25 -1
  23. package/dist/{chunk-6DCOIN4W.js → chunk-A2ARDILY.js} +783 -3
  24. package/dist/{chunk-CK2GMDXD.js → chunk-A2PTRSAO.js} +2 -2
  25. package/dist/{chunk-APKUAJ2L.js → chunk-A2RUBBVT.js} +14 -1
  26. package/dist/{chunk-GMIJ35PW.js → chunk-A4UJP4IS.js} +68 -20
  27. package/dist/{chunk-LQHVDZYC.js → chunk-AKE6C2D7.js} +4 -4
  28. package/dist/{chunk-W5KMNC5U.js → chunk-ASPS5O6F.js} +9 -10
  29. package/dist/{chunk-FLDC7ZAK.js → chunk-AU75JHSR.js} +6 -3
  30. package/dist/chunk-BEOAKGNA.js +484 -0
  31. package/dist/{chunk-XY3UDKKH.js → chunk-COVYNAKJ.js} +4 -4
  32. package/dist/{chunk-4ASVFYB2.js → chunk-DS4MDEQ7.js} +5 -5
  33. package/dist/{chunk-7JDTNFAK.js → chunk-EFUQENO5.js} +76 -32
  34. package/dist/{chunk-BULHGPHK.js → chunk-EMSOFHEN.js} +2 -2
  35. package/dist/{chunk-3BEKKRH5.js → chunk-ETTDF3S2.js} +49 -11
  36. package/dist/{chunk-JHOAH4TI.js → chunk-ETYF5QZR.js} +2 -2
  37. package/dist/{chunk-AHXIMHDQ.js → chunk-F5ZNUMSY.js} +53 -14
  38. package/dist/{chunk-I64ECJX3.js → chunk-FBP33UM6.js} +3 -3
  39. package/dist/{chunk-VIRANCNY.js → chunk-FGAMFJNJ.js} +58 -20
  40. package/dist/{chunk-774C2FF3.js → chunk-GRXPFBYC.js} +24 -3
  41. package/dist/{chunk-NNYFQOTK.js → chunk-GTO5VCYG.js} +10 -8
  42. package/dist/{chunk-RJ5LBZ5U.js → chunk-HES4K6DV.js} +13 -13
  43. package/dist/{chunk-AZNXGWDC.js → chunk-HGKOVKAX.js} +7 -7
  44. package/dist/{chunk-DWUMPMV2.js → chunk-HLGOG44K.js} +2 -2
  45. package/dist/{chunk-VJHBSPGF.js → chunk-HUTP35XT.js} +5 -4
  46. package/dist/{chunk-3CZLWOCI.js → chunk-HX7QNHC6.js} +3 -3
  47. package/dist/{chunk-R5NH5BZG.js → chunk-IALX52TR.js} +6 -6
  48. package/dist/{chunk-A44USUV7.js → chunk-ICZ7M6IZ.js} +23 -17
  49. package/dist/{chunk-27STWBOK.js → chunk-IF4KYSJZ.js} +10 -8
  50. package/dist/{chunk-HORZ5H2L.js → chunk-IG6J7JWH.js} +61 -22
  51. package/dist/{chunk-VRRDUYOK.js → chunk-IIUYKQ5J.js} +3 -3
  52. package/dist/{chunk-GMAH572Z.js → chunk-INTAQV2Y.js} +2 -2
  53. package/dist/{chunk-6AUZPPAV.js → chunk-ITXL2KU5.js} +2 -2
  54. package/dist/{chunk-KKHCNSKK.js → chunk-IWG2ECAO.js} +5 -5
  55. package/dist/{chunk-GQ644SPD.js → chunk-JGCEFKZP.js} +14 -14
  56. package/dist/{chunk-HNBY6CNV.js → chunk-JQLSFZZP.js} +2 -2
  57. package/dist/{chunk-CMVZWP32.js → chunk-JR7Q6GHE.js} +2 -2
  58. package/dist/{chunk-LHILKFDP.js → chunk-KC3WBBI7.js} +9 -9
  59. package/dist/{chunk-GABSL6TH.js → chunk-KK3L5NVK.js} +3 -3
  60. package/dist/{chunk-LC3FFD43.js → chunk-L2DIXZUT.js} +98 -48
  61. package/dist/{chunk-4WGMGKCZ.js → chunk-LCRPGGGS.js} +11 -11
  62. package/dist/{chunk-6KY7OCZC.js → chunk-LKGQ46P4.js} +3 -3
  63. package/dist/{chunk-HE5J53SZ.js → chunk-LW7STMYZ.js} +3 -3
  64. package/dist/{chunk-BD3WGY4T.js → chunk-M53MDBIW.js} +2 -2
  65. package/dist/{chunk-AN2DQB3G.js → chunk-MEH4TJEX.js} +12 -12
  66. package/dist/{chunk-SGPFVDUL.js → chunk-MNS2ENXF.js} +6 -6
  67. package/dist/{chunk-FXCB7H5O.js → chunk-MSWIBF6J.js} +2 -2
  68. package/dist/{chunk-BR7AYN76.js → chunk-NL7FUIVD.js} +12 -12
  69. package/dist/{chunk-AIMLCDAO.js → chunk-NN5TF4OV.js} +2 -2
  70. package/dist/{chunk-7GUF6SDR.js → chunk-NPPUZ4SK.js} +9 -9
  71. package/dist/{chunk-4K42RUGC.js → chunk-NYOOPQFD.js} +47 -12
  72. package/dist/{chunk-FFXCKZOU.js → chunk-O4CZDTQA.js} +3 -3
  73. package/dist/{chunk-6HTRCTAS.js → chunk-P5XXIVEU.js} +6 -4
  74. package/dist/{chunk-XEAQDIMF.js → chunk-PC4YLEKA.js} +6 -6
  75. package/dist/{chunk-Q7AH665U.js → chunk-PCVXXPYU.js} +121 -38
  76. package/dist/{chunk-W2DINCHL.js → chunk-PKUWYPI5.js} +207 -24
  77. package/dist/{chunk-PV2QO7QL.js → chunk-PSIDVCBA.js} +2 -2
  78. package/dist/{chunk-YR43LJT5.js → chunk-PV7ND5WL.js} +58 -15
  79. package/dist/{chunk-QI3BOLQB.js → chunk-Q5CMQVWF.js} +4 -4
  80. package/dist/{chunk-4RGZFA7H.js → chunk-Q5IHQ4NW.js} +11 -1
  81. package/dist/{chunk-SG4PRYO3.js → chunk-QQXFYTLC.js} +391 -60
  82. package/dist/{chunk-GWQJKTFS.js → chunk-QZYGRDMM.js} +118 -99
  83. package/dist/{chunk-CQFNIIQN.js → chunk-RKBCKCSF.js} +2 -2
  84. package/dist/{chunk-FUKNRLIJ.js → chunk-RSBH2C7O.js} +6 -6
  85. package/dist/{chunk-2QC4HXCY.js → chunk-RYNCWA5X.js} +11 -10
  86. package/dist/{chunk-NNUMX6WX.js → chunk-RZWIPDZ2.js} +40 -15
  87. package/dist/{chunk-VKNCC2GX.js → chunk-S52F62GW.js} +13 -13
  88. package/dist/{chunk-UQRIKAMH.js → chunk-SCOHNGPG.js} +59 -18
  89. package/dist/{chunk-VGNIDAPQ.js → chunk-SSHS42QG.js} +4 -4
  90. package/dist/chunk-TGOMHUOV.js +218 -0
  91. package/dist/{chunk-UKP5HWB5.js → chunk-UBQU2BY6.js} +4 -4
  92. package/dist/{chunk-IQJCVREL.js → chunk-UES4P7FN.js} +6 -6
  93. package/dist/chunk-US3P2DQO.js +87 -0
  94. package/dist/{chunk-GAWKIIPO.js → chunk-UXXLE6AH.js} +8 -8
  95. package/dist/{chunk-22OQWBWD.js → chunk-VMWSZCAK.js} +12 -11
  96. package/dist/{chunk-XG4NWFPY.js → chunk-VVIRAGID.js} +13 -13
  97. package/dist/{chunk-X3RXGSCZ.js → chunk-VXTUWXFB.js} +54 -15
  98. package/dist/{chunk-J7HI6G3G.js → chunk-W4TSD3IP.js} +6 -6
  99. package/dist/{chunk-FGDSTT3F.js → chunk-WB3NA3JJ.js} +2 -2
  100. package/dist/{chunk-KUSAVOWZ.js → chunk-WITOJZGL.js} +8 -4
  101. package/dist/{chunk-UVDCHR4E.js → chunk-WVGNXDEE.js} +2 -2
  102. package/dist/{chunk-HOXKNRON.js → chunk-X3X4LZDC.js} +2 -2
  103. package/dist/{chunk-SQCBSFT5.js → chunk-XKKH2DPG.js} +51 -263
  104. package/dist/{chunk-NR5HCAUD.js → chunk-XSVWUOUZ.js} +1 -1
  105. package/dist/{chunk-BFDVEO5R.js → chunk-Y4BBGFKY.js} +2 -2
  106. package/dist/{chunk-VAO6ANGC.js → chunk-YP2T5YUP.js} +14 -9
  107. package/dist/{chunk-PKNNHU7H.js → chunk-YXKNXIWA.js} +19 -11
  108. package/dist/{chunk-UFQJMOVZ.js → chunk-ZGIBV36U.js} +6 -6
  109. package/dist/{chunk-XQ4KN6JQ.js → chunk-ZP265ICS.js} +16 -15
  110. package/dist/{chunk-JTMSWEIW.js → chunk-ZWVKTWK6.js} +4 -4
  111. package/dist/{chunk-ALYZ3MAA.js → chunk-ZXNHHO6D.js} +8 -476
  112. package/dist/cli.cjs +166 -149
  113. package/dist/clock.js +34 -1
  114. package/dist/completion-registry.d.ts +129 -0
  115. package/dist/completion-registry.js +1278 -0
  116. package/dist/{compute-G55RG53N.js → compute-JAP5E2E4.js} +2 -2
  117. package/dist/dgmo-router-T4HGLIGA.js +88 -0
  118. package/dist/{dimensions-K6PGYYGT.js → dimensions-3JINHSYK.js} +8 -8
  119. package/dist/editor.js +28 -1
  120. package/dist/element.js +148 -133
  121. package/dist/element.mjs +2352 -746
  122. package/dist/{flowchart-parser-LALR6J6F.js → flowchart-parser-M7KKTLX7.js} +5 -5
  123. package/dist/{flowchart-renderer-DXYB5YRF.js → flowchart-renderer-FFEQFQEU.js} +9 -9
  124. package/dist/highlight.js +28 -1
  125. package/dist/index.js +77 -64
  126. package/dist/{layout-ZE5DRJWX.js → layout-3ZZBKUQC.js} +4 -4
  127. package/dist/{layout-3BVDMKXI.js → layout-AUKTWGYL.js} +4 -4
  128. package/dist/{layout-4IHCMWZN.js → layout-CRLTSFYQ.js} +4 -4
  129. package/dist/{layout-WCAIKGZG.js → layout-FNZDJGKF.js} +5 -5
  130. package/dist/layout-GHWRJKZQ.js +15 -0
  131. package/dist/{layout-3V2A4MUE.js → layout-LGXOKUCD.js} +6 -5
  132. package/dist/{layout-WSMPBQ4Q.js → layout-NF4EWFLT.js} +3 -3
  133. package/dist/{layout-OL2XFJXA.js → layout-SP7HJWKA.js} +3 -3
  134. package/dist/{layout-E6HR6PXH.js → layout-UR7CYAHL.js} +3 -3
  135. package/dist/layout-UTMEVFHN.js +15 -0
  136. package/dist/{layout-search-34DPZD43.js → layout-search-U2H4ORFJ.js} +14 -7
  137. package/dist/{legend-constants-P5EQWRQQ.js → legend-constants-B77VKB3R.js} +7 -2
  138. package/dist/{parser-6PPHAXXH.js → parser-2AXPSKWB.js} +5 -5
  139. package/dist/{parser-5HQXCNOS.js → parser-2AZ2KQTO.js} +4 -4
  140. package/dist/{parser-3KIGEEJM.js → parser-2LF33IS2.js} +4 -4
  141. package/dist/{parser-NNIL3HXU.js → parser-3QJ2Z4H4.js} +3 -3
  142. package/dist/parser-5GCQFSTQ.js +13 -0
  143. package/dist/{parser-6B6SSZT7.js → parser-62OHBRU5.js} +3 -3
  144. package/dist/{parser-VOERD6XR.js → parser-7LYJFZCP.js} +4 -4
  145. package/dist/{parser-ZGNXYFPS.js → parser-BMOTF72G.js} +3 -3
  146. package/dist/{parser-IVGHXLZP.js → parser-CIFLYZYP.js} +4 -3
  147. package/dist/{parser-GN2MM5CC.js → parser-D2UL2G5U.js} +3 -3
  148. package/dist/{parser-GKP2MHHL.js → parser-DM2APTKB.js} +3 -3
  149. package/dist/{parser-27Z76SN3.js → parser-DYYTPLBL.js} +4 -4
  150. package/dist/{parser-5FGJSQNS.js → parser-GOUGUTPU.js} +4 -4
  151. package/dist/{parser-G26MTBFS.js → parser-HGVUVD6J.js} +3 -3
  152. package/dist/{parser-EXNBDNGY.js → parser-IEJD3CZB.js} +3 -3
  153. package/dist/{parser-ZQDQTB4X.js → parser-JBEWNLAV.js} +5 -5
  154. package/dist/{parser-5QPFOB5F.js → parser-JMXPHNZD.js} +4 -4
  155. package/dist/{parser-4E4I3GNT.js → parser-JMXSQY3K.js} +4 -4
  156. package/dist/{parser-FF4BMRSB.js → parser-LUXS7J32.js} +4 -4
  157. package/dist/{parser-3VSWEKBF.js → parser-M5BUHULF.js} +4 -4
  158. package/dist/{parser-IKWK2ZU3.js → parser-MESRHUS4.js} +4 -5
  159. package/dist/{parser-3CODK6RG.js → parser-OOYNI2UT.js} +4 -4
  160. package/dist/{parser-YSLNDFLV.js → parser-PVBUAVRR.js} +4 -5
  161. package/dist/{parser-CKA3QMAG.js → parser-QKRBSQLJ.js} +5 -5
  162. package/dist/{parser-UWRX52PC.js → parser-S6NWSIJO.js} +4 -4
  163. package/dist/{parser-RNLTBIJ6.js → parser-SFEK6Q7Z.js} +4 -4
  164. package/dist/{parser-7JVIDLLR.js → parser-SUV52NQW.js} +4 -4
  165. package/dist/{parser-CRKLXGW7.js → parser-SZHGLOOZ.js} +4 -4
  166. package/dist/{parser-275KP7JO.js → parser-TO7IENWL.js} +5 -6
  167. package/dist/{parser-XNKJCMMA.js → parser-TVAMC7CQ.js} +4 -4
  168. package/dist/{parser-FOOFEJQU.js → parser-VAW46R57.js} +4 -4
  169. package/dist/{parser-XVPTRWZ4.js → parser-XDSPOXSE.js} +4 -4
  170. package/dist/pert.d.ts +2 -0
  171. package/dist/{renderer-D3BRNOMV.js → renderer-3PWLOJPD.js} +11 -11
  172. package/dist/{renderer-7NQSTQMQ.js → renderer-5EMHIQL5.js} +4 -4
  173. package/dist/{renderer-ZBTEX2JK.js → renderer-5PODNLYP.js} +4 -4
  174. package/dist/{renderer-6WRYVM5R.js → renderer-AQJIQ2XU.js} +9 -8
  175. package/dist/{renderer-JCZG6AYU.js → renderer-BEW3AYFT.js} +10 -10
  176. package/dist/{renderer-YUKPS27O.js → renderer-C3UYAXA6.js} +10 -8
  177. package/dist/{renderer-AK2WO4EI.js → renderer-CENXCMWG.js} +4 -4
  178. package/dist/{renderer-HIFQVEJA.js → renderer-CXM3ARYN.js} +10 -9
  179. package/dist/{renderer-JTCX6PCG.js → renderer-DW6TEBLA.js} +10 -9
  180. package/dist/{renderer-VMH6L6CP.js → renderer-FE5M6SEZ.js} +10 -9
  181. package/dist/{renderer-TYHGXAVT.js → renderer-FXK6ZL3P.js} +4 -4
  182. package/dist/{renderer-UPF7NRTI.js → renderer-G5ESLCJB.js} +12 -11
  183. package/dist/{renderer-CWEFGEIC.js → renderer-HTDS4FED.js} +14 -13
  184. package/dist/{renderer-XTXSOK3L.js → renderer-IO4KCFVL.js} +10 -10
  185. package/dist/{renderer-SQ54MDSA.js → renderer-IRAFJNTK.js} +10 -9
  186. package/dist/{renderer-JWGQSTMR.js → renderer-MFTTFW32.js} +15 -14
  187. package/dist/{renderer-2C6DJRYN.js → renderer-MPXI4FVL.js} +8 -8
  188. package/dist/{renderer-5MPN7CXZ.js → renderer-NVBEMQ6L.js} +5 -5
  189. package/dist/{renderer-7ZNVOVFG.js → renderer-OOGDCR6K.js} +3 -3
  190. package/dist/{renderer-COLQFSFV.js → renderer-Q5P72O4A.js} +9 -9
  191. package/dist/{renderer-WCWI4I6A.js → renderer-QZESC66H.js} +2 -2
  192. package/dist/{renderer-NE5W7CQP.js → renderer-RDBUXW7P.js} +6 -5
  193. package/dist/{renderer-6EN5XXJZ.js → renderer-S4XB3JR2.js} +11 -11
  194. package/dist/{renderer-WFSUBKUL.js → renderer-SIWEEWJ5.js} +9 -8
  195. package/dist/{renderer-LVZAHRP6.js → renderer-TKTM2SL4.js} +12 -12
  196. package/dist/{renderer-QD2SJF2I.js → renderer-TXTTV4HA.js} +10 -9
  197. package/dist/{renderer-YUXGXGSW.js → renderer-UZIU4AHK.js} +10 -9
  198. package/dist/{renderer-RLMOTXZ6.js → renderer-V72VJIGG.js} +14 -13
  199. package/dist/{renderer-UKXW2QPE.js → renderer-VEGOEZOI.js} +10 -8
  200. package/dist/{renderer-WNFXYYGL.js → renderer-W6I6T2TA.js} +8 -8
  201. package/dist/{renderer-KARQF3F3.js → renderer-WSHJRR2T.js} +8 -8
  202. package/dist/{renderer-radial-WF6VOUOD.js → renderer-radial-AG75PBYD.js} +9 -9
  203. package/dist/{resolver-WFKZYBJ2.js → resolver-ZSFQQRTH.js} +3 -3
  204. package/dist/{state-parser-L7DHZIQO.js → state-parser-KIPZGIB4.js} +5 -5
  205. package/dist/{state-renderer-TFEUOP4H.js → state-renderer-U6OSJG52.js} +13 -12
  206. package/docs/language-reference.md +2 -1
  207. package/package.json +5 -1
  208. package/dist/chunk-YJVA3QUU.js +0 -734
  209. package/dist/dgmo-router-B4S23EBH.js +0 -86
  210. package/dist/layout-3M5UYJHY.js +0 -14
  211. package/dist/layout-KPQWJNAG.js +0 -14
  212. package/dist/parser-7JHWEWXM.js +0 -13
@@ -12,9 +12,18 @@ import {
12
12
  renderChartTitle,
13
13
  resolveExportPalette
14
14
  } from "./chunk-ADYKAKE3.js";
15
+ import {
16
+ layoutInlineHeader
17
+ } from "./chunk-US3P2DQO.js";
15
18
  import {
16
19
  computeLegendLayout
17
- } from "./chunk-774C2FF3.js";
20
+ } from "./chunk-GRXPFBYC.js";
21
+ import {
22
+ TITLE_FONT_SIZE,
23
+ TITLE_FONT_WEIGHT,
24
+ TITLE_OFFSET,
25
+ TITLE_Y
26
+ } from "./chunk-A4GOY3PE.js";
18
27
  import {
19
28
  FONT_FAMILY
20
29
  } from "./chunk-6KFWC4CO.js";
@@ -23,7 +32,22 @@ import {
23
32
  getSimpleChartLegendGroups,
24
33
  parseChart,
25
34
  parseExtendedChart
26
- } from "./chunk-Q7AH665U.js";
35
+ } from "./chunk-PCVXXPYU.js";
36
+ import {
37
+ EMPHASIS_DIM_OPACITY,
38
+ EMPHASIS_DIM_TEXT_OPACITY,
39
+ resolveEmphasis
40
+ } from "./chunk-2CW5ZTNH.js";
41
+ import {
42
+ LEGEND_DOT_R,
43
+ LEGEND_ENTRY_FONT_SIZE,
44
+ LEGEND_HEIGHT,
45
+ LEGEND_PILL_FONT_SIZE,
46
+ legendChromeColors
47
+ } from "./chunk-Q5IHQ4NW.js";
48
+ import {
49
+ measureText
50
+ } from "./chunk-4ASYQ347.js";
27
51
  import {
28
52
  contrastText,
29
53
  getSegmentColors,
@@ -34,18 +58,9 @@ import {
34
58
  shapeFill,
35
59
  themeBaseBg
36
60
  } from "./chunk-JYDMBWRP.js";
37
- import {
38
- LEGEND_DOT_R,
39
- LEGEND_ENTRY_FONT_SIZE,
40
- LEGEND_HEIGHT,
41
- LEGEND_PILL_FONT_SIZE
42
- } from "./chunk-4RGZFA7H.js";
43
- import {
44
- measureText
45
- } from "./chunk-4ASYQ347.js";
46
61
  import {
47
62
  tagAttrKey
48
- } from "./chunk-CMVZWP32.js";
63
+ } from "./chunk-JR7Q6GHE.js";
49
64
 
50
65
  // src/utils/legend-svg.ts
51
66
  function esc(s) {
@@ -82,7 +97,10 @@ function renderLegendSvg(groups, options) {
82
97
  const wrapWidth = containerWidth > 0 ? containerWidth : 1200;
83
98
  const config = {
84
99
  groups,
85
- position: { placement: "top-center", titleRelation: "below-title" },
100
+ position: {
101
+ placement: "top-center",
102
+ titleRelation: options.align === "left" ? "inline-with-title" : "below-title"
103
+ },
86
104
  mode: "preview"
87
105
  };
88
106
  const state = { activeGroup: activeGroup ?? null };
@@ -90,8 +108,7 @@ function renderLegendSvg(groups, options) {
90
108
  if (!layout.activeCapsule && layout.pills.length === 0) {
91
109
  return { svg: "", height: 0, width: 0 };
92
110
  }
93
- const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
94
- const pillBorder = mix(palette.textMuted, palette.bg, 50);
111
+ const { groupBg, pillBorder } = legendChromeColors(palette, isDark);
95
112
  const parts = [];
96
113
  let bottom = 0;
97
114
  let left = Infinity;
@@ -142,7 +159,47 @@ function fmtNum(n) {
142
159
  if (Math.abs(n) >= 1e3) return n.toLocaleString("en-US");
143
160
  return String(Math.round(n * 100) / 100);
144
161
  }
145
- function reserveHeader(svg, chart, colors, palette, isDark, hasTitle, width) {
162
+ function renderInlineHeader(svg, groups, palette, isDark, width, info) {
163
+ const {
164
+ svg: legendSvg,
165
+ height: legendH,
166
+ width: legendW
167
+ } = renderLegendSvg(groups, {
168
+ palette,
169
+ isDark,
170
+ containerWidth: width,
171
+ activeGroup: groups[0].name,
172
+ className: "chart-legend",
173
+ align: "left"
174
+ });
175
+ if (!legendSvg) return null;
176
+ const geom = layoutInlineHeader({
177
+ requested: true,
178
+ title: info.title,
179
+ hasLegend: true,
180
+ legendWidth: legendW,
181
+ legendHeight: legendH,
182
+ containerWidth: width,
183
+ titleBandHeight: TITLE_OFFSET,
184
+ legendReserve: 0,
185
+ titleBaselineY: TITLE_Y,
186
+ titleFontSize: TITLE_FONT_SIZE
187
+ });
188
+ if (!geom.inline) return null;
189
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", geom.titleX).attr("y", TITLE_Y).attr("fill", info.textColor).attr("font-size", TITLE_FONT_SIZE).attr("font-weight", TITLE_FONT_WEIGHT).text(info.title);
190
+ if (info.titleLineNumber) {
191
+ titleEl.attr("data-line-number", info.titleLineNumber);
192
+ }
193
+ const node = svg.node();
194
+ if (node) {
195
+ node.insertAdjacentHTML(
196
+ "beforeend",
197
+ `<g transform="translate(${geom.legendX},${geom.legendY})">${legendSvg}</g>`
198
+ );
199
+ }
200
+ return TITLE_OFFSET + 12;
201
+ }
202
+ function reserveHeader(svg, chart, colors, palette, isDark, hasTitle, width, inlineTitle) {
146
203
  return injectLegendGroups(
147
204
  svg,
148
205
  // `no-legend` (#48) → pass no groups; injectLegendGroups then returns the
@@ -151,10 +208,31 @@ function reserveHeader(svg, chart, colors, palette, isDark, hasTitle, width) {
151
208
  palette,
152
209
  isDark,
153
210
  hasTitle,
154
- width
211
+ width,
212
+ inlineTitle
155
213
  );
156
214
  }
157
- function injectLegendGroups(svg, groups, palette, isDark, hasTitle, width) {
215
+ function injectLegendGroups(svg, groups, palette, isDark, hasTitle, width, inlineTitle) {
216
+ if (inlineTitle && groups.length > 0) {
217
+ const inset = renderInlineHeader(
218
+ svg,
219
+ groups,
220
+ palette,
221
+ isDark,
222
+ width,
223
+ inlineTitle
224
+ );
225
+ if (inset !== null) return inset;
226
+ }
227
+ if (inlineTitle) {
228
+ renderChartTitle(
229
+ svg,
230
+ inlineTitle.title,
231
+ inlineTitle.titleLineNumber,
232
+ width,
233
+ inlineTitle.textColor
234
+ );
235
+ }
158
236
  const titleH = hasTitle ? 40 : 0;
159
237
  if (groups.length === 0) return hasTitle ? titleH + 12 : 24;
160
238
  const legendY = 8 + titleH;
@@ -197,6 +275,7 @@ function tagDatum(sel, o) {
197
275
  if (o.name != null) sel.attr("data-name", o.name);
198
276
  if (o.value != null) sel.attr("data-value", String(o.value));
199
277
  if (o.color != null) sel.attr("data-color", o.color);
278
+ if (o.seriesName != null) sel.attr("data-series-name", o.seriesName);
200
279
  return sel;
201
280
  }
202
281
  function drawValueLabel(svg, text, x, y, color, anchor = "middle") {
@@ -211,7 +290,7 @@ function seriesValues(pt, seriesCount) {
211
290
  for (let s = 1; s < seriesCount; s++) out.push(pt.extraValues?.[s - 1] ?? 0);
212
291
  return out;
213
292
  }
214
- function renderBar(svg, chart, width, height, colors, palette, isDark, textColor, mutedColor, hasTitle) {
293
+ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor, mutedColor, hasTitle, inlineTitle) {
215
294
  const data = chart.data;
216
295
  const seriesNames = chart.seriesNames?.length ? chart.seriesNames : [chart.series ?? ""];
217
296
  const stacked = chart.barLayout === "stack";
@@ -226,7 +305,7 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
226
305
  const fillMode = chart.fillMode;
227
306
  const colorFor = (seriesIdx, catIdx, override) => {
228
307
  if (override) return override;
229
- return multiSeries ? colors[seriesIdx % colors.length] : colors[catIdx % colors.length];
308
+ return multiSeries ? chart.seriesNameColors?.[seriesIdx] ?? colors[seriesIdx % colors.length] : colors[catIdx % colors.length];
230
309
  };
231
310
  const fillOf = (c) => shapeFill(palette, c, isDark, { mode: fillMode });
232
311
  const top = reserveHeader(
@@ -236,7 +315,8 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
236
315
  palette,
237
316
  isDark,
238
317
  hasTitle,
239
- width
318
+ width,
319
+ inlineTitle
240
320
  );
241
321
  const perCat = data.map((d) => seriesValues(d, seriesCount));
242
322
  const maxVal = stacked ? d3max(perCat, (vals) => vals.reduce((a, b) => a + b, 0)) ?? 0 : d3max(perCat, (vals) => d3max(vals) ?? 0) ?? 0;
@@ -289,7 +369,8 @@ function renderBar(svg, chart, width, height, colors, palette, isDark, textColor
289
369
  key: multiSeries ? sName : d.label,
290
370
  name: multiSeries ? `${d.label} \xB7 ${sName}` : d.label,
291
371
  value: v,
292
- color: stroke
372
+ color: stroke,
373
+ seriesName: multiSeries ? sName : void 0
293
374
  };
294
375
  if (stacked) {
295
376
  if (horiz) {
@@ -402,7 +483,7 @@ import { line as d3line, area as d3area } from "d3-shape";
402
483
  function seriesValue(pt, s) {
403
484
  return s === 0 ? pt.value : pt.extraValues?.[s - 1] ?? 0;
404
485
  }
405
- function renderLine(svg, chart, width, height, colors, palette, isDark, textColor, mutedColor, bgColor, hasTitle) {
486
+ function renderLine(svg, chart, width, height, colors, palette, isDark, textColor, mutedColor, bgColor, hasTitle, inlineTitle) {
406
487
  const data = chart.data;
407
488
  const isArea = chart.fill === true;
408
489
  const solid = chart.fillMode === "solid";
@@ -428,7 +509,8 @@ function renderLine(svg, chart, width, height, colors, palette, isDark, textColo
428
509
  palette,
429
510
  isDark,
430
511
  hasTitle,
431
- width
512
+ width,
513
+ inlineTitle
432
514
  );
433
515
  const extentFor = (side) => {
434
516
  let lo = Infinity;
@@ -580,7 +662,7 @@ function renderPie(svg, chart, width, height, palette, isDark, textColor, topIns
580
662
  const MARGIN2 = 6;
581
663
  const halfW = width / 2 - MARGIN2;
582
664
  const rH = availH / 2 - availH * 0.06;
583
- const labelExtent = 1.268 + 0.0428 * maxLabelLen;
665
+ const labelExtent = 1.27 + 0.06 * maxLabelLen;
584
666
  const rLabeled = Math.min(rH, halfW / labelExtent);
585
667
  const showLabels = maxLabelLen > 0 && rLabeled >= 45;
586
668
  const rPlain = Math.min(rH, halfW * 0.94);
@@ -594,6 +676,7 @@ function renderPie(svg, chart, width, height, palette, isDark, textColor, topIns
594
676
  const arcs = d3pie().sort(null).value((d) => d.value)(data.map((d) => ({ value: d.value })));
595
677
  const arcGen = d3arc().innerRadius(hasHole ? radius * holeRatio : 0).outerRadius(radius);
596
678
  const g = svg.append("g").attr("transform", `translate(${cx},${cy})`);
679
+ const labelInfos = [];
597
680
  arcs.forEach((a, i) => {
598
681
  const stroke = strokeFor(i, data[i].color);
599
682
  const fill = shapeFill(palette, stroke, isDark, { mode: fillMode });
@@ -607,32 +690,65 @@ function renderPie(svg, chart, width, height, palette, isDark, textColor, topIns
607
690
  color: stroke
608
691
  });
609
692
  if (!showLabels) return;
693
+ const label = labels[i];
694
+ if (!label) return;
610
695
  const mid = (a.startAngle + a.endAngle) / 2 - Math.PI / 2;
611
696
  const rightSide = Math.cos(mid) >= 0;
612
- const x0 = Math.cos(mid) * radius;
613
- const y0 = Math.sin(mid) * radius;
614
- const x1 = Math.cos(mid) * (radius + elbowOut);
615
- const y1 = Math.sin(mid) * (radius + elbowOut);
616
- const x2 = x1 + (rightSide ? elbowRun : -elbowRun);
617
- const label = labels[i];
618
- if (label) {
619
- const tag = {
697
+ labelInfos.push({
698
+ rightSide,
699
+ x0: Math.cos(mid) * radius,
700
+ y0: Math.sin(mid) * radius,
701
+ // Radial stub end — meets the arc at 90° to the circle edge.
702
+ x1: Math.cos(mid) * (radius + elbowOut),
703
+ y1: Math.sin(mid) * (radius + elbowOut),
704
+ idealY: Math.sin(mid) * (radius + elbowOut),
705
+ y: 0,
706
+ label,
707
+ stroke,
708
+ // Tag the leader-line + label with the same emph-key as the wedge so
709
+ // hover (baked-CSS :has() and the app's JS dim) emphasizes all three
710
+ // together; colour the label text to match its segment.
711
+ tag: {
620
712
  line: data[i].lineNumber,
621
713
  key: data[i].label,
622
714
  name: data[i].label,
623
715
  value: `${fmtNum(data[i].value)} (${pct}%)`,
624
716
  color: stroke
625
- };
626
- tagDatum(
627
- g.append("polyline").attr("points", `${x0},${y0} ${x1},${y1} ${x2},${y1}`).attr("fill", "none").attr("stroke", stroke).attr("stroke-width", 1),
628
- tag
629
- );
630
- tagDatum(
631
- g.append("text").attr("x", x2 + (rightSide ? font * 0.3 : -font * 0.3)).attr("y", y1 + font * 0.3).attr("text-anchor", rightSide ? "start" : "end").attr("fill", stroke).attr("font-size", font).attr("font-family", FONT_FAMILY).text(label),
632
- tag
633
- );
634
- }
717
+ }
718
+ });
635
719
  });
720
+ if (showLabels && labelInfos.length > 0) {
721
+ const labelX = radius + elbowOut + elbowRun;
722
+ const minGap = font * 1.18;
723
+ const bound = availH / 2 - font;
724
+ for (const side of [true, false]) {
725
+ const group = labelInfos.filter((l) => l.rightSide === side);
726
+ if (group.length === 0) continue;
727
+ const topHalf = group.filter((l) => l.idealY < 0).sort((a, b) => b.idealY - a.idealY);
728
+ const botHalf = group.filter((l) => l.idealY >= 0).sort((a, b) => a.idealY - b.idealY);
729
+ topHalf.forEach((l, i) => {
730
+ l.y = i === 0 ? l.idealY : Math.min(l.idealY, topHalf[i - 1].y - minGap);
731
+ l.y = Math.max(l.y, -bound);
732
+ });
733
+ botHalf.forEach((l, i) => {
734
+ l.y = i === 0 ? l.idealY : Math.max(l.idealY, botHalf[i - 1].y + minGap);
735
+ l.y = Math.min(l.y, bound);
736
+ });
737
+ const sx = side ? 1 : -1;
738
+ const tx = sx * labelX;
739
+ for (const l of group) {
740
+ const xr = Math.abs(l.y0) < 1e-3 ? l.x1 : l.y * l.x0 / l.y0;
741
+ tagDatum(
742
+ g.append("polyline").attr("points", `${l.x0},${l.y0} ${xr},${l.y} ${tx},${l.y}`).attr("fill", "none").attr("stroke", l.stroke).attr("stroke-width", 1),
743
+ l.tag
744
+ );
745
+ tagDatum(
746
+ g.append("text").attr("x", tx + sx * font * 0.3).attr("y", l.y + font * 0.3).attr("text-anchor", side ? "start" : "end").attr("fill", l.stroke).attr("font-size", font).attr("font-family", FONT_FAMILY).text(l.label),
747
+ l.tag
748
+ );
749
+ }
750
+ }
751
+ }
636
752
  if (hasHole && !chart.noCenterTotal) {
637
753
  g.append("text").attr("text-anchor", "middle").attr("y", Math.max(4, 8 * labelScale)).attr("fill", textColor).attr("font-size", Math.max(11, 26 * labelScale)).attr("font-weight", 700).attr("font-family", FONT_FAMILY).text(fmtNum(total));
638
754
  }
@@ -1169,11 +1285,31 @@ function renderScatter(svg, chart, width, height, colors, palette, isDark, textC
1169
1285
  // src/charts-d3/sankey.ts
1170
1286
  var NODE_W = 20;
1171
1287
  var NODE_GAP = 14;
1288
+ var RIBBON_FILL_OPACITY = 0.6;
1172
1289
  function renderSankey(svg, chart, width, height, colors, bgColor, textColor, topInset) {
1173
1290
  const links = chart.links ?? [];
1174
1291
  if (links.length === 0) return;
1175
1292
  const solid = chart.fillMode === "solid";
1176
1293
  const names = Array.from(new Set(links.flatMap((l) => [l.source, l.target])));
1294
+ const walk = (seeds, up) => {
1295
+ const seen = new Set(seeds);
1296
+ for (let pass = 0; pass < names.length; pass++) {
1297
+ let grew = false;
1298
+ for (const l of links) {
1299
+ const from = up ? l.target : l.source;
1300
+ const to = up ? l.source : l.target;
1301
+ if (seen.has(from) && !seen.has(to)) {
1302
+ seen.add(to);
1303
+ grew = true;
1304
+ }
1305
+ }
1306
+ if (!grew) break;
1307
+ }
1308
+ return seen;
1309
+ };
1310
+ const flowClosure = (seeds) => /* @__PURE__ */ new Set([...walk(seeds, true), ...walk(seeds, false)]);
1311
+ const { dimmed } = resolveEmphasis(chart.emphasis, names, flowClosure);
1312
+ const linkDimmed = (l) => dimmed.has(l.source) || dimmed.has(l.target);
1177
1313
  const node = /* @__PURE__ */ new Map();
1178
1314
  names.forEach(
1179
1315
  (name, i) => node.set(name, {
@@ -1271,7 +1407,10 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1271
1407
  const ribbon = svg.append("path").attr(
1272
1408
  "d",
1273
1409
  `M${sx},${sy} C${cx0},${sy} ${cx0},${ty} ${tx},${ty} L${tx},${ty + th} C${cx0},${ty + th} ${cx0},${sy + th} ${sx},${sy + th} Z`
1274
- ).attr("fill", color).attr("fill-opacity", 0.6);
1410
+ ).attr("fill", color).attr(
1411
+ "fill-opacity",
1412
+ linkDimmed(l) ? RIBBON_FILL_OPACITY * EMPHASIS_DIM_OPACITY : RIBBON_FILL_OPACITY
1413
+ );
1275
1414
  tagDatum(ribbon, {
1276
1415
  line: l.lineNumber,
1277
1416
  // U+241F (symbol-for-unit-separator) — collision-proof AND XML-legal;
@@ -1286,7 +1425,9 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1286
1425
  const nodeLine = links.find(
1287
1426
  (l) => l.source === n.name || l.target === n.name
1288
1427
  )?.lineNumber;
1428
+ const nodeDim = dimmed.has(n.name);
1289
1429
  const nr = svg.append("rect").attr("x", n.x).attr("y", n.y).attr("width", NODE_W).attr("height", Math.max(1, n.h)).attr("fill", solid ? n.raw : mix(n.raw, bgColor, 75)).attr("stroke", n.raw).attr("stroke-width", 1);
1430
+ if (nodeDim) nr.attr("opacity", EMPHASIS_DIM_OPACITY);
1290
1431
  tagDatum(nr, {
1291
1432
  ...nodeLine !== void 0 && { line: nodeLine },
1292
1433
  key: `node:${n.name}`,
@@ -1295,7 +1436,8 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1295
1436
  color: n.raw
1296
1437
  });
1297
1438
  const lastLayer = n.rank === maxRank;
1298
- svg.append("text").attr("x", lastLayer ? n.x - 6 : n.x + NODE_W + 6).attr("y", n.y + n.h / 2 + 4).attr("text-anchor", lastLayer ? "end" : "start").attr("fill", textColor).attr("font-size", 13).attr("font-family", FONT_FAMILY).text(n.name);
1439
+ const label = svg.append("text").attr("x", lastLayer ? n.x - 6 : n.x + NODE_W + 6).attr("y", n.y + n.h / 2 + 4).attr("text-anchor", lastLayer ? "end" : "start").attr("fill", textColor).attr("font-size", 13).attr("font-family", FONT_FAMILY).text(n.name);
1440
+ if (nodeDim) label.attr("opacity", EMPHASIS_DIM_TEXT_OPACITY);
1299
1441
  }
1300
1442
  }
1301
1443
 
@@ -1377,13 +1519,166 @@ function renderChord(svg, chart, width, height, colors, palette, isDark, textCol
1377
1519
 
1378
1520
  // src/charts-d3/function.ts
1379
1521
  import { scaleLinear as scaleLinear4 } from "d3-scale";
1380
- import { line as d3line2 } from "d3-shape";
1522
+ import { line as d3line2, area as d3area2 } from "d3-shape";
1381
1523
 
1382
1524
  // src/utils/expr-eval.ts
1525
+ var FUNCS = {
1526
+ sin: Math.sin,
1527
+ cos: Math.cos,
1528
+ tan: Math.tan,
1529
+ ln: Math.log,
1530
+ log: Math.log10,
1531
+ exp: Math.exp,
1532
+ sqrt: Math.sqrt,
1533
+ abs: Math.abs
1534
+ };
1535
+ function tokenize(expr) {
1536
+ const tokens = [];
1537
+ let i = 0;
1538
+ const n = expr.length;
1539
+ while (i < n) {
1540
+ const c = expr.charAt(i);
1541
+ if (c === " " || c === " ") {
1542
+ i++;
1543
+ continue;
1544
+ }
1545
+ if (c >= "0" && c <= "9" || c === ".") {
1546
+ let j = i + 1;
1547
+ while (/[0-9.]/.test(expr.charAt(j))) j++;
1548
+ const exp = expr.charAt(j);
1549
+ if (exp === "e" || exp === "E") {
1550
+ let k = j + 1;
1551
+ const sign = expr.charAt(k);
1552
+ if (sign === "+" || sign === "-") k++;
1553
+ if (/[0-9]/.test(expr.charAt(k))) {
1554
+ while (/[0-9]/.test(expr.charAt(k))) k++;
1555
+ j = k;
1556
+ }
1557
+ }
1558
+ const num = Number(expr.slice(i, j));
1559
+ if (!isFinite(num)) throw new Error("bad number");
1560
+ tokens.push({ t: "num", v: num });
1561
+ i = j;
1562
+ continue;
1563
+ }
1564
+ if (/[a-zA-Z]/.test(c)) {
1565
+ let j = i + 1;
1566
+ while (/[a-zA-Z0-9]/.test(expr.charAt(j))) j++;
1567
+ tokens.push({ t: "id", v: expr.slice(i, j).toLowerCase() });
1568
+ i = j;
1569
+ continue;
1570
+ }
1571
+ if ("+-*/^()".includes(c)) {
1572
+ tokens.push({ t: "op", v: c });
1573
+ i++;
1574
+ continue;
1575
+ }
1576
+ throw new Error(`unexpected char: ${c}`);
1577
+ }
1578
+ return tokens;
1579
+ }
1580
+ var Parser = class {
1581
+ constructor(tokens, x) {
1582
+ this.tokens = tokens;
1583
+ this.x = x;
1584
+ }
1585
+ tokens;
1586
+ x;
1587
+ pos = 0;
1588
+ peek() {
1589
+ return this.tokens[this.pos];
1590
+ }
1591
+ eatOp(v) {
1592
+ const tk = this.peek();
1593
+ if (tk?.t !== "op" || tk.v !== v) throw new Error(`expected ${v}`);
1594
+ this.pos++;
1595
+ }
1596
+ evaluate() {
1597
+ const value = this.parseExpr();
1598
+ if (this.pos !== this.tokens.length) throw new Error("trailing input");
1599
+ return value;
1600
+ }
1601
+ // expr = term (('+' | '-') term)*
1602
+ parseExpr() {
1603
+ let value = this.parseTerm();
1604
+ for (; ; ) {
1605
+ const tk = this.peek();
1606
+ if (tk?.t === "op" && (tk.v === "+" || tk.v === "-")) {
1607
+ this.pos++;
1608
+ const rhs = this.parseTerm();
1609
+ value = tk.v === "+" ? value + rhs : value - rhs;
1610
+ } else break;
1611
+ }
1612
+ return value;
1613
+ }
1614
+ // term = factor (('*' | '/') factor)*
1615
+ parseTerm() {
1616
+ let value = this.parseFactor();
1617
+ for (; ; ) {
1618
+ const tk = this.peek();
1619
+ if (tk?.t === "op" && (tk.v === "*" || tk.v === "/")) {
1620
+ this.pos++;
1621
+ const rhs = this.parseFactor();
1622
+ value = tk.v === "*" ? value * rhs : value / rhs;
1623
+ } else break;
1624
+ }
1625
+ return value;
1626
+ }
1627
+ // factor = ('+' | '-') factor | power
1628
+ parseFactor() {
1629
+ const tk = this.peek();
1630
+ if (tk?.t === "op" && (tk.v === "+" || tk.v === "-")) {
1631
+ this.pos++;
1632
+ const operand = this.parseFactor();
1633
+ return tk.v === "-" ? -operand : operand;
1634
+ }
1635
+ return this.parsePower();
1636
+ }
1637
+ // power = primary ('^' factor)? — right-associative
1638
+ parsePower() {
1639
+ const base = this.parsePrimary();
1640
+ const tk = this.peek();
1641
+ if (tk?.t === "op" && tk.v === "^") {
1642
+ this.pos++;
1643
+ const exponent = this.parseFactor();
1644
+ return base ** exponent;
1645
+ }
1646
+ return base;
1647
+ }
1648
+ // primary = number | const | 'x' | func '(' expr ')' | '(' expr ')'
1649
+ parsePrimary() {
1650
+ const tk = this.peek();
1651
+ if (!tk) throw new Error("unexpected end");
1652
+ if (tk.t === "num") {
1653
+ this.pos++;
1654
+ return tk.v;
1655
+ }
1656
+ if (tk.t === "op" && tk.v === "(") {
1657
+ this.pos++;
1658
+ const value = this.parseExpr();
1659
+ this.eatOp(")");
1660
+ return value;
1661
+ }
1662
+ if (tk.t === "id") {
1663
+ this.pos++;
1664
+ if (tk.v === "x") return this.x;
1665
+ if (tk.v === "pi") return Math.PI;
1666
+ if (tk.v === "e") return Math.E;
1667
+ const fn = FUNCS[tk.v];
1668
+ if (fn) {
1669
+ this.eatOp("(");
1670
+ const arg = this.parseExpr();
1671
+ this.eatOp(")");
1672
+ return fn(arg);
1673
+ }
1674
+ throw new Error(`unknown identifier: ${tk.v}`);
1675
+ }
1676
+ throw new Error("unexpected token");
1677
+ }
1678
+ };
1383
1679
  function evaluateExpression(expr, x) {
1384
1680
  try {
1385
- const processed = expr.replace(/\bpi\b/gi, String(Math.PI)).replace(/\be\b/g, String(Math.E)).replace(/\bsin\s*\(/gi, "Math.sin(").replace(/\bcos\s*\(/gi, "Math.cos(").replace(/\btan\s*\(/gi, "Math.tan(").replace(/\bln\s*\(/gi, "Math.log(").replace(/\blog\s*\(/gi, "Math.log10(").replace(/\bexp\s*\(/gi, "Math.exp(").replace(/\bsqrt\s*\(/gi, "Math.sqrt(").replace(/\babs\s*\(/gi, "Math.abs(").replace(/\bx\b/gi, `(${x})`).replace(/\^/g, "**");
1386
- const result = new Function(`return ${processed}`)();
1681
+ const result = new Parser(tokenize(expr), x).evaluate();
1387
1682
  return typeof result === "number" && isFinite(result) ? result : NaN;
1388
1683
  } catch {
1389
1684
  return NaN;
@@ -1392,7 +1687,7 @@ function evaluateExpression(expr, x) {
1392
1687
 
1393
1688
  // src/charts-d3/function.ts
1394
1689
  var SAMPLES = 200;
1395
- function renderFunction(svg, chart, width, height, colors, textColor, mutedColor, topInset) {
1690
+ function renderFunction(svg, chart, width, height, colors, textColor, mutedColor, topInset, palette, isDark) {
1396
1691
  const fns = chart.functions ?? [];
1397
1692
  if (fns.length === 0) return;
1398
1693
  const xr = chart.xRange ?? { min: -10, max: 10 };
@@ -1440,9 +1735,17 @@ function renderFunction(svg, chart, width, height, colors, textColor, mutedColor
1440
1735
  svg.append("line").attr("x1", xx).attr("x2", xx).attr("y1", m.top).attr("y2", m.top + plotH).attr("stroke", mutedColor).attr("stroke-opacity", t === 0 ? 0.6 : 0.2);
1441
1736
  svg.append("text").attr("class", "dgmo-tick").attr("x", xx).attr("y", m.top + plotH + 18).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", TICK_FONT).attr("font-family", FONT_FAMILY).text(fmtNum(t));
1442
1737
  }
1443
- const gen = d3line2().defined((p) => isFinite(p[1]) && p[1] >= yLo - 1 && p[1] <= yHi + 1).x((p) => x(p[0])).y((p) => y(p[1]));
1738
+ const inRange = (p) => isFinite(p[1]) && p[1] >= yLo - 1 && p[1] <= yHi + 1;
1739
+ if (chart.fill === true) {
1740
+ const solid = chart.fillMode === "solid";
1741
+ const areaGen = d3area2().defined(inRange).x((p) => x(p[0])).y0(y(Math.max(y.domain()[0], 0))).y1((p) => y(p[1]));
1742
+ for (const c of curves) {
1743
+ svg.append("path").attr("class", "dgmo-series-area").attr("d", areaGen(c.pts) ?? "").attr("fill", solid ? c.color : shapeFill(palette, c.color, isDark)).attr("stroke", "none").attr("data-series-name", c.name);
1744
+ }
1745
+ }
1746
+ const gen = d3line2().defined(inRange).x((p) => x(p[0])).y((p) => y(p[1]));
1444
1747
  for (const c of curves) {
1445
- const path = svg.append("path").attr("d", gen(c.pts) ?? "").attr("fill", "none").attr("stroke", c.color).attr("stroke-width", 2.5).attr("stroke-linejoin", "round");
1748
+ const path = svg.append("path").attr("d", gen(c.pts) ?? "").attr("fill", "none").attr("stroke", c.color).attr("stroke-width", 1.75).attr("stroke-linejoin", "round").attr("data-series-name", c.name);
1446
1749
  tagDatum(path, { line: c.line, key: c.name, name: c.name, color: c.color });
1447
1750
  }
1448
1751
  drawXAxisTitle(
@@ -1469,6 +1772,25 @@ var D3_DATA_CHART_TYPES = /* @__PURE__ */ new Set([...STANDARD, ...EXTENDED]);
1469
1772
  function supportsD3DataChart(type) {
1470
1773
  return D3_DATA_CHART_TYPES.has(type);
1471
1774
  }
1775
+ var INLINE_LEGEND_TYPES = /* @__PURE__ */ new Set([
1776
+ "bar",
1777
+ "line",
1778
+ "radar",
1779
+ "scatter",
1780
+ "function"
1781
+ ]);
1782
+ function inlineTitleFor(chart, hasTitle, textColor) {
1783
+ if (!hasTitle || !chart.legendInline || chart.noLegend || !INLINE_LEGEND_TYPES.has(chart.type)) {
1784
+ return void 0;
1785
+ }
1786
+ return {
1787
+ title: chart.title,
1788
+ ...chart.titleLineNumber !== void 0 && {
1789
+ titleLineNumber: chart.titleLineNumber
1790
+ },
1791
+ textColor
1792
+ };
1793
+ }
1472
1794
  function firstNonCommentToken(content) {
1473
1795
  for (const raw of content.split("\n")) {
1474
1796
  const l = raw.trim();
@@ -1516,7 +1838,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1516
1838
  const std = forceExtended ? null : parseChart(content, palette);
1517
1839
  if (std && !std.error && std.data.length > 0 && STANDARD.has(std.type)) {
1518
1840
  const hasTitle2 = !std.noTitle && !!std.title;
1519
- if (hasTitle2)
1841
+ const inlineTitle2 = inlineTitleFor(std, hasTitle2, textColor);
1842
+ if (hasTitle2 && !inlineTitle2)
1520
1843
  renderChartTitle(s, std.title, std.titleLineNumber, width, textColor);
1521
1844
  switch (std.type) {
1522
1845
  case "bar":
@@ -1530,7 +1853,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1530
1853
  isDark,
1531
1854
  textColor,
1532
1855
  mutedColor,
1533
- hasTitle2
1856
+ hasTitle2,
1857
+ inlineTitle2
1534
1858
  );
1535
1859
  return true;
1536
1860
  case "line":
@@ -1545,7 +1869,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1545
1869
  textColor,
1546
1870
  mutedColor,
1547
1871
  bgColor,
1548
- hasTitle2
1872
+ hasTitle2,
1873
+ inlineTitle2
1549
1874
  );
1550
1875
  return true;
1551
1876
  case "pie":
@@ -1568,7 +1893,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1568
1893
  palette,
1569
1894
  isDark,
1570
1895
  hasTitle2,
1571
- width
1896
+ width,
1897
+ inlineTitle2
1572
1898
  );
1573
1899
  renderRadar(
1574
1900
  s,
@@ -1602,7 +1928,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1602
1928
  if (ext.error || !EXTENDED.has(ext.type)) return false;
1603
1929
  const seriesColors = getSeriesColors(palette);
1604
1930
  const hasTitle = !ext.noTitle && !!ext.title;
1605
- if (hasTitle)
1931
+ const inlineTitle = inlineTitleFor(ext, hasTitle, textColor);
1932
+ if (hasTitle && !inlineTitle)
1606
1933
  renderChartTitle(s, ext.title, ext.titleLineNumber, width, textColor);
1607
1934
  switch (ext.type) {
1608
1935
  case "funnel":
@@ -1638,7 +1965,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1638
1965
  palette,
1639
1966
  isDark,
1640
1967
  hasTitle,
1641
- width
1968
+ width,
1969
+ inlineTitle
1642
1970
  );
1643
1971
  renderScatter(
1644
1972
  s,
@@ -1687,7 +2015,8 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1687
2015
  palette,
1688
2016
  isDark,
1689
2017
  hasTitle,
1690
- width
2018
+ width,
2019
+ inlineTitle
1691
2020
  );
1692
2021
  renderFunction(
1693
2022
  s,
@@ -1697,7 +2026,9 @@ function renderInto(s, content, palette, isDark, width, height, textColor, muted
1697
2026
  seriesColors,
1698
2027
  textColor,
1699
2028
  mutedColor,
1700
- top
2029
+ top,
2030
+ palette,
2031
+ isDark
1701
2032
  );
1702
2033
  return true;
1703
2034
  }
@@ -1713,4 +2044,4 @@ export {
1713
2044
  supportsD3DataChart,
1714
2045
  renderDataChartD3
1715
2046
  };
1716
- //# sourceMappingURL=chunk-SG4PRYO3.js.map
2047
+ //# sourceMappingURL=chunk-QQXFYTLC.js.map