You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2022/05/25 03:18:20 UTC

[echarts] 02/03: feat: make target size an option

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

ovilia pushed a commit to branch feat-coarse-pointer
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 02beb9a9ba2874ad2d07d8aff8b62790a399aa73
Author: Ovilia <zw...@gmail.com>
AuthorDate: Tue May 24 15:25:34 2022 +0800

    feat: make target size an option
---
 src/core/echarts.ts        |   6 +-
 test/aria-target-size.html | 140 +++++++++++++++++++++++++++++++++++++++++++++
 test/lib/testHelper.js     |   7 ++-
 3 files changed, 151 insertions(+), 2 deletions(-)

diff --git a/src/core/echarts.ts b/src/core/echarts.ts
index 78ea7687b..f70bbc7b5 100644
--- a/src/core/echarts.ts
+++ b/src/core/echarts.ts
@@ -324,6 +324,8 @@ type EChartsInitOpts = {
     renderer?: RendererType,
     devicePixelRatio?: number,
     useDirtyRect?: boolean,
+    useTargetSize?: boolean,
+    targetSize?: number,
     ssr?: boolean,
     width?: number,
     height?: number
@@ -430,7 +432,9 @@ class ECharts extends Eventful<ECEventDefinition> {
             width: opts.width,
             height: opts.height,
             ssr: opts.ssr,
-            useDirtyRect: opts.useDirtyRect == null ? defaultUseDirtyRect : opts.useDirtyRect
+            useDirtyRect: opts.useDirtyRect == null ? defaultUseDirtyRect : opts.useDirtyRect,
+            useTargetSize: opts.useTargetSize,
+            targetSize: opts.targetSize
         });
         this._ssr = opts.ssr;
 
diff --git a/test/aria-target-size.html b/test/aria-target-size.html
new file mode 100644
index 000000000..2f536e703
--- /dev/null
+++ b/test/aria-target-size.html
@@ -0,0 +1,140 @@
+<!DOCTYPE html>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+<html>
+    <head>
+        <meta charset="utf-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1" />
+        <script src="lib/simpleRequire.js"></script>
+        <script src="lib/config.js"></script>
+        <script src="lib/jquery.min.js"></script>
+        <script src="lib/facePrint.js"></script>
+        <script src="lib/testHelper.js"></script>
+        <!-- <script src="ut/lib/canteen.js"></script> -->
+        <link rel="stylesheet" href="lib/reset.css" />
+    </head>
+    <body>
+        <style>
+        </style>
+
+
+
+        <div id="main0"></div>
+        <div id="main1"></div>
+        <div id="main2"></div>
+
+
+
+        <script>
+        require([
+            'echarts',
+            // 'map/js/china',
+            // './data/nutrients.json'
+        ], function (echarts) {
+            var option;
+
+            option = {
+                xAxis: {},
+                yAxis: {},
+                series: {
+                    type: 'scatter',
+                    data: [[11, 22], [33, 44]]
+                },
+                tooltip: {
+                    show: true
+                }
+            };
+
+            var chart = testHelper.create(echarts, 'main0', {
+                title: [
+                    'By default, targe size feature is turned **off** for non-mobile devices.',
+                    'So in this tese case, tooltip should **not show** if mouse position is near by but not on the data point.'
+                ],
+                option: option
+            });
+        });
+        </script>
+
+        <script>
+        require([
+            'echarts',
+            // 'map/js/china',
+            // './data/nutrients.json'
+        ], function (echarts) {
+            var option;
+
+            option = {
+                xAxis: {},
+                yAxis: {},
+                series: {
+                    type: 'scatter',
+                    data: [[11, 22], [33, 44]]
+                },
+                tooltip: {
+                    show: true
+                }
+            };
+
+            var chart = testHelper.create(echarts, 'main1', {
+                title: [
+                    'If targe size feature is turned **on** for non-mobile devices,',
+                    'like in this tese case, tooltip should **show** if mouse position is near by but not on the data point.'
+                ],
+                option: option,
+                useTargetSize: true
+            });
+        });
+        </script>
+
+        <script>
+        require([
+            'echarts',
+            // 'map/js/china',
+            // './data/nutrients.json'
+        ], function (echarts) {
+            var option;
+
+            option = {
+                xAxis: {},
+                yAxis: {},
+                series: {
+                    type: 'scatter',
+                    data: [[11, 22], [33, 44]]
+                },
+                tooltip: {
+                    show: true
+                }
+            };
+
+            var chart = testHelper.create(echarts, 'main2', {
+                title: [
+                    'In this case, the target size is set to be 200 so it should have a larger responsive area.'
+                ],
+                option: option,
+                useTargetSize: true,
+                targetSize: 200
+            });
+        });
+        </script>
+
+
+    </body>
+</html>
diff --git a/test/lib/testHelper.js b/test/lib/testHelper.js
index 93fb9bbb6..3efc2e883 100644
--- a/test/lib/testHelper.js
+++ b/test/lib/testHelper.js
@@ -262,6 +262,8 @@
      * @param {boolean|number} opt If number, means height
      * @param {boolean} opt.lazyUpdate
      * @param {boolean} opt.notMerge
+     * @param {boolean} opt.useTargetSize
+     * @param {boolean} opt.targetSize
      * @param {number} opt.width
      * @param {number} opt.height
      * @param {boolean} opt.draggable
@@ -284,7 +286,10 @@
                 dom.style.height = opt.height + 'px';
             }
 
-            var chart = echarts.init(dom);
+            var chart = echarts.init(dom, null, {
+                useTargetSize: opt.useTargetSize,
+                targetSize: opt.targetSize
+            });
 
             if (opt.draggable) {
                 if (!window.draggable) {


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