-
Notifications
You must be signed in to change notification settings - Fork 3
Create and use HISTORIC_RANGE_DEFAULT in extra params components #15
Conversation
Value of HISTORIC_RANGE_DEFAULT matches default historic_range param value of the Climate API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the range defaults to the most recent base year and the base year options are known, it would be better to inspect historicRangeOptions
and use the most recent year instead of hard-coding 1971.
Ok. I updated the PR to dynamically choose the default year. Unfortunately this has the side effect of making an additional pair of duplicate requests (although we can't always assume they're duplicates) just with the parameter added. I poked at seeing if I could clean up the request list quickly but its a broader problem across all indicators that this just makes worse for one case. I opened azavea/climate-change-lab#322 to address it. |
this.historicRangeOptions.unshift(''); | ||
this.historicRangeOptions = data.map(h => parseInt(h.start_year, 10)); | ||
if (!this.extraParams.historic_range) { | ||
const latestHistoricRange = Math.max(...this.historicRangeOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ellipsis for an array builder, neat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on update to CHANGELOG
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | |||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | |||
|
|||
## [Unreleased] | |||
- PercentileHistoricComponent and HistoricComponent now automatically choose a sensible dropdown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have preferred something more specific than "sensible", i.e., explicitly match the default from the API.
Value of HISTORIC_RANGE_DEFAULT matches default historic_range
param value of the Climate API
Overview
Updates the historic range param controls to just automatically set themselves to the same value that the Climate API defaults to (1971) without presenting a "blank" option, since the API selects a default anyways if no param value is provided. This reduces confusion as to what the dropdown options mean in the Lab.
Demo
Both screenshots taken after selecting the indicator shown. No further actions taken to select extra params values:
Testing Instructions
Once this branch is checked out, run:
Now checkout
develop
on climate-change-lab, ensure node_modules is up to date withyarn install
and then manually install the climate-change-components package with:You should now be able to select any of the indicators that use the historic_range param and get a default value selected for you when the indicator loads.
I had some trouble with my
apiHost
in lab set tohttps://app.staging.climate.azavea.com
. Starting my local Climate API box on at least the current develop and settingapiHost = http://localhost:8080
worked as a replacement.Closes #12