forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflare-treemap-default.ts
44 lines (42 loc) · 1018 Bytes
/
flare-treemap-default.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { schemeTableau10 } from 'd3-scale-chromatic';
import { G2Spec } from '../../../src';
import { tooltipSteps } from './utils';
export async function flareTreemapDefault(): Promise<G2Spec> {
return {
type: 'treemap',
height: 600,
width: 800,
data: {
type: 'fetch',
value: 'data/flare.csv',
},
layout: {
path: (d) => d.name.replace(/\./g, '/'),
tile: 'treemapBinary',
},
scale: { color: { range: schemeTableau10 } },
encode: {
value: 'size',
color: (d) => d.parent.data.name.split('.')[1],
},
tooltip: {
title: null,
items: [{ field: 'value' }],
},
style: {
labelText: (d) => {
const name = d.data.name
.split('.')
.pop()
.split(/(?=[A-Z][a-z])/g)[0];
return name;
},
labelFill: '#000',
labelPosition: 'top-left',
labelDx: 3,
labelDy: 3,
fillOpacity: 0.5,
},
} as any;
}
flareTreemapDefault.steps = tooltipSteps(0);