@easyv/charts 1.5.24 → 1.5.25

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.
@@ -163,7 +163,8 @@ var Unit = function Unit(_ref4) {
163
163
  translateY = _ref4$config$translat.y,
164
164
  _ref4$config$align = _ref4$config.align;
165
165
  _ref4$config$align = _ref4$config$align === void 0 ? defaultAlign : _ref4$config$align;
166
- var textAnchor = _ref4$config$align.textAnchor;
166
+ var textAnchor = _ref4$config$align.textAnchor,
167
+ dataUnit = _ref4.dataUnit;
167
168
  if (!show) return null;
168
169
  return /*#__PURE__*/_react["default"].createElement("text", {
169
170
  className: "__easyv-unit",
@@ -175,7 +176,7 @@ var Unit = function Unit(_ref4) {
175
176
  fontStyle: italic ? "italic" : "normal",
176
177
  letterSpacing: letterSpacing,
177
178
  textAnchor: textAnchor
178
- }, text);
179
+ }, dataUnit || text);
179
180
  };
180
181
 
181
182
  var Label = function Label(_ref5) {
@@ -279,6 +280,7 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
279
280
  marginTop = _ref6$margin.marginTop,
280
281
  positions = _ref6.positions,
281
282
  xLineRange = _ref6.xLineRange,
283
+ dataUnit = _ref6.dataUnit,
282
284
  range = _ref6.range,
283
285
  axisType = _ref6.axisType,
284
286
  _ref6$isClipAxis = _ref6.isClipAxis,
@@ -451,7 +453,8 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
451
453
  clipAxisRange: clipAxisRange,
452
454
  cPercent: cPercent
453
455
  }), isC && tickLine && drawAxisTickLine(), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
454
- config: unit
456
+ config: unit,
457
+ dataUnit: dataUnit
455
458
  })))));
456
459
  }));
457
460
 
@@ -442,7 +442,17 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
442
442
  config: background,
443
443
  bandLength: bandLength
444
444
  }))), (0, _toConsumableArray2["default"])(axes.values()).reverse().map(function (item, index) {
445
- var config = item.axisType == "x" ? axisX : item;
445
+ var axisType = item.axisType;
446
+ var dataUnit = "";
447
+ var config = axisType == "x" ? axisX : item;
448
+ var target = series.find(function (d) {
449
+ return d.yOrZ == axisType;
450
+ });
451
+
452
+ if (target && target.data[0]) {
453
+ dataUnit = target.data[0].data.__unit__;
454
+ }
455
+
446
456
  return /*#__PURE__*/_react["default"].createElement(_.Axis, (0, _extends2["default"])({
447
457
  ref: function ref(d) {
448
458
  axisElList.current[index] = d;
@@ -454,7 +464,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
454
464
  margin: {
455
465
  marginLeft: marginLeft,
456
466
  marginTop: marginTop
457
- }
467
+ },
468
+ dataUnit: dataUnit
458
469
  }, config, {
459
470
  key: index
460
471
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.5.24",
3
+ "version": "1.5.25",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -137,6 +137,7 @@ const AxisLine: ({
137
137
 
138
138
  const Unit: ({
139
139
  config: { show, text, font, translate, align },
140
+ dataUnit
140
141
  }: any) => ReactComponentElement<ComponentType> | null = ({
141
142
  config: {
142
143
  show,
@@ -145,6 +146,7 @@ const Unit: ({
145
146
  translate: { x: translateX, y: translateY },
146
147
  align: { textAnchor } = defaultAlign,
147
148
  },
149
+ dataUnit
148
150
  }) => {
149
151
  if (!show) return null;
150
152
  return (
@@ -159,7 +161,7 @@ const Unit: ({
159
161
  letterSpacing={letterSpacing}
160
162
  textAnchor={textAnchor}
161
163
  >
162
- {text}
164
+ {dataUnit || text}
163
165
  </text>
164
166
  );
165
167
  };
@@ -277,6 +279,7 @@ export default memo(
277
279
  margin:{ marginLeft, marginTop },
278
280
  positions,
279
281
  xLineRange,
282
+ dataUnit,
280
283
  range,
281
284
  axisType,
282
285
  //断轴图相关
@@ -499,7 +502,7 @@ export default memo(
499
502
  cPercent={cPercent}
500
503
  />}
501
504
  {isC && tickLine && drawAxisTickLine()}
502
- {unit && <Unit config={unit} />}
505
+ {unit && <Unit config={unit} dataUnit={dataUnit}/>}
503
506
  </g>
504
507
  </g>
505
508
  </svg>
@@ -379,7 +379,13 @@ const Chart = memo(
379
379
  )}
380
380
  {/* 坐标轴 */}
381
381
  {[...axes.values()].reverse().map((item, index) => {
382
- const config = item.axisType == "x" ? axisX : item;
382
+ const { axisType } = item;
383
+ let dataUnit = "";
384
+ const config = axisType == "x" ? axisX : item;
385
+ const target = series.find(d=>d.yOrZ==axisType);
386
+ if(target && target.data[0]){
387
+ dataUnit = target.data[0].data.__unit__;
388
+ }
383
389
  return (
384
390
  <Axis
385
391
  ref={(d) => {
@@ -390,6 +396,7 @@ const Chart = memo(
390
396
  yLineRange={yLineRange}
391
397
  controlInfo={controlInfo}
392
398
  margin={{marginLeft,marginTop}}
399
+ dataUnit={dataUnit}
393
400
  {...config}
394
401
  key={index}
395
402
  />
@@ -398,7 +405,6 @@ const Chart = memo(
398
405
  {showTooltip && !control && (
399
406
  <Indicator {...indicator} {...indicatorAttr} />
400
407
  )}
401
-
402
408
  <foreignObject
403
409
  style={
404
410
  {
@@ -481,7 +487,6 @@ const Chart = memo(
481
487
  })}
482
488
  </svg>
483
489
  </foreignObject>
484
-
485
490
  {baseLineData &&
486
491
  baseLineData.length > 0 &&
487
492
  baseLineData.map((item, index) => {