Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare View: TR-55 Runoff Charts #2123

Closed
wants to merge 1 commit into from
Closed

Conversation

kellyi
Copy link
Contributor

@kellyi kellyi commented Aug 7, 2017

Overview

This PR adds the TR-55 Compare View charts and sets up the table & chart values to adjust accordingly. gif demo's below.

Connects #2072

Demo

compare-charts

Notes

Currently there are a few quirks & limitations with this implementation, which we can either handle here or spin off elsewhere.

  1. I did not implement the popovers, which seem to be complicated enough to handle in another card. NVD3 has tooltips by default, but since the desired behavior's that the hovering over one value on the bar chart opens corresponding popovers for all three, which isn't a built-in NVD3 feature. I think we may end up wanting to use Bootstrap popovers for this.

  2. The bars themselves match the width of the scenario title placeholders when there are few enough of them to display in the scenario header without overflow. However, when there are more, the chart div seems not to expand in size beyond what's visible so the bars get squished.

  3. There's currently some flicker as new charts are shown when retrieving any of the results, which means it renders once per scenario if the precipitation slider value changes. Not sure what is the best way to handle this -- I think we may want to set some value to check whether any of the scenarios is currently polling and show a loading state if not?

  4. I think the maximum y axis value for "Combined Hydrology" should be the value the precipitation slider has been set to, but it seemed like the value these scenarios had was slightly off the number displayed for the slider. Not sure what is the best way to handle this, but we'll need to pass it in to the chart to set the yDomain.

Happy to try to address these here or to spin them off elsewhere; figured I'd put up the PR for review rather than spinning wheels on it.

Testing

  • get this branch, then update and server bundle.sh & hard refresh in the browser
  • create a new TR-55 project then create a few scenarios including some which would cause varied values for runoff/infiltration (think: veg basin gswi conservation practice or high density land cover)
  • open the compare view and verify that you see the new charts and that the values seem accurate to the underlying data
  • move the precipitation slider and verify that when the polling stops, the values in the chart have changed
  • click to see the table view, then move the precipitation slider, and verify that those values change too

@kellyi kellyi force-pushed the ki/compare-view-tr55-runoff branch 12 times, most recently from 90000e9 to fd3bb5e Compare August 9, 2017 21:48
@kellyi kellyi requested a review from rajadain August 9, 2017 21:48
@kellyi kellyi force-pushed the ki/compare-view-tr55-runoff branch from fd3bb5e to 6ce8300 Compare August 9, 2017 21:51
@kellyi
Copy link
Contributor Author

kellyi commented Aug 9, 2017

Realized I left off a change which forces the y axis for the non-Combined-Hydrology charts to go slightly beyond the max value of the bars:

screen shot 2017-08-09 at 5 51 28 pm

Amended the commit & pushed it anew.

@kellyi kellyi changed the title WIP: Compare View: TR-55 Runoff Charts Compare View: TR-55 Runoff Charts Aug 9, 2017
@rajadain
Copy link
Member

get this branch, then update and server

This is one of our few projects to which this doesn't apply.

@kellyi
Copy link
Contributor Author

kellyi commented Aug 10, 2017

This is one of our few projects to which this doesn't apply.

Whoops! bundle.sh then hard refresh instead!

@rajadain
Copy link
Member

The tick labels on the Combined Hydrology chart are incorrect:

image

This should be 10 instead of 1. The labels on the other charts are correct.

var self = this;
this.model.get('scenarios').forEach(function(scenario) {
scenario.get('results').on('change', function(s) {
if (s.attributes.name === 'runoff' && !s.attributes.polling) {

Choose a reason for hiding this comment

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

We should still use the backbone syntax: s.get('name') and s.get('polling'). We also may want to refer to it as r, for "result"

@@ -472,8 +534,74 @@ function getTr55Tabs(scenarios) {
})
},
],
// TODO Make Runoff charts
runoffCharts = [],
runoffCharts = [

Choose a reason for hiding this comment

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

@rajadain Was there a reason for all the arrays/objects in this function to not be actual models?
Why doesn't this return aTabsCollection?

@kellyi
Copy link
Contributor Author

kellyi commented Aug 10, 2017

The tick labels on the Combined Hydrology chart are incorrect:

Good catch. The combined hydrology chart needs to get the precipitation slider value as an input so it can use it to set its yDomain max value.

@rajadain
Copy link
Member

This is interesting: when the precipitation value is changed, we run a TR-55 job for all four scenarios (in this example), and update the chart as the values return. As the initial values return, there is great variation in the chart, as we have some new low values coexisting with high old values. Once all the new ones are gathered, the chart rescales itself to the new standard. This is not very obvious to the user (especially because there are no spinners or loading symbols, more on that later), but the effect can be jarring:

2017-08-10 11 22 53

Can we make it so that the chart updates when every scenario has finished running instead of individual ones?

@rajadain
Copy link
Member

In the wireframes: https://marvelapp.com/8hi9jg9/screen/29125398, the background color of the columns alternates. Was any thought given to this here?

@rajadain
Copy link
Member

It looks like all the edge cases I found have been noted above in the description. Otherwise this works well, and moves us closer. Going to take a look at the code now.

@kellyi
Copy link
Contributor Author

kellyi commented Aug 10, 2017

the background color of the columns alternates. Was any thought given to this here?

Whoops, missed that one. Should be simple enough to do with index mod 2 though, so I can add a commit to fix it.

Working on the combined hydrology ydomain value, too.

@@ -346,6 +346,8 @@ function renderCompareMultibarChart(chartEl, name, label, colors, stacked, data)
if (maxValue) {
yDomainMax = maxValue * 1.2;
}
} else {
yDomainMax = precipitation || 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fallback's to ensure that if precipitation's set to 0, the graph will still range from 0 to 1.

@kellyi
Copy link
Contributor Author

kellyi commented Aug 10, 2017

8a046c3 departs from the wireframes to show the max value on the y-axis:

screen shot 2017-08-10 at 12 14 08 pm

If we decide we don't want to show them, I can either drop the commit or we can set showMaxMin to be false in the future.

@rajadain
Copy link
Member

0.1 is shown twice in different locations in the Evapotranspiration chart in the screenshot. That can't be right.

@kellyi
Copy link
Contributor Author

kellyi commented Aug 10, 2017

0.1 is shown twice in different locations in the Evapotranspiration chart in the screenshot. That can't be right.

Ah, looks like we have to set the tick count differently if there are only two values.

- add chart row views & collection
- add compareChartRow template
- structure charts data in `getTR55Tabs` function
- create renderCompareMultibarChart function
- format data & other arguments properly in addChart fn
- style compare charts to match scenario cards in title
@kellyi kellyi force-pushed the ki/compare-view-tr55-runoff branch from 2ffae03 to dc0d178 Compare August 10, 2017 17:48
@kellyi
Copy link
Contributor Author

kellyi commented Aug 10, 2017

I squashed this down to one commit & rebased it on develop so it'll be a single commit while adjusting the model & collection hierarchy here.

@jfrankl
Copy link
Contributor

jfrankl commented Aug 14, 2017

See #2134 (comment)

@rajadain
Copy link
Member

Closing in favor of #2148.

@rajadain rajadain closed this Aug 16, 2017
@kellyi kellyi deleted the ki/compare-view-tr55-runoff branch August 16, 2017 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants