@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.
- package/build/index.js +1960 -0
- package/build/index.min.js +2 -2
- package/cjs/charts/storyline/index.d.ts +4 -0
- package/cjs/charts/storyline/index.js +22 -0
- package/cjs/charts/storyline/index.js.map +1 -0
- package/cjs/charts/storyline/interface.d.ts +59 -0
- package/cjs/charts/storyline/interface.js +6 -0
- package/cjs/charts/storyline/interface.js.map +1 -0
- package/cjs/charts/storyline/layout.d.ts +53 -0
- package/cjs/charts/storyline/layout.js +215 -0
- package/cjs/charts/storyline/layout.js.map +1 -0
- package/cjs/charts/storyline/layouts/bowl.d.ts +5 -0
- package/cjs/charts/storyline/layouts/bowl.js +286 -0
- package/cjs/charts/storyline/layouts/bowl.js.map +1 -0
- package/cjs/charts/storyline/layouts/clock.d.ts +5 -0
- package/cjs/charts/storyline/layouts/clock.js +233 -0
- package/cjs/charts/storyline/layouts/clock.js.map +1 -0
- package/cjs/charts/storyline/layouts/common.d.ts +87 -0
- package/cjs/charts/storyline/layouts/common.js +287 -0
- package/cjs/charts/storyline/layouts/common.js.map +1 -0
- package/cjs/charts/storyline/layouts/default.d.ts +4 -0
- package/cjs/charts/storyline/layouts/default.js +179 -0
- package/cjs/charts/storyline/layouts/default.js.map +1 -0
- package/cjs/charts/storyline/layouts/dome.d.ts +5 -0
- package/cjs/charts/storyline/layouts/dome.js +286 -0
- package/cjs/charts/storyline/layouts/dome.js.map +1 -0
- package/cjs/charts/storyline/layouts/landscape.d.ts +4 -0
- package/cjs/charts/storyline/layouts/landscape.js +254 -0
- package/cjs/charts/storyline/layouts/landscape.js.map +1 -0
- package/cjs/charts/storyline/layouts/portrait.d.ts +4 -0
- package/cjs/charts/storyline/layouts/portrait.js +241 -0
- package/cjs/charts/storyline/layouts/portrait.js.map +1 -0
- package/cjs/charts/storyline/storyline-transformer.d.ts +4 -0
- package/cjs/charts/storyline/storyline-transformer.js +62 -0
- package/cjs/charts/storyline/storyline-transformer.js.map +1 -0
- package/cjs/charts/storyline/storyline.d.ts +16 -0
- package/cjs/charts/storyline/storyline.js +36 -0
- package/cjs/charts/storyline/storyline.js.map +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +5 -5
- package/cjs/index.js.map +1 -1
- package/esm/charts/storyline/index.d.ts +4 -0
- package/esm/charts/storyline/index.js +8 -0
- package/esm/charts/storyline/index.js.map +1 -0
- package/esm/charts/storyline/interface.d.ts +59 -0
- package/esm/charts/storyline/interface.js +2 -0
- package/esm/charts/storyline/interface.js.map +1 -0
- package/esm/charts/storyline/layout.d.ts +53 -0
- package/esm/charts/storyline/layout.js +205 -0
- package/esm/charts/storyline/layout.js.map +1 -0
- package/esm/charts/storyline/layouts/bowl.d.ts +5 -0
- package/esm/charts/storyline/layouts/bowl.js +278 -0
- package/esm/charts/storyline/layouts/bowl.js.map +1 -0
- package/esm/charts/storyline/layouts/clock.d.ts +5 -0
- package/esm/charts/storyline/layouts/clock.js +227 -0
- package/esm/charts/storyline/layouts/clock.js.map +1 -0
- package/esm/charts/storyline/layouts/common.d.ts +87 -0
- package/esm/charts/storyline/layouts/common.js +255 -0
- package/esm/charts/storyline/layouts/common.js.map +1 -0
- package/esm/charts/storyline/layouts/default.d.ts +4 -0
- package/esm/charts/storyline/layouts/default.js +172 -0
- package/esm/charts/storyline/layouts/default.js.map +1 -0
- package/esm/charts/storyline/layouts/dome.d.ts +5 -0
- package/esm/charts/storyline/layouts/dome.js +278 -0
- package/esm/charts/storyline/layouts/dome.js.map +1 -0
- package/esm/charts/storyline/layouts/landscape.d.ts +4 -0
- package/esm/charts/storyline/layouts/landscape.js +250 -0
- package/esm/charts/storyline/layouts/landscape.js.map +1 -0
- package/esm/charts/storyline/layouts/portrait.d.ts +4 -0
- package/esm/charts/storyline/layouts/portrait.js +238 -0
- package/esm/charts/storyline/layouts/portrait.js.map +1 -0
- package/esm/charts/storyline/storyline-transformer.d.ts +4 -0
- package/esm/charts/storyline/storyline-transformer.js +61 -0
- package/esm/charts/storyline/storyline-transformer.js.map +1 -0
- package/esm/charts/storyline/storyline.d.ts +16 -0
- package/esm/charts/storyline/storyline.js +29 -0
- package/esm/charts/storyline/storyline.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./interface"), exports), __exportStar(require("./layout"), exports),
|
|
21
|
+
__exportStar(require("./storyline"), exports), __exportStar(require("./storyline-transformer"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/storyline/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,0DAAwC","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 @@
|
|
|
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,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.computeStorylineLayout = exports.normalizeLayout = exports.normalizePadding = void 0;
|
|
6
|
+
|
|
7
|
+
const DEFAULT_LAYOUT = "landscape", DEFAULT_PADDING = 24, normalizePadding = padding => {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
if (Array.isArray(padding)) return {
|
|
10
|
+
top: null !== (_a = padding[0]) && void 0 !== _a ? _a : 0,
|
|
11
|
+
right: null !== (_b = padding[1]) && void 0 !== _b ? _b : 0,
|
|
12
|
+
bottom: null !== (_c = padding[2]) && void 0 !== _c ? _c : 0,
|
|
13
|
+
left: null !== (_d = padding[3]) && void 0 !== _d ? _d : 0
|
|
14
|
+
};
|
|
15
|
+
const value = null != padding ? padding : 24;
|
|
16
|
+
return {
|
|
17
|
+
top: value,
|
|
18
|
+
right: value,
|
|
19
|
+
bottom: value,
|
|
20
|
+
left: value
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.normalizePadding = normalizePadding;
|
|
25
|
+
|
|
26
|
+
const normalizeLayout = layout => layout ? "string" == typeof layout ? {
|
|
27
|
+
type: layout
|
|
28
|
+
} : layout : {
|
|
29
|
+
type: "landscape"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.normalizeLayout = normalizeLayout;
|
|
33
|
+
|
|
34
|
+
const computeStorylineLayout = (data, options) => {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const layout = (0, exports.normalizeLayout)(options.layout), padding = (0, exports.normalizePadding)(null !== (_a = layout.padding) && void 0 !== _a ? _a : options.padding), gap = null !== (_b = options.gap) && void 0 !== _b ? _b : 40, lineDistance = null !== (_c = options.lineDistance) && void 0 !== _c ? _c : 8, blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap), circleGuide = "clock" === layout.type ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : void 0;
|
|
37
|
+
return {
|
|
38
|
+
blocks: blocks,
|
|
39
|
+
links: computeLinks(blocks, lineDistance),
|
|
40
|
+
circleGuide: circleGuide
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.computeStorylineLayout = computeStorylineLayout;
|
|
45
|
+
|
|
46
|
+
const computeBlockPositions = (data, layout, viewBox, block, padding, gap) => {
|
|
47
|
+
const count = data.length;
|
|
48
|
+
if (!count) return [];
|
|
49
|
+
const inner = {
|
|
50
|
+
x: padding.left,
|
|
51
|
+
y: padding.top,
|
|
52
|
+
width: Math.max(viewBox.width - padding.left - padding.right, block.width),
|
|
53
|
+
height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)
|
|
54
|
+
}, center = {
|
|
55
|
+
x: inner.x + inner.width / 2,
|
|
56
|
+
y: inner.y + inner.height / 2
|
|
57
|
+
};
|
|
58
|
+
let centers;
|
|
59
|
+
switch (layout.type) {
|
|
60
|
+
case "portrait":
|
|
61
|
+
centers = lineCenters(count, center.x, inner.y + block.height / 2, center.x, inner.y + inner.height - block.height / 2);
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case "up-ladder":
|
|
65
|
+
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);
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case "down-ladder":
|
|
69
|
+
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);
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
case "pulse":
|
|
73
|
+
centers = alternatingHorizontalCenters(count, inner, block, gap);
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case "spiral":
|
|
77
|
+
centers = alternatingVerticalCenters(count, inner, block, gap);
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case "clock":
|
|
81
|
+
centers = circularCenters(count, viewBox, block, padding, layout);
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
case "bowl":
|
|
85
|
+
centers = arcCenters(count, inner, block, layout, 200, 340);
|
|
86
|
+
break;
|
|
87
|
+
|
|
88
|
+
case "dome":
|
|
89
|
+
centers = arcCenters(count, inner, block, layout, 160, 20);
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case "left-wing":
|
|
93
|
+
centers = arcCenters(count, inner, block, layout, 250, 110);
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case "right-wing":
|
|
97
|
+
centers = arcCenters(count, inner, block, layout, -70, 70);
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
default:
|
|
101
|
+
centers = lineCenters(count, inner.x + block.width / 2, center.y, inner.x + inner.width - block.width / 2, center.y);
|
|
102
|
+
}
|
|
103
|
+
return centers.map(((point, index) => {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
return {
|
|
106
|
+
id: null !== (_b = null === (_a = data[index]) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : index,
|
|
107
|
+
index: index,
|
|
108
|
+
datum: data[index],
|
|
109
|
+
width: block.width,
|
|
110
|
+
height: block.height,
|
|
111
|
+
x: point.x - block.width / 2,
|
|
112
|
+
y: point.y - block.height / 2,
|
|
113
|
+
center: point
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
}, lineCenters = (count, x0, y0, x1, y1) => 1 === count ? [ {
|
|
117
|
+
x: (x0 + x1) / 2,
|
|
118
|
+
y: (y0 + y1) / 2
|
|
119
|
+
} ] : Array.from({
|
|
120
|
+
length: count
|
|
121
|
+
}, ((_, index) => {
|
|
122
|
+
const t = index / (count - 1);
|
|
123
|
+
return {
|
|
124
|
+
x: x0 + (x1 - x0) * t,
|
|
125
|
+
y: y0 + (y1 - y0) * t
|
|
126
|
+
};
|
|
127
|
+
})), alternatingHorizontalCenters = (count, inner, block, gap) => {
|
|
128
|
+
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));
|
|
129
|
+
return lineCenters(count, inner.x + block.width / 2, baseY, inner.x + inner.width - block.width / 2, baseY).map(((point, index) => ({
|
|
130
|
+
x: point.x,
|
|
131
|
+
y: point.y + (index % 2 == 0 ? -offset : offset)
|
|
132
|
+
})));
|
|
133
|
+
}, alternatingVerticalCenters = (count, inner, block, gap) => {
|
|
134
|
+
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));
|
|
135
|
+
return lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2).map(((point, index) => ({
|
|
136
|
+
x: point.x + (index % 2 == 0 ? -offset : offset),
|
|
137
|
+
y: point.y
|
|
138
|
+
})));
|
|
139
|
+
}, circularCenters = (count, viewBox, block, padding, layout) => {
|
|
140
|
+
var _a;
|
|
141
|
+
const guide = computeClockCircleGuide(viewBox, block, padding, layout), startAngle = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : -90;
|
|
142
|
+
if (1 === count) {
|
|
143
|
+
const angle = degreeToRadian(startAngle);
|
|
144
|
+
return [ {
|
|
145
|
+
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
146
|
+
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
147
|
+
} ];
|
|
148
|
+
}
|
|
149
|
+
return Array.from({
|
|
150
|
+
length: count
|
|
151
|
+
}, ((_, index) => {
|
|
152
|
+
const angle = degreeToRadian(startAngle + 360 * index / count);
|
|
153
|
+
return {
|
|
154
|
+
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
155
|
+
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
156
|
+
};
|
|
157
|
+
}));
|
|
158
|
+
}, computeClockCircleGuide = (viewBox, block, padding, layout) => {
|
|
159
|
+
var _a;
|
|
160
|
+
const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1), innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1), center = {
|
|
161
|
+
x: padding.left + innerWidth / 2,
|
|
162
|
+
y: padding.top + innerHeight / 2
|
|
163
|
+
}, ratio = null !== (_a = layout.radiusRatio) && void 0 !== _a ? _a : .7, maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
|
|
164
|
+
return {
|
|
165
|
+
center: center,
|
|
166
|
+
radius: Math.max(1, maxRadius * ratio)
|
|
167
|
+
};
|
|
168
|
+
}, arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = .88) => {
|
|
169
|
+
var _a, _b, _c, _d, _e;
|
|
170
|
+
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;
|
|
171
|
+
if (1 === count) {
|
|
172
|
+
const angle = degreeToRadian((startAngle + endAngle) / 2);
|
|
173
|
+
return [ {
|
|
174
|
+
x: center_x + Math.cos(angle) * rx,
|
|
175
|
+
y: center_y + Math.sin(angle) * ry
|
|
176
|
+
} ];
|
|
177
|
+
}
|
|
178
|
+
return Array.from({
|
|
179
|
+
length: count
|
|
180
|
+
}, ((_, index) => {
|
|
181
|
+
const t = index / (count - 1), angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
|
|
182
|
+
return {
|
|
183
|
+
x: center_x + Math.cos(angle) * rx,
|
|
184
|
+
y: center_y + Math.sin(angle) * ry
|
|
185
|
+
};
|
|
186
|
+
}));
|
|
187
|
+
}, angleDelta = (startAngle, endAngle) => {
|
|
188
|
+
const delta = endAngle - startAngle;
|
|
189
|
+
return Math.abs(delta) >= 360 ? 360 : delta;
|
|
190
|
+
}, degreeToRadian = degree => degree / 180 * Math.PI, computeLinks = (blocks, distance) => {
|
|
191
|
+
const links = [];
|
|
192
|
+
for (let i = 0; i < blocks.length - 1; i++) {
|
|
193
|
+
const from = blocks[i], to = blocks[i + 1], start = pointOnBlockEdge(from, to.center, distance), end = pointOnBlockEdge(to, from.center, distance);
|
|
194
|
+
links.push({
|
|
195
|
+
from: from,
|
|
196
|
+
to: to,
|
|
197
|
+
start: start,
|
|
198
|
+
end: end,
|
|
199
|
+
points: [ start, end ]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return links;
|
|
203
|
+
}, pointOnBlockEdge = (block, toward, distance) => {
|
|
204
|
+
const dx = toward.x - block.center.x, dy = toward.y - block.center.y;
|
|
205
|
+
if (0 === dx && 0 === dy) return {
|
|
206
|
+
x: block.center.x,
|
|
207
|
+
y: block.center.y
|
|
208
|
+
};
|
|
209
|
+
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;
|
|
210
|
+
return {
|
|
211
|
+
x: block.center.x + dx * scale + dx / length * distance,
|
|
212
|
+
y: block.center.y + dy * scale + dy / length * distance
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
//# 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;AAEpB,MAAM,gBA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AAM,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ;QACzD,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ;KAC1D,CAAC;AACJ,CAAC,CAAC","file":"layout.js","sourcesContent":["import type { IStorylineBlock, IStorylineLayoutOptions, StorylineLayoutType } from './interface';\n\nexport interface StorylineSize {\n width: number;\n height: number;\n}\n\nexport interface StorylinePadding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface StorylinePoint {\n x: number;\n y: number;\n}\n\nexport interface StorylineBlockPosition extends StorylinePoint, StorylineSize {\n id: string | number;\n index: number;\n datum: IStorylineBlock;\n center: StorylinePoint;\n}\n\nexport interface StorylineLinkPosition {\n from: StorylineBlockPosition;\n to: StorylineBlockPosition;\n start: StorylinePoint;\n end: StorylinePoint;\n points: StorylinePoint[];\n}\n\nexport interface StorylineCircleGuide {\n center: StorylinePoint;\n radius: number;\n}\n\nexport interface StorylineLayoutResult {\n blocks: StorylineBlockPosition[];\n links: StorylineLinkPosition[];\n circleGuide?: StorylineCircleGuide;\n}\n\nexport interface StorylineComputeOptions {\n layout: StorylineLayoutType | IStorylineLayoutOptions | undefined;\n viewBox: StorylineSize;\n block: StorylineSize;\n gap?: number;\n padding?: number | [number, number, number, number];\n lineDistance?: number;\n}\n\nconst DEFAULT_LAYOUT: StorylineLayoutType = 'landscape';\nconst DEFAULT_PADDING = 24;\n\nexport const normalizePadding = (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;
|