@visactor/vchart-extension 2.1.0-alpha.2 → 2.1.0-alpha.20

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 (223) hide show
  1. package/build/index.js +2393 -0
  2. package/build/index.min.js +2 -2
  3. package/cjs/charts/axis-3d/index.js +1 -2
  4. package/cjs/charts/axis-3d/linear-axis.js +2 -1
  5. package/cjs/charts/bar-3d/chart-spec-transformer.js +1 -1
  6. package/cjs/charts/bar-3d/chart.js +1 -1
  7. package/cjs/charts/bar-3d/constant.js +1 -1
  8. package/cjs/charts/bar-3d/index.js +1 -1
  9. package/cjs/charts/bar-3d/interface.js +1 -1
  10. package/cjs/charts/bar-3d/series-spec-transformer.js +1 -1
  11. package/cjs/charts/bar-3d/series.js +1 -1
  12. package/cjs/charts/bar-3d/theme.js +1 -1
  13. package/cjs/charts/candlestick/candlestick-transformer.js +1 -1
  14. package/cjs/charts/candlestick/candlestick.js +2 -1
  15. package/cjs/charts/candlestick/index.js +1 -1
  16. package/cjs/charts/candlestick/interface.js +1 -1
  17. package/cjs/charts/candlestick/util.js +1 -1
  18. package/cjs/charts/combination-candlestick/combination-candlestick-transformer.js +1 -1
  19. package/cjs/charts/combination-candlestick/combination-candlestick.js +1 -1
  20. package/cjs/charts/combination-candlestick/constant.js +1 -1
  21. package/cjs/charts/combination-candlestick/index.js +1 -1
  22. package/cjs/charts/combination-candlestick/interface.js +1 -1
  23. package/cjs/charts/conversion-funnel/arrow-data-transform.js +1 -1
  24. package/cjs/charts/conversion-funnel/constants.js +1 -1
  25. package/cjs/charts/conversion-funnel/conversion-funnel-transformer.js +1 -1
  26. package/cjs/charts/conversion-funnel/conversion-funnel.js +1 -1
  27. package/cjs/charts/conversion-funnel/index.js +1 -1
  28. package/cjs/charts/conversion-funnel/interface.js +1 -1
  29. package/cjs/charts/conversion-funnel/util.js +1 -1
  30. package/cjs/charts/funnel-3d/chart.js +2 -1
  31. package/cjs/charts/funnel-3d/constant.js +1 -1
  32. package/cjs/charts/funnel-3d/index.js +1 -1
  33. package/cjs/charts/funnel-3d/interface.js +1 -1
  34. package/cjs/charts/funnel-3d/series-spec-transformer.js +1 -1
  35. package/cjs/charts/funnel-3d/series.js +1 -1
  36. package/cjs/charts/funnel-3d/theme.js +1 -1
  37. package/cjs/charts/histogram-3d/chart.js +1 -1
  38. package/cjs/charts/storyline/index.d.ts +4 -0
  39. package/cjs/charts/storyline/index.js +22 -0
  40. package/cjs/charts/storyline/index.js.map +1 -0
  41. package/cjs/charts/storyline/interface.d.ts +69 -0
  42. package/cjs/charts/storyline/interface.js +6 -0
  43. package/cjs/charts/storyline/interface.js.map +1 -0
  44. package/cjs/charts/storyline/layout.d.ts +58 -0
  45. package/cjs/charts/storyline/layout.js +214 -0
  46. package/cjs/charts/storyline/layout.js.map +1 -0
  47. package/cjs/charts/storyline/layouts/arc.d.ts +5 -0
  48. package/cjs/charts/storyline/layouts/arc.js +327 -0
  49. package/cjs/charts/storyline/layouts/arc.js.map +1 -0
  50. package/cjs/charts/storyline/layouts/clock.d.ts +5 -0
  51. package/cjs/charts/storyline/layouts/clock.js +248 -0
  52. package/cjs/charts/storyline/layouts/clock.js.map +1 -0
  53. package/cjs/charts/storyline/layouts/common.d.ts +98 -0
  54. package/cjs/charts/storyline/layouts/common.js +293 -0
  55. package/cjs/charts/storyline/layouts/common.js.map +1 -0
  56. package/cjs/charts/storyline/layouts/default.d.ts +4 -0
  57. package/cjs/charts/storyline/layouts/default.js +183 -0
  58. package/cjs/charts/storyline/layouts/default.js.map +1 -0
  59. package/cjs/charts/storyline/layouts/ladder.d.ts +5 -0
  60. package/cjs/charts/storyline/layouts/ladder.js +207 -0
  61. package/cjs/charts/storyline/layouts/ladder.js.map +1 -0
  62. package/cjs/charts/storyline/layouts/landscape.d.ts +4 -0
  63. package/cjs/charts/storyline/layouts/landscape.js +258 -0
  64. package/cjs/charts/storyline/layouts/landscape.js.map +1 -0
  65. package/cjs/charts/storyline/layouts/portrait.d.ts +11 -0
  66. package/cjs/charts/storyline/layouts/portrait.js +270 -0
  67. package/cjs/charts/storyline/layouts/portrait.js.map +1 -0
  68. package/cjs/charts/storyline/layouts/wing.d.ts +4 -0
  69. package/cjs/charts/storyline/layouts/wing.js +272 -0
  70. package/cjs/charts/storyline/layouts/wing.js.map +1 -0
  71. package/cjs/charts/storyline/storyline-transformer.d.ts +4 -0
  72. package/cjs/charts/storyline/storyline-transformer.js +91 -0
  73. package/cjs/charts/storyline/storyline-transformer.js.map +1 -0
  74. package/cjs/charts/storyline/storyline.d.ts +16 -0
  75. package/cjs/charts/storyline/storyline.js +36 -0
  76. package/cjs/charts/storyline/storyline.js.map +1 -0
  77. package/cjs/components/bar-link/bar-link.js +1 -1
  78. package/cjs/components/bar-link/constant.js +1 -1
  79. package/cjs/components/bar-link/index.js +1 -1
  80. package/cjs/components/bar-link/type.js +1 -1
  81. package/cjs/components/bar-link/util.js +1 -1
  82. package/cjs/components/bar-regression-line/index.js +1 -1
  83. package/cjs/components/bar-regression-line/type.js +1 -1
  84. package/cjs/components/extension-mark-sync-state/extension-mark-sync-state.js +1 -1
  85. package/cjs/components/extension-mark-sync-state/index.js +1 -1
  86. package/cjs/components/extension-mark-sync-state/type.js +1 -1
  87. package/cjs/components/histogram-regression-line/index.js +1 -1
  88. package/cjs/components/histogram-regression-line/type.js +1 -2
  89. package/cjs/components/map-label/index.js +1 -1
  90. package/cjs/components/map-label/layout.js +1 -1
  91. package/cjs/components/map-label/map-label-transformer.js +1 -1
  92. package/cjs/components/map-label/map-label.js +1 -1
  93. package/cjs/components/map-label/theme.js +1 -1
  94. package/cjs/components/map-label/type.js +1 -1
  95. package/cjs/components/regression-line/index.js +1 -1
  96. package/cjs/components/regression-line/regression-line.js +1 -1
  97. package/cjs/components/regression-line/type.js +1 -1
  98. package/cjs/components/scatter-regression-line/index.js +1 -1
  99. package/cjs/components/scatter-regression-line/type.js +1 -1
  100. package/cjs/components/series-break/constant.js +1 -1
  101. package/cjs/components/series-break/index.js +1 -1
  102. package/cjs/components/series-break/series-break.js +1 -1
  103. package/cjs/components/series-break/type.js +1 -1
  104. package/cjs/components/series-break/util.js +1 -2
  105. package/cjs/components/series-label/constant.js +1 -1
  106. package/cjs/components/series-label/index.js +1 -1
  107. package/cjs/components/series-label/series-label.js +1 -1
  108. package/cjs/components/series-label/type.js +1 -1
  109. package/cjs/components/series-label/util.js +1 -1
  110. package/cjs/index.d.ts +1 -0
  111. package/cjs/index.js +5 -5
  112. package/cjs/index.js.map +1 -1
  113. package/esm/charts/axis-3d/index.js +1 -2
  114. package/esm/charts/axis-3d/linear-axis.js +2 -1
  115. package/esm/charts/bar-3d/chart-spec-transformer.js +1 -1
  116. package/esm/charts/bar-3d/chart.js +1 -1
  117. package/esm/charts/bar-3d/constant.js +1 -1
  118. package/esm/charts/bar-3d/index.js +1 -1
  119. package/esm/charts/bar-3d/interface.js +1 -1
  120. package/esm/charts/bar-3d/series-spec-transformer.js +1 -1
  121. package/esm/charts/bar-3d/series.js +1 -1
  122. package/esm/charts/bar-3d/theme.js +1 -1
  123. package/esm/charts/candlestick/candlestick-transformer.js +1 -1
  124. package/esm/charts/candlestick/candlestick.js +2 -1
  125. package/esm/charts/candlestick/index.js +1 -1
  126. package/esm/charts/candlestick/interface.js +1 -1
  127. package/esm/charts/candlestick/util.js +1 -1
  128. package/esm/charts/combination-candlestick/combination-candlestick-transformer.js +1 -1
  129. package/esm/charts/combination-candlestick/combination-candlestick.js +1 -1
  130. package/esm/charts/combination-candlestick/constant.js +1 -1
  131. package/esm/charts/combination-candlestick/index.js +1 -1
  132. package/esm/charts/combination-candlestick/interface.js +1 -1
  133. package/esm/charts/conversion-funnel/arrow-data-transform.js +1 -1
  134. package/esm/charts/conversion-funnel/constants.js +1 -1
  135. package/esm/charts/conversion-funnel/conversion-funnel-transformer.js +1 -1
  136. package/esm/charts/conversion-funnel/conversion-funnel.js +1 -1
  137. package/esm/charts/conversion-funnel/index.js +1 -1
  138. package/esm/charts/conversion-funnel/interface.js +1 -1
  139. package/esm/charts/conversion-funnel/util.js +1 -1
  140. package/esm/charts/funnel-3d/chart.js +2 -1
  141. package/esm/charts/funnel-3d/constant.js +1 -1
  142. package/esm/charts/funnel-3d/index.js +1 -1
  143. package/esm/charts/funnel-3d/interface.js +1 -1
  144. package/esm/charts/funnel-3d/series-spec-transformer.js +1 -1
  145. package/esm/charts/funnel-3d/series.js +1 -1
  146. package/esm/charts/funnel-3d/theme.js +1 -1
  147. package/esm/charts/histogram-3d/chart.js +1 -1
  148. package/esm/charts/storyline/index.d.ts +4 -0
  149. package/esm/charts/storyline/index.js +8 -0
  150. package/esm/charts/storyline/index.js.map +1 -0
  151. package/esm/charts/storyline/interface.d.ts +69 -0
  152. package/esm/charts/storyline/interface.js +2 -0
  153. package/esm/charts/storyline/interface.js.map +1 -0
  154. package/esm/charts/storyline/layout.d.ts +58 -0
  155. package/esm/charts/storyline/layout.js +204 -0
  156. package/esm/charts/storyline/layout.js.map +1 -0
  157. package/esm/charts/storyline/layouts/arc.d.ts +5 -0
  158. package/esm/charts/storyline/layouts/arc.js +320 -0
  159. package/esm/charts/storyline/layouts/arc.js.map +1 -0
  160. package/esm/charts/storyline/layouts/clock.d.ts +5 -0
  161. package/esm/charts/storyline/layouts/clock.js +242 -0
  162. package/esm/charts/storyline/layouts/clock.js.map +1 -0
  163. package/esm/charts/storyline/layouts/common.d.ts +98 -0
  164. package/esm/charts/storyline/layouts/common.js +258 -0
  165. package/esm/charts/storyline/layouts/common.js.map +1 -0
  166. package/esm/charts/storyline/layouts/default.d.ts +4 -0
  167. package/esm/charts/storyline/layouts/default.js +176 -0
  168. package/esm/charts/storyline/layouts/default.js.map +1 -0
  169. package/esm/charts/storyline/layouts/ladder.d.ts +5 -0
  170. package/esm/charts/storyline/layouts/ladder.js +198 -0
  171. package/esm/charts/storyline/layouts/ladder.js.map +1 -0
  172. package/esm/charts/storyline/layouts/landscape.d.ts +4 -0
  173. package/esm/charts/storyline/layouts/landscape.js +254 -0
  174. package/esm/charts/storyline/layouts/landscape.js.map +1 -0
  175. package/esm/charts/storyline/layouts/portrait.d.ts +11 -0
  176. package/esm/charts/storyline/layouts/portrait.js +274 -0
  177. package/esm/charts/storyline/layouts/portrait.js.map +1 -0
  178. package/esm/charts/storyline/layouts/wing.d.ts +4 -0
  179. package/esm/charts/storyline/layouts/wing.js +268 -0
  180. package/esm/charts/storyline/layouts/wing.js.map +1 -0
  181. package/esm/charts/storyline/storyline-transformer.d.ts +4 -0
  182. package/esm/charts/storyline/storyline-transformer.js +88 -0
  183. package/esm/charts/storyline/storyline-transformer.js.map +1 -0
  184. package/esm/charts/storyline/storyline.d.ts +16 -0
  185. package/esm/charts/storyline/storyline.js +29 -0
  186. package/esm/charts/storyline/storyline.js.map +1 -0
  187. package/esm/components/bar-link/bar-link.js +1 -1
  188. package/esm/components/bar-link/constant.js +1 -1
  189. package/esm/components/bar-link/index.js +1 -1
  190. package/esm/components/bar-link/type.js +1 -1
  191. package/esm/components/bar-link/util.js +1 -1
  192. package/esm/components/bar-regression-line/index.js +1 -1
  193. package/esm/components/bar-regression-line/type.js +1 -1
  194. package/esm/components/extension-mark-sync-state/extension-mark-sync-state.js +1 -1
  195. package/esm/components/extension-mark-sync-state/index.js +1 -1
  196. package/esm/components/extension-mark-sync-state/type.js +1 -1
  197. package/esm/components/histogram-regression-line/index.js +1 -1
  198. package/esm/components/histogram-regression-line/type.js +1 -2
  199. package/esm/components/map-label/index.js +1 -1
  200. package/esm/components/map-label/layout.js +1 -1
  201. package/esm/components/map-label/map-label-transformer.js +1 -1
  202. package/esm/components/map-label/map-label.js +1 -1
  203. package/esm/components/map-label/theme.js +1 -1
  204. package/esm/components/map-label/type.js +1 -1
  205. package/esm/components/regression-line/index.js +1 -1
  206. package/esm/components/regression-line/regression-line.js +1 -1
  207. package/esm/components/regression-line/type.js +1 -1
  208. package/esm/components/scatter-regression-line/index.js +1 -1
  209. package/esm/components/scatter-regression-line/type.js +1 -1
  210. package/esm/components/series-break/constant.js +1 -1
  211. package/esm/components/series-break/index.js +1 -1
  212. package/esm/components/series-break/series-break.js +1 -1
  213. package/esm/components/series-break/type.js +1 -1
  214. package/esm/components/series-break/util.js +1 -2
  215. package/esm/components/series-label/constant.js +1 -1
  216. package/esm/components/series-label/index.js +1 -1
  217. package/esm/components/series-label/series-label.js +1 -1
  218. package/esm/components/series-label/type.js +1 -1
  219. package/esm/components/series-label/util.js +1 -1
  220. package/esm/index.d.ts +1 -0
  221. package/esm/index.js +2 -0
  222. package/esm/index.js.map +1 -1
  223. package/package.json +8 -8
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.computeStorylineLayout = exports.normalizeLayout = exports.normalizePadding = void 0;
6
+
7
+ const DEFAULT_LAYOUT = "landscape", DEFAULT_PADDING = 24, normalizePadding = padding => {
8
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
9
+ if (Array.isArray(padding)) return {
10
+ top: null !== (_a = padding[0]) && void 0 !== _a ? _a : 0,
11
+ right: null !== (_b = padding[1]) && void 0 !== _b ? _b : 0,
12
+ bottom: null !== (_c = padding[2]) && void 0 !== _c ? _c : 0,
13
+ left: null !== (_d = padding[3]) && void 0 !== _d ? _d : 0
14
+ };
15
+ if (padding && "object" == typeof padding && "top" in padding) return {
16
+ top: null !== (_e = padding.top) && void 0 !== _e ? _e : 0,
17
+ right: null !== (_f = padding.right) && void 0 !== _f ? _f : 0,
18
+ bottom: null !== (_g = padding.bottom) && void 0 !== _g ? _g : 0,
19
+ left: null !== (_h = padding.left) && void 0 !== _h ? _h : 0
20
+ };
21
+ const value = null !== (_j = padding) && void 0 !== _j ? _j : 24;
22
+ return {
23
+ top: value,
24
+ right: value,
25
+ bottom: value,
26
+ left: value
27
+ };
28
+ };
29
+
30
+ exports.normalizePadding = normalizePadding;
31
+
32
+ const normalizeLayout = layout => layout ? "string" == typeof layout ? {
33
+ type: layout
34
+ } : layout : {
35
+ type: "landscape"
36
+ };
37
+
38
+ exports.normalizeLayout = normalizeLayout;
39
+
40
+ const computeStorylineLayout = (data, options) => {
41
+ var _a, _b, _c;
42
+ const layout = (0, exports.normalizeLayout)(options.layout), padding = (0, exports.normalizePadding)(null !== (_a = layout.padding) && void 0 !== _a ? _a : options.padding), gap = null !== (_b = options.gap) && void 0 !== _b ? _b : 40, lineDistance = null !== (_c = options.lineDistance) && void 0 !== _c ? _c : 8, blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap), circleGuide = "clock" === layout.type ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : void 0;
43
+ return {
44
+ blocks: blocks,
45
+ links: computeLinks(blocks, lineDistance),
46
+ circleGuide: circleGuide
47
+ };
48
+ };
49
+
50
+ exports.computeStorylineLayout = computeStorylineLayout;
51
+
52
+ const computeBlockPositions = (data, layout, viewBox, block, padding, gap) => {
53
+ const count = data.length;
54
+ if (!count) return [];
55
+ const inner = {
56
+ x: padding.left,
57
+ y: padding.top,
58
+ width: Math.max(viewBox.width - padding.left - padding.right, block.width),
59
+ height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)
60
+ }, center = {
61
+ x: inner.x + inner.width / 2,
62
+ y: inner.y + inner.height / 2
63
+ };
64
+ let centers;
65
+ switch (layout.type) {
66
+ case "portrait":
67
+ centers = lineCenters(count, center.x, inner.y + block.height / 2, center.x, inner.y + inner.height - block.height / 2);
68
+ break;
69
+
70
+ case "ladder":
71
+ {
72
+ const isDown = "down" === layout.direction, x0 = inner.x + block.width / 2, x1 = inner.x + inner.width - block.width / 2, yTop = inner.y + block.height / 2, yBot = inner.y + inner.height - block.height / 2, y0 = isDown ? yTop : yBot, y1 = isDown ? yBot : yTop, anchors = lineCenters(count, x0, y0, x1, y1), dx = x1 - x0, dy = y1 - y0, len = Math.hypot(dx, dy) || 1, nx = -dy / len, ny = dx / len, offset = 1.2 * Math.max(80, Math.min(240, Math.round(.42 * inner.height)));
73
+ centers = anchors.map(((p, i) => {
74
+ const sign = i % 2 == 0 ? 1 : -1;
75
+ return {
76
+ x: p.x + nx * offset * sign,
77
+ y: p.y + ny * offset * sign
78
+ };
79
+ }));
80
+ break;
81
+ }
82
+
83
+ case "spiral":
84
+ centers = alternatingVerticalCenters(count, inner, block, gap);
85
+ break;
86
+
87
+ case "clock":
88
+ centers = circularCenters(count, viewBox, block, padding, layout);
89
+ break;
90
+
91
+ case "arc":
92
+ {
93
+ const isDown = "down" === layout.direction, [s, e] = isDown ? [ 20, 160 ] : [ 200, 340 ];
94
+ centers = arcCenters(count, inner, block, layout, s, e);
95
+ break;
96
+ }
97
+
98
+ case "wing":
99
+ {
100
+ const direction = "right" === layout.direction ? "right" : "left", [s, e] = "right" === direction ? [ 110, 250 ] : [ -70, 70 ];
101
+ centers = arcCenters(count, inner, block, layout, s, e);
102
+ break;
103
+ }
104
+
105
+ default:
106
+ centers = lineCenters(count, inner.x + block.width / 2, center.y, inner.x + inner.width - block.width / 2, center.y);
107
+ }
108
+ return centers.map(((point, index) => {
109
+ var _a, _b;
110
+ return {
111
+ id: null !== (_b = null === (_a = data[index]) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : index,
112
+ index: index,
113
+ datum: data[index],
114
+ width: block.width,
115
+ height: block.height,
116
+ x: point.x - block.width / 2,
117
+ y: point.y - block.height / 2,
118
+ center: point
119
+ };
120
+ }));
121
+ }, lineCenters = (count, x0, y0, x1, y1) => 1 === count ? [ {
122
+ x: (x0 + x1) / 2,
123
+ y: (y0 + y1) / 2
124
+ } ] : Array.from({
125
+ length: count
126
+ }, ((_, index) => {
127
+ const t = index / (count - 1);
128
+ return {
129
+ x: x0 + (x1 - x0) * t,
130
+ y: y0 + (y1 - y0) * t
131
+ };
132
+ })), alternatingVerticalCenters = (count, inner, block, gap) => {
133
+ const baseX = inner.x + inner.width / 2, offset = Math.min(Math.max(.65 * block.width + gap / 2, 0), Math.max((inner.width - block.width) / 2, 0));
134
+ return lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2).map(((point, index) => ({
135
+ x: point.x + (index % 2 == 0 ? -offset : offset),
136
+ y: point.y
137
+ })));
138
+ }, circularCenters = (count, viewBox, block, padding, layout) => {
139
+ var _a;
140
+ const guide = computeClockCircleGuide(viewBox, block, padding, layout), startAngle = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : -90;
141
+ if (1 === count) {
142
+ const angle = degreeToRadian(startAngle);
143
+ return [ {
144
+ x: guide.center.x + Math.cos(angle) * guide.radius,
145
+ y: guide.center.y + Math.sin(angle) * guide.radius
146
+ } ];
147
+ }
148
+ return Array.from({
149
+ length: count
150
+ }, ((_, index) => {
151
+ const angle = degreeToRadian(startAngle + 360 * index / count);
152
+ return {
153
+ x: guide.center.x + Math.cos(angle) * guide.radius,
154
+ y: guide.center.y + Math.sin(angle) * guide.radius
155
+ };
156
+ }));
157
+ }, computeClockCircleGuide = (viewBox, block, padding, layout) => {
158
+ var _a;
159
+ const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1), innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1), center = {
160
+ x: padding.left + innerWidth / 2,
161
+ y: padding.top + innerHeight / 2
162
+ }, ratio = null !== (_a = layout.radiusRatio) && void 0 !== _a ? _a : .7, maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
163
+ return {
164
+ center: center,
165
+ radius: Math.max(1, maxRadius * ratio)
166
+ };
167
+ }, arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = .88) => {
168
+ var _a, _b, _c, _d, _e;
169
+ const startAngle = null !== (_b = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : fallbackStartAngle) && void 0 !== _b ? _b : -90, endAngle = null !== (_d = null !== (_c = layout.endAngle) && void 0 !== _c ? _c : fallbackEndAngle) && void 0 !== _d ? _d : 270, ratio = null !== (_e = layout.radiusRatio) && void 0 !== _e ? _e : defaultRatio, rx = Math.max((inner.width - block.width) / 2, 1) * ratio, ry = Math.max((inner.height - block.height) / 2, 1) * ratio, center_x = inner.x + inner.width / 2, center_y = inner.y + inner.height / 2;
170
+ if (1 === count) {
171
+ const angle = degreeToRadian((startAngle + endAngle) / 2);
172
+ return [ {
173
+ x: center_x + Math.cos(angle) * rx,
174
+ y: center_y + Math.sin(angle) * ry
175
+ } ];
176
+ }
177
+ return Array.from({
178
+ length: count
179
+ }, ((_, index) => {
180
+ const t = index / (count - 1), angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
181
+ return {
182
+ x: center_x + Math.cos(angle) * rx,
183
+ y: center_y + Math.sin(angle) * ry
184
+ };
185
+ }));
186
+ }, angleDelta = (startAngle, endAngle) => {
187
+ const delta = endAngle - startAngle;
188
+ return Math.abs(delta) >= 360 ? 360 : delta;
189
+ }, degreeToRadian = degree => degree / 180 * Math.PI, computeLinks = (blocks, distance) => {
190
+ const links = [];
191
+ for (let i = 0; i < blocks.length - 1; i++) {
192
+ const from = blocks[i], to = blocks[i + 1], start = pointOnBlockEdge(from, to.center, distance), end = pointOnBlockEdge(to, from.center, distance);
193
+ links.push({
194
+ from: from,
195
+ to: to,
196
+ start: start,
197
+ end: end,
198
+ points: [ start, end ]
199
+ });
200
+ }
201
+ return links;
202
+ }, pointOnBlockEdge = (block, toward, distance) => {
203
+ const dx = toward.x - block.center.x, dy = toward.y - block.center.y;
204
+ if (0 === dx && 0 === dy) return {
205
+ x: block.center.x,
206
+ y: block.center.y
207
+ };
208
+ const scaleX = 0 === dx ? Number.POSITIVE_INFINITY : block.width / 2 / Math.abs(dx), scaleY = 0 === dy ? Number.POSITIVE_INFINITY : block.height / 2 / Math.abs(dy), scale = Math.min(scaleX, scaleY), length = Math.sqrt(dx * dx + dy * dy) || 1;
209
+ return {
210
+ x: block.center.x + dx * scale + dx / length * distance,
211
+ y: block.center.y + dy * scale + dy / length * distance
212
+ };
213
+ };
214
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"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C,MAAM,CAAC,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;QACxB,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;KACjD;IACD,MAAM,MAAM,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpF,MAAM,MAAM,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ;QACzD,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ;KAC1D,CAAC;AACJ,CAAC,CAAC","file":"layout.js","sourcesContent":["import type { IStorylineBlock, IStorylineLayoutOptions, StorylineLayoutType } from './interface';\n\nexport interface StorylineSize {\n width: number;\n height: number;\n}\n\nexport interface StorylinePadding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface StorylinePoint {\n x: number;\n y: number;\n}\n\nexport interface StorylineBlockPosition extends StorylinePoint, StorylineSize {\n id: string | number;\n index: number;\n datum: IStorylineBlock;\n center: StorylinePoint;\n}\n\nexport interface StorylineLinkPosition {\n from: StorylineBlockPosition;\n to: StorylineBlockPosition;\n start: StorylinePoint;\n end: StorylinePoint;\n points: StorylinePoint[];\n}\n\nexport interface StorylineCircleGuide {\n center: StorylinePoint;\n radius: number;\n}\n\nexport interface StorylineLayoutResult {\n blocks: StorylineBlockPosition[];\n links: StorylineLinkPosition[];\n circleGuide?: StorylineCircleGuide;\n}\n\nexport interface StorylineComputeOptions {\n layout: StorylineLayoutType | IStorylineLayoutOptions | undefined;\n viewBox: StorylineSize;\n block: StorylineSize;\n gap?: number;\n padding?: number | [number, number, number, number];\n lineDistance?: number;\n}\n\nconst DEFAULT_LAYOUT: StorylineLayoutType = 'landscape';\nconst DEFAULT_PADDING = 24;\n\nexport const normalizePadding = (\n padding?: number | [number, number, number, number] | { top?: number; right?: number; bottom?: number; left?: number }\n): StorylinePadding => {\n if (Array.isArray(padding)) {\n return {\n top: padding[0] ?? 0,\n right: padding[1] ?? 0,\n bottom: padding[2] ?? 0,\n left: padding[3] ?? 0\n };\n }\n if (padding && typeof padding === 'object' && 'top' in padding) {\n return {\n top: (padding as { top?: number }).top ?? 0,\n right: (padding as { right?: number }).right ?? 0,\n bottom: (padding as { bottom?: number }).bottom ?? 0,\n left: (padding as { left?: number }).left ?? 0\n };\n }\n const value = (padding as number | undefined) ?? DEFAULT_PADDING;\n return { top: value, right: value, bottom: value, left: value };\n};\n\nexport const normalizeLayout = (layout?: StorylineLayoutType | IStorylineLayoutOptions): IStorylineLayoutOptions => {\n if (!layout) {\n return { type: DEFAULT_LAYOUT };\n }\n if (typeof layout === 'string') {\n return { type: layout };\n }\n return layout;\n};\n\nexport const computeStorylineLayout = (\n data: IStorylineBlock[],\n options: StorylineComputeOptions\n): StorylineLayoutResult => {\n const layout = normalizeLayout(options.layout);\n const padding = normalizePadding(layout.padding ?? options.padding);\n const gap = options.gap ?? 40;\n const lineDistance = options.lineDistance ?? 8;\n const blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap);\n const circleGuide =\n layout.type === 'clock' ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : undefined;\n return {\n blocks,\n links: computeLinks(blocks, lineDistance),\n circleGuide\n };\n};\n\nconst computeBlockPositions = (\n data: IStorylineBlock[],\n layout: IStorylineLayoutOptions,\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n gap: number\n): StorylineBlockPosition[] => {\n const count = data.length;\n if (!count) {\n return [];\n }\n\n const inner = {\n x: padding.left,\n y: padding.top,\n width: Math.max(viewBox.width - padding.left - padding.right, block.width),\n height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)\n };\n const center = {\n x: inner.x + inner.width / 2,\n y: inner.y + inner.height / 2\n };\n\n let centers: StorylinePoint[];\n switch (layout.type) {\n case 'portrait':\n centers = lineCenters(\n count,\n center.x,\n inner.y + block.height / 2,\n center.x,\n inner.y + inner.height - block.height / 2\n );\n break;\n case 'ladder': {\n // 沿对角线均匀采样 anchor 点,偶/奇 index 沿对角线\"法向\"做左/右偏移。\n // direction = 'up' (默认):左下 → 右上;direction = 'down':左上 → 右下。\n const isDown = layout.direction === 'down';\n const x0 = inner.x + block.width / 2;\n const x1 = inner.x + inner.width - block.width / 2;\n const yTop = inner.y + block.height / 2;\n const yBot = inner.y + inner.height - block.height / 2;\n const y0 = isDown ? yTop : yBot;\n const y1 = isDown ? yBot : yTop;\n const anchors = lineCenters(count, x0, y0, x1, y1);\n // 对角线方向向量\n const dx = x1 - x0;\n const dy = y1 - y0;\n const len = Math.hypot(dx, dy) || 1;\n // 法向单位向量\n const nx = -dy / len;\n const ny = dx / len;\n // 偏移量:与 headline fontSize 联动 —— 与 ladder.ts 中保持同一公式\n // headline fontSize = clamp(innerHeight * 0.42, 80, 240)\n // 偏移量 = headline fontSize * 1.2,让 block 与 headline 大字之间留出充足留白\n const headlineFontSize = Math.max(80, Math.min(240, Math.round(inner.height * 0.42)));\n const offset = headlineFontSize * 1.2;\n centers = anchors.map((p, i) => {\n // 偶数 index → 法向 +;奇数 index → 法向 -\n const sign = i % 2 === 0 ? 1 : -1;\n return {\n x: p.x + nx * offset * sign,\n y: p.y + ny * offset * sign\n };\n });\n break;\n }\n case 'spiral':\n centers = alternatingVerticalCenters(count, inner, block, gap);\n break;\n case 'clock':\n centers = circularCenters(count, viewBox, block, padding, layout);\n break;\n case 'arc': {\n // arc 布局:通过 direction 控制 dome(穹顶)/ bowl(碗形)方向\n // - 'up'(默认):弧线在上方(穹顶),等同原 dome\n // - 'down':弧线在下方(碗形),等同原 bowl\n const isDown = layout.direction === 'down';\n const [s, e] = isDown ? [20, 160] : [200, 340];\n centers = arcCenters(count, inner, block, layout, s, e);\n break;\n }\n case 'wing': {\n const direction = layout.direction === 'right' ? 'right' : 'left';\n const [s, e] = direction === 'right' ? [110, 250] : [-70, 70];\n centers = arcCenters(count, inner, block, layout, s, e);\n break;\n }\n case 'landscape':\n default:\n centers = lineCenters(\n count,\n inner.x + block.width / 2,\n center.y,\n inner.x + inner.width - block.width / 2,\n center.y\n );\n break;\n }\n\n return centers.map((point, index) => ({\n id: data[index]?.id ?? index,\n index,\n datum: data[index],\n width: block.width,\n height: block.height,\n x: point.x - block.width / 2,\n y: point.y - block.height / 2,\n center: point\n }));\n};\n\nconst lineCenters = (count: number, x0: number, y0: number, x1: number, y1: number): StorylinePoint[] => {\n if (count === 1) {\n return [{ x: (x0 + x1) / 2, y: (y0 + y1) / 2 }];\n }\n return Array.from({ length: count }, (_, index) => {\n const t = index / (count - 1);\n return {\n x: x0 + (x1 - x0) * t,\n y: y0 + (y1 - y0) * t\n };\n });\n};\n\nconst alternatingVerticalCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n gap: number\n) => {\n const baseX = inner.x + inner.width / 2;\n const offset = Math.min(Math.max(block.width * 0.65 + gap / 2, 0), Math.max((inner.width - block.width) / 2, 0));\n const points = lineCenters(\n count,\n baseX,\n inner.y + block.height / 2,\n baseX,\n inner.y + inner.height - block.height / 2\n );\n return points.map((point, index) => ({\n x: point.x + (index % 2 === 0 ? -offset : offset),\n y: point.y\n }));\n};\n\nconst circularCenters = (\n count: number,\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n layout: IStorylineLayoutOptions\n) => {\n const guide = computeClockCircleGuide(viewBox, block, padding, layout);\n const startAngle = layout.startAngle ?? -90;\n const delta = 360;\n\n if (count === 1) {\n const angle = degreeToRadian(startAngle);\n return [\n {\n x: guide.center.x + Math.cos(angle) * guide.radius,\n y: guide.center.y + Math.sin(angle) * guide.radius\n }\n ];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const angle = degreeToRadian(startAngle + (delta * index) / count);\n return {\n x: guide.center.x + Math.cos(angle) * guide.radius,\n y: guide.center.y + Math.sin(angle) * guide.radius\n };\n });\n};\n\nconst computeClockCircleGuide = (\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n layout: IStorylineLayoutOptions\n): StorylineCircleGuide => {\n const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1);\n const innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1);\n const center = {\n x: padding.left + innerWidth / 2,\n y: padding.top + innerHeight / 2\n };\n const ratio = layout.radiusRatio ?? 0.7;\n const maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);\n\n return {\n center,\n radius: Math.max(1, maxRadius * ratio)\n };\n};\n\nconst arcCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n layout: IStorylineLayoutOptions,\n fallbackStartAngle?: number,\n fallbackEndAngle?: number,\n defaultRatio = 0.88\n) => {\n const startAngle = layout.startAngle ?? fallbackStartAngle ?? -90;\n const endAngle = layout.endAngle ?? fallbackEndAngle ?? 270;\n const ratio = layout.radiusRatio ?? defaultRatio;\n const rx = Math.max((inner.width - block.width) / 2, 1) * ratio;\n const ry = Math.max((inner.height - block.height) / 2, 1) * ratio;\n const center = {\n x: inner.x + inner.width / 2,\n y: inner.y + inner.height / 2\n };\n\n if (count === 1) {\n const angle = degreeToRadian((startAngle + endAngle) / 2);\n return [{ x: center.x + Math.cos(angle) * rx, y: center.y + Math.sin(angle) * ry }];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const t = index / (count - 1);\n const angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);\n return {\n x: center.x + Math.cos(angle) * rx,\n y: center.y + Math.sin(angle) * ry\n };\n });\n};\n\nconst angleDelta = (startAngle: number, endAngle: number) => {\n const delta = endAngle - startAngle;\n return Math.abs(delta) >= 360 ? 360 : delta;\n};\n\nconst degreeToRadian = (degree: number) => (degree / 180) * Math.PI;\n\nconst computeLinks = (blocks: StorylineBlockPosition[], distance: number): StorylineLinkPosition[] => {\n const links: StorylineLinkPosition[] = [];\n for (let i = 0; i < blocks.length - 1; i++) {\n const from = blocks[i];\n const to = blocks[i + 1];\n const start = pointOnBlockEdge(from, to.center, distance);\n const end = pointOnBlockEdge(to, from.center, distance);\n links.push({\n from,\n to,\n start,\n end,\n points: [start, end]\n });\n }\n return links;\n};\n\nconst pointOnBlockEdge = (block: StorylineBlockPosition, toward: StorylinePoint, distance: number): StorylinePoint => {\n const dx = toward.x - block.center.x;\n const dy = toward.y - block.center.y;\n if (dx === 0 && dy === 0) {\n return { x: block.center.x, y: block.center.y };\n }\n const scaleX = dx === 0 ? Number.POSITIVE_INFINITY : block.width / 2 / Math.abs(dx);\n const scaleY = dy === 0 ? Number.POSITIVE_INFINITY : block.height / 2 / Math.abs(dy);\n const scale = Math.min(scaleX, scaleY);\n const length = Math.sqrt(dx * dx + dy * dy) || 1;\n return {\n x: block.center.x + dx * scale + (dx / length) * distance,\n y: block.center.y + dy * scale + (dy / length) * distance\n };\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IExtensionGroupMarkSpec } from '@visactor/vchart';
2
+ import type { IStorylineBlock, IStorylineSpec } from '../interface';
3
+ export declare const buildArcMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
4
+ export declare const buildArcCenterImageMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
5
+ export declare const buildArcBlockMark: (spec: IStorylineSpec, block: IStorylineBlock, index: number) => IExtensionGroupMarkSpec;
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.buildArcBlockMark = exports.buildArcCenterImageMark = exports.buildArcMark = void 0;
6
+
7
+ const vchart_1 = require("@visactor/vchart"), common_1 = require("./common"), ARC_BLOCK_IMAGE_SIZE = 240, ARC_BLOCK_IMAGE_BORDER = 3, ARC_BLOCK_IMAGE_HALO_PADDING = 6, ARC_TEXT_GAP_FROM_IMAGE = 10, ARC_TITLE_FONT_SIZE = 32, ARC_TITLE_LINE_HEIGHT = 34, ARC_CONTENT_LINE_HEIGHT = 26, ARC_CONTENT_FONT_SIZE = 20, ARC_TEXT_BOX_HEIGHT = 240, ARC_TITLE_TO_CONTENT_GAP = 4, ARC_TEXT_PADDING = 20, ARC_TEXT_BOX_MIN_WIDTH = 240, ARC_CENTER_IMAGE_SIZE_RATIO = .55, ARC_CENTER_IMAGE_TO_SYMBOL_RATIO = .8, ARC_GAP_FROM_CENTER_IMAGE = 200, isDownArc = spec => "down" === (0,
8
+ common_1.normalizeLayout)(spec.layout).direction, getArcCenterImageRect = (spec, ctx) => {
9
+ var _a, _b, _c, _e;
10
+ const {width: width, height: height, startX: startX, startY: startY} = (0, common_1.getRegionGeometry)(ctx), innerWidth = Math.max(width, 1), innerHeight = Math.max(height, 1), baseSize = .55 * Math.min(innerWidth, innerHeight), w = Math.max(null !== (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.width) && void 0 !== _b ? _b : baseSize, 80), h = Math.max(null !== (_e = null === (_c = spec.centerImage) || void 0 === _c ? void 0 : _c.height) && void 0 !== _e ? _e : baseSize, 80);
11
+ return {
12
+ x: startX + innerWidth / 2 - w / 2,
13
+ y: isDownArc(spec) ? startY : startY + innerHeight - h,
14
+ width: w,
15
+ height: h
16
+ };
17
+ }, getArcGeometry = (spec, ctx) => {
18
+ var _a, _b, _c;
19
+ const {width: width, startX: startX} = (0, common_1.getRegionGeometry)(ctx), innerWidth = Math.max(width, 1), blockWidth = (0,
20
+ common_1.resolveBlockWidth)(spec, width), layoutOpt = (0, common_1.normalizeLayout)(spec.layout), isDown = "down" === layoutOpt.direction, startAngle = null !== (_a = layoutOpt.startAngle) && void 0 !== _a ? _a : isDown ? 20 : 200, endAngle = null !== (_b = layoutOpt.endAngle) && void 0 !== _b ? _b : isDown ? 160 : 340, ratio = null !== (_c = layoutOpt.radiusRatio) && void 0 !== _c ? _c : .88, rx = Math.max((innerWidth - blockWidth) / 2, 1) * ratio, centerRect = getArcCenterImageRect(spec, ctx), centerTop = centerRect.y, centerBottom = centerRect.y + centerRect.height, sinStart = Math.sin(startAngle / 180 * Math.PI);
21
+ let cy, ry;
22
+ if (isDown) {
23
+ const denom = Math.max(1 - sinStart, .05);
24
+ ry = (centerRect.height + 200) / denom, cy = centerTop - ry * sinStart;
25
+ } else {
26
+ const denom = Math.max(1 + sinStart, .05);
27
+ ry = (centerRect.height + 200) / denom, cy = centerBottom - ry * sinStart;
28
+ }
29
+ return {
30
+ cx: startX + innerWidth / 2,
31
+ cy: cy,
32
+ rx: rx,
33
+ ry: ry,
34
+ startAngle: startAngle,
35
+ endAngle: endAngle,
36
+ centerTop: centerTop,
37
+ centerBottom: centerBottom
38
+ };
39
+ }, getArcBlockCenter = (spec, ctx, index) => {
40
+ var _a, _b, _c, _e;
41
+ const arc = getArcGeometry(spec, ctx), count = null !== (_b = null === (_a = spec.data) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0;
42
+ if (count <= 0) return {
43
+ x: arc.cx,
44
+ y: arc.cy
45
+ };
46
+ const t = 1 === count ? .5 : index / (count - 1), angle = (arc.startAngle + (arc.endAngle - arc.startAngle) * t) / 180 * Math.PI, px = arc.cx + Math.cos(angle) * arc.rx, py = arc.cy + Math.sin(angle) * arc.ry, nxRaw = Math.cos(angle) / arc.rx, nyRaw = Math.sin(angle) / arc.ry, nLen = Math.hypot(nxRaw, nyRaw) || 1, nx = nxRaw / nLen, ny = nyRaw / nLen, offset = (null !== (_e = null === (_c = spec.image) || void 0 === _c ? void 0 : _c.height) && void 0 !== _e ? _e : 240) / 2;
47
+ return {
48
+ x: px + nx * offset,
49
+ y: py + ny * offset
50
+ };
51
+ }, buildArcMark = spec => {
52
+ var _a;
53
+ if (!0 !== (null === (_a = spec.line) || void 0 === _a ? void 0 : _a.visible)) return null;
54
+ const themeColor = (0, common_1.getThemeColor)(spec);
55
+ return {
56
+ type: "group",
57
+ name: "storyline-arc",
58
+ zIndex: vchart_1.LayoutZIndex.Mark,
59
+ children: [ {
60
+ type: "path",
61
+ name: "storyline-arc-path",
62
+ interactive: !1,
63
+ style: {
64
+ stroke: themeColor,
65
+ lineWidth: 2,
66
+ lineCap: "round",
67
+ fill: "transparent",
68
+ fillOpacity: 0,
69
+ path: (_d, ctx) => {
70
+ const arc = getArcGeometry(spec, ctx), span = arc.endAngle - arc.startAngle, segments = [];
71
+ for (let i = 0; i <= 64; i++) {
72
+ const t = i / 64, angle = (arc.startAngle + span * t) / 180 * Math.PI, x = arc.cx + Math.cos(angle) * arc.rx, y = arc.cy + Math.sin(angle) * arc.ry;
73
+ segments.push(`${0 === i ? "M" : "L"} ${x.toFixed(2)} ${y.toFixed(2)}`);
74
+ }
75
+ return segments.join(" ");
76
+ }
77
+ }
78
+ } ]
79
+ };
80
+ };
81
+
82
+ exports.buildArcMark = buildArcMark;
83
+
84
+ const buildArcCenterImageMark = spec => {
85
+ var _a, _b, _c, _e;
86
+ if (!(!1 !== (null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.visible))) return null;
87
+ const themeColor = (0, common_1.getThemeColor)(spec), hasImage = !!(null === (_b = spec.centerImage) || void 0 === _b ? void 0 : _b.image), symbolGradient = {
88
+ gradient: "linear",
89
+ x0: .5,
90
+ y0: 0,
91
+ x1: .5,
92
+ y1: 1,
93
+ stops: [ {
94
+ offset: 0,
95
+ color: (0, common_1.withAlpha)(themeColor, .15)
96
+ }, {
97
+ offset: 1,
98
+ color: themeColor
99
+ } ]
100
+ };
101
+ return {
102
+ type: "group",
103
+ name: "storyline-arc-center",
104
+ zIndex: vchart_1.LayoutZIndex.Mark,
105
+ children: [ {
106
+ type: "symbol",
107
+ name: "storyline-arc-center-symbol",
108
+ interactive: !1,
109
+ style: {
110
+ x: (_d, ctx) => {
111
+ const r = getArcCenterImageRect(spec, ctx);
112
+ return r.x + r.width / 2;
113
+ },
114
+ y: (_d, ctx) => {
115
+ const r = getArcCenterImageRect(spec, ctx);
116
+ return r.y + r.height / 2;
117
+ },
118
+ size: (_d, ctx) => {
119
+ const r = getArcCenterImageRect(spec, ctx);
120
+ return Math.max(r.width, r.height);
121
+ },
122
+ symbolType: "circle",
123
+ fill: hasImage ? symbolGradient : "#ffffff",
124
+ stroke: themeColor,
125
+ lineWidth: 2
126
+ }
127
+ }, hasImage ? Object.assign(Object.assign({
128
+ type: "image",
129
+ name: "storyline-arc-center-image",
130
+ interactive: !1
131
+ }, spec.centerImage), {
132
+ style: Object.assign({
133
+ x: (_d, ctx) => {
134
+ var _a, _b;
135
+ const r = getArcCenterImageRect(spec, ctx), userWidth = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.width, w = "number" == typeof userWidth ? userWidth : .8 * Math.max(r.width, r.height);
136
+ return r.x + (r.width - w) / 2;
137
+ },
138
+ y: (_d, ctx) => {
139
+ var _a, _b;
140
+ const r = getArcCenterImageRect(spec, ctx), userHeight = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.height, h = "number" == typeof userHeight ? userHeight : .8 * Math.max(r.width, r.height);
141
+ return r.y + (r.height - h) / 2;
142
+ },
143
+ width: (_d, ctx) => {
144
+ var _a, _b;
145
+ const r = getArcCenterImageRect(spec, ctx), userWidth = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.width;
146
+ return "number" == typeof userWidth ? userWidth : .8 * Math.max(r.width, r.height);
147
+ },
148
+ height: (_d, ctx) => {
149
+ var _a, _b;
150
+ const r = getArcCenterImageRect(spec, ctx), userHeight = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.height;
151
+ return "number" == typeof userHeight ? userHeight : .8 * Math.max(r.width, r.height);
152
+ },
153
+ cornerRadius: (_d, ctx) => {
154
+ var _a, _b, _c, _e;
155
+ const r = getArcCenterImageRect(spec, ctx), userWidth = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.width, userHeight = null === (_e = null === (_c = spec.centerImage) || void 0 === _c ? void 0 : _c.style) || void 0 === _e ? void 0 : _e.height, w = "number" == typeof userWidth ? userWidth : .8 * Math.max(r.width, r.height), h = "number" == typeof userHeight ? userHeight : .8 * Math.max(r.width, r.height);
156
+ return Math.max(w, h) / 2;
157
+ },
158
+ image: null === (_c = spec.centerImage) || void 0 === _c ? void 0 : _c.image,
159
+ repeatX: "no-repeat",
160
+ repeatY: "no-repeat",
161
+ imageMode: "cover",
162
+ imagePosition: "center",
163
+ anchor: (_d, ctx) => {
164
+ const r = getArcCenterImageRect(spec, ctx);
165
+ return [ r.x + r.width / 2, r.y + r.height / 2 ];
166
+ }
167
+ }, null === (_e = spec.centerImage) || void 0 === _e ? void 0 : _e.style)
168
+ }) : null ].filter(Boolean)
169
+ };
170
+ };
171
+
172
+ exports.buildArcCenterImageMark = buildArcCenterImageMark;
173
+
174
+ const getArcBlockMetrics = (spec, index = 0) => {
175
+ var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
176
+ const titleFontSize = Number(null !== (_c = null === (_b = null === (_a = spec.title) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize) && void 0 !== _c ? _c : 32), titleLineHeight = Number(null !== (_g = null === (_f = null === (_e = spec.title) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.lineHeight) && void 0 !== _g ? _g : Math.max(34, Math.round(1.35 * titleFontSize))), contentFontSize = Number(null !== (_k = null === (_j = null === (_h = spec.content) || void 0 === _h ? void 0 : _h.style) || void 0 === _j ? void 0 : _j.fontSize) && void 0 !== _k ? _k : 20), contentLineHeight = Number(null !== (_o = null === (_m = null === (_l = spec.content) || void 0 === _l ? void 0 : _l.style) || void 0 === _m ? void 0 : _m.lineHeight) && void 0 !== _o ? _o : 26), contentHeight = Math.max(240 - titleLineHeight - 4, contentLineHeight), imageDiameter = Math.max(null !== (_q = null === (_p = spec.image) || void 0 === _p ? void 0 : _p.width) && void 0 !== _q ? _q : 240, null !== (_s = null === (_r = spec.image) || void 0 === _r ? void 0 : _r.height) && void 0 !== _s ? _s : 240), imageWidth = imageDiameter, imageHeight = imageDiameter, isDown = isDownArc(spec), count = Math.max(null !== (_u = null === (_t = spec.data) || void 0 === _t ? void 0 : _t.length) && void 0 !== _u ? _u : 0, 1), canvasWidth = Number(null !== (_v = spec.width) && void 0 !== _v ? _v : imageWidth * count), defaultTextWidth = Math.round(canvasWidth / (count + 1)), textBoxWidth = Math.max(Number(null !== (_x = null === (_w = spec.block) || void 0 === _w ? void 0 : _w.width) && void 0 !== _x ? _x : defaultTextWidth), 240), isLeftSide = index < count / 2, imageBox = {
177
+ x: -imageWidth / 2,
178
+ y: -imageHeight / 2,
179
+ width: imageWidth,
180
+ height: imageHeight
181
+ }, textBox = {
182
+ x: isLeftSide ? -20 : 20,
183
+ y: isDown ? imageBox.y + imageHeight + 10 : imageBox.y - 10 - 240,
184
+ width: textBoxWidth,
185
+ height: 240
186
+ };
187
+ return {
188
+ titleFontSize: titleFontSize,
189
+ titleLineHeight: titleLineHeight,
190
+ contentFontSize: contentFontSize,
191
+ contentLineHeight: contentLineHeight,
192
+ imageBox: imageBox,
193
+ textBox: textBox,
194
+ contentBox: {
195
+ x: textBox.x,
196
+ y: textBox.y + titleLineHeight + 4,
197
+ width: textBox.width,
198
+ height: contentHeight
199
+ },
200
+ isDown: isDown,
201
+ textAlign: isLeftSide ? "right" : "left"
202
+ };
203
+ }, buildArcBlockMark = (spec, block, index) => {
204
+ var _a, _b, _c, _e, _f;
205
+ const hasImage = !!block.image, contentText = Array.isArray(block.content) ? block.content : block.content ? [ block.content ] : [], themeColor = (0,
206
+ common_1.getThemeColor)(spec), metrics = getArcBlockMetrics(spec, index), connectorY = metrics.isDown ? metrics.imageBox.y + metrics.imageBox.height : metrics.textBox.y, connectorHeight = metrics.isDown ? Math.max(metrics.textBox.y + metrics.textBox.height - (metrics.imageBox.y + metrics.imageBox.height), 0) : Math.max(metrics.imageBox.y - metrics.textBox.y, 0);
207
+ return {
208
+ type: "group",
209
+ id: `storyline-block-${null !== (_a = block.id) && void 0 !== _a ? _a : index}`,
210
+ name: `storyline-block-${index}`,
211
+ zIndex: vchart_1.LayoutZIndex.Mark + 1,
212
+ style: {
213
+ x: (_d, ctx) => getArcBlockCenter(spec, ctx, index).x,
214
+ y: (_d, ctx) => getArcBlockCenter(spec, ctx, index).y
215
+ },
216
+ children: [ {
217
+ type: "rect",
218
+ name: `storyline-block-connector-${index}`,
219
+ interactive: !1,
220
+ zIndex: vchart_1.LayoutZIndex.Mark + 2,
221
+ style: {
222
+ x: -1,
223
+ y: connectorY,
224
+ width: 2,
225
+ height: connectorHeight,
226
+ fill: themeColor,
227
+ fillOpacity: .6
228
+ }
229
+ }, hasImage ? Object.assign(Object.assign({
230
+ type: "image",
231
+ name: `storyline-block-image-${index}`,
232
+ interactive: !1,
233
+ zIndex: vchart_1.LayoutZIndex.Mark + 3
234
+ }, (0, common_1.omitImageLayoutSpec)(spec.image)), {
235
+ style: Object.assign({
236
+ x: metrics.imageBox.x,
237
+ y: metrics.imageBox.y,
238
+ width: metrics.imageBox.width,
239
+ height: metrics.imageBox.height,
240
+ cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2,
241
+ image: block.image,
242
+ repeatX: "no-repeat",
243
+ repeatY: "no-repeat",
244
+ imageMode: "cover",
245
+ imagePosition: "center"
246
+ }, null === (_b = spec.image) || void 0 === _b ? void 0 : _b.style)
247
+ }) : {
248
+ type: "symbol",
249
+ name: `storyline-block-image-bg-${index}`,
250
+ interactive: !1,
251
+ zIndex: vchart_1.LayoutZIndex.Mark + 3,
252
+ style: {
253
+ x: 0,
254
+ y: 0,
255
+ size: Math.min(metrics.imageBox.width, metrics.imageBox.height),
256
+ symbolType: "circle",
257
+ fill: "#ffffff",
258
+ stroke: themeColor,
259
+ lineWidth: 2
260
+ }
261
+ }, !0 === (null === (_c = spec.image) || void 0 === _c ? void 0 : _c.showBackground) ? {
262
+ type: "symbol",
263
+ name: `storyline-block-image-halo-${index}`,
264
+ interactive: !1,
265
+ zIndex: vchart_1.LayoutZIndex.Mark + 3,
266
+ style: {
267
+ x: 0,
268
+ y: 0,
269
+ size: Math.min(metrics.imageBox.width, metrics.imageBox.height) + 12,
270
+ symbolType: "circle",
271
+ fill: "transparent",
272
+ stroke: themeColor,
273
+ lineWidth: 3
274
+ }
275
+ } : null, block.title ? Object.assign(Object.assign({
276
+ type: "text",
277
+ name: `storyline-block-title-${index}`,
278
+ interactive: !1,
279
+ zIndex: vchart_1.LayoutZIndex.Mark + 5
280
+ }, spec.title), {
281
+ style: Object.assign({
282
+ x: metrics.textBox.x,
283
+ y: metrics.textBox.y,
284
+ text: block.title,
285
+ maxLineWidth: metrics.textBox.width,
286
+ fontSize: metrics.titleFontSize,
287
+ lineHeight: metrics.titleLineHeight,
288
+ fontWeight: "bold",
289
+ fill: "#1f2430",
290
+ stroke: "#fff",
291
+ lineWidth: 5,
292
+ lineJoin: "round",
293
+ textAlign: metrics.textAlign,
294
+ textBaseline: "top"
295
+ }, null === (_e = spec.title) || void 0 === _e ? void 0 : _e.style)
296
+ }) : null, contentText.length ? Object.assign(Object.assign({
297
+ type: "text",
298
+ name: `storyline-block-content-${index}`,
299
+ interactive: !1,
300
+ zIndex: vchart_1.LayoutZIndex.Mark + 4
301
+ }, spec.content), {
302
+ textType: "rich",
303
+ style: Object.assign({
304
+ x: metrics.contentBox.x,
305
+ y: metrics.contentBox.y,
306
+ width: metrics.contentBox.width,
307
+ height: metrics.contentBox.height,
308
+ maxLineWidth: metrics.contentBox.width,
309
+ heightLimit: metrics.contentBox.height,
310
+ text: (0, common_1.buildRichContent)(contentText, spec, {
311
+ fontSize: metrics.contentFontSize,
312
+ lineHeight: metrics.contentLineHeight,
313
+ fill: "#596173",
314
+ align: metrics.textAlign
315
+ }),
316
+ textAlign: metrics.textAlign,
317
+ textBaseline: "top",
318
+ wordBreak: "break-word",
319
+ ellipsis: "...",
320
+ fill: "#596173"
321
+ }, null === (_f = spec.content) || void 0 === _f ? void 0 : _f.style)
322
+ }) : null ].filter(Boolean)
323
+ };
324
+ };
325
+
326
+ exports.buildArcBlockMark = buildArcBlockMark;
327
+ //# sourceMappingURL=arc.js.map