@alicloud/cloud-charts
Version:

56 lines (53 loc) • 1.86 kB
JavaScript
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import DimRect from '@antv/g2/esm/interaction/action/mask/dim-rect';
import themes from '../../themes';
/* 更新内置的 interaction */
// 带主题设置的 active-region 配置项,使用函数包裹,保证主题始终保持最新
export function activeRegionWithTheme(view) {
view.interaction('active-region', {
start: [{
trigger: 'plot:mousemove',
action: 'active-region:show',
arg: {
style: {
// 这一段必须放在函数中运行,否则主题无法更新
fill: themes['widgets-tooltip-cross-react'],
opacity: themes['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显示
export var NoCaptureDimRect = /*#__PURE__*/function (_DimRect) {
_inheritsLoose(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);