Bar graph added.

This commit is contained in:
prabhatdev
2020-07-28 00:48:25 +05:30
parent d0a6e2667d
commit 194b41124d
3468 changed files with 640611 additions and 169 deletions

164
node_modules/vega-lite/build/package.json generated vendored Normal file
View File

@@ -0,0 +1,164 @@
{
"name": "vega-lite",
"author": "Dominik Moritz, Kanit \"Ham\" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer",
"version": "4.14.0",
"collaborators": [
"Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)",
"Dominik Moritz (https://www.domoritz.de)",
"Arvind Satyanarayan (https://arvindsatya.com)",
"Jeffrey Heer (https://jheer.org)"
],
"homepage": "https://vega.github.io/vega-lite/",
"description": "Vega-Lite is a concise high-level language for interactive visualization.",
"main": "build/vega-lite.js",
"unpkg": "build/vega-lite.min.js",
"jsdelivr": "build/vega-lite.min.js",
"module": "build/src/index",
"types": "build/src/index.d.ts",
"bin": {
"vl2png": "./bin/vl2png",
"vl2svg": "./bin/vl2svg",
"vl2pdf": "./bin/vl2pdf",
"vl2vg": "./bin/vl2vg"
},
"directories": {
"test": "test"
},
"scripts": {
"changelog": "conventional-changelog -p angular -r 2",
"build": "yarn build:only",
"build:only": "yarn tsc:src && rollup -c",
"postbuild": "terser build/vega-lite.js -cm --source-map content=build/vega-lite.js.map,filename=build/vega-lite.min.js.map -o build/vega-lite.min.js && yarn schema && babel build/vega-lite.js --out-dir build-es5 --config-file ./babel.config.js",
"prebuild:examples": "yarn build:only",
"build:examples": "yarn data && TZ=America/Los_Angeles scripts/build-examples.sh",
"prebuild:examples-full": "yarn build:only",
"build:examples-full": "TZ=America/Los_Angeles scripts/build-examples.sh 1",
"build:example": "TZ=America/Los_Angeles scripts/build-example.sh",
"build:toc": "yarn build:jekyll && scripts/generate-toc",
"build:site": "yarn tsc:site && rollup -c site/rollup.config.js",
"build:jekyll": "pushd site && bundle exec jekyll build -q && popd",
"build:versions": "scripts/update-version.sh",
"clean": "find build ! -name 'vega-lite-schema.json' -type f -delete && rm -rf site/data/* && rm -f examples/compiled/*.png && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete",
"predeploy:site": "yarn presite",
"deploy:site": "gh-pages -d site",
"data": "rsync -r node_modules/vega-datasets/data/* site/data",
"schema": "mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",
"renameschema": "scripts/rename-schema.sh",
"presite": "yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",
"site": "pushd site && bundle exec jekyll serve -I -l && popd",
"tsc:src": "tsc -b src/tsconfig.src.json",
"tsc:site": "tsc -b site/tsconfig.site.json",
"prettierbase": "prettier '**/*.{md,css,yml}'",
"eslintbase": "eslint .",
"format": "yarn eslintbase --fix && yarn prettierbase --write",
"lint": "yarn eslintbase && yarn prettierbase --check",
"test": "jest test/ && yarn lint && yarn schema && jest examples/ && yarn test:runtime",
"test:inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand test",
"test:runtime": "TZ=America/Los_Angeles jest test-runtime/",
"test:runtime:generate": "yarn build:only && rm -Rf test-runtime/resources && VL_GENERATE_TESTS=true yarn test:runtime",
"watch:build": "yarn build:only && concurrently --kill-others -n Typescript,Rollup 'yarn tsc:src -w' 'rollup -c -w'",
"watch:site": "concurrently --kill-others -n Typescript,Rollup 'yarn tsc:site -w' 'rollup -c site/rollup.config.js -w'",
"watch:test": "jest --watch"
},
"repository": {
"type": "git",
"url": "https://github.com/vega/vega-lite.git"
},
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/vega/vega-lite/issues"
},
"devDependencies": {
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@rollup/plugin-commonjs": "14.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@types/chai": "^4.2.11",
"@types/d3": "^5.7.2",
"@types/jest": "^26.0.4",
"@types/mkdirp": "^1.0.1",
"@types/pako": "^1.0.1",
"@types/puppeteer": "^3.0.1",
"@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^3.6.1",
"ajv": "^6.12.3",
"chai": "^4.2.0",
"cheerio": "^1.0.0-rc.3",
"codecov": "^3.7.0",
"concurrently": "^5.2.0",
"conventional-changelog-cli": "^2.0.34",
"d3": "^5.16.0",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-prettier": "^3.1.4",
"gh-pages": "^3.1.0",
"highlight.js": "^10.1.1",
"jest": "^26.1.0",
"jest-puppeteer": "^4.4.0",
"mkdirp": "^1.0.4",
"pako": "^1.0.11",
"prettier": "^2.0.5",
"puppeteer": "^5.2.0",
"rollup": "^2.21.0",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^6.1.0",
"serve": "^11.3.2",
"svg2png-many": "^0.0.7",
"terser": "^4.8.0",
"ts-jest": "^26.1.2",
"ts-json-schema-generator": "^0.70.2",
"typescript": "~3.9.6",
"vega-cli": "^5.13.0",
"vega-datasets": "2.1.0",
"vega-embed": "^6.10.0",
"vega-tooltip": "^0.23.2",
"vega-typings": "^0.18.0",
"yaml-front-matter": "^4.1.0"
},
"dependencies": {
"@types/clone": "~0.1.30",
"@types/fast-json-stable-stringify": "^2.0.0",
"array-flat-polyfill": "^1.0.1",
"clone": "~2.1.2",
"fast-deep-equal": "~3.1.3",
"fast-json-stable-stringify": "~2.1.0",
"json-stringify-pretty-compact": "~2.0.0",
"tslib": "~2.0.0",
"vega-event-selector": "~2.0.3",
"vega-expression": "~2.6.5",
"vega-util": "~1.14.1",
"yargs": "~15.4.1"
},
"peerDependencies": {
"vega": "^5.13.0"
},
"jest": {
"preset": "jest-puppeteer",
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules",
"<rootDir>/build",
"<rootDir>/_site",
"<rootDir>/src"
],
"coverageDirectory": "./coverage/",
"collectCoverage": false,
"setupFiles": [
"./test/jest.overrides.ts"
]
}
}

31
node_modules/vega-lite/build/src/aggregate.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import { AggregateOp } from 'vega';
export declare const MULTIDOMAIN_SORT_OP_INDEX: {
count: number;
min: number;
max: number;
};
export interface ArgminDef {
argmin: string;
}
export interface ArgmaxDef {
argmax: string;
}
export declare type NonArgAggregateOp = Exclude<AggregateOp, 'argmin' | 'argmax'>;
export declare type Aggregate = NonArgAggregateOp | ArgmaxDef | ArgminDef;
export declare function isArgminDef(a: Aggregate | string): a is ArgminDef;
export declare function isArgmaxDef(a: Aggregate | string): a is ArgmaxDef;
export declare const AGGREGATE_OPS: AggregateOp[];
export declare function isAggregateOp(a: string | ArgminDef | ArgmaxDef): a is AggregateOp;
export declare const COUNTING_OPS: NonArgAggregateOp[];
export declare function isCountingAggregateOp(aggregate?: string | Aggregate): boolean;
export declare function isMinMaxOp(aggregate?: Aggregate | string): boolean;
/** Additive-based aggregation operations. These can be applied to stack. */
export declare const SUM_OPS: NonArgAggregateOp[];
/**
* Aggregation operators that always produce values within the range [domainMin, domainMax].
*/
export declare const SHARED_DOMAIN_OPS: AggregateOp[];
export declare const SHARED_DOMAIN_OP_INDEX: {
[T: string]: true;
};
//# sourceMappingURL=aggregate.d.ts.map

1
node_modules/vega-lite/build/src/aggregate.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../src/aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,MAAM,CAAC;AA8BjC,eAAO,MAAM,yBAAyB;;;;CAIrC,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAE1E,oBAAY,SAAS,GAAG,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAElE,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,CAAC,IAAI,SAAS,CAEjE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,CAAC,IAAI,SAAS,CAEjE;AAED,eAAO,MAAM,aAAa,eAA2B,CAAC;AAEtD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,CAAC,IAAI,WAAW,CAEjF;AAED,eAAO,MAAM,YAAY,EAAE,iBAAiB,EAA8C,CAAC;AAE3F,wBAAgB,qBAAqB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE7E;AAED,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAElE;AAED,4EAA4E;AAC5E,eAAO,MAAM,OAAO,EAAE,iBAAiB,EAAqD,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,EAA4D,CAAC;AAExG,eAAO,MAAM,sBAAsB;;CAA2B,CAAC"}

57
node_modules/vega-lite/build/src/aggregate.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
import { isString, toSet } from 'vega-util';
import { contains, keys } from './util';
const AGGREGATE_OP_INDEX = {
argmax: 1,
argmin: 1,
average: 1,
count: 1,
distinct: 1,
product: 1,
max: 1,
mean: 1,
median: 1,
min: 1,
missing: 1,
q1: 1,
q3: 1,
ci0: 1,
ci1: 1,
stderr: 1,
stdev: 1,
stdevp: 1,
sum: 1,
valid: 1,
values: 1,
variance: 1,
variancep: 1
};
export const MULTIDOMAIN_SORT_OP_INDEX = {
count: 1,
min: 1,
max: 1
};
export function isArgminDef(a) {
return !!a && !!a['argmin'];
}
export function isArgmaxDef(a) {
return !!a && !!a['argmax'];
}
export const AGGREGATE_OPS = keys(AGGREGATE_OP_INDEX);
export function isAggregateOp(a) {
return isString(a) && !!AGGREGATE_OP_INDEX[a];
}
export const COUNTING_OPS = ['count', 'valid', 'missing', 'distinct'];
export function isCountingAggregateOp(aggregate) {
return isString(aggregate) && contains(COUNTING_OPS, aggregate);
}
export function isMinMaxOp(aggregate) {
return isString(aggregate) && contains(['min', 'max'], aggregate);
}
/** Additive-based aggregation operations. These can be applied to stack. */
export const SUM_OPS = ['count', 'sum', 'distinct', 'valid', 'missing'];
/**
* Aggregation operators that always produce values within the range [domainMin, domainMax].
*/
export const SHARED_DOMAIN_OPS = ['mean', 'average', 'median', 'q1', 'q3', 'min', 'max'];
export const SHARED_DOMAIN_OP_INDEX = toSet(SHARED_DOMAIN_OPS);
//# sourceMappingURL=aggregate.js.map

1
node_modules/vega-lite/build/src/aggregate.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"aggregate.js","sourceRoot":"","sources":["../../src/aggregate.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAQ,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE5C,MAAM,kBAAkB,GAAsB;IAC5C,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;IACV,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CA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EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAwB,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAE7F;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAExG,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC"}

276
node_modules/vega-lite/build/src/axis.d.ts generated vendored Normal file
View File

@@ -0,0 +1,276 @@
import { Align, Axis as VgAxis, AxisEncode, AxisOrient, BaseAxis, Color, FontStyle, FontWeight, LabelOverlap, SignalRef, TextBaseline, TimeInterval, TimeIntervalStep } from 'vega';
import { ConditionalPredicate, Value, ValueDef } from './channeldef';
import { DateTime } from './datetime';
import { Guide, GuideEncodingEntry, TitleMixins, VlOnlyGuideConfig } from './guide';
import { Flag } from './util';
import { ExcludeMappedValueRefButKeepSignal, VgEncodeChannel } from './vega.schema';
export declare type BaseAxisNoValueRefs = AxisOverrideMixins & VLOnlyAxisMixins & ExcludeMappedValueRefButKeepSignal<BaseAxis>;
interface AxisOverrideMixins {
/**
* The anchor position of the axis in pixels. For x-axes with top or bottom orientation, this sets the axis group x coordinate. For y-axes with left or right orientation, this sets the axis group y coordinate.
*
* __Default value__: `0`
*/
position?: number | SignalRef;
/**
* The minimum desired step between axis ticks, in terms of scale domain values. For example, a value of `1` indicates that ticks should not be less than 1 unit apart. If `tickMinStep` is specified, the `tickCount` value will be adjusted, if necessary, to enforce the minimum step value.
*/
tickMinStep?: number | SignalRef;
/**
* A boolean flag indicating if grid lines should be included as part of the axis
*
* __Default value:__ `true` for [continuous scales](https://vega.github.io/vega-lite/docs/scale.html#continuous) that are not binned; otherwise, `false`.
*/
grid?: boolean;
/**
* Indicates if the first and last axis labels should be aligned flush with the scale range. Flush alignment for a horizontal axis will left-align the first label and right-align the last label. For vertical axes, bottom and top text baselines are applied instead. If this property is a number, it also indicates the number of pixels by which to offset the first and last labels; for example, a value of 2 will flush-align the first and last labels and also push them 2 pixels outward from the center of the axis. The additional adjustment can sometimes help the labels better visually group with corresponding axis ticks.
*
* __Default value:__ `true` for axis of a continuous x-scale. Otherwise, `false`.
*/
labelFlush?: boolean | number;
/**
* The strategy to use for resolving overlap of axis labels. If `false` (the default), no overlap reduction is attempted. If set to `true` or `"parity"`, a strategy of removing every other label is used (this works well for standard linear axes). If set to `"greedy"`, a linear scan of the labels is performed, removing any labels that overlaps with the last visible label (this often works better for log-scaled axes).
*
* __Default value:__ `true` for non-nominal fields with non-log scales; `"greedy"` for log scales; otherwise `false`.
*/
labelOverlap?: LabelOverlap;
/**
* The offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle.
*
* __Default value:__ derived from the [axis config](https://vega.github.io/vega-lite/docs/config.html#facet-scale-config)'s `offset` (`0` by default)
*/
offset?: number;
/**
* The orientation of the axis. One of `"top"`, `"bottom"`, `"left"` or `"right"`. The orientation can be used to further specialize the axis type (e.g., a y-axis oriented towards the right edge of the chart).
*
* __Default value:__ `"bottom"` for x-axes and `"left"` for y-axes.
*/
orient?: AxisOrient | SignalRef;
/**
* A desired number of ticks, for axes visualizing quantitative scales. The resulting number may be different so that values are "nice" (multiples of 2, 5, 10) and lie within the underlying scale's range.
*
* For scales of type `"time"` or `"utc"`, the tick count can instead be a time interval specifier. Legal string values are `"millisecond"`, `"second"`, `"minute"`, `"hour"`, `"day"`, `"week"`, `"month"`, and "year". Alternatively, an object-valued interval specifier of the form `{"interval": "month", "step": 3}` includes a desired number of interval steps. Here, ticks are generated for each quarter (Jan, Apr, Jul, Oct) boundary.
*
* __Default value__: Determine using a formula `ceil(width/40)` for x and `ceil(height/40)` for y.
*
* @minimum 0
*/
tickCount?: number | TimeInterval | TimeIntervalStep | SignalRef;
/**
* Explicitly set the visible axis tick values.
*/
values?: number[] | string[] | boolean[] | DateTime[] | SignalRef;
/**
* A non-negative integer indicating the z-index of the axis.
* If zindex is 0, axes should be drawn behind all chart elements.
* To put them in front, set `zindex` to `1` or more.
*
* __Default value:__ `0` (behind the marks).
*
* @TJS-type integer
* @minimum 0
*/
zindex?: number;
}
interface VLOnlyAxisMixins {
/**
* [Vega expression](https://vega.github.io/vega/docs/expressions/) for customizing labels.
*
* __Note:__ The label text and value can be assessed via the `label` and `value` properties of the axis's backing `datum` object.
*/
labelExpr?: string;
/**
* A string or array of strings indicating the name of custom styles to apply to the axis. A style is a named collection of axis property defined within the [style configuration](https://vega.github.io/vega-lite/docs/mark.html#style-config). If style is an array, later styles will override earlier styles.
*
* __Default value:__ (none)
* __Note:__ Any specified style will augment the default style. For example, an x-axis mark with `"style": "foo"` will use `config.axisX` and `config.style.foo` (the specified style `"foo"` has higher precedence).
*/
style?: string | string[];
}
export declare type SignalAxisProp = 'domainColor' | 'labelAlign' | 'labelColor' | 'gridColor' | 'tickColor' | 'titleColor' | 'title';
export declare type ConditionalAxisProp = 'labelAlign' | 'labelBaseline' | 'labelColor' | 'labelFont' | 'labelFontSize' | 'labelFontStyle' | 'labelFontWeight' | 'labelOpacity' | 'labelOffset' | 'labelPadding' | 'gridColor' | 'gridDash' | 'gridDashOffset' | 'gridOpacity' | 'gridWidth' | 'tickColor' | 'tickDash' | 'tickDashOffset' | 'tickOpacity' | 'tickSize' | 'tickWidth';
export declare const CONDITIONAL_AXIS_PROP_INDEX: Record<ConditionalAxisProp | SignalAxisProp, {
part: keyof AxisEncode;
vgProp: VgEncodeChannel;
} | null>;
export declare type ConditionalAxisProperty<V extends Value | number[]> = (ValueDef<V> | SignalRef) & {
condition: ConditionalPredicate<ValueDef<V> | SignalRef> | ConditionalPredicate<ValueDef<V> | SignalRef>[];
};
export declare function isConditionalAxisValue<V extends Value | number[]>(v: any): v is ConditionalAxisProperty<V>;
export declare type ConditionalAxisNumber = ConditionalAxisProperty<number | null>;
export declare type ConditionalAxisLabelAlign = ConditionalAxisProperty<Align | null>;
export declare type ConditionalAxisLabelBaseline = ConditionalAxisProperty<TextBaseline | null>;
export declare type ConditionalAxisColor = ConditionalAxisProperty<Color | null>;
export declare type ConditionalAxisString = ConditionalAxisProperty<string | null>;
export declare type ConditionalAxisLabelFontStyle = ConditionalAxisProperty<FontStyle | null>;
export declare type ConditionalAxisLabelFontWeight = ConditionalAxisProperty<FontWeight | null>;
export declare type ConditionalAxisNumberArray = ConditionalAxisProperty<number[] | null>;
export declare type AxisConfigBaseWithConditionalAndSignal = Omit<BaseAxisNoValueRefs, ConditionalAxisProp | SignalAxisProp> & AxisPropsWithConditionAndSignal;
export interface AxisPropsWithConditionAndSignal {
domainColor?: BaseAxisNoValueRefs['domainColor'] | SignalRef;
labelAlign?: BaseAxisNoValueRefs['labelAlign'] | ConditionalAxisLabelAlign;
labelBaseline?: BaseAxisNoValueRefs['labelBaseline'] | ConditionalAxisLabelBaseline;
labelColor?: BaseAxisNoValueRefs['labelColor'] | ConditionalAxisColor | SignalRef;
labelFont?: BaseAxisNoValueRefs['labelFont'] | ConditionalAxisString;
labelFontSize?: BaseAxisNoValueRefs['labelFontSize'] | ConditionalAxisNumber;
labelFontStyle?: BaseAxisNoValueRefs['labelFontStyle'] | ConditionalAxisLabelFontStyle;
labelFontWeight?: BaseAxisNoValueRefs['labelFontWeight'] | ConditionalAxisLabelFontWeight;
labelLineHeight?: BaseAxisNoValueRefs['labelLineHeight'] | ConditionalAxisNumber | SignalRef;
labelOpacity?: BaseAxisNoValueRefs['labelOpacity'] | ConditionalAxisNumber;
labelOffset?: BaseAxisNoValueRefs['labelOffset'] | ConditionalAxisNumber | SignalRef;
labelPadding?: BaseAxisNoValueRefs['labelPadding'] | ConditionalAxisNumber;
gridColor?: BaseAxisNoValueRefs['gridColor'] | ConditionalAxisColor | SignalRef;
gridDash?: BaseAxisNoValueRefs['gridDash'] | ConditionalAxisNumberArray;
gridDashOffset?: BaseAxisNoValueRefs['gridDashOffset'] | ConditionalAxisNumber;
gridOpacity?: BaseAxisNoValueRefs['gridOpacity'] | ConditionalAxisNumber;
gridWidth?: BaseAxisNoValueRefs['gridWidth'] | ConditionalAxisNumber;
tickColor?: BaseAxisNoValueRefs['tickColor'] | ConditionalAxisColor | SignalRef;
tickDash?: BaseAxisNoValueRefs['tickDash'] | ConditionalAxisNumberArray;
tickDashOffset?: BaseAxisNoValueRefs['tickDashOffset'] | ConditionalAxisNumber;
tickOpacity?: BaseAxisNoValueRefs['tickOpacity'] | ConditionalAxisNumber;
tickSize?: BaseAxisNoValueRefs['tickSize'] | ConditionalAxisNumber;
tickWidth?: BaseAxisNoValueRefs['tickWidth'] | ConditionalAxisNumber;
titleColor?: BaseAxisNoValueRefs['titleColor'] | SignalRef;
title?: TitleMixins['title'];
}
export declare type AxisConfig = Guide & VlOnlyGuideConfig & AxisConfigBaseWithConditionalAndSignal & {
/**
* Disable axis by default.
*/
disable?: boolean;
};
export interface Axis extends AxisConfigBaseWithConditionalAndSignal, Guide {
/**
* Mark definitions for custom axis encoding.
*
* @hidden
*/
encoding?: AxisEncoding;
}
export declare type AxisPart = keyof AxisEncoding;
export declare const AXIS_PARTS: AxisPart[];
/**
* A dictionary listing whether a certain axis property is applicable for only main axes or only grid axes.
*/
export declare const AXIS_PROPERTY_TYPE: Record<keyof VgAxis, 'main' | 'grid' | 'both'>;
export interface AxisEncoding {
/**
* Custom encoding for the axis container.
*/
axis?: GuideEncodingEntry;
/**
* Custom encoding for the axis domain rule mark.
*/
domain?: GuideEncodingEntry;
/**
* Custom encoding for axis gridline rule marks.
*/
grid?: GuideEncodingEntry;
/**
* Custom encoding for axis label text marks.
*/
labels?: GuideEncodingEntry;
/**
* Custom encoding for axis tick rule marks.
*/
ticks?: GuideEncodingEntry;
/**
* Custom encoding for the axis title text mark.
*/
title?: GuideEncodingEntry;
}
export declare const COMMON_AXIS_PROPERTIES_INDEX: Flag<keyof (VgAxis | Axis)>;
export declare function isAxisProperty(prop: string): prop is keyof Axis;
export declare const AXIS_PROPERTIES: ("orient" | "tickCount" | "aria" | "description" | "offset" | "titleAlign" | "titleAnchor" | "titleBaseline" | "titleColor" | "titleFont" | "titleFontSize" | "titleFontStyle" | "titleFontWeight" | "titleLimit" | "titleLineHeight" | "titleOpacity" | "titlePadding" | "labelAlign" | "labelBaseline" | "labelColor" | "labelFont" | "labelFontSize" | "labelFontStyle" | "labelFontWeight" | "labelLimit" | "labelOpacity" | "labelPadding" | "labelOffset" | "labelOverlap" | "labelSeparation" | "zindex" | "values" | "encoding" | "domain" | "title" | "labels" | "format" | "formatType" | "tickMinStep" | "labelExpr" | "titleAngle" | "labelAngle" | "labelLineHeight" | "translate" | "ticks" | "gridColor" | "gridDash" | "gridDashOffset" | "gridOpacity" | "gridWidth" | "tickColor" | "tickDash" | "tickDashOffset" | "tickOpacity" | "tickSize" | "tickWidth" | "domainColor" | "minExtent" | "maxExtent" | "bandPosition" | "titleX" | "titleY" | "domainCap" | "domainDash" | "domainDashOffset" | "domainOpacity" | "domainWidth" | "tickBand" | "tickCap" | "tickExtra" | "tickOffset" | "tickRound" | "grid" | "gridCap" | "labelBound" | "labelFlush" | "labelFlushOffset" | "position" | "style")[];
export interface AxisConfigMixins {
/**
* Axis configuration, which determines default properties for all `x` and `y` [axes](https://vega.github.io/vega-lite/docs/axis.html). For a full list of axis configuration options, please see the [corresponding section of the axis documentation](https://vega.github.io/vega-lite/docs/axis.html#config).
*/
axis?: AxisConfig;
/**
* X-axis specific config.
*/
axisX?: AxisConfig;
/**
* Y-axis specific config.
*/
axisY?: AxisConfig;
/**
* Config for y-axis along the left edge of the chart.
*/
axisLeft?: AxisConfig;
/**
* Config for y-axis along the right edge of the chart.
*/
axisRight?: AxisConfig;
/**
* Config for x-axis along the top edge of the chart.
*/
axisTop?: AxisConfig;
/**
* Config for x-axis along the bottom edge of the chart.
*/
axisBottom?: AxisConfig;
/**
* Config for axes with "band" scales.
*/
axisBand?: AxisConfig;
/**
* Config for axes with "point" scales.
*/
axisPoint?: AxisConfig;
/**
* Config for axes with "point" or "band" scales.
*/
axisDiscrete?: AxisConfig;
/**
* Config for quantitative axes.
*/
axisQuantitative?: AxisConfig;
/**
* Config for temporal axes.
*/
axisTemporal?: AxisConfig;
/**
* Config for x-axes with "band" scales.
*/
axisXBand?: AxisConfig;
/**
* Config for x-axes with "point" scales.
*/
axisXPoint?: AxisConfig;
/**
* Config for x-axes with "point" or "band" scales.
*/
axisXDiscrete?: AxisConfig;
/**
* Config for x-quantitative axes.
*/
axisXQuantitative?: AxisConfig;
/**
* Config for x-temporal axes.
*/
axisXTemporal?: AxisConfig;
/**
* Config for y-axes with "band" scales.
*/
axisYBand?: AxisConfig;
/**
* Config for y-axes with "point" scales.
*/
axisYPoint?: AxisConfig;
/**
* Config for y-axes with "point" or "band" scales.
*/
axisYDiscrete?: AxisConfig;
/**
* Config for y-quantitative axes.
*/
axisYQuantitative?: AxisConfig;
/**
* Config for y-temporal axes.
*/
axisYTemporal?: AxisConfig;
}
export {};
//# sourceMappingURL=axis.d.ts.map

1
node_modules/vega-lite/build/src/axis.d.ts.map generated vendored Normal file

File diff suppressed because one or more lines are too long

260
node_modules/vega-lite/build/src/axis.js generated vendored Normal file
View File

@@ -0,0 +1,260 @@
import { keys } from './util';
export const CONDITIONAL_AXIS_PROP_INDEX = {
domainColor: {
part: 'domain',
vgProp: 'stroke'
},
labelAlign: {
part: 'labels',
vgProp: 'align'
},
labelBaseline: {
part: 'labels',
vgProp: 'baseline'
},
labelColor: {
part: 'labels',
vgProp: 'fill'
},
labelFont: {
part: 'labels',
vgProp: 'font'
},
labelFontSize: {
part: 'labels',
vgProp: 'fontSize'
},
labelFontStyle: {
part: 'labels',
vgProp: 'fontStyle'
},
labelFontWeight: {
part: 'labels',
vgProp: 'fontWeight'
},
labelOpacity: {
part: 'labels',
vgProp: 'opacity'
},
labelOffset: null,
labelPadding: null,
gridColor: {
part: 'grid',
vgProp: 'stroke'
},
gridDash: {
part: 'grid',
vgProp: 'strokeDash'
},
gridDashOffset: {
part: 'grid',
vgProp: 'strokeDashOffset'
},
gridOpacity: {
part: 'grid',
vgProp: 'opacity'
},
gridWidth: {
part: 'grid',
vgProp: 'strokeWidth'
},
tickColor: {
part: 'ticks',
vgProp: 'stroke'
},
tickDash: {
part: 'ticks',
vgProp: 'strokeDash'
},
tickDashOffset: {
part: 'ticks',
vgProp: 'strokeDashOffset'
},
tickOpacity: {
part: 'ticks',
vgProp: 'opacity'
},
tickSize: null,
tickWidth: {
part: 'ticks',
vgProp: 'strokeWidth'
},
titleColor: {
part: 'title',
vgProp: 'fill'
},
title: null // title supports signal, let's use it.
};
export function isConditionalAxisValue(v) {
return v && v['condition'];
}
export const AXIS_PARTS = ['domain', 'grid', 'labels', 'ticks', 'title'];
/**
* A dictionary listing whether a certain axis property is applicable for only main axes or only grid axes.
*/
export const AXIS_PROPERTY_TYPE = {
grid: 'grid',
gridCap: 'grid',
gridColor: 'grid',
gridDash: 'grid',
gridDashOffset: 'grid',
gridOpacity: 'grid',
gridScale: 'grid',
gridWidth: 'grid',
orient: 'main',
bandPosition: 'both',
aria: 'main',
description: 'main',
domain: 'main',
domainCap: 'main',
domainColor: 'main',
domainDash: 'main',
domainDashOffset: 'main',
domainOpacity: 'main',
domainWidth: 'main',
format: 'main',
formatType: 'main',
labelAlign: 'main',
labelAngle: 'main',
labelBaseline: 'main',
labelBound: 'main',
labelColor: 'main',
labelFlush: 'main',
labelFlushOffset: 'main',
labelFont: 'main',
labelFontSize: 'main',
labelFontStyle: 'main',
labelFontWeight: 'main',
labelLimit: 'main',
labelLineHeight: 'main',
labelOffset: 'main',
labelOpacity: 'main',
labelOverlap: 'main',
labelPadding: 'main',
labels: 'main',
labelSeparation: 'main',
maxExtent: 'main',
minExtent: 'main',
offset: 'both',
position: 'main',
tickCap: 'main',
tickColor: 'main',
tickDash: 'main',
tickDashOffset: 'main',
tickMinStep: 'main',
tickOffset: 'both',
tickOpacity: 'main',
tickRound: 'both',
ticks: 'main',
tickSize: 'main',
tickWidth: 'both',
title: 'main',
titleAlign: 'main',
titleAnchor: 'main',
titleAngle: 'main',
titleBaseline: 'main',
titleColor: 'main',
titleFont: 'main',
titleFontSize: 'main',
titleFontStyle: 'main',
titleFontWeight: 'main',
titleLimit: 'main',
titleLineHeight: 'main',
titleOpacity: 'main',
titlePadding: 'main',
titleX: 'main',
titleY: 'main',
encode: 'both',
scale: 'both',
tickBand: 'both',
tickCount: 'both',
tickExtra: 'both',
translate: 'both',
values: 'both',
zindex: 'both' // this is actually set afterward, so it doesn't matter
};
export const COMMON_AXIS_PROPERTIES_INDEX = {
orient: 1,
aria: 1,
bandPosition: 1,
description: 1,
domain: 1,
domainCap: 1,
domainColor: 1,
domainDash: 1,
domainDashOffset: 1,
domainOpacity: 1,
domainWidth: 1,
format: 1,
formatType: 1,
grid: 1,
gridCap: 1,
gridColor: 1,
gridDash: 1,
gridDashOffset: 1,
gridOpacity: 1,
gridWidth: 1,
labelAlign: 1,
labelAngle: 1,
labelBaseline: 1,
labelBound: 1,
labelColor: 1,
labelFlush: 1,
labelFlushOffset: 1,
labelFont: 1,
labelFontSize: 1,
labelFontStyle: 1,
labelFontWeight: 1,
labelLimit: 1,
labelLineHeight: 1,
labelOffset: 1,
labelOpacity: 1,
labelOverlap: 1,
labelPadding: 1,
labels: 1,
labelSeparation: 1,
maxExtent: 1,
minExtent: 1,
offset: 1,
position: 1,
tickBand: 1,
tickCap: 1,
tickColor: 1,
tickCount: 1,
tickDash: 1,
tickDashOffset: 1,
tickExtra: 1,
tickMinStep: 1,
tickOffset: 1,
tickOpacity: 1,
tickRound: 1,
ticks: 1,
tickSize: 1,
tickWidth: 1,
title: 1,
titleAlign: 1,
titleAnchor: 1,
titleAngle: 1,
titleBaseline: 1,
titleColor: 1,
titleFont: 1,
titleFontSize: 1,
titleFontStyle: 1,
titleFontWeight: 1,
titleLimit: 1,
titleLineHeight: 1,
titleOpacity: 1,
titlePadding: 1,
titleX: 1,
titleY: 1,
translate: 1,
values: 1,
zindex: 1
};
const AXIS_PROPERTIES_INDEX = Object.assign(Object.assign({}, COMMON_AXIS_PROPERTIES_INDEX), { style: 1, labelExpr: 1, encoding: 1 });
export function isAxisProperty(prop) {
return !!AXIS_PROPERTIES_INDEX[prop];
}
// Export for dependent projects
export const AXIS_PROPERTIES = keys(AXIS_PROPERTIES_INDEX);
//# sourceMappingURL=axis.js.map

1
node_modules/vega-lite/build/src/axis.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

85
node_modules/vega-lite/build/src/bin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import { ExtendedChannel } from './channel';
import { SelectionExtent } from './selection';
export interface BaseBin {
/**
* The number base to use for automatic bin determination (default is base 10).
*
* __Default value:__ `10`
*
*/
base?: number;
/**
* An exact step size to use between bins.
*
* __Note:__ If provided, options such as maxbins will be ignored.
*/
step?: number;
/**
* An array of allowable step sizes to choose from.
* @minItems 1
*/
steps?: number[];
/**
* A minimum allowable step size (particularly useful for integer values).
*/
minstep?: number;
/**
* Scale factors indicating allowable subdivisions. The default value is [5, 2], which indicates that for base 10 numbers (the default base), the method may consider dividing bin sizes by 5 and/or 2. For example, for an initial step size of 10, the method can check if bin sizes of 2 (= 10/5), 5 (= 10/2), or 1 (= 10/(5*2)) might also satisfy the given constraints.
*
* __Default value:__ `[5, 2]`
*
* @minItems 1
*/
divide?: [number, number];
/**
* Maximum number of bins.
*
* __Default value:__ `6` for `row`, `column` and `shape` channels; `10` for other channels
*
* @minimum 2
*/
maxbins?: number;
/**
* A value in the binned domain at which to anchor the bins, shifting the bin boundaries if necessary to ensure that a boundary aligns with the anchor value.
*
* __Default value:__ the minimum bin extent value
*/
anchor?: number;
/**
* If true, attempts to make the bin boundaries use human-friendly boundaries, such as multiples of ten.
*
* __Default value:__ `true`
*/
nice?: boolean;
}
/**
* Binning properties or boolean flag for determining whether to bin data or not.
*/
export interface BinParams extends BaseBin {
/**
* A two-element (`[min, max]`) array indicating the range of desired bin values.
*/
extent?: BinExtent;
/**
* When set to `true`, Vega-Lite treats the input data as already binned.
*/
binned?: boolean;
}
export declare type Bin = boolean | BinParams | 'binned' | null;
export declare type BinExtent = [number, number] | SelectionExtent;
/**
* Create a key for the bin configuration. Not for prebinned bin.
*/
export declare function binToString(bin: BinParams | true): string;
/**
* Vega-Lite should bin the data.
*/
export declare function isBinning(bin: BinParams | boolean | 'binned'): bin is BinParams | true;
/**
* The data is already binned and so Vega-Lite should not bin it again.
*/
export declare function isBinned(bin: BinParams | boolean | 'binned'): bin is 'binned' | BinParams;
export declare function isBinParams(bin: BinParams | boolean | 'binned'): bin is BinParams;
export declare function isSelectionExtent(extent: BinExtent): extent is SelectionExtent;
export declare function autoMaxBins(channel?: ExtendedChannel): number;
//# sourceMappingURL=bin.d.ts.map

1
node_modules/vega-lite/build/src/bin.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/bin.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,eAAe,EAWhB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAG5C,MAAM,WAAW,OAAO;IACtB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,oBAAY,GAAG,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC;AAExD,oBAAY,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,eAAe,CAAC;AAE3D;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,UAUhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,GAAG,IAAI,SAAS,GAAG,IAAI,CAEtF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,GAAG,IAAI,QAAQ,GAAG,SAAS,CAEzF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,GAAG,IAAI,SAAS,CAEjF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,eAAe,CAE9E;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM,CAqB7D"}

57
node_modules/vega-lite/build/src/bin.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
import { isBoolean, isObject } from 'vega-util';
import { COLOR, COLUMN, FILL, FILLOPACITY, OPACITY, ROW, SHAPE, SIZE, STROKE, STROKEDASH, STROKEOPACITY, STROKEWIDTH } from './channel';
import { normalizeBin } from './channeldef';
import { keys, varName } from './util';
/**
* Create a key for the bin configuration. Not for prebinned bin.
*/
export function binToString(bin) {
if (isBoolean(bin)) {
bin = normalizeBin(bin, undefined);
}
return ('bin' +
keys(bin)
.map(p => (isSelectionExtent(bin[p]) ? varName(`_${p}_${Object.entries(bin[p])}`) : varName(`_${p}_${bin[p]}`)))
.join(''));
}
/**
* Vega-Lite should bin the data.
*/
export function isBinning(bin) {
return bin === true || (isBinParams(bin) && !bin.binned);
}
/**
* The data is already binned and so Vega-Lite should not bin it again.
*/
export function isBinned(bin) {
return bin === 'binned' || (isBinParams(bin) && bin.binned === true);
}
export function isBinParams(bin) {
return isObject(bin);
}
export function isSelectionExtent(extent) {
return extent === null || extent === void 0 ? void 0 : extent['selection'];
}
export function autoMaxBins(channel) {
switch (channel) {
case ROW:
case COLUMN:
case SIZE:
case COLOR:
case FILL:
case STROKE:
case STROKEWIDTH:
case OPACITY:
case FILLOPACITY:
case STROKEOPACITY:
// Facets and Size shouldn't have too many bins
// We choose 6 like shape to simplify the rule [falls through]
case SHAPE:
return 6; // Vega's "shape" has 6 distinct values
case STROKEDASH:
return 4; // We only provide 5 different stroke dash values (but 4 is more effective)
default:
return 10;
}
}
//# sourceMappingURL=bin.js.map

1
node_modules/vega-lite/build/src/bin.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,KAAK,EACL,MAAM,EAEN,IAAI,EACJ,WAAW,EACX,OAAO,EACP,GAAG,EACH,KAAK,EACL,IAAI,EACJ,MAAM,EACN,UAAU,EACV,aAAa,EACb,WAAW,EACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,QAAQ,CAAC;AA0ErC;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAqB;IAC/C,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE;QAClB,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;KACpC;IACD,OAAO,CACL,KAAK;QACL,IAAI,CAAC,GAAG,CAAC;aACN,GAAG,CAAC,C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KAAK;YACR,OAAO,CAAC,CAAC,CAAC,uCAAuC;QACnD,KAAK,UAAU;YACb,OAAO,CAAC,CAAC,CAAC,2EAA2E;QACvF;YACE,OAAO,EAAE,CAAC;KACb;AACH,CAAC"}

143
node_modules/vega-lite/build/src/channel.d.ts generated vendored Normal file
View File

@@ -0,0 +1,143 @@
import { RangeType } from './compile/scale/type';
import { Encoding } from './encoding';
import { Mark } from './mark';
import { EncodingFacetMapping } from './spec/facet';
export declare type Channel = keyof Encoding<any>;
export declare type ExtendedChannel = Channel | FacetChannel;
export declare const ROW: "row";
export declare const COLUMN: "column";
export declare const FACET: "facet";
export declare const X: "x";
export declare const Y: "y";
export declare const X2: "x2";
export declare const Y2: "y2";
export declare const RADIUS: "radius";
export declare const RADIUS2: "radius2";
export declare const THETA: "theta";
export declare const THETA2: "theta2";
export declare const LATITUDE: "latitude";
export declare const LONGITUDE: "longitude";
export declare const LATITUDE2: "latitude2";
export declare const LONGITUDE2: "longitude2";
export declare const COLOR: "color";
export declare const FILL: "fill";
export declare const STROKE: "stroke";
export declare const SHAPE: "shape";
export declare const SIZE: "size";
export declare const ANGLE: "angle";
export declare const OPACITY: "opacity";
export declare const FILLOPACITY: "fillOpacity";
export declare const STROKEOPACITY: "strokeOpacity";
export declare const STROKEWIDTH: "strokeWidth";
export declare const STROKEDASH: "strokeDash";
export declare const TEXT: "text";
export declare const ORDER: "order";
export declare const DETAIL: "detail";
export declare const KEY: "key";
export declare const TOOLTIP: "tooltip";
export declare const HREF: "href";
export declare const URL: "url";
export declare const DESCRIPTION: "description";
declare const POSITION_CHANNEL_INDEX: {
readonly x: 1;
readonly y: 1;
readonly x2: 1;
readonly y2: 1;
};
export declare type PositionChannel = keyof typeof POSITION_CHANNEL_INDEX;
declare const POLAR_POSITION_CHANNEL_INDEX: {
readonly theta: 1;
readonly theta2: 1;
readonly radius: 1;
readonly radius2: 1;
};
export declare type PolarPositionChannel = keyof typeof POLAR_POSITION_CHANNEL_INDEX;
export declare function isPolarPositionChannel(c: Channel): c is PolarPositionChannel;
declare const GEO_POSIITON_CHANNEL_INDEX: {
readonly longitude: 1;
readonly longitude2: 1;
readonly latitude: 1;
readonly latitude2: 1;
};
export declare type GeoPositionChannel = keyof typeof GEO_POSIITON_CHANNEL_INDEX;
export declare function getPositionChannelFromLatLong(channel: GeoPositionChannel): PositionChannel;
export declare function isGeoPositionChannel(c: Channel): c is GeoPositionChannel;
export declare const GEOPOSITION_CHANNELS: ("longitude" | "latitude" | "longitude2" | "latitude2")[];
export declare type ColorChannel = 'color' | 'fill' | 'stroke';
export declare function isColorChannel(channel: Channel): channel is ColorChannel;
export declare type FacetChannel = keyof EncodingFacetMapping<any>;
export declare const FACET_CHANNELS: ("facet" | "row" | "column")[];
export declare const CHANNELS: ExtendedChannel[];
/**
* Channels that cannot have an array of channelDef.
* model.fieldDef, getFieldDef only work for these channels.
*
* (The only two channels that can have an array of channelDefs are "detail" and "order".
* Since there can be multiple fieldDefs for detail and order, getFieldDef/model.fieldDef
* are not applicable for them. Similarly, selection projection won't work with "detail" and "order".)
*/
export declare const SINGLE_DEF_CHANNELS: ("stroke" | "color" | "text" | "shape" | "description" | "x" | "y" | "x2" | "y2" | "longitude" | "latitude" | "longitude2" | "latitude2" | "theta" | "theta2" | "radius" | "radius2" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "strokeDash" | "size" | "angle" | "key" | "href" | "url" | "facet" | "row" | "column")[];
export declare type SingleDefChannel = typeof SINGLE_DEF_CHANNELS[number];
export declare const SINGLE_DEF_UNIT_CHANNELS: ("stroke" | "color" | "text" | "shape" | "description" | "x" | "y" | "x2" | "y2" | "longitude" | "latitude" | "longitude2" | "latitude2" | "theta" | "theta2" | "radius" | "radius2" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "strokeDash" | "size" | "angle" | "key" | "href" | "url")[];
export declare type SingleDefUnitChannel = typeof SINGLE_DEF_UNIT_CHANNELS[number];
export declare function isSingleDefUnitChannel(str: string): str is SingleDefUnitChannel;
export declare function isChannel(str: string): str is Channel;
export declare type SecondaryRangeChannel = 'x2' | 'y2' | 'latitude2' | 'longitude2' | 'theta2' | 'radius2';
export declare const SECONDARY_RANGE_CHANNEL: SecondaryRangeChannel[];
export declare function isSecondaryRangeChannel(c: ExtendedChannel): c is SecondaryRangeChannel;
export declare type MainChannelOf<C extends ExtendedChannel> = C extends 'x2' ? 'x' : C extends 'y2' ? 'y' : C extends 'latitude2' ? 'latitude' : C extends 'longitude2' ? 'longitude' : C extends 'theta2' ? 'theta' : C extends 'radius2' ? 'radius' : C;
/**
* Get the main channel for a range channel. E.g. `x` for `x2`.
*/
export declare function getMainRangeChannel<C extends ExtendedChannel>(channel: C): MainChannelOf<C>;
export declare type SecondaryChannelOf<C extends Channel> = C extends 'x' ? 'x2' : C extends 'y' ? 'y2' : C extends 'latitude' ? 'latitude2' : C extends 'longitude' ? 'longitude2' : C extends 'theta' ? 'theta2' : C extends 'radius' ? 'radius2' : undefined;
export declare function getVgPositionChannel(channel: PolarPositionChannel | PositionChannel): "x" | "y" | "x2" | "y2" | "innerRadius" | "outerRadius" | "startAngle" | "endAngle";
/**
* Get the main channel for a range channel. E.g. `x` for `x2`.
*/
export declare function getSecondaryRangeChannel<C extends Channel>(channel: C): SecondaryChannelOf<C> | undefined;
export declare function getSizeChannel(channel: PositionChannel): 'width' | 'height';
export declare function getSizeChannel(channel: Channel): 'width' | 'height' | undefined;
/**
* Get the main channel for a range channel. E.g. `x` for `x2`.
*/
export declare function getOffsetChannel(channel: Channel): "xOffset" | "yOffset" | "x2Offset" | "y2Offset" | "thetaOffset" | "radiusOffset" | "theta2Offset" | "radius2Offset";
export declare const UNIT_CHANNELS: ("stroke" | "color" | "text" | "shape" | "description" | "x" | "y" | "x2" | "y2" | "longitude" | "latitude" | "longitude2" | "latitude2" | "theta" | "theta2" | "radius" | "radius2" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "strokeDash" | "size" | "angle" | "detail" | "key" | "tooltip" | "href" | "url" | "order")[];
export declare const NONPOSITION_CHANNELS: ("stroke" | "color" | "text" | "shape" | "description" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "strokeDash" | "size" | "angle" | "detail" | "key" | "tooltip" | "href" | "url" | "order")[];
export declare type NonPositionChannel = typeof NONPOSITION_CHANNELS[number];
export declare const POSITION_SCALE_CHANNEL_INDEX: {
readonly x: 1;
readonly y: 1;
};
export declare const POSITION_SCALE_CHANNELS: ("x" | "y")[];
export declare type PositionScaleChannel = keyof typeof POSITION_SCALE_CHANNEL_INDEX;
export declare function isXorY(channel: ExtendedChannel): channel is PositionScaleChannel;
export declare const POLAR_POSITION_SCALE_CHANNEL_INDEX: {
readonly theta: 1;
readonly radius: 1;
};
export declare const POLAR_POSITION_SCALE_CHANNELS: ("theta" | "radius")[];
export declare type PolarPositionScaleChannel = keyof typeof POLAR_POSITION_SCALE_CHANNEL_INDEX;
export declare function getPositionScaleChannel(sizeType: 'width' | 'height'): PositionScaleChannel;
export declare const NONPOSITION_SCALE_CHANNELS: ("stroke" | "color" | "shape" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "strokeDash" | "size" | "angle")[];
export declare type NonPositionScaleChannel = typeof NONPOSITION_SCALE_CHANNELS[number];
export declare function isNonPositionScaleChannel(channel: Channel): channel is NonPositionScaleChannel;
/**
* @returns whether Vega supports legends for a particular channel
*/
export declare function supportLegend(channel: NonPositionScaleChannel): boolean;
/** List of channels with scales */
export declare const SCALE_CHANNELS: ("stroke" | "color" | "shape" | "x" | "y" | "theta" | "radius" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "strokeDash" | "size" | "angle")[];
export declare type ScaleChannel = typeof SCALE_CHANNELS[number];
export declare function isScaleChannel(channel: Channel): channel is ScaleChannel;
export declare type SupportedMark = Partial<Record<Mark, 'always' | 'binned'>>;
/**
* Return whether a channel supports a particular mark type.
* @param channel channel name
* @param mark the mark type
* @return whether the mark supports the channel
*/
export declare function supportMark(channel: Channel, mark: Mark): "binned" | "always";
export declare function rangeType(channel: ExtendedChannel): RangeType;
export {};
//# sourceMappingURL=channel.d.ts.map

1
node_modules/vega-lite/build/src/channel.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/channel.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAGlD,oBAAY,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC1C,oBAAY,eAAe,GAAG,OAAO,GAAG,YAAY,CAAC;AAGrD,eAAO,MAAM,GAAG,OAAiB,CAAC;AAClC,eAAO,MAAM,MAAM,UAAoB,CAAC;AAExC,eAAO,MAAM,KAAK,SAAmB,CAAC;AAGtC,eAAO,MAAM,CAAC,KAAe,CAAC;AAC9B,eAAO,MAAM,CAAC,KAAe,CAAC;AAC9B,eAAO,MAAM,EAAE,MAAgB,CAAC;AAChC,eAAO,MAAM,EAAE,MAAgB,CAAC;AAGhC,eAAO,MAAM,MAAM,UAAoB,CAAC;AACxC,eAAO,MAAM,OAAO,WAAqB,CAAC;AAC1C,eAAO,MAAM,KAAK,SAAmB,CAAC;AACtC,eAAO,MAAM,MAAM,UAAoB,CAAC;AAGxC,eAAO,MAAM,QAAQ,YAAsB,CAAC;AAC5C,eAAO,MAAM,SAAS,aAAuB,CAAC;AAC9C,eAAO,MAAM,SAAS,aAAuB,CAAC;AAC9C,eAAO,MAAM,UAAU,cAAwB,CAAC;AAGhD,eAAO,MAAM,KAAK,SAAmB,CAAC;AAEtC,eAAO,MAAM,IAAI,QAAkB,CAAC;AAEpC,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M,OAAO,kCAAkC,CAAC;AAExF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,oBAAoB,CAE1F;AAkBD,eAAO,MAAM,0BAA0B,2IAAwC,CAAC;AAChF,oBAAY,uBAAuB,GAAG,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;AAEhF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,uBAAuB,CAE9F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,uBAAuB,WAgB7D;AASD,mCAAmC;AACnC,eAAO,MAAM,cAAc,4KAA4B,CAAC;AACxD,oBAAY,YAAY,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAEzD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,YAAY,CAExE;AAED,oBAAY,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,uBAEvD;AAmHD,wBAAgB,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,CAkD7D"}

441
node_modules/vega-lite/build/src/channel.js generated vendored Normal file
View File

@@ -0,0 +1,441 @@
/*
* Constants and utilities for encoding channels (Visual variables)
* such as 'x', 'y', 'color'.
*/
import { __rest } from "tslib";
import { keys } from './util';
// Facet
export const ROW = 'row';
export const COLUMN = 'column';
export const FACET = 'facet';
// Position
export const X = 'x';
export const Y = 'y';
export const X2 = 'x2';
export const Y2 = 'y2';
// Arc-Position
export const RADIUS = 'radius';
export const RADIUS2 = 'radius2';
export const THETA = 'theta';
export const THETA2 = 'theta2';
// Geo Position
export const LATITUDE = 'latitude';
export const LONGITUDE = 'longitude';
export const LATITUDE2 = 'latitude2';
export const LONGITUDE2 = 'longitude2';
// Mark property with scale
export const COLOR = 'color';
export const FILL = 'fill';
export const STROKE = 'stroke';
export const SHAPE = 'shape';
export const SIZE = 'size';
export const ANGLE = 'angle';
export const OPACITY = 'opacity';
export const FILLOPACITY = 'fillOpacity';
export const STROKEOPACITY = 'strokeOpacity';
export const STROKEWIDTH = 'strokeWidth';
export const STROKEDASH = 'strokeDash';
// Non-scale channel
export const TEXT = 'text';
export const ORDER = 'order';
export const DETAIL = 'detail';
export const KEY = 'key';
export const TOOLTIP = 'tooltip';
export const HREF = 'href';
export const URL = 'url';
export const DESCRIPTION = 'description';
const POSITION_CHANNEL_INDEX = {
x: 1,
y: 1,
x2: 1,
y2: 1
};
const POLAR_POSITION_CHANNEL_INDEX = {
theta: 1,
theta2: 1,
radius: 1,
radius2: 1
};
export function isPolarPositionChannel(c) {
return c in POLAR_POSITION_CHANNEL_INDEX;
}
const GEO_POSIITON_CHANNEL_INDEX = {
longitude: 1,
longitude2: 1,
latitude: 1,
latitude2: 1
};
export function getPositionChannelFromLatLong(channel) {
switch (channel) {
case LATITUDE:
return 'y';
case LATITUDE2:
return 'y2';
case LONGITUDE:
return 'x';
case LONGITUDE2:
return 'x2';
}
}
export function isGeoPositionChannel(c) {
return c in GEO_POSIITON_CHANNEL_INDEX;
}
export const GEOPOSITION_CHANNELS = keys(GEO_POSIITON_CHANNEL_INDEX);
const UNIT_CHANNEL_INDEX = Object.assign(Object.assign(Object.assign(Object.assign({}, POSITION_CHANNEL_INDEX), POLAR_POSITION_CHANNEL_INDEX), GEO_POSIITON_CHANNEL_INDEX), {
// color
color: 1, fill: 1, stroke: 1,
// other non-position with scale
opacity: 1, fillOpacity: 1, strokeOpacity: 1, strokeWidth: 1, strokeDash: 1, size: 1, angle: 1, shape: 1,
// channels without scales
order: 1, text: 1, detail: 1, key: 1, tooltip: 1, href: 1, url: 1, description: 1 });
export function isColorChannel(channel) {
return channel === COLOR || channel === FILL || channel === STROKE;
}
const FACET_CHANNEL_INDEX = {
row: 1,
column: 1,
facet: 1
};
export const FACET_CHANNELS = keys(FACET_CHANNEL_INDEX);
const CHANNEL_INDEX = Object.assign(Object.assign({}, UNIT_CHANNEL_INDEX), FACET_CHANNEL_INDEX);
export const CHANNELS = keys(CHANNEL_INDEX);
const { order: _o, detail: _d, tooltip: _tt1 } = CHANNEL_INDEX, SINGLE_DEF_CHANNEL_INDEX = __rest(CHANNEL_INDEX, ["order", "detail", "tooltip"]);
const { row: _r, column: _c, facet: _f } = SINGLE_DEF_CHANNEL_INDEX, SINGLE_DEF_UNIT_CHANNEL_INDEX = __rest(SINGLE_DEF_CHANNEL_INDEX, ["row", "column", "facet"]);
/**
* Channels that cannot have an array of channelDef.
* model.fieldDef, getFieldDef only work for these channels.
*
* (The only two channels that can have an array of channelDefs are "detail" and "order".
* Since there can be multiple fieldDefs for detail and order, getFieldDef/model.fieldDef
* are not applicable for them. Similarly, selection projection won't work with "detail" and "order".)
*/
export const SINGLE_DEF_CHANNELS = keys(SINGLE_DEF_CHANNEL_INDEX);
export const SINGLE_DEF_UNIT_CHANNELS = keys(SINGLE_DEF_UNIT_CHANNEL_INDEX);
export function isSingleDefUnitChannel(str) {
return !!SINGLE_DEF_UNIT_CHANNEL_INDEX[str];
}
export function isChannel(str) {
return !!CHANNEL_INDEX[str];
}
export const SECONDARY_RANGE_CHANNEL = [X2, Y2, LATITUDE2, LONGITUDE2, THETA2, RADIUS2];
export function isSecondaryRangeChannel(c) {
const main = getMainRangeChannel(c);
return main !== c;
}
/**
* Get the main channel for a range channel. E.g. `x` for `x2`.
*/
export function getMainRangeChannel(channel) {
switch (channel) {
case X2:
return X;
case Y2:
return Y;
case LATITUDE2:
return LATITUDE;
case LONGITUDE2:
return LONGITUDE;
case THETA2:
return THETA;
case RADIUS2:
return RADIUS;
}
return channel;
}
export function getVgPositionChannel(channel) {
if (isPolarPositionChannel(channel)) {
switch (channel) {
case THETA:
return 'startAngle';
case THETA2:
return 'endAngle';
case RADIUS:
return 'outerRadius';
case RADIUS2:
return 'innerRadius';
}
}
return channel;
}
/**
* Get the main channel for a range channel. E.g. `x` for `x2`.
*/
export function getSecondaryRangeChannel(channel) {
switch (channel) {
case X:
return X2;
case Y:
return Y2;
case LATITUDE:
return LATITUDE2;
case LONGITUDE:
return LONGITUDE2;
case THETA:
return THETA2;
case RADIUS:
return RADIUS2;
}
return undefined;
}
export function getSizeChannel(channel) {
switch (channel) {
case X:
case X2:
return 'width';
case Y:
case Y2:
return 'height';
}
return undefined;
}
/**
* Get the main channel for a range channel. E.g. `x` for `x2`.
*/
export function getOffsetChannel(channel) {
switch (channel) {
case X:
return 'xOffset';
case Y:
return 'yOffset';
case X2:
return 'x2Offset';
case Y2:
return 'y2Offset';
case THETA:
return 'thetaOffset';
case RADIUS:
return 'radiusOffset';
case THETA2:
return 'theta2Offset';
case RADIUS2:
return 'radius2Offset';
}
return undefined;
}
// CHANNELS without COLUMN, ROW
export const UNIT_CHANNELS = keys(UNIT_CHANNEL_INDEX);
// NONPOSITION_CHANNELS = UNIT_CHANNELS without X, Y, X2, Y2;
const { x: _x, y: _y,
// x2 and y2 share the same scale as x and y
x2: _x2, y2: _y2, latitude: _latitude, longitude: _longitude, latitude2: _latitude2, longitude2: _longitude2, theta: _theta, theta2: _theta2, radius: _radius, radius2: _radius2 } = UNIT_CHANNEL_INDEX,
// The rest of unit channels then have scale
NONPOSITION_CHANNEL_INDEX = __rest(UNIT_CHANNEL_INDEX, ["x", "y", "x2", "y2", "latitude", "longitude", "latitude2", "longitude2", "theta", "theta2", "radius", "radius2"]);
export const NONPOSITION_CHANNELS = keys(NONPOSITION_CHANNEL_INDEX);
export const POSITION_SCALE_CHANNEL_INDEX = {
x: 1,
y: 1
};
export const POSITION_SCALE_CHANNELS = keys(POSITION_SCALE_CHANNEL_INDEX);
export function isXorY(channel) {
return channel in POSITION_SCALE_CHANNEL_INDEX;
}
export const POLAR_POSITION_SCALE_CHANNEL_INDEX = {
theta: 1,
radius: 1
};
export const POLAR_POSITION_SCALE_CHANNELS = keys(POLAR_POSITION_SCALE_CHANNEL_INDEX);
export function getPositionScaleChannel(sizeType) {
return sizeType === 'width' ? X : Y;
}
// NON_POSITION_SCALE_CHANNEL = SCALE_CHANNELS without X, Y
const {
// x2 and y2 share the same scale as x and y
// text and tooltip have format instead of scale,
// href has neither format, nor scale
text: _t, tooltip: _tt, href: _hr, url: _u, description: _al,
// detail and order have no scale
detail: _dd, key: _k, order: _oo } = NONPOSITION_CHANNEL_INDEX, NONPOSITION_SCALE_CHANNEL_INDEX = __rest(NONPOSITION_CHANNEL_INDEX, ["text", "tooltip", "href", "url", "description", "detail", "key", "order"]);
export const NONPOSITION_SCALE_CHANNELS = keys(NONPOSITION_SCALE_CHANNEL_INDEX);
export function isNonPositionScaleChannel(channel) {
return !!NONPOSITION_CHANNEL_INDEX[channel];
}
/**
* @returns whether Vega supports legends for a particular channel
*/
export function supportLegend(channel) {
switch (channel) {
case COLOR:
case FILL:
case STROKE:
case SIZE:
case SHAPE:
case OPACITY:
case STROKEWIDTH:
case STROKEDASH:
return true;
case FILLOPACITY:
case STROKEOPACITY:
case ANGLE:
return false;
}
}
// Declare SCALE_CHANNEL_INDEX
const SCALE_CHANNEL_INDEX = Object.assign(Object.assign(Object.assign({}, POSITION_SCALE_CHANNEL_INDEX), POLAR_POSITION_SCALE_CHANNEL_INDEX), NONPOSITION_SCALE_CHANNEL_INDEX);
/** List of channels with scales */
export const SCALE_CHANNELS = keys(SCALE_CHANNEL_INDEX);
export function isScaleChannel(channel) {
return !!SCALE_CHANNEL_INDEX[channel];
}
/**
* Return whether a channel supports a particular mark type.
* @param channel channel name
* @param mark the mark type
* @return whether the mark supports the channel
*/
export function supportMark(channel, mark) {
return getSupportedMark(channel)[mark];
}
const ALL_MARKS = {
// all marks
arc: 'always',
area: 'always',
bar: 'always',
circle: 'always',
geoshape: 'always',
image: 'always',
line: 'always',
rule: 'always',
point: 'always',
rect: 'always',
square: 'always',
trail: 'always',
text: 'always',
tick: 'always'
};
const { geoshape: _g } = ALL_MARKS, ALL_MARKS_EXCEPT_GEOSHAPE = __rest(ALL_MARKS, ["geoshape"]);
/**
* Return a dictionary showing whether a channel supports mark type.
* @param channel
* @return A dictionary mapping mark types to 'always', 'binned', or undefined
*/
function getSupportedMark(channel) {
switch (channel) {
case COLOR:
case FILL:
case STROKE:
// falls through
case DESCRIPTION:
case DETAIL:
case KEY:
case TOOLTIP:
case HREF:
case ORDER: // TODO: revise (order might not support rect, which is not stackable?)
case OPACITY:
case FILLOPACITY:
case STROKEOPACITY:
case STROKEWIDTH:
// falls through
case FACET:
case ROW: // falls through
case COLUMN:
return ALL_MARKS;
case X:
case Y:
case LATITUDE:
case LONGITUDE:
// all marks except geoshape. geoshape does not use X, Y -- it uses a projection
return ALL_MARKS_EXCEPT_GEOSHAPE;
case X2:
case Y2:
case LATITUDE2:
case LONGITUDE2:
return {
area: 'always',
bar: 'always',
image: 'always',
rect: 'always',
rule: 'always',
circle: 'binned',
point: 'binned',
square: 'binned',
tick: 'binned',
line: 'binned',
trail: 'binned'
};
case SIZE:
return {
point: 'always',
tick: 'always',
rule: 'always',
circle: 'always',
square: 'always',
bar: 'always',
text: 'always',
line: 'always',
trail: 'always'
};
case STROKEDASH:
return {
line: 'always',
point: 'always',
tick: 'always',
rule: 'always',
circle: 'always',
square: 'always',
bar: 'always',
geoshape: 'always'
};
case SHAPE:
return { point: 'always', geoshape: 'always' };
case TEXT:
return { text: 'always' };
case ANGLE:
return { point: 'always', square: 'always', text: 'always' };
case URL:
return { image: 'always' };
case THETA:
return { text: 'always', arc: 'always' };
case RADIUS:
return { text: 'always', arc: 'always' };
case THETA2:
case RADIUS2:
return { arc: 'always' };
}
}
export function rangeType(channel) {
switch (channel) {
case X:
case Y:
case THETA:
case RADIUS:
case SIZE:
case ANGLE:
case STROKEWIDTH:
case OPACITY:
case FILLOPACITY:
case STROKEOPACITY:
// X2 and Y2 use X and Y scales, so they similarly have continuous range. [falls through]
case X2:
case Y2:
case THETA2:
case RADIUS2:
return undefined;
case FACET:
case ROW:
case COLUMN:
case SHAPE:
case STROKEDASH:
// TEXT, TOOLTIP, URL, and HREF have no scale but have discrete output [falls through]
case TEXT:
case TOOLTIP:
case HREF:
case URL:
case DESCRIPTION:
return 'discrete';
// Color can be either continuous or discrete, depending on scale type.
case COLOR:
case FILL:
case STROKE:
return 'flexible';
// No scale, no range type.
case LATITUDE:
case LONGITUDE:
case LATITUDE2:
case LONGITUDE2:
case DETAIL:
case KEY:
case ORDER:
return undefined;
}
}
//# sourceMappingURL=channel.js.map

1
node_modules/vega-lite/build/src/channel.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

901
node_modules/vega-lite/build/src/channeldef.d.ts generated vendored Normal file
View File

@@ -0,0 +1,901 @@
import { Gradient, SignalRef, Text } from 'vega';
import { Aggregate } from './aggregate';
import { Axis } from './axis';
import { Bin, BinParams } from './bin';
import { Channel, ExtendedChannel } from './channel';
import { CompositeAggregate } from './compositemark';
import { Config } from './config';
import { DateTime } from './datetime';
import { Encoding } from './encoding';
import { FormatMixins, Guide, GuideEncodingConditionalValueDef, TitleMixins } from './guide';
import { ImputeParams } from './impute';
import { Legend } from './legend';
import { LogicalComposition } from './logical';
import { MarkDef } from './mark';
import { Predicate } from './predicate';
import { Scale } from './scale';
import { Sort, SortOrder } from './sort';
import { StackOffset, StackProperties } from './stack';
import { TimeUnit, TimeUnitParams } from './timeunit';
import { AggregatedFieldDef, WindowFieldDef } from './transform';
import { StandardType, Type } from './type';
export declare type PrimitiveValue = number | string | boolean | null;
export declare type Value = PrimitiveValue | number[] | Gradient | Text | SignalRef;
/**
* Definition object for a constant value (primitive value or gradient definition) of an encoding channel.
*/
export interface ValueDef<V extends Value = Value> {
/**
* A constant value in visual domain (e.g., `"red"` / `"#0099ff"` / [gradient definition](https://vega.github.io/vega-lite/docs/types.html#gradient) for color, values between `0` to `1` for opacity).
*/
value: V;
}
export declare type PositionValueDef = ValueDef<number | 'width' | 'height' | SignalRef>;
export declare type NumericValueDef = ValueDef<number | SignalRef>;
/**
* A ValueDef with Condition<ValueDef | FieldDef> where either the condition or the value are optional.
* {
* condition: {field: ...} | {value: ...},
* value: ...,
* }
*/
/**
* @minProperties 1
*/
export declare type ValueDefWithCondition<F extends FieldDef<any> | DatumDef<any>, V extends Value = Value> = Partial<ValueDef<V | SignalRef>> & {
/**
* A field definition or one or more value definition(s) with a selection predicate.
*/
condition?: Conditional<F> | Conditional<ValueDef<V | SignalRef>> | Conditional<ValueDef<V | SignalRef>>[];
};
export declare type StringValueDefWithCondition<F extends Field, T extends Type = StandardType> = ValueDefWithCondition<MarkPropFieldOrDatumDef<F, T>, string | null>;
export declare type TypeForShape = 'nominal' | 'ordinal' | 'geojson';
export declare type Conditional<CD extends FieldDef<any> | DatumDef | ValueDef<any> | SignalRef> = ConditionalPredicate<CD> | ConditionalSelection<CD>;
export declare type ConditionalPredicate<CD extends FieldDef<any> | DatumDef | ValueDef<any> | SignalRef> = {
/**
* Predicate for triggering the condition
*/
test: LogicalComposition<Predicate>;
} & CD;
export declare type ConditionalSelection<CD extends FieldDef<any> | DatumDef | ValueDef<any> | SignalRef> = {
/**
* A [selection name](https://vega.github.io/vega-lite/docs/selection.html), or a series of [composed selections](https://vega.github.io/vega-lite/docs/selection.html#compose).
*/
selection: LogicalComposition<string>;
} & CD;
export declare function isConditionalSelection<T>(c: Conditional<T>): c is ConditionalSelection<T>;
export interface ConditionValueDefMixins<V extends Value = Value> {
/**
* One or more value definition(s) with [a selection or a test predicate](https://vega.github.io/vega-lite/docs/condition.html).
*
* __Note:__ A field definition's `condition` property can only contain [conditional value definitions](https://vega.github.io/vega-lite/docs/condition.html#value)
* since Vega-Lite only allows at most one encoded field per encoding channel.
*/
condition?: Conditional<ValueDef<V>> | Conditional<ValueDef<V>>[];
}
/**
* A FieldDef with Condition<ValueDef>
* {
* condition: {value: ...},
* field: ...,
* ...
* }
*/
export declare type FieldOrDatumDefWithCondition<F extends FieldDef<any, any> | DatumDef<any>, V extends Value = Value> = F & ConditionValueDefMixins<V | SignalRef>;
export declare type MarkPropDef<F extends Field, V extends Value, T extends Type = StandardType> = FieldOrDatumDefWithCondition<MarkPropFieldDef<F, T>, V> | FieldOrDatumDefWithCondition<DatumDef<F>, V> | ValueDefWithCondition<MarkPropFieldOrDatumDef<F, T>, V>;
export declare type ColorDef<F extends Field> = MarkPropDef<F, Gradient | string | null>;
export declare type NumericMarkPropDef<F extends Field> = MarkPropDef<F, number>;
export declare type NumericArrayMarkPropDef<F extends Field> = MarkPropDef<F, number[]>;
export declare type ShapeDef<F extends Field> = MarkPropDef<F, string | null, TypeForShape>;
export declare type StringFieldDefWithCondition<F extends Field> = FieldOrDatumDefWithCondition<StringFieldDef<F>, string>;
export declare type TextDef<F extends Field> = FieldOrDatumDefWithCondition<StringFieldDef<F>, Text> | FieldOrDatumDefWithCondition<StringDatumDef<F>, Text> | ValueDefWithCondition<StringFieldDef<F>, Text>;
/**
* A ValueDef with optional Condition<ValueDef | FieldDef>
* {
* condition: {field: ...} | {value: ...},
* value: ...,
* }
*/
/**
* Reference to a repeated value.
*/
export interface RepeatRef {
repeat: 'row' | 'column' | 'repeat' | 'layer';
}
export declare type FieldName = string;
export declare type Field = FieldName | RepeatRef;
export declare function isRepeatRef(field: Field | any): field is RepeatRef;
/** @@hidden */
export declare type HiddenCompositeAggregate = CompositeAggregate;
export interface FieldDefBase<F, B extends Bin = Bin> extends BandMixins {
/**
* __Required.__ A string defining the name of the field from which to pull a data value
* or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
*
* __See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.
*
* __Notes:__
* 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `"field": "foo.bar"` and `"field": "foo['bar']"`).
* If field names contain dots or brackets but are not nested, you can use `\\` to escape dots and brackets (e.g., `"a\\.b"` and `"a\\[0\\]"`).
* See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
* 2) `field` is not required if `aggregate` is `count`.
*/
field?: F;
/**
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field.
* or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation.
*/
timeUnit?: TimeUnit | TimeUnitParams;
/**
* Aggregation function for the field
* (e.g., `"mean"`, `"sum"`, `"median"`, `"min"`, `"max"`, `"count"`).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation.
*/
aggregate?: Aggregate | HiddenCompositeAggregate;
/**
* A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#params), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`"binned"`).
*
* - If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html) will be applied.
*
* - If `"binned"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.
*
* __Default value:__ `false`
*
* __See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation.
*/
bin?: B;
}
export declare function toFieldDefBase(fieldDef: FieldDef<string>): FieldDefBase<string>;
export interface TypeMixins<T extends Type> {
/**
* The type of measurement (`"quantitative"`, `"temporal"`, `"ordinal"`, or `"nominal"`) for the encoded field or constant value (`datum`).
* It can also be a `"geojson"` type for encoding ['geoshape'](https://vega.github.io/vega-lite/docs/geoshape.html).
*
* Since Vega-Lite 4.14.0, Vega-Lite automatically infers data types in many cases as discussed below. However, type is required for a field if:
* (1) the field is not nominal and the field encoding has no specified `aggregate` (except `argmin` and `argmax`), `bin`, scale type, custom `sort` order, nor `timeUnit`
* or (2) if you wish to use an ordinal scale for a field with `bin` or `timeUnit`.
*
* __Default value:__
*
* 1) For a data `field`, `"nominal"` is the default data type unless the field encoding has `aggregate`, `channel`, `bin`, scale type, `sort`, or `timeUnit` that satisfies the following criteria:
* - `"quantitative"` is the default type if (1) the encoded field contains `bin` or `aggregate` except `"argmin"` and `"argmax"`, (2) the encoding channel is `latitude` or `longitude` channel or (3) if the specified scale type is [a quantitative scale](https://vega.github.io/vega-lite/docs/scale.html#type).
* - `"temporal"` is the default type if (1) the encoded field contains `timeUnit` or (2) the specified scale type is a time or utc scale
* - `ordinal""` is the default type if (1) the encoded field contains a [custom `sort` order](https://vega.github.io/vega-lite/docs/sort.html#specifying-custom-sort-order) or (2) the specified scale type is an ordinal/point/band scale.
*
* 2) For a constant value in data domain (`datum`):
* - `"quantitative"` if the datum is a number
* - `"nominal"` if the datum is a string
* - `"temporal"` if the datum is [a date time object](https://vega.github.io/vega-lite/docs/datetime.html)
*
* __Note:__
* - Data `type` describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.
* - Data values for a temporal field can be either a date-time string (e.g., `"2015-03-07 12:32:17"`, `"17:01"`, `"2015-03-16"`. `"2015"`) or a timestamp number (e.g., `1552199579097`).
* - When using with [`bin`](https://vega.github.io/vega-lite/docs/bin.html), the `type` property can be either `"quantitative"` (for using a linear bin scale) or [`"ordinal"` (for using an ordinal bin scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html), the `type` property can be either `"temporal"` (default, for using a temporal scale) or [`"ordinal"` (for using an ordinal scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html), the `type` property refers to the post-aggregation data type. For example, we can calculate count `distinct` of a categorical field `"cat"` using `{"aggregate": "distinct", "field": "cat"}`. The `"type"` of the aggregate output is `"quantitative"`.
* - Secondary channels (e.g., `x2`, `y2`, `xError`, `yError`) do not have `type` as they must have exactly the same type as their primary channels (e.g., `x`, `y`).
*
* __See also:__ [`type`](https://vega.github.io/vega-lite/docs/type.html) documentation.
*/
type?: T;
}
/**
* Definition object for a data field, its type and transformation of an encoding channel.
*/
export declare type TypedFieldDef<F extends Field, T extends Type = any, B extends Bin = boolean | BinParams | 'binned' | null> = FieldDefBase<F, B> & TitleMixins & TypeMixins<T>;
export interface SortableFieldDef<F extends Field, T extends Type = StandardType, B extends Bin = boolean | BinParams | null> extends TypedFieldDef<F, T, B> {
/**
* Sort order for the encoded field.
*
* For continuous fields (quantitative or temporal), `sort` can be either `"ascending"` or `"descending"`.
*
* For discrete fields, `sort` can be one of the following:
* - `"ascending"` or `"descending"` -- for sorting by the values' natural order in JavaScript.
* - [A string indicating an encoding channel name to sort by](https://vega.github.io/vega-lite/docs/sort.html#sort-by-encoding) (e.g., `"x"` or `"y"`) with an optional minus prefix for descending sort (e.g., `"-x"` to sort by x-field, descending). This channel string is short-form of [a sort-by-encoding definition](https://vega.github.io/vega-lite/docs/sort.html#sort-by-encoding). For example, `"sort": "-x"` is equivalent to `"sort": {"encoding": "x", "order": "descending"}`.
* - [A sort field definition](https://vega.github.io/vega-lite/docs/sort.html#sort-field) for sorting by another field.
* - [An array specifying the field values in preferred order](https://vega.github.io/vega-lite/docs/sort.html#sort-array). In this case, the sort order will obey the values in the array, followed by any unspecified values in their original order. For discrete time field, values in the sort array can be [date-time definition objects](types#datetime). In addition, for time units `"month"` and `"day"`, the values can be the month or day names (case insensitive) or their 3-letter initials (e.g., `"Mon"`, `"Tue"`).
* - `null` indicating no sort.
*
* __Default value:__ `"ascending"`
*
* __Note:__ `null` and sorting by another channel is not supported for `row` and `column`.
*
* __See also:__ [`sort`](https://vega.github.io/vega-lite/docs/sort.html) documentation.
*/
sort?: Sort<F>;
}
export declare function isSortableFieldDef<F extends Field>(fieldDef: FieldDef<F>): fieldDef is SortableFieldDef<F>;
export declare type ScaleFieldDef<F extends Field, T extends Type = StandardType, B extends Bin = boolean | BinParams | null> = SortableFieldDef<F, T, B> & ScaleMixins;
export interface ScaleMixins {
/**
* An object defining properties of the channel's scale, which is the function that transforms values in the data domain (numbers, dates, strings, etc) to visual values (pixels, colors, sizes) of the encoding channels.
*
* If `null`, the scale will be [disabled and the data value will be directly encoded](https://vega.github.io/vega-lite/docs/scale.html#disable).
*
* __Default value:__ If undefined, default [scale properties](https://vega.github.io/vega-lite/docs/scale.html) are applied.
*
* __See also:__ [`scale`](https://vega.github.io/vega-lite/docs/scale.html) documentation.
*/
scale?: Scale | null;
}
export interface DatumDef<F extends Field = string, V extends PrimitiveValue | DateTime | SignalRef = PrimitiveValue | DateTime | SignalRef> extends Partial<TypeMixins<Type>>, BandMixins {
/**
* A constant value in data domain.
*/
datum?: F extends RepeatRef ? V | RepeatRef : V;
}
export declare type StringDatumDef<F extends Field = string> = DatumDef<F> & FormatMixins;
export declare type ScaleDatumDef<F extends Field = string> = ScaleMixins & DatumDef<F>;
/**
* A field definition of a secondary channel that shares a scale with another primary channel. For example, `x2`, `xError` and `xError2` share the same scale with `x`.
*/
export declare type SecondaryFieldDef<F extends Field> = FieldDefBase<F, null> & TitleMixins;
export declare type Position2Def<F extends Field> = SecondaryFieldDef<F> | DatumDef<F> | PositionValueDef;
export declare type SecondaryChannelDef<F extends Field> = Encoding<F>['x2' | 'y2'];
/**
* Field Def without scale (and without bin: "binned" support).
*/
export declare type FieldDefWithoutScale<F extends Field, T extends Type = StandardType> = TypedFieldDef<F, T>;
export declare type LatLongFieldDef<F extends Field> = FieldDefBase<F, null> & TitleMixins & Partial<TypeMixins<'quantitative'>>;
export declare type LatLongDef<F extends Field> = LatLongFieldDef<F> | DatumDef<F> | NumericValueDef;
export declare type PositionFieldDefBase<F extends Field> = ScaleFieldDef<F, StandardType, boolean | BinParams | 'binned' | null> & PositionBaseMixins;
export declare type PositionDatumDefBase<F extends Field> = ScaleDatumDef<F> & PositionBaseMixins;
export interface PositionBaseMixins {
/**
* Type of stacking offset if the field should be stacked.
* `stack` is only applicable for `x`, `y`, `theta`, and `radius` channels with continuous domains.
* For example, `stack` of `y` can be used to customize stacking for a vertical bar chart.
*
* `stack` can be one of the following values:
* - `"zero"` or `true`: stacking with baseline offset at zero value of the scale (for creating typical stacked [bar](https://vega.github.io/vega-lite/docs/stack.html#bar) and [area](https://vega.github.io/vega-lite/docs/stack.html#area) chart).
* - `"normalize"` - stacking with normalized domain (for creating [normalized stacked bar and area charts](https://vega.github.io/vega-lite/docs/stack.html#normalized). <br/>
* -`"center"` - stacking with center baseline (for [streamgraph](https://vega.github.io/vega-lite/docs/stack.html#streamgraph)).
* - `null` or `false` - No-stacking. This will produce layered [bar](https://vega.github.io/vega-lite/docs/stack.html#layered-bar-chart) and area chart.
*
* __Default value:__ `zero` for plots with all of the following conditions are true:
* (1) the mark is `bar`, `area`, or `arc`;
* (2) the stacked measure channel (x or y) has a linear scale;
* (3) At least one of non-position channels mapped to an unaggregated field that is different from x and y. Otherwise, `null` by default.
*
* __See also:__ [`stack`](https://vega.github.io/vega-lite/docs/stack.html) documentation.
*/
stack?: StackOffset | null | boolean;
}
export interface BandMixins {
/**
* For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.
*
* For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.
*
* @minimum 0
* @maximum 1
*/
band?: number;
}
export declare type PositionFieldDef<F extends Field> = PositionFieldDefBase<F> & PositionMixins;
export declare type PositionDatumDef<F extends Field> = PositionDatumDefBase<F> & PositionMixins;
export declare type PositionDef<F extends Field> = PositionFieldDef<F> | PositionDatumDef<F> | PositionValueDef;
export interface PositionMixins {
/**
* An object defining properties of axis's gridlines, ticks and labels.
* If `null`, the axis for the encoding channel will be removed.
*
* __Default value:__ If undefined, default [axis properties](https://vega.github.io/vega-lite/docs/axis.html) are applied.
*
* __See also:__ [`axis`](https://vega.github.io/vega-lite/docs/axis.html) documentation.
*/
axis?: Axis | null;
/**
* An object defining the properties of the Impute Operation to be applied.
* The field value of the other positional channel is taken as `key` of the `Impute` Operation.
* The field of the `color` channel if specified is used as `groupby` of the `Impute` Operation.
*
* __See also:__ [`impute`](https://vega.github.io/vega-lite/docs/impute.html) documentation.
*/
impute?: ImputeParams | null;
}
export declare type PolarDef<F extends Field> = PositionFieldDefBase<F> | PositionDatumDefBase<F> | PositionValueDef;
export declare function getBand({ channel, fieldDef, fieldDef2, markDef: mark, stack, config, isMidPoint }: {
isMidPoint?: boolean;
channel: Channel;
fieldDef: FieldDef<string> | DatumDef;
fieldDef2?: SecondaryChannelDef<string>;
stack: StackProperties;
markDef: MarkDef;
config: Config;
}): number;
export declare function hasBand(channel: Channel, fieldDef: FieldDef<string>, fieldDef2: SecondaryChannelDef<string>, stack: StackProperties, markDef: MarkDef, config: Config): boolean;
/**
* Field definition of a mark property, which can contain a legend.
*/
export declare type MarkPropFieldDef<F extends Field, T extends Type = Type> = ScaleFieldDef<F, T, boolean | BinParams | null> & LegendMixins;
export declare type MarkPropDatumDef<F extends Field> = LegendMixins & ScaleDatumDef<F>;
export declare type MarkPropFieldOrDatumDef<F extends Field, T extends Type = Type> = MarkPropFieldDef<F, T> | MarkPropDatumDef<F>;
export interface LegendMixins {
/**
* An object defining properties of the legend.
* If `null`, the legend for the encoding channel will be removed.
*
* __Default value:__ If undefined, default [legend properties](https://vega.github.io/vega-lite/docs/legend.html) are applied.
*
* __See also:__ [`legend`](https://vega.github.io/vega-lite/docs/legend.html) documentation.
*/
legend?: Legend | null;
}
export interface OrderFieldDef<F extends Field> extends FieldDefWithoutScale<F> {
/**
* The sort order. One of `"ascending"` (default) or `"descending"`.
*/
sort?: SortOrder;
}
export declare type OrderValueDef = ConditionValueDefMixins<number> & NumericValueDef;
export interface StringFieldDef<F extends Field> extends FieldDefWithoutScale<F, StandardType>, FormatMixins {
}
export declare type FieldDef<F extends Field, T extends Type = any> = SecondaryFieldDef<F> | TypedFieldDef<F, T>;
export declare type ChannelDef<F extends Field = string> = Encoding<F>[keyof Encoding<F>];
export declare function isConditionalDef<CD extends ChannelDef<any> | GuideEncodingConditionalValueDef | SignalRef>(channelDef: CD): channelDef is CD & {
condition: Conditional<any>;
};
/**
* Return if a channelDef is a ConditionalValueDef with ConditionFieldDef
*/
export declare function hasConditionalFieldDef<F extends Field>(channelDef: Partial<ChannelDef<F>>): channelDef is {
condition: Conditional<TypedFieldDef<F>>;
};
export declare function hasConditionalFieldOrDatumDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is {
condition: Conditional<TypedFieldDef<F>>;
};
export declare function hasConditionalValueDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is ValueDef<any> & {
condition: Conditional<ValueDef<any>> | Conditional<ValueDef<any>>[];
};
export declare function isFieldDef<F extends Field>(channelDef: Partial<ChannelDef<F>> | FieldDefBase<F> | DatumDef<F, any>): channelDef is FieldDefBase<F> | TypedFieldDef<F> | SecondaryFieldDef<F>;
export declare function channelDefType<F extends Field>(channelDef: ChannelDef<F>): Type | undefined;
export declare function isDatumDef<F extends Field>(channelDef: Partial<ChannelDef<F>> | FieldDefBase<F> | DatumDef<F, any>): channelDef is DatumDef<F, any>;
export declare function isContinuousFieldOrDatumDef<F extends Field>(cd: ChannelDef<F>): cd is TypedFieldDef<F> | DatumDef<F, number>;
export declare function isQuantitativeFieldOrDatumDef<F extends Field>(cd: ChannelDef<F>): boolean;
export declare function isNumericDataDef<F extends Field>(cd: ChannelDef<F>): cd is DatumDef<F, number>;
export declare function isFieldOrDatumDef<F extends Field>(channelDef: Partial<ChannelDef<F>>): channelDef is FieldDef<F, any> | DatumDef<F>;
export declare function isTypedFieldDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is TypedFieldDef<F>;
export declare function isValueDef<F extends Field>(channelDef: Partial<ChannelDef<F>>): channelDef is ValueDef<any>;
export declare function isScaleFieldDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is ScaleFieldDef<F>;
export declare function isPositionFieldOrDatumDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is PositionFieldDef<F> | PositionDatumDef<F>;
export declare function isMarkPropFieldOrDatumDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is MarkPropFieldDef<F, any> | MarkPropDatumDef<F>;
export declare function isStringFieldOrDatumDef<F extends Field>(channelDef: ChannelDef<F>): channelDef is StringFieldDef<F> | StringDatumDef<F>;
export declare function toStringFieldDef<F extends Field>(fieldDef: FieldDef<F>): StringFieldDef<F>;
export interface FieldRefOption {
/** Exclude bin, aggregate, timeUnit */
nofn?: boolean;
/** Wrap the field with datum, parent, or datum.datum (e.g., datum['...'] for Vega Expression */
expr?: 'datum' | 'parent' | 'datum.datum';
/** Prepend fn with custom function prefix */
prefix?: string;
/** Append suffix to the field ref for bin (default='start') */
binSuffix?: 'end' | 'range' | 'mid';
/** Append suffix to the field ref (general) */
suffix?: string;
/**
* Use the field name for `as` in a transform.
* We will not escape nested accesses because Vega transform outputs cannot be nested.
*/
forAs?: boolean;
}
/**
* Get a Vega field reference from a Vega-Lite field def.
*/
export declare function vgField(fieldDef: FieldDefBase<string> | WindowFieldDef | AggregatedFieldDef, opt?: FieldRefOption): string;
export declare function isDiscrete(def: TypedFieldDef<Field> | DatumDef<any, any>): boolean;
export declare function isContinuous(fieldDef: TypedFieldDef<Field>): boolean;
export declare function isCount(fieldDef: FieldDefBase<Field>): boolean;
export declare type FieldTitleFormatter = (fieldDef: FieldDefBase<string>, config: Config) => string;
export declare function verbalTitleFormatter(fieldDef: FieldDefBase<string>, config: Config): string;
export declare function functionalTitleFormatter(fieldDef: FieldDefBase<string>): string;
export declare const defaultTitleFormatter: FieldTitleFormatter;
export declare function setTitleFormatter(formatter: FieldTitleFormatter): void;
export declare function resetTitleFormatter(): void;
export declare function title(fieldOrDatumDef: TypedFieldDef<string> | SecondaryFieldDef<string> | DatumDef, config: Config, { allowDisabling, includeDefault }: {
allowDisabling: boolean;
includeDefault?: boolean;
}): string | string[] | SignalRef;
export declare function getGuide(fieldDef: TypedFieldDef<string> | SecondaryFieldDef<string> | DatumDef): Guide;
export declare function defaultTitle(fieldDef: FieldDefBase<string>, config: Config): string;
export declare function getFormatMixins(fieldDef: TypedFieldDef<string> | DatumDef): {
format: string | Record<string, unknown>;
formatType: string;
};
export declare function defaultType<T extends TypedFieldDef<Field>>(fieldDef: T, channel: ExtendedChannel): Type;
/**
* Returns the fieldDef -- either from the outer channelDef or from the condition of channelDef.
* @param channelDef
*/
export declare function getFieldDef<F extends Field>(channelDef: ChannelDef<F>): FieldDef<F>;
export declare function getFieldOrDatumDef<F extends Field = string, CD extends ChannelDef<F> = ChannelDef<F>>(channelDef: CD): FieldDef<F> | DatumDef<F>;
/**
* Convert type to full, lowercase type, or augment the fieldDef with a default type if missing.
*/
export declare function initChannelDef(channelDef: ChannelDef<string>, channel: ExtendedChannel, config: Config, opt?: {
compositeMark?: boolean;
}): ChannelDef<string>;
export declare function initFieldOrDatumDef(fd: FieldDef<string, any> | DatumDef, channel: ExtendedChannel, config: Config, opt: {
compositeMark?: boolean;
}): FieldDef<string, any> | DatumDef;
export declare function initFieldDef(fd: FieldDef<string, any>, channel: ExtendedChannel, { compositeMark }?: {
compositeMark?: boolean;
}): {
/**
* __Required.__ A string defining the name of the field from which to pull a data value
* or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
*
* __See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.
*
* __Notes:__
* 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `"field": "foo.bar"` and `"field": "foo['bar']"`).
* If field names contain dots or brackets but are not nested, you can use `\\` to escape dots and brackets (e.g., `"a\\.b"` and `"a\\[0\\]"`).
* See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
* 2) `field` is not required if `aggregate` is `count`.
*/
field?: string;
/**
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field.
* or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation.
*/
timeUnit?: "day" | "week" | "month" | "year" | "date" | "quarter" | "dayofyear" | "hours" | "minutes" | "seconds" | "milliseconds" | "utcyear" | "utcquarter" | "utcmonth" | "utcweek" | "utcday" | "utcdayofyear" | "utcdate" | "utchours" | "utcminutes" | "utcseconds" | "utcmilliseconds" | "yearquarter" | "yearquartermonth" | "yearmonth" | "yearmonthdate" | "yearmonthdatehours" | "yearmonthdatehoursminutes" | "yearmonthdatehoursminutesseconds" | "yearweek" | "yearweekday" | "yearweekdayhours" | "yearweekdayhoursminutes" | "yearweekdayhoursminutesseconds" | "yeardayofyear" | "quartermonth" | "monthdate" | "monthdatehours" | "monthdatehoursminutes" | "monthdatehoursminutesseconds" | "weekday" | "weeksdayhours" | "weekdayhoursminutes" | "weekdayhoursminutesseconds" | "dayhours" | "dayhoursminutes" | "dayhoursminutesseconds" | "hoursminutes" | "hoursminutesseconds" | "minutesseconds" | "secondsmilliseconds" | "utcyearquarter" | "utcyearquartermonth" | "utcyearmonth" | "utcyearmonthdate" | "utcyearmonthdatehours" | "utcyearmonthdatehoursminutes" | "utcyearmonthdatehoursminutesseconds" | "utcyearweek" | "utcyearweekday" | "utcyearweekdayhours" | "utcyearweekdayhoursminutes" | "utcyearweekdayhoursminutesseconds" | "utcyeardayofyear" | "utcquartermonth" | "utcmonthdate" | "utcmonthdatehours" | "utcmonthdatehoursminutes" | "utcmonthdatehoursminutesseconds" | "utcweekday" | "utcweeksdayhours" | "utcweekdayhoursminutes" | "utcweekdayhoursminutesseconds" | "utcdayhours" | "utcdayhoursminutes" | "utcdayhoursminutesseconds" | "utchoursminutes" | "utchoursminutesseconds" | "utcminutesseconds" | "utcsecondsmilliseconds" | TimeUnitParams;
/**
* Aggregation function for the field
* (e.g., `"mean"`, `"sum"`, `"median"`, `"min"`, `"max"`, `"count"`).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation.
*/
aggregate?: "count" | "min" | "max" | "average" | "distinct" | "mean" | "median" | "missing" | "product" | "q1" | "q3" | "ci0" | "ci1" | "stderr" | "stdev" | "stdevp" | "sum" | "valid" | "values" | "variance" | "variancep" | import("./aggregate").ArgminDef | import("./aggregate").ArgmaxDef | "boxplot" | "errorbar" | "errorband";
/**
* A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#params), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`"binned"`).
*
* - If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html) will be applied.
*
* - If `"binned"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.
*
* __Default value:__ `false`
*
* __See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation.
*/
bin?: null;
/**
* For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.
*
* For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.
*
* @minimum 0
* @maximum 1
*/
band?: number;
title?: string | string[] | SignalRef;
} | {
/**
* __Required.__ A string defining the name of the field from which to pull a data value
* or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
*
* __See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.
*
* __Notes:__
* 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `"field": "foo.bar"` and `"field": "foo['bar']"`).
* If field names contain dots or brackets but are not nested, you can use `\\` to escape dots and brackets (e.g., `"a\\.b"` and `"a\\[0\\]"`).
* See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
* 2) `field` is not required if `aggregate` is `count`.
*/
field?: string;
/**
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field.
* or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation.
*/
timeUnit?: "day" | "week" | "month" | "year" | "date" | "quarter" | "dayofyear" | "hours" | "minutes" | "seconds" | "milliseconds" | "utcyear" | "utcquarter" | "utcmonth" | "utcweek" | "utcday" | "utcdayofyear" | "utcdate" | "utchours" | "utcminutes" | "utcseconds" | "utcmilliseconds" | "yearquarter" | "yearquartermonth" | "yearmonth" | "yearmonthdate" | "yearmonthdatehours" | "yearmonthdatehoursminutes" | "yearmonthdatehoursminutesseconds" | "yearweek" | "yearweekday" | "yearweekdayhours" | "yearweekdayhoursminutes" | "yearweekdayhoursminutesseconds" | "yeardayofyear" | "quartermonth" | "monthdate" | "monthdatehours" | "monthdatehoursminutes" | "monthdatehoursminutesseconds" | "weekday" | "weeksdayhours" | "weekdayhoursminutes" | "weekdayhoursminutesseconds" | "dayhours" | "dayhoursminutes" | "dayhoursminutesseconds" | "hoursminutes" | "hoursminutesseconds" | "minutesseconds" | "secondsmilliseconds" | "utcyearquarter" | "utcyearquartermonth" | "utcyearmonth" | "utcyearmonthdate" | "utcyearmonthdatehours" | "utcyearmonthdatehoursminutes" | "utcyearmonthdatehoursminutesseconds" | "utcyearweek" | "utcyearweekday" | "utcyearweekdayhours" | "utcyearweekdayhoursminutes" | "utcyearweekdayhoursminutesseconds" | "utcyeardayofyear" | "utcquartermonth" | "utcmonthdate" | "utcmonthdatehours" | "utcmonthdatehoursminutes" | "utcmonthdatehoursminutesseconds" | "utcweekday" | "utcweeksdayhours" | "utcweekdayhoursminutes" | "utcweekdayhoursminutesseconds" | "utcdayhours" | "utcdayhoursminutes" | "utcdayhoursminutesseconds" | "utchoursminutes" | "utchoursminutesseconds" | "utcminutesseconds" | "utcsecondsmilliseconds" | TimeUnitParams;
/**
* Aggregation function for the field
* (e.g., `"mean"`, `"sum"`, `"median"`, `"min"`, `"max"`, `"count"`).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation.
*/
aggregate?: "count" | "min" | "max" | "average" | "distinct" | "mean" | "median" | "missing" | "product" | "q1" | "q3" | "ci0" | "ci1" | "stderr" | "stdev" | "stdevp" | "sum" | "valid" | "values" | "variance" | "variancep" | import("./aggregate").ArgminDef | import("./aggregate").ArgmaxDef | "boxplot" | "errorbar" | "errorband";
/**
* A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#params), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`"binned"`).
*
* - If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html) will be applied.
*
* - If `"binned"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.
*
* __Default value:__ `false`
*
* __See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation.
*/
bin?: boolean | BinParams | "binned";
/**
* For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.
*
* For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.
*
* @minimum 0
* @maximum 1
*/
band?: number;
title?: string | string[] | SignalRef;
/**
* The type of measurement (`"quantitative"`, `"temporal"`, `"ordinal"`, or `"nominal"`) for the encoded field or constant value (`datum`).
* It can also be a `"geojson"` type for encoding ['geoshape'](https://vega.github.io/vega-lite/docs/geoshape.html).
*
* Since Vega-Lite 4.14.0, Vega-Lite automatically infers data types in many cases as discussed below. However, type is required for a field if:
* (1) the field is not nominal and the field encoding has no specified `aggregate` (except `argmin` and `argmax`), `bin`, scale type, custom `sort` order, nor `timeUnit`
* or (2) if you wish to use an ordinal scale for a field with `bin` or `timeUnit`.
*
* __Default value:__
*
* 1) For a data `field`, `"nominal"` is the default data type unless the field encoding has `aggregate`, `channel`, `bin`, scale type, `sort`, or `timeUnit` that satisfies the following criteria:
* - `"quantitative"` is the default type if (1) the encoded field contains `bin` or `aggregate` except `"argmin"` and `"argmax"`, (2) the encoding channel is `latitude` or `longitude` channel or (3) if the specified scale type is [a quantitative scale](https://vega.github.io/vega-lite/docs/scale.html#type).
* - `"temporal"` is the default type if (1) the encoded field contains `timeUnit` or (2) the specified scale type is a time or utc scale
* - `ordinal""` is the default type if (1) the encoded field contains a [custom `sort` order](https://vega.github.io/vega-lite/docs/sort.html#specifying-custom-sort-order) or (2) the specified scale type is an ordinal/point/band scale.
*
* 2) For a constant value in data domain (`datum`):
* - `"quantitative"` if the datum is a number
* - `"nominal"` if the datum is a string
* - `"temporal"` if the datum is [a date time object](https://vega.github.io/vega-lite/docs/datetime.html)
*
* __Note:__
* - Data `type` describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.
* - Data values for a temporal field can be either a date-time string (e.g., `"2015-03-07 12:32:17"`, `"17:01"`, `"2015-03-16"`. `"2015"`) or a timestamp number (e.g., `1552199579097`).
* - When using with [`bin`](https://vega.github.io/vega-lite/docs/bin.html), the `type` property can be either `"quantitative"` (for using a linear bin scale) or [`"ordinal"` (for using an ordinal bin scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html), the `type` property can be either `"temporal"` (default, for using a temporal scale) or [`"ordinal"` (for using an ordinal scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html), the `type` property refers to the post-aggregation data type. For example, we can calculate count `distinct` of a categorical field `"cat"` using `{"aggregate": "distinct", "field": "cat"}`. The `"type"` of the aggregate output is `"quantitative"`.
* - Secondary channels (e.g., `x2`, `y2`, `xError`, `yError`) do not have `type` as they must have exactly the same type as their primary channels (e.g., `x`, `y`).
*
* __See also:__ [`type`](https://vega.github.io/vega-lite/docs/type.html) documentation.
*/
type?: any;
} | {
sort: {
encoding: "stroke" | "color" | "text" | "shape" | "x" | "y" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "size";
order?: undefined;
};
/**
* __Required.__ A string defining the name of the field from which to pull a data value
* or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
*
* __See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.
*
* __Notes:__
* 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `"field": "foo.bar"` and `"field": "foo['bar']"`).
* If field names contain dots or brackets but are not nested, you can use `\\` to escape dots and brackets (e.g., `"a\\.b"` and `"a\\[0\\]"`).
* See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
* 2) `field` is not required if `aggregate` is `count`.
*/
field?: string;
/**
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field.
* or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation.
*/
timeUnit?: "day" | "week" | "month" | "year" | "date" | "quarter" | "dayofyear" | "hours" | "minutes" | "seconds" | "milliseconds" | "utcyear" | "utcquarter" | "utcmonth" | "utcweek" | "utcday" | "utcdayofyear" | "utcdate" | "utchours" | "utcminutes" | "utcseconds" | "utcmilliseconds" | "yearquarter" | "yearquartermonth" | "yearmonth" | "yearmonthdate" | "yearmonthdatehours" | "yearmonthdatehoursminutes" | "yearmonthdatehoursminutesseconds" | "yearweek" | "yearweekday" | "yearweekdayhours" | "yearweekdayhoursminutes" | "yearweekdayhoursminutesseconds" | "yeardayofyear" | "quartermonth" | "monthdate" | "monthdatehours" | "monthdatehoursminutes" | "monthdatehoursminutesseconds" | "weekday" | "weeksdayhours" | "weekdayhoursminutes" | "weekdayhoursminutesseconds" | "dayhours" | "dayhoursminutes" | "dayhoursminutesseconds" | "hoursminutes" | "hoursminutesseconds" | "minutesseconds" | "secondsmilliseconds" | "utcyearquarter" | "utcyearquartermonth" | "utcyearmonth" | "utcyearmonthdate" | "utcyearmonthdatehours" | "utcyearmonthdatehoursminutes" | "utcyearmonthdatehoursminutesseconds" | "utcyearweek" | "utcyearweekday" | "utcyearweekdayhours" | "utcyearweekdayhoursminutes" | "utcyearweekdayhoursminutesseconds" | "utcyeardayofyear" | "utcquartermonth" | "utcmonthdate" | "utcmonthdatehours" | "utcmonthdatehoursminutes" | "utcmonthdatehoursminutesseconds" | "utcweekday" | "utcweeksdayhours" | "utcweekdayhoursminutes" | "utcweekdayhoursminutesseconds" | "utcdayhours" | "utcdayhoursminutes" | "utcdayhoursminutesseconds" | "utchoursminutes" | "utchoursminutesseconds" | "utcminutesseconds" | "utcsecondsmilliseconds" | TimeUnitParams;
/**
* Aggregation function for the field
* (e.g., `"mean"`, `"sum"`, `"median"`, `"min"`, `"max"`, `"count"`).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation.
*/
aggregate?: "count" | "min" | "max" | "average" | "distinct" | "mean" | "median" | "missing" | "product" | "q1" | "q3" | "ci0" | "ci1" | "stderr" | "stdev" | "stdevp" | "sum" | "valid" | "values" | "variance" | "variancep" | import("./aggregate").ArgminDef | import("./aggregate").ArgmaxDef | "boxplot" | "errorbar" | "errorband";
/**
* A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#params), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`"binned"`).
*
* - If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html) will be applied.
*
* - If `"binned"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.
*
* __Default value:__ `false`
*
* __See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation.
*/
bin?: boolean | BinParams;
/**
* For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.
*
* For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.
*
* @minimum 0
* @maximum 1
*/
band?: number;
title?: string | string[] | SignalRef;
/**
* The type of measurement (`"quantitative"`, `"temporal"`, `"ordinal"`, or `"nominal"`) for the encoded field or constant value (`datum`).
* It can also be a `"geojson"` type for encoding ['geoshape'](https://vega.github.io/vega-lite/docs/geoshape.html).
*
* Since Vega-Lite 4.14.0, Vega-Lite automatically infers data types in many cases as discussed below. However, type is required for a field if:
* (1) the field is not nominal and the field encoding has no specified `aggregate` (except `argmin` and `argmax`), `bin`, scale type, custom `sort` order, nor `timeUnit`
* or (2) if you wish to use an ordinal scale for a field with `bin` or `timeUnit`.
*
* __Default value:__
*
* 1) For a data `field`, `"nominal"` is the default data type unless the field encoding has `aggregate`, `channel`, `bin`, scale type, `sort`, or `timeUnit` that satisfies the following criteria:
* - `"quantitative"` is the default type if (1) the encoded field contains `bin` or `aggregate` except `"argmin"` and `"argmax"`, (2) the encoding channel is `latitude` or `longitude` channel or (3) if the specified scale type is [a quantitative scale](https://vega.github.io/vega-lite/docs/scale.html#type).
* - `"temporal"` is the default type if (1) the encoded field contains `timeUnit` or (2) the specified scale type is a time or utc scale
* - `ordinal""` is the default type if (1) the encoded field contains a [custom `sort` order](https://vega.github.io/vega-lite/docs/sort.html#specifying-custom-sort-order) or (2) the specified scale type is an ordinal/point/band scale.
*
* 2) For a constant value in data domain (`datum`):
* - `"quantitative"` if the datum is a number
* - `"nominal"` if the datum is a string
* - `"temporal"` if the datum is [a date time object](https://vega.github.io/vega-lite/docs/datetime.html)
*
* __Note:__
* - Data `type` describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.
* - Data values for a temporal field can be either a date-time string (e.g., `"2015-03-07 12:32:17"`, `"17:01"`, `"2015-03-16"`. `"2015"`) or a timestamp number (e.g., `1552199579097`).
* - When using with [`bin`](https://vega.github.io/vega-lite/docs/bin.html), the `type` property can be either `"quantitative"` (for using a linear bin scale) or [`"ordinal"` (for using an ordinal bin scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html), the `type` property can be either `"temporal"` (default, for using a temporal scale) or [`"ordinal"` (for using an ordinal scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html), the `type` property refers to the post-aggregation data type. For example, we can calculate count `distinct` of a categorical field `"cat"` using `{"aggregate": "distinct", "field": "cat"}`. The `"type"` of the aggregate output is `"quantitative"`.
* - Secondary channels (e.g., `x2`, `y2`, `xError`, `yError`) do not have `type` as they must have exactly the same type as their primary channels (e.g., `x`, `y`).
*
* __See also:__ [`type`](https://vega.github.io/vega-lite/docs/type.html) documentation.
*/
type?: StandardType;
} | {
sort: {
encoding: "stroke" | "color" | "text" | "shape" | "x" | "y" | "fill" | "opacity" | "fillOpacity" | "strokeOpacity" | "strokeWidth" | "size";
order: string;
};
/**
* __Required.__ A string defining the name of the field from which to pull a data value
* or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
*
* __See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.
*
* __Notes:__
* 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `"field": "foo.bar"` and `"field": "foo['bar']"`).
* If field names contain dots or brackets but are not nested, you can use `\\` to escape dots and brackets (e.g., `"a\\.b"` and `"a\\[0\\]"`).
* See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
* 2) `field` is not required if `aggregate` is `count`.
*/
field?: string;
/**
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field.
* or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation.
*/
timeUnit?: "day" | "week" | "month" | "year" | "date" | "quarter" | "dayofyear" | "hours" | "minutes" | "seconds" | "milliseconds" | "utcyear" | "utcquarter" | "utcmonth" | "utcweek" | "utcday" | "utcdayofyear" | "utcdate" | "utchours" | "utcminutes" | "utcseconds" | "utcmilliseconds" | "yearquarter" | "yearquartermonth" | "yearmonth" | "yearmonthdate" | "yearmonthdatehours" | "yearmonthdatehoursminutes" | "yearmonthdatehoursminutesseconds" | "yearweek" | "yearweekday" | "yearweekdayhours" | "yearweekdayhoursminutes" | "yearweekdayhoursminutesseconds" | "yeardayofyear" | "quartermonth" | "monthdate" | "monthdatehours" | "monthdatehoursminutes" | "monthdatehoursminutesseconds" | "weekday" | "weeksdayhours" | "weekdayhoursminutes" | "weekdayhoursminutesseconds" | "dayhours" | "dayhoursminutes" | "dayhoursminutesseconds" | "hoursminutes" | "hoursminutesseconds" | "minutesseconds" | "secondsmilliseconds" | "utcyearquarter" | "utcyearquartermonth" | "utcyearmonth" | "utcyearmonthdate" | "utcyearmonthdatehours" | "utcyearmonthdatehoursminutes" | "utcyearmonthdatehoursminutesseconds" | "utcyearweek" | "utcyearweekday" | "utcyearweekdayhours" | "utcyearweekdayhoursminutes" | "utcyearweekdayhoursminutesseconds" | "utcyeardayofyear" | "utcquartermonth" | "utcmonthdate" | "utcmonthdatehours" | "utcmonthdatehoursminutes" | "utcmonthdatehoursminutesseconds" | "utcweekday" | "utcweeksdayhours" | "utcweekdayhoursminutes" | "utcweekdayhoursminutesseconds" | "utcdayhours" | "utcdayhoursminutes" | "utcdayhoursminutesseconds" | "utchoursminutes" | "utchoursminutesseconds" | "utcminutesseconds" | "utcsecondsmilliseconds" | TimeUnitParams;
/**
* Aggregation function for the field
* (e.g., `"mean"`, `"sum"`, `"median"`, `"min"`, `"max"`, `"count"`).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation.
*/
aggregate?: "count" | "min" | "max" | "average" | "distinct" | "mean" | "median" | "missing" | "product" | "q1" | "q3" | "ci0" | "ci1" | "stderr" | "stdev" | "stdevp" | "sum" | "valid" | "values" | "variance" | "variancep" | import("./aggregate").ArgminDef | import("./aggregate").ArgmaxDef | "boxplot" | "errorbar" | "errorband";
/**
* A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#params), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`"binned"`).
*
* - If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html) will be applied.
*
* - If `"binned"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.
*
* __Default value:__ `false`
*
* __See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation.
*/
bin?: boolean | BinParams;
/**
* For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.
*
* For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.
*
* @minimum 0
* @maximum 1
*/
band?: number;
title?: string | string[] | SignalRef;
/**
* The type of measurement (`"quantitative"`, `"temporal"`, `"ordinal"`, or `"nominal"`) for the encoded field or constant value (`datum`).
* It can also be a `"geojson"` type for encoding ['geoshape'](https://vega.github.io/vega-lite/docs/geoshape.html).
*
* Since Vega-Lite 4.14.0, Vega-Lite automatically infers data types in many cases as discussed below. However, type is required for a field if:
* (1) the field is not nominal and the field encoding has no specified `aggregate` (except `argmin` and `argmax`), `bin`, scale type, custom `sort` order, nor `timeUnit`
* or (2) if you wish to use an ordinal scale for a field with `bin` or `timeUnit`.
*
* __Default value:__
*
* 1) For a data `field`, `"nominal"` is the default data type unless the field encoding has `aggregate`, `channel`, `bin`, scale type, `sort`, or `timeUnit` that satisfies the following criteria:
* - `"quantitative"` is the default type if (1) the encoded field contains `bin` or `aggregate` except `"argmin"` and `"argmax"`, (2) the encoding channel is `latitude` or `longitude` channel or (3) if the specified scale type is [a quantitative scale](https://vega.github.io/vega-lite/docs/scale.html#type).
* - `"temporal"` is the default type if (1) the encoded field contains `timeUnit` or (2) the specified scale type is a time or utc scale
* - `ordinal""` is the default type if (1) the encoded field contains a [custom `sort` order](https://vega.github.io/vega-lite/docs/sort.html#specifying-custom-sort-order) or (2) the specified scale type is an ordinal/point/band scale.
*
* 2) For a constant value in data domain (`datum`):
* - `"quantitative"` if the datum is a number
* - `"nominal"` if the datum is a string
* - `"temporal"` if the datum is [a date time object](https://vega.github.io/vega-lite/docs/datetime.html)
*
* __Note:__
* - Data `type` describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.
* - Data values for a temporal field can be either a date-time string (e.g., `"2015-03-07 12:32:17"`, `"17:01"`, `"2015-03-16"`. `"2015"`) or a timestamp number (e.g., `1552199579097`).
* - When using with [`bin`](https://vega.github.io/vega-lite/docs/bin.html), the `type` property can be either `"quantitative"` (for using a linear bin scale) or [`"ordinal"` (for using an ordinal bin scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html), the `type` property can be either `"temporal"` (default, for using a temporal scale) or [`"ordinal"` (for using an ordinal scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html), the `type` property refers to the post-aggregation data type. For example, we can calculate count `distinct` of a categorical field `"cat"` using `{"aggregate": "distinct", "field": "cat"}`. The `"type"` of the aggregate output is `"quantitative"`.
* - Secondary channels (e.g., `x2`, `y2`, `xError`, `yError`) do not have `type` as they must have exactly the same type as their primary channels (e.g., `x`, `y`).
*
* __See also:__ [`type`](https://vega.github.io/vega-lite/docs/type.html) documentation.
*/
type?: StandardType;
} | {
header: {
labelOrient: import("vega").Orient;
titleOrient: import("vega").Orient;
titleAnchor?: import("vega").TitleAnchor;
titleAlign?: SignalRef | "left" | "center" | "right";
titleAngle?: number;
titleBaseline?: SignalRef | "alphabetic" | "top" | "middle" | "bottom" | "line-top" | "line-bottom";
titleColor?: import("vega").ScaleField;
titleFont?: import("vega").ScaleField;
titleFontSize?: number | SignalRef;
titleFontStyle?: import("vega").ScaleField;
titleFontWeight?: SignalRef | "normal" | "bold" | "lighter" | "bolder" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
titleLimit?: number | SignalRef;
titleLineHeight?: number | SignalRef;
titlePadding?: number | SignalRef;
labels?: boolean;
labelAlign?: SignalRef | "left" | "center" | "right";
labelBaseline?: SignalRef | "alphabetic" | "top" | "middle" | "bottom" | "line-top" | "line-bottom";
labelAnchor?: import("vega").TitleAnchor;
labelExpr?: string;
labelAngle?: number;
labelColor?: import("vega").ScaleField;
labelFont?: import("vega").ScaleField;
labelFontSize?: number | SignalRef;
labelFontStyle?: import("vega").ScaleField;
labelFontWeight?: SignalRef | "normal" | "bold" | "lighter" | "bolder" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
labelLimit?: number | SignalRef;
labelLineHeight?: number | SignalRef;
labelPadding?: number | SignalRef;
format?: string | Record<string, unknown>;
formatType?: string;
title?: string | string[] | SignalRef;
};
sort?: string[] | number[] | "ascending" | "descending" | boolean[] | DateTime[] | import("./sort").EncodingSortField<string>;
/**
* __Required.__ A string defining the name of the field from which to pull a data value
* or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.
*
* __See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.
*
* __Notes:__
* 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `"field": "foo.bar"` and `"field": "foo['bar']"`).
* If field names contain dots or brackets but are not nested, you can use `\\` to escape dots and brackets (e.g., `"a\\.b"` and `"a\\[0\\]"`).
* See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html).
* 2) `field` is not required if `aggregate` is `count`.
*/
field?: string;
/**
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field.
* or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation.
*/
timeUnit?: "day" | "week" | "month" | "year" | "date" | "quarter" | "dayofyear" | "hours" | "minutes" | "seconds" | "milliseconds" | "utcyear" | "utcquarter" | "utcmonth" | "utcweek" | "utcday" | "utcdayofyear" | "utcdate" | "utchours" | "utcminutes" | "utcseconds" | "utcmilliseconds" | "yearquarter" | "yearquartermonth" | "yearmonth" | "yearmonthdate" | "yearmonthdatehours" | "yearmonthdatehoursminutes" | "yearmonthdatehoursminutesseconds" | "yearweek" | "yearweekday" | "yearweekdayhours" | "yearweekdayhoursminutes" | "yearweekdayhoursminutesseconds" | "yeardayofyear" | "quartermonth" | "monthdate" | "monthdatehours" | "monthdatehoursminutes" | "monthdatehoursminutesseconds" | "weekday" | "weeksdayhours" | "weekdayhoursminutes" | "weekdayhoursminutesseconds" | "dayhours" | "dayhoursminutes" | "dayhoursminutesseconds" | "hoursminutes" | "hoursminutesseconds" | "minutesseconds" | "secondsmilliseconds" | "utcyearquarter" | "utcyearquartermonth" | "utcyearmonth" | "utcyearmonthdate" | "utcyearmonthdatehours" | "utcyearmonthdatehoursminutes" | "utcyearmonthdatehoursminutesseconds" | "utcyearweek" | "utcyearweekday" | "utcyearweekdayhours" | "utcyearweekdayhoursminutes" | "utcyearweekdayhoursminutesseconds" | "utcyeardayofyear" | "utcquartermonth" | "utcmonthdate" | "utcmonthdatehours" | "utcmonthdatehoursminutes" | "utcmonthdatehoursminutesseconds" | "utcweekday" | "utcweeksdayhours" | "utcweekdayhoursminutes" | "utcweekdayhoursminutesseconds" | "utcdayhours" | "utcdayhoursminutes" | "utcdayhoursminutesseconds" | "utchoursminutes" | "utchoursminutesseconds" | "utcminutesseconds" | "utcsecondsmilliseconds" | TimeUnitParams;
/**
* Aggregation function for the field
* (e.g., `"mean"`, `"sum"`, `"median"`, `"min"`, `"max"`, `"count"`).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation.
*/
aggregate?: "count" | "min" | "max" | "average" | "distinct" | "mean" | "median" | "missing" | "product" | "q1" | "q3" | "ci0" | "ci1" | "stderr" | "stdev" | "stdevp" | "sum" | "valid" | "values" | "variance" | "variancep" | import("./aggregate").ArgminDef | import("./aggregate").ArgmaxDef | "boxplot" | "errorbar" | "errorband";
/**
* A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#params), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`"binned"`).
*
* - If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html) will be applied.
*
* - If `"binned"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.
*
* __Default value:__ `false`
*
* __See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation.
*/
bin?: boolean | BinParams;
/**
* For rect-based marks (`rect`, `bar`, and `image`), mark size relative to bandwidth of [band scales](https://vega.github.io/vega-lite/docs/scale.html#band), bins or time units. If set to `1`, the mark size is set to the bandwidth, the bin interval, or the time unit interval. If set to `0.5`, the mark size is half of the bandwidth or the time unit interval.
*
* For other marks, relative position on a band of a stacked, binned, time unit or band scale. If set to `0`, the marks will be positioned at the beginning of the band. If set to `0.5`, the marks will be positioned in the middle of the band.
*
* @minimum 0
* @maximum 1
*/
band?: number;
title?: string | string[] | SignalRef;
/**
* The type of measurement (`"quantitative"`, `"temporal"`, `"ordinal"`, or `"nominal"`) for the encoded field or constant value (`datum`).
* It can also be a `"geojson"` type for encoding ['geoshape'](https://vega.github.io/vega-lite/docs/geoshape.html).
*
* Since Vega-Lite 4.14.0, Vega-Lite automatically infers data types in many cases as discussed below. However, type is required for a field if:
* (1) the field is not nominal and the field encoding has no specified `aggregate` (except `argmin` and `argmax`), `bin`, scale type, custom `sort` order, nor `timeUnit`
* or (2) if you wish to use an ordinal scale for a field with `bin` or `timeUnit`.
*
* __Default value:__
*
* 1) For a data `field`, `"nominal"` is the default data type unless the field encoding has `aggregate`, `channel`, `bin`, scale type, `sort`, or `timeUnit` that satisfies the following criteria:
* - `"quantitative"` is the default type if (1) the encoded field contains `bin` or `aggregate` except `"argmin"` and `"argmax"`, (2) the encoding channel is `latitude` or `longitude` channel or (3) if the specified scale type is [a quantitative scale](https://vega.github.io/vega-lite/docs/scale.html#type).
* - `"temporal"` is the default type if (1) the encoded field contains `timeUnit` or (2) the specified scale type is a time or utc scale
* - `ordinal""` is the default type if (1) the encoded field contains a [custom `sort` order](https://vega.github.io/vega-lite/docs/sort.html#specifying-custom-sort-order) or (2) the specified scale type is an ordinal/point/band scale.
*
* 2) For a constant value in data domain (`datum`):
* - `"quantitative"` if the datum is a number
* - `"nominal"` if the datum is a string
* - `"temporal"` if the datum is [a date time object](https://vega.github.io/vega-lite/docs/datetime.html)
*
* __Note:__
* - Data `type` describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.
* - Data values for a temporal field can be either a date-time string (e.g., `"2015-03-07 12:32:17"`, `"17:01"`, `"2015-03-16"`. `"2015"`) or a timestamp number (e.g., `1552199579097`).
* - When using with [`bin`](https://vega.github.io/vega-lite/docs/bin.html), the `type` property can be either `"quantitative"` (for using a linear bin scale) or [`"ordinal"` (for using an ordinal bin scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html), the `type` property can be either `"temporal"` (default, for using a temporal scale) or [`"ordinal"` (for using an ordinal scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).
* - When using with [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html), the `type` property refers to the post-aggregation data type. For example, we can calculate count `distinct` of a categorical field `"cat"` using `{"aggregate": "distinct", "field": "cat"}`. The `"type"` of the aggregate output is `"quantitative"`.
* - Secondary channels (e.g., `x2`, `y2`, `xError`, `yError`) do not have `type` as they must have exactly the same type as their primary channels (e.g., `x`, `y`).
*
* __See also:__ [`type`](https://vega.github.io/vega-lite/docs/type.html) documentation.
*/
type?: StandardType;
};
export declare function normalizeBin(bin: BinParams | boolean | 'binned', channel?: ExtendedChannel): BinParams;
export declare function channelCompatibility(fieldDef: TypedFieldDef<Field>, channel: ExtendedChannel): {
compatible: boolean;
warning?: string;
};
/**
* Check if the field def uses a time format or does not use any format but is temporal
* (this does not cover field defs that are temporal but use a number format).
*/
export declare function isFieldOrDatumDefForTimeFormat(fieldOrDatumDef: FieldDef<string> | DatumDef): boolean;
/**
* Check if field def has type `temporal`. If you want to also cover field defs that use a time format, use `isTimeFormatFieldDef`.
*/
export declare function isTimeFieldDef(def: FieldDef<any> | DatumDef): boolean;
/**
* Getting a value associated with a fielddef.
* Convert the value to Vega expression if applicable (for datetime object, or string if the field def is temporal or has timeUnit)
*/
export declare function valueExpr(v: number | string | boolean | DateTime | SignalRef | number[], { timeUnit, type, wrapTime, undefinedIfExprNotRequired }: {
timeUnit: TimeUnit | TimeUnitParams;
type?: Type;
wrapTime?: boolean;
undefinedIfExprNotRequired?: boolean;
}): string;
/**
* Standardize value array -- convert each value to Vega expression if applicable
*/
export declare function valueArray(fieldOrDatumDef: TypedFieldDef<string> | DatumDef, values: (number | string | boolean | DateTime)[]): (string | number | boolean | DateTime | {
signal: string;
})[];
/**
* Checks whether a fieldDef for a particular channel requires a computed bin range.
*/
export declare function binRequiresRange(fieldDef: FieldDef<string>, channel: Channel): boolean;
//# sourceMappingURL=channeldef.d.ts.map

1
node_modules/vega-lite/build/src/channeldef.d.ts.map generated vendored Normal file

File diff suppressed because one or more lines are too long

679
node_modules/vega-lite/build/src/channeldef.js generated vendored Normal file
View File

@@ -0,0 +1,679 @@
import { __rest } from "tslib";
import { isArray, isBoolean, isNumber, isString } from 'vega-util';
import { isAggregateOp, isArgmaxDef, isArgminDef, isCountingAggregateOp } from './aggregate';
import { autoMaxBins, binToString, isBinned, isBinning } from './bin';
import { ANGLE, COLOR, COLUMN, DESCRIPTION, DETAIL, FACET, FILL, FILLOPACITY, HREF, isScaleChannel, isSecondaryRangeChannel, isXorY, KEY, LATITUDE, LATITUDE2, LONGITUDE, LONGITUDE2, OPACITY, ORDER, RADIUS, RADIUS2, ROW, SHAPE, SIZE, STROKE, STROKEDASH, STROKEOPACITY, STROKEWIDTH, TEXT, THETA, THETA2, TOOLTIP, URL, X, X2, Y, Y2 } from './channel';
import { getMarkConfig } from './compile/common';
import { isCustomFormatType } from './compile/format';
import { dateTimeToExpr, isDateTime } from './datetime';
import * as log from './log';
import { isRectBasedMark } from './mark';
import { SCALE_CATEGORY_INDEX } from './scale';
import { isSortByChannel } from './sort';
import { isFacetFieldDef } from './spec/facet';
import { getTimeUnitParts, isLocalSingleTimeUnit, normalizeTimeUnit, timeUnitToString } from './timeunit';
import { getFullName, QUANTITATIVE } from './type';
import { contains, flatAccessWithDatum, getFirstDefined, internalField, omit, removePathFromField, replacePathInField, titleCase } from './util';
import { isSignalRef } from './vega.schema';
export function isConditionalSelection(c) {
return c['selection'];
}
export function isRepeatRef(field) {
return field && !isString(field) && 'repeat' in field;
}
export function toFieldDefBase(fieldDef) {
const { field, timeUnit, bin, aggregate } = fieldDef;
return Object.assign(Object.assign(Object.assign(Object.assign({}, (timeUnit ? { timeUnit } : {})), (bin ? { bin } : {})), (aggregate ? { aggregate } : {})), { field });
}
export function isSortableFieldDef(fieldDef) {
return 'sort' in fieldDef;
}
export function getBand({ channel, fieldDef, fieldDef2, markDef: mark, stack, config, isMidPoint }) {
if (isFieldOrDatumDef(fieldDef) && fieldDef.band !== undefined) {
return fieldDef.band;
}
if (isFieldDef(fieldDef)) {
const { timeUnit, bin } = fieldDef;
if (timeUnit && !fieldDef2) {
if (isMidPoint) {
return getMarkConfig('timeUnitBandPosition', mark, config);
}
else {
return isRectBasedMark(mark.type) ? getMarkConfig('timeUnitBand', mark, config) : 0;
}
}
else if (isBinning(bin)) {
return isRectBasedMark(mark.type) && !isMidPoint ? 1 : 0.5;
}
}
if ((stack === null || stack === void 0 ? void 0 : stack.fieldChannel) === channel && isMidPoint) {
return 0.5;
}
return undefined;
}
export function hasBand(channel, fieldDef, fieldDef2, stack, markDef, config) {
if (isBinning(fieldDef.bin) || (fieldDef.timeUnit && isTypedFieldDef(fieldDef) && fieldDef.type === 'temporal')) {
return !!getBand({ channel, fieldDef, fieldDef2, stack, markDef, config });
}
return false;
}
export function isConditionalDef(channelDef) {
return !!channelDef && 'condition' in channelDef;
}
/**
* Return if a channelDef is a ConditionalValueDef with ConditionFieldDef
*/
export function hasConditionalFieldDef(channelDef) {
const condition = channelDef && channelDef['condition'];
return !!condition && !isArray(condition) && isFieldDef(condition);
}
export function hasConditionalFieldOrDatumDef(channelDef) {
const condition = channelDef && channelDef['condition'];
return !!condition && !isArray(condition) && isFieldOrDatumDef(condition);
}
export function hasConditionalValueDef(channelDef) {
const condition = channelDef && channelDef['condition'];
return !!condition && (isArray(condition) || isValueDef(condition));
}
export function isFieldDef(channelDef) {
// TODO: we can't use field in channelDef here as it's somehow failing runtime test
return !!channelDef && (!!channelDef['field'] || channelDef['aggregate'] === 'count');
}
export function channelDefType(channelDef) {
return channelDef && channelDef['type'];
}
export function isDatumDef(channelDef) {
return !!channelDef && 'datum' in channelDef;
}
export function isContinuousFieldOrDatumDef(cd) {
// TODO: make datum support DateTime object
return (isTypedFieldDef(cd) && isContinuous(cd)) || isNumericDataDef(cd);
}
export function isQuantitativeFieldOrDatumDef(cd) {
// TODO: make datum support DateTime object
return channelDefType(cd) === 'quantitative' || isNumericDataDef(cd);
}
export function isNumericDataDef(cd) {
return isDatumDef(cd) && isNumber(cd.datum);
}
export function isFieldOrDatumDef(channelDef) {
return isFieldDef(channelDef) || isDatumDef(channelDef);
}
export function isTypedFieldDef(channelDef) {
return !!channelDef && ('field' in channelDef || channelDef['aggregate'] === 'count') && 'type' in channelDef;
}
export function isValueDef(channelDef) {
return channelDef && 'value' in channelDef && 'value' in channelDef;
}
export function isScaleFieldDef(channelDef) {
return !!channelDef && ('scale' in channelDef || 'sort' in channelDef);
}
export function isPositionFieldOrDatumDef(channelDef) {
return channelDef && ('axis' in channelDef || 'stack' in channelDef || 'impute' in channelDef);
}
export function isMarkPropFieldOrDatumDef(channelDef) {
return !!channelDef && 'legend' in channelDef;
}
export function isStringFieldOrDatumDef(channelDef) {
return !!channelDef && ('format' in channelDef || 'formatType' in channelDef);
}
export function toStringFieldDef(fieldDef) {
// omit properties that don't exist in string field defs
return omit(fieldDef, ['legend', 'axis', 'header', 'scale']);
}
function isOpFieldDef(fieldDef) {
return 'op' in fieldDef;
}
/**
* Get a Vega field reference from a Vega-Lite field def.
*/
export function vgField(fieldDef, opt = {}) {
var _a, _b, _c;
let field = fieldDef.field;
const prefix = opt.prefix;
let suffix = opt.suffix;
let argAccessor = ''; // for accessing argmin/argmax field at the end without getting escaped
if (isCount(fieldDef)) {
field = internalField('count');
}
else {
let fn;
if (!opt.nofn) {
if (isOpFieldDef(fieldDef)) {
fn = fieldDef.op;
}
else {
const { bin, aggregate, timeUnit } = fieldDef;
if (isBinning(bin)) {
fn = binToString(bin);
suffix = ((_a = opt.binSuffix) !== null && _a !== void 0 ? _a : '') + ((_b = opt.suffix) !== null && _b !== void 0 ? _b : '');
}
else if (aggregate) {
if (isArgmaxDef(aggregate)) {
argAccessor = `["${field}"]`;
field = `argmax_${aggregate.argmax}`;
}
else if (isArgminDef(aggregate)) {
argAccessor = `["${field}"]`;
field = `argmin_${aggregate.argmin}`;
}
else {
fn = String(aggregate);
}
}
else if (timeUnit) {
fn = timeUnitToString(timeUnit);
suffix = ((!contains(['range', 'mid'], opt.binSuffix) && opt.binSuffix) || '') + ((_c = opt.suffix) !== null && _c !== void 0 ? _c : '');
}
}
}
if (fn) {
field = field ? `${fn}_${field}` : fn;
}
}
if (suffix) {
field = `${field}_${suffix}`;
}
if (prefix) {
field = `${prefix}_${field}`;
}
if (opt.forAs) {
return removePathFromField(field);
}
else if (opt.expr) {
// Expression to access flattened field. No need to escape dots.
return flatAccessWithDatum(field, opt.expr) + argAccessor;
}
else {
// We flattened all fields so paths should have become dot.
return replacePathInField(field) + argAccessor;
}
}
export function isDiscrete(def) {
switch (def.type) {
case 'nominal':
case 'ordinal':
case 'geojson':
return true;
case 'quantitative':
return isFieldDef(def) && !!def.bin;
case 'temporal':
return false;
}
throw new Error(log.message.invalidFieldType(def.type));
}
export function isContinuous(fieldDef) {
return !isDiscrete(fieldDef);
}
export function isCount(fieldDef) {
return fieldDef.aggregate === 'count';
}
export function verbalTitleFormatter(fieldDef, config) {
var _a;
const { field, bin, timeUnit, aggregate } = fieldDef;
if (aggregate === 'count') {
return config.countTitle;
}
else if (isBinning(bin)) {
return `${field} (binned)`;
}
else if (timeUnit) {
const unit = (_a = normalizeTimeUnit(timeUnit)) === null || _a === void 0 ? void 0 : _a.unit;
if (unit) {
return `${field} (${getTimeUnitParts(unit).join('-')})`;
}
}
else if (aggregate) {
if (isArgmaxDef(aggregate)) {
return `${field} for max ${aggregate.argmax}`;
}
else if (isArgminDef(aggregate)) {
return `${field} for min ${aggregate.argmin}`;
}
else {
return `${titleCase(aggregate)} of ${field}`;
}
}
return field;
}
export function functionalTitleFormatter(fieldDef) {
const { aggregate, bin, timeUnit, field } = fieldDef;
if (isArgmaxDef(aggregate)) {
return `${field} for argmax(${aggregate.argmax})`;
}
else if (isArgminDef(aggregate)) {
return `${field} for argmin(${aggregate.argmin})`;
}
const timeUnitParams = normalizeTimeUnit(timeUnit);
const fn = aggregate || (timeUnitParams === null || timeUnitParams === void 0 ? void 0 : timeUnitParams.unit) || ((timeUnitParams === null || timeUnitParams === void 0 ? void 0 : timeUnitParams.maxbins) && 'timeunit') || (isBinning(bin) && 'bin');
if (fn) {
return fn.toUpperCase() + '(' + field + ')';
}
else {
return field;
}
}
export const defaultTitleFormatter = (fieldDef, config) => {
switch (config.fieldTitle) {
case 'plain':
return fieldDef.field;
case 'functional':
return functionalTitleFormatter(fieldDef);
default:
return verbalTitleFormatter(fieldDef, config);
}
};
let titleFormatter = defaultTitleFormatter;
export function setTitleFormatter(formatter) {
titleFormatter = formatter;
}
export function resetTitleFormatter() {
setTitleFormatter(defaultTitleFormatter);
}
export function title(fieldOrDatumDef, config, { allowDisabling, includeDefault = true }) {
var _a, _b;
const guideTitle = (_a = getGuide(fieldOrDatumDef)) === null || _a === void 0 ? void 0 : _a.title;
if (!isFieldDef(fieldOrDatumDef)) {
return guideTitle;
}
const fieldDef = fieldOrDatumDef;
const def = includeDefault ? defaultTitle(fieldDef, config) : undefined;
if (allowDisabling) {
return getFirstDefined(guideTitle, fieldDef.title, def);
}
else {
return (_b = guideTitle !== null && guideTitle !== void 0 ? guideTitle : fieldDef.title) !== null && _b !== void 0 ? _b : def;
}
}
export function getGuide(fieldDef) {
if (isPositionFieldOrDatumDef(fieldDef) && fieldDef.axis) {
return fieldDef.axis;
}
else if (isMarkPropFieldOrDatumDef(fieldDef) && fieldDef.legend) {
return fieldDef.legend;
}
else if (isFacetFieldDef(fieldDef) && fieldDef.header) {
return fieldDef.header;
}
return undefined;
}
export function defaultTitle(fieldDef, config) {
return titleFormatter(fieldDef, config);
}
export function getFormatMixins(fieldDef) {
var _a;
if (isStringFieldOrDatumDef(fieldDef)) {
const { format, formatType } = fieldDef;
return { format, formatType };
}
else {
const guide = (_a = getGuide(fieldDef)) !== null && _a !== void 0 ? _a : {};
const { format, formatType } = guide;
return { format, formatType };
}
}
export function defaultType(fieldDef, channel) {
var _a;
switch (channel) {
case 'latitude':
case 'longitude':
return 'quantitative';
case 'row':
case 'column':
case 'facet':
case 'shape':
case 'strokeDash':
return 'nominal';
}
if (isSortableFieldDef(fieldDef) && isArray(fieldDef.sort)) {
return 'ordinal';
}
const { aggregate, bin, timeUnit } = fieldDef;
if (timeUnit) {
return 'temporal';
}
if (bin || (aggregate && !isArgmaxDef(aggregate) && !isArgminDef(aggregate))) {
return 'quantitative';
}
if (isScaleFieldDef(fieldDef) && ((_a = fieldDef.scale) === null || _a === void 0 ? void 0 : _a.type)) {
switch (SCALE_CATEGORY_INDEX[fieldDef.scale.type]) {
case 'numeric':
case 'discretizing':
return 'quantitative';
case 'time':
return 'temporal';
}
}
return 'nominal';
}
/**
* Returns the fieldDef -- either from the outer channelDef or from the condition of channelDef.
* @param channelDef
*/
export function getFieldDef(channelDef) {
if (isFieldDef(channelDef)) {
return channelDef;
}
else if (hasConditionalFieldDef(channelDef)) {
return channelDef.condition;
}
return undefined;
}
export function getFieldOrDatumDef(channelDef) {
if (isFieldOrDatumDef(channelDef)) {
return channelDef;
}
else if (hasConditionalFieldOrDatumDef(channelDef)) {
return channelDef.condition;
}
return undefined;
}
/**
* Convert type to full, lowercase type, or augment the fieldDef with a default type if missing.
*/
export function initChannelDef(channelDef, channel, config, opt = {}) {
if (isString(channelDef) || isNumber(channelDef) || isBoolean(channelDef)) {
const primitiveType = isString(channelDef) ? 'string' : isNumber(channelDef) ? 'number' : 'boolean';
log.warn(log.message.primitiveChannelDef(channel, primitiveType, channelDef));
return { value: channelDef };
}
// If a fieldDef contains a field, we need type.
if (isFieldOrDatumDef(channelDef)) {
return initFieldOrDatumDef(channelDef, channel, config, opt);
}
else if (hasConditionalFieldOrDatumDef(channelDef)) {
return Object.assign(Object.assign({}, channelDef), {
// Need to cast as normalizeFieldDef normally return FieldDef, but here we know that it is definitely Condition<FieldDef>
condition: initFieldOrDatumDef(channelDef.condition, channel, config, opt) });
}
return channelDef;
}
export function initFieldOrDatumDef(fd, channel, config, opt) {
if (isStringFieldOrDatumDef(fd)) {
const { format, formatType } = fd, rest = __rest(fd, ["format", "formatType"]);
if (isCustomFormatType(formatType) && !config.customFormatTypes) {
log.warn(log.message.customFormatTypeNotAllowed(channel));
return initFieldOrDatumDef(rest, channel, config, opt);
}
}
else {
const guideType = isPositionFieldOrDatumDef(fd)
? 'axis'
: isMarkPropFieldOrDatumDef(fd)
? 'legend'
: isFacetFieldDef(fd)
? 'header'
: null;
if (guideType && fd[guideType]) {
const _a = fd[guideType], { format, formatType } = _a, newGuide = __rest(_a, ["format", "formatType"]);
if (isCustomFormatType(formatType) && !config.customFormatTypes) {
log.warn(log.message.customFormatTypeNotAllowed(channel));
return initFieldOrDatumDef(Object.assign(Object.assign({}, fd), { [guideType]: newGuide }), channel, config, opt);
}
}
}
if (isFieldDef(fd)) {
return initFieldDef(fd, channel, opt);
}
return initDatumDef(fd);
}
function initDatumDef(datumDef) {
let type = datumDef['type'];
if (type) {
return datumDef;
}
const { datum } = datumDef;
type = isNumber(datum) ? 'quantitative' : isString(datum) ? 'nominal' : isDateTime(datum) ? 'temporal' : undefined;
return Object.assign(Object.assign({}, datumDef), { type });
}
export function initFieldDef(fd, channel, { compositeMark = false } = {}) {
const { aggregate, timeUnit, bin, field } = fd;
const fieldDef = Object.assign({}, fd);
// Drop invalid aggregate
if (!compositeMark && aggregate && !isAggregateOp(aggregate) && !isArgmaxDef(aggregate) && !isArgminDef(aggregate)) {
log.warn(log.message.invalidAggregate(aggregate));
delete fieldDef.aggregate;
}
// Normalize Time Unit
if (timeUnit) {
fieldDef.timeUnit = normalizeTimeUnit(timeUnit);
}
if (field) {
fieldDef.field = `${field}`;
}
// Normalize bin
if (isBinning(bin)) {
fieldDef.bin = normalizeBin(bin, channel);
}
if (isBinned(bin) && !isXorY(channel)) {
log.warn(log.message.channelShouldNotBeUsedForBinned(channel));
}
// Normalize Type
if (isTypedFieldDef(fieldDef)) {
const { type } = fieldDef;
const fullType = getFullName(type);
if (type !== fullType) {
// convert short type to full type
fieldDef.type = fullType;
}
if (type !== 'quantitative') {
if (isCountingAggregateOp(aggregate)) {
log.warn(log.message.invalidFieldTypeForCountAggregate(type, aggregate));
fieldDef.type = 'quantitative';
}
}
}
else if (!isSecondaryRangeChannel(channel)) {
// If type is empty / invalid, then augment with default type
const newType = defaultType(fieldDef, channel);
fieldDef['type'] = newType;
}
if (isTypedFieldDef(fieldDef)) {
const { compatible, warning } = channelCompatibility(fieldDef, channel) || {};
if (compatible === false) {
log.warn(warning);
}
}
if (isSortableFieldDef(fieldDef) && isString(fieldDef.sort)) {
const { sort } = fieldDef;
if (isSortByChannel(sort)) {
return Object.assign(Object.assign({}, fieldDef), { sort: { encoding: sort } });
}
const sub = sort.substr(1);
if (sort.charAt(0) === '-' && isSortByChannel(sub)) {
return Object.assign(Object.assign({}, fieldDef), { sort: { encoding: sub, order: 'descending' } });
}
}
if (isFacetFieldDef(fieldDef)) {
const { header } = fieldDef;
const { orient } = header, rest = __rest(header, ["orient"]);
if (orient) {
return Object.assign(Object.assign({}, fieldDef), { header: Object.assign(Object.assign({}, rest), { labelOrient: header.labelOrient || orient, titleOrient: header.titleOrient || orient }) });
}
}
return fieldDef;
}
export function normalizeBin(bin, channel) {
if (isBoolean(bin)) {
return { maxbins: autoMaxBins(channel) };
}
else if (bin === 'binned') {
return {
binned: true
};
}
else if (!bin.maxbins && !bin.step) {
return Object.assign(Object.assign({}, bin), { maxbins: autoMaxBins(channel) });
}
else {
return bin;
}
}
const COMPATIBLE = { compatible: true };
export function channelCompatibility(fieldDef, channel) {
const type = fieldDef.type;
if (type === 'geojson' && channel !== 'shape') {
return {
compatible: false,
warning: `Channel ${channel} should not be used with a geojson data.`
};
}
switch (channel) {
case ROW:
case COLUMN:
case FACET:
if (isContinuous(fieldDef)) {
return {
compatible: false,
warning: log.message.facetChannelShouldBeDiscrete(channel)
};
}
return COMPATIBLE;
case X:
case Y:
case COLOR:
case FILL:
case STROKE:
case TEXT:
case DETAIL:
case KEY:
case TOOLTIP:
case HREF:
case URL:
case ANGLE:
case THETA:
case RADIUS:
case DESCRIPTION:
return COMPATIBLE;
case LONGITUDE:
case LONGITUDE2:
case LATITUDE:
case LATITUDE2:
if (type !== QUANTITATIVE) {
return {
compatible: false,
warning: `Channel ${channel} should be used with a quantitative field only, not ${fieldDef.type} field.`
};
}
return COMPATIBLE;
case OPACITY:
case FILLOPACITY:
case STROKEOPACITY:
case STROKEWIDTH:
case SIZE:
case THETA2:
case RADIUS2:
case X2:
case Y2:
if (type === 'nominal' && !fieldDef['sort']) {
return {
compatible: false,
warning: `Channel ${channel} should not be used with an unsorted discrete field.`
};
}
return COMPATIBLE;
case STROKEDASH:
if (!contains(['ordinal', 'nominal'], fieldDef.type)) {
return {
compatible: false,
warning: 'StrokeDash channel should be used with only discrete data.'
};
}
return COMPATIBLE;
case SHAPE:
if (!contains(['ordinal', 'nominal', 'geojson'], fieldDef.type)) {
return {
compatible: false,
warning: 'Shape channel should be used with only either discrete or geojson data.'
};
}
return COMPATIBLE;
case ORDER:
if (fieldDef.type === 'nominal' && !('sort' in fieldDef)) {
return {
compatible: false,
warning: `Channel order is inappropriate for nominal field, which has no inherent order.`
};
}
return COMPATIBLE;
}
}
/**
* Check if the field def uses a time format or does not use any format but is temporal
* (this does not cover field defs that are temporal but use a number format).
*/
export function isFieldOrDatumDefForTimeFormat(fieldOrDatumDef) {
const { formatType } = getFormatMixins(fieldOrDatumDef);
return formatType === 'time' || (!formatType && isTimeFieldDef(fieldOrDatumDef));
}
/**
* Check if field def has type `temporal`. If you want to also cover field defs that use a time format, use `isTimeFormatFieldDef`.
*/
export function isTimeFieldDef(def) {
return def && (def['type'] === 'temporal' || (isFieldDef(def) && !!def.timeUnit));
}
/**
* Getting a value associated with a fielddef.
* Convert the value to Vega expression if applicable (for datetime object, or string if the field def is temporal or has timeUnit)
*/
export function valueExpr(v, { timeUnit, type, wrapTime, undefinedIfExprNotRequired }) {
var _a;
const unit = timeUnit && ((_a = normalizeTimeUnit(timeUnit)) === null || _a === void 0 ? void 0 : _a.unit);
let isTime = unit || type === 'temporal';
let expr;
if (isSignalRef(v)) {
expr = v.signal;
}
else if (isDateTime(v)) {
isTime = true;
expr = dateTimeToExpr(v);
}
else if (isString(v) || isNumber(v)) {
if (isTime) {
expr = `datetime(${JSON.stringify(v)})`;
if (isLocalSingleTimeUnit(unit)) {
// for single timeUnit, we will use dateTimeToExpr to convert number/string to match the timeUnit
if ((isNumber(v) && v < 10000) || (isString(v) && isNaN(Date.parse(v)))) {
expr = dateTimeToExpr({ [unit]: v });
}
}
}
}
if (expr) {
return wrapTime && isTime ? `time(${expr})` : expr;
}
// number or boolean or normal string
return undefinedIfExprNotRequired ? undefined : JSON.stringify(v);
}
/**
* Standardize value array -- convert each value to Vega expression if applicable
*/
export function valueArray(fieldOrDatumDef, values) {
const { type } = fieldOrDatumDef;
return values.map(v => {
const expr = valueExpr(v, {
timeUnit: isFieldDef(fieldOrDatumDef) ? fieldOrDatumDef.timeUnit : undefined,
type,
undefinedIfExprNotRequired: true
});
// return signal for the expression if we need an expression
if (expr !== undefined) {
return { signal: expr };
}
// otherwise just return the original value
return v;
});
}
/**
* Checks whether a fieldDef for a particular channel requires a computed bin range.
*/
export function binRequiresRange(fieldDef, channel) {
if (!isBinning(fieldDef.bin)) {
console.warn('Only call this method for binned field defs.');
return false;
}
// We need the range only when the user explicitly forces a binned field to be use discrete scale. In this case, bin range is used in axis and legend labels.
// We could check whether the axis or legend exists (not disabled) but that seems overkill.
return isScaleChannel(channel) && contains(['ordinal', 'nominal'], fieldDef.type);
}
//# sourceMappingURL=channeldef.js.map

1
node_modules/vega-lite/build/src/channeldef.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
import { Axis as VgAxis, NewSignal } from 'vega';
import { Config } from '../../config';
import { Model } from '../model';
import { AxisComponent, AxisComponentIndex } from './component';
export declare function assembleAxis(axisCmpt: AxisComponent, kind: 'main' | 'grid', config: Config, opt?: {
header: boolean;
}): VgAxis;
/**
* Add axis signals so grid line works correctly
* (Fix https://github.com/vega/vega-lite/issues/4226)
*/
export declare function assembleAxisSignals(model: Model): NewSignal[];
export declare function assembleAxes(axisComponents: AxisComponentIndex, config: Config): VgAxis[];
//# sourceMappingURL=assemble.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../../../src/compile/axis/assemble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,MAAM,EAAc,SAAS,EAAkB,MAAM,MAAM,CAAC;AAK5E,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAKpC,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAyB9D,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,GAAG,GAAE;IACH,MAAM,EAAE,OAAO,CAAC;CACC,GAClB,MAAM,CA0IR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,CAwB7D;AAED,wBAAgB,YAAY,CAAC,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAQzF"}

View File

@@ -0,0 +1,170 @@
import { __rest } from "tslib";
import { array, isArray } from 'vega-util';
import { AXIS_PARTS, AXIS_PROPERTY_TYPE, CONDITIONAL_AXIS_PROP_INDEX, isConditionalAxisValue } from '../../axis';
import { POSITION_SCALE_CHANNELS } from '../../channel';
import { defaultTitle } from '../../channeldef';
import { isText } from '../../title';
import { getFirstDefined, isEmpty, replaceAll } from '../../util';
import { isSignalRef } from '../../vega.schema';
import { exprFromValueOrSignalRef } from '../common';
import { expression } from '../predicate';
function assembleTitle(title, config) {
if (!title) {
return undefined;
}
if (isArray(title) && !isText(title)) {
return title.map(fieldDef => defaultTitle(fieldDef, config)).join(', ');
}
return title;
}
function setAxisEncode(axis, part, vgProp, vgRef) {
var _a, _b, _c;
axis.encode = (_a = axis.encode) !== null && _a !== void 0 ? _a : {};
axis.encode[part] = (_b = axis.encode[part]) !== null && _b !== void 0 ? _b : {};
axis.encode[part].update = (_c = axis.encode[part].update) !== null && _c !== void 0 ? _c : {};
// TODO: remove as any after https://github.com/prisma/nexus-prisma/issues/291
axis.encode[part].update[vgProp] = vgRef;
}
export function assembleAxis(axisCmpt, kind, config, opt = { header: false }) {
var _a, _b;
const _c = axisCmpt.combine(), { disable, orient, scale, labelExpr, title, zindex } = _c, axis = __rest(_c, ["disable", "orient", "scale", "labelExpr", "title", "zindex"]);
if (disable) {
return undefined;
}
for (const prop in axis) {
const propType = AXIS_PROPERTY_TYPE[prop];
const propValue = axis[prop];
if (propType && propType !== kind && propType !== 'both') {
// Remove properties that are not valid for this kind of axis
delete axis[prop];
}
else if (isConditionalAxisValue(propValue)) {
// deal with conditional axis value
const { condition } = propValue, valueOrSignalRef = __rest(propValue, ["condition"]);
const conditions = array(condition);
const propIndex = CONDITIONAL_AXIS_PROP_INDEX[prop];
if (propIndex) {
const { vgProp, part } = propIndex;
// If there is a corresponding Vega property for the channel,
// use Vega's custom axis encoding and delete the original axis property to avoid conflicts
const vgRef = [
...conditions.map(c => {
const { test } = c, valueOrSignalCRef = __rest(c, ["test"]);
return Object.assign({ test: expression(null, test) }, valueOrSignalCRef);
}),
valueOrSignalRef
];
setAxisEncode(axis, part, vgProp, vgRef);
delete axis[prop];
}
else if (propIndex === null) {
// If propIndex is null, this means we support conditional axis property by converting the condition to signal instead.
const signalRef = {
signal: conditions
.map(c => {
const { test } = c, valueOrSignalCRef = __rest(c, ["test"]);
return `${expression(null, test)} ? ${exprFromValueOrSignalRef(valueOrSignalCRef)} : `;
})
.join('') + exprFromValueOrSignalRef(valueOrSignalRef)
};
axis[prop] = signalRef;
}
}
else if (isSignalRef(propValue)) {
const propIndex = CONDITIONAL_AXIS_PROP_INDEX[prop];
if (propIndex) {
const { vgProp, part } = propIndex;
setAxisEncode(axis, part, vgProp, propValue);
delete axis[prop];
} // else do nothing since the property already supports signal
}
}
if (kind === 'grid') {
if (!axis.grid) {
return undefined;
}
// Remove unnecessary encode block
if (axis.encode) {
// Only need to keep encode block for grid
const { grid } = axis.encode;
axis.encode = Object.assign({}, (grid ? { grid } : {}));
if (isEmpty(axis.encode)) {
delete axis.encode;
}
}
return Object.assign(Object.assign({ scale,
orient }, axis), { domain: false, labels: false, aria: false,
// Always set min/maxExtent to 0 to ensure that `config.axis*.minExtent` and `config.axis*.maxExtent`
// would not affect gridAxis
maxExtent: 0, minExtent: 0, ticks: false, zindex: getFirstDefined(zindex, 0) // put grid behind marks by default
});
}
else {
// kind === 'main'
if (!opt.header && axisCmpt.mainExtracted) {
// if mainExtracted has been extracted to a separate facet
return undefined;
}
if (labelExpr !== undefined) {
let expr = labelExpr;
if (((_b = (_a = axis.encode) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b.update) && isSignalRef(axis.encode.labels.update.text)) {
expr = replaceAll(labelExpr, 'datum.label', axis.encode.labels.update.text.signal);
}
setAxisEncode(axis, 'labels', 'text', { signal: expr });
}
if (axis.labelAlign === null) {
delete axis.labelAlign;
}
// Remove unnecessary encode block
if (axis.encode) {
for (const part of AXIS_PARTS) {
if (!axisCmpt.hasAxisPart(part)) {
delete axis.encode[part];
}
}
if (isEmpty(axis.encode)) {
delete axis.encode;
}
}
const titleString = assembleTitle(title, config);
return Object.assign(Object.assign(Object.assign(Object.assign({ scale,
orient, grid: false }, (titleString ? { title: titleString } : {})), axis), (config.aria === false ? { aria: false } : {})), { zindex: getFirstDefined(zindex, 0) // put axis line above marks by default
});
}
}
/**
* Add axis signals so grid line works correctly
* (Fix https://github.com/vega/vega-lite/issues/4226)
*/
export function assembleAxisSignals(model) {
const { axes } = model.component;
const signals = [];
for (const channel of POSITION_SCALE_CHANNELS) {
if (axes[channel]) {
for (const axis of axes[channel]) {
if (!axis.get('disable') && !axis.get('gridScale')) {
// If there is x-axis but no y-scale for gridScale, need to set height/width so x-axis can draw the grid with the right height. Same for y-axis and width.
const sizeType = channel === 'x' ? 'height' : 'width';
const update = model.getSizeSignalRef(sizeType).signal;
if (sizeType !== update) {
signals.push({
name: sizeType,
update: update
});
}
}
}
}
}
return signals;
}
export function assembleAxes(axisComponents, config) {
const { x = [], y = [] } = axisComponents;
return [
...x.map(a => assembleAxis(a, 'grid', config)),
...y.map(a => assembleAxis(a, 'grid', config)),
...x.map(a => assembleAxis(a, 'main', config)),
...y.map(a => assembleAxis(a, 'main', config))
].filter(a => a); // filter undefined
}
//# sourceMappingURL=assemble.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
import { Axis as VgAxis, SignalRef, Text } from 'vega';
import { Axis, AxisPart, AxisPropsWithConditionAndSignal, ConditionalAxisProp, SignalAxisProp } from '../../axis';
import { FieldDefBase } from '../../channeldef';
import { Split } from '../split';
export declare type AxisComponentProps = Omit<VgAxis, 'title' | ConditionalAxisProp | SignalAxisProp> & Omit<AxisPropsWithConditionAndSignal, 'title'> & {
title: Text | FieldDefBase<string>[] | SignalRef;
labelExpr: string;
disable: boolean;
};
export declare const AXIS_COMPONENT_PROPERTIES: ("orient" | "tickCount" | "aria" | "description" | "offset" | "titleAlign" | "titleAnchor" | "titleBaseline" | "titleColor" | "titleFont" | "titleFontSize" | "titleFontStyle" | "titleFontWeight" | "titleLimit" | "titleLineHeight" | "titleOpacity" | "titlePadding" | "labelAlign" | "labelBaseline" | "labelColor" | "labelFont" | "labelFontSize" | "labelFontStyle" | "labelFontWeight" | "labelLimit" | "labelOpacity" | "labelPadding" | "labelOffset" | "labelOverlap" | "labelSeparation" | "zindex" | "values" | "domain" | "title" | "labels" | "format" | "formatType" | "tickMinStep" | "encode" | "labelExpr" | "disable" | "titleAngle" | "labelAngle" | "labelLineHeight" | "scale" | "translate" | "ticks" | "gridColor" | "gridDash" | "gridDashOffset" | "gridOpacity" | "gridWidth" | "tickColor" | "tickDash" | "tickDashOffset" | "tickOpacity" | "tickSize" | "tickWidth" | "domainColor" | "minExtent" | "maxExtent" | "bandPosition" | "titleX" | "titleY" | "domainCap" | "domainDash" | "domainDashOffset" | "domainOpacity" | "domainWidth" | "tickBand" | "tickCap" | "tickExtra" | "tickOffset" | "tickRound" | "grid" | "gridCap" | "labelBound" | "labelFlush" | "labelFlushOffset" | "position" | "gridScale")[];
export declare class AxisComponent extends Split<AxisComponentProps> {
readonly explicit: Partial<AxisComponentProps>;
readonly implicit: Partial<AxisComponentProps>;
mainExtracted: boolean;
constructor(explicit?: Partial<AxisComponentProps>, implicit?: Partial<AxisComponentProps>, mainExtracted?: boolean);
clone(): AxisComponent;
hasAxisPart(part: AxisPart): boolean;
hasOrientSignalRef(): boolean;
}
export interface AxisComponentIndex {
x?: AxisComponent[];
y?: AxisComponent[];
}
export interface AxisIndex {
x?: Axis;
y?: Axis;
}
//# sourceMappingURL=component.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/compile/axis/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,MAAM,EAAE,SAAS,EAAE,IAAI,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,+BAA+B,EAE/B,mBAAmB,EACnB,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAO/B,oBAAY,kBAAkB,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,mBAAmB,GAAG,cAAc,CAAC,GAC3F,IAAI,CAAC,+BAA+B,EAAE,OAAO,CAAC,GAAG;IAC/C,KAAK,EAAE,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAWJ,eAAO,MAAM,yBAAyB,qrCAAwC,CAAC;AAE/E,qBAAa,aAAc,SAAQ,KAAK,CAAC,kBAAkB,CAAC;aAExC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;aACrC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAC9C,aAAa;gBAFJ,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,EAC1C,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,EACnD,aAAa,UAAQ;IAKvB,KAAK;IAIL,WAAW,CAAC,IAAI,EAAE,QAAQ;IAe1B,kBAAkB;CAG1B;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;IACpB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,CAAC,CAAC,EAAE,IAAI,CAAC;IACT,CAAC,CAAC,EAAE,IAAI,CAAC;CACV"}

View File

@@ -0,0 +1,36 @@
import { COMMON_AXIS_PROPERTIES_INDEX } from '../../axis';
import { duplicate, keys } from '../../util';
import { Split } from '../split';
import { isSignalRef } from '../../vega.schema';
function isFalseOrNull(v) {
return v === false || v === null;
}
const AXIS_COMPONENT_PROPERTIES_INDEX = Object.assign(Object.assign({ disable: 1, gridScale: 1, scale: 1 }, COMMON_AXIS_PROPERTIES_INDEX), { labelExpr: 1, encode: 1 });
export const AXIS_COMPONENT_PROPERTIES = keys(AXIS_COMPONENT_PROPERTIES_INDEX);
export class AxisComponent extends Split {
constructor(explicit = {}, implicit = {}, mainExtracted = false) {
super();
this.explicit = explicit;
this.implicit = implicit;
this.mainExtracted = mainExtracted;
}
clone() {
return new AxisComponent(duplicate(this.explicit), duplicate(this.implicit), this.mainExtracted);
}
hasAxisPart(part) {
// FIXME(https://github.com/vega/vega-lite/issues/2552) this method can be wrong if users use a Vega theme.
if (part === 'axis') {
// always has the axis container part
return true;
}
if (part === 'grid' || part === 'title') {
return !!this.get(part);
}
// Other parts are enabled by default, so they should not be false or null.
return !isFalseOrNull(this.get(part));
}
hasOrientSignalRef() {
return isSignalRef(this.explicit.orient);
}
}
//# sourceMappingURL=component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/compile/axis/component.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,4BAA4B,EAG7B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,SAAS,EAAQ,IAAI,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,SAAS,aAAa,CAAC,CAAM;IAC3B,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC;AACnC,CAAC;AASD,MAAM,+BAA+B,iCACnC,OAAO,EAAE,CAAC,EACV,SAAS,EAAE,CAAC,EACZ,KAAK,EAAE,CAAC,IACL,4BAA4B,KAC/B,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,CAAC,GACV,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC,+BAA+B,CAAC,CAAC;AAE/E,MAAM,OAAO,aAAc,SAAQ,KAAyB;IAC1D,YACkB,WAAwC,EAAE,EAC1C,WAAwC,EAAE,EACnD,gBAAgB,KAAK;QAE5B,KAAK,EAAE,CAAC;QAJQ,aAAQ,GAAR,QAAQ,CAAkC;QAC1C,aAAQ,GAAR,QAAQ,CAAkC;QACnD,kBAAa,GAAb,aAAa,CAAQ;IAG9B,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACnG,CAAC;IAEM,WAAW,CAAC,IAAc;QAC/B,2GAA2G;QAE3G,IAAI,IAAI,KAAK,MAAM,EAAE;YACnB,qCAAqC;YACrC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,EAAE;YACvC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACzB;QACD,2EAA2E;QAC3E,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAEM,kBAAkB;QACvB,OAAO,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF"}

View File

@@ -0,0 +1,16 @@
import { ScaleType, SignalRef } from 'vega';
import { AxisConfig } from '../../axis';
import { PositionScaleChannel } from '../../channel';
import { Config, StyleConfigIndex } from '../../config';
export declare type AxisConfigs = ReturnType<typeof getAxisConfigs>;
export declare function getAxisConfigs(channel: PositionScaleChannel, scaleType: ScaleType, orient: string | SignalRef, config: Config): {
vlOnlyAxisConfig: any;
vgAxisConfig: any;
axisConfigStyle: any;
};
export declare function getAxisConfigStyle(axisConfigTypes: string[], config: Config): any;
export declare function getAxisConfig(property: keyof AxisConfig, styleConfigIndex: StyleConfigIndex, style: string | string[], axisConfigs?: Partial<AxisConfigs>): {
configFrom?: string;
configValue?: any;
};
//# sourceMappingURL=config.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/compile/axis/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAyCtD,oBAAY,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,MAAM;;;;EA8Bf;AAED,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,OAa3E;AACD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,UAAU,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,WAAW,GAAE,OAAO,CAAC,WAAW,CAAM,GACrC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAC,CAgB1C"}

View File

@@ -0,0 +1,85 @@
import { array } from 'vega-util';
import { isQuantitative } from '../../scale';
import { keys, titleCase } from '../../util';
import { isSignalRef } from '../../vega.schema';
import { getStyleConfig, signalOrStringValue } from '../common';
function getAxisConfigFromConfigTypes(configTypes, config, channel, orient) {
// TODO: add special casing to add conditional value based on orient signal
return Object.assign.apply(null, [
{},
...configTypes.map(configType => {
if (configType === 'axisOrient') {
const orient1 = channel === 'x' ? 'bottom' : 'left';
const orientConfig1 = config[channel === 'x' ? 'axisBottom' : 'axisLeft'] || {};
const orientConfig2 = config[channel === 'x' ? 'axisTop' : 'axisRight'] || {};
const props = new Set([...keys(orientConfig1), ...keys(orientConfig2)]);
const conditionalOrientAxisConfig = {};
for (const prop of props.values()) {
conditionalOrientAxisConfig[prop] = {
// orient is surely signal in this case
signal: `${orient['signal']} === "${orient1}" ? ${signalOrStringValue(orientConfig1[prop])} : ${signalOrStringValue(orientConfig2[prop])}`
};
}
return conditionalOrientAxisConfig;
}
return config[configType];
})
]);
}
export function getAxisConfigs(channel, scaleType, orient, config) {
const typeBasedConfigTypes = scaleType === 'band'
? ['axisDiscrete', 'axisBand']
: scaleType === 'point'
? ['axisDiscrete', 'axisPoint']
: isQuantitative(scaleType)
? ['axisQuantitative']
: scaleType === 'time' || scaleType === 'utc'
? ['axisTemporal']
: [];
const axisChannel = channel === 'x' ? 'axisX' : 'axisY';
const axisOrient = isSignalRef(orient) ? 'axisOrient' : 'axis' + titleCase(orient); // axisTop, axisBottom, ...
const vlOnlyConfigTypes = [
// technically Vega does have axisBand, but if we make another separation here,
// it will further introduce complexity in the code
...typeBasedConfigTypes,
...typeBasedConfigTypes.map(c => axisChannel + c.substr(4))
];
const vgConfigTypes = ['axis', axisOrient, axisChannel];
return {
vlOnlyAxisConfig: getAxisConfigFromConfigTypes(vlOnlyConfigTypes, config, channel, orient),
vgAxisConfig: getAxisConfigFromConfigTypes(vgConfigTypes, config, channel, orient),
axisConfigStyle: getAxisConfigStyle([...vgConfigTypes, ...vlOnlyConfigTypes], config)
};
}
export function getAxisConfigStyle(axisConfigTypes, config) {
var _a;
const toMerge = [{}];
for (const configType of axisConfigTypes) {
// TODO: add special casing to add conditional value based on orient signal
let style = (_a = config[configType]) === null || _a === void 0 ? void 0 : _a.style;
if (style) {
style = array(style);
for (const s of style) {
toMerge.push(config.style[s]);
}
}
}
return Object.assign.apply(null, toMerge);
}
export function getAxisConfig(property, styleConfigIndex, style, axisConfigs = {}) {
var _a;
const styleConfig = getStyleConfig(property, style, styleConfigIndex);
if (styleConfig !== undefined) {
return {
configFrom: 'style',
configValue: styleConfig
};
}
for (const configFrom of ['vlOnlyAxisConfig', 'vgAxisConfig', 'axisConfigStyle']) {
if (((_a = axisConfigs[configFrom]) === null || _a === void 0 ? void 0 : _a[property]) !== undefined) {
return { configFrom, configValue: axisConfigs[configFrom][property] };
}
}
return {};
}
//# sourceMappingURL=config.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/compile/axis/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAC;AAIhC,OAAO,EAAC,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EAAE,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAC,CAAC;SACrE;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}

View File

@@ -0,0 +1,4 @@
import { PositionScaleChannel } from '../../channel';
import { UnitModel } from '../unit';
export declare function labels(model: UnitModel, channel: PositionScaleChannel, specifiedLabelsSpec: any): any;
//# sourceMappingURL=encode.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../../src/compile/axis/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAG7E,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAElC,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,OAsB/F"}

View File

@@ -0,0 +1,21 @@
import { getSecondaryRangeChannel } from '../../channel';
import { getFieldOrDatumDef } from '../../channeldef';
import { formatCustomType, isCustomFormatType } from '../format';
export function labels(model, channel, specifiedLabelsSpec) {
var _a;
const { encoding, config } = model;
const fieldOrDatumDef = (_a = getFieldOrDatumDef(encoding[channel])) !== null && _a !== void 0 ? _a : getFieldOrDatumDef(encoding[getSecondaryRangeChannel(channel)]);
const axis = model.axis(channel) || {};
const { format, formatType } = axis;
if (isCustomFormatType(formatType)) {
return Object.assign({ text: formatCustomType({
fieldOrDatumDef,
field: 'datum.value',
format,
formatType,
config
}) }, specifiedLabelsSpec);
}
return specifiedLabelsSpec;
}
//# sourceMappingURL=encode.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../../../../src/compile/axis/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAuB,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAG/D,MAAM,UAAU,MAAM,CAAC,KAAgB,EAAE,OAA6B,EAAE,mBAAwB;;IAC9F,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,KAAK,CAAC;IAEjC,MAAM,eAAe,SACnB,kBAAkB,CAAS,QAAQ,CAAC,OAAO,CAAC,CAAC,mCAAI,kBAAkB,CAAC,QAAQ,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnH,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACvC,MAAM,EAAC,MAAM,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC;IAElC,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE;QAClC,uBACE,IAAI,EAAE,gBAAgB,CAAC;gBACrB,eAAe;gBACf,KAAK,EAAE,aAAa;gBACpB,MAAM;gBACN,UAAU;gBACV,MAAM;aACP,CAAC,IACC,mBAAmB,EACtB;KACH;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}

View File

@@ -0,0 +1,6 @@
import { LayerModel } from '../layer';
import { UnitModel } from '../unit';
import { AxisComponentIndex } from './component';
export declare function parseUnitAxes(model: UnitModel): AxisComponentIndex;
export declare function parseLayerAxes(model: LayerModel): void;
//# sourceMappingURL=parse.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/compile/axis/parse.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAClC,OAAO,EAAgB,kBAAkB,EAAgD,MAAM,aAAa,CAAC;AAK7G,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,kBAAkB,CAOlE;AASD,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,QAsE/C"}

262
node_modules/vega-lite/build/src/compile/axis/parse.js generated vendored Normal file
View File

@@ -0,0 +1,262 @@
import { AXIS_PARTS, isAxisProperty, isConditionalAxisValue } from '../../axis';
import { POSITION_SCALE_CHANNELS } from '../../channel';
import { getFieldOrDatumDef } from '../../channeldef';
import { getFirstDefined, isEmpty, keys, normalizeAngle } from '../../util';
import { isSignalRef } from '../../vega.schema';
import { mergeTitleComponent } from '../common';
import { guideEncodeEntry } from '../guide';
import { parseGuideResolve } from '../resolve';
import { defaultTieBreaker, mergeValuesWithExplicit } from '../split';
import { AxisComponent, AXIS_COMPONENT_PROPERTIES } from './component';
import { getAxisConfig, getAxisConfigs } from './config';
import * as encode from './encode';
import { axisRules, defaultOrient, getFieldDefTitle, getLabelAngle } from './properties';
export function parseUnitAxes(model) {
return POSITION_SCALE_CHANNELS.reduce((axis, channel) => {
if (model.component.scales[channel]) {
axis[channel] = [parseAxis(channel, model)];
}
return axis;
}, {});
}
const OPPOSITE_ORIENT = {
bottom: 'top',
top: 'bottom',
left: 'right',
right: 'left'
};
export function parseLayerAxes(model) {
var _a;
const { axes, resolve } = model.component;
const axisCount = { top: 0, bottom: 0, right: 0, left: 0 };
for (const child of model.children) {
child.parseAxesAndHeaders();
for (const channel of keys(child.component.axes)) {
resolve.axis[channel] = parseGuideResolve(model.component.resolve, channel);
if (resolve.axis[channel] === 'shared') {
// If the resolve says shared (and has not been overridden)
// We will try to merge and see if there is a conflict
axes[channel] = mergeAxisComponents(axes[channel], child.component.axes[channel]);
if (!axes[channel]) {
// If merge returns nothing, there is a conflict so we cannot make the axis shared.
// Thus, mark axis as independent and remove the axis component.
resolve.axis[channel] = 'independent';
delete axes[channel];
}
}
}
}
// Move axes to layer's axis component and merge shared axes
for (const channel of POSITION_SCALE_CHANNELS) {
for (const child of model.children) {
if (!child.component.axes[channel]) {
// skip if the child does not have a particular axis
continue;
}
if (resolve.axis[channel] === 'independent') {
// If axes are independent, concat the axisComponent array.
axes[channel] = ((_a = axes[channel]) !== null && _a !== void 0 ? _a : []).concat(child.component.axes[channel]);
// Automatically adjust orient
for (const axisComponent of child.component.axes[channel]) {
const { value: orient, explicit } = axisComponent.getWithExplicit('orient');
if (isSignalRef(orient)) {
continue;
}
if (axisCount[orient] > 0 && !explicit) {
// Change axis orient if the number do not match
const oppositeOrient = OPPOSITE_ORIENT[orient];
if (axisCount[orient] > axisCount[oppositeOrient]) {
axisComponent.set('orient', oppositeOrient, false);
}
}
axisCount[orient]++;
// TODO(https://github.com/vega/vega-lite/issues/2634): automatically add extra offset?
}
}
// After merging, make sure to remove axes from child
delete child.component.axes[channel];
}
// Suppress grid lines for dual axis charts (https://github.com/vega/vega-lite/issues/4676)
if (resolve.axis[channel] === 'independent' && axes[channel] && axes[channel].length > 1) {
for (const axisCmpt of axes[channel]) {
if (!!axisCmpt.get('grid') && !axisCmpt.explicit.grid) {
axisCmpt.implicit.grid = false;
}
}
}
}
}
function mergeAxisComponents(mergedAxisCmpts, childAxisCmpts) {
if (mergedAxisCmpts) {
// FIXME: this is a bit wrong once we support multiple axes
if (mergedAxisCmpts.length !== childAxisCmpts.length) {
return undefined; // Cannot merge axis component with different number of axes.
}
const length = mergedAxisCmpts.length;
for (let i = 0; i < length; i++) {
const merged = mergedAxisCmpts[i];
const child = childAxisCmpts[i];
if (!!merged !== !!child) {
return undefined;
}
else if (merged && child) {
const mergedOrient = merged.getWithExplicit('orient');
const childOrient = child.getWithExplicit('orient');
if (mergedOrient.explicit && childOrient.explicit && mergedOrient.value !== childOrient.value) {
// TODO: throw warning if resolve is explicit (We don't have info about explicit/implicit resolve yet.)
// Cannot merge due to inconsistent orient
return undefined;
}
else {
mergedAxisCmpts[i] = mergeAxisComponent(merged, child);
}
}
}
}
else {
// For first one, return a copy of the child
return childAxisCmpts.map(axisComponent => axisComponent.clone());
}
return mergedAxisCmpts;
}
function mergeAxisComponent(merged, child) {
for (const prop of AXIS_COMPONENT_PROPERTIES) {
const mergedValueWithExplicit = mergeValuesWithExplicit(merged.getWithExplicit(prop), child.getWithExplicit(prop), prop, 'axis',
// Tie breaker function
(v1, v2) => {
switch (prop) {
case 'title':
return mergeTitleComponent(v1, v2);
case 'gridScale':
return {
explicit: v1.explicit,
value: getFirstDefined(v1.value, v2.value)
};
}
return defaultTieBreaker(v1, v2, prop, 'axis');
});
merged.setWithExplicit(prop, mergedValueWithExplicit);
}
return merged;
}
// eslint-disable-next-line @typescript-eslint/ban-types
function isExplicit(value, property, axis, model, channel) {
if (property === 'disable') {
return axis !== undefined; // if axis is specified or null/false, then it's enable/disable state is explicit
}
axis = axis || {};
switch (property) {
case 'titleAngle':
case 'labelAngle':
return value === (isSignalRef(axis.labelAngle) ? axis.labelAngle : normalizeAngle(axis.labelAngle));
case 'values':
return !!axis.values;
// specified axis.values is already respected, but may get transformed.
case 'encode':
// both VL axis.encoding and axis.labelAngle affect VG axis.encode
return !!axis.encoding || !!axis.labelAngle;
case 'title':
// title can be explicit if fieldDef.title is set
if (value === getFieldDefTitle(model, channel)) {
return true;
}
}
// Otherwise, things are explicit if the returned value matches the specified property
return value === axis[property];
}
/**
* Properties to always include values from config
*/
const propsToAlwaysIncludeConfig = new Set([
'grid',
'translate',
// the rest are not axis configs in Vega, but are in VL, so we need to set too.
'format',
'formatType',
'orient',
'labelExpr',
'tickCount',
'position',
'tickMinStep'
]);
function parseAxis(channel, model) {
var _a, _b, _c;
let axis = model.axis(channel);
const axisComponent = new AxisComponent();
const fieldOrDatumDef = getFieldOrDatumDef(model.encoding[channel]);
const { mark, config } = model;
const orient = (axis === null || axis === void 0 ? void 0 : axis.orient) || ((_a = config[channel === 'x' ? 'axisX' : 'axisY']) === null || _a === void 0 ? void 0 : _a.orient) || ((_b = config.axis) === null || _b === void 0 ? void 0 : _b.orient) ||
defaultOrient(channel);
const scaleType = model.getScaleComponent(channel).get('type');
const axisConfigs = getAxisConfigs(channel, scaleType, orient, model.config);
const disable = axis !== undefined ? !axis : getAxisConfig('disable', config.style, axis === null || axis === void 0 ? void 0 : axis.style, axisConfigs).configValue;
axisComponent.set('disable', disable, axis !== undefined);
if (disable) {
return axisComponent;
}
axis = axis || {};
const labelAngle = getLabelAngle(fieldOrDatumDef, axis, channel, config.style, axisConfigs);
const ruleParams = {
fieldOrDatumDef,
axis,
channel,
model,
scaleType,
orient,
labelAngle,
mark,
config
};
// 1.2. Add properties
for (const property of AXIS_COMPONENT_PROPERTIES) {
const value = property in axisRules ? axisRules[property](ruleParams) : isAxisProperty(property) ? axis[property] : undefined;
const hasValue = value !== undefined;
const explicit = isExplicit(value, property, axis, model, channel);
if (hasValue && explicit) {
axisComponent.set(property, value, explicit);
}
else {
const { configValue = undefined, configFrom = undefined } = isAxisProperty(property) && property !== 'values'
? getAxisConfig(property, config.style, axis.style, axisConfigs)
: {};
const hasConfigValue = configValue !== undefined;
if (hasValue && !hasConfigValue) {
// only set property if it is explicitly set or has no config value (otherwise we will accidentally override config)
axisComponent.set(property, value, explicit);
}
else if (
// Cases need implicit values
// 1. Axis config that aren't available in Vega
!(configFrom === 'vgAxisConfig') ||
// 2. Certain properties are always included (see `propsToAlwaysIncludeConfig`'s declaration for more details)
(propsToAlwaysIncludeConfig.has(property) && hasConfigValue) ||
// 3. Conditional axis values and signals
isConditionalAxisValue(configValue) ||
isSignalRef(configValue)) {
// If a config is specified and is conditional, copy conditional value from axis config
axisComponent.set(property, configValue, false);
}
}
}
// 2) Add guide encode definition groups
const axisEncoding = (_c = axis.encoding) !== null && _c !== void 0 ? _c : {};
const axisEncode = AXIS_PARTS.reduce((e, part) => {
var _a;
if (!axisComponent.hasAxisPart(part)) {
// No need to create encode for a disabled part.
return e;
}
const axisEncodingPart = guideEncodeEntry((_a = axisEncoding[part]) !== null && _a !== void 0 ? _a : {}, model);
const value = part === 'labels' ? encode.labels(model, channel, axisEncodingPart) : axisEncodingPart;
if (value !== undefined && !isEmpty(value)) {
e[part] = { update: value };
}
return e;
}, {});
// FIXME: By having encode as one property, we won't have fine grained encode merging.
if (!isEmpty(axisEncode)) {
axisComponent.set('encode', axisEncode, !!axis.encoding || axis.labelAngle !== undefined);
}
return axisComponent;
}
//# sourceMappingURL=parse.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,55 @@
import { Align, AxisOrient, Orient, SignalRef } from 'vega';
import { Axis } from '../../axis';
import { PositionScaleChannel } from '../../channel';
import { DatumDef, PositionDatumDef, PositionFieldDef, TypedFieldDef } from '../../channeldef';
import { Config, StyleConfigIndex } from '../../config';
import { Mark } from '../../mark';
import { Sort } from '../../sort';
import { Type } from '../../type';
import { UnitModel } from '../unit';
import { ScaleType } from './../../scale';
import { AxisComponentProps } from './component';
import { AxisConfigs } from './config';
export interface AxisRuleParams {
fieldOrDatumDef: PositionFieldDef<string> | PositionDatumDef<string>;
axis: Axis;
channel: PositionScaleChannel;
model: UnitModel;
mark: Mark;
scaleType: ScaleType;
orient: Orient | SignalRef;
labelAngle: number | SignalRef;
config: Config;
}
export declare const axisRules: {
[k in keyof AxisComponentProps]?: (params: AxisRuleParams) => AxisComponentProps[k];
};
/**
* Default rules for whether to show a grid should be shown for a channel.
* If `grid` is unspecified, the default value is `true` for ordinal scales that are not binned
*/
export declare function defaultGrid(scaleType: ScaleType, fieldDef: TypedFieldDef<string> | DatumDef): boolean;
export declare function gridScale(model: UnitModel, channel: PositionScaleChannel): string;
export declare function getLabelAngle(fieldOrDatumDef: PositionFieldDef<string> | PositionDatumDef<string>, axis: Axis, channel: PositionScaleChannel, styleConfig: StyleConfigIndex, axisConfigs?: AxisConfigs): number | SignalRef;
export declare function normalizeAngleExpr(angle: SignalRef): string;
export declare function defaultLabelBaseline(angle: number | SignalRef, orient: AxisOrient | SignalRef, channel: 'x' | 'y', alwaysIncludeMiddle?: boolean): "top" | "middle" | "bottom" | {
signal: string;
};
export declare function defaultLabelAlign(angle: number | SignalRef, orient: AxisOrient | SignalRef, channel: 'x' | 'y'): Align | SignalRef;
export declare function defaultLabelFlush(type: Type, channel: PositionScaleChannel): boolean;
export declare function defaultLabelOverlap(type: Type, scaleType: ScaleType, hasTimeUnit: boolean, sort?: Sort<string>): true | "greedy";
export declare function defaultOrient(channel: PositionScaleChannel): "left" | "bottom";
export declare function defaultTickCount({ fieldOrDatumDef, scaleType, size, values: vals }: {
fieldOrDatumDef: TypedFieldDef<string> | DatumDef;
scaleType: ScaleType;
size?: SignalRef;
values?: Axis['values'];
}): {
signal: string;
};
export declare function getFieldDefTitle(model: UnitModel, channel: 'x' | 'y'): string | string[] | SignalRef;
export declare function values(axis: Axis, fieldOrDatumDef: TypedFieldDef<string> | DatumDef): SignalRef | (string | number | boolean | import("../../datetime").DateTime | {
signal: string;
})[];
export declare function defaultZindex(mark: Mark, fieldDef: TypedFieldDef<string> | DatumDef): 1 | 0;
//# sourceMappingURL=properties.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../../../src/compile/axis/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAC,oBAAoB,EAAI,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,QAAQ,EAGR,gBAAgB,EAChB,gBAAgB,EAEhB,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAmB,IAAI,EAAC,MAAM,YAAY,CAAC;AAKlD,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAClC,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAC,WAAW,EAA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EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,EAAE,GAAG,GAAG,GAAG,GACjB,KAAK,GAAG,SAAS,CAqCnB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,oBAAoB,WAK1E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,mBAS9G;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,qBAE1D;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,eAAe,EACf,SAAS,EACT,IAAI,EACJ,MAAM,EAAE,IAAI,EACb,EAAE;IACD,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;IAClD,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;CACzB;;EAoBA;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,GAAG,GAAG,iCAuBpE;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ;;KAUnF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,QAAQ,SAKnF"}

View File

@@ -0,0 +1,254 @@
import { isArray, isObject } from 'vega-util';
import { isBinned, isBinning } from '../../bin';
import { X } from '../../channel';
import { isDiscrete, isFieldDef, toFieldDefBase, valueArray } from '../../channeldef';
import { hasDiscreteDomain } from '../../scale';
import { normalizeTimeUnit } from '../../timeunit';
import { NOMINAL, ORDINAL } from '../../type';
import { contains, normalizeAngle } from '../../util';
import { isSignalRef } from '../../vega.schema';
import { mergeTitle, mergeTitleFieldDefs } from '../common';
import { guideFormat, guideFormatType } from '../format';
import { getAxisConfig } from './config';
export const axisRules = {
scale: ({ model, channel }) => model.scaleName(channel),
format: ({ fieldOrDatumDef, config, axis }) => {
const { format, formatType } = axis;
return guideFormat(fieldOrDatumDef, fieldOrDatumDef.type, format, formatType, config, true);
},
formatType: ({ axis, fieldOrDatumDef, scaleType }) => {
const { formatType } = axis;
return guideFormatType(formatType, fieldOrDatumDef, scaleType);
},
grid: ({ fieldOrDatumDef, axis, scaleType }) => {
var _a;
if (isFieldDef(fieldOrDatumDef) && isBinned(fieldOrDatumDef.bin)) {
return false;
}
else {
return (_a = axis.grid) !== null && _a !== void 0 ? _a : defaultGrid(scaleType, fieldOrDatumDef);
}
},
gridScale: ({ model, channel }) => gridScale(model, channel),
labelAlign: ({ axis, labelAngle, orient, channel }) => axis.labelAlign || defaultLabelAlign(labelAngle, orient, channel),
labelAngle: ({ labelAngle }) => labelAngle,
labelBaseline: ({ axis, labelAngle, orient, channel }) => axis.labelBaseline || defaultLabelBaseline(labelAngle, orient, channel),
labelFlush: ({ axis, fieldOrDatumDef, channel }) => { var _a; return (_a = axis.labelFlush) !== null && _a !== void 0 ? _a : defaultLabelFlush(fieldOrDatumDef.type, channel); },
labelOverlap: ({ axis, fieldOrDatumDef, scaleType }) => { var _a; return (_a = axis.labelOverlap) !== null && _a !== void 0 ? _a : defaultLabelOverlap(fieldOrDatumDef.type, scaleType, isFieldDef(fieldOrDatumDef) && !!fieldOrDatumDef.timeUnit, isFieldDef(fieldOrDatumDef) ? fieldOrDatumDef.sort : undefined); },
// we already calculate orient in parse
orient: ({ orient }) => orient,
tickCount: ({ channel, model, axis, fieldOrDatumDef, scaleType }) => {
var _a;
const sizeType = channel === 'x' ? 'width' : channel === 'y' ? 'height' : undefined;
const size = sizeType ? model.getSizeSignalRef(sizeType) : undefined;
return (_a = axis.tickCount) !== null && _a !== void 0 ? _a : defaultTickCount({ fieldOrDatumDef, scaleType, size, values: axis.values });
},
title: ({ axis, model, channel }) => {
if (axis.title !== undefined) {
return axis.title;
}
const fieldDefTitle = getFieldDefTitle(model, channel);
if (fieldDefTitle !== undefined) {
return fieldDefTitle;
}
const fieldDef = model.typedFieldDef(channel);
const channel2 = channel === 'x' ? 'x2' : 'y2';
const fieldDef2 = model.fieldDef(channel2);
// If title not specified, store base parts of fieldDef (and fieldDef2 if exists)
return mergeTitleFieldDefs(fieldDef ? [toFieldDefBase(fieldDef)] : [], isFieldDef(fieldDef2) ? [toFieldDefBase(fieldDef2)] : []);
},
values: ({ axis, fieldOrDatumDef }) => values(axis, fieldOrDatumDef),
zindex: ({ axis, fieldOrDatumDef, mark }) => { var _a; return (_a = axis.zindex) !== null && _a !== void 0 ? _a : defaultZindex(mark, fieldOrDatumDef); }
};
// TODO: we need to refactor this method after we take care of config refactoring
/**
* Default rules for whether to show a grid should be shown for a channel.
* If `grid` is unspecified, the default value is `true` for ordinal scales that are not binned
*/
export function defaultGrid(scaleType, fieldDef) {
return !hasDiscreteDomain(scaleType) && isFieldDef(fieldDef) && !isBinning(fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.bin);
}
export function gridScale(model, channel) {
const gridChannel = channel === 'x' ? 'y' : 'x';
if (model.getScaleComponent(gridChannel)) {
return model.scaleName(gridChannel);
}
return undefined;
}
export function getLabelAngle(fieldOrDatumDef, axis, channel, styleConfig, axisConfigs) {
const labelAngle = axis === null || axis === void 0 ? void 0 : axis.labelAngle;
// try axis value
if (labelAngle !== undefined) {
return isSignalRef(labelAngle) ? labelAngle : normalizeAngle(labelAngle);
}
else {
// try axis config value
const { configValue: angle } = getAxisConfig('labelAngle', styleConfig, axis === null || axis === void 0 ? void 0 : axis.style, axisConfigs);
if (angle !== undefined) {
return normalizeAngle(angle);
}
else {
// get default value
if (channel === X &&
contains([NOMINAL, ORDINAL], fieldOrDatumDef.type) &&
!(isFieldDef(fieldOrDatumDef) && fieldOrDatumDef.timeUnit)) {
return 270;
}
// no default
return undefined;
}
}
}
export function normalizeAngleExpr(angle) {
return `(((${angle.signal} % 360) + 360) % 360)`;
}
export function defaultLabelBaseline(angle, orient, channel, alwaysIncludeMiddle) {
if (angle !== undefined) {
if (channel === 'x') {
if (isSignalRef(angle)) {
const a = normalizeAngleExpr(angle);
const orientIsTop = isSignalRef(orient) ? `(${orient.signal} === "top")` : orient === 'top';
return {
signal: `(45 < ${a} && ${a} < 135) || (225 < ${a} && ${a} < 315) ? "middle" :` +
`(${a} <= 45 || 315 <= ${a}) === ${orientIsTop} ? "bottom" : "top"`
};
}
if ((45 < angle && angle < 135) || (225 < angle && angle < 315)) {
return 'middle';
}
if (isSignalRef(orient)) {
const op = angle <= 45 || 315 <= angle ? '===' : '!==';
return { signal: `${orient.signal} ${op} "top" ? "bottom" : "top"` };
}
return (angle <= 45 || 315 <= angle) === (orient === 'top') ? 'bottom' : 'top';
}
else {
if (isSignalRef(angle)) {
const a = normalizeAngleExpr(angle);
const orientIsLeft = isSignalRef(orient) ? `(${orient.signal} === "left")` : orient === 'left';
const middle = alwaysIncludeMiddle ? '"middle"' : 'null';
return {
signal: `${a} <= 45 || 315 <= ${a} || (135 <= ${a} && ${a} <= 225) ? ${middle} : (45 <= ${a} && ${a} <= 135) === ${orientIsLeft} ? "top" : "bottom"`
};
}
if (angle <= 45 || 315 <= angle || (135 <= angle && angle <= 225)) {
return alwaysIncludeMiddle ? 'middle' : null;
}
if (isSignalRef(orient)) {
const op = 45 <= angle && angle <= 135 ? '===' : '!==';
return { signal: `${orient.signal} ${op} "left" ? "top" : "bottom"` };
}
return (45 <= angle && angle <= 135) === (orient === 'left') ? 'top' : 'bottom';
}
}
return undefined;
}
export function defaultLabelAlign(angle, orient, channel) {
if (angle === undefined) {
return undefined;
}
const isX = channel === 'x';
const startAngle = isX ? 0 : 90;
const mainOrient = isX ? 'bottom' : 'left';
if (isSignalRef(angle)) {
const a = normalizeAngleExpr(angle);
const orientIsMain = isSignalRef(orient) ? `(${orient.signal} === "${mainOrient}")` : orient === mainOrient;
return {
signal: `(${startAngle ? '(' + a + ' + 90)' : a} % 180 === 0) ? ${isX ? null : '"center"'} :` +
`(${startAngle} < ${a} && ${a} < ${180 + startAngle}) === ${orientIsMain} ? "left" : "right"`
};
}
if ((angle + startAngle) % 180 === 0) {
// For bottom, use default label align so label flush still works
return isX ? null : 'center';
}
if (isSignalRef(orient)) {
const op = startAngle < angle && angle < 180 + startAngle ? '===' : '!==';
const orientIsMain = `${orient.signal} ${op} "${mainOrient}"`;
return {
signal: `${orientIsMain} ? "left" : "right"`
};
}
if ((startAngle < angle && angle < 180 + startAngle) === (orient === mainOrient)) {
return 'left';
}
return 'right';
}
export function defaultLabelFlush(type, channel) {
if (channel === 'x' && contains(['quantitative', 'temporal'], type)) {
return true;
}
return undefined;
}
export function defaultLabelOverlap(type, scaleType, hasTimeUnit, sort) {
// do not prevent overlap for nominal data because there is no way to infer what the missing labels are
if ((hasTimeUnit && !isObject(sort)) || (type !== 'nominal' && type !== 'ordinal')) {
if (scaleType === 'log') {
return 'greedy';
}
return true;
}
return undefined;
}
export function defaultOrient(channel) {
return channel === 'x' ? 'bottom' : 'left';
}
export function defaultTickCount({ fieldOrDatumDef, scaleType, size, values: vals }) {
var _a;
if (!vals && !hasDiscreteDomain(scaleType) && scaleType !== 'log') {
if (isFieldDef(fieldOrDatumDef)) {
if (isBinning(fieldOrDatumDef.bin)) {
// for binned data, we don't want more ticks than maxbins
return { signal: `ceil(${size.signal}/10)` };
}
if (fieldOrDatumDef.timeUnit &&
contains(['month', 'hours', 'day', 'quarter'], (_a = normalizeTimeUnit(fieldOrDatumDef.timeUnit)) === null || _a === void 0 ? void 0 : _a.unit)) {
return undefined;
}
}
return { signal: `ceil(${size.signal}/40)` };
}
return undefined;
}
export function getFieldDefTitle(model, channel) {
const channel2 = channel === 'x' ? 'x2' : 'y2';
const fieldDef = model.fieldDef(channel);
const fieldDef2 = model.fieldDef(channel2);
const title1 = fieldDef ? fieldDef.title : undefined;
const title2 = fieldDef2 ? fieldDef2.title : undefined;
if (title1 && title2) {
return mergeTitle(title1, title2);
}
else if (title1) {
return title1;
}
else if (title2) {
return title2;
}
else if (title1 !== undefined) {
// falsy value to disable config
return title1;
}
else if (title2 !== undefined) {
// falsy value to disable config
return title2;
}
return undefined;
}
export function values(axis, fieldOrDatumDef) {
const vals = axis.values;
if (isArray(vals)) {
return valueArray(fieldOrDatumDef, vals);
}
else if (isSignalRef(vals)) {
return vals;
}
return undefined;
}
export function defaultZindex(mark, fieldDef) {
if (mark === 'rect' && isDiscrete(fieldDef)) {
return 1;
}
return 0;
}
//# sourceMappingURL=properties.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import { Config } from '../config';
import { LayoutSizeMixins, NormalizedSpec } from '../spec';
import { Model } from './model';
export declare function buildModel(spec: NormalizedSpec, parent: Model, parentGivenName: string, unitSize: LayoutSizeMixins, config: Config): Model;
//# sourceMappingURL=buildmodel.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"buildmodel.d.ts","sourceRoot":"","sources":["../../../src/compile/buildmodel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAwD,gBAAgB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAIhH,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAG9B,wBAAgB,UAAU,CACxB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,KAAK,EACb,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,GACb,KAAK,CAWP"}

22
node_modules/vega-lite/build/src/compile/buildmodel.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import * as log from '../log';
import { isAnyConcatSpec, isFacetSpec, isLayerSpec, isUnitSpec } from '../spec';
import { ConcatModel } from './concat';
import { FacetModel } from './facet';
import { LayerModel } from './layer';
import { UnitModel } from './unit';
export function buildModel(spec, parent, parentGivenName, unitSize, config) {
if (isFacetSpec(spec)) {
return new FacetModel(spec, parent, parentGivenName, config);
}
else if (isLayerSpec(spec)) {
return new LayerModel(spec, parent, parentGivenName, unitSize, config);
}
else if (isUnitSpec(spec)) {
return new UnitModel(spec, parent, parentGivenName, unitSize, config);
}
else if (isAnyConcatSpec(spec)) {
return new ConcatModel(spec, parent, parentGivenName, config);
}
throw new Error(log.message.invalidSpec(spec));
}
//# sourceMappingURL=buildmodel.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"buildmodel.js","sourceRoot":"","sources":["../../../src/compile/buildmodel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAC,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAmC,MAAM,SAAS,CAAC;AAChH,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AAEjC,MAAM,UAAU,UAAU,CACxB,IAAoB,EACpB,MAAa,EACb,eAAuB,EACvB,QAA0B,EAC1B,MAAc;IAEd,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;QACrB,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;KAC9D;SAAM,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;QAC5B,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;KACxE;SAAM,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;QAC3B,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;KACvE;SAAM,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;QAChC,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;KAC/D;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACjD,CAAC"}

48
node_modules/vega-lite/build/src/compile/common.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import { SignalRef, Text } from 'vega';
import { AxisConfig } from '../axis';
import { FieldDefBase, FieldRefOption, OrderFieldDef } from '../channeldef';
import { Config, StyleConfigIndex } from '../config';
import { MarkConfig, MarkDef } from '../mark';
import { SortFields } from '../sort';
import { VgEncodeChannel, VgEncodeEntry, VgValueRef } from '../vega.schema';
import { AxisComponentProps } from './axis/component';
import { Explicit } from './split';
import { UnitModel } from './unit';
export declare const BIN_RANGE_DELIMITER = " \u2013 ";
export declare function signalOrValueRef<T>(value: T | SignalRef): {
value: T;
} | SignalRef;
export declare function exprFromValueOrSignalRef(ref: VgValueRef | SignalRef): string;
export declare function signalOrStringValue(v: SignalRef | any): string;
export declare function applyMarkConfig(e: VgEncodeEntry, model: UnitModel, propsList: (keyof MarkConfig)[]): Partial<Record<VgEncodeChannel, VgValueRef | (VgValueRef & {
test?: string;
})[]>>;
export declare function getStyles(mark: MarkDef): string[];
export declare function getMarkPropOrConfig<P extends keyof MarkDef>(channel: P, mark: MarkDef, config: Config, opt?: {
vgChannel?: VgEncodeChannel;
ignoreVgConfig?: boolean;
}): MarkDef[P];
/**
* Return property value from style or mark specific config property if exists.
* Otherwise, return general mark specific config.
*/
export declare function getMarkConfig<P extends keyof MarkDef>(channel: P, mark: MarkDef, config: Config, { vgChannel }?: {
vgChannel?: VgEncodeChannel;
}): MarkDef[P];
export declare function getMarkStyleConfig<P extends keyof MarkDef>(prop: P, mark: MarkDef, styleConfigIndex: StyleConfigIndex): any;
export declare function getStyleConfig<P extends keyof MarkDef | keyof AxisConfig>(p: P, styles: string | string[], styleConfigIndex: StyleConfigIndex): any;
/**
* Return Vega sort parameters (tuple of field and order).
*/
export declare function sortParams(orderDef: OrderFieldDef<string> | OrderFieldDef<string>[], fieldRefOption?: FieldRefOption): SortFields;
export declare type AxisTitleComponent = AxisComponentProps['title'];
export declare function mergeTitleFieldDefs(f1: readonly FieldDefBase<string>[], f2: readonly FieldDefBase<string>[]): FieldDefBase<string, boolean | import("../bin").BinParams | "binned">[];
export declare function mergeTitle(title1: Text | SignalRef, title2: Text | SignalRef): string | string[] | SignalRef;
export declare function mergeTitleComponent(v1: Explicit<AxisTitleComponent>, v2: Explicit<AxisTitleComponent>): {
explicit: boolean;
value: string | string[] | SignalRef;
} | {
explicit: boolean;
value: FieldDefBase<string, boolean | import("../bin").BinParams | "binned">[];
};
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/compile/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,MAAM,CAAC;AAErC,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAU,MAAM,eAAe,CAAC;AACnF,OAAO,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAGnC,OAAO,EAAc,eAAe,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM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AE,CAAC,EACJ,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,gBAAgB,EAAE,gBAAgB,OAYnC;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,EACzD,cAAc,CAAC,EAAE,cAAc,GAC9B,UAAU,CASZ;AAED,oBAAY,kBAAkB,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAE7D,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,YAAY,CAAC,MAAM,CAAC,EAAE,2EAa3G;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,GAAG,SAAS,iCAU5E;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC;;;;;;EAgCrG"}

153
node_modules/vega-lite/build/src/compile/common.js generated vendored Normal file
View File

@@ -0,0 +1,153 @@
import { array, stringValue } from 'vega-util';
import { vgField } from '../channeldef';
import { isText } from '../title';
import { deepEqual, getFirstDefined } from '../util';
import { isSignalRef } from '../vega.schema';
export const BIN_RANGE_DELIMITER = ' \u2013 ';
export function signalOrValueRef(value) {
if (isSignalRef(value)) {
return value;
}
return value !== undefined ? { value } : undefined;
}
export function exprFromValueOrSignalRef(ref) {
if (isSignalRef(ref)) {
return ref.signal;
}
return stringValue(ref.value);
}
export function signalOrStringValue(v) {
if (isSignalRef(v)) {
return v.signal;
}
return v == null ? null : stringValue(v);
}
export function applyMarkConfig(e, model, propsList) {
for (const property of propsList) {
const value = getMarkConfig(property, model.markDef, model.config);
if (value !== undefined) {
e[property] = signalOrValueRef(value);
}
}
return e;
}
export function getStyles(mark) {
var _a;
return [].concat(mark.type, (_a = mark.style) !== null && _a !== void 0 ? _a : []);
}
export function getMarkPropOrConfig(channel, mark, config, opt = {}) {
const { vgChannel, ignoreVgConfig } = opt;
if (vgChannel && mark[vgChannel] !== undefined) {
return mark[vgChannel];
}
else if (mark[channel] !== undefined) {
return mark[channel];
}
else if (ignoreVgConfig && (!vgChannel || vgChannel === channel)) {
return undefined;
}
return getMarkConfig(channel, mark, config, opt);
}
/**
* Return property value from style or mark specific config property if exists.
* Otherwise, return general mark specific config.
*/
export function getMarkConfig(channel, mark, config, { vgChannel } = {}) {
return getFirstDefined(
// style config has highest precedence
vgChannel ? getMarkStyleConfig(channel, mark, config.style) : undefined, getMarkStyleConfig(channel, mark, config.style),
// then mark-specific config
vgChannel ? config[mark.type][vgChannel] : undefined, config[mark.type][channel], // Need to cast because MarkDef doesn't perfectly match with AnyMarkConfig, but if the type isn't available, we'll get nothing here, which is fine
// If there is vgChannel, skip vl channel.
// For example, vl size for text is vg fontSize, but config.mark.size is only for point size.
vgChannel ? config.mark[vgChannel] : config.mark[channel] // Need to cast for the same reason as above
);
}
export function getMarkStyleConfig(prop, mark, styleConfigIndex) {
return getStyleConfig(prop, getStyles(mark), styleConfigIndex);
}
export function getStyleConfig(p, styles, styleConfigIndex) {
styles = array(styles);
let value;
for (const style of styles) {
const styleConfig = styleConfigIndex[style];
if (styleConfig && styleConfig[p] !== undefined) {
value = styleConfig[p];
}
}
return value;
}
/**
* Return Vega sort parameters (tuple of field and order).
*/
export function sortParams(orderDef, fieldRefOption) {
return array(orderDef).reduce((s, orderChannelDef) => {
var _a;
s.field.push(vgField(orderChannelDef, fieldRefOption));
s.order.push((_a = orderChannelDef.sort) !== null && _a !== void 0 ? _a : 'ascending');
return s;
}, { field: [], order: [] });
}
export function mergeTitleFieldDefs(f1, f2) {
const merged = [...f1];
f2.forEach(fdToMerge => {
for (const fieldDef1 of merged) {
// If already exists, no need to append to merged array
if (deepEqual(fieldDef1, fdToMerge)) {
return;
}
}
merged.push(fdToMerge);
});
return merged;
}
export function mergeTitle(title1, title2) {
if (deepEqual(title1, title2) || !title2) {
// if titles are the same or title2 is falsy
return title1;
}
else if (!title1) {
// if title1 is falsy
return title2;
}
else {
return [...array(title1), ...array(title2)].join(', ');
}
}
export function mergeTitleComponent(v1, v2) {
const v1Val = v1.value;
const v2Val = v2.value;
if (v1Val == null || v2Val === null) {
return {
explicit: v1.explicit,
value: null
};
}
else if ((isText(v1Val) || isSignalRef(v1Val)) && (isText(v2Val) || isSignalRef(v2Val))) {
return {
explicit: v1.explicit,
value: mergeTitle(v1Val, v2Val)
};
}
else if (isText(v1Val) || isSignalRef(v1Val)) {
return {
explicit: v1.explicit,
value: v1Val
};
}
else if (isText(v2Val) || isSignalRef(v2Val)) {
return {
explicit: v1.explicit,
value: v2Val
};
}
else if (!isText(v1Val) && !isSignalRef(v1Val) && !isText(v2Val) && !isSignalRef(v2Val)) {
return {
explicit: v1.explicit,
value: mergeTitleFieldDefs(v1Val, v2Val)
};
}
/* istanbul ignore next: Condition should not happen -- only for warning in development. */
throw new Error('It should never reach here');
}
//# sourceMappingURL=common.js.map

File diff suppressed because one or more lines are too long

97
node_modules/vega-lite/build/src/compile/compile.d.ts generated vendored Normal file
View File

@@ -0,0 +1,97 @@
import { LoggerInterface, Spec as VgSpec } from 'vega';
import * as vlFieldDef from '../channeldef';
import { Config } from '../config';
import { LayoutSizeMixins, TopLevelSpec } from '../spec';
import { TopLevelProperties } from '../spec/toplevel';
export interface CompileOptions {
/**
* Sets a Vega-Lite configuration.
*/
config?: Config;
/**
* Sets a custom logger.
*/
logger?: LoggerInterface;
/**
* Sets a field title formatter.
*/
fieldTitle?: vlFieldDef.FieldTitleFormatter;
}
/**
* Vega-Lite's main function, for compiling Vega-Lite spec into Vega spec.
*
* At a high-level, we make the following transformations in different phases:
*
* Input spec
* |
* | (Normalization)
* v
* Normalized Spec (Row/Column channels in single-view specs becomes faceted specs, composite marks becomes layered specs.)
* |
* | (Build Model)
* v
* A model tree of the spec
* |
* | (Parse)
* v
* A model tree with parsed components (intermediate structure of visualization primitives in a format that can be easily merged)
* |
* | (Optimize)
* v
* A model tree with parsed components with the data component optimized
* |
* | (Assemble)
* v
* Vega spec
*
* @param inputSpec The Vega-Lite specification.
* @param opt Optional arguments passed to the Vega-Lite compiler.
* @returns An object containing the compiled Vega spec and normalized Vega-Lite spec.
*/
export declare function compile(inputSpec: TopLevelSpec, opt?: CompileOptions): {
spec: VgSpec;
normalized: (import("../spec").NormalizedUnitSpec & TopLevelProperties & {
$schema?: string; /**
* Sets a Vega-Lite configuration.
*/
config?: Config;
datasets?: Record<string, import("../data").InlineDataset>;
usermeta?: Record<string, unknown>;
} & LayoutSizeMixins) | (import("../spec").NormalizedLayerSpec & TopLevelProperties & {
$schema?: string; /**
* Sets a Vega-Lite configuration.
*/
config?: Config;
datasets?: Record<string, import("../data").InlineDataset>;
usermeta?: Record<string, unknown>;
} & LayoutSizeMixins) | (import("../spec").GenericFacetSpec<import("../spec").NormalizedUnitSpec, import("../spec").NormalizedLayerSpec, string> & TopLevelProperties & {
$schema?: string; /**
* Sets a Vega-Lite configuration.
*/
config?: Config;
datasets?: Record<string, import("../data").InlineDataset>;
usermeta?: Record<string, unknown>;
} & LayoutSizeMixins) | (import("../spec/concat").GenericConcatSpec<import("../spec").GenericSpec<import("../spec").NormalizedUnitSpec, import("../spec").NormalizedLayerSpec, never, string>> & TopLevelProperties & {
$schema?: string; /**
* Sets a Vega-Lite configuration.
*/
config?: Config;
datasets?: Record<string, import("../data").InlineDataset>;
usermeta?: Record<string, unknown>;
} & LayoutSizeMixins) | (import("../spec").GenericVConcatSpec<import("../spec").GenericSpec<import("../spec").NormalizedUnitSpec, import("../spec").NormalizedLayerSpec, never, string>> & TopLevelProperties & {
$schema?: string; /**
* Sets a Vega-Lite configuration.
*/
config?: Config;
datasets?: Record<string, import("../data").InlineDataset>;
usermeta?: Record<string, unknown>;
} & LayoutSizeMixins) | (import("../spec").GenericHConcatSpec<import("../spec").GenericSpec<import("../spec").NormalizedUnitSpec, import("../spec").NormalizedLayerSpec, never, string>> & TopLevelProperties & {
$schema?: string; /**
* Sets a Vega-Lite configuration.
*/
config?: Config;
datasets?: Record<string, import("../data").InlineDataset>;
usermeta?: Record<string, unknown>;
} & LayoutSizeMixins);
};
//# sourceMappingURL=compile.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,eAAe,EAAE,IAAI,IAAI,MAAM,EAAC,MAAM,MAAM,CAAC;AAGnE,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAqC,MAAM,WAAW,CAAC;AAGrE,OAAO,EAAC,gBAAgB,EAAY,YAAY,EAAC,MAAM,SAAS,CAAC;AACjE,OAAO,EAML,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAO1B,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,mBAAmB,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,GAAE,cAAmB;;;0BA/CvE;;WAEG;;;;;0BAFH;;WAEG;;;;;0BAFH;;WAEG;;;;;0BAFH;;WAEG;;;;;0BAFH;;WAEG;;;;;0BAFH;;WAEG;;;;;EAoHJ"}

158
node_modules/vega-lite/build/src/compile/compile.js generated vendored Normal file
View File

@@ -0,0 +1,158 @@
import { isString, mergeConfig } from 'vega-util';
import { getPositionScaleChannel } from '../channel';
import * as vlFieldDef from '../channeldef';
import { initConfig, stripAndRedirectConfig } from '../config';
import * as log from '../log';
import { normalize } from '../normalize';
import { extractTopLevelProperties, getFitType, isFitType } from '../spec/toplevel';
import { keys } from '../util';
import { buildModel } from './buildmodel';
import { assembleRootData } from './data/assemble';
import { optimizeDataflow } from './data/optimize';
/**
* Vega-Lite's main function, for compiling Vega-Lite spec into Vega spec.
*
* At a high-level, we make the following transformations in different phases:
*
* Input spec
* |
* | (Normalization)
* v
* Normalized Spec (Row/Column channels in single-view specs becomes faceted specs, composite marks becomes layered specs.)
* |
* | (Build Model)
* v
* A model tree of the spec
* |
* | (Parse)
* v
* A model tree with parsed components (intermediate structure of visualization primitives in a format that can be easily merged)
* |
* | (Optimize)
* v
* A model tree with parsed components with the data component optimized
* |
* | (Assemble)
* v
* Vega spec
*
* @param inputSpec The Vega-Lite specification.
* @param opt Optional arguments passed to the Vega-Lite compiler.
* @returns An object containing the compiled Vega spec and normalized Vega-Lite spec.
*/
export function compile(inputSpec, opt = {}) {
// 0. Augment opt with default opts
if (opt.logger) {
// set the singleton logger to the provided logger
log.set(opt.logger);
}
if (opt.fieldTitle) {
// set the singleton field title formatter
vlFieldDef.setTitleFormatter(opt.fieldTitle);
}
try {
// 1. Initialize config by deep merging default config with the config provided via option and the input spec.
const config = initConfig(mergeConfig(opt.config, inputSpec.config));
// 2. Normalize: Convert input spec -> normalized spec
// - Decompose all extended unit specs into composition of unit spec. For example, a box plot get expanded into multiple layers of bars, ticks, and rules. The shorthand row/column channel is also expanded to a facet spec.
// - Normalize autosize and width or height spec
const spec = normalize(inputSpec, config);
// 3. Build Model: normalized spec -> Model (a tree structure)
// This phases instantiates the models with default config by doing a top-down traversal. This allows us to pass properties that child models derive from their parents via their constructors.
// See the abstract `Model` class and its children (UnitModel, LayerModel, FacetModel, ConcatModel) for different types of models.
const model = buildModel(spec, null, '', undefined, config);
// 4 Parse: Model --> Model with components
// Note that components = intermediate representations that are equivalent to Vega specs.
// We need these intermediate representation because we need to merge many visualization "components" like projections, scales, axes, and legends.
// We will later convert these components into actual Vega specs in the assemble phase.
// In this phase, we do a bottom-up traversal over the whole tree to
// parse for each type of components once (e.g., data, layout, mark, scale).
// By doing bottom-up traversal, we start parsing components of unit specs and
// then merge child components of parent composite specs.
//
// Please see inside model.parse() for order of different components parsed.
model.parse();
// drawDataflow(model.component.data.sources);
// 5. Optimize the dataflow. This will modify the data component of the model.
optimizeDataflow(model.component.data, model);
// drawDataflow(model.component.data.sources);
// 6. Assemble: convert model components --> Vega Spec.
const vgSpec = assembleTopLevelModel(model, getTopLevelProperties(inputSpec, spec.autosize, config, model), inputSpec.datasets, inputSpec.usermeta);
return {
spec: vgSpec,
normalized: spec
};
}
finally {
// Reset the singleton logger if a logger is provided
if (opt.logger) {
log.reset();
}
// Reset the singleton field title formatter if provided
if (opt.fieldTitle) {
vlFieldDef.resetTitleFormatter();
}
}
}
function getTopLevelProperties(inputSpec, autosize, config, model) {
const width = model.component.layoutSize.get('width');
const height = model.component.layoutSize.get('height');
if (autosize === undefined) {
autosize = { type: 'pad' };
if (model.hasAxisOrientSignalRef()) {
autosize.resize = true;
}
}
else if (isString(autosize)) {
autosize = { type: autosize };
}
if (width && height && isFitType(autosize.type)) {
if (width === 'step' && height === 'step') {
log.warn(log.message.droppingFit());
autosize.type = 'pad';
}
else if (width === 'step' || height === 'step') {
// effectively XOR, because else if
// get step dimension
const sizeType = width === 'step' ? 'width' : 'height';
// log that we're dropping fit for respective channel
log.warn(log.message.droppingFit(getPositionScaleChannel(sizeType)));
// setting type to inverse fit (so if we dropped fit-x, type is now fit-y)
const inverseSizeType = sizeType === 'width' ? 'height' : 'width';
autosize.type = getFitType(inverseSizeType);
}
}
return Object.assign(Object.assign(Object.assign({}, (keys(autosize).length === 1 && autosize.type
? autosize.type === 'pad'
? {}
: { autosize: autosize.type }
: { autosize })), extractTopLevelProperties(config)), extractTopLevelProperties(inputSpec));
}
/*
* Assemble the top-level model to a Vega spec.
*
* Note: this couldn't be `model.assemble()` since the top-level model
* needs some special treatment to generate top-level properties.
*/
function assembleTopLevelModel(model, topLevelProperties, datasets = {}, usermeta) {
// Config with Vega-Lite only config removed.
const vgConfig = model.config ? stripAndRedirectConfig(model.config) : undefined;
const data = [].concat(model.assembleSelectionData([]),
// only assemble data in the root
assembleRootData(model.component.data, datasets));
const projections = model.assembleProjections();
const title = model.assembleTitle();
const style = model.assembleGroupStyle();
const encodeEntry = model.assembleGroupEncodeEntry(true);
let layoutSignals = model.assembleLayoutSignals();
// move width and height signals with values to top level
layoutSignals = layoutSignals.filter(signal => {
if ((signal.name === 'width' || signal.name === 'height') && signal.value !== undefined) {
topLevelProperties[signal.name] = +signal.value;
return false;
}
return true;
});
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ $schema: 'https://vega.github.io/schema/vega/v5.json' }, (model.description ? { description: model.description } : {})), topLevelProperties), (title ? { title } : {})), (style ? { style } : {})), (encodeEntry ? { encode: { update: encodeEntry } } : {})), { data }), (projections.length > 0 ? { projections: projections } : {})), model.assembleGroup([...layoutSignals, ...model.assembleSelectionTopLevelSignals([])])), (vgConfig ? { config: vgConfig } : {})), (usermeta ? { usermeta } : {}));
}
//# sourceMappingURL=compile.js.map

File diff suppressed because one or more lines are too long

24
node_modules/vega-lite/build/src/compile/concat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { NewSignal } from 'vega';
import { Config } from '../config';
import { NormalizedConcatSpec } from '../spec';
import { VgLayout } from '../vega.schema';
import { VgData } from '../vega.schema';
import { Model } from './model';
export declare class ConcatModel extends Model {
readonly children: Model[];
constructor(spec: NormalizedConcatSpec, parent: Model, parentGivenName: string, config: Config);
parseData(): void;
parseSelections(): void;
parseMarkGroup(): void;
parseAxesAndHeaders(): void;
private getChildren;
parseLayoutSize(): void;
parseAxisGroup(): void;
assembleSelectionTopLevelSignals(signals: NewSignal[]): NewSignal[];
assembleSignals(): NewSignal[];
assembleLayoutSignals(): NewSignal[];
assembleSelectionData(data: readonly VgData[]): readonly VgData[];
assembleMarks(): any[];
protected assembleDefaultLayout(): VgLayout;
}
//# sourceMappingURL=concat.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../../src/compile/concat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC,OAAO,EAA+B,oBAAoB,EAAiB,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAKtC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,QAAQ,EAAE,KAAK,EAAE,CAAC;gBAEtB,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAYvF,SAAS;IAOT,eAAe;IAaf,cAAc;IAMd,mBAAmB;IAQ1B,OAAO,CAAC,WAAW;IASZ,eAAe;IAIf,cAAc,IAAI,IAAI;IAItB,gCAAgC,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE;IAInE,eAAe,IAAI,SAAS,EAAE;IAK9B,qBAAqB,IAAI,SAAS,EAAE;IAUpC,qBAAqB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE;IAIjE,aAAa,IAAI,GAAG,EAAE;IAkB7B,SAAS,CAAC,qBAAqB,IAAI,QAAQ;CAS5C"}

97
node_modules/vega-lite/build/src/compile/concat.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
import * as log from '../log';
import { isHConcatSpec, isVConcatSpec } from '../spec';
import { keys } from '../util';
import { buildModel } from './buildmodel';
import { parseData } from './data/parse';
import { assembleLayoutSignals } from './layoutsize/assemble';
import { parseConcatLayoutSize } from './layoutsize/parse';
import { Model } from './model';
export class ConcatModel extends Model {
constructor(spec, parent, parentGivenName, config) {
var _a, _b, _c, _d;
super(spec, 'concat', parent, parentGivenName, config, spec.resolve);
if (((_b = (_a = spec.resolve) === null || _a === void 0 ? void 0 : _a.axis) === null || _b === void 0 ? void 0 : _b.x) === 'shared' || ((_d = (_c = spec.resolve) === null || _c === void 0 ? void 0 : _c.axis) === null || _d === void 0 ? void 0 : _d.y) === 'shared') {
log.warn(log.message.CONCAT_CANNOT_SHARE_AXIS);
}
this.children = this.getChildren(spec).map((child, i) => {
return buildModel(child, this, this.getName('concat_' + i), undefined, config);
});
}
parseData() {
this.component.data = parseData(this);
for (const child of this.children) {
child.parseData();
}
}
parseSelections() {
// Merge selections up the hierarchy so that they may be referenced
// across unit specs. Persist their definitions within each child
// to assemble signals which remain within output Vega unit groups.
this.component.selection = {};
for (const child of this.children) {
child.parseSelections();
for (const key of keys(child.component.selection)) {
this.component.selection[key] = child.component.selection[key];
}
}
}
parseMarkGroup() {
for (const child of this.children) {
child.parseMarkGroup();
}
}
parseAxesAndHeaders() {
for (const child of this.children) {
child.parseAxesAndHeaders();
}
// TODO(#2415): support shared axes
}
getChildren(spec) {
if (isVConcatSpec(spec)) {
return spec.vconcat;
}
else if (isHConcatSpec(spec)) {
return spec.hconcat;
}
return spec.concat;
}
parseLayoutSize() {
parseConcatLayoutSize(this);
}
parseAxisGroup() {
return null;
}
assembleSelectionTopLevelSignals(signals) {
return this.children.reduce((sg, child) => child.assembleSelectionTopLevelSignals(sg), signals);
}
assembleSignals() {
this.children.forEach(child => child.assembleSignals());
return [];
}
assembleLayoutSignals() {
const layoutSignals = assembleLayoutSignals(this);
for (const child of this.children) {
layoutSignals.push(...child.assembleLayoutSignals());
}
return layoutSignals;
}
assembleSelectionData(data) {
return this.children.reduce((db, child) => child.assembleSelectionData(db), data);
}
assembleMarks() {
// only children have marks
return this.children.map(child => {
const title = child.assembleTitle();
const style = child.assembleGroupStyle();
const encodeEntry = child.assembleGroupEncodeEntry(false);
return Object.assign(Object.assign(Object.assign(Object.assign({ type: 'group', name: child.getName('group') }, (title ? { title } : {})), (style ? { style } : {})), (encodeEntry ? { encode: { update: encodeEntry } } : {})), child.assembleGroup());
});
}
assembleDefaultLayout() {
const columns = this.layout.columns;
return Object.assign(Object.assign({}, (columns != null ? { columns: columns } : {})), { bounds: 'full',
// Use align each so it can work with multiple plots with different size
align: 'each' });
}
}
//# sourceMappingURL=concat.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/compile/concat.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAC,aAAa,EAAE,aAAa,EAAuC,MAAM,SAAS,CAAC;AAE3F,OAAO,EAAC,IAAI,EAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGpC,YAAY,IAA0B,EAAE,MAAa,EAAE,eAAuB,EAAE,MAAc;;QAC5F,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAErE,IAAI,aAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,0CAAE,CAAC,MAAK,QAAQ,IAAI,aAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,0CAAE,CAAC,MAAK,QAAQ,EAAE;YAC5E,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CA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AAM,WAAW,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;YAE1D,iEACE,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IACzB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GACtB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GACtB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,MAAM,EAAE,EAAC,MAAM,EAAE,WAAW,EAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GACpD,KAAK,CAAC,aAAa,EAAE,EACxB;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAES,qBAAqB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QACpC,uCACK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAC9C,MAAM,EAAE,MAAM;YACd,wEAAwE;YACxE,KAAK,EAAE,MAAM,IACb;IACJ,CAAC;CACF"}

View File

@@ -0,0 +1,27 @@
import { AggregateOp, AggregateTransform as VgAggregateTransform } from 'vega';
import { AggregateTransform } from '../../transform';
import { Dict } from '../../util';
import { UnitModel } from '../unit';
import { DataFlowNode } from './dataflow';
declare type Measures = Dict<Partial<Record<AggregateOp, Set<string>>>>;
export declare class AggregateNode extends DataFlowNode {
private dimensions;
private measures;
clone(): AggregateNode;
/**
* @param dimensions string set for dimensions
* @param measures dictionary mapping field name => dict of aggregation functions and names to use
*/
constructor(parent: DataFlowNode, dimensions: Set<string>, measures: Measures);
get groupBy(): Set<string>;
static makeFromEncoding(parent: DataFlowNode, model: UnitModel): AggregateNode;
static makeFromTransform(parent: DataFlowNode, t: AggregateTransform): AggregateNode;
merge(other: AggregateNode): boolean;
addDimensions(fields: readonly string[]): void;
dependentFields(): Set<string>;
producedFields(): Set<string>;
hash(): string;
assemble(): VgAggregateTransform;
}
export {};
//# sourceMappingURL=aggregate.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,kBAAkB,IAAI,oBAAoB,EAAC,MAAM,MAAM,CAAC;AAW7E,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAC,IAAI,EAAsD,MAAM,YAAY,CAAC;AAErF,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAExC,aAAK,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAwChE,qBAAa,aAAc,SAAQ,YAAY;IASX,OAAO,CAAC,UAAU;IAAe,OAAO,CAAC,QAAQ;IAR5E,KAAK;IAIZ;;;OAGG;gBACS,MAAM,EAAE,YAAY,EAAU,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EAAU,QAAQ,EAAE,QAAQ;IAI7F,IAAI,OAAO,gBAEV;WAEa,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,GAAG,aAAa;WAoDvE,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE,kBAAkB,GAAG,aAAa;IA4BpF,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAUpC,aAAa,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE;IAIvC,eAAe;IAIf,cAAc;IAiBd,IAAI;IAIJ,QAAQ,IAAI,oBAAoB;CAyBxC"}

View File

@@ -0,0 +1,191 @@
import { isArgmaxDef, isArgminDef } from '../../aggregate';
import { getPositionChannelFromLatLong, getSecondaryRangeChannel, isGeoPositionChannel, isScaleChannel } from '../../channel';
import { binRequiresRange, hasBand, isTypedFieldDef, vgField } from '../../channeldef';
import * as log from '../../log';
import { duplicate, hash, keys, replacePathInField, setEqual } from '../../util';
import { isUnitModel } from '../model';
import { DataFlowNode } from './dataflow';
function addDimension(dims, channel, fieldDef, model) {
const channelDef2 = isUnitModel(model) ? model.encoding[getSecondaryRangeChannel(channel)] : undefined;
if (isTypedFieldDef(fieldDef) &&
isUnitModel(model) &&
hasBand(channel, fieldDef, channelDef2, model.stack, model.markDef, model.config)) {
dims.add(vgField(fieldDef, {}));
dims.add(vgField(fieldDef, { suffix: 'end' }));
if (fieldDef.bin && binRequiresRange(fieldDef, channel)) {
dims.add(vgField(fieldDef, { binSuffix: 'range' }));
}
}
else if (isGeoPositionChannel(channel)) {
const posChannel = getPositionChannelFromLatLong(channel);
dims.add(model.getName(posChannel));
}
else {
dims.add(vgField(fieldDef));
}
return dims;
}
function mergeMeasures(parentMeasures, childMeasures) {
var _a;
for (const field of keys(childMeasures)) {
// when we merge a measure, we either have to add an aggregation operator or even a new field
const ops = childMeasures[field];
for (const op of keys(ops)) {
if (field in parentMeasures) {
// add operator to existing measure field
parentMeasures[field][op] = new Set([...((_a = parentMeasures[field][op]) !== null && _a !== void 0 ? _a : []), ...ops[op]]);
}
else {
parentMeasures[field] = { [op]: ops[op] };
}
}
}
}
export class AggregateNode extends DataFlowNode {
/**
* @param dimensions string set for dimensions
* @param measures dictionary mapping field name => dict of aggregation functions and names to use
*/
constructor(parent, dimensions, measures) {
super(parent);
this.dimensions = dimensions;
this.measures = measures;
}
clone() {
return new AggregateNode(null, new Set(this.dimensions), duplicate(this.measures));
}
get groupBy() {
return this.dimensions;
}
static makeFromEncoding(parent, model) {
let isAggregate = false;
model.forEachFieldDef(fd => {
if (fd.aggregate) {
isAggregate = true;
}
});
const meas = {};
const dims = new Set();
if (!isAggregate) {
// no need to create this node if the model has no aggregation
return null;
}
model.forEachFieldDef((fieldDef, channel) => {
var _a, _b, _c, _d;
const { aggregate, field } = fieldDef;
if (aggregate) {
if (aggregate === 'count') {
meas['*'] = (_a = meas['*']) !== null && _a !== void 0 ? _a : {};
meas['*']['count'] = new Set([vgField(fieldDef, { forAs: true })]);
}
else {
if (isArgminDef(aggregate) || isArgmaxDef(aggregate)) {
const op = isArgminDef(aggregate) ? 'argmin' : 'argmax';
const argField = aggregate[op];
meas[argField] = (_b = meas[argField]) !== null && _b !== void 0 ? _b : {};
meas[argField][op] = new Set([vgField({ op, field: argField }, { forAs: true })]);
}
else {
meas[field] = (_c = meas[field]) !== null && _c !== void 0 ? _c : {};
meas[field][aggregate] = new Set([vgField(fieldDef, { forAs: true })]);
}
// For scale channel with domain === 'unaggregated', add min/max so we can use their union as unaggregated domain
if (isScaleChannel(channel) && model.scaleDomain(channel) === 'unaggregated') {
meas[field] = (_d = meas[field]) !== null && _d !== void 0 ? _d : {};
meas[field]['min'] = new Set([vgField({ field, aggregate: 'min' }, { forAs: true })]);
meas[field]['max'] = new Set([vgField({ field, aggregate: 'max' }, { forAs: true })]);
}
}
}
else {
addDimension(dims, channel, fieldDef, model);
}
});
if (dims.size + keys(meas).length === 0) {
return null;
}
return new AggregateNode(parent, dims, meas);
}
static makeFromTransform(parent, t) {
var _a, _b, _c;
const dims = new Set();
const meas = {};
for (const s of t.aggregate) {
const { op, field, as } = s;
if (op) {
if (op === 'count') {
meas['*'] = (_a = meas['*']) !== null && _a !== void 0 ? _a : {};
meas['*']['count'] = new Set([as ? as : vgField(s, { forAs: true })]);
}
else {
meas[field] = (_b = meas[field]) !== null && _b !== void 0 ? _b : {};
meas[field][op] = new Set([as ? as : vgField(s, { forAs: true })]);
}
}
}
for (const s of (_c = t.groupby) !== null && _c !== void 0 ? _c : []) {
dims.add(s);
}
if (dims.size + keys(meas).length === 0) {
return null;
}
return new AggregateNode(parent, dims, meas);
}
merge(other) {
if (setEqual(this.dimensions, other.dimensions)) {
mergeMeasures(this.measures, other.measures);
return true;
}
else {
log.debug('different dimensions, cannot merge');
return false;
}
}
addDimensions(fields) {
fields.forEach(this.dimensions.add, this.dimensions);
}
dependentFields() {
return new Set([...this.dimensions, ...keys(this.measures)]);
}
producedFields() {
const out = new Set();
for (const field of keys(this.measures)) {
for (const op of keys(this.measures[field])) {
const m = this.measures[field][op];
if (m.size === 0) {
out.add(`${op}_${field}`);
}
else {
m.forEach(out.add, out);
}
}
}
return out;
}
hash() {
return `Aggregate ${hash({ dimensions: this.dimensions, measures: this.measures })}`;
}
assemble() {
const ops = [];
const fields = [];
const as = [];
for (const field of keys(this.measures)) {
for (const op of keys(this.measures[field])) {
for (const alias of this.measures[field][op]) {
as.push(alias);
ops.push(op);
fields.push(field === '*' ? null : replacePathInField(field));
}
}
}
const result = {
type: 'aggregate',
groupby: [...this.dimensions].map(replacePathInField),
ops,
fields,
as
};
return result;
}
}
//# sourceMappingURL=aggregate.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
import { InlineDataset } from '../../data';
import { Dict } from '../../util';
import { VgData } from '../../vega.schema';
import { DataComponent } from './';
import { FacetNode } from './facet';
/**
* Assemble data sources that are derived from faceted data.
*/
export declare function assembleFacetData(root: FacetNode): VgData[];
/**
* Create Vega data array from a given compiled model and append all of them to the given array
*
* @param model
* @param data array
* @return modified data array
*/
export declare function assembleRootData(dataComponent: DataComponent, datasets: Dict<InlineDataset>): VgData[];
//# sourceMappingURL=assemble.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/assemble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAY,MAAM,YAAY,CAAC;AACpD,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,IAAI,CAAC;AAMjC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAwLlC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,CAa3D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAqDtG"}

View File

@@ -0,0 +1,238 @@
import { isUrlData } from '../../data';
import { AggregateNode } from './aggregate';
import { BinNode } from './bin';
import { CalculateNode } from './calculate';
import { OutputNode } from './dataflow';
import { DensityTransformNode } from './density';
import { FacetNode } from './facet';
import { FilterNode } from './filter';
import { FilterInvalidNode } from './filterinvalid';
import { FlattenTransformNode } from './flatten';
import { FoldTransformNode } from './fold';
import { ParseNode } from './formatparse';
import { GeoJSONNode } from './geojson';
import { GeoPointNode } from './geopoint';
import { GraticuleNode } from './graticule';
import { IdentifierNode } from './identifier';
import { ImputeNode } from './impute';
import { JoinAggregateTransformNode } from './joinaggregate';
import { LoessTransformNode } from './loess';
import { LookupNode } from './lookup';
import { QuantileTransformNode } from './quantile';
import { RegressionTransformNode } from './regression';
import { PivotTransformNode } from './pivot';
import { SampleTransformNode } from './sample';
import { SequenceNode } from './sequence';
import { SourceNode } from './source';
import { StackNode } from './stack';
import { TimeUnitNode } from './timeunit';
import { WindowTransformNode } from './window';
function makeWalkTree(data) {
// to name datasources
let datasetIndex = 0;
/**
* Recursively walk down the tree.
*/
function walkTree(node, dataSource) {
var _a;
if (node instanceof SourceNode) {
// If the source is a named data source or a data source with values, we need
// to put it in a different data source. Otherwise, Vega may override the data.
if (!node.isGenerator && !isUrlData(node.data)) {
data.push(dataSource);
const newData = {
name: null,
source: dataSource.name,
transform: []
};
dataSource = newData;
}
}
if (node instanceof ParseNode) {
if (node.parent instanceof SourceNode && !dataSource.source) {
// If node's parent is a root source and the data source does not refer to another data source, use normal format parse
dataSource.format = Object.assign(Object.assign({}, ((_a = dataSource.format) !== null && _a !== void 0 ? _a : {})), { parse: node.assembleFormatParse() });
// add calculates for all nested fields
dataSource.transform.push(...node.assembleTransforms(true));
}
else {
// Otherwise use Vega expression to parse
dataSource.transform.push(...node.assembleTransforms());
}
}
if (node instanceof FacetNode) {
if (!dataSource.name) {
dataSource.name = `data_${datasetIndex++}`;
}
if (!dataSource.source || dataSource.transform.length > 0) {
data.push(dataSource);
node.data = dataSource.name;
}
else {
node.data = dataSource.source;
}
for (const d of node.assemble()) {
data.push(d);
}
// break here because the rest of the tree has to be taken care of by the facet.
return;
}
if (node instanceof GraticuleNode ||
node instanceof SequenceNode ||
node instanceof FilterInvalidNode ||
node instanceof FilterNode ||
node instanceof CalculateNode ||
node instanceof GeoPointNode ||
node instanceof GeoJSONNode ||
node instanceof AggregateNode ||
node instanceof LookupNode ||
node instanceof WindowTransformNode ||
node instanceof JoinAggregateTransformNode ||
node instanceof FoldTransformNode ||
node instanceof FlattenTransformNode ||
node instanceof DensityTransformNode ||
node instanceof LoessTransformNode ||
node instanceof QuantileTransformNode ||
node instanceof RegressionTransformNode ||
node instanceof IdentifierNode ||
node instanceof SampleTransformNode ||
node instanceof PivotTransformNode) {
dataSource.transform.push(node.assemble());
}
if (node instanceof BinNode ||
node instanceof TimeUnitNode ||
node instanceof ImputeNode ||
node instanceof StackNode) {
dataSource.transform.push(...node.assemble());
}
if (node instanceof OutputNode) {
if (dataSource.source && dataSource.transform.length === 0) {
node.setSource(dataSource.source);
}
else if (node.parent instanceof OutputNode) {
// Note that an output node may be required but we still do not assemble a
// separate data source for it.
node.setSource(dataSource.name);
}
else {
if (!dataSource.name) {
dataSource.name = `data_${datasetIndex++}`;
}
// Here we set the name of the datasource we generated. From now on
// other assemblers can use it.
node.setSource(dataSource.name);
// if this node has more than one child, we will add a datasource automatically
if (node.numChildren() === 1) {
data.push(dataSource);
const newData = {
name: null,
source: dataSource.name,
transform: []
};
dataSource = newData;
}
}
}
switch (node.numChildren()) {
case 0:
// done
if (node instanceof OutputNode && (!dataSource.source || dataSource.transform.length > 0)) {
// do not push empty datasources that are simply references
data.push(dataSource);
}
break;
case 1:
walkTree(node.children[0], dataSource);
break;
default: {
if (!dataSource.name) {
dataSource.name = `data_${datasetIndex++}`;
}
let source = dataSource.name;
if (!dataSource.source || dataSource.transform.length > 0) {
data.push(dataSource);
}
else {
source = dataSource.source;
}
for (const child of node.children) {
const newData = {
name: null,
source: source,
transform: []
};
walkTree(child, newData);
}
break;
}
}
}
return walkTree;
}
/**
* Assemble data sources that are derived from faceted data.
*/
export function assembleFacetData(root) {
const data = [];
const walkTree = makeWalkTree(data);
for (const child of root.children) {
walkTree(child, {
source: root.name,
name: null,
transform: []
});
}
return data;
}
/**
* Create Vega data array from a given compiled model and append all of them to the given array
*
* @param model
* @param data array
* @return modified data array
*/
export function assembleRootData(dataComponent, datasets) {
var _a, _b;
const data = [];
// dataComponent.sources.forEach(debug);
// draw(dataComponent.sources);
const walkTree = makeWalkTree(data);
let sourceIndex = 0;
for (const root of dataComponent.sources) {
// assign a name if the source does not have a name yet
if (!root.hasName()) {
root.dataName = `source_${sourceIndex++}`;
}
const newData = root.assemble();
walkTree(root, newData);
}
// remove empty transform arrays for cleaner output
for (const d of data) {
if (d.transform.length === 0) {
delete d.transform;
}
}
// move sources without transforms (the ones that are potentially used in lookups) to the beginning
let whereTo = 0;
for (const [i, d] of data.entries()) {
if (((_a = d.transform) !== null && _a !== void 0 ? _a : []).length === 0 && !d.source) {
data.splice(whereTo++, 0, data.splice(i, 1)[0]);
}
}
// now fix the from references in lookup transforms
for (const d of data) {
for (const t of (_b = d.transform) !== null && _b !== void 0 ? _b : []) {
if (t.type === 'lookup') {
t.from = dataComponent.outputNodes[t.from].getSource();
}
}
}
// inline values for datasets that are in the datastore
for (const d of data) {
if (d.name in datasets) {
d.values = datasets[d.name];
}
}
return data;
}
//# sourceMappingURL=assemble.js.map

File diff suppressed because one or more lines are too long

40
node_modules/vega-lite/build/src/compile/data/bin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import { Transforms as VgTransform } from 'vega';
import { BinParams } from '../../bin';
import { FieldName } from '../../channeldef';
import { BinTransform } from '../../transform';
import { Dict } from '../../util';
import { Model, ModelWithField } from '../model';
import { DataFlowNode } from './dataflow';
export declare function getBinSignalName(model: Model, field: string, bin: boolean | BinParams): string;
export interface BinComponent {
bin: BinParams;
field: FieldName;
extentSignal?: string;
signal?: string;
span?: string;
/** Pairs of strings of the names of start and end signals */
as: [string, string][];
formula?: string;
formulaAs?: string;
}
export declare class BinNode extends DataFlowNode {
private bins;
clone(): BinNode;
constructor(parent: DataFlowNode, bins: Dict<BinComponent>);
static makeFromEncoding(parent: DataFlowNode, model: ModelWithField): BinNode;
/**
* Creates a bin node from BinTransform.
* The optional parameter should provide
*/
static makeFromTransform(parent: DataFlowNode, t: BinTransform, model: Model): BinNode;
/**
* Merge bin nodes. This method either integrates the bin config from the other node
* or if this node already has a bin config, renames the corresponding signal in the model.
*/
merge(other: BinNode, renameSignal: (s1: string, s2: string) => void): void;
producedFields(): Set<string>;
dependentFields(): Set<string>;
hash(): string;
assemble(): VgTransform[];
}
//# sourceMappingURL=bin.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,UAAU,IAAI,WAAW,EAAC,MAAM,MAAM,CAAC;AAE/E,OAAO,EAAC,SAAS,EAA4C,MAAM,WAAW,CAAC;AAE/E,OAAO,EAAmB,SAAS,EAAwD,MAAM,kBAAkB,CAAC;AAEpH,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,IAAI,EAA4E,MAAM,YAAY,CAAC;AAE3G,OAAO,EAAc,KAAK,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAgCxC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,SAAS,UAIrF;AAuCD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,SAAS,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6DAA6D;IAC7D,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAIvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,OAAQ,SAAQ,YAAY;IAKL,OAAO,CAAC,IAAI;IAJvC,KAAK;gBAIA,MAAM,EAAE,YAAY,EAAU,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC;WAIpD,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc;IAoB1E;;;OAGG;WACW,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK;IAOnF;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI;IAkBpE,cAAc;IAQd,eAAe;IAIf,IAAI;IAIJ,QAAQ,IAAI,WAAW,EAAE;CA+CjC"}

162
node_modules/vega-lite/build/src/compile/data/bin.js generated vendored Normal file
View File

@@ -0,0 +1,162 @@
import { __rest } from "tslib";
import { isString } from 'vega-util';
import { binToString, isBinning, isSelectionExtent } from '../../bin';
import { binRequiresRange, isTypedFieldDef, normalizeBin, vgField } from '../../channeldef';
import { duplicate, hash, isEmpty, keys, replacePathInField, unique, vals, varName } from '../../util';
import { binFormatExpression } from '../format';
import { isUnitModel } from '../model';
import { parseSelectionBinExtent } from '../selection/parse';
import { DataFlowNode } from './dataflow';
function rangeFormula(model, fieldDef, channel, config) {
var _a, _b;
if (binRequiresRange(fieldDef, channel)) {
// read format from axis or legend, if there is no format then use config.numberFormat
const guide = isUnitModel(model)
? (_b = (_a = model.axis(channel)) !== null && _a !== void 0 ? _a : model.legend(channel)) !== null && _b !== void 0 ? _b : {} : {};
const startField = vgField(fieldDef, { expr: 'datum' });
const endField = vgField(fieldDef, { expr: 'datum', binSuffix: 'end' });
return {
formulaAs: vgField(fieldDef, { binSuffix: 'range', forAs: true }),
formula: binFormatExpression(startField, endField, guide.format, guide.formatType, config)
};
}
return {};
}
function binKey(bin, field) {
return `${binToString(bin)}_${field}`;
}
function getSignalsFromModel(model, key) {
return {
signal: model.getName(`${key}_bins`),
extentSignal: model.getName(`${key}_extent`)
};
}
export function getBinSignalName(model, field, bin) {
var _a;
const normalizedBin = (_a = normalizeBin(bin, undefined)) !== null && _a !== void 0 ? _a : {};
const key = binKey(normalizedBin, field);
return model.getName(`${key}_bins`);
}
function isBinTransform(t) {
return 'as' in t;
}
function createBinComponent(t, bin, model) {
let as;
let span;
if (isBinTransform(t)) {
as = isString(t.as) ? [t.as, `${t.as}_end`] : [t.as[0], t.as[1]];
}
else {
as = [vgField(t, { forAs: true }), vgField(t, { binSuffix: 'end', forAs: true })];
}
const normalizedBin = Object.assign({}, normalizeBin(bin, undefined));
const key = binKey(normalizedBin, t.field);
const { signal, extentSignal } = getSignalsFromModel(model, key);
if (isSelectionExtent(normalizedBin.extent)) {
const ext = normalizedBin.extent;
const selName = ext.selection;
span = parseSelectionBinExtent(model.getSelectionComponent(varName(selName), selName), ext);
delete normalizedBin.extent; // Vega-Lite selection extent map to Vega's span property.
}
const binComponent = Object.assign(Object.assign(Object.assign({ bin: normalizedBin, field: t.field, as: [as] }, (signal ? { signal } : {})), (extentSignal ? { extentSignal } : {})), (span ? { span } : {}));
return { key, binComponent };
}
export class BinNode extends DataFlowNode {
constructor(parent, bins) {
super(parent);
this.bins = bins;
}
clone() {
return new BinNode(null, duplicate(this.bins));
}
static makeFromEncoding(parent, model) {
const bins = model.reduceFieldDef((binComponentIndex, fieldDef, channel) => {
if (isTypedFieldDef(fieldDef) && isBinning(fieldDef.bin)) {
const { key, binComponent } = createBinComponent(fieldDef, fieldDef.bin, model);
binComponentIndex[key] = Object.assign(Object.assign(Object.assign({}, binComponent), binComponentIndex[key]), rangeFormula(model, fieldDef, channel, model.config));
}
return binComponentIndex;
}, {});
if (isEmpty(bins)) {
return null;
}
return new BinNode(parent, bins);
}
/**
* Creates a bin node from BinTransform.
* The optional parameter should provide
*/
static makeFromTransform(parent, t, model) {
const { key, binComponent } = createBinComponent(t, t.bin, model);
return new BinNode(parent, {
[key]: binComponent
});
}
/**
* Merge bin nodes. This method either integrates the bin config from the other node
* or if this node already has a bin config, renames the corresponding signal in the model.
*/
merge(other, renameSignal) {
for (const key of keys(other.bins)) {
if (key in this.bins) {
renameSignal(other.bins[key].signal, this.bins[key].signal);
// Ensure that we don't have duplicate names for signal pairs
this.bins[key].as = unique([...this.bins[key].as, ...other.bins[key].as], hash);
}
else {
this.bins[key] = other.bins[key];
}
}
for (const child of other.children) {
other.removeChild(child);
child.parent = this;
}
other.remove();
}
producedFields() {
return new Set(vals(this.bins)
.map(c => c.as)
.flat(2));
}
dependentFields() {
return new Set(vals(this.bins).map(c => c.field));
}
hash() {
return `Bin ${hash(this.bins)}`;
}
assemble() {
return vals(this.bins).flatMap(bin => {
const transform = [];
const [binAs, ...remainingAs] = bin.as;
const _a = bin.bin, { extent } = _a, params = __rest(_a, ["extent"]);
const binTrans = Object.assign(Object.assign(Object.assign({ type: 'bin', field: replacePathInField(bin.field), as: binAs, signal: bin.signal }, (!isSelectionExtent(extent) ? { extent } : { extent: null })), (bin.span ? { span: { signal: `span(${bin.span})` } } : {})), params);
if (!extent && bin.extentSignal) {
transform.push({
type: 'extent',
field: replacePathInField(bin.field),
signal: bin.extentSignal
});
binTrans.extent = { signal: bin.extentSignal };
}
transform.push(binTrans);
for (const as of remainingAs) {
for (let i = 0; i < 2; i++) {
transform.push({
type: 'formula',
expr: vgField({ field: binAs[i] }, { expr: 'datum' }),
as: as[i]
});
}
}
if (bin.formula) {
transform.push({
type: 'formula',
expr: bin.formula,
as: bin.formulaAs
});
}
return transform;
});
}
}
//# sourceMappingURL=bin.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
import { FormulaTransform as VgFormulaTransform } from 'vega';
import { SingleDefChannel } from '../../channel';
import { FieldRefOption, TypedFieldDef } from '../../channeldef';
import { CalculateTransform } from '../../transform';
import { ModelWithField } from '../model';
import { DataFlowNode } from './dataflow';
export declare class CalculateNode extends DataFlowNode {
private readonly transform;
private _dependentFields;
clone(): CalculateNode;
constructor(parent: DataFlowNode, transform: CalculateTransform);
static parseAllForSortIndex(parent: DataFlowNode, model: ModelWithField): DataFlowNode;
producedFields(): Set<string>;
dependentFields(): Set<string>;
assemble(): VgFormulaTransform;
hash(): string;
}
export declare function sortArrayIndexField(fieldDef: TypedFieldDef<string>, channel: SingleDefChannel, opt?: FieldRefOption): string;
//# sourceMappingURL=calculate.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"calculate.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/calculate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,IAAI,kBAAkB,EAAC,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAmB,aAAa,EAAU,MAAM,kBAAkB,CAAC;AAIzF,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAGxC,qBAAa,aAAc,SAAQ,YAAY;IAOX,OAAO,CAAC,QAAQ,CAAC,SAAS;IAN5D,OAAO,CAAC,gBAAgB,CAAc;IAE/B,KAAK;gBAIA,MAAM,EAAE,YAAY,EAAmB,SAAS,EAAE,kBAAkB;WAMlE,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc;IA0BvE,cAAc;IAId,eAAe;IAIf,QAAQ,IAAI,kBAAkB;IAQ9B,IAAI;CAGZ;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,cAAc,UAEnH"}

View File

@@ -0,0 +1,59 @@
import { isScaleFieldDef, vgField } from '../../channeldef';
import { fieldFilterExpression } from '../../predicate';
import { isSortArray } from '../../sort';
import { duplicate, hash } from '../../util';
import { DataFlowNode } from './dataflow';
import { getDependentFields } from './expressions';
export class CalculateNode extends DataFlowNode {
constructor(parent, transform) {
super(parent);
this.transform = transform;
this._dependentFields = getDependentFields(this.transform.calculate);
}
clone() {
return new CalculateNode(null, duplicate(this.transform));
}
static parseAllForSortIndex(parent, model) {
// get all the encoding with sort fields from model
model.forEachFieldDef((fieldDef, channel) => {
if (!isScaleFieldDef(fieldDef)) {
return;
}
if (isSortArray(fieldDef.sort)) {
const { field, timeUnit } = fieldDef;
const sort = fieldDef.sort;
// generate `datum["a"] === val0 ? 0 : datum["a"] === val1 ? 1 : ... : n` via FieldEqualPredicate
const calculate = sort
.map((sortValue, i) => {
return `${fieldFilterExpression({ field, timeUnit, equal: sortValue })} ? ${i} : `;
})
.join('') + sort.length;
parent = new CalculateNode(parent, {
calculate,
as: sortArrayIndexField(fieldDef, channel, { forAs: true })
});
}
});
return parent;
}
producedFields() {
return new Set([this.transform.as]);
}
dependentFields() {
return this._dependentFields;
}
assemble() {
return {
type: 'formula',
expr: this.transform.calculate,
as: this.transform.as
};
}
hash() {
return `Calculate ${hash(this.transform)}`;
}
}
export function sortArrayIndexField(fieldDef, channel, opt) {
return vgField(fieldDef, Object.assign({ prefix: channel, suffix: 'sort_index' }, (opt !== null && opt !== void 0 ? opt : {})));
}
//# sourceMappingURL=calculate.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"calculate.js","sourceRoot":"","sources":["../../../../src/compile/data/calculate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAAiB,OAAO,EAAC,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAC,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAEjD,MAAM,OAAO,aAAc,SAAQ,YAAY;IAO7C,YAAY,MAAoB,EAAmB,SAA6B;QAC9E,KAAK,CAAC,MAAM,CAAC,CAAC;QADmC,cAAS,GAAT,SAAS,CAAoB;QAG9E,IAAI,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;IARM,KAAK;QACV,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5D,CAAC;IAQM,MAAM,CAAC,oBAAoB,CAAC,MAAoB,EAAE,KAAqB;QAC5E,mDAAmD;QACnD,KAAK,CAAC,eAAe,CAAC,CAAC,QAA+B,EAAE,OAAyB,EAAE,EAAE;YACnF,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;gBAC9B,OAAO;aACR;YACD,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC9B,MAAM,EAAC,KAAK,EAAE,QAAQ,EAAC,GAAG,QAAQ,CAAC;gBACnC,MAAM,IAAI,GAA6C,QAAQ,CAAC,IAAI,CAAC;gBACrE,iGAAiG;gB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{ Dict } from '../../util';
/**
* A node in the dataflow tree.
*/
export declare abstract class DataFlowNode {
readonly debugName?: string;
private _children;
private _parent;
protected _hash: string | number;
constructor(parent: DataFlowNode, debugName?: string);
/**
* Clone this node with a deep copy but don't clone links to children or parents.
*/
clone(): DataFlowNode;
/**
* Return a hash of the node.
*/
abstract hash(): string | number;
/**
* Set of fields that this node depends on.
*/
abstract dependentFields(): Set<string>;
/**
* Set of fields that are being created by this node.
*/
abstract producedFields(): Set<string>;
get parent(): DataFlowNode;
/**
* Set the parent of the node and also add this node to the parent's children.
*/
set parent(parent: DataFlowNode);
get children(): DataFlowNode[];
numChildren(): number;
addChild(child: DataFlowNode, loc?: number): void;
removeChild(oldChild: DataFlowNode): number;
/**
* Remove node from the dataflow.
*/
remove(): void;
/**
* Insert another node as a parent of this node.
*/
insertAsParentOf(other: DataFlowNode): void;
swapWithParent(): void;
}
export declare class OutputNode extends DataFlowNode {
readonly type: DataSourceType;
private readonly refCounts;
private _source;
private _name;
clone(): this;
/**
* @param source The name of the source. Will change in assemble.
* @param type The type of the output node.
* @param refCounts A global ref counter map.
*/
constructor(parent: DataFlowNode, source: string, type: DataSourceType, refCounts: Dict<number>);
dependentFields(): Set<string>;
producedFields(): Set<string>;
hash(): string | number;
/**
* Request the datasource name and increase the ref counter.
*
* During the parsing phase, this will return the simple name such as 'main' or 'raw'.
* It is crucial to request the name from an output node to mark it as a required node.
* If nobody ever requests the name, this datasource will not be instantiated in the assemble phase.
*
* In the assemble phase, this will return the correct name.
*/
getSource(): string;
isRequired(): boolean;
setSource(source: string): void;
}
//# sourceMappingURL=dataflow.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"dataflow.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/dataflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,IAAI,EAAW,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,8BAAsB,YAAY;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queId } from '../../util';
/**
* A node in the dataflow tree.
*/
export class DataFlowNode {
constructor(parent, debugName) {
this.debugName = debugName;
this._children = [];
this._parent = null;
if (parent) {
this.parent = parent;
}
}
/**
* Clone this node with a deep copy but don't clone links to children or parents.
*/
clone() {
throw new Error('Cannot clone node');
}
get parent() {
return this._parent;
}
/**
* Set the parent of the node and also add this node to the parent's children.
*/
set parent(parent) {
this._parent = parent;
if (parent) {
parent.addChild(this);
}
}
get children() {
return this._children;
}
numChildren() {
return this._children.length;
}
addChild(child, loc) {
// do not add the same child twice
if (this._children.indexOf(child) > -1) {
log.warn(log.message.ADD_SAME_CHILD_TWICE);
return;
}
if (loc !== undefined) {
this._children.splice(loc, 0, child);
}
else {
this._children.push(child);
}
}
removeChild(oldChild) {
const loc = this._children.indexOf(oldChild);
this._children.splice(loc, 1);
return loc;
}
/**
* Remove node from the dataflow.
*/
remove() {
let loc = this._parent.removeChild(this);
for (const child of this._children) {
// do not use the set method because we want to insert at a particular location
child._parent = this._parent;
this._parent.addChild(child, loc++);
}
}
/**
* Insert another node as a parent of this node.
*/
insertAsParentOf(other) {
const parent = other.parent;
parent.removeChild(this);
this.parent = parent;
other.parent = this;
}
swapWithParent() {
const parent = this._parent;
const newParent = parent.parent;
// reconnect the children
for (const child of this._children) {
child.parent = parent;
}
// remove old links
this._children = []; // equivalent to removing every child link one by one
parent.removeChild(this);
parent.parent.removeChild(parent);
// swap two nodes
this.parent = newParent;
parent.parent = this;
}
}
export class OutputNode extends DataFlowNode {
/**
* @param source The name of the source. Will change in assemble.
* @param type The type of the output node.
* @param refCounts A global ref counter map.
*/
constructor(parent, source, type, refCounts) {
super(parent, source);
this.type = type;
this.refCounts = refCounts;
this._source = this._name = source;
if (this.refCounts && !(this._name in this.refCounts)) {
this.refCounts[this._name] = 0;
}
}
clone() {
const cloneObj = new this.constructor();
cloneObj.debugName = 'clone_' + this.debugName;
cloneObj._source = this._source;
cloneObj._name = 'clone_' + this._name;
cloneObj.type = this.type;
cloneObj.refCounts = this.refCounts;
cloneObj.refCounts[cloneObj._name] = 0;
return cloneObj;
}
dependentFields() {
return new Set();
}
producedFields() {
return new Set();
}
hash() {
if (this._hash === undefined) {
this._hash = `Output ${uniqueId()}`;
}
return this._hash;
}
/**
* Request the datasource name and increase the ref counter.
*
* During the parsing phase, this will return the simple name such as 'main' or 'raw'.
* It is crucial to request the name from an output node to mark it as a required node.
* If nobody ever requests the name, this datasource will not be instantiated in the assemble phase.
*
* In the assemble phase, this will return the correct name.
*/
getSource() {
this.refCounts[this._name]++;
return this._source;
}
isRequired() {
return !!this.refCounts[this._name];
}
setSource(source) {
this._source = source;
}
}
//# sourceMappingURL=dataflow.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"dataflow.js","sourceRoot":"","sources":["../../../../src/compile/data/dataflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAO,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAgB,YAAY;IAOhC,YAAY,MAAoB,EAAkB,SAAkB;QAAlB,cAAS,GAAT,SAAS,CAAS;QAN5D,cAAS,GAAmB,EAAE,CAAC;QAE/B,YAAO,GAAiB,IAAI,CAAC;QAKnC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACtB;IACH,CAAC;IAED;;OAEG;IACI,KAAK;QACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAiBD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM,CAAC,MAAoB;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,EAAE;YACV,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACvB;IACH,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,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AAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAChC,QAAQ,CAAC,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC;QACvC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACpC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAsBM,eAAe;QACpB,OAAO,IAAI,GAAG,EAAU,CAAC;IAC3B,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,GAAG,EAAU,CAAC;IAC3B,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,UAAU,QAAQ,EAAE,EAAE,CAAC;SACrC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;;;;;OAQG;IACI,SAAS;QACd,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,UAAU;QACf,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAEM,SAAS,CAAC,MAAc;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;CACF"}

View File

@@ -0,0 +1,16 @@
import { DataFlowNode } from './dataflow';
/**
* Print debug information for dataflow tree.
*/
export declare function printDebugDataflow(node: DataFlowNode): void;
/**
* Show the dataflow graph as an image (rendered by https://kroki.io/) on the command line.
*/
export declare function drawDataflow(roots: readonly DataFlowNode[], size?: number): void;
/**
* Print the dataflow tree as graphviz.
*
* Render the output in e.g. http://viz-js.com/.
*/
export declare function dotString(roots: readonly DataFlowNode[]): string;
//# sourceMappingURL=debug.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/debug.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAa,MAAM,YAAY,CAAC;AAKpD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,QAQpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,EAAE,IAAI,SAAM,QAOtE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,UA8EvD"}

100
node_modules/vega-lite/build/src/compile/data/debug.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
import { entries, uniqueId } from '../../util';
import { OutputNode } from './dataflow';
import { SourceNode } from './source';
import pako from 'pako';
import { checkLinks } from './optimize';
/**
* Print debug information for dataflow tree.
*/
export function printDebugDataflow(node) {
console.log(`${node.constructor.name}${node.debugName ? `(${node.debugName})` : ''} -> ${node.children.map(c => {
return `${c.constructor.name}${c.debugName ? ` (${c.debugName})` : ''}`;
})}`);
console.log(node);
node.children.forEach(printDebugDataflow);
}
/**
* Show the dataflow graph as an image (rendered by https://kroki.io/) on the command line.
*/
export function drawDataflow(roots, size = 500) {
const dot = dotString(roots);
const text = new TextEncoder().encode(dot);
const compressed = pako.deflate(text, { level: 9, to: 'string' });
const result = btoa(compressed).replace(/\+/g, '-').replace(/\//g, '_');
const imageURL = `https://kroki.io/plantuml/png/${result}`;
console.log('%c ', `font-size:${size}px; background:url(${imageURL}) no-repeat; background-size:contain`);
}
/**
* Print the dataflow tree as graphviz.
*
* Render the output in e.g. http://viz-js.com/.
*/
export function dotString(roots) {
// check the graph before printing it since the logic below assumes a consistent graph
checkLinks(roots);
const nodes = {};
const edges = [];
function getId(node) {
let id = node['__uniqueid'];
if (id === undefined) {
id = uniqueId();
node['__uniqueid'] = id;
}
return id;
}
function getLabel(node) {
var _a;
const out = [node.constructor.name.slice(0, -4)];
if (node.debugName) {
out.push(`<i>${node.debugName}</i>`);
}
else if (node instanceof SourceNode) {
if (node.data.name || node.data.url) {
out.push(`<i>${(_a = node.data.name) !== null && _a !== void 0 ? _a : node.data.url}</i>`);
}
}
const dep = node.dependentFields();
if (dep === null || dep === void 0 ? void 0 : dep.size) {
out.push(`<font color="grey" point-size="10">IN:</font> ${[...node.dependentFields()].join(', ')}`);
}
const prod = node.producedFields();
if (prod === null || prod === void 0 ? void 0 : prod.size) {
out.push(`<font color="grey" point-size="10">OUT:</font> ${[...node.producedFields()].join(', ')}`);
}
if (node instanceof OutputNode) {
out.push(`<font color="grey" point-size="10">required:</font> ${node.isRequired()}`);
}
return out.join('<br/>');
}
function collector(node) {
var _a, _b;
const id = getId(node);
nodes[id] = {
id: id,
label: getLabel(node),
hash: node instanceof SourceNode
? (_b = (_a = node.data.url) !== null && _a !== void 0 ? _a : node.data.name) !== null && _b !== void 0 ? _b : node.debugName : String(node.hash()).replace(/"/g, '')
};
for (const child of node.children) {
edges.push([id, getId(child)]);
collector(child);
}
}
for (const n of roots) {
collector(n);
}
const dot = `digraph DataFlow {
rankdir = TB;
node [shape=record]
${entries(nodes)
.map(({ key, value }) => ` "${key}" [
label = <${value.label}>;
tooltip = "[${value.id}]&#010;${value.hash}"
]`)
.join('\n')}
${edges.map(([source, target]) => `"${source}" -> "${target}"`).join(' ')}
}`;
return dot;
}
//# sourceMappingURL=debug.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../../src/compile/data/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAe,UAAU,EAAC,MAAM,YAAY,CAAC;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,UAAU,EAAC,MAA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AAG,EAAE,KAAK,EAAC,EAAE,EAAE,CAAC,MAAM,GAAG;eAClB,KAAK,CAAC,KAAK;kBACR,KAAK,CAAC,EAAE,UAAU,KAAK,CAAC,IAAI;IAC1C,CACC;SACA,IAAI,CAAC,IAAI,CAAC;;IAEX,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EACzE,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}

View File

@@ -0,0 +1,16 @@
import { KDETransform as VgKDETransform } from 'vega';
import { DensityTransform } from '../../transform';
import { DataFlowNode } from './dataflow';
/**
* A class for density transform nodes
*/
export declare class DensityTransformNode extends DataFlowNode {
private transform;
clone(): DensityTransformNode;
constructor(parent: DataFlowNode, transform: DensityTransform);
dependentFields(): Set<string>;
producedFields(): Set<string>;
hash(): string;
assemble(): VgKDETransform;
}
//# sourceMappingURL=density.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"density.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/density.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,IAAI,cAAc,EAAC,MAAM,MAAM,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;IAKlB,OAAO,CAAC,SAAS;IAJ5C,KAAK;gBAIA,MAAM,EAAE,YAAY,EAAU,SAAS,EAAE,gBAAgB;IAO9D,eAAe;IAIf,cAAc;IAId,IAAI;IAIJ,QAAQ,IAAI,cAAc;CASlC"}

View File

@@ -0,0 +1,35 @@
import { __rest } from "tslib";
import { duplicate, hash } from '../../util';
import { DataFlowNode } from './dataflow';
/**
* A class for density transform nodes
*/
export class DensityTransformNode extends DataFlowNode {
constructor(parent, transform) {
var _a, _b, _c;
super(parent);
this.transform = transform;
this.transform = duplicate(transform); // duplicate to prevent side effects
const specifiedAs = (_a = this.transform.as) !== null && _a !== void 0 ? _a : [undefined, undefined];
this.transform.as = [(_b = specifiedAs[0]) !== null && _b !== void 0 ? _b : 'value', (_c = specifiedAs[1]) !== null && _c !== void 0 ? _c : 'density'];
}
clone() {
return new DensityTransformNode(null, duplicate(this.transform));
}
dependentFields() {
var _a;
return new Set([this.transform.density, ...((_a = this.transform.groupby) !== null && _a !== void 0 ? _a : [])]);
}
producedFields() {
return new Set(this.transform.as);
}
hash() {
return `DensityTransform ${hash(this.transform)}`;
}
assemble() {
const _a = this.transform, { density } = _a, rest = __rest(_a, ["density"]);
const result = Object.assign({ type: 'kde', field: density }, rest);
return result;
}
}
//# sourceMappingURL=density.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"density.js","sourceRoot":"","sources":["../../../../src/compile/data/density.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAKpD,YAAY,MAAoB,EAAU,SAA2B;;QACnE,KAAK,CAAC,MAAM,CAAC,CAAC;QAD0B,cAAS,GAAT,SAAS,CAAkB;QAEnE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,oCAAoC;QAC3E,MAAM,WAAW,SAAG,IAAI,CAAC,SAAS,CAAC,EAAE,mCAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAC,WAAW,CAAC,CAAC,CAAC,mCAAI,OAAO,QAAE,WAAW,CAAC,CAAC,CAAC,mCAAI,SAAS,CAAC,CAAC;IAC/E,CAAC;IATM,KAAK;QACV,OAAO,IAAI,oBAAoB,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACnE,CAAC;IASM,eAAe;;QACpB,OAAO,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,OAAC,IAAI,CAAC,SAAS,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAEM,IAAI;QACT,OAAO,oBAAoB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;IACpD,CAAC;IAEM,QAAQ;QACb,MAAM,KAAqB,IAAI,CAAC,SAAS,EAAnC,EAAC,OAAO,OAA2B,EAAtB,IAAI,cAAjB,WAAkB,CAAiB,CAAC;QAC1C,MAAM,MAAM,mBACV,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,OAAO,IACX,IAAI,CACR,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}

View File

@@ -0,0 +1,2 @@
export declare function getDependentFields(expression: string): Set<string>;
//# sourceMappingURL=expressions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/expressions.ts"],"names":[],"mappings":"AA4BA,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,eAUpD"}

View File

@@ -0,0 +1,32 @@
import { parse } from 'vega-expression';
function getName(node) {
const name = [];
if (node.type === 'Identifier') {
return [node.name];
}
if (node.type === 'Literal') {
return [node.value];
}
if (node.type === 'MemberExpression') {
name.push(...getName(node.object));
name.push(...getName(node.property));
}
return name;
}
function startsWithDatum(node) {
if (node.object.type === 'MemberExpression') {
return startsWithDatum(node.object);
}
return node.object.name === 'datum';
}
export function getDependentFields(expression) {
const ast = parse(expression);
const dependents = new Set();
ast.visit((node) => {
if (node.type === 'MemberExpression' && startsWithDatum(node)) {
dependents.add(getName(node).slice(1).join('.'));
}
});
return dependents;
}
//# sourceMappingURL=expressions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"expressions.js","sourceRoot":"","sources":["../../../../src/compile/data/expressions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAEtC,SAAS,OAAO,CAAC,IAAS;IACxB,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE;QAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpB;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACrB;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;KACtC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,eAAe,CAAC,IAAS;IAChC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE;QAC3C,OAAO,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACrC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IACnD,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAS,EAAE,EAAE;QACtB,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7D,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SAClD;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}

View File

@@ -0,0 +1,34 @@
import { VgData } from '../../vega.schema';
import { FacetModel } from '../facet';
import { DataFlowNode } from './dataflow';
/**
* A node that helps us track what fields we are faceting by.
*/
export declare class FacetNode extends DataFlowNode {
readonly model: FacetModel;
readonly name: string;
data: string;
private readonly column;
private readonly row;
private readonly facet;
private readonly childModel;
/**
* @param model The facet model.
* @param name The name that this facet source will have.
* @param data The source data for this facet data.
*/
constructor(parent: DataFlowNode, model: FacetModel, name: string, data: string);
hash(): string;
get fields(): string[];
dependentFields(): Set<string>;
producedFields(): Set<string>;
/**
* The name to reference this source is its name.
*/
getSource(): string;
private getChildIndependentFieldsWithStep;
private assembleRowColumnHeaderData;
private assembleFacetHeaderData;
assemble(): VgData[];
}
//# sourceMappingURL=facet.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"facet.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/facet.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAKpC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAexC;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY;aAgBvB,KAAK,EAAE,UAAU;aACjB,IAAI,EAAE,MAAM;IACrB,IAAI,EAAE,MAAM;IAjBrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAE1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAmB;IAEvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IAEzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAEnC;;;;OAIG;gBAED,MAAM,EAAE,YAAY,EACJ,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM;IAsBd,IAAI;IAYX,IAAI,MAAM,aAST;IAEM,eAAe;IAiBf,cAAc;IAIrB;;OAEG;IACI,SAAS;IAIhB,OAAO,CAAC,iCAAiC;IAyBzC,OAAO,CAAC,2BAA2B;IA0DnC,OAAO,CAAC,uBAAuB;IAmDxB,QAAQ;CA8ChB"}

232
node_modules/vega-lite/build/src/compile/data/facet.js generated vendored Normal file
View File

@@ -0,0 +1,232 @@
import { isArray } from 'vega-util';
import { isBinning } from '../../bin';
import { COLUMN, FACET_CHANNELS, POSITION_SCALE_CHANNELS, ROW } from '../../channel';
import { vgField } from '../../channeldef';
import * as log from '../../log';
import { hasDiscreteDomain } from '../../scale';
import { DEFAULT_SORT_OP, isSortField } from '../../sort';
import { hash } from '../../util';
import { isVgRangeStep } from '../../vega.schema';
import { HEADER_CHANNELS, HEADER_TYPES } from '../header/component';
import { assembleDomain, getFieldFromDomain } from '../scale/domain';
import { sortArrayIndexField } from './calculate';
import { DataFlowNode } from './dataflow';
/**
* A node that helps us track what fields we are faceting by.
*/
export class FacetNode extends DataFlowNode {
/**
* @param model The facet model.
* @param name The name that this facet source will have.
* @param data The source data for this facet data.
*/
constructor(parent, model, name, data) {
super(parent);
this.model = model;
this.name = name;
this.data = data;
for (const channel of FACET_CHANNELS) {
const fieldDef = model.facet[channel];
if (fieldDef) {
const { bin, sort } = fieldDef;
this[channel] = Object.assign({ name: model.getName(`${channel}_domain`), fields: [vgField(fieldDef), ...(isBinning(bin) ? [vgField(fieldDef, { binSuffix: 'end' })] : [])] }, (isSortField(sort)
? { sortField: sort }
: isArray(sort)
? { sortIndexField: sortArrayIndexField(fieldDef, channel) }
: {}));
}
}
this.childModel = model.child;
}
hash() {
let out = `Facet`;
for (const channel of FACET_CHANNELS) {
if (this[channel]) {
out += ` ${channel.charAt(0)}:${hash(this[channel])}`;
}
}
return out;
}
get fields() {
var _a;
const f = [];
for (const channel of FACET_CHANNELS) {
if ((_a = this[channel]) === null || _a === void 0 ? void 0 : _a.fields) {
f.push(...this[channel].fields);
}
}
return f;
}
dependentFields() {
const depFields = new Set(this.fields);
for (const channel of FACET_CHANNELS) {
if (this[channel]) {
if (this[channel].sortField) {
depFields.add(this[channel].sortField.field);
}
if (this[channel].sortIndexField) {
depFields.add(this[channel].sortIndexField);
}
}
}
return depFields;
}
producedFields() {
return new Set(); // facet does not produce any new fields
}
/**
* The name to reference this source is its name.
*/
getSource() {
return this.name;
}
getChildIndependentFieldsWithStep() {
const childIndependentFieldsWithStep = {};
for (const channel of POSITION_SCALE_CHANNELS) {
const childScaleComponent = this.childModel.component.scales[channel];
if (childScaleComponent && !childScaleComponent.merged) {
// independent scale
const type = childScaleComponent.get('type');
const range = childScaleComponent.get('range');
if (hasDiscreteDomain(type) && isVgRangeStep(range)) {
const domain = assembleDomain(this.childModel, channel);
const field = getFieldFromDomain(domain);
if (field) {
childIndependentFieldsWithStep[channel] = field;
}
else {
log.warn(log.message.unknownField(channel));
}
}
}
}
return childIndependentFieldsWithStep;
}
assembleRowColumnHeaderData(channel, crossedDataName, childIndependentFieldsWithStep) {
const childChannel = { row: 'y', column: 'x' }[channel];
const fields = [];
const ops = [];
const as = [];
if (childIndependentFieldsWithStep && childIndependentFieldsWithStep[childChannel]) {
if (crossedDataName) {
// If there is a crossed data, calculate max
fields.push(`distinct_${childIndependentFieldsWithStep[childChannel]}`);
ops.push('max');
}
else {
// If there is no crossed data, just calculate distinct
fields.push(childIndependentFieldsWithStep[childChannel]);
ops.push('distinct');
}
// Although it is technically a max, just name it distinct so it's easier to refer to it
as.push(`distinct_${childIndependentFieldsWithStep[childChannel]}`);
}
const { sortField, sortIndexField } = this[channel];
if (sortField) {
const { op = DEFAULT_SORT_OP, field } = sortField;
fields.push(field);
ops.push(op);
as.push(vgField(sortField, { forAs: true }));
}
else if (sortIndexField) {
fields.push(sortIndexField);
ops.push('max');
as.push(sortIndexField);
}
return {
name: this[channel].name,
// Use data from the crossed one if it exist
source: crossedDataName !== null && crossedDataName !== void 0 ? crossedDataName : this.data,
transform: [
Object.assign({ type: 'aggregate', groupby: this[channel].fields }, (fields.length
? {
fields,
ops,
as
}
: {}))
]
};
}
assembleFacetHeaderData(childIndependentFieldsWithStep) {
var _a, _b;
const { columns } = this.model.layout;
const { layoutHeaders } = this.model.component;
const data = [];
const hasSharedAxis = {};
for (const headerChannel of HEADER_CHANNELS) {
for (const headerType of HEADER_TYPES) {
const headers = (_a = (layoutHeaders[headerChannel] && layoutHeaders[headerChannel][headerType])) !== null && _a !== void 0 ? _a : [];
for (const header of headers) {
if (((_b = header.axes) === null || _b === void 0 ? void 0 : _b.length) > 0) {
hasSharedAxis[headerChannel] = true;
break;
}
}
}
if (hasSharedAxis[headerChannel]) {
const cardinality = `length(data("${this.facet.name}"))`;
const stop = headerChannel === 'row'
? columns
? { signal: `ceil(${cardinality} / ${columns})` }
: 1
: columns
? { signal: `min(${cardinality}, ${columns})` }
: { signal: cardinality };
data.push({
name: `${this.facet.name}_${headerChannel}`,
transform: [
{
type: 'sequence',
start: 0,
stop
}
]
});
}
}
const { row, column } = hasSharedAxis;
if (row || column) {
data.unshift(this.assembleRowColumnHeaderData('facet', null, childIndependentFieldsWithStep));
}
return data;
}
assemble() {
var _a, _b;
const data = [];
let crossedDataName = null;
const childIndependentFieldsWithStep = this.getChildIndependentFieldsWithStep();
const { column, row, facet } = this;
if (column && row && (childIndependentFieldsWithStep.x || childIndependentFieldsWithStep.y)) {
// Need to create a cross dataset to correctly calculate cardinality
crossedDataName = `cross_${this.column.name}_${this.row.name}`;
const fields = [].concat((_a = childIndependentFieldsWithStep.x) !== null && _a !== void 0 ? _a : [], (_b = childIndependentFieldsWithStep.y) !== null && _b !== void 0 ? _b : []);
const ops = fields.map(() => 'distinct');
data.push({
name: crossedDataName,
source: this.data,
transform: [
{
type: 'aggregate',
groupby: this.fields,
fields,
ops
}
]
});
}
for (const channel of [COLUMN, ROW]) {
if (this[channel]) {
data.push(this.assembleRowColumnHeaderData(channel, crossedDataName, childIndependentFieldsWithStep));
}
}
if (facet) {
const facetData = this.assembleFacetHeaderData(childIndependentFieldsWithStep);
if (facetData) {
data.push(...facetData);
}
}
return data;
}
}
//# sourceMappingURL=facet.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
import { FilterTransform as VgFilterTransform } from 'vega';
import { LogicalComposition } from '../../logical';
import { Predicate } from '../../predicate';
import { Model } from '../model';
import { DataFlowNode } from './dataflow';
export declare class FilterNode extends DataFlowNode {
private readonly model;
private readonly filter;
private expr;
private _dependentFields;
clone(): FilterNode;
constructor(parent: DataFlowNode, model: Model, filter: LogicalComposition<Predicate>);
dependentFields(): Set<string>;
producedFields(): Set<string>;
assemble(): VgFilterTransform;
hash(): string;
}
//# sourceMappingURL=filter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/compile/data/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,IAAI,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAGxC,qBAAa,UAAW,SAAQ,YAAY;IASxC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,gBAAgB,CAAc;IAC/B,KAAK;gBAKV,MAAM,EAAE,YAAY,EACH,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,kBAAkB,CAAC,SAAS,CAAC;IAWjD,eAAe;IAIf,cAAc;IAId,QAAQ,IAAI,iBAAiB;IAO7B,IAAI;CAGZ"}

View File

@@ -0,0 +1,34 @@
import { duplicate } from '../../util';
import { expression } from '../predicate';
import { DataFlowNode } from './dataflow';
import { getDependentFields } from './expressions';
export class FilterNode extends DataFlowNode {
constructor(parent, model, filter) {
super(parent);
this.model = model;
this.filter = filter;
// TODO: refactor this to not take a node and
// then add a static function makeFromOperand and make the constructor take only an expression
this.expr = expression(this.model, this.filter, this);
this._dependentFields = getDependentFields(this.expr);
}
clone() {
return new FilterNode(null, this.model, duplicate(this.filter));
}
dependentFields() {
return this._dependentFields;
}
producedFields() {
return new Set(); // filter does not produce any new fields
}
assemble() {
return {
type: 'filter',
expr: this.expr
};
}
hash() {
return `Filter ${this.expr}`;
}
}
//# sourceMappingURL=filter.js.map

Some files were not shown because too many files have changed in this diff Show More