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

Consistently re-use <Field> rather than <string|RepeatRef> #4493

Merged
merged 1 commit into from
Jan 26, 2019
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
199 changes: 31 additions & 168 deletions build/vega-lite-schema.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/rename-schema.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

perl -pi -e s,'<\(string\|RepeatRef\)>','',g build/vega-lite-schema.json
perl -pi -e s,'<\(string\|RepeatRef\)\,','<',g build/vega-lite-schema.json
perl -pi -e s,'<Field>','',g build/vega-lite-schema.json
perl -pi -e s,'<Field\,','<',g build/vega-lite-schema.json
perl -pi -e s,'<StandardType>','',g build/vega-lite-schema.json

perl -pi -e s,'FacetedCompositeUnitSpec','FacetedUnitSpec',g build/vega-lite-schema.json
Expand Down
3 changes: 1 addition & 2 deletions src/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
NumericValueDefWithCondition,
OrderFieldDef,
PositionFieldDef,
RepeatRef,
SecondaryFieldDef,
ShapeFieldDefWithCondition,
ShapeValueDefWithCondition,
Expand Down Expand Up @@ -266,7 +265,7 @@ export function isAggregate(encoding: EncodingWithFacet<Field>) {
return false;
});
}
export function extractTransformsFromEncoding(oldEncoding: Encoding<string | RepeatRef>, config: Config) {
export function extractTransformsFromEncoding(oldEncoding: Encoding<Field>, config: Config) {
const groupby: string[] = [];
const bins: BinTransform[] = [];
const timeUnits: TimeUnitTransform[] = [];
Expand Down
4 changes: 1 addition & 3 deletions src/fielddef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,7 @@ export function isTypedFieldDef<F extends Field>(channelDef: ChannelDef<FieldDef
return !!channelDef && ((!!channelDef['field'] && !!channelDef['type']) || channelDef['aggregate'] === 'count');
}

export function isStringFieldDef(
channelDef: ChannelDef<FieldDef<string | RepeatRef>>
): channelDef is TypedFieldDef<string> {
export function isStringFieldDef(channelDef: ChannelDef<FieldDef<Field>>): channelDef is TypedFieldDef<string> {
return isFieldDef(channelDef) && isString(channelDef.field);
}

Expand Down
6 changes: 3 additions & 3 deletions src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {COLUMN, ROW} from './channel';
import * as compositeMark from './compositemark';
import {Config} from './config';
import {channelHasField, Encoding} from './encoding';
import {Field, RepeatRef} from './fielddef';
import {Field} from './fielddef';
import * as log from './log';
import {
AnyMark,
Expand Down Expand Up @@ -131,7 +131,7 @@ function mergeProjection(opt: {parentProjection: Projection; projection: Project
function normalizeLayer(
spec: ExtendedLayerSpec,
config: Config,
parentEncoding?: Encoding<string | RepeatRef>,
parentEncoding?: Encoding<Field>,
parentProjection?: Projection
): NormalizedLayerSpec {
const {layer, encoding, projection, ...rest} = spec;
Expand Down Expand Up @@ -256,7 +256,7 @@ function getLineOverlay(markDef: MarkDef, markConfig: AreaConfig): MarkConfig {
function normalizeNonFacetUnit(
spec: GenericUnitSpec<Encoding<Field>, AnyMark>,
config: Config,
parentEncoding?: Encoding<string | RepeatRef>,
parentEncoding?: Encoding<Field>,
parentProjection?: Projection
): NormalizedUnitSpec | NormalizedLayerSpec {
const {encoding, projection} = spec;
Expand Down
4 changes: 2 additions & 2 deletions src/spec/facet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ChannelDef, Field, FieldDef, RepeatRef, TypedFieldDef} from '../fielddef';
import {ChannelDef, Field, FieldDef, TypedFieldDef} from '../fielddef';
import {Header} from '../header';
import {Resolve} from '../resolve';
import {EncodingSortField, SortArray, SortOrder} from '../sort';
Expand Down Expand Up @@ -58,7 +58,7 @@ export interface GenericFacetSpec<U extends GenericUnitSpec<any, any>, L extends
/**
* An object that describes mappings between `row` and `column` channels and their field definitions.
*/
facet: FacetMapping<string | RepeatRef>;
facet: FacetMapping<Field>;

/**
* A specification of the view that gets faceted.
Expand Down
4 changes: 2 additions & 2 deletions src/spec/layer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Encoding} from '../encoding';
import {RepeatRef} from '../fielddef';
import {Field} from '../fielddef';
import {Projection} from '../projection';
import {Resolve} from '../resolve';
import {BaseSpec, LayerUnitMixins} from './base';
Expand Down Expand Up @@ -29,7 +29,7 @@ export interface ExtendedLayerSpec extends GenericLayerSpec<CompositeUnitSpec> {
/**
* A shared key-value mapping between encoding channels and definition of fields in the underlying layers.
*/
encoding?: Encoding<string | RepeatRef>;
encoding?: Encoding<Field>;

/**
* An object defining properties of the geographic projection shared by underlying layers.
Expand Down
8 changes: 4 additions & 4 deletions src/spec/unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Encoding, EncodingWithFacet} from '../encoding';
import {RepeatRef} from '../fielddef';
import {Field} from '../fielddef';
import {AnyMark, Mark, MarkDef} from '../mark';
import {Projection} from '../projection';
import {SelectionDef} from '../selection';
Expand Down Expand Up @@ -39,17 +39,17 @@ export interface GenericUnitSpec<E extends Encoding<any>, M> extends BaseSpec, L
/**
* A unit specification without any shortcut/expansion syntax.
*/
export type NormalizedUnitSpec = GenericUnitSpec<Encoding<string | RepeatRef>, Mark | MarkDef>;
export type NormalizedUnitSpec = GenericUnitSpec<Encoding<Field>, Mark | MarkDef>;

/**
* Unit spec that can have a composite mark.
*/
export type CompositeUnitSpec = GenericUnitSpec<Encoding<string | RepeatRef>, AnyMark>;
export type CompositeUnitSpec = GenericUnitSpec<Encoding<Field>, AnyMark>;

/**
* Unit spec that can have a composite mark and row or column channels.
*/
export type FacetedCompositeUnitSpec = GenericUnitSpec<EncodingWithFacet<string | RepeatRef>, AnyMark>;
export type FacetedCompositeUnitSpec = GenericUnitSpec<EncodingWithFacet<Field>, AnyMark>;

export function isUnitSpec(spec: BaseSpec): spec is FacetedCompositeUnitSpec | NormalizedUnitSpec {
return !!spec['mark'];
Expand Down