Skip to content

Commit

Permalink
fix apache#9265 axis.nameGap set automatically given grid.containLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
FallenMax committed Mar 4, 2020
1 parent f4fc1b0 commit 2c0b627
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/component/axis/AxisBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {isRadianAroundZero, remRadian} from '../../util/number';
import {createSymbol} from '../../util/symbol';
import * as matrixUtil from 'zrender/src/core/matrix';
import {applyTransform as v2ApplyTransform} from 'zrender/src/core/vector';
import {shouldShowAllLabels} from '../../coord/axisHelper';
import {shouldShowAllLabels, estimateLabelUnionRect} from '../../coord/axisHelper';


var PI = Math.PI;
Expand Down Expand Up @@ -269,7 +269,22 @@ var builders = {
var nameLocation = axisModel.get('nameLocation');
var nameDirection = opt.nameDirection;
var textStyleModel = axisModel.getModel('nameTextStyle');
var gap = axisModel.get('nameGap') || 0;
// label + gap
var distanceToAxis = calcDistanceToAxis();
function calcDistanceToAxis() {
var axis = axisModel.axis;
if (axis.grid.model.get('containLabel') && !axis.model.get('axisLabel.inside')) {
var labelUnionRect = estimateLabelUnionRect(axis);
if (!labelUnionRect) {
return 0;
}
var dim = axis.isHorizontal() ? 'height' : 'width';
var margin = axisModel.get('axisLabel.margin');
return labelUnionRect[dim] + margin;
}
return 0;
}
var gap = (axisModel.get('nameGap') || 0) + distanceToAxis;

var extent = this.axisModel.axis.getExtent();
var gapSignal = extent[0] > extent[1] ? -1 : 1;
Expand Down

0 comments on commit 2c0b627

Please sign in to comment.