diff --git a/src/component/axis/AxisBuilder.js b/src/component/axis/AxisBuilder.js index 5cf864b0675e39e76eab70f4f292d0d645a9ba7b..7ba76fa727649d0b3b7e84468949e11f5e217cb1 100644 --- a/src/component/axis/AxisBuilder.js +++ b/src/component/axis/AxisBuilder.js @@ -189,10 +189,16 @@ var builders = { var symbolWidth = arrowSize[0]; var symbolHeight = arrowSize[1]; - each([ - [opt.rotation + Math.PI / 2, pt1], - [opt.rotation - Math.PI / 2, pt2] - ], function (item, index) { + each([{ + rotate: opt.rotation + Math.PI / 2, + offset: arrowOffset[0], + r: 0 + }, { + rotate: opt.rotation - Math.PI / 2, + offset: arrowOffset[1], + r: Math.sqrt((pt1[0] - pt2[0]) * (pt1[0] - pt2[0]) + + (pt1[1] - pt2[1]) * (pt1[1] - pt2[1])) + }], function (point, index) { if (arrows[index] !== 'none' && arrows[index] != null) { var symbol = createSymbol( arrows[index], @@ -205,26 +211,14 @@ var builders = { ); // Calculate arrow position with offset - var pos; - if (index === 0) { - if (opt.rotation === 0) { - pos = [item[1][0] + arrowOffset[0], item[1][1]]; - } - else { - pos = [item[1][0], item[1][1] + arrowOffset[0]]; - } - } - else { - if (opt.rotation === 0) { - pos = [item[1][0] + arrowOffset[1], item[1][1]]; - } - else { - pos = [item[1][0], item[1][1] + arrowOffset[1]]; - } - } + var r = point.r + point.offset; + var pos = [ + pt1[0] + r * Math.cos(opt.rotation), + pt1[1] - r * Math.sin(opt.rotation) + ]; symbol.attr({ - rotation: item[0], + rotation: point.rotate, position: pos, silent: true }); diff --git a/test/polarLine.html b/test/polarLine.html index 7948eaa48de627f9c2649619a45a3796da08bb8a..f1ddca0caea91ceb1dbe2d44e005e6e1e96d871e 100644 --- a/test/polarLine.html +++ b/test/polarLine.html @@ -53,9 +53,14 @@ polar: {}, angleAxis: { // data: ['类目1', '类目2', '类目3', '类目4', '类目5',] - data: xAxisData + data: xAxisData, + startAngle: 30 }, radiusAxis: { + axisLine: { + symbol: 'arrow', + symbolOffset: [20, -20] + } }, series: [{ coordinateSystem: 'polar',