Skip to content

fix(shopping): show the All cards line's dash in the trend chart's legend - #1597

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/shopping-chart-legend
Oct 27, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/shopping-chart-legend

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

A follow-up from #1585's approval. The trend chart's legend now shows the dash of the "All cards" line.

  • Recharts' default legend icon (legendType="line") draws the same solid icon for both series and ignores strokeDasharray.
  • On dark, the ink (0.87) and the grey (0.708) are only 1.75:1 apart, so the two icons were hard to tell apart.
  • Both series now use legendType="plainline". Recharts then draws each icon with its own series' dash: a dashed "All cards" beside a solid "Your cards", the same shape for both.

Related issue

Follow-up to #1585.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

Open Shopping. Under "Your shopping presence — last 30 days", the legend's "All cards" icon is dashed, and "Your cards" is solid.

Checked in the browser at 1024 px, light and dark, with this branch's web and the dev DB.

  • The legend's icons are <line>s: "All cards" has stroke-dasharray="4 3", "Your cards" has none.
  • They read apart in both themes.
  • Nothing scrolls sideways.

No test renders the chart: Recharts draws nothing at jsdom's zero size, and the change is the legend's look only.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run in web/:

  • yarn format, yarn lint (0 errors), yarn typecheck;
  • yarn test (4,138 tests);
  • yarn build.

🤖 Generated with Claude Code

…gend

Recharts' default legend icon is a solid line, so "Your cards" and the
dashed "All cards" looked alike. On dark they're only 1.75:1 apart.
Both series now use legendType="plainline", which draws each icon with
its series' own dash. A follow-up from ansvisor#1585.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups.

What I checked:

  • Own change. One commit on 5bbd162: legendType="plainline" on both series of ShoppingTrendChartView (shopping_charts.tsx:113, :126). It merges clean on main (15b5b5f), and with #1596 and #1603. No other open PR touches the file.
  • Recharts. With the installed 3.8.0, a plainline icon is a <line> drawn with the series' strokeDasharray (DefaultLegendContent), and both Area and Line hand their own props to the legend as its payload. So "All cards" gets 4 3 and "Your cards" none. <Legend> sets no iconType, so nothing overrides it.
  • Rendered. I rendered ShoppingTrendChartView with width={600} in jsdom: at this head the legend has two <line> icons, one with stroke-dasharray="4 3". With main's chart they are two <path>s with no dash.
  • Before the API deploy. Web only, the legend's look only.

Follow-ups:

  1. A test can cover this. The view takes a fixed width, so Recharts does draw it in jsdom (only ResponsiveContainer measures zero there). A test that renders <ShoppingTrendChartView width={600} data={…} /> and expects two .recharts-legend-icon elements, exactly one with stroke-dasharray="4 3", passes here and fails on main.
  2. The series names aren't in en.json (shopping_charts.tsx:59, :112, :124, unchanged here). "Card rate", "Your cards" and "All cards" are literals, and they show in the legend and the tooltips. Pass them in as props from the page's translations, as its other labels are.

@gkhngyk
gkhngyk merged commit 6055b0b into ansvisor:main Oct 27, 2026
6 checks passed
gkhngyk pushed a commit that referenced this pull request Oct 28, 2026
…nd test the trend legend's dash (#1670)

Follow-ups from #1597.

- "Card rate", "Your cards" and "All cards" were literals in
  shopping_charts.tsx, shown in the legend and the tooltips. They're now
  shopping.seriesCardRate / seriesOwnCards / seriesAllCards in en.json,
  passed in as props from the page's translations like its other labels.
- A test draws the trend chart at a fixed width (Recharts renders it in
  jsdom then) and expects two legend icons, exactly one dashed "4 3", with
  the names it was given. Without the All cards line's legendType the
  test fails.

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants