@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,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.StorylineChartSpecTransformer = void 0;
6
+
7
+ const vchart_1 = require("@visactor/vchart"), common_1 = require("./layouts/common"), clock_1 = require("./layouts/clock"), default_1 = require("./layouts/default"), landscape_1 = require("./layouts/landscape"), portrait_1 = require("./layouts/portrait"), dome_1 = require("./layouts/dome"), bowl_1 = require("./layouts/bowl");
8
+
9
+ class StorylineChartSpecTransformer extends vchart_1.CommonChartSpecTransformer {
10
+ transformSpec(spec) {
11
+ var _a;
12
+ applyDefaultPadding(spec);
13
+ const storylineSpec = Object.assign(Object.assign({}, spec), {
14
+ data: [ ...null !== (_a = spec.data) && void 0 !== _a ? _a : [] ]
15
+ });
16
+ spec.type = "common", spec.data = [], spec.series = [], spec.axes = [], spec.customMark = buildStorylineMarks(storylineSpec),
17
+ delete spec.layout, delete spec.title, super.transformSpec(spec);
18
+ }
19
+ }
20
+
21
+ exports.StorylineChartSpecTransformer = StorylineChartSpecTransformer;
22
+
23
+ const applyDefaultPadding = spec => {
24
+ var _a, _b, _c, _d;
25
+ const DEFAULT_OTHER = 20, p = spec.padding;
26
+ if (null != p) if ("number" != typeof p) if (Array.isArray(p)) {
27
+ const [t = DEFAULT_OTHER, r = DEFAULT_OTHER, b, l = DEFAULT_OTHER] = p;
28
+ spec.padding = [ t, r, null != b ? b : 100, l ];
29
+ } else "object" == typeof p && (spec.padding = {
30
+ top: null !== (_a = p.top) && void 0 !== _a ? _a : DEFAULT_OTHER,
31
+ right: null !== (_b = p.right) && void 0 !== _b ? _b : DEFAULT_OTHER,
32
+ bottom: null !== (_c = p.bottom) && void 0 !== _c ? _c : 100,
33
+ left: null !== (_d = p.left) && void 0 !== _d ? _d : DEFAULT_OTHER
34
+ }); else spec.padding = [ p, p, Math.max(p, 100), p ]; else spec.padding = [ DEFAULT_OTHER, DEFAULT_OTHER, 100, DEFAULT_OTHER ];
35
+ }, buildStorylineMarks = spec => {
36
+ var _a;
37
+ const lineMark = buildLineMark(spec), blockMarks = (null !== (_a = spec.data) && void 0 !== _a ? _a : []).map(((block, index) => buildBlockMark(spec, block, index)));
38
+ if ((0, common_1.isLandscape)(spec)) return [ ...blockMarks, lineMark ].filter(Boolean);
39
+ if ((0, common_1.isPortrait)(spec)) return [ lineMark, ...blockMarks ].filter(Boolean);
40
+ if ((0, common_1.isDome)(spec)) {
41
+ return [ (0, dome_1.buildDomeCenterImageMark)(spec), (0, dome_1.buildDomeArcMark)(spec), ...blockMarks ].filter(Boolean);
42
+ }
43
+ if ((0, common_1.isBowl)(spec)) {
44
+ return [ (0, bowl_1.buildBowlCenterImageMark)(spec), (0, bowl_1.buildBowlArcMark)(spec), ...blockMarks ].filter(Boolean);
45
+ }
46
+ if ((0, common_1.isClock)(spec)) {
47
+ const ringsMark = (0, clock_1.buildClockArcMark)(spec), centerImageMark = (0, clock_1.buildClockCenterImageMark)(spec);
48
+ return [ ringsMark, ...blockMarks, centerImageMark ].filter(Boolean);
49
+ }
50
+ return [ lineMark, ...blockMarks ].filter(Boolean);
51
+ }, buildLineMark = spec => {
52
+ var _a, _b, _c;
53
+ 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 : (0,
54
+ common_1.isLandscape)(spec) ? (0, landscape_1.buildLandscapeConnectingCurve)(spec) : (0,
55
+ common_1.isPortrait)(spec) ? (0, portrait_1.buildPortraitAxisMark)(spec) : (0, default_1.buildDefaultLineMark)(spec);
56
+ }, buildBlockMark = (spec, block, index) => (0, common_1.isLandscape)(spec) ? (0,
57
+ landscape_1.buildLandscapeBlockMark)(spec, block, index) : (0, common_1.isPortrait)(spec) ? (0,
58
+ portrait_1.buildPortraitBlockMark)(spec, block, index) : (0, common_1.isDome)(spec) ? (0,
59
+ dome_1.buildDomeBlockMark)(spec, block, index) : (0, common_1.isBowl)(spec) ? (0,
60
+ bowl_1.buildBowlBlockMark)(spec, block, index) : (0, common_1.isClock)(spec) ? (0,
61
+ clock_1.buildClockBlockMark)(spec, block, index) : (0, default_1.buildDefaultBlockMark)(spec, block, index);
62
+ //# sourceMappingURL=storyline-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/storyline-transformer.ts"],"names":[],"mappings":";;;AAAA,6CAA4F;AAE5F,6CAAoF;AACpF,2CAAoG;AACpG,+CAAgF;AAChF,mDAA6F;AAC7F,iDAAmF;AACnF,yCAAgG;AAChG,yCAAgG;AAEhG,MAAa,6BAA8B,SAAQ,mCAA+B;IAChF,aAAa,CAAC,IAAS;;QACrB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,aAAa,GAAG,gCACjB,IAAI,KACP,IAAI,EAAE,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,GACX,CAAC;QAEpB,IAAI,CAAC,IAAI,GAAG,QAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAA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IAAI,CAAC,EAAE;QACpB,OAAO,IAAA,iCAAsB,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KACnD;IACD,IAAI,IAAA,eAAM,EAAC,IAAI,CAAC,EAAE;QAChB,OAAO,IAAA,yBAAkB,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KAC/C;IACD,IAAI,IAAA,eAAM,EAAC,IAAI,CAAC,EAAE;QAChB,OAAO,IAAA,yBAAkB,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KAC/C;IACD,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAO,IAAA,2BAAmB,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KAChD;IAED,OAAO,IAAA,+BAAqB,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC","file":"storyline-transformer.js","sourcesContent":["import { CommonChartSpecTransformer, type IExtensionGroupMarkSpec } from '@visactor/vchart';\nimport type { IStorylineBlock, IStorylineSpec } from './interface';\nimport { isBowl, isClock, isDome, isLandscape, isPortrait } from './layouts/common';\nimport { buildClockArcMark, buildClockBlockMark, buildClockCenterImageMark } from './layouts/clock';\nimport { buildDefaultBlockMark, buildDefaultLineMark } from './layouts/default';\nimport { buildLandscapeBlockMark, buildLandscapeConnectingCurve } from './layouts/landscape';\nimport { buildPortraitAxisMark, buildPortraitBlockMark } from './layouts/portrait';\nimport { buildDomeArcMark, buildDomeBlockMark, buildDomeCenterImageMark } from './layouts/dome';\nimport { buildBowlArcMark, buildBowlBlockMark, buildBowlCenterImageMark } from './layouts/bowl';\n\nexport class StorylineChartSpecTransformer extends CommonChartSpecTransformer<any> {\n transformSpec(spec: any): void {\n applyDefaultPadding(spec);\n const storylineSpec = {\n ...spec,\n data: [...(spec.data ?? [])]\n } as IStorylineSpec;\n\n spec.type = 'common' as any;\n spec.data = [];\n spec.series = [];\n spec.axes = [];\n spec.customMark = buildStorylineMarks(storylineSpec);\n delete spec.layout;\n delete spec.title;\n super.transformSpec(spec as any);\n }\n}\n\n/**\n * 图表默认 padding:所有 storyline 布局底部默认留 100px,\n * 给 dome 的 centerImage / 其它布局的引导线留出呼吸空间。\n * 用户在 spec.padding 中显式指定的值会被保留,仅在缺省时生效。\n */\nconst applyDefaultPadding = (spec: any) => {\n const DEFAULT_BOTTOM = 100;\n const DEFAULT_OTHER = 20;\n const p = spec.padding;\n if (p === undefined || p === null) {\n spec.padding = [DEFAULT_OTHER, DEFAULT_OTHER, DEFAULT_BOTTOM, DEFAULT_OTHER];\n return;\n }\n if (typeof p === 'number') {\n spec.padding = [p, p, Math.max(p, DEFAULT_BOTTOM), p];\n return;\n }\n if (Array.isArray(p)) {\n const [t = DEFAULT_OTHER, r = DEFAULT_OTHER, b, l = DEFAULT_OTHER] = p;\n spec.padding = [t, r, b ?? DEFAULT_BOTTOM, l];\n return;\n }\n if (typeof p === 'object') {\n spec.padding = {\n top: p.top ?? DEFAULT_OTHER,\n right: p.right ?? DEFAULT_OTHER,\n bottom: p.bottom ?? DEFAULT_BOTTOM,\n left: p.left ?? DEFAULT_OTHER\n };\n }\n};\n\nconst buildStorylineMarks = (spec: IStorylineSpec) => {\n const lineMark = buildLineMark(spec);\n const blockMarks = (spec.data ?? []).map((block, index) => buildBlockMark(spec, block, index));\n // landscape:连接曲线绘制在所有 block 之上,避免被 image 遮挡\n if (isLandscape(spec)) {\n return [...blockMarks, lineMark].filter(Boolean) as IExtensionGroupMarkSpec[];\n }\n // portrait:lineMark 是中轴 rect,作为底层背景先绘制\n if (isPortrait(spec)) {\n return [lineMark, ...blockMarks].filter(Boolean) as IExtensionGroupMarkSpec[];\n }\n // dome:先绘制 centerImage(最底层视觉锚点),再绘制贯穿 block 的弧线,最后绘制 block;\n // dome 不绘制 block 之间默认的连接线\n if (isDome(spec)) {\n const centerImageMark = buildDomeCenterImageMark(spec);\n const arcMark = buildDomeArcMark(spec);\n return [centerImageMark, arcMark, ...blockMarks].filter(Boolean) as IExtensionGroupMarkSpec[];\n }\n // bowl:dome 的上下镜像 —— centerImage 贴顶,弧线 + block 在下方\n if (isBowl(spec)) {\n const centerImageMark = buildBowlCenterImageMark(spec);\n const arcMark = buildBowlArcMark(spec);\n return [centerImageMark, arcMark, ...blockMarks].filter(Boolean) as IExtensionGroupMarkSpec[];\n }\n // clock:辐射式信息盘 —— 圆环骨架 + 径向分隔线 → centerImage(盘心)→ blocks(楔形 + 外圈文字)\n if (isClock(spec)) {\n const ringsMark = buildClockArcMark(spec);\n const centerImageMark = buildClockCenterImageMark(spec);\n return [ringsMark, ...blockMarks, centerImageMark].filter(Boolean) as IExtensionGroupMarkSpec[];\n }\n return [lineMark, ...blockMarks].filter(Boolean) as IExtensionGroupMarkSpec[];\n};\n\nconst buildLineMark = (spec: IStorylineSpec): IExtensionGroupMarkSpec | null => {\n if (spec.line?.visible === false || (spec.data?.length ?? 0) <= 1) {\n return null;\n }\n if (isLandscape(spec)) {\n return buildLandscapeConnectingCurve(spec);\n }\n if (isPortrait(spec)) {\n return buildPortraitAxisMark(spec);\n }\n return buildDefaultLineMark(spec);\n};\n\nconst buildBlockMark = (spec: IStorylineSpec, block: IStorylineBlock, index: number): IExtensionGroupMarkSpec => {\n if (isLandscape(spec)) {\n return buildLandscapeBlockMark(spec, block, index);\n }\n if (isPortrait(spec)) {\n return buildPortraitBlockMark(spec, block, index);\n }\n if (isDome(spec)) {\n return buildDomeBlockMark(spec, block, index);\n }\n if (isBowl(spec)) {\n return buildBowlBlockMark(spec, block, index);\n }\n if (isClock(spec)) {\n return buildClockBlockMark(spec, block, index);\n }\n\n return buildDefaultBlockMark(spec, block, index);\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { BaseChart, VChart } from '@visactor/vchart';
2
+ import type { IStorylineSpec } from './interface';
3
+ import { StorylineChartSpecTransformer } from './storyline-transformer';
4
+ export declare class StorylineChart<T extends IStorylineSpec = IStorylineSpec> extends BaseChart<Omit<T, 'data' | 'title' | 'layout'>> {
5
+ type: string;
6
+ static type: string;
7
+ static readonly view: string;
8
+ _spec: T;
9
+ static readonly transformerConstructor: typeof StorylineChartSpecTransformer;
10
+ readonly transformerConstructor: typeof StorylineChartSpecTransformer;
11
+ init(): void;
12
+ protected isValid(): boolean;
13
+ }
14
+ export declare const registerStorylineChart: (option?: {
15
+ VChart?: typeof VChart;
16
+ }) => void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.registerStorylineChart = exports.StorylineChart = void 0;
6
+
7
+ const vchart_1 = require("@visactor/vchart"), storyline_transformer_1 = require("./storyline-transformer");
8
+
9
+ class StorylineChart extends vchart_1.BaseChart {
10
+ constructor() {
11
+ super(...arguments), this.type = "storyline", this.transformerConstructor = storyline_transformer_1.StorylineChartSpecTransformer;
12
+ }
13
+ init() {
14
+ this.isValid() && super.init();
15
+ }
16
+ isValid() {
17
+ var _a, _b;
18
+ const {data: data} = this._spec;
19
+ return !!Array.isArray(data) || (null === (_b = (_a = this._option).onError) || void 0 === _b || _b.call(_a, "Data is required and should be an array for storyline chart"),
20
+ !1);
21
+ }
22
+ }
23
+
24
+ exports.StorylineChart = StorylineChart, StorylineChart.type = "storyline", StorylineChart.view = "singleDefault",
25
+ StorylineChart.transformerConstructor = storyline_transformer_1.StorylineChartSpecTransformer;
26
+
27
+ const registerStorylineChart = option => {
28
+ (0, vchart_1.registerCommonChart)(), (0, vchart_1.registerCustomMark)(), (0, vchart_1.registerGroupMark)(),
29
+ (0, vchart_1.registerRectMark)(), (0, vchart_1.registerTextMark)(), (0, vchart_1.registerImageMark)(),
30
+ (0, vchart_1.registerLineMark)(), (0, vchart_1.registerPathMark)(), (0, vchart_1.registerArcMark)();
31
+ const vchartConstructor = (null == option ? void 0 : option.VChart) || vchart_1.VChart;
32
+ vchartConstructor && vchartConstructor.useChart([ StorylineChart ]);
33
+ };
34
+
35
+ exports.registerStorylineChart = registerStorylineChart;
36
+ //# sourceMappingURL=storyline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/storyline.ts"],"names":[],"mappings":";;;AAAA,6CAY0B;AAE1B,mEAAwE;AAExE,MAAa,cAA0D,SAAQ,kBAE9E;IAFD;;QAGE,SAAI,GAAG,WAAW,CAAC;QAOV,2BAAsB,GAAG,qDAA6B,CAAC;IAiBlE,CAAC;IAfC,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;YACnB,OAAO;SACR;QACD,KAAK,CAAC,IAAI,EAAE,CAAC;IACf,CAAC;IAES,OAAO;;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,OAAO,mDAAG,6DAA6D,CAAC,CAAC;YACtF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AA1BH,wCA2BC;AAvBQ,mBAAI,GAAG,WAAW,CAAC;AACV,mBAAI,GAAW,eAAe,CAAC;AAI/B,qCAAsB,GAAG,qDAA6B,CAAC;AAoBlE,MAAM,sBAAsB,GAAG,CAAC,MAAmC,EAAE,EAAE;IAC5E,IAAA,4BAAmB,GAAE,CAAC;IACtB,IAAA,2BAAkB,GAAE,CAAC;IACrB,IAAA,0BAAiB,GAAE,CAAC;IACpB,IAAA,yBAAgB,GAAE,CAAC;IACnB,IAAA,yBAAgB,GAAE,CAAC;IACnB,IAAA,0BAAiB,GAAE,CAAC;IACpB,IAAA,yBAAgB,GAAE,CAAC;IACnB,IAAA,yBAAgB,GAAE,CAAC;IACnB,IAAA,wBAAe,GAAE,CAAC;IAElB,MAAM,iBAAiB,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,eAAM,CAAC;IACnD,IAAI,iBAAiB,EAAE;QACrB,iBAAiB,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;KAC9C;AACH,CAAC,CAAC;AAfW,QAAA,sBAAsB,0BAejC","file":"storyline.js","sourcesContent":["import {\n BaseChart,\n VChart,\n registerArcMark,\n registerCommonChart,\n registerCustomMark,\n registerGroupMark,\n registerImageMark,\n registerLineMark,\n registerPathMark,\n registerRectMark,\n registerTextMark\n} from '@visactor/vchart';\nimport type { IStorylineSpec } from './interface';\nimport { StorylineChartSpecTransformer } from './storyline-transformer';\n\nexport class StorylineChart<T extends IStorylineSpec = IStorylineSpec> extends BaseChart<\n Omit<T, 'data' | 'title' | 'layout'>\n> {\n type = 'storyline';\n static type = 'storyline';\n static readonly view: string = 'singleDefault';\n\n declare _spec: T;\n\n static readonly transformerConstructor = StorylineChartSpecTransformer;\n readonly transformerConstructor = StorylineChartSpecTransformer;\n\n init() {\n if (!this.isValid()) {\n return;\n }\n super.init();\n }\n\n protected isValid() {\n const { data } = this._spec;\n if (!Array.isArray(data)) {\n this._option.onError?.('Data is required and should be an array for storyline chart');\n return false;\n }\n return true;\n }\n}\n\nexport const registerStorylineChart = (option?: { VChart?: typeof VChart }) => {\n registerCommonChart();\n registerCustomMark();\n registerGroupMark();\n registerRectMark();\n registerTextMark();\n registerImageMark();\n registerLineMark();\n registerPathMark();\n registerArcMark();\n\n const vchartConstructor = option?.VChart || VChart;\n if (vchartConstructor) {\n vchartConstructor.useChart([StorylineChart]);\n }\n};\n"]}
package/cjs/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './charts/pictogram';
17
17
  export * from './charts/image-cloud';
18
18
  export * from './charts/candlestick';
19
19
  export * from './charts/timeline';
20
+ export * from './charts/storyline';
20
21
  export * from './components/series-break';
21
22
  export * from './components/bar-link';
22
23
  export * from './components/series-label';
package/cjs/index.js CHANGED
@@ -36,8 +36,8 @@ Object.defineProperty(exports, "register3DPlugin", {
36
36
  }
37
37
  }), __exportStar(require("./charts/pictogram"), exports), __exportStar(require("./charts/image-cloud"), exports),
38
38
  __exportStar(require("./charts/candlestick"), exports), __exportStar(require("./charts/timeline"), exports),
39
- __exportStar(require("./components/series-break"), exports), __exportStar(require("./components/bar-link"), exports),
40
- __exportStar(require("./components/series-label"), exports), __exportStar(require("./components/map-label"), exports),
41
- __exportStar(require("./components/regression-line"), exports), __exportStar(require("./components/scatter-regression-line"), exports),
42
- __exportStar(require("./components/bar-regression-line"), exports), __exportStar(require("./components/histogram-regression-line"), exports),
43
- __exportStar(require("./components/extension-mark-sync-state"), exports);
39
+ __exportStar(require("./charts/storyline"), exports), __exportStar(require("./components/series-break"), exports),
40
+ __exportStar(require("./components/bar-link"), exports), __exportStar(require("./components/series-label"), exports),
41
+ __exportStar(require("./components/map-label"), exports), __exportStar(require("./components/regression-line"), exports),
42
+ __exportStar(require("./components/scatter-regression-line"), exports), __exportStar(require("./components/bar-regression-line"), exports),
43
+ __exportStar(require("./components/histogram-regression-line"), exports), __exportStar(require("./components/extension-mark-sync-state"), exports);
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,qEAAmD;AACnD,6DAA2C;AAC3C,uFAAqE;AACrE,qFAAmE;AACnE,yFAAuE;AAEvE,kDAAgC;AAChC,qDAAmC;AACnC,wDAAsC;AACtC,kDAAgC;AAChC,mEAAiD;AACjD,yDAAuC;AACvC,mDAAiC;AACjC,2DAAyC;AACzC,6CAAsD;AAA7C,0GAAA,gBAAgB,OAAA;AACzB,qDAAmC;AACnC,uDAAqC;AACrC,uDAAqC;AACrC,oDAAkC;AAElC,4DAA0C;AAC1C,wDAAsC;AACtC,4DAA0C;AAC1C,yDAAuC;AACvC,+DAA6C;AAC7C,uEAAqD;AACrD,mEAAiD;AACjD,yEAAuD;AACvD,yEAAuD","file":"index.js","sourcesContent":["export * from './charts/ranking-bar/ranking-bar';\nexport * from './charts/ranking-list/ranking-list';\nexport * from './charts/conversion-funnel';\nexport * from './charts/sequence-scatter-link/sequence-scatter-link';\nexport * from './charts/sequence-scatter-kde/sequence-scatter-kde';\nexport * from './charts/sequence-scatter-pixel/sequence-scatter-pixel';\n\nexport * from './charts/bar-3d';\nexport * from './charts/funnel-3d';\nexport * from './charts/histogram-3d';\nexport * from './charts/pie-3d';\nexport * from './charts/combination-candlestick';\nexport * from './charts/word-cloud-3d';\nexport * from './charts/axis-3d';\nexport * from './charts/range-column-3d';\nexport { register3DPlugin } from './charts/3d/plugin';\nexport * from './charts/pictogram';\nexport * from './charts/image-cloud';\nexport * from './charts/candlestick';\nexport * from './charts/timeline';\n\nexport * from './components/series-break';\nexport * from './components/bar-link';\nexport * from './components/series-label';\nexport * from './components/map-label';\nexport * from './components/regression-line';\nexport * from './components/scatter-regression-line';\nexport * from './components/bar-regression-line';\nexport * from './components/histogram-regression-line';\nexport * from './components/extension-mark-sync-state';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,qEAAmD;AACnD,6DAA2C;AAC3C,uFAAqE;AACrE,qFAAmE;AACnE,yFAAuE;AAEvE,kDAAgC;AAChC,qDAAmC;AACnC,wDAAsC;AACtC,kDAAgC;AAChC,mEAAiD;AACjD,yDAAuC;AACvC,mDAAiC;AACjC,2DAAyC;AACzC,6CAAsD;AAA7C,0GAAA,gBAAgB,OAAA;AACzB,qDAAmC;AACnC,uDAAqC;AACrC,uDAAqC;AACrC,oDAAkC;AAClC,qDAAmC;AAEnC,4DAA0C;AAC1C,wDAAsC;AACtC,4DAA0C;AAC1C,yDAAuC;AACvC,+DAA6C;AAC7C,uEAAqD;AACrD,mEAAiD;AACjD,yEAAuD;AACvD,yEAAuD","file":"index.js","sourcesContent":["export * from './charts/ranking-bar/ranking-bar';\nexport * from './charts/ranking-list/ranking-list';\nexport * from './charts/conversion-funnel';\nexport * from './charts/sequence-scatter-link/sequence-scatter-link';\nexport * from './charts/sequence-scatter-kde/sequence-scatter-kde';\nexport * from './charts/sequence-scatter-pixel/sequence-scatter-pixel';\n\nexport * from './charts/bar-3d';\nexport * from './charts/funnel-3d';\nexport * from './charts/histogram-3d';\nexport * from './charts/pie-3d';\nexport * from './charts/combination-candlestick';\nexport * from './charts/word-cloud-3d';\nexport * from './charts/axis-3d';\nexport * from './charts/range-column-3d';\nexport { register3DPlugin } from './charts/3d/plugin';\nexport * from './charts/pictogram';\nexport * from './charts/image-cloud';\nexport * from './charts/candlestick';\nexport * from './charts/timeline';\nexport * from './charts/storyline';\n\nexport * from './components/series-break';\nexport * from './components/bar-link';\nexport * from './components/series-label';\nexport * from './components/map-label';\nexport * from './components/regression-line';\nexport * from './components/scatter-regression-line';\nexport * from './components/bar-regression-line';\nexport * from './components/histogram-regression-line';\nexport * from './components/extension-mark-sync-state';\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './interface';
2
+ export * from './layout';
3
+ export * from './storyline';
4
+ export * from './storyline-transformer';
@@ -0,0 +1,8 @@
1
+ export * from "./interface";
2
+
3
+ export * from "./layout";
4
+
5
+ export * from "./storyline";
6
+
7
+ export * from "./storyline-transformer";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC","file":"index.js","sourcesContent":["export * from './interface';\nexport * from './layout';\nexport * from './storyline';\nexport * from './storyline-transformer';\n"]}
@@ -0,0 +1,59 @@
1
+ import type { IChartSpec, IComposedTextMarkSpec, IImageMarkSpec, IMarkSpec, IPathMarkSpec, IRectMarkSpec, ITextMarkSpec, StringOrNumber } from '@visactor/vchart';
2
+ export type StorylineLayoutType = 'clock' | 'bowl' | 'dome' | 'left-wing' | 'right-wing' | 'landscape' | 'portrait' | 'up-ladder' | 'down-ladder' | 'pulse' | 'spiral';
3
+ export type StorylineImagePosition = 'top' | 'left' | 'right' | 'bottom';
4
+ export type StorylineLineType = 'line' | 'polyline' | 'curve';
5
+ export interface IStorylineBlock {
6
+ id?: StringOrNumber;
7
+ title?: string;
8
+ content?: string | string[];
9
+ image?: string | HTMLImageElement | HTMLCanvasElement;
10
+ datum?: unknown;
11
+ }
12
+ export interface IStorylineLayoutOptions {
13
+ type: StorylineLayoutType;
14
+ padding?: number | [number, number, number, number];
15
+ radiusRatio?: number;
16
+ startAngle?: number;
17
+ endAngle?: number;
18
+ }
19
+ export interface IStorylineBlockSpec {
20
+ width?: number;
21
+ widthRatio?: number;
22
+ minWidth?: number;
23
+ maxWidth?: number;
24
+ height?: number;
25
+ padding?: number | [number, number, number, number];
26
+ gap?: number;
27
+ style?: Partial<IRectMarkSpec>;
28
+ }
29
+ export interface IStorylineImageSpec extends IMarkSpec<IImageMarkSpec> {
30
+ width?: number;
31
+ height?: number;
32
+ position?: StorylineImagePosition;
33
+ gap?: number;
34
+ }
35
+ export interface IStorylineCenterImageSpec extends IMarkSpec<IImageMarkSpec> {
36
+ width?: number;
37
+ height?: number;
38
+ visible?: boolean;
39
+ image?: string | HTMLImageElement | HTMLCanvasElement;
40
+ }
41
+ export interface IStorylineLineSpec extends IMarkSpec<IPathMarkSpec> {
42
+ visible?: boolean;
43
+ type?: StorylineLineType;
44
+ showArrow?: boolean;
45
+ arrowSize?: number;
46
+ distance?: number;
47
+ }
48
+ export interface IStorylineSpec extends Omit<IChartSpec, 'type' | 'data' | 'series' | 'title' | 'layout'> {
49
+ type: 'storyline';
50
+ data: IStorylineBlock[];
51
+ layout?: StorylineLayoutType | IStorylineLayoutOptions;
52
+ block?: IStorylineBlockSpec;
53
+ title?: IMarkSpec<ITextMarkSpec>;
54
+ content?: IMarkSpec<IComposedTextMarkSpec>;
55
+ image?: IStorylineImageSpec;
56
+ centerImage?: IStorylineCenterImageSpec;
57
+ line?: IStorylineLineSpec;
58
+ themeColor?: string;
59
+ }
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type {\n IChartSpec,\n IComposedTextMarkSpec,\n IImageMarkSpec,\n IMarkSpec,\n IPathMarkSpec,\n IRectMarkSpec,\n ITextMarkSpec,\n StringOrNumber\n} from '@visactor/vchart';\n\nexport type StorylineLayoutType =\n | 'clock'\n | 'bowl'\n | 'dome'\n | 'left-wing'\n | 'right-wing'\n | 'landscape'\n | 'portrait'\n | 'up-ladder'\n | 'down-ladder'\n | 'pulse'\n | 'spiral';\n\nexport type StorylineImagePosition = 'top' | 'left' | 'right' | 'bottom';\nexport type StorylineLineType = 'line' | 'polyline' | 'curve';\n\nexport interface IStorylineBlock {\n id?: StringOrNumber;\n title?: string;\n content?: string | string[];\n image?: string | HTMLImageElement | HTMLCanvasElement;\n datum?: unknown;\n}\n\nexport interface IStorylineLayoutOptions {\n type: StorylineLayoutType;\n /**\n * 边缘留白,支持单值或 [top, right, bottom, left]。\n */\n padding?: number | [number, number, number, number];\n /**\n * 对 circular/arc 布局生效,控制半径占可用空间的比例。\n */\n radiusRatio?: number;\n /**\n * 对 circular/arc 布局生效,角度单位为度。\n */\n startAngle?: number;\n /**\n * 对 circular/arc 布局生效,角度单位为度。\n */\n endAngle?: number;\n}\n\nexport interface IStorylineBlockSpec {\n width?: number;\n widthRatio?: number;\n minWidth?: number;\n maxWidth?: number;\n height?: number;\n padding?: number | [number, number, number, number];\n gap?: number;\n style?: Partial<IRectMarkSpec>;\n}\n\nexport interface IStorylineImageSpec extends IMarkSpec<IImageMarkSpec> {\n width?: number;\n height?: number;\n position?: StorylineImagePosition;\n gap?: number;\n}\n\nexport interface IStorylineCenterImageSpec extends IMarkSpec<IImageMarkSpec> {\n width?: number;\n height?: number;\n visible?: boolean;\n image?: string | HTMLImageElement | HTMLCanvasElement;\n}\n\nexport interface IStorylineLineSpec extends IMarkSpec<IPathMarkSpec> {\n visible?: boolean;\n type?: StorylineLineType;\n showArrow?: boolean;\n arrowSize?: number;\n /**\n * 连接线和 block 边缘之间的距离。\n */\n distance?: number;\n}\n\nexport interface IStorylineSpec extends Omit<IChartSpec, 'type' | 'data' | 'series' | 'title' | 'layout'> {\n type: 'storyline';\n data: IStorylineBlock[];\n layout?: StorylineLayoutType | IStorylineLayoutOptions;\n block?: IStorylineBlockSpec;\n title?: IMarkSpec<ITextMarkSpec>;\n content?: IMarkSpec<IComposedTextMarkSpec>;\n image?: IStorylineImageSpec;\n centerImage?: IStorylineCenterImageSpec;\n line?: IStorylineLineSpec;\n themeColor?: string;\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import type { IStorylineBlock, IStorylineLayoutOptions, StorylineLayoutType } from './interface';
2
+ export interface StorylineSize {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ export interface StorylinePadding {
7
+ top: number;
8
+ right: number;
9
+ bottom: number;
10
+ left: number;
11
+ }
12
+ export interface StorylinePoint {
13
+ x: number;
14
+ y: number;
15
+ }
16
+ export interface StorylineBlockPosition extends StorylinePoint, StorylineSize {
17
+ id: string | number;
18
+ index: number;
19
+ datum: IStorylineBlock;
20
+ center: StorylinePoint;
21
+ }
22
+ export interface StorylineLinkPosition {
23
+ from: StorylineBlockPosition;
24
+ to: StorylineBlockPosition;
25
+ start: StorylinePoint;
26
+ end: StorylinePoint;
27
+ points: StorylinePoint[];
28
+ }
29
+ export interface StorylineCircleGuide {
30
+ center: StorylinePoint;
31
+ radius: number;
32
+ }
33
+ export interface StorylineLayoutResult {
34
+ blocks: StorylineBlockPosition[];
35
+ links: StorylineLinkPosition[];
36
+ circleGuide?: StorylineCircleGuide;
37
+ }
38
+ export interface StorylineComputeOptions {
39
+ layout: StorylineLayoutType | IStorylineLayoutOptions | undefined;
40
+ viewBox: StorylineSize;
41
+ block: StorylineSize;
42
+ gap?: number;
43
+ padding?: number | [number, number, number, number];
44
+ lineDistance?: number;
45
+ }
46
+ export declare const normalizePadding: (padding?: number | [
47
+ number,
48
+ number,
49
+ number,
50
+ number
51
+ ]) => StorylinePadding;
52
+ export declare const normalizeLayout: (layout?: StorylineLayoutType | IStorylineLayoutOptions) => IStorylineLayoutOptions;
53
+ export declare const computeStorylineLayout: (data: IStorylineBlock[], options: StorylineComputeOptions) => StorylineLayoutResult;
@@ -0,0 +1,205 @@
1
+ const DEFAULT_LAYOUT = "landscape", DEFAULT_PADDING = 24;
2
+
3
+ export const normalizePadding = padding => {
4
+ var _a, _b, _c, _d;
5
+ if (Array.isArray(padding)) return {
6
+ top: null !== (_a = padding[0]) && void 0 !== _a ? _a : 0,
7
+ right: null !== (_b = padding[1]) && void 0 !== _b ? _b : 0,
8
+ bottom: null !== (_c = padding[2]) && void 0 !== _c ? _c : 0,
9
+ left: null !== (_d = padding[3]) && void 0 !== _d ? _d : 0
10
+ };
11
+ const value = null != padding ? padding : 24;
12
+ return {
13
+ top: value,
14
+ right: value,
15
+ bottom: value,
16
+ left: value
17
+ };
18
+ };
19
+
20
+ export const normalizeLayout = layout => layout ? "string" == typeof layout ? {
21
+ type: layout
22
+ } : layout : {
23
+ type: "landscape"
24
+ };
25
+
26
+ export const computeStorylineLayout = (data, options) => {
27
+ var _a, _b, _c;
28
+ const layout = normalizeLayout(options.layout), padding = normalizePadding(null !== (_a = layout.padding) && void 0 !== _a ? _a : options.padding), gap = null !== (_b = options.gap) && void 0 !== _b ? _b : 40, lineDistance = null !== (_c = options.lineDistance) && void 0 !== _c ? _c : 8, blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap), circleGuide = "clock" === layout.type ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : void 0;
29
+ return {
30
+ blocks: blocks,
31
+ links: computeLinks(blocks, lineDistance),
32
+ circleGuide: circleGuide
33
+ };
34
+ };
35
+
36
+ const computeBlockPositions = (data, layout, viewBox, block, padding, gap) => {
37
+ const count = data.length;
38
+ if (!count) return [];
39
+ const inner = {
40
+ x: padding.left,
41
+ y: padding.top,
42
+ width: Math.max(viewBox.width - padding.left - padding.right, block.width),
43
+ height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)
44
+ }, center = {
45
+ x: inner.x + inner.width / 2,
46
+ y: inner.y + inner.height / 2
47
+ };
48
+ let centers;
49
+ switch (layout.type) {
50
+ case "portrait":
51
+ centers = lineCenters(count, center.x, inner.y + block.height / 2, center.x, inner.y + inner.height - block.height / 2);
52
+ break;
53
+
54
+ case "up-ladder":
55
+ 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);
56
+ break;
57
+
58
+ case "down-ladder":
59
+ 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);
60
+ break;
61
+
62
+ case "pulse":
63
+ centers = alternatingHorizontalCenters(count, inner, block, gap);
64
+ break;
65
+
66
+ case "spiral":
67
+ centers = alternatingVerticalCenters(count, inner, block, gap);
68
+ break;
69
+
70
+ case "clock":
71
+ centers = circularCenters(count, viewBox, block, padding, layout);
72
+ break;
73
+
74
+ case "bowl":
75
+ centers = arcCenters(count, inner, block, layout, 200, 340);
76
+ break;
77
+
78
+ case "dome":
79
+ centers = arcCenters(count, inner, block, layout, 160, 20);
80
+ break;
81
+
82
+ case "left-wing":
83
+ centers = arcCenters(count, inner, block, layout, 250, 110);
84
+ break;
85
+
86
+ case "right-wing":
87
+ centers = arcCenters(count, inner, block, layout, -70, 70);
88
+ break;
89
+
90
+ default:
91
+ centers = lineCenters(count, inner.x + block.width / 2, center.y, inner.x + inner.width - block.width / 2, center.y);
92
+ }
93
+ return centers.map(((point, index) => {
94
+ var _a, _b;
95
+ return {
96
+ id: null !== (_b = null === (_a = data[index]) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : index,
97
+ index: index,
98
+ datum: data[index],
99
+ width: block.width,
100
+ height: block.height,
101
+ x: point.x - block.width / 2,
102
+ y: point.y - block.height / 2,
103
+ center: point
104
+ };
105
+ }));
106
+ }, lineCenters = (count, x0, y0, x1, y1) => 1 === count ? [ {
107
+ x: (x0 + x1) / 2,
108
+ y: (y0 + y1) / 2
109
+ } ] : Array.from({
110
+ length: count
111
+ }, ((_, index) => {
112
+ const t = index / (count - 1);
113
+ return {
114
+ x: x0 + (x1 - x0) * t,
115
+ y: y0 + (y1 - y0) * t
116
+ };
117
+ })), alternatingHorizontalCenters = (count, inner, block, gap) => {
118
+ const baseY = inner.y + inner.height / 2, offset = Math.min(Math.max(.65 * block.height + gap / 2, 0), Math.max((inner.height - block.height) / 2, 0));
119
+ return lineCenters(count, inner.x + block.width / 2, baseY, inner.x + inner.width - block.width / 2, baseY).map(((point, index) => ({
120
+ x: point.x,
121
+ y: point.y + (index % 2 == 0 ? -offset : offset)
122
+ })));
123
+ }, alternatingVerticalCenters = (count, inner, block, gap) => {
124
+ const baseX = inner.x + inner.width / 2, offset = Math.min(Math.max(.65 * block.width + gap / 2, 0), Math.max((inner.width - block.width) / 2, 0));
125
+ return lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2).map(((point, index) => ({
126
+ x: point.x + (index % 2 == 0 ? -offset : offset),
127
+ y: point.y
128
+ })));
129
+ }, circularCenters = (count, viewBox, block, padding, layout) => {
130
+ var _a;
131
+ const guide = computeClockCircleGuide(viewBox, block, padding, layout), startAngle = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : -90;
132
+ if (1 === count) {
133
+ const angle = degreeToRadian(startAngle);
134
+ return [ {
135
+ x: guide.center.x + Math.cos(angle) * guide.radius,
136
+ y: guide.center.y + Math.sin(angle) * guide.radius
137
+ } ];
138
+ }
139
+ return Array.from({
140
+ length: count
141
+ }, ((_, index) => {
142
+ const angle = degreeToRadian(startAngle + 360 * index / count);
143
+ return {
144
+ x: guide.center.x + Math.cos(angle) * guide.radius,
145
+ y: guide.center.y + Math.sin(angle) * guide.radius
146
+ };
147
+ }));
148
+ }, computeClockCircleGuide = (viewBox, block, padding, layout) => {
149
+ var _a;
150
+ const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1), innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1), center = {
151
+ x: padding.left + innerWidth / 2,
152
+ y: padding.top + innerHeight / 2
153
+ }, ratio = null !== (_a = layout.radiusRatio) && void 0 !== _a ? _a : .7, maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
154
+ return {
155
+ center: center,
156
+ radius: Math.max(1, maxRadius * ratio)
157
+ };
158
+ }, arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = .88) => {
159
+ var _a, _b, _c, _d, _e;
160
+ const startAngle = null !== (_b = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : fallbackStartAngle) && void 0 !== _b ? _b : -90, endAngle = null !== (_d = null !== (_c = layout.endAngle) && void 0 !== _c ? _c : fallbackEndAngle) && void 0 !== _d ? _d : 270, ratio = null !== (_e = layout.radiusRatio) && void 0 !== _e ? _e : defaultRatio, rx = Math.max((inner.width - block.width) / 2, 1) * ratio, ry = Math.max((inner.height - block.height) / 2, 1) * ratio, center_x = inner.x + inner.width / 2, center_y = inner.y + inner.height / 2;
161
+ if (1 === count) {
162
+ const angle = degreeToRadian((startAngle + endAngle) / 2);
163
+ return [ {
164
+ x: center_x + Math.cos(angle) * rx,
165
+ y: center_y + Math.sin(angle) * ry
166
+ } ];
167
+ }
168
+ return Array.from({
169
+ length: count
170
+ }, ((_, index) => {
171
+ const t = index / (count - 1), angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
172
+ return {
173
+ x: center_x + Math.cos(angle) * rx,
174
+ y: center_y + Math.sin(angle) * ry
175
+ };
176
+ }));
177
+ }, angleDelta = (startAngle, endAngle) => {
178
+ const delta = endAngle - startAngle;
179
+ return Math.abs(delta) >= 360 ? 360 : delta;
180
+ }, degreeToRadian = degree => degree / 180 * Math.PI, computeLinks = (blocks, distance) => {
181
+ const links = [];
182
+ for (let i = 0; i < blocks.length - 1; i++) {
183
+ const from = blocks[i], to = blocks[i + 1], start = pointOnBlockEdge(from, to.center, distance), end = pointOnBlockEdge(to, from.center, distance);
184
+ links.push({
185
+ from: from,
186
+ to: to,
187
+ start: start,
188
+ end: end,
189
+ points: [ start, end ]
190
+ });
191
+ }
192
+ return links;
193
+ }, pointOnBlockEdge = (block, toward, distance) => {
194
+ const dx = toward.x - block.center.x, dy = toward.y - block.center.y;
195
+ if (0 === dx && 0 === dy) return {
196
+ x: block.center.x,
197
+ y: block.center.y
198
+ };
199
+ const scaleX = 0 === dx ? Number.POSITIVE_INFINITY : block.width / 2 / Math.abs(dx), scaleY = 0 === dy ? Number.POSITIVE_INFINITY : block.height / 2 / Math.abs(dy), scale = Math.min(scaleX, scaleY), length = Math.sqrt(dx * dx + dy * dy) || 1;
200
+ return {
201
+ x: block.center.x + dx * scale + dx / length * distance,
202
+ y: block.center.y + dy * scale + dy / length * distance
203
+ };
204
+ };
205
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/storyline/layout.ts"],"names":[],"mappings":"AAsDA,MAAM,cAAc,GAAwB,WAAW,CAAC;AACxD,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAmD,EAAoB,EAAE;;IACxG,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC1B,OAAO;YACL,GAAG,EAAE,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,CAAC;YACpB,KAAK,EAAE,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,CAAC;YACtB,MAAM,EAAE,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,CAAC;YACvB,IAAI,EAAE,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,CAAC;SACtB,CAAC;KACH;IAC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AAE,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ;KAC1D,CAAC;AACJ,CAAC,CAAC","file":"layout.js","sourcesContent":["import type { IStorylineBlock, IStorylineLayoutOptions, StorylineLayoutType } from './interface';\n\nexport interface StorylineSize {\n width: number;\n height: number;\n}\n\nexport interface StorylinePadding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface StorylinePoint {\n x: number;\n y: number;\n}\n\nexport interface StorylineBlockPosition extends StorylinePoint, StorylineSize {\n id: string | number;\n index: number;\n datum: IStorylineBlock;\n center: StorylinePoint;\n}\n\nexport interface StorylineLinkPosition {\n from: StorylineBlockPosition;\n to: StorylineBlockPosition;\n start: StorylinePoint;\n end: StorylinePoint;\n points: StorylinePoint[];\n}\n\nexport interface StorylineCircleGuide {\n center: StorylinePoint;\n radius: number;\n}\n\nexport interface StorylineLayoutResult {\n blocks: StorylineBlockPosition[];\n links: StorylineLinkPosition[];\n circleGuide?: StorylineCircleGuide;\n}\n\nexport interface StorylineComputeOptions {\n layout: StorylineLayoutType | IStorylineLayoutOptions | undefined;\n viewBox: StorylineSize;\n block: StorylineSize;\n gap?: number;\n padding?: number | [number, number, number, number];\n lineDistance?: number;\n}\n\nconst DEFAULT_LAYOUT: StorylineLayoutType = 'landscape';\nconst DEFAULT_PADDING = 24;\n\nexport const normalizePadding = (padding?: number | [number, number, number, number]): StorylinePadding => {\n if (Array.isArray(padding)) {\n return {\n top: padding[0] ?? 0,\n right: padding[1] ?? 0,\n bottom: padding[2] ?? 0,\n left: padding[3] ?? 0\n };\n }\n const value = padding ?? DEFAULT_PADDING;\n return { top: value, right: value, bottom: value, left: value };\n};\n\nexport const normalizeLayout = (layout?: StorylineLayoutType | IStorylineLayoutOptions): IStorylineLayoutOptions => {\n if (!layout) {\n return { type: DEFAULT_LAYOUT };\n }\n if (typeof layout === 'string') {\n return { type: layout };\n }\n return layout;\n};\n\nexport const computeStorylineLayout = (\n data: IStorylineBlock[],\n options: StorylineComputeOptions\n): StorylineLayoutResult => {\n const layout = normalizeLayout(options.layout);\n const padding = normalizePadding(layout.padding ?? options.padding);\n const gap = options.gap ?? 40;\n const lineDistance = options.lineDistance ?? 8;\n const blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap);\n const circleGuide =\n layout.type === 'clock' ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : undefined;\n return {\n blocks,\n links: computeLinks(blocks, lineDistance),\n circleGuide\n };\n};\n\nconst computeBlockPositions = (\n data: IStorylineBlock[],\n layout: IStorylineLayoutOptions,\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n gap: number\n): StorylineBlockPosition[] => {\n const count = data.length;\n if (!count) {\n return [];\n }\n\n const inner = {\n x: padding.left,\n y: padding.top,\n width: Math.max(viewBox.width - padding.left - padding.right, block.width),\n height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)\n };\n const center = {\n x: inner.x + inner.width / 2,\n y: inner.y + inner.height / 2\n };\n\n let centers: StorylinePoint[];\n switch (layout.type) {\n case 'portrait':\n centers = lineCenters(\n count,\n center.x,\n inner.y + block.height / 2,\n center.x,\n inner.y + inner.height - block.height / 2\n );\n break;\n case 'up-ladder':\n centers = lineCenters(\n count,\n inner.x + block.width / 2,\n inner.y + inner.height - block.height / 2,\n inner.x + inner.width - block.width / 2,\n inner.y + block.height / 2\n );\n break;\n case 'down-ladder':\n centers = lineCenters(\n count,\n inner.x + block.width / 2,\n inner.y + block.height / 2,\n inner.x + inner.width - block.width / 2,\n inner.y + inner.height - block.height / 2\n );\n break;\n case 'pulse':\n centers = alternatingHorizontalCenters(count, inner, block, gap);\n break;\n case 'spiral':\n centers = alternatingVerticalCenters(count, inner, block, gap);\n break;\n case 'clock':\n centers = circularCenters(count, viewBox, block, padding, layout);\n break;\n case 'bowl':\n centers = arcCenters(count, inner, block, layout, 200, 340);\n break;\n case 'dome':\n centers = arcCenters(count, inner, block, layout, 160, 20);\n break;\n case 'left-wing':\n centers = arcCenters(count, inner, block, layout, 250, 110);\n break;\n case 'right-wing':\n centers = arcCenters(count, inner, block, layout, -70, 70);\n break;\n case 'landscape':\n default:\n centers = lineCenters(\n count,\n inner.x + block.width / 2,\n center.y,\n inner.x + inner.width - block.width / 2,\n center.y\n );\n break;\n }\n\n return centers.map((point, index) => ({\n id: data[index]?.id ?? index,\n index,\n datum: data[index],\n width: block.width,\n height: block.height,\n x: point.x - block.width / 2,\n y: point.y - block.height / 2,\n center: point\n }));\n};\n\nconst lineCenters = (count: number, x0: number, y0: number, x1: number, y1: number): StorylinePoint[] => {\n if (count === 1) {\n return [{ x: (x0 + x1) / 2, y: (y0 + y1) / 2 }];\n }\n return Array.from({ length: count }, (_, index) => {\n const t = index / (count - 1);\n return {\n x: x0 + (x1 - x0) * t,\n y: y0 + (y1 - y0) * t\n };\n });\n};\n\nconst alternatingHorizontalCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n gap: number\n) => {\n const baseY = inner.y + inner.height / 2;\n const offset = Math.min(Math.max(block.height * 0.65 + gap / 2, 0), Math.max((inner.height - block.height) / 2, 0));\n const points = lineCenters(count, inner.x + block.width / 2, baseY, inner.x + inner.width - block.width / 2, baseY);\n return points.map((point, index) => ({\n x: point.x,\n y: point.y + (index % 2 === 0 ? -offset : offset)\n }));\n};\n\nconst alternatingVerticalCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n gap: number\n) => {\n const baseX = inner.x + inner.width / 2;\n const offset = Math.min(Math.max(block.width * 0.65 + gap / 2, 0), Math.max((inner.width - block.width) / 2, 0));\n const points = lineCenters(\n count,\n baseX,\n inner.y + block.height / 2,\n baseX,\n inner.y + inner.height - block.height / 2\n );\n return points.map((point, index) => ({\n x: point.x + (index % 2 === 0 ? -offset : offset),\n y: point.y\n }));\n};\n\nconst circularCenters = (\n count: number,\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n layout: IStorylineLayoutOptions\n) => {\n const guide = computeClockCircleGuide(viewBox, block, padding, layout);\n const startAngle = layout.startAngle ?? -90;\n const delta = 360;\n\n if (count === 1) {\n const angle = degreeToRadian(startAngle);\n return [\n {\n x: guide.center.x + Math.cos(angle) * guide.radius,\n y: guide.center.y + Math.sin(angle) * guide.radius\n }\n ];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const angle = degreeToRadian(startAngle + (delta * index) / count);\n return {\n x: guide.center.x + Math.cos(angle) * guide.radius,\n y: guide.center.y + Math.sin(angle) * guide.radius\n };\n });\n};\n\nconst computeClockCircleGuide = (\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n layout: IStorylineLayoutOptions\n): StorylineCircleGuide => {\n const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1);\n const innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1);\n const center = {\n x: padding.left + innerWidth / 2,\n y: padding.top + innerHeight / 2\n };\n const ratio = layout.radiusRatio ?? 0.7;\n const maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);\n\n return {\n center,\n radius: Math.max(1, maxRadius * ratio)\n };\n};\n\nconst arcCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n layout: IStorylineLayoutOptions,\n fallbackStartAngle?: number,\n fallbackEndAngle?: number,\n defaultRatio = 0.88\n) => {\n const startAngle = layout.startAngle ?? fallbackStartAngle ?? -90;\n const endAngle = layout.endAngle ?? fallbackEndAngle ?? 270;\n const ratio = layout.radiusRatio ?? defaultRatio;\n const rx = Math.max((inner.width - block.width) / 2, 1) * ratio;\n const ry = Math.max((inner.height - block.height) / 2, 1) * ratio;\n const center = {\n x: inner.x + inner.width / 2,\n y: inner.y + inner.height / 2\n };\n\n if (count === 1) {\n const angle = degreeToRadian((startAngle + endAngle) / 2);\n return [{ x: center.x + Math.cos(angle) * rx, y: center.y + Math.sin(angle) * ry }];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const t = index / (count - 1);\n const angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);\n return {\n x: center.x + Math.cos(angle) * rx,\n y: center.y + Math.sin(angle) * ry\n };\n });\n};\n\nconst angleDelta = (startAngle: number, endAngle: number) => {\n const delta = endAngle - startAngle;\n return Math.abs(delta) >= 360 ? 360 : delta;\n};\n\nconst degreeToRadian = (degree: number) => (degree / 180) * Math.PI;\n\nconst computeLinks = (blocks: StorylineBlockPosition[], distance: number): StorylineLinkPosition[] => {\n const links: StorylineLinkPosition[] = [];\n for (let i = 0; i < blocks.length - 1; i++) {\n const from = blocks[i];\n const to = blocks[i + 1];\n const start = pointOnBlockEdge(from, to.center, distance);\n const end = pointOnBlockEdge(to, from.center, distance);\n links.push({\n from,\n to,\n start,\n end,\n points: [start, end]\n });\n }\n return links;\n};\n\nconst pointOnBlockEdge = (block: StorylineBlockPosition, toward: StorylinePoint, distance: number): StorylinePoint => {\n const dx = toward.x - block.center.x;\n const dy = toward.y - block.center.y;\n if (dx === 0 && dy === 0) {\n return { x: block.center.x, y: block.center.y };\n }\n const scaleX = dx === 0 ? Number.POSITIVE_INFINITY : block.width / 2 / Math.abs(dx);\n const scaleY = dy === 0 ? Number.POSITIVE_INFINITY : block.height / 2 / Math.abs(dy);\n const scale = Math.min(scaleX, scaleY);\n const length = Math.sqrt(dx * dx + dy * dy) || 1;\n return {\n x: block.center.x + dx * scale + (dx / length) * distance,\n y: block.center.y + dy * scale + (dy / length) * distance\n };\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IExtensionGroupMarkSpec } from '@visactor/vchart';
2
+ import type { IStorylineBlock, IStorylineSpec } from '../interface';
3
+ export declare const buildBowlArcMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
4
+ export declare const buildBowlCenterImageMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
5
+ export declare const buildBowlBlockMark: (spec: IStorylineSpec, block: IStorylineBlock, index: number) => IExtensionGroupMarkSpec;