-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(liquid): add outline, wave options for customize (#2099)
- Loading branch information
Showing
13 changed files
with
245 additions
and
67 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,7 @@ | ||
* **G2Plot Version**: | ||
* **Platform**: | ||
* **Mini Showcase(like screenshots)**: | ||
* **CodePen Link**: | ||
|
||
<!-- Describe your bugs below ^_^ --> | ||
|
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,12 @@ | ||
### PR includes | ||
<!-- Add completed items in this PR, and change [ ] to [x]. --> | ||
|
||
- [ ] fixed #0 | ||
- [ ] add / modify test cases | ||
- [ ] documents, demos | ||
|
||
### Screenshot | ||
|
||
| Before | After | | ||
|----|----| | ||
| ❌ | ✅ | |
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
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 |
---|---|---|
@@ -1,24 +1,13 @@ | ||
import { Liquid, measureTextWidth } from '@antv/g2plot'; | ||
import { Liquid } from '@antv/g2plot'; | ||
|
||
const liquidPlot = new Liquid('container', { | ||
percent: 0.25, | ||
statistic: { | ||
content: { | ||
style: { | ||
fontSize: 60, | ||
fill: 'black', | ||
}, | ||
customHtml: (container, view, { percent }) => { | ||
const { width, height } = container.getBoundingClientRect(); | ||
const d = Math.sqrt(Math.pow(width / 2, 2) + Math.pow(height / 2, 2)); | ||
const text = `${(percent * 100).toFixed(0)}%`; | ||
const textWidth = measureTextWidth(text, { fontSize: 60 }); | ||
const scale = Math.min(d / textWidth, 1); | ||
return `<div style="width:${d}px;height:${d}px;display:flex;align-items:center;justify-content:center;font-size:${scale}em;line-height:${ | ||
scale <= 1 ? 1 : 'inherit' | ||
}">${text}</div>`; | ||
}, | ||
}, | ||
outline: { | ||
border: 4, | ||
distance: 8, | ||
}, | ||
wave: { | ||
length: 128, | ||
}, | ||
}); | ||
liquidPlot.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
Oops, something went wrong.