@alicloud/cloud-charts
Version:

61 lines (58 loc) • 2.23 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.NoCaptureDimRect = void 0;
exports.activeRegionWithTheme = activeRegionWithTheme;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _dimRect = _interopRequireDefault(require("@antv/g2/esm/interaction/action/mask/dim-rect"));
var _themes = _interopRequireDefault(require("../../themes"));
/* 更新内置的 interaction */
// 带主题设置的 active-region 配置项,使用函数包裹,保证主题始终保持最新
function activeRegionWithTheme(view) {
view.interaction('active-region', {
start: [{
trigger: 'plot:mousemove',
action: 'active-region:show',
arg: {
style: {
// 这一段必须放在函数中运行,否则主题无法更新
fill: _themes["default"]['widgets-tooltip-cross-react'],
opacity: _themes["default"]['widgets-tooltip-cross-react-opacity']
}
// {number} appendRatio 适用于笛卡尔坐标系. 对于 x 轴非 linear 类型: 默认:0.25, x 轴 linear 类型: 默认 0
// appendRatio,
// {number} appendWidth 适用于笛卡尔坐标系. 像素级别,优先级 > appendRatio
// appendWidth,
}
}],
end: [{
trigger: 'plot:mouseleave',
action: 'active-region:hide'
}]
});
}
// 拖拽缩放时的mask显示
var NoCaptureDimRect = exports.NoCaptureDimRect = /*#__PURE__*/function (_DimRect) {
(0, _inheritsLoose2["default"])(NoCaptureDimRect, _DimRect);
function NoCaptureDimRect() {
return _DimRect.apply(this, arguments) || this;
}
var _proto = NoCaptureDimRect.prototype;
// 添加图形
_proto.getMaskAttrs = function getMaskAttrs() {
var _this$getRegion = this.getRegion(),
start = _this$getRegion.start,
end = _this$getRegion.end;
var x = Math.min(start.x, end.x);
var y = Math.min(start.y, end.y);
var width = Math.abs(end.x - start.x);
var height = Math.abs(end.y - start.y);
return {
x: x,
y: y,
width: width - 2,
height: height
};
};
return NoCaptureDimRect;
}(_dimRect["default"]);