-
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.
test: 给heatmap添加pattern的单测和文档,并给patternAttr的类型增加布尔值
- Loading branch information
酥云
committed
Aug 16, 2021
1 parent
6dae31d
commit c5cf813
Showing
4 changed files
with
72 additions
and
0 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,67 @@ | ||
import { Heatmap } from '../../../../src'; | ||
import { semanticBasicHeatmapData } from '../../../data/basic-heatmap'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
describe('heatmap: pattern', () => { | ||
it('pattern: obj', () => { | ||
const heatmap = new Heatmap(createDiv('style'), { | ||
width: 400, | ||
height: 300, | ||
data: semanticBasicHeatmapData, | ||
xField: 'name', | ||
yField: 'day', | ||
colorField: 'sales', | ||
pattern: { | ||
type: 'line', | ||
}, | ||
}); | ||
|
||
heatmap.render(); | ||
|
||
const geometry = heatmap.chart.geometries[0]; | ||
const elements = geometry.elements; | ||
expect(elements[0].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
|
||
heatmap.update({ | ||
pattern: false, | ||
}); | ||
|
||
expect(heatmap.chart.geometries[0].elements[0].shape.attr('fill') instanceof CanvasPattern).toEqual(false); | ||
|
||
heatmap.destroy(); | ||
}); | ||
|
||
it('pattern: callback', () => { | ||
const heatmap = new Heatmap(createDiv('style'), { | ||
width: 400, | ||
height: 300, | ||
data: semanticBasicHeatmapData, | ||
xField: 'name', | ||
yField: 'day', | ||
colorField: 'sales', | ||
pattern: ({ sales }) => { | ||
if (sales === 10) { | ||
return { type: 'dot' }; | ||
} | ||
}, | ||
}); | ||
|
||
heatmap.render(); | ||
|
||
const geometry = heatmap.chart.geometries[0]; | ||
const elements = geometry.elements; | ||
expect(elements[0].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
|
||
heatmap.update({ | ||
pattern: ({ sales }) => { | ||
if (sales === 19) { | ||
return { type: 'dot' }; | ||
} | ||
}, | ||
}); | ||
|
||
expect(heatmap.chart.geometries[0].elements[1].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
|
||
heatmap.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