@visactor/vchart-extension 2.1.0-alpha.13 → 2.1.0-alpha.15

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 (81) hide show
  1. package/build/index.js +1960 -0
  2. package/build/index.min.js +2 -2
  3. package/cjs/charts/storyline/index.d.ts +4 -0
  4. package/cjs/charts/storyline/index.js +22 -0
  5. package/cjs/charts/storyline/index.js.map +1 -0
  6. package/cjs/charts/storyline/interface.d.ts +59 -0
  7. package/cjs/charts/storyline/interface.js +6 -0
  8. package/cjs/charts/storyline/interface.js.map +1 -0
  9. package/cjs/charts/storyline/layout.d.ts +53 -0
  10. package/cjs/charts/storyline/layout.js +215 -0
  11. package/cjs/charts/storyline/layout.js.map +1 -0
  12. package/cjs/charts/storyline/layouts/bowl.d.ts +5 -0
  13. package/cjs/charts/storyline/layouts/bowl.js +286 -0
  14. package/cjs/charts/storyline/layouts/bowl.js.map +1 -0
  15. package/cjs/charts/storyline/layouts/clock.d.ts +5 -0
  16. package/cjs/charts/storyline/layouts/clock.js +233 -0
  17. package/cjs/charts/storyline/layouts/clock.js.map +1 -0
  18. package/cjs/charts/storyline/layouts/common.d.ts +87 -0
  19. package/cjs/charts/storyline/layouts/common.js +287 -0
  20. package/cjs/charts/storyline/layouts/common.js.map +1 -0
  21. package/cjs/charts/storyline/layouts/default.d.ts +4 -0
  22. package/cjs/charts/storyline/layouts/default.js +179 -0
  23. package/cjs/charts/storyline/layouts/default.js.map +1 -0
  24. package/cjs/charts/storyline/layouts/dome.d.ts +5 -0
  25. package/cjs/charts/storyline/layouts/dome.js +286 -0
  26. package/cjs/charts/storyline/layouts/dome.js.map +1 -0
  27. package/cjs/charts/storyline/layouts/landscape.d.ts +4 -0
  28. package/cjs/charts/storyline/layouts/landscape.js +254 -0
  29. package/cjs/charts/storyline/layouts/landscape.js.map +1 -0
  30. package/cjs/charts/storyline/layouts/portrait.d.ts +4 -0
  31. package/cjs/charts/storyline/layouts/portrait.js +241 -0
  32. package/cjs/charts/storyline/layouts/portrait.js.map +1 -0
  33. package/cjs/charts/storyline/storyline-transformer.d.ts +4 -0
  34. package/cjs/charts/storyline/storyline-transformer.js +62 -0
  35. package/cjs/charts/storyline/storyline-transformer.js.map +1 -0
  36. package/cjs/charts/storyline/storyline.d.ts +16 -0
  37. package/cjs/charts/storyline/storyline.js +36 -0
  38. package/cjs/charts/storyline/storyline.js.map +1 -0
  39. package/cjs/index.d.ts +1 -0
  40. package/cjs/index.js +5 -5
  41. package/cjs/index.js.map +1 -1
  42. package/esm/charts/storyline/index.d.ts +4 -0
  43. package/esm/charts/storyline/index.js +8 -0
  44. package/esm/charts/storyline/index.js.map +1 -0
  45. package/esm/charts/storyline/interface.d.ts +59 -0
  46. package/esm/charts/storyline/interface.js +2 -0
  47. package/esm/charts/storyline/interface.js.map +1 -0
  48. package/esm/charts/storyline/layout.d.ts +53 -0
  49. package/esm/charts/storyline/layout.js +205 -0
  50. package/esm/charts/storyline/layout.js.map +1 -0
  51. package/esm/charts/storyline/layouts/bowl.d.ts +5 -0
  52. package/esm/charts/storyline/layouts/bowl.js +278 -0
  53. package/esm/charts/storyline/layouts/bowl.js.map +1 -0
  54. package/esm/charts/storyline/layouts/clock.d.ts +5 -0
  55. package/esm/charts/storyline/layouts/clock.js +227 -0
  56. package/esm/charts/storyline/layouts/clock.js.map +1 -0
  57. package/esm/charts/storyline/layouts/common.d.ts +87 -0
  58. package/esm/charts/storyline/layouts/common.js +255 -0
  59. package/esm/charts/storyline/layouts/common.js.map +1 -0
  60. package/esm/charts/storyline/layouts/default.d.ts +4 -0
  61. package/esm/charts/storyline/layouts/default.js +172 -0
  62. package/esm/charts/storyline/layouts/default.js.map +1 -0
  63. package/esm/charts/storyline/layouts/dome.d.ts +5 -0
  64. package/esm/charts/storyline/layouts/dome.js +278 -0
  65. package/esm/charts/storyline/layouts/dome.js.map +1 -0
  66. package/esm/charts/storyline/layouts/landscape.d.ts +4 -0
  67. package/esm/charts/storyline/layouts/landscape.js +250 -0
  68. package/esm/charts/storyline/layouts/landscape.js.map +1 -0
  69. package/esm/charts/storyline/layouts/portrait.d.ts +4 -0
  70. package/esm/charts/storyline/layouts/portrait.js +238 -0
  71. package/esm/charts/storyline/layouts/portrait.js.map +1 -0
  72. package/esm/charts/storyline/storyline-transformer.d.ts +4 -0
  73. package/esm/charts/storyline/storyline-transformer.js +61 -0
  74. package/esm/charts/storyline/storyline-transformer.js.map +1 -0
  75. package/esm/charts/storyline/storyline.d.ts +16 -0
  76. package/esm/charts/storyline/storyline.js +29 -0
  77. package/esm/charts/storyline/storyline.js.map +1 -0
  78. package/esm/index.d.ts +1 -0
  79. package/esm/index.js +2 -0
  80. package/esm/index.js.map +1 -1
  81. package/package.json +8 -8
@@ -0,0 +1,87 @@
1
+ import type { ICustomMarkSpec } from '@visactor/vchart';
2
+ import type { IStorylineBlock, IStorylineSpec, StorylineImagePosition } from '../interface';
3
+ import { normalizeLayout, normalizePadding, type StorylineLayoutResult, type StorylinePoint } from '../layout';
4
+ export type LayoutContext = {
5
+ chart?: {
6
+ getAllRegions?: () => {
7
+ getLayoutRect?: () => {
8
+ width?: number;
9
+ height?: number;
10
+ };
11
+ getLayoutStartPoint?: () => {
12
+ x?: number;
13
+ y?: number;
14
+ };
15
+ }[];
16
+ getLayoutRect?: () => {
17
+ width?: number;
18
+ height?: number;
19
+ };
20
+ };
21
+ getLayoutBounds?: () => {
22
+ width?: () => number;
23
+ height?: () => number;
24
+ };
25
+ };
26
+ export declare const DEFAULT_BLOCK_WIDTH = 180;
27
+ export declare const DEFAULT_BLOCK_HEIGHT = 112;
28
+ export declare const DEFAULT_BLOCK_WIDTH_RATIO = 0.24;
29
+ export declare const DEFAULT_BLOCK_GAP = 36;
30
+ export declare const DEFAULT_IMAGE_WIDTH = 48;
31
+ export declare const DEFAULT_IMAGE_HEIGHT = 48;
32
+ export declare const DEFAULT_IMAGE_GAP = 10;
33
+ export declare const DEFAULT_THEME_COLOR = "#e8543d";
34
+ export declare const isLandscape: (spec: IStorylineSpec) => boolean;
35
+ export declare const isPortrait: (spec: IStorylineSpec) => boolean;
36
+ export declare const isClock: (spec: IStorylineSpec) => boolean;
37
+ export declare const isDome: (spec: IStorylineSpec) => boolean;
38
+ export declare const isBowl: (spec: IStorylineSpec) => boolean;
39
+ export declare const getThemeColor: (spec: IStorylineSpec) => string;
40
+ export declare const withAlpha: (color: string, alpha: number) => string;
41
+ export declare const resolveBlockWidth: (spec: IStorylineSpec, viewWidth: number) => number;
42
+ export declare const getRegionGeometry: (ctx: LayoutContext) => {
43
+ width: number;
44
+ height: number;
45
+ startX: number;
46
+ startY: number;
47
+ };
48
+ export declare const getLayout: (spec: IStorylineSpec, ctx: LayoutContext) => StorylineLayoutResult;
49
+ export declare const buildRichContent: (contentText: string[], spec: IStorylineSpec) => {
50
+ type: "rich";
51
+ text: {
52
+ text: string;
53
+ fontSize: number;
54
+ lineHeight: number;
55
+ fill: string;
56
+ }[];
57
+ };
58
+ export declare const omitImageLayoutSpec: (imageSpec: IStorylineSpec['image']) => {
59
+ id?: import("@visactor/vchart").StringOrNumber;
60
+ interactive?: boolean;
61
+ zIndex?: number;
62
+ visible?: boolean;
63
+ style?: import("@visactor/vchart").ConvertToMarkStyleSpec<import("@visactor/vchart").IImageMarkSpec>;
64
+ state?: import("@visactor/vchart").IMarkStateFullSpec<import("@visactor/vchart").IImageMarkSpec>;
65
+ stateSort?: (stateA: string, stateB: string) => number;
66
+ support3d?: boolean;
67
+ customShape?: (datum: any[], attrs: any, path: import("@visactor/vrender-core").ICustomPath2D) => import("@visactor/vrender-core").ICustomPath2D;
68
+ large?: boolean;
69
+ largeThreshold?: number;
70
+ progressiveStep?: number;
71
+ progressiveThreshold?: number;
72
+ };
73
+ export declare const getImageBox: (position: StorylineImagePosition, blockWidth: number, blockHeight: number, padding: ReturnType<typeof normalizePadding>, width: number, height: number, _gap: number, visible: boolean) => {
74
+ x: number;
75
+ y: number;
76
+ width: number;
77
+ height: number;
78
+ };
79
+ export declare const getTextBox: (position: StorylineImagePosition, blockWidth: number, blockHeight: number, padding: ReturnType<typeof normalizePadding>, imageWidth: number, imageHeight: number, imageGap: number, hasImage: boolean) => {
80
+ x: number;
81
+ y: number;
82
+ width: number;
83
+ height: number;
84
+ };
85
+ export declare const buildSmoothCurvePath: (points: StorylinePoint[]) => string;
86
+ export { normalizeLayout, normalizePadding };
87
+ export type { IStorylineBlock, ICustomMarkSpec, StorylinePoint };
@@ -0,0 +1,255 @@
1
+ var __rest = this && this.__rest || function(s, e) {
2
+ var t = {};
3
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
4
+ if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
5
+ var i = 0;
6
+ for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
7
+ }
8
+ return t;
9
+ };
10
+
11
+ import { computeStorylineLayout, normalizeLayout, normalizePadding } from "../layout";
12
+
13
+ export const DEFAULT_BLOCK_WIDTH = 180;
14
+
15
+ export const DEFAULT_BLOCK_HEIGHT = 112;
16
+
17
+ export const DEFAULT_BLOCK_WIDTH_RATIO = .24;
18
+
19
+ export const DEFAULT_BLOCK_GAP = 36;
20
+
21
+ export const DEFAULT_IMAGE_WIDTH = 48;
22
+
23
+ export const DEFAULT_IMAGE_HEIGHT = 48;
24
+
25
+ export const DEFAULT_IMAGE_GAP = 10;
26
+
27
+ export const DEFAULT_THEME_COLOR = "#e8543d";
28
+
29
+ export const isLandscape = spec => "landscape" === normalizeLayout(spec.layout).type;
30
+
31
+ export const isPortrait = spec => "portrait" === normalizeLayout(spec.layout).type;
32
+
33
+ export const isClock = spec => "clock" === normalizeLayout(spec.layout).type;
34
+
35
+ export const isDome = spec => "dome" === normalizeLayout(spec.layout).type;
36
+
37
+ export const isBowl = spec => "bowl" === normalizeLayout(spec.layout).type;
38
+
39
+ export const getThemeColor = spec => {
40
+ var _a;
41
+ return null !== (_a = spec.themeColor) && void 0 !== _a ? _a : "#e8543d";
42
+ };
43
+
44
+ export const withAlpha = (color, alpha) => {
45
+ const safeAlpha = Math.max(0, Math.min(1, alpha));
46
+ if (!color) return `rgba(0, 0, 0, ${safeAlpha})`;
47
+ const trimmed = color.trim();
48
+ if (trimmed.startsWith("#")) {
49
+ let hex = trimmed.slice(1);
50
+ if (3 !== hex.length && 4 !== hex.length || (hex = hex.split("").map((ch => ch + ch)).join("")),
51
+ 6 === hex.length || 8 === hex.length) {
52
+ return `rgba(${parseInt(hex.slice(0, 2), 16)}, ${parseInt(hex.slice(2, 4), 16)}, ${parseInt(hex.slice(4, 6), 16)}, ${safeAlpha})`;
53
+ }
54
+ }
55
+ const rgbMatch = trimmed.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
56
+ return rgbMatch ? `rgba(${rgbMatch[1]}, ${rgbMatch[2]}, ${rgbMatch[3]}, ${safeAlpha})` : trimmed;
57
+ };
58
+
59
+ export const resolveBlockWidth = (spec, viewWidth) => {
60
+ var _a, _b, _c, _d, _e, _f, _g;
61
+ if (null === (_a = spec.block) || void 0 === _a ? void 0 : _a.width) return spec.block.width;
62
+ const ratio = null !== (_c = null === (_b = spec.block) || void 0 === _b ? void 0 : _b.widthRatio) && void 0 !== _c ? _c : .24, minWidth = null !== (_e = null === (_d = spec.block) || void 0 === _d ? void 0 : _d.minWidth) && void 0 !== _e ? _e : 180, maxWidth = null !== (_g = null === (_f = spec.block) || void 0 === _f ? void 0 : _f.maxWidth) && void 0 !== _g ? _g : Math.max(minWidth, 320);
63
+ return Math.max(minWidth, Math.min(maxWidth, Math.round(viewWidth * ratio)));
64
+ };
65
+
66
+ export const getRegionGeometry = ctx => {
67
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
68
+ const region = null === (_c = null === (_b = null === (_a = ctx.chart) || void 0 === _a ? void 0 : _a.getAllRegions) || void 0 === _b ? void 0 : _b.call(_a)) || void 0 === _c ? void 0 : _c[0], regionRect = null === (_d = null == region ? void 0 : region.getLayoutRect) || void 0 === _d ? void 0 : _d.call(region), regionStart = null === (_e = null == region ? void 0 : region.getLayoutStartPoint) || void 0 === _e ? void 0 : _e.call(region), chartRect = null === (_g = null === (_f = ctx.chart) || void 0 === _f ? void 0 : _f.getLayoutRect) || void 0 === _g ? void 0 : _g.call(_f), bounds = null === (_h = ctx.getLayoutBounds) || void 0 === _h ? void 0 : _h.call(ctx);
69
+ return {
70
+ width: Math.max(null !== (_m = null !== (_k = null !== (_j = null == regionRect ? void 0 : regionRect.width) && void 0 !== _j ? _j : null == chartRect ? void 0 : chartRect.width) && void 0 !== _k ? _k : null === (_l = null == bounds ? void 0 : bounds.width) || void 0 === _l ? void 0 : _l.call(bounds)) && void 0 !== _m ? _m : 0, 1),
71
+ height: Math.max(null !== (_r = null !== (_p = null !== (_o = null == regionRect ? void 0 : regionRect.height) && void 0 !== _o ? _o : null == chartRect ? void 0 : chartRect.height) && void 0 !== _p ? _p : null === (_q = null == bounds ? void 0 : bounds.height) || void 0 === _q ? void 0 : _q.call(bounds)) && void 0 !== _r ? _r : 0, 1),
72
+ startX: null !== (_s = null == regionStart ? void 0 : regionStart.x) && void 0 !== _s ? _s : 0,
73
+ startY: null !== (_t = null == regionStart ? void 0 : regionStart.y) && void 0 !== _t ? _t : 0
74
+ };
75
+ };
76
+
77
+ export const getLayout = (spec, ctx) => {
78
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
79
+ const {width: width, height: height, startX: startX, startY: startY} = getRegionGeometry(ctx);
80
+ let blockWidth = resolveBlockWidth(spec, width), blockHeight = null !== (_b = null === (_a = spec.block) || void 0 === _a ? void 0 : _a.height) && void 0 !== _b ? _b : 112;
81
+ if (isLandscape(spec) && !(null === (_c = spec.block) || void 0 === _c ? void 0 : _c.width)) {
82
+ const count = null !== (_e = null === (_d = spec.data) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : 0;
83
+ if (count > 0) {
84
+ const padding = normalizePadding(null === (_f = spec.block) || void 0 === _f ? void 0 : _f.padding), LANDSCAPE_IMAGE_MIN_WIDTH = 80, adaptive = (Math.max(width - padding.left - padding.right, 1) - 40 * Math.max(count - 1, 0)) / count;
85
+ blockWidth = Math.max(LANDSCAPE_IMAGE_MIN_WIDTH, Math.floor(adaptive));
86
+ }
87
+ }
88
+ if (isPortrait(spec) && !(null === (_g = spec.block) || void 0 === _g ? void 0 : _g.height)) {
89
+ const count = null !== (_j = null === (_h = spec.data) || void 0 === _h ? void 0 : _h.length) && void 0 !== _j ? _j : 0;
90
+ if (count > 0) {
91
+ const padding = normalizePadding(null === (_k = spec.block) || void 0 === _k ? void 0 : _k.padding), innerHeight = Math.max(height - padding.top - padding.bottom, 1);
92
+ blockHeight = Math.max(160, Math.floor(innerHeight / count));
93
+ }
94
+ }
95
+ const result = computeStorylineLayout(null !== (_l = spec.data) && void 0 !== _l ? _l : [], {
96
+ layout: spec.layout,
97
+ viewBox: {
98
+ width: width,
99
+ height: height
100
+ },
101
+ block: {
102
+ width: blockWidth,
103
+ height: blockHeight
104
+ },
105
+ gap: null !== (_o = null === (_m = spec.block) || void 0 === _m ? void 0 : _m.gap) && void 0 !== _o ? _o : 36,
106
+ padding: null === (_p = spec.block) || void 0 === _p ? void 0 : _p.padding,
107
+ lineDistance: null === (_q = spec.line) || void 0 === _q ? void 0 : _q.distance
108
+ });
109
+ return startX || startY ? Object.assign(Object.assign({}, result), {
110
+ blocks: result.blocks.map((block => Object.assign(Object.assign({}, block), {
111
+ x: block.x + startX,
112
+ y: block.y + startY,
113
+ center: {
114
+ x: block.center.x + startX,
115
+ y: block.center.y + startY
116
+ }
117
+ }))),
118
+ links: result.links.map((link => Object.assign(Object.assign({}, link), {
119
+ start: {
120
+ x: link.start.x + startX,
121
+ y: link.start.y + startY
122
+ },
123
+ end: {
124
+ x: link.end.x + startX,
125
+ y: link.end.y + startY
126
+ },
127
+ points: link.points.map((point => ({
128
+ x: point.x + startX,
129
+ y: point.y + startY
130
+ })))
131
+ })))
132
+ }) : result;
133
+ };
134
+
135
+ export const buildRichContent = (contentText, spec) => {
136
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
137
+ const fontSize = Number(null !== (_c = null === (_b = null === (_a = spec.content) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize) && void 0 !== _c ? _c : 12), lineHeight = Number(null !== (_f = null === (_e = null === (_d = spec.content) || void 0 === _d ? void 0 : _d.style) || void 0 === _e ? void 0 : _e.lineHeight) && void 0 !== _f ? _f : 18), fill = null !== (_j = null === (_h = null === (_g = spec.content) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fill) && void 0 !== _j ? _j : "#596173";
138
+ return {
139
+ type: "rich",
140
+ text: contentText.reduce(((result, paragraph, index) => {
141
+ const suffix = index === contentText.length - 1 ? "" : "\n";
142
+ return result.push({
143
+ text: `${paragraph}${suffix}`,
144
+ fontSize: fontSize,
145
+ lineHeight: lineHeight,
146
+ fill: fill
147
+ }), result;
148
+ }), [])
149
+ };
150
+ };
151
+
152
+ export const omitImageLayoutSpec = imageSpec => {
153
+ if (!imageSpec) return {};
154
+ const {width: _width, height: _height, position: _position, gap: _gap} = imageSpec;
155
+ return __rest(imageSpec, [ "width", "height", "position", "gap" ]);
156
+ };
157
+
158
+ export const getImageBox = (position, blockWidth, blockHeight, padding, width, height, _gap, visible) => {
159
+ if (!visible) return {
160
+ x: padding.left,
161
+ y: padding.top,
162
+ width: 0,
163
+ height: 0
164
+ };
165
+ switch (position) {
166
+ case "left":
167
+ return {
168
+ x: padding.left,
169
+ y: (blockHeight - height) / 2,
170
+ width: width,
171
+ height: height
172
+ };
173
+
174
+ case "right":
175
+ return {
176
+ x: blockWidth - padding.right - width,
177
+ y: (blockHeight - height) / 2,
178
+ width: width,
179
+ height: height
180
+ };
181
+
182
+ case "bottom":
183
+ return {
184
+ x: (blockWidth - width) / 2,
185
+ y: blockHeight - padding.bottom - height,
186
+ width: width,
187
+ height: height
188
+ };
189
+
190
+ default:
191
+ return {
192
+ x: (blockWidth - width) / 2,
193
+ y: padding.top,
194
+ width: width,
195
+ height: height
196
+ };
197
+ }
198
+ };
199
+
200
+ export const getTextBox = (position, blockWidth, blockHeight, padding, imageWidth, imageHeight, imageGap, hasImage) => {
201
+ if (!hasImage) return {
202
+ x: padding.left,
203
+ y: padding.top,
204
+ width: blockWidth - padding.left - padding.right,
205
+ height: blockHeight - padding.top - padding.bottom
206
+ };
207
+ switch (position) {
208
+ case "left":
209
+ return {
210
+ x: padding.left + imageWidth + imageGap,
211
+ y: padding.top,
212
+ width: blockWidth - padding.left - padding.right - imageWidth - imageGap,
213
+ height: blockHeight - padding.top - padding.bottom
214
+ };
215
+
216
+ case "right":
217
+ return {
218
+ x: padding.left,
219
+ y: padding.top,
220
+ width: blockWidth - padding.left - padding.right - imageWidth - imageGap,
221
+ height: blockHeight - padding.top - padding.bottom
222
+ };
223
+
224
+ case "bottom":
225
+ return {
226
+ x: padding.left,
227
+ y: padding.top,
228
+ width: blockWidth - padding.left - padding.right,
229
+ height: blockHeight - padding.top - padding.bottom - imageHeight - imageGap
230
+ };
231
+
232
+ default:
233
+ return {
234
+ x: padding.left,
235
+ y: padding.top + imageHeight + imageGap,
236
+ width: blockWidth - padding.left - padding.right,
237
+ height: blockHeight - padding.top - padding.bottom - imageHeight - imageGap
238
+ };
239
+ }
240
+ };
241
+
242
+ export const buildSmoothCurvePath = points => {
243
+ var _a, _b;
244
+ if (points.length < 2) return "";
245
+ if (2 === points.length) return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;
246
+ let d = `M ${points[0].x} ${points[0].y}`;
247
+ for (let i = 0; i < points.length - 1; i++) {
248
+ const p0 = null !== (_a = points[i - 1]) && void 0 !== _a ? _a : points[i], p1 = points[i], p2 = points[i + 1], p3 = null !== (_b = points[i + 2]) && void 0 !== _b ? _b : p2;
249
+ d += ` C ${p1.x + (p2.x - p0.x) / 6} ${p1.y + (p2.y - p0.y) / 6}, ${p2.x - (p3.x - p1.x) / 6} ${p2.y - (p3.y - p1.y) / 6}, ${p2.x} ${p2.y}`;
250
+ }
251
+ return d;
252
+ };
253
+
254
+ export { normalizeLayout, normalizePadding };
255
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/layouts/common.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAGjB,MAAM,WAAW,CAAC;AAiBnB,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAI7C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAoB,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;AACvG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAoB,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;AACrG,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAoB,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK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EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC,IAAI,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KACzD;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAGF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC","file":"common.js","sourcesContent":["import type { ICustomMarkSpec } from '@visactor/vchart';\nimport type { IStorylineBlock, IStorylineSpec, StorylineImagePosition } from '../interface';\nimport {\n computeStorylineLayout,\n normalizeLayout,\n normalizePadding,\n type StorylineLayoutResult,\n type StorylinePoint\n} from '../layout';\n\n// ===== 布局通用类型 =====\n\nexport type LayoutContext = {\n chart?: {\n getAllRegions?: () => {\n getLayoutRect?: () => { width?: number; height?: number };\n getLayoutStartPoint?: () => { x?: number; y?: number };\n }[];\n getLayoutRect?: () => { width?: number; height?: number };\n };\n getLayoutBounds?: () => { width?: () => number; height?: () => number };\n};\n\n// ===== 通用默认值 =====\n\nexport const DEFAULT_BLOCK_WIDTH = 180;\nexport const DEFAULT_BLOCK_HEIGHT = 112;\nexport const DEFAULT_BLOCK_WIDTH_RATIO = 0.24;\nexport const DEFAULT_BLOCK_GAP = 36;\nexport const DEFAULT_IMAGE_WIDTH = 48;\nexport const DEFAULT_IMAGE_HEIGHT = 48;\nexport const DEFAULT_IMAGE_GAP = 10;\nexport const DEFAULT_THEME_COLOR = '#e8543d';\n\n// ===== 布局判定 =====\n\nexport const isLandscape = (spec: IStorylineSpec) => normalizeLayout(spec.layout).type === 'landscape';\nexport const isPortrait = (spec: IStorylineSpec) => normalizeLayout(spec.layout).type === 'portrait';\nexport const isClock = (spec: IStorylineSpec) => normalizeLayout(spec.layout).type === 'clock';\nexport const isDome = (spec: IStorylineSpec) => normalizeLayout(spec.layout).type === 'dome';\nexport const isBowl = (spec: IStorylineSpec) => normalizeLayout(spec.layout).type === 'bowl';\n\nexport const getThemeColor = (spec: IStorylineSpec) => spec.themeColor ?? DEFAULT_THEME_COLOR;\n\n// ===== 颜色工具 =====\n\n/**\n * 给颜色(#hex / rgb / rgba / hsl / 颜色关键字)追加/替换 alpha 通道,返回 rgba(...) 字符串\n */\nexport const withAlpha = (color: string, alpha: number): string => {\n const safeAlpha = Math.max(0, Math.min(1, alpha));\n if (!color) {\n return `rgba(0, 0, 0, ${safeAlpha})`;\n }\n const trimmed = color.trim();\n if (trimmed.startsWith('#')) {\n let hex = trimmed.slice(1);\n if (hex.length === 3 || hex.length === 4) {\n hex = hex\n .split('')\n .map(ch => ch + ch)\n .join('');\n }\n if (hex.length === 6 || hex.length === 8) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n return `rgba(${r}, ${g}, ${b}, ${safeAlpha})`;\n }\n }\n const rgbMatch = trimmed.match(/^rgba?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)/i);\n if (rgbMatch) {\n return `rgba(${rgbMatch[1]}, ${rgbMatch[2]}, ${rgbMatch[3]}, ${safeAlpha})`;\n }\n return trimmed;\n};\n\n// ===== 块宽度解析 =====\n\nexport const resolveBlockWidth = (spec: IStorylineSpec, viewWidth: number) => {\n if (spec.block?.width) {\n return spec.block.width;\n }\n const ratio = spec.block?.widthRatio ?? DEFAULT_BLOCK_WIDTH_RATIO;\n const minWidth = spec.block?.minWidth ?? DEFAULT_BLOCK_WIDTH;\n const maxWidth = spec.block?.maxWidth ?? Math.max(minWidth, 320);\n return Math.max(minWidth, Math.min(maxWidth, Math.round(viewWidth * ratio)));\n};\n\n// ===== 容器几何信息(chart region rect)=====\n\nexport const getRegionGeometry = (ctx: LayoutContext) => {\n const region = ctx.chart?.getAllRegions?.()?.[0];\n const regionRect = region?.getLayoutRect?.();\n const regionStart = region?.getLayoutStartPoint?.();\n const chartRect = ctx.chart?.getLayoutRect?.();\n const bounds = ctx.getLayoutBounds?.();\n const width = Math.max(regionRect?.width ?? chartRect?.width ?? bounds?.width?.() ?? 0, 1);\n const height = Math.max(regionRect?.height ?? chartRect?.height ?? bounds?.height?.() ?? 0, 1);\n return {\n width,\n height,\n startX: regionStart?.x ?? 0,\n startY: regionStart?.y ?? 0\n };\n};\n\n// ===== 布局计算(layout.ts 的封装,附加 startX/startY 平移)=====\n\nexport const getLayout = (spec: IStorylineSpec, ctx: LayoutContext): StorylineLayoutResult => {\n const { width, height, startX, startY } = getRegionGeometry(ctx);\n let blockWidth = resolveBlockWidth(spec, width);\n let blockHeight = spec.block?.height ?? DEFAULT_BLOCK_HEIGHT;\n // landscape:图片间距固定 40,根据 block 数量自适应单个 image 宽度\n if (isLandscape(spec) && !spec.block?.width) {\n const count = spec.data?.length ?? 0;\n if (count > 0) {\n const padding = normalizePadding(spec.block?.padding);\n const innerWidth = Math.max(width - padding.left - padding.right, 1);\n const LANDSCAPE_IMAGE_GAP = 40;\n const LANDSCAPE_IMAGE_MIN_WIDTH = 80;\n const totalGap = LANDSCAPE_IMAGE_GAP * Math.max(count - 1, 0);\n const adaptive = (innerWidth - totalGap) / count;\n blockWidth = Math.max(LANDSCAPE_IMAGE_MIN_WIDTH, Math.floor(adaptive));\n }\n }\n // portrait:每个 block 在垂直方向需要容纳 image + text,整体根据 viewBox 高度均分\n if (isPortrait(spec) && !spec.block?.height) {\n const count = spec.data?.length ?? 0;\n if (count > 0) {\n const padding = normalizePadding(spec.block?.padding);\n const innerHeight = Math.max(height - padding.top - padding.bottom, 1);\n blockHeight = Math.max(160, Math.floor(innerHeight / count));\n }\n }\n const result = computeStorylineLayout(spec.data ?? [], {\n layout: spec.layout,\n viewBox: { width, height },\n block: {\n width: blockWidth,\n height: blockHeight\n },\n gap: spec.block?.gap ?? DEFAULT_BLOCK_GAP,\n padding: spec.block?.padding,\n lineDistance: spec.line?.distance\n });\n if (!startX && !startY) {\n return result;\n }\n return {\n ...result,\n blocks: result.blocks.map(block => ({\n ...block,\n x: block.x + startX,\n y: block.y + startY,\n center: {\n x: block.center.x + startX,\n y: block.center.y + startY\n }\n })),\n links: result.links.map(link => ({\n ...link,\n start: { x: link.start.x + startX, y: link.start.y + startY },\n end: { x: link.end.x + startX, y: link.end.y + startY },\n points: link.points.map(point => ({ x: point.x + startX, y: point.y + startY }))\n }))\n };\n};\n\n// ===== 文本 / 图像通用工具 =====\n\nexport const buildRichContent = (contentText: string[], spec: IStorylineSpec) => {\n const fontSize = Number((spec.content?.style as any)?.fontSize ?? 12);\n const lineHeight = Number((spec.content?.style as any)?.lineHeight ?? 18);\n const fill = (spec.content?.style as any)?.fill ?? '#596173';\n\n return {\n type: 'rich' as const,\n text: contentText.reduce<{ text: string; fontSize: number; lineHeight: number; fill: string }[]>(\n (result, paragraph, index) => {\n const suffix = index === contentText.length - 1 ? '' : '\\n';\n result.push({\n text: `${paragraph}${suffix}`,\n fontSize,\n lineHeight,\n fill\n });\n return result;\n },\n []\n )\n };\n};\n\nexport const omitImageLayoutSpec = (imageSpec: IStorylineSpec['image']) => {\n if (!imageSpec) {\n return {};\n }\n const { width: _width, height: _height, position: _position, gap: _gap, ...rest } = imageSpec;\n return rest;\n};\n\n// ===== 默认 image / text 盒计算(用于通用 block)=====\n\nexport const getImageBox = (\n position: StorylineImagePosition,\n blockWidth: number,\n blockHeight: number,\n padding: ReturnType<typeof normalizePadding>,\n width: number,\n height: number,\n _gap: number,\n visible: boolean\n) => {\n if (!visible) {\n return { x: padding.left, y: padding.top, width: 0, height: 0 };\n }\n switch (position) {\n case 'left':\n return { x: padding.left, y: (blockHeight - height) / 2, width, height };\n case 'right':\n return { x: blockWidth - padding.right - width, y: (blockHeight - height) / 2, width, height };\n case 'bottom':\n return { x: (blockWidth - width) / 2, y: blockHeight - padding.bottom - height, width, height };\n case 'top':\n default:\n return { x: (blockWidth - width) / 2, y: padding.top, width, height };\n }\n};\n\nexport const getTextBox = (\n position: StorylineImagePosition,\n blockWidth: number,\n blockHeight: number,\n padding: ReturnType<typeof normalizePadding>,\n imageWidth: number,\n imageHeight: number,\n imageGap: number,\n hasImage: boolean\n) => {\n if (!hasImage) {\n return {\n x: padding.left,\n y: padding.top,\n width: blockWidth - padding.left - padding.right,\n height: blockHeight - padding.top - padding.bottom\n };\n }\n switch (position) {\n case 'left':\n return {\n x: padding.left + imageWidth + imageGap,\n y: padding.top,\n width: blockWidth - padding.left - padding.right - imageWidth - imageGap,\n height: blockHeight - padding.top - padding.bottom\n };\n case 'right':\n return {\n x: padding.left,\n y: padding.top,\n width: blockWidth - padding.left - padding.right - imageWidth - imageGap,\n height: blockHeight - padding.top - padding.bottom\n };\n case 'bottom':\n return {\n x: padding.left,\n y: padding.top,\n width: blockWidth - padding.left - padding.right,\n height: blockHeight - padding.top - padding.bottom - imageHeight - imageGap\n };\n case 'top':\n default:\n return {\n x: padding.left,\n y: padding.top + imageHeight + imageGap,\n width: blockWidth - padding.left - padding.right,\n height: blockHeight - padding.top - padding.bottom - imageHeight - imageGap\n };\n }\n};\n\n// ===== Catmull-Rom 平滑曲线 =====\n\n/**\n * 用 Catmull-Rom 转 cubic Bezier 生成平滑曲线 path(贯穿所有点)。\n */\nexport const buildSmoothCurvePath = (points: StorylinePoint[]): string => {\n if (points.length < 2) {\n return '';\n }\n if (points.length === 2) {\n return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;\n }\n let d = `M ${points[0].x} ${points[0].y}`;\n for (let i = 0; i < points.length - 1; i++) {\n const p0 = points[i - 1] ?? points[i];\n const p1 = points[i];\n const p2 = points[i + 1];\n const p3 = points[i + 2] ?? p2;\n const c1x = p1.x + (p2.x - p0.x) / 6;\n const c1y = p1.y + (p2.y - p0.y) / 6;\n const c2x = p2.x - (p3.x - p1.x) / 6;\n const c2y = p2.y - (p3.y - p1.y) / 6;\n d += ` C ${c1x} ${c1y}, ${c2x} ${c2y}, ${p2.x} ${p2.y}`;\n }\n return d;\n};\n\n// 重导出常用的 layout helper(避免外部再 import layout.ts)\nexport { normalizeLayout, normalizePadding };\nexport type { IStorylineBlock, ICustomMarkSpec, StorylinePoint };\n"]}
@@ -0,0 +1,4 @@
1
+ import type { IExtensionGroupMarkSpec } from '@visactor/vchart';
2
+ import type { IStorylineBlock, IStorylineSpec } from '../interface';
3
+ export declare const buildDefaultLineMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
4
+ export declare const buildDefaultBlockMark: (spec: IStorylineSpec, block: IStorylineBlock, index: number) => IExtensionGroupMarkSpec;
@@ -0,0 +1,172 @@
1
+ var __rest = this && this.__rest || function(s, e) {
2
+ var t = {};
3
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
4
+ if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
5
+ var i = 0;
6
+ for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
7
+ }
8
+ return t;
9
+ };
10
+
11
+ import { LayoutZIndex } from "@visactor/vchart";
12
+
13
+ import { DEFAULT_BLOCK_HEIGHT, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_GAP, buildRichContent, getImageBox, getLayout, getTextBox, normalizePadding, omitImageLayoutSpec, resolveBlockWidth } from "./common";
14
+
15
+ export const buildDefaultLineMark = spec => {
16
+ var _a, _b, _c, _d;
17
+ return !1 === (null === (_a = spec.line) || void 0 === _a ? void 0 : _a.visible) || (null !== (_c = null === (_b = spec.data) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0) <= 1 ? null : {
18
+ type: "group",
19
+ name: "storyline-links",
20
+ zIndex: LayoutZIndex.Mark,
21
+ children: (null !== (_d = spec.data) && void 0 !== _d ? _d : []).slice(1).map(((_, index) => {
22
+ var _a;
23
+ const _b = null !== (_a = spec.line) && void 0 !== _a ? _a : {}, {style: style = {}, type: type = "line", showArrow: showArrow = !1, arrowSize: arrowSize = 8} = _b, rest = __rest(_b, [ "style", "type", "showArrow", "arrowSize" ]);
24
+ return Object.assign(Object.assign({
25
+ type: "path",
26
+ name: `storyline-link-${index}`,
27
+ interactive: !1
28
+ }, rest), {
29
+ style: Object.assign(Object.assign({
30
+ stroke: "#8a94a6",
31
+ lineWidth: 1.5,
32
+ fill: "transparent",
33
+ fillOpacity: 0
34
+ }, style), {
35
+ path: (_datum, ctx) => {
36
+ const link = getLayout(spec, ctx).links[index];
37
+ return link ? buildLinkPath(link.points, type, showArrow, arrowSize) : "";
38
+ }
39
+ })
40
+ });
41
+ }))
42
+ };
43
+ };
44
+
45
+ const getDefaultBlockMetrics = (spec, ctx, index) => {
46
+ 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;
47
+ const block = getLayout(spec, ctx).blocks[index], padding = normalizePadding(null !== (_b = null === (_a = spec.block) || void 0 === _a ? void 0 : _a.padding) && void 0 !== _b ? _b : 12), imagePosition = null !== (_d = null === (_c = spec.image) || void 0 === _c ? void 0 : _c.position) && void 0 !== _d ? _d : "top", imageWidth = null !== (_f = null === (_e = spec.image) || void 0 === _e ? void 0 : _e.width) && void 0 !== _f ? _f : DEFAULT_IMAGE_WIDTH, imageHeight = null !== (_h = null === (_g = spec.image) || void 0 === _g ? void 0 : _g.height) && void 0 !== _h ? _h : DEFAULT_IMAGE_HEIGHT, imageGap = null !== (_k = null === (_j = spec.image) || void 0 === _j ? void 0 : _j.gap) && void 0 !== _k ? _k : DEFAULT_IMAGE_GAP, hasImage = !!(null === (_m = null === (_l = spec.data) || void 0 === _l ? void 0 : _l[index]) || void 0 === _m ? void 0 : _m.image), titleFontSize = Number(null !== (_q = null === (_p = null === (_o = spec.title) || void 0 === _o ? void 0 : _o.style) || void 0 === _p ? void 0 : _p.fontSize) && void 0 !== _q ? _q : 14), titleLineHeight = Number(null !== (_t = null === (_s = null === (_r = spec.title) || void 0 === _r ? void 0 : _r.style) || void 0 === _s ? void 0 : _s.lineHeight) && void 0 !== _t ? _t : Math.round(1.35 * titleFontSize)), titleHeight = (null === (_v = null === (_u = spec.data) || void 0 === _u ? void 0 : _u[index]) || void 0 === _v ? void 0 : _v.title) ? titleLineHeight : 0, blockWidth = null !== (_w = null == block ? void 0 : block.width) && void 0 !== _w ? _w : resolveBlockWidth(spec, 0), blockHeight = null !== (_z = null !== (_x = null == block ? void 0 : block.height) && void 0 !== _x ? _x : null === (_y = spec.block) || void 0 === _y ? void 0 : _y.height) && void 0 !== _z ? _z : DEFAULT_BLOCK_HEIGHT, imageBox = getImageBox(imagePosition, blockWidth, blockHeight, padding, imageWidth, imageHeight, imageGap, hasImage), textBox = getTextBox(imagePosition, blockWidth, blockHeight, padding, imageWidth, imageHeight, imageGap, hasImage), contentGap = (null === (_1 = null === (_0 = spec.data) || void 0 === _0 ? void 0 : _0[index]) || void 0 === _1 ? void 0 : _1.title) ? 8 : 0;
48
+ return {
49
+ block: {
50
+ width: blockWidth,
51
+ height: blockHeight
52
+ },
53
+ imageBox: imageBox,
54
+ textBox: textBox,
55
+ contentBox: {
56
+ y: textBox.y + titleHeight + contentGap,
57
+ height: Math.max(0, textBox.height - titleHeight - contentGap)
58
+ }
59
+ };
60
+ };
61
+
62
+ export const buildDefaultBlockMark = (spec, block, index) => {
63
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
64
+ const hasImage = !!block.image, contentText = Array.isArray(block.content) ? block.content : block.content ? [ block.content ] : [], titleFontSize = Number(null !== (_c = null === (_b = null === (_a = spec.title) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize) && void 0 !== _c ? _c : 14), titleLineHeight = Number(null !== (_f = null === (_e = null === (_d = spec.title) || void 0 === _d ? void 0 : _d.style) || void 0 === _e ? void 0 : _e.lineHeight) && void 0 !== _f ? _f : Math.round(1.35 * titleFontSize));
65
+ return {
66
+ type: "group",
67
+ id: `storyline-block-${null !== (_g = block.id) && void 0 !== _g ? _g : index}`,
68
+ name: `storyline-block-${index}`,
69
+ zIndex: LayoutZIndex.Mark + 1,
70
+ style: {
71
+ x: (_datum, ctx) => {
72
+ var _a, _b;
73
+ return null !== (_b = null === (_a = getLayout(spec, ctx).blocks[index]) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0;
74
+ },
75
+ y: (_datum, ctx) => {
76
+ var _a, _b;
77
+ return null !== (_b = null === (_a = getLayout(spec, ctx).blocks[index]) || void 0 === _a ? void 0 : _a.y) && void 0 !== _b ? _b : 0;
78
+ },
79
+ width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.width,
80
+ height: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.height
81
+ },
82
+ children: [ {
83
+ type: "rect",
84
+ name: `storyline-block-bg-${index}`,
85
+ interactive: !1,
86
+ style: Object.assign({
87
+ x: 0,
88
+ y: 0,
89
+ width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.width,
90
+ height: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).block.height,
91
+ cornerRadius: 8,
92
+ fill: "#ffffff",
93
+ stroke: "#d7dce5",
94
+ lineWidth: 1,
95
+ shadowBlur: 6,
96
+ shadowColor: "rgba(0, 0, 0, 0.08)"
97
+ }, null === (_h = spec.block) || void 0 === _h ? void 0 : _h.style)
98
+ }, hasImage ? Object.assign(Object.assign({
99
+ type: "image",
100
+ name: `storyline-block-image-${index}`,
101
+ interactive: !1
102
+ }, omitImageLayoutSpec(spec.image)), {
103
+ style: Object.assign({
104
+ x: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.x,
105
+ y: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.y,
106
+ width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.width,
107
+ height: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).imageBox.height,
108
+ image: block.image,
109
+ cornerRadius: 6
110
+ }, null === (_j = spec.image) || void 0 === _j ? void 0 : _j.style)
111
+ }) : null, block.title ? Object.assign(Object.assign({
112
+ type: "text",
113
+ name: `storyline-block-title-${index}`,
114
+ interactive: !1
115
+ }, spec.title), {
116
+ style: Object.assign({
117
+ x: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.x,
118
+ y: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.y,
119
+ text: block.title,
120
+ maxLineWidth: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.width,
121
+ fontSize: titleFontSize,
122
+ lineHeight: titleLineHeight,
123
+ fontWeight: "bold",
124
+ fill: "#1f2430",
125
+ textAlign: "left",
126
+ textBaseline: "top"
127
+ }, null === (_k = spec.title) || void 0 === _k ? void 0 : _k.style)
128
+ }) : null, contentText.length ? Object.assign(Object.assign({
129
+ type: "text",
130
+ name: `storyline-block-content-${index}`,
131
+ interactive: !1
132
+ }, spec.content), {
133
+ textType: "rich",
134
+ style: Object.assign({
135
+ x: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.x,
136
+ y: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).contentBox.y,
137
+ width: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.width,
138
+ text: buildRichContent(contentText, spec),
139
+ maxLineWidth: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).textBox.width,
140
+ fontSize: 12,
141
+ lineHeight: 18,
142
+ heightLimit: (_datum, ctx) => getDefaultBlockMetrics(spec, ctx, index).contentBox.height,
143
+ textAlign: "left",
144
+ textBaseline: "top",
145
+ wordBreak: "break-word",
146
+ ellipsis: "...",
147
+ fill: "#596173"
148
+ }, null === (_l = spec.content) || void 0 === _l ? void 0 : _l.style)
149
+ }) : null ].filter(Boolean)
150
+ };
151
+ };
152
+
153
+ const buildLinkPath = (points, type, showArrow, arrowSize) => {
154
+ const start = points[0], end = points[points.length - 1];
155
+ if (!start || !end) return "";
156
+ let path;
157
+ if ("curve" === type) {
158
+ const dx = end.x - start.x, dy = end.y - start.y, curve = Math.max(Math.min(.22 * Math.sqrt(dx * dx + dy * dy), 80), 24);
159
+ path = `M ${start.x} ${start.y} C ${start.x + dx / 2} ${start.y - curve} ${end.x - dx / 2} ${end.y + curve} ${end.x} ${end.y}`;
160
+ } else if ("polyline" === type) {
161
+ const mid = {
162
+ x: (start.x + end.x) / 2,
163
+ y: (start.y + end.y) / 2
164
+ };
165
+ path = `M ${start.x} ${start.y} L ${mid.x} ${start.y} L ${mid.x} ${end.y} L ${end.x} ${end.y}`;
166
+ } else path = `M ${start.x} ${start.y} L ${end.x} ${end.y}`;
167
+ return showArrow ? `${path} ${buildArrowPath(start, end, arrowSize)}` : path;
168
+ }, buildArrowPath = (start, end, size) => {
169
+ const angle = Math.atan2(end.y - start.y, end.x - start.x), left_x = end.x - Math.cos(angle - Math.PI / 6) * size, left_y = end.y - Math.sin(angle - Math.PI / 6) * size, right_x = end.x - Math.cos(angle + Math.PI / 6) * size, right_y = end.y - Math.sin(angle + Math.PI / 6) * size;
170
+ return `M ${left_x} ${left_y} L ${end.x} ${end.y} L ${right_x} ${right_y}`;
171
+ };
172
+ //# sourceMappingURL=default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/layouts/default.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAIL,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAMlB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAoB,EAAkC,EAAE;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AAC,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI;KAChD,CAAC;IACF,OAAO,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7E,CAAC,CAAC","file":"default.js","sourcesContent":["import type { IExtensionGroupMarkSpec } from '@visactor/vchart';\nimport { LayoutZIndex } from '@visactor/vchart';\nimport type { IStorylineBlock, IStorylineSpec, StorylineLineType } from '../interface';\nimport {\n type ICustomMarkSpec,\n type LayoutContext,\n type StorylinePoint,\n DEFAULT_BLOCK_HEIGHT,\n DEFAULT_IMAGE_WIDTH,\n DEFAULT_IMAGE_HEIGHT,\n DEFAULT_IMAGE_GAP,\n buildRichContent,\n getImageBox,\n getLayout,\n getTextBox,\n normalizePadding,\n omitImageLayoutSpec,\n resolveBlockWidth\n} from './common';\n\n/**\n * 默认布局:rect block(image + title + content) + 普通 link mark。\n */\n\nexport const buildDefaultLineMark = (spec: IStorylineSpec): IExtensionGroupMarkSpec | null => {\n if (spec.line?.visible === false || (spec.data?.length ?? 0) <= 1) {\n return null;\n }\n\n return {\n type: 'group' as any,\n name: 'storyline-links',\n zIndex: LayoutZIndex.Mark,\n children: (spec.data ?? []).slice(1).map((_, index) => {\n const { style = {}, type = 'line', showArrow = false, arrowSize = 8, ...rest } = spec.line ?? {};\n return {\n type: 'path',\n name: `storyline-link-${index}`,\n interactive: false,\n ...rest,\n style: {\n stroke: '#8a94a6',\n lineWidth: 1.5,\n fill: 'transparent',\n fillOpacity: 0,\n ...style,\n path: (_datum: unknown, ctx: LayoutContext) => {\n const link = getLayout(spec, ctx).links[index];\n if (!link) {\n return '';\n }\n return buildLinkPath(link.points, type, showArrow, arrowSize);\n }\n }\n } as ICustomMarkSpec<'path'>;\n })\n };\n};\n\nconst getDefaultBlockMetrics = (spec: IStorylineSpec, ctx: LayoutContext, index: number) => {\n const block = getLayout(spec, ctx).blocks[index];\n const padding = normalizePadding(spec.block?.padding ?? 12);\n const imagePosition = spec.image?.position ?? 'top';\n const imageWidth = spec.image?.width ?? DEFAULT_IMAGE_WIDTH;\n const imageHeight = spec.image?.height ?? DEFAULT_IMAGE_HEIGHT;\n const imageGap = spec.image?.gap ?? DEFAULT_IMAGE_GAP;\n const hasImage = !!spec.data?.[index]?.image;\n const titleFontSize = Number((spec.title?.style as any)?.fontSize ?? 14);\n const titleLineHeight = Number((spec.title?.style as any)?.lineHeight ?? Math.round(titleFontSize * 1.35));\n const titleHeight = spec.data?.[index]?.title ? titleLineHeight : 0;\n const blockWidth = block?.width ?? resolveBlockWidth(spec, 0);\n const blockHeight = block?.height ?? spec.block?.height ?? DEFAULT_BLOCK_HEIGHT;\n const imageBox = getImageBox(\n imagePosition,\n blockWidth,\n blockHeight,\n padding,\n imageWidth,\n imageHeight,\n imageGap,\n hasImage\n );\n const textBox = getTextBox(\n imagePosition,\n blockWidth,\n blockHeight,\n padding,\n imageWidth,\n imageHeight,\n imageGap,\n hasImage\n );\n const contentGap = spec.data?.[index]?.title ? 8 : 0;\n\n return {\n block: {\n width: blockWidth,\n height: blockHeight\n },\n imageBox,\n textBox,\n contentBox: {\n y: textBox.y + titleHeight + contentGap,\n height: Math.max(0, textBox.height - titleHeight - contentGap)\n }\n };\n};\n\nexport const buildDefaultBlockMark = (\n spec: IStorylineSpec,\n block: IStorylineBlock,\n index: number\n): IExtensionGroupMarkSpec => {\n const hasImage = !!block.image;\n const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];\n const titleFontSize = Number((spec.title?.style as any)?.fontSize ?? 14);\n const titleLineHeight = Number((spec.title?.style as any)?.lineHeight ?? Math.round(titleFontSize * 1.35));\n\n return {\n type: 'group' as any,\n id: `storyline-block-${block.id ?? index}`,\n name: `storyline-block-${index}`,\n zIndex: LayoutZIndex.Mark + 1,\n style: {\n x: (_datum: unknown, ctx: LayoutContext) => getLayout(spec, ctx).blocks[index]?.x ?? 0,\n y: (_datum: unknown, ctx: LayoutContext) => getLayout(spec, ctx).blocks[index]?.y ?? 0,\n width: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).block.width,\n height: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).block.height\n },\n children: [\n {\n type: 'rect',\n name: `storyline-block-bg-${index}`,\n interactive: false,\n style: {\n x: 0,\n y: 0,\n width: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).block.width,\n height: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).block.height,\n cornerRadius: 8,\n fill: '#ffffff',\n stroke: '#d7dce5',\n lineWidth: 1,\n shadowBlur: 6,\n shadowColor: 'rgba(0, 0, 0, 0.08)',\n ...spec.block?.style\n }\n },\n hasImage\n ? ({\n type: 'image',\n name: `storyline-block-image-${index}`,\n interactive: false,\n ...omitImageLayoutSpec(spec.image),\n style: {\n x: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).imageBox.x,\n y: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).imageBox.y,\n width: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).imageBox.width,\n height: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).imageBox.height,\n image: block.image,\n cornerRadius: 6,\n ...spec.image?.style\n }\n } as ICustomMarkSpec<'image'>)\n : null,\n block.title\n ? ({\n type: 'text',\n name: `storyline-block-title-${index}`,\n interactive: false,\n ...spec.title,\n style: {\n x: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).textBox.x,\n y: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).textBox.y,\n text: block.title,\n maxLineWidth: (_datum: unknown, ctx: LayoutContext) =>\n getDefaultBlockMetrics(spec, ctx, index).textBox.width,\n fontSize: titleFontSize,\n lineHeight: titleLineHeight,\n fontWeight: 'bold',\n fill: '#1f2430',\n textAlign: 'left',\n textBaseline: 'top',\n ...spec.title?.style\n }\n } as ICustomMarkSpec<'text'>)\n : null,\n contentText.length\n ? ({\n type: 'text',\n name: `storyline-block-content-${index}`,\n interactive: false,\n ...spec.content,\n textType: 'rich',\n style: {\n x: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).textBox.x,\n y: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).contentBox.y,\n width: (_datum: unknown, ctx: LayoutContext) => getDefaultBlockMetrics(spec, ctx, index).textBox.width,\n text: buildRichContent(contentText, spec),\n maxLineWidth: (_datum: unknown, ctx: LayoutContext) =>\n getDefaultBlockMetrics(spec, ctx, index).textBox.width,\n fontSize: 12,\n lineHeight: 18,\n heightLimit: (_datum: unknown, ctx: LayoutContext) =>\n getDefaultBlockMetrics(spec, ctx, index).contentBox.height,\n textAlign: 'left',\n textBaseline: 'top',\n wordBreak: 'break-word',\n ellipsis: '...',\n fill: '#596173',\n ...spec.content?.style\n }\n } as ICustomMarkSpec<'text'>)\n : null\n ].filter(Boolean) as ICustomMarkSpec<any>[]\n };\n};\n\nconst buildLinkPath = (\n points: StorylinePoint[],\n type: StorylineLineType,\n showArrow: boolean,\n arrowSize: number\n): string => {\n const start = points[0];\n const end = points[points.length - 1];\n if (!start || !end) {\n return '';\n }\n let path: string;\n if (type === 'curve') {\n const dx = end.x - start.x;\n const dy = end.y - start.y;\n const curve = Math.max(Math.min(Math.sqrt(dx * dx + dy * dy) * 0.22, 80), 24);\n path =\n `M ${start.x} ${start.y} ` +\n `C ${start.x + dx / 2} ${start.y - curve} ${end.x - dx / 2} ${end.y + curve} ${end.x} ${end.y}`;\n } else if (type === 'polyline') {\n const mid = { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };\n path = `M ${start.x} ${start.y} L ${mid.x} ${start.y} L ${mid.x} ${end.y} L ${end.x} ${end.y}`;\n } else {\n path = `M ${start.x} ${start.y} L ${end.x} ${end.y}`;\n }\n\n if (!showArrow) {\n return path;\n }\n return `${path} ${buildArrowPath(start, end, arrowSize)}`;\n};\n\nconst buildArrowPath = (start: StorylinePoint, end: StorylinePoint, size: number) => {\n const angle = Math.atan2(end.y - start.y, end.x - start.x);\n const left = {\n x: end.x - Math.cos(angle - Math.PI / 6) * size,\n y: end.y - Math.sin(angle - Math.PI / 6) * size\n };\n const right = {\n x: end.x - Math.cos(angle + Math.PI / 6) * size,\n y: end.y - Math.sin(angle + Math.PI / 6) * size\n };\n return `M ${left.x} ${left.y} L ${end.x} ${end.y} L ${right.x} ${right.y}`;\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IExtensionGroupMarkSpec } from '@visactor/vchart';
2
+ import type { IStorylineBlock, IStorylineSpec } from '../interface';
3
+ export declare const buildDomeArcMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
4
+ export declare const buildDomeCenterImageMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
5
+ export declare const buildDomeBlockMark: (spec: IStorylineSpec, block: IStorylineBlock, index: number) => IExtensionGroupMarkSpec;