Skip to content

Commit

Permalink
Switch from 12-hour clock to 24-hour clock in time axis labels and in…
Browse files Browse the repository at this point in the history
… tooltips (#446)

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

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Changelog entry

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Fix test

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Add redundant brackets for ease of reading

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Add comment explaining the chosen timeFormat

Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Jul 8, 2022
1 parent 16aa4bd commit 1acd3f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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')"
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

0 comments on commit 1acd3f4

Please sign in to comment.