-
-
Notifications
You must be signed in to change notification settings - Fork 635
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
feat: add config.numberFormatType
for using custom formatter with config.numberFormat
#8228
Conversation
da778ec
to
cbcb045
Compare
src/compile/format.ts
Outdated
@@ -121,7 +138,11 @@ export function formatCustomType({ | |||
}) { | |||
field ??= fieldToFormat(fieldOrDatumDef, expr, normalizeStack); | |||
|
|||
if (isFieldDef(fieldOrDatumDef) && isBinning(fieldOrDatumDef.bin)) { | |||
if ( | |||
field !== 'datum.value' && // For axis/legend, we can't correct know the end of the bin from `datum` |
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.
It turns out that this part of the code always trigger crashes if I don't add field !== 'datum.value'
-- see this example
8762532
to
9fa3563
Compare
565f8ab
to
3a21d8a
Compare
src/config.ts
Outdated
@@ -145,10 +145,22 @@ export interface VLOnlyConfig<ES extends ExprRef | SignalRef> { | |||
fieldTitle?: 'verbal' | 'functional' | 'plain'; | |||
|
|||
/** | |||
* D3 Number format for guide labels and text marks. For example `"s"` for SI units. Use [D3's number format pattern](https://github.com/d3/d3-format#locale_format). | |||
* If numberFormatType is not specified or is `"format"`, |
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.
* If numberFormatType is not specified or is `"format"`, | |
* If `numberFormatType` is not specified or is `"format"`, |
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.
I'm very confused by the special string "format"
here. Where is this coming from?
🚀 PR was released in |
…config.numberFormat` (vega#8228) Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
add
config.numberFormatType
for using custom formatter with config.numberFormat (just like there isformatType
forformat
)We can add
timeFormatType
later, but I think it's hairier so I wanna handle numberFormatType first.You can see that the example added originally treats
1.0
as D3's format. (But with the code changes, it now treats1.0
as a parameter ofpow
.)📦 Published PR as canary version:
5.2.1--canary.8228.a549581.0
✨ Test out this PR locally via:
npm install vega-lite@5.2.1--canary.8228.a549581.0 # or yarn add vega-lite@5.2.1--canary.8228.a549581.0