Skip to content

Add chart tooltip with formatted values (#211) - #264

Merged
arisu6804 merged 1 commit into
RemitFlow:mainfrom
Hollujay:feat/211-chart-tooltip-formatted-values
Jul 22, 2026
Merged

Add chart tooltip with formatted values (#211)#264
arisu6804 merged 1 commit into
RemitFlow:mainfrom
Hollujay:feat/211-chart-tooltip-formatted-values

Conversation

@Hollujay

@Hollujay Hollujay commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an interactive tooltip to the chart component that displays formatted values when hovering over bars. The tooltip shows the numeric value (optionally formatted via a formatValue callback) and an optional label for each data point.

Changes

src/components/Chart.jsx

  • Added hoveredIndex state to track which bar is being hovered
  • Added formatValue prop — a function that receives a data item and returns a formatted string for the tooltip
  • Added onMouseEnter/onMouseLeave handlers on each <rect> bar
  • Hovered bar uses a darker shade (#4f46e5) for visual feedback
  • Renders a role="tooltip" element centered above the hovered bar, with formatted value and optional label

src/components/Chart.css

  • Added .chart-wrapper for absolute positioning context
  • Added .chart-bar with pointer cursor and smooth fill transition
  • Added .chart-tooltip positioned above the bars, styled consistently with the existing Tooltip.css
  • Added .chart-tooltip-value (bold) and .chart-tooltip-label (muted, text-overflow ellipsis) sub-elements
  • Added prefers-contrast: more media query override matching existing patterns

src/components/Chart.stories.jsx (new)

  • Storybook stories for Default, WithFormattedValues, and SingleBar variants

src/pages/Transfers.jsx

  • Passes formatValue={(d) => formatAmount(d.value, d.currency)} to format transfer amounts as currency
  • Data items now include label (recipient) and currency for richer tooltip display

test/components/Chart.test.jsx

  • 6 tests covering: title rendering, bar count, tooltip show/hide on hover, raw value display, formatted value display, and label display.

Closes #211

@arisu6804

Copy link
Copy Markdown
Contributor

LGTM — clean work, merging! 🚀

@arisu6804
arisu6804 merged commit b982f06 into RemitFlow:main Jul 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a chart tooltip with formatted values

2 participants