@easyv/charts 1.10.15 → 1.10.17

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.
@@ -54,9 +54,12 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
54
54
  y = _ref$config$layout$tr.y,
55
55
  _ref$config$loop = _ref$config.loop,
56
56
  loop = _ref$config$loop === void 0 ? {} : _ref$config$loop,
57
+ rootLayoutMode = _ref$config.layoutMode,
57
58
  _ref$config$name = _ref$config.name,
58
59
  _ref$config$name2 = _ref$config$name === void 0 ? {} : _ref$config$name,
59
- layoutMode = _ref$config$name2.layoutMode,
60
+ nameLayoutMode = _ref$config$name2.layoutMode,
61
+ _ref$config$iconGap = _ref$config.iconGap,
62
+ iconGap = _ref$config$iconGap === void 0 ? 5 : _ref$config$iconGap,
60
63
  _ref$config$font = _ref$config.font,
61
64
  _ref$config$font2 = _ref$config$font === void 0 ? defaultFont : _ref$config$font,
62
65
  italic = _ref$config$font2.italic,
@@ -202,6 +205,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
202
205
  });
203
206
  return Math.max(maxMeasured, maxCfg);
204
207
  });
208
+
209
+ // legendOfRose:layoutMode 在 config 根级;legendOfPie:在 config.name.layoutMode
210
+ var layoutMode = nameLayoutMode !== null && nameLayoutMode !== void 0 ? nameLayoutMode : rootLayoutMode;
205
211
  var isPieAdaptive = isPieChart && layoutMode === "Adaptive";
206
212
  var isPieFixedWidthGrid = isPieChart && (layoutMode === "FixedWidth" || (layoutMode == null || layoutMode === "") && LegendType == "FixedWidth");
207
213
  var isFixedWidth = isPieChart ? isPieFixedWidthGrid : LegendType == "FixedWidth";
@@ -210,7 +216,6 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
210
216
  var fullWidth = (_ref3 = componentWidth !== null && componentWidth !== void 0 ? componentWidth : chartWidth) !== null && _ref3 !== void 0 ? _ref3 : 0;
211
217
  var legendAreaWidth = Math.max(0, fullWidth - marginLeft - marginRight);
212
218
  var sideLegendMaxWidth = isSideLegend ? Math.max(0, position === "left" || _alignment === "left" ? marginLeft : marginRight) : 0;
213
- var isSideLegendOnRight = isSideLegend && (position === "right" || _alignment === "right" && position !== "left");
214
219
  var fixedColumnsPerRow = Math.min(Math.max(1, Number(gridTemplateColumns) || 1), length);
215
220
  var isPieTopBottomFixedMultiCol = isPieChart && isFixedWidth && isCenterTopOrBottom && fixedColumnsPerRow > 1;
216
221
  var formatterExtra = _objectSpread(_objectSpread(_objectSpread({}, config), {}, {
@@ -238,26 +243,30 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
238
243
  selected = series.selected,
239
244
  index = series.index;
240
245
  var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config = series.config) === null || _series$config === void 0 || (_series$config = _series$config.line) === null || _series$config === void 0 ? void 0 : _series$config.type);
246
+ var sideIconWidth = parseFloat(_icon.width) || parseFloat(_icon.minWidth) || parseFloat(icon === null || icon === void 0 ? void 0 : icon.width) || 0;
247
+ var sideItemGap = Number(iconGap) || parseFloat(_icon.marginRight) || 0;
248
+ var sideTextMaxWidth = sideLegendMaxWidth > 0 ? Math.max(0, sideLegendMaxWidth - sideIconWidth - sideItemGap) : undefined;
241
249
  return /*#__PURE__*/_react["default"].createElement("li", {
242
250
  key: i,
243
251
  onClick: onClick(fieldName),
244
252
  "data-name": displayName || name,
245
253
  "data-index": index,
246
254
  style: {
247
- display: "flex",
255
+ display: "inline-flex",
248
256
  width: "max-content",
249
- maxWidth: sideLegendMaxWidth || undefined,
257
+ maxWidth: "100%",
250
258
  opacity: selected === false ? opacity / 100 : 1,
251
259
  alignItems: "center",
252
260
  cursor: "pointer",
253
- gap: _icon.gap,
261
+ gap: sideItemGap,
254
262
  minWidth: 0,
255
263
  overflow: "hidden",
256
264
  boxSizing: "border-box"
257
265
  }
258
266
  }, formatter ? formatter(series, formatterExtra) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
259
267
  style: _objectSpread(_objectSpread({}, _icon), {}, {
260
- flexShrink: 0
268
+ flexShrink: 0,
269
+ marginRight: 0
261
270
  })
262
271
  }), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
263
272
  type: "ellipsis",
@@ -265,9 +274,10 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
265
274
  style: _objectSpread(_objectSpread({}, font), {}, {
266
275
  fontStyle: italic ? "italic" : "normal",
267
276
  fontWeight: bold ? "bold" : "normal",
277
+ width: "auto",
278
+ maxWidth: sideTextMaxWidth,
268
279
  minWidth: 0,
269
- flex: "1 1 0%",
270
- maxWidth: "100%"
280
+ flex: "0 1 auto"
271
281
  }),
272
282
  speed: speed
273
283
  })));
@@ -290,13 +300,14 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
290
300
  overflowY: loop.show ? "scroll" : "auto"
291
301
  });
292
302
  if (isPieAdaptive && isSideLegend) {
303
+ // 左右侧图例:水平方向始终左对齐,图标落在同一条纵线上(与九宫格水平分量无关)
293
304
  var pieAdaptiveWrapperStyle = _objectSpread(_objectSpread({
294
305
  position: "absolute",
295
306
  display: "flex",
296
307
  flexDirection: "column",
297
308
  width: "max-content",
298
309
  maxWidth: sideLegendMaxWidth || undefined,
299
- alignItems: isSideLegendOnRight ? "flex-end" : "flex-start"
310
+ alignItems: "flex-start"
300
311
  }, getPosition(position, _alignment, x, y)), {}, {
301
312
  height: loop.show ? height : "auto",
302
313
  overflowY: loop.show ? "scroll" : "auto"
@@ -306,7 +317,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
306
317
  flexDirection: "column",
307
318
  width: "max-content",
308
319
  maxWidth: "100%",
309
- alignItems: isSideLegendOnRight ? "flex-end" : "flex-start",
320
+ alignItems: "flex-start",
310
321
  margin: 0,
311
322
  padding: 0,
312
323
  listStyle: "none",
@@ -49,14 +49,14 @@ var PIE_ADAPTIVE_MARGINS = {
49
49
  marginRight: 0
50
50
  },
51
51
  top: {
52
- marginTop: 150,
52
+ marginTop: 110,
53
53
  marginBottom: 24,
54
54
  marginLeft: 24,
55
55
  marginRight: 24
56
56
  },
57
57
  bottom: {
58
58
  marginTop: 24,
59
- marginBottom: 150,
59
+ marginBottom: 110,
60
60
  marginLeft: 24,
61
61
  marginRight: 24
62
62
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.10.15",
3
+ "version": "1.10.17",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -33,7 +33,9 @@ export default memo(
33
33
  translate: { x, y },
34
34
  },
35
35
  loop = {},
36
- name: { layoutMode } = {},
36
+ layoutMode: rootLayoutMode,
37
+ name: { layoutMode: nameLayoutMode } = {},
38
+ iconGap = 5,
37
39
  font: { italic, bold, ...font } = defaultFont,
38
40
  unselect: { opacity = 1 } = {},
39
41
  },
@@ -216,6 +218,8 @@ export default memo(
216
218
  return Math.max(maxMeasured, maxCfg);
217
219
  });
218
220
 
221
+ // legendOfRose:layoutMode 在 config 根级;legendOfPie:在 config.name.layoutMode
222
+ const layoutMode = nameLayoutMode ?? rootLayoutMode;
219
223
  const isPieAdaptive = isPieChart && layoutMode === "Adaptive";
220
224
  const isPieFixedWidthGrid =
221
225
  isPieChart &&
@@ -237,10 +241,6 @@ export default memo(
237
241
  : marginRight,
238
242
  )
239
243
  : 0;
240
- const isSideLegendOnRight =
241
- isSideLegend &&
242
- (position === "right" ||
243
- (_alignment === "right" && position !== "left"));
244
244
  const fixedColumnsPerRow = Math.min(
245
245
  Math.max(1, Number(gridTemplateColumns) || 1),
246
246
  length,
@@ -269,16 +269,20 @@ export default memo(
269
269
  };
270
270
 
271
271
  const renderPieSideItem = (series, i) => {
272
- const {
273
- type,
274
- name,
275
- displayName,
276
- fieldName,
277
- icon,
278
- selected,
279
- index,
280
- } = series;
272
+ const { type, name, displayName, fieldName, icon, selected, index } =
273
+ series;
281
274
  const _icon = getIcon(type, icon, series?.config?.line?.type);
275
+ const sideIconWidth =
276
+ parseFloat(_icon.width) ||
277
+ parseFloat(_icon.minWidth) ||
278
+ parseFloat(icon?.width) ||
279
+ 0;
280
+ const sideItemGap =
281
+ Number(iconGap) || parseFloat(_icon.marginRight) || 0;
282
+ const sideTextMaxWidth =
283
+ sideLegendMaxWidth > 0
284
+ ? Math.max(0, sideLegendMaxWidth - sideIconWidth - sideItemGap)
285
+ : undefined;
282
286
  return (
283
287
  <li
284
288
  key={i}
@@ -286,13 +290,13 @@ export default memo(
286
290
  data-name={displayName || name}
287
291
  data-index={index}
288
292
  style={{
289
- display: "flex",
293
+ display: "inline-flex",
290
294
  width: "max-content",
291
- maxWidth: sideLegendMaxWidth || undefined,
295
+ maxWidth: "100%",
292
296
  opacity: selected === false ? opacity / 100 : 1,
293
297
  alignItems: "center",
294
298
  cursor: "pointer",
295
- gap: _icon.gap,
299
+ gap: sideItemGap,
296
300
  minWidth: 0,
297
301
  overflow: "hidden",
298
302
  boxSizing: "border-box",
@@ -302,7 +306,13 @@ export default memo(
302
306
  formatter(series, formatterExtra)
303
307
  ) : (
304
308
  <>
305
- <span style={{ ..._icon, flexShrink: 0 }} />
309
+ <span
310
+ style={{
311
+ ..._icon,
312
+ flexShrink: 0,
313
+ marginRight: 0,
314
+ }}
315
+ />
306
316
  <TextOverflow
307
317
  type="ellipsis"
308
318
  value={displayName || name}
@@ -310,9 +320,10 @@ export default memo(
310
320
  ...font,
311
321
  fontStyle: italic ? "italic" : "normal",
312
322
  fontWeight: bold ? "bold" : "normal",
323
+ width: "auto",
324
+ maxWidth: sideTextMaxWidth,
313
325
  minWidth: 0,
314
- flex: "1 1 0%",
315
- maxWidth: "100%",
326
+ flex: "0 1 auto",
316
327
  }}
317
328
  speed={speed}
318
329
  />
@@ -353,13 +364,14 @@ export default memo(
353
364
  overflowY: loop.show ? "scroll" : "auto",
354
365
  };
355
366
  if (isPieAdaptive && isSideLegend) {
367
+ // 左右侧图例:水平方向始终左对齐,图标落在同一条纵线上(与九宫格水平分量无关)
356
368
  const pieAdaptiveWrapperStyle = {
357
369
  position: "absolute",
358
370
  display: "flex",
359
371
  flexDirection: "column",
360
372
  width: "max-content",
361
373
  maxWidth: sideLegendMaxWidth || undefined,
362
- alignItems: isSideLegendOnRight ? "flex-end" : "flex-start",
374
+ alignItems: "flex-start",
363
375
  ...getPosition(position, _alignment, x, y),
364
376
  height: loop.show ? height : "auto",
365
377
  overflowY: loop.show ? "scroll" : "auto",
@@ -369,7 +381,7 @@ export default memo(
369
381
  flexDirection: "column",
370
382
  width: "max-content",
371
383
  maxWidth: "100%",
372
- alignItems: isSideLegendOnRight ? "flex-end" : "flex-start",
384
+ alignItems: "flex-start",
373
385
  margin: 0,
374
386
  padding: 0,
375
387
  listStyle: "none",
@@ -591,7 +603,11 @@ export default memo(
591
603
  selected,
592
604
  index,
593
605
  } = series;
594
- const _icon = getIcon(type, icon, series?.config?.line?.type);
606
+ const _icon = getIcon(
607
+ type,
608
+ icon,
609
+ series?.config?.line?.type,
610
+ );
595
611
  return (
596
612
  <li
597
613
  key={i}
@@ -41,8 +41,8 @@ const PI = Math.PI;
41
41
  const PIE_ADAPTIVE_MARGINS = {
42
42
  right: { marginTop: 24, marginBottom: 24, marginLeft: 0, marginRight: 200 },
43
43
  left: { marginTop: 24, marginBottom: 24, marginLeft: 200, marginRight: 0 },
44
- top: { marginTop: 150, marginBottom: 24, marginLeft: 24, marginRight: 24 },
45
- bottom: { marginTop: 24, marginBottom: 150, marginLeft: 24, marginRight: 24 },
44
+ top: { marginTop: 110, marginBottom: 24, marginLeft: 24, marginRight: 24 },
45
+ bottom: { marginTop: 24, marginBottom: 110, marginLeft: 24, marginRight: 24 },
46
46
  hidden: { marginTop: 24, marginBottom: 24, marginLeft: 24, marginRight: 24 },
47
47
  };
48
48