@easyv/charts 1.10.37 → 1.10.39

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.
@@ -284,20 +284,16 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
284
284
  },
285
285
  onMouseLeave: function onMouseLeave(e) {
286
286
  triggerEvents ? triggerEvents(e, "mouseleave") : "";
287
- if (isControlChart && !auto) {
288
- setCtlTip(function (pre) {
289
- return {
290
- show: false,
291
- x: undefined,
292
- xName: undefined,
293
- indicatorList: pre.indicatorList.map(function (item) {
294
- return _objectSpread(_objectSpread({}, item), {}, {
295
- isShow: false
296
- });
297
- })
298
- };
299
- });
300
- }
287
+ // if (isControlChart && !auto) {
288
+ // setCtlTip((pre: any) => ({
289
+ // show: false,
290
+ // x: undefined,
291
+ // xName: undefined,
292
+ // indicatorList: pre.indicatorList.map((item: any) => {
293
+ // return { ...item, isShow: false };
294
+ // }),
295
+ // }));
296
+ // }
301
297
  },
302
298
  "data-mobile": JSON.stringify({
303
299
  x: xScaler(x),
@@ -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, value), /*#__PURE__*/React.createElement("tspan", {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.10.37",
3
+ "version": "1.10.39",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -55,4 +55,4 @@
55
55
  "commit": true
56
56
  }
57
57
  }
58
- }
58
+ }
@@ -280,16 +280,16 @@ export default memo(
280
280
  }}
281
281
  onMouseLeave={(e) => {
282
282
  triggerEvents ? triggerEvents(e, "mouseleave") : "";
283
- if (isControlChart && !auto) {
284
- setCtlTip((pre: any) => ({
285
- show: false,
286
- x: undefined,
287
- xName: undefined,
288
- indicatorList: pre.indicatorList.map((item: any) => {
289
- return { ...item, isShow: false };
290
- }),
291
- }));
292
- }
283
+ // if (isControlChart && !auto) {
284
+ // setCtlTip((pre: any) => ({
285
+ // show: false,
286
+ // x: undefined,
287
+ // xName: undefined,
288
+ // indicatorList: pre.indicatorList.map((item: any) => {
289
+ // return { ...item, isShow: false };
290
+ // }),
291
+ // }));
292
+ // }
293
293
  }}
294
294
  data-mobile={JSON.stringify({ x: xScaler(x), xName: data.x })}
295
295
  data-data={JSON.stringify(data)}
@@ -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 { position: _position = "outerStart", reverse = true } =
109
- label || {};
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>{value}</tspan>
234
+ <tspan>{displayValue}</tspan>
223
235
  <tspan
224
236
  dx={suffixX}
225
237
  dy={suffixY}