Skip to content

feat(graph): darken gridlines at every 20 contributions - #7

Merged
chicks-net merged 1 commit into
deployfrom
feat/major-gridlines
Oct 13, 2026
Merged

chicks-net merged 1 commit into
deployfrom
feat/major-gridlines

Conversation

@chicks-net

Copy link
Copy Markdown
Member

Summary

Emphasize Y-axis gridlines at tick values that are multiples of 20 (major/minor grid pattern) using the existing theme color — no new query params. Implements chicks-net/chicks-projects#129.

Changes

  • src/GraphCards.ts — add and export a Chartist plugin (majorGridPlugin) that listens for draw events and adds ct-grid-major to gridlines whose tick value data.axis.ticks[data.index] is numeric and % 20 === 0; wire it into getOptions() via plugins: [majorGridPlugin]. Chartist 0.11.4 (bundled via node-chartist) initializes plugins before creating the chart, so the listener catches every gridline. X-axis day ticks are strings, so the numeric check skips them. The tick-0 baseline darkens too (0 % 20 === 0), which reads as an intentional solid floor.
  • src/styles/graphStyle.ts — add .ct-grid.ct-grid-major { stroke-opacity: 0.85; stroke-dasharray: none; } after the .ct-grid rule. The doubled-class selector out-specifies .ct-grid; inline SVG attributes would lose to the existing CSS rule, so a class is required.
  • __test__/fakeInputs.ts — reuse majorGridPlugin in the test options so the utils.test.ts snapshot exercises the plugin (tick-0 gridline gains the class).
  • Snapshots — regenerated utils.test.ts.snap (tick-0 gridline gains ct-grid-major) and svgs.test.ts.snap (new CSS rule in the graphSvg snapshots; tick-0 gridline gains the class in the chart snapshot).

Verification

  • Full suite green locally: 13/13 tests, 4/4 snapshots; prettier/eslint clean on changed files.
  • Local smoke test against node dist/main.js:
    • ashutosh00710 (window max < 20): only the zero baseline darkens, as predicted in the issue.
    • sindresorhus (step-50 scale: ticks 0/50/100/…/400): exactly 5 major lines (0, 100, 200, 300, 400) — the irregularity accepted in the issue's known-limitations section.

Deferred (per issue)

  • Forcing ticks to multiples of 20 via Chartist.FixedScaleAxis
  • A grid_major_color query param (reuses the existing theme color)
  • Excluding the zero baseline from darkening (&& value > 0)

Checklist

  • Followed the contributing guidelines
  • Checked for other open PRs with the same change
  • Submission passes tests (npm test: 13/13)
  • Linted code locally (prettier + eslint clean on changed files)
  • Explanation of changes and why included
  • Tests updated as applicable (snapshot coverage for the new class)
  • Successfully ran tests with changes locally

Refs chicks-net/chicks-projects#129 (auto-close won't fire across owners — close manually after live verification)

Every gridline was styled identically (faint, dashed), making it hard to
eyeball where contribution counts cross the 20/40/60 thresholds. Emphasize
gridlines whose Y tick value is a multiple of 20 with a major/minor grid
pattern using the existing theme color — no new query params.

- Add a Chartist plugin (majorGridPlugin) in src/GraphCards.ts that
  listens for `draw` events and adds a ct-grid-major class to gridlines
  whose tick value is numeric and divisible by 20; wire it into
  getOptions() via plugins: [majorGridPlugin]
- Add .ct-grid.ct-grid-major CSS rule (stroke-opacity 0.85, solid) after
  .ct-grid in src/styles/graphStyle.ts — the doubled-class selector
  out-specifies .ct-grid; inline SVG attributes would lose to the CSS rule
- Reuse the plugin in the utils test options so the snapshot suite covers
  the new class; regenerate utils/svgs snapshots accordingly

Known limitation (accepted): with auto-scaled step 50 only 100/200/300/400
darken alongside the 0 baseline; forcing ticks to multiples of 20 via
FixedScaleAxis is deferred.

Implements chicks-net/chicks-projects#129
@chicks-net
chicks-net merged commit 012d477 into deploy Oct 13, 2026
1 check passed
@chicks-net
chicks-net deleted the feat/major-gridlines branch October 13, 2026 23:15
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.

1 participant