Skip to content

Commit

Permalink
Fix stacked100 and test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrswift committed Aug 9, 2024
1 parent 0011f5d commit 2f22a4e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/charts/area/stacked.typ
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@
..plot-args
) = stacked(
data.map(d=>{
let sum = y-keys.map(k=>d.at(k, default: 0)).sum()
for key in y-keys {
d.at(key) /= sum
let sum = y-keys.map(k=>data.map(d=>d.at(k, default: 0)).sum())
for (index, key) in y-keys.enumerate() {
d.at(key) /= sum.at(index)
}
d
}),
}),
label-key: label-key,
x-key: x-key,
y-keys: y-keys,
area-style: area-style,
axes: axes,
y-tick-step: 0.2,
y-format: (it)=>{$#{it*100}%$},
..plot-args
)
Binary file modified tests/charts/area/stacked/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/charts/area/stacked100/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tests/charts/area/stacked100/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
(2.5, 16.3, 17.6, 19.4, 15.3),
(5, 14.0, 15.3, 13.9, 18.7),
(7.5, 35.5, 26.5, 29.4, 25.8),
(10, 25.0, 20.6, 22.4, 22.0),
(12.5, 19.9, 18.2, 19.2, 16.4),
// (10, 25.0, 20.6, 22.4, 22.0),
// (12.5, 19.9, 18.2, 19.2, 16.4),
)

#let x-list = (0, 3.3, 6.6, 9.9)

#test-case(cetz-plot.chart.area.stacked(
#test-case(cetz-plot.chart.area.stacked100(
size: (10,9),
x-key: 0,
y-keys: (1,2,3,4),
Expand Down

0 comments on commit 2f22a4e

Please sign in to comment.