@easyv/charts 1.9.22 → 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,
@@ -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,23 +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;
344
+ cPercent = controlInfo.cPercent;
350
345
  var x = orientation == "right" ? width : 0;
351
346
  var y = orientation == "bottom" ? height - cHeight : 0;
352
347
  var LabelWidth = 1;
353
- if (label.labelNum == "Fixed") {
348
+ if (!label.adaptive && label.appearance) {
354
349
  LabelWidth = label.appearance.width;
355
350
  } else {
356
351
  if (allTicks.length && typeof allTicks[0] == "string") {
@@ -358,7 +353,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
358
353
  }
359
354
  }
360
355
  var LabelNum = Math.floor(width / (isC ? cPercent : 1) * (1 - paddingOuter) / LabelWidth);
361
- 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);
362
357
  if (!(on && ticks.length > 0)) return null;
363
358
 
364
359
  //数据抽取逻辑
@@ -449,13 +444,6 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
449
444
  }
450
445
  }
451
446
  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
- }
459
447
  var draw = function draw(ticks, scaler) {
460
448
  return ticks.map(function (tick, index) {
461
449
  var coordinate = scaler(tick);
@@ -476,7 +464,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
476
464
  coordinate: coordinate,
477
465
  iosTrans: {
478
466
  isIOS: isIOS,
479
- x: marginLeft + x + (isIOS && isC && axisType === "x" ? labelTranslateX : 0),
467
+ x: marginLeft + x,
480
468
  y: marginTop + y
481
469
  },
482
470
  config: label,
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.9.22",
3
+ "version": "1.9.23",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -226,7 +226,7 @@ type LabelType = {
226
226
  events?: Function;
227
227
  config: {
228
228
  show: boolean;
229
- labelNum: string;
229
+ adaptive:boolean;
230
230
  translate: Translate;
231
231
  font: Font;
232
232
  textAlign: TextAlign;
@@ -277,7 +277,7 @@ const Label: (
277
277
  events = defaultEvent,
278
278
  config: {
279
279
  show,
280
- labelNum,
280
+ adaptive,
281
281
  style,
282
282
  translate: { x: translateX, y: translateY },
283
283
  font,
@@ -323,7 +323,7 @@ const Label: (
323
323
  }px)`, // 用 transform 定位
324
324
  }}
325
325
  >
326
- {labelNum == "Fixed" ? (
326
+ {!adaptive ? (
327
327
  <TextOverflow
328
328
  ShowType="normal"
329
329
  type={textOverflow}
@@ -388,19 +388,15 @@ export default memo(
388
388
  controlInfo,
389
389
  rawTicks,
390
390
  paddingOuter,
391
- // 从展开的 config 中获取控制图相关属性
392
- controlEnd,
393
- start,
394
391
  }: any,
395
392
  ref
396
393
  ) => {
397
394
  const { width, height, isIOS } = useContext(chartContext);
398
- const { cHeight, isC, cPercent, cBarX, cWidth, cBarWidth } = controlInfo;
395
+ const { cHeight, isC, cPercent } = controlInfo;
399
396
  const x = orientation == "right" ? width : 0;
400
397
  const y = orientation == "bottom" ? height - cHeight : 0;
401
-
402
398
  let LabelWidth = 1;
403
- if (label.labelNum == "Fixed") {
399
+ if (!label.adaptive&&label.appearance) {
404
400
  LabelWidth = label.appearance.width;
405
401
  } else {
406
402
  if (allTicks.length && typeof allTicks[0] == "string") {
@@ -411,7 +407,7 @@ export default memo(
411
407
  ((width / (isC ? cPercent : 1)) * (1 - paddingOuter)) / LabelWidth
412
408
  );
413
409
  const ticks: any =
414
- label.labelNum == "Fixed"
410
+ !label.adaptive
415
411
  ? tickss
416
412
  : getEvenlySpacedElements(
417
413
  allTicks,
@@ -547,21 +543,6 @@ export default memo(
547
543
  }
548
544
  }
549
545
  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
-
565
546
  const draw = (ticks: any, scaler: any) => {
566
547
  return ticks.map((tick: string, index: number) => {
567
548
  const coordinate = scaler(tick);
@@ -590,16 +571,7 @@ export default memo(
590
571
  className="__easyv-label"
591
572
  orientation={orientation}
592
573
  coordinate={coordinate}
593
- iosTrans={{
594
- isIOS,
595
- x:
596
- marginLeft +
597
- x +
598
- (isIOS && isC && axisType === "x"
599
- ? labelTranslateX
600
- : 0),
601
- y: marginTop + y,
602
- }}
574
+ iosTrans={{ isIOS, x: marginLeft + x, y: marginTop + y }}
603
575
  config={label}
604
576
  label={tick}
605
577
  tickSize={_tickSize}
@@ -512,7 +512,6 @@ const Chart = memo(
512
512
  style={{ ...style, position: "absolute" }}
513
513
  width={width}
514
514
  height={height}
515
-
516
515
  marginLeft={marginLeft}
517
516
  marginTop={marginTop}
518
517
  onMouseEnter={() => {
@@ -569,6 +568,7 @@ const Chart = memo(
569
568
  dataUnit={dataUnit}
570
569
  {...config}
571
570
  key={index}
571
+ clipX={clipX}
572
572
  />
573
573
  );
574
574
  })}
@@ -595,7 +595,7 @@ const Chart = memo(
595
595
  height="100%"
596
596
  ref={seriesEl}
597
597
  style={{
598
- overflow: "visible", // 保留原有样式,clipPath会接管裁剪
598
+ overflow: "visible",
599
599
  position: "absolute",
600
600
  transform: isVertical
601
601
  ? `translate(${marginRight}px,${isIOS ? marginTop : 0}px)`