Skip to content

Conversation

@AndrewRybka
Copy link

Fixes #7795 for nominal fields

Copy link
Member

@domoritz domoritz left a 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.

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');
Copy link
Member

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.

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));
Copy link
Member

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?


export function isCustomFormatType(formatType: string) {
return formatType && formatType !== 'number' && formatType !== 'time';
return formatType && formatType !== 'number' && formatType !== 'time' && formatType !== 'utc';
Copy link
Member

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')
Copy link
Member

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).

@domoritz domoritz requested a review from a team February 18, 2024 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTC date labels do not display properly, seem to be using local browser timezone

2 participants