@antv/f2
Version:
Charts for mobile visualization.
95 lines (94 loc) • 2.6 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _tslib = require("tslib");
var _fEngine = require("@antv/f-engine");
var _default = exports.default = function _default(props // Coord 在 withTreemap 被转成 Coord 类型了,所以这里需要重新定义
) {
var nodes = props.nodes,
coord = props.coord,
onClick = props.onClick,
_a = props.label,
label = _a === void 0 ? false : _a;
if (coord.isPolar) {
var center = coord.center;
var x_1 = center.x,
y_1 = center.y;
return (0, _fEngine.jsx)("group", null, nodes.map(function (node) {
var xMin = node.xMin,
xMax = node.xMax,
yMin = node.yMin,
yMax = node.yMax,
color = node.color,
style = node.style;
return (0, _fEngine.jsx)("sector", {
style: (0, _tslib.__assign)({
cx: x_1,
cy: y_1,
lineWidth: '1px',
stroke: '#fff',
startAngle: xMin,
endAngle: xMax,
r0: yMin,
r: yMax,
fill: color
}, style),
onClick: onClick ? function () {
return onClick(node);
} : null
});
}));
}
return (0, _fEngine.jsx)("group", null, nodes.map(function (node) {
var key = node.key,
xMin = node.xMin,
xMax = node.xMax,
yMin = node.yMin,
yMax = node.yMax,
color = node.color,
style = node.style;
return (0, _fEngine.jsx)("group", null, (0, _fEngine.jsx)("rect", {
key: key,
style: (0, _tslib.__assign)({
x: xMin,
y: yMin,
width: xMax - xMin,
height: yMax - yMin,
fill: color,
lineWidth: '4px',
stroke: '#fff',
radius: '8px'
}, style),
animation: {
appear: {
easing: 'linear',
duration: 450,
property: ['fillOpacity', 'strokeOpacity'],
start: {
fillOpacity: 0,
strokeOpacity: 0
}
},
update: {
easing: 'linear',
duration: 450,
property: ['x', 'y', 'width', 'height', 'radius', 'lineWidth', 'fillOpacity', 'strokeOpacity']
}
},
onClick: onClick ? function () {
return onClick(node);
} : null
}), label && (0, _fEngine.jsx)("text", {
style: (0, _tslib.__assign)({
x: (xMin + xMax) / 2,
y: (yMin + yMax) / 2,
text: node.origin.name,
fill: 'white',
textAlign: 'center',
textBaseline: 'middle'
}, label)
}));
}));
};
;