-
Notifications
You must be signed in to change notification settings - Fork 620
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?
Conversation
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 don't have cycles to look into this in detail but it seems like in the previous pull request there was something intentional about distinguishing utc and time: https://github.com/vega/vega-lite/pull/7815/files#diff-df52deef186d568b5237ce82ff44bba2a0bed4e69430fae0e55b3b2876068414R140. This needs more careful testing as we want to make sure that we apply the right formatting for the right scale type. Please add more tests and I'd like another set of eyes on this.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test the new code? I thought it's for nominal.
@@ -1338,7 +1338,7 @@ export function channelCompatibility( | |||
*/ | |||
export function isFieldOrDatumDefForTimeFormat(fieldOrDatumDef: FieldDef<string> | DatumDef): boolean { | |||
const {formatType} = getFormatMixins(fieldOrDatumDef); | |||
return formatType === 'time' || (!formatType && isTimeFieldDef(fieldOrDatumDef)); | |||
return formatType === 'time' || formatType === 'utc' || (!formatType && isTimeFieldDef(fieldOrDatumDef)); |
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?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
We could use it here.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
and here (possible other places as well).
Fixes #7795 for nominal fields