From dd23da5204fa1be985797625682aa875bd07449e Mon Sep 17 00:00:00 2001 From: Susan <527971893@qq.com> Date: Wed, 16 Jun 2021 18:56:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(bullet):=20=E4=BF=AE=E5=A4=8D=E8=BD=B4?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=B7=BB=E5=8A=A0max=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=AD=90=E5=BC=B9=E5=9B=BEscale=E5=91=88=E7=8E=B0=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98=20(#2639)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(bullet): 修复轴组件添加max时,子弹图scale呈现不正确问题 * fix(bullet): 规范写法,将sync改为true,同步自身 Co-authored-by: 酥云 --- __tests__/bugs/issue-2636-spec.ts | 50 +++++++++++++++++++++++++++++++ src/plots/bullet/adaptor.ts | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 __tests__/bugs/issue-2636-spec.ts diff --git a/__tests__/bugs/issue-2636-spec.ts b/__tests__/bugs/issue-2636-spec.ts new file mode 100644 index 0000000000..b098359652 --- /dev/null +++ b/__tests__/bugs/issue-2636-spec.ts @@ -0,0 +1,50 @@ +import { Bullet } from '../../src/plots/bullet'; +import { createDiv } from '../utils/dom'; + +const data = [ + { + title: 'Test data point', + measures: [80], + ranges: [100], + target: 85, + }, +]; + +describe('#2636', () => { + it('yAxisMax', () => { + const bullet = new Bullet(createDiv('yAxisMax bullet'), { + data, + measureField: 'measures', + rangeField: 'ranges', + targetField: 'target', + xField: 'title', + color: { + range: '#f0efff', + measure: '#5B8FF9', + target: '#3D76DD', + }, + xAxis: { + line: null, + }, + yAxis: { + max: 200, + }, + }); + + bullet.render(); + + const chart = bullet.chart; + const scales = chart.geometries[0].scales; // 拿到比例尺 + + const scaleMeasureMax = scales.measures.max; + expect(scaleMeasureMax).toBe(200); + + const scaleRangesMax = scales.ranges.max; + expect(scaleRangesMax).toBe(200); + + const scaleTargetMax = scales.target.max; + expect(scaleTargetMax).toBe(200); + + bullet.destroy(); + }); +}); diff --git a/src/plots/bullet/adaptor.ts b/src/plots/bullet/adaptor.ts index 8f1fda7c6b..f0608dc1ad 100644 --- a/src/plots/bullet/adaptor.ts +++ b/src/plots/bullet/adaptor.ts @@ -98,7 +98,7 @@ export function meta(params: Params): Params { }, // 额外的 meta { - [measureField]: { min: extData?.min, max: extData?.max }, + [measureField]: { min: extData?.min, max: extData?.max, sync: true }, [targetField]: { sync: `${measureField}`, },