@visactor/vchart-extension 2.1.0-alpha.2 → 2.1.0-alpha.20
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 +2393 -0
- 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/funnel-3d/chart.js +2 -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/storyline/index.d.ts +4 -0
- package/cjs/charts/storyline/index.js +22 -0
- package/cjs/charts/storyline/index.js.map +1 -0
- package/cjs/charts/storyline/interface.d.ts +69 -0
- package/cjs/charts/storyline/interface.js +6 -0
- package/cjs/charts/storyline/interface.js.map +1 -0
- package/cjs/charts/storyline/layout.d.ts +58 -0
- package/cjs/charts/storyline/layout.js +214 -0
- package/cjs/charts/storyline/layout.js.map +1 -0
- package/cjs/charts/storyline/layouts/arc.d.ts +5 -0
- package/cjs/charts/storyline/layouts/arc.js +327 -0
- package/cjs/charts/storyline/layouts/arc.js.map +1 -0
- package/cjs/charts/storyline/layouts/clock.d.ts +5 -0
- package/cjs/charts/storyline/layouts/clock.js +248 -0
- package/cjs/charts/storyline/layouts/clock.js.map +1 -0
- package/cjs/charts/storyline/layouts/common.d.ts +98 -0
- package/cjs/charts/storyline/layouts/common.js +293 -0
- package/cjs/charts/storyline/layouts/common.js.map +1 -0
- package/cjs/charts/storyline/layouts/default.d.ts +4 -0
- package/cjs/charts/storyline/layouts/default.js +183 -0
- package/cjs/charts/storyline/layouts/default.js.map +1 -0
- package/cjs/charts/storyline/layouts/ladder.d.ts +5 -0
- package/cjs/charts/storyline/layouts/ladder.js +207 -0
- package/cjs/charts/storyline/layouts/ladder.js.map +1 -0
- package/cjs/charts/storyline/layouts/landscape.d.ts +4 -0
- package/cjs/charts/storyline/layouts/landscape.js +258 -0
- package/cjs/charts/storyline/layouts/landscape.js.map +1 -0
- package/cjs/charts/storyline/layouts/portrait.d.ts +11 -0
- package/cjs/charts/storyline/layouts/portrait.js +270 -0
- package/cjs/charts/storyline/layouts/portrait.js.map +1 -0
- package/cjs/charts/storyline/layouts/wing.d.ts +4 -0
- package/cjs/charts/storyline/layouts/wing.js +272 -0
- package/cjs/charts/storyline/layouts/wing.js.map +1 -0
- package/cjs/charts/storyline/storyline-transformer.d.ts +4 -0
- package/cjs/charts/storyline/storyline-transformer.js +91 -0
- package/cjs/charts/storyline/storyline-transformer.js.map +1 -0
- package/cjs/charts/storyline/storyline.d.ts +16 -0
- package/cjs/charts/storyline/storyline.js +36 -0
- package/cjs/charts/storyline/storyline.js.map +1 -0
- package/cjs/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 -2
- 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 -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 +1 -0
- 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/funnel-3d/chart.js +2 -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/storyline/index.d.ts +4 -0
- package/esm/charts/storyline/index.js +8 -0
- package/esm/charts/storyline/index.js.map +1 -0
- package/esm/charts/storyline/interface.d.ts +69 -0
- package/esm/charts/storyline/interface.js +2 -0
- package/esm/charts/storyline/interface.js.map +1 -0
- package/esm/charts/storyline/layout.d.ts +58 -0
- package/esm/charts/storyline/layout.js +204 -0
- package/esm/charts/storyline/layout.js.map +1 -0
- package/esm/charts/storyline/layouts/arc.d.ts +5 -0
- package/esm/charts/storyline/layouts/arc.js +320 -0
- package/esm/charts/storyline/layouts/arc.js.map +1 -0
- package/esm/charts/storyline/layouts/clock.d.ts +5 -0
- package/esm/charts/storyline/layouts/clock.js +242 -0
- package/esm/charts/storyline/layouts/clock.js.map +1 -0
- package/esm/charts/storyline/layouts/common.d.ts +98 -0
- package/esm/charts/storyline/layouts/common.js +258 -0
- package/esm/charts/storyline/layouts/common.js.map +1 -0
- package/esm/charts/storyline/layouts/default.d.ts +4 -0
- package/esm/charts/storyline/layouts/default.js +176 -0
- package/esm/charts/storyline/layouts/default.js.map +1 -0
- package/esm/charts/storyline/layouts/ladder.d.ts +5 -0
- package/esm/charts/storyline/layouts/ladder.js +198 -0
- package/esm/charts/storyline/layouts/ladder.js.map +1 -0
- package/esm/charts/storyline/layouts/landscape.d.ts +4 -0
- package/esm/charts/storyline/layouts/landscape.js +254 -0
- package/esm/charts/storyline/layouts/landscape.js.map +1 -0
- package/esm/charts/storyline/layouts/portrait.d.ts +11 -0
- package/esm/charts/storyline/layouts/portrait.js +274 -0
- package/esm/charts/storyline/layouts/portrait.js.map +1 -0
- package/esm/charts/storyline/layouts/wing.d.ts +4 -0
- package/esm/charts/storyline/layouts/wing.js +268 -0
- package/esm/charts/storyline/layouts/wing.js.map +1 -0
- package/esm/charts/storyline/storyline-transformer.d.ts +4 -0
- package/esm/charts/storyline/storyline-transformer.js +88 -0
- package/esm/charts/storyline/storyline-transformer.js.map +1 -0
- package/esm/charts/storyline/storyline.d.ts +16 -0
- package/esm/charts/storyline/storyline.js +29 -0
- package/esm/charts/storyline/storyline.js.map +1 -0
- package/esm/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 -2
- 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 -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 +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { LayoutZIndex } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { DEFAULT_BLOCK_HEIGHT, buildRichContent, getLayout, getThemeColor, omitImageLayoutSpec, resolveBlockWidth, withAlpha } from "./common";
|
|
4
|
+
|
|
5
|
+
const PORTRAIT_AXIS_WIDTH = 96, PORTRAIT_AXIS_PADDING = 50, PORTRAIT_MARKER_FONT_SIZE = 40, PORTRAIT_MARKER_LINE_HEIGHT = 28, PORTRAIT_MARKER_AXIS_PADDING = 6;
|
|
6
|
+
|
|
7
|
+
export const PORTRAIT_IMAGE_HEIGHT_RATIO = .6;
|
|
8
|
+
|
|
9
|
+
export const PORTRAIT_CONTENT_HEIGHT_RATIO = 1;
|
|
10
|
+
|
|
11
|
+
const PORTRAIT_IMAGE_GAP_FROM_AXIS = 24, PORTRAIT_SHADOW_OFFSET_X = 24, PORTRAIT_SHADOW_OFFSET_Y = 16, PORTRAIT_SHADOW_SCALE = 1;
|
|
12
|
+
|
|
13
|
+
export const PORTRAIT_TEXT_GAP_FROM_IMAGE = 8;
|
|
14
|
+
|
|
15
|
+
export const PORTRAIT_CONTENT_LINES = 3;
|
|
16
|
+
|
|
17
|
+
export const PORTRAIT_TITLE_LINE_HEIGHT = 34;
|
|
18
|
+
|
|
19
|
+
export const PORTRAIT_CONTENT_LINE_HEIGHT = 26;
|
|
20
|
+
|
|
21
|
+
const PORTRAIT_CONTENT_FONT_SIZE = 18;
|
|
22
|
+
|
|
23
|
+
export const PORTRAIT_TITLE_TO_CONTENT_GAP = 4;
|
|
24
|
+
|
|
25
|
+
const getPortraitAxisRect = (spec, ctx) => {
|
|
26
|
+
const blocks = getLayout(spec, ctx).blocks;
|
|
27
|
+
if (!blocks.length) return {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
width: 0,
|
|
31
|
+
height: 0
|
|
32
|
+
};
|
|
33
|
+
const firstCy = blocks[0].center.y, lastCy = blocks[blocks.length - 1].center.y, top = Math.min(firstCy, lastCy), bottom = Math.max(firstCy, lastCy);
|
|
34
|
+
return {
|
|
35
|
+
x: blocks[0].center.x - 48,
|
|
36
|
+
y: top - 50,
|
|
37
|
+
width: 96,
|
|
38
|
+
height: bottom - top + 100
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const buildPortraitAxisMark = spec => {
|
|
43
|
+
var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
44
|
+
const themeColor = getThemeColor(spec), lineStyle = null !== (_b = null === (_a = spec.line) || void 0 === _a ? void 0 : _a.style) && void 0 !== _b ? _b : {}, defaultFill = {
|
|
45
|
+
gradient: "linear",
|
|
46
|
+
x0: 0,
|
|
47
|
+
y0: 0,
|
|
48
|
+
x1: 0,
|
|
49
|
+
y1: 1,
|
|
50
|
+
stops: [ {
|
|
51
|
+
offset: 0,
|
|
52
|
+
color: withAlpha(themeColor, .2)
|
|
53
|
+
}, {
|
|
54
|
+
offset: 1,
|
|
55
|
+
color: withAlpha(themeColor, 1)
|
|
56
|
+
} ]
|
|
57
|
+
}, markerFontSize = Number(null !== (_f = null === (_e = null === (_c = spec.marker) || void 0 === _c ? void 0 : _c.style) || void 0 === _e ? void 0 : _e.fontSize) && void 0 !== _f ? _f : 40), markerLineHeight = Number(null !== (_j = null === (_h = null === (_g = spec.marker) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.lineHeight) && void 0 !== _j ? _j : 28), markerMarks = !1 !== (null === (_k = spec.marker) || void 0 === _k ? void 0 : _k.visible) ? (null !== (_l = spec.data) && void 0 !== _l ? _l : []).map(((block, index) => {
|
|
58
|
+
var _a;
|
|
59
|
+
if (!block.marker) return null;
|
|
60
|
+
const onLeft = index % 2 == 0, markerOffsetX = onLeft ? -42 : 42, markerTextAlign = onLeft ? "left" : "right";
|
|
61
|
+
return Object.assign(Object.assign({
|
|
62
|
+
type: "text",
|
|
63
|
+
textType: "rich",
|
|
64
|
+
name: `storyline-portrait-marker-${index}`,
|
|
65
|
+
interactive: !1
|
|
66
|
+
}, spec.marker), {
|
|
67
|
+
style: Object.assign({
|
|
68
|
+
x: (_d, ctx) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const lb = getLayout(spec, ctx).blocks[index];
|
|
71
|
+
return (null !== (_b = null === (_a = null == lb ? void 0 : lb.center) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0) + markerOffsetX;
|
|
72
|
+
},
|
|
73
|
+
y: (_d, ctx) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const lb = getLayout(spec, ctx).blocks[index];
|
|
76
|
+
return null !== (_b = null === (_a = null == lb ? void 0 : lb.center) || void 0 === _a ? void 0 : _a.y) && void 0 !== _b ? _b : 0;
|
|
77
|
+
},
|
|
78
|
+
text: {
|
|
79
|
+
type: "rich",
|
|
80
|
+
text: block.marker.split("").map(((char, i, arr) => ({
|
|
81
|
+
text: char + (i < arr.length - 1 ? "\n" : ""),
|
|
82
|
+
fontSize: markerFontSize,
|
|
83
|
+
lineHeight: markerLineHeight,
|
|
84
|
+
fill: "#fff",
|
|
85
|
+
align: markerTextAlign
|
|
86
|
+
})))
|
|
87
|
+
},
|
|
88
|
+
fontWeight: "bold",
|
|
89
|
+
lineJoin: "round",
|
|
90
|
+
shadowColor: "rgba(0, 0, 0, 0.3)",
|
|
91
|
+
shadowBlur: 8,
|
|
92
|
+
shadowOffsetX: 0,
|
|
93
|
+
shadowOffsetY: 5,
|
|
94
|
+
textAlign: markerTextAlign,
|
|
95
|
+
textBaseline: "middle"
|
|
96
|
+
}, null === (_a = spec.marker) || void 0 === _a ? void 0 : _a.style)
|
|
97
|
+
});
|
|
98
|
+
})).filter(Boolean) : [];
|
|
99
|
+
return {
|
|
100
|
+
type: "group",
|
|
101
|
+
name: "storyline-portrait-axis",
|
|
102
|
+
zIndex: LayoutZIndex.Mark,
|
|
103
|
+
children: [ {
|
|
104
|
+
type: "rect",
|
|
105
|
+
name: "storyline-portrait-axis-rect",
|
|
106
|
+
interactive: !1,
|
|
107
|
+
style: {
|
|
108
|
+
fill: null !== (_m = lineStyle.fill) && void 0 !== _m ? _m : defaultFill,
|
|
109
|
+
stroke: null !== (_o = lineStyle.stroke) && void 0 !== _o && _o,
|
|
110
|
+
lineWidth: null !== (_p = lineStyle.lineWidth) && void 0 !== _p ? _p : 0,
|
|
111
|
+
cornerRadius: null !== (_q = lineStyle.cornerRadius) && void 0 !== _q ? _q : 0,
|
|
112
|
+
x: (_d, ctx) => getPortraitAxisRect(spec, ctx).x,
|
|
113
|
+
y: (_d, ctx) => getPortraitAxisRect(spec, ctx).y,
|
|
114
|
+
width: (_d, ctx) => getPortraitAxisRect(spec, ctx).width,
|
|
115
|
+
height: (_d, ctx) => getPortraitAxisRect(spec, ctx).height
|
|
116
|
+
}
|
|
117
|
+
}, ...markerMarks ]
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const getPortraitMetrics = (spec, blockWidth, blockHeight, index) => {
|
|
122
|
+
var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
123
|
+
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 : 26), 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(34, 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 : 18), 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 : 26), imageWidth = null !== (_q = null === (_p = spec.image) || void 0 === _p ? void 0 : _p.width) && void 0 !== _q ? _q : Math.max(blockWidth, 80), imageHeight = null !== (_s = null === (_r = spec.image) || void 0 === _r ? void 0 : _r.height) && void 0 !== _s ? _s : Math.round(.6 * blockHeight), minContentHeight = 3 * contentLineHeight, contentHeight = Math.max(minContentHeight, Math.round(1 * blockHeight)), onLeft = index % 2 == 0, imageX = onLeft ? -72 - imageWidth : 72, imageY = -imageHeight / 2, textY = imageY + imageHeight + 8, shadowWidth = 1 * imageWidth, shadowHeight = 1 * imageHeight;
|
|
124
|
+
return {
|
|
125
|
+
onLeft: onLeft,
|
|
126
|
+
titleFontSize: titleFontSize,
|
|
127
|
+
titleLineHeight: titleLineHeight,
|
|
128
|
+
contentFontSize: contentFontSize,
|
|
129
|
+
contentLineHeight: contentLineHeight,
|
|
130
|
+
blockWidth: blockWidth,
|
|
131
|
+
imageBox: {
|
|
132
|
+
x: imageX,
|
|
133
|
+
y: imageY,
|
|
134
|
+
width: imageWidth,
|
|
135
|
+
height: imageHeight
|
|
136
|
+
},
|
|
137
|
+
shadowBox: {
|
|
138
|
+
x: imageX - (shadowWidth - imageWidth) / 2 + (onLeft ? -24 : 24),
|
|
139
|
+
y: imageY - (shadowHeight - imageHeight) / 2 + 16,
|
|
140
|
+
width: shadowWidth,
|
|
141
|
+
height: shadowHeight
|
|
142
|
+
},
|
|
143
|
+
textBox: {
|
|
144
|
+
x: imageX,
|
|
145
|
+
y: textY,
|
|
146
|
+
width: imageWidth,
|
|
147
|
+
height: titleLineHeight + 4 + contentHeight
|
|
148
|
+
},
|
|
149
|
+
contentBox: {
|
|
150
|
+
x: imageX,
|
|
151
|
+
y: textY + titleLineHeight + 4,
|
|
152
|
+
width: imageWidth,
|
|
153
|
+
height: contentHeight
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const buildPortraitBlockMark = (spec, block, index) => {
|
|
159
|
+
var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
160
|
+
const hasImage = !!block.image, hasSubImage = !!block.subImage, contentText = Array.isArray(block.content) ? block.content : block.content ? [ block.content ] : [], titleFontSize = Number(null !== (_c = null === (_b = null === (_a = spec.title) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize) && void 0 !== _c ? _c : 26), 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(34, Math.round(1.35 * titleFontSize))), getMetrics = ctx => {
|
|
161
|
+
var _a, _b, _c, _e;
|
|
162
|
+
const lb = getLayout(spec, ctx).blocks[index], w = null !== (_a = null == lb ? void 0 : lb.width) && void 0 !== _a ? _a : resolveBlockWidth(spec, 0), h = null !== (_e = null !== (_b = null == lb ? void 0 : lb.height) && void 0 !== _b ? _b : null === (_c = spec.block) || void 0 === _c ? void 0 : _c.height) && void 0 !== _e ? _e : DEFAULT_BLOCK_HEIGHT;
|
|
163
|
+
return getPortraitMetrics(spec, w, h, index);
|
|
164
|
+
}, themeColor = getThemeColor(spec), blockStyle = null !== (_j = null === (_h = spec.block) || void 0 === _h ? void 0 : _h.style) && void 0 !== _j ? _j : {};
|
|
165
|
+
return {
|
|
166
|
+
type: "group",
|
|
167
|
+
id: `storyline-block-${null !== (_k = block.id) && void 0 !== _k ? _k : index}`,
|
|
168
|
+
name: `storyline-block-${index}`,
|
|
169
|
+
zIndex: LayoutZIndex.Mark + 1,
|
|
170
|
+
style: {
|
|
171
|
+
x: (_d, ctx) => {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
const lb = getLayout(spec, ctx).blocks[index];
|
|
174
|
+
return null !== (_b = null === (_a = null == lb ? void 0 : lb.center) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0;
|
|
175
|
+
},
|
|
176
|
+
y: (_d, ctx) => {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
const lb = getLayout(spec, ctx).blocks[index];
|
|
179
|
+
return null !== (_b = null === (_a = null == lb ? void 0 : lb.center) || void 0 === _a ? void 0 : _a.y) && void 0 !== _b ? _b : 0;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
children: [ hasSubImage ? {
|
|
183
|
+
type: "image",
|
|
184
|
+
name: `storyline-block-shadow-image-${index}`,
|
|
185
|
+
interactive: !1,
|
|
186
|
+
style: {
|
|
187
|
+
x: (_d, ctx) => getMetrics(ctx).shadowBox.x,
|
|
188
|
+
y: (_d, ctx) => getMetrics(ctx).shadowBox.y,
|
|
189
|
+
width: (_d, ctx) => getMetrics(ctx).shadowBox.width,
|
|
190
|
+
height: (_d, ctx) => getMetrics(ctx).shadowBox.height,
|
|
191
|
+
image: block.subImage,
|
|
192
|
+
repeatX: "no-repeat",
|
|
193
|
+
repeatY: "no-repeat",
|
|
194
|
+
imageMode: "cover",
|
|
195
|
+
imagePosition: "center"
|
|
196
|
+
}
|
|
197
|
+
} : null, !0 === (null === (_l = spec.image) || void 0 === _l ? void 0 : _l.showBackground) ? {
|
|
198
|
+
type: "rect",
|
|
199
|
+
name: `storyline-block-image-bg-${index}`,
|
|
200
|
+
interactive: !1,
|
|
201
|
+
style: Object.assign({
|
|
202
|
+
x: (_d, ctx) => getMetrics(ctx).imageBox.x,
|
|
203
|
+
y: (_d, ctx) => getMetrics(ctx).imageBox.y,
|
|
204
|
+
width: (_d, ctx) => getMetrics(ctx).imageBox.width,
|
|
205
|
+
height: (_d, ctx) => getMetrics(ctx).imageBox.height,
|
|
206
|
+
cornerRadius: 8,
|
|
207
|
+
fill: "#ffffff",
|
|
208
|
+
stroke: themeColor,
|
|
209
|
+
lineWidth: 2
|
|
210
|
+
}, blockStyle)
|
|
211
|
+
} : null, hasImage ? Object.assign(Object.assign({
|
|
212
|
+
type: "image",
|
|
213
|
+
name: `storyline-block-image-${index}`,
|
|
214
|
+
interactive: !1
|
|
215
|
+
}, omitImageLayoutSpec(spec.image)), {
|
|
216
|
+
style: Object.assign({
|
|
217
|
+
x: (_d, ctx) => getMetrics(ctx).imageBox.x,
|
|
218
|
+
y: (_d, ctx) => getMetrics(ctx).imageBox.y,
|
|
219
|
+
width: (_d, ctx) => getMetrics(ctx).imageBox.width,
|
|
220
|
+
height: (_d, ctx) => getMetrics(ctx).imageBox.height,
|
|
221
|
+
image: block.image,
|
|
222
|
+
repeatX: "no-repeat",
|
|
223
|
+
repeatY: "no-repeat",
|
|
224
|
+
imageMode: "cover",
|
|
225
|
+
imagePosition: "center"
|
|
226
|
+
}, null === (_m = spec.image) || void 0 === _m ? void 0 : _m.style)
|
|
227
|
+
}) : null, block.title ? Object.assign(Object.assign({
|
|
228
|
+
type: "text",
|
|
229
|
+
name: `storyline-block-title-${index}`,
|
|
230
|
+
interactive: !1
|
|
231
|
+
}, spec.title), {
|
|
232
|
+
style: Object.assign({
|
|
233
|
+
x: (_d, ctx) => getMetrics(ctx).textBox.x,
|
|
234
|
+
y: (_d, ctx) => getMetrics(ctx).textBox.y,
|
|
235
|
+
text: block.title,
|
|
236
|
+
maxLineWidth: (_d, ctx) => getMetrics(ctx).textBox.width,
|
|
237
|
+
fontSize: titleFontSize,
|
|
238
|
+
lineHeight: titleLineHeight,
|
|
239
|
+
fontWeight: "bold",
|
|
240
|
+
fill: "#1f2430",
|
|
241
|
+
stroke: "#fff",
|
|
242
|
+
lineWidth: 5,
|
|
243
|
+
lineJoin: "round",
|
|
244
|
+
textAlign: "left",
|
|
245
|
+
textBaseline: "top"
|
|
246
|
+
}, null === (_o = spec.title) || void 0 === _o ? void 0 : _o.style)
|
|
247
|
+
}) : null, contentText.length ? Object.assign(Object.assign({
|
|
248
|
+
type: "text",
|
|
249
|
+
name: `storyline-block-content-${index}`,
|
|
250
|
+
interactive: !1
|
|
251
|
+
}, spec.content), {
|
|
252
|
+
textType: "rich",
|
|
253
|
+
style: Object.assign({
|
|
254
|
+
x: (_d, ctx) => getMetrics(ctx).contentBox.x,
|
|
255
|
+
y: (_d, ctx) => getMetrics(ctx).contentBox.y,
|
|
256
|
+
width: (_d, ctx) => getMetrics(ctx).contentBox.width,
|
|
257
|
+
height: (_d, ctx) => getMetrics(ctx).contentBox.height,
|
|
258
|
+
maxLineWidth: (_d, ctx) => getMetrics(ctx).contentBox.width,
|
|
259
|
+
heightLimit: (_d, ctx) => getMetrics(ctx).contentBox.height,
|
|
260
|
+
text: buildRichContent(contentText, spec, {
|
|
261
|
+
fontSize: 18,
|
|
262
|
+
lineHeight: 26,
|
|
263
|
+
fill: "#596173"
|
|
264
|
+
}),
|
|
265
|
+
textAlign: "left",
|
|
266
|
+
textBaseline: "top",
|
|
267
|
+
wordBreak: "break-word",
|
|
268
|
+
ellipsis: "...",
|
|
269
|
+
fill: "#596173"
|
|
270
|
+
}, null === (_p = spec.content) || void 0 === _p ? void 0 : _p.style)
|
|
271
|
+
}) : null ].filter(Boolean)
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=portrait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/storyline/layouts/portrait.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAGL,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACV,MAAM,UAAU,CAAC;AAIlB,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAKvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAC/C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAC/C,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CA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AAC,OAAO,KACf,QAAQ,EAAE,MAAM,EAChB,KAAK,kBACH,CAAC,EAAE,CAAC,EAAW,EAAE,GAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,EACpE,CAAC,EAAE,CAAC,EAAW,EAAE,GAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,EACpE,KAAK,EAAE,CAAC,EAAW,EAAE,GAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAC5E,MAAM,EAAE,CAAC,EAAW,EAAE,GAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,EAC9E,YAAY,EAAE,CAAC,EAAW,EAAE,GAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EACnF,WAAW,EAAE,CAAC,EAAW,EAAE,GAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,EACnF,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,IAAI,EAAE;4BACxC,QAAQ,EAAE,0BAA0B;4BACpC,UAAU,EAAE,4BAA4B;4BACxC,IAAI,EAAE,SAAS;yBAChB,CAAC,EACF,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE,KAAK,EACf,IAAI,EAAE,SAAS,IACZ,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,IAEG;gBAC/B,CAAC,CAAC,IAAI;SACT,CAAC,MAAM,CAAC,OAAO,CAA2B;KAC5C,CAAC;AACJ,CAAC,CAAC","file":"portrait.js","sourcesContent":["import type { IExtensionGroupMarkSpec } from '@visactor/vchart';\nimport { LayoutZIndex } from '@visactor/vchart';\nimport type { IStorylineBlock, IStorylineSpec } from '../interface';\nimport {\n type ICustomMarkSpec,\n type LayoutContext,\n DEFAULT_BLOCK_HEIGHT,\n buildRichContent,\n getLayout,\n getThemeColor,\n omitImageLayoutSpec,\n resolveBlockWidth,\n withAlpha\n} from './common';\n\n// portrait 布局:中轴 rect + 左右交替的 image + image 下方 title/content\n// 中轴默认加宽,便于在轴上叠放 block.marker 时间节点文字(纵向逐字排列)\nconst PORTRAIT_AXIS_WIDTH = 96;\nconst PORTRAIT_AXIS_PADDING = 50; // 中轴上下两端的留白\n// marker 时间节点文字的默认样式(fontSize 30、白色字、贴轴对应一侧边缘)\nconst PORTRAIT_MARKER_FONT_SIZE = 40;\nconst PORTRAIT_MARKER_LINE_HEIGHT = 28;\nconst PORTRAIT_MARKER_AXIS_PADDING = 6; // marker 距离轴边缘的水平内边距\n// image 默认尺寸的占比规则(基于 region 平均槽位):\n// - image 高度 = slotHeight * 0.6\n// - content 高度 = slotHeight * (0.6 + 0.4)\n// 其中 slotHeight = regionHeight / (blockCount + 1),由 getLayout 计算。\nexport const PORTRAIT_IMAGE_HEIGHT_RATIO = 0.6;\nexport const PORTRAIT_CONTENT_HEIGHT_RATIO = 1;\nconst PORTRAIT_IMAGE_GAP_FROM_AXIS = 24; // image 与中轴之间的水平间距\nconst PORTRAIT_SHADOW_OFFSET_X = 24; // subImage 相对主 image 的水平错位量\nconst PORTRAIT_SHADOW_OFFSET_Y = 16; // subImage 相对主 image 的垂直错位量\nconst PORTRAIT_SHADOW_SCALE = 1; // subImage 与主 image 同尺寸,仅做错位偏移\nexport const PORTRAIT_TEXT_GAP_FROM_IMAGE = 8;\nexport const PORTRAIT_CONTENT_LINES = 3;\nexport const PORTRAIT_TITLE_LINE_HEIGHT = 34;\nexport const PORTRAIT_CONTENT_LINE_HEIGHT = 26;\nconst PORTRAIT_CONTENT_FONT_SIZE = 18;\nexport const PORTRAIT_TITLE_TO_CONTENT_GAP = 4;\n\n/**\n * 获取 portrait 布局的中轴 rect 尺寸:宽度固定,高度贯穿首/尾 block 中心。\n */\nconst getPortraitAxisRect = (spec: IStorylineSpec, ctx: LayoutContext) => {\n const blocks = getLayout(spec, ctx).blocks;\n if (!blocks.length) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n const firstCy = blocks[0].center.y;\n const lastCy = blocks[blocks.length - 1].center.y;\n const top = Math.min(firstCy, lastCy);\n const bottom = Math.max(firstCy, lastCy);\n const cx = blocks[0].center.x;\n return {\n x: cx - PORTRAIT_AXIS_WIDTH / 2,\n y: top - PORTRAIT_AXIS_PADDING,\n width: PORTRAIT_AXIS_WIDTH,\n height: bottom - top + PORTRAIT_AXIS_PADDING * 2\n };\n};\n\nexport const buildPortraitAxisMark = (spec: IStorylineSpec): IExtensionGroupMarkSpec => {\n const themeColor = getThemeColor(spec);\n const lineStyle = spec.line?.style ?? {};\n const defaultFill = {\n gradient: 'linear',\n x0: 0,\n y0: 0,\n x1: 0,\n y1: 1,\n stops: [\n { offset: 0, color: withAlpha(themeColor, 0.2) },\n { offset: 1, color: withAlpha(themeColor, 1) }\n ]\n };\n // marker 时间节点文字:垂直方向逐字排列(每字符换行)\n const markerFontSize = Number((spec.marker?.style as any)?.fontSize ?? PORTRAIT_MARKER_FONT_SIZE);\n const markerLineHeight = Number((spec.marker?.style as any)?.lineHeight ?? PORTRAIT_MARKER_LINE_HEIGHT);\n const markerVisible = spec.marker?.visible !== false;\n // 把 \"2012\" 拆成 \"2\\n0\\n1\\n2\",由 text mark 的多行文本能力实现纵向排列\n const splitVertical = (text: string) => text.split('').join('\\n');\n\n const markerMarks = markerVisible\n ? (spec.data ?? [])\n .map((block, index) => {\n if (!block.marker) {\n return null;\n }\n // image 在 block 左侧时(index 偶数),marker 贴轴左边缘 + 左对齐;\n // image 在 block 右侧时(index 奇数),marker 贴轴右边缘 + 右对齐。\n const onLeft = index % 2 === 0;\n const axisHalf = PORTRAIT_AXIS_WIDTH / 2;\n const markerOffsetX = onLeft\n ? -axisHalf + PORTRAIT_MARKER_AXIS_PADDING\n : axisHalf - PORTRAIT_MARKER_AXIS_PADDING;\n const markerTextAlign: 'left' | 'right' = onLeft ? 'left' : 'right';\n return {\n type: 'text',\n textType: 'rich',\n name: `storyline-portrait-marker-${index}`,\n interactive: false,\n ...spec.marker,\n style: {\n x: (_d: unknown, ctx: LayoutContext) => {\n const lb = getLayout(spec, ctx).blocks[index];\n return (lb?.center?.x ?? 0) + markerOffsetX;\n },\n y: (_d: unknown, ctx: LayoutContext) => {\n const lb = getLayout(spec, ctx).blocks[index];\n return lb?.center?.y ?? 0;\n },\n text: {\n type: 'rich',\n text: block.marker.split('').map((char, i, arr) => ({\n text: char + (i < arr.length - 1 ? '\\n' : ''),\n fontSize: markerFontSize,\n lineHeight: markerLineHeight,\n fill: '#fff',\n align: markerTextAlign\n }))\n },\n fontWeight: 'bold',\n lineJoin: 'round',\n shadowColor: 'rgba(0, 0, 0, 0.3)',\n shadowBlur: 8,\n shadowOffsetX: 0,\n shadowOffsetY: 5,\n textAlign: markerTextAlign,\n textBaseline: 'middle',\n ...(spec.marker?.style as any)\n }\n } as ICustomMarkSpec<'text'>;\n })\n .filter(Boolean)\n : [];\n\n return {\n type: 'group' as any,\n name: 'storyline-portrait-axis',\n zIndex: LayoutZIndex.Mark,\n children: [\n {\n type: 'rect',\n name: 'storyline-portrait-axis-rect',\n interactive: false,\n style: {\n fill: (lineStyle as any).fill ?? defaultFill,\n stroke: (lineStyle as any).stroke ?? false,\n lineWidth: (lineStyle as any).lineWidth ?? 0,\n cornerRadius: (lineStyle as any).cornerRadius ?? 0,\n x: (_d: unknown, ctx: LayoutContext) => getPortraitAxisRect(spec, ctx).x,\n y: (_d: unknown, ctx: LayoutContext) => getPortraitAxisRect(spec, ctx).y,\n width: (_d: unknown, ctx: LayoutContext) => getPortraitAxisRect(spec, ctx).width,\n height: (_d: unknown, ctx: LayoutContext) => getPortraitAxisRect(spec, ctx).height\n }\n } as ICustomMarkSpec<'rect'>,\n ...(markerMarks as ICustomMarkSpec<any>[])\n ]\n };\n};\n\nconst getPortraitMetrics = (spec: IStorylineSpec, blockWidth: number, blockHeight: number, index: number) => {\n const titleFontSize = Number((spec.title?.style as any)?.fontSize ?? 26);\n const titleLineHeight = Number(\n (spec.title?.style as any)?.lineHeight ?? Math.max(PORTRAIT_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35))\n );\n const contentFontSize = Number((spec.content?.style as any)?.fontSize ?? PORTRAIT_CONTENT_FONT_SIZE);\n const contentLineHeight = Number((spec.content?.style as any)?.lineHeight ?? PORTRAIT_CONTENT_LINE_HEIGHT);\n const titleToContentGap = PORTRAIT_TITLE_TO_CONTENT_GAP;\n\n // 默认 image 高度 = blockHeight * 0.4(blockHeight = regionHeight / count,由 getLayout 计算);\n // 默认 image 宽度 = blockWidth,让 image 横向自适应单个 block 槽位宽度\n const imageWidth = spec.image?.width ?? Math.max(blockWidth, 80);\n const imageHeight = spec.image?.height ?? Math.round(blockHeight * PORTRAIT_IMAGE_HEIGHT_RATIO);\n const minContentHeight = PORTRAIT_CONTENT_LINES * contentLineHeight;\n // 默认 content 高度 = blockHeight * 0.4\n const contentHeight = Math.max(minContentHeight, Math.round(blockHeight * PORTRAIT_CONTENT_HEIGHT_RATIO));\n\n const textHeight = titleLineHeight + titleToContentGap + contentHeight;\n\n const onLeft = index % 2 === 0;\n\n const axisHalf = PORTRAIT_AXIS_WIDTH / 2;\n const imageX = onLeft\n ? -axisHalf - PORTRAIT_IMAGE_GAP_FROM_AXIS - imageWidth\n : axisHalf + PORTRAIT_IMAGE_GAP_FROM_AXIS;\n const imageY = -imageHeight / 2;\n\n const textX = imageX;\n const textY = imageY + imageHeight + PORTRAIT_TEXT_GAP_FROM_IMAGE;\n const textWidth = imageWidth;\n\n const contentBox = {\n x: textX,\n y: textY + titleLineHeight + titleToContentGap,\n width: textWidth,\n height: contentHeight\n };\n\n const shadowOffsetX = PORTRAIT_SHADOW_OFFSET_X;\n const shadowOffsetY = PORTRAIT_SHADOW_OFFSET_Y;\n const shadowWidth = imageWidth * PORTRAIT_SHADOW_SCALE;\n const shadowHeight = imageHeight * PORTRAIT_SHADOW_SCALE;\n const baseShadowX = imageX - (shadowWidth - imageWidth) / 2;\n const baseShadowY = imageY - (shadowHeight - imageHeight) / 2;\n const shadowBox = {\n x: baseShadowX + (onLeft ? -shadowOffsetX : shadowOffsetX),\n y: baseShadowY + shadowOffsetY,\n width: shadowWidth,\n height: shadowHeight\n };\n\n return {\n onLeft,\n titleFontSize,\n titleLineHeight,\n contentFontSize,\n contentLineHeight,\n blockWidth,\n imageBox: { x: imageX, y: imageY, width: imageWidth, height: imageHeight },\n shadowBox,\n textBox: { x: textX, y: textY, width: textWidth, height: textHeight },\n contentBox\n };\n};\n\nexport const buildPortraitBlockMark = (\n spec: IStorylineSpec,\n block: IStorylineBlock,\n index: number\n): IExtensionGroupMarkSpec => {\n const hasImage = !!block.image;\n const hasSubImage = !!block.subImage;\n const contentText = Array.isArray(block.content) ? block.content : block.content ? [block.content] : [];\n const titleFontSize = Number((spec.title?.style as any)?.fontSize ?? 26);\n const titleLineHeight = Number(\n (spec.title?.style as any)?.lineHeight ?? Math.max(PORTRAIT_TITLE_LINE_HEIGHT, Math.round(titleFontSize * 1.35))\n );\n\n const getMetrics = (ctx: LayoutContext) => {\n const lb = getLayout(spec, ctx).blocks[index];\n const w = lb?.width ?? resolveBlockWidth(spec, 0);\n const h = lb?.height ?? spec.block?.height ?? DEFAULT_BLOCK_HEIGHT;\n return getPortraitMetrics(spec, w, h, index);\n };\n const themeColor = getThemeColor(spec);\n const blockStyle = spec.block?.style ?? {};\n\n return {\n type: 'group' as any,\n id: `storyline-block-${block.id ?? index}`,\n name: `storyline-block-${index}`,\n zIndex: LayoutZIndex.Mark + 1,\n style: {\n x: (_d: unknown, ctx: LayoutContext) => {\n const lb = getLayout(spec, ctx).blocks[index];\n return lb?.center?.x ?? 0;\n },\n y: (_d: unknown, ctx: LayoutContext) => {\n const lb = getLayout(spec, ctx).blocks[index];\n return lb?.center?.y ?? 0;\n }\n },\n children: [\n hasSubImage\n ? ({\n type: 'image',\n name: `storyline-block-shadow-image-${index}`,\n interactive: false,\n style: {\n x: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).shadowBox.x,\n y: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).shadowBox.y,\n width: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).shadowBox.width,\n height: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).shadowBox.height,\n image: block.subImage,\n repeatX: 'no-repeat',\n repeatY: 'no-repeat',\n imageMode: 'cover',\n imagePosition: 'center'\n }\n } as ICustomMarkSpec<'image'>)\n : null,\n spec.image?.showBackground === true\n ? ({\n type: 'rect',\n name: `storyline-block-image-bg-${index}`,\n interactive: false,\n style: {\n x: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.x,\n y: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.y,\n width: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.width,\n height: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.height,\n cornerRadius: 8,\n fill: '#ffffff',\n stroke: themeColor,\n lineWidth: 2,\n ...blockStyle\n }\n } as ICustomMarkSpec<'rect'>)\n : null,\n hasImage\n ? ({\n type: 'image',\n name: `storyline-block-image-${index}`,\n interactive: false,\n ...omitImageLayoutSpec(spec.image),\n style: {\n x: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.x,\n y: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.y,\n width: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.width,\n height: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).imageBox.height,\n image: block.image,\n repeatX: 'no-repeat',\n repeatY: 'no-repeat',\n imageMode: 'cover',\n imagePosition: 'center',\n ...spec.image?.style\n }\n } as ICustomMarkSpec<'image'>)\n : null,\n block.title\n ? ({\n type: 'text',\n name: `storyline-block-title-${index}`,\n interactive: false,\n ...spec.title,\n style: {\n x: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).textBox.x,\n y: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).textBox.y,\n text: block.title,\n maxLineWidth: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).textBox.width,\n fontSize: titleFontSize,\n lineHeight: titleLineHeight,\n fontWeight: 'bold',\n fill: '#1f2430',\n stroke: '#fff',\n lineWidth: 5,\n lineJoin: 'round',\n textAlign: 'left',\n textBaseline: 'top',\n ...spec.title?.style\n }\n } as ICustomMarkSpec<'text'>)\n : null,\n contentText.length\n ? ({\n type: 'text',\n name: `storyline-block-content-${index}`,\n interactive: false,\n ...spec.content,\n textType: 'rich',\n style: {\n x: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).contentBox.x,\n y: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).contentBox.y,\n width: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).contentBox.width,\n height: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).contentBox.height,\n maxLineWidth: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).contentBox.width,\n heightLimit: (_d: unknown, ctx: LayoutContext) => getMetrics(ctx).contentBox.height,\n text: buildRichContent(contentText, spec, {\n fontSize: PORTRAIT_CONTENT_FONT_SIZE,\n lineHeight: PORTRAIT_CONTENT_LINE_HEIGHT,\n fill: '#596173'\n }),\n textAlign: 'left',\n textBaseline: 'top',\n wordBreak: 'break-word',\n ellipsis: '...',\n fill: '#596173',\n ...spec.content?.style\n }\n } as ICustomMarkSpec<'text'>)\n : null\n ].filter(Boolean) as ICustomMarkSpec<any>[]\n };\n};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IExtensionGroupMarkSpec } from '@visactor/vchart';
|
|
2
|
+
import type { IStorylineBlock, IStorylineSpec } from '../interface';
|
|
3
|
+
export declare const buildWingArcMark: (spec: IStorylineSpec) => IExtensionGroupMarkSpec | null;
|
|
4
|
+
export declare const buildWingBlockMark: (spec: IStorylineSpec, block: IStorylineBlock, index: number) => IExtensionGroupMarkSpec;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { LayoutZIndex } from "@visactor/vchart";
|
|
2
|
+
|
|
3
|
+
import { buildRichContent, getRegionGeometry, getThemeColor, normalizeLayout, omitImageLayoutSpec, withAlpha } from "./common";
|
|
4
|
+
|
|
5
|
+
const WING_BLOCK_IMAGE_SIZE = 160, WING_TEXT_GAP_FROM_IMAGE = 14, WING_TITLE_LINE_HEIGHT = 30, WING_TITLE_FONT_SIZE = 22, WING_CONTENT_LINE_HEIGHT = 17, WING_CONTENT_FONT_SIZE = 12, WING_TEXT_BOX_WIDTH = 240, WING_TEXT_BOX_HEIGHT = 110, WING_TITLE_TO_CONTENT_GAP = 4, getWingDirection = spec => {
|
|
6
|
+
var _a;
|
|
7
|
+
return null !== (_a = normalizeLayout(spec.layout).direction) && void 0 !== _a ? _a : "left";
|
|
8
|
+
}, getWingArcGeometry = (spec, ctx) => {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const {width: width, height: height, startX: startX, startY: startY} = getRegionGeometry(ctx), innerWidth = Math.max(width, 1), innerHeight = Math.max(height, 1), layoutOpt = normalizeLayout(spec.layout), direction = getWingDirection(spec), defaultStart = "right" === direction ? 110 : -70, defaultEnd = "right" === direction ? 250 : 70, startAngle = null !== (_a = layoutOpt.startAngle) && void 0 !== _a ? _a : defaultStart, endAngle = null !== (_b = layoutOpt.endAngle) && void 0 !== _b ? _b : defaultEnd, ratio = null !== (_c = layoutOpt.radiusRatio) && void 0 !== _c ? _c : .92, rx = .6 * innerWidth * ratio;
|
|
11
|
+
return {
|
|
12
|
+
cx: "right" === direction ? startX + innerWidth - .1 * rx : startX + .1 * rx,
|
|
13
|
+
cy: startY + innerHeight / 2,
|
|
14
|
+
rx: rx,
|
|
15
|
+
ry: innerHeight / 2 * ratio,
|
|
16
|
+
startAngle: startAngle,
|
|
17
|
+
endAngle: endAngle
|
|
18
|
+
};
|
|
19
|
+
}, getWingBlockCenter = (spec, ctx, index) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const arc = getWingArcGeometry(spec, ctx), count = null !== (_b = null === (_a = spec.data) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0;
|
|
22
|
+
if (count <= 0) return {
|
|
23
|
+
x: arc.cx,
|
|
24
|
+
y: arc.cy
|
|
25
|
+
};
|
|
26
|
+
const t = 1 === count ? .5 : index / (count - 1), angle = (arc.startAngle + (arc.endAngle - arc.startAngle) * t) / 180 * Math.PI;
|
|
27
|
+
return {
|
|
28
|
+
x: arc.cx + Math.cos(angle) * arc.rx,
|
|
29
|
+
y: arc.cy + Math.sin(angle) * arc.ry
|
|
30
|
+
};
|
|
31
|
+
}, isTextOnLeft = (spec, index) => "right" === getWingDirection(spec) ? index % 2 == 1 : index % 2 == 0;
|
|
32
|
+
|
|
33
|
+
export const buildWingArcMark = spec => {
|
|
34
|
+
var _a, _b, _c, _e, _f, _g, _h, _j;
|
|
35
|
+
if (!1 === (null === (_a = spec.line) || void 0 === _a ? void 0 : _a.visible)) return null;
|
|
36
|
+
const themeColor = getThemeColor(spec), lineStyle = null !== (_c = null === (_b = spec.line) || void 0 === _b ? void 0 : _b.style) && void 0 !== _c ? _c : {}, startWidth = Math.max(Number(null !== (_e = lineStyle.startWidth) && void 0 !== _e ? _e : 50), .5), endWidth = Math.max(Number(null !== (_g = null !== (_f = lineStyle.endWidth) && void 0 !== _f ? _f : lineStyle.lineWidth) && void 0 !== _g ? _g : 350), startWidth);
|
|
37
|
+
return {
|
|
38
|
+
type: "group",
|
|
39
|
+
name: "storyline-wing-arc",
|
|
40
|
+
zIndex: LayoutZIndex.Mark,
|
|
41
|
+
children: [ {
|
|
42
|
+
type: "path",
|
|
43
|
+
name: "storyline-wing-arc-path",
|
|
44
|
+
interactive: !1,
|
|
45
|
+
style: {
|
|
46
|
+
stroke: !1,
|
|
47
|
+
lineWidth: 0,
|
|
48
|
+
fill: null !== (_j = null !== (_h = lineStyle.fill) && void 0 !== _h ? _h : lineStyle.stroke) && void 0 !== _j ? _j : themeColor,
|
|
49
|
+
opacity: .95,
|
|
50
|
+
path: (_d, ctx) => {
|
|
51
|
+
const arc = getWingArcGeometry(spec, ctx), span = arc.endAngle - arc.startAngle, pts = [];
|
|
52
|
+
for (let i = 0; i <= 96; i++) {
|
|
53
|
+
const t = i / 96, angle = (arc.startAngle + span * t) / 180 * Math.PI, cx = arc.cx + Math.cos(angle) * arc.rx, cy = 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;
|
|
54
|
+
pts.push({
|
|
55
|
+
x: cx,
|
|
56
|
+
y: cy,
|
|
57
|
+
nx: nxRaw / nLen,
|
|
58
|
+
ny: nyRaw / nLen,
|
|
59
|
+
w: startWidth + (endWidth - startWidth) * t
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const segments = [];
|
|
63
|
+
for (let i = 0; i < pts.length; i++) {
|
|
64
|
+
const p = pts[i], x = p.x + p.nx * (p.w / 2), y = p.y + p.ny * (p.w / 2);
|
|
65
|
+
segments.push(`${0 === i ? "M" : "L"} ${x.toFixed(2)} ${y.toFixed(2)}`);
|
|
66
|
+
}
|
|
67
|
+
for (let i = pts.length - 1; i >= 0; i--) {
|
|
68
|
+
const p = pts[i], x = p.x - p.nx * (p.w / 2), y = p.y - p.ny * (p.w / 2);
|
|
69
|
+
segments.push(`L ${x.toFixed(2)} ${y.toFixed(2)}`);
|
|
70
|
+
}
|
|
71
|
+
return segments.push("Z"), segments.join(" ");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} ]
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const WING_TEXT_IMAGE_GAP = 120, getWingBlockMetrics = (spec, ctx, index) => {
|
|
79
|
+
var _a, _b, _c, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
80
|
+
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 : 22), 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(30, Math.round(1.3 * 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), imageWidth = Number(null !== (_q = null === (_p = spec.image) || void 0 === _p ? void 0 : _p.width) && void 0 !== _q ? _q : 160), imageHeight = Number(null !== (_s = null === (_r = spec.image) || void 0 === _r ? void 0 : _r.height) && void 0 !== _s ? _s : 160), imageBox = {
|
|
81
|
+
x: -imageWidth / 2,
|
|
82
|
+
y: -imageHeight / 2,
|
|
83
|
+
width: imageWidth,
|
|
84
|
+
height: imageHeight
|
|
85
|
+
}, direction = getWingDirection(spec), count = null !== (_u = null === (_t = spec.data) || void 0 === _t ? void 0 : _t.length) && void 0 !== _u ? _u : 0;
|
|
86
|
+
let textBox, contentBox, connectorBox, onLeft, verticalAlign;
|
|
87
|
+
if ("right" === direction && count > 0 && index === count - 1 || "left" === direction && 0 === index) {
|
|
88
|
+
const textX = -120, textY = imageHeight / 2 + 120;
|
|
89
|
+
textBox = {
|
|
90
|
+
x: textX,
|
|
91
|
+
y: textY,
|
|
92
|
+
width: 240,
|
|
93
|
+
height: 110
|
|
94
|
+
}, contentBox = {
|
|
95
|
+
x: textX,
|
|
96
|
+
y: textY + titleLineHeight + 4,
|
|
97
|
+
width: 240,
|
|
98
|
+
height: 1e5
|
|
99
|
+
}, connectorBox = {
|
|
100
|
+
x: -1,
|
|
101
|
+
y: imageHeight / 2,
|
|
102
|
+
width: 2,
|
|
103
|
+
height: 120
|
|
104
|
+
}, onLeft = !1, verticalAlign = "below";
|
|
105
|
+
} else {
|
|
106
|
+
const textOnLeft = "right" === direction, textX = textOnLeft ? -imageWidth / 2 - 120 - 240 : imageWidth / 2 + 120, textY = -55;
|
|
107
|
+
textBox = {
|
|
108
|
+
x: textX,
|
|
109
|
+
y: textY,
|
|
110
|
+
width: 240,
|
|
111
|
+
height: 110
|
|
112
|
+
}, contentBox = {
|
|
113
|
+
x: textX,
|
|
114
|
+
y: textY + titleLineHeight + 4,
|
|
115
|
+
width: 240,
|
|
116
|
+
height: 1e5
|
|
117
|
+
};
|
|
118
|
+
const imageEdgeX = textOnLeft ? -imageWidth / 2 : imageWidth / 2, textEdgeX = textOnLeft ? textX + 240 : textX;
|
|
119
|
+
connectorBox = {
|
|
120
|
+
x: Math.min(imageEdgeX, textEdgeX),
|
|
121
|
+
y: 0,
|
|
122
|
+
width: Math.abs(textEdgeX - imageEdgeX),
|
|
123
|
+
height: 2
|
|
124
|
+
}, onLeft = textOnLeft, verticalAlign = null;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
onLeft: onLeft,
|
|
128
|
+
verticalAlign: verticalAlign,
|
|
129
|
+
titleFontSize: titleFontSize,
|
|
130
|
+
titleLineHeight: titleLineHeight,
|
|
131
|
+
contentFontSize: contentFontSize,
|
|
132
|
+
contentLineHeight: contentLineHeight,
|
|
133
|
+
imageBox: imageBox,
|
|
134
|
+
textBox: textBox,
|
|
135
|
+
contentBox: contentBox,
|
|
136
|
+
connectorBox: connectorBox
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const buildWingBlockMark = (spec, block, index) => {
|
|
141
|
+
var _a, _b, _c, _e, _f;
|
|
142
|
+
const hasImage = !!block.image, contentText = Array.isArray(block.content) ? block.content : block.content ? [ block.content ] : [], themeColor = getThemeColor(spec), showBackground = !0 === (null === (_a = spec.image) || void 0 === _a ? void 0 : _a.showBackground);
|
|
143
|
+
return {
|
|
144
|
+
type: "group",
|
|
145
|
+
id: `storyline-block-${null !== (_b = block.id) && void 0 !== _b ? _b : index}`,
|
|
146
|
+
name: `storyline-block-${index}`,
|
|
147
|
+
zIndex: LayoutZIndex.Mark + 1,
|
|
148
|
+
style: {
|
|
149
|
+
x: (_d, ctx) => getWingBlockCenter(spec, ctx, index).x,
|
|
150
|
+
y: (_d, ctx) => getWingBlockCenter(spec, ctx, index).y
|
|
151
|
+
},
|
|
152
|
+
children: [ {
|
|
153
|
+
type: "rect",
|
|
154
|
+
name: `storyline-block-connector-${index}`,
|
|
155
|
+
interactive: !1,
|
|
156
|
+
zIndex: LayoutZIndex.Mark + 2,
|
|
157
|
+
style: {
|
|
158
|
+
x: (_d, ctx) => getWingBlockMetrics(spec, 0, index).connectorBox.x,
|
|
159
|
+
y: (_d, ctx) => getWingBlockMetrics(spec, 0, index).connectorBox.y,
|
|
160
|
+
width: (_d, ctx) => getWingBlockMetrics(spec, 0, index).connectorBox.width,
|
|
161
|
+
height: (_d, ctx) => getWingBlockMetrics(spec, 0, index).connectorBox.height,
|
|
162
|
+
fill: themeColor,
|
|
163
|
+
opacity: .6
|
|
164
|
+
}
|
|
165
|
+
}, showBackground ? {
|
|
166
|
+
type: "symbol",
|
|
167
|
+
name: `storyline-block-image-halo-${index}`,
|
|
168
|
+
interactive: !1,
|
|
169
|
+
style: {
|
|
170
|
+
x: 0,
|
|
171
|
+
y: 0,
|
|
172
|
+
size: (_d, ctx) => Math.max(getWingBlockMetrics(spec, 0, index).imageBox.width, getWingBlockMetrics(spec, 0, index).imageBox.height) + 12,
|
|
173
|
+
symbolType: "circle",
|
|
174
|
+
fill: withAlpha(themeColor, .18),
|
|
175
|
+
stroke: themeColor,
|
|
176
|
+
lineWidth: 1.5
|
|
177
|
+
}
|
|
178
|
+
} : null, hasImage ? Object.assign(Object.assign({
|
|
179
|
+
type: "image",
|
|
180
|
+
name: `storyline-block-image-${index}`,
|
|
181
|
+
interactive: !1
|
|
182
|
+
}, omitImageLayoutSpec(spec.image)), {
|
|
183
|
+
style: Object.assign({
|
|
184
|
+
x: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.x,
|
|
185
|
+
y: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.y,
|
|
186
|
+
width: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.width,
|
|
187
|
+
height: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.height,
|
|
188
|
+
cornerRadius: (_d, ctx) => Math.min(getWingBlockMetrics(spec, 0, index).imageBox.width, getWingBlockMetrics(spec, 0, index).imageBox.height) / 2,
|
|
189
|
+
image: block.image,
|
|
190
|
+
repeatX: "no-repeat",
|
|
191
|
+
repeatY: "no-repeat",
|
|
192
|
+
imageMode: "cover",
|
|
193
|
+
imagePosition: "center"
|
|
194
|
+
}, null === (_c = spec.image) || void 0 === _c ? void 0 : _c.style)
|
|
195
|
+
}) : {
|
|
196
|
+
type: "rect",
|
|
197
|
+
name: `storyline-block-image-bg-${index}`,
|
|
198
|
+
interactive: !1,
|
|
199
|
+
style: {
|
|
200
|
+
x: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.x,
|
|
201
|
+
y: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.y,
|
|
202
|
+
width: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.width,
|
|
203
|
+
height: (_d, ctx) => getWingBlockMetrics(spec, 0, index).imageBox.height,
|
|
204
|
+
cornerRadius: (_d, ctx) => Math.min(getWingBlockMetrics(spec, 0, index).imageBox.width, getWingBlockMetrics(spec, 0, index).imageBox.height) / 2,
|
|
205
|
+
fill: "#ffffff",
|
|
206
|
+
stroke: themeColor,
|
|
207
|
+
lineWidth: 2
|
|
208
|
+
}
|
|
209
|
+
}, block.title ? Object.assign(Object.assign({
|
|
210
|
+
type: "text",
|
|
211
|
+
name: `storyline-block-title-${index}`,
|
|
212
|
+
interactive: !1,
|
|
213
|
+
zIndex: LayoutZIndex.Mark + 10
|
|
214
|
+
}, spec.title), {
|
|
215
|
+
style: Object.assign({
|
|
216
|
+
x: (_d, ctx) => {
|
|
217
|
+
const m = getWingBlockMetrics(spec, 0, index);
|
|
218
|
+
return m.verticalAlign ? m.textBox.x + m.textBox.width / 2 : m.onLeft ? m.textBox.x + m.textBox.width : m.textBox.x;
|
|
219
|
+
},
|
|
220
|
+
y: (_d, ctx) => getWingBlockMetrics(spec, 0, index).textBox.y,
|
|
221
|
+
text: block.title,
|
|
222
|
+
maxLineWidth: (_d, ctx) => getWingBlockMetrics(spec, 0, index).textBox.width,
|
|
223
|
+
fontSize: (_d, ctx) => getWingBlockMetrics(spec, 0, index).titleFontSize,
|
|
224
|
+
lineHeight: (_d, ctx) => getWingBlockMetrics(spec, 0, index).titleLineHeight,
|
|
225
|
+
fontWeight: "bold",
|
|
226
|
+
fill: themeColor,
|
|
227
|
+
stroke: "#fff",
|
|
228
|
+
lineWidth: 5,
|
|
229
|
+
lineJoin: "round",
|
|
230
|
+
textAlign: (_d, ctx) => {
|
|
231
|
+
const m = getWingBlockMetrics(spec, 0, index);
|
|
232
|
+
return m.verticalAlign ? "center" : m.onLeft ? "right" : "left";
|
|
233
|
+
},
|
|
234
|
+
textBaseline: "top"
|
|
235
|
+
}, null === (_e = spec.title) || void 0 === _e ? void 0 : _e.style)
|
|
236
|
+
}) : null, contentText.length ? Object.assign(Object.assign({
|
|
237
|
+
type: "text",
|
|
238
|
+
name: `storyline-block-content-${index}`,
|
|
239
|
+
interactive: !1,
|
|
240
|
+
zIndex: LayoutZIndex.Mark + 10
|
|
241
|
+
}, spec.content), {
|
|
242
|
+
textType: "rich",
|
|
243
|
+
style: Object.assign({
|
|
244
|
+
x: (_d, ctx) => {
|
|
245
|
+
const m = getWingBlockMetrics(spec, 0, index);
|
|
246
|
+
return m.verticalAlign ? m.contentBox.x + m.contentBox.width / 2 : m.onLeft ? m.contentBox.x + m.contentBox.width : m.contentBox.x;
|
|
247
|
+
},
|
|
248
|
+
y: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentBox.y,
|
|
249
|
+
width: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentBox.width,
|
|
250
|
+
height: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentBox.height,
|
|
251
|
+
maxLineWidth: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentBox.width,
|
|
252
|
+
heightLimit: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentBox.height,
|
|
253
|
+
text: buildRichContent(contentText, spec),
|
|
254
|
+
fontSize: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentFontSize,
|
|
255
|
+
lineHeight: (_d, ctx) => getWingBlockMetrics(spec, 0, index).contentLineHeight,
|
|
256
|
+
textAlign: (_d, ctx) => {
|
|
257
|
+
const m = getWingBlockMetrics(spec, 0, index);
|
|
258
|
+
return m.verticalAlign ? "center" : m.onLeft ? "right" : "left";
|
|
259
|
+
},
|
|
260
|
+
textBaseline: "top",
|
|
261
|
+
wordBreak: "break-word",
|
|
262
|
+
ellipsis: "...",
|
|
263
|
+
fill: "#1f2430"
|
|
264
|
+
}, null === (_f = spec.content) || void 0 === _f ? void 0 : _f.style)
|
|
265
|
+
}) : null ].filter(Boolean)
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
//# sourceMappingURL=wing.js.map
|