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 all 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 @@ -9,6 +9,7 @@ New features
-------------
* Individual sensor charts show available annotations [see `PR #428 <http://www.github.com/FlexMeasures/flexmeasures/pull/428>`_]
* Collapsible sidepanel (hover/swipe) used for date selection on sensor charts, and various styling improvements [see `PR #447 <http://www.github.com/FlexMeasures/flexmeasures/pull/447>`_]
* 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
8 changes: 5 additions & 3 deletions flexmeasures/data/models/charts/defaults.py
Expand Up @@ -10,20 +10,22 @@
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"
# Use default timeFormat for date or second labels, and use 24-hour clock notation for other (hour and minute) labels
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={"labelOverlap": True, "labelSeparation": 1},
axis={"labelExpr": FORMAT_24H, "labelOverlap": True, "labelSeparation": 1},
),
"event_end": dict(
field="event_end",
type="temporal",
title=None,
axis={"labelOverlap": True, "labelSeparation": 1},
axis={"labelExpr": FORMAT_24H, "labelOverlap": True, "labelSeparation": 1},
),
"event_value": dict(
field="event_value",
Expand Down