Skip to content

Commit

Permalink
[#188523090] Bug fix: Graph numeric axis labels do not restore correc…
Browse files Browse the repository at this point in the history
…tly on component resize

* This bug was introduced when we attempted to limit the amount of numeric axis redrawing we had to do. Fix by starting from scratch each time.
  • Loading branch information
bfinzer committed Nov 27, 2024
1 parent 314e6ca commit d0cf34e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions v3/src/components/axis/helper-models/numeric-axis-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,10 @@ export class NumericAxisHelper extends AxisHelper {
: undefined
if (!isNumericAxisModel(this.axisModel) || !numericScale || !this.subAxisElt) return

const subAxisSelection = select(this.subAxisElt),
numericAxisSelection = subAxisSelection.selectAll('.numeric-axis-tag')
// If we don't already have a numeric axis, we have to remove whatever is there
if (numericAxisSelection.size() === 0) {
subAxisSelection.selectAll('*').remove()
}
const subAxisSelection = select(this.subAxisElt)

Check warning on line 47 in v3/src/components/axis/helper-models/numeric-axis-helper.ts

View check run for this annotation

Codecov / codecov/patch

v3/src/components/axis/helper-models/numeric-axis-helper.ts#L47

Added line #L47 was not covered by tests
// Simplest if we remove everything and start again. Without this, #188523090 caused trouble
subAxisSelection.selectAll('*').remove()

Check warning on line 49 in v3/src/components/axis/helper-models/numeric-axis-helper.ts

View check run for this annotation

Codecov / codecov/patch

v3/src/components/axis/helper-models/numeric-axis-helper.ts#L49

Added line #L49 was not covered by tests
this.renderAxisLine()
// The axis line gets removed and rerendered each time.
// Tag it so the next time around we know we have a numeric axis.
subAxisSelection.select('.axis-line').classed('numeric-axis-tag', true)

const axisScale = this.axis(numericScale).tickSizeOuter(0).tickFormat(format('.9'))
const duration = this.isAnimating() ? transitionDuration : 0
Expand Down

0 comments on commit d0cf34e

Please sign in to comment.