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

Switch from 12-hour clock to 24-hour clock in time axis labels and in tooltips #446

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -8,6 +8,7 @@ v0.11.0 | June XX, 2022
New features
-------------
* Individual sensor charts show available annotations [see `PR #428 <http://www.github.com/FlexMeasures/flexmeasures/pull/428>`_]
* Switched from 12-hour AM/PM to 24-hour clock notation for time series chart axis labels [see `PR #446 <http://www.github.com/FlexMeasures/flexmeasures/pull/446>`_]

Bugfixes
-----------
Expand Down
5 changes: 4 additions & 1 deletion flexmeasures/data/models/charts/defaults.py
Expand Up @@ -10,18 +10,21 @@
WIDTH = "container"
REDUCED_HEIGHT = REDUCED_WIDTH = 60
SELECTOR_COLOR = "darkred"
TIME_FORMAT = "%I:%M %p on %A %b %e, %Y"
TIME_FORMAT = "%H:%M on %A %b %e, %Y"
FORMAT_24H = "(hours(datum.value) == 0 & minutes(datum.value) == 0) | seconds(datum.value) != 0 ? timeFormat(datum.value) : timeFormat(datum.value, '%H:%M')"
Flix6x marked this conversation as resolved.
Show resolved Hide resolved
TIME_SELECTION_TOOLTIP = "Click and drag to select a time window"
FIELD_DEFINITIONS = {
"event_start": dict(
field="event_start",
type="temporal",
title=None,
axis={"labelExpr": FORMAT_24H},
),
"event_end": dict(
field="event_end",
type="temporal",
title=None,
axis={"labelExpr": FORMAT_24H},
),
"event_value": dict(
field="event_value",
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/data/models/charts/test_chart_defaults.py
Expand Up @@ -6,4 +6,4 @@
def test_default_encodings():
"""Check default encodings for valid vega-lite specifications."""
for field_name, field_definition in FIELD_DEFINITIONS.items():
assert alt.StringFieldDefWithCondition(**field_definition)
assert alt.PositionFieldDef(**field_definition)