From e208f5dfd257b215ea1ddd52f00358b81baa43ea Mon Sep 17 00:00:00 2001 From: cuijian-dexter <1109883925@qq.com> Date: Tue, 14 May 2019 15:32:39 +0800 Subject: [PATCH] funnel enhance--series.label.position (#9421) * New Feature--series.label.position add rightTop,rightBottom,leftTop,leftBottom * style: fix style in funnel text position --- src/chart/funnel/funnelLayout.js | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/chart/funnel/funnelLayout.js b/src/chart/funnel/funnelLayout.js index ee133c31e..1d6743629 100644 --- a/src/chart/funnel/funnelLayout.js +++ b/src/chart/funnel/funnelLayout.js @@ -104,7 +104,47 @@ function labelLayout(data) { x2 = x1 - labelLineLen; textX = x2 - 5; textAlign = 'right'; - } + } + else if (labelPosition === 'right') { + // Right side + x1 = (points[1][0] + points[2][0]) / 2; + y1 = (points[1][1] + points[2][1]) / 2; + x2 = x1 + labelLineLen; + textX = x2 + 5; + textAlign = 'left'; + } + else if (labelPosition === 'rightTop') { + // RightTop side + x1 = points[1][0]; + y1 = points[1][1]; + x2 = x1 + labelLineLen; + textX = x2 + 5; + textAlign = 'top'; + } + else if (labelPosition === 'rightBottom') { + // RightBottom side + x1 = points[2][0]; + y1 = points[2][1]; + x2 = x1 + labelLineLen; + textX = x2 + 5; + textAlign = 'bottom'; + } + else if (labelPosition === 'leftTop') { + // LeftTop side + x1 = points[0][0]; + y1 = points[1][1]; + x2 = x1 - labelLineLen; + textX = x2 - 5; + textAlign = 'right'; + } + else if (labelPosition === 'leftBottom') { + // LeftBottom side + x1 = points[3][0]; + y1 = points[2][1]; + x2 = x1 - labelLineLen; + textX = x2 - 5; + textAlign = 'right'; + } else { // Right side x1 = (points[1][0] + points[2][0]) / 2; -- GitLab