diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index ecd474da44..a3a05eca58 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -18672,7 +18672,7 @@ "description": "The spacing in pixels between sub-views of the composition operator. An object of the form `{\"row\": number, \"column\": number}` can be used to set different spacing values for rows and columns.\n\n__Default value__: Depends on `\"spacing\"` property of [the view composition configuration](https://vega.github.io/vega-lite/docs/config.html#view-config) (`20` by default)" }, "spec": { - "$ref": "#/definitions/Spec", + "$ref": "#/definitions/NonNormalizedSpec", "description": "A specification of the view that gets repeated." }, "title": { @@ -18700,6 +18700,9 @@ ], "type": "object" }, + "NonNormalizedSpec": { + "$ref": "#/definitions/Spec" + }, "NumericArrayMarkPropDef": { "$ref": "#/definitions/MarkPropDef" }, @@ -28826,7 +28829,7 @@ ], "type": "object" }, - "TopLevelGenericConcatSpec": { + "TopLevelConcatSpec": { "additionalProperties": false, "properties": { "$schema": { @@ -28893,7 +28896,7 @@ "concat": { "description": "A list of views to be concatenated.", "items": { - "$ref": "#/definitions/Spec" + "$ref": "#/definitions/NonNormalizedSpec" }, "type": "array" }, @@ -28985,7 +28988,7 @@ ], "type": "object" }, - "TopLevelGenericHConcatSpec": { + "TopLevelHConcatSpec": { "additionalProperties": false, "properties": { "$schema": { @@ -29053,7 +29056,7 @@ "hconcat": { "description": "A list of views to be concatenated and put into a row.", "items": { - "$ref": "#/definitions/Spec" + "$ref": "#/definitions/NonNormalizedSpec" }, "type": "array" }, @@ -29115,7 +29118,7 @@ ], "type": "object" }, - "TopLevelGenericVConcatSpec": { + "TopLevelVConcatSpec": { "additionalProperties": false, "properties": { "$schema": { @@ -29235,7 +29238,7 @@ "vconcat": { "description": "A list of views to be concatenated and put into a column.", "items": { - "$ref": "#/definitions/Spec" + "$ref": "#/definitions/NonNormalizedSpec" }, "type": "array" } @@ -29549,7 +29552,7 @@ "description": "The spacing in pixels between sub-views of the composition operator. An object of the form `{\"row\": number, \"column\": number}` can be used to set different spacing values for rows and columns.\n\n__Default value__: Depends on `\"spacing\"` property of [the view composition configuration](https://vega.github.io/vega-lite/docs/config.html#view-config) (`20` by default)" }, "spec": { - "$ref": "#/definitions/Spec", + "$ref": "#/definitions/NonNormalizedSpec", "description": "A specification of the view that gets repeated." }, "title": { @@ -29751,186 +29754,189 @@ } ] }, - "TopLevelSpec": { - "anyOf": [ - { - "$ref": "#/definitions/TopLevelUnitSpec" + "TopLevelFacetSpec": { + "additionalProperties": false, + "properties": { + "$schema": { + "description": "URL to [JSON schema](http://json-schema.org/) for a Vega-Lite specification. Unless you have a reason to change this, use `https://vega.github.io/schema/vega-lite/v4.json`. Setting the `$schema` property allows automatic validation and autocomplete in editors that support JSON schema.", + "format": "uri", + "type": "string" }, - { - "additionalProperties": false, - "properties": { - "$schema": { - "description": "URL to [JSON schema](http://json-schema.org/) for a Vega-Lite specification. Unless you have a reason to change this, use `https://vega.github.io/schema/vega-lite/v4.json`. Setting the `$schema` property allows automatic validation and autocomplete in editors that support JSON schema.", - "format": "uri", - "type": "string" - }, - "align": { - "anyOf": [ - { - "$ref": "#/definitions/LayoutAlign" - }, - { - "$ref": "#/definitions/RowCol" - } - ], - "description": "The alignment to apply to grid rows and columns. The supported string values are `\"all\"`, `\"each\"`, and `\"none\"`.\n\n- For `\"none\"`, a flow layout will be used, in which adjacent subviews are simply placed one after the other. - For `\"each\"`, subviews will be aligned into a clean grid structure, but each row or column may be of variable size. - For `\"all\"`, subviews will be aligned and each row or column will be sized identically based on the maximum observed size. String values for this property will be applied to both grid rows and columns.\n\nAlternatively, an object value of the form `{\"row\": string, \"column\": string}` can be used to supply different alignments for rows and columns.\n\n__Default value:__ `\"all\"`." - }, - "autosize": { - "anyOf": [ - { - "$ref": "#/definitions/AutosizeType" - }, - { - "$ref": "#/definitions/AutoSizeParams" - } - ], - "description": "How the visualization size should be determined. If a string, should be one of `\"pad\"`, `\"fit\"` or `\"none\"`. Object values can additionally specify parameters for content sizing and automatic resizing.\n\n__Default value__: `pad`" - }, - "background": { - "anyOf": [ - { - "$ref": "#/definitions/Color" - }, - { - "$ref": "#/definitions/ExprRef" - } - ], - "description": "CSS color property to use as the background of the entire view.\n\n__Default value:__ `\"white\"`" - }, - "bounds": { - "description": "The bounds calculation method to use for determining the extent of a sub-plot. One of `full` (the default) or `flush`.\n\n- If set to `full`, the entire calculated bounds (including axes, title, and legend) will be used. - If set to `flush`, only the specified width and height values for the sub-view will be used. The `flush` setting can be useful when attempting to place sub-plots without axes or legends into a uniform grid structure.\n\n__Default value:__ `\"full\"`", - "enum": [ - "full", - "flush" - ], - "type": "string" - }, - "center": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/RowCol" - } - ], - "description": "Boolean flag indicating if subviews should be centered relative to their respective rows or columns.\n\nAn object value of the form `{\"row\": boolean, \"column\": boolean}` can be used to supply different centering values for rows and columns.\n\n__Default value:__ `false`" - }, - "columns": { - "description": "The number of columns to include in the view composition layout.\n\n__Default value__: `undefined` -- An infinite number of columns (a single row) will be assumed. This is equivalent to `hconcat` (for `concat`) and to using the `column` channel (for `facet` and `repeat`).\n\n__Note__:\n\n1) This property is only for: - the general (wrappable) `concat` operator (not `hconcat`/`vconcat`) - the `facet` and `repeat` operator with one field/repetition definition (without row/column nesting)\n\n2) Setting the `columns` to `1` is equivalent to `vconcat` (for `concat`) and to using the `row` channel (for `facet` and `repeat`).", - "type": "number" - }, - "config": { - "$ref": "#/definitions/Config", - "description": "Vega-Lite configuration object. This property can only be defined at the top-level of a specification." - }, - "data": { - "anyOf": [ - { - "$ref": "#/definitions/Data" - }, - { - "type": "null" - } - ], - "description": "An object describing the data source. Set to `null` to ignore the parent's data source. If no data is set, it is derived from the parent." - }, - "datasets": { - "$ref": "#/definitions/Datasets", - "description": "A global data store for named datasets. This is a mapping from names to inline datasets. This can be an array of objects or primitive values or a string. Arrays of primitive values are ingested as objects with a `data` property." - }, - "description": { - "description": "Description of this mark for commenting purpose.", - "type": "string" + "align": { + "anyOf": [ + { + "$ref": "#/definitions/LayoutAlign" }, - "facet": { - "anyOf": [ - { - "$ref": "#/definitions/FacetFieldDef" - }, - { - "$ref": "#/definitions/FacetMapping" - } - ], - "description": "Definition for how to facet the data. One of: 1) [a field definition for faceting the plot by one field](https://vega.github.io/vega-lite/docs/facet.html#field-def) 2) [An object that maps `row` and `column` channels to their field definitions](https://vega.github.io/vega-lite/docs/facet.html#mapping)" + { + "$ref": "#/definitions/RowCol" + } + ], + "description": "The alignment to apply to grid rows and columns. The supported string values are `\"all\"`, `\"each\"`, and `\"none\"`.\n\n- For `\"none\"`, a flow layout will be used, in which adjacent subviews are simply placed one after the other. - For `\"each\"`, subviews will be aligned into a clean grid structure, but each row or column may be of variable size. - For `\"all\"`, subviews will be aligned and each row or column will be sized identically based on the maximum observed size. String values for this property will be applied to both grid rows and columns.\n\nAlternatively, an object value of the form `{\"row\": string, \"column\": string}` can be used to supply different alignments for rows and columns.\n\n__Default value:__ `\"all\"`." + }, + "autosize": { + "anyOf": [ + { + "$ref": "#/definitions/AutosizeType" }, - "name": { - "description": "Name of the visualization for later reference.", - "type": "string" + { + "$ref": "#/definitions/AutoSizeParams" + } + ], + "description": "How the visualization size should be determined. If a string, should be one of `\"pad\"`, `\"fit\"` or `\"none\"`. Object values can additionally specify parameters for content sizing and automatic resizing.\n\n__Default value__: `pad`" + }, + "background": { + "anyOf": [ + { + "$ref": "#/definitions/Color" }, - "padding": { - "anyOf": [ - { - "$ref": "#/definitions/Padding" - }, - { - "$ref": "#/definitions/ExprRef" - } - ], - "description": "The default visualization padding, in pixels, from the edge of the visualization canvas to the data rectangle. If a number, specifies padding for all sides. If an object, the value should have the format `{\"left\": 5, \"top\": 5, \"right\": 5, \"bottom\": 5}` to specify padding for each side of the visualization.\n\n__Default value__: `5`" + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "CSS color property to use as the background of the entire view.\n\n__Default value:__ `\"white\"`" + }, + "bounds": { + "description": "The bounds calculation method to use for determining the extent of a sub-plot. One of `full` (the default) or `flush`.\n\n- If set to `full`, the entire calculated bounds (including axes, title, and legend) will be used. - If set to `flush`, only the specified width and height values for the sub-view will be used. The `flush` setting can be useful when attempting to place sub-plots without axes or legends into a uniform grid structure.\n\n__Default value:__ `\"full\"`", + "enum": [ + "full", + "flush" + ], + "type": "string" + }, + "center": { + "anyOf": [ + { + "type": "boolean" }, - "params": { - "description": "Dynamic variables that parameterize a visualization.", - "items": { - "$ref": "#/definitions/Parameter" - }, - "type": "array" + { + "$ref": "#/definitions/RowCol" + } + ], + "description": "Boolean flag indicating if subviews should be centered relative to their respective rows or columns.\n\nAn object value of the form `{\"row\": boolean, \"column\": boolean}` can be used to supply different centering values for rows and columns.\n\n__Default value:__ `false`" + }, + "columns": { + "description": "The number of columns to include in the view composition layout.\n\n__Default value__: `undefined` -- An infinite number of columns (a single row) will be assumed. This is equivalent to `hconcat` (for `concat`) and to using the `column` channel (for `facet` and `repeat`).\n\n__Note__:\n\n1) This property is only for: - the general (wrappable) `concat` operator (not `hconcat`/`vconcat`) - the `facet` and `repeat` operator with one field/repetition definition (without row/column nesting)\n\n2) Setting the `columns` to `1` is equivalent to `vconcat` (for `concat`) and to using the `row` channel (for `facet` and `repeat`).", + "type": "number" + }, + "config": { + "$ref": "#/definitions/Config", + "description": "Vega-Lite configuration object. This property can only be defined at the top-level of a specification." + }, + "data": { + "anyOf": [ + { + "$ref": "#/definitions/Data" }, - "resolve": { - "$ref": "#/definitions/Resolve", - "description": "Scale, axis, and legend resolutions for view composition specifications." + { + "type": "null" + } + ], + "description": "An object describing the data source. Set to `null` to ignore the parent's data source. If no data is set, it is derived from the parent." + }, + "datasets": { + "$ref": "#/definitions/Datasets", + "description": "A global data store for named datasets. This is a mapping from names to inline datasets. This can be an array of objects or primitive values or a string. Arrays of primitive values are ingested as objects with a `data` property." + }, + "description": { + "description": "Description of this mark for commenting purpose.", + "type": "string" + }, + "facet": { + "anyOf": [ + { + "$ref": "#/definitions/FacetFieldDef" }, - "spacing": { - "anyOf": [ - { - "type": "number" - }, - { - "$ref": "#/definitions/RowCol" - } - ], - "description": "The spacing in pixels between sub-views of the composition operator. An object of the form `{\"row\": number, \"column\": number}` can be used to set different spacing values for rows and columns.\n\n__Default value__: Depends on `\"spacing\"` property of [the view composition configuration](https://vega.github.io/vega-lite/docs/config.html#view-config) (`20` by default)" + { + "$ref": "#/definitions/FacetMapping" + } + ], + "description": "Definition for how to facet the data. One of: 1) [a field definition for faceting the plot by one field](https://vega.github.io/vega-lite/docs/facet.html#field-def) 2) [An object that maps `row` and `column` channels to their field definitions](https://vega.github.io/vega-lite/docs/facet.html#mapping)" + }, + "name": { + "description": "Name of the visualization for later reference.", + "type": "string" + }, + "padding": { + "anyOf": [ + { + "$ref": "#/definitions/Padding" }, - "spec": { - "anyOf": [ - { - "$ref": "#/definitions/LayerSpec" - }, - { - "$ref": "#/definitions/UnitSpecWithFrame" - } - ], - "description": "A specification of the view that gets faceted." + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The default visualization padding, in pixels, from the edge of the visualization canvas to the data rectangle. If a number, specifies padding for all sides. If an object, the value should have the format `{\"left\": 5, \"top\": 5, \"right\": 5, \"bottom\": 5}` to specify padding for each side of the visualization.\n\n__Default value__: `5`" + }, + "params": { + "description": "Dynamic variables that parameterize a visualization.", + "items": { + "$ref": "#/definitions/Parameter" + }, + "type": "array" + }, + "resolve": { + "$ref": "#/definitions/Resolve", + "description": "Scale, axis, and legend resolutions for view composition specifications." + }, + "spacing": { + "anyOf": [ + { + "type": "number" }, - "title": { - "anyOf": [ - { - "$ref": "#/definitions/Text" - }, - { - "$ref": "#/definitions/TitleParams" - } - ], - "description": "Title for the plot." + { + "$ref": "#/definitions/RowCol" + } + ], + "description": "The spacing in pixels between sub-views of the composition operator. An object of the form `{\"row\": number, \"column\": number}` can be used to set different spacing values for rows and columns.\n\n__Default value__: Depends on `\"spacing\"` property of [the view composition configuration](https://vega.github.io/vega-lite/docs/config.html#view-config) (`20` by default)" + }, + "spec": { + "anyOf": [ + { + "$ref": "#/definitions/LayerSpec" }, - "transform": { - "description": "An array of data transformations such as filter and new field calculation.", - "items": { - "$ref": "#/definitions/Transform" - }, - "type": "array" + { + "$ref": "#/definitions/UnitSpecWithFrame" + } + ], + "description": "A specification of the view that gets faceted." + }, + "title": { + "anyOf": [ + { + "$ref": "#/definitions/Text" }, - "usermeta": { - "$ref": "#/definitions/Dict", - "description": "Optional metadata that will be passed to Vega. This object is completely ignored by Vega and Vega-Lite and can be used for custom metadata." + { + "$ref": "#/definitions/TitleParams" } - }, - "required": [ - "data", - "facet", - "spec" ], - "type": "object" + "description": "Title for the plot." + }, + "transform": { + "description": "An array of data transformations such as filter and new field calculation.", + "items": { + "$ref": "#/definitions/Transform" + }, + "type": "array" + }, + "usermeta": { + "$ref": "#/definitions/Dict", + "description": "Optional metadata that will be passed to Vega. This object is completely ignored by Vega and Vega-Lite and can be used for custom metadata." + } + }, + "required": [ + "data", + "facet", + "spec" + ], + "type": "object" + }, + "TopLevelSpec": { + "anyOf": [ + { + "$ref": "#/definitions/TopLevelUnitSpec" + }, + { + "$ref": "#/definitions/TopLevelFacetSpec" }, { "$ref": "#/definitions/TopLevelLayerSpec" @@ -29939,13 +29945,13 @@ "$ref": "#/definitions/TopLevelRepeatSpec" }, { - "$ref": "#/definitions/TopLevelGenericConcatSpec" + "$ref": "#/definitions/TopLevelConcatSpec" }, { - "$ref": "#/definitions/TopLevelGenericVConcatSpec" + "$ref": "#/definitions/TopLevelVConcatSpec" }, { - "$ref": "#/definitions/TopLevelGenericHConcatSpec" + "$ref": "#/definitions/TopLevelHConcatSpec" } ], "description": "A Vega-Lite top-level specification. This is the root class for all Vega-Lite specifications. (The json schema is generated from this type.)" diff --git a/scripts/rename-schema.sh b/scripts/rename-schema.sh index 667752006e..c47ecef8e0 100755 --- a/scripts/rename-schema.sh +++ b/scripts/rename-schema.sh @@ -10,6 +10,7 @@ perl -pi -e s,'\,ExprRef>','>',g build/vega-lite-schema.json perl -pi -e s,'CompositeEncoding','Encoding',g build/vega-lite-schema.json perl -pi -e s,'Generic(.*)','\1',g build/vega-lite-schema.json +perl -pi -e s,'Generic(.*)','\1',g build/vega-lite-schema.json perl -pi -e s,'ValueDef(.*)','ValueDef\1',g build/vega-lite-schema.json perl -pi -e s,'Conditional<(.*)>','Conditional\1',g build/vega-lite-schema.json diff --git a/src/normalize/index.ts b/src/normalize/index.ts index 0a31f340f6..d15a5c5c42 100644 --- a/src/normalize/index.ts +++ b/src/normalize/index.ts @@ -5,15 +5,13 @@ import {Config, initConfig} from '../config'; import * as log from '../log'; import { FacetedUnitSpec, - GenericSpec, isLayerSpec, isUnitSpec, - LayerSpec, LayoutSizeMixins, + NonNormalizedSpec, NormalizedSpec, RepeatSpec, - TopLevelSpec, - UnitSpec + TopLevelSpec } from '../spec'; import {AutoSizeParams, AutosizeType, TopLevel} from '../spec/toplevel'; import {deepEqual} from '../util'; @@ -45,7 +43,7 @@ const normalizer = new CoreNormalizer(); * Decompose extended unit specs into composition of pure unit specs. */ function normalizeGenericSpec( - spec: GenericSpec, LayerSpec, RepeatSpec, Field> | FacetedUnitSpec | RepeatSpec, + spec: NonNormalizedSpec | FacetedUnitSpec | RepeatSpec, config: Config = {} ) { return normalizer.map(spec, {config}); diff --git a/src/spec/index.ts b/src/spec/index.ts index ca31aff437..02ceb99700 100644 --- a/src/spec/index.ts +++ b/src/spec/index.ts @@ -51,15 +51,9 @@ export type GenericSpec< */ export type NormalizedSpec = GenericSpec; -/** - * @internal - */ export type TopLevelFacetSpec = TopLevel, LayerSpec, Field>> & DataMixins; -/** - * @internal - */ export type NonNormalizedSpec = GenericSpec, LayerSpec, RepeatSpec, Field>; /**