Skip to content

Commit cb8505b

Browse files
Merge pull request #32 from cetz-package/bar-element-gallery-fixes
Bar Element Gallery Fixes
2 parents 9155ee8 + 60d3fde commit cb8505b

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

gallery/barchart.typ

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414

1515
#canvas({
1616
draw.set-style(legend: (fill: white))
17-
chart.barchart(mode: "clustered",
18-
size: (9, auto),
19-
label-key: 0,
20-
value-key: (..range(1, 4)),
21-
bar-width: .8,
22-
x-tick-step: 2.5,
23-
data2,
24-
labels: ([Low], [Medium], [High], [Very high]),
25-
legend: "legend.inner-north-east",)
26-
})
17+
chart.bar.clustered(size: (9, 8),
18+
label-key: 0,
19+
y-keys: (..range(1, 5)),
20+
bar-width: .8,
21+
data2,
22+
labels: ([Low], [Medium], [High], [Very high]),
23+
legend: "inner-north-east")
24+
})

gallery/line.typ

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919

2020
// Set-up a thin axis style
2121
set-style(axes: (stroke: .5pt, tick: (stroke: .5pt)),
22-
legend: (stroke: none, orientation: ttb, item: (spacing: .3), scale: 80%))
22+
legend: (stroke: none, fill: none, orientation: ttb, item: (spacing: .3), scale: 80%))
2323

2424
plot.plot(size: (12, 8),
2525
x-tick-step: calc.pi/2,
26-
x-format: plot.formats.multiple-of,
26+
x-format: axes.format.multiple-of,
2727
y-tick-step: 2, y-min: -2.5, y-max: 2.5,
2828
legend: "inner-north",
2929
{
3030
let domain = (-1.1 * calc.pi, +1.1 * calc.pi)
3131

3232
for ((title, f)) in fn {
33-
plot.add-fill-between(f, f1, domain: domain,
33+
plot.add.fill-between(f, f1, domain: domain,
3434
style: (stroke: none), label: title)
3535
}
36-
plot.add(f1, domain: domain, label: $ sin x $,
36+
plot.add.xy(f1, domain: domain, label: $ sin x $,
3737
style: (stroke: black))
3838
})
3939
})

src/charts/bar/clustered.typ

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@
6868
series-data.push(
6969
(
7070
label: if label-key != none {labels.at(series-index)},
71-
data: for (observation-index, observation) in data.enumerate() {
71+
data: for (observation-index, observation) in data.enumerate() {
7272
let x = observation-index - cluster-width/2 + series-index * (bar-width + bar-spacing) + bar-width/2
7373
let y = observation.at(y-key, default: 0)
74+
7475
((
7576
x: x,
7677
y: y,
@@ -96,4 +97,4 @@
9697
axes: axes,
9798
..plot-args,
9899
)
99-
}
100+
}

0 commit comments

Comments
 (0)