-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: lkd01632719 <lkd01632719@antgroup.com> Co-authored-by: Joel Alan <31396322+lxfu1@users.noreply.github.com>
- Loading branch information
1 parent
3ac0a6f
commit 02a7ec2
Showing
10 changed files
with
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { SankeyOptions } from '../../core'; | ||
import { CommonConfig } from '../../interface'; | ||
import { BaseChart } from '../base'; | ||
|
||
export type SankeyConfig = CommonConfig<SankeyOptions>; | ||
|
||
const SankeyChart = (props: SankeyConfig) => <BaseChart {...props} chartType="Sankey" />; | ||
|
||
export default SankeyChart; |
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,21 @@ | ||
import { mark } from '../../components'; | ||
import type { Adaptor } from '../../types'; | ||
import { flow, transformOptions } from '../../utils'; | ||
import type { SankeyOptions } from './type'; | ||
|
||
type Params = Adaptor<SankeyOptions>; | ||
|
||
/** | ||
* @param chart | ||
* @param options | ||
*/ | ||
export function adaptor(params: Params) { | ||
/** | ||
* 图表差异化处理 | ||
*/ | ||
const init = (params: Params) => { | ||
return params; | ||
}; | ||
|
||
return flow(init, transformOptions, mark)(params); | ||
} |
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 { Plot } from '../../base'; | ||
import type { Adaptor } from '../../types'; | ||
import { adaptor } from './adaptor'; | ||
import { SankeyOptions } from './type'; | ||
|
||
export type { SankeyOptions }; | ||
|
||
export class Sankey extends Plot<SankeyOptions> { | ||
/** 图表类型 */ | ||
public type = 'sankey'; | ||
|
||
/** | ||
* 获取 双轴图 默认配置项 | ||
* 供外部使用 | ||
*/ | ||
static getDefaultOptions(): Partial<SankeyOptions> { | ||
return { type: 'view', children: [{ type: 'sankey' }] }; | ||
} | ||
|
||
/** | ||
* 获取 条形图 默认配置 | ||
*/ | ||
protected getDefaultOptions() { | ||
return Sankey.getDefaultOptions(); | ||
} | ||
|
||
/** | ||
* 条形图适配器 | ||
*/ | ||
protected getSchemaAdaptor(): (params: Adaptor<SankeyOptions>) => void { | ||
return adaptor; | ||
} | ||
} |
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,3 @@ | ||
import type { Options, BaseOptions } from '../../types/common'; | ||
|
||
export type SankeyOptions = Options & BaseOptions; |
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 { Sankey } from '@ant-design/plots' | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const DemoSankey = () => { | ||
const config = { | ||
layout: { nodeAlign: "center", nodePadding: 0.03 }, | ||
data: { | ||
type: "fetch", | ||
value: "https://assets.antv.antgroup.com/g2/energy.json", | ||
transform: [ | ||
{ | ||
type: "custom", | ||
callback: (data) => ({ | ||
links: data, | ||
}), | ||
}, | ||
], | ||
}, | ||
scale: { | ||
color: { | ||
range: [ | ||
"#4e79a7", | ||
"#f28e2c", | ||
"#e15759", | ||
"#76b7b2", | ||
"#59a14f", | ||
"#edc949", | ||
"#af7aa1", | ||
"#ff9da7", | ||
"#9c755f", | ||
"#bab0ab", | ||
], | ||
}, | ||
}, | ||
style: { | ||
labelSpacing: 3, | ||
labelFontWeight: "bold", | ||
nodeStrokeWidth: 1.2, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"title": { | ||
"zh": "中文分类", | ||
"en": "Category" | ||
}, | ||
"demos": [ | ||
{ | ||
"filename": "basic.js", | ||
"title": { | ||
"zh": "桑基图", | ||
"en": "Sankey" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*dACBR7ANcfEAAAAAAAAAAAAADmJ7AQ/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,4 @@ | ||
--- | ||
title: Sankey | ||
order: 20 | ||
--- |
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,6 @@ | ||
--- | ||
title: 桑基图 | ||
order: 20 | ||
--- | ||
|
||
|