From d0206b7a4db1c3ba00220d26973a473fb168cb00 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Sun, 21 Nov 2021 11:33:04 -0500 Subject: [PATCH 1/3] fix: support utc formatting for ordinal data --- src/compile/format.ts | 2 +- test/compile/format.test.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/compile/format.ts b/src/compile/format.ts index 20f49f5103..bbc645a37b 100644 --- a/src/compile/format.ts +++ b/src/compile/format.ts @@ -160,7 +160,7 @@ export function guideFormatType( return formatType; } if (isFieldOrDatumDefForTimeFormat(fieldOrDatumDef) && scaleType !== 'time' && scaleType !== 'utc') { - return 'time'; + return isFieldDef(fieldOrDatumDef) && normalizeTimeUnit(fieldOrDatumDef?.timeUnit)?.utc ? 'utc' : 'time'; } return undefined; } diff --git a/test/compile/format.test.ts b/test/compile/format.test.ts index 0b93dae8c5..8c935585a2 100644 --- a/test/compile/format.test.ts +++ b/test/compile/format.test.ts @@ -1,5 +1,5 @@ import {vgField} from '../../src/channeldef'; -import {formatSignalRef, numberFormat, timeFormatExpression} from '../../src/compile/format'; +import {formatSignalRef, guideFormatType, numberFormat, timeFormatExpression} from '../../src/compile/format'; import {defaultConfig} from '../../src/config'; import {NOMINAL, ORDINAL, QUANTITATIVE, TEMPORAL} from '../../src/type'; @@ -130,4 +130,17 @@ describe('Format', () => { }); }); }); + + describe('guideFormatType()', () => { + 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'); + }); + + it('should return utc for utc time units', () => { + expect( + guideFormatType('', {field: ' foo', type: 'ordinal', timeUnit: {utc: true, unit: 'year'}}, 'ordinal') + ).toBe('utc'); + }); + }); }); From 33f6d02abd1101892a60086c22b2bd1daeb3e6b6 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 21 Nov 2021 16:34:48 +0000 Subject: [PATCH 2/3] chore: update TOC [CI] --- site/_includes/docs_toc.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/site/_includes/docs_toc.md b/site/_includes/docs_toc.md index 35cfa70926..e658f7baf1 100644 --- a/site/_includes/docs_toc.md +++ b/site/_includes/docs_toc.md @@ -287,7 +287,6 @@ - [Nominal]({{site.baseurl}}/docs/type.html#nominal) - [GeoJSON]({{site.baseurl}}/docs/type.html#geojson) - [Value]({{site.baseurl}}/docs/value.html) - - [Examples]({{site.baseurl}}/docs/value.html#examples) - [Projection]({{site.baseurl}}/docs/projection.html) - [Documentation Overview]({{site.baseurl}}/docs/projection.html#documentation-overview) - [Projection Properties]({{site.baseurl}}/docs/projection.html#projection-properties) @@ -330,7 +329,6 @@ - [Using Parameters]({{site.baseurl}}/docs/parameter.html#using-parameters) - [Selection Configuration]({{site.baseurl}}/docs/parameter.html#config) - [Value]({{site.baseurl}}/docs/value.html) - - [Examples]({{site.baseurl}}/docs/value.html#examples) - [Expr]({{site.baseurl}}/docs/parameter.html) - [Documentation Overview]({{site.baseurl}}/docs/parameter.html#documentation-overview) - [Defining a Parameter]({{site.baseurl}}/docs/parameter.html#defining-a-parameter) From 1d4424634ccfd65eeb8598b7738a43f9a8b7815e Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 21 Nov 2021 16:36:08 +0000 Subject: [PATCH 3/3] chore: update examples [CI] --- examples/compiled/time_parse_utc.png | Bin 1592 -> 1381 bytes examples/compiled/time_parse_utc.svg | 2 +- examples/compiled/time_parse_utc.vg.json | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/compiled/time_parse_utc.png b/examples/compiled/time_parse_utc.png index f346b1a5c1123c289cfd045230f61c15299f12c9..a5f60d2e42fe362e1835551a099982208ccd807e 100644 GIT binary patch delta 1344 zcmV-G1;6^Z4CM-tHh&sPL_t(&f$f@4Op|9E$3L_bv<*#w##oDNF+gcesKIJ72NR94 zEK+xX?W~C-#zYJ!dQ;+Ia6r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Uss!4O8I4BoI__H~VC7x8a)tW(dOABhDJ?ApKqix+R;x)%OIwr#molQ~ zc@~R>SFc{pc}4# \ No newline at end of file +00:00time \ No newline at end of file diff --git a/examples/compiled/time_parse_utc.vg.json b/examples/compiled/time_parse_utc.vg.json index 87a0feffe6..3971c5a8f4 100644 --- a/examples/compiled/time_parse_utc.vg.json +++ b/examples/compiled/time_parse_utc.vg.json @@ -71,7 +71,7 @@ "format": { "signal": "timeUnitSpecifier([\"hours\"], {\"year-month\":\"%b %Y \",\"year-month-date\":\"%b %d, %Y \"})" }, - "formatType": "time", + "formatType": "utc", "labelOverlap": true, "zindex": 0 }