Skip to content

Commit

Permalink
feat(axis): add type config axis, it will picked into scale config (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc authored Oct 6, 2020
1 parent 78f3a0c commit c2c50a3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
33 changes: 33 additions & 0 deletions __tests__/bugs/issue-968-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { COMPONENT_TYPE } from '@antv/g2/lib/constant';
import { Line } from '../../src';
import { createDiv } from '.././utils/dom';

describe('#968', () => {
it('axis type', () => {
const data = [
{ year: '1991', value: 3 },
{ year: '1992', value: 4 },
{ year: '1993', value: 3.5 },
{ year: '1994', value: 5 },
{ year: '1995', value: 4.9 },
{ year: '1996', value: 6 },
{ year: '1997', value: 7 },
{ year: '1998', value: 9 },
{ year: '1999', value: 13 },
];

const line = new Line(createDiv(), {
data,
xField: 'year',
yField: 'value',
height: 300,
yAxis: {
type: 'log',
},
});

line.render();

expect(line.chart.getYScales()[0].type).toBe('log');
});
});
1 change: 1 addition & 0 deletions src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* 需要从轴配置中提取出来作为 meta 的属性 key 列表
*/
export const AXIS_META_CONFIG_KEYS = [
'type',
'tickCount',
'tickInterval',
'min',
Expand Down
4 changes: 4 additions & 0 deletions src/types/axis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { AxisOption } from '@antv/g2/lib/interface';

export type Axis = AxisOption & {
/**
* 坐标轴类型
*/
readonly type?: string;
/**
* 是否美化
*/
Expand Down

0 comments on commit c2c50a3

Please sign in to comment.