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: describe how to set a custom scheme by setting the range, reverts #9262 #9266

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21928,20 +21928,14 @@
{
"$ref": "#/definitions/ColorScheme"
},
{
"items": {
"type": "string"
},
"type": "array"
},
{
"$ref": "#/definitions/SchemeParams"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "A string indicating a color [scheme](https://vega.github.io/vega-lite/docs/scale.html#scheme) name (e.g., `\"category10\"` or `\"blues\"`) or a [scheme parameter object](https://vega.github.io/vega-lite/docs/scale.html#scheme-params).\n\nDiscrete color schemes may be used with [discrete](https://vega.github.io/vega-lite/docs/scale.html#discrete) or [discretizing](https://vega.github.io/vega-lite/docs/scale.html#discretizing) scales. Continuous color schemes are intended for use with color scales.\n\nFor the full list of supported schemes, please refer to the [Vega Scheme](https://vega.github.io/vega/docs/schemes/#reference) reference."
"description": "A string indicating a color [scheme](https://vega.github.io/vega-lite/docs/scale.html#scheme) name (e.g., `\"category10\"` or `\"blues\"`) or a [scheme parameter object](https://vega.github.io/vega-lite/docs/scale.html#scheme-params).\n\nDiscrete color schemes may be used with [discrete](https://vega.github.io/vega-lite/docs/scale.html#discrete) or [discretizing](https://vega.github.io/vega-lite/docs/scale.html#discretizing) scales. Continuous color schemes are intended for use with color scales.\n\nTo set a custom scheme, instead set the list of values [as the scale range](https://vega.github.io/vega-lite/docs/scale.html#2-setting-the-range-property-to-an-array-of-valid-css-color-strings).\n\nFor the full list of supported schemes, please refer to the [Vega Scheme](https://vega.github.io/vega/docs/schemes/#reference) reference."
},
"type": {
"$ref": "#/definitions/ScaleType",
Expand Down
2 changes: 1 addition & 1 deletion src/compile/scale/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export function parseRangeForChannel(channel: ScaleChannel, model: UnitModel): E
return makeImplicit(d);
}

function parseScheme(scheme: Scheme | SignalRef | string[]): RangeScheme {
function parseScheme(scheme: Scheme | SignalRef): RangeScheme {
if (isExtendedScheme(scheme)) {
return {
scheme: scheme.name,
Expand Down
6 changes: 4 additions & 2 deletions src/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export type Domain =

export type Scheme = string | SchemeParams;

export function isExtendedScheme(scheme: Scheme | SignalRef | string[]): scheme is SchemeParams {
export function isExtendedScheme(scheme: Scheme | SignalRef): scheme is SchemeParams {
return !isString(scheme) && !!scheme['name'];
}

Expand Down Expand Up @@ -609,9 +609,11 @@ export interface Scale<ES extends ExprRef | SignalRef = ExprRef | SignalRef> {
*
* Discrete color schemes may be used with [discrete](https://vega.github.io/vega-lite/docs/scale.html#discrete) or [discretizing](https://vega.github.io/vega-lite/docs/scale.html#discretizing) scales. Continuous color schemes are intended for use with color scales.
*
* To set a custom scheme, instead set the list of values [as the scale range](https://vega.github.io/vega-lite/docs/scale.html#2-setting-the-range-property-to-an-array-of-valid-css-color-strings).
*
* For the full list of supported schemes, please refer to the [Vega Scheme](https://vega.github.io/vega/docs/schemes/#reference) reference.
*/
scheme?: ColorScheme | string[] | SchemeParams | ES;
scheme?: ColorScheme | SchemeParams | ES;

/**
* The alignment of the steps within the scale range.
Expand Down