Repository navigation
Padded scale for LineChart axes - #1632
Conversation
|
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
left a comment
There was a problem hiding this comment.
Thanks Trevor. As with last time I made a few changes on the branch before approving:
- Field
fractionofPaddedrenamed tomargin, 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 withAuto - Checks on the
Paddedmargin andEverystep moved from the reflection layer (which maps Fluid datatypes to the corresponding PureScript datatyype) intodomainandtickValues; 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!
No description provided.