From 10cb26060230b458110910c2f350cd6ab7572086 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Thu, 5 Mar 2020 10:12:28 -0800 Subject: [PATCH] fix: correct layer spec type to be circular --- build/vega-lite-schema.json | 174 ++++----------------- examples/specs/parallel_coordinate.vl.json | 7 +- package.json | 2 +- scripts/rename-schema.sh | 5 +- src/spec/index.ts | 16 +- src/spec/layer.ts | 9 +- yarn.lock | 8 +- 7 files changed, 54 insertions(+), 167 deletions(-) diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index d04fefe4d40..a5cc79c3cd0 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -7371,7 +7371,7 @@ } ] }, - "GenericConcatSpec>": { + "NormalizedConcatSpec": { "additionalProperties": false, "description": "Base interface for a generalized concatenation specification.", "properties": { @@ -7412,7 +7412,7 @@ "concat": { "description": "A list of views to be concatenated.", "items": { - "$ref": "#/definitions/GenericSpec" + "$ref": "#/definitions/NormalizedSpec" }, "type": "array" }, @@ -7474,7 +7474,7 @@ ], "type": "object" }, - "GenericConcatSpec>": { + "ConcatSpec": { "additionalProperties": false, "description": "Base interface for a generalized concatenation specification.", "properties": { @@ -7515,7 +7515,7 @@ "concat": { "description": "A list of views to be concatenated.", "items": { - "$ref": "#/definitions/GenericSpec" + "$ref": "#/definitions/Spec" }, "type": "array" }, @@ -7815,7 +7815,7 @@ ], "type": "object" }, - "GenericHConcatSpec>": { + "NormalizedHConcatSpec": { "additionalProperties": false, "description": "Base interface for a horizontal concatenation specification.", "properties": { @@ -7849,7 +7849,7 @@ "hconcat": { "description": "A list of views to be concatenated and put into a row.", "items": { - "$ref": "#/definitions/GenericSpec" + "$ref": "#/definitions/NormalizedSpec" }, "type": "array" }, @@ -7889,7 +7889,7 @@ ], "type": "object" }, - "GenericHConcatSpec>": { + "HConcatSpec": { "additionalProperties": false, "description": "Base interface for a horizontal concatenation specification.", "properties": { @@ -7923,7 +7923,7 @@ "hconcat": { "description": "A list of views to be concatenated and put into a row.", "items": { - "$ref": "#/definitions/GenericSpec" + "$ref": "#/definitions/Spec" }, "type": "array" }, @@ -7963,7 +7963,7 @@ ], "type": "object" }, - "GenericSpec": { + "NormalizedSpec": { "anyOf": [ { "$ref": "#/definitions/FacetedUnitSpec" @@ -7978,18 +7978,18 @@ "$ref": "#/definitions/GenericFacetSpec" }, { - "$ref": "#/definitions/GenericConcatSpec>" + "$ref": "#/definitions/NormalizedConcatSpec" }, { - "$ref": "#/definitions/GenericVConcatSpec>" + "$ref": "#/definitions/NormalizedVConcatSpec" }, { - "$ref": "#/definitions/GenericHConcatSpec>" + "$ref": "#/definitions/NormalizedHConcatSpec" } ], "description": "Any specification in Vega-Lite." }, - "GenericSpec": { + "Spec": { "anyOf": [ { "$ref": "#/definitions/FacetedUnitSpec" @@ -8004,18 +8004,18 @@ "$ref": "#/definitions/GenericFacetSpec" }, { - "$ref": "#/definitions/GenericConcatSpec>" + "$ref": "#/definitions/ConcatSpec" }, { - "$ref": "#/definitions/GenericVConcatSpec>" + "$ref": "#/definitions/VConcatSpec" }, { - "$ref": "#/definitions/GenericHConcatSpec>" + "$ref": "#/definitions/HConcatSpec" } ], "description": "Any specification in Vega-Lite." }, - "GenericVConcatSpec>": { + "NormalizedVConcatSpec": { "additionalProperties": false, "description": "Base interface for a vertical concatenation specification.", "properties": { @@ -8079,7 +8079,7 @@ "vconcat": { "description": "A list of views to be concatenated and put into a column.", "items": { - "$ref": "#/definitions/GenericSpec" + "$ref": "#/definitions/NormalizedSpec" }, "type": "array" } @@ -8089,7 +8089,7 @@ ], "type": "object" }, - "GenericVConcatSpec>": { + "VConcatSpec": { "additionalProperties": false, "description": "Base interface for a vertical concatenation specification.", "properties": { @@ -8153,7 +8153,7 @@ "vconcat": { "description": "A list of views to be concatenated and put into a column.", "items": { - "$ref": "#/definitions/GenericSpec" + "$ref": "#/definitions/Spec" }, "type": "array" } @@ -12319,114 +12319,6 @@ } ] }, - "PartsMixins": { - "additionalProperties": false, - "properties": { - "box": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - }, - "median": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - }, - "outliers": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - }, - "rule": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - }, - "ticks": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - } - }, - "type": "object" - }, - "PartsMixins": { - "additionalProperties": false, - "properties": { - "band": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - }, - "borders": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - } - }, - "type": "object" - }, - "PartsMixins": { - "additionalProperties": false, - "properties": { - "rule": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - }, - "ticks": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MarkConfig" - } - ] - } - }, - "type": "object" - }, "PivotTransform": { "additionalProperties": false, "properties": { @@ -13575,7 +13467,7 @@ "description": "The spacing in pixels between sub-views of the composition operator.\nAn object of the form `{\"row\": number, \"column\": number}` can be used to set\ndifferent 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/GenericSpec", + "$ref": "#/definitions/Spec", "description": "A specification of the view that gets repeated." }, "title": { @@ -14878,10 +14770,6 @@ ], "type": "string" }, - "Spec": { - "$ref": "#/definitions/GenericSpec", - "description": "Spec with composite marks and repeat." - }, "SphereGenerator": { "additionalProperties": false, "properties": { @@ -15865,7 +15753,7 @@ ], "type": "object" }, - "TopLevelGenericConcatSpec": { + "TopLevelNormalizedConcatSpec": { "additionalProperties": false, "properties": { "$schema": { @@ -15925,7 +15813,7 @@ "concat": { "description": "A list of views to be concatenated.", "items": { - "$ref": "#/definitions/Spec" + "$ref": "#/definitions/NormalizedSpec" }, "type": "array" }, @@ -16003,7 +15891,7 @@ ], "type": "object" }, - "TopLevelGenericHConcatSpec": { + "TopLevelNormalizedHConcatSpec": { "additionalProperties": false, "properties": { "$schema": { @@ -16064,7 +15952,7 @@ "hconcat": { "description": "A list of views to be concatenated and put into a row.", "items": { - "$ref": "#/definitions/Spec" + "$ref": "#/definitions/NormalizedSpec" }, "type": "array" }, @@ -16112,7 +16000,7 @@ ], "type": "object" }, - "TopLevelGenericVConcatSpec": { + "TopLevelNormalizedVConcatSpec": { "additionalProperties": false, "properties": { "$schema": { @@ -16211,7 +16099,7 @@ "vconcat": { "description": "A list of views to be concatenated and put into a column.", "items": { - "$ref": "#/definitions/Spec" + "$ref": "#/definitions/NormalizedSpec" }, "type": "array" } @@ -16485,7 +16373,7 @@ "description": "The spacing in pixels between sub-views of the composition operator.\nAn object of the form `{\"row\": number, \"column\": number}` can be used to set\ndifferent 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/GenericSpec", + "$ref": "#/definitions/Spec", "description": "A specification of the view that gets repeated." }, "title": { @@ -16687,13 +16575,13 @@ "$ref": "#/definitions/TopLevelRepeatSpec" }, { - "$ref": "#/definitions/TopLevelGenericConcatSpec" + "$ref": "#/definitions/TopLevelNormalizedConcatSpec" }, { - "$ref": "#/definitions/TopLevelGenericVConcatSpec" + "$ref": "#/definitions/TopLevelNormalizedVConcatSpec" }, { - "$ref": "#/definitions/TopLevelGenericHConcatSpec" + "$ref": "#/definitions/TopLevelNormalizedHConcatSpec" } ], "description": "A Vega-Lite top-level specification.\nThis is the root class for all Vega-Lite specifications.\n(The json schema is generated from this type.)" diff --git a/examples/specs/parallel_coordinate.vl.json b/examples/specs/parallel_coordinate.vl.json index 8599fc03670..707f3ea2e9f 100644 --- a/examples/specs/parallel_coordinate.vl.json +++ b/examples/specs/parallel_coordinate.vl.json @@ -53,7 +53,7 @@ "field": "sepalWidth" }] } - },{ + }, { "encoding": { "x": {"type": "nominal", "field": "key"}, "y": {"value": 0} @@ -66,8 +66,7 @@ }, { "mark": {"type": "tick", "style": "tick", "size": 8, "color": "#ccc"} }] - },{ - + }, { "encoding": { "x": {"type": "nominal", "field": "key"}, "y": {"value": 150} @@ -80,7 +79,7 @@ }, { "mark": {"type": "tick", "style": "tick", "size": 8, "color": "#ccc"} }] - },{ + }, { "encoding": { "x": {"type": "nominal", "field": "key"}, "y": {"value": 300} diff --git a/package.json b/package.json index a00a88e536e..d8075f801b3 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,7 @@ "svg2png-many": "^0.0.7", "terser": "^4.6.4", "ts-jest": "^25.2.1", - "ts-json-schema-generator": "0.61.1", + "ts-json-schema-generator": "^0.64.0", "typescript": "~3.8.2", "vega-cli": "^5.9.2", "vega-datasets": "^1.30.2", diff --git a/scripts/rename-schema.sh b/scripts/rename-schema.sh index 5a4dc7c79fd..0595b85c0e5 100755 --- a/scripts/rename-schema.sh +++ b/scripts/rename-schema.sh @@ -7,9 +7,8 @@ perl -pi -e s,'','',g build/vega-lite-schema.json perl -pi -e s,'CompositeEncoding','Encoding',g build/vega-lite-schema.json -perl -pi -e s,'GenericLayerSpec','LayerSpec',g build/vega-lite-schema.json # This is required as LayerSpec's own definition would depend on generic and have GenericLayerSpec, not LayerSpec -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,'Generic(.*)','Normalized\1',g build/vega-lite-schema.json perl -pi -e s,'ValueDef(.*)\<\(number\|\\\"width\\\"\)\>','XValueDef\1',g build/vega-lite-schema.json perl -pi -e s,'ValueDef(.*)\<\(number\|\\\"height\\\"\)\>','YValueDef\1',g build/vega-lite-schema.json diff --git a/src/spec/index.ts b/src/spec/index.ts index 3774b05bac0..3484e56b2a0 100644 --- a/src/spec/index.ts +++ b/src/spec/index.ts @@ -1,19 +1,18 @@ -import {FieldName} from './../channeldef'; /** * Definition for specifications in Vega-Lite. In general, there are 3 variants of specs for each type of specs: * - Generic specs are generic versions of specs and they are parameterized differently for internal and external specs. * - The external specs (no prefix) would allow composite marks, row/column encodings, and mark macros like point/line overlay. * - The internal specs (with `Normalized` prefix) would only support primitive marks and support no macros/shortcuts. */ - import {Field} from '../channeldef'; +import {FieldName} from './../channeldef'; import {DataMixins} from './base'; import {GenericConcatSpec, GenericHConcatSpec, GenericVConcatSpec} from './concat'; import {GenericFacetSpec} from './facet'; import {GenericLayerSpec, LayerSpec, NormalizedLayerSpec} from './layer'; +import {RepeatSpec} from './repeat'; import {TopLevel} from './toplevel'; import {FacetedUnitSpec, GenericUnitSpec, NormalizedUnitSpec, TopLevelUnitSpec, UnitSpecWithFrame} from './unit'; -import {RepeatSpec} from './repeat'; export {BaseSpec, LayoutSizeMixins} from './base'; export { @@ -52,11 +51,6 @@ export type GenericSpec< */ export type NormalizedSpec = GenericSpec; -/** - * Spec with composite marks and repeat. - */ -export type Spec = GenericSpec; - export type TopLevelFacetSpec = TopLevel> & DataMixins; /** @@ -69,6 +63,6 @@ export type TopLevelSpec = | TopLevelFacetSpec | TopLevel | TopLevel - | TopLevel> - | TopLevel> - | TopLevel>; + | TopLevel>> + | TopLevel>> + | TopLevel>>; diff --git a/src/spec/layer.ts b/src/spec/layer.ts index ed060d290a8..8adbe4c01fc 100644 --- a/src/spec/layer.ts +++ b/src/spec/layer.ts @@ -18,7 +18,14 @@ export interface GenericLayerSpec> extends B /** * A full layered plot specification, which may contains `encoding` and `projection` properties that will be applied to underlying unit (single-view) specifications. */ -export interface LayerSpec extends GenericLayerSpec { +export interface LayerSpec extends BaseSpec, FrameMixins, ResolveMixins { + /** + * Layer or single view specifications to be layered. + * + * __Note__: Specifications inside `layer` cannot use `row` and `column` channels as layering facet specifications is not allowed. Instead, use the [facet operator](https://vega.github.io/vega-lite/docs/facet.html) and place a layer inside a facet. + */ + layer: (LayerSpec | UnitSpec)[]; + /** * A shared key-value mapping between encoding channels and definition of fields in the underlying layers. */ diff --git a/yarn.lock b/yarn.lock index bd53a04d762..a4b32f9fac9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7456,10 +7456,10 @@ ts-jest@^25.2.1: semver "^5.5" yargs-parser "^16.1.0" -ts-json-schema-generator@0.61.1: - version "0.61.1" - resolved "https://registry.yarnpkg.com/ts-json-schema-generator/-/ts-json-schema-generator-0.61.1.tgz#92b5022b1f4678037312c5d56ff5bf44a067143e" - integrity sha512-JLoFdVhQh9dXAMjJVFd3dok0LX+Ko5oGilPMEePxjrQDNBeh9nHbQFK1SGAQKf5kk7Fe120dXqeapjUBTTePQg== +ts-json-schema-generator@^0.64.0: + version "0.64.0" + resolved "https://registry.yarnpkg.com/ts-json-schema-generator/-/ts-json-schema-generator-0.64.0.tgz#5e0b1c1ce92bf8cee1bf10d39a103c9c48d22f77" + integrity sha512-cYyF8BP6mdaau/MfxwxrtRJUaDmi+QLDK/Z140H6sxphCCvHz2KR4+teNulFY2JlhPCzvq5Vj8wiaSSXRMlzsQ== dependencies: "@types/json-schema" "^7.0.4" commander "~4.1.1"