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:02 UTC

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

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