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

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

commit 6a9e7239acbc0d6162d7550c6cad7d98d681a0d7
Author: 100pah <sushuang0...@gmail.com>
AuthorDate: Thu Aug 6 00:28:56 2020 +0800

    fix: In Line.js (used by graph and markLine), when rotation is not 
specified by users, the "auto rotation" rule should not be broken when rendered 
at the second time (like when drag graph or move dataZoom). (Brought by 
7c3f1896fa1fa93fc7d019f40fd4584024ca32eb #12392 )
---
 src/chart/helper/Line.js        | 18 ++++++++++++------
 test/markLine-symbolRotate.html | 19 ++++++++++++++-----
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/chart/helper/Line.js b/src/chart/helper/Line.js
index 7824751..260fa36 100644
--- a/src/chart/helper/Line.js
+++ b/src/chart/helper/Line.js
@@ -57,8 +57,8 @@ function createSymbol(name, lineData, idx) {
     );
 
     // rotate by default if symbolRotate is not specified or NaN
-    symbolPath.rotation = symbolRotate == null || isNaN(symbolRotate)
-        ? undefined
+    symbolPath.__specifiedRotation = symbolRotate == null || 
isNaN(symbolRotate)
+        ? void 0
         : +symbolRotate * Math.PI / 180 || 0;
     symbolPath.name = name;
 
@@ -131,13 +131,16 @@ function updateSymbolAndLabelBeforeLineUpdate() {
         // when symbol is set to be 'arrow' in markLine,
         // symbolRotate value will be ignored, and compulsively use tangent 
angle.
         // rotate by default if symbol rotation is not specified
-        if (symbolFrom.rotation == null
-            || (symbolFrom.shape && symbolFrom.shape.symbolType === 'arrow')) {
+        var specifiedRotation = symbolFrom.__specifiedRotation;
+        if (specifiedRotation == null) {
             var tangent = line.tangentAt(0);
             symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(
                 tangent[1], tangent[0]
             ));
         }
+        else {
+            symbolFrom.attr('rotation', specifiedRotation);
+        }
         symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
     }
     if (symbolTo) {
@@ -146,13 +149,16 @@ function updateSymbolAndLabelBeforeLineUpdate() {
         // when symbol is set to be 'arrow' in markLine,
         // symbolRotate value will be ignored, and compulsively use tangent 
angle.
         // rotate by default if symbol rotation is not specified
-        if (symbolTo.rotation == null
-            || (symbolTo.shape && symbolTo.shape.symbolType === 'arrow')) {
+        var specifiedRotation = symbolTo.__specifiedRotation;
+        if (specifiedRotation == null) {
             var tangent = line.tangentAt(1);
             symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(
                 tangent[1], tangent[0]
             ));
         }
+        else {
+            symbolTo.attr('rotation', specifiedRotation);
+        }
         symbolTo.attr('scale', [invScale * percent, invScale * percent]);
     }
 
diff --git a/test/markLine-symbolRotate.html b/test/markLine-symbolRotate.html
index 96bd4b1..1a5afd5 100644
--- a/test/markLine-symbolRotate.html
+++ b/test/markLine-symbolRotate.html
@@ -118,6 +118,10 @@ under the License.
                                 silent: true,
                                 // symbol: 'triangle',
                                 data: [
+                                [
+                                    {name: 'rotation not specified', coord: 
['2014-06-20', 300], symbol: 'arrow'},
+                                    {coord: ['2014-07-18', 320], symbol: 
'triangle'}
+                                ],
                                 {
                                     yAxis: 50,
                                     // symbolRotate: 0,
@@ -133,15 +137,18 @@ under the License.
                                     yAxis: 150,
                                     symbol: 'roundRect',
                                     symbolRotate: 40
-                                }, {
+                                },
+                                {
                                     yAxis: 200,
                                     symbol: 'diamond',
-                                    symbolRotate: 70
-                                }, {
+                                    symbolRotate: 45
+                                },
+                                {
                                     yAxis: 250,
                                     symbol: 'pin',
                                     symbolRotate: 45
-                                }, {
+                                },
+                                {
                                     yAxis: 300,
                                     symbol: 'circle',
                                     symbolRotate: 90
@@ -162,7 +169,9 @@ under the License.
                                     lineStyle: {
                                         color: '#14c4ba'
                                     }
-                                }]]
+                                }
+                                ]
+                                ]
                             }
                         }]
                     };


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

Reply via email to