Skip to content

Commit

Permalink
fix(bullet): 修复轴组件添加max时,子弹图scale呈现不正确问题 (#2639)
Browse files Browse the repository at this point in the history
* fix(bullet): 修复轴组件添加max时,子弹图scale呈现不正确问题

* fix(bullet): 规范写法,将sync改为true,同步自身

Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com>
  • Loading branch information
Angelii and 酥云 authored Jun 16, 2021
1 parent 4c437f6 commit dd23da5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions __tests__/bugs/issue-2636-spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
2 changes: 1 addition & 1 deletion src/plots/bullet/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function meta(params: Params<BulletOptions>): Params<BulletOptions> {
},
// 额外的 meta
{
[measureField]: { min: extData?.min, max: extData?.max },
[measureField]: { min: extData?.min, max: extData?.max, sync: true },
[targetField]: {
sync: `${measureField}`,
},
Expand Down

0 comments on commit dd23da5

Please sign in to comment.