minerva-design 1.13.2 → 1.14.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 (202) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/custom-elements.json +194 -12
  3. package/dist/angular/fesm2022/minerva-angular.mjs +20 -0
  4. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  5. package/dist/angular/types/minerva-angular.d.ts +10 -1
  6. package/dist/charts/canvas.d.cts +1 -0
  7. package/dist/charts/canvas.d.ts +1 -0
  8. package/dist/charts/engine/canvas.cjs +1 -1
  9. package/dist/charts/engine/canvas.cjs.map +1 -1
  10. package/dist/charts/engine/canvas.js +152 -128
  11. package/dist/charts/engine/canvas.js.map +1 -1
  12. package/dist/charts/engine/chart.cjs +1 -1
  13. package/dist/charts/engine/chart.cjs.map +1 -1
  14. package/dist/charts/engine/chart.js +475 -405
  15. package/dist/charts/engine/chart.js.map +1 -1
  16. package/dist/charts/engine/controller.cjs +2 -2
  17. package/dist/charts/engine/controller.cjs.map +1 -1
  18. package/dist/charts/engine/controller.js +263 -248
  19. package/dist/charts/engine/controller.js.map +1 -1
  20. package/dist/charts/engine/dom.cjs +1 -1
  21. package/dist/charts/engine/dom.cjs.map +1 -1
  22. package/dist/charts/engine/dom.d.cts +34 -0
  23. package/dist/charts/engine/dom.d.ts +34 -0
  24. package/dist/charts/engine/dom.js +62 -51
  25. package/dist/charts/engine/dom.js.map +1 -1
  26. package/dist/charts/engine/graph/chart.cjs +1 -1
  27. package/dist/charts/engine/graph/chart.cjs.map +1 -1
  28. package/dist/charts/engine/graph/chart.js +835 -821
  29. package/dist/charts/engine/graph/chart.js.map +1 -1
  30. package/dist/charts/engine/graph/dom.cjs +1 -1
  31. package/dist/charts/engine/graph/dom.cjs.map +1 -1
  32. package/dist/charts/engine/graph/dom.js +44 -51
  33. package/dist/charts/engine/graph/dom.js.map +1 -1
  34. package/dist/charts/engine/hover-rect.cjs +2 -0
  35. package/dist/charts/engine/hover-rect.cjs.map +1 -0
  36. package/dist/charts/engine/hover-rect.d.cts +10 -0
  37. package/dist/charts/engine/hover-rect.d.ts +10 -0
  38. package/dist/charts/engine/hover-rect.js +47 -0
  39. package/dist/charts/engine/hover-rect.js.map +1 -0
  40. package/dist/charts/engine/items.cjs +1 -1
  41. package/dist/charts/engine/items.cjs.map +1 -1
  42. package/dist/charts/engine/items.js +8 -8
  43. package/dist/charts/engine/model.cjs +1 -1
  44. package/dist/charts/engine/model.cjs.map +1 -1
  45. package/dist/charts/engine/model.js +191 -191
  46. package/dist/charts/engine/model.js.map +1 -1
  47. package/dist/charts/engine/orderbook/depth.cjs +1 -1
  48. package/dist/charts/engine/orderbook/depth.cjs.map +1 -1
  49. package/dist/charts/engine/orderbook/depth.js +63 -63
  50. package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
  51. package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
  52. package/dist/charts/engine/orderbook/heatmap.js +155 -155
  53. package/dist/charts/engine/orderbook/host.cjs +1 -1
  54. package/dist/charts/engine/orderbook/host.cjs.map +1 -1
  55. package/dist/charts/engine/orderbook/host.js +87 -75
  56. package/dist/charts/engine/orderbook/host.js.map +1 -1
  57. package/dist/charts/engine/orderbook/ladder.cjs +1 -1
  58. package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
  59. package/dist/charts/engine/orderbook/ladder.js +41 -41
  60. package/dist/charts/engine/orderbook/tape.cjs +1 -1
  61. package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
  62. package/dist/charts/engine/orderbook/tape.js +31 -31
  63. package/dist/charts/engine/presets.cjs +2 -2
  64. package/dist/charts/engine/presets.cjs.map +1 -1
  65. package/dist/charts/engine/presets.js +15 -15
  66. package/dist/charts/engine/renderers/vector-gpu.cjs +24 -0
  67. package/dist/charts/engine/renderers/vector-gpu.cjs.map +1 -0
  68. package/dist/charts/engine/renderers/vector-gpu.d.cts +22 -0
  69. package/dist/charts/engine/renderers/vector-gpu.d.ts +22 -0
  70. package/dist/charts/engine/renderers/vector-gpu.js +301 -0
  71. package/dist/charts/engine/renderers/vector-gpu.js.map +1 -0
  72. package/dist/charts/engine/renderers/vector.cjs +2 -0
  73. package/dist/charts/engine/renderers/vector.cjs.map +1 -0
  74. package/dist/charts/engine/renderers/vector.d.cts +140 -0
  75. package/dist/charts/engine/renderers/vector.d.ts +140 -0
  76. package/dist/charts/engine/renderers/vector.js +568 -0
  77. package/dist/charts/engine/renderers/vector.js.map +1 -0
  78. package/dist/charts/engine/scene.cjs +1 -1
  79. package/dist/charts/engine/scene.cjs.map +1 -1
  80. package/dist/charts/engine/scene.d.cts +43 -3
  81. package/dist/charts/engine/scene.d.ts +43 -3
  82. package/dist/charts/engine/scene.js +411 -338
  83. package/dist/charts/engine/scene.js.map +1 -1
  84. package/dist/charts/engine/shapes/bullet.cjs +1 -1
  85. package/dist/charts/engine/shapes/bullet.cjs.map +1 -1
  86. package/dist/charts/engine/shapes/bullet.js +36 -36
  87. package/dist/charts/engine/shapes/calendar.cjs +1 -1
  88. package/dist/charts/engine/shapes/calendar.cjs.map +1 -1
  89. package/dist/charts/engine/shapes/calendar.js +53 -53
  90. package/dist/charts/engine/shapes/chart.cjs +1 -1
  91. package/dist/charts/engine/shapes/chart.cjs.map +1 -1
  92. package/dist/charts/engine/shapes/chart.d.cts +3 -2
  93. package/dist/charts/engine/shapes/chart.d.ts +3 -2
  94. package/dist/charts/engine/shapes/chart.js +192 -162
  95. package/dist/charts/engine/shapes/chart.js.map +1 -1
  96. package/dist/charts/engine/shapes/draw.cjs +1 -1
  97. package/dist/charts/engine/shapes/draw.cjs.map +1 -1
  98. package/dist/charts/engine/shapes/draw.js +87 -86
  99. package/dist/charts/engine/shapes/draw.js.map +1 -1
  100. package/dist/charts/engine/shapes/layout.cjs +2 -2
  101. package/dist/charts/engine/shapes/layout.cjs.map +1 -1
  102. package/dist/charts/engine/shapes/layout.d.cts +8 -7
  103. package/dist/charts/engine/shapes/layout.d.ts +8 -7
  104. package/dist/charts/engine/shapes/layout.js +262 -166
  105. package/dist/charts/engine/shapes/layout.js.map +1 -1
  106. package/dist/charts/engine/shapes/types.d.cts +13 -1
  107. package/dist/charts/engine/shapes/types.d.ts +13 -1
  108. package/dist/charts/engine/three-d/chart.cjs +1 -1
  109. package/dist/charts/engine/three-d/chart.cjs.map +1 -1
  110. package/dist/charts/engine/three-d/chart.js +266 -257
  111. package/dist/charts/engine/three-d/chart.js.map +1 -1
  112. package/dist/charts/engine/three-d/dom.cjs +1 -1
  113. package/dist/charts/engine/three-d/dom.cjs.map +1 -1
  114. package/dist/charts/engine/three-d/dom.js +28 -35
  115. package/dist/charts/engine/three-d/dom.js.map +1 -1
  116. package/dist/charts/engine/three-d/geometry.cjs +1 -1
  117. package/dist/charts/engine/three-d/geometry.cjs.map +1 -1
  118. package/dist/charts/engine/three-d/geometry.js +70 -70
  119. package/dist/charts/engine/three-d/overlay.cjs +1 -1
  120. package/dist/charts/engine/three-d/overlay.cjs.map +1 -1
  121. package/dist/charts/engine/three-d/overlay.js +15 -15
  122. package/dist/charts/engine/tooltip.cjs +2 -0
  123. package/dist/charts/engine/tooltip.cjs.map +1 -0
  124. package/dist/charts/engine/tooltip.d.cts +94 -0
  125. package/dist/charts/engine/tooltip.d.ts +94 -0
  126. package/dist/charts/engine/tooltip.js +242 -0
  127. package/dist/charts/engine/tooltip.js.map +1 -0
  128. package/dist/charts/engine/trading/chart.cjs +1 -1
  129. package/dist/charts/engine/trading/chart.cjs.map +1 -1
  130. package/dist/charts/engine/trading/chart.js +135 -135
  131. package/dist/charts/react/shapes.cjs +1 -1
  132. package/dist/charts/react/shapes.cjs.map +1 -1
  133. package/dist/charts/react/shapes.d.cts +10 -1
  134. package/dist/charts/react/shapes.d.ts +10 -1
  135. package/dist/charts/react/shapes.js +24 -19
  136. package/dist/charts/react/shapes.js.map +1 -1
  137. package/dist/core/contracts.cjs +1 -1
  138. package/dist/core/contracts.cjs.map +1 -1
  139. package/dist/core/contracts.js +1 -1
  140. package/dist/core/contracts.js.map +1 -1
  141. package/dist/native/charts/src/canvas.cjs +1 -1
  142. package/dist/native/charts/src/canvas.js +8 -7
  143. package/dist/native/charts/src/engine/canvas.cjs +1 -1
  144. package/dist/native/charts/src/engine/canvas.js +2 -0
  145. package/dist/native/charts/src/engine/controller.cjs +2 -2
  146. package/dist/native/charts/src/engine/controller.cjs.map +1 -1
  147. package/dist/native/charts/src/engine/controller.js +102 -87
  148. package/dist/native/charts/src/engine/controller.js.map +1 -1
  149. package/dist/native/charts/src/engine/hover-rect.cjs +2 -0
  150. package/dist/native/charts/src/engine/hover-rect.cjs.map +1 -0
  151. package/dist/native/charts/src/engine/hover-rect.js +47 -0
  152. package/dist/native/charts/src/engine/hover-rect.js.map +1 -0
  153. package/dist/native/charts/src/engine/scene.cjs +1 -1
  154. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  155. package/dist/native/charts/src/engine/scene.js +318 -245
  156. package/dist/native/charts/src/engine/scene.js.map +1 -1
  157. package/dist/native/charts/src/engine/shapes/draw.cjs +1 -1
  158. package/dist/native/charts/src/engine/shapes/draw.cjs.map +1 -1
  159. package/dist/native/charts/src/engine/shapes/draw.js +81 -80
  160. package/dist/native/charts/src/engine/shapes/draw.js.map +1 -1
  161. package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
  162. package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
  163. package/dist/native/charts/src/engine/shapes/layout.js +239 -143
  164. package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
  165. package/dist/native/charts/src/engine/tooltip.cjs +2 -0
  166. package/dist/native/charts/src/engine/tooltip.cjs.map +1 -0
  167. package/dist/native/charts/src/engine/tooltip.js +164 -0
  168. package/dist/native/charts/src/engine/tooltip.js.map +1 -0
  169. package/dist/native/components/Chart/scene.cjs +1 -1
  170. package/dist/native/components/Chart/scene.cjs.map +1 -1
  171. package/dist/native/components/Chart/scene.js +210 -187
  172. package/dist/native/components/Chart/scene.js.map +1 -1
  173. package/dist/native/source/components/Chart/scene.tsx +55 -2
  174. package/dist/taro/index.js +2026 -1626
  175. package/dist/uni/charts-canvas.js +1 -0
  176. package/dist/vue/components/Chart/BulletChart.vue.d.ts +2 -0
  177. package/dist/vue/components/Chart/CalendarHeatmap.vue.d.ts +2 -0
  178. package/dist/vue/components/Chart/ChordChart.vue.d.ts +2 -0
  179. package/dist/vue/components/Chart/DonutChart.vue.d.ts +2 -0
  180. package/dist/vue/components/Chart/FunnelChart.vue.d.ts +2 -0
  181. package/dist/vue/components/Chart/GaugeChart.vue.d.ts +2 -0
  182. package/dist/vue/components/Chart/PieChart.vue.d.ts +2 -0
  183. package/dist/vue/components/Chart/RadarChart.vue.d.ts +2 -0
  184. package/dist/vue/components/Chart/RadialBarChart.vue.d.ts +2 -0
  185. package/dist/vue/components/Chart/SankeyChart.vue.d.ts +2 -0
  186. package/dist/vue/components/Chart/SunburstChart.vue.d.ts +2 -0
  187. package/dist/vue/components/Chart/TreemapChart.vue.d.ts +2 -0
  188. package/dist/vue/components/Chart/props.d.ts +2 -0
  189. package/dist/vue/components/Chart/props.js +1 -0
  190. package/dist/vue/components/Chart/props.js.map +1 -1
  191. package/dist/vue/components/Chart/shape.d.ts +2 -1
  192. package/dist/vue/components/Chart/shape.js +2 -0
  193. package/dist/vue/components/Chart/shape.js.map +1 -1
  194. package/dist/vue/components/Chart/types.d.ts +2 -0
  195. package/dist/weapp/charts/canvas.js +2576 -1969
  196. package/dist/weapp/charts/core.js +1 -0
  197. package/dist/web-components/components/chart/shape-chart.d.ts +9 -7
  198. package/dist/web-components/components/chart/shape-chart.js +3 -0
  199. package/dist/web-components/components/chart/shape-chart.js.map +1 -1
  200. package/dist/web-components/components/chart/shapes-extended.d.ts +6 -6
  201. package/dist/web-components/components/chart/shapes-extended.js.map +1 -1
  202. package/package.json +1 -1
@@ -1,48 +1,49 @@
1
- import { toCss as e } from "../color.js";
2
- import { font as t } from "../overlay.js";
3
- import { TAU as n } from "./scene.js";
1
+ import { CANVAS_TOOLTIP_ALPHA as e } from "../tooltip.js";
2
+ import { toCss as t } from "../color.js";
3
+ import { font as n } from "../overlay.js";
4
+ import { TAU as r } from "./scene.js";
4
5
  //#region src/engine/shapes/draw.ts
5
- var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Math.max(0, Math.min(e.pad, e.r1 * (e.a1 - e.a0) / 3)), o = (e, t) => t > 0 ? Math.asin(Math.min(1, e / t)) : Math.PI / 2, s = (e, t, r = 0, i = 0) => {
6
- let s = t.cx + r, c = t.cy + i, { r0: l, r1: u, a0: d, a1: f } = t, p = f - d;
6
+ var i = "rgba(15, 23, 42, 0.18)", a = "rgba(255, 255, 255, 0.14)", o = (e) => Math.max(0, Math.min(e.pad, e.r1 * (e.a1 - e.a0) / 3)), s = (e, t) => t > 0 ? Math.asin(Math.min(1, e / t)) : Math.PI / 2, c = (e, t, n = 0, i = 0) => {
7
+ let a = t.cx + n, c = t.cy + i, { r0: l, r1: u, a0: d, a1: f } = t, p = f - d;
7
8
  if (e.beginPath(), p <= 0 || u <= l) return;
8
- if (p >= n - 1e-6) {
9
- e.moveTo(s + u, c), e.arc(s, c, u, 0, n), l > 0 && (e.moveTo(s + l, c), e.arc(s, c, l, n, 0, !0)), e.closePath();
9
+ if (p >= r - 1e-6) {
10
+ e.moveTo(a + u, c), e.arc(a, c, u, 0, r), l > 0 && (e.moveTo(a + l, c), e.arc(a, c, l, r, 0, !0)), e.closePath();
10
11
  return;
11
12
  }
12
- let m = a(t) / 2, h = (e, t, n) => {
13
- let r = e + t * o(m, n);
14
- return [s + n * Math.cos(r), c + n * Math.sin(r)];
15
- }, g = (e, t) => [s + t * Math.cos(e), c + t * Math.sin(e)], _ = o(m, u), v = Math.max(0, p - 2 * _), y = l > 0 ? o(m, l) : 0, b = l > 0 ? p - 2 * y : 0, x = l > 0 && b > 1e-4, S = u - l, C = Math.max(0, Math.min(t.corner, S / 2, u * v / 2 - .01)), w = x ? Math.max(0, Math.min(t.corner, S / 2, l * b / 2 - .01)) : 0;
13
+ let m = o(t) / 2, h = (e, t, n) => {
14
+ let r = e + t * s(m, n);
15
+ return [a + n * Math.cos(r), c + n * Math.sin(r)];
16
+ }, g = (e, t) => [a + t * Math.cos(e), c + t * Math.sin(e)], _ = s(m, u), v = Math.max(0, p - 2 * _), y = l > 0 ? s(m, l) : 0, b = l > 0 ? p - 2 * y : 0, x = l > 0 && b > 1e-4, S = u - l, C = Math.max(0, Math.min(t.corner, S / 2, u * v / 2 - .01)), w = x ? Math.max(0, Math.min(t.corner, S / 2, l * b / 2 - .01)) : 0;
16
17
  if (C > .5) {
17
18
  let t = h(d, 1, u - C);
18
19
  e.moveTo(t[0], t[1]);
19
20
  let n = h(d, 1, u), r = g(d + _ + C / u, u);
20
- e.quadraticCurveTo(n[0], n[1], r[0], r[1]), e.arc(s, c, u, d + _ + C / u, f - _ - C / u);
21
- let i = h(f, -1, u), a = h(f, -1, u - C);
22
- e.quadraticCurveTo(i[0], i[1], a[0], a[1]);
21
+ e.quadraticCurveTo(n[0], n[1], r[0], r[1]), e.arc(a, c, u, d + _ + C / u, f - _ - C / u);
22
+ let i = h(f, -1, u), o = h(f, -1, u - C);
23
+ e.quadraticCurveTo(i[0], i[1], o[0], o[1]);
23
24
  } else {
24
25
  let t = g(d + _, u);
25
- e.moveTo(t[0], t[1]), e.arc(s, c, u, d + _, f - _);
26
+ e.moveTo(t[0], t[1]), e.arc(a, c, u, d + _, f - _);
26
27
  }
27
28
  if (x) {
28
29
  if (w > .5) {
29
30
  let t = h(f, -1, l + w);
30
31
  e.lineTo(t[0], t[1]);
31
32
  let n = h(f, -1, l), r = g(f - y - w / l, l);
32
- e.quadraticCurveTo(n[0], n[1], r[0], r[1]), e.arc(s, c, l, f - y - w / l, d + y + w / l, !0);
33
- let i = h(d, 1, l), a = h(d, 1, l + w);
34
- e.quadraticCurveTo(i[0], i[1], a[0], a[1]);
33
+ e.quadraticCurveTo(n[0], n[1], r[0], r[1]), e.arc(a, c, l, f - y - w / l, d + y + w / l, !0);
34
+ let i = h(d, 1, l), o = h(d, 1, l + w);
35
+ e.quadraticCurveTo(i[0], i[1], o[0], o[1]);
35
36
  } else {
36
37
  let t = g(f - y, l);
37
- e.lineTo(t[0], t[1]), e.arc(s, c, l, f - y, d + y, !0);
38
+ e.lineTo(t[0], t[1]), e.arc(a, c, l, f - y, d + y, !0);
38
39
  }
39
- } else if (m <= 0) e.lineTo(s, c);
40
+ } else if (m <= 0) e.lineTo(a, c);
40
41
  else if (p < Math.PI) {
41
42
  let t = m / Math.sin(p / 2), n = (d + f) / 2;
42
- e.lineTo(s + t * Math.cos(n), c + t * Math.sin(n));
43
- } else e.lineTo(s + m * Math.cos(f - Math.PI / 2), c + m * Math.sin(f - Math.PI / 2)), e.lineTo(s + m * Math.cos(d + Math.PI / 2), c + m * Math.sin(d + Math.PI / 2));
43
+ e.lineTo(a + t * Math.cos(n), c + t * Math.sin(n));
44
+ } else e.lineTo(a + m * Math.cos(f - Math.PI / 2), c + m * Math.sin(f - Math.PI / 2)), e.lineTo(a + m * Math.cos(d + Math.PI / 2), c + m * Math.sin(d + Math.PI / 2));
44
45
  e.closePath();
45
- }, c = (e, t, n, r, i, a) => {
46
+ }, l = (e, t, n, r, i, a) => {
46
47
  let o = t.length >> 1;
47
48
  if (o < 2) return;
48
49
  let s = (e) => t[(r ? o - 1 - e : e) * 2] + i, c = (e) => t[(r ? o - 1 - e : e) * 2 + 1] + a;
@@ -58,35 +59,35 @@ var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Ma
58
59
  u > .01 ? e.arcTo(s(t), c(t), s(r), c(r), u) : e.lineTo(s(t), c(t));
59
60
  }
60
61
  e.closePath();
61
- }, l = (e, t, n = 0, r = 0) => {
62
- e.beginPath(), c(e, t.points, t.radius ?? 0, !1, n, r), t.hole && c(e, t.hole, 0, !0, n, r);
63
- }, u = (e, t, n, r, i, a) => {
62
+ }, u = (e, t, n = 0, r = 0) => {
63
+ e.beginPath(), l(e, t.points, t.radius ?? 0, !1, n, r), t.hole && l(e, t.hole, 0, !0, n, r);
64
+ }, d = (e, t, n, r, i, a) => {
64
65
  let o = Math.max(0, Math.min(a, r / 2, i / 2));
65
66
  if (e.beginPath(), o <= .01) {
66
67
  e.moveTo(t, n), e.lineTo(t + r, n), e.lineTo(t + r, n + i), e.lineTo(t, n + i), e.closePath();
67
68
  return;
68
69
  }
69
70
  e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.arcTo(t + r, n, t + r, n + o, o), e.lineTo(t + r, n + i - o), e.arcTo(t + r, n + i, t + r - o, n + i, o), e.lineTo(t + o, n + i), e.arcTo(t, n + i, t, n + i - o, o), e.lineTo(t, n + o), e.arcTo(t, n, t + o, n, o), e.closePath();
70
- }, d = (e, t) => {
71
+ }, f = (e, t) => {
71
72
  typeof e.setLineDash == "function" && e.setLineDash(t);
72
- }, f = (e, t, r, i) => {
73
- e.beginPath(), e.arc(t, r, Math.max(0, i), 0, n);
74
- }, p = (e, t) => !!t && e.hit !== void 0 && (e.hit === t.index || !!e.also?.includes(t.index)), m = (e, t) => {
73
+ }, p = (e, t, n, i) => {
74
+ e.beginPath(), e.arc(t, n, Math.max(0, i), 0, r);
75
+ }, m = (e, t) => !!t && e.hit !== void 0 && (e.hit === t.index || !!e.also?.includes(t.index)), h = (e, t) => {
75
76
  let n = (t.x0 + t.x1) / 2;
76
77
  e.beginPath(), e.moveTo(t.x0, t.y0), e.bezierCurveTo(n, t.y0, n, t.y1, t.x1, t.y1);
77
- }, h = (e, t) => {
78
+ }, g = (e, t) => {
78
79
  if (t.color0 === t.color1 || typeof e.createLinearGradient != "function" || Math.abs(t.x1 - t.x0) < 1) return t.color0;
79
80
  let n = e.createLinearGradient(t.x0, 0, t.x1, 0);
80
81
  return n.addColorStop(0, t.color0), n.addColorStop(1, t.color1), n;
81
- }, g = (e) => Math.abs(e.s0 - e.t0) < 1e-9 && Math.abs(e.s1 - e.t1) < 1e-9, _ = (e) => {
82
+ }, _ = (e) => Math.abs(e.s0 - e.t0) < 1e-9 && Math.abs(e.s1 - e.t1) < 1e-9, v = (e) => {
82
83
  let t = (e.s0 + e.s1) / 2;
83
84
  return [e.cx + e.r * .4 * Math.cos(t), e.cy + e.r * .4 * Math.sin(t)];
84
- }, v = (e, t) => {
85
+ }, y = (e, t) => {
85
86
  let { cx: n, cy: r, r: i } = t, a = (e, t = i) => [n + t * Math.cos(e), r + t * Math.sin(e)];
86
87
  e.beginPath();
87
88
  let o = a(t.s0);
88
- if (e.moveTo(o[0], o[1]), t.s1 > t.s0 && e.arc(n, r, i, t.s0, t.s1), g(t)) {
89
- let [n, r] = _(t);
89
+ if (e.moveTo(o[0], o[1]), t.s1 > t.s0 && e.arc(n, r, i, t.s0, t.s1), _(t)) {
90
+ let [n, r] = v(t);
90
91
  e.quadraticCurveTo(n, r, o[0], o[1]), e.closePath();
91
92
  return;
92
93
  }
@@ -98,98 +99,98 @@ var r = "rgba(15, 23, 42, 0.18)", i = "rgba(255, 255, 255, 0.14)", a = (e) => Ma
98
99
  e.quadraticCurveTo(n, r, o[0], o[1]), t.t1 > t.t0 && e.arc(n, r, i, t.t0, t.t1);
99
100
  }
100
101
  e.quadraticCurveTo(n, r, o[0], o[1]), e.closePath();
101
- }, y = (e, t) => {
102
+ }, b = (e, t) => {
102
103
  if (t.color0 === t.color1 || typeof e.createLinearGradient != "function") return t.color0;
103
104
  let n = (t.s0 + t.s1) / 2, r = (t.t0 + t.t1) / 2, i = t.cx + t.r * Math.cos(n), a = t.cy + t.r * Math.sin(n), o = t.cx + t.r * Math.cos(r), s = t.cy + t.r * Math.sin(r);
104
105
  if (Math.hypot(o - i, s - a) < 1) return t.color0;
105
106
  let c = e.createLinearGradient(i, a, o, s);
106
107
  return c.addColorStop(0, t.color0), c.addColorStop(1, t.color1), c;
107
- }, b = (e, t, n) => {
108
+ }, x = (e, t, n) => {
108
109
  e.save();
109
- let a = t.enter, o = a ? Math.max(0, Math.min(1, a.alpha)) : 1;
110
- a && a.scale !== 1 && (e.translate(a.cx, a.cy), e.scale(a.scale, a.scale), e.translate(-a.cx, -a.cy)), e.lineJoin = "round", e.lineCap = "round";
111
- for (let a of t.nodes) {
112
- let c = a.hit !== void 0, g = p(a, n), _ = g && a.hit === n?.index, b = o * (a.alpha ?? 1);
113
- if (n && c && !g && (b *= t.dim), b <= .002) continue;
114
- e.globalAlpha = b;
115
- let x = _ && a.shift ? a.shift[0] : 0, S = _ && a.shift ? a.shift[1] : 0;
116
- switch (a.kind) {
110
+ let r = t.enter, o = r ? Math.max(0, Math.min(1, r.alpha)) : 1;
111
+ r && r.scale !== 1 && (e.translate(r.cx, r.cy), e.scale(r.scale, r.scale), e.translate(-r.cx, -r.cy)), e.lineJoin = "round", e.lineCap = "round";
112
+ for (let r of t.nodes) {
113
+ let s = r.hit !== void 0, l = m(r, n), _ = l && r.hit === n?.index, v = o * (r.alpha ?? 1);
114
+ if (n && s && !l && (v *= t.dim), v <= .002) continue;
115
+ e.globalAlpha = v;
116
+ let x = _ && r.shift ? r.shift[0] : 0, S = _ && r.shift ? r.shift[1] : 0;
117
+ switch (r.kind) {
117
118
  case "sector":
118
- s(e, a, x, S), e.fillStyle = a.fill, _ ? (e.save(), e.shadowColor = r, e.shadowBlur = 14, e.shadowOffsetY = 4, e.fill(), e.restore()) : e.fill();
119
+ c(e, r, x, S), e.fillStyle = r.fill, _ ? (e.save(), e.shadowColor = i, e.shadowBlur = 14, e.shadowOffsetY = 4, e.fill(), e.restore()) : e.fill();
119
120
  break;
120
121
  case "polygon": {
121
- l(e, a, x, S);
122
- let t = g && a.hoverFill ? a.hoverFill : a.fill;
123
- t && (e.fillStyle = t, e.fill(), g && a.brighten && (e.fillStyle = i, e.fill())), a.stroke && (e.strokeStyle = a.stroke, e.lineWidth = g && a.hoverLineWidth ? a.hoverLineWidth : a.lineWidth ?? 1, e.stroke());
122
+ u(e, r, x, S);
123
+ let t = l && r.hoverFill ? r.hoverFill : r.fill;
124
+ t && (e.fillStyle = t, e.fill(), l && r.brighten && (e.fillStyle = a, e.fill())), r.stroke && (e.strokeStyle = r.stroke, e.lineWidth = l && r.hoverLineWidth ? r.hoverLineWidth : r.lineWidth ?? 1, e.stroke());
124
125
  break;
125
126
  }
126
127
  case "rect":
127
- u(e, a.x + x, a.y + S, a.width, a.height, a.radius), e.fillStyle = a.fill, e.fill(), g && a.brighten && (e.fillStyle = i, e.fill()), _ && a.hoverStroke && a.width > 3 && a.height > 3 && (u(e, a.x + x + .75, a.y + S + .75, a.width - 1.5, a.height - 1.5, Math.max(0, a.radius - .75)), e.strokeStyle = a.hoverStroke, e.lineWidth = 1.5, e.stroke());
128
+ d(e, r.x + x, r.y + S, r.width, r.height, r.radius), e.fillStyle = r.fill, e.fill(), l && r.brighten && (e.fillStyle = a, e.fill()), _ && r.hoverStroke && r.width > 3 && r.height > 3 && (d(e, r.x + x + .75, r.y + S + .75, r.width - 1.5, r.height - 1.5, Math.max(0, r.radius - .75)), e.strokeStyle = r.hoverStroke, e.lineWidth = 1.5, e.stroke());
128
129
  break;
129
130
  case "arc":
130
- if (a.a1 - a.a0 <= 1e-6 || a.width <= 0) break;
131
- e.beginPath(), e.arc(a.cx + x, a.cy + S, a.r, a.a0, a.a1), e.lineCap = a.cap, e.lineWidth = a.width, e.strokeStyle = a.color, e.stroke(), e.lineCap = "round";
131
+ if (r.a1 - r.a0 <= 1e-6 || r.width <= 0) break;
132
+ e.beginPath(), e.arc(r.cx + x, r.cy + S, r.r, r.a0, r.a1), e.lineCap = r.cap, e.lineWidth = r.width, e.strokeStyle = r.color, e.stroke(), e.lineCap = "round";
132
133
  break;
133
134
  case "circle": {
134
- if (!a.fill && !a.stroke) break;
135
- let t = g && (a.indicator === void 0 || a.indicator === n?.indicator), r = t && a.hoverR ? a.hoverR : a.r, i = a.cx + x, o = a.cy + S;
136
- t && a.halo && (f(e, i, o, r + 5), e.fillStyle = a.halo, e.fill()), f(e, i, o, r), a.fill && (e.fillStyle = a.fill, e.fill()), a.stroke && (e.strokeStyle = a.stroke, e.lineWidth = a.lineWidth ?? 1, e.stroke());
135
+ if (!r.fill && !r.stroke) break;
136
+ let t = l && (r.indicator === void 0 || r.indicator === n?.indicator), i = t && r.hoverR ? r.hoverR : r.r, a = r.cx + x, o = r.cy + S;
137
+ t && r.halo && (p(e, a, o, i + 5), e.fillStyle = r.halo, e.fill()), p(e, a, o, i), r.fill && (e.fillStyle = r.fill, e.fill()), r.stroke && (e.strokeStyle = r.stroke, e.lineWidth = r.lineWidth ?? 1, e.stroke());
137
138
  break;
138
139
  }
139
140
  case "line": {
140
- let t = a.points;
141
+ let t = r.points;
141
142
  if (t.length < 4) break;
142
143
  e.beginPath(), e.moveTo(t[0] + x, t[1] + S);
143
144
  for (let n = 2; n < t.length; n += 2) e.lineTo(t[n] + (n === t.length - 2 ? 0 : x), t[n + 1] + (n === t.length - 2 ? 0 : S));
144
- e.strokeStyle = a.color, e.lineWidth = a.width, a.dash && d(e, a.dash), e.stroke(), a.dash && d(e, []);
145
+ e.strokeStyle = r.color, e.lineWidth = r.width, r.dash && f(e, r.dash), e.stroke(), r.dash && f(e, []);
145
146
  break;
146
147
  }
147
148
  case "text": {
148
- let t = a.indicator !== void 0 && n?.indicator === a.indicator;
149
- e.font = t && a.hoverFont ? a.hoverFont : a.font, e.textAlign = a.align, e.textBaseline = a.baseline;
150
- let r = !!a.rotate, i = a.x + x, o = a.y + S;
151
- r && (e.save(), e.translate(i, o), e.rotate(a.rotate ?? 0), i = 0, o = 0), a.halo && (e.strokeStyle = a.halo, e.lineWidth = 3, e.strokeText(a.text, i, o)), e.fillStyle = t && a.hoverColor ? a.hoverColor : a.color, e.fillText(a.text, i, o), r && e.restore();
149
+ let t = r.indicator !== void 0 && n?.indicator === r.indicator;
150
+ e.font = t && r.hoverFont ? r.hoverFont : r.font, e.textAlign = r.align, e.textBaseline = r.baseline;
151
+ let i = !!r.rotate, a = r.x + x, o = r.y + S;
152
+ i && (e.save(), e.translate(a, o), e.rotate(r.rotate ?? 0), a = 0, o = 0), r.halo && (e.strokeStyle = r.halo, e.lineWidth = 3, e.strokeText(r.text, a, o)), e.fillStyle = t && r.hoverColor ? r.hoverColor : r.color, e.fillText(r.text, a, o), i && e.restore();
152
153
  break;
153
154
  }
154
155
  case "link":
155
- if (a.width <= 0) break;
156
- g && a.activeAlpha !== void 0 && (e.globalAlpha = o * a.activeAlpha), m(e, a), e.lineCap = "butt", e.lineWidth = Math.max(1, a.width), e.strokeStyle = h(e, a), e.stroke(), e.lineCap = "round";
156
+ if (r.width <= 0) break;
157
+ l && r.activeAlpha !== void 0 && (e.globalAlpha = o * r.activeAlpha), h(e, r), e.lineCap = "butt", e.lineWidth = Math.max(1, r.width), e.strokeStyle = g(e, r), e.stroke(), e.lineCap = "round";
157
158
  break;
158
159
  case "ribbon":
159
- g && a.activeAlpha !== void 0 && (e.globalAlpha = o * a.activeAlpha), v(e, a), e.fillStyle = y(e, a), e.fill(), _ && (e.strokeStyle = a.color0, e.lineWidth = 1, e.stroke());
160
+ l && r.activeAlpha !== void 0 && (e.globalAlpha = o * r.activeAlpha), y(e, r), e.fillStyle = b(e, r), e.fill(), _ && (e.strokeStyle = r.color0, e.lineWidth = 1, e.stroke());
160
161
  break;
161
162
  case "guide": {
162
163
  let t = n?.indicator;
163
- if (t === void 0 || !a.ends[t]) break;
164
- e.globalAlpha = o, e.beginPath(), e.moveTo(a.cx, a.cy), e.lineTo(a.ends[t][0], a.ends[t][1]), e.strokeStyle = a.color, e.lineWidth = 1, d(e, [3, 3]), e.stroke(), d(e, []);
164
+ if (t === void 0 || !r.ends[t]) break;
165
+ e.globalAlpha = o, e.beginPath(), e.moveTo(r.cx, r.cy), e.lineTo(r.ends[t][0], r.ends[t][1]), e.strokeStyle = r.color, e.lineWidth = 1, f(e, [3, 3]), e.stroke(), f(e, []);
165
166
  break;
166
167
  }
167
168
  }
168
169
  }
169
170
  e.restore();
170
- }, x = (n, r, i) => {
171
- n.save(), n.font = t(r, 12), n.textBaseline = "middle", n.textAlign = "left";
172
- for (let t of i) {
173
- let i = t.y + t.height / 2;
174
- n.globalAlpha = t.hidden ? .45 : 1, n.fillStyle = t.color, f(n, t.x + 4.5, i, 4.5), n.fill(), n.fillStyle = e(r.textMuted), n.fillText(t.name, t.x + 15, i, Math.max(1, t.width - 15)), t.hidden && n.fillRect(t.x + 15, i, t.width - 15, 1);
171
+ }, S = (e, r, i) => {
172
+ e.save(), e.font = n(r, 12), e.textBaseline = "middle", e.textAlign = "left";
173
+ for (let n of i) {
174
+ let i = n.y + n.height / 2;
175
+ e.globalAlpha = n.hidden ? .45 : 1, e.fillStyle = n.color, p(e, n.x + 4.5, i, 4.5), e.fill(), e.fillStyle = t(r.textMuted), e.fillText(n.name, n.x + 15, i, Math.max(1, n.width - 15)), n.hidden && e.fillRect(n.x + 15, i, n.width - 15, 1);
175
176
  }
176
- n.restore();
177
- }, S = (n, i, a) => {
178
- let { padding: o, lineHeight: s } = a;
179
- n.save(), n.globalAlpha = 1, n.save(), n.shadowColor = r, n.shadowBlur = 16, n.shadowOffsetY = 6, u(n, a.x, a.y, a.width, a.height, 8), n.fillStyle = e(i.background), n.fill(), n.restore(), u(n, a.x + .5, a.y + .5, a.width - 1, a.height - 1, 8), n.strokeStyle = e(i.axis), n.lineWidth = 1, n.stroke(), n.textBaseline = "middle";
180
- let c = a.y + o + s / 2, l = a.x + o + 2, d = a.x + a.width - o - 2;
181
- if (a.text) {
182
- n.font = t(i, 12), n.fillStyle = e(i.text), n.textAlign = "left";
183
- for (let e of a.text) n.fillText(e, l, c), c += s;
184
- } else if (a.content) {
185
- let { content: r } = a, o = l;
186
- r.color && (n.fillStyle = r.color, f(n, o + 4, c, 4), n.fill(), o += 14), n.font = t(i, 12, 600), n.fillStyle = e(i.text), n.textAlign = "left";
187
- for (let e of a.titleLines ?? [r.title]) n.fillText(e, o, c), c += s;
188
- for (let a of r.rows) o = l, a.color && (n.fillStyle = a.color, f(n, o + 4, c, 4), n.fill(), o += 14), n.font = t(i, 12, a.strong ? 600 : 400), n.textAlign = "left", n.fillStyle = e(a.strong ? i.text : i.textMuted), n.fillText(a.name, o, c), n.font = t(i, 12, 600), n.textAlign = "right", n.fillStyle = e(i.text), n.fillText(a.value, d, c), c += s;
177
+ e.restore();
178
+ }, C = (r, a, o) => {
179
+ let { padding: s, lineHeight: c } = o;
180
+ r.save(), r.globalAlpha = 1, r.save(), r.shadowColor = i, r.shadowBlur = 16, r.shadowOffsetY = 6, d(r, o.x, o.y, o.width, o.height, 8), r.fillStyle = t(a.background, e), r.fill(), r.restore(), d(r, o.x + .5, o.y + .5, o.width - 1, o.height - 1, 8), r.strokeStyle = t(a.axis), r.lineWidth = 1, r.stroke(), r.textBaseline = "middle";
181
+ let l = o.y + s + c / 2, u = o.x + s + 2, f = o.x + o.width - s - 2;
182
+ if (o.text) {
183
+ r.font = n(a, 12), r.fillStyle = t(a.text), r.textAlign = "left";
184
+ for (let e of o.text) r.fillText(e, u, l), l += c;
185
+ } else if (o.content) {
186
+ let { content: e } = o, i = u;
187
+ e.color && (r.fillStyle = e.color, p(r, i + 4, l, 4), r.fill(), i += 14), r.font = n(a, 12, 600), r.fillStyle = t(a.text), r.textAlign = "left";
188
+ for (let t of o.titleLines ?? [e.title]) r.fillText(t, i, l), l += c;
189
+ for (let o of e.rows) i = u, o.color && (r.fillStyle = o.color, p(r, i + 4, l, 4), r.fill(), i += 14), r.font = n(a, 12, o.strong ? 600 : 400), r.textAlign = "left", r.fillStyle = t(o.strong ? a.text : a.textMuted), r.fillText(o.name, i, l), r.font = n(a, 12, 600), r.textAlign = "right", r.fillStyle = t(a.text), r.fillText(o.value, f, l), l += c;
189
190
  }
190
- n.restore();
191
+ r.restore();
191
192
  };
192
193
  //#endregion
193
- export { x as drawShapeLegend, b as drawShapeScene, S as drawShapeTooltip, _ as loopControl, p as nodeActive, o as padAngleAt, g as ribbonIsLoop, u as roundRectPath, a as sectorPad, s as sectorPath };
194
+ export { S as drawShapeLegend, x as drawShapeScene, C as drawShapeTooltip, v as loopControl, m as nodeActive, s as padAngleAt, _ as ribbonIsLoop, d as roundRectPath, o as sectorPad, c as sectorPath };
194
195
 
195
196
  //# sourceMappingURL=draw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"draw.js","names":["SHADOW","BRIGHTEN","sectorPad","node","padAngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","TAU","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","ribbonIsLoop","loopControl","ribbonPath","at","qx","qy","p0","tip","p1","ribbonStyle","ms","mt","x0","y0","x1","y1","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","font","theme","box","boxes","toCss","drawShapeTooltip","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type RibbonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/** Whether a chord ribbon joins an arc to itself (a self flow) */\nexport const ribbonIsLoop = (node: RibbonNode) =>\n Math.abs(node.s0 - node.t0) < 1e-9 && Math.abs(node.s1 - node.t1) < 1e-9;\n\n/** Control point of the inward bulge of a self-flow ribbon */\nexport const loopControl = (node: RibbonNode): [number, number] => {\n const m = (node.s0 + node.s1) / 2;\n return [\n node.cx + node.r * 0.4 * Math.cos(m),\n node.cy + node.r * 0.4 * Math.sin(m),\n ];\n};\n\n/** Outline of a chord ribbon: source arc, curve, target arc or arrowhead, curve */\nconst ribbonPath = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n const { cx, cy, r } = node;\n const at = (a: number, radius = r): [number, number] => [\n cx + radius * Math.cos(a),\n cy + radius * Math.sin(a),\n ];\n ctx.beginPath();\n const s = at(node.s0);\n ctx.moveTo(s[0], s[1]);\n if (node.s1 > node.s0) ctx.arc(cx, cy, r, node.s0, node.s1);\n if (ribbonIsLoop(node)) {\n const [qx, qy] = loopControl(node);\n ctx.quadraticCurveTo(qx, qy, s[0], s[1]);\n ctx.closePath();\n return;\n }\n if (node.head > 0) {\n const p0 = at(node.t0, r - node.head);\n const tip = at((node.t0 + node.t1) / 2);\n const p1 = at(node.t1, r - node.head);\n ctx.quadraticCurveTo(cx, cy, p0[0], p0[1]);\n ctx.lineTo(tip[0], tip[1]);\n ctx.lineTo(p1[0], p1[1]);\n } else {\n const t = at(node.t0);\n ctx.quadraticCurveTo(cx, cy, t[0], t[1]);\n if (node.t1 > node.t0) ctx.arc(cx, cy, r, node.t0, node.t1);\n }\n ctx.quadraticCurveTo(cx, cy, s[0], s[1]);\n ctx.closePath();\n};\n\nconst ribbonStyle = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\"\n )\n return node.color0;\n const ms = (node.s0 + node.s1) / 2;\n const mt = (node.t0 + node.t1) / 2;\n const x0 = node.cx + node.r * Math.cos(ms);\n const y0 = node.cy + node.r * Math.sin(ms);\n const x1 = node.cx + node.r * Math.cos(mt);\n const y1 = node.cy + node.r * Math.sin(mt);\n if (Math.hypot(x1 - x0, y1 - y0) < 1) return node.color0;\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"ribbon\": {\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n ribbonPath(ctx, node);\n ctx.fillStyle = ribbonStyle(ctx, node);\n ctx.fill();\n if (focused) {\n ctx.strokeStyle = node.color0;\n ctx.lineWidth = 1;\n ctx.stroke();\n }\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.titleLines ?? [content.title]) {\n ctx.fillText(line, x, y);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":";;;;AAoBA,IAAMA,IAAS,0BACTC,IAAW,6BAGJC,KAAa,MACxB,KAAK,IAAI,GAAG,KAAK,IAAIC,EAAK,KAAMA,EAAK,MAAMA,EAAK,KAAKA,EAAK,MAAO,CAAC,CAAC,GAGxDC,KAAc,GAAc,MACvCC,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI,GAAGC,IAAOD,CAAC,CAAC,IAAI,KAAK,KAAK,GAG1CE,KACX,GACA,GACA,IAAK,GACL,IAAK,MACF;CACH,IAAMC,IAAKL,EAAK,KAAKM,GACfC,IAAKP,EAAK,KAAKQ,GACf,EAAE,OAAI,OAAI,OAAI,UAAOR,GACrBS,IAAOC,IAAKC;CAElB,IADAC,EAAI,UAAU,GACVH,KAAQ,KAAKI,KAAMC,GAAI;CAC3B,IAAIL,KAAQM,IAAM,MAAM;EAOtB,AANAH,EAAI,OAAOP,IAAKQ,GAAIN,CAAE,GACtBK,EAAI,IAAIP,GAAIE,GAAIM,GAAI,GAAGE,CAAG,GACtBD,IAAK,MACPF,EAAI,OAAOP,IAAKS,GAAIP,CAAE,GACtBK,EAAI,IAAIP,GAAIE,GAAIO,GAAIC,GAAK,GAAG,EAAI,IAElCH,EAAI,UAAU;EACd;CACF;CACA,IAAMT,IAAOJ,EAAUC,CAAI,IAAI,GAEzBgB,KAAQ,GAAW,GAAc,MAAgC;EACrE,IAAMC,IAAIC,IAAIC,IAAOlB,EAAWE,GAAMD,CAAC;EACvC,OAAO,CAACG,IAAKH,IAAI,KAAK,IAAIe,CAAC,GAAGV,IAAKL,IAAI,KAAK,IAAIe,CAAC,CAAC;CACpD,GACMG,KAAS,GAAW,MAAgC,CACxDf,IAAKH,IAAI,KAAK,IAAIgB,CAAC,GACnBX,IAAKL,IAAI,KAAK,IAAIgB,CAAC,CACrB,GAEMG,I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ngleAt","r","half","sectorPath","cx","dx","cy","dy","span","a1","a0","ctx","r1","r0","TAU","edge","t","a","side","polar","po","outerSpan","pi","innerSpan","hasInner","thick","co","ci","s","c","e","c2","e2","d","m","polygonSubpath","n","points","px","reverse","i","py","radius","j","p","lenPrev","lenNext","polygonPath","roundRectPath","w","h","x","y","setDash","dash","circle","nodeActive","hover","linkPath","xm","linkStyle","gradient","ribbonIsLoop","loopControl","ribbonPath","at","qx","qy","p0","tip","p1","ribbonStyle","ms","mt","x0","y0","x1","y1","drawShapeScene","enter","scene","base","owned","active","focused","alpha","fill","big","strong","rotated","k","drawShapeLegend","font","theme","box","boxes","toCss","drawShapeTooltip","CANVAS_TOOLTIP_ALPHA","padding","lineHeight","left","right","line","content","row"],"sources":["../../../../../charts/src/engine/shapes/draw.ts"],"sourcesContent":["// Draws a ShapeScene on any CanvasRenderingContext2D (browser, OffscreenCanvas,\n// mini-programs). Only uses the widely available path APIs: arc, arcTo,\n// quadraticCurveTo, bezierCurveTo and linear gradients (no roundRect, no\n// Path2D, no fill rules).\n\nimport { toCss } from \"../color\";\nimport { font } from \"../overlay\";\nimport type { ChartTheme } from \"../theme\";\nimport { CANVAS_TOOLTIP_ALPHA } from \"../tooltip\";\nimport type { ShapeLegendBox, ShapeTooltipBox } from \"./layout\";\nimport {\n TAU,\n type LinkNode,\n type PolygonNode,\n type RibbonNode,\n type SectorNode,\n type ShapeHover,\n type ShapeNode,\n type ShapeScene,\n} from \"./scene\";\n\nconst SHADOW = \"rgba(15, 23, 42, 0.18)\";\nconst BRIGHTEN = \"rgba(255, 255, 255, 0.14)\";\n\n/** Gap of a sector, reduced so thin slices keep most of their arc */\nexport const sectorPad = (node: SectorNode) =>\n Math.max(0, Math.min(node.pad, (node.r1 * (node.a1 - node.a0)) / 3));\n\n/** Angle offset of a point at distance `r` from a radial edge moved by `half` px */\nexport const padAngleAt = (half: number, r: number) =>\n r > 0 ? Math.asin(Math.min(1, half / r)) : Math.PI / 2;\n\n/** Annular sector with pixel gaps and rounded corners */\nexport const sectorPath = (\n ctx: CanvasRenderingContext2D,\n node: SectorNode,\n dx = 0,\n dy = 0,\n) => {\n const cx = node.cx + dx;\n const cy = node.cy + dy;\n const { r0, r1, a0, a1 } = node;\n const span = a1 - a0;\n ctx.beginPath();\n if (span <= 0 || r1 <= r0) return;\n if (span >= TAU - 1e-6) {\n ctx.moveTo(cx + r1, cy);\n ctx.arc(cx, cy, r1, 0, TAU);\n if (r0 > 0) {\n ctx.moveTo(cx + r0, cy);\n ctx.arc(cx, cy, r0, TAU, 0, true);\n }\n ctx.closePath();\n return;\n }\n const half = sectorPad(node) / 2;\n // point at distance `r` on the start (side 1) or end (side -1) edge\n const edge = (a: number, side: 1 | -1, r: number): [number, number] => {\n const t = a + side * padAngleAt(half, r);\n return [cx + r * Math.cos(t), cy + r * Math.sin(t)];\n };\n const polar = (a: number, r: number): [number, number] => [\n cx + r * Math.cos(a),\n cy + r * Math.sin(a),\n ];\n\n const po = padAngleAt(half, r1);\n const outerSpan = Math.max(0, span - 2 * po);\n const pi = r0 > 0 ? padAngleAt(half, r0) : 0;\n const innerSpan = r0 > 0 ? span - 2 * pi : 0;\n const hasInner = r0 > 0 && innerSpan > 1e-4;\n const thick = r1 - r0;\n const co = Math.max(\n 0,\n Math.min(node.corner, thick / 2, (r1 * outerSpan) / 2 - 0.01),\n );\n const ci = hasInner\n ? Math.max(0, Math.min(node.corner, thick / 2, (r0 * innerSpan) / 2 - 0.01))\n : 0;\n\n // outer edge\n if (co > 0.5) {\n const s = edge(a0, 1, r1 - co);\n ctx.moveTo(s[0], s[1]);\n const c = edge(a0, 1, r1);\n const e = polar(a0 + po + co / r1, r1);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r1, a0 + po + co / r1, a1 - po - co / r1);\n const c2 = edge(a1, -1, r1);\n const e2 = edge(a1, -1, r1 - co);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a0 + po, r1);\n ctx.moveTo(s[0], s[1]);\n ctx.arc(cx, cy, r1, a0 + po, a1 - po);\n }\n\n // inner edge (or apex)\n if (hasInner) {\n if (ci > 0.5) {\n const s = edge(a1, -1, r0 + ci);\n ctx.lineTo(s[0], s[1]);\n const c = edge(a1, -1, r0);\n const e = polar(a1 - pi - ci / r0, r0);\n ctx.quadraticCurveTo(c[0], c[1], e[0], e[1]);\n ctx.arc(cx, cy, r0, a1 - pi - ci / r0, a0 + pi + ci / r0, true);\n const c2 = edge(a0, 1, r0);\n const e2 = edge(a0, 1, r0 + ci);\n ctx.quadraticCurveTo(c2[0], c2[1], e2[0], e2[1]);\n } else {\n const s = polar(a1 - pi, r0);\n ctx.lineTo(s[0], s[1]);\n ctx.arc(cx, cy, r0, a1 - pi, a0 + pi, true);\n }\n } else if (half <= 0) {\n ctx.lineTo(cx, cy);\n } else if (span < Math.PI) {\n // the two offset edges meet on the bisector\n const d = half / Math.sin(span / 2);\n const m = (a0 + a1) / 2;\n ctx.lineTo(cx + d * Math.cos(m), cy + d * Math.sin(m));\n } else {\n ctx.lineTo(\n cx + half * Math.cos(a1 - Math.PI / 2),\n cy + half * Math.sin(a1 - Math.PI / 2),\n );\n ctx.lineTo(\n cx + half * Math.cos(a0 + Math.PI / 2),\n cy + half * Math.sin(a0 + Math.PI / 2),\n );\n }\n ctx.closePath();\n};\n\n/** Closed polygon with rounded corners (adds a subpath) */\nconst polygonSubpath = (\n ctx: CanvasRenderingContext2D,\n points: readonly number[],\n radius: number,\n reverse: boolean,\n dx: number,\n dy: number,\n) => {\n const n = points.length >> 1;\n if (n < 2) return;\n const px = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2] + dx;\n };\n const py = (i: number) => {\n const k = reverse ? n - 1 - i : i;\n return points[k * 2 + 1] + dy;\n };\n if (radius <= 0 || n < 3) {\n ctx.moveTo(px(0), py(0));\n for (let i = 1; i < n; i++) ctx.lineTo(px(i), py(i));\n ctx.closePath();\n return;\n }\n // start in the middle of the last edge so every corner is rounded\n ctx.moveTo((px(n - 1) + px(0)) / 2, (py(n - 1) + py(0)) / 2);\n for (let i = 0; i < n; i++) {\n const j = (i + 1) % n;\n const p = (i + n - 1) % n;\n const lenPrev = Math.hypot(px(i) - px(p), py(i) - py(p));\n const lenNext = Math.hypot(px(j) - px(i), py(j) - py(i));\n const r = Math.min(radius, lenPrev / 2, lenNext / 2);\n if (r > 0.01) ctx.arcTo(px(i), py(i), px(j), py(j), r);\n else ctx.lineTo(px(i), py(i));\n }\n ctx.closePath();\n};\n\nconst polygonPath = (\n ctx: CanvasRenderingContext2D,\n node: PolygonNode,\n dx = 0,\n dy = 0,\n) => {\n ctx.beginPath();\n polygonSubpath(ctx, node.points, node.radius ?? 0, false, dx, dy);\n // reversed winding cuts the hole with the default nonzero rule\n if (node.hole) polygonSubpath(ctx, node.hole, 0, true, dx, dy);\n};\n\n/** Rounded rectangle path (no `ctx.roundRect`) */\nexport const roundRectPath = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number,\n) => {\n const r = Math.max(0, Math.min(radius, w / 2, h / 2));\n ctx.beginPath();\n if (r <= 0.01) {\n ctx.moveTo(x, y);\n ctx.lineTo(x + w, y);\n ctx.lineTo(x + w, y + h);\n ctx.lineTo(x, y + h);\n ctx.closePath();\n return;\n }\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n};\n\nconst setDash = (ctx: CanvasRenderingContext2D, dash: number[]) => {\n if (typeof ctx.setLineDash === \"function\") ctx.setLineDash(dash);\n};\n\nconst circle = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n r: number,\n) => {\n ctx.beginPath();\n ctx.arc(x, y, Math.max(0, r), 0, TAU);\n};\n\n/** Whether a node is emphasized by the hovered item (its own or an `also` one) */\nexport const nodeActive = (node: ShapeNode, hover: ShapeHover | null) =>\n !!hover &&\n node.hit !== undefined &&\n (node.hit === hover.index || !!node.also?.includes(hover.index));\n\n/** Center line of a sankey link */\nconst linkPath = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n const xm = (node.x0 + node.x1) / 2;\n ctx.beginPath();\n ctx.moveTo(node.x0, node.y0);\n ctx.bezierCurveTo(xm, node.y0, xm, node.y1, node.x1, node.y1);\n};\n\nconst linkStyle = (ctx: CanvasRenderingContext2D, node: LinkNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\" ||\n Math.abs(node.x1 - node.x0) < 1\n )\n return node.color0;\n const gradient = ctx.createLinearGradient(node.x0, 0, node.x1, 0);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/** Whether a chord ribbon joins an arc to itself (a self flow) */\nexport const ribbonIsLoop = (node: RibbonNode) =>\n Math.abs(node.s0 - node.t0) < 1e-9 && Math.abs(node.s1 - node.t1) < 1e-9;\n\n/** Control point of the inward bulge of a self-flow ribbon */\nexport const loopControl = (node: RibbonNode): [number, number] => {\n const m = (node.s0 + node.s1) / 2;\n return [\n node.cx + node.r * 0.4 * Math.cos(m),\n node.cy + node.r * 0.4 * Math.sin(m),\n ];\n};\n\n/** Outline of a chord ribbon: source arc, curve, target arc or arrowhead, curve */\nconst ribbonPath = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n const { cx, cy, r } = node;\n const at = (a: number, radius = r): [number, number] => [\n cx + radius * Math.cos(a),\n cy + radius * Math.sin(a),\n ];\n ctx.beginPath();\n const s = at(node.s0);\n ctx.moveTo(s[0], s[1]);\n if (node.s1 > node.s0) ctx.arc(cx, cy, r, node.s0, node.s1);\n if (ribbonIsLoop(node)) {\n const [qx, qy] = loopControl(node);\n ctx.quadraticCurveTo(qx, qy, s[0], s[1]);\n ctx.closePath();\n return;\n }\n if (node.head > 0) {\n const p0 = at(node.t0, r - node.head);\n const tip = at((node.t0 + node.t1) / 2);\n const p1 = at(node.t1, r - node.head);\n ctx.quadraticCurveTo(cx, cy, p0[0], p0[1]);\n ctx.lineTo(tip[0], tip[1]);\n ctx.lineTo(p1[0], p1[1]);\n } else {\n const t = at(node.t0);\n ctx.quadraticCurveTo(cx, cy, t[0], t[1]);\n if (node.t1 > node.t0) ctx.arc(cx, cy, r, node.t0, node.t1);\n }\n ctx.quadraticCurveTo(cx, cy, s[0], s[1]);\n ctx.closePath();\n};\n\nconst ribbonStyle = (ctx: CanvasRenderingContext2D, node: RibbonNode) => {\n if (\n node.color0 === node.color1 ||\n typeof ctx.createLinearGradient !== \"function\"\n )\n return node.color0;\n const ms = (node.s0 + node.s1) / 2;\n const mt = (node.t0 + node.t1) / 2;\n const x0 = node.cx + node.r * Math.cos(ms);\n const y0 = node.cy + node.r * Math.sin(ms);\n const x1 = node.cx + node.r * Math.cos(mt);\n const y1 = node.cy + node.r * Math.sin(mt);\n if (Math.hypot(x1 - x0, y1 - y0) < 1) return node.color0;\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n gradient.addColorStop(0, node.color0);\n gradient.addColorStop(1, node.color1);\n return gradient;\n};\n\n/**\n * Draws a scene in CSS pixels (the caller sets the pixel-ratio transform and\n * clears the canvas). `hover` emphasizes an item and dims the others.\n */\nexport const drawShapeScene = (\n ctx: CanvasRenderingContext2D,\n scene: ShapeScene,\n hover: ShapeHover | null,\n) => {\n ctx.save();\n const enter = scene.enter;\n const base = enter ? Math.max(0, Math.min(1, enter.alpha)) : 1;\n if (enter && enter.scale !== 1) {\n ctx.translate(enter.cx, enter.cy);\n ctx.scale(enter.scale, enter.scale);\n ctx.translate(-enter.cx, -enter.cy);\n }\n ctx.lineJoin = \"round\";\n ctx.lineCap = \"round\";\n\n for (const node of scene.nodes) {\n const owned = node.hit !== undefined;\n const active = nodeActive(node, hover);\n // the hovered item itself (shadows, pop-out); `also` nodes are only emphasized\n const focused = active && node.hit === hover?.index;\n let alpha = base * (node.alpha ?? 1);\n if (hover && owned && !active) alpha *= scene.dim;\n if (alpha <= 0.002) continue;\n ctx.globalAlpha = alpha;\n const dx = focused && node.shift ? node.shift[0] : 0;\n const dy = focused && node.shift ? node.shift[1] : 0;\n\n switch (node.kind) {\n case \"sector\": {\n sectorPath(ctx, node, dx, dy);\n ctx.fillStyle = node.fill;\n if (focused) {\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 14;\n ctx.shadowOffsetY = 4;\n ctx.fill();\n ctx.restore();\n } else ctx.fill();\n break;\n }\n case \"polygon\": {\n polygonPath(ctx, node, dx, dy);\n const fill = active && node.hoverFill ? node.hoverFill : node.fill;\n if (fill) {\n ctx.fillStyle = fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth =\n active && node.hoverLineWidth\n ? node.hoverLineWidth\n : (node.lineWidth ?? 1);\n ctx.stroke();\n }\n break;\n }\n case \"rect\": {\n roundRectPath(\n ctx,\n node.x + dx,\n node.y + dy,\n node.width,\n node.height,\n node.radius,\n );\n ctx.fillStyle = node.fill;\n ctx.fill();\n if (active && node.brighten) {\n ctx.fillStyle = BRIGHTEN;\n ctx.fill();\n }\n if (focused && node.hoverStroke && node.width > 3 && node.height > 3) {\n roundRectPath(\n ctx,\n node.x + dx + 0.75,\n node.y + dy + 0.75,\n node.width - 1.5,\n node.height - 1.5,\n Math.max(0, node.radius - 0.75),\n );\n ctx.strokeStyle = node.hoverStroke;\n ctx.lineWidth = 1.5;\n ctx.stroke();\n }\n break;\n }\n case \"arc\": {\n if (node.a1 - node.a0 <= 1e-6 || node.width <= 0) break;\n ctx.beginPath();\n ctx.arc(node.cx + dx, node.cy + dy, node.r, node.a0, node.a1);\n ctx.lineCap = node.cap;\n ctx.lineWidth = node.width;\n ctx.strokeStyle = node.color;\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"circle\": {\n if (!node.fill && !node.stroke) break;\n const big =\n active &&\n (node.indicator === undefined || node.indicator === hover?.indicator);\n const r = big && node.hoverR ? node.hoverR : node.r;\n const x = node.cx + dx;\n const y = node.cy + dy;\n if (big && node.halo) {\n circle(ctx, x, y, r + 5);\n ctx.fillStyle = node.halo;\n ctx.fill();\n }\n circle(ctx, x, y, r);\n if (node.fill) {\n ctx.fillStyle = node.fill;\n ctx.fill();\n }\n if (node.stroke) {\n ctx.strokeStyle = node.stroke;\n ctx.lineWidth = node.lineWidth ?? 1;\n ctx.stroke();\n }\n break;\n }\n case \"line\": {\n const p = node.points;\n if (p.length < 4) break;\n ctx.beginPath();\n ctx.moveTo(p[0] + dx, p[1] + dy);\n // the last point stays: leader lines bend to their fixed label\n for (let i = 2; i < p.length; i += 2)\n ctx.lineTo(\n p[i] + (i === p.length - 2 ? 0 : dx),\n p[i + 1] + (i === p.length - 2 ? 0 : dy),\n );\n ctx.strokeStyle = node.color;\n ctx.lineWidth = node.width;\n if (node.dash) setDash(ctx, node.dash);\n ctx.stroke();\n if (node.dash) setDash(ctx, []);\n break;\n }\n case \"text\": {\n const strong =\n node.indicator !== undefined && hover?.indicator === node.indicator;\n ctx.font = strong && node.hoverFont ? node.hoverFont : node.font;\n ctx.textAlign = node.align;\n ctx.textBaseline = node.baseline;\n const rotated = !!node.rotate;\n let x = node.x + dx;\n let y = node.y + dy;\n if (rotated) {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(node.rotate ?? 0);\n x = 0;\n y = 0;\n }\n if (node.halo) {\n ctx.strokeStyle = node.halo;\n ctx.lineWidth = 3;\n ctx.strokeText(node.text, x, y);\n }\n ctx.fillStyle =\n strong && node.hoverColor ? node.hoverColor : node.color;\n ctx.fillText(node.text, x, y);\n if (rotated) ctx.restore();\n break;\n }\n case \"link\": {\n if (node.width <= 0) break;\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n linkPath(ctx, node);\n ctx.lineCap = \"butt\";\n ctx.lineWidth = Math.max(1, node.width);\n ctx.strokeStyle = linkStyle(ctx, node);\n ctx.stroke();\n ctx.lineCap = \"round\";\n break;\n }\n case \"ribbon\": {\n if (active && node.activeAlpha !== undefined)\n ctx.globalAlpha = base * node.activeAlpha;\n ribbonPath(ctx, node);\n ctx.fillStyle = ribbonStyle(ctx, node);\n ctx.fill();\n if (focused) {\n ctx.strokeStyle = node.color0;\n ctx.lineWidth = 1;\n ctx.stroke();\n }\n break;\n }\n case \"guide\": {\n const k = hover?.indicator;\n if (k === undefined || !node.ends[k]) break;\n ctx.globalAlpha = base;\n ctx.beginPath();\n ctx.moveTo(node.cx, node.cy);\n ctx.lineTo(node.ends[k][0], node.ends[k][1]);\n ctx.strokeStyle = node.color;\n ctx.lineWidth = 1;\n setDash(ctx, [3, 3]);\n ctx.stroke();\n setDash(ctx, []);\n break;\n }\n default:\n break;\n }\n }\n ctx.restore();\n};\n\n/** Legend drawn on a canvas (dots, muted names, struck-through when hidden) */\nexport const drawShapeLegend = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n boxes: readonly ShapeLegendBox[],\n) => {\n ctx.save();\n ctx.font = font(theme, 12);\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n for (const box of boxes) {\n const cy = box.y + box.height / 2;\n ctx.globalAlpha = box.hidden ? 0.45 : 1;\n ctx.fillStyle = box.color;\n circle(ctx, box.x + 4.5, cy, 4.5);\n ctx.fill();\n ctx.fillStyle = toCss(theme.textMuted);\n ctx.fillText(box.name, box.x + 15, cy, Math.max(1, box.width - 15));\n if (box.hidden) ctx.fillRect(box.x + 15, cy, box.width - 15, 1);\n }\n ctx.restore();\n};\n\n/** Tooltip drawn on a canvas, styled like the DOM tooltip */\nexport const drawShapeTooltip = (\n ctx: CanvasRenderingContext2D,\n theme: ChartTheme,\n box: ShapeTooltipBox,\n) => {\n const { padding, lineHeight } = box;\n ctx.save();\n ctx.globalAlpha = 1;\n ctx.save();\n ctx.shadowColor = SHADOW;\n ctx.shadowBlur = 16;\n ctx.shadowOffsetY = 6;\n roundRectPath(ctx, box.x, box.y, box.width, box.height, 8);\n ctx.fillStyle = toCss(theme.background, CANVAS_TOOLTIP_ALPHA);\n ctx.fill();\n ctx.restore();\n roundRectPath(\n ctx,\n box.x + 0.5,\n box.y + 0.5,\n box.width - 1,\n box.height - 1,\n 8,\n );\n ctx.strokeStyle = toCss(theme.axis);\n ctx.lineWidth = 1;\n ctx.stroke();\n\n ctx.textBaseline = \"middle\";\n let y = box.y + padding + lineHeight / 2;\n const left = box.x + padding + 2;\n const right = box.x + box.width - padding - 2;\n if (box.text) {\n ctx.font = font(theme, 12);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.text) {\n ctx.fillText(line, left, y);\n y += lineHeight;\n }\n } else if (box.content) {\n const { content } = box;\n let x = left;\n if (content.color) {\n ctx.fillStyle = content.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, 600);\n ctx.fillStyle = toCss(theme.text);\n ctx.textAlign = \"left\";\n for (const line of box.titleLines ?? [content.title]) {\n ctx.fillText(line, x, y);\n y += lineHeight;\n }\n for (const row of content.rows) {\n x = left;\n if (row.color) {\n ctx.fillStyle = row.color;\n circle(ctx, x + 4, y, 4);\n ctx.fill();\n x += 14;\n }\n ctx.font = font(theme, 12, row.strong ? 600 : 400);\n ctx.textAlign = \"left\";\n ctx.fillStyle = toCss(row.strong ? theme.text : theme.textMuted);\n ctx.fillText(row.name, x, y);\n ctx.font = font(theme, 12, 600);\n ctx.textAlign = \"right\";\n ctx.fillStyle = toCss(theme.text);\n ctx.fillText(row.value, right, y);\n y += lineHeight;\n }\n }\n ctx.restore();\n};\n"],"mappings":";;;;;AAqBA,I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AAI,MAErB,AADAnF,EAAI,SAAS4F,GAAMF,GAAMjD,CAAC,GAC1B,KAAKgD;CAET,OAAO,IAAIN,EAAI,SAAS;EACtB,IAAM,EAAE,eAAYA,GAChB3C,IAAIkD;EASR,AARIG,EAAQ,UACV,EAAI,YAAYA,EAAQ,OACxBjD,EAAO5C,GAAKwC,IAAI,GAAGC,GAAG,CAAC,GACvBzC,EAAI,KAAK,GACT,KAAK,KAEP,EAAI,OAAOiF,EAAKC,GAAO,IAAI,GAAG,GAC9B,EAAI,YAAYG,EAAMH,EAAM,IAAI,GAChC,EAAI,YAAY;EAChB,KAAK,IAAMU,KAAQT,EAAI,cAAc,CAACU,EAAQ,KAAK,GAEjD,AADA7F,EAAI,SAAS4F,GAAMpD,GAAGC,CAAC,GACvB,KAAKgD;EAEP,KAAK,IAAMK,KAAOD,EAAQ,MAgBxB,AAfA,IAAIH,GACAI,EAAI,UACN,EAAI,YAAYA,EAAI,OACpBlD,EAAO5C,GAAKwC,IAAI,GAAGC,GAAG,CAAC,GACvBzC,EAAI,KAAK,GACT,KAAK,KAEP,EAAI,OAAOiF,EAAKC,GAAO,IAAIY,EAAI,SAAS,MAAM,GAAG,GACjD,EAAI,YAAY,QAChB,EAAI,YAAYT,EAAMS,EAAI,SAASZ,EAAM,OAAOA,EAAM,SAAS,GAC/DlF,EAAI,SAAS8F,EAAI,MAAMtD,GAAGC,CAAC,GAC3B,EAAI,OAAOwC,EAAKC,GAAO,IAAI,GAAG,GAC9B,EAAI,YAAY,SAChB,EAAI,YAAYG,EAAMH,EAAM,IAAI,GAChClF,EAAI,SAAS8F,EAAI,OAAOH,GAAOlD,CAAC,GAChC,KAAKgD;CAET;CACA,EAAI,QAAQ;AACd"}
@@ -1,3 +1,3 @@
1
- const e=require("../color.cjs"),t=require("../locale.cjs"),n=require("../overlay.cjs"),r=require("./labels.cjs"),i=require("./scene.cjs"),a=require("./calendar.cjs"),o=require("./bullet.cjs"),s=require("./chord.cjs"),c=require("./funnel.cjs"),l=require("./gauge.cjs"),u=require("./pie.cjs"),d=require("./radar.cjs"),f=require("./radialBar.cjs"),p=require("./sankey.cjs"),m=require("./sunburst.cjs"),h=require("./treemap.cjs");var g=new Set,_=[],v=e=>{let{options:n,theme:v,width:y,height:b}=e,x=e.bounds??{x:0,y:0,width:y,height:b},S=e.from??null,C=i.clamp(e.t??1,0,1),w=v.palette.length?v.palette:[v.primary],T=t.resolveLocale(n.locale),E=r.shapeLabels(n),D={theme:v,measure:e.measure,hidden:e.hidden??g,enter:i.clamp(e.enter??1,0,1),value:(e,t)=>{if(!S||C>=1)return t;let n=S.get(e)??0;return n+(t-n)*C},format:n.format??r.localeFormat(T),percent:n.percentFormat??r.localePercent(T),labels:E,locale:T,color:(e,t)=>i.resolveWith(v,e,w[t%w.length]),area:i.inset(x,n.padding),focus:e.focus??_},O;switch(n.type){case`pie`:O=u.layoutPie(n,D);break;case`radar`:O=d.layoutRadar(n,D);break;case`gauge`:O=l.layoutGauge(n,D);break;case`funnel`:O=c.layoutFunnel(n,D);break;case`sankey`:O=p.layoutSankey(n,D);break;case`sunburst`:O=m.layoutSunburst(n,D);break;case`radialBar`:O=f.layoutRadialBar(n,D);break;case`calendarHeatmap`:O=a.layoutCalendar(n,D);break;case`bullet`:O=o.layoutBullet(n,D);break;case`chord`:O=s.layoutChord(n,D);break;default:O=h.layoutTreemap(n,D)}return{type:n.type,width:y,height:b,labels:E,locale:T,...O}},y=(e,t=g,n=_)=>{let r=new Map;switch(e.type){case`pie`:u.pieValues(e,t,r);break;case`radar`:d.radarValues(e,t,r);break;case`gauge`:l.gaugeValues(e,t,r);break;case`funnel`:c.funnelValues(e,t,r);break;case`sankey`:p.sankeyValues(e,t,r);break;case`sunburst`:m.sunburstValues(e,t,n,r);break;case`radialBar`:f.radialBarValues(e,t,r);break;case`calendarHeatmap`:a.calendarValues(e,t,r);break;case`bullet`:o.bulletValues(e,t,r);break;case`chord`:s.chordValues(e,t,r);break;default:h.treemapValues(e,t,r)}return r},b=(e,t,n)=>{let r=new Map;return t.forEach((t,i)=>{let a=e.get(i)??0;r.set(i,a+(t-a)*n)}),r},x=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(e===void 0||Math.abs(e-r)>1e-12)return!1}return!0},S=e=>{let t=typeof e.legend==`object`?e.legend:{};return{position:t.position??`bottom`,toggle:t.toggle??!0}},C=(t,n,o=g)=>{if(t.legend===!1)return null;let l=n.palette.length?n.palette:[n.primary],u=(t,r)=>e.toCss(i.resolveWith(n,t,l[r%l.length])),m=[],h=t.legend!==void 0;switch(t.type){case`pie`:h=!0,m=t.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:o.has(t)}));break;case`funnel`:h=!0,m=c.funnelOrder(t,g).map(e=>({index:e,name:t.data[e].name,color:u(t.data[e].color,e),hidden:o.has(e)}));break;case`radar`:h||(h=t.series.length>1),m=t.series.map((e,n)=>({index:n,name:d.seriesName(t,n,r.shapeLabels(t)),color:u(e.color,n),hidden:o.has(n)}));break;case`treemap`:case`sunburst`:m=t.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:o.has(t)}));break;case`radialBar`:h||(h=!f.radialBarLabels(t)),m=t.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:o.has(t)}));break;case`bullet`:m=t.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:o.has(t)}));break;case`sankey`:{let e=p.resolveSankey(t);m=e.names.map((t,n)=>({index:n,name:t,color:u(e.colors[n],n),hidden:o.has(n)}));break}case`calendarHeatmap`:h=!0,m=a.calendarLegend(t,n,o);break;case`chord`:{h=!0;let e=s.resolveChord(t);m=e.names.map((t,n)=>({index:n,name:t,color:u(e.colors[n],n),hidden:o.has(n)}));break}}return h&&m.length?m:null},w=e=>{switch(e.type){case`radar`:return e.series.length;case`gauge`:return 0;case`sankey`:return p.resolveSankey(e).names.length;case`calendarHeatmap`:return a.calendarModel(e)?.count??0;case`chord`:return s.resolveChord(e).names.length;default:return e.data.length}},T=(e,t)=>{if(!t)return null;let n=e.items.find(e=>e.index===t.index);if(!n)return null;if(n.indicators){let e=i.clamp(t.indicator??0,0,n.indicators.length-1),r=n.indicators[e];return{index:n.index,indicator:e,name:n.name,value:r.value,percent:r.percent,color:n.color}}return{index:n.index,name:n.name,value:n.value,percent:n.percent,color:n.color,...n.path?{path:n.path}:{},...n.event}},E=(e,t)=>e===t||!!e&&!!t&&e.index===t.index&&e.indicator===t.indicator,D=(e,t)=>{let n=e.items.find(e=>e.index===t.index);if(!n)return null;let r=n.indicators?n.rows.map((e,n)=>n===(t.indicator??-1)?{...e,strong:!0}:e):n.rows;return{title:n.path?n.path.join(` / `):n.name,color:n.color,rows:r}},O=(e,t)=>{let n=e.items.find(e=>e.index===t.index);if(!n)return``;if(n.indicators){let e=i.clamp(t.indicator??0,0,n.indicators.length-1);return`${n.name}, ${n.indicators[e].name}: ${n.rows[e]?.value??n.indicators[e].value}`}return`${n.path?n.path.join(` / `):n.name}: ${n.rows[0]?.value??n.value} (${n.share??r.localePercent(e.locale)(n.percent)})`},k=e=>{let t=r.shapeLabels(e);switch(e.type){case`pie`:return e.rose?t.roseChart:(e.innerRadius??0)>0?t.donutChart:t.pieChart;case`radar`:return t.radarChart;case`gauge`:return e.label?r.interpolate(t.gaugeChartNamed,{label:e.label}):t.gaugeChart;case`funnel`:return t.funnelChart;case`sankey`:return t.sankeyChart;case`sunburst`:return t.sunburstChart;case`radialBar`:return t.radialBarChart;case`calendarHeatmap`:return t.calendarHeatmap;case`bullet`:return t.bulletChart;case`chord`:return t.chordChart;default:return t.treemapChart}},A=e=>e.empty?(e.labels??r.SHAPE_LABELS.en).noData:e.items.slice(0,12).map(t=>t.indicators?`${t.name}: ${t.indicators.map((e,n)=>`${e.name} ${t.rows[n]?.value??e.value}`).join(`, `)}`:O(e,{index:t.index})).join(`; `),j=20,M=(e,t,r,i,a,o)=>{let s=n.font(a,12),c=[[]],l=0;for(let n of e){let e=Math.min(t-8,16+o(n.name,s)),r=c[c.length-1];r.length&&l+14+e>t-8&&(c.push(r=[]),l=0),r.length&&(l+=14),r.push({...n,x:l,y:0,width:e,height:j}),l+=e}let u=c.length*j+8,d=r===`top`?2:i-u+6,f=[];return c.forEach((e,n)=>{let r=e[e.length-1],i=(t-(r?r.x+r.width:0))/2;for(let t of e)f.push({...t,x:t.x+i,y:d+n*j})}),{boxes:f,height:u}},N=6,P=14,F=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),I=(e,t,n,r,i,a,o)=>{let s=N,c=(e,t)=>({x:Math.max(s,Math.min(e,a-r-s)),y:Math.max(s,Math.min(t,o-i-s))}),{x:l,y:u}=n,d=e?.radar;if(!d||!e||!t){let e=l+16;return e+r>a-s&&(e=l-16-r),c(e,u-i/2)}let f=[[l,u]],p=e.items.find(e=>e.index===t.index),m=p?.indicators&&t.indicator!==void 0?p.indicators[t.indicator]:void 0;m&&f.push([m.x,m.y]);let h=d.labels??[],g=l-d.cx,_=u-d.cy,v=Math.hypot(g,_);v>1?(g/=v,_/=v):(g=1,_=0);let y=P,b=[[l+y,u-i/2],[l-y-r,u-i/2],[l-r/2,u-y-i],[l-r/2,u+y],[l+y,u-y-i],[l+y,u+y],[l-y-r,u-y-i],[l-y-r,u+y]],x=c(b[0][0],b[0][1]),S=1/0;for(let[e,t]of b){let n=c(e,t),a={x:n.x,y:n.y,width:r,height:i},o=0;for(let[e,t]of f)e>a.x-8&&e<a.x+r+8&&t>a.y-8&&t<a.y+i+8&&(o+=1e6);for(let e of h)o+=F(a,e)*4;let s=n.x+r/2-l,d=n.y+i/2-u,p=Math.hypot(s,d)||1;o+=p*.5,o-=(s*g+d*_)/p*40,o+=Math.abs(n.x-e)+Math.abs(n.y-t),o<S&&(S=o,x=n)}return x},L=(e,t,r,a,o,s,c,l=null,u=null)=>{let d=0,f,p,m,h;if(typeof e==`string`){m=e.split(`
2
- `);let t=n.font(s,12);for(let e of m)d=Math.max(d,c(e,t));f=m.length}else{p=e;let t=n.font(s,12,600),r=e.color?14:0,o=Math.max(60,Math.min(260,a-16-18)-r);h=i.wrapText(e.title,o,t,c,3),h.length||(h=[e.title]);for(let e of h)d=Math.max(d,r+c(e,t));for(let t of e.rows)d=Math.max(d,(t.color?14:0)+c(t.name,n.font(s,12))+16+c(t.value,n.font(s,12,600)));f=h.length+e.rows.length}let g=Math.max(96,Math.ceil(d+18+4)),_=f*18+18,{x:v,y}=I(l,u,{x:t,y:r},g,_,a,o);return{x:v,y,width:g,height:_,padding:9,lineHeight:18,...p?{content:p,titleLines:h}:{},...m?{text:m}:{}}};exports.blendValues=b,exports.describeChart=k,exports.describeItem=O,exports.describeScene=A,exports.hoverEvent=T,exports.layoutShapeLegend=M,exports.layoutShapeScene=v,exports.layoutShapeTooltip=L,exports.legendConfig=S,exports.placeShapeTooltip=I,exports.sameHover=E,exports.sameValues=x,exports.shapeLegend=C,exports.shapeValues=y,exports.toggleCount=w,exports.tooltipContent=D;
1
+ const e=require("../tooltip.cjs"),t=require("../locale.cjs"),n=require("../color.cjs"),r=require("../overlay.cjs"),i=require("./labels.cjs"),a=require("./scene.cjs"),o=require("./calendar.cjs"),s=require("./bullet.cjs"),c=require("./chord.cjs"),l=require("./funnel.cjs"),u=require("./gauge.cjs"),d=require("./pie.cjs"),f=require("./radar.cjs"),p=require("./radialBar.cjs"),m=require("./sankey.cjs"),h=require("./sunburst.cjs"),g=require("./treemap.cjs");var _=new Set,v=[],y=e=>{let{options:n,theme:r,width:y,height:b}=e,x=e.bounds??{x:0,y:0,width:y,height:b},S=e.from??null,C=a.clamp(e.t??1,0,1),w=r.palette.length?r.palette:[r.primary],T=t.resolveLocale(n.locale),E=i.shapeLabels(n),D={theme:r,measure:e.measure,hidden:e.hidden??_,enter:a.clamp(e.enter??1,0,1),value:(e,t)=>{if(!S||C>=1)return t;let n=S.get(e)??0;return n+(t-n)*C},format:n.format??i.localeFormat(T),percent:n.percentFormat??i.localePercent(T),labels:E,locale:T,color:(e,t)=>a.resolveWith(r,e,w[t%w.length]),area:a.inset(x,n.padding),focus:e.focus??v},O;switch(n.type){case`pie`:O=d.layoutPie(n,D);break;case`radar`:O=f.layoutRadar(n,D);break;case`gauge`:O=u.layoutGauge(n,D);break;case`funnel`:O=l.layoutFunnel(n,D);break;case`sankey`:O=m.layoutSankey(n,D);break;case`sunburst`:O=h.layoutSunburst(n,D);break;case`radialBar`:O=p.layoutRadialBar(n,D);break;case`calendarHeatmap`:O=o.layoutCalendar(n,D);break;case`bullet`:O=s.layoutBullet(n,D);break;case`chord`:O=c.layoutChord(n,D);break;default:O=g.layoutTreemap(n,D)}return{type:n.type,width:y,height:b,labels:E,locale:T,...O}},b=(e,t=_,n=v)=>{let r=new Map;switch(e.type){case`pie`:d.pieValues(e,t,r);break;case`radar`:f.radarValues(e,t,r);break;case`gauge`:u.gaugeValues(e,t,r);break;case`funnel`:l.funnelValues(e,t,r);break;case`sankey`:m.sankeyValues(e,t,r);break;case`sunburst`:h.sunburstValues(e,t,n,r);break;case`radialBar`:p.radialBarValues(e,t,r);break;case`calendarHeatmap`:o.calendarValues(e,t,r);break;case`bullet`:s.bulletValues(e,t,r);break;case`chord`:c.chordValues(e,t,r);break;default:g.treemapValues(e,t,r)}return r},x=(e,t,n)=>{let r=new Map;return t.forEach((t,i)=>{let a=e.get(i)??0;r.set(i,a+(t-a)*n)}),r},S=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(e===void 0||Math.abs(e-r)>1e-12)return!1}return!0},C=e=>{let t=typeof e.legend==`object`?e.legend:{};return{position:t.position??`bottom`,toggle:t.toggle??!0}},w=(e,t,r=_)=>{if(e.legend===!1)return null;let s=t.palette.length?t.palette:[t.primary],u=(e,r)=>n.toCss(a.resolveWith(t,e,s[r%s.length])),d=[],h=e.legend!==void 0;switch(e.type){case`pie`:h=!0,d=e.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:r.has(t)}));break;case`funnel`:h=!0,d=l.funnelOrder(e,_).map(t=>({index:t,name:e.data[t].name,color:u(e.data[t].color,t),hidden:r.has(t)}));break;case`radar`:h||(h=e.series.length>1),d=e.series.map((t,n)=>({index:n,name:f.seriesName(e,n,i.shapeLabels(e)),color:u(t.color,n),hidden:r.has(n)}));break;case`treemap`:case`sunburst`:d=e.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:r.has(t)}));break;case`radialBar`:h||(h=!p.radialBarLabels(e)),d=e.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:r.has(t)}));break;case`bullet`:d=e.data.map((e,t)=>({index:t,name:e.name,color:u(e.color,t),hidden:r.has(t)}));break;case`sankey`:{let t=m.resolveSankey(e);d=t.names.map((e,n)=>({index:n,name:e,color:u(t.colors[n],n),hidden:r.has(n)}));break}case`calendarHeatmap`:h=!0,d=o.calendarLegend(e,t,r);break;case`chord`:{h=!0;let t=c.resolveChord(e);d=t.names.map((e,n)=>({index:n,name:e,color:u(t.colors[n],n),hidden:r.has(n)}));break}}return h&&d.length?d:null},T=e=>{switch(e.type){case`radar`:return e.series.length;case`gauge`:return 0;case`sankey`:return m.resolveSankey(e).names.length;case`calendarHeatmap`:return o.calendarModel(e)?.count??0;case`chord`:return c.resolveChord(e).names.length;default:return e.data.length}},E=(e,t)=>{if(!t)return null;let n=e.items.find(e=>e.index===t.index);if(!n)return null;if(n.indicators){let e=a.clamp(t.indicator??0,0,n.indicators.length-1),r=n.indicators[e];return{index:n.index,indicator:e,name:n.name,value:r.value,percent:r.percent,color:n.color}}return{index:n.index,name:n.name,value:n.value,percent:n.percent,color:n.color,...n.path?{path:n.path}:{},...n.event}},D=(e,t)=>e===t||!!e&&!!t&&e.index===t.index&&e.indicator===t.indicator,O=(e,t)=>{let n=e.items.find(e=>e.index===t.index);if(!n)return null;let r=n.indicators?n.rows.map((e,n)=>n===(t.indicator??-1)?{...e,strong:!0}:e):n.rows;return{title:n.path?n.path.join(` / `):n.name,color:n.color,rows:r}},k=(e,t)=>{let n=e.items.find(e=>e.index===t.index);if(!n)return``;if(n.indicators){let e=a.clamp(t.indicator??0,0,n.indicators.length-1);return`${n.name}, ${n.indicators[e].name}: ${n.rows[e]?.value??n.indicators[e].value}`}return`${n.path?n.path.join(` / `):n.name}: ${n.rows[0]?.value??n.value} (${n.share??i.localePercent(e.locale)(n.percent)})`},A=e=>{let t=i.shapeLabels(e);switch(e.type){case`pie`:return e.rose?t.roseChart:(e.innerRadius??0)>0?t.donutChart:t.pieChart;case`radar`:return t.radarChart;case`gauge`:return e.label?i.interpolate(t.gaugeChartNamed,{label:e.label}):t.gaugeChart;case`funnel`:return t.funnelChart;case`sankey`:return t.sankeyChart;case`sunburst`:return t.sunburstChart;case`radialBar`:return t.radialBarChart;case`calendarHeatmap`:return t.calendarHeatmap;case`bullet`:return t.bulletChart;case`chord`:return t.chordChart;default:return t.treemapChart}},j=e=>e.empty?(e.labels??i.SHAPE_LABELS.en).noData:e.items.slice(0,12).map(t=>t.indicators?`${t.name}: ${t.indicators.map((e,n)=>`${e.name} ${t.rows[n]?.value??e.value}`).join(`, `)}`:k(e,{index:t.index})).join(`; `),M=20,N=(e,t,n,i,a,o)=>{let s=r.font(a,12),c=[[]],l=0;for(let n of e){let e=Math.min(t-8,16+o(n.name,s)),r=c[c.length-1];r.length&&l+14+e>t-8&&(c.push(r=[]),l=0),r.length&&(l+=14),r.push({...n,x:l,y:0,width:e,height:M}),l+=e}let u=c.length*M+8,d=n===`top`?2:i-u+6,f=[];return c.forEach((e,n)=>{let r=e[e.length-1],i=(t-(r?r.x+r.width:0))/2;for(let t of e)f.push({...t,x:t.x+i,y:d+n*M})}),{boxes:f,height:u}},P=6,F=14,I=6,L=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),R=(e,t,n,r,i,a)=>{let o=[],s=[],c=i=>{for(let a of[n,r])o.push(e+a*Math.cos(i)),s.push(t+a*Math.sin(i))};c(i),c(a);let l=Math.ceil(i/(Math.PI/2));for(let e=l;Math.PI/2*e<=a;e++)c(Math.PI/2*e);let u=Math.min(...o),d=Math.min(...s);return{x:u,y:d,width:Math.max(...o)-u,height:Math.max(...s)-d}},z=(t,n)=>{let r=null,i=t=>{r=e.unionRect(r,t)};for(let e of t.nodes)if(e.hit===n)switch(e.kind){case`rect`:i(e);break;case`sector`:i(R(e.cx,e.cy,e.r0,e.r1,e.a0,e.a1));break;case`arc`:i(R(e.cx,e.cy,e.r-e.width/2,e.r+e.width/2,e.a0,e.a1));break;case`polygon`:{let t=e.points,n=1/0,r=1/0,a=-1/0,o=-1/0;for(let e=0;e+1<t.length;e+=2)n=Math.min(n,t[e]),a=Math.max(a,t[e]),r=Math.min(r,t[e+1]),o=Math.max(o,t[e+1]);a>=n&&i({x:n,y:r,width:a-n,height:o-r});break}case`circle`:i({x:e.cx-e.r,y:e.cy-e.r,width:e.r*2,height:e.r*2});break;case`link`:{let t=e.width/2,n=Math.min(e.y0,e.y1)-t;i({x:Math.min(e.x0,e.x1),y:n,width:Math.abs(e.x1-e.x0),height:Math.abs(e.y1-e.y0)+e.width});break}}return r},B=e=>{let t=Number(/(\d+(?:\.\d+)?)px/.exec(e.font)?.[1]??12),n=a.estimateText(e.text,e.font);return{x:e.align===`center`?e.x-n/2:e.align===`right`?e.x-n:e.x,y:e.baseline===`top`?e.y:e.baseline===`middle`?e.y-t/2:e.y-t,width:n,height:t}},V=(t,n,r,i,a,o,s,c=null)=>{let l=P,{x:u,y:d}=r,f=I,p=()=>e.placeTooltip({anchor:r,size:{width:i,height:a},stage:{width:o,height:s},margin:l,avoid:{x:u-f,y:d-f,width:12,height:12},bounds:c,gap:10});if(!t||!n||i+12>o||a+12>s)return p();let m=(e,t)=>({x:Math.max(l,Math.min(e,o-i-l)),y:Math.max(l,Math.min(t,s-a-l))}),h=[[u,d]],g=t.items.find(e=>e.index===n.index),_=g?.indicators&&n.indicator!==void 0?g.indicators[n.indicator]:void 0;_&&h.push([_.x,_.y]);let v=z(t,n.index),y=[...t.radar?.labels??[]];for(let e of t.nodes)e.kind===`text`&&!e.rotate&&e.indicator===void 0&&y.push(B(e));let b=t.radar,x=0,S=0;if(b){x=u-b.cx,S=d-b.cy;let e=Math.hypot(x,S);e>1?(x/=e,S/=e):(x=1,S=0)}let C=F,w=[[u+C,d-a/2],[u-C-i,d-a/2],[u-i/2,d-C-a],[u-i/2,d+C],[u+C,d-C-a],[u+C,d+C],[u-C-i,d-C-a],[u-C-i,d+C]];v&&w.push([v.x+v.width+10,d-a/2],[v.x-10-i,d-a/2],[u-i/2,v.y-10-a],[u-i/2,v.y+v.height+10]),w.push([l,d-a/2],[o-i-l,d-a/2],[u-i/2,l],[u-i/2,s-a-l]);let T=i*a,E=null,D=1/0;for(let[e,t]of w){let n=m(e,t),r={x:n.x,y:n.y,width:i,height:a},o=0;for(let[e,t]of h)e>r.x-8&&e<r.x+i+8&&t>r.y-8&&t<r.y+a+8&&(o+=1e6);v&&(o+=L(r,v)/T*400);for(let e of y)o+=L(r,e)*4;let s=n.x+i/2-u,c=n.y+a/2-d,l=Math.hypot(s,c)||1;o+=l*.35,b&&(o-=(s*x+c*S)/l*40),o+=Math.abs(n.x-e)+Math.abs(n.y-t),o<D&&(D=o,E=n)}return!E||D>=1e6?p():{...E,fit:`stage`}},H=(e,t,n,i,o,s,c,l=null,u=null)=>{let d=0,f,p,m,h;if(typeof e==`string`){m=e.split(`
2
+ `);let t=r.font(s,12);for(let e of m)d=Math.max(d,c(e,t));f=m.length}else{p=e;let t=r.font(s,12,600),n=e.color?14:0,o=Math.max(60,Math.min(260,i-16-18)-n);h=a.wrapText(e.title,o,t,c,3),h.length||(h=[e.title]);for(let e of h)d=Math.max(d,n+c(e,t));for(let t of e.rows)d=Math.max(d,(t.color?14:0)+c(t.name,r.font(s,12))+16+c(t.value,r.font(s,12,600)));f=h.length+e.rows.length}let g=Math.max(96,Math.ceil(d+18+4)),_=f*18+18,{x:v,y}=V(l,u,{x:t,y:n},g,_,i,o);return{x:v,y,width:g,height:_,padding:9,lineHeight:18,...p?{content:p,titleLines:h}:{},...m?{text:m}:{}}};exports.blendValues=x,exports.describeChart=A,exports.describeItem=k,exports.describeScene=j,exports.hoverEvent=E,exports.layoutShapeLegend=N,exports.layoutShapeScene=y,exports.layoutShapeTooltip=H,exports.legendConfig=C,exports.placeShapeTooltip=V,exports.sameHover=D,exports.sameValues=S,exports.shapeLegend=w,exports.shapeValues=b,exports.toggleCount=T,exports.tooltipContent=O;
3
3
  //# sourceMappingURL=layout.cjs.map