-
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.
Browse files
Browse the repository at this point in the history
* fix(issue-2375): 中心文本交互,走 statistic 通道一样的逻辑,将额外信息传入交互中 fix: 修复饼图中心文本交互没有走 custom-html * fix(issue-2375): 添加饼图中心文本csutomHtml的单测 * test: 移除测试中的所有 settimeout * fix(gauge): 修复仪表盘单测 * fix(pie): 修复饼图单测, statistic 配置默认处理
- Loading branch information
Showing
12 changed files
with
212 additions
and
124 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,70 @@ | ||
import { Pie } from '../../src'; | ||
import { createDiv } from '.././utils/dom'; | ||
import { simulateMouseEvent } from '.././utils/event'; | ||
|
||
describe('#2375', () => { | ||
test('statistic-active, not use customHtml', async () => { | ||
const data = [ | ||
{ | ||
type: '分类一', | ||
value: 27, | ||
}, | ||
{ | ||
type: '分类二', | ||
value: 25, | ||
}, | ||
{ | ||
type: '分类三', | ||
value: 18, | ||
}, | ||
{ | ||
type: '分类四', | ||
value: 15, | ||
}, | ||
{ | ||
type: '分类五', | ||
value: 10, | ||
}, | ||
{ | ||
type: '其它', | ||
value: 5, | ||
}, | ||
]; | ||
|
||
const plot = new Pie(createDiv(), { | ||
width: 400, | ||
height: 400, | ||
radius: 1, | ||
innerRadius: 0.3, | ||
padding: [0, 0, 0, 0], | ||
data, | ||
angleField: 'value', | ||
colorField: 'type', | ||
interactions: [{ type: 'element-active' }, { type: 'pie-statistic-active' }], | ||
statistic: { | ||
title: false, | ||
content: { | ||
customHtml: () => 'xxx', | ||
}, | ||
}, | ||
animation: false, | ||
}); | ||
|
||
plot.render(); | ||
function getAnnotations(chart) { | ||
return chart.getComponents().filter((co) => co.type === 'annotation'); | ||
} | ||
|
||
const annotations = getAnnotations(plot.chart); | ||
expect(annotations.length).toBe(1); | ||
|
||
let htmlAnnotations = plot.container.querySelectorAll('.g2-html-annotation'); | ||
expect((htmlAnnotations[0] as HTMLElement).innerText).toBe('xxx'); | ||
|
||
simulateMouseEvent(plot.chart.geometries[0].elements[0].shape, 'mouseenter', {}); | ||
htmlAnnotations = plot.container.querySelectorAll('.g2-html-annotation'); | ||
expect((htmlAnnotations[0] as HTMLElement).innerText).toBe('xxx'); | ||
|
||
plot.destroy(); | ||
}); | ||
}); |
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
Oops, something went wrong.