Smoking habit tracker

fix(diagrams): weekday patterns bars not aligned #8

Open io-industries.dev
Open opened by io-industries.dev

fix(diagrams): weekday patterns bars not aligned #

Area: Data & Diagrams · Weekday Patterns · pages/diagrams.vue Type: bug (visual) Priority: p2

Summary #

Bars and counts in Weekday Patterns on /diagrams are not aligned — label width (Mon vs Wednesday / i18n) pushes the bar start position, so rows look ragged.

Current behavior #

pages/diagrams.vue:114-126:

<div v-for="day in weekdayPatterns" class="data-row">
  <span class="data-row-label">{{ day.label }}</span>
  <div class="flex items-center gap-2 flex-1 mx-4" role="img" :aria-label="…">
    <div class="chart-bar h-3" :style="{ width: Math.max(4,(day.count/maxCigsPerDay)*100)+'%' }"></div>
  </div>
  <span class="data-row-value">{{ day.count }}</span>
</div>
  • .data-row { display:flex; justify-content:space-between } + flex-1 mx-4 on the bar container.
  • data-row-label has no fixed width → mx-4 offset is relative to label end, so bar left edges don't line up when labels differ in length (i18n: Mo vs Wednesday, Montag, etc.).
  • Count column also space-between → counts don't line up vertically.
  • weekdayPatterns is last 7 days from heatData.counts.slice(-7) mapped to locale labels (diagrams.weekday_*), so order/labels vary.

Expected behavior #

Use a fixed grid so label / bar / count each have pinned columns:

<div class="grid grid-cols-[5rem_1fr_2.5rem] items-center gap-2 py-2 border-t border-base-300 first:border-t-0">
  <span class="data-row-label text-left truncate">{{ day.label }}</span>
  <div class="flex items-center" role="img" :aria-label="…">
    <div class="chart-bar h-3" :style="{ width: … }"></div>
  </div>
  <span class="data-row-value text-right">{{ day.count }}</span>
</div>

Alternatives: grid-cols-[80px_1fr_40px] or grid-cols-[6rem_1fr_3rem] — pick one that fits longest i18n label at 0.8125rem.

  • Bar h-3, bg-primary, width Math.max(4, (day.count/maxCigsPerDay)*100)+'%' stays.
  • Keep role="img" + aria-label and aria-hidden on count.
  • Works at all widths, no shift between locales.

Files to touch #

  • pages/diagrams.vue:114-126 — Weekday Patterns template
  • assets/css/marathon-components.css — consider a .data-row-grid helper if reused elsewhere

Acceptance criteria #

How to test #

  1. Open /diagrams → inspect Weekday Patterns → toggle i18n locale (or temporarily hardcode long label like Wednesday) → bars must not move.
  2. Measure: left edge of each .chart-bar parent should be identical x.
  3. Resize 320→1280 → alignment holds.
Sign up or Sign in to add to the discussion.