kalkih/mini-graph-card

Improve showing a date for a selected point

ildar170975 opened this issue · 2 comments

Consider this card:

type: custom:mini-graph-card
entities:
  - entity: sensor.xiaomi_cg_1_co2
hours_to_show: 24
hour24: true

image

The selected point belongs to an interval which has both left & right bounds from "yesterday".
Only a time is displayed for these bounds.

Another case - an interval with bounds from different days:

image
Same - no dates are displayed for bounds.

This happens if hours_to_show <= 24.

Now check this card:

type: custom:mini-graph-card
entities:
  - entity: sensor.xiaomi_cg_1_co2
hours_to_show: 24.1
hour24: true

When both bounds are from "today" - a date is displayed for both bounds:

image
I would say - no need to show a date for a today's bound (at least for both of them).

When bounds from different days - dates are shown for both bounds as well, looks OK:

image

And when both bounds are from same "not-today" day:

image

Proposals:

  1. If a bound belongs to a "not-today" date - show a date for the bound (independently on hours_to_show).
  2. If both bounds belong to the same "not-today" date - show a date for the left bound only (described here).
  3. If a bound belongs to a "today" date - do NOT show a date for the bound (independently on hours_to_show).

Alternatively:

  1. If hours_to_show <= 24 - do NOT show a date for a bound; otherwise - show a date (i.e. leave the current behaviour).
  2. If both bounds belong to the same date AND dates are supposed to be shown (see pt. 1) - show a date for the left bound only (described here).

Just to note: the current behaviour is apparently "by design":

const additional = conf.hours_to_show > 24 ? { day: 'numeric', weekday: 'short' } : {};

But that doesn't mean we can't improve it.

Additional suggestion: if both bounds also have the same time (as will happen with points per hour > 60), show only one time.

if both bounds also have the same time (as will happen with points per hour > 60), show only one time.

Agreed!