@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
|
@@ -22,4 +22,4 @@ Bar3dChart.type = "bar3d", Bar3dChart.seriesType = SeriesType3dEnum.bar3d, Bar3d
|
|
|
22
22
|
export const registerBar3dChart = () => {
|
|
23
23
|
register3DPlugin(), registerLayout3d(), registerBar3dSeries(), Factory.registerChart(Bar3dChart.type, Bar3dChart);
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chart.js.map
|
|
25
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
2
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -27,4 +27,4 @@ export const registerBar3dSeries = () => {
|
|
|
27
27
|
registerBar3dAnimation(), registerRect3dMark(), registerCartesianBandAxis(), registerCartesianLinearAxis(),
|
|
28
28
|
Factory.registerSeries(Bar3dSeries.type, Bar3dSeries);
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=series.js.map
|
|
30
|
+
//# sourceMappingURL=series.js.map
|
|
@@ -19,4 +19,5 @@ CandlestickChart.transformerConstructor = CandlestickChartSpecTransformer;
|
|
|
19
19
|
export const registerCandlestickChart = () => {
|
|
20
20
|
registerDimensionTooltipProcessor(), registerMarkTooltipProcessor(), registerDimensionEvents(),
|
|
21
21
|
registerDimensionHover(), registerCandlestickSeries(), Factory.registerChart(CandlestickChart.type, CandlestickChart);
|
|
22
|
-
};
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=candlestick.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
2
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -26,4 +26,4 @@ mixin(CombinationCandlestickChart, StackChartMixin);
|
|
|
26
26
|
export const registerCombinationCandlestickChart = () => {
|
|
27
27
|
registerCandlestickSeries(), Factory.registerChart(CombinationCandlestickChart.type, CombinationCandlestickChart);
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=combination-candlestick.js.map
|
|
29
|
+
//# sourceMappingURL=combination-candlestick.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const CombinationCandlestickChart_TYPE = "combinationCandlestick";
|
|
2
|
-
//# sourceMappingURL=constant.js.map
|
|
2
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
2
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -54,4 +54,4 @@ export const registerConversionFunnelChart = option => {
|
|
|
54
54
|
const vchartConstructor = (null == option ? void 0 : option.VChart) || VChart;
|
|
55
55
|
vchartConstructor && (vchartConstructor.useChart([ ConversionFunnelChart ]), vchartConstructor.useSeries([ ConversionFunnelSeries ]));
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=conversion-funnel.js.map
|
|
57
|
+
//# sourceMappingURL=conversion-funnel.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
2
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -21,4 +21,5 @@ Funnel3dChart.transformerConstructor = FunnelChartSpecTransformer;
|
|
|
21
21
|
export const registerFunnel3dChart = () => {
|
|
22
22
|
registerMarkTooltipProcessor(), register3DPlugin(), registerLayout3d(), registerFunnel3dSeries(),
|
|
23
23
|
Factory.registerChart(Funnel3dChart.type, Funnel3dChart);
|
|
24
|
-
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
2
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -5,4 +5,4 @@ export class Funnel3dSeriesSpecTransformer extends FunnelSeriesSpecTransformer {
|
|
|
5
5
|
this._addMarkLabelSpec(spec, "funnel3d"), spec.isTransform && this._addMarkLabelSpec(spec, "transform3d", "transformLabel");
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
//# sourceMappingURL=series-spec-transformer.js.map
|
|
8
|
+
//# sourceMappingURL=series-spec-transformer.js.map
|
|
@@ -81,4 +81,4 @@ Funnel3dSeries.builtInTheme = {
|
|
|
81
81
|
export const registerFunnel3dSeries = () => {
|
|
82
82
|
registerPyramid3dMark(), registerTextMark(), registerRuleMark(), Factory.registerSeries(Funnel3dSeries.type, Funnel3dSeries);
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=series.js.map
|
|
84
|
+
//# sourceMappingURL=series.js.map
|
|
@@ -27,4 +27,4 @@ export const registerHistogram3dChart = () => {
|
|
|
27
27
|
registerDimensionEvents(), registerDimensionHover(), register3DPlugin(), registerLayout3d(),
|
|
28
28
|
registerBar3dSeries(), Factory.registerChart(Histogram3dChart.type, Histogram3dChart);
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chart.js.map
|
|
30
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/storyline/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC","file":"index.js","sourcesContent":["export * from './interface';\nexport * from './layout';\nexport * from './storyline';\nexport * from './storyline-transformer';\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { IChartSpec, IComposedTextMarkSpec, IImageMarkSpec, IMarkSpec, IPathMarkSpec, IRectMarkSpec, ITextMarkSpec, StringOrNumber } from '@visactor/vchart';
|
|
2
|
+
export type StorylineLayoutType = 'clock' | 'arc' | 'wing' | 'landscape' | 'portrait' | 'ladder' | 'spiral';
|
|
3
|
+
export type StorylineImagePosition = 'top' | 'left' | 'right' | 'bottom';
|
|
4
|
+
export type StorylineLineType = 'line' | 'polyline' | 'curve';
|
|
5
|
+
export type StorylineWingDirection = 'left' | 'right';
|
|
6
|
+
export type StorylineLadderDirection = 'up' | 'down';
|
|
7
|
+
export type StorylineArcDirection = 'up' | 'down';
|
|
8
|
+
export interface IStorylineBlock {
|
|
9
|
+
id?: StringOrNumber;
|
|
10
|
+
title?: string;
|
|
11
|
+
content?: string | string[];
|
|
12
|
+
image?: string | HTMLImageElement | HTMLCanvasElement;
|
|
13
|
+
subImage?: string | HTMLImageElement | HTMLCanvasElement;
|
|
14
|
+
marker?: string;
|
|
15
|
+
datum?: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface IStorylineLayoutOptions {
|
|
18
|
+
type: StorylineLayoutType;
|
|
19
|
+
padding?: number | [number, number, number, number];
|
|
20
|
+
radiusRatio?: number;
|
|
21
|
+
startAngle?: number;
|
|
22
|
+
endAngle?: number;
|
|
23
|
+
direction?: StorylineWingDirection | StorylineLadderDirection | StorylineArcDirection;
|
|
24
|
+
headline?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IStorylineBlockSpec {
|
|
27
|
+
width?: number;
|
|
28
|
+
widthRatio?: number;
|
|
29
|
+
minWidth?: number;
|
|
30
|
+
maxWidth?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
padding?: number | [number, number, number, number];
|
|
33
|
+
gap?: number;
|
|
34
|
+
showBackground?: boolean;
|
|
35
|
+
style?: Partial<IRectMarkSpec>;
|
|
36
|
+
}
|
|
37
|
+
export interface IStorylineImageSpec extends IMarkSpec<IImageMarkSpec> {
|
|
38
|
+
width?: number;
|
|
39
|
+
height?: number;
|
|
40
|
+
position?: StorylineImagePosition;
|
|
41
|
+
gap?: number;
|
|
42
|
+
showBackground?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface IStorylineCenterImageSpec extends IMarkSpec<IImageMarkSpec> {
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
visible?: boolean;
|
|
48
|
+
image?: string | HTMLImageElement | HTMLCanvasElement;
|
|
49
|
+
}
|
|
50
|
+
export interface IStorylineLineSpec extends IMarkSpec<IPathMarkSpec> {
|
|
51
|
+
visible?: boolean;
|
|
52
|
+
type?: StorylineLineType;
|
|
53
|
+
showArrow?: boolean;
|
|
54
|
+
arrowSize?: number;
|
|
55
|
+
distance?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface IStorylineSpec extends Omit<IChartSpec, 'type' | 'data' | 'series' | 'title' | 'layout'> {
|
|
58
|
+
type: 'storyline';
|
|
59
|
+
data: IStorylineBlock[];
|
|
60
|
+
layout?: StorylineLayoutType | IStorylineLayoutOptions;
|
|
61
|
+
block?: IStorylineBlockSpec;
|
|
62
|
+
title?: IMarkSpec<ITextMarkSpec>;
|
|
63
|
+
content?: IMarkSpec<IComposedTextMarkSpec>;
|
|
64
|
+
image?: IStorylineImageSpec;
|
|
65
|
+
centerImage?: IStorylineCenterImageSpec;
|
|
66
|
+
line?: IStorylineLineSpec;
|
|
67
|
+
marker?: IMarkSpec<ITextMarkSpec>;
|
|
68
|
+
themeColor?: string;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/charts/storyline/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type {\n IChartSpec,\n IComposedTextMarkSpec,\n IImageMarkSpec,\n IMarkSpec,\n IPathMarkSpec,\n IRectMarkSpec,\n ITextMarkSpec,\n StringOrNumber\n} from '@visactor/vchart';\n\nexport type StorylineLayoutType = 'clock' | 'arc' | 'wing' | 'landscape' | 'portrait' | 'ladder' | 'spiral';\n\nexport type StorylineImagePosition = 'top' | 'left' | 'right' | 'bottom';\nexport type StorylineLineType = 'line' | 'polyline' | 'curve';\nexport type StorylineWingDirection = 'left' | 'right';\nexport type StorylineLadderDirection = 'up' | 'down';\nexport type StorylineArcDirection = 'up' | 'down';\n\nexport interface IStorylineBlock {\n id?: StringOrNumber;\n title?: string;\n content?: string | string[];\n image?: string | HTMLImageElement | HTMLCanvasElement;\n /**\n * 绘制在主 image 背后的装饰图(如 portrait 布局的错位 shadow image)。\n * 若未配置,则不会绘制装饰 image。\n */\n subImage?: string | HTMLImageElement | HTMLCanvasElement;\n /**\n * 时间节点文本(如 \"2012\")。\n * 仅 portrait 布局生效:在中轴 rect 上沿每个 block 的 center.y 处纵向绘制。\n * 配合 spec.marker 控制样式与显隐。\n */\n marker?: string;\n datum?: unknown;\n}\n\nexport interface IStorylineLayoutOptions {\n type: StorylineLayoutType;\n /**\n * 边缘留白,支持单值或 [top, right, bottom, left]。\n */\n padding?: number | [number, number, number, number];\n /**\n * 对 circular/arc 布局生效,控制半径占可用空间的比例。\n */\n radiusRatio?: number;\n /**\n * 对 circular/arc 布局生效,角度单位为度。\n */\n startAngle?: number;\n /**\n * 对 circular/arc 布局生效,角度单位为度。\n */\n endAngle?: number;\n /**\n * 方向控制:\n * - wing 布局:'left' | 'right',圆心锚位置;\n * - ladder 布局:'up' | 'down','up' 表示左下→右上对角线(默认),'down' 表示左上→右下对角线;\n * - arc 布局:'up' | 'down','up' 表示穹顶(centerImage 贴底,弧线在上方),'down' 表示碗形(centerImage 贴顶,弧线在下方)。\n */\n direction?: StorylineWingDirection | StorylineLadderDirection | StorylineArcDirection;\n /**\n * 对 ladder 布局生效:贯穿画布的倾斜大字 headline。\n * 缺省时使用占位文本。倾斜方向自动跟随对角线。\n */\n headline?: string;\n}\n\nexport interface IStorylineBlockSpec {\n width?: number;\n widthRatio?: number;\n minWidth?: number;\n maxWidth?: number;\n height?: number;\n padding?: number | [number, number, number, number];\n gap?: number;\n /**\n * 是否展示 block 背后的卡片背景 rect(白底 + 描边 + 阴影)。\n * 仅 up-ladder 等少数布局支持,默认 false(不展示)。\n */\n showBackground?: boolean;\n style?: Partial<IRectMarkSpec>;\n}\n\nexport interface IStorylineImageSpec extends IMarkSpec<IImageMarkSpec> {\n width?: number;\n height?: number;\n position?: StorylineImagePosition;\n gap?: number;\n /**\n * 是否展示 image 背后的白色背景 rect(白底 + 主题色描边)。\n * portrait / landscape / wing 等布局支持。\n * 默认 false(不展示)。\n * 注:不影响 subImage(错位装饰图元的显隐。\n */\n showBackground?: boolean;\n}\n\nexport interface IStorylineCenterImageSpec extends IMarkSpec<IImageMarkSpec> {\n width?: number;\n height?: number;\n visible?: boolean;\n image?: string | HTMLImageElement | HTMLCanvasElement;\n}\n\nexport interface IStorylineLineSpec extends IMarkSpec<IPathMarkSpec> {\n visible?: boolean;\n type?: StorylineLineType;\n showArrow?: boolean;\n arrowSize?: number;\n /**\n * 连接线和 block 边缘之间的距离。\n */\n distance?: number;\n}\n\nexport interface IStorylineSpec extends Omit<IChartSpec, 'type' | 'data' | 'series' | 'title' | 'layout'> {\n type: 'storyline';\n data: IStorylineBlock[];\n layout?: StorylineLayoutType | IStorylineLayoutOptions;\n block?: IStorylineBlockSpec;\n title?: IMarkSpec<ITextMarkSpec>;\n content?: IMarkSpec<IComposedTextMarkSpec>;\n image?: IStorylineImageSpec;\n centerImage?: IStorylineCenterImageSpec;\n line?: IStorylineLineSpec;\n /**\n * 时间节点文本配置(仅 portrait 布局生效)。\n * 当 spec.data[i].marker 有值时,在中轴 rect 上沿垂直方向绘制每个 block 的时间节点文本。\n */\n marker?: IMarkSpec<ITextMarkSpec>;\n themeColor?: string;\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
] | {
|
|
52
|
+
top?: number;
|
|
53
|
+
right?: number;
|
|
54
|
+
bottom?: number;
|
|
55
|
+
left?: number;
|
|
56
|
+
}) => StorylinePadding;
|
|
57
|
+
export declare const normalizeLayout: (layout?: StorylineLayoutType | IStorylineLayoutOptions) => IStorylineLayoutOptions;
|
|
58
|
+
export declare const computeStorylineLayout: (data: IStorylineBlock[], options: StorylineComputeOptions) => StorylineLayoutResult;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
const DEFAULT_LAYOUT = "landscape", DEFAULT_PADDING = 24;
|
|
2
|
+
|
|
3
|
+
export const normalizePadding = padding => {
|
|
4
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
5
|
+
if (Array.isArray(padding)) return {
|
|
6
|
+
top: null !== (_a = padding[0]) && void 0 !== _a ? _a : 0,
|
|
7
|
+
right: null !== (_b = padding[1]) && void 0 !== _b ? _b : 0,
|
|
8
|
+
bottom: null !== (_c = padding[2]) && void 0 !== _c ? _c : 0,
|
|
9
|
+
left: null !== (_d = padding[3]) && void 0 !== _d ? _d : 0
|
|
10
|
+
};
|
|
11
|
+
if (padding && "object" == typeof padding && "top" in padding) return {
|
|
12
|
+
top: null !== (_e = padding.top) && void 0 !== _e ? _e : 0,
|
|
13
|
+
right: null !== (_f = padding.right) && void 0 !== _f ? _f : 0,
|
|
14
|
+
bottom: null !== (_g = padding.bottom) && void 0 !== _g ? _g : 0,
|
|
15
|
+
left: null !== (_h = padding.left) && void 0 !== _h ? _h : 0
|
|
16
|
+
};
|
|
17
|
+
const value = null !== (_j = padding) && void 0 !== _j ? _j : 24;
|
|
18
|
+
return {
|
|
19
|
+
top: value,
|
|
20
|
+
right: value,
|
|
21
|
+
bottom: value,
|
|
22
|
+
left: value
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const normalizeLayout = layout => layout ? "string" == typeof layout ? {
|
|
27
|
+
type: layout
|
|
28
|
+
} : layout : {
|
|
29
|
+
type: "landscape"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const computeStorylineLayout = (data, options) => {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const layout = normalizeLayout(options.layout), padding = normalizePadding(null !== (_a = layout.padding) && void 0 !== _a ? _a : options.padding), gap = null !== (_b = options.gap) && void 0 !== _b ? _b : 40, lineDistance = null !== (_c = options.lineDistance) && void 0 !== _c ? _c : 8, blocks = computeBlockPositions(data, layout, options.viewBox, options.block, padding, gap), circleGuide = "clock" === layout.type ? computeClockCircleGuide(options.viewBox, options.block, padding, layout) : void 0;
|
|
35
|
+
return {
|
|
36
|
+
blocks: blocks,
|
|
37
|
+
links: computeLinks(blocks, lineDistance),
|
|
38
|
+
circleGuide: circleGuide
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const computeBlockPositions = (data, layout, viewBox, block, padding, gap) => {
|
|
43
|
+
const count = data.length;
|
|
44
|
+
if (!count) return [];
|
|
45
|
+
const inner = {
|
|
46
|
+
x: padding.left,
|
|
47
|
+
y: padding.top,
|
|
48
|
+
width: Math.max(viewBox.width - padding.left - padding.right, block.width),
|
|
49
|
+
height: Math.max(viewBox.height - padding.top - padding.bottom, block.height)
|
|
50
|
+
}, center = {
|
|
51
|
+
x: inner.x + inner.width / 2,
|
|
52
|
+
y: inner.y + inner.height / 2
|
|
53
|
+
};
|
|
54
|
+
let centers;
|
|
55
|
+
switch (layout.type) {
|
|
56
|
+
case "portrait":
|
|
57
|
+
centers = lineCenters(count, center.x, inner.y + block.height / 2, center.x, inner.y + inner.height - block.height / 2);
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
case "ladder":
|
|
61
|
+
{
|
|
62
|
+
const isDown = "down" === layout.direction, x0 = inner.x + block.width / 2, x1 = inner.x + inner.width - block.width / 2, yTop = inner.y + block.height / 2, yBot = inner.y + inner.height - block.height / 2, y0 = isDown ? yTop : yBot, y1 = isDown ? yBot : yTop, anchors = lineCenters(count, x0, y0, x1, y1), dx = x1 - x0, dy = y1 - y0, len = Math.hypot(dx, dy) || 1, nx = -dy / len, ny = dx / len, offset = 1.2 * Math.max(80, Math.min(240, Math.round(.42 * inner.height)));
|
|
63
|
+
centers = anchors.map(((p, i) => {
|
|
64
|
+
const sign = i % 2 == 0 ? 1 : -1;
|
|
65
|
+
return {
|
|
66
|
+
x: p.x + nx * offset * sign,
|
|
67
|
+
y: p.y + ny * offset * sign
|
|
68
|
+
};
|
|
69
|
+
}));
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case "spiral":
|
|
74
|
+
centers = alternatingVerticalCenters(count, inner, block, gap);
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
case "clock":
|
|
78
|
+
centers = circularCenters(count, viewBox, block, padding, layout);
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
case "arc":
|
|
82
|
+
{
|
|
83
|
+
const isDown = "down" === layout.direction, [s, e] = isDown ? [ 20, 160 ] : [ 200, 340 ];
|
|
84
|
+
centers = arcCenters(count, inner, block, layout, s, e);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case "wing":
|
|
89
|
+
{
|
|
90
|
+
const direction = "right" === layout.direction ? "right" : "left", [s, e] = "right" === direction ? [ 110, 250 ] : [ -70, 70 ];
|
|
91
|
+
centers = arcCenters(count, inner, block, layout, s, e);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
default:
|
|
96
|
+
centers = lineCenters(count, inner.x + block.width / 2, center.y, inner.x + inner.width - block.width / 2, center.y);
|
|
97
|
+
}
|
|
98
|
+
return centers.map(((point, index) => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
return {
|
|
101
|
+
id: null !== (_b = null === (_a = data[index]) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : index,
|
|
102
|
+
index: index,
|
|
103
|
+
datum: data[index],
|
|
104
|
+
width: block.width,
|
|
105
|
+
height: block.height,
|
|
106
|
+
x: point.x - block.width / 2,
|
|
107
|
+
y: point.y - block.height / 2,
|
|
108
|
+
center: point
|
|
109
|
+
};
|
|
110
|
+
}));
|
|
111
|
+
}, lineCenters = (count, x0, y0, x1, y1) => 1 === count ? [ {
|
|
112
|
+
x: (x0 + x1) / 2,
|
|
113
|
+
y: (y0 + y1) / 2
|
|
114
|
+
} ] : Array.from({
|
|
115
|
+
length: count
|
|
116
|
+
}, ((_, index) => {
|
|
117
|
+
const t = index / (count - 1);
|
|
118
|
+
return {
|
|
119
|
+
x: x0 + (x1 - x0) * t,
|
|
120
|
+
y: y0 + (y1 - y0) * t
|
|
121
|
+
};
|
|
122
|
+
})), alternatingVerticalCenters = (count, inner, block, gap) => {
|
|
123
|
+
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));
|
|
124
|
+
return lineCenters(count, baseX, inner.y + block.height / 2, baseX, inner.y + inner.height - block.height / 2).map(((point, index) => ({
|
|
125
|
+
x: point.x + (index % 2 == 0 ? -offset : offset),
|
|
126
|
+
y: point.y
|
|
127
|
+
})));
|
|
128
|
+
}, circularCenters = (count, viewBox, block, padding, layout) => {
|
|
129
|
+
var _a;
|
|
130
|
+
const guide = computeClockCircleGuide(viewBox, block, padding, layout), startAngle = null !== (_a = layout.startAngle) && void 0 !== _a ? _a : -90;
|
|
131
|
+
if (1 === count) {
|
|
132
|
+
const angle = degreeToRadian(startAngle);
|
|
133
|
+
return [ {
|
|
134
|
+
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
135
|
+
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
136
|
+
} ];
|
|
137
|
+
}
|
|
138
|
+
return Array.from({
|
|
139
|
+
length: count
|
|
140
|
+
}, ((_, index) => {
|
|
141
|
+
const angle = degreeToRadian(startAngle + 360 * index / count);
|
|
142
|
+
return {
|
|
143
|
+
x: guide.center.x + Math.cos(angle) * guide.radius,
|
|
144
|
+
y: guide.center.y + Math.sin(angle) * guide.radius
|
|
145
|
+
};
|
|
146
|
+
}));
|
|
147
|
+
}, computeClockCircleGuide = (viewBox, block, padding, layout) => {
|
|
148
|
+
var _a;
|
|
149
|
+
const innerWidth = Math.max(viewBox.width - padding.left - padding.right, 1), innerHeight = Math.max(viewBox.height - padding.top - padding.bottom, 1), center = {
|
|
150
|
+
x: padding.left + innerWidth / 2,
|
|
151
|
+
y: padding.top + innerHeight / 2
|
|
152
|
+
}, ratio = null !== (_a = layout.radiusRatio) && void 0 !== _a ? _a : .7, maxRadius = Math.max(Math.min(innerWidth - block.width, innerHeight - block.height) / 2, 1);
|
|
153
|
+
return {
|
|
154
|
+
center: center,
|
|
155
|
+
radius: Math.max(1, maxRadius * ratio)
|
|
156
|
+
};
|
|
157
|
+
}, arcCenters = (count, inner, block, layout, fallbackStartAngle, fallbackEndAngle, defaultRatio = .88) => {
|
|
158
|
+
var _a, _b, _c, _d, _e;
|
|
159
|
+
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;
|
|
160
|
+
if (1 === count) {
|
|
161
|
+
const angle = degreeToRadian((startAngle + endAngle) / 2);
|
|
162
|
+
return [ {
|
|
163
|
+
x: center_x + Math.cos(angle) * rx,
|
|
164
|
+
y: center_y + Math.sin(angle) * ry
|
|
165
|
+
} ];
|
|
166
|
+
}
|
|
167
|
+
return Array.from({
|
|
168
|
+
length: count
|
|
169
|
+
}, ((_, index) => {
|
|
170
|
+
const t = index / (count - 1), angle = degreeToRadian(startAngle + angleDelta(startAngle, endAngle) * t);
|
|
171
|
+
return {
|
|
172
|
+
x: center_x + Math.cos(angle) * rx,
|
|
173
|
+
y: center_y + Math.sin(angle) * ry
|
|
174
|
+
};
|
|
175
|
+
}));
|
|
176
|
+
}, angleDelta = (startAngle, endAngle) => {
|
|
177
|
+
const delta = endAngle - startAngle;
|
|
178
|
+
return Math.abs(delta) >= 360 ? 360 : delta;
|
|
179
|
+
}, degreeToRadian = degree => degree / 180 * Math.PI, computeLinks = (blocks, distance) => {
|
|
180
|
+
const links = [];
|
|
181
|
+
for (let i = 0; i < blocks.length - 1; i++) {
|
|
182
|
+
const from = blocks[i], to = blocks[i + 1], start = pointOnBlockEdge(from, to.center, distance), end = pointOnBlockEdge(to, from.center, distance);
|
|
183
|
+
links.push({
|
|
184
|
+
from: from,
|
|
185
|
+
to: to,
|
|
186
|
+
start: start,
|
|
187
|
+
end: end,
|
|
188
|
+
points: [ start, end ]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return links;
|
|
192
|
+
}, pointOnBlockEdge = (block, toward, distance) => {
|
|
193
|
+
const dx = toward.x - block.center.x, dy = toward.y - block.center.y;
|
|
194
|
+
if (0 === dx && 0 === dy) return {
|
|
195
|
+
x: block.center.x,
|
|
196
|
+
y: block.center.y
|
|
197
|
+
};
|
|
198
|
+
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;
|
|
199
|
+
return {
|
|
200
|
+
x: block.center.x + dx * scale + dx / length * distance,
|
|
201
|
+
y: block.center.y + dy * scale + dy / length * distance
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=layout.js.map
|