@easyv/charts 1.6.3 → 1.6.4

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.
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _react = require("react");
@@ -134,7 +136,8 @@ var _default = function _default(_ref) {
134
136
 
135
137
  var _axes = (0, _react.useMemo)(function () {
136
138
  var tmp = new Map();
137
- var xAxisPositions = [];
139
+ var xAxisPositions = new Set(); //用Set去重,去掉重复的x轴
140
+
138
141
  axes.forEach(function (item) {
139
142
  var _item$config$label = item.config.label,
140
143
  extent = _item$config$label.extent,
@@ -396,17 +399,17 @@ var _default = function _default(_ref) {
396
399
  if (type == "linear" && config.on) {
397
400
  var zeroPosition = scaler(0);
398
401
 
399
- if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
402
+ if (!isNaN(zeroPosition)) {
400
403
  if (_direction === "horizontal") {
401
- xAxisPositions.push({
404
+ xAxisPositions.add(JSON.stringify({
402
405
  x: zeroPosition,
403
406
  y: 0
404
- });
407
+ }));
405
408
  } else if (_direction === "vertical") {
406
- xAxisPositions.push({
409
+ xAxisPositions.add(JSON.stringify({
407
410
  x: 0,
408
411
  y: zeroPosition
409
- });
412
+ }));
410
413
  }
411
414
  }
412
415
  }
@@ -456,7 +459,9 @@ var _default = function _default(_ref) {
456
459
  }));
457
460
  }
458
461
  });
459
- tmp.get("x") && (tmp.get("x").positions = xAxisPositions);
462
+ tmp.get("x") && (tmp.get("x").positions = (0, _toConsumableArray2["default"])(xAxisPositions).map(function (d) {
463
+ return JSON.parse(d);
464
+ }));
460
465
  return tmp;
461
466
  }, [axes, controlInfo]);
462
467
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -102,7 +102,7 @@ export default ({
102
102
 
103
103
  const _axes = useMemo(() => {
104
104
  const tmp = new Map();
105
- const xAxisPositions = [];
105
+ const xAxisPositions = new Set(); //用Set去重,去掉重复的x轴
106
106
  axes.forEach((item) => {
107
107
  const {
108
108
  config: {
@@ -390,7 +390,6 @@ export default ({
390
390
  );
391
391
  }
392
392
  let scaler = scales[type]().domain(newDomain).range(range);
393
-
394
393
  scaler.type = type;
395
394
  if (type !== "ordinal") scaler.clamp(true);
396
395
 
@@ -425,17 +424,17 @@ export default ({
425
424
  const lengthWithoutPaddingOuter = length - _paddingOuter;
426
425
  if (type == "linear" && config.on) {
427
426
  const zeroPosition = scaler(0);
428
- if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
427
+ if (!isNaN(zeroPosition)) {
429
428
  if (direction === "horizontal") {
430
- xAxisPositions.push({
429
+ xAxisPositions.add(JSON.stringify({
431
430
  x: zeroPosition,
432
431
  y: 0,
433
- });
432
+ }));
434
433
  } else if (direction === "vertical") {
435
- xAxisPositions.push({
434
+ xAxisPositions.add(JSON.stringify({
436
435
  x: 0,
437
436
  y: zeroPosition,
438
- });
437
+ }));
439
438
  }
440
439
  }
441
440
  }
@@ -487,7 +486,7 @@ export default ({
487
486
  });
488
487
  }
489
488
  });
490
- tmp.get("x") && (tmp.get("x").positions = xAxisPositions);
489
+ tmp.get("x") && (tmp.get("x").positions = [...xAxisPositions].map(d=>JSON.parse(d)));
491
490
  return tmp;
492
491
  }, [axes, controlInfo]);
493
492
  return _axes;