@easyv/charts 1.10.13 → 1.10.15
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/change.md +26 -0
- package/config.json +119 -0
- package/lib/components/Chart.js +5 -5
- package/lib/components/Legend.js +272 -38
- package/lib/components/Marquee.js +1 -1
- package/lib/components/PieChart.js +193 -102
- package/lib/components/TextOverflow.js +2 -5
- package/lib/formatter/legend.js +78 -26
- package/lib/utils/legendPlacement.js +37 -0
- package/package.json +2 -2
- package/src/components/Chart.js +11 -3
- package/src/components/Legend.js +374 -99
- package/src/components/Marquee.tsx +4 -4
- package/src/components/PieChart.js +161 -102
- package/src/components/TextOverflow.tsx +2 -3
- package/src/formatter/legend.js +151 -68
- package/src/utils/legendPlacement.js +28 -0
package/change.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
### 1.饼图图例的类目配置项下有一个布局类型配置项,当布局类型=固定宽度时,沿用当前的逻辑,当布局类型=自适应时,需要进行如下调整:
|
|
2
|
+
|
|
3
|
+
- 当图例位置在左侧时或右侧时,调用updateConfig函数修改组件的边距配置项,图例在右侧时,上下左右边距分别为:24,24,0,200,图例在左侧时,上下左右边距分别为,24,24,200,0。图例将纵向排成一列展示,每一行图例总宽度不能超过200px,避免和饼图区域产生重叠,如果文字太长,则默认按溢出省略号展示,文本不得换行。
|
|
4
|
+
- 当图例位置在正上方或正下方时,调用updateConfig函数修改组件的边距配置项,图例在正上方时,上下左右边距分别为:150,24,24,24,图例在正下方时,上下左右边距分别为,24,150,24,24。图例将是横向排列的流式布局,一行满时,图例会自动换行,但是图例文本不换行,最多就是省略号显示。
|
|
5
|
+
- 当图例不显示时,调用updateConfig函数修改组件的边距配置项,上下左右边距分别为:24,24,24,24。
|
|
6
|
+
|
|
7
|
+
### 2.如果饼图需要显示中间的当前值,当前值的类目名称需要水平居中显示。
|
|
8
|
+
|
|
9
|
+
### updateConfig函数说明:
|
|
10
|
+
|
|
11
|
+
updateConfig({id?, type, payload}) (需要平台 v3.13.0版本及以上才支持)
|
|
12
|
+
● id:可不传,默认为当前组件的id,如果是子组件的更新,则必须穿子组件的id,不然会更新失败。
|
|
13
|
+
● type: 'config' | 'data' | ’actions' | 'camera' | 'triggers'(v5.14.0及以上支持)
|
|
14
|
+
○ config: 更新组件的configuration属性。
|
|
15
|
+
■ 在v4.13.0之前,用于更新config,只能是组件进入编辑模式,即edit为true的时候才支持
|
|
16
|
+
■ v4.13.0及以上,支持组件在非编辑模式下,也可以支持更新config配置,但只在编辑页面才生效。
|
|
17
|
+
○ data: 更新组件的data静态数据
|
|
18
|
+
○ actions: 用于动态更新组件的actions配置。使用场景为:自定义动作中可能存在一些动态的数据,需要在其他配置项发生变化的时候,需要动态更新,比如场景的镜头数据等。
|
|
19
|
+
○ camera: 该类型是在镜头数据保存的时候才需要用到,一般不是三维的镜头数据使用不上。
|
|
20
|
+
● payload:
|
|
21
|
+
○ 当type === 'data'时,payload为静态数据数组,
|
|
22
|
+
○ 当type === 'triggers'时,payload为 { name: string; value: string;}[]
|
|
23
|
+
○ 否则为{path, field, value} | {path, field, value}[], carema 则为镜头的数据。
|
|
24
|
+
○ path: string 需要更新的config属性路径 如['chart', 'component', 'color']
|
|
25
|
+
○ field: string 需要更新的控件属性 默认为value
|
|
26
|
+
○ value: any 控件属性对应的值
|
package/config.json
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dimension": {
|
|
3
|
+
"chartPosition": {
|
|
4
|
+
"left": 100,
|
|
5
|
+
"top": 100
|
|
6
|
+
},
|
|
7
|
+
"chartDimension": {
|
|
8
|
+
"width": 420,
|
|
9
|
+
"height": 210
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"margin": {
|
|
13
|
+
"marginTop": 30,
|
|
14
|
+
"marginBottom": 30,
|
|
15
|
+
"marginLeft": 0,
|
|
16
|
+
"marginRight": 120
|
|
17
|
+
},
|
|
18
|
+
"legend": {
|
|
19
|
+
"show": true,
|
|
20
|
+
"order": "",
|
|
21
|
+
"iconSize": {
|
|
22
|
+
"width": 10,
|
|
23
|
+
"height": 10
|
|
24
|
+
},
|
|
25
|
+
"iconGap": 5,
|
|
26
|
+
"layout": {
|
|
27
|
+
"alignment": "center right",
|
|
28
|
+
"gridTemplateColumns": 1,
|
|
29
|
+
"gridGap": {
|
|
30
|
+
"gridRowGap": 20,
|
|
31
|
+
"gridColumnGap": 10
|
|
32
|
+
},
|
|
33
|
+
"translate": {
|
|
34
|
+
"x": 0,
|
|
35
|
+
"y": 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"name": {
|
|
39
|
+
"show": true,
|
|
40
|
+
"font": {
|
|
41
|
+
"fontFamily": "SourceHanSansCN-Medium",
|
|
42
|
+
"fontSize": 12,
|
|
43
|
+
"color": "rgba(230, 247, 255, 1)",
|
|
44
|
+
"bold": false,
|
|
45
|
+
"italic": false,
|
|
46
|
+
"letterSpacing": 0
|
|
47
|
+
},
|
|
48
|
+
"layoutMode": "Adaptive",
|
|
49
|
+
"maxWidth": 80,
|
|
50
|
+
"textOverflow": "ellipsis",
|
|
51
|
+
"speed": 5,
|
|
52
|
+
"translate": {
|
|
53
|
+
"x": 0,
|
|
54
|
+
"y": 0
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"percent": {
|
|
58
|
+
"show": true,
|
|
59
|
+
"precision": 0,
|
|
60
|
+
"gap": 15,
|
|
61
|
+
"sameColor": true,
|
|
62
|
+
"align": "left",
|
|
63
|
+
"font": {
|
|
64
|
+
"fontFamily": "SourceHanSansCN-Medium",
|
|
65
|
+
"fontSize": 12,
|
|
66
|
+
"color": "rgba(230, 247, 255, 1)",
|
|
67
|
+
"bold": false,
|
|
68
|
+
"italic": false,
|
|
69
|
+
"letterSpacing": 0
|
|
70
|
+
},
|
|
71
|
+
"translate": {
|
|
72
|
+
"x": 0,
|
|
73
|
+
"y": 0
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"value": {
|
|
77
|
+
"show": false,
|
|
78
|
+
"splitConfig": {
|
|
79
|
+
"show": false,
|
|
80
|
+
"splitCount": 3,
|
|
81
|
+
"style": "default",
|
|
82
|
+
"separator": ",",
|
|
83
|
+
"fontFamily": "SourceHanSansCN-Medium",
|
|
84
|
+
"margin": {
|
|
85
|
+
"left": 0,
|
|
86
|
+
"right": 0
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"suffix": {
|
|
90
|
+
"show": true,
|
|
91
|
+
"text": "",
|
|
92
|
+
"fontSize": 12,
|
|
93
|
+
"translate": {
|
|
94
|
+
"x": 0,
|
|
95
|
+
"y": 0
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"gap": 0,
|
|
99
|
+
"sameColor": false,
|
|
100
|
+
"align": "left",
|
|
101
|
+
"font": {
|
|
102
|
+
"fontFamily": "SourceHanSansCN-Medium",
|
|
103
|
+
"fontSize": 12,
|
|
104
|
+
"color": "rgba(230, 247, 255, 1)",
|
|
105
|
+
"bold": false,
|
|
106
|
+
"italic": false,
|
|
107
|
+
"letterSpacing": 0
|
|
108
|
+
},
|
|
109
|
+
"translate": {
|
|
110
|
+
"x": 0,
|
|
111
|
+
"y": 0
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"loop": {
|
|
115
|
+
"show": false,
|
|
116
|
+
"interval": 3
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
package/lib/components/Chart.js
CHANGED
|
@@ -13,8 +13,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _context = require("../context");
|
|
15
15
|
var _ = require(".");
|
|
16
|
-
var
|
|
17
|
-
var _excluded = ["id", "type", "config", "config", "data", "onRelative", "emit", "emitEvent"];
|
|
16
|
+
var _excluded = ["id", "type", "config", "config", "data", "onRelative", "emit", "emitEvent", "updateConfig"];
|
|
18
17
|
/**
|
|
19
18
|
* 总入口,通过外面传进来的type来确定渲染哪种图表,饼环图表为“pie”,否则为轴类图表
|
|
20
19
|
*/
|
|
@@ -41,7 +40,6 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
41
40
|
type = _ref2.type,
|
|
42
41
|
config = _ref2.config,
|
|
43
42
|
_ref2$config = _ref2.config,
|
|
44
|
-
axes = _ref2$config.axes,
|
|
45
43
|
_ref2$config$chart$ma = _ref2$config.chart.margin,
|
|
46
44
|
marginRight = _ref2$config$chart$ma.marginRight,
|
|
47
45
|
marginLeft = _ref2$config$chart$ma.marginLeft,
|
|
@@ -52,6 +50,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
52
50
|
onRelative = _ref2.onRelative,
|
|
53
51
|
emit = _ref2.emit,
|
|
54
52
|
emitEvent = _ref2.emitEvent,
|
|
53
|
+
updateConfig = _ref2.updateConfig,
|
|
55
54
|
props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
56
55
|
var width = props.width,
|
|
57
56
|
height = props.height;
|
|
@@ -105,9 +104,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
105
104
|
height: chartHeight,
|
|
106
105
|
triggerOnRelative: triggerOnRelative,
|
|
107
106
|
svg: svg,
|
|
108
|
-
onEmit: onEmit
|
|
107
|
+
onEmit: onEmit,
|
|
108
|
+
updateConfig: updateConfig
|
|
109
109
|
};
|
|
110
|
-
}, [id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit]);
|
|
110
|
+
}, [id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit, updateConfig]);
|
|
111
111
|
(0, _react.useEffect)(function () {
|
|
112
112
|
var isAnimation = window.screenConfig ? window.screenConfig.isAnimation : true; //大屏的全局设置是否允许开启动画,false为不允许
|
|
113
113
|
if (!isAnimation) setActive(false);
|
package/lib/components/Legend.js
CHANGED
|
@@ -12,6 +12,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
12
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _utils = require("../utils");
|
|
15
|
+
var _legendPlacement = require("../utils/legendPlacement");
|
|
15
16
|
var _TextOverflow = _interopRequireDefault(require("./TextOverflow"));
|
|
16
17
|
var _excluded = ["italic", "bold"];
|
|
17
18
|
/**
|
|
@@ -26,7 +27,7 @@ var defaultFont = {
|
|
|
26
27
|
fontWeight: "normal"
|
|
27
28
|
};
|
|
28
29
|
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
29
|
-
var _config$value, _config$percent, _config$value2, _config$value3, _config$name;
|
|
30
|
+
var _config$value, _config$percent, _config$value2, _config$value3, _config$name, _ref3;
|
|
30
31
|
var series = _ref.series,
|
|
31
32
|
height = _ref.height,
|
|
32
33
|
data = _ref.data,
|
|
@@ -53,6 +54,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
53
54
|
y = _ref$config$layout$tr.y,
|
|
54
55
|
_ref$config$loop = _ref$config.loop,
|
|
55
56
|
loop = _ref$config$loop === void 0 ? {} : _ref$config$loop,
|
|
57
|
+
_ref$config$name = _ref$config.name,
|
|
58
|
+
_ref$config$name2 = _ref$config$name === void 0 ? {} : _ref$config$name,
|
|
59
|
+
layoutMode = _ref$config$name2.layoutMode,
|
|
56
60
|
_ref$config$font = _ref$config.font,
|
|
57
61
|
_ref$config$font2 = _ref$config$font === void 0 ? defaultFont : _ref$config$font,
|
|
58
62
|
italic = _ref$config$font2.italic,
|
|
@@ -65,7 +69,15 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
65
69
|
filterData = _ref.filterData,
|
|
66
70
|
formatter = _ref.formatter,
|
|
67
71
|
judge = _ref.judge,
|
|
68
|
-
pieClick = _ref.pieClick
|
|
72
|
+
pieClick = _ref.pieClick,
|
|
73
|
+
_ref$isPieChart = _ref.isPieChart,
|
|
74
|
+
isPieChart = _ref$isPieChart === void 0 ? false : _ref$isPieChart,
|
|
75
|
+
chartWidth = _ref.chartWidth,
|
|
76
|
+
componentWidth = _ref.componentWidth,
|
|
77
|
+
_ref$marginLeft = _ref.marginLeft,
|
|
78
|
+
marginLeft = _ref$marginLeft === void 0 ? 0 : _ref$marginLeft,
|
|
79
|
+
_ref$marginRight = _ref.marginRight,
|
|
80
|
+
marginRight = _ref$marginRight === void 0 ? 0 : _ref$marginRight;
|
|
69
81
|
if (!show) return null;
|
|
70
82
|
var ref_container = (0, _react.useRef)(null); // 滚动容器
|
|
71
83
|
var ref_scrollTop = (0, _react.useRef)(0); // 当前滚动距离
|
|
@@ -113,10 +125,12 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
113
125
|
});
|
|
114
126
|
};
|
|
115
127
|
var _series = (0, _utils.sortPie)(series, order, columnsSeries);
|
|
116
|
-
var
|
|
117
|
-
_alignment
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
var _parseLegendAlignment = (0, _legendPlacement.parseLegendAlignment)(alignment),
|
|
129
|
+
_alignment = _parseLegendAlignment.alignment,
|
|
130
|
+
position = _parseLegendAlignment.position,
|
|
131
|
+
isCenterTopOrBottom = _parseLegendAlignment.isCenterTopOrBottom,
|
|
132
|
+
isSidePlacement = _parseLegendAlignment.isSidePlacement;
|
|
133
|
+
var legendMainAlign = _alignment == "left" ? "flex-start" : _alignment == "center" ? "center" : "flex-end";
|
|
120
134
|
var length = _series.length;
|
|
121
135
|
var onClick = (0, _react.useCallback)(function (fieldName) {
|
|
122
136
|
return function (e) {
|
|
@@ -188,6 +202,76 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
188
202
|
});
|
|
189
203
|
return Math.max(maxMeasured, maxCfg);
|
|
190
204
|
});
|
|
205
|
+
var isPieAdaptive = isPieChart && layoutMode === "Adaptive";
|
|
206
|
+
var isPieFixedWidthGrid = isPieChart && (layoutMode === "FixedWidth" || (layoutMode == null || layoutMode === "") && LegendType == "FixedWidth");
|
|
207
|
+
var isFixedWidth = isPieChart ? isPieFixedWidthGrid : LegendType == "FixedWidth";
|
|
208
|
+
var isSideLegend = isPieAdaptive && isSidePlacement;
|
|
209
|
+
var isTopBottomAdaptive = isPieAdaptive && isCenterTopOrBottom;
|
|
210
|
+
var fullWidth = (_ref3 = componentWidth !== null && componentWidth !== void 0 ? componentWidth : chartWidth) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
211
|
+
var legendAreaWidth = Math.max(0, fullWidth - marginLeft - marginRight);
|
|
212
|
+
var sideLegendMaxWidth = isSideLegend ? Math.max(0, position === "left" || _alignment === "left" ? marginLeft : marginRight) : 0;
|
|
213
|
+
var isSideLegendOnRight = isSideLegend && (position === "right" || _alignment === "right" && position !== "left");
|
|
214
|
+
var fixedColumnsPerRow = Math.min(Math.max(1, Number(gridTemplateColumns) || 1), length);
|
|
215
|
+
var isPieTopBottomFixedMultiCol = isPieChart && isFixedWidth && isCenterTopOrBottom && fixedColumnsPerRow > 1;
|
|
216
|
+
var formatterExtra = _objectSpread(_objectSpread(_objectSpread({}, config), {}, {
|
|
217
|
+
valueMaxWidth: valueMaxWidth,
|
|
218
|
+
percentMaxWidth: percentMaxWidth,
|
|
219
|
+
nameMaxWidth: nameMaxWidth,
|
|
220
|
+
otherData: data,
|
|
221
|
+
columnsSeries: columnsSeries,
|
|
222
|
+
fieldColumnKeys: fieldColumnKeys,
|
|
223
|
+
fieldsColumnWidths: fieldsColumnWidths,
|
|
224
|
+
legendPosition: position,
|
|
225
|
+
isPieAdaptive: true
|
|
226
|
+
}, isSideLegend && sideLegendMaxWidth > 0 ? {
|
|
227
|
+
adaptiveMaxWidth: sideLegendMaxWidth
|
|
228
|
+
} : {}), isTopBottomAdaptive ? {
|
|
229
|
+
chartWidth: legendAreaWidth
|
|
230
|
+
} : {});
|
|
231
|
+
var renderPieSideItem = function renderPieSideItem(series, i) {
|
|
232
|
+
var _series$config;
|
|
233
|
+
var type = series.type,
|
|
234
|
+
name = series.name,
|
|
235
|
+
displayName = series.displayName,
|
|
236
|
+
fieldName = series.fieldName,
|
|
237
|
+
icon = series.icon,
|
|
238
|
+
selected = series.selected,
|
|
239
|
+
index = series.index;
|
|
240
|
+
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);
|
|
241
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
242
|
+
key: i,
|
|
243
|
+
onClick: onClick(fieldName),
|
|
244
|
+
"data-name": displayName || name,
|
|
245
|
+
"data-index": index,
|
|
246
|
+
style: {
|
|
247
|
+
display: "flex",
|
|
248
|
+
width: "max-content",
|
|
249
|
+
maxWidth: sideLegendMaxWidth || undefined,
|
|
250
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
251
|
+
alignItems: "center",
|
|
252
|
+
cursor: "pointer",
|
|
253
|
+
gap: _icon.gap,
|
|
254
|
+
minWidth: 0,
|
|
255
|
+
overflow: "hidden",
|
|
256
|
+
boxSizing: "border-box"
|
|
257
|
+
}
|
|
258
|
+
}, formatter ? formatter(series, formatterExtra) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
259
|
+
style: _objectSpread(_objectSpread({}, _icon), {}, {
|
|
260
|
+
flexShrink: 0
|
|
261
|
+
})
|
|
262
|
+
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
263
|
+
type: "ellipsis",
|
|
264
|
+
value: displayName || name,
|
|
265
|
+
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
266
|
+
fontStyle: italic ? "italic" : "normal",
|
|
267
|
+
fontWeight: bold ? "bold" : "normal",
|
|
268
|
+
minWidth: 0,
|
|
269
|
+
flex: "1 1 0%",
|
|
270
|
+
maxWidth: "100%"
|
|
271
|
+
}),
|
|
272
|
+
speed: speed
|
|
273
|
+
})));
|
|
274
|
+
};
|
|
191
275
|
var stylePieOrAxis = formatter ? _objectSpread(_objectSpread({
|
|
192
276
|
display: "flex",
|
|
193
277
|
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",
|
|
@@ -198,16 +282,120 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
198
282
|
overflowY: loop.show ? "scroll" : "auto"
|
|
199
283
|
}) : _objectSpread(_objectSpread({
|
|
200
284
|
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",
|
|
285
|
+
maxWidth: "100%",
|
|
286
|
+
boxSizing: "border-box",
|
|
205
287
|
position: "absolute"
|
|
206
288
|
}, getPosition(position, _alignment, x, y)), {}, {
|
|
207
289
|
height: loop.show ? height : "auto",
|
|
208
290
|
overflowY: loop.show ? "scroll" : "auto"
|
|
209
291
|
});
|
|
210
|
-
|
|
292
|
+
if (isPieAdaptive && isSideLegend) {
|
|
293
|
+
var pieAdaptiveWrapperStyle = _objectSpread(_objectSpread({
|
|
294
|
+
position: "absolute",
|
|
295
|
+
display: "flex",
|
|
296
|
+
flexDirection: "column",
|
|
297
|
+
width: "max-content",
|
|
298
|
+
maxWidth: sideLegendMaxWidth || undefined,
|
|
299
|
+
alignItems: isSideLegendOnRight ? "flex-end" : "flex-start"
|
|
300
|
+
}, getPosition(position, _alignment, x, y)), {}, {
|
|
301
|
+
height: loop.show ? height : "auto",
|
|
302
|
+
overflowY: loop.show ? "scroll" : "auto"
|
|
303
|
+
});
|
|
304
|
+
var pieAdaptiveListStyle = {
|
|
305
|
+
display: "flex",
|
|
306
|
+
flexDirection: "column",
|
|
307
|
+
width: "max-content",
|
|
308
|
+
maxWidth: "100%",
|
|
309
|
+
alignItems: isSideLegendOnRight ? "flex-end" : "flex-start",
|
|
310
|
+
margin: 0,
|
|
311
|
+
padding: 0,
|
|
312
|
+
listStyle: "none",
|
|
313
|
+
gap: "".concat(gridRowGap, "px")
|
|
314
|
+
};
|
|
315
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
316
|
+
className: "__easyv-legend-wrapper",
|
|
317
|
+
style: pieAdaptiveWrapperStyle,
|
|
318
|
+
ref: ref_container
|
|
319
|
+
}, /*#__PURE__*/_react["default"].createElement("ul", {
|
|
320
|
+
style: pieAdaptiveListStyle
|
|
321
|
+
}, _series.map(function (series, i) {
|
|
322
|
+
return renderPieSideItem(series, i);
|
|
323
|
+
})));
|
|
324
|
+
}
|
|
325
|
+
if (isTopBottomAdaptive) {
|
|
326
|
+
var topBottomWrapperStyle = _objectSpread(_objectSpread({
|
|
327
|
+
position: "absolute",
|
|
328
|
+
width: legendAreaWidth || "100%",
|
|
329
|
+
maxWidth: legendAreaWidth || "100%",
|
|
330
|
+
boxSizing: "border-box"
|
|
331
|
+
}, getPosition(position, _alignment, x, y)), {}, {
|
|
332
|
+
height: loop.show ? height : "auto",
|
|
333
|
+
overflowY: loop.show ? "scroll" : "auto"
|
|
334
|
+
});
|
|
335
|
+
var topBottomListStyle = {
|
|
336
|
+
display: "flex",
|
|
337
|
+
flexDirection: "row",
|
|
338
|
+
flexWrap: "wrap",
|
|
339
|
+
width: "100%",
|
|
340
|
+
maxWidth: "100%",
|
|
341
|
+
boxSizing: "border-box",
|
|
342
|
+
margin: 0,
|
|
343
|
+
padding: 0,
|
|
344
|
+
listStyle: "none",
|
|
345
|
+
justifyContent: legendMainAlign,
|
|
346
|
+
gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px")
|
|
347
|
+
};
|
|
348
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
349
|
+
className: "__easyv-legend-wrapper",
|
|
350
|
+
style: topBottomWrapperStyle,
|
|
351
|
+
ref: ref_container
|
|
352
|
+
}, /*#__PURE__*/_react["default"].createElement("ul", {
|
|
353
|
+
style: topBottomListStyle
|
|
354
|
+
}, _series.map(function (series, i) {
|
|
355
|
+
var _series$config2;
|
|
356
|
+
var type = series.type,
|
|
357
|
+
name = series.name,
|
|
358
|
+
displayName = series.displayName,
|
|
359
|
+
fieldName = series.fieldName,
|
|
360
|
+
icon = series.icon,
|
|
361
|
+
selected = series.selected,
|
|
362
|
+
index = series.index;
|
|
363
|
+
var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$config2 = series.config) === null || _series$config2 === void 0 || (_series$config2 = _series$config2.line) === null || _series$config2 === void 0 ? void 0 : _series$config2.type);
|
|
364
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
365
|
+
key: i,
|
|
366
|
+
onClick: onClick(fieldName),
|
|
367
|
+
"data-name": displayName || name,
|
|
368
|
+
"data-index": index,
|
|
369
|
+
style: {
|
|
370
|
+
display: "inline-flex",
|
|
371
|
+
alignItems: "center",
|
|
372
|
+
width: "max-content",
|
|
373
|
+
maxWidth: "100%",
|
|
374
|
+
minWidth: 0,
|
|
375
|
+
overflow: "hidden",
|
|
376
|
+
boxSizing: "border-box",
|
|
377
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
378
|
+
cursor: "pointer",
|
|
379
|
+
gap: _icon.gap,
|
|
380
|
+
flexShrink: 0
|
|
381
|
+
}
|
|
382
|
+
}, formatter ? formatter(series, formatterExtra) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
383
|
+
style: _objectSpread(_objectSpread({}, _icon), {}, {
|
|
384
|
+
flexShrink: 0
|
|
385
|
+
})
|
|
386
|
+
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
387
|
+
type: "ellipsis",
|
|
388
|
+
value: displayName || name,
|
|
389
|
+
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
390
|
+
fontStyle: italic ? "italic" : "normal",
|
|
391
|
+
fontWeight: bold ? "bold" : "normal",
|
|
392
|
+
minWidth: 0
|
|
393
|
+
}),
|
|
394
|
+
speed: speed
|
|
395
|
+
})));
|
|
396
|
+
})));
|
|
397
|
+
}
|
|
398
|
+
return isFixedWidth ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
211
399
|
className: "__easyv-legend-wrapper",
|
|
212
400
|
style: _objectSpread(_objectSpread({
|
|
213
401
|
position: "absolute",
|
|
@@ -220,11 +408,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
220
408
|
}, /*#__PURE__*/_react["default"].createElement("ul", {
|
|
221
409
|
style: {
|
|
222
410
|
display: "grid",
|
|
223
|
-
|
|
224
|
-
|
|
411
|
+
rowGap: gridRowGap + "px",
|
|
412
|
+
columnGap: (isPieTopBottomFixedMultiCol ? Math.max(gridColumnGap, 40) : gridColumnGap) + "px",
|
|
413
|
+
justifyContent: isPieTopBottomFixedMultiCol ? legendMainAlign : undefined,
|
|
414
|
+
gridTemplateColumns: isPieTopBottomFixedMultiCol ? "repeat(".concat(fixedColumnsPerRow, ", max-content)") : "repeat(".concat(fixedColumnsPerRow, ", minmax(0, 1fr))")
|
|
225
415
|
}
|
|
226
416
|
}, _series.map(function (series, i) {
|
|
227
|
-
var _series$
|
|
417
|
+
var _series$config3;
|
|
228
418
|
var type = series.type,
|
|
229
419
|
name = series.name,
|
|
230
420
|
displayName = series.displayName,
|
|
@@ -232,7 +422,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
232
422
|
icon = series.icon,
|
|
233
423
|
selected = series.selected,
|
|
234
424
|
index = series.index;
|
|
235
|
-
var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$
|
|
425
|
+
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);
|
|
236
426
|
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
237
427
|
key: i,
|
|
238
428
|
onClick: onClick(fieldName),
|
|
@@ -270,19 +460,19 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
270
460
|
className: "__easyv-legend-wrapper",
|
|
271
461
|
style: stylePieOrAxis,
|
|
272
462
|
ref: ref_container
|
|
273
|
-
}, (0, _toConsumableArray2["default"])(Array(Math.ceil(series.length / gridTemplateColumns))).map(function (_, indexs) {
|
|
463
|
+
}, formatter ? (0, _toConsumableArray2["default"])(Array(Math.ceil(series.length / gridTemplateColumns))).map(function (_, indexs) {
|
|
274
464
|
return /*#__PURE__*/_react["default"].createElement("ul", {
|
|
275
465
|
key: indexs,
|
|
276
|
-
style:
|
|
466
|
+
style: {
|
|
277
467
|
display: "flex",
|
|
278
468
|
width: "fit-content",
|
|
279
|
-
justifyContent:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
469
|
+
justifyContent: legendMainAlign,
|
|
470
|
+
gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px"),
|
|
471
|
+
marginBottom: gridRowGap + "px"
|
|
472
|
+
}
|
|
283
473
|
}, _series.map(function (series, i) {
|
|
284
474
|
if (Math.floor(i / gridTemplateColumns) == indexs) {
|
|
285
|
-
var _series$
|
|
475
|
+
var _series$config4;
|
|
286
476
|
var type = series.type,
|
|
287
477
|
name = series.name,
|
|
288
478
|
displayName = series.displayName,
|
|
@@ -290,7 +480,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
290
480
|
icon = series.icon,
|
|
291
481
|
selected = series.selected,
|
|
292
482
|
index = series.index;
|
|
293
|
-
var _icon = (0, _utils.getIcon)(type, icon, series === null || series === void 0 || (_series$
|
|
483
|
+
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);
|
|
294
484
|
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
295
485
|
key: i,
|
|
296
486
|
onClick: onClick(fieldName),
|
|
@@ -302,9 +492,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
302
492
|
alignItems: "center",
|
|
303
493
|
cursor: "pointer",
|
|
304
494
|
gap: _icon.gap,
|
|
305
|
-
overflow:
|
|
495
|
+
overflow: "visible"
|
|
306
496
|
}
|
|
307
|
-
}, formatter
|
|
497
|
+
}, formatter(series, _objectSpread(_objectSpread({}, config), {}, {
|
|
308
498
|
valueMaxWidth: valueMaxWidth,
|
|
309
499
|
percentMaxWidth: percentMaxWidth,
|
|
310
500
|
nameMaxWidth: nameMaxWidth,
|
|
@@ -312,22 +502,66 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
312
502
|
columnsSeries: columnsSeries,
|
|
313
503
|
fieldColumnKeys: fieldColumnKeys,
|
|
314
504
|
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
505
|
})));
|
|
328
506
|
}
|
|
329
507
|
}));
|
|
330
|
-
})
|
|
508
|
+
}) : /*#__PURE__*/_react["default"].createElement("ul", {
|
|
509
|
+
style: {
|
|
510
|
+
display: "flex",
|
|
511
|
+
flexDirection: "row",
|
|
512
|
+
flexWrap: "wrap",
|
|
513
|
+
width: "100%",
|
|
514
|
+
maxWidth: "100%",
|
|
515
|
+
boxSizing: "border-box",
|
|
516
|
+
margin: 0,
|
|
517
|
+
padding: 0,
|
|
518
|
+
listStyle: "none",
|
|
519
|
+
justifyContent: legendMainAlign,
|
|
520
|
+
gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px")
|
|
521
|
+
}
|
|
522
|
+
}, _series.map(function (series, i) {
|
|
523
|
+
var _series$config5;
|
|
524
|
+
var type = series.type,
|
|
525
|
+
name = series.name,
|
|
526
|
+
displayName = series.displayName,
|
|
527
|
+
fieldName = series.fieldName,
|
|
528
|
+
icon = series.icon,
|
|
529
|
+
selected = series.selected,
|
|
530
|
+
index = series.index;
|
|
531
|
+
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);
|
|
532
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
533
|
+
key: i,
|
|
534
|
+
onClick: onClick(fieldName),
|
|
535
|
+
"data-name": displayName || name,
|
|
536
|
+
"data-index": index,
|
|
537
|
+
style: {
|
|
538
|
+
display: "inline-flex",
|
|
539
|
+
alignItems: "center",
|
|
540
|
+
maxWidth: "100%",
|
|
541
|
+
minWidth: 0,
|
|
542
|
+
boxSizing: "border-box",
|
|
543
|
+
verticalAlign: "middle",
|
|
544
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
545
|
+
cursor: "pointer",
|
|
546
|
+
gap: _icon.gap
|
|
547
|
+
}
|
|
548
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
549
|
+
style: _objectSpread(_objectSpread({}, _icon), {}, {
|
|
550
|
+
flexShrink: 0
|
|
551
|
+
})
|
|
552
|
+
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
553
|
+
type: "ellipsis",
|
|
554
|
+
value: displayName || name,
|
|
555
|
+
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
556
|
+
fontStyle: italic ? "italic" : "normal",
|
|
557
|
+
fontWeight: bold ? "bold" : "normal",
|
|
558
|
+
minWidth: 0,
|
|
559
|
+
flex: "1 1 0%",
|
|
560
|
+
maxWidth: "100%"
|
|
561
|
+
}),
|
|
562
|
+
speed: speed
|
|
563
|
+
}));
|
|
564
|
+
})));
|
|
331
565
|
});
|
|
332
566
|
var getPosition = function getPosition(position, alignment) {
|
|
333
567
|
var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -53,7 +53,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
53
53
|
var textWidth = target.current.scrollWidth;
|
|
54
54
|
var containerWidth = rootRef.current.clientWidth;
|
|
55
55
|
if (textWidth <= containerWidth) {
|
|
56
|
-
console.log("文字全部可视");
|
|
56
|
+
// console.log("文字全部可视");
|
|
57
57
|
//表示文字全部可视
|
|
58
58
|
cancelAnimationFrame(timer.current || 0);
|
|
59
59
|
target.current.style.transform = "translate(0px,0px)"; //重置偏移
|