From ab0dca213408b07318926237541765ad8f9fa0fa Mon Sep 17 00:00:00 2001 From: "Weng, Chia-Ling" <75072960+ChiaLingWeng@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:55:19 +0000 Subject: [PATCH 1/3] doc: mark sequential scales as deprecated --- site/docs/encoding/scale.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/docs/encoding/scale.md b/site/docs/encoding/scale.md index 86673fb955..5e2f3586b7 100644 --- a/site/docs/encoding/scale.md +++ b/site/docs/encoding/scale.md @@ -207,6 +207,8 @@ Continuous scales map a continuous domain (numbers or dates) to a continuous out By default, Vega-Lite uses `"linear"` scales for quantitative fields and uses `"time"` scales for temporal fields for all [encoding channels](encoding.html#channel). +Note that for Vega-Lite ≥ 5.0, Sequential scales ([`"sequential"`](https://vega.github.io/vega/docs/scales/#sequential)) are deprecated: specifications should now use a linear (or log, etc.) scale with a color-valued range, rather than a sequential scale. + In addition to [`type`](#type), [`domain`](#domain), and [`range`](#range), continuous scales support the following properties: {% include table.html props="clamp,interpolate,nice,padding,zero" source="Scale" %} From ef524b5bdca67aec0fdb0157572b0ec3bef9a8d9 Mon Sep 17 00:00:00 2001 From: "Weng, Chia-Ling" <75072960+ChiaLingWeng@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:19:11 +0000 Subject: [PATCH 2/3] fix: deprecate sequential scales --- site/docs/encoding/scale.md | 2 -- src/compile/selection/scales.ts | 4 ++++ src/log/message.ts | 18 +++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/site/docs/encoding/scale.md b/site/docs/encoding/scale.md index 5e2f3586b7..86673fb955 100644 --- a/site/docs/encoding/scale.md +++ b/site/docs/encoding/scale.md @@ -207,8 +207,6 @@ Continuous scales map a continuous domain (numbers or dates) to a continuous out By default, Vega-Lite uses `"linear"` scales for quantitative fields and uses `"time"` scales for temporal fields for all [encoding channels](encoding.html#channel). -Note that for Vega-Lite ≥ 5.0, Sequential scales ([`"sequential"`](https://vega.github.io/vega/docs/scales/#sequential)) are deprecated: specifications should now use a linear (or log, etc.) scale with a color-valued range, rather than a sequential scale. - In addition to [`type`](#type), [`domain`](#domain), and [`range`](#range), continuous scales support the following properties: {% include table.html props="clamp,interpolate,nice,padding,zero" source="Scale" %} diff --git a/src/compile/selection/scales.ts b/src/compile/selection/scales.ts index d716bfa20e..23efb9627c 100644 --- a/src/compile/selection/scales.ts +++ b/src/compile/selection/scales.ts @@ -28,6 +28,10 @@ const scaleBindings: SelectionCompiler<'interval'> = { const scale = model.getScaleComponent(channel); const scaleType = scale ? scale.get('type') : undefined; + if (scaleType == "sequential") { + log.warn(log.message.SEQUENTIAL_SCALE_DEPRECATED) + } + if (!scale || !hasContinuousDomain(scaleType)) { log.warn(log.message.SCALE_BINDINGS_CONTINUOUS); continue; diff --git a/src/log/message.ts b/src/log/message.ts index 4f2cfd11d3..f23cba8f8e 100644 --- a/src/log/message.ts +++ b/src/log/message.ts @@ -82,6 +82,9 @@ export function selectionNotFound(name: string) { export const SCALE_BINDINGS_CONTINUOUS = 'Scale bindings are currently only supported for scales with unbinned, continuous domains.'; +export const SEQUENTIAL_SCALE_DEPRECATED = + 'Sequntial scales are deprecated. The available quantitative scale type values are linear, log, pow, sqrt, symlog, time and utc'; + export const LEGEND_BINDINGS_MUST_HAVE_PROJECTION = 'Legend bindings are only supported for selections over an individual field or encoding channel.'; export function cannotLookupVariableParameter(name: string) { @@ -179,9 +182,8 @@ export function missingFieldType(channel: Channel, newType: Type) { } export function droppingColor(type: 'encoding' | 'property', opt: {fill?: boolean; stroke?: boolean}) { const {fill, stroke} = opt; - return `Dropping color ${type} as the plot also has ${ - fill && stroke ? 'fill and stroke' : fill ? 'fill' : 'stroke' - }.`; + return `Dropping color ${type} as the plot also has ${fill && stroke ? 'fill and stroke' : fill ? 'fill' : 'stroke' + }.`; } export function relativeBandSizeNotSupported(sizeChannel: 'width' | 'height') { @@ -226,9 +228,8 @@ export function facetChannelDropped(channels: FacetChannel[]) { } export function discreteChannelCannotEncode(channel: Channel, type: Type) { - return `Using discrete channel "${channel}" to encode "${type}" field can be misleading as it does not encode ${ - type === 'ordinal' ? 'order' : 'magnitude' - }.`; + return `Using discrete channel "${channel}" to encode "${type}" field can be misleading as it does not encode ${type === 'ordinal' ? 'order' : 'magnitude' + }.`; } // MARK @@ -359,9 +360,8 @@ export function droppedDay(d: DateTime | DateTimeExpr) { } export function errorBarCenterAndExtentAreNotNeeded(center: ErrorBarCenter, extent: ErrorBarExtent) { - return `${extent ? 'extent ' : ''}${extent && center ? 'and ' : ''}${center ? 'center ' : ''}${ - extent && center ? 'are ' : 'is ' - }not needed when data are aggregated.`; + return `${extent ? 'extent ' : ''}${extent && center ? 'and ' : ''}${center ? 'center ' : ''}${extent && center ? 'are ' : 'is ' + }not needed when data are aggregated.`; } export function errorBarCenterIsUsedWithWrongExtent( From 9c2e8a50b39169ff9276a83d74ec0bc19bcbf3c3 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Fri, 19 Jan 2024 08:24:25 +0000 Subject: [PATCH 3/3] style: auto-formatting [CI] --- src/compile/selection/scales.ts | 4 ++-- src/log/message.ts | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/compile/selection/scales.ts b/src/compile/selection/scales.ts index 23efb9627c..ec68192b5e 100644 --- a/src/compile/selection/scales.ts +++ b/src/compile/selection/scales.ts @@ -28,8 +28,8 @@ const scaleBindings: SelectionCompiler<'interval'> = { const scale = model.getScaleComponent(channel); const scaleType = scale ? scale.get('type') : undefined; - if (scaleType == "sequential") { - log.warn(log.message.SEQUENTIAL_SCALE_DEPRECATED) + if (scaleType == 'sequential') { + log.warn(log.message.SEQUENTIAL_SCALE_DEPRECATED); } if (!scale || !hasContinuousDomain(scaleType)) { diff --git a/src/log/message.ts b/src/log/message.ts index f23cba8f8e..7d6826930e 100644 --- a/src/log/message.ts +++ b/src/log/message.ts @@ -182,8 +182,9 @@ export function missingFieldType(channel: Channel, newType: Type) { } export function droppingColor(type: 'encoding' | 'property', opt: {fill?: boolean; stroke?: boolean}) { const {fill, stroke} = opt; - return `Dropping color ${type} as the plot also has ${fill && stroke ? 'fill and stroke' : fill ? 'fill' : 'stroke' - }.`; + return `Dropping color ${type} as the plot also has ${ + fill && stroke ? 'fill and stroke' : fill ? 'fill' : 'stroke' + }.`; } export function relativeBandSizeNotSupported(sizeChannel: 'width' | 'height') { @@ -228,8 +229,9 @@ export function facetChannelDropped(channels: FacetChannel[]) { } export function discreteChannelCannotEncode(channel: Channel, type: Type) { - return `Using discrete channel "${channel}" to encode "${type}" field can be misleading as it does not encode ${type === 'ordinal' ? 'order' : 'magnitude' - }.`; + return `Using discrete channel "${channel}" to encode "${type}" field can be misleading as it does not encode ${ + type === 'ordinal' ? 'order' : 'magnitude' + }.`; } // MARK @@ -360,8 +362,9 @@ export function droppedDay(d: DateTime | DateTimeExpr) { } export function errorBarCenterAndExtentAreNotNeeded(center: ErrorBarCenter, extent: ErrorBarExtent) { - return `${extent ? 'extent ' : ''}${extent && center ? 'and ' : ''}${center ? 'center ' : ''}${extent && center ? 'are ' : 'is ' - }not needed when data are aggregated.`; + return `${extent ? 'extent ' : ''}${extent && center ? 'and ' : ''}${center ? 'center ' : ''}${ + extent && center ? 'are ' : 'is ' + }not needed when data are aggregated.`; } export function errorBarCenterIsUsedWithWrongExtent(