Skip to content

Commit c2c50a3

Browse files
authored
feat(axis): add type config axis, it will picked into scale config (#1686)
1 parent 78f3a0c commit c2c50a3

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

__tests__/bugs/issue-968-spec.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { COMPONENT_TYPE } from '@antv/g2/lib/constant';
2+
import { Line } from '../../src';
3+
import { createDiv } from '.././utils/dom';
4+
5+
describe('#968', () => {
6+
it('axis type', () => {
7+
const data = [
8+
{ year: '1991', value: 3 },
9+
{ year: '1992', value: 4 },
10+
{ year: '1993', value: 3.5 },
11+
{ year: '1994', value: 5 },
12+
{ year: '1995', value: 4.9 },
13+
{ year: '1996', value: 6 },
14+
{ year: '1997', value: 7 },
15+
{ year: '1998', value: 9 },
16+
{ year: '1999', value: 13 },
17+
];
18+
19+
const line = new Line(createDiv(), {
20+
data,
21+
xField: 'year',
22+
yField: 'value',
23+
height: 300,
24+
yAxis: {
25+
type: 'log',
26+
},
27+
});
28+
29+
line.render();
30+
31+
expect(line.chart.getYScales()[0].type).toBe('log');
32+
});
33+
});

src/constant.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* 需要从轴配置中提取出来作为 meta 的属性 key 列表
33
*/
44
export const AXIS_META_CONFIG_KEYS = [
5+
'type',
56
'tickCount',
67
'tickInterval',
78
'min',

src/types/axis.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { AxisOption } from '@antv/g2/lib/interface';
22

33
export type Axis = AxisOption & {
4+
/**
5+
* 坐标轴类型
6+
*/
7+
readonly type?: string;
48
/**
59
* 是否美化
610
*/

0 commit comments

Comments
 (0)