@easyv/charts 1.2.14 → 1.3.0

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.
Files changed (76) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/lib/components/Axis.js +10 -10
  5. package/lib/components/Background.js +13 -3
  6. package/lib/components/Band.js +8 -8
  7. package/lib/components/Carousel.js +2 -2
  8. package/lib/components/CartesianChart.js +5 -1
  9. package/lib/components/ConicalGradient.js +21 -21
  10. package/lib/components/Indicator.js +2 -2
  11. package/lib/components/Label.js +11 -12
  12. package/lib/components/Lighter.js +179 -179
  13. package/lib/components/LinearGradient.js +2 -2
  14. package/lib/components/Marquee.js +3 -3
  15. package/lib/components/StackData.js +2 -4
  16. package/lib/components/StereoBar.js +14 -14
  17. package/lib/components/TextOverflow.js +3 -3
  18. package/lib/css/index.module.css +41 -41
  19. package/lib/css/piechart.module.css +26 -26
  20. package/lib/element/ConicGradient.js +72 -72
  21. package/lib/hooks/useAnimateData.js +5 -5
  22. package/lib/hooks/useAxes.js +5 -5
  23. package/lib/hooks/useCarouselAxisX.js +5 -5
  24. package/lib/hooks/useExtentData.js +10 -8
  25. package/lib/hooks/useFilterData.js +5 -5
  26. package/lib/hooks/useStackData.js +11 -10
  27. package/lib/hooks/useTooltip.js +10 -10
  28. package/lib/utils/index.js +62 -41
  29. package/package.json +54 -53
  30. package/src/components/AnimateData.tsx +24 -24
  31. package/src/components/Axis.tsx +354 -354
  32. package/src/components/Background.tsx +62 -45
  33. package/src/components/Band.tsx +169 -173
  34. package/src/components/BaseLine.js +82 -82
  35. package/src/components/Brush.js +159 -159
  36. package/src/components/Carousel.tsx +144 -144
  37. package/src/components/CartesianChart.js +33 -22
  38. package/src/components/Chart.js +99 -99
  39. package/src/components/ChartContainer.tsx +63 -63
  40. package/src/components/ConicalGradient.js +258 -258
  41. package/src/components/ExtentData.js +17 -17
  42. package/src/components/FilterData.js +23 -23
  43. package/src/components/Indicator.js +13 -13
  44. package/src/components/Label.js +225 -206
  45. package/src/components/Legend.js +158 -158
  46. package/src/components/Lighter.jsx +173 -173
  47. package/src/components/Line.js +145 -145
  48. package/src/components/LinearGradient.js +29 -29
  49. package/src/components/Mapping.js +71 -71
  50. package/src/components/Marquee.js +88 -88
  51. package/src/components/PieChart.js +1278 -1278
  52. package/src/components/StackData.js +16 -20
  53. package/src/components/StereoBar.tsx +307 -311
  54. package/src/components/TextOverflow.js +51 -51
  55. package/src/components/Tooltip.js +169 -169
  56. package/src/components/index.js +55 -55
  57. package/src/context/index.js +2 -2
  58. package/src/css/index.module.css +41 -41
  59. package/src/css/piechart.module.css +26 -26
  60. package/src/element/ConicGradient.jsx +55 -55
  61. package/src/element/Line.tsx +33 -33
  62. package/src/element/index.ts +3 -3
  63. package/src/formatter/index.js +1 -1
  64. package/src/formatter/legend.js +90 -90
  65. package/src/hooks/index.js +17 -17
  66. package/src/hooks/useAnimateData.ts +67 -67
  67. package/src/hooks/useAxes.js +144 -144
  68. package/src/hooks/useCarouselAxisX.js +163 -163
  69. package/src/hooks/useExtentData.js +89 -88
  70. package/src/hooks/useFilterData.js +72 -72
  71. package/src/hooks/useStackData.js +101 -100
  72. package/src/hooks/useTooltip.ts +96 -96
  73. package/src/index.js +6 -6
  74. package/src/types/index.d.ts +67 -67
  75. package/src/utils/index.js +731 -714
  76. package/tsconfig.json +23 -23
package/.babelrc CHANGED
@@ -1,8 +1,8 @@
1
- {
2
- "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3
- "plugins": [
4
- "@babel/plugin-proposal-export-default-from",
5
- "@babel/plugin-transform-runtime",
6
- "@babel/plugin-proposal-class-properties"
7
- ]
8
- }
1
+ {
2
+ "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3
+ "plugins": [
4
+ "@babel/plugin-proposal-export-default-from",
5
+ "@babel/plugin-transform-runtime",
6
+ "@babel/plugin-proposal-class-properties"
7
+ ]
8
+ }
package/.husky/commit-msg CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
4
  yarn commitlint --edit $1
package/CHANGELOG.md CHANGED
@@ -1,18 +1,18 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [1.1.1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/compare/v1.1.0...v1.1.1) (2022-04-13)
6
-
7
- ## 1.1.0 (2022-04-02)
8
-
9
-
10
- ### Features
11
-
12
- * 轴标签,label支持样式传入 ([749a595](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/749a595a96b95917dafdc1766f63efec73398d64))
13
- * axis轴标签支持点击触发回调 ([1f636e1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1f636e1840f4f3b48c2b9765ce6087759d82fb17))
14
-
15
-
16
- ### Bug Fixes
17
-
18
- * **band组件:** 修复foreignObject在Safari浏览器下的位置诡异偏离问题 ([1a65d54](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1a65d54abbcf6c9e84cc85cc8b6a9d28b24fa4c4))
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [1.1.1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/compare/v1.1.0...v1.1.1) (2022-04-13)
6
+
7
+ ## 1.1.0 (2022-04-02)
8
+
9
+
10
+ ### Features
11
+
12
+ * 轴标签,label支持样式传入 ([749a595](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/749a595a96b95917dafdc1766f63efec73398d64))
13
+ * axis轴标签支持点击触发回调 ([1f636e1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1f636e1840f4f3b48c2b9765ce6087759d82fb17))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **band组件:** 修复foreignObject在Safari浏览器下的位置诡异偏离问题 ([1a65d54](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1a65d54abbcf6c9e84cc85cc8b6a9d28b24fa4c4))
@@ -59,16 +59,16 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
59
59
  return 'M0, -0.5V' + (height + 0.5);
60
60
  }
61
61
  };
62
- /**
63
- * 根据坐标轴位置来确定轴标签的垂直对齐方式,水平对齐方式,以及轴标签位于坐标轴的哪个方向
64
- * @param orientation 坐标轴位置
65
- * @param rotate 旋转角度
66
- * @returns {
67
- * dominantBaseline,
68
- * textAnchor,
69
- * directionX,
70
- * directionY
71
- * }
62
+ /**
63
+ * 根据坐标轴位置来确定轴标签的垂直对齐方式,水平对齐方式,以及轴标签位于坐标轴的哪个方向
64
+ * @param orientation 坐标轴位置
65
+ * @param rotate 旋转角度
66
+ * @returns {
67
+ * dominantBaseline,
68
+ * textAnchor,
69
+ * directionX,
70
+ * directionY
71
+ * }
72
72
  */
73
73
 
74
74
 
@@ -13,8 +13,8 @@ var _react = _interopRequireDefault(require("react"));
13
13
 
14
14
  var _utils = require("../utils");
15
15
 
16
- /**
17
- * 轴类图背景
16
+ /**
17
+ * 轴类图背景
18
18
  */
19
19
  var _default = function _default(_ref) {
20
20
  var _ref$axis = _ref.axis,
@@ -22,12 +22,22 @@ var _default = function _default(_ref) {
22
22
  scaler = _ref$axis.scaler,
23
23
  step = _ref$axis.step,
24
24
  direction = _ref$axis.direction,
25
+ bandLength = _ref.bandLength,
25
26
  _ref$config = _ref.config,
26
27
  background = _ref$config.background,
28
+ paddingInner = _ref$config.seriesIntervalWidth,
27
29
  paddingOuter = _ref$config.paddingInner,
28
30
  length = _ref.length;
29
31
  var isVertical = direction === 'vertical';
30
- var bandwidth = (0, _utils.getBandwidth)(step, paddingOuter);
32
+
33
+ var _getSeriesInfo = (0, _utils.getSeriesInfo)({
34
+ step: step,
35
+ bandLength: bandLength,
36
+ paddingInner: paddingInner,
37
+ paddingOuter: paddingOuter
38
+ }),
39
+ bandwidth = _getSeriesInfo.width;
40
+
31
41
  var size = isVertical ? {
32
42
  width: length,
33
43
  height: bandwidth
@@ -111,19 +111,19 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
111
111
  direction = _ref3$xAxis.direction,
112
112
  yScaler = _ref3.yAxis.scaler;
113
113
  if (!data.length) return null;
114
- var bandwidth = (0, _utils.getBandwidth)(step, paddingOuter);
115
114
 
116
- var _getBandSeriesStepAnd = (0, _utils.getBandSeriesStepAndWidth)({
117
- width: bandwidth,
115
+ var _getSeriesInfo = (0, _utils.getSeriesInfo)({
116
+ step: step,
117
+ bandLength: bandLength,
118
118
  paddingInner: paddingInner,
119
- bandLength: bandLength
119
+ paddingOuter: paddingOuter
120
120
  }),
121
- seriesStep = _getBandSeriesStepAnd.seriesStep,
122
- seriesWidth = _getBandSeriesStepAnd.seriesWidth;
121
+ seriesWidth = _getSeriesInfo.seriesWidth,
122
+ seriesStep = _getSeriesInfo.seriesStep,
123
+ seriesStart = _getSeriesInfo.seriesStart;
123
124
 
124
125
  var _data = showHighlight ? getHighlightData(data, extent) : data;
125
126
 
126
- var offset = (seriesWidth + paddingInner * seriesStep) * bandLength - paddingInner * seriesStep;
127
127
  var isVertical = direction === 'vertical';
128
128
  return /*#__PURE__*/_react["default"].createElement("g", {
129
129
  className: "__easyv-band"
@@ -141,7 +141,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
141
141
 
142
142
  var y1 = yScaler(isVertical ? end : start);
143
143
  var y2 = yScaler(isVertical ? start : end);
144
- var positionX = xScaler(x) + seriesStep * index - offset / 2;
144
+ var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
145
145
  if (isNaN(positionX)) return null;
146
146
  var positionY = y < 0 ? y1 : y2;
147
147
  var attr = getAttr({
@@ -49,8 +49,8 @@ var defaultAnimation = {
49
49
  opacity: 100
50
50
  }
51
51
  };
52
- /**
53
- * 饼图类图表轮播逻辑,用来管理currentIndex,及回调逻辑(HOC)
52
+ /**
53
+ * 饼图类图表轮播逻辑,用来管理currentIndex,及回调逻辑(HOC)
54
54
  */
55
55
 
56
56
  var _default = function _default(Component) {
@@ -44,6 +44,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
44
44
  animation = _ref$config$chart.animation,
45
45
  legend = _ref$config$chart.legend,
46
46
  series = _ref$config.series,
47
+ bandLength = _ref$config.bandLength,
47
48
  tooltip = _ref$config.tooltip,
48
49
  _ref$config$baseLine = _ref$config.baseLine,
49
50
  _ref$config$baseLine$ = _ref$config$baseLine.orientation,
@@ -133,7 +134,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
133
134
  }, background && /*#__PURE__*/_react["default"].createElement(_.Background, {
134
135
  length: isVertical ? chartWidth : chartHeight,
135
136
  axis: axisX,
136
- config: background
137
+ config: background,
138
+ bandLength: bandLength
137
139
  }), (0, _toConsumableArray2["default"])(axes.values()).map(function (item, index) {
138
140
  var config = item.axisType == 'x' ? axisX : item;
139
141
  return /*#__PURE__*/_react["default"].createElement(_.Axis, (0, _extends2["default"])({
@@ -149,6 +151,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
149
151
  return yAxis && Component && /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({
150
152
  key: index
151
153
  }, config, {
154
+ bandLength: bandLength,
152
155
  xAxis: axisX,
153
156
  yAxis: yAxis,
154
157
  triggerClick: onInteraction
@@ -161,6 +164,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
161
164
  return yAxis && /*#__PURE__*/_react["default"].createElement(_.Label, (0, _extends2["default"])({
162
165
  key: index
163
166
  }, config, {
167
+ bandLength: bandLength,
164
168
  xAxis: axisX,
165
169
  yAxis: yAxis,
166
170
  triggerClick: onInteraction
@@ -23,8 +23,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
23
23
 
24
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
25
 
26
- /**
27
- * 饼图装饰内圈
26
+ /**
27
+ * 饼图装饰内圈
28
28
  */
29
29
  var _default = function _default(_ref) {
30
30
  var width = _ref.width,
@@ -127,8 +127,8 @@ var _default = function _default(_ref) {
127
127
  }
128
128
  });
129
129
  };
130
- /**
131
- * ConicalGradient
130
+ /**
131
+ * ConicalGradient
132
132
  */
133
133
 
134
134
 
@@ -140,11 +140,11 @@ function ConicalGradient() {
140
140
  }
141
141
 
142
142
  ConicalGradient.prototype = {
143
- /**
144
- * addColorStop
145
- *
146
- * @param {Number} offset
147
- * @param {Array} color RGBA值
143
+ /**
144
+ * addColorStop
145
+ *
146
+ * @param {Number} offset
147
+ * @param {Array} color RGBA值
148
148
  */
149
149
  addColorStop: function addColorStop(offset, color) {
150
150
  this._offsets.push(offset);
@@ -154,23 +154,23 @@ ConicalGradient.prototype = {
154
154
  return this;
155
155
  },
156
156
 
157
- /**
158
- * _offsetsReverse (array.forEach callback)
157
+ /**
158
+ * _offsetsReverse (array.forEach callback)
159
159
  */
160
160
  _offsetsReverse: function _offsetsReverse(offset, index, array) {
161
161
  array[index] = 1 - offset;
162
162
  },
163
163
 
164
- /**
165
- * fill
166
- *
167
- * @param {Number} context
168
- * @param {Number} x
169
- * @param {Number} y
170
- * @param {Number} radius
171
- * @param {Number} startAngle
172
- * @param {Number} endAngle
173
- * @param {Boolean} anticlockwise
164
+ /**
165
+ * fill
166
+ *
167
+ * @param {Number} context
168
+ * @param {Number} x
169
+ * @param {Number} y
170
+ * @param {Number} radius
171
+ * @param {Number} startAngle
172
+ * @param {Number} endAngle
173
+ * @param {Boolean} anticlockwise
174
174
  */
175
175
  fill: function fill(context, x, y, radius, startAngle, endAngle, anticlockwise) {
176
176
  var offsets = this._offsets;
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- /**
9
- * 轴类图表移上去的指示框背景
8
+ /**
9
+ * 轴类图表移上去的指示框背景
10
10
  */
11
11
  var _default = function _default(_ref) {
12
12
  var color = _ref.color,
@@ -41,7 +41,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
41
41
  direction = _ref$xAxis.direction,
42
42
  yScaler = _ref.yAxis.scaler,
43
43
  triggerClick = _ref.triggerClick;
44
- var lineType = config.hasOwnProperty('line'); //堆叠处理
44
+ var lineType = config.hasOwnProperty('line'); // 堆叠处理
45
45
 
46
46
  var showIcon = icon && icon.show;
47
47
  var showLabel = label && label.show;
@@ -51,17 +51,16 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
51
51
  width = _useContext.width,
52
52
  height = _useContext.height;
53
53
 
54
- var bandwidth = (0, _utils.getBandwidth)(step, paddingOuter);
55
-
56
- var _getBandSeriesStepAnd = (0, _utils.getBandSeriesStepAndWidth)({
57
- width: bandwidth,
54
+ var _getSeriesInfo = (0, _utils.getSeriesInfo)({
55
+ step: step,
56
+ bandLength: bandLength,
58
57
  paddingInner: paddingInner,
59
- bandLength: bandLength
58
+ paddingOuter: paddingOuter
60
59
  }),
61
- seriesStep = _getBandSeriesStepAnd.seriesStep,
62
- seriesWidth = _getBandSeriesStepAnd.seriesWidth;
60
+ seriesStep = _getSeriesInfo.seriesStep,
61
+ seriesWidth = _getSeriesInfo.seriesWidth,
62
+ seriesStart = _getSeriesInfo.seriesStart;
63
63
 
64
- var offset = (seriesWidth + paddingInner * seriesStep) * bandLength - paddingInner * seriesStep;
65
64
  var isVertical = direction === 'vertical';
66
65
  var _position = label.position;
67
66
  return /*#__PURE__*/React.createElement("g", {
@@ -78,11 +77,11 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
78
77
  showY = _ref2$data.showY,
79
78
  s = _ref2$data.s;
80
79
 
81
- var y1 = yScaler(isVertical ? end : start); //处理z型折线图和堆叠柱图的逻辑冲突
80
+ var y1 = yScaler(isVertical ? end : start); // 处理z型折线图和堆叠柱图的逻辑冲突
82
81
 
83
82
  var y2 = lineType ? start ? yScaler(isVertical ? start : end - start) : yScaler(isVertical ? start : end) : yScaler(isVertical ? start : end); // const y2 = yScaler(isVertical ? start : end);
84
83
 
85
- var positionX = xScaler(x) + seriesStep * index - offset / 2;
84
+ var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
86
85
  if (isNaN(positionX)) return null;
87
86
  var position = positionX + seriesWidth / 2;
88
87
  var labelPosition = isVertical ? getVerticalLabel({
@@ -109,7 +108,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
109
108
  key: i,
110
109
  onClick: triggerClick,
111
110
  "data-data": JSON.stringify(data)
112
- }, showIcon && /*#__PURE__*/React.createElement(Icon, {
111
+ }, showIcon && !isNaN(attr.y) && /*#__PURE__*/React.createElement(Icon, {
113
112
  cx: attr.x,
114
113
  cy: attr.y,
115
114
  config: icon