Skip to content

Commit

Permalink
fix: describe how to set a custom scheme by setting the range, reverts
Browse files Browse the repository at this point in the history
…#9262 (#9266)

reverts #9262
fixes #9022

These two seem to be equivalent so let's officially support only the
simpler one.

<img width="353" alt="Screenshot 2024-02-18 at 10 27 34"
src="https://github.com/vega/vega-lite/assets/589034/36ec606c-2fbd-4777-9442-c13536ecc8bd">

---------

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
domoritz and GitHub Actions Bot authored Mar 19, 2024
1 parent 3e0543b commit e6af641
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 1 addition & 7 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21942,20 +21942,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

0 comments on commit e6af641

Please sign in to comment.