-
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.
- Loading branch information
酥云
committed
Aug 17, 2021
1 parent
c5cf813
commit e1c5b24
Showing
3 changed files
with
75 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,71 @@ | ||
import { RadialBar } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
import { antvStar } from '../../../data/antv-star'; | ||
|
||
const xField = 'name'; | ||
const yField = 'star'; | ||
|
||
describe('radial-bar pattern', () => { | ||
it('pattern: obj', () => { | ||
const bar = new RadialBar(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: antvStar, | ||
xField, | ||
yField, | ||
pattern: { | ||
type: 'line', | ||
}, | ||
}); | ||
bar.render(); | ||
|
||
const geometry = bar.chart.geometries[0]; | ||
const elements = geometry.elements; | ||
expect(elements[0].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
expect(elements[1].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
expect(elements[2].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
|
||
bar.update({ | ||
pattern: false, | ||
}); | ||
|
||
expect(bar.chart.geometries[0].elements[1].shape.attr('fill') instanceof CanvasPattern).toEqual(false); | ||
|
||
bar.destroy(); | ||
}); | ||
|
||
it('pattern: callback', () => { | ||
const bar = new RadialBar(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: antvStar, | ||
xField, | ||
yField, | ||
pattern: (d) => { | ||
if (d.star > 7346) { | ||
return { type: 'dot' }; | ||
} | ||
}, | ||
}); | ||
bar.render(); | ||
|
||
const geometry = bar.chart.geometries[0]; | ||
const elements = geometry.elements; | ||
expect(elements[7].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
expect(elements[0].shape.attr('fill') instanceof CanvasPattern).toEqual(false); | ||
|
||
bar.update({ | ||
pattern: (d) => { | ||
if (d.star > 7100) { | ||
return { type: 'dot' }; | ||
} | ||
}, | ||
}); | ||
|
||
expect(bar.chart.geometries[0].elements[7].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
expect(bar.chart.geometries[0].elements[6].shape.attr('fill') instanceof CanvasPattern).toEqual(false); | ||
expect(bar.chart.geometries[0].elements[5].shape.attr('fill') instanceof CanvasPattern).toEqual(true); | ||
|
||
bar.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