From 7762f1df51fa37d21631cbbca62af8cf0208536e Mon Sep 17 00:00:00 2001 From: arcsin1 Date: Mon, 17 Aug 2020 16:17:47 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E6=94=B9histogram=E7=9B=B4?= =?UTF-8?q?=E6=96=B9=E5=9B=BE=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/unit/plots/histogram/index-spec.ts | 13 ++++--------- package.json | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/__tests__/unit/plots/histogram/index-spec.ts b/__tests__/unit/plots/histogram/index-spec.ts index 8e00f332cc..7b842d87e6 100644 --- a/__tests__/unit/plots/histogram/index-spec.ts +++ b/__tests__/unit/plots/histogram/index-spec.ts @@ -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, @@ -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); }); diff --git a/package.json b/package.json index c43bf2d4fe..2ebe0b2188 100644 --- a/package.json +++ b/package.json @@ -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",