@easyv/charts 1.10.33 → 1.10.34

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.
@@ -46,6 +46,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
46
46
  _ref$config$layout$al = _ref$config$layout.alignment,
47
47
  alignment = _ref$config$layout$al === void 0 ? "right center" : _ref$config$layout$al,
48
48
  gridTemplateColumns = _ref$config$layout.gridTemplateColumns,
49
+ layoutType = _ref$config$layout.layoutType,
49
50
  _ref$config$layout$gr = _ref$config$layout.gridGap,
50
51
  gridColumnGap = _ref$config$layout$gr.gridColumnGap,
51
52
  gridRowGap = _ref$config$layout$gr.gridRowGap,
@@ -226,6 +227,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
226
227
  var isPieAdaptive = isPieChart && layoutMode === "Adaptive";
227
228
  var isPieFixedWidthGrid = isPieChart && (layoutMode === "FixedWidth" || (layoutMode == null || layoutMode === "") && LegendType == "FixedWidth");
228
229
  var isFixedWidth = isPieChart ? isPieFixedWidthGrid : LegendType == "FixedWidth";
230
+ var isAxisFixedWidth = !isPieChart && (LegendType == "FixedWidth" || rootLayoutMode === "FixedWidth" || layoutType === "FixedWidth");
229
231
  var isSideLegend = isPieAdaptive && isSidePlacement;
230
232
  var isTopBottomAdaptive = isPieAdaptive && isCenterTopOrBottom;
231
233
  var fullWidth = (_ref4 = componentWidth !== null && componentWidth !== void 0 ? componentWidth : chartWidth) !== null && _ref4 !== void 0 ? _ref4 : 0;
@@ -429,6 +431,66 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
429
431
  })));
430
432
  })));
431
433
  }
434
+ if (isAxisFixedWidth) {
435
+ var axisLegendTextWidth = normalizeCssSize(maxWidth);
436
+ var axisGridColumns = Math.min(Math.max(1, Number(gridTemplateColumns) || 1), length);
437
+ return /*#__PURE__*/_react["default"].createElement("div", {
438
+ className: "__easyv-legend-wrapper",
439
+ style: _objectSpread(_objectSpread({
440
+ position: "absolute",
441
+ display: "flex"
442
+ }, getPosition(position, _alignment, x, y)), {}, {
443
+ height: loopHeight,
444
+ overflowY: loop.show ? "scroll" : "auto"
445
+ }),
446
+ ref: ref_container
447
+ }, /*#__PURE__*/_react["default"].createElement("ul", {
448
+ style: {
449
+ display: "grid",
450
+ gridGap: gridRowGap + "px " + gridColumnGap + "px",
451
+ gridTemplateColumns: "repeat(" + axisGridColumns + ", 1fr)"
452
+ }
453
+ }, _series.map(function (series, i) {
454
+ var _series$config3;
455
+ var type = series.type,
456
+ name = series.name,
457
+ displayName = series.displayName,
458
+ fieldName = series.fieldName,
459
+ icon = series.icon,
460
+ selected = series.selected,
461
+ index = series.index;
462
+ var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config3 = series.config) === null || _series$config3 === void 0 || (_series$config3 = _series$config3.line) === null || _series$config3 === void 0 ? void 0 : _series$config3.type);
463
+ return /*#__PURE__*/_react["default"].createElement("li", {
464
+ key: i,
465
+ onClick: onClick(fieldName),
466
+ "data-name": displayName || name,
467
+ "data-index": index,
468
+ style: {
469
+ display: "flex",
470
+ opacity: selected === false ? opacity / 100 : 1,
471
+ alignItems: "center",
472
+ cursor: "pointer",
473
+ gap: _icon.gap
474
+ }
475
+ }, /*#__PURE__*/_react["default"].createElement("span", {
476
+ style: _objectSpread(_objectSpread({}, _icon), {}, {
477
+ flexShrink: 0
478
+ })
479
+ }), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
480
+ type: textOverflow,
481
+ value: displayName || name,
482
+ style: _objectSpread(_objectSpread({}, font), {}, {
483
+ width: axisLegendTextWidth,
484
+ minWidth: axisLegendTextWidth,
485
+ flexShrink: 0,
486
+ boxSizing: "border-box",
487
+ fontStyle: italic ? "italic" : "normal",
488
+ fontWeight: bold ? "bold" : "normal"
489
+ }),
490
+ speed: speed
491
+ }));
492
+ })));
493
+ }
432
494
  return isFixedWidth ? /*#__PURE__*/_react["default"].createElement("div", {
433
495
  className: "__easyv-legend-wrapper",
434
496
  style: _objectSpread(_objectSpread({
@@ -448,7 +510,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
448
510
  gridTemplateColumns: isPieTopBottomFixedMultiCol ? "repeat(".concat(fixedColumnsPerRow, ", max-content)") : "repeat(".concat(fixedColumnsPerRow, ", minmax(0, 1fr))")
449
511
  }
450
512
  }, _series.map(function (series, i) {
451
- var _series$config3;
513
+ var _series$config4;
452
514
  var type = series.type,
453
515
  name = series.name,
454
516
  displayName = series.displayName,
@@ -456,7 +518,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
456
518
  icon = series.icon,
457
519
  selected = series.selected,
458
520
  index = series.index;
459
- var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config3 = series.config) === null || _series$config3 === void 0 || (_series$config3 = _series$config3.line) === null || _series$config3 === void 0 ? void 0 : _series$config3.type);
521
+ var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config4 = series.config) === null || _series$config4 === void 0 || (_series$config4 = _series$config4.line) === null || _series$config4 === void 0 ? void 0 : _series$config4.type);
460
522
  return /*#__PURE__*/_react["default"].createElement("li", {
461
523
  key: i,
462
524
  onClick: onClick(fieldName),
@@ -506,7 +568,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
506
568
  }
507
569
  }, _series.map(function (series, i) {
508
570
  if (Math.floor(i / columnsPerRow) == indexs) {
509
- var _series$config4;
571
+ var _series$config5;
510
572
  var type = series.type,
511
573
  name = series.name,
512
574
  displayName = series.displayName,
@@ -514,7 +576,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
514
576
  icon = series.icon,
515
577
  selected = series.selected,
516
578
  index = series.index;
517
- var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config4 = series.config) === null || _series$config4 === void 0 || (_series$config4 = _series$config4.line) === null || _series$config4 === void 0 ? void 0 : _series$config4.type);
579
+ var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config5 = series.config) === null || _series$config5 === void 0 || (_series$config5 = _series$config5.line) === null || _series$config5 === void 0 ? void 0 : _series$config5.type);
518
580
  return /*#__PURE__*/_react["default"].createElement("li", {
519
581
  key: i,
520
582
  onClick: onClick(fieldName),
@@ -554,7 +616,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
554
616
  gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px")
555
617
  }
556
618
  }, _series.map(function (series, i) {
557
- var _series$config5;
619
+ var _series$config6;
558
620
  var type = series.type,
559
621
  name = series.name,
560
622
  displayName = series.displayName,
@@ -562,7 +624,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
562
624
  icon = series.icon,
563
625
  selected = series.selected,
564
626
  index = series.index;
565
- var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config5 = series.config) === null || _series$config5 === void 0 || (_series$config5 = _series$config5.line) === null || _series$config5 === void 0 ? void 0 : _series$config5.type);
627
+ var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config6 = series.config) === null || _series$config6 === void 0 || (_series$config6 = _series$config6.line) === null || _series$config6 === void 0 ? void 0 : _series$config6.type);
566
628
  return /*#__PURE__*/_react["default"].createElement("li", {
567
629
  key: i,
568
630
  onClick: onClick(fieldName),
@@ -597,6 +659,17 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
597
659
  }));
598
660
  })));
599
661
  });
662
+ var normalizeCssSize = function normalizeCssSize(value) {
663
+ if (value == null || value === "") return value;
664
+ if (typeof value === "number" && Number.isFinite(value)) {
665
+ return "".concat(value, "px");
666
+ }
667
+ var str = String(value).trim();
668
+ if (/^-?\d+(\.\d+)?$/.test(str)) {
669
+ return "".concat(str, "px");
670
+ }
671
+ return str;
672
+ };
600
673
  var getPosition = function getPosition(position, alignment) {
601
674
  var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
602
675
  var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
@@ -27,8 +27,8 @@ var _excluded = ["startAngle", "endAngle", "antiClockwise"],
27
27
  _excluded2 = ["padAngle", "innerRadius", "outerRadius", "cornerRadius", "startAngle", "endAngle"],
28
28
  _excluded3 = ["formatter"],
29
29
  _excluded4 = ["startAngle", "endAngle"];
30
- /**
31
- * 饼环图
30
+ /**
31
+ * 饼环图
32
32
  */
33
33
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
34
34
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.10.33",
3
+ "version": "1.10.34",
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
+ }
@@ -29,6 +29,7 @@ export default memo(
29
29
  layout: {
30
30
  alignment = "right center",
31
31
  gridTemplateColumns,
32
+ layoutType,
32
33
  gridGap: { gridColumnGap, gridRowGap },
33
34
  translate: { x, y },
34
35
  },
@@ -247,6 +248,11 @@ export default memo(
247
248
  const isFixedWidth = isPieChart
248
249
  ? isPieFixedWidthGrid
249
250
  : LegendType == "FixedWidth";
251
+ const isAxisFixedWidth =
252
+ !isPieChart &&
253
+ (LegendType == "FixedWidth" ||
254
+ rootLayoutMode === "FixedWidth" ||
255
+ layoutType === "FixedWidth");
250
256
  const isSideLegend = isPieAdaptive && isSidePlacement;
251
257
  const isTopBottomAdaptive = isPieAdaptive && isCenterTopOrBottom;
252
258
  const fullWidth = componentWidth ?? chartWidth ?? 0;
@@ -507,6 +513,79 @@ export default memo(
507
513
  );
508
514
  }
509
515
 
516
+ if (isAxisFixedWidth) {
517
+ const axisLegendTextWidth = normalizeCssSize(maxWidth);
518
+ const axisGridColumns = Math.min(
519
+ Math.max(1, Number(gridTemplateColumns) || 1),
520
+ length,
521
+ );
522
+ return (
523
+ <div
524
+ className="__easyv-legend-wrapper"
525
+ style={{
526
+ position: "absolute",
527
+ display: "flex",
528
+ ...getPosition(position, _alignment, x, y),
529
+ height: loopHeight,
530
+ overflowY: loop.show ? "scroll" : "auto",
531
+ }}
532
+ ref={ref_container}
533
+ >
534
+ <ul
535
+ style={{
536
+ display: "grid",
537
+ gridGap: gridRowGap + "px " + gridColumnGap + "px",
538
+ gridTemplateColumns: "repeat(" + axisGridColumns + ", 1fr)",
539
+ }}
540
+ >
541
+ {_series.map((series, i) => {
542
+ const {
543
+ type,
544
+ name,
545
+ displayName,
546
+ fieldName,
547
+ icon,
548
+ selected,
549
+ index,
550
+ } = series;
551
+ const _icon = getIcon(type, icon, series?.config?.line?.type);
552
+ return (
553
+ <li
554
+ key={i}
555
+ onClick={onClick(fieldName)}
556
+ data-name={displayName || name}
557
+ data-index={index}
558
+ style={{
559
+ display: "flex",
560
+ opacity: selected === false ? opacity / 100 : 1,
561
+ alignItems: "center",
562
+ cursor: "pointer",
563
+ gap: _icon.gap,
564
+ }}
565
+ >
566
+ <span style={{ ..._icon, flexShrink: 0 }} />
567
+ <TextOverflow
568
+ type={textOverflow}
569
+ value={displayName || name}
570
+ style={{
571
+ ...font,
572
+ width: axisLegendTextWidth,
573
+ minWidth: axisLegendTextWidth,
574
+ flexShrink: 0,
575
+ boxSizing: "border-box",
576
+ fontStyle: italic ? "italic" : "normal",
577
+ fontWeight: bold ? "bold" : "normal",
578
+ }}
579
+ speed={speed}
580
+ />
581
+ </li>
582
+ );
583
+ })}
584
+ </ul>
585
+ </div>
586
+ );
587
+ }
588
+
510
589
  return isFixedWidth ? (
511
590
  <div
512
591
  className="__easyv-legend-wrapper"
@@ -723,6 +802,18 @@ export default memo(
723
802
  },
724
803
  );
725
804
 
805
+ const normalizeCssSize = (value) => {
806
+ if (value == null || value === "") return value;
807
+ if (typeof value === "number" && Number.isFinite(value)) {
808
+ return `${value}px`;
809
+ }
810
+ const str = String(value).trim();
811
+ if (/^-?\d+(\.\d+)?$/.test(str)) {
812
+ return `${str}px`;
813
+ }
814
+ return str;
815
+ };
816
+
726
817
  const getPosition = (position, alignment, x = 0, y = 0) => {
727
818
  switch (position) {
728
819
  case "top":