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/11/17 10:52:56 UTC
[echarts] 01/01: fix(dataZoom): fallback to extent start/end when parsed value or percent is invalid.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch fix-datazoom
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit ab39c8afa1d6b9ba132e9fbdefd52e093df89401
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Nov 17 18:48:49 2022 +0800
fix(dataZoom): fallback to extent start/end when parsed value or percent is invalid.
---
src/component/dataZoom/AxisProxy.ts | 9 +++++++--
test/axis-lastLabel.html | 29 ++++++++++-------------------
2 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/src/component/dataZoom/AxisProxy.ts b/src/component/dataZoom/AxisProxy.ts
index 19a14c9ba..8c05f8cea 100644
--- a/src/component/dataZoom/AxisProxy.ts
+++ b/src/component/dataZoom/AxisProxy.ts
@@ -189,8 +189,13 @@ class AxisProxy {
// valueWindow[idx] = round(boundValue);
// percentWindow[idx] = round(boundPercent);
- valueWindow[idx] = boundValue;
- percentWindow[idx] = boundPercent;
+ // fallback to extent start/end when parsed value or percent is invalid
+ valueWindow[idx] = boundValue == null || isNaN(boundValue)
+ ? dataExtent[idx]
+ : boundValue;
+ percentWindow[idx] = boundPercent == null || isNaN(boundPercent)
+ ? percentExtent[idx]
+ : boundPercent;
});
asc(valueWindow);
diff --git a/test/axis-lastLabel.html b/test/axis-lastLabel.html
index d34e5a39f..5a8f9b609 100644
--- a/test/axis-lastLabel.html
+++ b/test/axis-lastLabel.html
@@ -130,10 +130,6 @@ under the License.
'echarts'
], function (rainfallData, echarts) {
- var chart = echarts.init(document.getElementById('chart0'), null, {
-
- });
-
var option = {
tooltip : {
trigger: 'axis'
@@ -204,10 +200,6 @@ under the License.
'echarts'
], function (rainfallData, echarts) {
- var chart = echarts.init(document.getElementById('chart1'), null, {
-
- });
-
var option = {
tooltip : {
trigger: 'axis'
@@ -289,10 +281,6 @@ under the License.
'echarts'
], function (rainfallData, echarts) {
- var chart = echarts.init(document.getElementById('chart1'), null, {
-
- });
-
var option = {
tooltip: {
trigger: 'axis'
@@ -300,8 +288,15 @@ under the License.
dataZoom: {
show: true,
realtime: true,
- startValue: '2009-09-20 12:00',
- end: 100
+ // The `startValue` does not exist in the categories as it's splitted by '-' rather than '/'
+ // It will fallback to the first category
+ // The same to `endValue` / `end` / `start`
+ startValue: '2009-07-20 12:00',
+ // the `endValue` should work
+ endValue: '2009/8/20 12:00',
+ // start: 50,
+ // end: 60,
+ // end: 'aaaa'
},
xAxis: {
axisTick: {
@@ -372,10 +367,6 @@ under the License.
'echarts'
], function (rainfallData, echarts) {
- var chart = echarts.init(document.getElementById('chart1'), null, {
-
- });
-
var option = {
tooltip : {
trigger: 'axis',
@@ -461,4 +452,4 @@ under the License.
</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