You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2025/05/30 18:12:57 UTC

(echarts) 03/04: feat(visualMap): support specify `seriesId` on visualMap option; previously only seriesIndex can be specified, not convenient and not consistent with other components.

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch feat-matrix-enhance
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 8ddd15d320bbab70e22b0dd87d725bb5160fa1c8
Author: 100pah <su...@gmail.com>
AuthorDate: Tue May 27 04:31:04 2025 +0800

    feat(visualMap): support specify `seriesId` on visualMap option; previously only seriesIndex can be specified, not convenient and not consistent with other components.
---
 src/component/visualMap/VisualMapModel.ts | 45 ++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/component/visualMap/VisualMapModel.ts b/src/component/visualMap/VisualMapModel.ts
index 85b3162e5..74c791694 100644
--- a/src/component/visualMap/VisualMapModel.ts
+++ b/src/component/visualMap/VisualMapModel.ts
@@ -32,7 +32,8 @@ import {
     BorderOptionMixin,
     OptionDataValue,
     BuiltinVisualProperty,
-    DimensionIndex
+    DimensionIndex,
+    OptionId
 } from '../../util/types';
 import ComponentModel from '../../model/Component';
 import Model from '../../model/Model';
@@ -67,12 +68,13 @@ export interface VisualMapOption<T extends VisualOptionBase = VisualOptionBase>
     /**
      * 'all' or null/undefined: all series.
      * A number or an array of number: the specified series.
-     * set min: 0, max: 200, only for campatible with ec2.
-     * In fact min max should not have default value.
      */
     seriesIndex?: 'all' | number[] | number
+    seriesId?: OptionId | OptionId[]
 
     /**
+     * set min: 0, max: 200, only for campatible with ec2.
+     * In fact min max should not have default value.
      * min value, must specified if pieces is not specified.
      */
     min?: number
@@ -237,23 +239,30 @@ class VisualMapModel<Opts extends VisualMapOption = VisualMapOption> extends Com
     }
 
     /**
-     * @protected
-     * @return {Array.<number>} An array of series indices.
+     * @return An array of series indices.
      */
-    getTargetSeriesIndices() {
-        const optionSeriesIndex = this.option.seriesIndex;
-        let seriesIndices: number[] = [];
-
-        if (optionSeriesIndex == null || optionSeriesIndex === 'all') {
-            this.ecModel.eachSeries(function (seriesModel, index) {
-                seriesIndices.push(index);
-            });
-        }
-        else {
-            seriesIndices = modelUtil.normalizeToArray(optionSeriesIndex);
+    protected getTargetSeriesIndices(): number[] {
+        const optionSeriesId = this.option.seriesId;
+        let optionSeriesIndex = this.option.seriesIndex;
+        if (optionSeriesIndex == null && optionSeriesId == null) {
+            optionSeriesIndex = 'all';
         }
 
-        return seriesIndices;
+        const seriesModels = modelUtil.queryReferringComponents(
+            this.ecModel,
+            'series',
+            {
+                index: optionSeriesIndex,
+                id: optionSeriesId,
+            },
+            {
+                useDefault: false,
+                enableAll: true,
+                enableNone: false,
+            }
+        ).models;
+
+        return zrUtil.map(seriesModels, seriesModel => seriesModel.componentIndex);
     }
 
     /**
@@ -605,7 +614,7 @@ class VisualMapModel<Opts extends VisualMapOption = VisualMapOption> extends Com
         // zlevel: 0,
         z: 4,
 
-        seriesIndex: 'all',
+        // seriesIndex: 'all',
 
         min: 0,
         max: 200,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org