-
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(sunburst): add sunburst demo (#5854)
- Loading branch information
1 parent
d923eb9
commit 22575e5
Showing
12 changed files
with
244 additions
and
0 deletions.
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
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,56 @@ | ||
{ | ||
"title": { | ||
"zh": "中文分类", | ||
"en": "Category" | ||
}, | ||
"demos": [ | ||
{ | ||
"filename": "sunburst-default.ts", | ||
"title": { | ||
"zh": "旭日图", | ||
"en": "Sunburst Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*-aInRJfa4-8AAAAAAAAAAAAADmJ7AQ/original" | ||
}, | ||
{ | ||
"filename": "sunburst-label.ts", | ||
"title": { | ||
"zh": "旭日图带标签", | ||
"en": "Sunburst Label Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*GBxdT697NYQAAAAAAAAAAAAADmJ7AQ/original" | ||
}, | ||
{ | ||
"filename": "sunburst-color.ts", | ||
"title": { | ||
"zh": "旭日图自定义颜色通道", | ||
"en": "Sunburst ColorField Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7L4tQ4F61ZkAAAAAAAAAAAAADmJ7AQ/original" | ||
}, | ||
{ | ||
"filename": "sunburst-style.ts", | ||
"title": { | ||
"zh": "旭日图自定义样式", | ||
"en": "Sunburst Style Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*BP7zQ6SMiKcAAAAAAAAAAAAADmJ7AQ/original" | ||
}, | ||
{ | ||
"filename": "sunburst-pattern.ts", | ||
"title": { | ||
"zh": "旭日图自定义纹理", | ||
"en": "Sunburst Pattern Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*rVCgTqydP5kAAAAAAAAAAAAADmJ7AQ/original" | ||
}, | ||
{ | ||
"filename": "sunburst-interaction.ts", | ||
"title": { | ||
"zh": "旭日图交互配置", | ||
"en": "Sunburst Interaction Config Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7C0NQK9_TfwAAAAAAAAAAAAADmJ7AQ/original" | ||
} | ||
] | ||
} |
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 { plotlib } from '@antv/g2-extension-plot'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...plotlib() }); | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.sunburst() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json', | ||
}) | ||
.encode('value', 'sum') | ||
.encode('color', 'label'); | ||
|
||
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 { plotlib } from '@antv/g2-extension-plot'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...plotlib() }); | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.sunburst() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/antfincdn/ryp44nvUYZ/coffee.json', | ||
}) | ||
.animate('enter', { type: 'waveIn' }) | ||
.coordinate({ type: 'polar', innerRadius: 0 }); | ||
|
||
chart.render(); |
47 changes: 47 additions & 0 deletions
47
site/examples/general/sunburst/demo/sunburst-interaction.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,47 @@ | ||
import { plotlib } from '@antv/g2-extension-plot'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...plotlib() }); | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.sunburst() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json', | ||
}) | ||
.encode('value', 'sum') | ||
.label({ | ||
text: 'name', | ||
transform: [ | ||
{ | ||
type: 'overflowHide', | ||
}, | ||
], | ||
}) | ||
.interaction({ | ||
drillDown: { | ||
breadCrumb: { | ||
rootText: '起始', | ||
style: { | ||
fontSize: '18px', | ||
fill: '#333', | ||
}, | ||
active: { | ||
fill: 'red', | ||
}, | ||
}, | ||
// FixedColor default: true, true -> drillDown update scale, false -> scale keep. | ||
fixedColor: false, | ||
}, | ||
}) | ||
.state({ | ||
active: { zIndex: 2, stroke: 'red' }, | ||
inactive: { zIndex: 1, stroke: '#fff' }, | ||
}); | ||
|
||
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,27 @@ | ||
import { plotlib } from '@antv/g2-extension-plot'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...plotlib() }); | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.sunburst() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json', | ||
}) | ||
.encode('value', 'sum') | ||
.label({ | ||
text: 'name', | ||
transform: [ | ||
{ | ||
type: 'overflowHide', | ||
}, | ||
], | ||
}); | ||
|
||
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,37 @@ | ||
import { lines } from '@antv/g-pattern'; | ||
import { plotlib } from '@antv/g2-extension-plot'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...plotlib() }); | ||
|
||
const colors = ['#e8c1a0', '#f47560', '#f1e15b', '#e8a838', '#61cdbb']; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.sunburst() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json', | ||
}) | ||
.encode('value', 'sum') | ||
.style({ | ||
fill: (_, idx) => { | ||
return { | ||
image: lines({ | ||
backgroundColor: colors[idx % colors.length], | ||
backgroundOpacity: 0.65, | ||
stroke: colors[idx % colors.length], | ||
lineWidth: 4, | ||
spacing: 5, | ||
}), | ||
repetition: 'repeat', | ||
transform: 'rotate(30deg)', | ||
}; | ||
}, | ||
}); | ||
|
||
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,25 @@ | ||
import { plotlib } from '@antv/g2-extension-plot'; | ||
import { Runtime, corelib, extend } from '@antv/g2'; | ||
|
||
const Chart = extend(Runtime, { ...corelib(), ...plotlib() }); | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.sunburst() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json', | ||
}) | ||
.encode('value', 'sum') | ||
.style({ | ||
fill: (v) => { | ||
if (v['path'] === '类别 3') return 'red'; | ||
if (v['name'] === '类别 2.1.1') return '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,4 @@ | ||
--- | ||
title: Sunburst | ||
order: 16 | ||
--- |
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,4 @@ | ||
--- | ||
title: 旭日图 | ||
order: 16 | ||
--- |
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