-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add polar attribute to heatmap (#2425)
* feat: add polar attribute to heatmap * feat: add polar attribute to heatmap add heatMap polar examples * feat: add polar attribute to heatmap add heatMap polar examples * feat: add polar attribute to heatmap add heatMap polar examples -2 * feat: add polar attribute add heatMap polar examples add document * feat: add polar attribute add heatMap polar examples add document * feat: add polar attribute add heatMap polar examples add document Co-authored-by: wb-xcf804241 <wb-xcf804241@antgroup.com>
- Loading branch information
1 parent
2589854
commit 55842a6
Showing
8 changed files
with
230 additions
and
6 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,70 @@ | ||
import { Heatmap } from '../../../../src'; | ||
import { semanticBasicHeatmapData } from '../../../data/basic-heatmap'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
describe('heatmap', () => { | ||
it('x*y*color and default coordinate', () => { | ||
const heatmap = new Heatmap(createDiv('default axis'), { | ||
width: 400, | ||
height: 300, | ||
data: semanticBasicHeatmapData, | ||
xField: 'name', | ||
yField: 'day', | ||
colorField: 'sales', | ||
shape: 'circle', | ||
}); | ||
|
||
heatmap.render(); | ||
|
||
// @ts-ignore | ||
expect(heatmap.chart.options.coordinate.type).toBe('rect'); | ||
|
||
heatmap.destroy(); | ||
}); | ||
|
||
it('x*y*color and custom axis', () => { | ||
const heatmap = new Heatmap(createDiv('custom axis'), { | ||
width: 400, | ||
height: 300, | ||
data: semanticBasicHeatmapData, | ||
xField: 'name', | ||
yField: 'day', | ||
colorField: 'sales', | ||
shape: 'circle', | ||
coordinate: { | ||
type: 'polar', | ||
cfg: { | ||
radius: 0.85, | ||
innerRadius: 0.2, | ||
}, | ||
}, | ||
}); | ||
|
||
heatmap.render(); | ||
|
||
// @ts-ignore | ||
expect(heatmap.chart.options.coordinate.type).toBe('polar'); | ||
// @ts-ignore | ||
expect(heatmap.chart.options.coordinate.cfg.radius).toBe(0.85); | ||
// @ts-ignore | ||
expect(heatmap.chart.options.coordinate.cfg.innerRadius).toBe(0.2); | ||
|
||
heatmap.update({ | ||
...heatmap.options, | ||
coordinate: { | ||
type: 'polar', | ||
cfg: { | ||
startAngle: 1, | ||
endAngle: 2, | ||
}, | ||
}, | ||
}); | ||
|
||
// @ts-ignore | ||
expect(heatmap.chart.options.coordinate.cfg.startAngle).toBe(1); | ||
// @ts-ignore | ||
expect(heatmap.chart.options.coordinate.cfg.endAngle).toBe(2); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Heatmap } from '@antv/g2plot'; | ||
|
||
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/polar-heatmap.json') | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
const heatmapPlot = new Heatmap(document.getElementById('container'), { | ||
data, | ||
xField: 'time', | ||
yField: 'week', | ||
colorField: 'value', | ||
legend: true, | ||
color: '#BAE7FF-#1890FF-#1028ff', | ||
coordinate: { | ||
// 坐标轴属性配置 | ||
type: 'polar', // 极坐标 | ||
cfg: { | ||
innerRadius: 0.2, | ||
}, | ||
}, | ||
heatmapStyle: { | ||
stroke: '#f5f5f5', | ||
opacity: 0.8, | ||
}, | ||
meta: { | ||
time: { | ||
type: 'cat', | ||
}, | ||
value: { | ||
min: 0, | ||
max: 1, | ||
}, | ||
}, | ||
xAxis: { | ||
line: null, | ||
grid: null, | ||
tickLine: null, | ||
label: { | ||
offset: 12, | ||
style: { | ||
fill: '#666', | ||
fontSize: 12, | ||
textBaseline: 'top', | ||
}, | ||
}, | ||
}, | ||
yAxis: { | ||
top: true, | ||
line: null, | ||
grid: null, | ||
tickLine: null, | ||
label: { | ||
offset: 0, | ||
style: { | ||
fill: '#fff', | ||
textAlign: 'center', | ||
shadowBlur: 2, | ||
shadowColor: 'rgba(0, 0, 0, .45)', | ||
}, | ||
}, | ||
}, | ||
tooltip: { | ||
showMarkers: false, | ||
}, | ||
interactions: [{ type: 'element-active' }], | ||
}); | ||
heatmapPlot.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