@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.
@@ -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
- width: LabelWidth,
296
+ display: "inline-block",
297
297
  transform: transform,
298
- justifyContent: "flex-start",
299
- display: "block",
298
+ position: "absolute",
300
299
  top: translateY,
301
300
  left: translateX
302
301
  }
@@ -43,7 +43,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
43
43
  onMouseMove: onMouseMove,
44
44
  ref: ref,
45
45
  style: _objectSpread({
46
- overflow: "hidden",
46
+ overflow: "visible",
47
47
  position: "absolute",
48
48
  width: width,
49
49
  height: height
@@ -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
- // 2. 存储tooltip的实际宽高
44
+ // 存储tooltip的实际宽高
45
45
  var _useState = (0, _react.useState)({
46
46
  width: 0,
47
47
  height: 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.9.26",
3
+ "version": "1.9.28",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -55,4 +55,4 @@
55
55
  "commit": true
56
56
  }
57
57
  }
58
- }
58
+ }
@@ -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(orientation, rotate);
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
- width: LabelWidth,
350
+ display: "inline-block",
348
351
  transform,
349
- justifyContent: "flex-start",
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
- !label.adaptive
411
- ? tickss
412
- : getEvenlySpacedElements(
413
- allTicks,
414
- LabelNum < allTicks.length
415
- ? LabelNum > allTicks.length / 2
416
- ? Math.ceil(allTicks.length / 2)
417
- : LabelNum
418
- : allTicks.length,
419
- label.showLast
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(${translateX + coreOffset
352
- }px,${marginTop}px)`;
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
- ? xLineRange + 100 + marginRight + marginLeft
462
- : xLineRange,
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
- curControlPercent.current
728
+ curControlPercent.current
728
729
  }
729
730
  marginLeft={marginLeft}
730
731
  marginTop={marginTop}
@@ -54,7 +54,7 @@ export default memo(
54
54
  onMouseMove={onMouseMove}
55
55
  ref={ref}
56
56
  style={{
57
- overflow: "hidden",
57
+ overflow: "visible",
58
58
  position: "absolute",
59
59
  width,
60
60
  height,
@@ -1,4 +1,4 @@
1
- import React, { memo,useRef,useState,useEffect } from "react";
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
- // 2. 存储tooltip的实际宽高
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
- ref={tooltipRef}
281
- className="__easyv-tooltip"
282
- style={{
283
- pointerEvents: "none",
284
- transform: getTipPos(mousePos, pieCenter),
285
- boxSizing: "border-box",
286
- padding: getMargin(margin),
287
- background: image
288
- ? "50% 50% / 100% 100% no-repeat url(" +
289
- window.appConfig.ASSETS_URL +
290
- image +
291
- ")"
292
- : "rgba(48, 55, 66, 0.85)",
293
- overflow: "hidden",
294
- }}
295
- >
296
- <dl
297
- style={{
298
- display: "flex",
299
- flexDirection: "column",
300
- justifyContent: "space-between",
301
- margin: 0,
302
- height: "100%",
303
- }}
304
- >
305
- {Item()}
306
- </dl>
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 = position + marginLeft - tooltipSize.width - translateTip.x;
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 = position + marginTop - tooltipSize.height - translateTip.y;
66
- translate3d.y = newPositon <= 0 ? newPositon : height - tooltipSize.height;
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
- ref={tooltipRef}
90
- className="__easyv-tooltip"
91
- style={{
92
- pointerEvents: "none",
93
- transform: tipPosition,
94
- display: "inline-block",
95
- position: "absolute",
96
- margin: 0,
97
- boxSizing: "border-box",
98
- padding: getMargin(margin),
99
- background:
100
- bgType == "image"
101
- ? image
102
- ? "50% 50% / 100% 100% no-repeat url(" +
103
- window.appConfig.ASSETS_URL +
104
- image +
105
- ")"
106
- : "transparent"
107
- : bgColor,
108
- ...getFontStyle(font),
109
- width: "fit-content",
110
- maxWidth: "none",
111
- overflow: "visible",
112
- zIndex: 9999,
113
- }}
114
- >
115
- {formatter ? (
116
- formatter({
117
- series,
118
- x: { x, config: xAxis },
119
- data: { data, config: dataConfig },
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
- </div>
217
- )}
218
- </div>
219
+ </div>
220
+ )}
221
+ </div>
219
222
  ) : (
220
223
  ""
221
224
  );