@easyv/charts 1.9.20 → 1.9.22

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.
@@ -334,14 +334,19 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
334
334
  clipAxisRange = _ref6.clipAxisRange,
335
335
  controlInfo = _ref6.controlInfo,
336
336
  rawTicks = _ref6.rawTicks,
337
- paddingOuter = _ref6.paddingOuter;
337
+ paddingOuter = _ref6.paddingOuter,
338
+ controlEnd = _ref6.controlEnd,
339
+ start = _ref6.start;
338
340
  var _useContext = (0, _react.useContext)(_context.chartContext),
339
341
  width = _useContext.width,
340
342
  height = _useContext.height,
341
343
  isIOS = _useContext.isIOS;
342
344
  var cHeight = controlInfo.cHeight,
343
345
  isC = controlInfo.isC,
344
- cPercent = controlInfo.cPercent;
346
+ cPercent = controlInfo.cPercent,
347
+ cBarX = controlInfo.cBarX,
348
+ cWidth = controlInfo.cWidth,
349
+ cBarWidth = controlInfo.cBarWidth;
345
350
  var x = orientation == "right" ? width : 0;
346
351
  var y = orientation == "bottom" ? height - cHeight : 0;
347
352
  var LabelWidth = 1;
@@ -444,6 +449,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
444
449
  }
445
450
  }
446
451
  function drawLabel() {
452
+ // 在 drawLabel 内部重新计算 translateX,确保使用最新的 controlInfo
453
+ var labelTranslateX = 0;
454
+ if (isC && isIOS && axisType === "x" && controlEnd !== undefined && start !== undefined) {
455
+ var percent = cBarX / (cWidth - cBarWidth);
456
+ var validPercent = isNaN(percent) ? 1 : percent;
457
+ labelTranslateX = -(controlEnd + start / cPercent - width) * validPercent;
458
+ }
447
459
  var draw = function draw(ticks, scaler) {
448
460
  return ticks.map(function (tick, index) {
449
461
  var coordinate = scaler(tick);
@@ -464,7 +476,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
464
476
  coordinate: coordinate,
465
477
  iosTrans: {
466
478
  isIOS: isIOS,
467
- x: marginLeft + x,
479
+ x: marginLeft + x + (isIOS && isC && axisType === "x" ? labelTranslateX : 0),
468
480
  y: marginTop + y
469
481
  },
470
482
  config: label,
@@ -127,6 +127,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
127
127
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
128
128
  controlInfo = _useState6[0],
129
129
  setControlInfo = _useState6[1];
130
+ var _useState7 = (0, _react.useState)(0),
131
+ _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
132
+ clipX = _useState8[0],
133
+ setClipX = _useState8[1];
130
134
  var cWidth = controlInfo.cWidth,
131
135
  cHeight = controlInfo.cHeight,
132
136
  cBarWidth = controlInfo.cBarWidth,
@@ -166,10 +170,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
166
170
  })
167
171
  };
168
172
  };
169
- var _useState7 = (0, _react.useState)(initCtlTip),
170
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
171
- ctlTip = _useState8[0],
172
- setCtlTip = _useState8[1]; //控制图的提示框
173
+ var _useState9 = (0, _react.useState)(initCtlTip),
174
+ _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
175
+ ctlTip = _useState10[0],
176
+ setCtlTip = _useState10[1]; //控制图的提示框
173
177
 
174
178
  (0, _react.useEffect)(function () {
175
179
  var handleAction = function handleAction(e) {
@@ -352,7 +356,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
352
356
  percent = isNaN(percent) ? 1 : percent;
353
357
  var translateX = -(controlEnd + start / cPercent - chartWidth) * percent;
354
358
  curControlPercent.current = percent;
355
- // seriesEl.current.style.transform = `translate(${translateX}px,${marginTop}px)`;
359
+ setClipX(-translateX);
360
+ var _isVertical = axisX.direction === "vertical";
361
+ var coreOffset = _isVertical ? marginRight : isIOS ? marginLeft : 0;
362
+ seriesEl.current.style.transform = "translate(".concat(translateX + coreOffset, "px,").concat(marginTop, "px)");
356
363
  axisElList.current[2].style.transform = "translate(".concat(translateX, "px,", 0, "px)");
357
364
  }
358
365
  }, [controlInfo]);
@@ -596,7 +603,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
596
603
  }, /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement("clipPath", {
597
604
  id: "chart-clip-".concat(id)
598
605
  }, /*#__PURE__*/_react["default"].createElement("rect", {
599
- x: "0",
606
+ x: clipX,
600
607
  y: "0",
601
608
  width: xLineRange,
602
609
  height: yLineRange,
@@ -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: "visible",
46
+ overflow: "hidden",
47
47
  position: "absolute",
48
48
  width: width,
49
49
  height: height
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.9.20",
3
+ "version": "1.9.22",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -388,13 +388,17 @@ export default memo(
388
388
  controlInfo,
389
389
  rawTicks,
390
390
  paddingOuter,
391
+ // 从展开的 config 中获取控制图相关属性
392
+ controlEnd,
393
+ start,
391
394
  }: any,
392
395
  ref
393
396
  ) => {
394
397
  const { width, height, isIOS } = useContext(chartContext);
395
- const { cHeight, isC, cPercent } = controlInfo;
398
+ const { cHeight, isC, cPercent, cBarX, cWidth, cBarWidth } = controlInfo;
396
399
  const x = orientation == "right" ? width : 0;
397
400
  const y = orientation == "bottom" ? height - cHeight : 0;
401
+
398
402
  let LabelWidth = 1;
399
403
  if (label.labelNum == "Fixed") {
400
404
  LabelWidth = label.appearance.width;
@@ -543,6 +547,21 @@ export default memo(
543
547
  }
544
548
  }
545
549
  function drawLabel() {
550
+ // 在 drawLabel 内部重新计算 translateX,确保使用最新的 controlInfo
551
+ let labelTranslateX = 0;
552
+ if (
553
+ isC &&
554
+ isIOS &&
555
+ axisType === "x" &&
556
+ controlEnd !== undefined &&
557
+ start !== undefined
558
+ ) {
559
+ const percent = cBarX / (cWidth - cBarWidth);
560
+ const validPercent = isNaN(percent) ? 1 : percent;
561
+ labelTranslateX =
562
+ -(controlEnd + start / cPercent - width) * validPercent;
563
+ }
564
+
546
565
  const draw = (ticks: any, scaler: any) => {
547
566
  return ticks.map((tick: string, index: number) => {
548
567
  const coordinate = scaler(tick);
@@ -571,7 +590,16 @@ export default memo(
571
590
  className="__easyv-label"
572
591
  orientation={orientation}
573
592
  coordinate={coordinate}
574
- iosTrans={{ isIOS, x: marginLeft + x, y: marginTop + y }}
593
+ iosTrans={{
594
+ isIOS,
595
+ x:
596
+ marginLeft +
597
+ x +
598
+ (isIOS && isC && axisType === "x"
599
+ ? labelTranslateX
600
+ : 0),
601
+ y: marginTop + y,
602
+ }}
575
603
  config={label}
576
604
  label={tick}
577
605
  tickSize={_tickSize}
@@ -115,6 +115,7 @@ const Chart = memo(
115
115
  cPercent: dragPercent,
116
116
  cBarX: controlX,
117
117
  });
118
+ const [clipX, setClipX] = useState(0);
118
119
  const { cWidth, cHeight, cBarWidth, cPercent, cBarX } = controlInfo;
119
120
 
120
121
  yLineRange -= cHeight;
@@ -344,7 +345,12 @@ const Chart = memo(
344
345
  const translateX =
345
346
  -(controlEnd + start / cPercent - chartWidth) * percent;
346
347
  curControlPercent.current = percent;
347
- // seriesEl.current.style.transform = `translate(${translateX}px,${marginTop}px)`;
348
+ setClipX(-translateX);
349
+ const isVertical = axisX.direction === "vertical";
350
+ const coreOffset = isVertical ? marginRight : isIOS ? marginLeft : 0;
351
+ seriesEl.current.style.transform = `translate(${
352
+ translateX + coreOffset
353
+ }px,${marginTop}px)`;
348
354
  axisElList.current[2].style.transform = `translate(${translateX}px,${0}px)`;
349
355
  }
350
356
  }, [controlInfo]);
@@ -506,6 +512,7 @@ const Chart = memo(
506
512
  style={{ ...style, position: "absolute" }}
507
513
  width={width}
508
514
  height={height}
515
+
509
516
  marginLeft={marginLeft}
510
517
  marginTop={marginTop}
511
518
  onMouseEnter={() => {
@@ -583,7 +590,6 @@ const Chart = memo(
583
590
  : `translateY(${-marginTop}px)`,
584
591
  }}
585
592
  >
586
- {/* 关键修改1:添加clipPath定义,限定裁剪区域 */}
587
593
  <svg
588
594
  width="100%"
589
595
  height="100%"
@@ -600,7 +606,7 @@ const Chart = memo(
600
606
  <defs>
601
607
  <clipPath id={`chart-clip-${id}`}>
602
608
  <rect
603
- x="0"
609
+ x={clipX}
604
610
  y="0"
605
611
  width={xLineRange}
606
612
  height={yLineRange}
@@ -610,6 +616,7 @@ const Chart = memo(
610
616
  </defs>
611
617
 
612
618
  {/* 关键修改2:将所有图表内容包裹在g标签中,并应用clipPath */}
619
+ {/* <g> */}
613
620
  <g clipPath={`url(#chart-clip-${id})`}>
614
621
  {/* 控制图指示器部分 */}
615
622
  <g>
@@ -54,7 +54,7 @@ export default memo(
54
54
  onMouseMove={onMouseMove}
55
55
  ref={ref}
56
56
  style={{
57
- overflow: "visible",
57
+ overflow: "hidden",
58
58
  position: "absolute",
59
59
  width,
60
60
  height,