-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: treemap drilldown 1.0.0 (#6038)
* feat(interaction): add drilldown in treemap * feat(interaction): add drilldown in treemap * feat(interaction): add drilldown in treemap * feat(interaction): add drilldown in treemap --------- Co-authored-by: wb-xcf804241 <wb-xcf804241@alibaba-inc.com>
- Loading branch information
1 parent
cded9ed
commit 935df1b
Showing
27 changed files
with
2,005 additions
and
641 deletions.
There are no files selected for viewing
1,100 changes: 660 additions & 440 deletions
1,100
__tests__/integration/snapshots/static/flareTreemapCustom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
571 changes: 571 additions & 0 deletions
571
__tests__/integration/snapshots/static/flareTreemapDrillDown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,68 @@ | ||
import { G2Spec } from '../../../src'; | ||
|
||
export function flareTreemapDrillDown(): G2Spec { | ||
return { | ||
type: 'treemap', | ||
width: 600, | ||
height: 400, | ||
layout: { tile: 'treemapBinary', paddingInner: 5 }, | ||
data: { | ||
value: { | ||
name: '商品', | ||
children: [ | ||
{ | ||
name: '文具', | ||
children: [ | ||
{ | ||
name: '笔', | ||
children: [ | ||
{ name: '铅笔', value: 430 }, | ||
{ name: '圆珠笔', value: 530 }, | ||
{ name: '钢笔', value: 80 }, | ||
{ name: '水彩', value: 130 }, | ||
], | ||
}, | ||
{ name: '铅笔盒', value: 30 }, | ||
{ name: '直尺', value: 60 }, | ||
{ name: '笔记本', value: 160 }, | ||
{ name: '其他', value: 80 }, | ||
], | ||
}, | ||
{ | ||
name: '零食', | ||
children: [ | ||
{ name: '饼干', value: 280 }, | ||
{ name: '辣条', value: 150 }, | ||
{ name: '牛奶糖', value: 210 }, | ||
{ name: '泡泡糖', value: 80 }, | ||
{ | ||
name: '饮品', | ||
children: [ | ||
{ name: '可乐', value: 122 }, | ||
{ name: '矿泉水', value: 244 }, | ||
{ name: '果汁', value: 49 }, | ||
{ name: '牛奶', value: 82 }, | ||
], | ||
}, | ||
{ name: '其他', value: 40 }, | ||
], | ||
}, | ||
{ name: '其他', value: 450 }, | ||
], | ||
}, | ||
}, | ||
encode: { value: 'value' }, | ||
style: { | ||
labelFill: '#000', | ||
labelStroke: '#fff', | ||
labelLineWidth: 1.5, | ||
labelFontSize: 14, | ||
labelPosition: 'top-left', | ||
labelDx: 5, | ||
labelDy: 5, | ||
}, | ||
interaction: { | ||
treemapDrillDown: { breadCrumbY: 12, activeFill: '#873bf4' }, | ||
}, | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
width: 600, | ||
height: 400, | ||
}); | ||
|
||
const data = { | ||
name: '商品', | ||
children: [ | ||
{ | ||
name: '文具', | ||
children: [ | ||
{ | ||
name: '笔', | ||
children: [ | ||
{ name: '铅笔', value: 430 }, | ||
{ name: '圆珠笔', value: 530 }, | ||
{ name: '钢笔', value: 80 }, | ||
{ name: '水彩', value: 130 }, | ||
], | ||
}, | ||
{ name: '铅笔盒', value: 30 }, | ||
{ name: '直尺', value: 60 }, | ||
{ name: '笔记本', value: 160 }, | ||
{ name: '其他', value: 80 }, | ||
], | ||
}, | ||
{ | ||
name: '零食', | ||
children: [ | ||
{ name: '饼干', value: 280 }, | ||
{ name: '辣条', value: 150 }, | ||
{ name: '牛奶糖', value: 210 }, | ||
{ name: '泡泡糖', value: 80 }, | ||
{ | ||
name: '饮品', | ||
children: [ | ||
{ name: '可乐', value: 122 }, | ||
{ name: '矿泉水', value: 244 }, | ||
{ name: '果汁', value: 49 }, | ||
{ name: '牛奶', value: 82 }, | ||
], | ||
}, | ||
{ name: '其他', value: 40 }, | ||
], | ||
}, | ||
{ name: '其他', value: 450 }, | ||
], | ||
}; | ||
|
||
chart | ||
.treemap() | ||
.data({ | ||
value: data, | ||
}) | ||
.layout({ | ||
tile: 'treemapBinary', | ||
paddingInner: 5, | ||
}) | ||
.encode('value', 'value') | ||
.interaction({ | ||
treemapDrillDown: { | ||
breadCrumbY: 12, | ||
activeFill: '#873bf4', | ||
}, | ||
}) | ||
.style({ | ||
labelFill: '#000', | ||
labelStroke: '#fff', | ||
labelLineWidth: 1.5, | ||
labelFontSize: 14, | ||
labelPosition: 'top-left', | ||
labelDx: 5, | ||
labelDy: 5, | ||
}); | ||
|
||
chart.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
Oops, something went wrong.