@easyv/charts 1.10.37 → 1.10.38
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/Label.js +11 -1
- package/package.json +2 -2
- package/src/components/Label.js +18 -6
package/lib/components/Label.js
CHANGED
|
@@ -43,6 +43,13 @@ var getHighlightData = function getHighlightData(data, extent) {
|
|
|
43
43
|
return data;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
+
var formatWithComma = function formatWithComma(value) {
|
|
47
|
+
if (value === null || value === undefined || value === "") return value;
|
|
48
|
+
return String(value).replace(/^(-?\d+)(\.\d+)?$/, function (_, _int) {
|
|
49
|
+
var dec = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
50
|
+
return _int.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + dec;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
46
53
|
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
47
54
|
var isXRepeat = _ref.isXRepeat,
|
|
48
55
|
_ref$config = _ref.config,
|
|
@@ -228,11 +235,14 @@ var Label = function Label(_ref5) {
|
|
|
228
235
|
_ref5$config$suffix$t = _ref5$config$suffix.translate,
|
|
229
236
|
suffixX = _ref5$config$suffix$t.x,
|
|
230
237
|
suffixY = _ref5$config$suffix$t.y,
|
|
238
|
+
_ref5$config$commaFor = _ref5$config.commaFormatting,
|
|
239
|
+
commaFormatting = _ref5$config$commaFor === void 0 ? true : _ref5$config$commaFor,
|
|
231
240
|
_ref5$textAnchor = _ref5.textAnchor,
|
|
232
241
|
textAnchor = _ref5$textAnchor === void 0 ? "middle" : _ref5$textAnchor,
|
|
233
242
|
_ref5$dominantBaselin = _ref5.dominantBaseline,
|
|
234
243
|
dominantBaseline = _ref5$dominantBaselin === void 0 ? "middle" : _ref5$dominantBaselin,
|
|
235
244
|
reverse = _ref5.reverse;
|
|
245
|
+
var displayValue = commaFormatting ? formatWithComma(value) : value;
|
|
236
246
|
return /*#__PURE__*/React.createElement("text", {
|
|
237
247
|
x: x,
|
|
238
248
|
y: y,
|
|
@@ -243,7 +253,7 @@ var Label = function Label(_ref5) {
|
|
|
243
253
|
textAnchor: textAnchor,
|
|
244
254
|
dominantBaseline: dominantBaseline,
|
|
245
255
|
style: _objectSpread({}, (0, _utils.formatFont)(font, "svg"))
|
|
246
|
-
}, /*#__PURE__*/React.createElement("tspan", null,
|
|
256
|
+
}, /*#__PURE__*/React.createElement("tspan", null, displayValue), /*#__PURE__*/React.createElement("tspan", {
|
|
247
257
|
dx: suffixX,
|
|
248
258
|
dy: suffixY,
|
|
249
259
|
style: _objectSpread({}, (0, _utils.getFontStyle)(suffixFont, "svg"))
|
package/package.json
CHANGED
package/src/components/Label.js
CHANGED
|
@@ -30,6 +30,13 @@ const getHighlightData = (data, extent) => {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
const formatWithComma = (value) => {
|
|
34
|
+
if (value === null || value === undefined || value === "") return value;
|
|
35
|
+
return String(value).replace(/^(-?\d+)(\.\d+)?$/, (_, int, dec = "") => {
|
|
36
|
+
return int.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + dec;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
33
40
|
export default memo(
|
|
34
41
|
({
|
|
35
42
|
isXRepeat,
|
|
@@ -98,15 +105,18 @@ export default memo(
|
|
|
98
105
|
data,
|
|
99
106
|
data: { x, y, showY, s },
|
|
100
107
|
},
|
|
101
|
-
i
|
|
108
|
+
i,
|
|
102
109
|
) => {
|
|
103
110
|
let y1, y2;
|
|
104
111
|
const { icon, label } =
|
|
105
112
|
x == curXLabel ? selectConfig : flag ? highlightConfig : other;
|
|
106
113
|
const showIcon = icon && icon.show;
|
|
107
114
|
const showLabel = label && label.show;
|
|
108
|
-
const {
|
|
109
|
-
|
|
115
|
+
const {
|
|
116
|
+
position: _position = "outerStart",
|
|
117
|
+
reverse = true,
|
|
118
|
+
} = label || {};
|
|
119
|
+
|
|
110
120
|
if (isClipAxis) {
|
|
111
121
|
if (end > +clipValue) {
|
|
112
122
|
y1 = yScaler[1](start);
|
|
@@ -183,11 +193,11 @@ export default memo(
|
|
|
183
193
|
)}
|
|
184
194
|
</g>
|
|
185
195
|
);
|
|
186
|
-
}
|
|
196
|
+
},
|
|
187
197
|
)}
|
|
188
198
|
</g>
|
|
189
199
|
);
|
|
190
|
-
}
|
|
200
|
+
},
|
|
191
201
|
);
|
|
192
202
|
|
|
193
203
|
const Label = ({
|
|
@@ -202,11 +212,13 @@ const Label = ({
|
|
|
202
212
|
font: suffixFont,
|
|
203
213
|
translate: { x: suffixX, y: suffixY },
|
|
204
214
|
},
|
|
215
|
+
commaFormatting = true,
|
|
205
216
|
},
|
|
206
217
|
textAnchor = "middle",
|
|
207
218
|
dominantBaseline = "middle",
|
|
208
219
|
reverse,
|
|
209
220
|
}) => {
|
|
221
|
+
const displayValue = commaFormatting ? formatWithComma(value) : value;
|
|
210
222
|
return (
|
|
211
223
|
<text
|
|
212
224
|
x={x}
|
|
@@ -219,7 +231,7 @@ const Label = ({
|
|
|
219
231
|
dominantBaseline={dominantBaseline}
|
|
220
232
|
style={{ ...formatFont(font, "svg") }}
|
|
221
233
|
>
|
|
222
|
-
<tspan>{
|
|
234
|
+
<tspan>{displayValue}</tspan>
|
|
223
235
|
<tspan
|
|
224
236
|
dx={suffixX}
|
|
225
237
|
dy={suffixY}
|