Skip to content

Commit

Permalink
fix: 修复初始化padding问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Feb 4, 2021
1 parent 51fedaa commit f22fb72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/components/src/chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Chart extends Component {
// @ts-ignore
height,
animate,
padding: batch2hd(padding) || [ 0, 0, 0, 0 ],
// padding: batch2hd(padding) || [ 0, 0, 0, 0 ],
});
// 直接设置数据
chart.source(data);
Expand All @@ -57,6 +57,15 @@ class Chart extends Component {
width: canvasWidth,
height: canvasHeight
});

// TODO, 后续优化
const p = batch2hd(padding);
layout.update({
top: p[0],
right: -p[1],
bottom: -p[2],
left: p[3],
});
const componentTree = createComponentTree(children);
const component = new ComboComponent({ children: componentTree });

Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/chart/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class Layout {
this[key] = current + value;
});
const { left, top, right, bottom, width, height } = this;
this.chart._updateLayout([ top, width - right, height - bottom, left ]);
try {
this.chart._updateLayout([ top, width - right, height - bottom, left ]);
} catch (e) {
}
}
}

Expand Down

0 comments on commit f22fb72

Please sign in to comment.