Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

@@ -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');
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.

@@ -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));
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?

@@ -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';
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