-
Notifications
You must be signed in to change notification settings - Fork 621
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
fix: add support for formatType: "utc" #9265
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ import {TimeUnit} from './../timeunit'; | |
import {datumDefToExpr} from './mark/encode/valueref'; | ||
|
||
export function isCustomFormatType(formatType: string) { | ||
return formatType && formatType !== 'number' && formatType !== 'time'; | ||
return formatType && formatType !== 'number' && formatType !== 'time' && formatType !== 'utc'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use it here. |
||
} | ||
|
||
function customFormatExpr(formatType: string, field: string, format: string | Dict<unknown>) { | ||
|
@@ -227,7 +227,10 @@ export function guideFormatType( | |
fieldOrDatumDef: FieldDef<string> | DatumDef<string>, | ||
scaleType: ScaleType | ||
) { | ||
if (formatType && (isSignalRef(formatType) || formatType === 'number' || formatType === 'time')) { | ||
if ( | ||
formatType && | ||
(isSignalRef(formatType) || formatType === 'number' || formatType === 'time' || formatType === 'utc') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here (possible other places as well). |
||
) { | ||
return formatType; | ||
} | ||
if (isFieldOrDatumDefForTimeFormat(fieldOrDatumDef) && scaleType !== 'time' && scaleType !== 'utc') { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,6 +356,7 @@ describe('Format', () => { | |
it('should return existing format type', () => { | ||
expect(guideFormatType('number', {field: ' foo', type: 'quantitative'}, 'ordinal')).toBe('number'); | ||
expect(guideFormatType('time', {field: ' foo', type: 'quantitative'}, 'ordinal')).toBe('time'); | ||
expect(guideFormatType('utc', {field: ' foo', type: 'quantitative'}, 'ordinal')).toBe('utc'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this test the new code? I thought it's for nominal. |
||
}); | ||
|
||
it('should return utc for utc time units', () => { | ||
|
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.
We use
formatType === 'time' || formatType === 'utc'
quite often. Can we pull it out into a reusable method?