@easyv/charts 1.10.32 → 1.10.34

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.
@@ -44,74 +44,6 @@ export default memo(
44
44
  auto,
45
45
  manual,
46
46
  }) => {
47
- const getBigScreenScale = () => {
48
- // 优先使用全局提供的方法
49
- if (typeof window.getScreenScale === "function") {
50
- try {
51
- const result = window.getScreenScale();
52
- if (Array.isArray(result) && result.length >= 6) {
53
- return result;
54
- }
55
- } catch (e) {
56
- console.error("调用全局 getScreenScale 出错:", e);
57
- }
58
- }
59
-
60
- // 获取容器元素
61
- const bigscreenDom = document.getElementById("bigscreen-container");
62
-
63
- // 元素不存在时的处理
64
- if (!bigscreenDom) {
65
- return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
66
- }
67
-
68
- // 确保元素可见(未被隐藏)
69
- const isVisible =
70
- window.getComputedStyle(bigscreenDom).display !== "none" &&
71
- window.getComputedStyle(bigscreenDom).visibility !== "hidden";
72
- if (!isVisible) {
73
- return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
74
- }
75
-
76
- // 获取元素的布局矩形(最可靠的尺寸获取方式)
77
- const rect = bigscreenDom.getBoundingClientRect();
78
-
79
- // 提取基础尺寸(从布局矩形获取,不受样式影响)
80
- const screenWidth = rect.width || window.innerWidth;
81
- const screenHeight = rect.height || window.innerHeight;
82
- const screenLeft = rect.left || 0;
83
- const screenTop = rect.top || 0;
84
-
85
- // 处理缩放
86
- let scaleX = 1;
87
- let scaleY = 1;
88
-
89
- try {
90
- const computedStyle = window.getComputedStyle(bigscreenDom);
91
- const transform = computedStyle.transform;
92
-
93
- if (transform && transform !== "none") {
94
- // 解析 transform matrix
95
- const matrix = new DOMMatrix(transform);
96
- scaleX = matrix.a; // 缩放X因子
97
- scaleY = matrix.d; // 缩放Y因子
98
- }
99
- } catch (e) {
100
- console.error("解析缩放样式出错:", e);
101
- }
102
-
103
- // 最终返回值(确保不会有undefined)
104
- const result = [
105
- isNaN(scaleX) ? 1 : scaleX,
106
- isNaN(scaleY) ? 1 : scaleY,
107
- isNaN(screenWidth) ? window.innerWidth : screenWidth,
108
- isNaN(screenHeight) ? window.innerHeight : screenHeight,
109
- isNaN(screenLeft) ? 0 : screenLeft,
110
- isNaN(screenTop) ? 0 : screenTop,
111
- ];
112
- return result;
113
- };
114
- const [scaleX, scaleY] = getBigScreenScale();
115
47
  const tooltipRef = useRef(null);
116
48
  const [tooltipSize, setTooltipSize] = useState({
117
49
  width: 0,
@@ -121,46 +53,35 @@ export default memo(
121
53
  const translate3d = isVertical
122
54
  ? {
123
55
  ...translateTip,
124
- y: translateTip.y / scaleY + position + marginTop / scaleY,
56
+ y: translateTip.y + position + marginTop,
125
57
  }
126
58
  : {
127
59
  ...translateTip,
128
- x: translateTip.x / scaleX + position + marginLeft / scaleX,
60
+ x: translateTip.x + position + marginLeft,
129
61
  };
130
-
131
- if (
132
- !isVertical &&
133
- translate3d.x + tooltipSize.width / scaleX > width / scaleX
134
- ) {
135
- const newPositon =
136
- position +
137
- marginLeft / scaleX -
138
- tooltipSize.width / scaleX -
139
- translateTip.x / scaleX;
140
- translate3d.x = newPositon >= 0 ? newPositon : 0;
141
- console.log("translate3d", translate3d);
142
- console.log("scale", scaleX, scaleY);
143
- console.log("width", width, height);
144
- console.log("position", position, marginLeft, marginTop);
145
- console.log("tooltipSize", tooltipSize);
146
- console.log("translateTip", translateTip);
62
+ if (!isVertical && translate3d.x + tooltipSize.width > width) {
63
+ translate3d.x =
64
+ position + marginLeft - tooltipSize.width - translateTip.x;
65
+ translate3d.x = translate3d.x >= 0 ? translate3d.x : 0;
66
+ translate3d.x =
67
+ translate3d.x + tooltipSize.width > width
68
+ ? width - tooltipSize.width
69
+ : translate3d.x;
70
+ translate3d.x = translate3d.x >= 0 ? translate3d.x : 0;
147
71
  }
148
- if (
149
- isVertical &&
150
- translate3d.y + tooltipSize.height / scaleY > height / scaleY
151
- ) {
152
- const newPositon =
153
- position +
154
- marginTop / scaleY -
155
- tooltipSize.height / scaleY -
156
- translateTip.y / scaleY;
72
+ if (isVertical && translate3d.y + tooltipSize.height > height) {
73
+ translate3d.y =
74
+ position + marginTop - tooltipSize.height - translateTip.y;
75
+ translate3d.y = translate3d.y >= 0 ? translate3d.y : 0;
157
76
  translate3d.y =
158
- newPositon <= 0
159
- ? newPositon
160
- : height / scaleY - tooltipSize.height / scaleY;
77
+ translate3d.y + tooltipSize.height > height
78
+ ? height - tooltipSize.height
79
+ : translate3d.y;
80
+ translate3d.y = translate3d.y >= 0 ? translate3d.y : 0;
161
81
  }
162
82
  return getTranslate3d(translate3d);
163
83
  }, [
84
+ isVertical,
164
85
  width,
165
86
  height,
166
87
  marginLeft,
@@ -171,10 +92,9 @@ export default memo(
171
92
  ]);
172
93
  useEffect(() => {
173
94
  if (tooltipRef.current && (manual || auto)) {
174
- const rect = tooltipRef.current.getBoundingClientRect();
175
95
  setTooltipSize({
176
- width: rect.width,
177
- height: rect.height,
96
+ width: tooltipRef.current.offsetWidth,
97
+ height: tooltipRef.current.offsetHeight,
178
98
  });
179
99
  }
180
100
  }, [manual, auto, formatter, data, series, x]);