-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lkd01632719
committed
Dec 27, 2023
1 parent
67928ab
commit e4005be
Showing
6 changed files
with
162 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Sankey } from '@ant-design/plots'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const colors = [ | ||
'#5B8FF9', | ||
'#61DDAA', | ||
'#65789B', | ||
'#F6BD16', | ||
'#7262fd', | ||
'#78D3F8', | ||
'#9661BC', | ||
'#F6903D', | ||
'#008685', | ||
'#F08BB4', | ||
]; | ||
|
||
const DemoSankey = () => { | ||
const config = { | ||
data: { | ||
value: [ | ||
{ source: '首次打开', target: '首页 UV', value: 160 }, | ||
{ source: '结果页', target: '首页 UV', value: 40 }, | ||
{ source: '验证页', target: '首页 UV', value: 10 }, | ||
{ source: '我的', target: '首页 UV', value: 10 }, | ||
{ source: '朋友', target: '首页 UV', value: 8 }, | ||
{ source: '其他来源', target: '首页 UV', value: 27 }, | ||
{ source: '首页 UV', target: '理财', value: 30 }, | ||
{ source: '首页 UV', target: '扫一扫', value: 40 }, | ||
{ source: '首页 UV', target: '服务', value: 35 }, | ||
{ source: '首页 UV', target: '蚂蚁森林', value: 25 }, | ||
{ source: '首页 UV', target: '跳失', value: 10 }, | ||
{ source: '首页 UV', target: '借呗', value: 30 }, | ||
{ source: '首页 UV', target: '花呗', value: 40 }, | ||
{ source: '首页 UV', target: '其他流向', value: 45 }, | ||
], | ||
}, | ||
scale: { color: { range: colors } }, | ||
layout: { nodeWidth: 0.01 }, | ||
linkColorField: (d) => d.source.key, | ||
style: { | ||
labelFontSize: 13, | ||
linkFillOpacity: 0.4, | ||
nodeStrokeWidth: 0, | ||
}, | ||
}; | ||
return <Sankey {...config} />; | ||
}; | ||
|
||
ReactDOM.render(<DemoSankey />, document.getElementById('container')); |
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,19 @@ | ||
import { Sankey } from '@ant-design/plots'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const DemoSankey = () => { | ||
const config = { | ||
data: { | ||
type: 'fetch', | ||
value: 'https://gw.alipayobjects.com/os/bmw-prod/fa3414cc-75ed-47b4-8306-f2ffe8c40127.json', | ||
}, | ||
scale: { color: { range: ['red', 'green', 'yellow'] } }, | ||
layout: { nodeWidth: 0.01, nodePadding: 0.01 }, | ||
linkColorField: (d) => d.source.key, | ||
style: { linkFillOpacity: 0.4 }, | ||
}; | ||
return <Sankey {...config} />; | ||
}; | ||
|
||
ReactDOM.render(<DemoSankey />, document.getElementById('container')); |
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,53 @@ | ||
import { Sankey } from '@ant-design/plots'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const colors = [ | ||
'#5B8FF9', | ||
'#61DDAA', | ||
'#65789B', | ||
'#F6BD16', | ||
'#7262fd', | ||
'#78D3F8', | ||
'#9661BC', | ||
'#F6903D', | ||
'#008685', | ||
'#F08BB4', | ||
]; | ||
|
||
const DemoSankey = () => { | ||
const config = { | ||
data: { | ||
value: [ | ||
{ source: '首次打开', target: '首页 UV', value: 160 }, | ||
{ source: '结果页', target: '首页 UV', value: 40 }, | ||
{ source: '验证页', target: '首页 UV', value: 10 }, | ||
{ source: '我的', target: '首页 UV', value: 10 }, | ||
{ source: '朋友', target: '首页 UV', value: 8 }, | ||
{ source: '其他来源', target: '首页 UV', value: 27 }, | ||
{ source: '首页 UV', target: '理财', value: 30 }, | ||
{ source: '首页 UV', target: '扫一扫', value: 40 }, | ||
{ source: '首页 UV', target: '服务', value: 35 }, | ||
{ source: '首页 UV', target: '蚂蚁森林', value: 25 }, | ||
{ source: '首页 UV', target: '跳失', value: 10 }, | ||
{ source: '首页 UV', target: '借呗', value: 30 }, | ||
{ source: '首页 UV', target: '花呗', value: 40 }, | ||
{ source: '首页 UV', target: '其他流向', value: 45 }, | ||
], | ||
}, | ||
scale: { color: { range: colors } }, | ||
layout: { | ||
nodeWidth: 0.01, | ||
nodeSort: (a, b) => b.value - a.value, | ||
}, | ||
linkColorField: (d) => d.source.key, | ||
style: { | ||
labelFontSize: 13, | ||
linkFillOpacity: 0.4, | ||
nodeStrokeWidth: 0, | ||
}, | ||
}; | ||
return <Sankey {...config} />; | ||
}; | ||
|
||
ReactDOM.render(<DemoSankey />, document.getElementById('container')); |