Skip to content

Commit

Permalink
fix: 修复几个bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Apr 30, 2021
1 parent 91a918d commit ea347dc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@antv/scale": "~0.3.3",
"@antv/util": "~2.0.6",
"@babel/runtime": "^7.12.5",
"d3-cloud": "^1.2.5",
"d3-hierarchy": "^2.0.0",
"d3-interpolate": "^2.0.1"
},
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/canvas/animation/interpolate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
interpolateObject
} from 'd3-interpolate';

// const hasNaN = (obj) => {
// return Object.keys(obj).find(key => isNaN(obj[key]))
// }

function interpolateObjectArray(a, b) {
const nb = b ? b.length : 0;
Expand All @@ -28,9 +31,15 @@ export default (a: any, b: any) => {
}
if (Array.isArray(b)) {
if (typeof b !== 'number') {
// if (hasNaN(a[0])) {
// return interpolateObjectArray(b, b);
// }
return interpolateObjectArray(a, b);
}
return interpolateNumberArray(a, b);
}
// if (isNaN(a)) {
// return interpolateNumber(b, b);
// }
return interpolateNumber(a, b);
};
10 changes: 10 additions & 0 deletions packages/components/src/chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,20 @@ class Chart extends Container {

update(props) {
super.update(props);
const { scale, data } = props;
const { components } = this;
map(components, (component) => {
component.chart = this;
});

// TODO: scale和数据更新的变化
if (scale) {
const { scaleController } = this;
each(scale, (cfg, field) => {
scaleController.setDef(field, cfg)
scaleController.createScale(field, data);
});
}
this.resetLayout();
}

Expand Down
12 changes: 11 additions & 1 deletion packages/components/src/component/container.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, renderJSXElement, compareRenderTree } from '@ali/f2-jsx';
import { map, mapTwo } from '@ali/f2x-util';
import { map, mapTwo, isArray } from '@ali/f2x-util';
import Component from './index';
import PlaceholderComponent from './placeholder';
import equal from './equal';
Expand Down Expand Up @@ -137,6 +137,16 @@ class ContainerComponent extends Component {
// 如果之前是展位组件,现在有新的组件,是个新建逻辑
// @ts-ignore
if (component.placeholder) {
if (isArray(child)) {
return map(child, (c) => {
const newComponent = this.createComponent(c);
newComponent.init({
layout,
container: component.container,
});
return newComponent;
});
}
const newComponent = this.createComponent(child);
newComponent.init({
layout,
Expand Down
2 changes: 1 addition & 1 deletion packages/jsx/src/animation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default (element: any, animationCfg, nextAttrs, lastAttrs) => {
});
// 默认用 animation 配置里的 easing 和 duration
clip.easing = clip.easing || easing;
clip.delay = clip.delay || delay;
clip.delay = typeof clip.delay === 'number' ? clip.delay : delay;
clip.duration = clip.duration || duration;
clip.element = clipElement;
}
Expand Down

0 comments on commit ea347dc

Please sign in to comment.