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 2018/09/10 08:41:14 UTC

[incubator-echarts] branch release updated: fix: encode: {x: -1}

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

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


The following commit(s) were added to refs/heads/release by this push:
     new 56d08c4  fix: encode: {x: -1}
56d08c4 is described below

commit 56d08c4d2afadc76efa1ec0f92aec9f0efe4e8f3
Author: sushuang <su...@gmail.com>
AuthorDate: Mon Sep 10 16:40:51 2018 +0800

    fix: encode: {x: -1}
---
 src/component/dataZoom/AxisProxy.js   |  5 ++++-
 src/data/helper/completeDimensions.js | 19 ++++++++++++++++-
 test/encode.html                      | 40 +++++++++++++++++++++++++++++++++--
 3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/src/component/dataZoom/AxisProxy.js b/src/component/dataZoom/AxisProxy.js
index 11b6535..cfadab9 100644
--- a/src/component/dataZoom/AxisProxy.js
+++ b/src/component/dataZoom/AxisProxy.js
@@ -338,11 +338,14 @@ AxisProxy.prototype = {
         // TODO
         // filterMode 'weakFilter' and 'empty' is not optimized for huge data yet.
 
-        // Process series data
         each(seriesModels, function (seriesModel) {
             var seriesData = seriesModel.getData();
             var dataDims = seriesData.mapDimension(axisDim, true);
 
+            if (!dataDims.length) {
+                return;
+            }
+
             if (filterMode === 'weakFilter') {
                 seriesData.filterSelf(function (dataIndex) {
                     var leftOut;
diff --git a/src/data/helper/completeDimensions.js b/src/data/helper/completeDimensions.js
index 3685b64..890531d 100644
--- a/src/data/helper/completeDimensions.js
+++ b/src/data/helper/completeDimensions.js
@@ -113,6 +113,15 @@ function completeDimensions(sysDims, source, opt) {
     // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
     encodeDef.each(function (dataDims, coordDim) {
         dataDims = normalizeToArray(dataDims).slice();
+
+        // Note: It is allowed that `dataDims.length` is `0`, e.g., options is
+        // `{encode: {x: -1, y: 1}}`. Should not filter anything in
+        // this case.
+        if (dataDims.length === 1 && dataDims[0] < 0) {
+            encodeDef.set(coordDim, false);
+            return;
+        }
+
         var validDataDims = encodeDef.set(coordDim, []);
         each(dataDims, function (resultDimIdx, idx) {
             // The input resultDimIdx can be dim name or index.
@@ -148,7 +157,15 @@ function completeDimensions(sysDims, source, opt) {
                 = sysDimItem.dimsDef = sysDimItem.otherDims = null;
         }
 
-        var dataDims = normalizeToArray(encodeDef.get(coordDim));
+        var dataDims = encodeDef.get(coordDim);
+
+        // negative resultDimIdx means no need to mapping.
+        if (dataDims === false) {
+            return;
+        }
+
+        var dataDims = normalizeToArray(dataDims);
+
         // dimensions provides default dim sequences.
         if (!dataDims.length) {
             for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
diff --git a/test/encode.html b/test/encode.html
index 13af96d..025c6e3 100644
--- a/test/encode.html
+++ b/test/encode.html
@@ -391,6 +391,9 @@ under the License.
             ], function (echarts) {
 
                 var option = {
+                    title: {
+                        text: 'deafault (filter)'
+                    },
                     xAxis: {},
                     yAxis: {},
                     dataZoom: [{
@@ -424,7 +427,7 @@ under the License.
                             };
                         },
                         encode: {
-                            x: null,
+                            x: -1,
                             y: 0
                         },
                         data: [
@@ -443,12 +446,45 @@ under the License.
                         'series not controlled by xAxis but only by yAxis',
                         'x axis can not filter blue circle, but y axis can do'
                     ],
-                    info: option.series[0].encode
+                    info: option.series[0].encode,
+                    buttons: [{
+                        text: 'filterMode: weakFitler',
+                        onclick: function () {
+                            option.dataZoom[0].filterMode = option.dataZoom[1].filterMode = 'weakFilter';
+                            option.title.text = 'filterMode: weakFilter';
+                            chart.setOption(option, true);
+                        }
+                    }, {
+                        text: 'filterMode: deafault (filter)',
+                        onclick: function () {
+                            option.dataZoom[0].filterMode = option.dataZoom[1].filterMode = void 0;
+                            option.title.text = 'deafault (filter)'
+                            chart.setOption(option, true);
+                        }
+                    }, {
+                        text: 'filterMode: empty',
+                        onclick: function () {
+                            option.dataZoom[0].filterMode = option.dataZoom[1].filterMode = 'empty';
+                            option.title.text = 'filterMode: empty';
+                            chart.setOption(option, true);
+                        }
+                    }, {
+                        text: 'filterMode: none',
+                        onclick: function () {
+                            option.dataZoom[0].filterMode = option.dataZoom[1].filterMode = 'none'
+                            option.title.text = 'filterMode: none';
+                            chart.setOption(option, true);
+                        }
+                    }]
                 });
             });
 
         </script>
 
 
+
+
+
+
     </body>
 </html>
\ No newline at end of file


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