Skip to content

Commit

Permalink
FIS-673 RLOI graph not scaled for forecast values (#146)
Browse files Browse the repository at this point in the history
* Scale for graph should include both observed and forecast values

* Remove unneeded conditional from extent function

The lines array has already been pre-processed to filter out negative values
  • Loading branch information
neilbmclaughlin authored and teddmason committed Oct 27, 2020
1 parent b8b8c1d commit feb1b37
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/src/js/components/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,11 @@ function LineChart (containerId, data) {
}

function modifyAxis () {
// Initialize scales
xExtent = d3.extent(data.observed, function (d, i) { return new Date(d.ts) })
yExtent = d3.extent(data.observed, function (d, i) { return data.plotNegativeValues ? d._ : Math.max(d._, 0) })
// Note: xExtent uses observed and forecast data rather than lines for the scenario where river levels
// start or end as -ve since we still need to determine the datetime span of the graph even if the
// values are excluded from plotting by virtue of being -ve
xExtent = d3.extent(data.observed.concat(data.forecast), function (d, i) { return new Date(d.ts) })
yExtent = d3.extent(lines, function (d, i) { return d._ })

// Increase X range by 5% from now value
let date = new Date(data.now)
Expand Down

0 comments on commit feb1b37

Please sign in to comment.