-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpyramid.typ
More file actions
37 lines (33 loc) · 768 Bytes
/
pyramid.typ
File metadata and controls
37 lines (33 loc) · 768 Bytes
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
#import "@preview/cetz:0.4.2"
#import "@preview/cetz-plot:0.1.3": chart
#set page(width: auto, height: auto, margin: .5cm)
#let data = (
([Cash], 768),
([Funds], 1312),
([Stocks], 3812),
([Bonds], 7167),
)
#let total = data.map(i => i.last()).sum()
#cetz.canvas({
let colors = gradient.linear(red, yellow)
chart.pyramid(
data,
value-key: 1,
label-key: 0,
mode: "AREA-HEIGHT",
stroke: none,
level-style: colors,
inner-label: (
content: (value, label) => align(center, stack(
label + "\n",
str(calc.round(value / total * 10000) / 100) + "%",
spacing: 2pt,
dir: ttb
))
),
side-label: (
content: (value, label) => "$" + str(value)
),
gap: 10%
)
})