diff --git a/src/chart/helper/Line.js b/src/chart/helper/Line.js index 7824751c5f..260fa36d52 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 96bd4b138a..1a5afd5381 100644 --- a/test/markLine-symbolRotate.html +++ b/test/markLine-symbolRotate.html @@ -118,6 +118,10 @@ 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 @@ 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 @@ lineStyle: { color: '#14c4ba' } - }]] + } + ] + ] } }] };