Skip to content

Commit

Permalink
Avoid div0
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Jul 10, 2021
1 parent f634965 commit d24c0d6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/core.layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ function placeBoxes(boxes, chartArea, params, stacks) {
for (const layout of boxes) {
const box = layout.box;
const stack = stacks[layout.stack] || {count: 1, placed: 0, weight: 1};
const weight = (stack.weight * layout.stackWeight) || 1
if (layout.horizontal) {
const width = chartArea.w / stack.weight * layout.stackWeight;
const width = chartArea.w / weight;
const height = stack.size || box.height;
if (defined(stack.start)) {
y = stack.start;
Expand All @@ -238,7 +239,7 @@ function placeBoxes(boxes, chartArea, params, stacks) {
stack.placed += width;
y = box.bottom;
} else {
const height = chartArea.h / stack.weight * layout.stackWeight;
const height = chartArea.h / weight;
const width = stack.size || box.width;
if (defined(stack.start)) {
x = stack.start;
Expand Down

0 comments on commit d24c0d6

Please sign in to comment.