import {Field} from '../channeldef.js'; import {SharedCompositeEncoding} from '../compositemark/index.js'; import {ExprRef} from '../expr.js'; import {Projection} from '../projection.js'; import {hasProperty} from '../util.js'; import {BaseSpec, FrameMixins, ResolveMixins} from './base.js'; import {GenericUnitSpec, NormalizedUnitSpec, UnitSpec} from './unit.js'; /** * Base interface for a layer specification. */ export interface GenericLayerSpec> 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: (GenericLayerSpec | U)[]; } /** * 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 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. */ encoding?: SharedCompositeEncoding; /** * An object defining properties of the geographic projection shared by underlying layers. */ projection?: Projection; } /** * A layered specification without any shortcut/expansion syntax. */ export type NormalizedLayerSpec = GenericLayerSpec; export function isLayerSpec(spec: BaseSpec): spec is GenericLayerSpec { return hasProperty(spec, 'layer'); }