Skip to content

Commit 14ff076

Browse files
author
诸岳
authored
Merge pull request #190 from antvis/config-autoDraw
fix(g-canvas): autoDraw should be true by default
2 parents 6135b77 + 337b41a commit 14ff076

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

packages/g-canvas/__tests__/unit/canvas-spec.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('canvas test', () => {
4040
expect(canvas.getChildren().length).eql(1);
4141
});
4242

43-
it('add shape', () => {
43+
it('add shape', (done) => {
4444
const circle = canvas.addShape({
4545
type: 'circle',
4646
attrs: {
@@ -52,13 +52,6 @@ describe('canvas test', () => {
5252
});
5353
expect(circle.get('type')).eql('circle');
5454
expect(circle.attr('r')).eql(10);
55-
});
56-
57-
it('draw', (done) => {
58-
expect(getColor(canvas.get('context'), 10, 10)).eql('#000000');
59-
// 默认的 draw 是延迟的所以要延迟测试
60-
canvas.draw();
61-
expect(getColor(canvas.get('context'), 10, 10)).eql('#000000');
6255
setTimeout(() => {
6356
expect(getColor(canvas.get('context'), 10, 10)).eql('#ff0000');
6457
done();
@@ -88,7 +81,6 @@ describe('canvas test', () => {
8881
fill: 'red',
8982
},
9083
});
91-
canvas.draw();
9284
let called = false;
9385
let clickShape = null;
9486
canvas.on('click', (ev) => {

packages/g-canvas/src/canvas.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Canvas extends AbstractCanvas {
3838
getDefaultCfg() {
3939
const cfg = super.getDefaultCfg();
4040
// 是否自动绘制,不需要用户调用 draw 方法
41-
cfg['autoDraw'] = false;
41+
cfg['autoDraw'] = true;
4242
// 是否允许局部刷新图表
4343
cfg['localRefresh'] = true;
4444
cfg['refreshElements'] = [];

0 commit comments

Comments
 (0)