diff --git a/__tests__/unit/plots/area/index-spec.ts b/__tests__/unit/plots/area/index-spec.ts index 6a625175bb..d45b4f6cee 100644 --- a/__tests__/unit/plots/area/index-spec.ts +++ b/__tests__/unit/plots/area/index-spec.ts @@ -39,7 +39,7 @@ describe('area', () => { area.render(); expect(area.chart.getScaleByField('x').type).toBe('cat'); - expect(area.chart.getScaleByField('x').range).toEqual([0, 1]); + expect(area.chart.getScaleByField('x').range).toEqual([1 / 8, 7 / 8]); area.update({ ...area.options, meta: { diff --git a/__tests__/unit/plots/line/index-spec.ts b/__tests__/unit/plots/line/index-spec.ts index c8b811a9e5..7a10601512 100644 --- a/__tests__/unit/plots/line/index-spec.ts +++ b/__tests__/unit/plots/line/index-spec.ts @@ -74,7 +74,7 @@ describe('line', () => { line.render(); expect(line.chart.getScaleByField('x').type).toBe('cat'); - expect(line.chart.getScaleByField('x').range).toEqual([0, 1]); + expect(line.chart.getScaleByField('x').range).toEqual([1 / 8, 7 / 8]); line.update({ meta: { x: { diff --git a/examples/area/basic/demo/basic-gradients.ts b/examples/area/basic/demo/basic-gradients.ts index 2de7d8d02a..53ad7822ed 100644 --- a/examples/area/basic/demo/basic-gradients.ts +++ b/examples/area/basic/demo/basic-gradients.ts @@ -8,6 +8,7 @@ fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38cc xField: 'Date', yField: 'scales', xAxis: { + range: [0, 1], tickCount: 5, }, areaStyle: () => { diff --git a/examples/area/basic/demo/basic.ts b/examples/area/basic/demo/basic.ts index a76ef415d7..dd0482dad7 100644 --- a/examples/area/basic/demo/basic.ts +++ b/examples/area/basic/demo/basic.ts @@ -8,6 +8,7 @@ fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38cc xField: 'Date', yField: 'scales', xAxis: { + range: [0, 1], tickCount: 5, }, }); diff --git a/src/constant.ts b/src/constant.ts index f7f39f8184..fd29ef15e6 100644 --- a/src/constant.ts +++ b/src/constant.ts @@ -11,6 +11,8 @@ export const AXIS_META_CONFIG_KEYS = [ 'nice', 'minLimit', 'maxLimit', + // 坐标轴的范围 + 'range', 'tickMethod', // type: 'log' 的底 'base', diff --git a/src/plots/line/adaptor.ts b/src/plots/line/adaptor.ts index 87a8e252f4..0aaf2d41fb 100644 --- a/src/plots/line/adaptor.ts +++ b/src/plots/line/adaptor.ts @@ -58,7 +58,6 @@ export function meta(params: Params): Params { { [xField]: { type: 'cat', - range: [0, 1], }, [yField]: adjustYMetaByZero(data, yField), }