@visactor/vchart-extension 2.1.0-alpha.16 → 2.1.0-alpha.18

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 (227) hide show
  1. package/build/index.js +0 -2216
  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/histogram-3d/chart.js +2 -1
  31. package/cjs/charts/histogram-3d/index.js +1 -1
  32. package/cjs/charts/histogram-3d/interface.js +1 -1
  33. package/cjs/charts/image-cloud/image-cloud-transformer.js +1 -1
  34. package/cjs/charts/image-cloud/image-cloud.js +1 -1
  35. package/cjs/charts/image-cloud/index.js +1 -1
  36. package/cjs/charts/image-cloud/interface.js +1 -1
  37. package/cjs/charts/image-cloud/series/image-cloud.d.ts +1 -1
  38. package/cjs/charts/pictogram/element-highlight-by-graphic-name.js +1 -1
  39. package/cjs/components/bar-link/bar-link.js +1 -1
  40. package/cjs/components/bar-link/constant.js +1 -1
  41. package/cjs/components/bar-link/index.js +1 -1
  42. package/cjs/components/bar-link/type.js +1 -1
  43. package/cjs/components/bar-link/util.js +1 -1
  44. package/cjs/components/bar-regression-line/index.js +1 -1
  45. package/cjs/components/bar-regression-line/type.js +1 -1
  46. package/cjs/components/extension-mark-sync-state/extension-mark-sync-state.js +1 -1
  47. package/cjs/components/extension-mark-sync-state/index.js +1 -1
  48. package/cjs/components/extension-mark-sync-state/type.js +1 -1
  49. package/cjs/components/histogram-regression-line/index.js +1 -1
  50. package/cjs/components/histogram-regression-line/type.js +1 -1
  51. package/cjs/components/map-label/index.js +1 -1
  52. package/cjs/components/map-label/layout.js +1 -1
  53. package/cjs/components/map-label/map-label-transformer.js +1 -2
  54. package/cjs/components/map-label/map-label.d.ts +1 -1
  55. package/cjs/components/map-label/map-label.js +1 -1
  56. package/cjs/components/map-label/theme.js +1 -1
  57. package/cjs/components/map-label/type.js +1 -1
  58. package/cjs/components/regression-line/index.js +1 -1
  59. package/cjs/components/regression-line/regression-line.js +1 -1
  60. package/cjs/components/regression-line/type.js +1 -1
  61. package/cjs/components/scatter-regression-line/index.js +1 -1
  62. package/cjs/components/scatter-regression-line/type.js +1 -1
  63. package/cjs/components/series-break/constant.js +1 -1
  64. package/cjs/components/series-break/index.js +1 -1
  65. package/cjs/components/series-break/series-break.js +1 -1
  66. package/cjs/components/series-break/type.js +1 -1
  67. package/cjs/components/series-break/util.js +1 -2
  68. package/cjs/components/series-label/constant.js +1 -1
  69. package/cjs/components/series-label/index.js +1 -1
  70. package/cjs/components/series-label/series-label.js +1 -1
  71. package/cjs/components/series-label/type.js +1 -1
  72. package/cjs/components/series-label/util.js +1 -1
  73. package/cjs/index.d.ts +0 -1
  74. package/cjs/index.js +5 -5
  75. package/cjs/index.js.map +1 -1
  76. package/esm/charts/axis-3d/index.js +1 -2
  77. package/esm/charts/axis-3d/linear-axis.js +2 -1
  78. package/esm/charts/bar-3d/chart-spec-transformer.js +1 -1
  79. package/esm/charts/bar-3d/chart.js +1 -1
  80. package/esm/charts/bar-3d/constant.js +1 -1
  81. package/esm/charts/bar-3d/index.js +1 -1
  82. package/esm/charts/bar-3d/interface.js +1 -1
  83. package/esm/charts/bar-3d/series-spec-transformer.js +1 -1
  84. package/esm/charts/bar-3d/series.js +1 -1
  85. package/esm/charts/bar-3d/theme.js +1 -1
  86. package/esm/charts/candlestick/candlestick-transformer.js +1 -1
  87. package/esm/charts/candlestick/candlestick.js +2 -1
  88. package/esm/charts/candlestick/index.js +1 -1
  89. package/esm/charts/candlestick/interface.js +1 -1
  90. package/esm/charts/candlestick/util.js +1 -1
  91. package/esm/charts/combination-candlestick/combination-candlestick-transformer.js +1 -1
  92. package/esm/charts/combination-candlestick/combination-candlestick.js +1 -1
  93. package/esm/charts/combination-candlestick/constant.js +1 -1
  94. package/esm/charts/combination-candlestick/index.js +1 -1
  95. package/esm/charts/combination-candlestick/interface.js +1 -1
  96. package/esm/charts/conversion-funnel/arrow-data-transform.js +1 -1
  97. package/esm/charts/conversion-funnel/constants.js +1 -1
  98. package/esm/charts/conversion-funnel/conversion-funnel-transformer.js +1 -1
  99. package/esm/charts/conversion-funnel/conversion-funnel.js +1 -1
  100. package/esm/charts/conversion-funnel/index.js +1 -1
  101. package/esm/charts/conversion-funnel/interface.js +1 -1
  102. package/esm/charts/conversion-funnel/util.js +1 -1
  103. package/esm/charts/histogram-3d/chart.js +2 -1
  104. package/esm/charts/histogram-3d/index.js +1 -1
  105. package/esm/charts/histogram-3d/interface.js +1 -1
  106. package/esm/charts/image-cloud/image-cloud-transformer.js +1 -1
  107. package/esm/charts/image-cloud/image-cloud.js +1 -1
  108. package/esm/charts/image-cloud/index.js +1 -1
  109. package/esm/charts/image-cloud/interface.js +1 -1
  110. package/esm/charts/image-cloud/series/image-cloud.d.ts +1 -1
  111. package/esm/charts/pictogram/element-highlight-by-graphic-name.js +1 -1
  112. package/esm/components/bar-link/bar-link.js +1 -1
  113. package/esm/components/bar-link/constant.js +1 -1
  114. package/esm/components/bar-link/index.js +1 -1
  115. package/esm/components/bar-link/type.js +1 -1
  116. package/esm/components/bar-link/util.js +1 -1
  117. package/esm/components/bar-regression-line/index.js +1 -1
  118. package/esm/components/bar-regression-line/type.js +1 -1
  119. package/esm/components/extension-mark-sync-state/extension-mark-sync-state.js +1 -1
  120. package/esm/components/extension-mark-sync-state/index.js +1 -1
  121. package/esm/components/extension-mark-sync-state/type.js +1 -1
  122. package/esm/components/histogram-regression-line/index.js +1 -1
  123. package/esm/components/histogram-regression-line/type.js +1 -1
  124. package/esm/components/map-label/index.js +1 -1
  125. package/esm/components/map-label/layout.js +1 -1
  126. package/esm/components/map-label/map-label-transformer.js +1 -2
  127. package/esm/components/map-label/map-label.d.ts +1 -1
  128. package/esm/components/map-label/map-label.js +1 -1
  129. package/esm/components/map-label/theme.js +1 -1
  130. package/esm/components/map-label/type.js +1 -1
  131. package/esm/components/regression-line/index.js +1 -1
  132. package/esm/components/regression-line/regression-line.js +1 -1
  133. package/esm/components/regression-line/type.js +1 -1
  134. package/esm/components/scatter-regression-line/index.js +1 -1
  135. package/esm/components/scatter-regression-line/type.js +1 -1
  136. package/esm/components/series-break/constant.js +1 -1
  137. package/esm/components/series-break/index.js +1 -1
  138. package/esm/components/series-break/series-break.js +1 -1
  139. package/esm/components/series-break/type.js +1 -1
  140. package/esm/components/series-break/util.js +1 -2
  141. package/esm/components/series-label/constant.js +1 -1
  142. package/esm/components/series-label/index.js +1 -1
  143. package/esm/components/series-label/series-label.js +1 -1
  144. package/esm/components/series-label/type.js +1 -1
  145. package/esm/components/series-label/util.js +1 -1
  146. package/esm/index.d.ts +0 -1
  147. package/esm/index.js +0 -2
  148. package/esm/index.js.map +1 -1
  149. package/package.json +7 -7
  150. package/cjs/charts/storyline/index.d.ts +0 -4
  151. package/cjs/charts/storyline/index.js +0 -22
  152. package/cjs/charts/storyline/index.js.map +0 -1
  153. package/cjs/charts/storyline/interface.d.ts +0 -61
  154. package/cjs/charts/storyline/interface.js +0 -6
  155. package/cjs/charts/storyline/interface.js.map +0 -1
  156. package/cjs/charts/storyline/layout.d.ts +0 -53
  157. package/cjs/charts/storyline/layout.js +0 -214
  158. package/cjs/charts/storyline/layout.js.map +0 -1
  159. package/cjs/charts/storyline/layouts/bowl.d.ts +0 -5
  160. package/cjs/charts/storyline/layouts/bowl.js +0 -285
  161. package/cjs/charts/storyline/layouts/bowl.js.map +0 -1
  162. package/cjs/charts/storyline/layouts/clock.d.ts +0 -5
  163. package/cjs/charts/storyline/layouts/clock.js +0 -247
  164. package/cjs/charts/storyline/layouts/clock.js.map +0 -1
  165. package/cjs/charts/storyline/layouts/common.d.ts +0 -88
  166. package/cjs/charts/storyline/layouts/common.js +0 -291
  167. package/cjs/charts/storyline/layouts/common.js.map +0 -1
  168. package/cjs/charts/storyline/layouts/default.d.ts +0 -4
  169. package/cjs/charts/storyline/layouts/default.js +0 -179
  170. package/cjs/charts/storyline/layouts/default.js.map +0 -1
  171. package/cjs/charts/storyline/layouts/dome.d.ts +0 -5
  172. package/cjs/charts/storyline/layouts/dome.js +0 -300
  173. package/cjs/charts/storyline/layouts/dome.js.map +0 -1
  174. package/cjs/charts/storyline/layouts/landscape.d.ts +0 -4
  175. package/cjs/charts/storyline/layouts/landscape.js +0 -254
  176. package/cjs/charts/storyline/layouts/landscape.js.map +0 -1
  177. package/cjs/charts/storyline/layouts/portrait.d.ts +0 -4
  178. package/cjs/charts/storyline/layouts/portrait.js +0 -241
  179. package/cjs/charts/storyline/layouts/portrait.js.map +0 -1
  180. package/cjs/charts/storyline/layouts/wing.d.ts +0 -4
  181. package/cjs/charts/storyline/layouts/wing.js +0 -215
  182. package/cjs/charts/storyline/layouts/wing.js.map +0 -1
  183. package/cjs/charts/storyline/storyline-transformer.d.ts +0 -4
  184. package/cjs/charts/storyline/storyline-transformer.js +0 -66
  185. package/cjs/charts/storyline/storyline-transformer.js.map +0 -1
  186. package/cjs/charts/storyline/storyline.d.ts +0 -16
  187. package/cjs/charts/storyline/storyline.js +0 -36
  188. package/cjs/charts/storyline/storyline.js.map +0 -1
  189. package/esm/charts/storyline/index.d.ts +0 -4
  190. package/esm/charts/storyline/index.js +0 -8
  191. package/esm/charts/storyline/index.js.map +0 -1
  192. package/esm/charts/storyline/interface.d.ts +0 -61
  193. package/esm/charts/storyline/interface.js +0 -2
  194. package/esm/charts/storyline/interface.js.map +0 -1
  195. package/esm/charts/storyline/layout.d.ts +0 -53
  196. package/esm/charts/storyline/layout.js +0 -204
  197. package/esm/charts/storyline/layout.js.map +0 -1
  198. package/esm/charts/storyline/layouts/bowl.d.ts +0 -5
  199. package/esm/charts/storyline/layouts/bowl.js +0 -277
  200. package/esm/charts/storyline/layouts/bowl.js.map +0 -1
  201. package/esm/charts/storyline/layouts/clock.d.ts +0 -5
  202. package/esm/charts/storyline/layouts/clock.js +0 -241
  203. package/esm/charts/storyline/layouts/clock.js.map +0 -1
  204. package/esm/charts/storyline/layouts/common.d.ts +0 -88
  205. package/esm/charts/storyline/layouts/common.js +0 -257
  206. package/esm/charts/storyline/layouts/common.js.map +0 -1
  207. package/esm/charts/storyline/layouts/default.d.ts +0 -4
  208. package/esm/charts/storyline/layouts/default.js +0 -172
  209. package/esm/charts/storyline/layouts/default.js.map +0 -1
  210. package/esm/charts/storyline/layouts/dome.d.ts +0 -5
  211. package/esm/charts/storyline/layouts/dome.js +0 -292
  212. package/esm/charts/storyline/layouts/dome.js.map +0 -1
  213. package/esm/charts/storyline/layouts/landscape.d.ts +0 -4
  214. package/esm/charts/storyline/layouts/landscape.js +0 -250
  215. package/esm/charts/storyline/layouts/landscape.js.map +0 -1
  216. package/esm/charts/storyline/layouts/portrait.d.ts +0 -4
  217. package/esm/charts/storyline/layouts/portrait.js +0 -238
  218. package/esm/charts/storyline/layouts/portrait.js.map +0 -1
  219. package/esm/charts/storyline/layouts/wing.d.ts +0 -4
  220. package/esm/charts/storyline/layouts/wing.js +0 -210
  221. package/esm/charts/storyline/layouts/wing.js.map +0 -1
  222. package/esm/charts/storyline/storyline-transformer.d.ts +0 -4
  223. package/esm/charts/storyline/storyline-transformer.js +0 -66
  224. package/esm/charts/storyline/storyline-transformer.js.map +0 -1
  225. package/esm/charts/storyline/storyline.d.ts +0 -16
  226. package/esm/charts/storyline/storyline.js +0 -29
  227. package/esm/charts/storyline/storyline.js.map +0 -1
package/build/index.js CHANGED
@@ -5822,2216 +5822,6 @@
5822
5822
  vchart.Factory.registerChart(TimelineChart.type, TimelineChart);
5823
5823
  };
5824
5824
 
5825
- const DEFAULT_LAYOUT = 'landscape';
5826
- const DEFAULT_PADDING = 24;
5827
- const normalizePadding = (padding) => {
5828
- var _a, _b, _c, _d;
5829
- if (Array.isArray(padding)) {
5830
- return {
5831
- top: (_a = padding[0]) !== null && _a !== void 0 ? _a : 0,
5832
- right: (_b = padding[1]) !== null && _b !== void 0 ? _b : 0,
5833
- bottom: (_c = padding[2]) !== null && _c !== void 0 ? _c : 0,
5834
- left: (_d = padding[3]) !== null && _d !== void 0 ? _d : 0
5835
- };
5836
- }
5837
- const value = padding !== null && padding !== void 0 ? padding : DEFAULT_PADDING;
5838
- return { top: value, right: value, bottom: value, left: value };
5839
- };
5840
- const normalizeLayout = (layout) => {
5841
- if (!layout) {
5842
- return { type: DEFAULT_LAYOUT };
5843
- }
5844
- if (typeof layout === 'string') {
5845
- return { type: layout };
5846
- }
5847
- return layout;
5848
- };
5849
- const computeStorylineLayout = (data, options) => {
5850
- var _a, _b, _c;
5851
- const layout = normalizeLayout(options.layout);
5852
- const padding = normalizePadding((_a = layout.padding) !== null && _a !== void 0 ? _a : options.padding);
5853
- const gap = (_b = options.gap) !== null && _b !== void 0 ? _b : 40;
5854
- const lineDistance = (_c = options.lineDistance) !== null && _c !== void 0 ? _c : 8;
5855
- const blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap);
5856
- const circleGuide = layout.type === 'clock' ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : undefined;
5857
- return {
5858
- blocks,
5859
- links: computeLinks(blocks, lineDistance),
5860
- circleGuide
5861
- };
5862
- };
5863
- const computeBlockPositions = (data, layout, viewBox, block, padding, gap) => {
5864
- const count = data.length;
5865
- if (!count) {
5866
- return [];
5867
- }
5868
- const inner = {
5869
- x: padding.left,
5870
- y: padding.top,
5871
- width: Math.max(viewBox.width - padding.left - padding.right, block.width),
5872
- height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)
5873
- };
5874
- const center = {
5875
- x: inner.x + inner.width / 2,
5876
- y: inner.y + inner.height / 2
5877
- };
5878
- let centers;
5879
- switch (layout.type) {
5880
- case 'portrait':
5881
- centers = lineCenters(count, center.x, inner.y + block.height / 2, center.x, inner.y + inner.height - block.height / 2);
5882
- break;
5883
- case 'up-ladder':
5884
- centers = lineCenters(count, inner.x + block.width / 2, inner.y + inner.height - block.height / 2, inner.x + inner.width - block.width / 2, inner.y + block.height / 2);
5885
- break;
5886
- case 'down-ladder':
5887
- centers = lineCenters(count, inner.x + block.width / 2, inner.y + block.height / 2, inner.x + inner.width - block.width / 2, inner.y + inner.height - block.height / 2);
5888
- break;
5889
- case 'pulse':
5890
- centers = alternatingHorizontalCenters(count, inner, block, gap);
5891
- break;
5892
- case 'spiral':
5893
- centers = alternatingVerticalCenters(count, inner, block, gap);
5894
- break;
5895
- case 'clock':
5896
- centers = circularCenters(count, viewBox, block, padding, layout);
5897
- break;
5898
- case 'bowl':
5899
- centers = arcCenters(count, inner, block, layout, 200, 340);
5900
- break;
5901
- case 'dome':
5902
- centers = arcCenters(count, inner, block, layout, 160, 20);
5903
- break;
5904
- case 'wing': {
5905
- const direction = layout.direction === 'right' ? 'right' : 'left';
5906
- const [s, e] = direction === 'right' ? [110, 250] : [-70, 70];
5907
- centers = arcCenters(count, inner, block, layout, s, e);
5908
- break;
5909
- }
5910
- case 'landscape':
5911
- default:
5912
- centers = lineCenters(count, inner.x + block.width / 2, center.y, inner.x + inner.width - block.width / 2, center.y);
5913
- break;
5914
- }
5915
- return centers.map((point, index) => {
5916
- var _a, _b;
5917
- return ({
5918
- id: (_b = (_a = data[index]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : index,
5919
- index,
5920
- datum: data[index],
5921
- width: block.width,
5922
- height: block.height,
5923
- x: point.x - block.width / 2,
5924
- y: point.y - block.height / 2,
5925
- center: point
5926
- });
5927
- });
5928
- };
5929
- const lineCenters = (count, x0, y0, x1, y1) => {
5930
- if (count === 1) {
5931
- return [{ x: (x0 + x1) / 2, y: (y0 + y1) / 2 }];
5932
- }
5933
- return Array.from({ length: count }, (_, index) => {
5934
- const t = index / (count - 1);
5935
- return {
5936
- x: x0 + (x1 - x0) * t,
5937
- y: y0 + (y1 - y0) * t
5938
- };
5939
- });
5940
- };
5941
- const alternatingHorizontalCenters = (count, inner, block, gap) => {
5942
- const baseY = inner.y + inner.height / 2;
5943
- const offset = Math.min(Math.max(block.height * 0.65 + gap / 2, 0), Math.max((inner.height - block.height) / 2, 0));
5944
- const points = lineCenters(count, inner.x + block.width / 2, baseY, inner.x + inner.width - block.width / 2, baseY);
5945
- return points.map((point, index) => ({
5946
- x: point.x,
5947
- y: point.y + (index % 2 === 0 ? -offset : offset)
5948
- }));
5949
- };
5950
- const alternatingVerticalCenters = (count, inner, block, gap) => {
5951
- const baseX = inner.x + inner.width / 2;
5952
- const offset = Math.min(Math.max(block.width * 0.65 + gap / 2, 0), Math.max((inner.width - block.width) / 2, 0));
5953
- const points = lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2);
5954
- return points.map((point, index) => ({
5955
- x: point.x + (index % 2 === 0 ? -offset : offset),
5956
- y: point.y
5957
- }));
5958
- };
5959
- const circularCenters = (count, viewBox, block, padding, layout) => {
5960
- var _a;
5961
- const guide = computeClockCircleGuide(viewBox, block, padding, layout);
5962
- const startAngle = (_a = layout.startAngle) !== null && _a !== void 0 ? _a : -90;
5963
- const delta = 360;
5964
- if (count === 1) {
5965
- const angle = degreeToRadian(startAngle);
5966
- return [
5967
- {
5968
- x: guide.center.x + Math.cos(angle) * guide.radius,
5969
- y: guide.center.y + Math.sin(angle) * guide.radius
5970
- }
5971
- ];
5972
- }
5973
- return Array.from({ length: count }, (_, index) => {
5974
- const angle = degreeToRadian(startAngle + (delta * index) / count);
5975
- return {
5976
- x: guide.center.x + Math.cos(angle) * guide.radius,
5977
- y: guide.center.y + Math.sin(angle) * guide.radius
5978
- };
5979
- });
5980
- };
5981
- const computeClockCircleGuide = (viewBox, block, padding, layout) => {
5982
- var _a;
5983
- const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1);
5984
- const innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1);
5985
- const center = {
5986
- x: padding.left + innerWidth / 2,
5987
- y: padding.top + innerHeight / 2
5988
- };
5989
- const ratio = (_a = layout.radiusRatio) !== null && _a !== void 0 ? _a : 0.7;
5990
- const maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
5991
- return {
5992
- center,
5993
- radius: Math.max(1, maxRadius * ratio)
5994
- };
5995
- };
5996
- const arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = 0.88) => {
5997
- var _a, _b, _c, _d, _e;
5998
- const startAngle = (_b = (_a = layout.startAngle) !== null && _a !== void 0 ? _a : fallbackStartAngle) !== null && _b !== void 0 ? _b : -90;
5999
- const endAngle = (_d = (_c = layout.endAngle) !== null && _c !== void 0 ? _c : fallbackEndAngle) !== null && _d !== void 0 ? _d : 270;
6000
- const ratio = (_e = layout.radiusRatio) !== null && _e !== void 0 ? _e : defaultRatio;
6001
- const rx = Math.max((inner.width - block.width) / 2, 1) * ratio;
6002
- const ry = Math.max((inner.height - block.height) / 2, 1) * ratio;
6003
- const center = {
6004
- x: inner.x + inner.width / 2,
6005
- y: inner.y + inner.height / 2
6006
- };
6007
- if (count === 1) {
6008
- const angle = degreeToRadian((startAngle + endAngle) / 2);
6009
- return [{ x: center.x + Math.cos(angle) * rx, y: center.y + Math.sin(angle) * ry }];
6010
- }
6011
- return Array.from({ length: count }, (_, index) => {
6012
- const t = index / (count - 1);
6013
- const angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
6014
- return {
6015
- x: center.x + Math.cos(angle) * rx,
6016
- y: center.y + Math.sin(angle) * ry
6017
- };
6018
- });
6019
- };
6020
- const angleDelta = (startAngle, endAngle) => {
6021
- const delta = endAngle - startAngle;
6022
- return Math.abs(delta) >= 360 ? 360 : delta;
6023
- };
6024
- const degreeToRadian = (degree) => (degree / 180) * Math.PI;
6025
- const computeLinks = (blocks, distance) => {
6026
- const links = [];
6027
- for (let i = 0; i < blocks.length - 1; i++) {
6028
- const from = blocks[i];
6029
- const to = blocks[i + 1];
6030
- const start = pointOnBlockEdge(from, to.center, distance);
6031
- const end = pointOnBlockEdge(to, from.center, distance);
6032
- links.push({
6033
- from,
6034
- to,
6035
- start,
6036
- end,
6037
- points: [start, end]
6038
- });
6039
- }
6040
- return links;
6041
- };
6042
- const pointOnBlockEdge = (block, toward, distance) => {
6043
- const dx = toward.x - block.center.x;
6044
- const dy = toward.y - block.center.y;
6045
- if (dx === 0 && dy === 0) {
6046
- return { x: block.center.x, y: block.center.y };
6047
- }
6048
- const scaleX = dx === 0 ? Number.POSITIVE_INFINITY : block.width / 2 / Math.abs(dx);
6049
- const scaleY = dy === 0 ? Number.POSITIVE_INFINITY : block.height / 2 / Math.abs(dy);
6050
- const scale = Math.min(scaleX, scaleY);
6051
- const length = Math.sqrt(dx * dx + dy * dy) || 1;
6052
- return {
6053
- x: block.center.x + dx * scale + (dx / length) * distance,
6054
- y: block.center.y + dy * scale + (dy / length) * distance
6055
- };
6056
- };
6057
-
6058
- const DEFAULT_BLOCK_WIDTH = 180;
6059
- const DEFAULT_BLOCK_HEIGHT = 112;
6060
- const DEFAULT_BLOCK_WIDTH_RATIO = 0.24;
6061
- const DEFAULT_BLOCK_GAP = 36;
6062
- const DEFAULT_IMAGE_WIDTH = 48;
6063
- const DEFAULT_IMAGE_HEIGHT = 48;
6064
- const DEFAULT_IMAGE_GAP = 10;
6065
- const DEFAULT_THEME_COLOR = '#e8543d';
6066
- const isLandscape = (spec) => normalizeLayout(spec.layout).type === 'landscape';
6067
- const isPortrait = (spec) => normalizeLayout(spec.layout).type === 'portrait';
6068
- const isClock = (spec) => normalizeLayout(spec.layout).type === 'clock';
6069
- const isDome = (spec) => normalizeLayout(spec.layout).type === 'dome';
6070
- const isBowl = (spec) => normalizeLayout(spec.layout).type === 'bowl';
6071
- const isWing = (spec) => normalizeLayout(spec.layout).type === 'wing';
6072
- const getThemeColor = (spec) => { var _a; return (_a = spec.themeColor) !== null && _a !== void 0 ? _a : DEFAULT_THEME_COLOR; };
6073
- const withAlpha = (color, alpha) => {
6074
- const safeAlpha = Math.max(0, Math.min(1, alpha));
6075
- if (!color) {
6076
- return `rgba(0, 0, 0, ${safeAlpha})`;
6077
- }
6078
- const trimmed = color.trim();
6079
- if (trimmed.startsWith('#')) {
6080
- let hex = trimmed.slice(1);
6081
- if (hex.length === 3 || hex.length === 4) {
6082
- hex = hex
6083
- .split('')
6084
- .map(ch => ch + ch)
6085
- .join('');
6086
- }
6087
- if (hex.length === 6 || hex.length === 8) {
6088
- const r = parseInt(hex.slice(0, 2), 16);
6089
- const g = parseInt(hex.slice(2, 4), 16);
6090
- const b = parseInt(hex.slice(4, 6), 16);
6091
- return `rgba(${r}, ${g}, ${b}, ${safeAlpha})`;
6092
- }
6093
- }
6094
- const rgbMatch = trimmed.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
6095
- if (rgbMatch) {
6096
- return `rgba(${rgbMatch[1]}, ${rgbMatch[2]}, ${rgbMatch[3]}, ${safeAlpha})`;
6097
- }
6098
- return trimmed;
6099
- };
6100
- const resolveBlockWidth = (spec, viewWidth) => {
6101
- var _a, _b, _c, _d, _e, _f, _g;
6102
- if ((_a = spec.block) === null || _a === void 0 ? void 0 : _a.width) {
6103
- return spec.block.width;
6104
- }
6105
- const ratio = (_c = (_b = spec.block) === null || _b === void 0 ? void 0 : _b.widthRatio) !== null && _c !== void 0 ? _c : DEFAULT_BLOCK_WIDTH_RATIO;
6106
- const minWidth = (_e = (_d = spec.block) === null || _d === void 0 ? void 0 : _d.minWidth) !== null && _e !== void 0 ? _e : DEFAULT_BLOCK_WIDTH;
6107
- const maxWidth = (_g = (_f = spec.block) === null || _f === void 0 ? void 0 : _f.maxWidth) !== null && _g !== void 0 ? _g : Math.max(minWidth, 320);
6108
- return Math.max(minWidth, Math.min(maxWidth, Math.round(viewWidth * ratio)));
6109
- };
6110
- const getRegionGeometry = (ctx) => {
6111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
6112
- const region = (_c = (_b = (_a = ctx.chart) === null || _a === void 0 ? void 0 : _a.getAllRegions) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c[0];
6113
- const regionRect = (_d = region === null || region === void 0 ? void 0 : region.getLayoutRect) === null || _d === void 0 ? void 0 : _d.call(region);
6114
- const regionStart = (_e = region === null || region === void 0 ? void 0 : region.getLayoutStartPoint) === null || _e === void 0 ? void 0 : _e.call(region);
6115
- const chartRect = (_g = (_f = ctx.chart) === null || _f === void 0 ? void 0 : _f.getLayoutRect) === null || _g === void 0 ? void 0 : _g.call(_f);
6116
- const bounds = (_h = ctx.getLayoutBounds) === null || _h === void 0 ? void 0 : _h.call(ctx);
6117
- const width = Math.max((_m = (_k = (_j = regionRect === null || regionRect === void 0 ? void 0 : regionRect.width) !== null && _j !== void 0 ? _j : chartRect === null || chartRect === void 0 ? void 0 : chartRect.width) !== null && _k !== void 0 ? _k : (_l = bounds === null || bounds === void 0 ? void 0 : bounds.width) === null || _l === void 0 ? void 0 : _l.call(bounds)) !== null && _m !== void 0 ? _m : 0, 1);
6118
- const height = Math.max((_r = (_p = (_o = regionRect === null || regionRect === void 0 ? void 0 : regionRect.height) !== null && _o !== void 0 ? _o : chartRect === null || chartRect === void 0 ? void 0 : chartRect.height) !== null && _p !== void 0 ? _p : (_q = bounds === null || bounds === void 0 ? void 0 : bounds.height) === null || _q === void 0 ? void 0 : _q.call(bounds)) !== null && _r !== void 0 ? _r : 0, 1);
6119
- return {
6120
- width,
6121
- height,
6122
- startX: (_s = regionStart === null || regionStart === void 0 ? void 0 : regionStart.x) !== null && _s !== void 0 ? _s : 0,
6123
- startY: (_t = regionStart === null || regionStart === void 0 ? void 0 : regionStart.y) !== null && _t !== void 0 ? _t : 0
6124
- };
6125
- };
6126
- const getLayout = (spec, ctx) => {
6127
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
6128
- const { width, height, startX, startY } = getRegionGeometry(ctx);
6129
- let blockWidth = resolveBlockWidth(spec, width);
6130
- let blockHeight = (_b = (_a = spec.block) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : DEFAULT_BLOCK_HEIGHT;
6131
- if (isLandscape(spec) && !((_c = spec.block) === null || _c === void 0 ? void 0 : _c.width)) {
6132
- const count = (_e = (_d = spec.data) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
6133
- if (count > 0) {
6134
- const padding = normalizePadding((_f = spec.block) === null || _f === void 0 ? void 0 : _f.padding);
6135
- const innerWidth = Math.max(width - padding.left - padding.right, 1);
6136
- const LANDSCAPE_IMAGE_GAP = 40;
6137
- const LANDSCAPE_IMAGE_MIN_WIDTH = 80;
6138
- const totalGap = LANDSCAPE_IMAGE_GAP * Math.max(count - 1, 0);
6139
- const adaptive = (innerWidth - totalGap) / count;
6140
- blockWidth = Math.max(LANDSCAPE_IMAGE_MIN_WIDTH, Math.floor(adaptive));
6141
- }
6142
- }
6143
- if (isPortrait(spec) && !((_g = spec.block) === null || _g === void 0 ? void 0 : _g.height)) {
6144
- const count = (_j = (_h = spec.data) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0;
6145
- if (count > 0) {
6146
- const padding = normalizePadding((_k = spec.block) === null || _k === void 0 ? void 0 : _k.padding);
6147
- const innerHeight = Math.max(height - padding.top - padding.bottom, 1);
6148
- blockHeight = Math.max(160, Math.floor(innerHeight / count));
6149
- }
6150
- }
6151
- const result = computeStorylineLayout((_l = spec.data) !== null && _l !== void 0 ? _l : [], {
6152
- layout: spec.layout,
6153
- viewBox: { width, height },
6154
- block: {
6155
- width: blockWidth,
6156
- height: blockHeight
6157
- },
6158
- gap: (_o = (_m = spec.block) === null || _m === void 0 ? void 0 : _m.gap) !== null && _o !== void 0 ? _o : DEFAULT_BLOCK_GAP,
6159
- padding: (_p = spec.block) === null || _p === void 0 ? void 0 : _p.padding,
6160
- lineDistance: (_q = spec.line) === null || _q === void 0 ? void 0 : _q.distance
6161
- });
6162
- if (!startX && !startY) {
6163
- return result;
6164
- }
6165
- return Object.assign(Object.assign({}, result), { blocks: result.blocks.map(block => (Object.assign(Object.assign({}, block), { x: block.x + startX, y: block.y + startY, center: {
6166
- x: block.center.x + startX,
6167
- y: block.center.y + startY
6168
- } }))), links: result.links.map(link => (Object.assign(Object.assign({}, link), { start: { x: link.start.x + startX, y: link.start.y + startY }, end: { x: link.end.x + startX, y: link.end.y + startY }, points: link.points.map(point => ({ x: point.x + startX, y: point.y + startY })) }))) });
6169
- };
6170
- const buildRichContent = (contentText, spec) => {
6171
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6172
- const fontSize = Number((_c = (_b = (_a = spec.content) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 12);
6173
- const lineHeight = Number((_f = (_e = (_d = spec.content) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.lineHeight) !== null && _f !== void 0 ? _f : 18);
6174
- const fill = (_j = (_h = (_g = spec.content) === null || _g === void 0 ? void 0 : _g.style) === null || _h === void 0 ? void 0 : _h.fill) !== null && _j !== void 0 ? _j : '#596173';
6175
- return {
6176
- type: 'rich',
6177
- text: contentText.reduce((result, paragraph, index) => {
6178
- const suffix = index === contentText.length - 1 ? '' : '\n';
6179
- result.push({
6180
- text: `${paragraph}${suffix}`,
6181
- fontSize,
6182
- lineHeight,
6183
- fill
6184
- });
6185
- return result;
6186
- }, [])
6187
- };
6188
- };
6189
- const omitImageLayoutSpec = (imageSpec) => {
6190
- if (!imageSpec) {
6191
- return {};
6192
- }
6193
- const rest = __rest(imageSpec, ["width", "height", "position", "gap"]);
6194
- return rest;
6195
- };
6196
- const getImageBox = (position, blockWidth, blockHeight, padding, width, height, _gap, visible) => {
6197
- if (!visible) {
6198
- return { x: padding.left, y: padding.top, width: 0, height: 0 };
6199
- }
6200
- switch (position) {
6201
- case 'left':
6202
- return { x: padding.left, y: (blockHeight - height) / 2, width, height };
6203
- case 'right':
6204
- return { x: blockWidth - padding.right - width, y: (blockHeight - height) / 2, width, height };
6205
- case 'bottom':
6206
- return { x: (blockWidth - width) / 2, y: blockHeight - padding.bottom - height, width, height };
6207
- case 'top':
6208
- default:
6209
- return { x: (blockWidth - width) / 2, y: padding.top, width, height };
6210
- }
6211
- };
6212
- const getTextBox = (position, blockWidth, blockHeight, padding, imageWidth, imageHeight, imageGap, hasImage) => {
6213
- if (!hasImage) {
6214
- return {
6215
- x: padding.left,
6216
- y: padding.top,
6217
- width: blockWidth - padding.left - padding.right,
6218
- height: blockHeight - padding.top - padding.bottom
6219
- };
6220
- }
6221
- switch (position) {
6222
- case 'left':
6223
- return {
6224
- x: padding.left + imageWidth + imageGap,
6225
- y: padding.top,
6226
- width: blockWidth - padding.left - padding.right - imageWidth - imageGap,
6227
- height: blockHeight - padding.top - padding.bottom
6228
- };
6229
- case 'right':
6230
- return {
6231
- x: padding.left,
6232
- y: padding.top,
6233
- width: blockWidth - padding.left - padding.right - imageWidth - imageGap,
6234
- height: blockHeight - padding.top - padding.bottom
6235
- };
6236
- case 'bottom':
6237
- return {
6238
- x: padding.left,
6239
- y: padding.top,
6240
- width: blockWidth - padding.left - padding.right,
6241
- height: blockHeight - padding.top - padding.bottom - imageHeight - imageGap
6242
- };
6243
- case 'top':
6244
- default:
6245
- return {
6246
- x: padding.left,
6247
- y: padding.top + imageHeight + imageGap,
6248
- width: blockWidth - padding.left - padding.right,
6249
- height: blockHeight - padding.top - padding.bottom - imageHeight - imageGap
6250
- };
6251
- }
6252
- };
6253
- const buildSmoothCurvePath = (points) => {
6254
- var _a, _b;
6255
- if (points.length < 2) {
6256
- return '';
6257
- }
6258
- if (points.length === 2) {
6259
- return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;
6260
- }
6261
- let d = `M ${points[0].x} ${points[0].y}`;
6262
- for (let i = 0; i < points.length - 1; i++) {
6263
- const p0 = (_a = points[i - 1]) !== null && _a !== void 0 ? _a : points[i];
6264
- const p1 = points[i];
6265
- const p2 = points[i + 1];
6266
- const p3 = (_b = points[i + 2]) !== null && _b !== void 0 ? _b : p2;
6267
- const c1x = p1.x + (p2.x - p0.x) / 6;
6268
- const c1y = p1.y + (p2.y - p0.y) / 6;
6269
- const c2x = p2.x - (p3.x - p1.x) / 6;
6270
- const c2y = p2.y - (p3.y - p1.y) / 6;
6271
- d += ` C ${c1x} ${c1y}, ${c2x} ${c2y}, ${p2.x} ${p2.y}`;
6272
- }
6273
- return d;
6274
- };
6275
-
6276
- const CLOCK_CENTER_RADIUS_RATIO = 0.5;
6277
- const CLOCK_CENTER_IMAGE_INSET_RATIO = 0.86;
6278
- const CLOCK_ORBIT_RATIO = 0.58;
6279
- const CLOCK_DOT_RATIO = 0.58;
6280
- const CLOCK_TEXT_INNER_RATIO = 0.7;
6281
- const CLOCK_TEXT_MAX_WIDTH = 200;
6282
- const CLOCK_DOT_DIAMETER_RATIO = 0.24;
6283
- const CLOCK_LEAD_LINE_GAP = 6;
6284
- const CLOCK_TEXT_GAP_FROM_LEAD = 8;
6285
- const CLOCK_ORBIT_DASH = [4, 4];
6286
- const CLOCK_TITLE_FONT_SIZE = 13;
6287
- const CLOCK_TITLE_LINE_HEIGHT = 18;
6288
- const CLOCK_CONTENT_FONT_SIZE = 11;
6289
- const CLOCK_CONTENT_LINE_HEIGHT = 15;
6290
- const getClockGeometry = (spec, ctx) => {
6291
- var _a, _b, _c;
6292
- const { width, height, startX, startY } = getRegionGeometry(ctx);
6293
- const padding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
6294
- const innerWidth = Math.max(width - padding.left - padding.right, 1);
6295
- const innerHeight = Math.max(height - padding.top - padding.bottom, 1);
6296
- const cx = startX + padding.left + innerWidth / 2;
6297
- const cy = startY + padding.top + innerHeight / 2;
6298
- const R = Math.max(Math.min(innerWidth, innerHeight) / 2, 1);
6299
- const count = (_c = (_b = spec.data) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
6300
- const step = count > 0 ? (Math.PI * 2) / count : 0;
6301
- return { cx, cy, R, count, step };
6302
- };
6303
- const getClockBlockAngle = (geom, index) => -Math.PI / 2 + geom.step * (index + 0.5);
6304
- const polar = (cx, cy, r, angle) => ({
6305
- x: cx + Math.cos(angle) * r,
6306
- y: cy + Math.sin(angle) * r
6307
- });
6308
- const isOnLeftHalf = (angle) => Math.cos(angle) < 0;
6309
- const buildClockCenterImageMark = (spec) => {
6310
- var _a, _b, _c, _e;
6311
- if (((_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.visible) === false) {
6312
- return null;
6313
- }
6314
- const themeColor = getThemeColor(spec);
6315
- const hasImage = !!((_b = spec.centerImage) === null || _b === void 0 ? void 0 : _b.image);
6316
- return {
6317
- type: 'group',
6318
- name: 'storyline-clock-center',
6319
- zIndex: vchart.LayoutZIndex.Mark + 2,
6320
- children: [
6321
- {
6322
- type: 'symbol',
6323
- name: 'storyline-clock-center-halo',
6324
- interactive: false,
6325
- style: {
6326
- x: (_d, ctx) => getClockGeometry(spec, ctx).cx,
6327
- y: (_d, ctx) => getClockGeometry(spec, ctx).cy,
6328
- size: (_d, ctx) => {
6329
- const g = getClockGeometry(spec, ctx);
6330
- return g.R * CLOCK_CENTER_RADIUS_RATIO * 2.16;
6331
- },
6332
- symbolType: 'circle',
6333
- fill: withAlpha(themeColor, 0.28),
6334
- stroke: 'transparent'
6335
- }
6336
- },
6337
- hasImage
6338
- ? {
6339
- type: 'image',
6340
- name: 'storyline-clock-center-image',
6341
- interactive: false,
6342
- style: Object.assign({ x: (_d, ctx) => {
6343
- const g = getClockGeometry(spec, ctx);
6344
- return g.cx - g.R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO;
6345
- }, y: (_d, ctx) => {
6346
- const g = getClockGeometry(spec, ctx);
6347
- return g.cy - g.R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO;
6348
- }, width: (_d, ctx) => getClockGeometry(spec, ctx).R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO * 2, height: (_d, ctx) => getClockGeometry(spec, ctx).R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO * 2, image: (_c = spec.centerImage) === null || _c === void 0 ? void 0 : _c.image, cornerRadius: (_d, ctx) => getClockGeometry(spec, ctx).R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center', anchor: (_d, ctx) => {
6349
- const g = getClockGeometry(spec, ctx);
6350
- return [g.cx, g.cy];
6351
- }, dx: (_d, ctx) => {
6352
- var _a, _b;
6353
- const g = getClockGeometry(spec, ctx);
6354
- const rectW = g.R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO * 2;
6355
- const userWidth = (_b = (_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.width;
6356
- const w = typeof userWidth === 'number' ? userWidth : rectW;
6357
- return (rectW - w) / 2;
6358
- }, dy: (_d, ctx) => {
6359
- var _a, _b;
6360
- const g = getClockGeometry(spec, ctx);
6361
- const rectH = g.R * CLOCK_CENTER_RADIUS_RATIO * CLOCK_CENTER_IMAGE_INSET_RATIO * 2;
6362
- const userHeight = (_b = (_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.height;
6363
- const h = typeof userHeight === 'number' ? userHeight : rectH;
6364
- return (rectH - h) / 2;
6365
- } }, (_e = spec.centerImage) === null || _e === void 0 ? void 0 : _e.style)
6366
- }
6367
- : {
6368
- type: 'symbol',
6369
- name: 'storyline-clock-center-placeholder',
6370
- interactive: false,
6371
- style: {
6372
- x: (_d, ctx) => getClockGeometry(spec, ctx).cx,
6373
- y: (_d, ctx) => getClockGeometry(spec, ctx).cy,
6374
- size: (_d, ctx) => getClockGeometry(spec, ctx).R * CLOCK_CENTER_RADIUS_RATIO * 2,
6375
- symbolType: 'circle',
6376
- fill: '#ffffff',
6377
- stroke: themeColor,
6378
- lineWidth: 2
6379
- }
6380
- }
6381
- ].filter(Boolean)
6382
- };
6383
- };
6384
- const buildClockArcMark = (spec) => {
6385
- const themeColor = getThemeColor(spec);
6386
- const orbitPath = (_d, ctx) => {
6387
- const g = getClockGeometry(spec, ctx);
6388
- const r = g.R * CLOCK_ORBIT_RATIO;
6389
- return [
6390
- `M ${(g.cx + r).toFixed(2)} ${g.cy.toFixed(2)}`,
6391
- `A ${r.toFixed(2)} ${r.toFixed(2)} 0 1 1 ${(g.cx - r).toFixed(2)} ${g.cy.toFixed(2)}`,
6392
- `A ${r.toFixed(2)} ${r.toFixed(2)} 0 1 1 ${(g.cx + r).toFixed(2)} ${g.cy.toFixed(2)}`
6393
- ].join(' ');
6394
- };
6395
- return {
6396
- type: 'group',
6397
- name: 'storyline-clock-orbit',
6398
- zIndex: vchart.LayoutZIndex.Mark,
6399
- children: [
6400
- {
6401
- type: 'path',
6402
- name: 'storyline-clock-orbit-path',
6403
- interactive: false,
6404
- style: {
6405
- path: orbitPath,
6406
- stroke: withAlpha(themeColor, 0.7),
6407
- lineWidth: 1,
6408
- lineDash: CLOCK_ORBIT_DASH,
6409
- fill: 'transparent',
6410
- fillOpacity: 0
6411
- }
6412
- }
6413
- ]
6414
- };
6415
- };
6416
- const getClockDotCenter = (spec, ctx, index) => {
6417
- const g = getClockGeometry(spec, ctx);
6418
- const angle = getClockBlockAngle(g, index);
6419
- const r = g.R * CLOCK_DOT_RATIO;
6420
- return Object.assign(Object.assign({}, polar(g.cx, g.cy, r, angle)), { diameter: g.R * CLOCK_DOT_DIAMETER_RATIO, angle });
6421
- };
6422
- const getClockLeadLine = (spec, ctx, index) => {
6423
- const g = getClockGeometry(spec, ctx);
6424
- const angle = getClockBlockAngle(g, index);
6425
- const dotR = (g.R * CLOCK_DOT_DIAMETER_RATIO) / 2;
6426
- const start = polar(g.cx, g.cy, g.R * CLOCK_DOT_RATIO + dotR + CLOCK_LEAD_LINE_GAP, angle);
6427
- const end = polar(g.cx, g.cy, g.R * CLOCK_TEXT_INNER_RATIO - CLOCK_TEXT_GAP_FROM_LEAD, angle);
6428
- return { start, end };
6429
- };
6430
- const getClockTextRect = (spec, ctx, index) => {
6431
- var _a;
6432
- const g = getClockGeometry(spec, ctx);
6433
- const { width: regionWidth, startX } = getRegionGeometry(ctx);
6434
- const padding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
6435
- const angle = getClockBlockAngle(g, index);
6436
- const onLeft = isOnLeftHalf(angle);
6437
- const rInner = g.R * CLOCK_TEXT_INNER_RATIO;
6438
- const innerPoint = polar(g.cx, g.cy, rInner, angle);
6439
- const leftEdge = startX + padding.left;
6440
- const rightEdge = startX + regionWidth - padding.right;
6441
- const width = onLeft
6442
- ? Math.min(Math.max(innerPoint.x - leftEdge, 80), CLOCK_TEXT_MAX_WIDTH)
6443
- : Math.min(Math.max(rightEdge - innerPoint.x, 80), CLOCK_TEXT_MAX_WIDTH);
6444
- return { x: innerPoint.x, y: innerPoint.y, width, onLeft, anchorY: innerPoint.y };
6445
- };
6446
- const buildClockBlockMark = (spec, block, index) => {
6447
- var _a, _b, _c;
6448
- const hasImage = !!block.image;
6449
- const themeColor = getThemeColor(spec);
6450
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
6451
- const leadPath = (_d, ctx) => {
6452
- const { start, end } = getClockLeadLine(spec, ctx, index);
6453
- return `M ${start.x.toFixed(2)} ${start.y.toFixed(2)} L ${end.x.toFixed(2)} ${end.y.toFixed(2)}`;
6454
- };
6455
- const children = [
6456
- {
6457
- type: 'path',
6458
- name: `storyline-clock-lead-${index}`,
6459
- interactive: false,
6460
- style: {
6461
- path: leadPath,
6462
- stroke: withAlpha(themeColor, 0.7),
6463
- lineWidth: 1,
6464
- lineDash: [3, 3],
6465
- fill: 'transparent',
6466
- fillOpacity: 0
6467
- }
6468
- },
6469
- hasImage
6470
- ? {
6471
- type: 'image',
6472
- name: `storyline-clock-dot-${index}`,
6473
- interactive: false,
6474
- style: {
6475
- x: (_d, ctx) => {
6476
- const dot = getClockDotCenter(spec, ctx, index);
6477
- return dot.x - dot.diameter / 2;
6478
- },
6479
- y: (_d, ctx) => {
6480
- const dot = getClockDotCenter(spec, ctx, index);
6481
- return dot.y - dot.diameter / 2;
6482
- },
6483
- width: (_d, ctx) => getClockDotCenter(spec, ctx, index).diameter,
6484
- height: (_d, ctx) => getClockDotCenter(spec, ctx, index).diameter,
6485
- image: block.image,
6486
- cornerRadius: (_d, ctx) => getClockDotCenter(spec, ctx, index).diameter / 2,
6487
- repeatX: 'no-repeat',
6488
- repeatY: 'no-repeat',
6489
- imageMode: 'cover',
6490
- imagePosition: 'center',
6491
- stroke: themeColor,
6492
- lineWidth: 2
6493
- }
6494
- }
6495
- : {
6496
- type: 'symbol',
6497
- name: `storyline-clock-dot-${index}`,
6498
- interactive: false,
6499
- style: {
6500
- x: (_d, ctx) => getClockDotCenter(spec, ctx, index).x,
6501
- y: (_d, ctx) => getClockDotCenter(spec, ctx, index).y,
6502
- size: (_d, ctx) => getClockDotCenter(spec, ctx, index).diameter,
6503
- symbolType: 'circle',
6504
- fill: themeColor,
6505
- stroke: '#ffffff',
6506
- lineWidth: 1.5
6507
- }
6508
- },
6509
- block.title
6510
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-clock-title-${index}`, interactive: false }, spec.title), { style: Object.assign({ x: (_d, ctx) => getClockTextRect(spec, ctx, index).x, y: (_d, ctx) => getClockTextRect(spec, ctx, index).anchorY - CLOCK_TITLE_LINE_HEIGHT, text: block.title, maxLineWidth: (_d, ctx) => getClockTextRect(spec, ctx, index).width, fontSize: CLOCK_TITLE_FONT_SIZE, lineHeight: CLOCK_TITLE_LINE_HEIGHT, fontWeight: 'bold', fill: themeColor, textAlign: (_d, ctx) => getClockTextRect(spec, ctx, index).onLeft ? 'right' : 'left', textBaseline: 'top' }, (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) })
6511
- : null,
6512
- contentText.length
6513
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-clock-content-${index}`, interactive: false }, spec.content), { textType: 'rich', style: Object.assign({ x: (_d, ctx) => getClockTextRect(spec, ctx, index).x, y: (_d, ctx) => getClockTextRect(spec, ctx, index).anchorY + 4, width: (_d, ctx) => getClockTextRect(spec, ctx, index).width, maxLineWidth: (_d, ctx) => getClockTextRect(spec, ctx, index).width, text: buildRichContent(contentText, spec), fontSize: CLOCK_CONTENT_FONT_SIZE, lineHeight: CLOCK_CONTENT_LINE_HEIGHT, fill: '#3a3f4d', textAlign: (_d, ctx) => getClockTextRect(spec, ctx, index).onLeft ? 'right' : 'left', textBaseline: 'top', wordBreak: 'break-word' }, (_b = spec.content) === null || _b === void 0 ? void 0 : _b.style) })
6514
- : null
6515
- ];
6516
- return {
6517
- type: 'group',
6518
- id: `storyline-block-${(_c = block.id) !== null && _c !== void 0 ? _c : index}`,
6519
- name: `storyline-block-${index}`,
6520
- zIndex: vchart.LayoutZIndex.Mark + 1,
6521
- children: children.filter(Boolean)
6522
- };
6523
- };
6524
-
6525
- const buildDefaultLineMark = (spec) => {
6526
- var _a, _b, _c, _d;
6527
- if (((_a = spec.line) === null || _a === void 0 ? void 0 : _a.visible) === false || ((_c = (_b = spec.data) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) <= 1) {
6528
- return null;
6529
- }
6530
- return {
6531
- type: 'group',
6532
- name: 'storyline-links',
6533
- zIndex: vchart.LayoutZIndex.Mark,
6534
- children: ((_d = spec.data) !== null && _d !== void 0 ? _d : []).slice(1).map((_, index) => {
6535
- var _a;
6536
- const _b = (_a = spec.line) !== null && _a !== void 0 ? _a : {}, { style = {}, type = 'line', showArrow = false, arrowSize = 8 } = _b, rest = __rest(_b, ["style", "type", "showArrow", "arrowSize"]);
6537
- return Object.assign(Object.assign({ type: 'path', name: `storyline-link-${index}`, interactive: false }, rest), { style: Object.assign(Object.assign({ stroke: '#8a94a6', lineWidth: 1.5, fill: 'transparent', fillOpacity: 0 }, style), { path: (_datum, ctx) => {
6538
- const link = getLayout(spec, ctx).links[index];
6539
- if (!link) {
6540
- return '';
6541
- }
6542
- return buildLinkPath(link.points, type, showArrow, arrowSize);
6543
- } }) });
6544
- })
6545
- };
6546
- };
6547
- const getDefaultBlockMetrics = (spec, ctx, index) => {
6548
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
6549
- const block = getLayout(spec, ctx).blocks[index];
6550
- const padding = normalizePadding((_b = (_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding) !== null && _b !== void 0 ? _b : 12);
6551
- const imagePosition = (_d = (_c = spec.image) === null || _c === void 0 ? void 0 : _c.position) !== null && _d !== void 0 ? _d : 'top';
6552
- const imageWidth = (_f = (_e = spec.image) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : DEFAULT_IMAGE_WIDTH;
6553
- const imageHeight = (_h = (_g = spec.image) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : DEFAULT_IMAGE_HEIGHT;
6554
- const imageGap = (_k = (_j = spec.image) === null || _j === void 0 ? void 0 : _j.gap) !== null && _k !== void 0 ? _k : DEFAULT_IMAGE_GAP;
6555
- const hasImage = !!((_m = (_l = spec.data) === null || _l === void 0 ? void 0 : _l[index]) === null || _m === void 0 ? void 0 : _m.image);
6556
- const titleFontSize = Number((_q = (_p = (_o = spec.title) === null || _o === void 0 ? void 0 : _o.style) === null || _p === void 0 ? void 0 : _p.fontSize) !== null && _q !== void 0 ? _q : 14);
6557
- const titleLineHeight = Number((_t = (_s = (_r = spec.title) === null || _r === void 0 ? void 0 : _r.style) === null || _s === void 0 ? void 0 : _s.lineHeight) !== null && _t !== void 0 ? _t : Math.round(titleFontSize * 1.35));
6558
- const titleHeight = ((_v = (_u = spec.data) === null || _u === void 0 ? void 0 : _u[index]) === null || _v === void 0 ? void 0 : _v.title) ? titleLineHeight : 0;
6559
- const blockWidth = (_w = block === null || block === void 0 ? void 0 : block.width) !== null && _w !== void 0 ? _w : resolveBlockWidth(spec, 0);
6560
- const blockHeight = (_z = (_x = block === null || block === void 0 ? void 0 : block.height) !== null && _x !== void 0 ? _x : (_y = spec.block) === null || _y === void 0 ? void 0 : _y.height) !== null && _z !== void 0 ? _z : DEFAULT_BLOCK_HEIGHT;
6561
- const imageBox = getImageBox(imagePosition, blockWidth, blockHeight, padding, imageWidth, imageHeight, imageGap, hasImage);
6562
- const textBox = getTextBox(imagePosition, blockWidth, blockHeight, padding, imageWidth, imageHeight, imageGap, hasImage);
6563
- const contentGap = ((_1 = (_0 = spec.data) === null || _0 === void 0 ? void 0 : _0[index]) === null || _1 === void 0 ? void 0 : _1.title) ? 8 : 0;
6564
- return {
6565
- block: {
6566
- width: blockWidth,
6567
- height: blockHeight
6568
- },
6569
- imageBox,
6570
- textBox,
6571
- contentBox: {
6572
- y: textBox.y + titleHeight + contentGap,
6573
- height: Math.max(0, textBox.height - titleHeight - contentGap)
6574
- }
6575
- };
6576
- };
6577
- const buildDefaultBlockMark = (spec, block, index) => {
6578
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
6579
- const hasImage = !!block.image;
6580
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
6581
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 14);
6582
- const titleLineHeight = Number((_f = (_e = (_d = spec.title) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.lineHeight) !== null && _f !== void 0 ? _f : Math.round(titleFontSize * 1.35));
6583
- return {
6584
- type: 'group',
6585
- id: `storyline-block-${(_g = block.id) !== null && _g !== void 0 ? _g : index}`,
6586
- name: `storyline-block-${index}`,
6587
- zIndex: vchart.LayoutZIndex.Mark + 1,
6588
- style: {
6589
- x: (_datum, ctx) => { var _a, _b; return (_b = (_a = getLayout(spec, ctx).blocks[index]) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0; },
6590
- y: (_datum, ctx) => { var _a, _b; return (_b = (_a = getLayout(spec, ctx).blocks[index]) === null || _a === void 0 ? void 0 : _a.y) !== null && _b !== void 0 ? _b : 0; },
6591
- width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.width,
6592
- height: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.height
6593
- },
6594
- children: [
6595
- {
6596
- type: 'rect',
6597
- name: `storyline-block-bg-${index}`,
6598
- interactive: false,
6599
- style: Object.assign({ x: 0, y: 0, width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.width, height: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.height, cornerRadius: 8, fill: '#ffffff', stroke: '#d7dce5', lineWidth: 1, shadowBlur: 6, shadowColor: 'rgba(0, 0, 0, 0.08)' }, (_h = spec.block) === null || _h === void 0 ? void 0 : _h.style)
6600
- },
6601
- hasImage
6602
- ? Object.assign(Object.assign({ type: 'image', name: `storyline-block-image-${index}`, interactive: false }, omitImageLayoutSpec(spec.image)), { style: Object.assign({ x: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.x, y: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.y, width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.width, height: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.height, image: block.image, cornerRadius: 6 }, (_j = spec.image) === null || _j === void 0 ? void 0 : _j.style) })
6603
- : null,
6604
- block.title
6605
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-title-${index}`, interactive: false }, spec.title), { style: Object.assign({ x: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.x, y: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.y, text: block.title, maxLineWidth: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.width, fontSize: titleFontSize, lineHeight: titleLineHeight, fontWeight: 'bold', fill: '#1f2430', textAlign: 'left', textBaseline: 'top' }, (_k = spec.title) === null || _k === void 0 ? void 0 : _k.style) })
6606
- : null,
6607
- contentText.length
6608
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-content-${index}`, interactive: false }, spec.content), { textType: 'rich', style: Object.assign({ x: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.x, y: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).contentBox.y, width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.width, text: buildRichContent(contentText, spec), maxLineWidth: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.width, fontSize: 12, lineHeight: 18, heightLimit: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).contentBox.height, textAlign: 'left', textBaseline: 'top', wordBreak: 'break-word', ellipsis: '...', fill: '#596173' }, (_l = spec.content) === null || _l === void 0 ? void 0 : _l.style) })
6609
- : null
6610
- ].filter(Boolean)
6611
- };
6612
- };
6613
- const buildLinkPath = (points, type, showArrow, arrowSize) => {
6614
- const start = points[0];
6615
- const end = points[points.length - 1];
6616
- if (!start || !end) {
6617
- return '';
6618
- }
6619
- let path;
6620
- if (type === 'curve') {
6621
- const dx = end.x - start.x;
6622
- const dy = end.y - start.y;
6623
- const curve = Math.max(Math.min(Math.sqrt(dx * dx + dy * dy) * 0.22, 80), 24);
6624
- path =
6625
- `M ${start.x} ${start.y} ` +
6626
- `C ${start.x + dx / 2} ${start.y - curve} ${end.x - dx / 2} ${end.y + curve} ${end.x} ${end.y}`;
6627
- }
6628
- else if (type === 'polyline') {
6629
- const mid = { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };
6630
- path = `M ${start.x} ${start.y} L ${mid.x} ${start.y} L ${mid.x} ${end.y} L ${end.x} ${end.y}`;
6631
- }
6632
- else {
6633
- path = `M ${start.x} ${start.y} L ${end.x} ${end.y}`;
6634
- }
6635
- if (!showArrow) {
6636
- return path;
6637
- }
6638
- return `${path} ${buildArrowPath(start, end, arrowSize)}`;
6639
- };
6640
- const buildArrowPath = (start, end, size) => {
6641
- const angle = Math.atan2(end.y - start.y, end.x - start.x);
6642
- const left = {
6643
- x: end.x - Math.cos(angle - Math.PI / 6) * size,
6644
- y: end.y - Math.sin(angle - Math.PI / 6) * size
6645
- };
6646
- const right = {
6647
- x: end.x - Math.cos(angle + Math.PI / 6) * size,
6648
- y: end.y - Math.sin(angle + Math.PI / 6) * size
6649
- };
6650
- return `M ${left.x} ${left.y} L ${end.x} ${end.y} L ${right.x} ${right.y}`;
6651
- };
6652
-
6653
- const LANDSCAPE_IMAGE_HEIGHT_RATIO = 0.42;
6654
- const LANDSCAPE_DETACHED_GAP = 64;
6655
- const LANDSCAPE_CONNECTOR_ARROW_SIZE = 9;
6656
- const LANDSCAPE_CONNECTOR_X_RATIO = 0.2;
6657
- const LANDSCAPE_TEXT_GAP_FROM_CONNECTOR = 12;
6658
- const LANDSCAPE_CONTENT_LINES = 4;
6659
- const LANDSCAPE_TITLE_LINE_HEIGHT = 19;
6660
- const LANDSCAPE_CONTENT_LINE_HEIGHT = 18;
6661
- const LANDSCAPE_CONTENT_FONT_SIZE = 12;
6662
- const LANDSCAPE_TITLE_TO_CONTENT_GAP = 4;
6663
- const getLandscapeImageCenter = (spec, ctx, index) => {
6664
- var _a, _b, _c, _e;
6665
- const lb = getLayout(spec, ctx).blocks[index];
6666
- if (!lb) {
6667
- return null;
6668
- }
6669
- const cx = (_b = (_a = lb.center) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : lb.x + lb.width / 2;
6670
- const cy = (_e = (_c = lb.center) === null || _c === void 0 ? void 0 : _c.y) !== null && _e !== void 0 ? _e : lb.y + lb.height / 2;
6671
- const stagger = (index % 2 === 0 ? -1 : 1) * lb.height * 0.1;
6672
- return { x: cx, y: cy + stagger };
6673
- };
6674
- const buildLandscapeConnectingCurve = (spec) => {
6675
- var _a, _b, _c, _e, _f, _g, _h;
6676
- const themeColor = getThemeColor(spec);
6677
- const lineStyle = (_b = (_a = spec.line) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
6678
- const count = (_e = (_c = spec.data) === null || _c === void 0 ? void 0 : _c.length) !== null && _e !== void 0 ? _e : 0;
6679
- const symbolSize = 14;
6680
- const symbolChildren = [];
6681
- for (let i = 0; i < count; i++) {
6682
- const idx = i;
6683
- symbolChildren.push({
6684
- type: 'symbol',
6685
- name: `storyline-landscape-curve-symbol-${idx}`,
6686
- interactive: false,
6687
- style: {
6688
- symbolType: 'circle',
6689
- size: symbolSize,
6690
- fill: themeColor,
6691
- x: (_d, ctx) => { var _a, _b; return (_b = (_a = getLandscapeImageCenter(spec, ctx, idx)) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0; },
6692
- y: (_d, ctx) => { var _a, _b; return (_b = (_a = getLandscapeImageCenter(spec, ctx, idx)) === null || _a === void 0 ? void 0 : _a.y) !== null && _b !== void 0 ? _b : 0; }
6693
- }
6694
- });
6695
- }
6696
- return {
6697
- type: 'group',
6698
- name: 'storyline-landscape-curve',
6699
- zIndex: vchart.LayoutZIndex.Mark + 2,
6700
- children: [
6701
- {
6702
- type: 'path',
6703
- name: 'storyline-landscape-curve-path',
6704
- interactive: false,
6705
- style: {
6706
- stroke: (_f = lineStyle.stroke) !== null && _f !== void 0 ? _f : themeColor,
6707
- lineWidth: (_g = lineStyle.lineWidth) !== null && _g !== void 0 ? _g : 4,
6708
- lineDash: (_h = lineStyle.lineDash) !== null && _h !== void 0 ? _h : [6, 5],
6709
- lineCap: 'round',
6710
- fill: 'transparent',
6711
- fillOpacity: 0,
6712
- path: (_d, ctx) => {
6713
- const points = [];
6714
- for (let i = 0; i < count; i++) {
6715
- const center = getLandscapeImageCenter(spec, ctx, i);
6716
- if (center) {
6717
- points.push(center);
6718
- }
6719
- }
6720
- return buildSmoothCurvePath(points);
6721
- }
6722
- }
6723
- },
6724
- ...symbolChildren
6725
- ]
6726
- };
6727
- };
6728
- const getLandscapeMetrics = (spec, blockWidth, blockHeight, index) => {
6729
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
6730
- const padding = normalizePadding((_b = (_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding) !== null && _b !== void 0 ? _b : 12);
6731
- const titleFontSize = Number((_f = (_e = (_c = spec.title) === null || _c === void 0 ? void 0 : _c.style) === null || _e === void 0 ? void 0 : _e.fontSize) !== null && _f !== void 0 ? _f : 14);
6732
- const titleLineHeight = Number((_j = (_h = (_g = spec.title) === null || _g === void 0 ? void 0 : _g.style) === null || _h === void 0 ? void 0 : _h.lineHeight) !== null && _j !== void 0 ? _j : Math.max(LANDSCAPE_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35)));
6733
- const contentFontSize = Number((_m = (_l = (_k = spec.content) === null || _k === void 0 ? void 0 : _k.style) === null || _l === void 0 ? void 0 : _l.fontSize) !== null && _m !== void 0 ? _m : LANDSCAPE_CONTENT_FONT_SIZE);
6734
- const contentLineHeight = Number((_q = (_p = (_o = spec.content) === null || _o === void 0 ? void 0 : _o.style) === null || _p === void 0 ? void 0 : _p.lineHeight) !== null && _q !== void 0 ? _q : LANDSCAPE_CONTENT_LINE_HEIGHT);
6735
- const imageHeight = Math.max((_s = (_r = spec.image) === null || _r === void 0 ? void 0 : _r.height) !== null && _s !== void 0 ? _s : Math.round(blockHeight * LANDSCAPE_IMAGE_HEIGHT_RATIO), titleLineHeight + padding.top + padding.bottom);
6736
- const connectorGap = LANDSCAPE_DETACHED_GAP;
6737
- const contentHeight = LANDSCAPE_CONTENT_LINES * contentLineHeight;
6738
- const titleToContentGap = LANDSCAPE_TITLE_TO_CONTENT_GAP;
6739
- const textHeight = titleLineHeight + titleToContentGap + contentHeight;
6740
- const textOnTop = index % 2 === 0;
6741
- let textBox;
6742
- let contentBox;
6743
- let imageBox;
6744
- let connector;
6745
- let groupTop;
6746
- let groupHeight;
6747
- const imageX = 0;
6748
- const connectorX = imageX + blockWidth * LANDSCAPE_CONNECTOR_X_RATIO;
6749
- const textX = connectorX + LANDSCAPE_TEXT_GAP_FROM_CONNECTOR;
6750
- const textWidth = Math.max(blockWidth - (textX - imageX), 0);
6751
- if (textOnTop) {
6752
- const imageY = 0;
6753
- const textY = imageY - connectorGap - textHeight;
6754
- const connectorY1 = imageY;
6755
- const connectorY2 = textY + titleLineHeight / 2;
6756
- imageBox = { x: imageX, y: imageY, width: blockWidth, height: imageHeight };
6757
- textBox = { x: textX, y: textY, width: textWidth, height: textHeight };
6758
- contentBox = {
6759
- x: textX,
6760
- y: textY + titleLineHeight + titleToContentGap,
6761
- width: textWidth,
6762
- height: contentHeight
6763
- };
6764
- connector = { x1: connectorX, y1: connectorY1, x2: connectorX, y2: connectorY2 };
6765
- groupTop = textY;
6766
- groupHeight = imageHeight - groupTop;
6767
- }
6768
- else {
6769
- const imageY = 0;
6770
- const textY = imageY + imageHeight + connectorGap;
6771
- const connectorY1 = imageY + imageHeight;
6772
- const connectorY2 = textY + textHeight;
6773
- imageBox = { x: imageX, y: imageY, width: blockWidth, height: imageHeight };
6774
- textBox = { x: textX, y: textY, width: textWidth, height: textHeight };
6775
- contentBox = {
6776
- x: textX,
6777
- y: textY + titleLineHeight + titleToContentGap,
6778
- width: textWidth,
6779
- height: contentHeight
6780
- };
6781
- connector = { x1: connectorX, y1: connectorY1, x2: connectorX, y2: connectorY2 };
6782
- groupTop = imageY;
6783
- groupHeight = textY + textHeight - imageY;
6784
- }
6785
- return {
6786
- padding,
6787
- titleFontSize,
6788
- titleLineHeight,
6789
- contentFontSize,
6790
- contentLineHeight,
6791
- contentHeight,
6792
- blockWidth,
6793
- imageBox,
6794
- textBox,
6795
- contentBox,
6796
- connector,
6797
- textOnTop,
6798
- groupTop,
6799
- groupHeight
6800
- };
6801
- };
6802
- const buildLandscapeBlockMark = (spec, block, index) => {
6803
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
6804
- const hasImage = !!block.image;
6805
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
6806
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 14);
6807
- const titleLineHeight = Number((_g = (_f = (_e = spec.title) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.lineHeight) !== null && _g !== void 0 ? _g : Math.round(titleFontSize * 1.35));
6808
- const getMetrics = (ctx) => {
6809
- var _a, _b, _c, _e;
6810
- const layoutBlock = getLayout(spec, ctx).blocks[index];
6811
- const w = (_a = layoutBlock === null || layoutBlock === void 0 ? void 0 : layoutBlock.width) !== null && _a !== void 0 ? _a : resolveBlockWidth(spec, 0);
6812
- const h = (_e = (_b = layoutBlock === null || layoutBlock === void 0 ? void 0 : layoutBlock.height) !== null && _b !== void 0 ? _b : (_c = spec.block) === null || _c === void 0 ? void 0 : _c.height) !== null && _e !== void 0 ? _e : DEFAULT_BLOCK_HEIGHT;
6813
- return getLandscapeMetrics(spec, w, h, index);
6814
- };
6815
- const blockStyle = (_j = (_h = spec.block) === null || _h === void 0 ? void 0 : _h.style) !== null && _j !== void 0 ? _j : {};
6816
- const lineStyle = (_l = (_k = spec.line) === null || _k === void 0 ? void 0 : _k.style) !== null && _l !== void 0 ? _l : {};
6817
- const themeColor = getThemeColor(spec);
6818
- const connectorStroke = (_m = lineStyle.stroke) !== null && _m !== void 0 ? _m : themeColor;
6819
- const connectorLineWidth = (_o = lineStyle.lineWidth) !== null && _o !== void 0 ? _o : 2;
6820
- const connectorDash = (_p = lineStyle.lineDash) !== null && _p !== void 0 ? _p : [4, 4];
6821
- return {
6822
- type: 'group',
6823
- id: `storyline-block-${(_q = block.id) !== null && _q !== void 0 ? _q : index}`,
6824
- name: `storyline-block-${index}`,
6825
- zIndex: vchart.LayoutZIndex.Mark + 1,
6826
- style: {
6827
- x: (_d, ctx) => {
6828
- var _a;
6829
- const lb = getLayout(spec, ctx).blocks[index];
6830
- return (_a = lb === null || lb === void 0 ? void 0 : lb.x) !== null && _a !== void 0 ? _a : 0;
6831
- },
6832
- y: (_d, ctx) => {
6833
- var _a, _b, _c, _e, _f, _g, _h;
6834
- const lb = getLayout(spec, ctx).blocks[index];
6835
- const m = getMetrics(ctx);
6836
- const cy = (_b = (_a = lb === null || lb === void 0 ? void 0 : lb.center) === null || _a === void 0 ? void 0 : _a.y) !== null && _b !== void 0 ? _b : ((_c = lb === null || lb === void 0 ? void 0 : lb.y) !== null && _c !== void 0 ? _c : 0) + ((_e = lb === null || lb === void 0 ? void 0 : lb.height) !== null && _e !== void 0 ? _e : 0) / 2;
6837
- const blockH = (_h = (_f = lb === null || lb === void 0 ? void 0 : lb.height) !== null && _f !== void 0 ? _f : (_g = spec.block) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : DEFAULT_BLOCK_HEIGHT;
6838
- const stagger = (index % 2 === 0 ? -1 : 1) * blockH * 0.1;
6839
- return cy - m.imageBox.height / 2 + stagger;
6840
- },
6841
- width: (_d, ctx) => getMetrics(ctx).blockWidth,
6842
- height: (_d, ctx) => getMetrics(ctx).groupHeight
6843
- },
6844
- children: [
6845
- {
6846
- type: 'rect',
6847
- name: `storyline-block-image-bg-${index}`,
6848
- interactive: false,
6849
- style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).imageBox.x, y: (_d, ctx) => getMetrics(ctx).imageBox.y, width: (_d, ctx) => getMetrics(ctx).imageBox.width, height: (_d, ctx) => getMetrics(ctx).imageBox.height, cornerRadius: 8, fill: '#ffffff', stroke: themeColor, lineWidth: 2 }, blockStyle)
6850
- },
6851
- hasImage
6852
- ? Object.assign(Object.assign({ type: 'image', name: `storyline-block-image-${index}`, interactive: false }, omitImageLayoutSpec(spec.image)), { style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).imageBox.x, y: (_d, ctx) => getMetrics(ctx).imageBox.y, width: (_d, ctx) => getMetrics(ctx).imageBox.width, height: (_d, ctx) => getMetrics(ctx).imageBox.height, image: block.image, cornerRadius: 8, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center' }, (_r = spec.image) === null || _r === void 0 ? void 0 : _r.style) })
6853
- : null,
6854
- {
6855
- type: 'path',
6856
- name: `storyline-block-connector-${index}`,
6857
- interactive: false,
6858
- style: {
6859
- stroke: connectorStroke,
6860
- lineWidth: connectorLineWidth,
6861
- lineDash: connectorDash,
6862
- fill: connectorStroke,
6863
- path: (_d, ctx) => {
6864
- const m = getMetrics(ctx);
6865
- const tipSize = LANDSCAPE_CONNECTOR_ARROW_SIZE;
6866
- const x = m.connector.x1;
6867
- const y0 = m.connector.y1;
6868
- const y1 = m.connector.y2;
6869
- const tipDir = y1 < y0 ? -1 : 1;
6870
- const baseY = y1 - tipDir * tipSize;
6871
- const dashLine = `M ${x} ${y0} L ${x} ${baseY}`;
6872
- const triangle = `M ${x - tipSize / 2} ${baseY} L ${x + tipSize / 2} ${baseY} L ${x} ${y1} Z`;
6873
- return `${dashLine} ${triangle}`;
6874
- }
6875
- }
6876
- },
6877
- block.title
6878
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-title-${index}`, interactive: false }, spec.title), { style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).textBox.x, y: (_d, ctx) => getMetrics(ctx).textBox.y, text: block.title, maxLineWidth: (_d, ctx) => getMetrics(ctx).textBox.width, fontSize: titleFontSize, lineHeight: titleLineHeight, fontWeight: 'bold', fill: '#1f2430', textAlign: 'left', textBaseline: 'top' }, (_s = spec.title) === null || _s === void 0 ? void 0 : _s.style) })
6879
- : null,
6880
- contentText.length
6881
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-content-${index}`, interactive: false }, spec.content), { textType: 'rich', style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).contentBox.x, y: (_d, ctx) => getMetrics(ctx).contentBox.y, width: (_d, ctx) => getMetrics(ctx).contentBox.width, height: (_d, ctx) => getMetrics(ctx).contentBox.height, maxLineWidth: (_d, ctx) => getMetrics(ctx).contentBox.width, heightLimit: (_d, ctx) => getMetrics(ctx).contentBox.height, text: buildRichContent(contentText, spec), fontSize: LANDSCAPE_CONTENT_FONT_SIZE, lineHeight: LANDSCAPE_CONTENT_LINE_HEIGHT, textAlign: 'left', textBaseline: 'top', wordBreak: 'break-word', ellipsis: '...', fill: '#596173' }, (_t = spec.content) === null || _t === void 0 ? void 0 : _t.style) })
6882
- : null
6883
- ].filter(Boolean)
6884
- };
6885
- };
6886
-
6887
- const PORTRAIT_AXIS_WIDTH = 64;
6888
- const PORTRAIT_AXIS_PADDING = 50;
6889
- const PORTRAIT_IMAGE_WIDTH = 180;
6890
- const PORTRAIT_IMAGE_HEIGHT = 110;
6891
- const PORTRAIT_IMAGE_GAP_FROM_AXIS = 24;
6892
- const PORTRAIT_SHADOW_OFFSET_X = 36;
6893
- const PORTRAIT_SHADOW_OFFSET_Y = 20;
6894
- const PORTRAIT_SHADOW_SCALE = 1.12;
6895
- const PORTRAIT_TEXT_GAP_FROM_IMAGE = 8;
6896
- const PORTRAIT_CONTENT_LINES = 3;
6897
- const PORTRAIT_TITLE_LINE_HEIGHT = 19;
6898
- const PORTRAIT_CONTENT_LINE_HEIGHT = 18;
6899
- const PORTRAIT_CONTENT_FONT_SIZE = 12;
6900
- const PORTRAIT_TITLE_TO_CONTENT_GAP = 4;
6901
- const getPortraitAxisRect = (spec, ctx) => {
6902
- const blocks = getLayout(spec, ctx).blocks;
6903
- if (!blocks.length) {
6904
- return { x: 0, y: 0, width: 0, height: 0 };
6905
- }
6906
- const firstCy = blocks[0].center.y;
6907
- const lastCy = blocks[blocks.length - 1].center.y;
6908
- const top = Math.min(firstCy, lastCy);
6909
- const bottom = Math.max(firstCy, lastCy);
6910
- const cx = blocks[0].center.x;
6911
- return {
6912
- x: cx - PORTRAIT_AXIS_WIDTH / 2,
6913
- y: top - PORTRAIT_AXIS_PADDING,
6914
- width: PORTRAIT_AXIS_WIDTH,
6915
- height: bottom - top + PORTRAIT_AXIS_PADDING * 2
6916
- };
6917
- };
6918
- const buildPortraitAxisMark = (spec) => {
6919
- var _a, _b, _c, _e, _f, _g;
6920
- const themeColor = getThemeColor(spec);
6921
- const lineStyle = (_b = (_a = spec.line) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
6922
- const defaultFill = {
6923
- gradient: 'linear',
6924
- x0: 0,
6925
- y0: 0,
6926
- x1: 0,
6927
- y1: 1,
6928
- stops: [
6929
- { offset: 0, color: withAlpha(themeColor, 0.2) },
6930
- { offset: 1, color: withAlpha(themeColor, 1) }
6931
- ]
6932
- };
6933
- return {
6934
- type: 'group',
6935
- name: 'storyline-portrait-axis',
6936
- zIndex: vchart.LayoutZIndex.Mark,
6937
- children: [
6938
- {
6939
- type: 'rect',
6940
- name: 'storyline-portrait-axis-rect',
6941
- interactive: false,
6942
- style: {
6943
- fill: (_c = lineStyle.fill) !== null && _c !== void 0 ? _c : defaultFill,
6944
- stroke: (_e = lineStyle.stroke) !== null && _e !== void 0 ? _e : false,
6945
- lineWidth: (_f = lineStyle.lineWidth) !== null && _f !== void 0 ? _f : 0,
6946
- cornerRadius: (_g = lineStyle.cornerRadius) !== null && _g !== void 0 ? _g : 0,
6947
- x: (_d, ctx) => getPortraitAxisRect(spec, ctx).x,
6948
- y: (_d, ctx) => getPortraitAxisRect(spec, ctx).y,
6949
- width: (_d, ctx) => getPortraitAxisRect(spec, ctx).width,
6950
- height: (_d, ctx) => getPortraitAxisRect(spec, ctx).height
6951
- }
6952
- }
6953
- ]
6954
- };
6955
- };
6956
- const getPortraitMetrics = (spec, blockWidth, _blockHeight, index) => {
6957
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
6958
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 14);
6959
- const titleLineHeight = Number((_g = (_f = (_e = spec.title) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.lineHeight) !== null && _g !== void 0 ? _g : Math.max(PORTRAIT_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35)));
6960
- const contentFontSize = Number((_k = (_j = (_h = spec.content) === null || _h === void 0 ? void 0 : _h.style) === null || _j === void 0 ? void 0 : _j.fontSize) !== null && _k !== void 0 ? _k : PORTRAIT_CONTENT_FONT_SIZE);
6961
- const contentLineHeight = Number((_o = (_m = (_l = spec.content) === null || _l === void 0 ? void 0 : _l.style) === null || _m === void 0 ? void 0 : _m.lineHeight) !== null && _o !== void 0 ? _o : PORTRAIT_CONTENT_LINE_HEIGHT);
6962
- const contentHeight = PORTRAIT_CONTENT_LINES * contentLineHeight;
6963
- const titleToContentGap = PORTRAIT_TITLE_TO_CONTENT_GAP;
6964
- const textHeight = titleLineHeight + titleToContentGap + contentHeight;
6965
- const imageWidth = (_q = (_p = spec.image) === null || _p === void 0 ? void 0 : _p.width) !== null && _q !== void 0 ? _q : PORTRAIT_IMAGE_WIDTH;
6966
- const imageHeight = (_s = (_r = spec.image) === null || _r === void 0 ? void 0 : _r.height) !== null && _s !== void 0 ? _s : PORTRAIT_IMAGE_HEIGHT;
6967
- const onLeft = index % 2 === 0;
6968
- const axisHalf = PORTRAIT_AXIS_WIDTH / 2;
6969
- const imageX = onLeft
6970
- ? -axisHalf - PORTRAIT_IMAGE_GAP_FROM_AXIS - imageWidth
6971
- : axisHalf + PORTRAIT_IMAGE_GAP_FROM_AXIS;
6972
- const imageY = -imageHeight / 2;
6973
- const textX = imageX;
6974
- const textY = imageY + imageHeight + PORTRAIT_TEXT_GAP_FROM_IMAGE;
6975
- const textWidth = imageWidth;
6976
- const contentBox = {
6977
- x: textX,
6978
- y: textY + titleLineHeight + titleToContentGap,
6979
- width: textWidth,
6980
- height: contentHeight
6981
- };
6982
- const shadowOffsetX = PORTRAIT_SHADOW_OFFSET_X;
6983
- const shadowOffsetY = PORTRAIT_SHADOW_OFFSET_Y;
6984
- const shadowWidth = imageWidth * PORTRAIT_SHADOW_SCALE;
6985
- const shadowHeight = imageHeight * PORTRAIT_SHADOW_SCALE;
6986
- const baseShadowX = imageX - (shadowWidth - imageWidth) / 2;
6987
- const baseShadowY = imageY - (shadowHeight - imageHeight) / 2;
6988
- const shadowBox = {
6989
- x: baseShadowX + (onLeft ? -shadowOffsetX : shadowOffsetX),
6990
- y: baseShadowY + shadowOffsetY,
6991
- width: shadowWidth,
6992
- height: shadowHeight
6993
- };
6994
- return {
6995
- onLeft,
6996
- titleFontSize,
6997
- titleLineHeight,
6998
- contentFontSize,
6999
- contentLineHeight,
7000
- blockWidth,
7001
- imageBox: { x: imageX, y: imageY, width: imageWidth, height: imageHeight },
7002
- shadowBox,
7003
- textBox: { x: textX, y: textY, width: textWidth, height: textHeight },
7004
- contentBox
7005
- };
7006
- };
7007
- const buildPortraitBlockMark = (spec, block, index) => {
7008
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o;
7009
- const hasImage = !!block.image;
7010
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
7011
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 14);
7012
- const titleLineHeight = Number((_g = (_f = (_e = spec.title) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.lineHeight) !== null && _g !== void 0 ? _g : Math.max(PORTRAIT_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35)));
7013
- const getMetrics = (ctx) => {
7014
- var _a, _b, _c, _e;
7015
- const lb = getLayout(spec, ctx).blocks[index];
7016
- const w = (_a = lb === null || lb === void 0 ? void 0 : lb.width) !== null && _a !== void 0 ? _a : resolveBlockWidth(spec, 0);
7017
- const h = (_e = (_b = lb === null || lb === void 0 ? void 0 : lb.height) !== null && _b !== void 0 ? _b : (_c = spec.block) === null || _c === void 0 ? void 0 : _c.height) !== null && _e !== void 0 ? _e : DEFAULT_BLOCK_HEIGHT;
7018
- return getPortraitMetrics(spec, w, h, index);
7019
- };
7020
- const themeColor = getThemeColor(spec);
7021
- const blockStyle = (_j = (_h = spec.block) === null || _h === void 0 ? void 0 : _h.style) !== null && _j !== void 0 ? _j : {};
7022
- return {
7023
- type: 'group',
7024
- id: `storyline-block-${(_k = block.id) !== null && _k !== void 0 ? _k : index}`,
7025
- name: `storyline-block-${index}`,
7026
- zIndex: vchart.LayoutZIndex.Mark + 1,
7027
- style: {
7028
- x: (_d, ctx) => {
7029
- var _a, _b;
7030
- const lb = getLayout(spec, ctx).blocks[index];
7031
- return (_b = (_a = lb === null || lb === void 0 ? void 0 : lb.center) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0;
7032
- },
7033
- y: (_d, ctx) => {
7034
- var _a, _b;
7035
- const lb = getLayout(spec, ctx).blocks[index];
7036
- return (_b = (_a = lb === null || lb === void 0 ? void 0 : lb.center) === null || _a === void 0 ? void 0 : _a.y) !== null && _b !== void 0 ? _b : 0;
7037
- }
7038
- },
7039
- children: [
7040
- hasImage
7041
- ? {
7042
- type: 'image',
7043
- name: `storyline-block-shadow-image-${index}`,
7044
- interactive: false,
7045
- style: {
7046
- x: (_d, ctx) => getMetrics(ctx).shadowBox.x,
7047
- y: (_d, ctx) => getMetrics(ctx).shadowBox.y,
7048
- width: (_d, ctx) => getMetrics(ctx).shadowBox.width,
7049
- height: (_d, ctx) => getMetrics(ctx).shadowBox.height,
7050
- image: block.image,
7051
- cornerRadius: 8,
7052
- repeatX: 'no-repeat',
7053
- repeatY: 'no-repeat',
7054
- imageMode: 'cover',
7055
- imagePosition: 'center'
7056
- }
7057
- }
7058
- : null,
7059
- hasImage
7060
- ? {
7061
- type: 'rect',
7062
- name: `storyline-block-shadow-mask-${index}`,
7063
- interactive: false,
7064
- style: {
7065
- x: (_d, ctx) => getMetrics(ctx).shadowBox.x,
7066
- y: (_d, ctx) => getMetrics(ctx).shadowBox.y,
7067
- width: (_d, ctx) => getMetrics(ctx).shadowBox.width,
7068
- height: (_d, ctx) => getMetrics(ctx).shadowBox.height,
7069
- cornerRadius: 8,
7070
- stroke: false,
7071
- lineWidth: 0,
7072
- fill: {
7073
- gradient: 'linear',
7074
- x0: 0,
7075
- y0: 0,
7076
- x1: 0,
7077
- y1: 1,
7078
- stops: [
7079
- { offset: 0, color: withAlpha(themeColor, 0.2) },
7080
- { offset: 1, color: withAlpha(themeColor, 1) }
7081
- ]
7082
- }
7083
- }
7084
- }
7085
- : null,
7086
- {
7087
- type: 'rect',
7088
- name: `storyline-block-image-bg-${index}`,
7089
- interactive: false,
7090
- style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).imageBox.x, y: (_d, ctx) => getMetrics(ctx).imageBox.y, width: (_d, ctx) => getMetrics(ctx).imageBox.width, height: (_d, ctx) => getMetrics(ctx).imageBox.height, cornerRadius: 8, fill: '#ffffff', stroke: themeColor, lineWidth: 2 }, blockStyle)
7091
- },
7092
- hasImage
7093
- ? Object.assign(Object.assign({ type: 'image', name: `storyline-block-image-${index}`, interactive: false }, omitImageLayoutSpec(spec.image)), { style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).imageBox.x, y: (_d, ctx) => getMetrics(ctx).imageBox.y, width: (_d, ctx) => getMetrics(ctx).imageBox.width, height: (_d, ctx) => getMetrics(ctx).imageBox.height, image: block.image, cornerRadius: 8, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center' }, (_l = spec.image) === null || _l === void 0 ? void 0 : _l.style) })
7094
- : null,
7095
- block.title
7096
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-title-${index}`, interactive: false }, spec.title), { style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).textBox.x, y: (_d, ctx) => getMetrics(ctx).textBox.y, text: block.title, maxLineWidth: (_d, ctx) => getMetrics(ctx).textBox.width, fontSize: titleFontSize, lineHeight: titleLineHeight, fontWeight: 'bold', fill: '#1f2430', textAlign: 'left', textBaseline: 'top' }, (_m = spec.title) === null || _m === void 0 ? void 0 : _m.style) })
7097
- : null,
7098
- contentText.length
7099
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-content-${index}`, interactive: false }, spec.content), { textType: 'rich', style: Object.assign({ x: (_d, ctx) => getMetrics(ctx).contentBox.x, y: (_d, ctx) => getMetrics(ctx).contentBox.y, width: (_d, ctx) => getMetrics(ctx).contentBox.width, height: (_d, ctx) => getMetrics(ctx).contentBox.height, maxLineWidth: (_d, ctx) => getMetrics(ctx).contentBox.width, heightLimit: (_d, ctx) => getMetrics(ctx).contentBox.height, text: buildRichContent(contentText, spec), fontSize: PORTRAIT_CONTENT_FONT_SIZE, lineHeight: PORTRAIT_CONTENT_LINE_HEIGHT, textAlign: 'left', textBaseline: 'top', wordBreak: 'break-word', ellipsis: '...', fill: '#596173' }, (_o = spec.content) === null || _o === void 0 ? void 0 : _o.style) })
7100
- : null
7101
- ].filter(Boolean)
7102
- };
7103
- };
7104
-
7105
- const DOME_BLOCK_IMAGE_SIZE = 140;
7106
- const DOME_TEXT_GAP_FROM_IMAGE = 10;
7107
- const DOME_TITLE_LINE_HEIGHT = 19;
7108
- const DOME_CONTENT_LINE_HEIGHT = 17;
7109
- const DOME_CONTENT_FONT_SIZE = 12;
7110
- const DOME_TEXT_BOX_HEIGHT = 300;
7111
- const DOME_TITLE_TO_CONTENT_GAP = 4;
7112
- const DOME_TEXT_LEFT_PADDING = 20;
7113
- const DOME_CENTER_IMAGE_SIZE_RATIO = 0.4;
7114
- const DOME_ARC_TOP_GAP_FROM_CENTER_IMAGE = 300;
7115
- const getDomeCenterImageRect = (spec, ctx) => {
7116
- var _a, _b, _c, _e, _f;
7117
- const { width, height, startX, startY } = getRegionGeometry(ctx);
7118
- const padding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
7119
- const innerWidth = Math.max(width - padding.left - padding.right, 1);
7120
- const innerHeight = Math.max(height - padding.top - padding.bottom, 1);
7121
- const baseSize = Math.min(innerWidth, innerHeight) * DOME_CENTER_IMAGE_SIZE_RATIO;
7122
- const w = Math.max((_c = (_b = spec.centerImage) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : baseSize, 80);
7123
- const h = Math.max((_f = (_e = spec.centerImage) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : baseSize, 80);
7124
- const cx = startX + padding.left + innerWidth / 2;
7125
- const top = startY + padding.top + innerHeight - h;
7126
- return { x: cx - w / 2, y: top, width: w, height: h };
7127
- };
7128
- const getDomeArcGeometry = (spec, ctx) => {
7129
- var _a, _b, _c, _e;
7130
- const { width, startX } = getRegionGeometry(ctx);
7131
- const blockPadding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
7132
- const innerWidth = Math.max(width - blockPadding.left - blockPadding.right, 1);
7133
- const blockWidth = resolveBlockWidth(spec, width);
7134
- const layoutOpt = normalizeLayout(spec.layout);
7135
- const startAngle = (_b = layoutOpt.startAngle) !== null && _b !== void 0 ? _b : 200;
7136
- const endAngle = (_c = layoutOpt.endAngle) !== null && _c !== void 0 ? _c : 340;
7137
- const ratio = (_e = layoutOpt.radiusRatio) !== null && _e !== void 0 ? _e : 0.88;
7138
- const rx = Math.max((innerWidth - blockWidth) / 2, 1) * ratio;
7139
- const centerRect = getDomeCenterImageRect(spec, ctx);
7140
- const centerTop = centerRect.y;
7141
- const centerBottom = centerRect.y + centerRect.height;
7142
- const sinStart = Math.sin((startAngle / 180) * Math.PI);
7143
- const denom = Math.max(1 + sinStart, 0.05);
7144
- const ry = (centerRect.height + DOME_ARC_TOP_GAP_FROM_CENTER_IMAGE) / denom;
7145
- const cy = centerBottom - ry * sinStart;
7146
- return {
7147
- cx: startX + blockPadding.left + innerWidth / 2,
7148
- cy,
7149
- rx,
7150
- ry,
7151
- startAngle,
7152
- endAngle,
7153
- centerTop,
7154
- centerBottom
7155
- };
7156
- };
7157
- const getDomeBlockCenter = (spec, ctx, index) => {
7158
- var _a, _b, _c, _e;
7159
- const arc = getDomeArcGeometry(spec, ctx);
7160
- const count = (_b = (_a = spec.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
7161
- if (count <= 0) {
7162
- return { x: arc.cx, y: arc.cy };
7163
- }
7164
- const t = count === 1 ? 0.5 : index / (count - 1);
7165
- const angle = ((arc.startAngle + (arc.endAngle - arc.startAngle) * t) / 180) * Math.PI;
7166
- const px = arc.cx + Math.cos(angle) * arc.rx;
7167
- const py = arc.cy + Math.sin(angle) * arc.ry;
7168
- const nxRaw = Math.cos(angle) / arc.rx;
7169
- const nyRaw = Math.sin(angle) / arc.ry;
7170
- const nLen = Math.hypot(nxRaw, nyRaw) || 1;
7171
- const nx = nxRaw / nLen;
7172
- const ny = nyRaw / nLen;
7173
- const imageHeight = (_e = (_c = spec.image) === null || _c === void 0 ? void 0 : _c.height) !== null && _e !== void 0 ? _e : DOME_BLOCK_IMAGE_SIZE;
7174
- const offset = imageHeight / 2;
7175
- return { x: px + nx * offset, y: py + ny * offset };
7176
- };
7177
- const buildDomeArcMark = (spec) => {
7178
- var _a;
7179
- if (((_a = spec.line) === null || _a === void 0 ? void 0 : _a.visible) !== true) {
7180
- return null;
7181
- }
7182
- const themeColor = getThemeColor(spec);
7183
- return {
7184
- type: 'group',
7185
- name: 'storyline-dome-arc',
7186
- zIndex: vchart.LayoutZIndex.Mark,
7187
- children: [
7188
- {
7189
- type: 'path',
7190
- name: 'storyline-dome-arc-path',
7191
- interactive: false,
7192
- style: {
7193
- stroke: themeColor,
7194
- lineWidth: 2,
7195
- lineCap: 'round',
7196
- fill: 'transparent',
7197
- fillOpacity: 0,
7198
- path: (_d, ctx) => {
7199
- const arc = getDomeArcGeometry(spec, ctx);
7200
- const span = arc.endAngle - arc.startAngle;
7201
- const samples = 64;
7202
- const segments = [];
7203
- for (let i = 0; i <= samples; i++) {
7204
- const t = i / samples;
7205
- const angle = ((arc.startAngle + span * t) / 180) * Math.PI;
7206
- const x = arc.cx + Math.cos(angle) * arc.rx;
7207
- const y = arc.cy + Math.sin(angle) * arc.ry;
7208
- segments.push(`${i === 0 ? 'M' : 'L'} ${x.toFixed(2)} ${y.toFixed(2)}`);
7209
- }
7210
- return segments.join(' ');
7211
- }
7212
- }
7213
- }
7214
- ]
7215
- };
7216
- };
7217
- const buildDomeCenterImageMark = (spec) => {
7218
- var _a, _b, _c, _e;
7219
- const visible = ((_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.visible) !== false;
7220
- if (!visible) {
7221
- return null;
7222
- }
7223
- const themeColor = getThemeColor(spec);
7224
- const hasImage = !!((_b = spec.centerImage) === null || _b === void 0 ? void 0 : _b.image);
7225
- const symbolGradient = {
7226
- gradient: 'linear',
7227
- x0: 0.5,
7228
- y0: 0,
7229
- x1: 0.5,
7230
- y1: 1,
7231
- stops: [
7232
- { offset: 0, color: withAlpha(themeColor, 0.15) },
7233
- { offset: 1, color: themeColor }
7234
- ]
7235
- };
7236
- return {
7237
- type: 'group',
7238
- name: 'storyline-dome-center',
7239
- zIndex: vchart.LayoutZIndex.Mark,
7240
- children: [
7241
- {
7242
- type: 'symbol',
7243
- name: 'storyline-dome-center-symbol',
7244
- interactive: false,
7245
- style: {
7246
- x: (_d, ctx) => {
7247
- const r = getDomeCenterImageRect(spec, ctx);
7248
- return r.x + r.width / 2;
7249
- },
7250
- y: (_d, ctx) => {
7251
- const r = getDomeCenterImageRect(spec, ctx);
7252
- return r.y + r.height / 2;
7253
- },
7254
- size: (_d, ctx) => {
7255
- const r = getDomeCenterImageRect(spec, ctx);
7256
- return Math.max(r.width, r.height) * 1.1;
7257
- },
7258
- symbolType: 'circle',
7259
- fill: symbolGradient,
7260
- stroke: themeColor,
7261
- lineWidth: 2
7262
- }
7263
- },
7264
- {
7265
- type: 'rect',
7266
- name: 'storyline-dome-center-rect',
7267
- interactive: false,
7268
- style: {
7269
- x: (_d, ctx) => getDomeCenterImageRect(spec, ctx).x,
7270
- y: (_d, ctx) => getDomeCenterImageRect(spec, ctx).y,
7271
- width: (_d, ctx) => getDomeCenterImageRect(spec, ctx).width,
7272
- height: (_d, ctx) => getDomeCenterImageRect(spec, ctx).height,
7273
- cornerRadius: 12,
7274
- fill: '#ffffff',
7275
- stroke: themeColor,
7276
- lineWidth: 2
7277
- }
7278
- },
7279
- hasImage
7280
- ? Object.assign(Object.assign({ type: 'image', name: 'storyline-dome-center-image', interactive: false }, spec.centerImage), { style: Object.assign({ x: (_d, ctx) => getDomeCenterImageRect(spec, ctx).x, y: (_d, ctx) => getDomeCenterImageRect(spec, ctx).y, width: (_d, ctx) => getDomeCenterImageRect(spec, ctx).width, height: (_d, ctx) => getDomeCenterImageRect(spec, ctx).height, image: (_c = spec.centerImage) === null || _c === void 0 ? void 0 : _c.image, cornerRadius: 12, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center', anchor: (_d, ctx) => {
7281
- const r = getDomeCenterImageRect(spec, ctx);
7282
- return [r.x + r.width / 2, r.y + r.height / 2];
7283
- }, dx: (_d, ctx) => {
7284
- var _a, _b;
7285
- const r = getDomeCenterImageRect(spec, ctx);
7286
- const userWidth = (_b = (_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.width;
7287
- const w = typeof userWidth === 'number' ? userWidth : r.width;
7288
- return (r.width - w) / 2;
7289
- }, dy: (_d, ctx) => {
7290
- var _a, _b;
7291
- const r = getDomeCenterImageRect(spec, ctx);
7292
- const userHeight = (_b = (_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.height;
7293
- const h = typeof userHeight === 'number' ? userHeight : r.height;
7294
- return (r.height - h) / 2;
7295
- } }, (_e = spec.centerImage) === null || _e === void 0 ? void 0 : _e.style) })
7296
- : null
7297
- ].filter(Boolean)
7298
- };
7299
- };
7300
- const getDomeBlockMetrics = (spec) => {
7301
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
7302
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 14);
7303
- const titleLineHeight = Number((_g = (_f = (_e = spec.title) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.lineHeight) !== null && _g !== void 0 ? _g : Math.max(DOME_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35)));
7304
- const contentFontSize = Number((_k = (_j = (_h = spec.content) === null || _h === void 0 ? void 0 : _h.style) === null || _j === void 0 ? void 0 : _j.fontSize) !== null && _k !== void 0 ? _k : DOME_CONTENT_FONT_SIZE);
7305
- const contentLineHeight = Number((_o = (_m = (_l = spec.content) === null || _l === void 0 ? void 0 : _l.style) === null || _m === void 0 ? void 0 : _m.lineHeight) !== null && _o !== void 0 ? _o : DOME_CONTENT_LINE_HEIGHT);
7306
- const titleToContentGap = DOME_TITLE_TO_CONTENT_GAP;
7307
- const textHeight = DOME_TEXT_BOX_HEIGHT;
7308
- const contentHeight = Math.max(textHeight - titleLineHeight - titleToContentGap, contentLineHeight);
7309
- const imageWidth = (_q = (_p = spec.image) === null || _p === void 0 ? void 0 : _p.width) !== null && _q !== void 0 ? _q : DOME_BLOCK_IMAGE_SIZE;
7310
- const imageHeight = (_s = (_r = spec.image) === null || _r === void 0 ? void 0 : _r.height) !== null && _s !== void 0 ? _s : DOME_BLOCK_IMAGE_SIZE;
7311
- const imageBox = {
7312
- x: -imageWidth / 2,
7313
- y: -imageHeight / 2,
7314
- width: imageWidth,
7315
- height: imageHeight
7316
- };
7317
- const textBox = {
7318
- x: -imageWidth / 2 + DOME_TEXT_LEFT_PADDING,
7319
- y: imageBox.y - DOME_TEXT_GAP_FROM_IMAGE - textHeight,
7320
- width: imageWidth - DOME_TEXT_LEFT_PADDING,
7321
- height: textHeight
7322
- };
7323
- const contentBox = {
7324
- x: textBox.x,
7325
- y: textBox.y + titleLineHeight + titleToContentGap,
7326
- width: textBox.width,
7327
- height: contentHeight
7328
- };
7329
- return {
7330
- titleFontSize,
7331
- titleLineHeight,
7332
- contentFontSize,
7333
- contentLineHeight,
7334
- imageBox,
7335
- textBox,
7336
- contentBox
7337
- };
7338
- };
7339
- const buildDomeBlockMark = (spec, block, index) => {
7340
- var _a, _b, _c, _e;
7341
- const hasImage = !!block.image;
7342
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
7343
- const themeColor = getThemeColor(spec);
7344
- const metrics = getDomeBlockMetrics(spec);
7345
- return {
7346
- type: 'group',
7347
- id: `storyline-block-${(_a = block.id) !== null && _a !== void 0 ? _a : index}`,
7348
- name: `storyline-block-${index}`,
7349
- zIndex: vchart.LayoutZIndex.Mark + 1,
7350
- style: {
7351
- x: (_d, ctx) => getDomeBlockCenter(spec, ctx, index).x,
7352
- y: (_d, ctx) => getDomeBlockCenter(spec, ctx, index).y
7353
- },
7354
- children: [
7355
- {
7356
- type: 'rect',
7357
- name: `storyline-block-connector-${index}`,
7358
- interactive: false,
7359
- style: {
7360
- x: metrics.imageBox.x,
7361
- y: metrics.textBox.y,
7362
- width: 2,
7363
- height: Math.max(metrics.imageBox.y - metrics.textBox.y, 0),
7364
- fill: themeColor,
7365
- fillOpacity: 0.6
7366
- }
7367
- },
7368
- hasImage
7369
- ? Object.assign(Object.assign({ type: 'image', name: `storyline-block-image-${index}`, interactive: false }, omitImageLayoutSpec(spec.image)), { style: Object.assign({ x: metrics.imageBox.x, y: metrics.imageBox.y, width: metrics.imageBox.width, height: metrics.imageBox.height, image: block.image, cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center', stroke: themeColor, lineWidth: 2 }, (_b = spec.image) === null || _b === void 0 ? void 0 : _b.style) })
7370
- : {
7371
- type: 'rect',
7372
- name: `storyline-block-image-bg-${index}`,
7373
- interactive: false,
7374
- style: {
7375
- x: metrics.imageBox.x,
7376
- y: metrics.imageBox.y,
7377
- width: metrics.imageBox.width,
7378
- height: metrics.imageBox.height,
7379
- cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2,
7380
- fill: '#ffffff',
7381
- stroke: themeColor,
7382
- lineWidth: 2
7383
- }
7384
- },
7385
- block.title
7386
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-title-${index}`, interactive: false }, spec.title), { style: Object.assign({ x: metrics.textBox.x, y: metrics.textBox.y, text: block.title, maxLineWidth: metrics.textBox.width, fontSize: metrics.titleFontSize, lineHeight: metrics.titleLineHeight, fontWeight: 'bold', fill: '#1f2430', textAlign: 'left', textBaseline: 'top' }, (_c = spec.title) === null || _c === void 0 ? void 0 : _c.style) })
7387
- : null,
7388
- contentText.length
7389
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-content-${index}`, interactive: false }, spec.content), { textType: 'rich', style: Object.assign({ x: metrics.contentBox.x, y: metrics.contentBox.y, width: metrics.contentBox.width, height: metrics.contentBox.height, maxLineWidth: metrics.contentBox.width, heightLimit: metrics.contentBox.height, text: buildRichContent(contentText, spec), fontSize: DOME_CONTENT_FONT_SIZE, lineHeight: DOME_CONTENT_LINE_HEIGHT, textAlign: 'left', textBaseline: 'top', wordBreak: 'break-word', ellipsis: '...', fill: '#596173' }, (_e = spec.content) === null || _e === void 0 ? void 0 : _e.style) })
7390
- : null
7391
- ].filter(Boolean)
7392
- };
7393
- };
7394
-
7395
- const BOWL_BLOCK_IMAGE_SIZE = 140;
7396
- const BOWL_TEXT_GAP_FROM_IMAGE = 10;
7397
- const BOWL_TITLE_LINE_HEIGHT = 19;
7398
- const BOWL_CONTENT_LINE_HEIGHT = 17;
7399
- const BOWL_CONTENT_FONT_SIZE = 12;
7400
- const BOWL_TEXT_BOX_HEIGHT = 300;
7401
- const BOWL_TITLE_TO_CONTENT_GAP = 4;
7402
- const BOWL_TEXT_LEFT_PADDING = 20;
7403
- const BOWL_CENTER_IMAGE_SIZE_RATIO = 0.4;
7404
- const BOWL_ARC_BOTTOM_GAP_FROM_CENTER_IMAGE = 300;
7405
- const getBowlCenterImageRect = (spec, ctx) => {
7406
- var _a, _b, _c, _e, _f;
7407
- const { width, height, startX, startY } = getRegionGeometry(ctx);
7408
- const padding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
7409
- const innerWidth = Math.max(width - padding.left - padding.right, 1);
7410
- const innerHeight = Math.max(height - padding.top - padding.bottom, 1);
7411
- const baseSize = Math.min(innerWidth, innerHeight) * BOWL_CENTER_IMAGE_SIZE_RATIO;
7412
- const w = Math.max((_c = (_b = spec.centerImage) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : baseSize, 80);
7413
- const h = Math.max((_f = (_e = spec.centerImage) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : baseSize, 80);
7414
- const cx = startX + padding.left + innerWidth / 2;
7415
- const top = startY + padding.top;
7416
- return { x: cx - w / 2, y: top, width: w, height: h };
7417
- };
7418
- const getBowlArcGeometry = (spec, ctx) => {
7419
- var _a, _b, _c, _e;
7420
- const { width, startX } = getRegionGeometry(ctx);
7421
- const blockPadding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
7422
- const innerWidth = Math.max(width - blockPadding.left - blockPadding.right, 1);
7423
- const blockWidth = resolveBlockWidth(spec, width);
7424
- const layoutOpt = normalizeLayout(spec.layout);
7425
- const startAngle = (_b = layoutOpt.startAngle) !== null && _b !== void 0 ? _b : 20;
7426
- const endAngle = (_c = layoutOpt.endAngle) !== null && _c !== void 0 ? _c : 160;
7427
- const ratio = (_e = layoutOpt.radiusRatio) !== null && _e !== void 0 ? _e : 0.88;
7428
- const rx = Math.max((innerWidth - blockWidth) / 2, 1) * ratio;
7429
- const centerRect = getBowlCenterImageRect(spec, ctx);
7430
- const centerTop = centerRect.y;
7431
- const centerBottom = centerRect.y + centerRect.height;
7432
- const sinStart = Math.sin((startAngle / 180) * Math.PI);
7433
- const denom = Math.max(1 - sinStart, 0.05);
7434
- const ry = (centerRect.height + BOWL_ARC_BOTTOM_GAP_FROM_CENTER_IMAGE) / denom;
7435
- const cy = centerTop - ry * sinStart;
7436
- return {
7437
- cx: startX + blockPadding.left + innerWidth / 2,
7438
- cy,
7439
- rx,
7440
- ry,
7441
- startAngle,
7442
- endAngle,
7443
- centerTop,
7444
- centerBottom
7445
- };
7446
- };
7447
- const getBowlBlockCenter = (spec, ctx, index) => {
7448
- var _a, _b, _c, _e;
7449
- const arc = getBowlArcGeometry(spec, ctx);
7450
- const count = (_b = (_a = spec.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
7451
- if (count <= 0) {
7452
- return { x: arc.cx, y: arc.cy };
7453
- }
7454
- const t = count === 1 ? 0.5 : index / (count - 1);
7455
- const angle = ((arc.startAngle + (arc.endAngle - arc.startAngle) * t) / 180) * Math.PI;
7456
- const px = arc.cx + Math.cos(angle) * arc.rx;
7457
- const py = arc.cy + Math.sin(angle) * arc.ry;
7458
- const nxRaw = Math.cos(angle) / arc.rx;
7459
- const nyRaw = Math.sin(angle) / arc.ry;
7460
- const nLen = Math.hypot(nxRaw, nyRaw) || 1;
7461
- const nx = nxRaw / nLen;
7462
- const ny = nyRaw / nLen;
7463
- const imageHeight = (_e = (_c = spec.image) === null || _c === void 0 ? void 0 : _c.height) !== null && _e !== void 0 ? _e : BOWL_BLOCK_IMAGE_SIZE;
7464
- const offset = imageHeight / 2;
7465
- return { x: px + nx * offset, y: py + ny * offset };
7466
- };
7467
- const buildBowlArcMark = (spec) => {
7468
- var _a;
7469
- if (((_a = spec.line) === null || _a === void 0 ? void 0 : _a.visible) !== true) {
7470
- return null;
7471
- }
7472
- const themeColor = getThemeColor(spec);
7473
- return {
7474
- type: 'group',
7475
- name: 'storyline-bowl-arc',
7476
- zIndex: vchart.LayoutZIndex.Mark,
7477
- children: [
7478
- {
7479
- type: 'path',
7480
- name: 'storyline-bowl-arc-path',
7481
- interactive: false,
7482
- style: {
7483
- stroke: themeColor,
7484
- lineWidth: 2,
7485
- lineCap: 'round',
7486
- fill: 'transparent',
7487
- fillOpacity: 0,
7488
- path: (_d, ctx) => {
7489
- const arc = getBowlArcGeometry(spec, ctx);
7490
- const span = arc.endAngle - arc.startAngle;
7491
- const samples = 64;
7492
- const segments = [];
7493
- for (let i = 0; i <= samples; i++) {
7494
- const t = i / samples;
7495
- const angle = ((arc.startAngle + span * t) / 180) * Math.PI;
7496
- const x = arc.cx + Math.cos(angle) * arc.rx;
7497
- const y = arc.cy + Math.sin(angle) * arc.ry;
7498
- segments.push(`${i === 0 ? 'M' : 'L'} ${x.toFixed(2)} ${y.toFixed(2)}`);
7499
- }
7500
- return segments.join(' ');
7501
- }
7502
- }
7503
- }
7504
- ]
7505
- };
7506
- };
7507
- const buildBowlCenterImageMark = (spec) => {
7508
- var _a, _b, _c, _e;
7509
- const visible = ((_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.visible) !== false;
7510
- if (!visible) {
7511
- return null;
7512
- }
7513
- const themeColor = getThemeColor(spec);
7514
- const hasImage = !!((_b = spec.centerImage) === null || _b === void 0 ? void 0 : _b.image);
7515
- const symbolGradient = {
7516
- gradient: 'linear',
7517
- x0: 0.5,
7518
- y0: 0,
7519
- x1: 0.5,
7520
- y1: 1,
7521
- stops: [
7522
- { offset: 0, color: withAlpha(themeColor, 0.15) },
7523
- { offset: 1, color: themeColor }
7524
- ]
7525
- };
7526
- return {
7527
- type: 'group',
7528
- name: 'storyline-bowl-center',
7529
- zIndex: vchart.LayoutZIndex.Mark,
7530
- children: [
7531
- {
7532
- type: 'symbol',
7533
- name: 'storyline-bowl-center-symbol',
7534
- interactive: false,
7535
- style: {
7536
- x: (_d, ctx) => {
7537
- const r = getBowlCenterImageRect(spec, ctx);
7538
- return r.x + r.width / 2;
7539
- },
7540
- y: (_d, ctx) => {
7541
- const r = getBowlCenterImageRect(spec, ctx);
7542
- return r.y + r.height / 2;
7543
- },
7544
- size: (_d, ctx) => {
7545
- const r = getBowlCenterImageRect(spec, ctx);
7546
- return Math.max(r.width, r.height) * 1.1;
7547
- },
7548
- symbolType: 'circle',
7549
- fill: symbolGradient,
7550
- stroke: themeColor,
7551
- lineWidth: 2
7552
- }
7553
- },
7554
- hasImage
7555
- ? Object.assign(Object.assign({ type: 'image', name: 'storyline-bowl-center-image', interactive: false }, spec.centerImage), { style: Object.assign({ x: (_d, ctx) => getBowlCenterImageRect(spec, ctx).x, y: (_d, ctx) => getBowlCenterImageRect(spec, ctx).y, width: (_d, ctx) => getBowlCenterImageRect(spec, ctx).width, height: (_d, ctx) => getBowlCenterImageRect(spec, ctx).height, image: (_c = spec.centerImage) === null || _c === void 0 ? void 0 : _c.image, cornerRadius: 12, repeatX: 'no-repeat', repeatY: 'no-repeat', imagePosition: 'center', anchor: (_d, ctx) => {
7556
- const r = getBowlCenterImageRect(spec, ctx);
7557
- return [r.x + r.width / 2, r.y + r.height / 2];
7558
- }, dx: (_d, ctx) => {
7559
- var _a, _b;
7560
- const r = getBowlCenterImageRect(spec, ctx);
7561
- const userWidth = (_b = (_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.width;
7562
- const w = typeof userWidth === 'number' ? userWidth : r.width;
7563
- return (r.width - w) / 2;
7564
- }, dy: (_d, ctx) => {
7565
- var _a, _b;
7566
- const r = getBowlCenterImageRect(spec, ctx);
7567
- const userHeight = (_b = (_a = spec.centerImage) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.height;
7568
- const h = typeof userHeight === 'number' ? userHeight : r.height;
7569
- return (r.height - h) / 2;
7570
- } }, (_e = spec.centerImage) === null || _e === void 0 ? void 0 : _e.style) })
7571
- : null
7572
- ].filter(Boolean)
7573
- };
7574
- };
7575
- const getBowlBlockMetrics = (spec) => {
7576
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
7577
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 14);
7578
- const titleLineHeight = Number((_g = (_f = (_e = spec.title) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.lineHeight) !== null && _g !== void 0 ? _g : Math.max(BOWL_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35)));
7579
- const contentFontSize = Number((_k = (_j = (_h = spec.content) === null || _h === void 0 ? void 0 : _h.style) === null || _j === void 0 ? void 0 : _j.fontSize) !== null && _k !== void 0 ? _k : BOWL_CONTENT_FONT_SIZE);
7580
- const contentLineHeight = Number((_o = (_m = (_l = spec.content) === null || _l === void 0 ? void 0 : _l.style) === null || _m === void 0 ? void 0 : _m.lineHeight) !== null && _o !== void 0 ? _o : BOWL_CONTENT_LINE_HEIGHT);
7581
- const titleToContentGap = BOWL_TITLE_TO_CONTENT_GAP;
7582
- const textHeight = BOWL_TEXT_BOX_HEIGHT;
7583
- const contentHeight = Math.max(textHeight - titleLineHeight - titleToContentGap, contentLineHeight);
7584
- const imageWidth = (_q = (_p = spec.image) === null || _p === void 0 ? void 0 : _p.width) !== null && _q !== void 0 ? _q : BOWL_BLOCK_IMAGE_SIZE;
7585
- const imageHeight = (_s = (_r = spec.image) === null || _r === void 0 ? void 0 : _r.height) !== null && _s !== void 0 ? _s : BOWL_BLOCK_IMAGE_SIZE;
7586
- const imageBox = {
7587
- x: -imageWidth / 2,
7588
- y: -imageHeight / 2,
7589
- width: imageWidth,
7590
- height: imageHeight
7591
- };
7592
- const textBox = {
7593
- x: -imageWidth / 2 + BOWL_TEXT_LEFT_PADDING,
7594
- y: imageBox.y + imageHeight + BOWL_TEXT_GAP_FROM_IMAGE,
7595
- width: imageWidth - BOWL_TEXT_LEFT_PADDING,
7596
- height: textHeight
7597
- };
7598
- const contentBox = {
7599
- x: textBox.x,
7600
- y: textBox.y + titleLineHeight + titleToContentGap,
7601
- width: textBox.width,
7602
- height: contentHeight
7603
- };
7604
- return {
7605
- titleFontSize,
7606
- titleLineHeight,
7607
- contentFontSize,
7608
- contentLineHeight,
7609
- imageBox,
7610
- textBox,
7611
- contentBox
7612
- };
7613
- };
7614
- const buildBowlBlockMark = (spec, block, index) => {
7615
- var _a, _b, _c, _e;
7616
- const hasImage = !!block.image;
7617
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
7618
- const themeColor = getThemeColor(spec);
7619
- const metrics = getBowlBlockMetrics(spec);
7620
- return {
7621
- type: 'group',
7622
- id: `storyline-block-${(_a = block.id) !== null && _a !== void 0 ? _a : index}`,
7623
- name: `storyline-block-${index}`,
7624
- zIndex: vchart.LayoutZIndex.Mark + 1,
7625
- style: {
7626
- x: (_d, ctx) => getBowlBlockCenter(spec, ctx, index).x,
7627
- y: (_d, ctx) => getBowlBlockCenter(spec, ctx, index).y
7628
- },
7629
- children: [
7630
- {
7631
- type: 'rect',
7632
- name: `storyline-block-connector-${index}`,
7633
- interactive: false,
7634
- style: {
7635
- x: metrics.imageBox.x,
7636
- y: metrics.imageBox.y + metrics.imageBox.height,
7637
- width: 2,
7638
- height: Math.max(metrics.textBox.y + metrics.textBox.height - (metrics.imageBox.y + metrics.imageBox.height), 0),
7639
- fill: themeColor,
7640
- fillOpacity: 0.6
7641
- }
7642
- },
7643
- hasImage
7644
- ? Object.assign(Object.assign({ type: 'image', name: `storyline-block-image-${index}`, interactive: false }, omitImageLayoutSpec(spec.image)), { style: Object.assign({ x: metrics.imageBox.x, y: metrics.imageBox.y, width: metrics.imageBox.width, height: metrics.imageBox.height, image: block.image, cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center', stroke: themeColor, lineWidth: 2 }, (_b = spec.image) === null || _b === void 0 ? void 0 : _b.style) })
7645
- : {
7646
- type: 'rect',
7647
- name: `storyline-block-image-bg-${index}`,
7648
- interactive: false,
7649
- style: {
7650
- x: metrics.imageBox.x,
7651
- y: metrics.imageBox.y,
7652
- width: metrics.imageBox.width,
7653
- height: metrics.imageBox.height,
7654
- cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2,
7655
- fill: '#ffffff',
7656
- stroke: themeColor,
7657
- lineWidth: 2
7658
- }
7659
- },
7660
- block.title
7661
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-title-${index}`, interactive: false }, spec.title), { style: Object.assign({ x: metrics.textBox.x, y: metrics.textBox.y, text: block.title, maxLineWidth: metrics.textBox.width, fontSize: metrics.titleFontSize, lineHeight: metrics.titleLineHeight, fontWeight: 'bold', fill: '#1f2430', textAlign: 'left', textBaseline: 'top' }, (_c = spec.title) === null || _c === void 0 ? void 0 : _c.style) })
7662
- : null,
7663
- contentText.length
7664
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-content-${index}`, interactive: false }, spec.content), { textType: 'rich', style: Object.assign({ x: metrics.contentBox.x, y: metrics.contentBox.y, width: metrics.contentBox.width, height: metrics.contentBox.height, maxLineWidth: metrics.contentBox.width, heightLimit: metrics.contentBox.height, text: buildRichContent(contentText, spec), fontSize: BOWL_CONTENT_FONT_SIZE, lineHeight: BOWL_CONTENT_LINE_HEIGHT, textAlign: 'left', textBaseline: 'top', wordBreak: 'break-word', ellipsis: '...', fill: '#596173' }, (_e = spec.content) === null || _e === void 0 ? void 0 : _e.style) })
7665
- : null
7666
- ].filter(Boolean)
7667
- };
7668
- };
7669
-
7670
- const WING_BLOCK_IMAGE_SIZE = 96;
7671
- const WING_TEXT_GAP_FROM_IMAGE = 14;
7672
- const WING_TITLE_LINE_HEIGHT = 26;
7673
- const WING_TITLE_FONT_SIZE = 20;
7674
- const WING_CONTENT_LINE_HEIGHT = 17;
7675
- const WING_CONTENT_FONT_SIZE = 12;
7676
- const WING_TEXT_BOX_WIDTH = 240;
7677
- const WING_TEXT_BOX_HEIGHT = 110;
7678
- const WING_TITLE_TO_CONTENT_GAP = 4;
7679
- const getWingDirection = (spec) => {
7680
- var _a;
7681
- return (_a = normalizeLayout(spec.layout).direction) !== null && _a !== void 0 ? _a : 'left';
7682
- };
7683
- const getWingArcGeometry = (spec, ctx) => {
7684
- var _a, _b, _c, _e;
7685
- const { width, height, startX, startY } = getRegionGeometry(ctx);
7686
- const padding = normalizePadding((_a = spec.block) === null || _a === void 0 ? void 0 : _a.padding);
7687
- const innerWidth = Math.max(width - padding.left - padding.right, 1);
7688
- const innerHeight = Math.max(height - padding.top - padding.bottom, 1);
7689
- const layoutOpt = normalizeLayout(spec.layout);
7690
- const direction = getWingDirection(spec);
7691
- const defaultStart = direction === 'right' ? 110 : -70;
7692
- const defaultEnd = direction === 'right' ? 250 : 70;
7693
- const startAngle = (_b = layoutOpt.startAngle) !== null && _b !== void 0 ? _b : defaultStart;
7694
- const endAngle = (_c = layoutOpt.endAngle) !== null && _c !== void 0 ? _c : defaultEnd;
7695
- const ratio = (_e = layoutOpt.radiusRatio) !== null && _e !== void 0 ? _e : 0.92;
7696
- const ry = (innerHeight / 2) * ratio;
7697
- const rx = innerWidth * 0.6 * ratio;
7698
- const cx = direction === 'right' ? startX + padding.left + innerWidth - rx * 0.1 : startX + padding.left + rx * 0.1;
7699
- const cy = startY + padding.top + innerHeight / 2;
7700
- return { cx, cy, rx, ry, startAngle, endAngle };
7701
- };
7702
- const getWingBlockCenter = (spec, ctx, index) => {
7703
- var _a, _b;
7704
- const arc = getWingArcGeometry(spec, ctx);
7705
- const count = (_b = (_a = spec.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
7706
- if (count <= 0) {
7707
- return { x: arc.cx, y: arc.cy };
7708
- }
7709
- const t = count === 1 ? 0.5 : index / (count - 1);
7710
- const angle = ((arc.startAngle + (arc.endAngle - arc.startAngle) * t) / 180) * Math.PI;
7711
- return {
7712
- x: arc.cx + Math.cos(angle) * arc.rx,
7713
- y: arc.cy + Math.sin(angle) * arc.ry
7714
- };
7715
- };
7716
- const isTextOnLeft = (spec, index) => {
7717
- const direction = getWingDirection(spec);
7718
- return direction === 'right' ? index % 2 === 1 : index % 2 === 0;
7719
- };
7720
- const buildWingArcMark = (spec) => {
7721
- var _a, _b, _c, _e, _f, _g, _h, _j;
7722
- if (((_a = spec.line) === null || _a === void 0 ? void 0 : _a.visible) === false) {
7723
- return null;
7724
- }
7725
- const themeColor = getThemeColor(spec);
7726
- const lineStyle = ((_c = (_b = spec.line) === null || _b === void 0 ? void 0 : _b.style) !== null && _c !== void 0 ? _c : {});
7727
- const startWidth = Math.max(Number((_e = lineStyle.startWidth) !== null && _e !== void 0 ? _e : 2), 0.5);
7728
- const endWidth = Math.max(Number((_g = (_f = lineStyle.endWidth) !== null && _f !== void 0 ? _f : lineStyle.lineWidth) !== null && _g !== void 0 ? _g : 18), startWidth);
7729
- return {
7730
- type: 'group',
7731
- name: 'storyline-wing-arc',
7732
- zIndex: vchart.LayoutZIndex.Mark,
7733
- children: [
7734
- {
7735
- type: 'path',
7736
- name: 'storyline-wing-arc-path',
7737
- interactive: false,
7738
- style: {
7739
- stroke: false,
7740
- lineWidth: 0,
7741
- fill: (_j = (_h = lineStyle.fill) !== null && _h !== void 0 ? _h : lineStyle.stroke) !== null && _j !== void 0 ? _j : themeColor,
7742
- opacity: 0.95,
7743
- path: (_d, ctx) => {
7744
- const arc = getWingArcGeometry(spec, ctx);
7745
- const span = arc.endAngle - arc.startAngle;
7746
- const samples = 96;
7747
- const pts = [];
7748
- for (let i = 0; i <= samples; i++) {
7749
- const t = i / samples;
7750
- const angle = ((arc.startAngle + span * t) / 180) * Math.PI;
7751
- const cx = arc.cx + Math.cos(angle) * arc.rx;
7752
- const cy = arc.cy + Math.sin(angle) * arc.ry;
7753
- const nxRaw = Math.cos(angle) / arc.rx;
7754
- const nyRaw = Math.sin(angle) / arc.ry;
7755
- const nLen = Math.hypot(nxRaw, nyRaw) || 1;
7756
- pts.push({
7757
- x: cx,
7758
- y: cy,
7759
- nx: nxRaw / nLen,
7760
- ny: nyRaw / nLen,
7761
- w: startWidth + (endWidth - startWidth) * t
7762
- });
7763
- }
7764
- const segments = [];
7765
- for (let i = 0; i < pts.length; i++) {
7766
- const p = pts[i];
7767
- const x = p.x + p.nx * (p.w / 2);
7768
- const y = p.y + p.ny * (p.w / 2);
7769
- segments.push(`${i === 0 ? 'M' : 'L'} ${x.toFixed(2)} ${y.toFixed(2)}`);
7770
- }
7771
- for (let i = pts.length - 1; i >= 0; i--) {
7772
- const p = pts[i];
7773
- const x = p.x - p.nx * (p.w / 2);
7774
- const y = p.y - p.ny * (p.w / 2);
7775
- segments.push(`L ${x.toFixed(2)} ${y.toFixed(2)}`);
7776
- }
7777
- segments.push('Z');
7778
- return segments.join(' ');
7779
- }
7780
- }
7781
- }
7782
- ]
7783
- };
7784
- };
7785
- const getWingBlockMetrics = (spec, index) => {
7786
- var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
7787
- const titleFontSize = Number((_c = (_b = (_a = spec.title) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : WING_TITLE_FONT_SIZE);
7788
- const titleLineHeight = Number((_g = (_f = (_e = spec.title) === null || _e === void 0 ? void 0 : _e.style) === null || _f === void 0 ? void 0 : _f.lineHeight) !== null && _g !== void 0 ? _g : Math.max(WING_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.3)));
7789
- const contentFontSize = Number((_k = (_j = (_h = spec.content) === null || _h === void 0 ? void 0 : _h.style) === null || _j === void 0 ? void 0 : _j.fontSize) !== null && _k !== void 0 ? _k : WING_CONTENT_FONT_SIZE);
7790
- const contentLineHeight = Number((_o = (_m = (_l = spec.content) === null || _l === void 0 ? void 0 : _l.style) === null || _m === void 0 ? void 0 : _m.lineHeight) !== null && _o !== void 0 ? _o : WING_CONTENT_LINE_HEIGHT);
7791
- const titleToContentGap = WING_TITLE_TO_CONTENT_GAP;
7792
- const textHeight = WING_TEXT_BOX_HEIGHT;
7793
- const contentHeight = Math.max(textHeight - titleLineHeight - titleToContentGap, contentLineHeight);
7794
- const imageWidth = (_q = (_p = spec.image) === null || _p === void 0 ? void 0 : _p.width) !== null && _q !== void 0 ? _q : WING_BLOCK_IMAGE_SIZE;
7795
- const imageHeight = (_s = (_r = spec.image) === null || _r === void 0 ? void 0 : _r.height) !== null && _s !== void 0 ? _s : WING_BLOCK_IMAGE_SIZE;
7796
- const imageBox = {
7797
- x: -imageWidth / 2,
7798
- y: -imageHeight / 2,
7799
- width: imageWidth,
7800
- height: imageHeight
7801
- };
7802
- const onLeft = isTextOnLeft(spec, index);
7803
- const textWidth = WING_TEXT_BOX_WIDTH;
7804
- const textX = onLeft
7805
- ? -imageWidth / 2 - WING_TEXT_GAP_FROM_IMAGE - textWidth
7806
- : imageWidth / 2 + WING_TEXT_GAP_FROM_IMAGE;
7807
- const textY = -textHeight / 2;
7808
- const textBox = { x: textX, y: textY, width: textWidth, height: textHeight };
7809
- const contentBox = {
7810
- x: textX,
7811
- y: textY + titleLineHeight + titleToContentGap,
7812
- width: textWidth,
7813
- height: contentHeight
7814
- };
7815
- return {
7816
- onLeft,
7817
- titleFontSize,
7818
- titleLineHeight,
7819
- contentFontSize,
7820
- contentLineHeight,
7821
- imageBox,
7822
- textBox,
7823
- contentBox
7824
- };
7825
- };
7826
- const buildWingBlockMark = (spec, block, index) => {
7827
- var _a, _b, _c, _e;
7828
- const hasImage = !!block.image;
7829
- const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];
7830
- const themeColor = getThemeColor(spec);
7831
- const metrics = getWingBlockMetrics(spec, index);
7832
- return {
7833
- type: 'group',
7834
- id: `storyline-block-${(_a = block.id) !== null && _a !== void 0 ? _a : index}`,
7835
- name: `storyline-block-${index}`,
7836
- zIndex: vchart.LayoutZIndex.Mark + 1,
7837
- style: {
7838
- x: (_d, ctx) => getWingBlockCenter(spec, ctx, index).x,
7839
- y: (_d, ctx) => getWingBlockCenter(spec, ctx, index).y
7840
- },
7841
- children: [
7842
- {
7843
- type: 'symbol',
7844
- name: `storyline-block-image-halo-${index}`,
7845
- interactive: false,
7846
- style: {
7847
- x: 0,
7848
- y: 0,
7849
- size: Math.max(metrics.imageBox.width, metrics.imageBox.height) + 12,
7850
- symbolType: 'circle',
7851
- fill: withAlpha(themeColor, 0.18),
7852
- stroke: themeColor,
7853
- lineWidth: 1.5
7854
- }
7855
- },
7856
- hasImage
7857
- ? Object.assign(Object.assign({ type: 'image', name: `storyline-block-image-${index}`, interactive: false }, omitImageLayoutSpec(spec.image)), { style: Object.assign({ x: metrics.imageBox.x, y: metrics.imageBox.y, width: metrics.imageBox.width, height: metrics.imageBox.height, image: block.image, cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2, repeatX: 'no-repeat', repeatY: 'no-repeat', imageMode: 'cover', imagePosition: 'center', stroke: '#ffffff', lineWidth: 3 }, (_b = spec.image) === null || _b === void 0 ? void 0 : _b.style) })
7858
- : {
7859
- type: 'rect',
7860
- name: `storyline-block-image-bg-${index}`,
7861
- interactive: false,
7862
- style: {
7863
- x: metrics.imageBox.x,
7864
- y: metrics.imageBox.y,
7865
- width: metrics.imageBox.width,
7866
- height: metrics.imageBox.height,
7867
- cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2,
7868
- fill: '#ffffff',
7869
- stroke: themeColor,
7870
- lineWidth: 2
7871
- }
7872
- },
7873
- block.title
7874
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-title-${index}`, interactive: false, zIndex: vchart.LayoutZIndex.Mark + 10 }, spec.title), { style: Object.assign({ x: metrics.onLeft ? metrics.textBox.x + metrics.textBox.width : metrics.textBox.x, y: metrics.textBox.y, text: block.title, maxLineWidth: metrics.textBox.width, fontSize: metrics.titleFontSize, lineHeight: metrics.titleLineHeight, fontWeight: 'bold', fill: themeColor, textAlign: metrics.onLeft ? 'right' : 'left', textBaseline: 'top' }, (_c = spec.title) === null || _c === void 0 ? void 0 : _c.style) })
7875
- : null,
7876
- contentText.length
7877
- ? Object.assign(Object.assign({ type: 'text', name: `storyline-block-content-${index}`, interactive: false, zIndex: vchart.LayoutZIndex.Mark + 10 }, spec.content), { textType: 'rich', style: Object.assign({ x: metrics.onLeft ? metrics.contentBox.x + metrics.contentBox.width : metrics.contentBox.x, y: metrics.contentBox.y, width: metrics.contentBox.width, height: metrics.contentBox.height, maxLineWidth: metrics.contentBox.width, heightLimit: metrics.contentBox.height, text: buildRichContent(contentText, spec), fontSize: WING_CONTENT_FONT_SIZE, lineHeight: WING_CONTENT_LINE_HEIGHT, textAlign: metrics.onLeft ? 'right' : 'left', textBaseline: 'top', wordBreak: 'break-word', ellipsis: '...', fill: '#1f2430' }, (_e = spec.content) === null || _e === void 0 ? void 0 : _e.style) })
7878
- : null
7879
- ].filter(Boolean)
7880
- };
7881
- };
7882
-
7883
- class StorylineChartSpecTransformer extends vchart.CommonChartSpecTransformer {
7884
- transformSpec(spec) {
7885
- var _a;
7886
- applyDefaultPadding(spec);
7887
- const storylineSpec = Object.assign(Object.assign({}, spec), { data: [...((_a = spec.data) !== null && _a !== void 0 ? _a : [])] });
7888
- spec.type = 'common';
7889
- spec.data = [];
7890
- spec.series = [];
7891
- spec.axes = [];
7892
- spec.customMark = buildStorylineMarks(storylineSpec);
7893
- delete spec.layout;
7894
- delete spec.title;
7895
- super.transformSpec(spec);
7896
- }
7897
- }
7898
- const applyDefaultPadding = (spec) => {
7899
- var _a, _b, _c, _d;
7900
- const LARGE = 100;
7901
- const SMALL = 20;
7902
- const bowl = isBowl(spec);
7903
- const defaultTop = bowl ? LARGE : SMALL;
7904
- const defaultBottom = bowl ? SMALL : LARGE;
7905
- const p = spec.padding;
7906
- if (p === undefined || p === null) {
7907
- spec.padding = [defaultTop, SMALL, defaultBottom, SMALL];
7908
- return;
7909
- }
7910
- if (typeof p === 'number') {
7911
- spec.padding = bowl ? [Math.max(p, LARGE), p, p, p] : [p, p, Math.max(p, LARGE), p];
7912
- return;
7913
- }
7914
- if (Array.isArray(p)) {
7915
- const [t, r = SMALL, b, l = SMALL] = p;
7916
- spec.padding = [t !== null && t !== void 0 ? t : defaultTop, r, b !== null && b !== void 0 ? b : defaultBottom, l];
7917
- return;
7918
- }
7919
- if (typeof p === 'object') {
7920
- spec.padding = {
7921
- top: (_a = p.top) !== null && _a !== void 0 ? _a : defaultTop,
7922
- right: (_b = p.right) !== null && _b !== void 0 ? _b : SMALL,
7923
- bottom: (_c = p.bottom) !== null && _c !== void 0 ? _c : defaultBottom,
7924
- left: (_d = p.left) !== null && _d !== void 0 ? _d : SMALL
7925
- };
7926
- }
7927
- };
7928
- const buildStorylineMarks = (spec) => {
7929
- var _a;
7930
- const lineMark = buildLineMark(spec);
7931
- const blockMarks = ((_a = spec.data) !== null && _a !== void 0 ? _a : []).map((block, index) => buildBlockMark(spec, block, index));
7932
- if (isLandscape(spec)) {
7933
- return [...blockMarks, lineMark].filter(Boolean);
7934
- }
7935
- if (isPortrait(spec)) {
7936
- return [lineMark, ...blockMarks].filter(Boolean);
7937
- }
7938
- if (isDome(spec)) {
7939
- const centerImageMark = buildDomeCenterImageMark(spec);
7940
- const arcMark = buildDomeArcMark(spec);
7941
- return [centerImageMark, arcMark, ...blockMarks].filter(Boolean);
7942
- }
7943
- if (isBowl(spec)) {
7944
- const centerImageMark = buildBowlCenterImageMark(spec);
7945
- const arcMark = buildBowlArcMark(spec);
7946
- return [centerImageMark, arcMark, ...blockMarks].filter(Boolean);
7947
- }
7948
- if (isClock(spec)) {
7949
- const ringsMark = buildClockArcMark(spec);
7950
- const centerImageMark = buildClockCenterImageMark(spec);
7951
- return [ringsMark, ...blockMarks, centerImageMark].filter(Boolean);
7952
- }
7953
- if (isWing(spec)) {
7954
- const arcMark = buildWingArcMark(spec);
7955
- return [arcMark, ...blockMarks].filter(Boolean);
7956
- }
7957
- return [lineMark, ...blockMarks].filter(Boolean);
7958
- };
7959
- const buildLineMark = (spec) => {
7960
- var _a, _b, _c;
7961
- if (((_a = spec.line) === null || _a === void 0 ? void 0 : _a.visible) === false || ((_c = (_b = spec.data) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) <= 1) {
7962
- return null;
7963
- }
7964
- if (isLandscape(spec)) {
7965
- return buildLandscapeConnectingCurve(spec);
7966
- }
7967
- if (isPortrait(spec)) {
7968
- return buildPortraitAxisMark(spec);
7969
- }
7970
- return buildDefaultLineMark(spec);
7971
- };
7972
- const buildBlockMark = (spec, block, index) => {
7973
- if (isLandscape(spec)) {
7974
- return buildLandscapeBlockMark(spec, block, index);
7975
- }
7976
- if (isPortrait(spec)) {
7977
- return buildPortraitBlockMark(spec, block, index);
7978
- }
7979
- if (isDome(spec)) {
7980
- return buildDomeBlockMark(spec, block, index);
7981
- }
7982
- if (isBowl(spec)) {
7983
- return buildBowlBlockMark(spec, block, index);
7984
- }
7985
- if (isClock(spec)) {
7986
- return buildClockBlockMark(spec, block, index);
7987
- }
7988
- if (isWing(spec)) {
7989
- return buildWingBlockMark(spec, block, index);
7990
- }
7991
- return buildDefaultBlockMark(spec, block, index);
7992
- };
7993
-
7994
- class StorylineChart extends vchart.BaseChart {
7995
- constructor() {
7996
- super(...arguments);
7997
- this.type = 'storyline';
7998
- this.transformerConstructor = StorylineChartSpecTransformer;
7999
- }
8000
- init() {
8001
- if (!this.isValid()) {
8002
- return;
8003
- }
8004
- super.init();
8005
- }
8006
- isValid() {
8007
- var _a, _b;
8008
- const { data } = this._spec;
8009
- if (!Array.isArray(data)) {
8010
- (_b = (_a = this._option).onError) === null || _b === void 0 ? void 0 : _b.call(_a, 'Data is required and should be an array for storyline chart');
8011
- return false;
8012
- }
8013
- return true;
8014
- }
8015
- }
8016
- StorylineChart.type = 'storyline';
8017
- StorylineChart.view = 'singleDefault';
8018
- StorylineChart.transformerConstructor = StorylineChartSpecTransformer;
8019
- const registerStorylineChart = (option) => {
8020
- vchart.registerCommonChart();
8021
- vchart.registerCustomMark();
8022
- vchart.registerGroupMark();
8023
- vchart.registerRectMark();
8024
- vchart.registerTextMark();
8025
- vchart.registerImageMark();
8026
- vchart.registerLineMark();
8027
- vchart.registerPathMark();
8028
- vchart.registerArcMark();
8029
- const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
8030
- if (vchartConstructor) {
8031
- vchartConstructor.useChart([StorylineChart]);
8032
- }
8033
- };
8034
-
8035
5825
  const SERIES_BREAK = 'seriesBreak';
8036
5826
 
8037
5827
  function generateZigzagPath(start, end, size, angle, isVertical = false) {
@@ -10171,8 +7961,6 @@
10171
7961
  exports.SequenceScatterPixel = SequenceScatterPixel;
10172
7962
  exports.SeriesBreakComponent = SeriesBreakComponent;
10173
7963
  exports.SeriesLabelComponent = SeriesLabelComponent;
10174
- exports.StorylineChart = StorylineChart;
10175
- exports.StorylineChartSpecTransformer = StorylineChartSpecTransformer;
10176
7964
  exports.TimelineChart = TimelineChart;
10177
7965
  exports.WordCloud3dChart = WordCloud3dChart;
10178
7966
  exports.WordCloud3dChartSpecTransformer = WordCloud3dChartSpecTransformer;
@@ -10184,7 +7972,6 @@
10184
7972
  exports.appendSeriesBreakConfig = appendSeriesBreakConfig;
10185
7973
  exports.appendSeriesLabelConfig = appendSeriesLabelConfig;
10186
7974
  exports.clearSVGSource = clearSVGSource;
10187
- exports.computeStorylineLayout = computeStorylineLayout;
10188
7975
  exports.getBarLinkConfig = getBarLinkConfig;
10189
7976
  exports.getBarRegressionLineConfig = getBarRegressionLineConfig;
10190
7977
  exports.getHistogramRegressionLineConfig = getHistogramRegressionLineConfig;
@@ -10192,8 +7979,6 @@
10192
7979
  exports.getScatterRegressionLineConfig = getScatterRegressionLineConfig;
10193
7980
  exports.getSeriesBreakConfig = getSeriesBreakConfig;
10194
7981
  exports.getSeriesLabelConfig = getSeriesLabelConfig;
10195
- exports.normalizeLayout = normalizeLayout;
10196
- exports.normalizePadding = normalizePadding;
10197
7982
  exports.register3DPlugin = register3DPlugin;
10198
7983
  exports.registerAxis3dPlugin = registerAxis3dPlugin;
10199
7984
  exports.registerBar3dChart = registerBar3dChart;
@@ -10225,7 +8010,6 @@
10225
8010
  exports.registerSequenceScatterPixel = registerSequenceScatterPixel;
10226
8011
  exports.registerSeriesBreak = registerSeriesBreak;
10227
8012
  exports.registerSeriesLabel = registerSeriesLabel;
10228
- exports.registerStorylineChart = registerStorylineChart;
10229
8013
  exports.registerTimelineChart = registerTimelineChart;
10230
8014
  exports.registerWordCloud3dChart = registerWordCloud3dChart;
10231
8015
  exports.registerWordCloud3dSeries = registerWordCloud3dSeries;