Skip to content

Commit

Permalink
Merge pull request #32 from cetz-package/bar-element-gallery-fixes
Browse files Browse the repository at this point in the history
Bar Element Gallery Fixes
  • Loading branch information
johannes-wolf authored Aug 5, 2024
2 parents 9155ee8 + 60d3fde commit cb8505b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
18 changes: 8 additions & 10 deletions gallery/barchart.typ
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

#canvas({
draw.set-style(legend: (fill: white))
chart.barchart(mode: "clustered",
size: (9, auto),
label-key: 0,
value-key: (..range(1, 4)),
bar-width: .8,
x-tick-step: 2.5,
data2,
labels: ([Low], [Medium], [High], [Very high]),
legend: "legend.inner-north-east",)
})
chart.bar.clustered(size: (9, 8),
label-key: 0,
y-keys: (..range(1, 5)),
bar-width: .8,
data2,
labels: ([Low], [Medium], [High], [Very high]),
legend: "inner-north-east")
})
8 changes: 4 additions & 4 deletions gallery/line.typ
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@

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

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

for ((title, f)) in fn {
plot.add-fill-between(f, f1, domain: domain,
plot.add.fill-between(f, f1, domain: domain,
style: (stroke: none), label: title)
}
plot.add(f1, domain: domain, label: $ sin x $,
plot.add.xy(f1, domain: domain, label: $ sin x $,
style: (stroke: black))
})
})
5 changes: 3 additions & 2 deletions src/charts/bar/clustered.typ
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@
series-data.push(
(
label: if label-key != none {labels.at(series-index)},
data: for (observation-index, observation) in data.enumerate() {
data: for (observation-index, observation) in data.enumerate() {
let x = observation-index - cluster-width/2 + series-index * (bar-width + bar-spacing) + bar-width/2
let y = observation.at(y-key, default: 0)

((
x: x,
y: y,
Expand All @@ -96,4 +97,4 @@
axes: axes,
..plot-args,
)
}
}

0 comments on commit cb8505b

Please sign in to comment.