diff --git a/src/charts/area/stacked.typ b/src/charts/area/stacked.typ index b6d4e24..528e0e9 100644 --- a/src/charts/area/stacked.typ +++ b/src/charts/area/stacked.typ @@ -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 ) \ No newline at end of file diff --git a/tests/charts/area/stacked/ref/1.png b/tests/charts/area/stacked/ref/1.png index e9d3f22..546f453 100644 Binary files a/tests/charts/area/stacked/ref/1.png and b/tests/charts/area/stacked/ref/1.png differ diff --git a/tests/charts/area/stacked100/ref/1.png b/tests/charts/area/stacked100/ref/1.png index 1a79893..ecb53b0 100644 Binary files a/tests/charts/area/stacked100/ref/1.png and b/tests/charts/area/stacked100/ref/1.png differ diff --git a/tests/charts/area/stacked100/test.typ b/tests/charts/area/stacked100/test.typ index 821dba4..c8f5c3e 100644 --- a/tests/charts/area/stacked100/test.typ +++ b/tests/charts/area/stacked100/test.typ @@ -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),