Skip to content

Commit

Permalink
[ui] Line charts: explicitly update X-axis whenever xScale changes (#…
Browse files Browse the repository at this point in the history
…14814)

* Explicitly update X-axis whenever xScale changes

* Changelog
  • Loading branch information
philrenaud committed Oct 6, 2022
1 parent a138821 commit 8a3c975
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/14814.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed line charts to update x-axis (time) where relevant
```
7 changes: 7 additions & 0 deletions ui/app/components/line-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ export default class LineChart extends Component {
});
}

@action
recomputeXAxis(el) {
if (!this.isDestroyed && !this.isDestroying) {
d3.select(el.querySelector('.x-axis')).call(this.xAxis);
}
}

mountD3Elements() {
if (!this.isDestroyed && !this.isDestroying) {
d3.select(this.element.querySelector('.x-axis')).call(this.xAxis);
Expand Down
1 change: 1 addition & 0 deletions ui/app/templates/components/line-chart.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
...attributes
{{did-insert this.onInsert}}
{{did-update this.renderChart}}
{{did-update this.recomputeXAxis this.xScale}}
{{window-resize this.updateDimensions}}>
<svg data-test-line-chart aria-labelledby="{{this.titleId}}" aria-describedby="{{this.descriptionId}}">
<title id="{{this.titleId}}">{{this.title}}</title>
Expand Down

0 comments on commit 8a3c975

Please sign in to comment.