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
Issue 502 visually distinguish forecasts from measurements #503
Changes from 12 commits
0047179
b1b7142
8d0d480
2724ac0
473a0ba
dbdb885
50f23c3
e1c4cef
144ae0e
0ededc9
48c0299
c6fff67
15a7e64
ab42e39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,13 +311,33 @@ function submit_sensor_type() { | |
$("#sensor_type-form").attr("action", empty_location).submit(); | ||
} | ||
|
||
/** Tooltips: Register custom formatter for quantities incl. units | ||
Usage: | ||
{ | ||
'format': [<d3-format>, <sensor unit>], | ||
'formatType': 'quantityWithUnitFormat' | ||
} | ||
*/ | ||
/** Tooltips: Register custom formatters | ||
* | ||
* - Quantities incl. units | ||
* Usage: | ||
* { | ||
* 'format': [<d3-format>, <sensor unit>], | ||
* 'formatType': 'quantityWithUnitFormat' | ||
* } | ||
* - Timedeltas measured in human-readable quantities (usually not milliseconds) | ||
* Usage: | ||
* { | ||
* 'format': [<d3-format>, <breakpoint>], | ||
* 'formatType': 'timedeltaFormat' | ||
* } | ||
* <d3-format> is a d3 format identifier, e.g. 'd' for decimal notation, rounded to integer. | ||
* See https://github.com/d3/d3-format for more details. | ||
* <breakpoint> is a scalar that decides the breakpoint from one duration unit to the next larger unit. | ||
* For example, a breakpoint of 4 means we format 4 days as '4 days', but 3.96 days as '95 hours'. | ||
*/ | ||
vega.expressionFunction('quantityWithUnitFormat', function(datum, params) { | ||
return d3.format(params[0])(datum) + " " + params[1]; | ||
}); | ||
vega.expressionFunction('timedeltaFormat', function(timedelta, params) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we document here what I had to find out by myself? params[0] is a D3 format identifier (.e.g "d" for days) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, d stands for decimal notation, rounded to integer. It's a d3-format rather than a d3-time-format. I'm expanding the inline documentation. |
||
return (Math.abs(timedelta) > 1000 * 60 * 60 * 24 * 365.2425 * params[1] ? d3.format(params[0])(timedelta / (1000 * 60 * 60 * 24 * 365.2425)) + " years" | ||
: Math.abs(timedelta) > 1000 * 60 * 60 * 24 * params[1] ? d3.format(params[0])(timedelta / (1000 * 60 * 60 * 24)) + " days" | ||
: Math.abs(timedelta) > 1000 * 60 * 60 * params[1] ? d3.format(params[0])(timedelta / (1000 * 60 * 60)) + " hours" | ||
: Math.abs(timedelta) > 1000 * 60 * params[1] ? d3.format(params[0])(timedelta / (1000 * 60)) + " minutes" | ||
: Math.abs(timedelta) > 1000 * params[1] ? d3.format(params[0])(timedelta / 1000) + " seconds" | ||
: d3.format(params[0])(timedelta) + " milliseconds"); | ||
}); |
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.
This looks like a hard-coded value used in development?
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.
Indeed. I encountered significant page loading delay here. I'll make a new ticket to make this asynchronous.
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.
See #515.