-
Notifications
You must be signed in to change notification settings - Fork 565
Add user-configurable toggle for 'nice' scale on charts #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
|
@copilot nice work. I just realized this is probably more general than bar charts - can you rename? |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Renamed to |
| globalAggregateMaxExtentScaledSignal: string; | ||
| niceScale: boolean; | ||
| niceScale: boolean | SignalRef; | ||
| niceScaleDisplay?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - lets not have this niceScaleDisplay passed through here. Implement this as SignalNames.ZProportion does: see specViewOptions.language.zScaleProportion in packages\sanddance-specs\src\signals.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented globally in textSignals() following the ZProportion pattern in commit cbed0ed. The signal is now created globally and accesses the language string directly from specViewOptions.language.scaleNice without passing through props.
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
| globalAggregateMaxExtentSignal: string; | ||
| globalAggregateMaxExtentScaledSignal: string; | ||
| niceScale: boolean; | ||
| niceScale: boolean | SignalRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this should be deleted and the nice scale should be added to GlobalScope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit a9c3182. The niceScale property has been removed from AggregateContainerProps and the signal is now accessed from GlobalScope.signals.scaleNice.
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Overview
Fixes #22 by adding a user-controllable checkbox to enable/disable the "nice" scale feature on charts. Previously, this was hardcoded to
truefor bar charts andfalsefor strips and treemap charts, giving users no control over axis rounding behavior.What Changed
The "nice" scale property in Vega rounds axis tick values to human-friendly numbers (e.g., 0, 10, 20, 30 instead of 0, 9.3, 18.6, 27.9). This improves readability but sacrifices precision. This PR converts the hardcoded boolean into a user-configurable global signal that appears as a checkbox in the Chart Options panel.
Implementation Details
Signal Architecture
ScaleNiceto theSignalNamesconstants (renamed fromBarChartNicefor generality)true(maintains backward compatibility)textSignals()function, following the pattern ofZProportionGlobalScope.signalsfor centralized accessspecViewOptions.language.scaleNicewithout prop passingspecCapabilitiesfor bothbarchartVandbarchartH(excluded forsum-strip-percentlayout where it doesn't apply)Type System Updates
scaleNicetoGlobalSignalsinterface in globalScope.tsSpecLanguageinterface withscaleNicepropertyniceScaleproperty fromAggregateContainerProps(now accessed from GlobalScope)User Interface
Affected Chart Types
true)false)false)Testing
All existing tests pass without modification, confirming backward compatibility:
Benefits
ZGroundedandZProportionOriginal prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.