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
Added y axis label to Line- and Areagraph #1995
Conversation
@DrFaust cool! can you post a screenshot so we can see what it looks like? |
|
@DrFaust Thank you, well done! 👍 Two minor things that I noticed:
|
Agreed with @alixunderplatz for the two points. Maybe you can reproduce that behaviour? Thanks for looking into this! |
Good point @alixunderplatz I updated the first label text and will have a look at the tooltip like @corradio proposed. |
Hi @alixunderplatz & @corradio. I changed it so that the unit of the second graph is dynamically set depending on the data. For a maximum with more than 1 GW its GW units otherwise it will be MW. Would be glad if you would have time to take a look.. |
web/src/components/areagraph.js
Outdated
var formattingFactor = 1; | ||
if (!that._displayByEmissions) { | ||
// Display in GW or MW | ||
formattingFactor = maxTotalValue > 1e3 ? 1e3 : 1; |
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.
Instead I suggest using this:
https://github.com/tmrowco/electricitymap-contrib/blob/master/web/src/helpers/formatting.js#L13
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 tried to use d3.format before, but failed. Output of that function is a formatted string, which would not work here since we need to align the total dataset dynamically accordingly. Thats why this threshold is implemented.
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.
What do you mean exactly by "align the total dataset dynamically accordingly"? I'm trying to figure out if we can find a more elegant solution because some areas have kW scale data.
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. Sure 👍 . Added a new scalePower formatter.
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 meant that data and domain need to be scaled.
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.
Last small challenge and we should be good to go! Thank you for your patience.
web/src/components/areagraph.js
Outdated
return (d.totalCo2Production + d.totalCo2Import + d.totalCo2Discharge) / 1e6 / 60.0; | ||
} | ||
}) | ||
maxTotalValue |
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.
can you multiply here by 1.1? It gives a bit of space between the graph and the axis (and then we keep the existing behavior)
This is a PR for issue #968
I placed the unit labels parallel to the axis and not at the top because it provided more space this way.
The second chart is now in GW.
Happy for feedpack!