@easyv/charts 1.9.21 → 1.9.23

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.
@@ -227,7 +227,7 @@ var Label = function Label(_ref5) {
227
227
  events = _ref5$events === void 0 ? defaultEvent : _ref5$events,
228
228
  _ref5$config = _ref5.config,
229
229
  show = _ref5$config.show,
230
- labelNum = _ref5$config.labelNum,
230
+ adaptive = _ref5$config.adaptive,
231
231
  style = _ref5$config.style,
232
232
  _ref5$config$translat = _ref5$config.translate,
233
233
  translateX = _ref5$config$translat.x,
@@ -264,7 +264,7 @@ var Label = function Label(_ref5) {
264
264
  // y={y}
265
265
  ,
266
266
  style: {
267
- overflow: "hidden"
267
+ overflow: "visible"
268
268
  }
269
269
  }, /*#__PURE__*/_react["default"].createElement("div", {
270
270
  className: className,
@@ -280,7 +280,7 @@ var Label = function Label(_ref5) {
280
280
  cursor: "pointer",
281
281
  transform: "translate(".concat(x + (isIOS ? iosX : 0), "px, ").concat(y + (isIOS ? iosY : 0), "px)") // 用 transform 定位
282
282
  })
283
- }, labelNum == "Fixed" ? /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
283
+ }, !adaptive ? /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
284
284
  ShowType: "normal",
285
285
  type: textOverflow,
286
286
  speed: speed,
@@ -334,24 +334,18 @@ 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,
338
- controlEnd = _ref6.controlEnd,
339
- start = _ref6.start;
337
+ paddingOuter = _ref6.paddingOuter;
340
338
  var _useContext = (0, _react.useContext)(_context.chartContext),
341
339
  width = _useContext.width,
342
340
  height = _useContext.height,
343
341
  isIOS = _useContext.isIOS;
344
342
  var cHeight = controlInfo.cHeight,
345
343
  isC = controlInfo.isC,
346
- cPercent = controlInfo.cPercent,
347
- cBarX = controlInfo.cBarX,
348
- cWidth = controlInfo.cWidth,
349
- cBarWidth = controlInfo.cBarWidth;
350
- var clipPathIdRef = (0, _react.useRef)("axis-clip-".concat(orientation, "-").concat(axisType, "-").concat(Math.random().toString(36).substr(2, 9)));
344
+ cPercent = controlInfo.cPercent;
351
345
  var x = orientation == "right" ? width : 0;
352
346
  var y = orientation == "bottom" ? height - cHeight : 0;
353
347
  var LabelWidth = 1;
354
- if (label.labelNum == "Fixed") {
348
+ if (!label.adaptive && label.appearance) {
355
349
  LabelWidth = label.appearance.width;
356
350
  } else {
357
351
  if (allTicks.length && typeof allTicks[0] == "string") {
@@ -359,7 +353,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
359
353
  }
360
354
  }
361
355
  var LabelNum = Math.floor(width / (isC ? cPercent : 1) * (1 - paddingOuter) / LabelWidth);
362
- var ticks = label.labelNum == "Fixed" ? tickss : getEvenlySpacedElements(allTicks, LabelNum < allTicks.length ? LabelNum > allTicks.length / 2 ? Math.ceil(allTicks.length / 2) : LabelNum : allTicks.length, label.showLast);
356
+ var ticks = !label.adaptive ? tickss : getEvenlySpacedElements(allTicks, LabelNum < allTicks.length ? LabelNum > allTicks.length / 2 ? Math.ceil(allTicks.length / 2) : LabelNum : allTicks.length, label.showLast);
363
357
  if (!(on && ticks.length > 0)) return null;
364
358
 
365
359
  //数据抽取逻辑
@@ -450,13 +444,6 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
450
444
  }
451
445
  }
452
446
  function drawLabel() {
453
- // 在 drawLabel 内部重新计算 translateX,确保使用最新的 controlInfo
454
- var labelTranslateX = 0;
455
- if (isC && isIOS && axisType === "x" && controlEnd !== undefined && start !== undefined) {
456
- var percent = cBarX / (cWidth - cBarWidth);
457
- var validPercent = isNaN(percent) ? 1 : percent;
458
- labelTranslateX = -(controlEnd + start / cPercent - width) * validPercent;
459
- }
460
447
  var draw = function draw(ticks, scaler) {
461
448
  return ticks.map(function (tick, index) {
462
449
  var coordinate = scaler(tick);
@@ -477,7 +464,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
477
464
  coordinate: coordinate,
478
465
  iosTrans: {
479
466
  isIOS: isIOS,
480
- x: marginLeft + x + (isIOS && isC && axisType === "x" ? labelTranslateX : 0),
467
+ x: marginLeft + x,
481
468
  y: marginTop + y
482
469
  },
483
470
  config: label,
@@ -550,20 +537,10 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
550
537
  }), tickLine && drawAxisTickLine()))), /*#__PURE__*/_react["default"].createElement("svg", {
551
538
  width: width,
552
539
  style: {
553
- overflow: "hidden"
540
+ overflow: axisType === "x" && isC ? "hidden" : "visible"
554
541
  }
555
- }, axisType === "x" && isC || isIOS && axisType === "x" ? /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement("clipPath", {
556
- id: clipPathIdRef.current,
557
- clipPathUnits: "userSpaceOnUse"
558
- }, /*#__PURE__*/_react["default"].createElement("rect", {
559
- x: "0",
560
- y: "0",
561
- width: xLineRange,
562
- height: height + 200,
563
- fill: "transparent"
564
- }))) : null, /*#__PURE__*/_react["default"].createElement("g", {
565
- transform: "translate(" + x + ", " + y + ")",
566
- clipPath: axisType === "x" && isC || isIOS && axisType === "x" ? "url(#".concat(clipPathIdRef.current, ")") : undefined
542
+ }, /*#__PURE__*/_react["default"].createElement("g", {
543
+ transform: "translate(" + x + ", " + y + ")"
567
544
  }, /*#__PURE__*/_react["default"].createElement("g", {
568
545
  ref: ref
569
546
  }, label && gridLine && drawLabel(), isC && /*#__PURE__*/_react["default"].createElement(AxisLine, {
@@ -579,7 +579,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
579
579
  },
580
580
  dataUnit: dataUnit
581
581
  }, config, {
582
- key: index
582
+ key: index,
583
+ clipX: clipX
583
584
  }));
584
585
  }), showTooltip && !control && zIndex == "bottom" && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, {
585
586
  manual: true,
@@ -596,7 +597,6 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
596
597
  ref: seriesEl,
597
598
  style: {
598
599
  overflow: "visible",
599
- // 保留原有样式,clipPath会接管裁剪
600
600
  position: "absolute",
601
601
  transform: isVertical ? "translate(".concat(marginRight, "px,").concat(isIOS ? marginTop : 0, "px)") : "translate(".concat(isIOS ? marginLeft : 0, "px,").concat(marginTop, "px)")
602
602
  }
@@ -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.21",
3
+ "version": "1.9.23",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -9,7 +9,6 @@ import React, {
9
9
  CSSProperties,
10
10
  MouseEventHandler,
11
11
  forwardRef,
12
- useRef,
13
12
  } from "react";
14
13
  import { getTickCoord, getGridCoord, getFontStyle } from "../utils";
15
14
  import { chartContext } from "../context";
@@ -227,7 +226,7 @@ type LabelType = {
227
226
  events?: Function;
228
227
  config: {
229
228
  show: boolean;
230
- labelNum: string;
229
+ adaptive:boolean;
231
230
  translate: Translate;
232
231
  font: Font;
233
232
  textAlign: TextAlign;
@@ -278,7 +277,7 @@ const Label: (
278
277
  events = defaultEvent,
279
278
  config: {
280
279
  show,
281
- labelNum,
280
+ adaptive,
282
281
  style,
283
282
  translate: { x: translateX, y: translateY },
284
283
  font,
@@ -308,7 +307,7 @@ const Label: (
308
307
  height="100%"
309
308
  // x={x}
310
309
  // y={y}
311
- style={{ overflow: "hidden" }}
310
+ style={{ overflow: "visible" }}
312
311
  >
313
312
  <div
314
313
  className={className}
@@ -324,7 +323,7 @@ const Label: (
324
323
  }px)`, // 用 transform 定位
325
324
  }}
326
325
  >
327
- {labelNum == "Fixed" ? (
326
+ {!adaptive ? (
328
327
  <TextOverflow
329
328
  ShowType="normal"
330
329
  type={textOverflow}
@@ -389,24 +388,15 @@ export default memo(
389
388
  controlInfo,
390
389
  rawTicks,
391
390
  paddingOuter,
392
- // 从展开的 config 中获取控制图相关属性
393
- controlEnd,
394
- start,
395
391
  }: any,
396
392
  ref
397
393
  ) => {
398
394
  const { width, height, isIOS } = useContext(chartContext);
399
- const { cHeight, isC, cPercent, cBarX, cWidth, cBarWidth } = controlInfo;
400
- const clipPathIdRef = useRef(
401
- `axis-clip-${orientation}-${axisType}-${Math.random()
402
- .toString(36)
403
- .substr(2, 9)}`
404
- );
395
+ const { cHeight, isC, cPercent } = controlInfo;
405
396
  const x = orientation == "right" ? width : 0;
406
397
  const y = orientation == "bottom" ? height - cHeight : 0;
407
-
408
398
  let LabelWidth = 1;
409
- if (label.labelNum == "Fixed") {
399
+ if (!label.adaptive&&label.appearance) {
410
400
  LabelWidth = label.appearance.width;
411
401
  } else {
412
402
  if (allTicks.length && typeof allTicks[0] == "string") {
@@ -417,7 +407,7 @@ export default memo(
417
407
  ((width / (isC ? cPercent : 1)) * (1 - paddingOuter)) / LabelWidth
418
408
  );
419
409
  const ticks: any =
420
- label.labelNum == "Fixed"
410
+ !label.adaptive
421
411
  ? tickss
422
412
  : getEvenlySpacedElements(
423
413
  allTicks,
@@ -553,21 +543,6 @@ export default memo(
553
543
  }
554
544
  }
555
545
  function drawLabel() {
556
- // 在 drawLabel 内部重新计算 translateX,确保使用最新的 controlInfo
557
- let labelTranslateX = 0;
558
- if (
559
- isC &&
560
- isIOS &&
561
- axisType === "x" &&
562
- controlEnd !== undefined &&
563
- start !== undefined
564
- ) {
565
- const percent = cBarX / (cWidth - cBarWidth);
566
- const validPercent = isNaN(percent) ? 1 : percent;
567
- labelTranslateX =
568
- -(controlEnd + start / cPercent - width) * validPercent;
569
- }
570
-
571
546
  const draw = (ticks: any, scaler: any) => {
572
547
  return ticks.map((tick: string, index: number) => {
573
548
  const coordinate = scaler(tick);
@@ -596,16 +571,7 @@ export default memo(
596
571
  className="__easyv-label"
597
572
  orientation={orientation}
598
573
  coordinate={coordinate}
599
- iosTrans={{
600
- isIOS,
601
- x:
602
- marginLeft +
603
- x +
604
- (isIOS && isC && axisType === "x"
605
- ? labelTranslateX
606
- : 0),
607
- y: marginTop + y,
608
- }}
574
+ iosTrans={{ isIOS, x: marginLeft + x, y: marginTop + y }}
609
575
  config={label}
610
576
  label={tick}
611
577
  tickSize={_tickSize}
@@ -714,34 +680,10 @@ export default memo(
714
680
  <svg
715
681
  width={width}
716
682
  style={{
717
- overflow: "hidden",
683
+ overflow: axisType === "x" && isC ? "hidden" : "visible",
718
684
  }}
719
685
  >
720
- {/* 定义裁剪路径:用于iOS端超出隐藏 */}
721
- {(axisType === "x" && isC) || (isIOS && axisType === "x") ? (
722
- <defs>
723
- <clipPath
724
- id={clipPathIdRef.current}
725
- clipPathUnits="userSpaceOnUse"
726
- >
727
- <rect
728
- x="0"
729
- y="0"
730
- width={xLineRange}
731
- height={height + 200}
732
- fill="transparent"
733
- />
734
- </clipPath>
735
- </defs>
736
- ) : null}
737
- <g
738
- transform={"translate(" + x + ", " + y + ")"}
739
- clipPath={
740
- (axisType === "x" && isC) || (isIOS && axisType === "x")
741
- ? `url(#${clipPathIdRef.current})`
742
- : undefined
743
- }
744
- >
686
+ <g transform={"translate(" + x + ", " + y + ")"}>
745
687
  {/* 用于控制图 */}
746
688
  <g ref={ref as any}>
747
689
  {label && gridLine && drawLabel()}
@@ -568,6 +568,7 @@ const Chart = memo(
568
568
  dataUnit={dataUnit}
569
569
  {...config}
570
570
  key={index}
571
+ clipX={clipX}
571
572
  />
572
573
  );
573
574
  })}
@@ -594,7 +595,7 @@ const Chart = memo(
594
595
  height="100%"
595
596
  ref={seriesEl}
596
597
  style={{
597
- overflow: "visible", // 保留原有样式,clipPath会接管裁剪
598
+ overflow: "visible",
598
599
  position: "absolute",
599
600
  transform: isVertical
600
601
  ? `translate(${marginRight}px,${isIOS ? marginTop : 0}px)`
@@ -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,