Skip to content

Commit

Permalink
fix: null stack data
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Jul 26, 2021
1 parent 381d1eb commit f067ca5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/utils/buildAxis.linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,13 @@ function stackSeries<TDatum>(
const stacker = stack()
.keys(seriesIndices)
.value((_, seriesIndex, index) => {
const val = axisOptions.getValue(
const originalDatum =
axisSeries[Number(seriesIndex)]?.datums[index]?.originalDatum
)

const val =
typeof originalDatum !== 'undefined'
? axisOptions.getValue(originalDatum)
: 0

if (typeof val === 'undefined' || val === null) {
return 0
Expand All @@ -439,11 +443,13 @@ function stackSeries<TDatum>(

stacked.forEach((s, sIndex) => {
s.forEach((datum, i) => {
// @ts-ignore
datum.data = axisSeries[sIndex].datums[i]
if (axisSeries[sIndex].datums[i]) {
// @ts-ignore
datum.data = axisSeries[sIndex].datums[i]

axisSeries[sIndex].datums[i].stackData =
datum as unknown as StackDatum<TDatum>
axisSeries[sIndex].datums[i].stackData =
datum as unknown as StackDatum<TDatum>
}
})
})
}
Expand Down

1 comment on commit f067ca5

@vercel
Copy link

@vercel vercel bot commented on f067ca5 Jul 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.