@easyv/charts 1.1.8 → 1.2.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.
@@ -34,13 +34,13 @@ var _default = function _default(data, dataAnimation) {
34
34
  (0, _react.useEffect)(function () {
35
35
  var animateRef = null;
36
36
 
37
- if (dataAnimation && data.length) {
37
+ if (dataAnimation && dataAnimation.show && dataAnimation.duration && data.length) {
38
38
  animateRef = (0, _popmotion.animate)({
39
39
  autoplay: true,
40
40
  repeat: 0,
41
41
  from: 0,
42
42
  to: 1,
43
- duration: 500,
43
+ duration: dataAnimation.duration * 1000,
44
44
  ease: _popmotion.linear,
45
45
  onUpdate: function onUpdate(v) {
46
46
  setAnimateData(function (oldData) {
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
- "release": "standard-version",
8
7
  "make": "babel src -d lib --extensions .ts,.tsx,.js && cp -r src/css lib",
9
8
  "prepare": "husky install"
10
9
  },
@@ -32,7 +31,7 @@
32
31
  "standard-version": "^9.3.2"
33
32
  },
34
33
  "dependencies": {
35
- "@easyv/utils": "^0.0.44",
34
+ "@easyv/utils": "^0.0.45",
36
35
  "d3v7": "npm:d3@^7.0.0",
37
36
  "popmotion": "^9.3.6",
38
37
  "react": "^17.0.2",
@@ -12,7 +12,7 @@ export default (Component: ComponentType<any>) =>
12
12
  ...rest
13
13
  }: {
14
14
  data: DataType[];
15
- config: { dataAnimation: boolean; [key: string]: any };
15
+ config: { dataAnimation: DataAnimation; [key: string]: any };
16
16
  [key: string]: any;
17
17
  }) => (
18
18
  <Component
@@ -8,18 +8,23 @@ import { animate, linear } from 'popmotion';
8
8
  * @returns 改变后的数据
9
9
  */
10
10
 
11
- export default (data: DataType[], dataAnimation: boolean) => {
11
+ export default (data: DataType[], dataAnimation: DataAnimation) => {
12
12
  const [animateData, setAnimateData] = useState<DataType[]>([]);
13
13
 
14
14
  useEffect(() => {
15
15
  let animateRef: any = null;
16
- if (dataAnimation && data.length) {
16
+ if (
17
+ dataAnimation &&
18
+ dataAnimation.show &&
19
+ dataAnimation.duration &&
20
+ data.length
21
+ ) {
17
22
  animateRef = animate({
18
23
  autoplay: true,
19
24
  repeat: 0,
20
25
  from: 0,
21
26
  to: 1,
22
- duration: 500,
27
+ duration: dataAnimation.duration * 1000,
23
28
  ease: linear,
24
29
  onUpdate: (v: number) => {
25
30
  setAnimateData((oldData: DataType[]) => {
@@ -3,6 +3,11 @@ declare module 'd3v7' {
3
3
  export * from 'd3-array';
4
4
  }
5
5
 
6
+ type DataAnimation = {
7
+ show: boolean;
8
+ duration: number;
9
+ };
10
+
6
11
  type DataType = {
7
12
  x: string;
8
13
  y: number;