NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/g2/lib/chart/util/bbox-of-back-plot.js
2023-09-14 14:47:11 +08:00

59 lines
1.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var G = require('../../renderer');
var Util = require('../../util');
var mergeBBox = require('./merge-bbox');
function applyMatrix(point, matrix, tag) {
if (tag === void 0) {
tag = 1;
}
var vector = [point.x, point.y, tag];
Util.vec3.transformMat3(vector, vector, matrix);
return {
x: vector[0],
y: vector[1]
};
}
function getTitleBBox(title) {
var bbox = title.getBBox();
var leftTop = {
x: bbox.minX,
y: bbox.minY
};
var rightBottom = {
x: bbox.maxX,
y: bbox.maxY
};
var matrix = title.attr('matrix');
leftTop = applyMatrix(leftTop, matrix);
rightBottom = applyMatrix(rightBottom, matrix);
return {
minX: leftTop.x,
minY: leftTop.y,
maxX: rightBottom.x,
maxY: rightBottom.y
};
}
module.exports = function BBoxOfBackPlot(backPlot, defaultBBox) {
var bbox = defaultBBox;
Util.each(backPlot.get('children'), function (group) {
// 这段代码假设了子元素是 axis同时 title 超出长度,
// 这种临时代码需要在 4.0 中修复掉
if (group instanceof G.Group) {
Util.each(group.get('children'), function (element) {
if (element instanceof G.Group && element.get('children').length || element instanceof G.Path) {
bbox = mergeBBox(bbox, element.getBBox());
} else if (element instanceof G.Text) {
// title
var elementBBox = getTitleBBox(element);
bbox = mergeBBox(bbox, elementBBox);
}
});
}
});
return bbox;
};