@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.
- package/commitlint.config.js +1 -1
- package/lib/components/AnimateData.js +1 -0
- package/lib/components/Axis.js +1 -1
- package/lib/components/CartesianChart.js +3 -3
- package/lib/components/Legend.js +12 -3
- package/lib/hooks/useAxes.js +1 -1
- package/package.json +1 -1
- package/src/components/AnimateData.tsx +4 -3
- package/src/components/Axis.tsx +1 -1
- package/src/components/CartesianChart.js +4 -4
- package/src/components/Legend.js +166 -165
- package/src/components/TextOverflow.js +0 -2
- package/src/hooks/useAxes.js +1 -1
package/commitlint.config.js
CHANGED
|
@@ -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
|
});
|
package/lib/components/Axis.js
CHANGED
|
@@ -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
|
-
|
|
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 &&
|
|
99
|
+
return tickName !== undefined && originData.filter(function (d) {
|
|
100
100
|
return d.x === tickName;
|
|
101
101
|
});
|
|
102
|
-
}, [tickName,
|
|
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;
|
package/lib/components/Legend.js
CHANGED
|
@@ -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("
|
|
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
|
-
|
|
138
|
+
}),
|
|
139
|
+
speed: speed
|
|
140
|
+
})));
|
|
132
141
|
})));
|
|
133
142
|
});
|
|
134
143
|
|
package/lib/hooks/useAxes.js
CHANGED
|
@@ -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
|
@@ -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
|
);
|
package/src/components/Axis.tsx
CHANGED
|
@@ -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 &&
|
|
88
|
-
[tickName,
|
|
87
|
+
() => tickName !== undefined && originData.filter((d) => d.x === tickName),
|
|
88
|
+
[tickName, originData]
|
|
89
89
|
);
|
|
90
90
|
|
|
91
91
|
const showTooltip = !!(
|
package/src/components/Legend.js
CHANGED
|
@@ -1,165 +1,166 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 图例
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo, useCallback } from 'react';
|
|
5
|
-
import { getIcon, sortPie } from '../utils';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
config
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
};
|
package/src/hooks/useAxes.js
CHANGED
|
@@ -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,
|