Skip to content

Commit

Permalink
fix(scales): linear scale when stacked types
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 22, 2021
1 parent dc8ac36 commit 7393acf
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/scales/src/linearScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,23 @@ export const createLinearScale = <Output extends NumberValue>(
) => {
let minValue: NumberValue
if (min === 'auto') {
minValue = stacked === true ? data.minStacked : data.min
minValue = stacked === true ? data.minStacked ?? 0 : data.min
} else {
minValue = min
}

let maxValue: NumberValue
if (max === 'auto') {
maxValue = stacked === true ? data.maxStacked : data.max
maxValue = stacked === true ? data.maxStacked ?? 0 : data.max
} else {
maxValue = max
}

const scale = scaleLinear<number, Output>()
.rangeRound(axis === 'x' ? [0, size] : [size, 0])
.domain(reverse ? [maxValue, minValue] : [minValue, maxValue])
.clamp(clamp)

if (reverse === true) {
scale.domain([maxValue, minValue])
} else {
scale.domain([minValue, maxValue])
}

if (nice === true) scale.nice()
else if (typeof nice === 'number') scale.nice(nice)

Expand Down

0 comments on commit 7393acf

Please sign in to comment.