You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2019/11/07 05:38:21 UTC

[incubator-echarts] branch release updated (fef810f -> 1191976)

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

sushuang pushed a change to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.


    from fef810f  Merge pull request #11545 from apache/master
     new 092921c  fix: code style
     new 8695d41  fix: fix test case. When draggable tool is used and the page layout will be changed, the draggable area should sync with the placeholder.
     new 1191976  fix: make code more robust.

The 3 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.


Summary of changes:
 src/coord/polar/polarCreator.js |  2 +-
 src/layout/barGrid.js           | 34 ++++++++-------
 test/lib/draggable.js           | 93 ++++++++++++++++++++++++++++-------------
 test/lib/testHelper.js          |  2 +-
 4 files changed, 83 insertions(+), 48 deletions(-)


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


[incubator-echarts] 02/03: fix: fix test case. When draggable tool is used and the page layout will be changed, the draggable area should sync with the placeholder.

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

sushuang pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 8695d4140fc2d7332e79ffdeee699265408950fc
Author: SHUANG SU <su...@gmail.com>
AuthorDate: Thu Nov 7 01:59:50 2019 +0800

    fix: fix test case. When draggable tool is used and the page layout will be changed, the draggable area should sync with the placeholder.
---
 test/lib/draggable.js  | 93 ++++++++++++++++++++++++++++++++++----------------
 test/lib/testHelper.js |  2 +-
 2 files changed, 64 insertions(+), 31 deletions(-)

diff --git a/test/lib/draggable.js b/test/lib/draggable.js
index 2eb3b78..c5bf49d 100644
--- a/test/lib/draggable.js
+++ b/test/lib/draggable.js
@@ -38,7 +38,6 @@
          * @param {boolean} [opt.lockX=false]
          * @param {boolean} [opt.lockY=false]
          * @param {number} [opt.throttle=false]
-         * @param {boolean} [opt.addPlaceholder=false]
          * @param {Function} [opt.onDrag]
          * @return {type}  description
          */
@@ -55,17 +54,23 @@
             var mainEl = $(mainEl);
             var id = mainEl.attr('data-draggable-id');
 
-            if (opt.addPlaceholder) {
-                var width = mainEl.outerWidth();
-                var height = mainEl.outerHeight();
-                $('<div></div>').css({
-                    width: width,
-                    height: height,
-                    margin: 0,
-                    padding: 0,
-                    visibility: 'hidden'
-                }).insertAfter(mainEl);
-            }
+            var width = mainEl.outerWidth();
+            var height = mainEl.outerHeight();
+            var mainStyle = mainEl[0].style;
+            var placeholder = $('<div></div>').css({
+                position: mainStyle.position,
+                width: width,
+                height: height,
+                top: mainStyle.top,
+                bottom: mainStyle.bottom,
+                left: mainStyle.left,
+                right: mainStyle.right,
+                borderWidth: 0,
+                margin: 0,
+                padding: 0,
+                visibility: 'hidden'
+            });
+            placeholder.insertAfter(mainEl);
 
             if (id == null) {
                 id = +Math.random();
@@ -111,8 +116,6 @@
 
             mainEl.css({
                 'position': 'absolute',
-                'left': mainEl[0].offsetLeft + 'px',
-                'top': mainEl[0].offsetTop + 'px',
                 'width': mainEl[0].offsetWidth + 'px',
                 'height': mainEl[0].offsetHeight + 'px',
                 'border-style': 'solid',
@@ -124,21 +127,8 @@
 
             mainEl.parent().append(controlEl);
 
+            var locationMaker = createLocationMaker(mainEl);
             var controlSize = controlEl[0].offsetWidth;
-
-            var boxSizing = mainEl.css('box-sizing');
-
-            var borderBoxBroder = boxSizing === 'border-box' ? 2 * BORDER_WIDTH : 0;
-            var mainContentWidth = opt.width || (mainEl.width() + borderBoxBroder);
-            var mainContentHeight = opt.height || (mainEl.height() + borderBoxBroder);
-
-            var mainOffset = mainEl.offset();
-            resize(
-                mainOffset.left + mainContentWidth + BORDER_WIDTH,
-                mainOffset.top + mainContentHeight + BORDER_WIDTH,
-                true
-            );
-
             var dragging = false;
 
             controlEl.on('mousedown', function () {
@@ -155,7 +145,31 @@
                 dragging = false;
             });
 
+            relocate(opt.width, opt.height);
 
+            // A temporarily way to handle the reflow.
+            // Where the position should be sync to the placeholder.
+            $(function () {
+                setTimeout(function () {
+                    relocate();
+                }, 0);
+            });
+
+            function relocate(width, height) {
+                mainEl.css({
+                    'left': locationMaker.left(placeholder[0].offsetLeft) + 'px',
+                    'top': locationMaker.top(placeholder[0].offsetTop) + 'px',
+                });
+                var mainContentWidth = width != null ? width : locationMaker.width(mainEl.width());
+                var mainContentHeight = height != null ? height : locationMaker.height(mainEl.height());
+
+                var mainOffset = mainEl.offset();
+                resize(
+                    mainOffset.left + mainContentWidth + BORDER_WIDTH,
+                    mainOffset.top + mainContentHeight + BORDER_WIDTH,
+                    true
+                );
+            }
 
             function resize(x, y, isInit) {
                 var mainOffset = mainEl.offset();
@@ -170,7 +184,7 @@
                     );
                     mainEl.css(
                         'width',
-                        (mainContentWidth + borderBoxBroder) + 'px'
+                        locationMaker.width(mainContentWidth) + 'px'
                     );
                 }
 
@@ -181,7 +195,7 @@
                     );
                     mainEl.css(
                         'height',
-                        (mainContentHeight + borderBoxBroder) + 'px'
+                        locationMaker.height(mainContentHeight) + 'px'
                     );
                 }
 
@@ -192,6 +206,25 @@
         }
     };
 
+    function createLocationMaker(mainEl) {
+        var isBorderBox = mainEl.css('box-sizing') === 'border-box';
+
+        return {
+            width: function (w) {
+                return w + (isBorderBox ? 2 * BORDER_WIDTH : 0);
+            },
+            height: function (h) {
+                return h + (isBorderBox ? 2 * BORDER_WIDTH : 0);
+            },
+            left: function (l) {
+                return l - (isBorderBox ? 0: BORDER_WIDTH);
+            },
+            top: function (t) {
+                return t - (isBorderBox ? 0: BORDER_WIDTH);
+            }
+        };
+    }
+
     function throttle(fn, delay, trailing, debounce) {
 
         var currCall = (new Date()).getTime();
diff --git a/test/lib/testHelper.js b/test/lib/testHelper.js
index e0ca0d2..d8fb5a3 100644
--- a/test/lib/testHelper.js
+++ b/test/lib/testHelper.js
@@ -239,7 +239,7 @@
                         + '<script src="lib/draggable.js"></script>'
                     );
                 }
-                window.draggable.init(dom, chart, {throttle: 70, addPlaceholder: true});
+                window.draggable.init(dom, chart, {throttle: 70});
             }
 
             option && chart.setOption(option, {


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


[incubator-echarts] 01/03: fix: code style

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

sushuang pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 092921c24bb4713932bee50037cf4bf4b246845d
Author: SHUANG SU <su...@gmail.com>
AuthorDate: Tue Nov 5 01:23:29 2019 +0800

    fix: code style
---
 src/coord/polar/polarCreator.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/coord/polar/polarCreator.js b/src/coord/polar/polarCreator.js
index 670776b..156f97f 100644
--- a/src/coord/polar/polarCreator.js
+++ b/src/coord/polar/polarCreator.js
@@ -50,7 +50,7 @@ function resizePolar(polar, polarModel, api) {
 
     var radius = polarModel.get('radius');
     if (radius == null) {
-        radius = [0, "100%"];
+        radius = [0, '100%'];
     }
     else if (!zrUtil.isArray(radius)) {
         // r0 = 0


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


[incubator-echarts] 03/03: fix: make code more robust.

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

sushuang pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit 119197611e132ff21d9af2052fc3487894760672
Author: SHUANG SU <su...@gmail.com>
AuthorDate: Thu Nov 7 05:18:44 2019 +0800

    fix: make code more robust.
---
 src/layout/barGrid.js | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/layout/barGrid.js b/src/layout/barGrid.js
index 069cc25..09e85e3 100644
--- a/src/layout/barGrid.js
+++ b/src/layout/barGrid.js
@@ -130,24 +130,26 @@ function getValueAxesMinGaps(barSeries) {
     });
 
     var axisMinGaps = [];
-    for (var i in axisValues) {
-        var valuesInAxis = axisValues[i];
-        if (valuesInAxis) {
-            // Sort axis values into ascending order to calculate gaps
-            valuesInAxis.sort(function (a, b) {
-                return a - b;
-            });
-
-            var min = null;
-            for (var j = 1; j < valuesInAxis.length; ++j) {
-                var delta = valuesInAxis[j] - valuesInAxis[j - 1];
-                if (delta > 0) {
-                    // Ignore 0 delta because they are of the same axis value
-                    min = min === null ? delta : Math.min(min, delta);
+    for (var key in axisValues) {
+        if (axisValues.hasOwnProperty(key)) {
+            var valuesInAxis = axisValues[key];
+            if (valuesInAxis) {
+                // Sort axis values into ascending order to calculate gaps
+                valuesInAxis.sort(function (a, b) {
+                    return a - b;
+                });
+
+                var min = null;
+                for (var j = 1; j < valuesInAxis.length; ++j) {
+                    var delta = valuesInAxis[j] - valuesInAxis[j - 1];
+                    if (delta > 0) {
+                        // Ignore 0 delta because they are of the same axis value
+                        min = min === null ? delta : Math.min(min, delta);
+                    }
                 }
+                // Set to null if only have one data
+                axisMinGaps[key] = min;
             }
-            // Set to null if only have one data
-            axisMinGaps[i] = min;
         }
     }
     return axisMinGaps;


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