@easyv/charts 1.8.23 → 1.8.25
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 +8 -5
- package/lib/components/Band.js +7 -3
- package/lib/components/CartesianChart.js +24 -6
- package/lib/components/Chart.js +17 -7
- package/lib/components/Label.js +11 -3
- package/lib/components/Legend.js +68 -62
- package/lib/components/PieChart.js +2 -0
- package/lib/components/pieTooltip.js +19 -21
- package/package.json +1 -1
- package/src/components/Axis.tsx +72 -63
- package/src/components/Band.tsx +153 -113
- package/src/components/CartesianChart.js +287 -211
- package/src/components/Chart.js +94 -60
- package/src/components/Label.js +85 -39
- package/src/components/Legend.js +222 -135
- package/src/components/PieChart.js +2 -0
- package/src/components/PieTooltip.jsx +279 -198
|
@@ -69,21 +69,21 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
69
69
|
var _icon = (0, _utils.getIcon)(type, icon);
|
|
70
70
|
return /*#__PURE__*/_react["default"].createElement("dd", {
|
|
71
71
|
style: {
|
|
72
|
-
display:
|
|
73
|
-
justifyContent:
|
|
74
|
-
lineHeight: lineHeight +
|
|
72
|
+
display: "flex",
|
|
73
|
+
justifyContent: "space-between",
|
|
74
|
+
lineHeight: lineHeight + "px"
|
|
75
75
|
}
|
|
76
76
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
77
77
|
style: {
|
|
78
78
|
// border: '1px solid red',
|
|
79
|
-
display:
|
|
80
|
-
alignItems:
|
|
79
|
+
display: "flex",
|
|
80
|
+
alignItems: "center",
|
|
81
81
|
gap: icon.iconGap
|
|
82
82
|
}
|
|
83
83
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
84
84
|
style: _objectSpread(_objectSpread({}, _icon), {}, {
|
|
85
|
-
width: iconSize +
|
|
86
|
-
height: iconSize +
|
|
85
|
+
width: iconSize + "px",
|
|
86
|
+
height: iconSize + "px"
|
|
87
87
|
})
|
|
88
88
|
}), /*#__PURE__*/_react["default"].createElement("span", {
|
|
89
89
|
style: (0, _utils.getFontStyle)(name)
|
|
@@ -95,30 +95,28 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
95
95
|
};
|
|
96
96
|
var getBigScreenScale = function getBigScreenScale() {
|
|
97
97
|
// 优先使用全局提供的方法
|
|
98
|
-
if (typeof window.getScreenScale ===
|
|
98
|
+
if (typeof window.getScreenScale === "function") {
|
|
99
99
|
try {
|
|
100
100
|
var _result = window.getScreenScale();
|
|
101
101
|
if (Array.isArray(_result) && _result.length >= 6) {
|
|
102
102
|
return _result;
|
|
103
103
|
}
|
|
104
104
|
} catch (e) {
|
|
105
|
-
console.error(
|
|
105
|
+
console.error("调用全局 getScreenScale 出错:", e);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// 获取容器元素
|
|
110
|
-
var bigscreenDom = document.getElementById(
|
|
110
|
+
var bigscreenDom = document.getElementById("bigscreen-container");
|
|
111
111
|
|
|
112
112
|
// 元素不存在时的处理
|
|
113
113
|
if (!bigscreenDom) {
|
|
114
|
-
console.warn('未找到 bigscreen-container 元素,使用视口尺寸');
|
|
115
114
|
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
// 确保元素可见(未被隐藏)
|
|
119
|
-
var isVisible = window.getComputedStyle(bigscreenDom).display !==
|
|
118
|
+
var isVisible = window.getComputedStyle(bigscreenDom).display !== "none" && window.getComputedStyle(bigscreenDom).visibility !== "hidden";
|
|
120
119
|
if (!isVisible) {
|
|
121
|
-
console.warn('bigscreen-container 元素不可见,使用视口尺寸');
|
|
122
120
|
return [1, 1, window.innerWidth, window.innerHeight, 0, 0];
|
|
123
121
|
}
|
|
124
122
|
|
|
@@ -137,14 +135,14 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
137
135
|
try {
|
|
138
136
|
var computedStyle = window.getComputedStyle(bigscreenDom);
|
|
139
137
|
var transform = computedStyle.transform;
|
|
140
|
-
if (transform && transform !==
|
|
138
|
+
if (transform && transform !== "none") {
|
|
141
139
|
// 解析 transform matrix
|
|
142
140
|
var matrix = new DOMMatrix(transform);
|
|
143
141
|
scaleX = matrix.a; // 缩放X因子
|
|
144
142
|
scaleY = matrix.d; // 缩放Y因子
|
|
145
143
|
}
|
|
146
144
|
} catch (e) {
|
|
147
|
-
console.error(
|
|
145
|
+
console.error("解析缩放样式出错:", e);
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
// 最终返回值(确保不会有undefined)
|
|
@@ -185,19 +183,19 @@ var PieTooltip = exports.PieTooltip = /*#__PURE__*/(0, _react.memo)(function (pr
|
|
|
185
183
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
186
184
|
className: "__easyv-tooltip",
|
|
187
185
|
style: {
|
|
188
|
-
pointerEvents:
|
|
186
|
+
pointerEvents: "none",
|
|
189
187
|
transform: getTipPos(mousePos, pieCenter),
|
|
190
188
|
width: tipWidth,
|
|
191
189
|
height: tipHeight,
|
|
192
190
|
padding: (0, _utils.getMargin)(margin),
|
|
193
|
-
background: image ?
|
|
191
|
+
background: image ? "50% 50% / 100% 100% no-repeat url(" + window.appConfig.ASSETS_URL + image + ")" : "rgba(48, 55, 66, 0.85)"
|
|
194
192
|
}
|
|
195
193
|
}, /*#__PURE__*/_react["default"].createElement("dl", {
|
|
196
194
|
style: {
|
|
197
|
-
display:
|
|
198
|
-
flexDirection:
|
|
199
|
-
justifyContent:
|
|
200
|
-
height:
|
|
195
|
+
display: "flex",
|
|
196
|
+
flexDirection: "column",
|
|
197
|
+
justifyContent: "space-between",
|
|
198
|
+
height: "100%"
|
|
201
199
|
}
|
|
202
200
|
}, Item()));
|
|
203
201
|
});
|
package/package.json
CHANGED
package/src/components/Axis.tsx
CHANGED
|
@@ -37,13 +37,13 @@ const defaultFormatter: (
|
|
|
37
37
|
const getAxesPath: (
|
|
38
38
|
orientation: Orientation,
|
|
39
39
|
{ width, height }: Context,
|
|
40
|
-
cHeight:number,
|
|
41
|
-
cPercent:number
|
|
40
|
+
cHeight: number,
|
|
41
|
+
cPercent: number
|
|
42
42
|
) => string = (orientation, { width, height }, cHeight, cPercent) => {
|
|
43
43
|
switch (orientation) {
|
|
44
44
|
case "top":
|
|
45
45
|
case "bottom":
|
|
46
|
-
return "M-0.5, 0H" + width/cPercent;
|
|
46
|
+
return "M-0.5, 0H" + width / cPercent;
|
|
47
47
|
case "left":
|
|
48
48
|
case "right":
|
|
49
49
|
return "M0, -0.5V" + (height + 0.5 - cHeight);
|
|
@@ -99,13 +99,13 @@ const AxisLine: ({
|
|
|
99
99
|
config,
|
|
100
100
|
isClipAxis,
|
|
101
101
|
clipAxisRange,
|
|
102
|
-
cPercent
|
|
102
|
+
cPercent,
|
|
103
103
|
}: any) => ReactComponentElement<ComponentType> | null = ({
|
|
104
104
|
orientation = defaultOrientation,
|
|
105
105
|
config: { show, color, lineWidth, cHeight },
|
|
106
106
|
isClipAxis = false,
|
|
107
107
|
clipAxisRange = [],
|
|
108
|
-
cPercent = 1
|
|
108
|
+
cPercent = 1,
|
|
109
109
|
}) => {
|
|
110
110
|
if (!show) return null;
|
|
111
111
|
const context: Context = useContext(chartContext);
|
|
@@ -137,7 +137,7 @@ const AxisLine: ({
|
|
|
137
137
|
|
|
138
138
|
const Unit: ({
|
|
139
139
|
config: { show, text, font, translate, align },
|
|
140
|
-
dataUnit
|
|
140
|
+
dataUnit,
|
|
141
141
|
}: any) => ReactComponentElement<ComponentType> | null = ({
|
|
142
142
|
config: {
|
|
143
143
|
show,
|
|
@@ -146,7 +146,7 @@ const Unit: ({
|
|
|
146
146
|
translate: { x: translateX, y: translateY },
|
|
147
147
|
align: { textAnchor } = defaultAlign,
|
|
148
148
|
},
|
|
149
|
-
dataUnit
|
|
149
|
+
dataUnit,
|
|
150
150
|
}) => {
|
|
151
151
|
if (!show) return null;
|
|
152
152
|
return (
|
|
@@ -182,7 +182,7 @@ type LabelType = {
|
|
|
182
182
|
formatter: Function;
|
|
183
183
|
tickSize: number;
|
|
184
184
|
rotate: number;
|
|
185
|
-
|
|
185
|
+
events?: Function;
|
|
186
186
|
config: {
|
|
187
187
|
show: boolean;
|
|
188
188
|
translate: Translate;
|
|
@@ -199,13 +199,13 @@ const Label: (
|
|
|
199
199
|
className,
|
|
200
200
|
orientation = defaultOrientation,
|
|
201
201
|
label,
|
|
202
|
-
iosTrans:{ isIOS, x:iosX, y:iosY },
|
|
202
|
+
iosTrans: { isIOS, x: iosX, y: iosY },
|
|
203
203
|
coordinate,
|
|
204
204
|
formatter = defaultFormatter,
|
|
205
205
|
tickSize,
|
|
206
206
|
rotate = 0,
|
|
207
207
|
config,
|
|
208
|
-
|
|
208
|
+
events = defaultEvent,
|
|
209
209
|
config: {
|
|
210
210
|
show,
|
|
211
211
|
style,
|
|
@@ -226,42 +226,48 @@ const Label: (
|
|
|
226
226
|
(isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
|
|
227
227
|
|
|
228
228
|
const _style = style && (typeof style == "object" ? style : style(_label));
|
|
229
|
-
|
|
229
|
+
|
|
230
230
|
return (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
<foreignObject
|
|
232
|
+
width="1"
|
|
233
|
+
height="1"
|
|
234
|
+
// x={x}
|
|
235
|
+
// y={y}
|
|
236
|
+
style={{ overflow: "visible" }}
|
|
237
|
+
>
|
|
238
|
+
<div
|
|
239
|
+
className={className}
|
|
240
|
+
onClick={(e) => events(e, "click")}
|
|
241
|
+
data-data={JSON.stringify({ x: label })}
|
|
242
|
+
style={{
|
|
243
|
+
..._style,
|
|
244
|
+
...getFontStyle(font),
|
|
245
|
+
/** Safari Bug **/
|
|
246
|
+
position: "absolute",
|
|
247
|
+
cursor: "pointer",
|
|
248
|
+
left: x + (isIOS ? iosX : 0),
|
|
249
|
+
top: y + (isIOS ? iosY : 0),
|
|
250
|
+
}}
|
|
237
251
|
>
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
252
|
+
<TextOverflow
|
|
253
|
+
ShowType="normal"
|
|
254
|
+
type={textOverflow}
|
|
255
|
+
speed={speed}
|
|
256
|
+
value={_label}
|
|
242
257
|
style={{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
258
|
+
width,
|
|
259
|
+
transform,
|
|
260
|
+
textAlign,
|
|
261
|
+
justifyContent:
|
|
262
|
+
textAlign == "left"
|
|
263
|
+
? "flex-start"
|
|
264
|
+
: textAlign == "right"
|
|
265
|
+
? "flex-end"
|
|
266
|
+
: "center",
|
|
250
267
|
}}
|
|
251
|
-
>
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
speed={speed}
|
|
255
|
-
value={_label}
|
|
256
|
-
style={{
|
|
257
|
-
width,
|
|
258
|
-
transform,
|
|
259
|
-
textAlign,
|
|
260
|
-
justifyContent: textAlign=="left"?"flex-start":textAlign=="right"?"flex-end":"center",
|
|
261
|
-
}}
|
|
262
|
-
></TextOverflow>
|
|
263
|
-
</div>
|
|
264
|
-
</foreignObject>
|
|
268
|
+
></TextOverflow>
|
|
269
|
+
</div>
|
|
270
|
+
</foreignObject>
|
|
265
271
|
);
|
|
266
272
|
};
|
|
267
273
|
|
|
@@ -275,9 +281,9 @@ export default memo(
|
|
|
275
281
|
ticks,
|
|
276
282
|
formatter,
|
|
277
283
|
rotate,
|
|
278
|
-
|
|
284
|
+
triggerEvents,
|
|
279
285
|
config: { on, label, axisLine, tickLine, gridLine, unit },
|
|
280
|
-
margin:{ marginLeft, marginTop },
|
|
286
|
+
margin: { marginLeft, marginTop },
|
|
281
287
|
positions,
|
|
282
288
|
xLineRange,
|
|
283
289
|
dataUnit,
|
|
@@ -297,8 +303,8 @@ export default memo(
|
|
|
297
303
|
const { width, height, isIOS } = useContext(chartContext);
|
|
298
304
|
const { cHeight, isC, cPercent } = controlInfo;
|
|
299
305
|
const x = orientation == "right" ? width : 0;
|
|
300
|
-
const y = orientation == "bottom" ? height-cHeight : 0;
|
|
301
|
-
|
|
306
|
+
const y = orientation == "bottom" ? height - cHeight : 0;
|
|
307
|
+
|
|
302
308
|
function drawAxisTickLine() {
|
|
303
309
|
const draw = (ticks: any, scaler: any) => {
|
|
304
310
|
return ticks.map((tick: string, index: number) => {
|
|
@@ -318,7 +324,9 @@ export default memo(
|
|
|
318
324
|
const y1 = gridCoord.y1;
|
|
319
325
|
return (
|
|
320
326
|
!(
|
|
321
|
-
(orientation == "bottom" &&
|
|
327
|
+
(orientation == "bottom" &&
|
|
328
|
+
!isC &&
|
|
329
|
+
(x1 < 0 || x1 > xLineRange)) ||
|
|
322
330
|
y1 < 0 ||
|
|
323
331
|
y1 > yLineRange
|
|
324
332
|
) && (
|
|
@@ -336,7 +344,7 @@ export default memo(
|
|
|
336
344
|
);
|
|
337
345
|
});
|
|
338
346
|
};
|
|
339
|
-
|
|
347
|
+
|
|
340
348
|
if (isClipAxis) {
|
|
341
349
|
return (
|
|
342
350
|
<>
|
|
@@ -347,7 +355,7 @@ export default memo(
|
|
|
347
355
|
);
|
|
348
356
|
} else if (isC && orientation == "bottom") {
|
|
349
357
|
return <>{draw(rawTicks, scaler)}</>;
|
|
350
|
-
}else {
|
|
358
|
+
} else {
|
|
351
359
|
return <>{draw(ticks, scaler)}</>;
|
|
352
360
|
}
|
|
353
361
|
}
|
|
@@ -380,13 +388,13 @@ export default memo(
|
|
|
380
388
|
className="__easyv-label"
|
|
381
389
|
orientation={orientation}
|
|
382
390
|
coordinate={coordinate}
|
|
383
|
-
iosTrans
|
|
391
|
+
iosTrans={{ isIOS, x: marginLeft + x, y: marginTop + y }}
|
|
384
392
|
config={label}
|
|
385
393
|
label={tick}
|
|
386
394
|
tickSize={_tickSize}
|
|
387
395
|
formatter={formatter}
|
|
388
396
|
rotate={rotate}
|
|
389
|
-
|
|
397
|
+
events={triggerEvents}
|
|
390
398
|
/>
|
|
391
399
|
)}
|
|
392
400
|
{gridLine && (
|
|
@@ -429,7 +437,7 @@ export default memo(
|
|
|
429
437
|
>
|
|
430
438
|
<AxisLine
|
|
431
439
|
orientation={orientation}
|
|
432
|
-
config={{...axisLine,cHeight}}
|
|
440
|
+
config={{ ...axisLine, cHeight }}
|
|
433
441
|
range={range}
|
|
434
442
|
/>
|
|
435
443
|
{tickLine &&
|
|
@@ -473,7 +481,7 @@ export default memo(
|
|
|
473
481
|
<g transform={"translate(" + x + ", " + y + ")"}>
|
|
474
482
|
<AxisLine
|
|
475
483
|
orientation={orientation}
|
|
476
|
-
config={{...axisLine,cHeight}}
|
|
484
|
+
config={{ ...axisLine, cHeight }}
|
|
477
485
|
isClipAxis={isClipAxis}
|
|
478
486
|
clipAxisRange={clipAxisRange}
|
|
479
487
|
cPercent={cPercent}
|
|
@@ -487,23 +495,24 @@ export default memo(
|
|
|
487
495
|
<svg
|
|
488
496
|
width={width}
|
|
489
497
|
style={{
|
|
490
|
-
overflow:
|
|
491
|
-
axisType === "x" && isC ? "hidden":"visible",
|
|
498
|
+
overflow: axisType === "x" && isC ? "hidden" : "visible",
|
|
492
499
|
}}
|
|
493
500
|
>
|
|
494
501
|
<g transform={"translate(" + x + ", " + y + ")"}>
|
|
495
502
|
{/* 用于控制图 */}
|
|
496
503
|
<g ref={ref as any}>
|
|
497
504
|
{label && gridLine && drawLabel()}
|
|
498
|
-
{isC &&
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
+
{isC && (
|
|
506
|
+
<AxisLine
|
|
507
|
+
orientation={orientation}
|
|
508
|
+
config={{ ...axisLine, cHeight }}
|
|
509
|
+
isClipAxis={isClipAxis}
|
|
510
|
+
clipAxisRange={clipAxisRange}
|
|
511
|
+
cPercent={cPercent}
|
|
512
|
+
/>
|
|
513
|
+
)}
|
|
505
514
|
{isC && tickLine && drawAxisTickLine()}
|
|
506
|
-
{unit && <Unit config={unit} dataUnit={dataUnit}/>}
|
|
515
|
+
{unit && <Unit config={unit} dataUnit={dataUnit} />}
|
|
507
516
|
</g>
|
|
508
517
|
</g>
|
|
509
518
|
</svg>
|