@visactor/vchart-extension 2.1.0-alpha.17 → 2.1.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +0 -2148
- package/build/index.min.js +2 -2
- package/cjs/charts/axis-3d/index.js +1 -2
- package/cjs/charts/axis-3d/linear-axis.js +2 -1
- package/cjs/charts/bar-3d/chart-spec-transformer.js +1 -1
- package/cjs/charts/bar-3d/chart.js +1 -1
- package/cjs/charts/bar-3d/constant.js +1 -1
- package/cjs/charts/bar-3d/index.js +1 -1
- package/cjs/charts/bar-3d/interface.js +2 -1
- package/cjs/charts/bar-3d/series-spec-transformer.js +1 -1
- package/cjs/charts/bar-3d/series.js +1 -1
- package/cjs/charts/bar-3d/theme.js +1 -1
- package/cjs/charts/candlestick/candlestick-transformer.js +1 -1
- package/cjs/charts/candlestick/candlestick.js +1 -1
- package/cjs/charts/candlestick/index.js +1 -1
- package/cjs/charts/candlestick/interface.js +1 -1
- package/cjs/charts/candlestick/util.js +1 -1
- package/cjs/charts/combination-candlestick/combination-candlestick-transformer.js +1 -1
- package/cjs/charts/combination-candlestick/combination-candlestick.js +1 -1
- package/cjs/charts/combination-candlestick/constant.js +1 -1
- package/cjs/charts/combination-candlestick/index.js +1 -1
- package/cjs/charts/combination-candlestick/interface.js +1 -1
- package/cjs/charts/conversion-funnel/arrow-data-transform.js +2 -1
- package/cjs/charts/conversion-funnel/constants.js +1 -1
- package/cjs/charts/conversion-funnel/conversion-funnel-transformer.js +1 -1
- package/cjs/charts/conversion-funnel/conversion-funnel.js +1 -1
- package/cjs/charts/conversion-funnel/index.js +1 -1
- package/cjs/charts/conversion-funnel/interface.js +1 -1
- package/cjs/charts/conversion-funnel/util.js +1 -1
- package/cjs/charts/funnel-3d/chart.js +1 -1
- package/cjs/charts/funnel-3d/constant.js +1 -1
- package/cjs/charts/funnel-3d/index.js +1 -1
- package/cjs/charts/funnel-3d/interface.js +1 -1
- package/cjs/charts/funnel-3d/series-spec-transformer.js +1 -1
- package/cjs/charts/funnel-3d/series.js +1 -1
- package/cjs/charts/funnel-3d/theme.js +1 -1
- package/cjs/charts/histogram-3d/chart.js +1 -1
- package/cjs/charts/image-cloud/series/image-cloud.d.ts +1 -1
- package/cjs/components/bar-link/bar-link.js +1 -1
- package/cjs/components/bar-link/constant.js +1 -1
- package/cjs/components/bar-link/index.js +1 -1
- package/cjs/components/bar-link/type.js +1 -1
- package/cjs/components/bar-link/util.js +1 -1
- package/cjs/components/bar-regression-line/index.js +1 -1
- package/cjs/components/bar-regression-line/type.js +1 -1
- package/cjs/components/extension-mark-sync-state/extension-mark-sync-state.js +1 -1
- package/cjs/components/extension-mark-sync-state/index.js +1 -1
- package/cjs/components/extension-mark-sync-state/type.js +1 -1
- package/cjs/components/histogram-regression-line/index.js +1 -1
- package/cjs/components/histogram-regression-line/type.js +1 -1
- package/cjs/components/map-label/index.js +1 -1
- package/cjs/components/map-label/layout.js +1 -1
- package/cjs/components/map-label/map-label-transformer.js +1 -2
- package/cjs/components/map-label/map-label.d.ts +1 -1
- package/cjs/components/map-label/map-label.js +1 -1
- package/cjs/components/map-label/theme.js +1 -1
- package/cjs/components/map-label/type.js +1 -1
- package/cjs/components/regression-line/index.js +1 -1
- package/cjs/components/regression-line/regression-line.js +1 -1
- package/cjs/components/regression-line/type.js +1 -1
- package/cjs/components/scatter-regression-line/index.js +1 -1
- package/cjs/components/scatter-regression-line/type.js +1 -1
- package/cjs/components/series-break/constant.js +1 -1
- package/cjs/components/series-break/index.js +1 -1
- package/cjs/components/series-break/series-break.js +1 -1
- package/cjs/components/series-break/type.js +1 -1
- package/cjs/components/series-break/util.js +1 -2
- package/cjs/components/series-label/constant.js +1 -1
- package/cjs/components/series-label/index.js +1 -1
- package/cjs/components/series-label/series-label.js +1 -1
- package/cjs/components/series-label/type.js +1 -1
- package/cjs/components/series-label/util.js +1 -1
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +5 -5
- package/cjs/index.js.map +1 -1
- package/esm/charts/axis-3d/index.js +1 -2
- package/esm/charts/axis-3d/linear-axis.js +2 -1
- package/esm/charts/bar-3d/chart-spec-transformer.js +1 -1
- package/esm/charts/bar-3d/chart.js +1 -1
- package/esm/charts/bar-3d/constant.js +1 -1
- package/esm/charts/bar-3d/index.js +1 -1
- package/esm/charts/bar-3d/interface.js +2 -1
- package/esm/charts/bar-3d/series-spec-transformer.js +1 -1
- package/esm/charts/bar-3d/series.js +1 -1
- package/esm/charts/bar-3d/theme.js +1 -1
- package/esm/charts/candlestick/candlestick-transformer.js +1 -1
- package/esm/charts/candlestick/candlestick.js +1 -1
- package/esm/charts/candlestick/index.js +1 -1
- package/esm/charts/candlestick/interface.js +1 -1
- package/esm/charts/candlestick/util.js +1 -1
- package/esm/charts/combination-candlestick/combination-candlestick-transformer.js +1 -1
- package/esm/charts/combination-candlestick/combination-candlestick.js +1 -1
- package/esm/charts/combination-candlestick/constant.js +1 -1
- package/esm/charts/combination-candlestick/index.js +1 -1
- package/esm/charts/combination-candlestick/interface.js +1 -1
- package/esm/charts/conversion-funnel/arrow-data-transform.js +2 -1
- package/esm/charts/conversion-funnel/constants.js +1 -1
- package/esm/charts/conversion-funnel/conversion-funnel-transformer.js +1 -1
- package/esm/charts/conversion-funnel/conversion-funnel.js +1 -1
- package/esm/charts/conversion-funnel/index.js +1 -1
- package/esm/charts/conversion-funnel/interface.js +1 -1
- package/esm/charts/conversion-funnel/util.js +1 -1
- package/esm/charts/funnel-3d/chart.js +1 -1
- package/esm/charts/funnel-3d/constant.js +1 -1
- package/esm/charts/funnel-3d/index.js +1 -1
- package/esm/charts/funnel-3d/interface.js +1 -1
- package/esm/charts/funnel-3d/series-spec-transformer.js +1 -1
- package/esm/charts/funnel-3d/series.js +1 -1
- package/esm/charts/funnel-3d/theme.js +1 -1
- package/esm/charts/histogram-3d/chart.js +1 -1
- package/esm/charts/image-cloud/series/image-cloud.d.ts +1 -1
- package/esm/components/bar-link/bar-link.js +1 -1
- package/esm/components/bar-link/constant.js +1 -1
- package/esm/components/bar-link/index.js +1 -1
- package/esm/components/bar-link/type.js +1 -1
- package/esm/components/bar-link/util.js +1 -1
- package/esm/components/bar-regression-line/index.js +1 -1
- package/esm/components/bar-regression-line/type.js +1 -1
- package/esm/components/extension-mark-sync-state/extension-mark-sync-state.js +1 -1
- package/esm/components/extension-mark-sync-state/index.js +1 -1
- package/esm/components/extension-mark-sync-state/type.js +1 -1
- package/esm/components/histogram-regression-line/index.js +1 -1
- package/esm/components/histogram-regression-line/type.js +1 -1
- package/esm/components/map-label/index.js +1 -1
- package/esm/components/map-label/layout.js +1 -1
- package/esm/components/map-label/map-label-transformer.js +1 -2
- package/esm/components/map-label/map-label.d.ts +1 -1
- package/esm/components/map-label/map-label.js +1 -1
- package/esm/components/map-label/theme.js +1 -1
- package/esm/components/map-label/type.js +1 -1
- package/esm/components/regression-line/index.js +1 -1
- package/esm/components/regression-line/regression-line.js +1 -1
- package/esm/components/regression-line/type.js +1 -1
- package/esm/components/scatter-regression-line/index.js +1 -1
- package/esm/components/scatter-regression-line/type.js +1 -1
- package/esm/components/series-break/constant.js +1 -1
- package/esm/components/series-break/index.js +1 -1
- package/esm/components/series-break/series-break.js +1 -1
- package/esm/components/series-break/type.js +1 -1
- package/esm/components/series-break/util.js +1 -2
- package/esm/components/series-label/constant.js +1 -1
- package/esm/components/series-label/index.js +1 -1
- package/esm/components/series-label/series-label.js +1 -1
- package/esm/components/series-label/type.js +1 -1
- package/esm/components/series-label/util.js +1 -1
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -2
- package/esm/index.js.map +1 -1
- package/package.json +7 -7
- package/cjs/charts/storyline/index.d.ts +0 -4
- package/cjs/charts/storyline/index.js +0 -22
- package/cjs/charts/storyline/index.js.map +0 -1
- package/cjs/charts/storyline/interface.d.ts +0 -67
- package/cjs/charts/storyline/interface.js +0 -6
- package/cjs/charts/storyline/interface.js.map +0 -1
- package/cjs/charts/storyline/layout.d.ts +0 -53
- package/cjs/charts/storyline/layout.js +0 -208
- package/cjs/charts/storyline/layout.js.map +0 -1
- package/cjs/charts/storyline/layouts/arc.d.ts +0 -5
- package/cjs/charts/storyline/layouts/arc.js +0 -295
- package/cjs/charts/storyline/layouts/arc.js.map +0 -1
- package/cjs/charts/storyline/layouts/clock.d.ts +0 -5
- package/cjs/charts/storyline/layouts/clock.js +0 -246
- package/cjs/charts/storyline/layouts/clock.js.map +0 -1
- package/cjs/charts/storyline/layouts/common.d.ts +0 -89
- package/cjs/charts/storyline/layouts/common.js +0 -291
- package/cjs/charts/storyline/layouts/common.js.map +0 -1
- package/cjs/charts/storyline/layouts/default.d.ts +0 -4
- package/cjs/charts/storyline/layouts/default.js +0 -181
- package/cjs/charts/storyline/layouts/default.js.map +0 -1
- package/cjs/charts/storyline/layouts/ladder.d.ts +0 -5
- package/cjs/charts/storyline/layouts/ladder.js +0 -205
- package/cjs/charts/storyline/layouts/ladder.js.map +0 -1
- package/cjs/charts/storyline/layouts/landscape.d.ts +0 -4
- package/cjs/charts/storyline/layouts/landscape.js +0 -256
- package/cjs/charts/storyline/layouts/landscape.js.map +0 -1
- package/cjs/charts/storyline/layouts/portrait.d.ts +0 -4
- package/cjs/charts/storyline/layouts/portrait.js +0 -215
- package/cjs/charts/storyline/layouts/portrait.js.map +0 -1
- package/cjs/charts/storyline/layouts/wing.d.ts +0 -4
- package/cjs/charts/storyline/layouts/wing.js +0 -215
- package/cjs/charts/storyline/layouts/wing.js.map +0 -1
- package/cjs/charts/storyline/storyline-transformer.d.ts +0 -4
- package/cjs/charts/storyline/storyline-transformer.js +0 -78
- package/cjs/charts/storyline/storyline-transformer.js.map +0 -1
- package/cjs/charts/storyline/storyline.d.ts +0 -16
- package/cjs/charts/storyline/storyline.js +0 -36
- package/cjs/charts/storyline/storyline.js.map +0 -1
- package/esm/charts/storyline/index.d.ts +0 -4
- package/esm/charts/storyline/index.js +0 -8
- package/esm/charts/storyline/index.js.map +0 -1
- package/esm/charts/storyline/interface.d.ts +0 -67
- package/esm/charts/storyline/interface.js +0 -2
- package/esm/charts/storyline/interface.js.map +0 -1
- package/esm/charts/storyline/layout.d.ts +0 -53
- package/esm/charts/storyline/layout.js +0 -198
- package/esm/charts/storyline/layout.js.map +0 -1
- package/esm/charts/storyline/layouts/arc.d.ts +0 -5
- package/esm/charts/storyline/layouts/arc.js +0 -286
- package/esm/charts/storyline/layouts/arc.js.map +0 -1
- package/esm/charts/storyline/layouts/clock.d.ts +0 -5
- package/esm/charts/storyline/layouts/clock.js +0 -240
- package/esm/charts/storyline/layouts/clock.js.map +0 -1
- package/esm/charts/storyline/layouts/common.d.ts +0 -89
- package/esm/charts/storyline/layouts/common.js +0 -257
- package/esm/charts/storyline/layouts/common.js.map +0 -1
- package/esm/charts/storyline/layouts/default.d.ts +0 -4
- package/esm/charts/storyline/layouts/default.js +0 -174
- package/esm/charts/storyline/layouts/default.js.map +0 -1
- package/esm/charts/storyline/layouts/ladder.d.ts +0 -5
- package/esm/charts/storyline/layouts/ladder.js +0 -196
- package/esm/charts/storyline/layouts/ladder.js.map +0 -1
- package/esm/charts/storyline/layouts/landscape.d.ts +0 -4
- package/esm/charts/storyline/layouts/landscape.js +0 -252
- package/esm/charts/storyline/layouts/landscape.js.map +0 -1
- package/esm/charts/storyline/layouts/portrait.d.ts +0 -4
- package/esm/charts/storyline/layouts/portrait.js +0 -212
- package/esm/charts/storyline/layouts/portrait.js.map +0 -1
- package/esm/charts/storyline/layouts/wing.d.ts +0 -4
- package/esm/charts/storyline/layouts/wing.js +0 -210
- package/esm/charts/storyline/layouts/wing.js.map +0 -1
- package/esm/charts/storyline/storyline-transformer.d.ts +0 -4
- package/esm/charts/storyline/storyline-transformer.js +0 -76
- package/esm/charts/storyline/storyline-transformer.js.map +0 -1
- package/esm/charts/storyline/storyline.d.ts +0 -16
- package/esm/charts/storyline/storyline.js +0 -29
- package/esm/charts/storyline/storyline.js.map +0 -1
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { IChartSpec, IComposedTextMarkSpec, IImageMarkSpec, IMarkSpec, IPathMarkSpec, IRectMarkSpec, ITextMarkSpec, StringOrNumber } from '@visactor/vchart';
|
|
2
|
-
export type StorylineLayoutType = 'clock' | 'arc' | 'wing' | 'landscape' | 'portrait' | 'ladder' | 'spiral';
|
|
3
|
-
export type StorylineImagePosition = 'top' | 'left' | 'right' | 'bottom';
|
|
4
|
-
export type StorylineLineType = 'line' | 'polyline' | 'curve';
|
|
5
|
-
export type StorylineWingDirection = 'left' | 'right';
|
|
6
|
-
export type StorylineLadderDirection = 'up' | 'down';
|
|
7
|
-
export type StorylineArcDirection = 'up' | 'down';
|
|
8
|
-
export interface IStorylineBlock {
|
|
9
|
-
id?: StringOrNumber;
|
|
10
|
-
title?: string;
|
|
11
|
-
content?: string | string[];
|
|
12
|
-
image?: string | HTMLImageElement | HTMLCanvasElement;
|
|
13
|
-
subImage?: string | HTMLImageElement | HTMLCanvasElement;
|
|
14
|
-
datum?: unknown;
|
|
15
|
-
}
|
|
16
|
-
export interface IStorylineLayoutOptions {
|
|
17
|
-
type: StorylineLayoutType;
|
|
18
|
-
padding?: number | [number, number, number, number];
|
|
19
|
-
radiusRatio?: number;
|
|
20
|
-
startAngle?: number;
|
|
21
|
-
endAngle?: number;
|
|
22
|
-
direction?: StorylineWingDirection | StorylineLadderDirection | StorylineArcDirection;
|
|
23
|
-
headline?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface IStorylineBlockSpec {
|
|
26
|
-
width?: number;
|
|
27
|
-
widthRatio?: number;
|
|
28
|
-
minWidth?: number;
|
|
29
|
-
maxWidth?: number;
|
|
30
|
-
height?: number;
|
|
31
|
-
padding?: number | [number, number, number, number];
|
|
32
|
-
gap?: number;
|
|
33
|
-
showBackground?: boolean;
|
|
34
|
-
style?: Partial<IRectMarkSpec>;
|
|
35
|
-
}
|
|
36
|
-
export interface IStorylineImageSpec extends IMarkSpec<IImageMarkSpec> {
|
|
37
|
-
width?: number;
|
|
38
|
-
height?: number;
|
|
39
|
-
position?: StorylineImagePosition;
|
|
40
|
-
gap?: number;
|
|
41
|
-
showBackground?: boolean;
|
|
42
|
-
}
|
|
43
|
-
export interface IStorylineCenterImageSpec extends IMarkSpec<IImageMarkSpec> {
|
|
44
|
-
width?: number;
|
|
45
|
-
height?: number;
|
|
46
|
-
visible?: boolean;
|
|
47
|
-
image?: string | HTMLImageElement | HTMLCanvasElement;
|
|
48
|
-
}
|
|
49
|
-
export interface IStorylineLineSpec extends IMarkSpec<IPathMarkSpec> {
|
|
50
|
-
visible?: boolean;
|
|
51
|
-
type?: StorylineLineType;
|
|
52
|
-
showArrow?: boolean;
|
|
53
|
-
arrowSize?: number;
|
|
54
|
-
distance?: number;
|
|
55
|
-
}
|
|
56
|
-
export interface IStorylineSpec extends Omit<IChartSpec, 'type' | 'data' | 'series' | 'title' | 'layout'> {
|
|
57
|
-
type: 'storyline';
|
|
58
|
-
data: IStorylineBlock[];
|
|
59
|
-
layout?: StorylineLayoutType | IStorylineLayoutOptions;
|
|
60
|
-
block?: IStorylineBlockSpec;
|
|
61
|
-
title?: IMarkSpec<ITextMarkSpec>;
|
|
62
|
-
content?: IMarkSpec<IComposedTextMarkSpec>;
|
|
63
|
-
image?: IStorylineImageSpec;
|
|
64
|
-
centerImage?: IStorylineCenterImageSpec;
|
|
65
|
-
line?: IStorylineLineSpec;
|
|
66
|
-
themeColor?: string;
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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 = 'clock' | 'arc' | 'wing' | 'landscape' | 'portrait' | 'ladder' | 'spiral';\n\nexport type StorylineImagePosition = 'top' | 'left' | 'right' | 'bottom';\nexport type StorylineLineType = 'line' | 'polyline' | 'curve';\nexport type StorylineWingDirection = 'left' | 'right';\nexport type StorylineLadderDirection = 'up' | 'down';\nexport type StorylineArcDirection = 'up' | 'down';\n\nexport interface IStorylineBlock {\n id?: StringOrNumber;\n title?: string;\n content?: string | string[];\n image?: string | HTMLImageElement | HTMLCanvasElement;\n /**\n * 绘制在主 image 背后的装饰图(如 portrait 布局的错位 shadow image)。\n * 仅在对应布局的 image.showBackground 为 true 时生效。\n * 若未配置,则不会绘制装饰 image。\n */\n subImage?: 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 * 方向控制:\n * - wing 布局:'left' | 'right',圆心锚位置;\n * - ladder 布局:'up' | 'down','up' 表示左下→右上对角线(默认),'down' 表示左上→右下对角线;\n * - arc 布局:'up' | 'down','up' 表示穹顶(centerImage 贴底,弧线在上方),'down' 表示碗形(centerImage 贴顶,弧线在下方)。\n */\n direction?: StorylineWingDirection | StorylineLadderDirection | StorylineArcDirection;\n /**\n * 对 ladder 布局生效:贯穿画布的倾斜大字 headline。\n * 缺省时使用占位文本。倾斜方向自动跟随对角线。\n */\n headline?: string;\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 /**\n * 是否展示 block 背后的卡片背景 rect(白底 + 描边 + 阴影)。\n * 仅 up-ladder 等少数布局支持,默认 false(不展示)。\n */\n showBackground?: boolean;\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 * 是否展示 image 背后的装饰图元(halo / shadow / 背景 rect 等)。\n * 不同布局对应的装饰图元不同:\n * - wing: 圆形 halo symbol\n * - portrait: 错位 shadow image + mask\n * - clock: 楔形/圆形背景 rect\n * - dome / bowl / landscape: image-bg(无图时的占位 rect 不受此开关影响)\n * 默认 false(不展示)。\n */\n showBackground?: boolean;\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"]}
|
|
@@ -1,53 +0,0 @@
|
|
|
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;
|
|
@@ -1,208 +0,0 @@
|
|
|
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 "ladder":
|
|
65
|
-
{
|
|
66
|
-
const isDown = "down" === layout.direction, x0 = inner.x + block.width / 2, x1 = inner.x + inner.width - block.width / 2, yTop = inner.y + block.height / 2, yBot = inner.y + inner.height - block.height / 2, y0 = isDown ? yTop : yBot, y1 = isDown ? yBot : yTop, anchors = lineCenters(count, x0, y0, x1, y1), dx = x1 - x0, dy = y1 - y0, len = Math.hypot(dx, dy) || 1, nx = -dy / len, ny = dx / len, offset = 1.2 * Math.max(80, Math.min(240, Math.round(.42 * inner.height)));
|
|
67
|
-
centers = anchors.map(((p, i) => {
|
|
68
|
-
const sign = i % 2 == 0 ? 1 : -1;
|
|
69
|
-
return {
|
|
70
|
-
x: p.x + nx * offset * sign,
|
|
71
|
-
y: p.y + ny * offset * sign
|
|
72
|
-
};
|
|
73
|
-
}));
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
case "spiral":
|
|
78
|
-
centers = alternatingVerticalCenters(count, inner, block, gap);
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
case "clock":
|
|
82
|
-
centers = circularCenters(count, viewBox, block, padding, layout);
|
|
83
|
-
break;
|
|
84
|
-
|
|
85
|
-
case "arc":
|
|
86
|
-
{
|
|
87
|
-
const isDown = "down" === layout.direction, [s, e] = isDown ? [ 20, 160 ] : [ 200, 340 ];
|
|
88
|
-
centers = arcCenters(count, inner, block, layout, s, e);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
case "wing":
|
|
93
|
-
{
|
|
94
|
-
const direction = "right" === layout.direction ? "right" : "left", [s, e] = "right" === direction ? [ 110, 250 ] : [ -70, 70 ];
|
|
95
|
-
centers = arcCenters(count, inner, block, layout, s, e);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
default:
|
|
100
|
-
centers = lineCenters(count, inner.x + block.width / 2, center.y, inner.x + inner.width - block.width / 2, center.y);
|
|
101
|
-
}
|
|
102
|
-
return centers.map(((point, index) => {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
return {
|
|
105
|
-
id: null !== (_b = null === (_a = data[index]) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : index,
|
|
106
|
-
index: index,
|
|
107
|
-
datum: data[index],
|
|
108
|
-
width: block.width,
|
|
109
|
-
height: block.height,
|
|
110
|
-
x: point.x - block.width / 2,
|
|
111
|
-
y: point.y - block.height / 2,
|
|
112
|
-
center: point
|
|
113
|
-
};
|
|
114
|
-
}));
|
|
115
|
-
}, lineCenters = (count, x0, y0, x1, y1) => 1 === count ? [ {
|
|
116
|
-
x: (x0 + x1) / 2,
|
|
117
|
-
y: (y0 + y1) / 2
|
|
118
|
-
} ] : Array.from({
|
|
119
|
-
length: count
|
|
120
|
-
}, ((_, index) => {
|
|
121
|
-
const t = index / (count - 1);
|
|
122
|
-
return {
|
|
123
|
-
x: x0 + (x1 - x0) * t,
|
|
124
|
-
y: y0 + (y1 - y0) * t
|
|
125
|
-
};
|
|
126
|
-
})), alternatingVerticalCenters = (count, inner, block, gap) => {
|
|
127
|
-
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));
|
|
128
|
-
return lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2).map(((point, index) => ({
|
|
129
|
-
x: point.x + (index % 2 == 0 ? -offset : offset),
|
|
130
|
-
y: point.y
|
|
131
|
-
})));
|
|
132
|
-
}, circularCenters = (count, viewBox, block, padding, layout) => {
|
|
133
|
-
var _a;
|
|
134
|
-
const guide = computeClockCircleGuide(viewBox, block, padding, layout), startAngle = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : -90;
|
|
135
|
-
if (1 === count) {
|
|
136
|
-
const angle = degreeToRadian(startAngle);
|
|
137
|
-
return [ {
|
|
138
|
-
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
139
|
-
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
140
|
-
} ];
|
|
141
|
-
}
|
|
142
|
-
return Array.from({
|
|
143
|
-
length: count
|
|
144
|
-
}, ((_, index) => {
|
|
145
|
-
const angle = degreeToRadian(startAngle + 360 * index / count);
|
|
146
|
-
return {
|
|
147
|
-
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
148
|
-
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
149
|
-
};
|
|
150
|
-
}));
|
|
151
|
-
}, computeClockCircleGuide = (viewBox, block, padding, layout) => {
|
|
152
|
-
var _a;
|
|
153
|
-
const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1), innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1), center = {
|
|
154
|
-
x: padding.left + innerWidth / 2,
|
|
155
|
-
y: padding.top + innerHeight / 2
|
|
156
|
-
}, ratio = null !== (_a = layout.radiusRatio) && void 0 !== _a ? _a : .7, maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
|
|
157
|
-
return {
|
|
158
|
-
center: center,
|
|
159
|
-
radius: Math.max(1, maxRadius * ratio)
|
|
160
|
-
};
|
|
161
|
-
}, arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = .88) => {
|
|
162
|
-
var _a, _b, _c, _d, _e;
|
|
163
|
-
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;
|
|
164
|
-
if (1 === count) {
|
|
165
|
-
const angle = degreeToRadian((startAngle + endAngle) / 2);
|
|
166
|
-
return [ {
|
|
167
|
-
x: center_x + Math.cos(angle) * rx,
|
|
168
|
-
y: center_y + Math.sin(angle) * ry
|
|
169
|
-
} ];
|
|
170
|
-
}
|
|
171
|
-
return Array.from({
|
|
172
|
-
length: count
|
|
173
|
-
}, ((_, index) => {
|
|
174
|
-
const t = index / (count - 1), angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
|
|
175
|
-
return {
|
|
176
|
-
x: center_x + Math.cos(angle) * rx,
|
|
177
|
-
y: center_y + Math.sin(angle) * ry
|
|
178
|
-
};
|
|
179
|
-
}));
|
|
180
|
-
}, angleDelta = (startAngle, endAngle) => {
|
|
181
|
-
const delta = endAngle - startAngle;
|
|
182
|
-
return Math.abs(delta) >= 360 ? 360 : delta;
|
|
183
|
-
}, degreeToRadian = degree => degree / 180 * Math.PI, computeLinks = (blocks, distance) => {
|
|
184
|
-
const links = [];
|
|
185
|
-
for (let i = 0; i < blocks.length - 1; i++) {
|
|
186
|
-
const from = blocks[i], to = blocks[i + 1], start = pointOnBlockEdge(from, to.center, distance), end = pointOnBlockEdge(to, from.center, distance);
|
|
187
|
-
links.push({
|
|
188
|
-
from: from,
|
|
189
|
-
to: to,
|
|
190
|
-
start: start,
|
|
191
|
-
end: end,
|
|
192
|
-
points: [ start, end ]
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return links;
|
|
196
|
-
}, pointOnBlockEdge = (block, toward, distance) => {
|
|
197
|
-
const dx = toward.x - block.center.x, dy = toward.y - block.center.y;
|
|
198
|
-
if (0 === dx && 0 === dy) return {
|
|
199
|
-
x: block.center.x,
|
|
200
|
-
y: block.center.y
|
|
201
|
-
};
|
|
202
|
-
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;
|
|
203
|
-
return {
|
|
204
|
-
x: block.center.x + dx * scale + dx / length * distance,
|
|
205
|
-
y: block.center.y + dy * scale + dy / length * distance
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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;KAC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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 'ladder': {\n // 沿对角线均匀采样 anchor 点,偶/奇 index 沿对角线\"法向\"做左/右偏移。\n // direction = 'up' (默认):左下 → 右上;direction = 'down':左上 → 右下。\n const isDown = layout.direction === 'down';\n const x0 = inner.x + block.width / 2;\n const x1 = inner.x + inner.width - block.width / 2;\n const yTop = inner.y + block.height / 2;\n const yBot = inner.y + inner.height - block.height / 2;\n const y0 = isDown ? yTop : yBot;\n const y1 = isDown ? yBot : yTop;\n const anchors = lineCenters(count, x0, y0, x1, y1);\n // 对角线方向向量\n const dx = x1 - x0;\n const dy = y1 - y0;\n const len = Math.hypot(dx, dy) || 1;\n // 法向单位向量\n const nx = -dy / len;\n const ny = dx / len;\n // 偏移量:与 headline fontSize 联动 —— 与 ladder.ts 中保持同一公式\n // headline fontSize = clamp(innerHeight * 0.42, 80, 240)\n // 偏移量 = headline fontSize * 1.2,让 block 与 headline 大字之间留出充足留白\n const headlineFontSize = Math.max(80, Math.min(240, Math.round(inner.height * 0.42)));\n const offset = headlineFontSize * 1.2;\n centers = anchors.map((p, i) => {\n // 偶数 index → 法向 +;奇数 index → 法向 -\n const sign = i % 2 === 0 ? 1 : -1;\n return {\n x: p.x + nx * offset * sign,\n y: p.y + ny * offset * sign\n };\n });\n break;\n }\n case 'spiral':\n centers = alternatingVerticalCenters(count, inner, block, gap);\n break;\n case 'clock':\n centers = circularCenters(count, viewBox, block, padding, layout);\n break;\n case 'arc': {\n // arc 布局:通过 direction 控制 dome(穹顶)/ bowl(碗形)方向\n // - 'up'(默认):弧线在上方(穹顶),等同原 dome\n // - 'down':弧线在下方(碗形),等同原 bowl\n const isDown = layout.direction === 'down';\n const [s, e] = isDown ? [20, 160] : [200, 340];\n centers = arcCenters(count, inner, block, layout, s, e);\n break;\n }\n case 'wing': {\n const direction = layout.direction === 'right' ? 'right' : 'left';\n const [s, e] = direction === 'right' ? [110, 250] : [-70, 70];\n centers = arcCenters(count, inner, block, layout, s, e);\n break;\n }\n case 'landscape':\n default:\n centers = lineCenters(\n count,\n inner.x + block.width / 2,\n center.y,\n inner.x + inner.width - block.width / 2,\n center.y\n );\n break;\n }\n\n return centers.map((point, index) => ({\n id: data[index]?.id ?? index,\n index,\n datum: data[index],\n width: block.width,\n height: block.height,\n x: point.x - block.width / 2,\n y: point.y - block.height / 2,\n center: point\n }));\n};\n\nconst lineCenters = (count: number, x0: number, y0: number, x1: number, y1: number): StorylinePoint[] => {\n if (count === 1) {\n return [{ x: (x0 + x1) / 2, y: (y0 + y1) / 2 }];\n }\n return Array.from({ length: count }, (_, index) => {\n const t = index / (count - 1);\n return {\n x: x0 + (x1 - x0) * t,\n y: y0 + (y1 - y0) * t\n };\n });\n};\n\nconst alternatingVerticalCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n gap: number\n) => {\n const baseX = inner.x + inner.width / 2;\n const offset = Math.min(Math.max(block.width * 0.65 + gap / 2, 0), Math.max((inner.width - block.width) / 2, 0));\n const points = lineCenters(\n count,\n baseX,\n inner.y + block.height / 2,\n baseX,\n inner.y + inner.height - block.height / 2\n );\n return points.map((point, index) => ({\n x: point.x + (index % 2 === 0 ? -offset : offset),\n y: point.y\n }));\n};\n\nconst circularCenters = (\n count: number,\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n layout: IStorylineLayoutOptions\n) => {\n const guide = computeClockCircleGuide(viewBox, block, padding, layout);\n const startAngle = layout.startAngle ?? -90;\n const delta = 360;\n\n if (count === 1) {\n const angle = degreeToRadian(startAngle);\n return [\n {\n x: guide.center.x + Math.cos(angle) * guide.radius,\n y: guide.center.y + Math.sin(angle) * guide.radius\n }\n ];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const angle = degreeToRadian(startAngle + (delta * index) / count);\n return {\n x: guide.center.x + Math.cos(angle) * guide.radius,\n y: guide.center.y + Math.sin(angle) * guide.radius\n };\n });\n};\n\nconst computeClockCircleGuide = (\n viewBox: StorylineSize,\n block: StorylineSize,\n padding: StorylinePadding,\n layout: IStorylineLayoutOptions\n): StorylineCircleGuide => {\n const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1);\n const innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1);\n const center = {\n x: padding.left + innerWidth / 2,\n y: padding.top + innerHeight / 2\n };\n const ratio = layout.radiusRatio ?? 0.7;\n const maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);\n\n return {\n center,\n radius: Math.max(1, maxRadius * ratio)\n };\n};\n\nconst arcCenters = (\n count: number,\n inner: { x: number; y: number; width: number; height: number },\n block: StorylineSize,\n layout: IStorylineLayoutOptions,\n fallbackStartAngle?: number,\n fallbackEndAngle?: number,\n defaultRatio = 0.88\n) => {\n const startAngle = layout.startAngle ?? fallbackStartAngle ?? -90;\n const endAngle = layout.endAngle ?? fallbackEndAngle ?? 270;\n const ratio = layout.radiusRatio ?? defaultRatio;\n const rx = Math.max((inner.width - block.width) / 2, 1) * ratio;\n const ry = Math.max((inner.height - block.height) / 2, 1) * ratio;\n const center = {\n x: inner.x + inner.width / 2,\n y: inner.y + inner.height / 2\n };\n\n if (count === 1) {\n const angle = degreeToRadian((startAngle + endAngle) / 2);\n return [{ x: center.x + Math.cos(angle) * rx, y: center.y + Math.sin(angle) * ry }];\n }\n\n return Array.from({ length: count }, (_, index) => {\n const t = index / (count - 1);\n const angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);\n return {\n x: center.x + Math.cos(angle) * rx,\n y: center.y + Math.sin(angle) * ry\n };\n });\n};\n\nconst angleDelta = (startAngle: number, endAngle: number) => {\n const delta = endAngle - startAngle;\n return Math.abs(delta) >= 360 ? 360 : delta;\n};\n\nconst degreeToRadian = (degree: number) => (degree / 180) * Math.PI;\n\nconst computeLinks = (blocks: StorylineBlockPosition[], distance: number): StorylineLinkPosition[] => {\n const links: StorylineLinkPosition[] = [];\n for (let i = 0; i < blocks.length - 1; i++) {\n const from = blocks[i];\n const to = blocks[i + 1];\n const start = pointOnBlockEdge(from, to.center, distance);\n const end = pointOnBlockEdge(to, from.center, distance);\n links.push({\n from,\n to,\n start,\n end,\n points: [start, end]\n });\n }\n return links;\n};\n\nconst pointOnBlockEdge = (block: StorylineBlockPosition, toward: StorylinePoint, distance: number): StorylinePoint => {\n const dx = toward.x - block.center.x;\n const dy = toward.y - block.center.y;\n if (dx === 0 && dy === 0) {\n return { x: block.center.x, y: block.center.y };\n }\n const scaleX = dx === 0 ? Number.POSITIVE_INFINITY : block.width / 2 / Math.abs(dx);\n const scaleY = dy === 0 ? Number.POSITIVE_INFINITY : block.height / 2 / Math.abs(dy);\n const scale = Math.min(scaleX, scaleY);\n const length = Math.sqrt(dx * dx + dy * dy) || 1;\n return {\n x: block.center.x + dx * scale + (dx / length) * distance,\n y: block.center.y + dy * scale + (dy / length) * distance\n };\n};\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IExtensionGroupMarkSpec } from '@visactor/vchart';
|
|
2
|
-
import type { IStorylineBlock, IStorylineSpec } from '../interface';
|
|
3
|
-
export declare const buildArcMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
|
|
4
|
-
export declare const buildArcCenterImageMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
|
|
5
|
-
export declare const buildArcBlockMark: (spec: IStorylineSpec, block: IStorylineBlock, index: number) => IExtensionGroupMarkSpec;
|