@antv/g2 5.4.1 → 5.4.2

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.
Files changed (98) hide show
  1. package/dist/g2.lite.min.js +10 -10
  2. package/dist/g2.min.js +10 -10
  3. package/esm/component/constant.d.ts +1 -0
  4. package/esm/component/constant.js +8 -0
  5. package/esm/component/constant.js.map +1 -1
  6. package/esm/component/slider.js +3 -1
  7. package/esm/component/slider.js.map +1 -1
  8. package/esm/composition/view.js +4 -4
  9. package/esm/composition/view.js.map +1 -1
  10. package/esm/index.d.ts +2 -0
  11. package/esm/interaction/adaptiveFilter.d.ts +147 -0
  12. package/esm/interaction/adaptiveFilter.js +305 -0
  13. package/esm/interaction/adaptiveFilter.js.map +1 -0
  14. package/esm/interaction/legendFilter.js +4 -0
  15. package/esm/interaction/legendFilter.js.map +1 -1
  16. package/esm/interaction/sliderFilter.d.ts +2 -1
  17. package/esm/interaction/sliderFilter.js +400 -42
  18. package/esm/interaction/sliderFilter.js.map +1 -1
  19. package/esm/interaction/sliderWheel.d.ts +0 -3
  20. package/esm/interaction/sliderWheel.js +91 -10
  21. package/esm/interaction/sliderWheel.js.map +1 -1
  22. package/esm/interaction/tooltip.d.ts +2 -2
  23. package/esm/interaction/tooltip.js +32 -8
  24. package/esm/interaction/tooltip.js.map +1 -1
  25. package/esm/interaction/utils.d.ts +69 -0
  26. package/esm/interaction/utils.js +201 -0
  27. package/esm/interaction/utils.js.map +1 -1
  28. package/esm/lib/core.d.ts +1 -0
  29. package/esm/lib/core.js +2 -1
  30. package/esm/lib/core.js.map +1 -1
  31. package/esm/lib/std.d.ts +1 -0
  32. package/esm/mark/beeswarm.d.ts +7 -0
  33. package/esm/mark/beeswarm.js +98 -0
  34. package/esm/mark/beeswarm.js.map +1 -0
  35. package/esm/mark/index.d.ts +2 -0
  36. package/esm/mark/index.js +1 -0
  37. package/esm/mark/index.js.map +1 -1
  38. package/esm/runtime/layout.js +35 -4
  39. package/esm/runtime/layout.js.map +1 -1
  40. package/esm/runtime/render.js +1 -0
  41. package/esm/runtime/render.js.map +1 -1
  42. package/esm/spec/interaction.d.ts +7 -0
  43. package/lib/component/constant.d.ts +1 -0
  44. package/lib/component/constant.js +9 -1
  45. package/lib/component/constant.js.map +1 -1
  46. package/lib/component/slider.js +3 -1
  47. package/lib/component/slider.js.map +1 -1
  48. package/lib/composition/view.js +4 -4
  49. package/lib/composition/view.js.map +1 -1
  50. package/lib/index.d.ts +2 -0
  51. package/lib/interaction/adaptiveFilter.d.ts +147 -0
  52. package/lib/interaction/adaptiveFilter.js +315 -0
  53. package/lib/interaction/adaptiveFilter.js.map +1 -0
  54. package/lib/interaction/legendFilter.js +4 -0
  55. package/lib/interaction/legendFilter.js.map +1 -1
  56. package/lib/interaction/sliderFilter.d.ts +2 -1
  57. package/lib/interaction/sliderFilter.js +399 -41
  58. package/lib/interaction/sliderFilter.js.map +1 -1
  59. package/lib/interaction/sliderWheel.d.ts +0 -3
  60. package/lib/interaction/sliderWheel.js +91 -10
  61. package/lib/interaction/sliderWheel.js.map +1 -1
  62. package/lib/interaction/tooltip.d.ts +2 -2
  63. package/lib/interaction/tooltip.js +32 -8
  64. package/lib/interaction/tooltip.js.map +1 -1
  65. package/lib/interaction/utils.d.ts +69 -0
  66. package/lib/interaction/utils.js +207 -1
  67. package/lib/interaction/utils.js.map +1 -1
  68. package/lib/lib/core.d.ts +1 -0
  69. package/lib/lib/core.js +1 -0
  70. package/lib/lib/core.js.map +1 -1
  71. package/lib/lib/std.d.ts +1 -0
  72. package/lib/mark/beeswarm.d.ts +7 -0
  73. package/lib/mark/beeswarm.js +102 -0
  74. package/lib/mark/beeswarm.js.map +1 -0
  75. package/lib/mark/index.d.ts +2 -0
  76. package/lib/mark/index.js +3 -1
  77. package/lib/mark/index.js.map +1 -1
  78. package/lib/runtime/layout.js +41 -10
  79. package/lib/runtime/layout.js.map +1 -1
  80. package/lib/runtime/render.js +1 -0
  81. package/lib/runtime/render.js.map +1 -1
  82. package/lib/spec/interaction.d.ts +7 -0
  83. package/package.json +3 -3
  84. package/src/component/constant.ts +9 -0
  85. package/src/component/slider.ts +6 -1
  86. package/src/composition/view.ts +4 -1
  87. package/src/interaction/adaptiveFilter.ts +517 -0
  88. package/src/interaction/legendFilter.ts +4 -0
  89. package/src/interaction/sliderFilter.ts +762 -72
  90. package/src/interaction/sliderWheel.ts +109 -10
  91. package/src/interaction/tooltip.ts +33 -8
  92. package/src/interaction/utils.ts +261 -0
  93. package/src/lib/core.ts +2 -0
  94. package/src/mark/beeswarm.ts +150 -0
  95. package/src/mark/index.ts +2 -0
  96. package/src/runtime/layout.ts +46 -3
  97. package/src/runtime/render.ts +1 -0
  98. package/src/spec/interaction.ts +7 -0
@@ -0,0 +1,517 @@
1
+ import { isOrdinalScale } from '../utils/scale';
2
+ import { isFalsyValue } from './utils';
3
+
4
+ /**
5
+ * Runtime scale interface for adaptive filtering operations.
6
+ * Represents the actual scale instance available at runtime.
7
+ */
8
+ export interface RuntimeScale {
9
+ getOptions(): {
10
+ domain: unknown[];
11
+ range?: [number, number];
12
+ ratio?: number;
13
+ };
14
+ map(value: unknown): number;
15
+ invert(value: number): unknown;
16
+ getBandWidth?: (value?: unknown) => number;
17
+ getStep?: (value?: unknown) => number;
18
+ }
19
+
20
+ /**
21
+ * Adaptive filter mode configuration.
22
+ */
23
+ export type AdaptiveFilterMode =
24
+ | 'filter' // Enable adaptive filtering with data window filtering
25
+ | false // Disable adaptive filtering
26
+ | null; // Disable adaptive filtering
27
+
28
+ /**
29
+ * Mark data structure for adaptive filtering.
30
+ * Contains mark identifier and associated channel data.
31
+ */
32
+ export interface MarkDataPair {
33
+ markKey: string;
34
+ channelData: { [key: string]: unknown[] };
35
+ }
36
+
37
+ /**
38
+ * Scale information for single-axis adaptive filtering.
39
+ */
40
+ export interface SingleAxisScaleInfo {
41
+ currentScale: RuntimeScale;
42
+ targetScale: RuntimeScale;
43
+ isSourceDiscrete: boolean;
44
+ isTargetDiscrete: boolean;
45
+ shouldPreserveZeroBaseline: boolean;
46
+ }
47
+
48
+ /**
49
+ * Scale information for multi-axis adaptive filtering.
50
+ */
51
+ export interface MultiAxisScaleInfo {
52
+ currentScale: RuntimeScale;
53
+ targetScales: RuntimeScale[];
54
+ isSourceDiscrete: boolean;
55
+ isTargetDiscrete: boolean[];
56
+ shouldPreserveZeroBaseline: boolean[];
57
+ targetScaleKeys: string[];
58
+ }
59
+
60
+ /**
61
+ * Parameters for single-axis adaptive filtering operations.
62
+ */
63
+ export interface SingleAxisFilteringParams {
64
+ markDataPairs: MarkDataPair[];
65
+ domain: unknown[];
66
+ scaleInfo: SingleAxisScaleInfo;
67
+ adaptiveMode: AdaptiveFilterMode;
68
+ shouldFilterXAxis?: boolean;
69
+ }
70
+
71
+ /**
72
+ * Parameters for multi-axis adaptive filtering operations.
73
+ */
74
+ export interface MultiAxisFilteringParams {
75
+ markDataPairs: MarkDataPair[];
76
+ domain: unknown[];
77
+ scaleInfo: MultiAxisScaleInfo;
78
+ markToScaleMap: Map<string, string>;
79
+ adaptiveMode: AdaptiveFilterMode;
80
+ isViewSlider: boolean;
81
+ shouldFilterXAxis?: boolean;
82
+ }
83
+
84
+ /**
85
+ * Options for calculating filtered domain values.
86
+ */
87
+ interface CalculateFilteredDomainOptions {
88
+ isTargetDiscrete: boolean;
89
+ filteredValues: number[];
90
+ shouldPreserveZeroBaseline: boolean;
91
+ }
92
+
93
+ /**
94
+ * Extracts scale information for single-axis adaptive filtering.
95
+ *
96
+ * @param shouldFilterXAxis - Whether to adapt X-axis (true) or Y-axis (false)
97
+ * @param scaleX - X-axis scale instance
98
+ * @param scaleY - Y-axis scale instance
99
+ * @returns Scale information required for single-axis filtering
100
+ */
101
+ export function extractSingleAxisScaleInfo(
102
+ shouldFilterXAxis: boolean,
103
+ scaleX: RuntimeScale,
104
+ scaleY: RuntimeScale,
105
+ ): SingleAxisScaleInfo {
106
+ const currentScale = shouldFilterXAxis ? scaleY : scaleX;
107
+ const targetScale = shouldFilterXAxis ? scaleX : scaleY;
108
+ const isSourceDiscrete = isOrdinalScale(currentScale);
109
+ const isTargetDiscrete = isOrdinalScale(targetScale);
110
+
111
+ const targetOriginalDomain = targetScale.getOptions().domain;
112
+ const shouldPreserveZeroBaseline =
113
+ !isTargetDiscrete &&
114
+ targetOriginalDomain &&
115
+ targetOriginalDomain.length >= 2 &&
116
+ targetOriginalDomain[0] === 0;
117
+
118
+ return {
119
+ currentScale,
120
+ targetScale,
121
+ isSourceDiscrete,
122
+ isTargetDiscrete,
123
+ shouldPreserveZeroBaseline,
124
+ };
125
+ }
126
+
127
+ /**
128
+ * Extracts scale information for multi-axis adaptive filtering.
129
+ * Handles scenarios where multiple independent scales exist (x1, x2, y1, y2, etc.).
130
+ *
131
+ * @param shouldFilterXAxis - Whether to adapt X-axis (true) or Y-axis (false)
132
+ * @param scale - Record of all available scale instances
133
+ * @param scaleX - Primary X-axis scale instance
134
+ * @param scaleY - Primary Y-axis scale instance
135
+ * @param channelDomain - Channel domain configuration
136
+ * @returns Scale information required for multi-axis filtering
137
+ */
138
+ export function extractMultiAxisScaleInfo(
139
+ shouldFilterXAxis: boolean,
140
+ scale: Record<string, RuntimeScale>,
141
+ scaleX: RuntimeScale,
142
+ scaleY: RuntimeScale,
143
+ channelDomain: Record<string, unknown[]>,
144
+ ): MultiAxisScaleInfo {
145
+ const currentScale = shouldFilterXAxis ? scaleY : scaleX;
146
+
147
+ /**
148
+ * Retrieves scale domains for a specific axis type (x or y).
149
+ * Supports both primary axes (x, y) and numbered variants (x1, x2, y1, y2).
150
+ */
151
+ const getAxisScaleDomains = (axisType: 'x' | 'y') => {
152
+ const axisScales: Record<string, unknown[]> = {};
153
+ Object.keys(channelDomain).forEach((key) => {
154
+ if (key === axisType || key.match(new RegExp(`^${axisType}\\d+$`))) {
155
+ axisScales[key] = channelDomain[key];
156
+ }
157
+ });
158
+ return axisScales;
159
+ };
160
+
161
+ const targetScaleDomain = shouldFilterXAxis
162
+ ? getAxisScaleDomains('x')
163
+ : getAxisScaleDomains('y');
164
+ const targetScaleKeys = Object.keys(targetScaleDomain);
165
+
166
+ const targetScales = targetScaleKeys.map((item) => scale[item]);
167
+ const isSourceDiscrete = isOrdinalScale(currentScale);
168
+ const isTargetDiscrete = targetScales.map((targetScale) =>
169
+ isOrdinalScale(targetScale),
170
+ );
171
+
172
+ const shouldPreserveZeroBaseline = targetScales.map((targetScale, index) => {
173
+ const targetOriginalDomain = targetScale.getOptions().domain;
174
+ const isDiscrete = isTargetDiscrete[index];
175
+ return (
176
+ !isDiscrete &&
177
+ targetOriginalDomain &&
178
+ targetOriginalDomain.length >= 2 &&
179
+ targetOriginalDomain[0] === 0
180
+ );
181
+ });
182
+
183
+ return {
184
+ currentScale,
185
+ targetScales,
186
+ isSourceDiscrete,
187
+ isTargetDiscrete,
188
+ shouldPreserveZeroBaseline,
189
+ targetScaleKeys,
190
+ };
191
+ }
192
+
193
+ /**
194
+ * Removes duplicate values from an array and returns sorted result.
195
+ *
196
+ * @param values - Array of numeric values
197
+ * @returns Sorted array with unique values
198
+ */
199
+ function getUniqueSortedValues(values: number[]): number[] {
200
+ const uniqueValues = Array.from(new Set(values));
201
+ return uniqueValues.sort((a, b) => a - b);
202
+ }
203
+
204
+ /**
205
+ * Calculates the filtered domain based on target scale type and constraints.
206
+ *
207
+ * @param options - Configuration for domain calculation
208
+ * @returns Calculated domain array
209
+ */
210
+ function calculateFilteredDomain({
211
+ isTargetDiscrete,
212
+ filteredValues,
213
+ shouldPreserveZeroBaseline,
214
+ }: CalculateFilteredDomainOptions): unknown[] {
215
+ if (isTargetDiscrete) {
216
+ return getUniqueSortedValues(filteredValues);
217
+ } else {
218
+ const min = Math.min(...filteredValues);
219
+ const max = Math.max(...filteredValues);
220
+ return shouldPreserveZeroBaseline ? [0, max] : [min, max];
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Converts various value types to numeric for comparison.
226
+ * Handles Date objects, strings, and numbers.
227
+ */
228
+ function convertToNumeric(value: unknown): number {
229
+ if (value instanceof Date) {
230
+ return value.getTime();
231
+ }
232
+ if (typeof value === 'string') {
233
+ return parseFloat(value);
234
+ }
235
+ return Number(value);
236
+ }
237
+
238
+ /**
239
+ * Filters mark data based on domain constraints with bidirectional support.
240
+ * Supports both discrete and continuous scales with proper domain calculation.
241
+ *
242
+ * @param markDataPairs - Array of mark data with channel information
243
+ * @param domain - Domain values for filtering
244
+ * @param isSourceDiscrete - Whether the source scale is discrete
245
+ * @param isTargetDiscrete - Whether the target scale is discrete
246
+ * @param shouldPreserveZeroBaseline - Whether to preserve zero baseline for continuous scales
247
+ * @param adaptiveMode - Adaptive filtering mode configuration
248
+ * @param shouldFilterXAxis - Whether to adapt X-axis (true) or Y-axis (false)
249
+ * @returns Filtered domain array
250
+ */
251
+ export function filterMarkDataByDomain(
252
+ markDataPairs: MarkDataPair[],
253
+ domain: unknown[],
254
+ isSourceDiscrete: boolean,
255
+ isTargetDiscrete: boolean,
256
+ shouldPreserveZeroBaseline: boolean,
257
+ adaptiveMode: AdaptiveFilterMode = 'filter',
258
+ shouldFilterXAxis = false,
259
+ ): unknown[] {
260
+ if (isFalsyValue(adaptiveMode)) {
261
+ return [];
262
+ }
263
+
264
+ const sourceChannel = shouldFilterXAxis ? 'y' : 'x';
265
+ const targetChannel = shouldFilterXAxis ? 'x' : 'y';
266
+ const allFilteredTargetValues: number[] = [];
267
+
268
+ for (const markData of markDataPairs) {
269
+ const { channelData } = markData;
270
+ const sourceValues = channelData[sourceChannel] || [];
271
+ const targetValues = channelData[targetChannel] || [];
272
+
273
+ // Handle different data structures based on channel type:
274
+ // X channel: one-dimensional array [x1, x2, x3, ...]
275
+ // Y channel: two-dimensional array [[y1, y2, y3, ...]]
276
+
277
+ // Normalize source values to one-dimensional array
278
+ const normalizedSourceValues = Array.isArray(sourceValues[0])
279
+ ? sourceValues[0] // If it's 2D array (Y channel), take first sub-array
280
+ : sourceValues; // If it's 1D array (X channel), use as is
281
+
282
+ // Handle target values based on their structure
283
+ const isTargetArray2D = Array.isArray(targetValues[0]);
284
+
285
+ if (normalizedSourceValues.length === 0) continue;
286
+
287
+ const dataLength = normalizedSourceValues.length;
288
+
289
+ for (let i = 0; i < dataLength; i++) {
290
+ const sourceValue = normalizedSourceValues[i];
291
+ let shouldInclude = false;
292
+
293
+ if (isSourceDiscrete) {
294
+ shouldInclude = domain.includes(sourceValue);
295
+ } else {
296
+ // Handle both numeric and Date domains
297
+ if (domain.length >= 2) {
298
+ const sourceTime = convertToNumeric(sourceValue);
299
+ const domainStartTime = convertToNumeric(domain[0]);
300
+ const domainEndTime = convertToNumeric(domain[domain.length - 1]);
301
+
302
+ if (
303
+ !isNaN(sourceTime) &&
304
+ !isNaN(domainStartTime) &&
305
+ !isNaN(domainEndTime)
306
+ ) {
307
+ shouldInclude =
308
+ sourceTime >= domainStartTime && sourceTime <= domainEndTime;
309
+ }
310
+ }
311
+ }
312
+
313
+ if (adaptiveMode === 'filter' && shouldInclude) {
314
+ // Collect target channel values for this data point
315
+ if (isTargetArray2D) {
316
+ // Target is 2D array (Y channel)
317
+ const numChannels = targetValues.length;
318
+ for (let channelIdx = 0; channelIdx < numChannels; channelIdx++) {
319
+ const channelData = targetValues[channelIdx];
320
+ if (Array.isArray(channelData) && i < channelData.length) {
321
+ const targetValue = channelData[i];
322
+ const numericValue = convertToNumeric(targetValue);
323
+ if (!isNaN(numericValue)) {
324
+ allFilteredTargetValues.push(numericValue);
325
+ }
326
+ }
327
+ }
328
+ } else {
329
+ // Target is 1D array (X channel)
330
+ if (i < targetValues.length) {
331
+ const targetValue = targetValues[i];
332
+ const numericValue = convertToNumeric(targetValue);
333
+ if (!isNaN(numericValue)) {
334
+ allFilteredTargetValues.push(numericValue);
335
+ }
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ if (allFilteredTargetValues.length > 0) {
343
+ return calculateFilteredDomain({
344
+ isTargetDiscrete,
345
+ filteredValues: allFilteredTargetValues,
346
+ shouldPreserveZeroBaseline,
347
+ });
348
+ }
349
+
350
+ return [];
351
+ }
352
+
353
+ /**
354
+ * Processes adaptive filtering for single-axis scenarios.
355
+ *
356
+ * @param params - Single-axis filtering parameters
357
+ * @returns Filtered domain array
358
+ */
359
+ export function processSingleAxisFiltering({
360
+ markDataPairs,
361
+ domain,
362
+ scaleInfo,
363
+ adaptiveMode,
364
+ shouldFilterXAxis = false,
365
+ }: SingleAxisFilteringParams): unknown[] {
366
+ const { isSourceDiscrete, isTargetDiscrete, shouldPreserveZeroBaseline } =
367
+ scaleInfo;
368
+
369
+ return filterMarkDataByDomain(
370
+ markDataPairs,
371
+ domain,
372
+ isSourceDiscrete,
373
+ isTargetDiscrete,
374
+ shouldPreserveZeroBaseline,
375
+ adaptiveMode,
376
+ shouldFilterXAxis,
377
+ );
378
+ }
379
+
380
+ /**
381
+ * Processes multi-axis filtering for view-level sliders.
382
+ * Handles scenarios with independent scales across multiple marks.
383
+ *
384
+ * @param params - Multi-axis filtering parameters
385
+ * @returns Map of scale keys to filtered domain arrays
386
+ */
387
+ export function processMultiAxisViewFiltering({
388
+ markDataPairs,
389
+ domain,
390
+ scaleInfo,
391
+ markToScaleMap,
392
+ adaptiveMode,
393
+ shouldFilterXAxis = false,
394
+ }: MultiAxisFilteringParams): Map<string, unknown[]> {
395
+ const filteredDomain = new Map<string, unknown[]>();
396
+ const {
397
+ isSourceDiscrete,
398
+ isTargetDiscrete,
399
+ shouldPreserveZeroBaseline,
400
+ targetScaleKeys,
401
+ } = scaleInfo;
402
+
403
+ markDataPairs.forEach((markData) => {
404
+ const scaleKey = markToScaleMap.get(markData.markKey);
405
+ if (!scaleKey) return;
406
+
407
+ const scaleIndex = targetScaleKeys.indexOf(scaleKey);
408
+ if (scaleIndex === -1) return;
409
+
410
+ const currentIsTargetDiscrete = isTargetDiscrete[scaleIndex];
411
+ const currentShouldPreserveZeroBaseline =
412
+ shouldPreserveZeroBaseline[scaleIndex];
413
+
414
+ const markFilteredDomain = filterMarkDataByDomain(
415
+ [markData],
416
+ domain,
417
+ isSourceDiscrete,
418
+ currentIsTargetDiscrete,
419
+ currentShouldPreserveZeroBaseline,
420
+ adaptiveMode,
421
+ shouldFilterXAxis,
422
+ );
423
+
424
+ filteredDomain.set(scaleKey, markFilteredDomain);
425
+ });
426
+
427
+ return filteredDomain;
428
+ }
429
+
430
+ /**
431
+ * Processes multi-axis filtering for mark-level sliders.
432
+ * Uses all marks that share the same target scale key instead of just the target mark.
433
+ *
434
+ * @param markDataPairs - Array of mark data pairs
435
+ * @param domain - Domain values for filtering
436
+ * @param scaleInfo - Single-axis scale information
437
+ * @param targetMarkKey - Key of the target mark to filter
438
+ * @param targetScaleKey - Key of the target scale to update
439
+ * @param adaptiveMode - Adaptive filtering mode
440
+ * @param shouldFilterXAxis - Whether to adapt X-axis (true) or Y-axis (false)
441
+ * @param markToScaleMap - Map from mark keys to scale keys to identify shared axes
442
+ * @returns Map of scale keys to filtered domain arrays
443
+ */
444
+ export function processMultiAxisMarkFiltering(
445
+ markDataPairs: MarkDataPair[],
446
+ domain: unknown[],
447
+ scaleInfo: SingleAxisScaleInfo,
448
+ targetMarkKey: string,
449
+ targetScaleKey: string,
450
+ adaptiveMode: AdaptiveFilterMode,
451
+ shouldFilterXAxis = false,
452
+ markToScaleMap?: Map<string, string>,
453
+ ): Map<string, unknown[]> {
454
+ const filteredDomain = new Map<string, unknown[]>();
455
+
456
+ // Early return if no data to process
457
+ if (markDataPairs.length === 0 || domain.length === 0) {
458
+ return filteredDomain;
459
+ }
460
+
461
+ const { isSourceDiscrete, isTargetDiscrete, shouldPreserveZeroBaseline } =
462
+ scaleInfo;
463
+
464
+ // Find all marks that share the same target scale key
465
+ const relevantMarkData = markToScaleMap
466
+ ? markDataPairs.filter((markData) => {
467
+ const markScaleKey = markToScaleMap.get(markData.markKey);
468
+ return markScaleKey === targetScaleKey;
469
+ })
470
+ : markDataPairs.filter((markData) => markData.markKey === targetMarkKey);
471
+
472
+ // Early return if no relevant marks found
473
+ if (relevantMarkData.length === 0) {
474
+ return filteredDomain;
475
+ }
476
+
477
+ const markFilteredDomain = filterMarkDataByDomain(
478
+ relevantMarkData,
479
+ domain,
480
+ isSourceDiscrete,
481
+ isTargetDiscrete,
482
+ shouldPreserveZeroBaseline,
483
+ adaptiveMode,
484
+ shouldFilterXAxis,
485
+ );
486
+
487
+ filteredDomain.set(targetScaleKey, markFilteredDomain);
488
+ return filteredDomain;
489
+ }
490
+
491
+ /**
492
+ * Updates channel domains with filtered results.
493
+ * Supports both single-axis and multi-axis scenarios.
494
+ *
495
+ * @param channelDomain - Current channel domain configuration
496
+ * @param filteredDomain - Filtered domain values (array for single-axis, Map for multi-axis)
497
+ * @param shouldFilterXAxis - Whether X-axis is being filtered
498
+ * @param isMultiAxis - Whether this is a multi-axis scenario
499
+ */
500
+ export function updateChannelDomains(
501
+ channelDomain: Record<string, unknown[]>,
502
+ filteredDomain: unknown[] | Map<string, unknown[]>,
503
+ shouldFilterXAxis: boolean,
504
+ isMultiAxis: boolean,
505
+ ): void {
506
+ if (isMultiAxis && filteredDomain instanceof Map) {
507
+ filteredDomain.forEach((domain, scaleKey) => {
508
+ if (domain && Array.isArray(domain) && domain.length > 0) {
509
+ channelDomain[scaleKey] = domain;
510
+ }
511
+ });
512
+ } else if (!isMultiAxis && Array.isArray(filteredDomain)) {
513
+ if (filteredDomain.length > 0) {
514
+ channelDomain[shouldFilterXAxis ? 'x' : 'y'] = filteredDomain;
515
+ }
516
+ }
517
+ }
@@ -1,6 +1,7 @@
1
1
  import { DisplayObject } from '@antv/g';
2
2
  import { deepMix, throttle } from '@antv/util';
3
3
  import { subObject } from '../utils/helper';
4
+ import { ANNOTATION_MARKS } from '../component/constant';
4
5
  import { useState, setCursor, restoreCursor } from './utils';
5
6
 
6
7
  export const CATEGORY_LEGEND_CLASS_NAME = 'legend-category';
@@ -298,6 +299,9 @@ async function filterView(
298
299
  const newMarks = marks.map((mark) => {
299
300
  if (mark.type === 'legends') return mark;
300
301
 
302
+ // Skip Annotation marks.
303
+ if (ANNOTATION_MARKS.includes(mark.type)) return mark;
304
+
301
305
  // Inset after aggregate transform, such as group, and bin.
302
306
  const { transform = [], data = [] } = mark;
303
307
  const index = transform.findIndex(