Skip to content

Commit

Permalink
Eliminate Vg prefixes from the JSON schema
Browse files Browse the repository at this point in the history
Fix #4071
  • Loading branch information
kanitw committed Jan 19, 2019
1 parent 47472f1 commit bdaacd1
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 312 deletions.
477 changes: 237 additions & 240 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
Expand Up @@ -34,5 +34,5 @@ perl -pi -e s,'LogicalNot<string>','SelectionNot',g build/vega-lite-schema.json

perl -pi -e s,'TopLevel<(.*)>','TopLevel\1',g build/vega-lite-schema.json

perl -pi -e s,'BaseAxis<(.*)>','VgAxisConfig',g build/vega-lite-schema.json
perl -pi -e s,'BaseTitle<(.*)>','VgTitleConfig',g build/vega-lite-schema.json
perl -pi -e s,'BaseAxis<(.*)>','BaseAxisConfig',g build/vega-lite-schema.json
perl -pi -e s,'BaseTitle<(.*)>','BaseTitleConfig',g build/vega-lite-schema.json
4 changes: 2 additions & 2 deletions src/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Align, Axis as VgAxis, AxisOrient, BaseAxis, FontWeight, LabelOverlap, T
import {DateTime} from './datetime';
import {Guide, GuideEncodingEntry, VlOnlyGuideConfig} from './guide';
import {Flag, flagKeys} from './util';
import {Color, VgLayoutAlign} from './vega.schema';
import {Color, LayoutAlign} from './vega.schema';

type BaseAxisNoSignals = AxisMixins &
BaseAxis<
Expand All @@ -15,7 +15,7 @@ type BaseAxisNoSignals = AxisMixins &
FontWeight,
Align,
TextBaseline,
VgLayoutAlign,
LayoutAlign,
LabelOverlap,
number[]
>;
Expand Down
4 changes: 2 additions & 2 deletions src/compile/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {ScaleType} from '../scale';
import {formatExpression, TimeUnit} from '../timeunit';
import {QUANTITATIVE} from '../type';
import {getFirstDefined, stringify} from '../util';
import {VgCompare, VgEncodeEntry, VgMarkConfig} from '../vega.schema';
import {BaseMarkConfig, VgCompare, VgEncodeEntry} from '../vega.schema';
import {AxisComponentProps} from './axis/component';
import {Explicit} from './split';
import {UnitModel} from './unit';
Expand Down Expand Up @@ -62,7 +62,7 @@ export function getStyleConfig<P extends keyof MarkConfig>(prop: P, mark: MarkDe

// MarkConfig extends VgMarkConfig so a prop may not be a valid property for style
// However here we also check if it is defined, so it is okay to cast here
const p = prop as keyof VgMarkConfig;
const p = prop as keyof BaseMarkConfig;
if (styleConfig && styleConfig[p] !== undefined) {
value = styleConfig[p];
}
Expand Down
4 changes: 2 additions & 2 deletions src/compile/header/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Utility for generating row / column headers
*/
import {Axis as VgAxis, AxisOrient, TitleConfig as VgTitleConfig} from 'vega';
import {Axis as VgAxis, AxisOrient, TitleConfig} from 'vega';
import {isArray} from 'vega-util';
import {Config} from '../../config';
import {vgField} from '../../fielddef';
Expand Down Expand Up @@ -217,7 +217,7 @@ export function getHeaderProperties(
config: Config,
facetFieldDef: FacetFieldDef<string>,
properties: (keyof HeaderConfig)[],
propertiesMap: {[k in keyof HeaderConfig]: keyof VgTitleConfig}
propertiesMap: {[k in keyof HeaderConfig]: keyof TitleConfig}
) {
const props = {};
for (const prop of properties) {
Expand Down
4 changes: 2 additions & 2 deletions src/compile/scale/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from '../../scale';
import {Type} from '../../type';
import * as util from '../../util';
import {isVgRangeStep, VgRange, VgScheme} from '../../vega.schema';
import {isVgRangeStep, SchemeConfig, VgRange} from '../../vega.schema';
import {evalOrMakeSignalRefComponent, SignalRefComponent} from '../signal';
import {Explicit, makeExplicit, makeImplicit} from '../split';
import {UnitModel} from '../unit';
Expand Down Expand Up @@ -202,7 +202,7 @@ export function parseRangeForChannel(

function parseScheme(scheme: Scheme) {
if (isExtendedScheme(scheme)) {
const r: VgScheme = {scheme: scheme.name};
const r: SchemeConfig = {scheme: scheme.name};
if (scheme.count) {
r.count = scheme.count;
}
Expand Down
8 changes: 4 additions & 4 deletions src/compile/selection/interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {X, Y} from '../../channel';
import {warn} from '../../log';
import {hasContinuousDomain, isBinScale} from '../../scale';
import {keys} from '../../util';
import {VgEventStream} from '../../vega.schema';
import {EventStream} from '../../vega.schema';
import {UnitModel} from '../unit';
import {
channelSignalName,
Expand Down Expand Up @@ -31,7 +31,7 @@ const interval: SelectionCompiler = {

if (selCmpt.translate && !hasScales) {
const filterExpr = `!event.item || event.item.mark.name !== ${stringValue(name + BRUSH)}`;
events(selCmpt, (_: any[], evt: VgEventStream) => {
events(selCmpt, (_: any[], evt: EventStream) => {
const filters = evt.between[0].filter || (evt.between[0].filter = []);
if (filters.indexOf(filterExpr) < 0) {
filters.push(filterExpr);
Expand Down Expand Up @@ -188,7 +188,7 @@ function channelSignals(model: UnitModel, selCmpt: SelectionComponent, channel:
const size = model.getSizeSignalRef(channel === X ? 'width' : 'height').signal;
const coord = `${channel}(unit)`;

const on = events(selCmpt, (def: any[], evt: VgEventStream) => {
const on = events(selCmpt, (def: any[], evt: EventStream) => {
return def.concat(
{events: evt.between[0], update: `[${coord}, ${coord}]`}, // Brush Start
{events: evt, update: `[${vname}[0], clamp(${coord}, 0, ${size})]`} // Brush End
Expand Down Expand Up @@ -222,7 +222,7 @@ function channelSignals(model: UnitModel, selCmpt: SelectionComponent, channel:
}

function events(selCmpt: SelectionComponent, cb: (...args: any[]) => void) {
return selCmpt.events.reduce((on: any[], evt: VgEventStream) => {
return selCmpt.events.reduce((on: any[], evt: EventStream) => {
if (!evt.between) {
warn(`${evt} is not an ordered event stream for interval selections`);
return on;
Expand Down
6 changes: 3 additions & 3 deletions src/compile/selection/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {isString, stringValue} from 'vega-util';
import {Channel, ScaleChannel, SingleDefChannel, X, Y} from '../../channel';
import {warn} from '../../log';
import {LogicalOperand} from '../../logical';
import {BrushConfig, SELECTION_ID, SelectionDef, SelectionResolution, SelectionType} from '../../selection';
import {BrushConfig, SelectionDef, SelectionResolution, SelectionType, SELECTION_ID} from '../../selection';
import {accessPathWithDatum, Dict, duplicate, keys, logicalExpr, varName} from '../../util';
import {VgData, VgEventStream} from '../../vega.schema';
import {EventStream, VgData} from '../../vega.schema';
import {DataFlowNode} from '../data/dataflow';
import {TimeUnitNode} from '../data/timeunit';
import {FacetModel} from '../facet';
Expand All @@ -28,7 +28,7 @@ export const VL_SELECTION_RESOLVE = 'vlSelectionResolve';
export interface SelectionComponent {
name: string;
type: SelectionType;
events: VgEventStream;
events: EventStream;
// predicate?: string;
bind?: 'scales' | Binding | Dict<Binding>;
resolve: SelectionResolution;
Expand Down
22 changes: 11 additions & 11 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {TopLevelProperties} from './spec/toplevel';
import {StackOffset} from './stack';
import {extractTitleConfig, TitleConfig} from './title';
import {duplicate, keys, mergeDeep} from './util';
import {VgMarkConfig, VgScheme} from './vega.schema';
import {BaseMarkConfig, SchemeConfig} from './vega.schema';

export interface ViewConfig extends ViewBackground {
/**
Expand Down Expand Up @@ -50,43 +50,43 @@ export const defaultViewConfig: ViewConfig = {
height: 200
};

export type RangeConfigValue = (number | string)[] | VgScheme | {step: number};
export type RangeConfigValue = (number | string)[] | SchemeConfig | {step: number};

export type RangeConfig = RangeConfigProps & {[name: string]: RangeConfigValue};

export interface RangeConfigProps {
/**
* Default range for _nominal_ (categorical) fields.
*/
category?: string[] | VgScheme;
category?: string[] | SchemeConfig;

/**
* Default range for diverging _quantitative_ fields.
*/
diverging?: string[] | VgScheme;
diverging?: string[] | SchemeConfig;

/**
* Default range for _quantitative_ heatmaps.
*/
heatmap?: string[] | VgScheme;
heatmap?: string[] | SchemeConfig;

/**
* Default range for _ordinal_ fields.
*/
ordinal?: string[] | VgScheme;
ordinal?: string[] | SchemeConfig;

/**
* Default range for _quantitative_ and _temporal_ fields.
*/
ramp?: string[] | VgScheme;
ramp?: string[] | SchemeConfig;

/**
* Default range palette for the `shape` channel.
*/
symbol?: string[];
}

export function isVgScheme(rangeConfig: string[] | VgScheme): rangeConfig is VgScheme {
export function isVgScheme(rangeConfig: string[] | SchemeConfig): rangeConfig is SchemeConfig {
return rangeConfig && !!rangeConfig['scheme'];
}

Expand Down Expand Up @@ -144,7 +144,7 @@ export interface VLOnlyConfig {
}

export interface StyleConfigIndex {
[style: string]: VgMarkConfig;
[style: string]: BaseMarkConfig;
}

export interface Config
Expand Down Expand Up @@ -354,7 +354,7 @@ function redirectConfig(
toProp?: string,
compositeMarkPart?: string
) {
const propConfig: VgMarkConfig =
const propConfig: BaseMarkConfig =
prop === 'title'
? extractTitleConfig(config.title).mark
: compositeMarkPart
Expand All @@ -365,7 +365,7 @@ function redirectConfig(
toProp = 'cell'; // View's default style is "cell"
}

const style: VgMarkConfig = {
const style: BaseMarkConfig = {
...propConfig,
...config.style[prop]
};
Expand Down
6 changes: 3 additions & 3 deletions src/header.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {FontWeight, TextBaseline, TitleConfig as VgTitleConfig} from 'vega';
import {FontWeight, TextBaseline, TitleConfig} from 'vega';
import {Guide} from './guide';
import {keys} from './util';

export const HEADER_TITLE_PROPERTIES_MAP: {[k in keyof HeaderConfig]: keyof VgTitleConfig} = {
export const HEADER_TITLE_PROPERTIES_MAP: {[k in keyof HeaderConfig]: keyof TitleConfig} = {
titleAnchor: 'anchor',
titleAngle: 'angle',
titleBaseline: 'baseline',
Expand All @@ -14,7 +14,7 @@ export const HEADER_TITLE_PROPERTIES_MAP: {[k in keyof HeaderConfig]: keyof VgTi
titlePadding: 'offset'
};

export const HEADER_LABEL_PROPERTIES_MAP: {[k in keyof HeaderConfig]: keyof VgTitleConfig} = {
export const HEADER_LABEL_PROPERTIES_MAP: {[k in keyof HeaderConfig]: keyof TitleConfig} = {
labelAngle: 'angle',
labelColor: 'color',
labelFont: 'font',
Expand Down
6 changes: 3 additions & 3 deletions src/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {DateTime} from './datetime';
import {Guide, GuideEncodingEntry, VlOnlyGuideConfig} from './guide';
import {Flag, flagKeys} from './util';
import {Color, VgLayoutAlign} from './vega.schema';
import {Color, LayoutAlign} from './vega.schema';

export type LegendConfig = LegendMixins &
VlOnlyGuideConfig &
Expand All @@ -25,7 +25,7 @@ export type LegendConfig = LegendMixins &
FontWeight,
Align,
TextBaseline,
VgLayoutAlign,
LayoutAlign,
LabelOverlap,
SymbolShape
> & {
Expand Down Expand Up @@ -83,7 +83,7 @@ export interface Legend
FontWeight,
Align,
TextBaseline,
VgLayoutAlign,
LayoutAlign,
LabelOverlap,
SymbolShape
>,
Expand Down
4 changes: 2 additions & 2 deletions src/mark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {toSet} from 'vega-util';
import {CompositeMark, CompositeMarkDef} from './compositemark/index';
import {contains, flagKeys} from './util';
import {VgMarkConfig} from './vega.schema';
import {BaseMarkConfig} from './vega.schema';

export namespace Mark {
export const AREA: 'area' = 'area';
Expand Down Expand Up @@ -90,7 +90,7 @@ export interface TooltipContent {
content: 'encoding' | 'data';
}

export interface MarkConfig extends ColorMixins, VgMarkConfig {
export interface MarkConfig extends ColorMixins, BaseMarkConfig {
// ========== VL-Specific ==========

/**
Expand Down
4 changes: 2 additions & 2 deletions src/projection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {VgProjectionType} from './vega.schema';
import {ProjectionType} from './vega.schema';

export type ProjectionType = VgProjectionType;
export type ProjectionType = ProjectionType;

export interface Projection {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/selection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Binding} from 'vega';
import {SingleDefChannel} from './channel';
import {VgEventStream} from './vega.schema';
import {EventStream} from './vega.schema';

export const SELECTION_ID = '_vgsid_';
export type SelectionType = 'single' | 'multi' | 'interval';
Expand All @@ -11,7 +11,7 @@ export interface BaseSelectionDef {
* A [Vega event stream](https://vega.github.io/vega/docs/event-streams/) (object or selector) that triggers the selection.
* For interval selections, the event stream must specify a [start and end](https://vega.github.io/vega/docs/event-streams/#between-filters).
*/
on?: VgEventStream;
on?: EventStream;
/**
* With layered and multi-view displays, a strategy that determines how
* selections' data queries are resolved when applied in a filter transform,
Expand Down
4 changes: 2 additions & 2 deletions src/spec/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Data} from '../data';
import {TitleParams} from '../title';
import {Transform} from '../transform';
import {VgMarkConfig} from '../vega.schema';
import {BaseMarkConfig} from '../vega.schema';

export {normalizeTopLevelSpec as normalize} from '../normalize';
export {TopLevel} from './toplevel';
Expand Down Expand Up @@ -90,7 +90,7 @@ export interface LayerUnitMixins extends LayoutSizeMixins {
export interface ViewBackground
extends Partial<
Pick<
VgMarkConfig,
BaseMarkConfig,
| 'cornerRadius'
| 'fillOpacity'
| 'opacity'
Expand Down
4 changes: 2 additions & 2 deletions src/spec/toplevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Config} from '../config';
import {InlineDataset} from '../data';
import * as log from '../log';
import {Dict} from '../util';
import {RowCol, VgLayoutAlign} from '../vega.schema';
import {LayoutAlign, RowCol} from '../vega.schema';
import {BaseSpec} from './index';
import {Datasets, GenericCompositionLayout, TopLevelProperties} from './toplevel';

Expand Down Expand Up @@ -117,7 +117,7 @@ export interface GenericCompositionLayout extends BoundsMixins {
*
* __Default value:__ `"all"`.
*/
align?: VgLayoutAlign | RowCol<VgLayoutAlign>;
align?: LayoutAlign | RowCol<LayoutAlign>;

/**
* Boolean flag indicating if subviews should be centered relative to their respective rows or columns.
Expand Down
6 changes: 3 additions & 3 deletions src/title.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Align, BaseTitle, FontWeight, TextBaseline, TextEncodeEntry, TitleAnchor, TitleFrame} from 'vega';
import {Color, VgMarkConfig} from './vega.schema';
import {BaseMarkConfig, Color} from './vega.schema';

type BaseTitleNoSignals = BaseTitle<number, string, Color, FontWeight, Align, TextBaseline, TitleFrame, TitleAnchor>;

Expand Down Expand Up @@ -51,7 +51,7 @@ export interface TitleParams extends TitleBase {
export function extractTitleConfig(
titleConfig: TitleConfig
): {
mark: VgMarkConfig;
mark: BaseMarkConfig;
nonMark: BaseTitleNoSignals;
} {
const {
Expand All @@ -66,7 +66,7 @@ export function extractTitleConfig(
...titleMarkConfig
} = titleConfig;

const mark: VgMarkConfig = {
const mark: BaseMarkConfig = {
...titleMarkConfig,
...(color ? {fill: color} : {})
};
Expand Down

0 comments on commit bdaacd1

Please sign in to comment.