@easyv/charts 1.3.20 → 1.3.22

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.
@@ -1 +1 @@
1
- module.exports = {extends: ['@commitlint/config-conventional']}
1
+ module.exports = {extends: ['@commitlint/config-conventional']}
@@ -33,6 +33,7 @@ var _default = function _default(Component) {
33
33
  rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
34
34
  return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, rest, {
35
35
  config: config,
36
+ originData: data,
36
37
  data: (0, _hooks.useAnimateData)(data, dataAnimation)
37
38
  }));
38
39
  });
@@ -223,7 +223,7 @@ var Label = function Label(_ref5) {
223
223
  return /*#__PURE__*/_react["default"].createElement("tspan", {
224
224
  key: index,
225
225
  x: x,
226
- dy: "1em"
226
+ dy: index != 0 ? '1em' : '0'
227
227
  }, item);
228
228
  }) : _label);
229
229
  };
@@ -65,7 +65,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
65
65
  indicator = _ref$config$tooltip$c3 === void 0 ? {} : _ref$config$tooltip$c3,
66
66
  brush = _ref$config.brush,
67
67
  style = _ref.style,
68
- data = _ref.data,
68
+ originData = _ref.originData,
69
69
  filterData = _ref.filterData;
70
70
  var context = (0, _react.useContext)(_context.chartContext);
71
71
 
@@ -96,10 +96,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
96
96
  setIndex = _useTooltip.setIndex;
97
97
 
98
98
  var tooltipData = (0, _react.useMemo)(function () {
99
- return tickName !== undefined && data.filter(function (d) {
99
+ return tickName !== undefined && originData.filter(function (d) {
100
100
  return d.x === tickName;
101
101
  });
102
- }, [tickName, data]);
102
+ }, [tickName, originData]);
103
103
  var showTooltip = !!(tooltipData && tooltipData.length && (auto || manual));
104
104
  var isVertical = axisX.direction === 'vertical';
105
105
  var indicatorWidth = indicator.width * axisX.step / 100;
@@ -19,6 +19,8 @@ var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _utils = require("../utils");
21
21
 
22
+ var _TextOverflow = _interopRequireDefault(require("./TextOverflow"));
23
+
22
24
  var _excluded = ["italic", "bold"];
23
25
 
24
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -42,6 +44,9 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
42
44
  _ref$config$order = _ref$config.order,
43
45
  order = _ref$config$order === void 0 ? '' : _ref$config$order,
44
46
  interactive = _ref$config.interactive,
47
+ maxWidth = _ref$config.maxWidth,
48
+ textOverflow = _ref$config.textOverflow,
49
+ speed = _ref$config.speed,
45
50
  _ref$config$layout = _ref$config.layout,
46
51
  _ref$config$layout$al = _ref$config$layout.alignment,
47
52
  alignment = _ref$config$layout$al === void 0 ? 'right center' : _ref$config$layout$al,
@@ -123,12 +128,16 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
123
128
  }
124
129
  }, formatter ? formatter(series, config) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
125
130
  style: _icon
126
- }), /*#__PURE__*/_react["default"].createElement("span", {
131
+ }), /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
132
+ type: textOverflow,
133
+ value: displayName || name,
127
134
  style: _objectSpread(_objectSpread({}, font), {}, {
135
+ width: maxWidth,
128
136
  fontStyle: italic ? 'italic' : 'normal',
129
137
  fontWeight: bold ? 'bold' : 'normal'
130
- })
131
- }, displayName || name)));
138
+ }),
139
+ speed: speed
140
+ })));
132
141
  })));
133
142
  });
134
143
 
@@ -145,7 +145,7 @@ var _default = function _default(_ref) {
145
145
  if (type == 'linear' && config.on) {
146
146
  var zeroPosition = scaler(0);
147
147
 
148
- if (zeroPosition !== range[0]) {
148
+ if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
149
149
  if (direction === 'horizontal') {
150
150
  xAxisPositions.push({
151
151
  x: zeroPosition,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.3.20",
3
+ "version": "1.3.22",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -14,11 +14,12 @@ export default (Component: ComponentType<any>) =>
14
14
  data: DataType[];
15
15
  config: { dataAnimation: DataAnimation; [key: string]: any };
16
16
  [key: string]: any;
17
- }) => (
18
- <Component
17
+ }) => {
18
+ return <Component
19
19
  {...rest}
20
20
  config={config}
21
+ originData={data}
21
22
  data={useAnimateData(data, dataAnimation)}
22
23
  />
23
- )
24
+ }
24
25
  );
@@ -227,7 +227,7 @@ const Label: (
227
227
  >
228
228
  {!!Array.isArray(_label)
229
229
  ? _label.map((item, index) => (
230
- <tspan key={index} x={x} dy='1em'>
230
+ <tspan key={index} x={x} dy={index!=0?'1em':'0'}>
231
231
  {item}
232
232
  </tspan>
233
233
  ))
@@ -55,7 +55,8 @@ const Chart = memo(
55
55
  brush,
56
56
  },
57
57
  style,
58
- data,
58
+ //data,
59
+ originData,
59
60
  filterData,
60
61
  }) => {
61
62
  const context = useContext(chartContext);
@@ -65,7 +66,6 @@ const Chart = memo(
65
66
  triggerOnRelative,
66
67
  onEmit,
67
68
  } = useContext(chartContext);
68
-
69
69
  const svg = createRef();
70
70
  const axes = useAxes({ axes: axesConfig, context });
71
71
  const axisX = useCarouselAxisX(axes.get('x'), animation);
@@ -84,8 +84,8 @@ const Chart = memo(
84
84
  config: tooltipConfig,
85
85
  });
86
86
  const tooltipData = useMemo(
87
- () => tickName !== undefined && data.filter((d) => d.x === tickName),
88
- [tickName, data]
87
+ () => tickName !== undefined && originData.filter((d) => d.x === tickName),
88
+ [tickName, originData]
89
89
  );
90
90
 
91
91
  const showTooltip = !!(
@@ -1,165 +1,166 @@
1
- /**
2
- * 图例
3
- */
4
- import React, { memo, useCallback } from 'react';
5
- import { getIcon, sortPie } from '../utils';
6
-
7
- const defaultFont = {
8
- fontStyle: 'normal',
9
- fontWeight: 'normal',
10
- };
11
-
12
- export default memo(
13
- ({
14
- series,
15
- config,
16
- config: {
17
- show,
18
- order = '',
19
- interactive,
20
- layout: {
21
- alignment = 'right center',
22
- gridTemplateColumns,
23
- gridGap: { gridColumnGap, gridRowGap },
24
- translate: { x, y },
25
- },
26
- font: { italic, bold, ...font } = defaultFont,
27
- unselect: { opacity = 1 } = {},
28
- },
29
- filterData,
30
- formatter,
31
- judge
32
- }) => {
33
- if (!show) return null;
34
- const _series = sortPie(series, order);
35
- const [_alignment, position] = alignment.split(' ');
36
- const length = _series.length;
37
-
38
- const onClick = useCallback(
39
- (e) => {
40
- const { dataset } = e.currentTarget;
41
- const { name } = dataset;
42
- filterData && interactive && filterData(name);
43
- },
44
- [interactive, filterData]
45
- );
46
-
47
- //木然判断数据都为零时做的,此处并不严谨,待想到好方法在进一步解决
48
-
49
- if (judge == 0) {
50
- _series.forEach((d) => {
51
- d.percent=0
52
- })
53
- }
54
-
55
- return (
56
- <div
57
- className='__easyv-legend-wrapper'
58
- style={{
59
- position: 'absolute',
60
- height: 'auto',
61
- display: 'flex',
62
- transform: 'translate3d(' + x + 'px, ' + y + 'px, 0px)',
63
- ...getPosition(position, _alignment),
64
- }}
65
- >
66
- <ul
67
- style={{
68
- display: 'grid',
69
- gridGap: gridRowGap + 'px ' + gridColumnGap + 'px',
70
- gridTemplateColumns:
71
- 'repeat(' + Math.min(gridTemplateColumns, length) + ', 1fr)',
72
- }}
73
- >
74
- {_series.map((series, index) => {
75
- const { type, name, displayName, icon, selected } = series;
76
- const _icon = getIcon(type, icon, series?.config?.line?.type);
77
- return (
78
- <li
79
- key={index}
80
- onClick={onClick}
81
- data-name={name}
82
- style={{
83
- display: 'flex',
84
- opacity: selected === false ? opacity / 100 : 1,
85
- alignItems: 'center',
86
- gap: _icon.gap,
87
- }}
88
- >
89
- {formatter ? (
90
- formatter(series, config)
91
- ) : (
92
- <>
93
- <span style={_icon} />
94
- <span
95
- style={{
96
- ...font,
97
- fontStyle: italic ? 'italic' : 'normal',
98
- fontWeight: bold ? 'bold' : 'normal',
99
- }}
100
- >
101
- {displayName || name}
102
- </span>
103
- </>
104
- )}
105
- </li>
106
- );
107
- })}
108
- </ul>
109
- </div>
110
- );
111
- }
112
- );
113
-
114
- const getPosition = (position, alignment) => {
115
- switch (position) {
116
- case 'top':
117
- return {
118
- left: 0,
119
- right: 0,
120
- top: 5,
121
- justifyContent:
122
- alignment === 'center'
123
- ? 'center'
124
- : alignment === 'left'
125
- ? 'flex-start'
126
- : 'flex-end',
127
- };
128
- case 'right':
129
- return {
130
- top: 0,
131
- bottom: 0,
132
- right: 10,
133
- alignItems:
134
- alignment === 'center'
135
- ? 'center'
136
- : alignment === 'left'
137
- ? 'flex-start'
138
- : 'flex-end',
139
- };
140
- case 'left':
141
- return {
142
- top: 0,
143
- bottom: 0,
144
- left: 10,
145
- alignItems:
146
- alignment === 'center'
147
- ? 'center'
148
- : alignment === 'left'
149
- ? 'flex-start'
150
- : 'flex-end',
151
- };
152
- default:
153
- return {
154
- left: 0,
155
- right: 0,
156
- bottom: 5,
157
- justifyContent:
158
- alignment === 'center'
159
- ? 'center'
160
- : alignment === 'left'
161
- ? 'flex-start'
162
- : 'flex-end',
163
- };
164
- }
165
- };
1
+ /**
2
+ * 图例
3
+ */
4
+ import React, { memo, useCallback } from 'react';
5
+ import { getIcon, sortPie } from '../utils';
6
+ import TextOverflow from './TextOverflow';
7
+
8
+ const defaultFont = {
9
+ fontStyle: 'normal',
10
+ fontWeight: 'normal',
11
+ };
12
+
13
+ export default memo(
14
+ ({
15
+ series,
16
+ config,
17
+ config: {
18
+ show,
19
+ order = '',
20
+ interactive,
21
+ maxWidth,
22
+ textOverflow,
23
+ speed,
24
+ layout: {
25
+ alignment = 'right center',
26
+ gridTemplateColumns,
27
+ gridGap: { gridColumnGap, gridRowGap },
28
+ translate: { x, y },
29
+ },
30
+ font: { italic, bold, ...font } = defaultFont,
31
+ unselect: { opacity = 1 } = {},
32
+ },
33
+ filterData,
34
+ formatter,
35
+ judge
36
+ }) => {
37
+ if (!show) return null;
38
+ const _series = sortPie(series, order);
39
+ const [_alignment, position] = alignment.split(' ');
40
+ const length = _series.length;
41
+
42
+ const onClick = useCallback(
43
+ (e) => {
44
+ const { dataset } = e.currentTarget;
45
+ const { name } = dataset;
46
+ filterData && interactive && filterData(name);
47
+ },
48
+ [interactive, filterData]
49
+ );
50
+
51
+ //木然判断数据都为零时做的,此处并不严谨,待想到好方法在进一步解决
52
+ if (judge == 0) {
53
+ _series.forEach((d) => {
54
+ d.percent=0
55
+ })
56
+ }
57
+
58
+ return (
59
+ <div
60
+ className='__easyv-legend-wrapper'
61
+ style={{
62
+ position: 'absolute',
63
+ height: 'auto',
64
+ display: 'flex',
65
+ transform: 'translate3d(' + x + 'px, ' + y + 'px, 0px)',
66
+ ...getPosition(position, _alignment),
67
+ }}
68
+ >
69
+ <ul
70
+ style={{
71
+ display: 'grid',
72
+ gridGap: gridRowGap + 'px ' + gridColumnGap + 'px',
73
+ gridTemplateColumns:
74
+ 'repeat(' + Math.min(gridTemplateColumns, length) + ', 1fr)',
75
+ }}
76
+ >
77
+ {_series.map((series, index) => {
78
+ const { type, name, displayName, icon, selected } = series;
79
+ const _icon = getIcon(type, icon, series?.config?.line?.type);
80
+ return (
81
+ <li
82
+ key={index}
83
+ onClick={onClick}
84
+ data-name={name}
85
+ style={{
86
+ display: 'flex',
87
+ opacity: selected === false ? opacity / 100 : 1,
88
+ alignItems: 'center',
89
+ gap: _icon.gap,
90
+ }}
91
+ >
92
+ {formatter ? (
93
+ formatter(series, config)
94
+ ) : (
95
+ <>
96
+ <span style={_icon} />
97
+ <TextOverflow type={textOverflow} value={displayName || name} style={{
98
+ ...font,
99
+ width:maxWidth,
100
+ fontStyle: italic ? 'italic' : 'normal',
101
+ fontWeight: bold ? 'bold' : 'normal',
102
+ }} speed={speed}></TextOverflow>
103
+
104
+ </>
105
+ )}
106
+ </li>
107
+ );
108
+ })}
109
+ </ul>
110
+ </div>
111
+ );
112
+ }
113
+ );
114
+
115
+ const getPosition = (position, alignment) => {
116
+ switch (position) {
117
+ case 'top':
118
+ return {
119
+ left: 0,
120
+ right: 0,
121
+ top: 5,
122
+ justifyContent:
123
+ alignment === 'center'
124
+ ? 'center'
125
+ : alignment === 'left'
126
+ ? 'flex-start'
127
+ : 'flex-end',
128
+ };
129
+ case 'right':
130
+ return {
131
+ top: 0,
132
+ bottom: 0,
133
+ right: 10,
134
+ alignItems:
135
+ alignment === 'center'
136
+ ? 'center'
137
+ : alignment === 'left'
138
+ ? 'flex-start'
139
+ : 'flex-end',
140
+ };
141
+ case 'left':
142
+ return {
143
+ top: 0,
144
+ bottom: 0,
145
+ left: 10,
146
+ alignItems:
147
+ alignment === 'center'
148
+ ? 'center'
149
+ : alignment === 'left'
150
+ ? 'flex-start'
151
+ : 'flex-end',
152
+ };
153
+ default:
154
+ return {
155
+ left: 0,
156
+ right: 0,
157
+ bottom: 5,
158
+ justifyContent:
159
+ alignment === 'center'
160
+ ? 'center'
161
+ : alignment === 'left'
162
+ ? 'flex-start'
163
+ : 'flex-end',
164
+ };
165
+ }
166
+ };
@@ -33,13 +33,11 @@ export default memo((props) => {
33
33
  }
34
34
  };
35
35
 
36
-
37
36
  const styles = {
38
37
  ...getTextOverflow(type),
39
38
  ...style
40
39
  }
41
40
 
42
-
43
41
  return type == 'marquee' ? (
44
42
  <Marquee
45
43
  value={value}
@@ -141,7 +141,7 @@ export default ({ axes, context: { width, height } }) => {
141
141
 
142
142
  if (type == 'linear' && config.on) {
143
143
  const zeroPosition = scaler(0);
144
- if (zeroPosition !== range[0]) {
144
+ if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
145
145
  if (direction === 'horizontal') {
146
146
  xAxisPositions.push({
147
147
  x: zeroPosition,