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/06/01 09:54:11 UTC

[echarts] branch fix-17141 created (now 3c6eb554e)

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

ovilia pushed a change to branch fix-17141
in repository https://gitbox.apache.org/repos/asf/echarts.git


      at 3c6eb554e test(dataZoom): add test cases

This branch includes the following new commits:

     new 843306b9f fix(dataZoom): detail view with value axis
     new 3c6eb554e test(dataZoom): add test cases

The 2 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] 02/02: test(dataZoom): add test cases

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

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

commit 3c6eb554ea838d98c964503fa27976ebb06ef0c7
Author: Ovilia <zw...@gmail.com>
AuthorDate: Wed Jun 1 17:53:16 2022 +0800

    test(dataZoom): add test cases
---
 test/dataZoom-detail.html | 306 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 306 insertions(+)

diff --git a/test/dataZoom-detail.html b/test/dataZoom-detail.html
new file mode 100644
index 000000000..d5e299857
--- /dev/null
+++ b/test/dataZoom-detail.html
@@ -0,0 +1,306 @@
+<!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="main01"></div>
+        <div id="main1"></div>
+        <div id="main2"></div>
+        <div id="main3"></div>
+        <div id="main4"></div>
+
+
+
+
+
+
+        <script>
+            require([
+                'echarts',
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                option = {
+                    xAxis: {
+                        type: 'value'
+                    },
+                    yAxis: {
+                        type: 'value'
+                    },
+                    series: [
+                        {
+                        data: [
+                            [12, 3],
+                            [15, 50],
+                            [18, 30],
+                            [44, 50]
+                        ],
+                        type: 'line'
+                        }
+                    ],
+                    dataZoom: {
+                        startValue: 15
+                    }
+                };
+
+                var chart = testHelper.create(echarts, 'main0', {
+                    title: [
+                        'Value xAxis'
+                    ],
+                    option: option
+                });
+            });
+        </script>
+
+
+
+        <script>
+            require([
+                'echarts',
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                option = {
+                    xAxis: {
+                        type: 'value'
+                    },
+                    yAxis: {
+                        type: 'value'
+                    },
+                    series: [
+                        {
+                        data: [
+                            [12, 3],
+                            [15, 50],
+                            [18, 30],
+                            [44, 50]
+                        ],
+                        type: 'line'
+                        }
+                    ],
+                    dataZoom: [{
+                        xAxisIndex: 0
+                    }, {
+                        yAxisIndex: 0,
+                        filterMode: 'none'
+                    }]
+                };
+
+                var chart = testHelper.create(echarts, 'main01', {
+                    title: [
+                        'Value axes, filter none'
+                    ],
+                    option: option
+                });
+            });
+        </script>
+
+
+
+        <script>
+            require([
+                'echarts',
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                option = {
+                    xAxis: {
+                        type: 'value'
+                    },
+                    yAxis: {
+                        type: 'value'
+                    },
+                    series: [
+                        {
+                        data: [
+                            [12, 3],
+                            [15, 50],
+                            [18, 30],
+                            [44, 50]
+                        ],
+                        type: 'line'
+                        }
+                    ],
+                    dataZoom: {
+                        startValue: 18
+                    }
+                };
+
+                var chart = testHelper.create(echarts, 'main1', {
+                    title: [
+                        'Value xAxis with startValue'
+                    ],
+                    option: option
+                });
+            });
+        </script>
+
+
+
+        <script>
+            require([
+                'echarts',
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                option = {
+                    xAxis: {
+                        type: 'value',
+                        min: 8
+                    },
+                    yAxis: {
+                        type: 'value'
+                    },
+                    series: [
+                        {
+                        data: [
+                            [12, 3],
+                            [15, 50],
+                            [18, 30],
+                            [44, 50]
+                        ],
+                        type: 'line'
+                        }
+                    ],
+                    dataZoom: {
+                        startValue: 12
+                    }
+                };
+
+                var chart = testHelper.create(echarts, 'main2', {
+                    title: [
+                        'Value xAxis with min'
+                    ],
+                    option: option
+                });
+            });
+        </script>
+
+
+
+        <script>
+            require([
+                'echarts',
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                option = {
+                    xAxis: {
+                        type: 'value',
+                        min: 8
+                    },
+                    yAxis: {
+                        type: 'value'
+                    },
+                    series: [
+                        {
+                        data: [
+                            [-12, 3],
+                            [15, 50],
+                            [18, 30],
+                            [44, 50]
+                        ],
+                        type: 'line'
+                        }
+                    ],
+                    dataZoom: {
+                        startValue: 12
+                    }
+                };
+
+                var chart = testHelper.create(echarts, 'main3', {
+                    title: [
+                        'Value xAxis with negative min'
+                    ],
+                    option: option
+                });
+            });
+        </script>
+
+
+
+        <script>
+            require([
+                'echarts',
+                // 'map/js/china',
+                // './data/nutrients.json'
+            ], function (echarts) {
+                var option;
+
+                option = {
+                    xAxis: {
+                        type: 'value'
+                    },
+                    yAxis: {
+                        type: 'value'
+                    },
+                    series: [
+                        {
+                        data: [
+                            [44, 50],
+                            [18, 30],
+                            [15, 50],
+                            [12, 3]
+                        ],
+                        type: 'line'
+                        }
+                    ],
+                    dataZoom: {
+                    }
+                };
+
+                var chart = testHelper.create(echarts, 'main4', {
+                    title: [
+                        'Reversed xAxis'
+                    ],
+                    option: option
+                });
+            });
+        </script>
+    </body>
+</html>


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


[echarts] 01/02: fix(dataZoom): detail view with value axis

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

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

commit 843306b9ffa3abd5095887ee17ad6a5674644436
Author: Ovilia <zw...@gmail.com>
AuthorDate: Wed Jun 1 17:24:23 2022 +0800

    fix(dataZoom): detail view with value axis
---
 src/component/dataZoom/AxisProxy.ts      |  4 ++++
 src/component/dataZoom/SliderZoomView.ts | 25 +++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/component/dataZoom/AxisProxy.ts b/src/component/dataZoom/AxisProxy.ts
index e7be785fc..053816952 100644
--- a/src/component/dataZoom/AxisProxy.ts
+++ b/src/component/dataZoom/AxisProxy.ts
@@ -231,6 +231,10 @@ class AxisProxy {
         };
     }
 
+    getDataExtent() {
+        return this._dataExtent;
+    }
+
     /**
      * Notice: reset should not be called before series.restoreData() called,
      * so it is recommanded to be called in "process stage" but not "model init
diff --git a/src/component/dataZoom/SliderZoomView.ts b/src/component/dataZoom/SliderZoomView.ts
index 6669929fb..f11107792 100644
--- a/src/component/dataZoom/SliderZoomView.ts
+++ b/src/component/dataZoom/SliderZoomView.ts
@@ -374,6 +374,9 @@ class SliderZoomView extends DataZoomView {
             data !== this._shadowData || otherDim !== this._shadowDim
             || size[0] !== oldSize[0] || size[1] !== oldSize[1]
         ) {
+            const axisProxy = this.dataZoomModel.findRepresentativeAxisProxy();
+            const thisDataExtent = axisProxy.getDataExtent();
+
             let otherDataExtent = data.getDataExtent(otherDim);
             // Nice extent.
             const otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
@@ -384,17 +387,15 @@ class SliderZoomView extends DataZoomView {
             const otherShadowExtent = [0, size[1]];
             const thisShadowExtent = [0, size[0]];
 
-            const areaPoints = [[size[0], 0], [0, 0]];
+            const areaPoints: number[][] = [];
             const linePoints: number[][] = [];
-            const step = thisShadowExtent[1] / (data.count() - 1);
-            let thisCoord = 0;
 
             // Optimize for large data shadow
             const stride = Math.round(data.count() / size[0]);
             let lastIsEmpty: boolean;
-            data.each([otherDim], function (value: ParsedValue, index) {
+            data.each([info.thisDim, otherDim], function (thisValue: ParsedValue, thatValue: ParsedValue, index) {
                 if (stride > 0 && (index % stride)) {
-                    thisCoord += step;
+                    // thisCoord += step;
                     return;
                 }
 
@@ -403,10 +404,12 @@ class SliderZoomView extends DataZoomView {
 
                 // FIXME
                 // 应该使用统一的空判断?还是在list里进行空判断?
-                const isEmpty = value == null || isNaN(value as number) || value === '';
+                const isEmpty = thatValue == null || isNaN(thatValue as number) || thatValue === '';
                 // See #4235.
                 const otherCoord = isEmpty
-                    ? 0 : linearMap(value as number, otherDataExtent, otherShadowExtent, true);
+                    ? 0 : linearMap(thatValue as number, otherDataExtent, otherShadowExtent, true);
+                const thisCoord = isEmpty
+                    ? 0 : linearMap(thisValue as number, thisDataExtent, thisShadowExtent, true);
 
                 // Attempt to draw data shadow precisely when there are empty value.
                 if (isEmpty && !lastIsEmpty && index) {
@@ -418,10 +421,16 @@ class SliderZoomView extends DataZoomView {
                     linePoints.push([thisCoord, 0]);
                 }
 
+                if (index === 0) {
+                    areaPoints.push([thisCoord, 0]);
+                }
                 areaPoints.push([thisCoord, otherCoord]);
+                if (index === data.count() - 1) {
+                    areaPoints.push([thisCoord, 0]);
+                }
+
                 linePoints.push([thisCoord, otherCoord]);
 
-                thisCoord += step;
                 lastIsEmpty = isEmpty;
             });
 


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