-
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(state-style): 若干图表支持 state 设置样式 & 增加文档 (#2334)
* feat(heatmap): 热力图支持 state 设置样式 * feat(state-style): 面积图、柱条形图、直方图支持state设置样式 & 增加若干state-style文档
- Loading branch information
Showing
26 changed files
with
257 additions
and
24 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 { Heatmap } from '../../../../src'; | ||
import { semanticBasicHeatmapData } from '../../../data/basic-heatmap'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
describe('heatmap', () => { | ||
const heatmap = new Heatmap(createDiv('basic heatmap'), { | ||
width: 400, | ||
height: 300, | ||
data: semanticBasicHeatmapData, | ||
xField: 'name', | ||
yField: 'day', | ||
colorField: 'sales', | ||
interactions: [{ type: 'element-active' }], | ||
}); | ||
|
||
heatmap.render(); | ||
|
||
it('set statesStyle', () => { | ||
heatmap.update({ | ||
state: { | ||
active: { | ||
style: { | ||
stroke: 'red', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
heatmap.setState( | ||
'active', | ||
(d: any) => d.name === semanticBasicHeatmapData[0].name && d.day === semanticBasicHeatmapData[0].day | ||
); | ||
|
||
const shape = heatmap.chart.geometries[0].elements[0].shape; | ||
|
||
expect(shape.attr('stroke')).toBe('red'); | ||
}); | ||
|
||
it('set statesStyle by theme', () => { | ||
heatmap.update({ | ||
state: undefined, | ||
shape: 'square', | ||
theme: { | ||
geometries: { | ||
polygon: { | ||
square: { | ||
active: { | ||
style: { | ||
stroke: 'yellow', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
heatmap.setState( | ||
'active', | ||
(d: any) => d.name === semanticBasicHeatmapData[0].name && d.day === semanticBasicHeatmapData[0].day | ||
); | ||
|
||
const shape = heatmap.chart.geometries[0].elements[0].shape; | ||
|
||
expect(shape.attr('stroke')).toBe('yellow'); | ||
}); | ||
|
||
afterAll(() => { | ||
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
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
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.