-
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.
* feat(venn): 韦恩图颜色回调重构 1. 修复 color 设置回调,导致图例颜色不正确 2. color 回调参数,增加 defaultColor 默认色 3. 完善韦恩图文档 & 增加 demo * test(venn): 韦恩图单测 fix: #2906 * test(venn): 添加韦恩图 color 单测
- Loading branch information
Showing
10 changed files
with
211 additions
and
22 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,28 @@ | ||
import { Venn } from '../../src'; | ||
import { createDiv } from '../utils/dom'; | ||
|
||
describe('#2906', () => { | ||
it('venn plot color callback', () => { | ||
const plot = new Venn(createDiv(), { | ||
setsField: 'sets', | ||
sizeField: 'size', | ||
data: [ | ||
{ sets: ['A'], size: 12, label: 'A' }, | ||
{ sets: ['B'], size: 12, label: 'B' }, | ||
{ sets: ['C'], size: 12, label: 'C' }, | ||
{ sets: ['A', 'B'], size: 2, label: 'A&B' }, | ||
{ sets: ['A', 'C'], size: 2, label: 'A&C' }, | ||
{ sets: ['B', 'C'], size: 2, label: 'B&C' }, | ||
{ sets: ['A', 'B', 'C'], size: 1 }, | ||
], | ||
pointStyle: { fillOpacity: 0.85 }, | ||
color: (datum) => (datum.sets?.length === 1 ? 'blue' : 'red'), | ||
}); | ||
plot.render(); | ||
|
||
const legendController = plot.chart.getController('legend'); | ||
const items = legendController.getComponents()[0].component.get('items'); | ||
expect(items[0].marker.style.fill).toBe('blue'); | ||
expect(items[3].marker.style.fill).toBe('red'); | ||
}); | ||
}); |
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,6 @@ | ||
--- | ||
title: Venn | ||
order: 30 | ||
--- | ||
|
||
`markdown:docs/manual/plots/venn.zh.md` |
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,35 @@ | ||
--- | ||
title: 韦恩图 | ||
order: 30 | ||
--- | ||
|
||
<iframe width="100%" height="500" frameborder="0" allowfullscreen style="border:1px solid #d9d9d9;" src="https://www.yuque.com/antv/g2plot/venn-guide?view=doc_embed"> | ||
## 快速上手 | ||
<div class="sign"> | ||
```ts | ||
import { Venn } from '@antv/g2plot'; | ||
const plot = new Venn('container', { | ||
data: [ | ||
{ sets: ['A'], size: 12, label: 'A' }, | ||
{ sets: ['B'], size: 12, label: 'B' }, | ||
{ sets: ['C'], size: 12, label: 'C' }, | ||
{ sets: ['A', 'B'], size: 2, label: 'A&B' }, | ||
{ sets: ['A', 'C'], size: 2, label: 'A&C' }, | ||
{ sets: ['B', 'C'], size: 2, label: 'B&C' }, | ||
{ sets: ['A', 'B', 'C'], size: 1 }, | ||
], | ||
setsField: 'sets', | ||
sizeField: 'size', | ||
}); | ||
plot.render(); | ||
``` | ||
</div> | ||
📊 查看更多<a href="/zh/examples/more-plots/venn#basic" target='blank'>示例</a>. | ||
🎨 韦恩图详细的配置参考 [API 文档](/zh/docs/api/plots/venn)。 |
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,23 @@ | ||
import { Venn } from '@antv/g2plot'; | ||
|
||
const plot = new Venn('container', { | ||
data: [ | ||
{ sets: ['A'], size: 102, label: 'A' }, | ||
{ sets: ['B'], size: 12, label: 'B' }, | ||
{ sets: ['C'], size: 12, label: 'C' }, | ||
{ sets: ['A', 'B'], size: 2, label: 'A&B' }, | ||
{ sets: ['A', 'C'], size: 2, label: 'A&C' }, | ||
{ sets: ['B', 'C'], size: 2, label: 'B&C' }, | ||
{ sets: ['A', 'B', 'C'], size: 1 }, | ||
], | ||
setsField: 'sets', | ||
sizeField: 'size', | ||
pointStyle: { fillOpacity: 0.85 }, | ||
color: (datum, defaultColor) => { | ||
if (datum.size > 100) { | ||
return '#FF4500'; | ||
} | ||
return defaultColor; | ||
}, | ||
}); | ||
plot.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