From 31243cdf228291493c7c8698c8fced0f1a222af5 Mon Sep 17 00:00:00 2001 From: sushuang Date: Thu, 2 Nov 2017 02:27:49 +0800 Subject: [PATCH] Fix dataZoom action error when only use one param of 'start' or 'end'. --- src/component/dataZoom/DataZoomModel.js | 26 +++- test/dataZoom-action.html | 190 ++++++++++++++++++++++++ test/lib/requireES.js | 10 +- 3 files changed, 214 insertions(+), 12 deletions(-) create mode 100644 test/dataZoom-action.html diff --git a/src/component/dataZoom/DataZoomModel.js b/src/component/dataZoom/DataZoomModel.js index c36eff441..f5e28949b 100644 --- a/src/component/dataZoom/DataZoomModel.js +++ b/src/component/dataZoom/DataZoomModel.js @@ -433,12 +433,8 @@ var DataZoomModel = echarts.extendComponentModel({ * @param {boolean} [ignoreUpdateRangeUsg=false] */ setRawRange: function (opt, ignoreUpdateRangeUsg) { - each(['start', 'end', 'startValue', 'endValue'], function (name) { - // If any of those prop is null/undefined, we should alos set - // them, because only one pair between start/end and - // startValue/endValue can work. - this.option[name] = opt[name]; - }, this); + setOneSide(opt, this.option, 'start'); + setOneSide(opt, this.option, 'end'); !ignoreUpdateRangeUsg && updateRangeUse(this, opt); }, @@ -514,6 +510,24 @@ var DataZoomModel = echarts.extendComponentModel({ }); +// percentName: 'start' or 'end', valueName: 'startValue' or 'endValue' +function setOneSide(inputParams, option, percentName) { + var names = [percentName, percentName + 'Value']; + var hasValueIdx; + each(names, function (name, index) { + if (inputParams[name] != null) { + option[name] = inputParams[name]; + hasValueIdx = index; + } + }); + // If only 'start' or 'startValue' is set in inputParams and then assigned + // to option, the other one should be cleared in option. because only one + // pair between start/end and startValue/endValue can work. + if (hasValueIdx != null) { + option[names[1 - hasValueIdx]] = null; + } +} + function retrieveRaw(option) { var ret = {}; each( diff --git a/test/dataZoom-action.html b/test/dataZoom-action.html new file mode 100644 index 000000000..41e35f543 --- /dev/null +++ b/test/dataZoom-action.html @@ -0,0 +1,190 @@ + + + + + + + + + + + + +
+ by dispatchAction: + + + +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/test/lib/requireES.js b/test/lib/requireES.js index edf56ef81..12290f3bd 100644 --- a/test/lib/requireES.js +++ b/test/lib/requireES.js @@ -26,13 +26,11 @@ * * [Caution]: * - * 1) Modules are not shared between different - * calling of `simpleModuleLoader.load()`. + * 1) Modules are not shared between different calling of `requireES(...)`. * - * 2) Whether import `*` or `default` is determined - * by module itself. That is, if the module only - * export `default` (like `xxx/SomeClz`), we import - * `default`, otherwise import `*` (like `xxx/util`). + * 2) Whether import `*` or `default` is determined by the module itself. + * That is, if the module (like `xxx/SomeClz`) only export `default` , it + * imports `default`, otherwise (like `xxx/util`) it imports `*`. */ /* global define, ActiveXObject */ -- GitLab