-
Notifications
You must be signed in to change notification settings - Fork 605
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
1 parent
2548f05
commit daee178
Showing
7 changed files
with
75 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { WordCloud } from '@antv/g2plot'; | ||
|
||
const data = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ '.split('').map((item) => ({ name: item, value: 1 })); | ||
|
||
const wordCloud = new WordCloud('container', { | ||
data, | ||
width: 600, | ||
height: 400, | ||
wordField: 'name', | ||
weightField: 'value', | ||
colorField: 'name', | ||
wordStyle: { | ||
fontFamily: 'Verdana', | ||
fontSize: 16, | ||
rotation: 0, | ||
}, | ||
customPlacement(word, index, words) { | ||
const width = this.ele.clientWidth; | ||
const height = this.ele.clientHeight; | ||
const length = words.length; | ||
|
||
return { | ||
x: (width / length) * index, | ||
y: (height / length) * index, | ||
}; | ||
}, | ||
}); | ||
|
||
wordCloud.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
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,24 @@ | ||
import { WordCloud } from '@antv/g2plot'; | ||
|
||
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/antv-keywords.json') | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
const wordCloud = new WordCloud('container', { | ||
data, | ||
width: 600, | ||
height: 400, | ||
wordField: 'name', | ||
weightField: 'value', | ||
colorField: 'name', | ||
wordStyle: { | ||
fontFamily: 'Verdana', | ||
fontSize: [8, 32], | ||
rotation: 0, | ||
}, | ||
// 返回值设置成一个 [0, 1) 区间内的值, | ||
// 可以让每次渲染的位置相同(前提是每次的宽高一致)。 | ||
random: () => 0.5, | ||
}); | ||
|
||
wordCloud.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