-
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.
fix(word-cloud): fix tooltip and add demo of custom tooltip
- Loading branch information
1 parent
d8dd66c
commit 98011e5
Showing
6 changed files
with
80 additions
and
30 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,32 @@ | ||
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', | ||
imageMask: 'https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*07tdTIOmvlYAAAAAAAAAAABkARQnAQ', | ||
wordStyle: { | ||
fontFamily: 'Verdana', | ||
fontSize: [8, 32], | ||
}, | ||
tooltip: { | ||
customContent(_, data) { | ||
if (!data.length) return; | ||
return `<h4 style="margin-top: 1em;">title</h4> | ||
<li class="g2-tooltip-list-item" style="margin-bottom:4px;display:flex;align-items:center;"> | ||
<span style="background-color:${data[0]?.mappingData?.color};" class="g2-tooltip-marker"></span> | ||
<span style="display:inline-flex;flex:1;justify-content:space-between"> | ||
<span style="margin-right: 16px;">${data[0]?.data.text}:</span><span>${data[0]?.data.value}</span> | ||
</span> | ||
</li>`; | ||
}, | ||
}, | ||
}); | ||
|
||
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