@easyv/charts 1.10.13 → 1.10.14
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.
package/lib/components/Legend.js
CHANGED
|
@@ -117,6 +117,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
117
117
|
_alignment$split2 = (0, _slicedToArray2["default"])(_alignment$split, 2),
|
|
118
118
|
_alignment = _alignment$split2[0],
|
|
119
119
|
position = _alignment$split2[1];
|
|
120
|
+
var legendMainAlign = alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end";
|
|
120
121
|
var length = _series.length;
|
|
121
122
|
var onClick = (0, _react.useCallback)(function (fieldName) {
|
|
122
123
|
return function (e) {
|
|
@@ -198,10 +199,8 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
198
199
|
overflowY: loop.show ? "scroll" : "auto"
|
|
199
200
|
}) : _objectSpread(_objectSpread({
|
|
200
201
|
width: "100%",
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
alignContent: alignment.split(" ")[0] == "center" && (alignment.split(" ")[1] == "left" || alignment.split(" ")[1] == "right") ? alignment.split(" ")[1] == "left" ? "flex-start" : "flex-end" : alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
|
|
204
|
-
flexDirection: "column",
|
|
202
|
+
maxWidth: "100%",
|
|
203
|
+
boxSizing: "border-box",
|
|
205
204
|
position: "absolute"
|
|
206
205
|
}, getPosition(position, _alignment, x, y)), {}, {
|
|
207
206
|
height: loop.show ? height : "auto",
|
|
@@ -270,16 +269,16 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
270
269
|
className: "__easyv-legend-wrapper",
|
|
271
270
|
style: stylePieOrAxis,
|
|
272
271
|
ref: ref_container
|
|
273
|
-
}, (0, _toConsumableArray2["default"])(Array(Math.ceil(series.length / gridTemplateColumns))).map(function (_, indexs) {
|
|
272
|
+
}, formatter ? (0, _toConsumableArray2["default"])(Array(Math.ceil(series.length / gridTemplateColumns))).map(function (_, indexs) {
|
|
274
273
|
return /*#__PURE__*/_react["default"].createElement("ul", {
|
|
275
274
|
key: indexs,
|
|
276
|
-
style:
|
|
275
|
+
style: {
|
|
277
276
|
display: "flex",
|
|
278
277
|
width: "fit-content",
|
|
279
|
-
justifyContent:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
278
|
+
justifyContent: legendMainAlign,
|
|
279
|
+
gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px"),
|
|
280
|
+
marginBottom: gridRowGap + "px"
|
|
281
|
+
}
|
|
283
282
|
}, _series.map(function (series, i) {
|
|
284
283
|
if (Math.floor(i / gridTemplateColumns) == indexs) {
|
|
285
284
|
var _series$config2;
|
|
@@ -302,9 +301,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
302
301
|
alignItems: "center",
|
|
303
302
|
cursor: "pointer",
|
|
304
303
|
gap: _icon.gap,
|
|
305
|
-
overflow:
|
|
304
|
+
overflow: "visible"
|
|
306
305
|
}
|
|
307
|
-
}, formatter
|
|
306
|
+
}, formatter(series, _objectSpread(_objectSpread({}, config), {}, {
|
|
308
307
|
valueMaxWidth: valueMaxWidth,
|
|
309
308
|
percentMaxWidth: percentMaxWidth,
|
|
310
309
|
nameMaxWidth: nameMaxWidth,
|
|
@@ -312,22 +311,66 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
312
311
|
columnsSeries: columnsSeries,
|
|
313
312
|
fieldColumnKeys: fieldColumnKeys,
|
|
314
313
|
fieldsColumnWidths: fieldsColumnWidths
|
|
315
|
-
})) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
316
|
-
style: _icon
|
|
317
|
-
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
318
|
-
ShowType: LegendType,
|
|
319
|
-
type: "ellipsis",
|
|
320
|
-
value: displayName || name,
|
|
321
|
-
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
322
|
-
fontStyle: italic ? "italic" : "normal",
|
|
323
|
-
fontWeight: bold ? "bold" : "normal",
|
|
324
|
-
minWidth: getCanvasTextWidth(displayName ? displayName.substring(0, 5) || name.substring(0, 5) : "", font.letterSpacing, "".concat(font.fontSize, "px ").concat(font.fontFamily))
|
|
325
|
-
}),
|
|
326
|
-
speed: speed
|
|
327
314
|
})));
|
|
328
315
|
}
|
|
329
316
|
}));
|
|
330
|
-
})
|
|
317
|
+
}) : /*#__PURE__*/_react["default"].createElement("ul", {
|
|
318
|
+
style: {
|
|
319
|
+
display: "flex",
|
|
320
|
+
flexDirection: "row",
|
|
321
|
+
flexWrap: "wrap",
|
|
322
|
+
width: "100%",
|
|
323
|
+
maxWidth: "100%",
|
|
324
|
+
boxSizing: "border-box",
|
|
325
|
+
margin: 0,
|
|
326
|
+
padding: 0,
|
|
327
|
+
listStyle: "none",
|
|
328
|
+
justifyContent: legendMainAlign,
|
|
329
|
+
gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px")
|
|
330
|
+
}
|
|
331
|
+
}, _series.map(function (series, i) {
|
|
332
|
+
var _series$config3;
|
|
333
|
+
var type = series.type,
|
|
334
|
+
name = series.name,
|
|
335
|
+
displayName = series.displayName,
|
|
336
|
+
fieldName = series.fieldName,
|
|
337
|
+
icon = series.icon,
|
|
338
|
+
selected = series.selected,
|
|
339
|
+
index = series.index;
|
|
340
|
+
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);
|
|
341
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
342
|
+
key: i,
|
|
343
|
+
onClick: onClick(fieldName),
|
|
344
|
+
"data-name": displayName || name,
|
|
345
|
+
"data-index": index,
|
|
346
|
+
style: {
|
|
347
|
+
display: "inline-flex",
|
|
348
|
+
alignItems: "center",
|
|
349
|
+
maxWidth: "100%",
|
|
350
|
+
minWidth: 0,
|
|
351
|
+
boxSizing: "border-box",
|
|
352
|
+
verticalAlign: "middle",
|
|
353
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
354
|
+
cursor: "pointer",
|
|
355
|
+
gap: _icon.gap
|
|
356
|
+
}
|
|
357
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
358
|
+
style: _objectSpread(_objectSpread({}, _icon), {}, {
|
|
359
|
+
flexShrink: 0
|
|
360
|
+
})
|
|
361
|
+
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
362
|
+
type: "ellipsis",
|
|
363
|
+
value: displayName || name,
|
|
364
|
+
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
365
|
+
fontStyle: italic ? "italic" : "normal",
|
|
366
|
+
fontWeight: bold ? "bold" : "normal",
|
|
367
|
+
minWidth: 0,
|
|
368
|
+
flex: "1 1 0%",
|
|
369
|
+
maxWidth: "100%"
|
|
370
|
+
}),
|
|
371
|
+
speed: speed
|
|
372
|
+
}));
|
|
373
|
+
})));
|
|
331
374
|
});
|
|
332
375
|
var getPosition = function getPosition(position, alignment) {
|
|
333
376
|
var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -24,8 +24,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
24
24
|
_props$speed = props.speed,
|
|
25
25
|
speed = _props$speed === void 0 ? 5 : _props$speed,
|
|
26
26
|
_props$config = props.config,
|
|
27
|
-
config = _props$config === void 0 ? {} : _props$config
|
|
28
|
-
ShowType = props.ShowType;
|
|
27
|
+
config = _props$config === void 0 ? {} : _props$config;
|
|
29
28
|
var _config$needTitle = config.needTitle,
|
|
30
29
|
needTitle = _config$needTitle === void 0 ? true : _config$needTitle;
|
|
31
30
|
var getTextOverflow = function getTextOverflow(type) {
|
|
@@ -62,9 +61,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
62
61
|
style: styles,
|
|
63
62
|
ref: ref
|
|
64
63
|
}) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
65
|
-
style: _objectSpread(
|
|
66
|
-
whiteSpace: ShowType == "Adaptive" ? "normal" : styles.whiteSpace
|
|
67
|
-
}),
|
|
64
|
+
style: _objectSpread({}, styles),
|
|
68
65
|
ref: ref,
|
|
69
66
|
title: needTitle && type == "ellipsis" ? text || undefined : undefined,
|
|
70
67
|
dangerouslySetInnerHTML: {
|
package/package.json
CHANGED
package/src/components/Legend.js
CHANGED
|
@@ -87,6 +87,12 @@ export default memo(
|
|
|
87
87
|
|
|
88
88
|
const _series = sortPie(series, order, columnsSeries);
|
|
89
89
|
const [_alignment, position] = alignment.split(" ");
|
|
90
|
+
const legendMainAlign =
|
|
91
|
+
alignment.split(" ")[0] == "left"
|
|
92
|
+
? "flex-start"
|
|
93
|
+
: alignment.split(" ")[0] == "center"
|
|
94
|
+
? "center"
|
|
95
|
+
: "flex-end";
|
|
90
96
|
const length = _series.length;
|
|
91
97
|
|
|
92
98
|
const onClick = useCallback(
|
|
@@ -221,21 +227,8 @@ export default memo(
|
|
|
221
227
|
}
|
|
222
228
|
: {
|
|
223
229
|
width: "100%",
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
alignContent:
|
|
227
|
-
alignment.split(" ")[0] == "center" &&
|
|
228
|
-
(alignment.split(" ")[1] == "left" ||
|
|
229
|
-
alignment.split(" ")[1] == "right")
|
|
230
|
-
? alignment.split(" ")[1] == "left"
|
|
231
|
-
? "flex-start"
|
|
232
|
-
: "flex-end"
|
|
233
|
-
: alignment.split(" ")[0] == "left"
|
|
234
|
-
? "flex-start"
|
|
235
|
-
: alignment.split(" ")[0] == "center"
|
|
236
|
-
? "center"
|
|
237
|
-
: "flex-end",
|
|
238
|
-
flexDirection: "column",
|
|
230
|
+
maxWidth: "100%",
|
|
231
|
+
boxSizing: "border-box",
|
|
239
232
|
position: "absolute",
|
|
240
233
|
...getPosition(position, _alignment, x, y),
|
|
241
234
|
height: loop.show ? height : "auto",
|
|
@@ -326,53 +319,47 @@ export default memo(
|
|
|
326
319
|
style={stylePieOrAxis}
|
|
327
320
|
ref={ref_container}
|
|
328
321
|
>
|
|
329
|
-
{
|
|
330
|
-
(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
gap: _icon.gap,
|
|
371
|
-
overflow: formatter ? "visible" : undefined,
|
|
372
|
-
}}
|
|
373
|
-
>
|
|
374
|
-
{formatter ? (
|
|
375
|
-
formatter(series, {
|
|
322
|
+
{formatter ? (
|
|
323
|
+
[...Array(Math.ceil(series.length / gridTemplateColumns))].map(
|
|
324
|
+
(_, indexs) => (
|
|
325
|
+
<ul
|
|
326
|
+
key={indexs}
|
|
327
|
+
style={{
|
|
328
|
+
display: "flex",
|
|
329
|
+
width: "fit-content",
|
|
330
|
+
justifyContent: legendMainAlign,
|
|
331
|
+
gap: `${gridRowGap}px ${gridColumnGap}px`,
|
|
332
|
+
marginBottom: gridRowGap + "px",
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
{_series.map((series, i) => {
|
|
336
|
+
if (Math.floor(i / gridTemplateColumns) == indexs) {
|
|
337
|
+
const {
|
|
338
|
+
type,
|
|
339
|
+
name,
|
|
340
|
+
displayName,
|
|
341
|
+
fieldName,
|
|
342
|
+
icon,
|
|
343
|
+
selected,
|
|
344
|
+
index,
|
|
345
|
+
} = series;
|
|
346
|
+
const _icon = getIcon(type, icon, series?.config?.line?.type);
|
|
347
|
+
return (
|
|
348
|
+
<li
|
|
349
|
+
key={i}
|
|
350
|
+
onClick={onClick(fieldName)}
|
|
351
|
+
data-name={displayName || name}
|
|
352
|
+
data-index={index}
|
|
353
|
+
style={{
|
|
354
|
+
display: "flex",
|
|
355
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
356
|
+
alignItems: "center",
|
|
357
|
+
cursor: "pointer",
|
|
358
|
+
gap: _icon.gap,
|
|
359
|
+
overflow: "visible",
|
|
360
|
+
}}
|
|
361
|
+
>
|
|
362
|
+
{formatter(series, {
|
|
376
363
|
...config,
|
|
377
364
|
valueMaxWidth,
|
|
378
365
|
percentMaxWidth,
|
|
@@ -381,37 +368,77 @@ export default memo(
|
|
|
381
368
|
columnsSeries,
|
|
382
369
|
fieldColumnKeys,
|
|
383
370
|
fieldsColumnWidths,
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
371
|
+
})}
|
|
372
|
+
</li>
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
})}
|
|
376
|
+
</ul>
|
|
377
|
+
),
|
|
378
|
+
)
|
|
379
|
+
) : (
|
|
380
|
+
<ul
|
|
381
|
+
style={{
|
|
382
|
+
display: "flex",
|
|
383
|
+
flexDirection: "row",
|
|
384
|
+
flexWrap: "wrap",
|
|
385
|
+
width: "100%",
|
|
386
|
+
maxWidth: "100%",
|
|
387
|
+
boxSizing: "border-box",
|
|
388
|
+
margin: 0,
|
|
389
|
+
padding: 0,
|
|
390
|
+
listStyle: "none",
|
|
391
|
+
justifyContent: legendMainAlign,
|
|
392
|
+
gap: `${gridRowGap}px ${gridColumnGap}px`,
|
|
393
|
+
}}
|
|
394
|
+
>
|
|
395
|
+
{_series.map((series, i) => {
|
|
396
|
+
const {
|
|
397
|
+
type,
|
|
398
|
+
name,
|
|
399
|
+
displayName,
|
|
400
|
+
fieldName,
|
|
401
|
+
icon,
|
|
402
|
+
selected,
|
|
403
|
+
index,
|
|
404
|
+
} = series;
|
|
405
|
+
const _icon = getIcon(type, icon, series?.config?.line?.type);
|
|
406
|
+
return (
|
|
407
|
+
<li
|
|
408
|
+
key={i}
|
|
409
|
+
onClick={onClick(fieldName)}
|
|
410
|
+
data-name={displayName || name}
|
|
411
|
+
data-index={index}
|
|
412
|
+
style={{
|
|
413
|
+
display: "inline-flex",
|
|
414
|
+
alignItems: "center",
|
|
415
|
+
maxWidth: "100%",
|
|
416
|
+
minWidth: 0,
|
|
417
|
+
boxSizing: "border-box",
|
|
418
|
+
verticalAlign: "middle",
|
|
419
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
420
|
+
cursor: "pointer",
|
|
421
|
+
gap: _icon.gap,
|
|
422
|
+
}}
|
|
423
|
+
>
|
|
424
|
+
<span style={{ ..._icon, flexShrink: 0 }} />
|
|
425
|
+
<TextOverflow
|
|
426
|
+
type="ellipsis"
|
|
427
|
+
value={displayName || name}
|
|
428
|
+
style={{
|
|
429
|
+
...font,
|
|
430
|
+
fontStyle: italic ? "italic" : "normal",
|
|
431
|
+
fontWeight: bold ? "bold" : "normal",
|
|
432
|
+
minWidth: 0,
|
|
433
|
+
flex: "1 1 0%",
|
|
434
|
+
maxWidth: "100%",
|
|
435
|
+
}}
|
|
436
|
+
speed={speed}
|
|
437
|
+
/>
|
|
438
|
+
</li>
|
|
439
|
+
);
|
|
440
|
+
})}
|
|
441
|
+
</ul>
|
|
415
442
|
)}
|
|
416
443
|
</div>
|
|
417
444
|
);
|
|
@@ -11,7 +11,8 @@ interface flowText {
|
|
|
11
11
|
speed: number;
|
|
12
12
|
style: CSSProperties;
|
|
13
13
|
config?: any;
|
|
14
|
-
|
|
14
|
+
/** 历史兼容字段,图例等调用方可能传入,已不再影响省略号换行行为 */
|
|
15
|
+
ShowType?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export default memo(
|
|
@@ -22,7 +23,6 @@ export default memo(
|
|
|
22
23
|
style, // 样式
|
|
23
24
|
speed = 5, // 动画速度
|
|
24
25
|
config = {},
|
|
25
|
-
ShowType,
|
|
26
26
|
} = props;
|
|
27
27
|
const { needTitle = true } = config;
|
|
28
28
|
|
|
@@ -64,7 +64,6 @@ export default memo(
|
|
|
64
64
|
<div
|
|
65
65
|
style={{
|
|
66
66
|
...styles,
|
|
67
|
-
whiteSpace: ShowType == "Adaptive" ? "normal" : styles.whiteSpace,
|
|
68
67
|
}}
|
|
69
68
|
ref={ref}
|
|
70
69
|
title={needTitle && type == "ellipsis" ? text || undefined : undefined}
|