@easyv/charts 1.10.30 → 1.10.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -372,8 +372,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
372
372
|
var eventData = {
|
|
373
373
|
data: visibleData
|
|
374
374
|
};
|
|
375
|
-
triggerOnRelative("
|
|
376
|
-
onEmit("
|
|
375
|
+
triggerOnRelative("controlChange", eventData);
|
|
376
|
+
onEmit("controlChange", eventData);
|
|
377
377
|
}, [control, originData, chartWidth, triggerOnRelative, onEmit]);
|
|
378
378
|
(0, _react.useEffect)(function () {
|
|
379
379
|
if (!control) return;
|
|
@@ -27,8 +27,8 @@ var _excluded = ["startAngle", "endAngle", "antiClockwise"],
|
|
|
27
27
|
_excluded2 = ["padAngle", "innerRadius", "outerRadius", "cornerRadius", "startAngle", "endAngle"],
|
|
28
28
|
_excluded3 = ["formatter"],
|
|
29
29
|
_excluded4 = ["startAngle", "endAngle"];
|
|
30
|
-
/**
|
|
31
|
-
* 饼环图
|
|
30
|
+
/**
|
|
31
|
+
* 饼环图
|
|
32
32
|
*/
|
|
33
33
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
34
34
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
@@ -51,6 +51,66 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
51
51
|
height = _ref.height,
|
|
52
52
|
auto = _ref.auto,
|
|
53
53
|
manual = _ref.manual;
|
|
54
|
+
var getBigScreenScale = function getBigScreenScale() {
|
|
55
|
+
// 优先使用全局提供的方法
|
|
56
|
+
if (typeof window.getScreenScale === "function") {
|
|
57
|
+
try {
|
|
58
|
+
var _result = window.getScreenScale();
|
|
59
|
+
if (Array.isArray(_result) && _result.length >= 6) {
|
|
60
|
+
return _result;
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error("调用全局 getScreenScale 出错:", e);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 获取容器元素
|
|
68
|
+
var bigscreenDom = document.getElementById("bigscreen-container");
|
|
69
|
+
|
|
70
|
+
// 元素不存在时的处理
|
|
71
|
+
if (!bigscreenDom) {
|
|
72
|
+
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 确保元素可见(未被隐藏)
|
|
76
|
+
var isVisible = window.getComputedStyle(bigscreenDom).display !== "none" && window.getComputedStyle(bigscreenDom).visibility !== "hidden";
|
|
77
|
+
if (!isVisible) {
|
|
78
|
+
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 获取元素的布局矩形(最可靠的尺寸获取方式)
|
|
82
|
+
var rect = bigscreenDom.getBoundingClientRect();
|
|
83
|
+
|
|
84
|
+
// 提取基础尺寸(从布局矩形获取,不受样式影响)
|
|
85
|
+
var screenWidth = rect.width || window.innerWidth;
|
|
86
|
+
var screenHeight = rect.height || window.innerHeight;
|
|
87
|
+
var screenLeft = rect.left || 0;
|
|
88
|
+
var screenTop = rect.top || 0;
|
|
89
|
+
|
|
90
|
+
// 处理缩放
|
|
91
|
+
var scaleX = 1;
|
|
92
|
+
var scaleY = 1;
|
|
93
|
+
try {
|
|
94
|
+
var computedStyle = window.getComputedStyle(bigscreenDom);
|
|
95
|
+
var transform = computedStyle.transform;
|
|
96
|
+
if (transform && transform !== "none") {
|
|
97
|
+
// 解析 transform matrix
|
|
98
|
+
var matrix = new DOMMatrix(transform);
|
|
99
|
+
scaleX = matrix.a; // 缩放X因子
|
|
100
|
+
scaleY = matrix.d; // 缩放Y因子
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.error("解析缩放样式出错:", e);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 最终返回值(确保不会有undefined)
|
|
107
|
+
var result = [isNaN(scaleX) ? 1 : scaleX, isNaN(scaleY) ? 1 : scaleY, isNaN(screenWidth) ? window.innerWidth : screenWidth, isNaN(screenHeight) ? window.innerHeight : screenHeight, isNaN(screenLeft) ? 0 : screenLeft, isNaN(screenTop) ? 0 : screenTop];
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
var _getBigScreenScale = getBigScreenScale(),
|
|
111
|
+
_getBigScreenScale2 = (0, _slicedToArray2["default"])(_getBigScreenScale, 2),
|
|
112
|
+
scaleX = _getBigScreenScale2[0],
|
|
113
|
+
scaleY = _getBigScreenScale2[1];
|
|
54
114
|
var tooltipRef = (0, _react.useRef)(null);
|
|
55
115
|
var _useState = (0, _react.useState)({
|
|
56
116
|
width: 0,
|
|
@@ -61,17 +121,23 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
61
121
|
setTooltipSize = _useState2[1];
|
|
62
122
|
var tipPosition = (0, _react.useMemo)(function () {
|
|
63
123
|
var translate3d = isVertical ? _objectSpread(_objectSpread({}, translateTip), {}, {
|
|
64
|
-
y: translateTip.y + position + marginTop
|
|
124
|
+
y: translateTip.y / scaleY + position + marginTop / scaleY
|
|
65
125
|
}) : _objectSpread(_objectSpread({}, translateTip), {}, {
|
|
66
|
-
x: translateTip.x + position + marginLeft
|
|
126
|
+
x: translateTip.x / scaleX + position + marginLeft / scaleX
|
|
67
127
|
});
|
|
68
|
-
if (!isVertical && translate3d.x + tooltipSize.width > width) {
|
|
69
|
-
var newPositon = position + marginLeft - tooltipSize.width - translateTip.x;
|
|
128
|
+
if (!isVertical && translate3d.x + tooltipSize.width / scaleX > width / scaleX) {
|
|
129
|
+
var newPositon = position + marginLeft / scaleX - tooltipSize.width / scaleX - translateTip.x / scaleX;
|
|
70
130
|
translate3d.x = newPositon >= 0 ? newPositon : 0;
|
|
131
|
+
console.log("translate3d", translate3d);
|
|
132
|
+
console.log("scale", scaleX, scaleY);
|
|
133
|
+
console.log("width", width, height);
|
|
134
|
+
console.log("position", position, marginLeft, marginTop);
|
|
135
|
+
console.log("tooltipSize", tooltipSize);
|
|
136
|
+
console.log("translateTip", translateTip);
|
|
71
137
|
}
|
|
72
|
-
if (isVertical && translate3d.y + tooltipSize.height > height) {
|
|
73
|
-
var _newPositon = position + marginTop - tooltipSize.height - translateTip.y;
|
|
74
|
-
translate3d.y = _newPositon <= 0 ? _newPositon : height - tooltipSize.height;
|
|
138
|
+
if (isVertical && translate3d.y + tooltipSize.height / scaleY > height / scaleY) {
|
|
139
|
+
var _newPositon = position + marginTop / scaleY - tooltipSize.height / scaleY - translateTip.y / scaleY;
|
|
140
|
+
translate3d.y = _newPositon <= 0 ? _newPositon : height / scaleY - tooltipSize.height / scaleY;
|
|
75
141
|
}
|
|
76
142
|
return (0, _utils.getTranslate3d)(translate3d);
|
|
77
143
|
}, [width, height, marginLeft, marginTop, position, tooltipSize, translateTip]);
|
package/package.json
CHANGED
|
@@ -362,8 +362,8 @@ const Chart = memo(
|
|
|
362
362
|
chartWidth,
|
|
363
363
|
);
|
|
364
364
|
const eventData = { data: visibleData };
|
|
365
|
-
triggerOnRelative("
|
|
366
|
-
onEmit("
|
|
365
|
+
triggerOnRelative("controlChange", eventData);
|
|
366
|
+
onEmit("controlChange", eventData);
|
|
367
367
|
}, [control, originData, chartWidth, triggerOnRelative, onEmit]);
|
|
368
368
|
useEffect(() => {
|
|
369
369
|
if (!control) return;
|