@visactor/vseed 0.4.25 → 0.4.26
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/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/column.js +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/column.js.map +1 -1
- package/dist/esm/pipeline/advanced/chart/pipes/config/line.js +1 -0
- package/dist/esm/pipeline/advanced/chart/pipes/config/line.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/area.js +5 -1
- package/dist/esm/pipeline/spec/chart/pipeline/area.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/areaPercent.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/bar.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/bar.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barParallel.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/barPercent.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/column.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/column.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnParallel.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js +3 -1
- package/dist/esm/pipeline/spec/chart/pipeline/columnPercent.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipeline/line.js +5 -1
- package/dist/esm/pipeline/spec/chart/pipeline/line.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js +157 -73
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.d.ts +19 -4
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.js +56 -10
- package/dist/esm/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.js.map +1 -1
- package/dist/esm/pipeline/spec/chart/pipes/region/index.d.ts +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/region/index.js +1 -0
- package/dist/esm/pipeline/spec/chart/pipes/region/regionPadding.d.ts +2 -0
- package/dist/esm/pipeline/spec/chart/pipes/region/regionPadding.js +20 -0
- package/dist/esm/pipeline/spec/chart/pipes/region/regionPadding.js.map +1 -0
- package/dist/esm/types/chartType/area/area.d.ts +11 -1
- package/dist/esm/types/chartType/area/zArea.d.ts +309 -0
- package/dist/esm/types/chartType/area/zArea.js +3 -1
- package/dist/esm/types/chartType/area/zArea.js.map +1 -1
- package/dist/esm/types/chartType/areaPercent/areaPercent.d.ts +6 -1
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.d.ts +6 -0
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.js +2 -1
- package/dist/esm/types/chartType/areaPercent/zAreaPercent.js.map +1 -1
- package/dist/esm/types/chartType/bar/bar.d.ts +6 -1
- package/dist/esm/types/chartType/bar/zBar.d.ts +6 -0
- package/dist/esm/types/chartType/bar/zBar.js +2 -1
- package/dist/esm/types/chartType/bar/zBar.js.map +1 -1
- package/dist/esm/types/chartType/barParallel/barParallel.d.ts +6 -1
- package/dist/esm/types/chartType/barParallel/zBarParallel.d.ts +6 -0
- package/dist/esm/types/chartType/barParallel/zBarParallel.js +2 -1
- package/dist/esm/types/chartType/barParallel/zBarParallel.js.map +1 -1
- package/dist/esm/types/chartType/barPercent/barPercent.d.ts +6 -1
- package/dist/esm/types/chartType/barPercent/zBarPercent.d.ts +6 -0
- package/dist/esm/types/chartType/barPercent/zBarPercent.js +2 -1
- package/dist/esm/types/chartType/barPercent/zBarPercent.js.map +1 -1
- package/dist/esm/types/chartType/column/column.d.ts +6 -1
- package/dist/esm/types/chartType/column/zColumn.d.ts +6 -0
- package/dist/esm/types/chartType/column/zColumn.js +2 -1
- package/dist/esm/types/chartType/column/zColumn.js.map +1 -1
- package/dist/esm/types/chartType/columnParallel/columnParallel.d.ts +6 -1
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.d.ts +6 -0
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.js +2 -1
- package/dist/esm/types/chartType/columnParallel/zColumnParallel.js.map +1 -1
- package/dist/esm/types/chartType/columnPercent/columnPercent.d.ts +6 -1
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.d.ts +6 -0
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.js +2 -1
- package/dist/esm/types/chartType/columnPercent/zColumnPercent.js.map +1 -1
- package/dist/esm/types/chartType/line/line.d.ts +11 -1
- package/dist/esm/types/chartType/line/zLine.d.ts +309 -0
- package/dist/esm/types/chartType/line/zLine.js +3 -1
- package/dist/esm/types/chartType/line/zLine.js.map +1 -1
- package/dist/esm/types/properties/config/area.d.ts +12 -0
- package/dist/esm/types/properties/config/area.js +2 -0
- package/dist/esm/types/properties/config/area.js.map +1 -1
- package/dist/esm/types/properties/config/bar.d.ts +18 -0
- package/dist/esm/types/properties/config/bar.js +2 -0
- package/dist/esm/types/properties/config/bar.js.map +1 -1
- package/dist/esm/types/properties/config/column.d.ts +18 -0
- package/dist/esm/types/properties/config/column.js +2 -0
- package/dist/esm/types/properties/config/column.js.map +1 -1
- package/dist/esm/types/properties/config/config.d.ts +66 -0
- package/dist/esm/types/properties/config/line.d.ts +6 -0
- package/dist/esm/types/properties/config/line.js +2 -0
- package/dist/esm/types/properties/config/line.js.map +1 -1
- package/dist/esm/types/properties/config/race.d.ts +12 -0
- package/dist/esm/types/properties/index.d.ts +1 -0
- package/dist/esm/types/properties/index.js +1 -0
- package/dist/esm/types/properties/regionPadding/index.d.ts +2 -0
- package/dist/esm/types/properties/regionPadding/index.js +1 -0
- package/dist/esm/types/properties/regionPadding/regionPadding.d.ts +6 -0
- package/dist/esm/types/properties/regionPadding/regionPadding.js +0 -0
- package/dist/esm/types/properties/regionPadding/zRegionPadding.d.ts +7 -0
- package/dist/esm/types/properties/regionPadding/zRegionPadding.js +11 -0
- package/dist/esm/types/properties/regionPadding/zRegionPadding.js.map +1 -0
- package/dist/esm/types/properties/theme/customTheme.d.ts +132 -0
- package/dist/umd/index.js +485 -291
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ANNOTATION_Z_INDEX } from "../../../../utils/constant.js";
|
|
2
|
-
import { buildDifferenceCoordinateDatum, buildDifferenceText,
|
|
2
|
+
import { buildDifferenceCoordinateDatum, buildDifferenceText, getDifferenceLineStackResolveMode, getRuntimeDifferenceValue, inferDifferenceBracketDirection, inferDifferenceConnectDirection, resolveDifferenceAnchor, usesDifferenceLineElementStackEnd } from "./annotationDifferenceLineCommon.js";
|
|
3
3
|
const DEFAULT_LINE_COLOR = '#BCC1CB';
|
|
4
4
|
const DEFAULT_TEXT_COLOR = '#ffffff';
|
|
5
5
|
const DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB';
|
|
@@ -10,6 +10,11 @@ const DEFAULT_CORNER_RADIUS = 4;
|
|
|
10
10
|
const DEFAULT_LABEL_PADDING = 4;
|
|
11
11
|
const DEFAULT_END_SYMBOL_SIZE = 12;
|
|
12
12
|
const DEFAULT_END_SYMBOL_REF_X = -4;
|
|
13
|
+
const DEFAULT_BRACKET_EXPAND_DISTANCE = 80;
|
|
14
|
+
const DEFAULT_BRACKET_LINE_DASH = [
|
|
15
|
+
2,
|
|
16
|
+
2
|
|
17
|
+
];
|
|
13
18
|
const getDifferenceLinePath = (index, total)=>1 === total ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`;
|
|
14
19
|
const assertDifferenceLineConfig = (value, path)=>{
|
|
15
20
|
if ('object' != typeof value || null === value || Array.isArray(value)) throw new Error(`${path} must be an object`);
|
|
@@ -29,98 +34,177 @@ const annotationDifferenceLine_annotationDifferenceLine = (spec, context)=>{
|
|
|
29
34
|
annotationDifferenceLine
|
|
30
35
|
];
|
|
31
36
|
const dataset = advancedVSeed.dataset.flat();
|
|
32
|
-
const
|
|
33
|
-
const
|
|
37
|
+
const chartSpec = spec;
|
|
38
|
+
const stackResolveMode = getDifferenceLineStackResolveMode(vseed, advancedVSeed);
|
|
39
|
+
const useElementStackEnd = usesDifferenceLineElementStackEnd(vseed, advancedVSeed);
|
|
40
|
+
const isBracketChart = 'line' === vseed.chartType || 'area' === vseed.chartType;
|
|
34
41
|
const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index)=>{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
42
|
+
try {
|
|
43
|
+
assertDifferenceLineConfig(annotationDifferenceLine, getDifferenceLinePath(index, annotationDifferenceLineList.length));
|
|
44
|
+
const start = resolveDifferenceAnchor({
|
|
45
|
+
dataset,
|
|
46
|
+
selectorLabel: 'start',
|
|
47
|
+
selectorValue: annotationDifferenceLine.start.selector,
|
|
48
|
+
spec: chartSpec,
|
|
49
|
+
stackResolveMode,
|
|
50
|
+
allowSelectorFallback: !useElementStackEnd
|
|
51
|
+
});
|
|
52
|
+
const end = resolveDifferenceAnchor({
|
|
53
|
+
dataset,
|
|
54
|
+
selectorLabel: 'end',
|
|
55
|
+
selectorValue: annotationDifferenceLine.end.selector,
|
|
56
|
+
spec: chartSpec,
|
|
57
|
+
stackResolveMode,
|
|
58
|
+
allowSelectorFallback: !useElementStackEnd
|
|
59
|
+
});
|
|
60
|
+
if (!start || !end) return [];
|
|
61
|
+
if (start.mode !== end.mode) return [];
|
|
62
|
+
const usesRuntimeStackEnd = useElementStackEnd || ('column' === vseed.chartType || 'bar' === vseed.chartType) && 'element' === start.mode && 'auto' === stackResolveMode;
|
|
63
|
+
const useBracketStyle = isBracketChart || ('column' === vseed.chartType || 'bar' === vseed.chartType) && 'element' === start.mode && 'auto' === stackResolveMode;
|
|
64
|
+
const isStackedBarElementBracket = 'bar' === vseed.chartType && 'element' === start.mode && 'auto' === stackResolveMode;
|
|
65
|
+
const connectDirection = useBracketStyle ? isStackedBarElementBracket ? 'top' : inferDifferenceBracketDirection(start, end) : inferDifferenceConnectDirection(vseed, [
|
|
66
|
+
start.value,
|
|
67
|
+
end.value
|
|
68
|
+
]);
|
|
69
|
+
const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR;
|
|
70
|
+
const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR;
|
|
71
|
+
const textBackgroundColor = annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR;
|
|
72
|
+
const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE;
|
|
73
|
+
const differenceType = annotationDifferenceLine.differenceType ?? 'absolute';
|
|
74
|
+
const label = usesRuntimeStackEnd ? {
|
|
75
|
+
visible: true,
|
|
76
|
+
position: 'middle',
|
|
77
|
+
refY: 0,
|
|
78
|
+
formatMethod: (_markData, seriesData)=>{
|
|
79
|
+
try {
|
|
80
|
+
return buildDifferenceText(getRuntimeDifferenceValue({
|
|
67
81
|
anchor: start,
|
|
68
82
|
seriesData,
|
|
69
|
-
|
|
70
|
-
}),
|
|
71
|
-
buildDifferenceCoordinateDatum({
|
|
83
|
+
useElementStackEnd: usesRuntimeStackEnd
|
|
84
|
+
}), getRuntimeDifferenceValue({
|
|
72
85
|
anchor: end,
|
|
73
86
|
seriesData,
|
|
74
|
-
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
useElementStackEnd: usesRuntimeStackEnd
|
|
88
|
+
}), differenceType);
|
|
89
|
+
} catch {
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
style: {
|
|
94
|
+
fill: textColor,
|
|
95
|
+
fontSize: textFontSize
|
|
96
|
+
},
|
|
97
|
+
labelBackground: {
|
|
98
|
+
visible: true,
|
|
99
|
+
padding: DEFAULT_LABEL_PADDING,
|
|
78
100
|
style: {
|
|
79
|
-
|
|
101
|
+
fill: textBackgroundColor,
|
|
102
|
+
fillOpacity: 1,
|
|
80
103
|
stroke: lineColor,
|
|
81
|
-
lineWidth:
|
|
82
|
-
lineDash: [
|
|
83
|
-
0
|
|
84
|
-
],
|
|
104
|
+
lineWidth: 1,
|
|
85
105
|
cornerRadius: DEFAULT_CORNER_RADIUS
|
|
86
106
|
}
|
|
107
|
+
}
|
|
108
|
+
} : {
|
|
109
|
+
visible: true,
|
|
110
|
+
position: 'middle',
|
|
111
|
+
refY: 0,
|
|
112
|
+
text: buildDifferenceText(start.value, end.value, differenceType),
|
|
113
|
+
style: {
|
|
114
|
+
fill: textColor,
|
|
115
|
+
fontSize: textFontSize
|
|
87
116
|
},
|
|
88
|
-
|
|
89
|
-
confine: true,
|
|
117
|
+
labelBackground: {
|
|
90
118
|
visible: true,
|
|
91
|
-
|
|
92
|
-
text: buildDifferenceText(start.value, end.value, annotationDifferenceLine.differenceType ?? 'absolute'),
|
|
119
|
+
padding: DEFAULT_LABEL_PADDING,
|
|
93
120
|
style: {
|
|
94
|
-
fill:
|
|
95
|
-
|
|
121
|
+
fill: textBackgroundColor,
|
|
122
|
+
fillOpacity: 1,
|
|
123
|
+
stroke: lineColor,
|
|
124
|
+
lineWidth: 1,
|
|
125
|
+
cornerRadius: DEFAULT_CORNER_RADIUS
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return [
|
|
130
|
+
{
|
|
131
|
+
type: 'type-step',
|
|
132
|
+
autoRange: true,
|
|
133
|
+
zIndex: ANNOTATION_Z_INDEX,
|
|
134
|
+
connectDirection,
|
|
135
|
+
expandDistance: useBracketStyle ? DEFAULT_BRACKET_EXPAND_DISTANCE : DEFAULT_EXPAND_DISTANCE,
|
|
136
|
+
coordinates: (seriesData, relativeSeries)=>{
|
|
137
|
+
try {
|
|
138
|
+
return [
|
|
139
|
+
buildDifferenceCoordinateDatum({
|
|
140
|
+
anchor: start,
|
|
141
|
+
seriesData,
|
|
142
|
+
relativeSeries,
|
|
143
|
+
useElementStackEnd: usesRuntimeStackEnd
|
|
144
|
+
}),
|
|
145
|
+
buildDifferenceCoordinateDatum({
|
|
146
|
+
anchor: end,
|
|
147
|
+
seriesData,
|
|
148
|
+
relativeSeries,
|
|
149
|
+
useElementStackEnd: usesRuntimeStackEnd
|
|
150
|
+
})
|
|
151
|
+
];
|
|
152
|
+
} catch {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
96
155
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
156
|
+
line: useBracketStyle ? {
|
|
157
|
+
multiSegment: true,
|
|
158
|
+
mainSegmentIndex: 1,
|
|
159
|
+
style: [
|
|
160
|
+
{
|
|
161
|
+
visible: true,
|
|
162
|
+
stroke: lineColor,
|
|
163
|
+
lineWidth: DEFAULT_LINE_WIDTH,
|
|
164
|
+
lineDash: DEFAULT_BRACKET_LINE_DASH
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
visible: true,
|
|
168
|
+
stroke: lineColor,
|
|
169
|
+
lineWidth: DEFAULT_LINE_WIDTH
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
visible: true,
|
|
173
|
+
stroke: lineColor,
|
|
174
|
+
lineWidth: DEFAULT_LINE_WIDTH,
|
|
175
|
+
lineDash: DEFAULT_BRACKET_LINE_DASH
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
} : {
|
|
100
179
|
style: {
|
|
101
|
-
|
|
102
|
-
fillOpacity: 1,
|
|
180
|
+
visible: true,
|
|
103
181
|
stroke: lineColor,
|
|
104
|
-
lineWidth:
|
|
182
|
+
lineWidth: DEFAULT_LINE_WIDTH,
|
|
183
|
+
lineDash: [
|
|
184
|
+
0
|
|
185
|
+
],
|
|
105
186
|
cornerRadius: DEFAULT_CORNER_RADIUS
|
|
106
187
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
188
|
+
},
|
|
189
|
+
label,
|
|
190
|
+
startSymbol: {
|
|
191
|
+
visible: false
|
|
192
|
+
},
|
|
193
|
+
endSymbol: {
|
|
194
|
+
visible: true,
|
|
195
|
+
size: DEFAULT_END_SYMBOL_SIZE,
|
|
196
|
+
refX: DEFAULT_END_SYMBOL_REF_X,
|
|
197
|
+
style: {
|
|
198
|
+
fill: lineColor
|
|
199
|
+
}
|
|
118
200
|
}
|
|
119
201
|
}
|
|
120
|
-
|
|
121
|
-
|
|
202
|
+
];
|
|
203
|
+
} catch {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
122
206
|
});
|
|
123
|
-
const specMarkLine =
|
|
207
|
+
const specMarkLine = chartSpec.markLine || [];
|
|
124
208
|
return {
|
|
125
209
|
...spec,
|
|
126
210
|
markLine: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.ts"],"sourcesContent":["import type { IBarChartSpec, ICartesianSeries, IMarkLineSpec } from '@visactor/vchart'\nimport type { AnnotationDifferenceLine, VChartSpecPipe } from 'src/types'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport {\n buildDifferenceCoordinateDatum,\n buildDifferenceText,\n inferDifferenceConnectDirection,\n isDifferenceLineStacked,\n resolveDifferenceAnchor,\n} from './annotationDifferenceLineCommon'\n\nconst DEFAULT_LINE_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_COLOR = '#ffffff'\nconst DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_FONT_SIZE = 12\nconst DEFAULT_EXPAND_DISTANCE = 24\nconst DEFAULT_LINE_WIDTH = 2\nconst DEFAULT_CORNER_RADIUS = 4\nconst DEFAULT_LABEL_PADDING = 4\nconst DEFAULT_END_SYMBOL_SIZE = 12\nconst DEFAULT_END_SYMBOL_REF_X = -4\n\nconst getDifferenceLinePath = (index: number, total: number) =>\n total === 1 ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`\n\nconst assertDifferenceLineConfig: (value: unknown, path: string) => asserts value is AnnotationDifferenceLine = (\n value,\n path,\n) => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${path} must be an object`)\n }\n\n const start = (value as Record<string, unknown>).start\n if (typeof start !== 'object' || start === null || Array.isArray(start)) {\n throw new Error(`${path}.start is required`)\n }\n if ((start as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.start.selector is required`)\n }\n\n const end = (value as Record<string, unknown>).end\n if (typeof end !== 'object' || end === null || Array.isArray(end)) {\n throw new Error(`${path}.end is required`)\n }\n if ((end as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.end.selector is required`)\n }\n}\n\nexport const annotationDifferenceLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const annotationDifferenceLine = advancedVSeed.annotation?.annotationDifferenceLine\n\n if (!annotationDifferenceLine) {\n return spec\n }\n\n const theme = advancedVSeed.config?.[vseed.chartType as 'column']?.annotation?.annotationDifferenceLine\n const annotationDifferenceLineList = Array.isArray(annotationDifferenceLine)\n ? annotationDifferenceLine\n : [annotationDifferenceLine]\n const dataset = advancedVSeed.dataset.flat()\n const barSpec = spec as IBarChartSpec\n const isStacked = isDifferenceLineStacked(vseed, advancedVSeed)\n\n const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index) => {\n assertDifferenceLineConfig(\n annotationDifferenceLine,\n getDifferenceLinePath(index, annotationDifferenceLineList.length),\n )\n\n const start = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'start',\n selectorValue: annotationDifferenceLine.start.selector,\n spec: barSpec,\n isStacked,\n })\n const end = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'end',\n selectorValue: annotationDifferenceLine.end.selector,\n spec: barSpec,\n isStacked,\n })\n\n if (!start || !end) {\n return []\n }\n\n const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR\n const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR\n const textBackgroundColor =\n annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR\n const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE\n\n return [\n {\n type: 'type-step',\n autoRange: true,\n zIndex: ANNOTATION_Z_INDEX,\n connectDirection: inferDifferenceConnectDirection(vseed, [start.value, end.value]),\n expandDistance: DEFAULT_EXPAND_DISTANCE,\n coordinates: (seriesData: any[], relativeSeries: ICartesianSeries) => [\n buildDifferenceCoordinateDatum({\n anchor: start,\n seriesData,\n relativeSeries,\n }),\n buildDifferenceCoordinateDatum({\n anchor: end,\n seriesData,\n relativeSeries,\n }),\n ],\n line: {\n style: {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: [0],\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n label: {\n confine: true,\n visible: true,\n position: 'middle',\n text: buildDifferenceText(start.value, end.value, annotationDifferenceLine.differenceType ?? 'absolute'),\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n },\n startSymbol: {\n visible: false,\n },\n endSymbol: {\n visible: true,\n size: DEFAULT_END_SYMBOL_SIZE,\n refX: DEFAULT_END_SYMBOL_REF_X,\n style: {\n fill: lineColor,\n },\n },\n } as IMarkLineSpec,\n ]\n })\n\n const specMarkLine = (barSpec.markLine as IMarkLineSpec[]) || []\n\n return {\n ...spec,\n markLine: [...specMarkLine, ...markLine],\n }\n}\n"],"names":["DEFAULT_LINE_COLOR","DEFAULT_TEXT_COLOR","DEFAULT_TEXT_BACKGROUND_COLOR","DEFAULT_TEXT_FONT_SIZE","DEFAULT_EXPAND_DISTANCE","DEFAULT_LINE_WIDTH","DEFAULT_CORNER_RADIUS","DEFAULT_LABEL_PADDING","DEFAULT_END_SYMBOL_SIZE","DEFAULT_END_SYMBOL_REF_X","getDifferenceLinePath","index","total","assertDifferenceLineConfig","value","path","Array","Error","start","end","annotationDifferenceLine","spec","context","advancedVSeed","vseed","theme","annotationDifferenceLineList","dataset","barSpec","isStacked","isDifferenceLineStacked","markLine","resolveDifferenceAnchor","lineColor","textColor","textBackgroundColor","textFontSize","ANNOTATION_Z_INDEX","inferDifferenceConnectDirection","seriesData","relativeSeries","buildDifferenceCoordinateDatum","buildDifferenceText","specMarkLine"],"mappings":";;AAWA,MAAMA,qBAAqB;AAC3B,MAAMC,qBAAqB;AAC3B,MAAMC,gCAAgC;AACtC,MAAMC,yBAAyB;AAC/B,MAAMC,0BAA0B;AAChC,MAAMC,qBAAqB;AAC3B,MAA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EAAEC,yBAAyB,cAAc,IAAI;oBAC7F,OAAO;wBACL,MAAMc;wBACN,UAAUE;oBACZ;oBACA,iBAAiB;wBACf,SAAS;wBACT,SAAS7B;wBACT,OAAO;4BACL,MAAM4B;4BACN,aAAa;4BACb,QAAQF;4BACR,WAAW;4BACX,cAAc3B;wBAChB;oBACF;gBACF;gBACA,aAAa;oBACX,SAAS;gBACX;gBACA,WAAW;oBACT,SAAS;oBACT,MAAME;oBACN,MAAMC;oBACN,OAAO;wBACL,MAAMwB;oBACR;gBACF;YACF;SACD;IACH;IAEA,MAAMU,eAAgBf,QAAQ,QAAQ,IAAwB,EAAE;IAEhE,OAAO;QACL,GAAGP,IAAI;QACP,UAAU;eAAIsB;eAAiBZ;SAAS;IAC1C;AACF"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationDifferenceLine.ts"],"sourcesContent":["import type { IAreaChartSpec, IBarChartSpec, ICartesianSeries, ILineChartSpec, IMarkLineSpec } from '@visactor/vchart'\nimport type { AnnotationDifferenceLine, VChartSpecPipe } from 'src/types'\nimport { ANNOTATION_Z_INDEX } from '../../../../utils/constant'\nimport {\n buildDifferenceCoordinateDatum,\n buildDifferenceText,\n getDifferenceLineStackResolveMode,\n getRuntimeDifferenceValue,\n inferDifferenceBracketDirection,\n inferDifferenceConnectDirection,\n usesDifferenceLineElementStackEnd,\n resolveDifferenceAnchor,\n} from './annotationDifferenceLineCommon'\n\nconst DEFAULT_LINE_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_COLOR = '#ffffff'\nconst DEFAULT_TEXT_BACKGROUND_COLOR = '#BCC1CB'\nconst DEFAULT_TEXT_FONT_SIZE = 12\nconst DEFAULT_EXPAND_DISTANCE = 24\nconst DEFAULT_LINE_WIDTH = 2\nconst DEFAULT_CORNER_RADIUS = 4\nconst DEFAULT_LABEL_PADDING = 4\nconst DEFAULT_END_SYMBOL_SIZE = 12\nconst DEFAULT_END_SYMBOL_REF_X = -4\nconst DEFAULT_BRACKET_EXPAND_DISTANCE = 80\nconst DEFAULT_BRACKET_LINE_DASH: [number, number] = [2, 2]\n\nconst getDifferenceLinePath = (index: number, total: number) =>\n total === 1 ? 'annotationDifferenceLine' : `annotationDifferenceLine[${index}]`\n\nconst assertDifferenceLineConfig: (value: unknown, path: string) => asserts value is AnnotationDifferenceLine = (\n value,\n path,\n) => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${path} must be an object`)\n }\n\n const start = (value as Record<string, unknown>).start\n if (typeof start !== 'object' || start === null || Array.isArray(start)) {\n throw new Error(`${path}.start is required`)\n }\n if ((start as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.start.selector is required`)\n }\n\n const end = (value as Record<string, unknown>).end\n if (typeof end !== 'object' || end === null || Array.isArray(end)) {\n throw new Error(`${path}.end is required`)\n }\n if ((end as Record<string, unknown>).selector == null) {\n throw new Error(`${path}.end.selector is required`)\n }\n}\n\nexport const annotationDifferenceLine: VChartSpecPipe = (spec, context) => {\n const { advancedVSeed, vseed } = context\n const annotationDifferenceLine = advancedVSeed.annotation?.annotationDifferenceLine\n\n if (!annotationDifferenceLine) {\n return spec\n }\n\n const theme = advancedVSeed.config?.[vseed.chartType as 'column']?.annotation?.annotationDifferenceLine\n const annotationDifferenceLineList = Array.isArray(annotationDifferenceLine)\n ? annotationDifferenceLine\n : [annotationDifferenceLine]\n const dataset = advancedVSeed.dataset.flat()\n const chartSpec = spec as IBarChartSpec | ILineChartSpec | IAreaChartSpec\n const stackResolveMode = getDifferenceLineStackResolveMode(vseed, advancedVSeed)\n const useElementStackEnd = usesDifferenceLineElementStackEnd(vseed, advancedVSeed)\n const isBracketChart = vseed.chartType === 'line' || vseed.chartType === 'area'\n\n const markLine = annotationDifferenceLineList.flatMap((annotationDifferenceLine, index) => {\n try {\n assertDifferenceLineConfig(\n annotationDifferenceLine,\n getDifferenceLinePath(index, annotationDifferenceLineList.length),\n )\n\n const start = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'start',\n selectorValue: annotationDifferenceLine.start.selector,\n spec: chartSpec,\n stackResolveMode,\n allowSelectorFallback: !useElementStackEnd,\n })\n const end = resolveDifferenceAnchor({\n dataset,\n selectorLabel: 'end',\n selectorValue: annotationDifferenceLine.end.selector,\n spec: chartSpec,\n stackResolveMode,\n allowSelectorFallback: !useElementStackEnd,\n })\n\n if (!start || !end) {\n return []\n }\n\n if (start.mode !== end.mode) {\n return []\n }\n\n const usesRuntimeStackEnd =\n useElementStackEnd ||\n ((vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n start.mode === 'element' &&\n stackResolveMode === 'auto')\n const useBracketStyle =\n isBracketChart ||\n ((vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n start.mode === 'element' &&\n stackResolveMode === 'auto')\n const isStackedBarElementBracket =\n vseed.chartType === 'bar' && start.mode === 'element' && stackResolveMode === 'auto'\n const connectDirection = useBracketStyle\n ? isStackedBarElementBracket\n ? 'top'\n : inferDifferenceBracketDirection(start, end)\n : inferDifferenceConnectDirection(vseed, [start.value, end.value])\n\n const lineColor = annotationDifferenceLine.lineColor ?? theme?.lineColor ?? DEFAULT_LINE_COLOR\n const textColor = annotationDifferenceLine.textColor ?? theme?.textColor ?? DEFAULT_TEXT_COLOR\n const textBackgroundColor =\n annotationDifferenceLine.textBackgroundColor ?? theme?.textBackgroundColor ?? DEFAULT_TEXT_BACKGROUND_COLOR\n const textFontSize = annotationDifferenceLine.textFontSize ?? theme?.textFontSize ?? DEFAULT_TEXT_FONT_SIZE\n const differenceType = annotationDifferenceLine.differenceType ?? 'absolute'\n\n const label = usesRuntimeStackEnd\n ? {\n visible: true,\n position: 'middle',\n refY: 0,\n formatMethod: (_markData: any[], seriesData: any[]) => {\n try {\n return buildDifferenceText(\n getRuntimeDifferenceValue({\n anchor: start,\n seriesData,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n getRuntimeDifferenceValue({\n anchor: end,\n seriesData,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n differenceType,\n )\n } catch {\n return ''\n }\n },\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n }\n : {\n visible: true,\n position: 'middle',\n refY: 0,\n text: buildDifferenceText(start.value, end.value, differenceType),\n style: {\n fill: textColor,\n fontSize: textFontSize,\n },\n labelBackground: {\n visible: true,\n padding: DEFAULT_LABEL_PADDING,\n style: {\n fill: textBackgroundColor,\n fillOpacity: 1,\n stroke: lineColor,\n lineWidth: 1,\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n }\n\n return [\n {\n type: 'type-step',\n autoRange: true,\n zIndex: ANNOTATION_Z_INDEX,\n connectDirection,\n expandDistance: useBracketStyle ? DEFAULT_BRACKET_EXPAND_DISTANCE : DEFAULT_EXPAND_DISTANCE,\n coordinates: (seriesData: any[], relativeSeries: ICartesianSeries) => {\n try {\n return [\n buildDifferenceCoordinateDatum({\n anchor: start,\n seriesData,\n relativeSeries,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n buildDifferenceCoordinateDatum({\n anchor: end,\n seriesData,\n relativeSeries,\n useElementStackEnd: usesRuntimeStackEnd,\n }),\n ]\n } catch {\n return []\n }\n },\n line: useBracketStyle\n ? {\n multiSegment: true,\n mainSegmentIndex: 1,\n style: [\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: DEFAULT_BRACKET_LINE_DASH,\n },\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n },\n {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: DEFAULT_BRACKET_LINE_DASH,\n },\n ],\n }\n : {\n style: {\n visible: true,\n stroke: lineColor,\n lineWidth: DEFAULT_LINE_WIDTH,\n lineDash: [0],\n cornerRadius: DEFAULT_CORNER_RADIUS,\n },\n },\n label,\n startSymbol: {\n visible: false,\n },\n endSymbol: {\n visible: true,\n size: DEFAULT_END_SYMBOL_SIZE,\n refX: DEFAULT_END_SYMBOL_REF_X,\n style: {\n fill: lineColor,\n },\n },\n } as IMarkLineSpec,\n ]\n } catch {\n return []\n }\n })\n\n const specMarkLine = (chartSpec.markLine as IMarkLineSpec[]) || []\n\n return {\n ...spec,\n markLine: [...specMarkLine, ...markLine],\n }\n}\n"],"names":["DEFAULT_LINE_COLOR","DEFAULT_TEXT_COLOR","DEFAULT_TEXT_BACKGROUND_COLOR","DEFAULT_TEXT_FONT_SIZE","DEFAULT_EXPAND_DISTANCE","DEFAULT_LINE_WIDTH","DEFAULT_CORNER_RADIUS","DEFAULT_LABEL_PADDING","DEFAULT_END_SYMBOL_SIZE","DEFAULT_END_SYMBOL_REF_X","DEFAULT_BRACKET_EXPAND_DISTANCE","DEFAULT_BRACKET_LINE_DASH","getDifferenceLinePath","index","total","assertDifferenceLineConfig","value","path","Array","Error","start","end","annotationDifferenceLine","spec","context","advancedVSeed","vseed","theme","annotationDifferenceLineList","dataset","chartSpec","stackResolveMode","getDifferenceLineStackResolveMode","useElementStackEnd","usesDifferenceLineElementStackEnd","isBracketChart","markLine","resolveDifferenceAnchor","usesRuntimeStackEnd","useBracketStyle","isStackedBarElementBracket","connectDirection","inferDifferenceBracketDirection","inferDifferenceConnectDirection","lineColor","textColor","textBackgroundColor","textFontSize","differenceType","label","_markData","seriesData","buildDifferenceText","getRuntimeDifferenceValue","ANNOTATION_Z_INDEX","relativeSeries","buildDifferenceCoordinateDatum","specMarkLine"],"mappings":";;AAcA,MAAMA,qBAAqB;AAC3B,MAAMC,qBAAqB;AAC3B,MAAMC,gCAAgC;AACtC,MAAMC,yBAAyB;AAC/B,MAAMC,0BAA0B;AAChC,MAAMC,qBAA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QAAQgD;oBACRb;oBACA,gBAAgBF,kBAAkB7B,kCAAkCN;oBACpE,aAAa,CAAC+C,YAAmBI;wBAC/B,IAAI;4BACF,OAAO;gCACLC,+BAA+B;oCAC7B,QAAQpC;oCACR+B;oCACAI;oCACA,oBAAoBjB;gCACtB;gCACAkB,+BAA+B;oCAC7B,QAAQnC;oCACR8B;oCACAI;oCACA,oBAAoBjB;gCACtB;6BACD;wBACH,EAAE,OAAM;4BACN,OAAO,EAAE;wBACX;oBACF;oBACA,MAAMC,kBACF;wBACE,cAAc;wBACd,kBAAkB;wBAClB,OAAO;4BACL;gCACE,SAAS;gCACT,QAAQK;gCACR,WAAWvC;gCACX,UAAUM;4BACZ;4BACA;gCACE,SAAS;gCACT,QAAQiC;gCACR,WAAWvC;4BACb;4BACA;gCACE,SAAS;gCACT,QAAQuC;gCACR,WAAWvC;gCACX,UAAUM;4BACZ;yBACD;oBACH,IACA;wBACE,OAAO;4BACL,SAAS;4BACT,QAAQiC;4BACR,WAAWvC;4BACX,UAAU;gCAAC;6BAAE;4BACb,cAAcC;wBAChB;oBACF;oBACJ2C;oBACA,aAAa;wBACX,SAAS;oBACX;oBACA,WAAW;wBACT,SAAS;wBACT,MAAMzC;wBACN,MAAMC;wBACN,OAAO;4BACL,MAAMmC;wBACR;oBACF;gBACF;aACD;QACH,EAAE,OAAM;YACN,OAAO,EAAE;QACX;IACF;IAEA,MAAMa,eAAgB3B,UAAU,QAAQ,IAAwB,EAAE;IAElE,OAAO;QACL,GAAGP,IAAI;QACP,UAAU;eAAIkC;eAAiBrB;SAAS;IAC1C;AACF"}
|
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
import type { IBarChartSpec, ICartesianSeries } from '@visactor/vchart';
|
|
1
|
+
import type { IAreaChartSpec, IBarChartSpec, ICartesianSeries, ILineChartSpec } from '@visactor/vchart';
|
|
2
2
|
import type { AdvancedVSeed, Datum, Selector, Selectors, VSeed } from '../../../../../types';
|
|
3
3
|
type DifferenceSelectorLabel = 'start' | 'end';
|
|
4
|
+
type DifferenceChartSpec = IBarChartSpec | ILineChartSpec | IAreaChartSpec;
|
|
5
|
+
export type DifferenceStackResolveMode = 'none' | 'stackTotal' | 'auto';
|
|
6
|
+
export type DifferenceAnchorMode = 'element' | 'stackTotal';
|
|
4
7
|
export type ResolvedDifferenceAnchor = {
|
|
8
|
+
mode: DifferenceAnchorMode;
|
|
5
9
|
selectorLabel: DifferenceSelectorLabel;
|
|
6
10
|
coordinateDatum: Datum;
|
|
7
11
|
matchedDatum?: Datum;
|
|
8
12
|
stackGroupDatum?: Datum;
|
|
13
|
+
bandDatum: Datum;
|
|
14
|
+
bandIndex?: number;
|
|
9
15
|
value: number;
|
|
10
16
|
};
|
|
11
|
-
export declare const
|
|
17
|
+
export declare const getDifferenceLineStackResolveMode: (vseed: VSeed, advancedVSeed: AdvancedVSeed) => DifferenceStackResolveMode;
|
|
18
|
+
export declare const usesDifferenceLineElementStackEnd: (vseed: VSeed, advancedVSeed: AdvancedVSeed) => boolean;
|
|
12
19
|
export declare const resolveDifferenceAnchor: (options: {
|
|
13
20
|
dataset: Datum[];
|
|
14
21
|
selectorLabel: DifferenceSelectorLabel;
|
|
15
22
|
selectorValue: Selector | Selectors;
|
|
16
|
-
spec:
|
|
17
|
-
|
|
23
|
+
spec: DifferenceChartSpec;
|
|
24
|
+
stackResolveMode: DifferenceStackResolveMode;
|
|
25
|
+
allowSelectorFallback?: boolean;
|
|
18
26
|
}) => ResolvedDifferenceAnchor | undefined;
|
|
19
27
|
export declare const getStackRuntimeTotal: (runtimeMatches: Datum[]) => number | undefined;
|
|
20
28
|
export declare const buildDifferenceCoordinateDatum: (options: {
|
|
21
29
|
anchor: ResolvedDifferenceAnchor;
|
|
22
30
|
seriesData: Datum[];
|
|
23
31
|
relativeSeries: ICartesianSeries;
|
|
32
|
+
useElementStackEnd?: boolean;
|
|
24
33
|
}) => Record<string | number, any>;
|
|
34
|
+
export declare const getRuntimeDifferenceValue: (options: {
|
|
35
|
+
anchor: ResolvedDifferenceAnchor;
|
|
36
|
+
seriesData: Datum[];
|
|
37
|
+
useElementStackEnd?: boolean;
|
|
38
|
+
}) => number;
|
|
25
39
|
export declare const buildDifferenceText: (startValue: number, endValue: number, differenceType?: "absolute" | "percent") => string;
|
|
26
40
|
export declare const inferDifferenceConnectDirection: (vseed: VSeed, values: [number, number]) => "left" | "top" | "right" | "bottom";
|
|
41
|
+
export declare const inferDifferenceBracketDirection: (start: ResolvedDifferenceAnchor, end: ResolvedDifferenceAnchor) => "left" | "right";
|
|
27
42
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isDimensionSelector, isFieldSelector, isMeasureSelector, isPartialDatumSelector, isValueSelector, selector } from "../../../../../dataSelector/index.js";
|
|
2
2
|
import { hasMultipleMeasureInSingleView, isBarLikeChart } from "../../../../utils/index.js";
|
|
3
3
|
import { isSubset } from "./utils.js";
|
|
4
|
+
const STACK_END_FIELD = '__VCHART_STACK_END';
|
|
4
5
|
const toArray = (value)=>{
|
|
5
6
|
if (Array.isArray(value)) return value;
|
|
6
7
|
return null == value ? [] : [
|
|
@@ -22,6 +23,10 @@ const buildStackGroupDatum = (datum, bandFields)=>Object.fromEntries(bandFields.
|
|
|
22
23
|
field,
|
|
23
24
|
datum[field]
|
|
24
25
|
]));
|
|
26
|
+
const resolveBandIndex = (dataset, bandDatum)=>{
|
|
27
|
+
const bandIndex = dataset.findIndex((datum)=>isSubset(bandDatum, datum));
|
|
28
|
+
return bandIndex >= 0 ? bandIndex : void 0;
|
|
29
|
+
};
|
|
25
30
|
const buildFallbackSelectorDatum = (selectorValue)=>{
|
|
26
31
|
const selectorList = Array.isArray(selectorValue) ? selectorValue : [
|
|
27
32
|
selectorValue
|
|
@@ -68,7 +73,7 @@ const inferFallbackValue = (fallbackDatum, valueField, bandFields)=>{
|
|
|
68
73
|
return fallbackDatum[numericCandidateKeys[0]];
|
|
69
74
|
};
|
|
70
75
|
const resolveFallbackAnchor = (options)=>{
|
|
71
|
-
const { selectorLabel, selectorValue, valueField, bandFields } = options;
|
|
76
|
+
const { dataset, selectorLabel, selectorValue, valueField, bandFields } = options;
|
|
72
77
|
const fallbackDatum = buildFallbackSelectorDatum(selectorValue);
|
|
73
78
|
if (!fallbackDatum) return;
|
|
74
79
|
const inferredValue = inferFallbackValue(fallbackDatum, valueField, bandFields);
|
|
@@ -77,11 +82,15 @@ const resolveFallbackAnchor = (options)=>{
|
|
|
77
82
|
...fallbackDatum,
|
|
78
83
|
[valueField]: inferredValue
|
|
79
84
|
};
|
|
85
|
+
const bandDatum = buildStackGroupDatum(coordinateDatum, bandFields);
|
|
80
86
|
try {
|
|
81
87
|
return {
|
|
88
|
+
mode: 'element',
|
|
82
89
|
selectorLabel,
|
|
83
90
|
coordinateDatum,
|
|
84
91
|
matchedDatum: fallbackDatum,
|
|
92
|
+
bandDatum,
|
|
93
|
+
bandIndex: resolveBandIndex(dataset, bandDatum),
|
|
85
94
|
value: normalizeDifferenceValue(inferredValue, selectorLabel, valueField)
|
|
86
95
|
};
|
|
87
96
|
} catch {
|
|
@@ -92,24 +101,36 @@ const hasMixedSigns = (values)=>{
|
|
|
92
101
|
const nonZeroValues = values.filter((value)=>0 !== value);
|
|
93
102
|
return nonZeroValues.some((value)=>value > 0) && nonZeroValues.some((value)=>value < 0);
|
|
94
103
|
};
|
|
95
|
-
const
|
|
104
|
+
const getDifferenceLineStackResolveMode = (vseed, advancedVSeed)=>{
|
|
105
|
+
const hasMultipleMeasure = hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? []);
|
|
106
|
+
if (!hasMultipleMeasure) return 'none';
|
|
107
|
+
if ('column' === vseed.chartType) return 'auto';
|
|
108
|
+
if ('bar' === vseed.chartType) return 'auto';
|
|
109
|
+
return 'none';
|
|
110
|
+
};
|
|
111
|
+
const usesDifferenceLineElementStackEnd = (vseed, advancedVSeed)=>'area' === vseed.chartType && hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? []);
|
|
96
112
|
const resolveDifferenceAnchor = (options)=>{
|
|
97
|
-
const { dataset, selectorLabel, selectorValue, spec,
|
|
113
|
+
const { dataset, selectorLabel, selectorValue, spec, stackResolveMode, allowSelectorFallback = true } = options;
|
|
98
114
|
const matches = dataset.filter((datum)=>selector(datum, selectorValue));
|
|
99
115
|
const valueField = getDifferenceValueField(spec);
|
|
100
116
|
const bandFields = getDifferenceBandFields(spec);
|
|
101
|
-
if (0 === matches.length) return
|
|
117
|
+
if (0 === matches.length) return 'none' === stackResolveMode && allowSelectorFallback ? resolveFallbackAnchor({
|
|
118
|
+
dataset,
|
|
102
119
|
selectorLabel,
|
|
103
120
|
selectorValue,
|
|
104
121
|
valueField,
|
|
105
122
|
bandFields
|
|
106
|
-
});
|
|
107
|
-
if (
|
|
123
|
+
}) : void 0;
|
|
124
|
+
if ('none' === stackResolveMode || 'auto' === stackResolveMode && 1 === matches.length) {
|
|
108
125
|
if (1 !== matches.length) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one datum, got ${matches.length}`);
|
|
126
|
+
const bandDatum = buildStackGroupDatum(matches[0], bandFields);
|
|
109
127
|
return {
|
|
128
|
+
mode: 'element',
|
|
110
129
|
selectorLabel,
|
|
111
130
|
coordinateDatum: matches[0],
|
|
112
131
|
matchedDatum: matches[0],
|
|
132
|
+
bandDatum,
|
|
133
|
+
bandIndex: resolveBandIndex(dataset, bandDatum),
|
|
113
134
|
value: normalizeDifferenceValue(matches[0][valueField], selectorLabel, valueField)
|
|
114
135
|
};
|
|
115
136
|
}
|
|
@@ -121,27 +142,37 @@ const resolveDifferenceAnchor = (options)=>{
|
|
|
121
142
|
if (1 !== stackGroups.size) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack group, got ${stackGroups.size}`);
|
|
122
143
|
const stackGroupDatum = Array.from(stackGroups.values())[0];
|
|
123
144
|
const groupRows = dataset.filter((datum)=>isSubset(stackGroupDatum, datum));
|
|
145
|
+
if ('auto' === stackResolveMode && groupRows.length !== matches.length) throw new Error(`annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack element or one full stack group`);
|
|
124
146
|
const groupValues = groupRows.map((datum)=>normalizeDifferenceValue(datum[valueField], selectorLabel, valueField));
|
|
125
147
|
if (hasMixedSigns(groupValues)) throw new Error('annotationDifferenceLine does not support mixed-sign stack totals in v1');
|
|
126
148
|
return {
|
|
149
|
+
mode: 'stackTotal',
|
|
127
150
|
selectorLabel,
|
|
128
151
|
coordinateDatum: stackGroupDatum,
|
|
129
152
|
matchedDatum: matches[0],
|
|
130
153
|
stackGroupDatum,
|
|
154
|
+
bandDatum: stackGroupDatum,
|
|
155
|
+
bandIndex: resolveBandIndex(dataset, stackGroupDatum),
|
|
131
156
|
value: groupValues.reduce((sum, value)=>sum + value, 0)
|
|
132
157
|
};
|
|
133
158
|
};
|
|
134
159
|
const getStackRuntimeTotal = (runtimeMatches)=>{
|
|
135
|
-
const stackEndValues = runtimeMatches.map((datum)=>Number(datum
|
|
160
|
+
const stackEndValues = runtimeMatches.map((datum)=>Number(datum[STACK_END_FIELD]));
|
|
136
161
|
if (stackEndValues.some((value)=>Number.isNaN(value))) return;
|
|
137
162
|
if (hasMixedSigns(stackEndValues)) throw new Error('annotationDifferenceLine does not support mixed-sign runtime stack totals in v1');
|
|
138
163
|
return stackEndValues.some((value)=>value < 0) ? Math.min(...stackEndValues) : Math.max(...stackEndValues);
|
|
139
164
|
};
|
|
140
165
|
const buildDifferenceCoordinateDatum = (options)=>{
|
|
141
|
-
const { anchor, seriesData, relativeSeries } = options;
|
|
166
|
+
const { anchor, seriesData, relativeSeries, useElementStackEnd = false } = options;
|
|
142
167
|
if (!anchor.stackGroupDatum) {
|
|
143
168
|
const runtimeMatches = anchor.matchedDatum ? seriesData.filter((datum)=>isSubset(anchor.matchedDatum, datum)) : [];
|
|
144
|
-
return runtimeMatches[0] ?? anchor.coordinateDatum;
|
|
169
|
+
if (!useElementStackEnd) return runtimeMatches[0] ?? anchor.coordinateDatum;
|
|
170
|
+
const runtimeMatch = runtimeMatches[0];
|
|
171
|
+
const runtimeStackEnd = Number(runtimeMatch?.[STACK_END_FIELD]);
|
|
172
|
+
return {
|
|
173
|
+
...runtimeMatch ?? anchor.coordinateDatum,
|
|
174
|
+
[relativeSeries.getStackValueField()]: Number.isNaN(runtimeStackEnd) ? anchor.value : runtimeStackEnd
|
|
175
|
+
};
|
|
145
176
|
}
|
|
146
177
|
const runtimeMatches = seriesData.filter((datum)=>isSubset(anchor.stackGroupDatum, datum));
|
|
147
178
|
const runtimeStackTotal = getStackRuntimeTotal(runtimeMatches);
|
|
@@ -150,6 +181,17 @@ const buildDifferenceCoordinateDatum = (options)=>{
|
|
|
150
181
|
[relativeSeries.getStackValueField()]: runtimeStackTotal ?? anchor.value
|
|
151
182
|
};
|
|
152
183
|
};
|
|
184
|
+
const getRuntimeDifferenceValue = (options)=>{
|
|
185
|
+
const { anchor, seriesData, useElementStackEnd = false } = options;
|
|
186
|
+
if (anchor.stackGroupDatum) {
|
|
187
|
+
const runtimeMatches = seriesData.filter((datum)=>isSubset(anchor.stackGroupDatum, datum));
|
|
188
|
+
return getStackRuntimeTotal(runtimeMatches) ?? anchor.value;
|
|
189
|
+
}
|
|
190
|
+
if (!useElementStackEnd || !anchor.matchedDatum) return anchor.value;
|
|
191
|
+
const runtimeMatch = seriesData.find((datum)=>isSubset(anchor.matchedDatum, datum));
|
|
192
|
+
const runtimeStackEnd = Number(runtimeMatch?.[STACK_END_FIELD]);
|
|
193
|
+
return Number.isNaN(runtimeStackEnd) ? anchor.value : runtimeStackEnd;
|
|
194
|
+
};
|
|
153
195
|
const buildDifferenceText = (startValue, endValue, differenceType = 'absolute')=>{
|
|
154
196
|
if ('percent' === differenceType) {
|
|
155
197
|
if (0 === startValue) throw new Error('annotationDifferenceLine percent difference cannot be computed because start value is 0');
|
|
@@ -162,6 +204,10 @@ const inferDifferenceConnectDirection = (vseed, values)=>{
|
|
|
162
204
|
if (isBarLikeChart(vseed)) return isNegativeSide ? 'left' : 'right';
|
|
163
205
|
return isNegativeSide ? 'bottom' : 'top';
|
|
164
206
|
};
|
|
165
|
-
|
|
207
|
+
const inferDifferenceBracketDirection = (start, end)=>{
|
|
208
|
+
if (void 0 === start.bandIndex || void 0 === end.bandIndex) return 'right';
|
|
209
|
+
return start.bandIndex <= end.bandIndex ? 'right' : 'left';
|
|
210
|
+
};
|
|
211
|
+
export { buildDifferenceCoordinateDatum, buildDifferenceText, getDifferenceLineStackResolveMode, getRuntimeDifferenceValue, getStackRuntimeTotal, inferDifferenceBracketDirection, inferDifferenceConnectDirection, resolveDifferenceAnchor, usesDifferenceLineElementStackEnd };
|
|
166
212
|
|
|
167
213
|
//# sourceMappingURL=annotationDifferenceLineCommon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.ts"],"sourcesContent":["import type { IBarChartSpec, ICartesianSeries } from '@visactor/vchart'\nimport {\n isDimensionSelector,\n isFieldSelector,\n isMeasureSelector,\n isPartialDatumSelector,\n isValueSelector,\n selector,\n} from '../../../../../dataSelector'\nimport { hasMultipleMeasureInSingleView, isBarLikeChart } from 'src/pipeline/utils'\nimport type { AdvancedVSeed, Datum, Selector, Selectors, VSeed } from 'src/types'\nimport { isSubset } from './utils'\n\ntype DifferenceSelectorLabel = 'start' | 'end'\n\nexport type ResolvedDifferenceAnchor = {\n selectorLabel: DifferenceSelectorLabel\n coordinateDatum: Datum\n matchedDatum?: Datum\n stackGroupDatum?: Datum\n value: number\n}\n\nconst toArray = <T>(value: T | T[] | undefined | null): T[] => {\n if (Array.isArray(value)) {\n return value\n }\n\n return value === undefined || value === null ? [] : [value]\n}\n\nconst getDifferenceBandFields = (spec: IBarChartSpec): string[] => {\n return toArray((spec.direction === 'horizontal' ? spec.yField : spec.xField) as string | string[] | undefined)\n}\n\nconst getDifferenceValueField = (spec: IBarChartSpec): string => {\n const valueField = toArray(\n (spec.direction === 'horizontal' ? spec.xField : spec.yField) as string | string[] | undefined,\n )[0]\n\n if (!valueField) {\n throw new Error('annotationDifferenceLine requires a value field in the target chart spec')\n }\n\n return valueField\n}\n\nconst normalizeDifferenceValue = (value: unknown, selectorLabel: DifferenceSelectorLabel, field: string): number => {\n const numberValue = Number(value)\n\n if (Number.isNaN(numberValue)) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector resolved to a non-numeric value on field \"${field}\"`,\n )\n }\n\n return numberValue\n}\n\nconst buildStackGroupDatum = (datum: Datum, bandFields: string[]) => {\n return Object.fromEntries(bandFields.map((field) => [field, datum[field]])) as Datum\n}\n\nconst buildFallbackSelectorDatum = (selectorValue: Selector | Selectors): Datum | undefined => {\n const selectorList = Array.isArray(selectorValue) ? selectorValue : [selectorValue]\n const fallbackDatum: Datum = {}\n\n for (const currentSelector of selectorList) {\n if (isValueSelector(currentSelector) || isFieldSelector(currentSelector)) {\n return undefined\n }\n\n if (isMeasureSelector(currentSelector)) {\n const operator = currentSelector.operator || currentSelector.op\n const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [currentSelector.value]\n\n if (!['=', '=='].includes(operator as string) || selectorValues.length !== 1) {\n return undefined\n }\n\n fallbackDatum[currentSelector.field] = selectorValues[0]\n continue\n }\n\n if (isDimensionSelector(currentSelector)) {\n const operator = currentSelector.operator || currentSelector.op\n const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [currentSelector.value]\n\n if (operator !== 'in' || selectorValues.length !== 1) {\n return undefined\n }\n\n fallbackDatum[currentSelector.field] = selectorValues[0]\n continue\n }\n\n if (isPartialDatumSelector(currentSelector)) {\n Object.assign(fallbackDatum, currentSelector)\n continue\n }\n\n return undefined\n }\n\n return Object.keys(fallbackDatum).length > 0 ? fallbackDatum : undefined\n}\n\nconst inferFallbackValue = (fallbackDatum: Datum, valueField: string, bandFields: string[]) => {\n if (valueField in fallbackDatum) {\n return fallbackDatum[valueField]\n }\n\n const numericCandidateKeys = Object.keys(fallbackDatum).filter((key) => {\n if (key === valueField || bandFields.includes(key)) {\n return false\n }\n\n return typeof fallbackDatum[key] === 'number'\n })\n\n if (numericCandidateKeys.length !== 1) {\n return undefined\n }\n\n return fallbackDatum[numericCandidateKeys[0]]\n}\n\nconst resolveFallbackAnchor = (options: {\n selectorLabel: DifferenceSelectorLabel\n selectorValue: Selector | Selectors\n valueField: string\n bandFields: string[]\n}): ResolvedDifferenceAnchor | undefined => {\n const { selectorLabel, selectorValue, valueField, bandFields } = options\n const fallbackDatum = buildFallbackSelectorDatum(selectorValue)\n\n if (!fallbackDatum) {\n return undefined\n }\n\n const inferredValue = inferFallbackValue(fallbackDatum, valueField, bandFields)\n\n if (inferredValue === undefined) {\n return undefined\n }\n\n const coordinateDatum = {\n ...fallbackDatum,\n [valueField]: inferredValue,\n }\n\n try {\n return {\n selectorLabel,\n coordinateDatum,\n matchedDatum: fallbackDatum,\n value: normalizeDifferenceValue(inferredValue, selectorLabel, valueField),\n }\n } catch {\n return undefined\n }\n}\n\nconst hasMixedSigns = (values: number[]) => {\n const nonZeroValues = values.filter((value) => value !== 0)\n\n return nonZeroValues.some((value) => value > 0) && nonZeroValues.some((value) => value < 0)\n}\n\nexport const isDifferenceLineStacked = (vseed: VSeed, advancedVSeed: AdvancedVSeed) => {\n return (\n (vseed.chartType === 'column' || vseed.chartType === 'bar') &&\n hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? [])\n )\n}\n\nexport const resolveDifferenceAnchor = (options: {\n dataset: Datum[]\n selectorLabel: DifferenceSelectorLabel\n selectorValue: Selector | Selectors\n spec: IBarChartSpec\n isStacked: boolean\n}): ResolvedDifferenceAnchor | undefined => {\n const { dataset, selectorLabel, selectorValue, spec, isStacked } = options\n const matches = dataset.filter((datum) => selector(datum, selectorValue))\n const valueField = getDifferenceValueField(spec)\n const bandFields = getDifferenceBandFields(spec)\n\n if (matches.length === 0) {\n return isStacked ? undefined : resolveFallbackAnchor({ selectorLabel, selectorValue, valueField, bandFields })\n }\n\n if (!isStacked) {\n if (matches.length !== 1) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one datum, got ${matches.length}`,\n )\n }\n\n return {\n selectorLabel,\n coordinateDatum: matches[0],\n matchedDatum: matches[0],\n value: normalizeDifferenceValue(matches[0][valueField], selectorLabel, valueField),\n }\n }\n const stackGroups = new Map<string, Datum>()\n\n matches.forEach((datum) => {\n const stackGroupDatum = buildStackGroupDatum(datum, bandFields)\n stackGroups.set(JSON.stringify(stackGroupDatum), stackGroupDatum)\n })\n\n if (stackGroups.size !== 1) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack group, got ${stackGroups.size}`,\n )\n }\n\n const stackGroupDatum = Array.from(stackGroups.values())[0]\n const groupRows = dataset.filter((datum) => isSubset(stackGroupDatum, datum))\n const groupValues = groupRows.map((datum) => normalizeDifferenceValue(datum[valueField], selectorLabel, valueField))\n\n if (hasMixedSigns(groupValues)) {\n throw new Error('annotationDifferenceLine does not support mixed-sign stack totals in v1')\n }\n\n return {\n selectorLabel,\n coordinateDatum: stackGroupDatum,\n matchedDatum: matches[0],\n stackGroupDatum,\n value: groupValues.reduce((sum, value) => sum + value, 0),\n }\n}\n\nexport const getStackRuntimeTotal = (runtimeMatches: Datum[]) => {\n const stackEndValues = runtimeMatches.map((datum) => Number(datum.__VCHART_STACK_END))\n\n if (stackEndValues.some((value) => Number.isNaN(value))) {\n return undefined\n }\n\n if (hasMixedSigns(stackEndValues)) {\n throw new Error('annotationDifferenceLine does not support mixed-sign runtime stack totals in v1')\n }\n\n return stackEndValues.some((value) => value < 0) ? Math.min(...stackEndValues) : Math.max(...stackEndValues)\n}\n\nexport const buildDifferenceCoordinateDatum = (options: {\n anchor: ResolvedDifferenceAnchor\n seriesData: Datum[]\n relativeSeries: ICartesianSeries\n}) => {\n const { anchor, seriesData, relativeSeries } = options\n\n if (!anchor.stackGroupDatum) {\n const runtimeMatches = anchor.matchedDatum\n ? seriesData.filter((datum) => isSubset(anchor.matchedDatum as Datum, datum))\n : []\n\n return runtimeMatches[0] ?? anchor.coordinateDatum\n }\n\n const runtimeMatches = seriesData.filter((datum) => isSubset(anchor.stackGroupDatum as Datum, datum))\n const runtimeStackTotal = getStackRuntimeTotal(runtimeMatches)\n\n return {\n ...(runtimeMatches[0] ?? anchor.coordinateDatum),\n [relativeSeries.getStackValueField()]: runtimeStackTotal ?? anchor.value,\n }\n}\n\nexport const buildDifferenceText = (\n startValue: number,\n endValue: number,\n differenceType: 'absolute' | 'percent' = 'absolute',\n) => {\n if (differenceType === 'percent') {\n if (startValue === 0) {\n throw new Error('annotationDifferenceLine percent difference cannot be computed because start value is 0')\n }\n\n return `${(((endValue - startValue) / startValue) * 100).toFixed(0)}%`\n }\n\n return `${endValue - startValue}`\n}\n\nexport const inferDifferenceConnectDirection = (vseed: VSeed, values: [number, number]) => {\n const isNegativeSide = values.every((value) => value < 0)\n\n if (isBarLikeChart(vseed)) {\n return isNegativeSide ? 'left' : 'right'\n }\n\n return isNegativeSide ? 'bottom' : 'top'\n}\n"],"names":["toArray","value","Array","getDifferenceBandFields","spec","getDifferenceValueField","valueField","Error","normalizeDifferenceValue","selectorLabel","field","numberValue","Number","buildStackGroupDatum","datum","bandFields","Object","buildFallbackSelectorDatum","selectorValue","selectorList","fallbackDatum","currentSelector","isValueSelector","isFieldSelector","isMeasureSelector","operator","selectorValues","isDimensionSelector","isPartialDatumSelector","undefined","inferFallbackValue","numericCandidateKeys","key","resolveFallbackAnchor","options","inferredValue","coordinateDatum","hasMixedSigns","values","nonZeroValues","isDifferenceLineStacked","vseed","advancedVSeed","hasMultipleMeasureInSingleView","resolveDifferenceAnchor","dataset","isStacked","matches","selector","stackGroups","Map","stackGroupDatum","JSON","groupRows","isSubset","groupValues","sum","getStackRuntimeTotal","runtimeMatches","stackEndValues","Math","buildDifferenceCoordinateDatum","anchor","seriesData","relativeSeries","runtimeStackTotal","buildDifferenceText","startValue","endValue","differenceType","inferDifferenceConnectDirection","isNegativeSide","isBarLikeChart"],"mappings":";;;AAuBA,MAAMA,UAAU,CAAIC;IAClB,IAAIC,MAAM,OAAO,CAACD,QAChB,OAAOA;IAGT,OAAOA,QAAAA,QAAwC,EAAE,GAAG;QAACA;KAAM;AAC7D;AAEA,MAAME,0BAA0B,CAACC,OACxBJ,QAASI,AAAmB,iBAAnBA,KAAK,SAAS,GAAoBA,KAAK,MAAM,GAAGA,KAAK,MAAM;AAG7E,MAAMC,0BAA0B,CAACD;IAC/B,MAAME,aAAaN,QAChBI,AAAmB,iBAAnBA,KAAK,SAAS,GAAoBA,KAAK,MAAM,GAAGA,KAAK,MAAM,CAC7D,CAAC,EAAE;IAEJ,IAAI,CAACE,YACH,MAAM,IAAIC,MAAM;IAGlB,OAAOD;AACT;AAEA,MAAME,2BAA2B,CAACP,OAAgBQ,eAAwCC;IACxF,MAAMC,cAAcC,OAAOX;IAE3B,IAAIW,OAAO,KAAK,CAACD,cACf,MAAM,IAAIJ,MACR,CAAC,yBAAyB,EAAEE,cAAc,oDAAoD,EAAEC,MAAM,CAAC,CAAC;IAI5G,OAAOC;AACT;AAEA,MAAME,uBAAuB,CAACC,OAAcC,aACnCC,OAAO,WAAW,CAACD,WAAW,GAAG,CAAC,CAACL,QAAU;YAACA;YAAOI,KAAK,CAACJ,MAAM;SAAC;AAG3E,MAAMO,6BAA6B,CAACC;IAClC,MAAMC,eAAejB,MAAM,OAAO,CAACgB,iBAAiBA,gBAAgB;QAACA;KAAc;IACnF,MAAME,gBAAuB,CAAC;IAE9B,KAAK,MAAMC,mBAAmBF,aAAc;QAC1C,IAAIG,gBAAgBD,oBAAoBE,gBAAgBF,kBACtD;QAGF,IAAIG,kBAAkBH,kBAAkB;YACtC,MAAMI,WAAWJ,gBAAgB,QAAQ,IAAIA,gBAAgB,EAAE;YAC/D,MAAMK,iBAAiBxB,MAAM,OAAO,CAACmB,gBAAgB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KAAK2D,KAAK,GAAG,IAAID,kBAAkBC,KAAK,GAAG,IAAID;AAC/F;AAEO,MAAME,iCAAiC,CAAC3B;IAK7C,MAAM,EAAE4B,MAAM,EAAEC,UAAU,EAAEC,cAAc,EAAE,GAAG9B;IAE/C,IAAI,CAAC4B,OAAO,eAAe,EAAE;QAC3B,MAAMJ,iBAAiBI,OAAO,YAAY,GACtCC,WAAW,MAAM,CAAC,CAACjD,QAAUwC,SAASQ,OAAO,YAAY,EAAWhD,UACpE,EAAE;QAEN,OAAO4C,cAAc,CAAC,EAAE,IAAII,OAAO,eAAe;IACpD;IAEA,MAAMJ,iBAAiBK,WAAW,MAAM,CAAC,CAACjD,QAAUwC,SAASQ,OAAO,eAAe,EAAWhD;IAC9F,MAAMmD,oBAAoBR,qBAAqBC;IAE/C,OAAO;QACL,GAAIA,cAAc,CAAC,EAAE,IAAII,OAAO,eAAe;QAC/C,CAACE,eAAe,kBAAkB,GAAG,EAAEC,qBAAqBH,OAAO,KAAK;IAC1E;AACF;AAEO,MAAMI,sBAAsB,CACjCC,YACAC,UACAC,iBAAyC,UAAU;IAEnD,IAAIA,AAAmB,cAAnBA,gBAA8B;QAChC,IAAIF,AAAe,MAAfA,YACF,MAAM,IAAI5D,MAAM;QAGlB,OAAO,GAAI,AAAE6D,CAAAA,CAAAA,WAAWD,UAAS,IAAKA,aAAc,GAAE,EAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACxE;IAEA,OAAO,GAAGC,WAAWD,YAAY;AACnC;AAEO,MAAMG,kCAAkC,CAAC7B,OAAcH;IAC5D,MAAMiC,iBAAiBjC,OAAO,KAAK,CAAC,CAACrC,QAAUA,QAAQ;IAEvD,IAAIuE,eAAe/B,QACjB,OAAO8B,iBAAiB,SAAS;IAGnC,OAAOA,iBAAiB,WAAW;AACrC"}
|
|
1
|
+
{"version":3,"file":"pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.js","sources":["../../../../../../../src/pipeline/spec/chart/pipes/annotation/annotationDifferenceLineCommon.ts"],"sourcesContent":["import type { IAreaChartSpec, IBarChartSpec, ICartesianSeries, ILineChartSpec } from '@visactor/vchart'\nimport {\n isDimensionSelector,\n isFieldSelector,\n isMeasureSelector,\n isPartialDatumSelector,\n isValueSelector,\n selector,\n} from '../../../../../dataSelector'\nimport { hasMultipleMeasureInSingleView, isBarLikeChart } from 'src/pipeline/utils'\nimport type { AdvancedVSeed, Datum, Selector, Selectors, VSeed } from 'src/types'\nimport { isSubset } from './utils'\n\ntype DifferenceSelectorLabel = 'start' | 'end'\ntype DifferenceChartSpec = IBarChartSpec | ILineChartSpec | IAreaChartSpec\nexport type DifferenceStackResolveMode = 'none' | 'stackTotal' | 'auto'\nexport type DifferenceAnchorMode = 'element' | 'stackTotal'\n\nexport type ResolvedDifferenceAnchor = {\n mode: DifferenceAnchorMode\n selectorLabel: DifferenceSelectorLabel\n coordinateDatum: Datum\n matchedDatum?: Datum\n stackGroupDatum?: Datum\n bandDatum: Datum\n bandIndex?: number\n value: number\n}\n\nconst STACK_END_FIELD = '__VCHART_STACK_END'\n\nconst toArray = <T>(value: T | T[] | undefined | null): T[] => {\n if (Array.isArray(value)) {\n return value\n }\n\n return value === undefined || value === null ? [] : [value]\n}\n\nconst getDifferenceBandFields = (spec: DifferenceChartSpec): string[] => {\n return toArray((spec.direction === 'horizontal' ? spec.yField : spec.xField) as string | string[] | undefined)\n}\n\nconst getDifferenceValueField = (spec: DifferenceChartSpec): string => {\n const valueField = toArray(\n (spec.direction === 'horizontal' ? spec.xField : spec.yField) as string | string[] | undefined,\n )[0]\n\n if (!valueField) {\n throw new Error('annotationDifferenceLine requires a value field in the target chart spec')\n }\n\n return valueField\n}\n\nconst normalizeDifferenceValue = (value: unknown, selectorLabel: DifferenceSelectorLabel, field: string): number => {\n const numberValue = Number(value)\n\n if (Number.isNaN(numberValue)) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector resolved to a non-numeric value on field \"${field}\"`,\n )\n }\n\n return numberValue\n}\n\nconst buildStackGroupDatum = (datum: Datum, bandFields: string[]) => {\n return Object.fromEntries(bandFields.map((field) => [field, datum[field]])) as Datum\n}\n\nconst resolveBandIndex = (dataset: Datum[], bandDatum: Datum) => {\n const bandIndex = dataset.findIndex((datum) => isSubset(bandDatum, datum))\n\n return bandIndex >= 0 ? bandIndex : undefined\n}\n\nconst buildFallbackSelectorDatum = (selectorValue: Selector | Selectors): Datum | undefined => {\n const selectorList = Array.isArray(selectorValue) ? selectorValue : [selectorValue]\n const fallbackDatum: Datum = {}\n\n for (const currentSelector of selectorList) {\n if (isValueSelector(currentSelector) || isFieldSelector(currentSelector)) {\n return undefined\n }\n\n if (isMeasureSelector(currentSelector)) {\n const operator = currentSelector.operator || currentSelector.op\n const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [currentSelector.value]\n\n if (!['=', '=='].includes(operator as string) || selectorValues.length !== 1) {\n return undefined\n }\n\n fallbackDatum[currentSelector.field] = selectorValues[0]\n continue\n }\n\n if (isDimensionSelector(currentSelector)) {\n const operator = currentSelector.operator || currentSelector.op\n const selectorValues = Array.isArray(currentSelector.value) ? currentSelector.value : [currentSelector.value]\n\n if (operator !== 'in' || selectorValues.length !== 1) {\n return undefined\n }\n\n fallbackDatum[currentSelector.field] = selectorValues[0]\n continue\n }\n\n if (isPartialDatumSelector(currentSelector)) {\n Object.assign(fallbackDatum, currentSelector)\n continue\n }\n\n return undefined\n }\n\n return Object.keys(fallbackDatum).length > 0 ? fallbackDatum : undefined\n}\n\nconst inferFallbackValue = (fallbackDatum: Datum, valueField: string, bandFields: string[]) => {\n if (valueField in fallbackDatum) {\n return fallbackDatum[valueField]\n }\n\n const numericCandidateKeys = Object.keys(fallbackDatum).filter((key) => {\n if (key === valueField || bandFields.includes(key)) {\n return false\n }\n\n return typeof fallbackDatum[key] === 'number'\n })\n\n if (numericCandidateKeys.length !== 1) {\n return undefined\n }\n\n return fallbackDatum[numericCandidateKeys[0]]\n}\n\nconst resolveFallbackAnchor = (options: {\n dataset: Datum[]\n selectorLabel: DifferenceSelectorLabel\n selectorValue: Selector | Selectors\n valueField: string\n bandFields: string[]\n}): ResolvedDifferenceAnchor | undefined => {\n const { dataset, selectorLabel, selectorValue, valueField, bandFields } = options\n const fallbackDatum = buildFallbackSelectorDatum(selectorValue)\n\n if (!fallbackDatum) {\n return undefined\n }\n\n const inferredValue = inferFallbackValue(fallbackDatum, valueField, bandFields)\n\n if (inferredValue === undefined) {\n return undefined\n }\n\n const coordinateDatum = {\n ...fallbackDatum,\n [valueField]: inferredValue,\n }\n const bandDatum = buildStackGroupDatum(coordinateDatum, bandFields)\n\n try {\n return {\n mode: 'element',\n selectorLabel,\n coordinateDatum,\n matchedDatum: fallbackDatum,\n bandDatum,\n bandIndex: resolveBandIndex(dataset, bandDatum),\n value: normalizeDifferenceValue(inferredValue, selectorLabel, valueField),\n }\n } catch {\n return undefined\n }\n}\n\nconst hasMixedSigns = (values: number[]) => {\n const nonZeroValues = values.filter((value) => value !== 0)\n\n return nonZeroValues.some((value) => value > 0) && nonZeroValues.some((value) => value < 0)\n}\n\nexport const getDifferenceLineStackResolveMode = (\n vseed: VSeed,\n advancedVSeed: AdvancedVSeed,\n): DifferenceStackResolveMode => {\n const hasMultipleMeasure = hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? [])\n\n if (!hasMultipleMeasure) {\n return 'none'\n }\n\n if (vseed.chartType === 'column') {\n return 'auto'\n }\n\n if (vseed.chartType === 'bar') {\n return 'auto'\n }\n\n return 'none'\n}\n\nexport const usesDifferenceLineElementStackEnd = (vseed: VSeed, advancedVSeed: AdvancedVSeed) => {\n return vseed.chartType === 'area' && hasMultipleMeasureInSingleView(advancedVSeed.reshapeMeasures ?? [])\n}\n\nexport const resolveDifferenceAnchor = (options: {\n dataset: Datum[]\n selectorLabel: DifferenceSelectorLabel\n selectorValue: Selector | Selectors\n spec: DifferenceChartSpec\n stackResolveMode: DifferenceStackResolveMode\n allowSelectorFallback?: boolean\n}): ResolvedDifferenceAnchor | undefined => {\n const { dataset, selectorLabel, selectorValue, spec, stackResolveMode, allowSelectorFallback = true } = options\n const matches = dataset.filter((datum) => selector(datum, selectorValue))\n const valueField = getDifferenceValueField(spec)\n const bandFields = getDifferenceBandFields(spec)\n\n if (matches.length === 0) {\n return stackResolveMode === 'none' && allowSelectorFallback\n ? resolveFallbackAnchor({ dataset, selectorLabel, selectorValue, valueField, bandFields })\n : undefined\n }\n\n if (stackResolveMode === 'none' || (stackResolveMode === 'auto' && matches.length === 1)) {\n if (matches.length !== 1) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one datum, got ${matches.length}`,\n )\n }\n\n const bandDatum = buildStackGroupDatum(matches[0], bandFields)\n\n return {\n mode: 'element',\n selectorLabel,\n coordinateDatum: matches[0],\n matchedDatum: matches[0],\n bandDatum,\n bandIndex: resolveBandIndex(dataset, bandDatum),\n value: normalizeDifferenceValue(matches[0][valueField], selectorLabel, valueField),\n }\n }\n const stackGroups = new Map<string, Datum>()\n\n matches.forEach((datum) => {\n const stackGroupDatum = buildStackGroupDatum(datum, bandFields)\n stackGroups.set(JSON.stringify(stackGroupDatum), stackGroupDatum)\n })\n\n if (stackGroups.size !== 1) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack group, got ${stackGroups.size}`,\n )\n }\n\n const stackGroupDatum = Array.from(stackGroups.values())[0]\n const groupRows = dataset.filter((datum) => isSubset(stackGroupDatum, datum))\n\n if (stackResolveMode === 'auto' && groupRows.length !== matches.length) {\n throw new Error(\n `annotationDifferenceLine ${selectorLabel} selector must resolve to exactly one stack element or one full stack group`,\n )\n }\n const groupValues = groupRows.map((datum) => normalizeDifferenceValue(datum[valueField], selectorLabel, valueField))\n\n if (hasMixedSigns(groupValues)) {\n throw new Error('annotationDifferenceLine does not support mixed-sign stack totals in v1')\n }\n\n return {\n mode: 'stackTotal',\n selectorLabel,\n coordinateDatum: stackGroupDatum,\n matchedDatum: matches[0],\n stackGroupDatum,\n bandDatum: stackGroupDatum,\n bandIndex: resolveBandIndex(dataset, stackGroupDatum),\n value: groupValues.reduce((sum, value) => sum + value, 0),\n }\n}\n\nexport const getStackRuntimeTotal = (runtimeMatches: Datum[]) => {\n const stackEndValues = runtimeMatches.map((datum) => Number(datum[STACK_END_FIELD]))\n\n if (stackEndValues.some((value) => Number.isNaN(value))) {\n return undefined\n }\n\n if (hasMixedSigns(stackEndValues)) {\n throw new Error('annotationDifferenceLine does not support mixed-sign runtime stack totals in v1')\n }\n\n return stackEndValues.some((value) => value < 0) ? Math.min(...stackEndValues) : Math.max(...stackEndValues)\n}\n\nexport const buildDifferenceCoordinateDatum = (options: {\n anchor: ResolvedDifferenceAnchor\n seriesData: Datum[]\n relativeSeries: ICartesianSeries\n useElementStackEnd?: boolean\n}) => {\n const { anchor, seriesData, relativeSeries, useElementStackEnd = false } = options\n\n if (!anchor.stackGroupDatum) {\n const runtimeMatches = anchor.matchedDatum\n ? seriesData.filter((datum) => isSubset(anchor.matchedDatum as Datum, datum))\n : []\n\n if (!useElementStackEnd) {\n return runtimeMatches[0] ?? anchor.coordinateDatum\n }\n\n const runtimeMatch = runtimeMatches[0]\n const runtimeStackEnd = Number(runtimeMatch?.[STACK_END_FIELD])\n\n return {\n ...(runtimeMatch ?? anchor.coordinateDatum),\n [relativeSeries.getStackValueField()]: Number.isNaN(runtimeStackEnd) ? anchor.value : runtimeStackEnd,\n }\n }\n\n const runtimeMatches = seriesData.filter((datum) => isSubset(anchor.stackGroupDatum as Datum, datum))\n const runtimeStackTotal = getStackRuntimeTotal(runtimeMatches)\n\n return {\n ...(runtimeMatches[0] ?? anchor.coordinateDatum),\n [relativeSeries.getStackValueField()]: runtimeStackTotal ?? anchor.value,\n }\n}\n\nexport const getRuntimeDifferenceValue = (options: {\n anchor: ResolvedDifferenceAnchor\n seriesData: Datum[]\n useElementStackEnd?: boolean\n}) => {\n const { anchor, seriesData, useElementStackEnd = false } = options\n\n if (anchor.stackGroupDatum) {\n const runtimeMatches = seriesData.filter((datum) => isSubset(anchor.stackGroupDatum as Datum, datum))\n return getStackRuntimeTotal(runtimeMatches) ?? anchor.value\n }\n\n if (!useElementStackEnd || !anchor.matchedDatum) {\n return anchor.value\n }\n\n const runtimeMatch = seriesData.find((datum) => isSubset(anchor.matchedDatum as Datum, datum))\n const runtimeStackEnd = Number(runtimeMatch?.[STACK_END_FIELD])\n\n return Number.isNaN(runtimeStackEnd) ? anchor.value : runtimeStackEnd\n}\n\nexport const buildDifferenceText = (\n startValue: number,\n endValue: number,\n differenceType: 'absolute' | 'percent' = 'absolute',\n) => {\n if (differenceType === 'percent') {\n if (startValue === 0) {\n throw new Error('annotationDifferenceLine percent difference cannot be computed because start value is 0')\n }\n\n return `${(((endValue - startValue) / startValue) * 100).toFixed(0)}%`\n }\n\n return `${endValue - startValue}`\n}\n\nexport const inferDifferenceConnectDirection = (vseed: VSeed, values: [number, number]) => {\n const isNegativeSide = values.every((value) => value < 0)\n\n if (isBarLikeChart(vseed)) {\n return isNegativeSide ? 'left' : 'right'\n }\n\n return isNegativeSide ? 'bottom' : 'top'\n}\n\nexport const inferDifferenceBracketDirection = (\n start: ResolvedDifferenceAnchor,\n end: ResolvedDifferenceAnchor,\n): 'left' | 'right' => {\n if (start.bandIndex === undefined || end.bandIndex === undefined) {\n return 'right'\n }\n\n return start.bandIndex <= end.bandIndex ? 'right' : 'left'\n}\n"],"names":["STACK_END_FIELD","toArray","value","Array","getDifferenceBandFields","spec","getDifferenceValueField","valueField","Error","normalizeDifferenceValue","selectorLabel","field","numberValue","Number","buildStackGroupDatum","datum","bandFields","Object","resolveBandIndex","dataset","bandDatum","bandIndex","isSubset","undefined","buildFallbackSelectorDatum","selectorValue","selectorList","fallbackDatum","currentSelector","isValueSelector","isFieldSelector","isMeasureSelector","operator","selectorValues","isDimensionSelector","isPartialDatumSelector","inferFallbackValue","numericCandidateKeys","key","resolveFallbackAnchor","options","inferredValue","coordinateDatum","hasMixedSigns","values","nonZeroValues","getDifferenceLineStackResolveMode","vseed","advancedVSeed","hasMultipleMeasure","hasMultipleMeasureInSingleView","usesDifferenceLineElementStackEnd","resolveDifferenceAnchor","stackResolveMode","allowSelectorFallback","matches","selector","stackGroups","Map","stackGroupDatum","JSON","groupRows","groupValues","sum","getStackRuntimeTotal","runtimeMatches","stackEndValues","Math","buildDifferenceCoordinateDatum","anchor","seriesData","relativeSeries","useElementStackEnd","runtimeMatch","runtimeStackEnd","runtimeStackTotal","getRuntimeDifferenceValue","buildDifferenceText","startValue","endValue","differenceType","inferDifferenceConnectDirection","isNegativeSide","isBarLikeChart","inferDifferenceBracketDirection","start","end"],"mappings":";;;AA6BA,MAAMA,kBAAkB;AAExB,MAAMC,UAAU,CAAIC;IAClB,IAAIC,MAAM,OAAO,CAACD,QAChB,OAAOA;IAGT,OAAOA,QAAAA,QAAwC,EAAE,GAAG;QAACA;KAAM;AAC7D;AAEA,MAAME,0BAA0B,CAACC,OACxBJ,QAASI,AAAmB,iBAAnBA,KAAK,SAAS,GAAoBA,KAAK,MAAM,GAAGA,KAAK,MAAM;AAG7E,MAAMC,0BAA0B,CAACD;IAC/B,MAAME,aAAaN,QAChBI,AAAmB,iBAAnBA,KAAK,SAAS,GAAoBA,KAAK,MAAM,GAAGA,KAAK,MAAM,CAC7D,CAAC,EAAE;IAEJ,IAAI,CAACE,YACH,MAAM,IAAIC,MAAM;IAGlB,OAAOD;AACT;AAEA,MAAME,2BAA2B,CAACP,OAAgBQ,eAAwCC;IACxF,MAAMC,cAAcC,OAAOX;IAE3B,IAAIW,OAAO,KAAK,CAACD,cACf,MAAM,IAAIJ,MACR,CAAC,yBAAyB,EAAEE,cAAc,oDAAoD,EAAEC,MAAM,CAAC,CAAC;IAI5G,OAAOC;AACT;AAEA,MAAME,uBAAuB,CAACC,OAAcC,aACnCC,OAAO,WAAW,CAACD,WAAW,GAAG,CAAC,CAACL,QAAU;YAACA;YAAOI,KAAK,CAACJ,MAAM;SAAC;AAG3E,MAAMO,mB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