Skip to content

fix(shopping): draw the Shopping page's charts in the theme's ink, as Mentions' trend does - #1585

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

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

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

The Shopping page (Product Visibility) draws its two charts in the theme's ink, as the Mentions trend does. The user asked for it. Before, they used --chart-2.

One file: web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.tsx.

  • Card rate by platform: the bars fill with var(--primary).
  • Your shopping presence: a ComposedChart in place of the LineChart.
    • Your cards is an area: the --primary stroke, a fill fading from 0.18 to 0 (shoppingTrendFill), no dots, and an active dot (r 4) on hover.
    • All cards is a dashed line (4 3) in --muted-foreground.

Left as they are on purpose: the merchant colours in Where AI sends shoppers (eBay's blue among them). That's a palette chosen per destination for contrast and colour blindness, not the theme's series colour.

Written by a side session working on the user's behalf, and handed over for the browser check, the full checks and this PR.

Related issue

None. User request.

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 Product Visibility for a brand with shopping cards:

  • the card-rate bars and the "Your cards" area are in the theme's ink;
  • "All cards" is a dashed grey line;
  • hovering shows the dot.

Checked in the browser at 1024 px, light and dark, with this branch's web and the dev DB. Main's 00267 was applied there first: dev lacked it, so the page couldn't read its overview.

Seen in passing, and unchanged here: the card-rate chart labels every other platform under its bars.

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 and yarn build.

  • yarn test: 4,125 of 4,126 passed. The one that failed, new-content-dialog.test.tsx, is untouched here and timed out under load. Run alone, its 42 tests pass.

🤖 Generated with Claude Code

… Mentions' trend does

The Card rate bars and the cards trend were blue (--chart-2, --chart-4).
They now follow Mentions & sentiment over time: the theme's primary (black
on light, near-white on dark), and the trend's own series as an area with
the same fading fill. All cards, the second series, is a grey dashed line,
told apart by lightness and line rather than hue. No dots on the lines,
an active dot on hover, as in Mentions.

The Where AI sends shoppers split keeps its own colours: one per
destination, checked for contrast and colour-blind separation.

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:

  • Contrast, light and dark.
    • --primary is oklch(0.205) on light and oklch(0.87) on dark (globals.css:59, :96). --muted-foreground is 0.556 and 0.708 (:64, :101). The charts sit on var(--card).
    • The bars and "Your cards" stand at 17.9:1 against the card on light and 12.1:1 on dark. "All cards" stands at 4.7:1 on light and 6.9:1 on dark.
    • That's above 3:1 for the marks, and above 4.5:1 for the tooltip and legend text drawn in those colours.
  • Tooltip and legend. Recharts colours each row with the series' stroke, not the fill (getLegendItemColor(stroke, fill)). So "Your cards" reads in ink, not in the gradient's url(#…), and "All cards" reads in grey, on the card's background.
  • The area and the dashed line.
    • Own cards never exceed all cards, so the dashed line runs above the area, and it's drawn after it.
    • The gradient id is unique on the page. The page draws one trend (page.tsx:1138), and Mentions uses mentionsTrendFill.
    • The trend is zero-filled to 30 days (shopping.ts:178-188), so dropping the dots never leaves a lone point invisible.
    • It matches Mentions' trend (_trend-chart.tsx:80-83 and its Area): the same stroke, the same 0.18→0 fill, no dots, and an active dot of r 4.
  • Tests. No test reads these charts' colours or chart types, and nothing tests shopping_charts.tsx. The Where AI sends shoppers colours are unchanged.
  • Merge. One commit on 55b49e7 (main), so it merges as is.
  • Before the API deploy. Web only. Nothing depends on the API.

Follow-up:

  1. The legend doesn't show the dash (shopping_charts.tsx:109, :120).
    • Recharts' default legendType="line" draws the same solid icon for both series and ignores strokeDasharray.
    • On dark, ink (0.87) and grey (0.708) are only 1.75:1 apart, so the two icons are hard to tell apart.
    • Fix: add legendType="plainline" to the Line. Recharts then draws its icon with the series' strokeDasharray. Add it to the Area too, so both icons have the same shape.

@gkhngyk
gkhngyk merged commit 5bbd162 into ansvisor:main Oct 27, 2026
6 checks passed
gkhngyk pushed a commit that referenced this pull request Oct 27, 2026
…gend (#1597)

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 #1585.

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