-
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.
* feat(plots): add WorlCloud * feat(plots): add WorlCloud --------- Co-authored-by: Joel Alan <31396322+lxfu1@users.noreply.github.com>
- Loading branch information
1 parent
59d40f7
commit 601752d
Showing
13 changed files
with
157 additions
and
2 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,11 @@ | ||
import React from 'react'; | ||
import { BaseChart } from '../base'; | ||
|
||
import type { WordCloudOptions } from '../../core'; | ||
import type { CommonConfig } from '../../interface'; | ||
|
||
export type WordCloudConfig = CommonConfig<WordCloudOptions>; | ||
|
||
const WordCloudChart = (props: WordCloudConfig) => <BaseChart {...props} chartType="WordCloud" />; | ||
|
||
export default WordCloudChart; |
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
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,22 @@ | ||
import { flow, transformOptions } from '../../utils'; | ||
import { mark } from '../../components'; | ||
|
||
import type { Adaptor } from '../../types'; | ||
import type { WordCloudOptions } from './type'; | ||
|
||
type Params = Adaptor<WordCloudOptions>; | ||
|
||
/** | ||
* @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,34 @@ | ||
import { Plot } from '../../base'; | ||
import { adaptor } from './adaptor'; | ||
|
||
import type { WordCloudOptions } from './type'; | ||
import type { Adaptor } from '../../types'; | ||
|
||
export type { WordCloudOptions }; | ||
|
||
export class WordCloud extends Plot<WordCloudOptions> { | ||
/** 图表类型 */ | ||
public type = 'WordCloud'; | ||
|
||
/** | ||
* 获取 词云图 默认配置项 | ||
* 供外部使用 | ||
*/ | ||
static getDefaultOptions(): Partial<WordCloudOptions> { | ||
return { type: 'view', children: [{ type: 'wordCloud' }] }; | ||
} | ||
|
||
/** | ||
* 获取 词云图 默认配置 | ||
*/ | ||
protected getDefaultOptions() { | ||
return WordCloud.getDefaultOptions(); | ||
} | ||
|
||
/** | ||
* 词云图适配器 | ||
*/ | ||
protected getSchemaAdaptor(): (params: Adaptor<WordCloudOptions>) => 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 { BaseOptions, Options } from '../../types/common'; | ||
|
||
export type WordCloudOptions = 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,24 @@ | ||
{ | ||
"title": { | ||
"zh": "中文分类", | ||
"en": "Category" | ||
}, | ||
"demos": [ | ||
{ | ||
"filename": "wordCloud.js", | ||
"title": { | ||
"zh": "词云图", | ||
"en": "WordCloud Chart" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*2uvpTI0lHiYAAAAAAAAAAAAADmJ7AQ/original" | ||
}, | ||
{ | ||
"filename": "wordCloud-image.js", | ||
"title": { | ||
"zh": "带图片遮罩的词云图", | ||
"en": "WordCloud with image mask" | ||
}, | ||
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*zDm0SJEQSHwAAAAAAAAAAAAADmJ7AQ/original" | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
site/examples/statistics/wordCloud/demo/wordCloud-image.js
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 { WordCloud } from '@ant-design/plots'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const DemoWordCloud = () => { | ||
const config = { | ||
width: 1000, | ||
height: 400, | ||
autoFit: false, | ||
data: { | ||
type: "fetch", | ||
value: | ||
"https://gw.alipayobjects.com/os/antvdemo/assets/data/antv-keywords.json", | ||
}, | ||
layout: { | ||
imageMask: | ||
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*LKU4TYEiB-4AAAAAAAAAAAAADmJ7AQ/original", | ||
fontSize: 10, | ||
}, | ||
colorField: 'name', | ||
textField: 'name', | ||
legend: false, | ||
}; | ||
return <WordCloud {...config} />; | ||
}; | ||
|
||
ReactDOM.render(<DemoWordCloud />, 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,18 @@ | ||
import { WordCloud } from '@ant-design/plots'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const DemoWordCloud = () => { | ||
const config = { | ||
paddingTop: 40, | ||
data: { | ||
type: "fetch", | ||
value: "https://assets.antv.antgroup.com/g2/philosophy-word.json", | ||
}, | ||
layout: { spiral: "rectangular" }, | ||
colorField: 'text', | ||
}; | ||
return <WordCloud {...config} />; | ||
}; | ||
|
||
ReactDOM.render(<DemoWordCloud />, 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,4 @@ | ||
--- | ||
title: WordCloud | ||
order: 13 | ||
--- |
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: 13 | ||
--- |