@easyv/charts 1.7.38 → 1.8.1
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
|
@@ -162,7 +162,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
162
162
|
style: {
|
|
163
163
|
display: 'grid',
|
|
164
164
|
gridGap: gridRowGap + 'px ' + gridColumnGap + 'px',
|
|
165
|
-
gridTemplateColumns: "".concat(nameMaxWidth, "px ").concat(valueMaxWidth, "px ").concat(percentMaxWidth, "px")
|
|
165
|
+
gridTemplateColumns: formatter ? "".concat(nameMaxWidth, "px ").concat(valueMaxWidth, "px ").concat(percentMaxWidth, "px") : 'repeat(' + Math.min(gridTemplateColumns, length) + ', 1fr)' //饼图或者柱状图配合不同的图例显示格式
|
|
166
166
|
}
|
|
167
167
|
}, _series.map(function (series, index) {
|
|
168
168
|
var _series$config;
|
|
@@ -1054,6 +1054,16 @@ var Label = function Label(_ref10) {
|
|
|
1054
1054
|
}, (_showValue ? "(" : "") + percent + "%" + (_showValue ? ")" : "")))));
|
|
1055
1055
|
}));
|
|
1056
1056
|
};
|
|
1057
|
+
function getAlign(align, reverse) {
|
|
1058
|
+
if (align == "center") return "center";
|
|
1059
|
+
if (align == "left") return reverse ? "flex-end" : "flex-start";
|
|
1060
|
+
return reverse ? "flex-start" : "flex-end";
|
|
1061
|
+
}
|
|
1062
|
+
function getTranslate(translate, reverse) {
|
|
1063
|
+
var x = translate.x,
|
|
1064
|
+
y = translate.y;
|
|
1065
|
+
return "translate(".concat(reverse ? -x : x, "px, ").concat(y, "px)");
|
|
1066
|
+
}
|
|
1057
1067
|
var RingLabel = function RingLabel(_ref12) {
|
|
1058
1068
|
var _ref12$config = _ref12.config,
|
|
1059
1069
|
ringDuration = _ref12$config.ringDuration,
|
|
@@ -1064,6 +1074,8 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1064
1074
|
lineColor = _ref12$config.lineColor,
|
|
1065
1075
|
distance = _ref12$config.distance,
|
|
1066
1076
|
mode = _ref12$config.mode,
|
|
1077
|
+
_ref12$config$align = _ref12$config.align,
|
|
1078
|
+
align = _ref12$config$align === void 0 ? "center" : _ref12$config$align,
|
|
1067
1079
|
show = _ref12$config.show,
|
|
1068
1080
|
_ref12$config$transla = _ref12$config.translate,
|
|
1069
1081
|
translateX = _ref12$config$transla.x,
|
|
@@ -1074,6 +1086,7 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1074
1086
|
maxWidth = _ref12$config$name.maxWidth,
|
|
1075
1087
|
textOverflow = _ref12$config$name.textOverflow,
|
|
1076
1088
|
speed = _ref12$config$name.speed,
|
|
1089
|
+
nameTranslate = _ref12$config$name.translate,
|
|
1077
1090
|
_ref12$config$value = _ref12$config.value,
|
|
1078
1091
|
showValue = _ref12$config$value.show,
|
|
1079
1092
|
valueFont = _ref12$config$value.font,
|
|
@@ -1084,10 +1097,12 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1084
1097
|
_ref12$config$value$s2 = _ref12$config$value$s.translate,
|
|
1085
1098
|
suffixTranslateX = _ref12$config$value$s2.x,
|
|
1086
1099
|
suffixTranslateY = _ref12$config$value$s2.y,
|
|
1100
|
+
valueTranslate = _ref12$config$value.translate,
|
|
1087
1101
|
_ref12$config$percent = _ref12$config.percent,
|
|
1088
1102
|
showPercent = _ref12$config$percent.show,
|
|
1089
1103
|
percentFont = _ref12$config$percent.font,
|
|
1090
1104
|
precision = _ref12$config$percent.precision,
|
|
1105
|
+
percentTranslate = _ref12$config$percent.translate,
|
|
1091
1106
|
_ref12$iosStyle = _ref12.iosStyle,
|
|
1092
1107
|
isIOS = _ref12$iosStyle.isIOS,
|
|
1093
1108
|
left = _ref12$iosStyle.left,
|
|
@@ -1165,7 +1180,9 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1165
1180
|
width: "max-content",
|
|
1166
1181
|
animationDelay: "".concat((actualIndex + 1) * ringDuration - labelDuration, "ms"),
|
|
1167
1182
|
display: "flex",
|
|
1168
|
-
|
|
1183
|
+
flexDirection: mode == "horizontal" ? "row" : "column",
|
|
1184
|
+
alignItems: getAlign(align, x3 >= 0),
|
|
1185
|
+
justifyContent: "center"
|
|
1169
1186
|
}
|
|
1170
1187
|
}, _showName && /*#__PURE__*/_react["default"].createElement(_.TextOverflow, {
|
|
1171
1188
|
type: textOverflow,
|
|
@@ -1174,10 +1191,13 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1174
1191
|
style: _objectSpread(_objectSpread({
|
|
1175
1192
|
maxWidth: maxWidth
|
|
1176
1193
|
}, (0, _utils.getFontStyle)(nameFont)), {}, {
|
|
1177
|
-
"float": mode == "horizontal" ? "left" : "none"
|
|
1194
|
+
"float": mode == "horizontal" ? "left" : "none",
|
|
1195
|
+
transform: getTranslate(nameTranslate, x3 >= 0)
|
|
1178
1196
|
})
|
|
1179
1197
|
}), showValue && /*#__PURE__*/_react["default"].createElement("span", {
|
|
1180
|
-
style: (0, _utils.getFontStyle)(valueFont)
|
|
1198
|
+
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
|
|
1199
|
+
transform: getTranslate(valueTranslate, x3 >= 0)
|
|
1200
|
+
})
|
|
1181
1201
|
}, realData.y, showSuffix && /*#__PURE__*/_react["default"].createElement("span", {
|
|
1182
1202
|
style: {
|
|
1183
1203
|
position: "relative",
|
|
@@ -1186,7 +1206,9 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1186
1206
|
top: suffixTranslateY
|
|
1187
1207
|
}
|
|
1188
1208
|
}, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
1189
|
-
style: (0, _utils.getFontStyle)(percentFont)
|
|
1209
|
+
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(percentFont)), {}, {
|
|
1210
|
+
transform: getTranslate(percentTranslate, x3 >= 0)
|
|
1211
|
+
})
|
|
1190
1212
|
}, (_showValue ? "(" : "") + percent + "%" + (_showValue ? ")" : "")))));
|
|
1191
1213
|
}));
|
|
1192
1214
|
};
|
package/package.json
CHANGED
package/src/components/Legend.js
CHANGED
|
@@ -140,7 +140,8 @@ export default memo(
|
|
|
140
140
|
style={{
|
|
141
141
|
display: 'grid',
|
|
142
142
|
gridGap: gridRowGap + 'px ' + gridColumnGap + 'px',
|
|
143
|
-
gridTemplateColumns:
|
|
143
|
+
gridTemplateColumns:formatter?`${nameMaxWidth}px ${valueMaxWidth}px ${percentMaxWidth}px`:
|
|
144
|
+
'repeat(' + Math.min(gridTemplateColumns, length) + ', 1fr)',//饼图或者柱状图配合不同的图例显示格式
|
|
144
145
|
}}
|
|
145
146
|
>
|
|
146
147
|
{_series.map((series, index) => {
|
|
@@ -1241,6 +1241,15 @@ const Label = ({
|
|
|
1241
1241
|
);
|
|
1242
1242
|
};
|
|
1243
1243
|
|
|
1244
|
+
function getAlign(align, reverse){
|
|
1245
|
+
if(align=="center")return "center";
|
|
1246
|
+
if(align=="left")return reverse?"flex-end":"flex-start";
|
|
1247
|
+
return reverse?"flex-start":"flex-end"
|
|
1248
|
+
}
|
|
1249
|
+
function getTranslate(translate, reverse){
|
|
1250
|
+
const { x, y } = translate;
|
|
1251
|
+
return `translate(${reverse?-x:x}px, ${y}px)`
|
|
1252
|
+
}
|
|
1244
1253
|
const RingLabel = ({
|
|
1245
1254
|
config: {
|
|
1246
1255
|
ringDuration,
|
|
@@ -1250,9 +1259,10 @@ const RingLabel = ({
|
|
|
1250
1259
|
lineColor,
|
|
1251
1260
|
distance,
|
|
1252
1261
|
mode,
|
|
1262
|
+
align="center",
|
|
1253
1263
|
show,
|
|
1254
1264
|
translate: { x: translateX, y: translateY },
|
|
1255
|
-
name: { show: showName, font: nameFont, maxWidth, textOverflow, speed },
|
|
1265
|
+
name: { show: showName, font: nameFont, maxWidth, textOverflow, speed, translate:nameTranslate },
|
|
1256
1266
|
value: {
|
|
1257
1267
|
show: showValue,
|
|
1258
1268
|
font: valueFont,
|
|
@@ -1262,8 +1272,9 @@ const RingLabel = ({
|
|
|
1262
1272
|
fontSize: suffixFontSize,
|
|
1263
1273
|
translate: { x: suffixTranslateX, y: suffixTranslateY },
|
|
1264
1274
|
},
|
|
1275
|
+
translate:valueTranslate
|
|
1265
1276
|
},
|
|
1266
|
-
percent: { show: showPercent, font: percentFont, precision },
|
|
1277
|
+
percent: { show: showPercent, font: percentFont, precision, translate:percentTranslate },
|
|
1267
1278
|
},
|
|
1268
1279
|
iosStyle:{
|
|
1269
1280
|
isIOS, left, top
|
|
@@ -1374,7 +1385,9 @@ const RingLabel = ({
|
|
|
1374
1385
|
width: "max-content",
|
|
1375
1386
|
animationDelay: `${(actualIndex + 1) * ringDuration - labelDuration}ms`,
|
|
1376
1387
|
display:"flex",
|
|
1377
|
-
|
|
1388
|
+
flexDirection:mode=="horizontal"?"row":"column",
|
|
1389
|
+
alignItems:getAlign(align, x3>=0),
|
|
1390
|
+
justifyContent:"center"
|
|
1378
1391
|
}}
|
|
1379
1392
|
>
|
|
1380
1393
|
{_showName && (
|
|
@@ -1388,11 +1401,12 @@ const RingLabel = ({
|
|
|
1388
1401
|
maxWidth,
|
|
1389
1402
|
...getFontStyle(nameFont),
|
|
1390
1403
|
float: mode == "horizontal" ? "left" : "none",
|
|
1404
|
+
transform:getTranslate(nameTranslate, x3>=0)
|
|
1391
1405
|
}}
|
|
1392
1406
|
></TextOverflow>
|
|
1393
1407
|
)}
|
|
1394
1408
|
{showValue && (
|
|
1395
|
-
<span style={getFontStyle(valueFont)}>
|
|
1409
|
+
<span style={{...getFontStyle(valueFont), transform:getTranslate(valueTranslate, x3>=0)}}>
|
|
1396
1410
|
{realData.y}
|
|
1397
1411
|
{showSuffix && (
|
|
1398
1412
|
<span
|
|
@@ -1409,7 +1423,7 @@ const RingLabel = ({
|
|
|
1409
1423
|
</span>
|
|
1410
1424
|
)}
|
|
1411
1425
|
{showPercent && (
|
|
1412
|
-
<span style={getFontStyle(percentFont)}>
|
|
1426
|
+
<span style={{...getFontStyle(percentFont), transform:getTranslate(percentTranslate, x3>=0)}}>
|
|
1413
1427
|
{(_showValue ? "(" : "") +
|
|
1414
1428
|
percent +
|
|
1415
1429
|
"%" +
|