@easyv/charts 1.10.35 → 1.10.36
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.
- package/lib/components/PieChart.js +13 -2
- package/package.json +1 -1
- package/src/components/PieChart.js +14 -2
|
@@ -237,6 +237,17 @@ var getLabelColumnHeight = function getLabelColumnHeight(_ref2) {
|
|
|
237
237
|
return height || 12;
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
+
// 大屏 transform:scale 后 getBoundingClientRect 会带缩放;offsetHeight 不受 transform 影响,与 SVG 坐标一致
|
|
241
|
+
var getLabelDomHeight = function getLabelDomHeight(el) {
|
|
242
|
+
if (!el) return 0;
|
|
243
|
+
if (el.offsetHeight) return el.offsetHeight;
|
|
244
|
+
var rect = el.getBoundingClientRect();
|
|
245
|
+
if (!rect.height) return 0;
|
|
246
|
+
// offsetHeight 不可用时,用宽高比估算当前 scaleY 再还原
|
|
247
|
+
var scaleY = el.offsetWidth > 0 && rect.width > 0 ? rect.width / el.offsetWidth : 1;
|
|
248
|
+
return Math.round(rect.height / (scaleY || 1));
|
|
249
|
+
};
|
|
250
|
+
|
|
240
251
|
// 水平布局:同侧重叠时按半高之和推开
|
|
241
252
|
var resolveLabelY = function resolveLabelY(y2, side, placedYBySide, labelHeight) {
|
|
242
253
|
var placed = placedYBySide[side];
|
|
@@ -1207,7 +1218,7 @@ var Label = function Label(_ref19) {
|
|
|
1207
1218
|
Object.keys(labelElsRef.current).forEach(function (key) {
|
|
1208
1219
|
var el = labelElsRef.current[key];
|
|
1209
1220
|
if (!el) return;
|
|
1210
|
-
var h =
|
|
1221
|
+
var h = getLabelDomHeight(el);
|
|
1211
1222
|
if (!h) return;
|
|
1212
1223
|
next[key] = h;
|
|
1213
1224
|
if (prev[key] !== h) changed = true;
|
|
@@ -1422,7 +1433,7 @@ var RingLabel = function RingLabel(_ref21) {
|
|
|
1422
1433
|
Object.keys(labelElsRef.current).forEach(function (key) {
|
|
1423
1434
|
var el = labelElsRef.current[key];
|
|
1424
1435
|
if (!el) return;
|
|
1425
|
-
var h =
|
|
1436
|
+
var h = getLabelDomHeight(el);
|
|
1426
1437
|
if (!h) return;
|
|
1427
1438
|
next[key] = h;
|
|
1428
1439
|
if (prev[key] !== h) changed = true;
|
package/package.json
CHANGED
|
@@ -215,6 +215,18 @@ const getLabelColumnHeight = ({
|
|
|
215
215
|
return height || 12;
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
// 大屏 transform:scale 后 getBoundingClientRect 会带缩放;offsetHeight 不受 transform 影响,与 SVG 坐标一致
|
|
219
|
+
const getLabelDomHeight = (el) => {
|
|
220
|
+
if (!el) return 0;
|
|
221
|
+
if (el.offsetHeight) return el.offsetHeight;
|
|
222
|
+
const rect = el.getBoundingClientRect();
|
|
223
|
+
if (!rect.height) return 0;
|
|
224
|
+
// offsetHeight 不可用时,用宽高比估算当前 scaleY 再还原
|
|
225
|
+
const scaleY =
|
|
226
|
+
el.offsetWidth > 0 && rect.width > 0 ? rect.width / el.offsetWidth : 1;
|
|
227
|
+
return Math.round(rect.height / (scaleY || 1));
|
|
228
|
+
};
|
|
229
|
+
|
|
218
230
|
// 水平布局:同侧重叠时按半高之和推开
|
|
219
231
|
const resolveLabelY = (y2, side, placedYBySide, labelHeight) => {
|
|
220
232
|
const placed = placedYBySide[side];
|
|
@@ -1324,7 +1336,7 @@ const Label = ({
|
|
|
1324
1336
|
Object.keys(labelElsRef.current).forEach((key) => {
|
|
1325
1337
|
const el = labelElsRef.current[key];
|
|
1326
1338
|
if (!el) return;
|
|
1327
|
-
const h =
|
|
1339
|
+
const h = getLabelDomHeight(el);
|
|
1328
1340
|
if (!h) return;
|
|
1329
1341
|
next[key] = h;
|
|
1330
1342
|
if (prev[key] !== h) changed = true;
|
|
@@ -1615,7 +1627,7 @@ const RingLabel = ({
|
|
|
1615
1627
|
Object.keys(labelElsRef.current).forEach((key) => {
|
|
1616
1628
|
const el = labelElsRef.current[key];
|
|
1617
1629
|
if (!el) return;
|
|
1618
|
-
const h =
|
|
1630
|
+
const h = getLabelDomHeight(el);
|
|
1619
1631
|
if (!h) return;
|
|
1620
1632
|
next[key] = h;
|
|
1621
1633
|
if (prev[key] !== h) changed = true;
|