@visactor/vchart-extension 2.1.0-alpha.16 → 2.1.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +0 -2216
- 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 +1 -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 +2 -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 +1 -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/histogram-3d/chart.js +2 -1
- package/cjs/charts/histogram-3d/index.js +1 -1
- package/cjs/charts/histogram-3d/interface.js +1 -1
- package/cjs/charts/image-cloud/image-cloud-transformer.js +1 -1
- package/cjs/charts/image-cloud/image-cloud.js +1 -1
- package/cjs/charts/image-cloud/index.js +1 -1
- package/cjs/charts/image-cloud/interface.js +1 -1
- package/cjs/charts/image-cloud/series/image-cloud.d.ts +1 -1
- package/cjs/charts/pictogram/element-highlight-by-graphic-name.js +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 +1 -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 +2 -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 +1 -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/histogram-3d/chart.js +2 -1
- package/esm/charts/histogram-3d/index.js +1 -1
- package/esm/charts/histogram-3d/interface.js +1 -1
- package/esm/charts/image-cloud/image-cloud-transformer.js +1 -1
- package/esm/charts/image-cloud/image-cloud.js +1 -1
- package/esm/charts/image-cloud/index.js +1 -1
- package/esm/charts/image-cloud/interface.js +1 -1
- package/esm/charts/image-cloud/series/image-cloud.d.ts +1 -1
- package/esm/charts/pictogram/element-highlight-by-graphic-name.js +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 -61
- 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 -214
- package/cjs/charts/storyline/layout.js.map +0 -1
- package/cjs/charts/storyline/layouts/bowl.d.ts +0 -5
- package/cjs/charts/storyline/layouts/bowl.js +0 -285
- package/cjs/charts/storyline/layouts/bowl.js.map +0 -1
- package/cjs/charts/storyline/layouts/clock.d.ts +0 -5
- package/cjs/charts/storyline/layouts/clock.js +0 -247
- package/cjs/charts/storyline/layouts/clock.js.map +0 -1
- package/cjs/charts/storyline/layouts/common.d.ts +0 -88
- 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 -179
- package/cjs/charts/storyline/layouts/default.js.map +0 -1
- package/cjs/charts/storyline/layouts/dome.d.ts +0 -5
- package/cjs/charts/storyline/layouts/dome.js +0 -300
- package/cjs/charts/storyline/layouts/dome.js.map +0 -1
- package/cjs/charts/storyline/layouts/landscape.d.ts +0 -4
- package/cjs/charts/storyline/layouts/landscape.js +0 -254
- 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 -241
- 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 -66
- 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 -61
- 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 -204
- package/esm/charts/storyline/layout.js.map +0 -1
- package/esm/charts/storyline/layouts/bowl.d.ts +0 -5
- package/esm/charts/storyline/layouts/bowl.js +0 -277
- package/esm/charts/storyline/layouts/bowl.js.map +0 -1
- package/esm/charts/storyline/layouts/clock.d.ts +0 -5
- package/esm/charts/storyline/layouts/clock.js +0 -241
- package/esm/charts/storyline/layouts/clock.js.map +0 -1
- package/esm/charts/storyline/layouts/common.d.ts +0 -88
- 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 -172
- package/esm/charts/storyline/layouts/default.js.map +0 -1
- package/esm/charts/storyline/layouts/dome.d.ts +0 -5
- package/esm/charts/storyline/layouts/dome.js +0 -292
- package/esm/charts/storyline/layouts/dome.js.map +0 -1
- package/esm/charts/storyline/layouts/landscape.d.ts +0 -4
- package/esm/charts/storyline/layouts/landscape.js +0 -250
- 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 -238
- 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 -66
- 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 +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 =\n | 'clock'\n | 'bowl'\n | 'dome'\n | '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';\nexport type StorylineWingDirection = 'left' | 'right';\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 * 对 wing 布局生效,控制翅膀展开方向。\n * - 'left':圆心锚在画布左侧、弧凸向右展开(默认);\n * - 'right':圆心锚在画布右侧、弧凸向左展开。\n */\n direction?: StorylineWingDirection;\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"]}
|
|
@@ -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,214 +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 "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 "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
|
-
})), alternatingHorizontalCenters = (count, inner, block, gap) => {
|
|
127
|
-
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));
|
|
128
|
-
return lineCenters(count, inner.x + block.width / 2, baseY, inner.x + inner.width - block.width / 2, baseY).map(((point, index) => ({
|
|
129
|
-
x: point.x,
|
|
130
|
-
y: point.y + (index % 2 == 0 ? -offset : offset)
|
|
131
|
-
})));
|
|
132
|
-
}, alternatingVerticalCenters = (count, inner, block, gap) => {
|
|
133
|
-
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));
|
|
134
|
-
return lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2).map(((point, index) => ({
|
|
135
|
-
x: point.x + (index % 2 == 0 ? -offset : offset),
|
|
136
|
-
y: point.y
|
|
137
|
-
})));
|
|
138
|
-
}, circularCenters = (count, viewBox, block, padding, layout) => {
|
|
139
|
-
var _a;
|
|
140
|
-
const guide = computeClockCircleGuide(viewBox, block, padding, layout), startAngle = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : -90;
|
|
141
|
-
if (1 === count) {
|
|
142
|
-
const angle = degreeToRadian(startAngle);
|
|
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
|
-
return Array.from({
|
|
149
|
-
length: count
|
|
150
|
-
}, ((_, index) => {
|
|
151
|
-
const angle = degreeToRadian(startAngle + 360 * index / count);
|
|
152
|
-
return {
|
|
153
|
-
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
154
|
-
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
155
|
-
};
|
|
156
|
-
}));
|
|
157
|
-
}, computeClockCircleGuide = (viewBox, block, padding, layout) => {
|
|
158
|
-
var _a;
|
|
159
|
-
const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1), innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1), center = {
|
|
160
|
-
x: padding.left + innerWidth / 2,
|
|
161
|
-
y: padding.top + innerHeight / 2
|
|
162
|
-
}, ratio = null !== (_a = layout.radiusRatio) && void 0 !== _a ? _a : .7, maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
|
|
163
|
-
return {
|
|
164
|
-
center: center,
|
|
165
|
-
radius: Math.max(1, maxRadius * ratio)
|
|
166
|
-
};
|
|
167
|
-
}, arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = .88) => {
|
|
168
|
-
var _a, _b, _c, _d, _e;
|
|
169
|
-
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;
|
|
170
|
-
if (1 === count) {
|
|
171
|
-
const angle = degreeToRadian((startAngle + endAngle) / 2);
|
|
172
|
-
return [ {
|
|
173
|
-
x: center_x + Math.cos(angle) * rx,
|
|
174
|
-
y: center_y + Math.sin(angle) * ry
|
|
175
|
-
} ];
|
|
176
|
-
}
|
|
177
|
-
return Array.from({
|
|
178
|
-
length: count
|
|
179
|
-
}, ((_, index) => {
|
|
180
|
-
const t = index / (count - 1), angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
|
|
181
|
-
return {
|
|
182
|
-
x: center_x + Math.cos(angle) * rx,
|
|
183
|
-
y: center_y + Math.sin(angle) * ry
|
|
184
|
-
};
|
|
185
|
-
}));
|
|
186
|
-
}, angleDelta = (startAngle, endAngle) => {
|
|
187
|
-
const delta = endAngle - startAngle;
|
|
188
|
-
return Math.abs(delta) >= 360 ? 360 : delta;
|
|
189
|
-
}, degreeToRadian = degree => degree / 180 * Math.PI, computeLinks = (blocks, distance) => {
|
|
190
|
-
const links = [];
|
|
191
|
-
for (let i = 0; i < blocks.length - 1; i++) {
|
|
192
|
-
const from = blocks[i], to = blocks[i + 1], start = pointOnBlockEdge(from, to.center, distance), end = pointOnBlockEdge(to, from.center, distance);
|
|
193
|
-
links.push({
|
|
194
|
-
from: from,
|
|
195
|
-
to: to,
|
|
196
|
-
start: start,
|
|
197
|
-
end: end,
|
|
198
|
-
points: [ start, end ]
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
return links;
|
|
202
|
-
}, pointOnBlockEdge = (block, toward, distance) => {
|
|
203
|
-
const dx = toward.x - block.center.x, dy = toward.y - block.center.y;
|
|
204
|
-
if (0 === dx && 0 === dy) return {
|
|
205
|
-
x: block.center.x,
|
|
206
|
-
y: block.center.y
|
|
207
|
-
};
|
|
208
|
-
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;
|
|
209
|
-
return {
|
|
210
|
-
x: block.center.x + dx * scale + dx / length * distance,
|
|
211
|
-
y: block.center.y + dy * scale + dy / length * distance
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
//# 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;KACH;IACD,MAAM,KAAK,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,eAAe,CAAC;IACzC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAClE,CAAC,CAAC;AAXW,QAAA,g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AAC,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 '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 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"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
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;
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.buildBowlBlockMark = exports.buildBowlCenterImageMark = exports.buildBowlArcMark = void 0;
|
|
6
|
-
|
|
7
|
-
const vchart_1 = require("@visactor/vchart"), common_1 = require("./common"), BOWL_BLOCK_IMAGE_SIZE = 140, BOWL_TEXT_GAP_FROM_IMAGE = 10, BOWL_TITLE_LINE_HEIGHT = 19, BOWL_CONTENT_LINE_HEIGHT = 17, BOWL_CONTENT_FONT_SIZE = 12, BOWL_TEXT_BOX_HEIGHT = 300, BOWL_TITLE_TO_CONTENT_GAP = 4, BOWL_TEXT_LEFT_PADDING = 20, BOWL_CENTER_IMAGE_SIZE_RATIO = .4, BOWL_ARC_BOTTOM_GAP_FROM_CENTER_IMAGE = 300, getBowlCenterImageRect = (spec, ctx) => {
|
|
8
|
-
var _a, _b, _c, _e, _f;
|
|
9
|
-
const {width: width, height: height, startX: startX, startY: startY} = (0, common_1.getRegionGeometry)(ctx), padding = (0,
|
|
10
|
-
common_1.normalizePadding)(null === (_a = spec.block) || void 0 === _a ? void 0 : _a.padding), innerWidth = Math.max(width - padding.left - padding.right, 1), innerHeight = Math.max(height - padding.top - padding.bottom, 1), baseSize = .4 * Math.min(innerWidth, innerHeight), w = Math.max(null !== (_c = null === (_b = spec.centerImage) || void 0 === _b ? void 0 : _b.width) && void 0 !== _c ? _c : baseSize, 80), h = Math.max(null !== (_f = null === (_e = spec.centerImage) || void 0 === _e ? void 0 : _e.height) && void 0 !== _f ? _f : baseSize, 80);
|
|
11
|
-
return {
|
|
12
|
-
x: startX + padding.left + innerWidth / 2 - w / 2,
|
|
13
|
-
y: startY + padding.top,
|
|
14
|
-
width: w,
|
|
15
|
-
height: h
|
|
16
|
-
};
|
|
17
|
-
}, getBowlArcGeometry = (spec, ctx) => {
|
|
18
|
-
var _a, _b, _c, _e;
|
|
19
|
-
const {width: width, startX: startX} = (0, common_1.getRegionGeometry)(ctx), blockPadding = (0,
|
|
20
|
-
common_1.normalizePadding)(null === (_a = spec.block) || void 0 === _a ? void 0 : _a.padding), innerWidth = Math.max(width - blockPadding.left - blockPadding.right, 1), blockWidth = (0,
|
|
21
|
-
common_1.resolveBlockWidth)(spec, width), layoutOpt = (0, common_1.normalizeLayout)(spec.layout), startAngle = null !== (_b = layoutOpt.startAngle) && void 0 !== _b ? _b : 20, endAngle = null !== (_c = layoutOpt.endAngle) && void 0 !== _c ? _c : 160, ratio = null !== (_e = layoutOpt.radiusRatio) && void 0 !== _e ? _e : .88, rx = Math.max((innerWidth - blockWidth) / 2, 1) * ratio, centerRect = getBowlCenterImageRect(spec, ctx), centerTop = centerRect.y, centerBottom = centerRect.y + centerRect.height, sinStart = Math.sin(startAngle / 180 * Math.PI), denom = Math.max(1 - sinStart, .05), ry = (centerRect.height + 300) / denom, cy = centerTop - ry * sinStart;
|
|
22
|
-
return {
|
|
23
|
-
cx: startX + blockPadding.left + innerWidth / 2,
|
|
24
|
-
cy: cy,
|
|
25
|
-
rx: rx,
|
|
26
|
-
ry: ry,
|
|
27
|
-
startAngle: startAngle,
|
|
28
|
-
endAngle: endAngle,
|
|
29
|
-
centerTop: centerTop,
|
|
30
|
-
centerBottom: centerBottom
|
|
31
|
-
};
|
|
32
|
-
}, getBowlBlockCenter = (spec, ctx, index) => {
|
|
33
|
-
var _a, _b, _c, _e;
|
|
34
|
-
const arc = getBowlArcGeometry(spec, ctx), count = null !== (_b = null === (_a = spec.data) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0;
|
|
35
|
-
if (count <= 0) return {
|
|
36
|
-
x: arc.cx,
|
|
37
|
-
y: arc.cy
|
|
38
|
-
};
|
|
39
|
-
const t = 1 === count ? .5 : index / (count - 1), angle = (arc.startAngle + (arc.endAngle - arc.startAngle) * t) / 180 * Math.PI, px = arc.cx + Math.cos(angle) * arc.rx, py = arc.cy + Math.sin(angle) * arc.ry, nxRaw = Math.cos(angle) / arc.rx, nyRaw = Math.sin(angle) / arc.ry, nLen = Math.hypot(nxRaw, nyRaw) || 1, nx = nxRaw / nLen, ny = nyRaw / nLen, offset = (null !== (_e = null === (_c = spec.image) || void 0 === _c ? void 0 : _c.height) && void 0 !== _e ? _e : 140) / 2;
|
|
40
|
-
return {
|
|
41
|
-
x: px + nx * offset,
|
|
42
|
-
y: py + ny * offset
|
|
43
|
-
};
|
|
44
|
-
}, buildBowlArcMark = spec => {
|
|
45
|
-
var _a;
|
|
46
|
-
if (!0 !== (null === (_a = spec.line) || void 0 === _a ? void 0 : _a.visible)) return null;
|
|
47
|
-
const themeColor = (0, common_1.getThemeColor)(spec);
|
|
48
|
-
return {
|
|
49
|
-
type: "group",
|
|
50
|
-
name: "storyline-bowl-arc",
|
|
51
|
-
zIndex: vchart_1.LayoutZIndex.Mark,
|
|
52
|
-
children: [ {
|
|
53
|
-
type: "path",
|
|
54
|
-
name: "storyline-bowl-arc-path",
|
|
55
|
-
interactive: !1,
|
|
56
|
-
style: {
|
|
57
|
-
stroke: themeColor,
|
|
58
|
-
lineWidth: 2,
|
|
59
|
-
lineCap: "round",
|
|
60
|
-
fill: "transparent",
|
|
61
|
-
fillOpacity: 0,
|
|
62
|
-
path: (_d, ctx) => {
|
|
63
|
-
const arc = getBowlArcGeometry(spec, ctx), span = arc.endAngle - arc.startAngle, segments = [];
|
|
64
|
-
for (let i = 0; i <= 64; i++) {
|
|
65
|
-
const t = i / 64, angle = (arc.startAngle + span * t) / 180 * Math.PI, x = arc.cx + Math.cos(angle) * arc.rx, y = arc.cy + Math.sin(angle) * arc.ry;
|
|
66
|
-
segments.push(`${0 === i ? "M" : "L"} ${x.toFixed(2)} ${y.toFixed(2)}`);
|
|
67
|
-
}
|
|
68
|
-
return segments.join(" ");
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} ]
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.buildBowlArcMark = buildBowlArcMark;
|
|
76
|
-
|
|
77
|
-
const buildBowlCenterImageMark = spec => {
|
|
78
|
-
var _a, _b, _c, _e;
|
|
79
|
-
if (!(!1 !== (null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.visible))) return null;
|
|
80
|
-
const themeColor = (0, common_1.getThemeColor)(spec), hasImage = !!(null === (_b = spec.centerImage) || void 0 === _b ? void 0 : _b.image), symbolGradient = {
|
|
81
|
-
gradient: "linear",
|
|
82
|
-
x0: .5,
|
|
83
|
-
y0: 0,
|
|
84
|
-
x1: .5,
|
|
85
|
-
y1: 1,
|
|
86
|
-
stops: [ {
|
|
87
|
-
offset: 0,
|
|
88
|
-
color: (0, common_1.withAlpha)(themeColor, .15)
|
|
89
|
-
}, {
|
|
90
|
-
offset: 1,
|
|
91
|
-
color: themeColor
|
|
92
|
-
} ]
|
|
93
|
-
};
|
|
94
|
-
return {
|
|
95
|
-
type: "group",
|
|
96
|
-
name: "storyline-bowl-center",
|
|
97
|
-
zIndex: vchart_1.LayoutZIndex.Mark,
|
|
98
|
-
children: [ {
|
|
99
|
-
type: "symbol",
|
|
100
|
-
name: "storyline-bowl-center-symbol",
|
|
101
|
-
interactive: !1,
|
|
102
|
-
style: {
|
|
103
|
-
x: (_d, ctx) => {
|
|
104
|
-
const r = getBowlCenterImageRect(spec, ctx);
|
|
105
|
-
return r.x + r.width / 2;
|
|
106
|
-
},
|
|
107
|
-
y: (_d, ctx) => {
|
|
108
|
-
const r = getBowlCenterImageRect(spec, ctx);
|
|
109
|
-
return r.y + r.height / 2;
|
|
110
|
-
},
|
|
111
|
-
size: (_d, ctx) => {
|
|
112
|
-
const r = getBowlCenterImageRect(spec, ctx);
|
|
113
|
-
return 1.1 * Math.max(r.width, r.height);
|
|
114
|
-
},
|
|
115
|
-
symbolType: "circle",
|
|
116
|
-
fill: symbolGradient,
|
|
117
|
-
stroke: themeColor,
|
|
118
|
-
lineWidth: 2
|
|
119
|
-
}
|
|
120
|
-
}, hasImage ? Object.assign(Object.assign({
|
|
121
|
-
type: "image",
|
|
122
|
-
name: "storyline-bowl-center-image",
|
|
123
|
-
interactive: !1
|
|
124
|
-
}, spec.centerImage), {
|
|
125
|
-
style: Object.assign({
|
|
126
|
-
x: (_d, ctx) => getBowlCenterImageRect(spec, ctx).x,
|
|
127
|
-
y: (_d, ctx) => getBowlCenterImageRect(spec, ctx).y,
|
|
128
|
-
width: (_d, ctx) => getBowlCenterImageRect(spec, ctx).width,
|
|
129
|
-
height: (_d, ctx) => getBowlCenterImageRect(spec, ctx).height,
|
|
130
|
-
image: null === (_c = spec.centerImage) || void 0 === _c ? void 0 : _c.image,
|
|
131
|
-
cornerRadius: 12,
|
|
132
|
-
repeatX: "no-repeat",
|
|
133
|
-
repeatY: "no-repeat",
|
|
134
|
-
imagePosition: "center",
|
|
135
|
-
anchor: (_d, ctx) => {
|
|
136
|
-
const r = getBowlCenterImageRect(spec, ctx);
|
|
137
|
-
return [ r.x + r.width / 2, r.y + r.height / 2 ];
|
|
138
|
-
},
|
|
139
|
-
dx: (_d, ctx) => {
|
|
140
|
-
var _a, _b;
|
|
141
|
-
const r = getBowlCenterImageRect(spec, ctx), userWidth = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.width, w = "number" == typeof userWidth ? userWidth : r.width;
|
|
142
|
-
return (r.width - w) / 2;
|
|
143
|
-
},
|
|
144
|
-
dy: (_d, ctx) => {
|
|
145
|
-
var _a, _b;
|
|
146
|
-
const r = getBowlCenterImageRect(spec, ctx), userHeight = null === (_b = null === (_a = spec.centerImage) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.height, h = "number" == typeof userHeight ? userHeight : r.height;
|
|
147
|
-
return (r.height - h) / 2;
|
|
148
|
-
}
|
|
149
|
-
}, null === (_e = spec.centerImage) || void 0 === _e ? void 0 : _e.style)
|
|
150
|
-
}) : null ].filter(Boolean)
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
exports.buildBowlCenterImageMark = buildBowlCenterImageMark;
|
|
155
|
-
|
|
156
|
-
const getBowlBlockMetrics = spec => {
|
|
157
|
-
var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
158
|
-
const titleFontSize = Number(null !== (_c = null === (_b = null === (_a = spec.title) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize) && void 0 !== _c ? _c : 14), titleLineHeight = Number(null !== (_g = null === (_f = null === (_e = spec.title) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.lineHeight) && void 0 !== _g ? _g : Math.max(19, Math.round(1.35 * titleFontSize))), contentFontSize = Number(null !== (_k = null === (_j = null === (_h = spec.content) || void 0 === _h ? void 0 : _h.style) || void 0 === _j ? void 0 : _j.fontSize) && void 0 !== _k ? _k : 12), contentLineHeight = Number(null !== (_o = null === (_m = null === (_l = spec.content) || void 0 === _l ? void 0 : _l.style) || void 0 === _m ? void 0 : _m.lineHeight) && void 0 !== _o ? _o : 17), contentHeight = Math.max(300 - titleLineHeight - 4, contentLineHeight), imageWidth = null !== (_q = null === (_p = spec.image) || void 0 === _p ? void 0 : _p.width) && void 0 !== _q ? _q : 140, imageHeight = null !== (_s = null === (_r = spec.image) || void 0 === _r ? void 0 : _r.height) && void 0 !== _s ? _s : 140, imageBox = {
|
|
159
|
-
x: -imageWidth / 2,
|
|
160
|
-
y: -imageHeight / 2,
|
|
161
|
-
width: imageWidth,
|
|
162
|
-
height: imageHeight
|
|
163
|
-
}, textBox = {
|
|
164
|
-
x: -imageWidth / 2 + 20,
|
|
165
|
-
y: imageBox.y + imageHeight + 10,
|
|
166
|
-
width: imageWidth - 20,
|
|
167
|
-
height: 300
|
|
168
|
-
};
|
|
169
|
-
return {
|
|
170
|
-
titleFontSize: titleFontSize,
|
|
171
|
-
titleLineHeight: titleLineHeight,
|
|
172
|
-
contentFontSize: contentFontSize,
|
|
173
|
-
contentLineHeight: contentLineHeight,
|
|
174
|
-
imageBox: imageBox,
|
|
175
|
-
textBox: textBox,
|
|
176
|
-
contentBox: {
|
|
177
|
-
x: textBox.x,
|
|
178
|
-
y: textBox.y + titleLineHeight + 4,
|
|
179
|
-
width: textBox.width,
|
|
180
|
-
height: contentHeight
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
}, buildBowlBlockMark = (spec, block, index) => {
|
|
184
|
-
var _a, _b, _c, _e;
|
|
185
|
-
const hasImage = !!block.image, contentText = Array.isArray(block.content) ? block.content : block.content ? [ block.content ] : [], themeColor = (0,
|
|
186
|
-
common_1.getThemeColor)(spec), metrics = getBowlBlockMetrics(spec);
|
|
187
|
-
return {
|
|
188
|
-
type: "group",
|
|
189
|
-
id: `storyline-block-${null !== (_a = block.id) && void 0 !== _a ? _a : index}`,
|
|
190
|
-
name: `storyline-block-${index}`,
|
|
191
|
-
zIndex: vchart_1.LayoutZIndex.Mark + 1,
|
|
192
|
-
style: {
|
|
193
|
-
x: (_d, ctx) => getBowlBlockCenter(spec, ctx, index).x,
|
|
194
|
-
y: (_d, ctx) => getBowlBlockCenter(spec, ctx, index).y
|
|
195
|
-
},
|
|
196
|
-
children: [ {
|
|
197
|
-
type: "rect",
|
|
198
|
-
name: `storyline-block-connector-${index}`,
|
|
199
|
-
interactive: !1,
|
|
200
|
-
style: {
|
|
201
|
-
x: metrics.imageBox.x,
|
|
202
|
-
y: metrics.imageBox.y + metrics.imageBox.height,
|
|
203
|
-
width: 2,
|
|
204
|
-
height: Math.max(metrics.textBox.y + metrics.textBox.height - (metrics.imageBox.y + metrics.imageBox.height), 0),
|
|
205
|
-
fill: themeColor,
|
|
206
|
-
fillOpacity: .6
|
|
207
|
-
}
|
|
208
|
-
}, hasImage ? Object.assign(Object.assign({
|
|
209
|
-
type: "image",
|
|
210
|
-
name: `storyline-block-image-${index}`,
|
|
211
|
-
interactive: !1
|
|
212
|
-
}, (0, common_1.omitImageLayoutSpec)(spec.image)), {
|
|
213
|
-
style: Object.assign({
|
|
214
|
-
x: metrics.imageBox.x,
|
|
215
|
-
y: metrics.imageBox.y,
|
|
216
|
-
width: metrics.imageBox.width,
|
|
217
|
-
height: metrics.imageBox.height,
|
|
218
|
-
image: block.image,
|
|
219
|
-
cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2,
|
|
220
|
-
repeatX: "no-repeat",
|
|
221
|
-
repeatY: "no-repeat",
|
|
222
|
-
imageMode: "cover",
|
|
223
|
-
imagePosition: "center",
|
|
224
|
-
stroke: themeColor,
|
|
225
|
-
lineWidth: 2
|
|
226
|
-
}, null === (_b = spec.image) || void 0 === _b ? void 0 : _b.style)
|
|
227
|
-
}) : {
|
|
228
|
-
type: "rect",
|
|
229
|
-
name: `storyline-block-image-bg-${index}`,
|
|
230
|
-
interactive: !1,
|
|
231
|
-
style: {
|
|
232
|
-
x: metrics.imageBox.x,
|
|
233
|
-
y: metrics.imageBox.y,
|
|
234
|
-
width: metrics.imageBox.width,
|
|
235
|
-
height: metrics.imageBox.height,
|
|
236
|
-
cornerRadius: Math.min(metrics.imageBox.width, metrics.imageBox.height) / 2,
|
|
237
|
-
fill: "#ffffff",
|
|
238
|
-
stroke: themeColor,
|
|
239
|
-
lineWidth: 2
|
|
240
|
-
}
|
|
241
|
-
}, block.title ? Object.assign(Object.assign({
|
|
242
|
-
type: "text",
|
|
243
|
-
name: `storyline-block-title-${index}`,
|
|
244
|
-
interactive: !1
|
|
245
|
-
}, spec.title), {
|
|
246
|
-
style: Object.assign({
|
|
247
|
-
x: metrics.textBox.x,
|
|
248
|
-
y: metrics.textBox.y,
|
|
249
|
-
text: block.title,
|
|
250
|
-
maxLineWidth: metrics.textBox.width,
|
|
251
|
-
fontSize: metrics.titleFontSize,
|
|
252
|
-
lineHeight: metrics.titleLineHeight,
|
|
253
|
-
fontWeight: "bold",
|
|
254
|
-
fill: "#1f2430",
|
|
255
|
-
textAlign: "left",
|
|
256
|
-
textBaseline: "top"
|
|
257
|
-
}, null === (_c = spec.title) || void 0 === _c ? void 0 : _c.style)
|
|
258
|
-
}) : null, contentText.length ? Object.assign(Object.assign({
|
|
259
|
-
type: "text",
|
|
260
|
-
name: `storyline-block-content-${index}`,
|
|
261
|
-
interactive: !1
|
|
262
|
-
}, spec.content), {
|
|
263
|
-
textType: "rich",
|
|
264
|
-
style: Object.assign({
|
|
265
|
-
x: metrics.contentBox.x,
|
|
266
|
-
y: metrics.contentBox.y,
|
|
267
|
-
width: metrics.contentBox.width,
|
|
268
|
-
height: metrics.contentBox.height,
|
|
269
|
-
maxLineWidth: metrics.contentBox.width,
|
|
270
|
-
heightLimit: metrics.contentBox.height,
|
|
271
|
-
text: (0, common_1.buildRichContent)(contentText, spec),
|
|
272
|
-
fontSize: 12,
|
|
273
|
-
lineHeight: 17,
|
|
274
|
-
textAlign: "left",
|
|
275
|
-
textBaseline: "top",
|
|
276
|
-
wordBreak: "break-word",
|
|
277
|
-
ellipsis: "...",
|
|
278
|
-
fill: "#596173"
|
|
279
|
-
}, null === (_e = spec.content) || void 0 === _e ? void 0 : _e.style)
|
|
280
|
-
}) : null ].filter(Boolean)
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
exports.buildBowlBlockMark = buildBowlBlockMark;
|
|
285
|
-
//# sourceMappingURL=bowl.js.map
|