@easyv/charts 1.7.31 → 1.7.32
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
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
@@ -33,6 +34,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
33
34
|
_ref$config$order = _ref$config.order,
|
|
34
35
|
order = _ref$config$order === void 0 ? '' : _ref$config$order,
|
|
35
36
|
interactive = _ref$config.interactive,
|
|
37
|
+
LegendType = _ref$config.LegendType,
|
|
36
38
|
maxWidth = _ref$config.maxWidth,
|
|
37
39
|
textOverflow = _ref$config.textOverflow,
|
|
38
40
|
speed = _ref$config.speed,
|
|
@@ -122,7 +124,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
122
124
|
d.percent = 0;
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
127
|
+
return LegendType == "FixedWidth" ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
126
128
|
className: "__easyv-legend-wrapper",
|
|
127
129
|
style: _objectSpread(_objectSpread({
|
|
128
130
|
position: 'absolute',
|
|
@@ -169,7 +171,66 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
169
171
|
}),
|
|
170
172
|
speed: speed
|
|
171
173
|
})));
|
|
172
|
-
})))
|
|
174
|
+
}))) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
175
|
+
className: "__easyv-legend-wrapper",
|
|
176
|
+
style: _objectSpread(_objectSpread({
|
|
177
|
+
display: 'flex',
|
|
178
|
+
flexWrap: "wrap",
|
|
179
|
+
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",
|
|
180
|
+
flexDirection: "column",
|
|
181
|
+
position: 'absolute'
|
|
182
|
+
}, getPosition(position, _alignment, x, y)), {}, {
|
|
183
|
+
height: loop.show ? height : 'auto',
|
|
184
|
+
overflowY: loop.show ? 'scroll' : 'auto',
|
|
185
|
+
width: "100%"
|
|
186
|
+
}),
|
|
187
|
+
ref: ref_container
|
|
188
|
+
}, (0, _toConsumableArray2["default"])(Array(Math.ceil(series.length / gridTemplateColumns))).map(function (_, indexs) {
|
|
189
|
+
return /*#__PURE__*/_react["default"].createElement("ul", {
|
|
190
|
+
key: indexs,
|
|
191
|
+
style: (0, _defineProperty2["default"])({
|
|
192
|
+
display: 'flex',
|
|
193
|
+
width: 'fit-content',
|
|
194
|
+
justifyContent: alignment.split(" ")[0] == "left" ? "flex-start" : alignment.split(" ")[0] == "center" ? "center" : "flex-end",
|
|
195
|
+
marginBottom: "0px",
|
|
196
|
+
gap: "".concat(gridRowGap, "px ").concat(gridColumnGap, "px")
|
|
197
|
+
}, "marginBottom", gridRowGap + "px")
|
|
198
|
+
}, _series.map(function (series, index) {
|
|
199
|
+
if (Math.floor(index / gridTemplateColumns) == indexs) {
|
|
200
|
+
var _series$config2;
|
|
201
|
+
var type = series.type,
|
|
202
|
+
name = series.name,
|
|
203
|
+
displayName = series.displayName,
|
|
204
|
+
icon = series.icon,
|
|
205
|
+
selected = series.selected;
|
|
206
|
+
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);
|
|
207
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
208
|
+
key: index,
|
|
209
|
+
onClick: onClick,
|
|
210
|
+
"data-name": name,
|
|
211
|
+
style: {
|
|
212
|
+
display: 'flex',
|
|
213
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
cursor: "pointer",
|
|
216
|
+
gap: _icon.gap
|
|
217
|
+
}
|
|
218
|
+
}, formatter ? formatter(series, config) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
219
|
+
style: _icon
|
|
220
|
+
}), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
221
|
+
ShowType: LegendType,
|
|
222
|
+
type: "ellipsis",
|
|
223
|
+
value: displayName || name,
|
|
224
|
+
style: _objectSpread(_objectSpread({}, font), {}, {
|
|
225
|
+
fontStyle: italic ? 'italic' : 'normal',
|
|
226
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
227
|
+
minWidth: getCanvasTextWidth(displayName.substring(0, 5) || name.substring(0, 5), font.letterSpacing, "".concat(font.fontSize, "px ").concat(font.fontFamily))
|
|
228
|
+
}),
|
|
229
|
+
speed: speed
|
|
230
|
+
})));
|
|
231
|
+
}
|
|
232
|
+
}));
|
|
233
|
+
}));
|
|
173
234
|
});
|
|
174
235
|
var getPosition = function getPosition(position, alignment) {
|
|
175
236
|
var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -203,4 +264,12 @@ var getPosition = function getPosition(position, alignment) {
|
|
|
203
264
|
transform: "translate3d(calc(".concat(alignment == 'center' ? '-50%' : '0px', " + ").concat(x, "px), ").concat(y, "px, 0px)")
|
|
204
265
|
};
|
|
205
266
|
}
|
|
267
|
+
};
|
|
268
|
+
var getCanvasTextWidth = function getCanvasTextWidth(text, letterSpacing) {
|
|
269
|
+
var font = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '16px Arial';
|
|
270
|
+
var canvas = document.createElement('canvas');
|
|
271
|
+
var ctx = canvas.getContext('2d');
|
|
272
|
+
ctx.font = font;
|
|
273
|
+
return ctx.measureText(text).width + text.length * letterSpacing + "px";
|
|
274
|
+
// return ctx.measureText(text).width+(text.length-1)*letterSpacing+"px";//-1有bug
|
|
206
275
|
};
|
|
@@ -24,7 +24,8 @@ 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
|
|
27
|
+
config = _props$config === void 0 ? {} : _props$config,
|
|
28
|
+
ShowType = props.ShowType;
|
|
28
29
|
var _config$needTitle = config.needTitle,
|
|
29
30
|
needTitle = _config$needTitle === void 0 ? true : _config$needTitle;
|
|
30
31
|
var getTextOverflow = function getTextOverflow(type) {
|
|
@@ -59,7 +60,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
59
60
|
style: styles,
|
|
60
61
|
ref: ref
|
|
61
62
|
}) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
62
|
-
style: styles,
|
|
63
|
+
style: _objectSpread(_objectSpread({}, styles), {}, {
|
|
64
|
+
whiteSpace: ShowType == "Adaptive" ? "normal" : styles.whiteSpace
|
|
65
|
+
}),
|
|
63
66
|
ref: ref,
|
|
64
67
|
title: needTitle && type == "ellipsis" ? text || undefined : undefined,
|
|
65
68
|
dangerouslySetInnerHTML: {
|
package/package.json
CHANGED
package/src/components/Legend.js
CHANGED
|
@@ -19,6 +19,7 @@ export default memo(
|
|
|
19
19
|
show,
|
|
20
20
|
order = '',
|
|
21
21
|
interactive,
|
|
22
|
+
LegendType,//类型
|
|
22
23
|
maxWidth,
|
|
23
24
|
textOverflow,
|
|
24
25
|
speed,
|
|
@@ -100,6 +101,7 @@ export default memo(
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
return (
|
|
104
|
+
LegendType=="FixedWidth"?
|
|
103
105
|
<div
|
|
104
106
|
className='__easyv-legend-wrapper'
|
|
105
107
|
style={{
|
|
@@ -153,6 +155,72 @@ export default memo(
|
|
|
153
155
|
);
|
|
154
156
|
})}
|
|
155
157
|
</ul>
|
|
158
|
+
</div>:<div
|
|
159
|
+
className='__easyv-legend-wrapper'
|
|
160
|
+
style={{
|
|
161
|
+
display:'flex',
|
|
162
|
+
flexWrap:"wrap",
|
|
163
|
+
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",
|
|
164
|
+
flexDirection: "column",
|
|
165
|
+
position: 'absolute',
|
|
166
|
+
...getPosition(position, _alignment, x, y),
|
|
167
|
+
height: loop.show ? height : 'auto',
|
|
168
|
+
overflowY: loop.show ? 'scroll' : 'auto',
|
|
169
|
+
width:"100%"
|
|
170
|
+
}}
|
|
171
|
+
ref={ref_container}
|
|
172
|
+
>
|
|
173
|
+
|
|
174
|
+
{[...Array(Math.ceil(series.length/gridTemplateColumns))].map((_,indexs)=>(
|
|
175
|
+
<ul
|
|
176
|
+
key={indexs}
|
|
177
|
+
style={{
|
|
178
|
+
display: 'flex',
|
|
179
|
+
width: 'fit-content',
|
|
180
|
+
justifyContent:alignment.split(" ")[0]=="left"?"flex-start":alignment.split(" ")[0]=="center"?"center":"flex-end",
|
|
181
|
+
marginBottom:"0px",
|
|
182
|
+
gap:`${gridRowGap}px ${gridColumnGap}px`,
|
|
183
|
+
marginBottom:gridRowGap+"px"
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
{_series.map((series, index) => {
|
|
187
|
+
if(Math.floor(index/gridTemplateColumns)==indexs){
|
|
188
|
+
const { type, name, displayName, icon, selected } = series;
|
|
189
|
+
const _icon = getIcon(type, icon, series?.config?.line?.type);
|
|
190
|
+
return (
|
|
191
|
+
<li
|
|
192
|
+
key={index}
|
|
193
|
+
onClick={onClick}
|
|
194
|
+
data-name={name}
|
|
195
|
+
style={{
|
|
196
|
+
display: 'flex',
|
|
197
|
+
opacity: selected === false ? opacity / 100 : 1,
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
cursor: "pointer",
|
|
200
|
+
gap: _icon.gap,
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
{formatter ? (
|
|
204
|
+
formatter(series, config)
|
|
205
|
+
) : (
|
|
206
|
+
<>
|
|
207
|
+
<span style={_icon} />
|
|
208
|
+
<TextOverflow ShowType={LegendType} type="ellipsis" value={displayName || name} style={{
|
|
209
|
+
...font,
|
|
210
|
+
fontStyle: italic ? 'italic' : 'normal',
|
|
211
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
212
|
+
minWidth:getCanvasTextWidth(displayName.substring(0,5) || name.substring(0,5),font.letterSpacing,`${font.fontSize}px ${font.fontFamily}` )
|
|
213
|
+
}} speed={speed}></TextOverflow>
|
|
214
|
+
|
|
215
|
+
</>
|
|
216
|
+
)}
|
|
217
|
+
</li>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
})}
|
|
221
|
+
</ul>
|
|
222
|
+
))
|
|
223
|
+
}
|
|
156
224
|
</div>
|
|
157
225
|
);
|
|
158
226
|
}
|
|
@@ -188,3 +256,10 @@ const getPosition = (position, alignment, x = 0, y = 0) => {
|
|
|
188
256
|
};
|
|
189
257
|
}
|
|
190
258
|
};
|
|
259
|
+
const getCanvasTextWidth=(text,letterSpacing, font = '16px Arial')=>{
|
|
260
|
+
const canvas = document.createElement('canvas');
|
|
261
|
+
const ctx = canvas.getContext('2d');
|
|
262
|
+
ctx.font = font;
|
|
263
|
+
return ctx.measureText(text).width+(text.length)*letterSpacing+"px";
|
|
264
|
+
// return ctx.measureText(text).width+(text.length-1)*letterSpacing+"px";//-1有bug
|
|
265
|
+
}
|
|
@@ -10,7 +10,8 @@ interface flowText{
|
|
|
10
10
|
value:string,
|
|
11
11
|
speed:number,
|
|
12
12
|
style:CSSProperties,
|
|
13
|
-
config?:any
|
|
13
|
+
config?:any,
|
|
14
|
+
ShowType:string
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export default memo(forwardRef((props:flowText, ref:any) => {
|
|
@@ -19,7 +20,8 @@ export default memo(forwardRef((props:flowText, ref:any) => {
|
|
|
19
20
|
value, // 文本
|
|
20
21
|
style, // 样式
|
|
21
22
|
speed = 5, // 动画速度
|
|
22
|
-
config = {}
|
|
23
|
+
config = {},
|
|
24
|
+
ShowType
|
|
23
25
|
} = props;
|
|
24
26
|
const { needTitle = true } = config;
|
|
25
27
|
|
|
@@ -60,6 +62,7 @@ export default memo(forwardRef((props:flowText, ref:any) => {
|
|
|
60
62
|
style={styles}
|
|
61
63
|
ref={ref} />
|
|
62
64
|
) : (
|
|
63
|
-
<div style={styles
|
|
65
|
+
<div style={{...styles,
|
|
66
|
+
whiteSpace:ShowType=="Adaptive"?"normal":styles.whiteSpace}} ref={ref} title={needTitle && type=="ellipsis"?text || undefined:undefined} dangerouslySetInnerHTML={{__html:value}}></div>
|
|
64
67
|
);
|
|
65
68
|
}));
|