-
Notifications
You must be signed in to change notification settings - Fork 23
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
Move the existing dashboard to NREL's template #50
Conversation
Next steps: |
Made some changes to support the dynamic configs PR: #51 |
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.
I see that the metrics are dynamic, but what about the dates? It seems like if you knew what the start date was, generating the months after that should be not too bad. Fortunately, the months don't have the additional x and y parameters that the metrics do.
moment.js should make this relatively straightforward, not sure if we want to add that dependency. Not sure if there is an easy way without it that works across multiple years, though
const MONTHS = () => {
const months = []
const dateStart = moment()
const dateEnd = moment().add(12, ‘month') while (dateEnd.diff(dateStart, ‘months') >= 0) {
months.push(dateStart.format(‘M'))
dateStart.add(1, ‘month')
}
return months
}
frontend/metrics_program.html
Outdated
<option value="ntrips_ebike_purpose" data-sizex="4" data-sizey="4">eBike trip count by purpose</option> | ||
<option value="ntrips_ebike_replaced_mode" data-sizex="4" data-sizey="4">eBike trip count by replaced mode</option> |
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.
Shouldn't this use the mode_of_interest
from the config instead of the hardcoded eBike
?
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.
Renamed all hard-coded plot names
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.
You renamed all of them to "mode specific", which doesn't mean that much to an end user since it is not clear which mode you are targeting.
I think we should fill this in with the mode of interest instead. There are jquery templating plugins
https://www.endyourif.com/jquery-creating-templates-for-your-html-content/#jquery-template
but we should also be able to do something simpler with string replacement in javascript
Now the date list should populate from the date in the dynamic configs. Currently using numeric date for convenience, but could add a map from numbers to months. |
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.
Number of changes is going down...
frontend/index.html
Outdated
<li data-row="1" data-col="1" data-sizex="4" data-sizey="4"> | ||
Number of trips (Nov 2020) | ||
<button class='remove'>x</button> | ||
<img src='plots/ntrips_mode_confirm_2020_11_prepilot.png' width=90% height=90%> | ||
</li> |
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.
we also need to change this to show the plots for the most recent month instead of the hardcoded results for 2020_11 which is way too old
Added DoE logo and text near bottom of page, to match the example more closely we could write some text at the top, or also the DoE logo could be at the top near the NREL logo. This is what ended up looking cleanest. |
Specifying `navbar-expand-lg` works
Similar to the existing CanBikeCO
This also required some refactoring of the `getMonthList` function. Without the refactoring, we would get into an infinite loop where we kept iterating over dates forever. I am not 100% sure if this is because the current month = 9 and the start month for the selected program was also 9, or whether it was because the start_month was a string. + convert the configured values into ints otherwise you end up with a month that is 91111111 This works now
Before this change, the "value" in the option was misformatted, AND did not have the initial zero padding for the month. Fixes are to create a padded value for the month (https://bobbyhadz.com/blog/javascript-pad-number-with-leading-zeros) and then use built-in javascript templates (back ticks) to construct the options in a more legible fashion. https://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals So now we have a solution for templating in raw javascript that does not depend on any templating libraries. Yay!
… interest Attempts which did not work: - using the backtick templates - were not replaced, probably because this was part of a different load - using a different string - e.g. MODE_OF_INTEREST instead of `${data.intro.mode_of_interest}` - error while loading - Removing ticks around the mode of interest - error while loading Final solution is to load the data, and in the callback, change the text manually using `replaceAll` and then set the options. That works properly.
Note that we display the mode of interest in the internal representation, not in the potentially translated representation. Added to e-mission/e-mission-docs#788 |
At this point, the only tasks left are:
|
oh wait, we also remove the hardcoding on the initial set of slots. |
The problem with the javascript-based templating is that it only works on javascript, not in HTML. |
- The set of graphs are different from programs and studies - we "hack" the graph creation by setting the values in the metric and then simulating a mouse click. This allows us to reuse the existing code to add metrics, which relies heavily on data in the select options - we make sure to set the date to the most recent one so that the graphs that are displayed are for the most recent month and year - As a bonus, the most recent month and year are selected, which is what people expect :)
NOW, we can finally work on creating the production dockerfiles/docker-compose. |
NREL OpenPATH dashboard makes it seem like this is *the* dashboard for NREL OpenPATH. But in fact, it is the dashboard for each individual study or program. So let's actually populate the title (page title + top visible title) with the study-specific information. As a bonus, this is an example for @sebastianbarry on how to configure text without having to include a templating library.
@zackAemmer e267dcd is not actually a typo - it was an experiment to see where I needed to put the ticks. Once I figured it out, I didn't go back and change it. Thanks for making it consistent with the others! |
My changes approved by @zackAemmer |
Minimal changes to existing code, this simply copies the existing dashboard to the style/format in the NREL template.