Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: 修改histogram直方图的测试用例 #1447

Merged
merged 1 commit into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions __tests__/unit/plots/histogram/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ describe('histogram', () => {
expect(shapes.length - 1).toBe(4);
});

/**
* 这个测试 dataset 处理方式有问题
* issue已经提过去了 https://github.com/antvis/data-set/issues/90
*/
it('automatic calculate binNumber', () => {
const histogram = new Histogram(createDiv(), {
width: 400,
Expand All @@ -56,11 +52,10 @@ describe('histogram', () => {
const geometry = histogram.chart.geometries[0];
const shapeOrigin = geometry.getShapes()[0].get('origin').data;

/**
* 结合 dataset 的写法是 binWidth = histogramData(最大值-最小值)/ 默认值30
* https://github.com/antvis/data-set/blob/master/src/transform/bin/histogram.ts#L45
*/
const binWidth = (23.4 - 1.2) / 30;
// 最大值 - 最小值
const width = 23.4 - 1.2;
const binNumber = Math.ceil(Math.log(histogramData.length) / Math.LN2) + 1;
const binWidth = width / binNumber;

expect(shapeOrigin.range[1] - shapeOrigin.range[0]).toBe(binWidth);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
},
"dependencies": {
"@antv/data-set": "^0.11.4",
"@antv/data-set": "^0.11.5",
"@antv/event-emitter": "^0.1.2",
"@antv/g2": "^4.0.15",
"size-sensor": "^1.0.1",
Expand Down