-
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.
docs: add the two axis charts demo (#5740)
* feat: add two-axis-chart demos and finish code * feat: add demo info in meta.json * feat: add screenshot link to meta.json and format code style * fix: fix the chart title in meta.json * fix: change the chart name in English
- Loading branch information
Showing
5 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
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 { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
const data = [ | ||
{ time: '10:10', call: 4, waiting: 2, people: 2 }, | ||
{ time: '10:15', call: 2, waiting: 6, people: 3 }, | ||
{ time: '10:20', call: 13, waiting: 2, people: 5 }, | ||
{ time: '10:25', call: 9, waiting: 9, people: 1 }, | ||
{ time: '10:30', call: 5, waiting: 2, people: 3 }, | ||
{ time: '10:35', call: 8, waiting: 2, people: 1 }, | ||
{ time: '10:40', call: 13, waiting: 1, people: 2 }, | ||
]; | ||
|
||
chart.data(data); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'waiting') | ||
.encode('color', () => 'waiting') | ||
.encode('series', () => 'waiting') | ||
.axis('y', { title: 'Waiting' }); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'people') | ||
.encode('color', () => 'people') | ||
.encode('series', () => 'people') | ||
.scale('y', { independent: true }) | ||
.axis('y', { position: 'right', grid: null, title: 'People' }); | ||
|
||
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,45 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
const data = [ | ||
{ time: '10:10', call: 4, waiting: 2, people: 2 }, | ||
{ time: '10:15', call: 2, waiting: 6, people: 3 }, | ||
{ time: '10:20', call: 13, waiting: 2, people: 5 }, | ||
{ time: '10:25', call: 9, waiting: 9, people: 1 }, | ||
{ time: '10:30', call: 5, waiting: 2, people: 3 }, | ||
{ time: '10:35', call: 8, waiting: 2, people: 1 }, | ||
{ time: '10:40', call: 13, waiting: 1, people: 2 }, | ||
]; | ||
|
||
chart.data(data); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'waiting') | ||
.encode('color', () => 'waiting') | ||
.encode('series', () => 'waiting') | ||
.axis('y', { title: 'Waiting' }) | ||
.scale('y', { nice: true }); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'people') | ||
.encode('color', () => 'people') | ||
.encode('series', () => 'people') | ||
.scale('y', { independent: true }) | ||
.axis('y', { position: 'right', grid: null, title: 'People' }); | ||
|
||
chart | ||
.line() | ||
.encode('x', 'time') | ||
.encode('y', 'call') | ||
.encode('color', () => 'call') | ||
.scale('series', { independent: true }); | ||
|
||
chart.render(); |
53 changes: 53 additions & 0 deletions
53
site/examples/general/dual/demo/dual-axis-multi-line-bar.ts
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,53 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
const data = [ | ||
{ time: '10:10', call: 4, waiting: 2, people: 2, mock: 3 }, | ||
{ time: '10:15', call: 2, waiting: 6, people: 3, mock: 4 }, | ||
{ time: '10:20', call: 13, waiting: 2, people: 5, mock: 1 }, | ||
{ time: '10:25', call: 9, waiting: 9, people: 1, mock: 2 }, | ||
{ time: '10:30', call: 5, waiting: 2, people: 3, mock: 5 }, | ||
{ time: '10:35', call: 8, waiting: 2, people: 1, mock: 3 }, | ||
{ time: '10:40', call: 13, waiting: 1, people: 2, mock: 2 }, | ||
]; | ||
|
||
chart.data(data); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'waiting') | ||
.encode('color', () => 'waiting') | ||
.encode('series', () => 'waiting') | ||
.axis('y', { title: null }) | ||
.scale('y', { nice: true }); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'people') | ||
.encode('color', () => 'people') | ||
.encode('series', () => 'people') | ||
.scale('y', { key: '2' }) | ||
.axis('y', { position: 'right', grid: null, title: null }); | ||
|
||
chart | ||
.line() | ||
.encode('x', 'time') | ||
.encode('y', 'call') | ||
.encode('color', () => 'call') | ||
.scale('series', { independent: true }); | ||
|
||
chart | ||
.line() | ||
.encode('x', 'time') | ||
.encode('y', 'mock') | ||
.encode('color', () => 'mock') | ||
.scale('y', { key: '2' }) | ||
.scale('series', { independent: true }); | ||
|
||
chart.render(); |
49 changes: 49 additions & 0 deletions
49
site/examples/general/dual/demo/dual-axis-stacked-group-bar.ts
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,49 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
const data = [ | ||
{ time: '10:10', call: 4, waiting: 2, people: 2, mock: 3 }, | ||
{ time: '10:15', call: 2, waiting: 6, people: 3, mock: 4 }, | ||
{ time: '10:20', call: 13, waiting: 2, people: 5, mock: 1 }, | ||
{ time: '10:25', call: 9, waiting: 9, people: 1, mock: 2 }, | ||
{ time: '10:30', call: 5, waiting: 2, people: 3, mock: 5 }, | ||
{ time: '10:35', call: 8, waiting: 2, people: 1, mock: 3 }, | ||
{ time: '10:40', call: 13, waiting: 1, people: 2, mock: 2 }, | ||
]; | ||
|
||
chart.data(data); | ||
|
||
chart | ||
.interval() | ||
.data({ | ||
transform: [{ type: 'fold', fields: ['call', 'waiting'] }], | ||
}) | ||
.encode('x', 'time') | ||
.encode('y', 'value') | ||
.encode('color', 'key') | ||
.encode('series', () => 'a') | ||
.transform({ type: 'stackY' }) | ||
.scale('y', { nice: true }) | ||
.axis('y', { title: null }); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'people') | ||
.encode('color', () => 'people') | ||
.encode('series', () => 'b'); | ||
|
||
chart | ||
.interval() | ||
.encode('x', 'time') | ||
.encode('y', 'mock') | ||
.encode('color', () => 'mock') | ||
.encode('series', () => 'c') | ||
.scale('y', { independent: true }) | ||
.axis('y', { position: 'right' }); | ||
|
||
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