-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(static-mark): add axisX and axisY (#5188)
* feat(static-mark): add axisX and axisY * docs(mark): add axisX and axisY
- Loading branch information
Showing
27 changed files
with
516 additions
and
42 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function alphabetIntervalAxis(): G2Spec { | ||
return { | ||
type: 'view', | ||
padding: 'auto', | ||
children: [ | ||
{ | ||
type: 'interval', | ||
transform: [{ type: 'sortX', by: 'y', reverse: true }], | ||
data: { | ||
type: 'fetch', | ||
value: 'data/alphabet.csv', | ||
}, | ||
encode: { | ||
x: 'letter', | ||
y: 'frequency', | ||
color: 'steelblue', | ||
}, | ||
axis: { y: { tickCount: 10 }, x: false }, | ||
}, | ||
{ type: 'axisX', title: 'Letter', style: { labelFontSize: 20 } }, | ||
{ | ||
type: 'axisY', | ||
labelFormatter: '.0%', | ||
title: 'Frequency', | ||
scale: { y: { nice: true } }, | ||
}, | ||
{ | ||
type: 'axisY', | ||
position: 'right', | ||
scale: { | ||
y: { | ||
type: 'linear', | ||
independent: true, | ||
domain: [0, 10], | ||
range: [1, 0], | ||
}, | ||
}, | ||
style: { | ||
grid: false, | ||
}, | ||
}, | ||
], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function mockAxisX(): G2Spec { | ||
return { | ||
type: 'axisX', | ||
padding: 'auto', | ||
height: 80, | ||
scale: { | ||
x: { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}, | ||
}, | ||
tickCount: 10, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function mockAxisXYPolar(): G2Spec { | ||
return { | ||
type: 'view', | ||
padding: 'auto', | ||
coordinate: { type: 'polar' }, | ||
scale: { | ||
x: { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}, | ||
y: { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}, | ||
}, | ||
children: [ | ||
{ | ||
type: 'axisX', | ||
title: 'AxisX', | ||
tickFilter: (_, i, ticks) => i && i !== ticks.length - 1, | ||
}, | ||
{ | ||
type: 'axisY', | ||
title: 'AxisY', | ||
style: { | ||
labelFontSize: 14, | ||
gridLineWidth: 10, | ||
gridStroke: 'red', | ||
}, | ||
}, | ||
], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function mockAxisXY(): G2Spec { | ||
return { | ||
type: 'view', | ||
padding: 'auto', | ||
scale: { | ||
x: { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}, | ||
y: { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}, | ||
}, | ||
children: [ | ||
{ type: 'axisX', title: 'AxisX' }, | ||
{ | ||
type: 'axisY', | ||
title: 'AxisY', | ||
tickCount: 10, | ||
style: { | ||
labelFontSize: 14, | ||
gridLineWidth: 10, | ||
gridStroke: 'red', | ||
}, | ||
}, | ||
], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function mockAxisY(): G2Spec { | ||
return { | ||
type: 'axisY', | ||
padding: 10, | ||
paddingLeft: 'auto', | ||
width: 100, | ||
scale: { | ||
y: { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}, | ||
}, | ||
tickCount: 10, | ||
title: 'axisX', | ||
style: { | ||
labelFontSize: 14, | ||
gridLineWidth: 10, | ||
gridStroke: 'red', | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.interval() | ||
.data({ | ||
type: 'fetch', | ||
value: | ||
'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c54a55fee580.csv', | ||
}) | ||
.encode('x', 'letter') | ||
.encode('y', 'frequency') | ||
.axis('y', { labelFormatter: '.0%' }); | ||
|
||
chart | ||
.axisY() | ||
.attr('position', 'right') | ||
.scale('y', { | ||
type: 'linear', | ||
independent: true, | ||
domain: [0, 10], | ||
range: [1, 0], | ||
}) | ||
.style('grid', false); | ||
|
||
chart.render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
padding: 'auto', | ||
}); | ||
|
||
chart | ||
.coordinate({ type: 'polar' }) | ||
.scale('x', { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}) | ||
.scale('y', { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [1, 0], | ||
}); | ||
|
||
chart | ||
.axisX() | ||
.attr('title', 'AxisX') | ||
.attr('tickFilter', (_, i, ticks) => i && i !== ticks.length - 1); | ||
|
||
chart | ||
.axisY() | ||
.attr('title', 'AxisY') | ||
.style('labelFontSize', 14) | ||
.style('gridLineWidth', 10) | ||
.style('gridStroke', 'red'); | ||
|
||
chart.render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
padding: 'auto', | ||
height: 80, | ||
}); | ||
|
||
chart | ||
.axisX() | ||
.scale('x', { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}) | ||
.attr('tickCount', 10) | ||
.attr('title', 'AxisX'); | ||
|
||
chart.render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
padding: 'auto', | ||
}); | ||
|
||
chart | ||
.scale('x', { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}) | ||
.scale('y', { | ||
type: 'linear', | ||
domain: [5, 10], | ||
range: [0, 1], | ||
}); | ||
|
||
chart.axisX().attr('title', 'AxisX'); | ||
|
||
chart | ||
.axisY() | ||
.attr('title', 'AxisY') | ||
.attr('tickCount', 10) | ||
.style('labelFontSize', 14) | ||
.style('gridLineWidth', 10) | ||
.style('gridStroke', 'red'); | ||
|
||
chart.render(); |
Oops, something went wrong.