Skip to content

Padded scale for LineChart axes - #1632

Merged
rolyp-claude-bot merged 8 commits into
fluid-1.1from
1626-padded-scale
Nov 3, 2026
Merged

rolyp-claude-bot merged 8 commits into
fluid-1.1from
1626-padded-scale

Conversation

@trevormuwonge

Copy link
Copy Markdown
Collaborator

No description provided.

@trevormuwonge

Copy link
Copy Markdown
Collaborator Author

Padded(fraction) adds a padded range to Scale: the data extent widened by fraction times its width at both ends, so Padded(0.05) matches the paper's axes. It is a new case alongside Auto, FromZero and Fixed, so existing programs and charts are unchanged (SVGs compared before and after).

It is in Scale.purs (domain). No JavaScript changed, since D3.js only receives the resolved interval. I read your "JS code for Scale" as library code for Scale; tell me if you meant otherwise.

A zero-width extent is widened by the fraction of its absolute value, or of 1 when it is zero. A negative fraction is rejected when the view is built; no test reaches that.

Tests: a fourth chart on /co2, where Padded(0.05) with ticks every 5 gives 310 to 435 against 315 to 430 for Auto, checked on the rendered tick labels. Three deliberate breaks each failed it.

Timing: at 584 points Padded renders the same SVG as Fixed with the equivalent literal limits, with load time and heap close to it in headless Chrome.

@rolyp I haven't tested the full article page, which crashed when the limits were computed in the program. That needs a release, so could you release once this is merged? The parked article branch is waiting on it. This adds a feature after 1.1.0, so milestone and branch are your call.

@rolyp rolyp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Trevor. As with last time I made a few changes on the branch before approving:

  • Field fraction of Padded renamed to margin, which makes a bit more sense
  • Zero-width fallback removed from domain, because the padding then depended on the distance of the value from 0; constant data now gives a zero-width domain, as with Auto
  • Checks on the Padded margin and Every step moved from the reflection layer (which maps Fluid datatypes to the corresponding PureScript datatyype) into domain and tickValues; that keeps reflection purely mechanical
  • Error messages reworded a bit

So axes.fld in your repo can use Padded(0.05) instead of computing the limits itself. I also pushed some graph performance improvements to 1.1, and maximum and minimum should be faster too. They're now called min and max, though.

Those performance improvements don't affect the bigger question of how to make the graph performance; that's an open issue that I've parked for now and will come back to after the PLDI deadline next Friday.

Thanks for the PR!

@rolyp-claude-bot
rolyp-claude-bot merged commit 4cff422 into fluid-1.1 Nov 3, 2026
3 checks passed
@rolyp-claude-bot
rolyp-claude-bot deleted the 1626-padded-scale branch November 3, 2026 14:40
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.

3 participants