Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance funnel chart label display policy #8759

Merged
merged 10 commits into from
Sep 21, 2018
18 changes: 14 additions & 4 deletions src/chart/funnel/funnelLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,19 @@ function labelLayout(data) {
var linePoints;

if (isLabelInside) {
textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
textAlign = 'center';
if (labelPosition === 'insideLeft') {
textX = (points[0][0] + points[3][0]) / 2 + 5;
textY = (points[0][1] + points[3][1]) / 2;
textAlign = 'left';
} else if (labelPosition === 'insideRight') {
textX = (points[1][0] + points[2][0]) / 2 - 5;
textY = (points[1][1] + points[2][1]) / 2;
textAlign = 'right';
} else {
textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
textAlign = 'center';
}
linePoints = [
[textX, textY], [textX, textY]
];
Expand Down Expand Up @@ -202,4 +212,4 @@ export default function (ecModel, api, payload) {

labelLayout(data);
});
}
}