@easyv/charts 1.4.17 → 1.4.19

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/.husky/commit-msg CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
2
  . "$(dirname "$0")/_/husky.sh"
3
3
 
4
- pnpm commitlint --edit $1
4
+ yarn commitlint --edit $1
@@ -46,10 +46,12 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
46
46
  marginLeft = _ref$config$line$marg.marginLeft,
47
47
  marginRight = _ref$config$line$marg.marginRight,
48
48
  strokeDasharray = _ref$config$line.strokeDasharray,
49
+ yOrZ = _ref.yOrZ,
49
50
  _ref$yAxis = _ref.yAxis,
50
51
  yScaler = _ref$yAxis.scaler,
51
52
  clipValue = _ref$yAxis.clipValue,
52
53
  isClipAxis = _ref$yAxis.isClipAxis,
54
+ scaler = _ref.axisX.scaler,
53
55
  data = _ref.data;
54
56
 
55
57
  try {
@@ -62,7 +64,18 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
62
64
  x1 = orientation == 'left' ? yScaler[1](data.value) : marginLeft, x2 = orientation == 'left' ? yScaler[1](data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler[1](data.value), y2 = orientation == 'left' ? height - marginRight : yScaler[1](data.value);
63
65
  }
64
66
  } else {
65
- x1 = orientation == 'left' ? yScaler(data.value) : marginLeft, x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler(data.value), y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
67
+ if (yOrZ == "x") {
68
+ x1 = orientation == 'left' ? marginLeft : scaler(data.value), x2 = orientation == 'left' ? width - marginRight : scaler(data.value), y1 = orientation == 'left' ? scaler(data.value) : marginLeft, y2 = orientation == 'left' ? scaler(data.value) : height - marginRight;
69
+ } else {
70
+ x1 = orientation == 'left' ? yScaler(data.value) : marginLeft, x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler(data.value), y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
71
+ }
72
+ } //当坐标值存在undefined时,返回null
73
+
74
+
75
+ if ([x1, x2, y1, y2].some(function (d) {
76
+ return d == undefined;
77
+ })) {
78
+ return null;
66
79
  }
67
80
 
68
81
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("g", {
@@ -225,7 +225,9 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
225
225
  key: index,
226
226
  config: baseLineConfig[index],
227
227
  baseLineOri: baseLineOri,
228
+ yOrZ: yOrZ,
228
229
  yAxis: yAxis,
230
+ axisX: axisX,
229
231
  data: item
230
232
  });
231
233
  })), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
@@ -151,6 +151,12 @@ var Label = function Label(_ref3) {
151
151
  translateX = _ref3$config$translat2 === void 0 ? 0 : _ref3$config$translat2,
152
152
  _ref3$config$translat3 = _ref3$config$translat.y,
153
153
  translateY = _ref3$config$translat3 === void 0 ? 0 : _ref3$config$translat3,
154
+ _ref3$config$suffix = _ref3$config.suffix,
155
+ content = _ref3$config$suffix.content,
156
+ suffixFont = _ref3$config$suffix.font,
157
+ _ref3$config$suffix$t = _ref3$config$suffix.translate,
158
+ suffixX = _ref3$config$suffix$t.x,
159
+ suffixY = _ref3$config$suffix$t.y,
154
160
  _ref3$textAnchor = _ref3.textAnchor,
155
161
  textAnchor = _ref3$textAnchor === void 0 ? "middle" : _ref3$textAnchor,
156
162
  _ref3$dominantBaselin = _ref3.dominantBaseline,
@@ -164,7 +170,11 @@ var Label = function Label(_ref3) {
164
170
  }),
165
171
  textAnchor: textAnchor,
166
172
  dominantBaseline: dominantBaseline
167
- }, font), value);
173
+ }, font), /*#__PURE__*/React.createElement("tspan", null, value), /*#__PURE__*/React.createElement("tspan", {
174
+ dx: suffixX,
175
+ dy: suffixY,
176
+ style: _objectSpread({}, (0, _utils.getFontStyle)(suffixFont, "svg"))
177
+ }, content));
168
178
  };
169
179
 
170
180
  var Icon = function Icon(_ref4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -46,7 +46,6 @@ export default ({
46
46
  width: bandwidth,
47
47
  height: length,
48
48
  };
49
-
50
49
  return ticks.map((tick, index: number) => {
51
50
  return (
52
51
  <rect
@@ -34,11 +34,12 @@ export default memo(
34
34
  strokeDasharray,
35
35
  },
36
36
  },
37
- yAxis: { scaler: yScaler,clipValue,isClipAxis },
37
+ yOrZ,
38
+ yAxis: { scaler: yScaler, clipValue, isClipAxis },
39
+ axisX: { scaler },
38
40
  data
39
41
  }) => {
40
42
  try{
41
-
42
43
  let x1,x2,y1,y2
43
44
  if (isClipAxis) {
44
45
  if (data.value > +clipValue) {
@@ -53,12 +54,22 @@ export default memo(
53
54
  y2 = orientation == 'left' ? height - marginRight : yScaler[1](data.value);
54
55
  }
55
56
  } else {
56
- x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
57
- x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
58
- y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
59
- y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
57
+ if(yOrZ=="x"){
58
+ x1 = orientation == 'left' ? marginLeft:scaler(data.value),
59
+ x2 = orientation == 'left' ? width - marginRight:scaler(data.value),
60
+ y1 = orientation == 'left' ? scaler(data.value):marginLeft ,
61
+ y2 = orientation == 'left' ? scaler(data.value):height - marginRight;
62
+ }else{
63
+ x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
64
+ x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
65
+ y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
66
+ y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
67
+ }
68
+ }
69
+ //当坐标值存在undefined时,返回null
70
+ if([x1,x2,y1,y2].some(d=>d==undefined)){
71
+ return null
60
72
  }
61
-
62
73
  return (
63
74
  <>
64
75
  <g className='__easyv-baseLine' >
@@ -218,7 +218,9 @@ const Chart = memo(
218
218
  key={index}
219
219
  config={baseLineConfig[index]}
220
220
  baseLineOri={baseLineOri}
221
+ yOrZ={yOrZ}
221
222
  yAxis={yAxis}
223
+ axisX={axisX}
222
224
  data={item}
223
225
  />
224
226
  )
@@ -2,7 +2,7 @@
2
2
  * 轴类图表标签
3
3
  */
4
4
  import { memo, useContext } from "react";
5
- import { getTranslate2d, getSeriesInfo } from "../utils";
5
+ import { getTranslate2d, getSeriesInfo, getFontStyle } from "../utils";
6
6
  import { chartContext } from "../context";
7
7
 
8
8
  export default memo(
@@ -120,6 +120,9 @@ const Label = ({
120
120
  config: {
121
121
  font,
122
122
  translate: { x: translateX = 0, y: translateY = 0 },
123
+ suffix:{
124
+ content, font:suffixFont, translate:{ x:suffixX, y:suffixY }
125
+ }
123
126
  },
124
127
  textAnchor = "middle",
125
128
  dominantBaseline = "middle",
@@ -136,7 +139,10 @@ const Label = ({
136
139
  dominantBaseline={dominantBaseline}
137
140
  {...font}
138
141
  >
139
- {value}
142
+ <tspan>{value}</tspan>
143
+ <tspan dx={suffixX} dy={suffixY} style={{
144
+ ...getFontStyle(suffixFont,"svg")
145
+ }}>{content}</tspan>
140
146
  </text>
141
147
  );
142
148
  };