Repository navigation
feat(graph): darken gridlines at every 20 contributions - #7
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fordrawevents and addsct-grid-majorto gridlines whose tick valuedata.axis.ticks[data.index]is numeric and% 20 === 0; wire it intogetOptions()viaplugins: [majorGridPlugin]. Chartist 0.11.4 (bundled vianode-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-gridrule. 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— reusemajorGridPluginin the test options so theutils.test.tssnapshot exercises the plugin (tick-0 gridline gains the class).utils.test.ts.snap(tick-0 gridline gainsct-grid-major) andsvgs.test.ts.snap(new CSS rule in the graphSvg snapshots; tick-0 gridline gains the class in the chart snapshot).Verification
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)
Chartist.FixedScaleAxisgrid_major_colorquery param (reuses the existing themecolor)&& value > 0)Checklist
npm test: 13/13)Refs chicks-net/chicks-projects#129 (auto-close won't fire across owners — close manually after live verification)