@easyv/charts 1.9.26 → 1.9.28
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/Axis.js +3 -4
- package/lib/components/ChartContainer.js +1 -1
- package/lib/components/pieTooltip.js +1 -1
- package/package.json +2 -2
- package/src/components/Axis.tsx +19 -18
- package/src/components/CartesianChart.js +6 -5
- package/src/components/ChartContainer.tsx +1 -1
- package/src/components/PieTooltip.jsx +33 -34
- package/src/components/Tooltip.js +53 -50
package/lib/components/Axis.js
CHANGED
|
@@ -248,7 +248,7 @@ var Label = function Label(_ref5) {
|
|
|
248
248
|
showType: config.showType
|
|
249
249
|
}
|
|
250
250
|
}));
|
|
251
|
-
var _getLayout = getLayout(orientation, rotate),
|
|
251
|
+
var _getLayout = getLayout(orientation, adaptive ? 0 : rotate),
|
|
252
252
|
transform = _getLayout.transform,
|
|
253
253
|
directionX = _getLayout.directionX,
|
|
254
254
|
directionY = _getLayout.directionY;
|
|
@@ -293,10 +293,9 @@ var Label = function Label(_ref5) {
|
|
|
293
293
|
}
|
|
294
294
|
}) : /*#__PURE__*/_react["default"].createElement("span", {
|
|
295
295
|
style: {
|
|
296
|
-
|
|
296
|
+
display: "inline-block",
|
|
297
297
|
transform: transform,
|
|
298
|
-
|
|
299
|
-
display: "block",
|
|
298
|
+
position: "absolute",
|
|
300
299
|
top: translateY,
|
|
301
300
|
left: translateX
|
|
302
301
|
}
|
|
@@ -41,7 +41,7 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
41
41
|
data = props.data,
|
|
42
42
|
series = props.series;
|
|
43
43
|
var tooltipRef = (0, _react.useRef)(null);
|
|
44
|
-
//
|
|
44
|
+
// 存储tooltip的实际宽高
|
|
45
45
|
var _useState = (0, _react.useState)({
|
|
46
46
|
width: 0,
|
|
47
47
|
height: 0
|
package/package.json
CHANGED
package/src/components/Axis.tsx
CHANGED
|
@@ -226,7 +226,7 @@ type LabelType = {
|
|
|
226
226
|
events?: Function;
|
|
227
227
|
config: {
|
|
228
228
|
show: boolean;
|
|
229
|
-
adaptive:boolean;
|
|
229
|
+
adaptive: boolean;
|
|
230
230
|
translate: Translate;
|
|
231
231
|
font: Font;
|
|
232
232
|
textAlign: TextAlign;
|
|
@@ -291,7 +291,10 @@ const Label: (
|
|
|
291
291
|
...config,
|
|
292
292
|
format: { type: config.format, showType: config.showType },
|
|
293
293
|
});
|
|
294
|
-
const { transform, directionX, directionY } = getLayout(
|
|
294
|
+
const { transform, directionX, directionY } = getLayout(
|
|
295
|
+
orientation,
|
|
296
|
+
adaptive ? 0 : rotate
|
|
297
|
+
);
|
|
295
298
|
const isVertical = orientation == "left" || orientation == "right";
|
|
296
299
|
|
|
297
300
|
const x =
|
|
@@ -344,10 +347,9 @@ const Label: (
|
|
|
344
347
|
) : (
|
|
345
348
|
<span
|
|
346
349
|
style={{
|
|
347
|
-
|
|
350
|
+
display: "inline-block",
|
|
348
351
|
transform,
|
|
349
|
-
|
|
350
|
-
display: "block",
|
|
352
|
+
position: "absolute",
|
|
351
353
|
top: translateY,
|
|
352
354
|
left: translateX,
|
|
353
355
|
}}
|
|
@@ -396,7 +398,7 @@ export default memo(
|
|
|
396
398
|
const x = orientation == "right" ? width : 0;
|
|
397
399
|
const y = orientation == "bottom" ? height - cHeight : 0;
|
|
398
400
|
let LabelWidth = 1;
|
|
399
|
-
if (!label.adaptive&&label.appearance) {
|
|
401
|
+
if (!label.adaptive && label.appearance) {
|
|
400
402
|
LabelWidth = label.appearance.width;
|
|
401
403
|
} else {
|
|
402
404
|
if (allTicks.length && typeof allTicks[0] == "string") {
|
|
@@ -406,18 +408,17 @@ export default memo(
|
|
|
406
408
|
const LabelNum = Math.floor(
|
|
407
409
|
((width / (isC ? cPercent : 1)) * (1 - paddingOuter)) / LabelWidth
|
|
408
410
|
);
|
|
409
|
-
const ticks: any =
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
LabelNum
|
|
415
|
-
?
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
);
|
|
411
|
+
const ticks: any = !label.adaptive
|
|
412
|
+
? tickss
|
|
413
|
+
: getEvenlySpacedElements(
|
|
414
|
+
allTicks,
|
|
415
|
+
LabelNum < allTicks.length
|
|
416
|
+
? LabelNum > allTicks.length / 2
|
|
417
|
+
? Math.ceil(allTicks.length / 2)
|
|
418
|
+
: LabelNum
|
|
419
|
+
: allTicks.length,
|
|
420
|
+
label.showLast
|
|
421
|
+
);
|
|
421
422
|
if (!(on && ticks.length > 0)) return null;
|
|
422
423
|
|
|
423
424
|
//数据抽取逻辑
|
|
@@ -348,8 +348,9 @@ const Chart = memo(
|
|
|
348
348
|
setClipX(-translateX);
|
|
349
349
|
const isVertical = axisX.direction === "vertical";
|
|
350
350
|
const coreOffset = isVertical ? marginRight : isIOS ? marginLeft : 0;
|
|
351
|
-
seriesEl.current.style.transform = `translate(${
|
|
352
|
-
|
|
351
|
+
seriesEl.current.style.transform = `translate(${
|
|
352
|
+
translateX + coreOffset
|
|
353
|
+
}px,${marginTop}px)`;
|
|
353
354
|
axisElList.current[2].style.transform = `translate(${translateX}px,${0}px)`;
|
|
354
355
|
}
|
|
355
356
|
}, [controlInfo]);
|
|
@@ -458,8 +459,8 @@ const Chart = memo(
|
|
|
458
459
|
const controlChartTooltipData =
|
|
459
460
|
ctlXName && originData.filter((d) => d.x === ctlXName);
|
|
460
461
|
const bodyWidth = isVertical
|
|
461
|
-
|
|
462
|
-
|
|
462
|
+
? xLineRange + 100 + marginRight + marginLeft
|
|
463
|
+
: xLineRange,
|
|
463
464
|
bodyHeight = isVertical
|
|
464
465
|
? yLineRange
|
|
465
466
|
: yLineRange + marginTop + marginBottom;
|
|
@@ -724,7 +725,7 @@ const Chart = memo(
|
|
|
724
725
|
ctlX -
|
|
725
726
|
marginLeft -
|
|
726
727
|
(axisX.controlEnd + axisX.start / cPercent - chartWidth) *
|
|
727
|
-
|
|
728
|
+
curControlPercent.current
|
|
728
729
|
}
|
|
729
730
|
marginLeft={marginLeft}
|
|
730
731
|
marginTop={marginTop}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo,useRef,useState,useEffect
|
|
1
|
+
import React, { memo, useRef, useState, useEffect } from "react";
|
|
2
2
|
import {
|
|
3
3
|
getFontStyle,
|
|
4
4
|
getMargin,
|
|
@@ -42,7 +42,7 @@ export const PieTooltip = memo((props) => {
|
|
|
42
42
|
series,
|
|
43
43
|
} = props;
|
|
44
44
|
const tooltipRef = useRef(null);
|
|
45
|
-
//
|
|
45
|
+
// 存储tooltip的实际宽高
|
|
46
46
|
const [tooltipSize, setTooltipSize] = useState({
|
|
47
47
|
width: 0,
|
|
48
48
|
height: 0,
|
|
@@ -56,7 +56,6 @@ export const PieTooltip = memo((props) => {
|
|
|
56
56
|
width: rect.width,
|
|
57
57
|
height: rect.height,
|
|
58
58
|
});
|
|
59
|
-
|
|
60
59
|
} catch (e) {
|
|
61
60
|
console.error("获取tooltip尺寸失败:", e);
|
|
62
61
|
}
|
|
@@ -93,7 +92,7 @@ export const PieTooltip = memo((props) => {
|
|
|
93
92
|
display: "flex",
|
|
94
93
|
justifyContent: "space-between",
|
|
95
94
|
lineHeight: lineHeight + "px",
|
|
96
|
-
alignItems:"center"
|
|
95
|
+
alignItems: "center",
|
|
97
96
|
}}
|
|
98
97
|
>
|
|
99
98
|
<span
|
|
@@ -114,13 +113,13 @@ export const PieTooltip = memo((props) => {
|
|
|
114
113
|
<span style={getFontStyle(name)}>{displayName || s}</span>
|
|
115
114
|
</span>
|
|
116
115
|
{valueIsShow && (
|
|
117
|
-
<span style={{...getFontStyle(valueFont),marginLeft:"10px"}}>
|
|
116
|
+
<span style={{ ...getFontStyle(valueFont), marginLeft: "10px" }}>
|
|
118
117
|
{y}
|
|
119
118
|
{valueSuffixIsShow && renderSuffix(valueSuffix)}
|
|
120
119
|
</span>
|
|
121
120
|
)}
|
|
122
121
|
{percentageIsShow && (
|
|
123
|
-
<span style={{...getFontStyle(percentageFont),marginLeft:"10px"}}>
|
|
122
|
+
<span style={{ ...getFontStyle(percentageFont), marginLeft: "10px" }}>
|
|
124
123
|
{Number(percent).toFixed(precision)}
|
|
125
124
|
{percentageSuffixIsShow && renderSuffix(percentageSuffix)}
|
|
126
125
|
</span>
|
|
@@ -277,33 +276,33 @@ export const PieTooltip = memo((props) => {
|
|
|
277
276
|
|
|
278
277
|
return (
|
|
279
278
|
<div
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
>
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
</div>
|
|
279
|
+
ref={tooltipRef}
|
|
280
|
+
className="__easyv-tooltip"
|
|
281
|
+
style={{
|
|
282
|
+
pointerEvents: "none",
|
|
283
|
+
transform: getTipPos(mousePos, pieCenter),
|
|
284
|
+
boxSizing: "border-box",
|
|
285
|
+
padding: getMargin(margin),
|
|
286
|
+
background: image
|
|
287
|
+
? "50% 50% / 100% 100% no-repeat url(" +
|
|
288
|
+
window.appConfig.ASSETS_URL +
|
|
289
|
+
image +
|
|
290
|
+
")"
|
|
291
|
+
: "rgba(48, 55, 66, 0.85)",
|
|
292
|
+
overflow: "hidden",
|
|
293
|
+
}}
|
|
294
|
+
>
|
|
295
|
+
<dl
|
|
296
|
+
style={{
|
|
297
|
+
display: "flex",
|
|
298
|
+
flexDirection: "column",
|
|
299
|
+
justifyContent: "space-between",
|
|
300
|
+
margin: 0,
|
|
301
|
+
height: "100%",
|
|
302
|
+
}}
|
|
303
|
+
>
|
|
304
|
+
{Item()}
|
|
305
|
+
</dl>
|
|
306
|
+
</div>
|
|
308
307
|
);
|
|
309
308
|
});
|
|
@@ -58,12 +58,15 @@ export default memo(
|
|
|
58
58
|
x: translateTip.x + position + marginLeft,
|
|
59
59
|
};
|
|
60
60
|
if (!isVertical && translate3d.x + tooltipSize.width > width) {
|
|
61
|
-
const newPositon =
|
|
61
|
+
const newPositon =
|
|
62
|
+
position + marginLeft - tooltipSize.width - translateTip.x;
|
|
62
63
|
translate3d.x = newPositon >= 0 ? newPositon : 0;
|
|
63
64
|
}
|
|
64
65
|
if (isVertical && translate3d.y + tooltipSize.height > height) {
|
|
65
|
-
const newPositon =
|
|
66
|
-
|
|
66
|
+
const newPositon =
|
|
67
|
+
position + marginTop - tooltipSize.height - translateTip.y;
|
|
68
|
+
translate3d.y =
|
|
69
|
+
newPositon <= 0 ? newPositon : height - tooltipSize.height;
|
|
67
70
|
}
|
|
68
71
|
return getTranslate3d(translate3d);
|
|
69
72
|
}, [
|
|
@@ -86,51 +89,51 @@ export default memo(
|
|
|
86
89
|
}, [manual, auto, formatter, data, series, x]);
|
|
87
90
|
return manual || auto ? (
|
|
88
91
|
<div
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
<div
|
|
123
|
-
style={{
|
|
124
|
-
display: "flex",
|
|
125
|
-
flexDirection: "column",
|
|
126
|
-
justifyContent: "space-between",
|
|
127
|
-
gap,
|
|
128
|
-
height: "100%",
|
|
129
|
-
width: "auto",
|
|
130
|
-
maxWidth: "none",
|
|
131
|
-
}}
|
|
132
|
-
>
|
|
92
|
+
ref={tooltipRef}
|
|
93
|
+
className="__easyv-tooltip"
|
|
94
|
+
style={{
|
|
95
|
+
pointerEvents: "none",
|
|
96
|
+
transform: tipPosition,
|
|
97
|
+
display: "inline-block",
|
|
98
|
+
position: "absolute",
|
|
99
|
+
margin: 0,
|
|
100
|
+
boxSizing: "border-box",
|
|
101
|
+
padding: getMargin(margin),
|
|
102
|
+
background:
|
|
103
|
+
bgType == "image"
|
|
104
|
+
? image
|
|
105
|
+
? "50% 50% / 100% 100% no-repeat url(" +
|
|
106
|
+
window.appConfig.ASSETS_URL +
|
|
107
|
+
image +
|
|
108
|
+
")"
|
|
109
|
+
: "transparent"
|
|
110
|
+
: bgColor,
|
|
111
|
+
...getFontStyle(font),
|
|
112
|
+
width: "fit-content",
|
|
113
|
+
maxWidth: "none",
|
|
114
|
+
overflow: "visible",
|
|
115
|
+
zIndex: 9999,
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
{formatter ? (
|
|
119
|
+
formatter({
|
|
120
|
+
series,
|
|
121
|
+
x: { x, config: xAxis },
|
|
122
|
+
data: { data, config: dataConfig },
|
|
123
|
+
})
|
|
124
|
+
) : (
|
|
133
125
|
<div
|
|
126
|
+
style={{
|
|
127
|
+
display: "flex",
|
|
128
|
+
flexDirection: "column",
|
|
129
|
+
justifyContent: "space-between",
|
|
130
|
+
gap,
|
|
131
|
+
height: "100%",
|
|
132
|
+
width: "auto",
|
|
133
|
+
maxWidth: "none",
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<div
|
|
134
137
|
style={{
|
|
135
138
|
textAlign: align,
|
|
136
139
|
transform: getTranslate3d(translateXAxis),
|
|
@@ -213,9 +216,9 @@ export default memo(
|
|
|
213
216
|
);
|
|
214
217
|
})}
|
|
215
218
|
</div>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
</div>
|
|
219
222
|
) : (
|
|
220
223
|
""
|
|
221
224
|
);
|