@easyv/charts 1.2.1 → 1.2.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.
Files changed (90) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/commitlint.config.js +1 -1
  5. package/lib/components/AnimateData.js +40 -36
  6. package/lib/components/Axis.js +333 -329
  7. package/lib/components/Background.js +2 -2
  8. package/lib/components/Band.js +177 -173
  9. package/lib/components/Brush.js +201 -201
  10. package/lib/components/Carousel.js +171 -164
  11. package/lib/components/CartesianChart.js +11 -7
  12. package/lib/components/Chart.js +114 -111
  13. package/lib/components/ChartContainer.js +62 -58
  14. package/lib/components/ConicalGradient.js +268 -264
  15. package/lib/components/ExtentData.js +48 -45
  16. package/lib/components/FilterData.js +56 -53
  17. package/lib/components/Indicator.js +2 -2
  18. package/lib/components/Label.js +278 -278
  19. package/lib/components/Legend.js +160 -154
  20. package/lib/components/Lighter.js +179 -179
  21. package/lib/components/Line.js +187 -181
  22. package/lib/components/LinearGradient.js +2 -2
  23. package/lib/components/Mapping.js +130 -127
  24. package/lib/components/Marquee.js +98 -0
  25. package/lib/components/PieChart.js +1078 -1061
  26. package/lib/components/StackData.js +48 -45
  27. package/lib/components/StereoBar.js +340 -336
  28. package/lib/components/TextOverflow.js +65 -0
  29. package/lib/components/Tooltip.js +155 -155
  30. package/lib/components/index.js +202 -194
  31. package/lib/css/index.module.css +41 -41
  32. package/lib/css/piechart.module.css +26 -26
  33. package/lib/element/ConicGradient.js +72 -72
  34. package/lib/formatter/legend.js +91 -91
  35. package/lib/hooks/index.js +62 -62
  36. package/lib/hooks/useAnimateData.js +88 -88
  37. package/lib/hooks/useAxes.js +135 -135
  38. package/lib/hooks/useCarouselAxisX.js +184 -184
  39. package/lib/hooks/useExtentData.js +128 -128
  40. package/lib/hooks/useFilterData.js +112 -112
  41. package/lib/hooks/useStackData.js +136 -134
  42. package/lib/hooks/useTooltip.js +10 -10
  43. package/lib/index.js +89 -85
  44. package/lib/utils/index.js +835 -832
  45. package/package.json +53 -51
  46. package/src/components/AnimateData.tsx +24 -24
  47. package/src/components/Axis.tsx +354 -354
  48. package/src/components/Background.tsx +45 -45
  49. package/src/components/Band.tsx +173 -173
  50. package/src/components/Brush.js +159 -159
  51. package/src/components/Carousel.tsx +144 -144
  52. package/src/components/Chart.js +99 -99
  53. package/src/components/ChartContainer.tsx +63 -63
  54. package/src/components/ConicalGradient.js +258 -258
  55. package/src/components/ExtentData.js +17 -17
  56. package/src/components/FilterData.js +23 -23
  57. package/src/components/Indicator.js +13 -13
  58. package/src/components/Label.js +206 -206
  59. package/src/components/Legend.js +158 -158
  60. package/src/components/Lighter.jsx +173 -173
  61. package/src/components/Line.js +144 -144
  62. package/src/components/LinearGradient.js +29 -29
  63. package/src/components/Mapping.js +71 -71
  64. package/src/components/Marquee.js +93 -74
  65. package/src/components/PieChart.js +1288 -1097
  66. package/src/components/StackData.js +20 -20
  67. package/src/components/StereoBar.tsx +310 -310
  68. package/src/components/TextOverflow.js +51 -0
  69. package/src/components/Tooltip.js +169 -169
  70. package/src/components/index.js +53 -51
  71. package/src/context/index.js +2 -2
  72. package/src/css/index.module.css +41 -41
  73. package/src/css/piechart.module.css +26 -26
  74. package/src/element/ConicGradient.jsx +55 -55
  75. package/src/element/Line.tsx +33 -33
  76. package/src/element/index.ts +3 -3
  77. package/src/formatter/index.js +1 -1
  78. package/src/formatter/legend.js +90 -90
  79. package/src/hooks/index.js +17 -17
  80. package/src/hooks/useAnimateData.ts +67 -67
  81. package/src/hooks/useAxes.js +144 -144
  82. package/src/hooks/useCarouselAxisX.js +163 -163
  83. package/src/hooks/useExtentData.js +88 -88
  84. package/src/hooks/useFilterData.js +72 -72
  85. package/src/hooks/useStackData.js +100 -100
  86. package/src/hooks/useTooltip.ts +96 -96
  87. package/src/index.js +6 -6
  88. package/src/types/index.d.ts +67 -67
  89. package/src/utils/index.js +696 -696
  90. package/tsconfig.json +22 -22
@@ -1,202 +1,202 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _react = require("react");
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
- var left = {
21
- position: 'relative',
22
- width: 5,
23
- height: '100%',
24
- cursor: 'col-resize',
25
- backgroundClip: 'content-box'
26
- };
27
- var center = {
28
- flex: '1 1 0%',
29
- height: '100%',
30
- cursor: 'move'
31
- };
32
- var right = {
33
- position: 'relative',
34
- width: 5,
35
- height: '100%',
36
- cursor: 'col-resize',
37
- backgroundClip: 'content-box'
38
- };
39
- var initialPosition = {
40
- start: 0,
41
- end: 0,
42
- status: ''
43
- };
44
-
45
- var getValue = function getValue(x, min, max) {
46
- return Math.max(min, Math.min(x, max));
47
- };
48
-
49
- var _default = function _default(_ref) {
50
- var width = _ref.width,
51
- _ref$config = _ref.config,
52
- height = _ref$config.height,
53
- background = _ref$config.background,
54
- _ref$config$margin = _ref$config.margin,
55
- marginLeft = _ref$config$margin.marginLeft,
56
- marginRight = _ref$config$margin.marginRight,
57
- _ref$config$detail = _ref$config.detail,
58
- blockWidth = _ref$config$detail.width,
59
- color = _ref$config$detail.color;
60
-
61
- var _useState = (0, _react.useState)({
62
- translateX: 0,
63
- width: blockWidth
64
- }),
65
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
66
- state = _useState2[0],
67
- setState = _useState2[1];
68
-
69
- var availableWidth = width - marginLeft - marginRight;
70
- var cache = (0, _react.useRef)(state);
71
- var move = (0, _react.useCallback)(function (_ref2) {
72
- var delta = _ref2.delta,
73
- status = _ref2.status,
74
- name = _ref2.name;
75
- var _cache$current = cache.current,
76
- width = _cache$current.width,
77
- translateX = _cache$current.translateX;
78
- var minWidth = 40;
79
- var minX = 0;
80
-
81
- switch (name) {
82
- case 'center':
83
- translateX = getValue(translateX + delta, minX, availableWidth - width);
84
- break;
85
-
86
- case 'left':
87
- var tempWidth = width;
88
- width = getValue(width + delta * -1, minWidth, translateX + width);
89
- translateX = getValue(translateX + delta, minX, translateX + tempWidth - width);
90
- break;
91
-
92
- case 'right':
93
- width = getValue(width + delta, minWidth, availableWidth - translateX);
94
- break;
95
- }
96
-
97
- if (status === 'up') {
98
- cache.current = {
99
- width: width,
100
- translateX: translateX
101
- };
102
- }
103
-
104
- setState({
105
- width: width,
106
- translateX: translateX
107
- });
108
- }, [availableWidth]);
109
- (0, _react.useEffect)(function () {}, [state]);
110
- return /*#__PURE__*/React.createElement("div", {
111
- style: {
112
- marginLeft: marginLeft,
113
- marginRight: marginRight,
114
- height: height,
115
- background: background,
116
- position: 'absolute',
117
- bottom: 0,
118
- width: availableWidth
119
- }
120
- }, /*#__PURE__*/React.createElement("div", {
121
- style: {
122
- display: 'flex',
123
- justifyContent: 'space-between',
124
- position: 'absolute',
125
- top: 0,
126
- left: 0,
127
- transform: 'translate3d(' + state.translateX + 'px, 0, 0)',
128
- height: '100%',
129
- width: state.width + 'px',
130
- backgroundColor: color
131
- }
132
- }, /*#__PURE__*/React.createElement(Move, {
133
- style: left,
134
- move: move,
135
- name: "left"
136
- }), /*#__PURE__*/React.createElement(Move, {
137
- style: center,
138
- move: move,
139
- name: "center"
140
- }), /*#__PURE__*/React.createElement(Move, {
141
- style: right,
142
- move: move,
143
- name: "right"
144
- })));
145
- };
146
-
147
- exports["default"] = _default;
148
- var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
149
- var style = _ref3.style,
150
- move = _ref3.move,
151
- name = _ref3.name;
152
-
153
- var _useState3 = (0, _react.useState)(initialPosition),
154
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
155
- position = _useState4[0],
156
- setPosition = _useState4[1];
157
-
158
- var documentOnMouseMove = (0, _react.useCallback)(function (e) {
159
- // console.log('documentOnMouseMove');
160
- setPosition(function (position) {
161
- return _objectSpread(_objectSpread({}, position), {}, {
162
- end: e.clientX,
163
- status: 'move'
164
- });
165
- });
166
- }, []);
167
- var documentOnMouseUp = (0, _react.useCallback)(function (e) {
168
- // console.log('documentOnMouseUp');
169
- setPosition(function (position) {
170
- return _objectSpread(_objectSpread({}, position), {}, {
171
- end: e.clientX,
172
- status: 'up'
173
- });
174
- });
175
- document.removeEventListener('mousemove', documentOnMouseMove);
176
- document.removeEventListener('mouseup', documentOnMouseUp);
177
- }, []);
178
- var onMouseDown = (0, _react.useCallback)(function (e) {
179
- // console.log('onMouseDown');
180
- setPosition({
181
- end: e.clientX,
182
- start: e.clientX,
183
- status: 'down'
184
- });
185
- document.addEventListener('mousemove', documentOnMouseMove);
186
- document.addEventListener('mouseup', documentOnMouseUp);
187
- }, []);
188
- (0, _react.useEffect)(function () {
189
- var start = position.start,
190
- end = position.end,
191
- status = position.status;
192
- move({
193
- delta: end - start,
194
- status: status,
195
- name: name
196
- });
197
- }, [position, move, name]);
198
- return /*#__PURE__*/React.createElement("div", {
199
- style: style,
200
- onMouseDown: onMouseDown
201
- });
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _react = require("react");
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
+
20
+ var left = {
21
+ position: 'relative',
22
+ width: 5,
23
+ height: '100%',
24
+ cursor: 'col-resize',
25
+ backgroundClip: 'content-box'
26
+ };
27
+ var center = {
28
+ flex: '1 1 0%',
29
+ height: '100%',
30
+ cursor: 'move'
31
+ };
32
+ var right = {
33
+ position: 'relative',
34
+ width: 5,
35
+ height: '100%',
36
+ cursor: 'col-resize',
37
+ backgroundClip: 'content-box'
38
+ };
39
+ var initialPosition = {
40
+ start: 0,
41
+ end: 0,
42
+ status: ''
43
+ };
44
+
45
+ var getValue = function getValue(x, min, max) {
46
+ return Math.max(min, Math.min(x, max));
47
+ };
48
+
49
+ var _default = function _default(_ref) {
50
+ var width = _ref.width,
51
+ _ref$config = _ref.config,
52
+ height = _ref$config.height,
53
+ background = _ref$config.background,
54
+ _ref$config$margin = _ref$config.margin,
55
+ marginLeft = _ref$config$margin.marginLeft,
56
+ marginRight = _ref$config$margin.marginRight,
57
+ _ref$config$detail = _ref$config.detail,
58
+ blockWidth = _ref$config$detail.width,
59
+ color = _ref$config$detail.color;
60
+
61
+ var _useState = (0, _react.useState)({
62
+ translateX: 0,
63
+ width: blockWidth
64
+ }),
65
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
66
+ state = _useState2[0],
67
+ setState = _useState2[1];
68
+
69
+ var availableWidth = width - marginLeft - marginRight;
70
+ var cache = (0, _react.useRef)(state);
71
+ var move = (0, _react.useCallback)(function (_ref2) {
72
+ var delta = _ref2.delta,
73
+ status = _ref2.status,
74
+ name = _ref2.name;
75
+ var _cache$current = cache.current,
76
+ width = _cache$current.width,
77
+ translateX = _cache$current.translateX;
78
+ var minWidth = 40;
79
+ var minX = 0;
80
+
81
+ switch (name) {
82
+ case 'center':
83
+ translateX = getValue(translateX + delta, minX, availableWidth - width);
84
+ break;
85
+
86
+ case 'left':
87
+ var tempWidth = width;
88
+ width = getValue(width + delta * -1, minWidth, translateX + width);
89
+ translateX = getValue(translateX + delta, minX, translateX + tempWidth - width);
90
+ break;
91
+
92
+ case 'right':
93
+ width = getValue(width + delta, minWidth, availableWidth - translateX);
94
+ break;
95
+ }
96
+
97
+ if (status === 'up') {
98
+ cache.current = {
99
+ width: width,
100
+ translateX: translateX
101
+ };
102
+ }
103
+
104
+ setState({
105
+ width: width,
106
+ translateX: translateX
107
+ });
108
+ }, [availableWidth]);
109
+ (0, _react.useEffect)(function () {}, [state]);
110
+ return /*#__PURE__*/React.createElement("div", {
111
+ style: {
112
+ marginLeft: marginLeft,
113
+ marginRight: marginRight,
114
+ height: height,
115
+ background: background,
116
+ position: 'absolute',
117
+ bottom: 0,
118
+ width: availableWidth
119
+ }
120
+ }, /*#__PURE__*/React.createElement("div", {
121
+ style: {
122
+ display: 'flex',
123
+ justifyContent: 'space-between',
124
+ position: 'absolute',
125
+ top: 0,
126
+ left: 0,
127
+ transform: 'translate3d(' + state.translateX + 'px, 0, 0)',
128
+ height: '100%',
129
+ width: state.width + 'px',
130
+ backgroundColor: color
131
+ }
132
+ }, /*#__PURE__*/React.createElement(Move, {
133
+ style: left,
134
+ move: move,
135
+ name: "left"
136
+ }), /*#__PURE__*/React.createElement(Move, {
137
+ style: center,
138
+ move: move,
139
+ name: "center"
140
+ }), /*#__PURE__*/React.createElement(Move, {
141
+ style: right,
142
+ move: move,
143
+ name: "right"
144
+ })));
145
+ };
146
+
147
+ exports["default"] = _default;
148
+ var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
149
+ var style = _ref3.style,
150
+ move = _ref3.move,
151
+ name = _ref3.name;
152
+
153
+ var _useState3 = (0, _react.useState)(initialPosition),
154
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
155
+ position = _useState4[0],
156
+ setPosition = _useState4[1];
157
+
158
+ var documentOnMouseMove = (0, _react.useCallback)(function (e) {
159
+ // console.log('documentOnMouseMove');
160
+ setPosition(function (position) {
161
+ return _objectSpread(_objectSpread({}, position), {}, {
162
+ end: e.clientX,
163
+ status: 'move'
164
+ });
165
+ });
166
+ }, []);
167
+ var documentOnMouseUp = (0, _react.useCallback)(function (e) {
168
+ // console.log('documentOnMouseUp');
169
+ setPosition(function (position) {
170
+ return _objectSpread(_objectSpread({}, position), {}, {
171
+ end: e.clientX,
172
+ status: 'up'
173
+ });
174
+ });
175
+ document.removeEventListener('mousemove', documentOnMouseMove);
176
+ document.removeEventListener('mouseup', documentOnMouseUp);
177
+ }, []);
178
+ var onMouseDown = (0, _react.useCallback)(function (e) {
179
+ // console.log('onMouseDown');
180
+ setPosition({
181
+ end: e.clientX,
182
+ start: e.clientX,
183
+ status: 'down'
184
+ });
185
+ document.addEventListener('mousemove', documentOnMouseMove);
186
+ document.addEventListener('mouseup', documentOnMouseUp);
187
+ }, []);
188
+ (0, _react.useEffect)(function () {
189
+ var start = position.start,
190
+ end = position.end,
191
+ status = position.status;
192
+ move({
193
+ delta: end - start,
194
+ status: status,
195
+ name: name
196
+ });
197
+ }, [position, move, name]);
198
+ return /*#__PURE__*/React.createElement("div", {
199
+ style: style,
200
+ onMouseDown: onMouseDown
201
+ });
202
202
  });