Skip to content

Commit

Permalink
test(padding): add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Sep 7, 2020
1 parent 554f619 commit c474d28
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/chart/layout/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function calculatePadding(view: View): Padding {
}

// 是 auto padding,根据组件的情况,来计算 padding
const { viewBBox, autoPadding } = view;
const { viewBBox } = view;

const paddingCal = new PaddingCal();

Expand Down
40 changes: 40 additions & 0 deletions tests/bugs/padding-update-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Chart } from '../../src';
import { createDiv } from '../util/dom';

describe('1265', () => {
it('1265', () => {
const data = [
{ name: 'a', time: '10:10', call: 4, waiting: 2, people: 2 },
{ name: 'b', time: '10:10', call: 4, waiting: 21, people: 2 },
{ name: 'a', time: '10:15', call: 2, waiting: 6, people: 3 },
{ name: 'b', time: '10:15', call: 2, waiting: 16, people: 3 },
{ name: 'a', time: '10:20', call: 13, waiting: 2, people: 5 },
{ name: 'b', time: '10:20', call: 13, waiting: 12, people: 5 },
{ name: 'a', time: '10:25', call: 9, waiting: 9, people: 1 },
{ name: 'b', time: '10:25', call: 9, waiting: 19, people: 1 },
];
const chart = new Chart({
container: createDiv(),
autoFit: false,
width: 400,
height: 300,
padding: 24,
});
chart.data(data);
chart.line().position('time*people').color('#fdae6b').size(3).shape('smooth');
chart.render();

expect(chart.padding).toBe(24);
expect(chart.coordinateBBox.tl).toEqual({ x: 24, y: 24 });

chart.clear();

chart.padding = 48;
chart.data(data);
chart.line().position('time*people').color('#fdae6b').size(3).shape('smooth');
chart.render();

expect(chart.padding).toBe(48);
expect(chart.coordinateBBox.tl).toEqual({ x: 48, y: 48 });
});
});

0 comments on commit c474d28

Please sign in to comment.