You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2022/07/28 14:13:00 UTC

[echarts] branch fix/symbol-emphasis-scale created (now 4ed662984)

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

wangzx pushed a change to branch fix/symbol-emphasis-scale
in repository https://gitbox.apache.org/repos/asf/echarts.git


      at 4ed662984 test(vrt): fix changing value of select via js doesn't trigger `change` event.

This branch includes the following new commits:

     new c76c297e6 fix(symbol): fix `emphasis.scale` can't be reset and specified value may not be respect.
     new bffad00b2 test(symbol): add test case for `emphasis.scale`
     new 4ed662984 test(vrt): fix changing value of select via js doesn't trigger `change` event.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[echarts] 03/03: test(vrt): fix changing value of select via js doesn't trigger `change` event.

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch fix/symbol-emphasis-scale
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 4ed662984e006d889436dec4e6432e5a2355cdce
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Jul 28 22:09:38 2022 +0800

    test(vrt): fix changing value of select via js doesn't trigger `change` event.
---
 test/runTest/runtime/ActionPlayback.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/test/runTest/runtime/ActionPlayback.js b/test/runTest/runtime/ActionPlayback.js
index 6a41f4271..aa50caa67 100644
--- a/test/runTest/runtime/ActionPlayback.js
+++ b/test/runTest/runtime/ActionPlayback.js
@@ -186,7 +186,10 @@ export class ActionPlayback {
                 screenshotTaken = true;
                 break;
             case 'valuechange':
-                document.querySelector(op.selector).value = op.value;
+                const selector = document.querySelector(op.selector);
+                selector.value = op.value;
+                // changing value via js won't trigger `change` event, so trigger it manually
+                selector.dispatchEvent(new Event('change'));
                 break;
         }
 
@@ -213,4 +216,4 @@ export class ActionPlayback {
 
         return true;
     }
-};
\ 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


[echarts] 02/03: test(symbol): add test case for `emphasis.scale`

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch fix/symbol-emphasis-scale
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit bffad00b26dacf53d4ab383a3d70aec14359eb11
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Jul 28 22:08:05 2022 +0800

    test(symbol): add test case for `emphasis.scale`
---
 test/runTest/actions/__meta__.json |  1 +
 test/runTest/actions/symbol.json   |  1 +
 test/symbol.html                   | 72 +++++++++++++++++++++++++++++++-------
 3 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index 5de0031e9..4267114bd 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -170,6 +170,7 @@
   "stackBar-dataZoom": 7,
   "sunburst-book": 1,
   "sunburst-canvas": 1,
+  "symbol": 1,
   "symbol2": 1,
   "themeRiver": 1,
   "timeScale": 1,
diff --git a/test/runTest/actions/symbol.json b/test/runTest/actions/symbol.json
new file mode 100644
index 000000000..a3eaba4ee
--- /dev/null
+++ b/test/runTest/actions/symbol.json
@@ -0,0 +1 @@
+[{"name":"Action 1","ops":[{"type":"mousemove","time":191,"x":749,"y":85},{"type":"mousemove","time":392,"x":733,"y":119},{"type":"mousemove","time":606,"x":704,"y":150},{"type":"screenshot","time":2032},{"type":"mousemove","time":2274,"x":705,"y":150},{"type":"mousemove","time":2479,"x":711,"y":74},{"type":"mousemove","time":2689,"x":706,"y":36},{"type":"mousemove","time":2897,"x":700,"y":20},{"type":"mousemove","time":3361,"x":697,"y":5},{"type":"mousemove","time":3407,"x":697,"y":7},{ [...]
\ No newline at end of file
diff --git a/test/symbol.html b/test/symbol.html
index 808f9a7cf..465cb3890 100644
--- a/test/symbol.html
+++ b/test/symbol.html
@@ -23,6 +23,8 @@ under the License.
         <meta charset="utf-8">
         <script src="lib/simpleRequire.js"></script>
         <script src="lib/config.js"></script>
+        <script src="lib/dat.gui.min.js"></script>
+        <link rel="stylesheet" href="lib/reset.css">
     </head>
     <body>
         <style>
@@ -35,12 +37,12 @@ under the License.
         <script>
 
             require([
-                'echarts'
-            ], function (echarts) {
+                '../node_modules/seedrandom/seedrandom.js',
+                'echarts',
+            ], function (seedrandom, echarts) {
+                Math.random = new seedrandom('echarts-random');
 
-                var chart = echarts.init(document.getElementById('main'), null, {
-
-                });
+                var chart = echarts.init(document.getElementById('main'));
 
                 var symbolList = [
                     'circle',
@@ -86,12 +88,6 @@ under the License.
                     legend: {
                         data: series.map(function (series) {return series.name;})
                     },
-                    tooltip: {
-                        trigger: 'axis',
-                        axisPointer: {
-                            type: 'cross'
-                        }
-                    },
                     xAxis: {
                         type: 'value',
                         splitLine: {
@@ -106,8 +102,60 @@ under the License.
                     },
                     series: series
                 });
+
+                window.addEventListener('resize', chart.resize);
+
+                var symbolScaleValueMap = {
+                    'undefined': undefined,
+                    'null': null,
+                    'true': true,
+                    'false': false,
+                    '0': 0,
+                    '0.5': 0.5,
+                    '1': 1,
+                    '1.1': 1.1,
+                    '2': 2,
+                    'NaN': NaN,
+                    'Infinity': Infinity,
+                    'Negative(-1)': -1,
+                    'Empty String': '',
+                    'String(\'abc\')': 'abc'
+                }
+
+                var config = {
+                    hoverScale: 'false',
+                    tooltipTrigger: 'item'
+                };
+
+                var gui = new dat.GUI();
+                gui.add(config, 'hoverScale', Object.keys(symbolScaleValueMap))
+                    .onChange(update);
+                gui.add(config, 'tooltipTrigger', ['axis', 'item'])
+                    .onChange(update);
+
+                update();
+
+                function update() {
+                    var activeHoverScale = symbolScaleValueMap[config.hoverScale];
+                    console.log('active hoverScale', activeHoverScale);
+                    series.forEach(function (series) {
+                        series.emphasis = series.emphasis || {};
+                        series.emphasis.scale = activeHoverScale;
+                    });
+                    var tooltip = {
+                        trigger: config.tooltipTrigger,
+                        axisPointer: config.tooltipTrigger === 'axis'
+                            ? { type: 'cross' }
+                            : null
+                    };
+                    console.log(tooltip);
+                    chart.setOption({
+                        tooltip: tooltip,
+                        series: series
+                    });
+                }
             });
 
         </script>
     </body>
-</html>
\ No newline at end of file
+</html>


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


[echarts] 01/03: fix(symbol): fix `emphasis.scale` can't be reset and specified value may not be respect.

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch fix/symbol-emphasis-scale
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit c76c297e60829e9f46e8d72a07a778784a914bd7
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Jul 28 22:01:27 2022 +0800

    fix(symbol): fix `emphasis.scale` can't be reset and specified value may not be respect.
    
    - null / undefined / true means to use default strategy.
    - 0 / false / negative number / NaN / Infinity means no scale.
---
 src/chart/helper/Symbol.ts | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts
index c31e9b11b..e77a84dca 100644
--- a/src/chart/helper/Symbol.ts
+++ b/src/chart/helper/Symbol.ts
@@ -336,11 +336,19 @@ class Symbol extends graphic.Group {
         symbolPath.ensureState('select').style = selectItemStyle;
         symbolPath.ensureState('blur').style = blurItemStyle;
 
-        if (hoverScale) {
-            const scaleRatio = Math.max(isNumber(hoverScale) ? hoverScale : 1.1, 3 / this._sizeY);
-            emphasisState.scaleX = this._sizeX * scaleRatio;
-            emphasisState.scaleY = this._sizeY * scaleRatio;
-        }
+        // null / undefined / true means to use default strategy.
+        // 0 / false / negative number / NaN / Infinity means no scale.
+        const scaleRatio =
+            hoverScale == null || hoverScale === true
+                ? Math.max(1.1, 3 / this._sizeY)
+                // PENDING: restrict hoverScale > 1? It seems unreasonable to scale down
+                : isFinite(hoverScale as number) && hoverScale > 0
+                    ? +hoverScale
+                    : 1;
+        // always set scale to allow resetting
+        emphasisState.scaleX = this._sizeX * scaleRatio;
+        emphasisState.scaleY = this._sizeY * scaleRatio;
+
         this.setSymbolScale(1);
 
         toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled);


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