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

Separate NormalizedUnitSpec from CompositeUnitSpec #4440

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5,124 changes: 3,746 additions & 1,378 deletions build/vega-lite-schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/compiled/bar_swap_custom.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/compiled/bar_swap_custom.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{"value": "#4c78a8"}
],
"tooltip": {
"signal": "{\"a\": ''+datum[\"a\"], \"Average of b\": format(datum[\"average_b\"], \"\")}"
"signal": "{\"a\": ''+datum[\"a\"], \"Mean of b\": format(datum[\"average_b\"], \"\")}"
},
"x": {"scale": "x", "field": "average_b"},
"x2": {"scale": "x", "value": 0},
Expand Down Expand Up @@ -89,7 +89,7 @@
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "Average of b",
"title": "Mean of b",
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"deploy:gh": "scripts/deploy-gh.sh",
"deploy:schema": "scripts/deploy-schema.sh",
"preschema": "npm run prebuild",
"schema": "node --stack-size=2800 ./node_modules/.bin/ts-json-schema-generator --no-type-check --path tsconfig.json --type TopLevelSpec > build/vega-lite-schema.json && npm run renameschema && cp build/vega-lite-schema.json _data/",
"schema": "node --stack-size=4000 ./node_modules/.bin/ts-json-schema-generator --no-type-check --path tsconfig.json --type TopLevelSpec > build/vega-lite-schema.json && npm run renameschema && cp build/vega-lite-schema.json _data/",
"renameschema": "scripts/rename-schema.sh",
"presite": "npm run prebuild && npm run data && npm run build:site && npm run build:toc && npm run build:versions && scripts/create-example-pages",
"site": "bundle exec jekyll serve --incremental",
Expand Down
4 changes: 2 additions & 2 deletions scripts/check-schema.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

if grep 'Generic.*Spec<' ./build/vega-lite-schema.json
if grep 'Generic[^U].*Spec<' ./build/vega-lite-schema.json
then
echo "Generic*Spec in the schema have not been replaced."
echo "Non-Unit Generic Spec in the schema have not been replaced."
exit 1
elif grep 'UnitSpec<Encoding' ./build/vega-lite-schema.json
then
Expand Down
10 changes: 7 additions & 3 deletions scripts/rename-schema.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/usr/bin/env bash

perl -pi -e s,'\<EmptyObject\>','',g build/vega-lite-schema.json
perl -pi -e s,'\&EmptyObject','',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,'\&FacetMapping','WithFacet',g build/vega-lite-schema.json
perl -pi -e s,'<FacetMapping>','WithFacet',g build/vega-lite-schema.json

perl -pi -e s,'FacetedCompositeUnitSpec','FacetedUnitSpec',g build/vega-lite-schema.json
perl -pi -e s,'ExtendedLayerSpec','LayerSpec',g build/vega-lite-schema.json
perl -pi -e s,'GenericLayerSpec<CompositeUnitSpec>','LayerSpec',g build/vega-lite-schema.json
perl -pi -e s,'Generic(.*)<FacetedUnitSpec\,LayerSpec>','\1',g build/vega-lite-schema.json
perl -pi -e s,'GenericLayerSpec<ExtendedUnitSpec>','LayerSpec',g build/vega-lite-schema.json
perl -pi -e s,'Generic(.*)<FacetedExtendedUnitSpec\,LayerSpec>','\1',g build/vega-lite-schema.json

perl -pi -e s,'GenericUnitSpec<EncodingWithFacet\,AnyMark>','FacetedCompositeUnitSpecAlias',g build/vega-lite-schema.json
perl -pi -e s,'GenericUnitSpec<Encoding\,AnyMark>','CompositeUnitSpecAlias',g build/vega-lite-schema.json
Expand Down
25 changes: 0 additions & 25 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ export const X = Channel.X;
export const Y = Channel.Y;
export const X2 = Channel.X2;
export const Y2 = Channel.Y2;
export const XERROR = Channel.XERROR;
export const YERROR = Channel.YERROR;
export const XERROR2 = Channel.XERROR2;
export const YERROR2 = Channel.YERROR2;

export const LATITUDE = Channel.LATITUDE;
export const LATITUDE2 = Channel.LATITUDE2;
Expand Down Expand Up @@ -111,10 +107,6 @@ const UNIT_CHANNEL_INDEX: Flag<keyof Encoding<any>> = {
y: 1,
x2: 1,
y2: 1,
xError: 1,
yError: 1,
xError2: 1,
yError2: 1,

...GEOPOSITION_CHANNEL_INDEX,

Expand Down Expand Up @@ -180,10 +172,6 @@ export type SingleDefUnitChannel =
| 'y'
| 'x2'
| 'y2'
| 'xError'
| 'yError'
| 'xError2'
| 'yError2'
| 'longitude'
| 'latitude'
| 'longitude2'
Expand Down Expand Up @@ -237,10 +225,6 @@ const {
// x2 and y2 share the same scale as x and y
x2: _x2,
y2: _y2,
xError: _xError,
yError: _yError,
xError2: _xError2,
yError2: _yError2,
latitude: _latitude,
longitude: _longitude,
latitude2: _latitude2,
Expand Down Expand Up @@ -409,11 +393,6 @@ function getSupportedMark(channel: Channel): SupportedMark {
return {point: 'always', geoshape: 'always'};
case TEXT:
return {text: 'always'};
case XERROR:
case YERROR:
case XERROR2:
case YERROR2:
return {};
}
}

Expand All @@ -429,10 +408,6 @@ export function rangeType(channel: Channel): RangeType {
// X2 and Y2 use X and Y scales, so they similarly have continuous range.
case X2:
case Y2:
case XERROR:
case YERROR:
case XERROR2:
case YERROR2:
return undefined;

case ROW:
Expand Down
4 changes: 0 additions & 4 deletions src/compile/mark/mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ export function pathGroupingFields(mark: Mark, encoding: Encoding<string>): stri
case 'href':
case 'x2':
case 'y2':
case 'xError':
case 'yError':
case 'xError2':
case 'yError2':

case 'latitude':
case 'longitude':
Expand Down
14 changes: 7 additions & 7 deletions src/compositemark/boxplot.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {isNumber, isObject} from 'vega-util';
import {Channel} from '../channel';
import {Config} from '../config';
import {Encoding, extractTransformsFromEncoding} from '../encoding';
import {PositionFieldDef} from '../fielddef';
import {Field, PositionFieldDef} from '../fielddef';
import * as log from '../log';
import {isMarkDef, MarkDef} from '../mark';
import {GenericUnitSpec, NormalizedLayerSpec, NormalizedUnitSpec} from '../spec';
Expand All @@ -13,14 +12,17 @@ import {
compositeMarkContinuousAxis,
compositeMarkOrient,
CompositeMarkTooltipSummary,
filterUnsupportedChannels,
GenericCompositeMarkDef,
getCompositeMarkTooltip,
makeCompositeAggregatePartFactory,
partLayerMixins,
PartsMixins
} from './common';

export type BoxPlotUnitSpec<
EE = {} // extra encoding parameter (for faceted composite unit spec)
> = GenericUnitSpec<BoxPlotEncoding<Field> & EE, BoxPlot | BoxPlotDef>;

export const BOXPLOT: 'boxplot' = 'boxplot';
export type BoxPlot = typeof BOXPLOT;

Expand Down Expand Up @@ -68,21 +70,19 @@ export type BoxPlotDef = GenericCompositeMarkDef<BoxPlot> &
orient?: Orient;
};

export type BoxPlotEncoding<F extends Field> = Pick<Encoding<F>, 'x' | 'y' | 'color' | 'detail' | 'opacity' | 'size'>;

export interface BoxPlotConfigMixins {
/**
* Box Config
*/
boxplot?: BoxPlotConfig;
}

const boxPlotSupportedChannels: Channel[] = ['x', 'y', 'color', 'detail', 'opacity', 'size'];

export function normalizeBoxPlot(
spec: GenericUnitSpec<Encoding<string>, BoxPlot | BoxPlotDef>,
config: Config
): NormalizedLayerSpec {
spec = filterUnsupportedChannels(spec, boxPlotSupportedChannels, BOXPLOT);

// TODO: use selection
const {mark, encoding: _encoding, selection, projection: _p, ...outerSpec} = spec;
const markDef: BoxPlotDef = isMarkDef(mark) ? mark : {type: mark};
Expand Down