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 2020/11/08 16:57:49 UTC

[incubator-echarts] 01/01: fix: [dataZoom] remove duplicated declaration (test case: test/stream-filter2.html)

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

sushuang pushed a commit to branch fix/dataZoom
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 79a5f587ced5a3a970cf63fd0669a895cef9c9b8
Author: 100pah <su...@gmail.com>
AuthorDate: Mon Nov 9 00:57:19 2020 +0800

    fix: [dataZoom] remove duplicated declaration (test case: test/stream-filter2.html)
---
 src/component/dataZoom/DataZoomModel.ts |  7 +++--
 test/dataZoom-feature.html              | 46 +++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/component/dataZoom/DataZoomModel.ts b/src/component/dataZoom/DataZoomModel.ts
index 08076e9..01b6478 100644
--- a/src/component/dataZoom/DataZoomModel.ts
+++ b/src/component/dataZoom/DataZoomModel.ts
@@ -138,8 +138,11 @@ class DataZoomAxisInfo {
     indexMap: boolean[] = [];
 
     add(axisCmptIdx: number) {
-        this.indexList.push(axisCmptIdx);
-        this.indexMap[axisCmptIdx] = true;
+        // Remove duplication.
+        if (!this.indexMap[axisCmptIdx]) {
+            this.indexList.push(axisCmptIdx);
+            this.indexMap[axisCmptIdx] = true;
+        }
     }
 }
 export type DataZoomTargetAxisInfoMap = HashMap<DataZoomAxisInfo, DataZoomAxisDimension>;
diff --git a/test/dataZoom-feature.html b/test/dataZoom-feature.html
index fd9e788..1110036 100644
--- a/test/dataZoom-feature.html
+++ b/test/dataZoom-feature.html
@@ -42,6 +42,7 @@ under the License.
         <div id="auto_axis_second_setOption_normal_dz"></div>
         <div id="specified_axis_second_setOption_normal_dz"></div>
         <div id="remove_dz"></div>
+        <div id="duplicated_dataZoom_ref"></div>
 
 
 
@@ -704,6 +705,51 @@ under the License.
 
 
 
+
+
+        <script>
+        require(['echarts'], function (echarts) {
+
+            var option = {
+                toolbox: {
+                    left: 'center',
+                    feature: {
+                        dataZoom: {}
+                    }
+                },
+                xAxis: [{
+                }],
+                yAxis: [{
+                }],
+                dataZoom: [{
+                    type: 'slider',
+                    // Duplicated declaration
+                    yAxisIndex: [0, 0]
+                }, {
+                    type: 'inside',
+                    // Duplicated declaration
+                    yAxisIndex: [0, 0]
+                }],
+                series: [{
+                    type: 'line',
+                    data: [[22, 11], [44, 33]]
+                }]
+            };
+
+            var chart = testHelper.create(echarts, 'duplicated_dataZoom_ref', {
+                title: [
+                    'Use dataZoom, should no error thrown.',
+                ],
+                option: option,
+                height: 350
+            });
+        });
+        </script>
+
+
+
+
+
     </body>
 </html>
 


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