Socket
Socket
Sign inDemoInstall

vega-lite

Package Overview
Dependencies
Maintainers
2
Versions
470
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-lite - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

13

CONTRIBUTING.md

@@ -16,3 +16,3 @@ # Contributing

See our [issue](.github/ISSUE_TEMPLATE.md) and [pull request](.github/PULL_REQUEST_TEMPLATE.md) templates for more information.
See our [issue](.github/ISSUE_TEMPLATE.md) and [pull request](.github/PULL_REQUEST_TEMPLATE.md) templates for more information.

@@ -59,3 +59,3 @@ ### Looking for a Task to Contribute

Now you should be able to build and test the code.
3. To make the gallery work, you need to install [bower](http://bower.io/) and its dependencies:

@@ -67,5 +67,5 @@

```
4. To serve the website and documentation, you will need [ruby](https://www.ruby-lang.org/en/), [bundler](http://bundler.io/) and [Jekyll](https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/).
4. To serve the website and documentation, you will need [ruby](https://www.ruby-lang.org/en/), [bundler](http://bundler.io/) and [Jekyll](https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/).
For ruby, Mac users can use [homebrew](http://brew.sh) to add it:

@@ -76,3 +76,3 @@ ```sh

For bundler:
For bundler:
```sh

@@ -94,3 +94,2 @@ gem install bundler

- `examples/` – Example Vega-Lite specifications.
- `examples/docs/` contains examples that are used in the documetnation, but should not be shown in the gallery.
- `examples/vl-examples.json` lists all examples under `examples/`. Similarly, `examples/docs/vl-docs-examples.json` lists all examples under `examples/docs`.

@@ -107,4 +106,2 @@

`vl.compile` is in `src/compile/compile.ts`.
- `src/schema/` contains JSON schema and TypeScript interface declaration.
We compile `schema` variable inside `src/schema/schema.ts` to generate the JSON schema.

@@ -111,0 +108,0 @@ - `test/` - Code for unit testing. `test`'s structure reflects `src`'s' directory structure.

{
"name": "vega-lite",
"author": "Jeffrey Heer, Dominik Moritz, Kanit \"Ham\" Wongsuphasawat",
"version": "1.0.11",
"version": "1.0.12",
"collaborators": [

@@ -6,0 +6,0 @@ "Kanit Wongsuphasawat <kanitw@gmail.com> (http://kanitw.yellowpigz.com)",

@@ -7,2 +7,4 @@ # Vega-Lite

![Teaser](site/static/teaser.png)
Vega-Lite provides a higher-level grammar for visual analysis, akin to ggplot or Tableau, that generates complete [Vega](https://vega.github.io/) specifications.

@@ -9,0 +11,0 @@

@@ -55,3 +55,4 @@ "use strict";

test: filteredFields.map(function (fieldName) {
return 'datum.' + fieldName + '!==null';
return '(datum.' + fieldName + '!==null' +
' && !isNaN(datum.' + fieldName + '))';
}).join(' && ')

@@ -58,0 +59,0 @@ }] : [];

@@ -76,3 +76,4 @@ import {FieldDef} from '../../fielddef';

test: filteredFields.map(function(fieldName) {
return 'datum.' + fieldName + '!==null';
return '(datum.' + fieldName + '!==null' +
' && !isNaN(datum.'+ fieldName + '))';
}).join(' && ')

@@ -79,0 +80,0 @@ }] : [];

@@ -183,5 +183,5 @@ "use strict";

LayerModel.prototype.compatibleSource = function (child) {
var sourceUrl = this.data().url;
var data = this.data();
var childData = child.component.data;
var compatible = !childData.source || (sourceUrl && sourceUrl === childData.source.url);
var compatible = !childData.source || (data && data.url === childData.source.url);
return compatible;

@@ -188,0 +188,0 @@ };

@@ -250,7 +250,7 @@ import {Channel} from '../channel';

public compatibleSource(child: UnitModel) {
const sourceUrl = this.data().url;
const data = this.data();
const childData = child.component.data;
const compatible = !childData.source || (sourceUrl && sourceUrl === childData.source.url);
const compatible = !childData.source || (data && data.url === childData.source.url);
return compatible;
}
}

@@ -11,3 +11,3 @@

import {LayerModel} from './layer';
import {TEXT as TEXT_MARK} from '../mark';
import {TEXT as TEXTMARK} from '../mark';
import {Model} from './model';

@@ -100,3 +100,3 @@ import {rawDomain} from './time';

} else {
if (model.mark() === TEXT_MARK && channel === X) {
if (model.mark() === TEXTMARK && channel === X) {
// for text table without x/y scale we need wider bandSize

@@ -103,0 +103,0 @@ return model.config().scale.textBandWidth + '';

@@ -13,33 +13,57 @@ "use strict";

var p = {};
var orient = model.config().mark.orient;
if (orient !== undefined) {
p.orient = { value: orient };
var config = model.config();
var _orient = orient(config.mark.orient);
if (_orient) {
p.orient = _orient;
}
var stack = model.stack();
var xFieldDef = model.encoding().x;
p.x = x(model.encoding().x, model.scaleName(channel_1.X), model.stack());
var _x2 = x2(model.encoding().x, model.scaleName(channel_1.X), model.stack(), config.mark.orient);
if (_x2) {
p.x2 = _x2;
}
p.y = y(model.encoding().y, model.scaleName(channel_1.Y), model.stack());
var _y2 = y2(model.encoding().y, model.scaleName(channel_1.Y), model.stack(), config.mark.orient);
if (_y2) {
p.y2 = _y2;
}
common_1.applyColorAndOpacity(p, model);
common_1.applyMarkConfig(p, model, ['interpolate', 'tension']);
return p;
}
area.properties = properties;
function orient(orient) {
if (orient) {
return { value: orient };
}
return undefined;
}
function x(fieldDef, scaleName, stack) {
if (stack && channel_1.X === stack.fieldChannel) {
p.x = {
scale: model.scaleName(channel_1.X),
field: model.field(channel_1.X, { suffix: '_start' })
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { suffix: '_start' })
};
}
else if (fielddef_1.isMeasure(xFieldDef)) {
p.x = { scale: model.scaleName(channel_1.X), field: model.field(channel_1.X) };
else if (fielddef_1.isMeasure(fieldDef)) {
return { scale: scaleName, field: fielddef_1.field(fieldDef) };
}
else if (fielddef_1.isDimension(xFieldDef)) {
p.x = {
scale: model.scaleName(channel_1.X),
field: model.field(channel_1.X, { binSuffix: '_mid' })
else if (fielddef_1.isDimension(fieldDef)) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { binSuffix: '_mid' })
};
}
return undefined;
}
function x2(fieldDef, scaleName, stack, orient) {
if (orient === 'horizontal') {
if (stack && channel_1.X === stack.fieldChannel) {
p.x2 = {
scale: model.scaleName(channel_1.X),
field: model.field(channel_1.X, { suffix: '_end' })
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { suffix: '_end' })
};
}
else {
p.x2 = {
scale: model.scaleName(channel_1.X),
return {
scale: scaleName,
value: 0

@@ -49,31 +73,36 @@ };

}
var yFieldDef = model.encoding().y;
return undefined;
}
function y(fieldDef, scaleName, stack) {
if (stack && channel_1.Y === stack.fieldChannel) {
p.y = {
scale: model.scaleName(channel_1.Y),
field: model.field(channel_1.Y, { suffix: '_start' })
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { suffix: '_start' })
};
}
else if (fielddef_1.isMeasure(yFieldDef)) {
p.y = {
scale: model.scaleName(channel_1.Y),
field: model.field(channel_1.Y)
else if (fielddef_1.isMeasure(fieldDef)) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef)
};
}
else if (fielddef_1.isDimension(yFieldDef)) {
p.y = {
scale: model.scaleName(channel_1.Y),
field: model.field(channel_1.Y, { binSuffix: '_mid' })
else if (fielddef_1.isDimension(fieldDef)) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { binSuffix: '_mid' })
};
}
return undefined;
}
function y2(fieldDef, scaleName, stack, orient) {
if (orient !== 'horizontal') {
if (stack && channel_1.Y === stack.fieldChannel) {
p.y2 = {
scale: model.scaleName(channel_1.Y),
field: model.field(channel_1.Y, { suffix: '_end' })
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { suffix: '_end' })
};
}
else {
p.y2 = {
scale: model.scaleName(channel_1.Y),
return {
scale: scaleName,
value: 0

@@ -83,7 +112,4 @@ };

}
common_1.applyColorAndOpacity(p, model);
common_1.applyMarkConfig(p, model, ['interpolate', 'tension']);
return p;
return undefined;
}
area.properties = properties;
function labels(model) {

@@ -90,0 +116,0 @@ return undefined;

import {UnitModel} from '../unit';
import {X, Y} from '../../channel';
import {isDimension, isMeasure} from '../../fielddef';
import {isDimension, isMeasure, FieldDef, field} from '../../fielddef';
import {VgValueRef} from '../../vega.schema';
import {applyColorAndOpacity, applyMarkConfig} from '../common';
import {StackProperties} from '../stack';

@@ -14,35 +17,58 @@ export namespace area {

let p: any = {};
const config = model.config();
const orient = model.config().mark.orient;
if (orient !== undefined) {
p.orient = { value: orient };
const _orient = orient(config.mark.orient);
if (_orient) { p.orient = _orient; }
p.x = x(model.encoding().x, model.scaleName(X), model.stack());
const _x2 = x2(model.encoding().x, model.scaleName(X), model.stack(), config.mark.orient);
if (_x2) { p.x2 = _x2; }
p.y = y(model.encoding().y, model.scaleName(Y), model.stack());
const _y2 = y2(model.encoding().y, model.scaleName(Y), model.stack(), config.mark.orient);
if (_y2) { p.y2 = _y2; }
applyColorAndOpacity(p, model);
applyMarkConfig(p, model, ['interpolate', 'tension']);
return p;
}
function orient(orient: string): VgValueRef {
if (orient) {
return { value: orient };
}
return undefined;
}
const stack = model.stack();
const xFieldDef = model.encoding().x;
function x(fieldDef: FieldDef, scaleName: string, stack: StackProperties): VgValueRef {
// x
if (stack && X === stack.fieldChannel) { // Stacked Measure
p.x = {
scale: model.scaleName(X),
field: model.field(X, { suffix: '_start' })
return {
scale: scaleName,
field: field(fieldDef, { suffix: '_start' })
};
} else if (isMeasure(xFieldDef)) { // Measure
p.x = { scale: model.scaleName(X), field: model.field(X) };
} else if (isDimension(xFieldDef)) {
p.x = {
scale: model.scaleName(X),
field: model.field(X, { binSuffix: '_mid' })
} else if (isMeasure(fieldDef)) { // Measure
return { scale: scaleName, field: field(fieldDef) };
} else if (isDimension(fieldDef)) {
return {
scale: scaleName,
field: field(fieldDef, { binSuffix: '_mid' })
};
}
return undefined;
}
function x2(fieldDef: FieldDef, scaleName: string, stack: StackProperties, orient: string): VgValueRef {
// x2
if (orient === 'horizontal') {
if (stack && X === stack.fieldChannel) {
p.x2 = {
scale: model.scaleName(X),
field: model.field(X, { suffix: '_end' })
return {
scale: scaleName,
field: field(fieldDef, { suffix: '_end' })
};
} else {
p.x2 = {
scale: model.scaleName(X),
return {
scale: scaleName,
value: 0

@@ -52,31 +78,36 @@ };

}
return undefined;
}
function y(fieldDef: FieldDef, scaleName: string, stack: StackProperties): VgValueRef {
// y
const yFieldDef = model.encoding().y;
if (stack && Y === stack.fieldChannel) { // Stacked Measure
p.y = {
scale: model.scaleName(Y),
field: model.field(Y, { suffix: '_start' })
return {
scale: scaleName,
field: field(fieldDef, { suffix: '_start' })
};
} else if (isMeasure(yFieldDef)) {
p.y = {
scale: model.scaleName(Y),
field: model.field(Y)
} else if (isMeasure(fieldDef)) {
return {
scale: scaleName,
field: field(fieldDef)
};
} else if (isDimension(yFieldDef)) {
p.y = {
scale: model.scaleName(Y),
field: model.field(Y, { binSuffix: '_mid' })
} else if (isDimension(fieldDef)) {
return {
scale: scaleName,
field: field(fieldDef, { binSuffix: '_mid' })
};
}
return undefined;
}
function y2(fieldDef: FieldDef, scaleName: string, stack: StackProperties, orient: string): VgValueRef {
if (orient !== 'horizontal') { // 'vertical' or undefined are vertical
if (stack && Y === stack.fieldChannel) {
p.y2 = {
scale: model.scaleName(Y),
field: model.field(Y, { suffix: '_end' })
return {
scale: scaleName,
field: field(fieldDef, { suffix: '_end' })
};
} else {
p.y2 = {
scale: model.scaleName(Y),
return {
scale: scaleName,
value: 0

@@ -86,6 +117,3 @@ };

}
applyColorAndOpacity(p, model);
applyMarkConfig(p, model, ['interpolate', 'tension']);
return p;
return undefined;
}

@@ -92,0 +120,0 @@

"use strict";
var channel_1 = require('../../channel');
var fielddef_1 = require('../../fielddef');
var common_1 = require('../common');

@@ -12,35 +13,41 @@ var line;

var p = {};
if (model.has(channel_1.X)) {
p.x = {
scale: model.scaleName(channel_1.X),
field: model.field(channel_1.X, { binSuffix: '_mid' })
};
var config = model.config();
p.x = x(model.encoding().x, model.scaleName(channel_1.X), config);
p.y = y(model.encoding().y, model.scaleName(channel_1.Y), config);
var _size = size(model.encoding().size, config);
if (_size) {
p.strokeWidth = _size;
}
else {
p.x = { value: 0 };
}
if (model.has(channel_1.Y)) {
p.y = {
scale: model.scaleName(channel_1.Y),
field: model.field(channel_1.Y, { binSuffix: '_mid' })
};
}
else {
p.y = { field: { group: 'height' } };
}
common_1.applyColorAndOpacity(p, model);
common_1.applyMarkConfig(p, model, ['interpolate', 'tension']);
var size = sizeValue(model);
if (size) {
p.strokeWidth = { value: size };
}
return p;
}
line.properties = properties;
function sizeValue(model) {
var fieldDef = model.fieldDef(channel_1.SIZE);
function x(fieldDef, scaleName, config) {
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { binSuffix: '_mid' })
};
}
}
return { value: 0 };
}
function y(fieldDef, scaleName, config) {
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { binSuffix: '_mid' })
};
}
}
return { field: { group: 'height' } };
}
function size(fieldDef, config) {
if (fieldDef && fieldDef.value !== undefined) {
return fieldDef.value;
return { value: fieldDef.value };
}
return model.config().mark.lineSize;
return { value: config.mark.lineSize };
}

@@ -47,0 +54,0 @@ function labels(model) {

@@ -0,6 +1,9 @@

import {X, Y} from '../../channel';
import {Config} from '../../config';
import {FieldDef, field} from '../../fielddef';
import {VgValueRef} from '../../vega.schema';
import {applyColorAndOpacity, applyMarkConfig} from '../common';
import {UnitModel} from '../unit';
import {X, Y, SIZE} from '../../channel';
import {applyColorAndOpacity, applyMarkConfig} from '../common';
export namespace line {

@@ -14,40 +17,49 @@ export function markType() {

let p: any = {};
const config = model.config();
// x
if (model.has(X)) {
p.x = {
scale: model.scaleName(X),
field: model.field(X, { binSuffix: '_mid' })
};
} else {
p.x = { value: 0 };
}
p.x = x(model.encoding().x, model.scaleName(X), config);
// y
if (model.has(Y)) {
p.y = {
scale: model.scaleName(Y),
field: model.field(Y, { binSuffix: '_mid' })
};
} else {
p.y = { field: { group: 'height' } };
}
p.y = y(model.encoding().y, model.scaleName(Y), config);
const _size = size(model.encoding().size, config);
if (_size) { p.strokeWidth = _size; }
applyColorAndOpacity(p, model);
applyMarkConfig(p, model, ['interpolate', 'tension']);
return p;
}
// size as a channel is not supported in Vega yet.
const size = sizeValue(model);
if (size) {
p.strokeWidth = { value: size };
function x(fieldDef: FieldDef, scaleName: string, config: Config): VgValueRef {
// x
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: field(fieldDef, { binSuffix: '_mid' })
};
}
// TODO: fieldDef.value (for layering)
}
return p;
return { value: 0 };
}
function sizeValue(model: UnitModel) {
const fieldDef = model.fieldDef(SIZE);
function y(fieldDef: FieldDef, scaleName: string, config: Config): VgValueRef {
// y
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: field(fieldDef, { binSuffix: '_mid' })
};
}
// TODO: fieldDef.value (for layering)
}
return { field: { group: 'height' } };
}
function size(fieldDef: FieldDef, config: Config) {
if (fieldDef && fieldDef.value !== undefined) {
return fieldDef.value;
return { value: fieldDef.value};
}
return model.config().mark.lineSize;
return { value: config.mark.lineSize };
}

@@ -54,0 +66,0 @@

@@ -5,2 +5,3 @@ import {X, Y, SHAPE, SIZE} from '../../channel';

import {Scale} from '../../scale';
import {VgValueRef} from '../../vega.schema';

@@ -32,3 +33,3 @@ import {applyColorAndOpacity} from '../common';

function x(fieldDef: FieldDef, scaleName: string, config: Config): any {
function x(fieldDef: FieldDef, scaleName: string, config: Config): VgValueRef {
// x

@@ -47,3 +48,3 @@ if (fieldDef) {

function y(fieldDef: FieldDef, scaleName: string, config: Config): any {
function y(fieldDef: FieldDef, scaleName: string, config: Config): VgValueRef {
// y

@@ -62,3 +63,3 @@ if (fieldDef) {

function size(fieldDef: ChannelDefWithLegend, scaleName: string, scale: Scale, config: Config): any {
function size(fieldDef: ChannelDefWithLegend, scaleName: string, scale: Scale, config: Config): VgValueRef {
if (fieldDef) {

@@ -77,3 +78,3 @@ if (fieldDef.field) {

function shape(fieldDef: ChannelDefWithLegend, scaleName: string, scale: Scale, config: Config, fixedShape?: string): any {
function shape(fieldDef: ChannelDefWithLegend, scaleName: string, scale: Scale, config: Config, fixedShape?: string): VgValueRef {
// shape

@@ -80,0 +81,0 @@ if (fixedShape) { // square and circle marks

"use strict";
var channel_1 = require('../../channel');
var fielddef_1 = require('../../fielddef');
var common_1 = require('../common');

@@ -12,38 +13,13 @@ var tick;

var p = {};
if (model.has(channel_1.X)) {
p.xc = {
scale: model.scaleName(channel_1.X),
field: model.field(channel_1.X, { binSuffix: '_mid' })
};
var config = model.config();
p.xc = x(model.encoding().x, model.scaleName(channel_1.X), config);
p.yc = y(model.encoding().y, model.scaleName(channel_1.Y), config);
if (config.mark.orient === 'horizontal') {
p.width = size(model.encoding().size, model.scaleName(channel_1.SIZE), config, (model.scale(channel_1.X) || {}).bandSize);
p.height = { value: config.mark.tickThickness };
}
else {
p.xc = { value: model.config().scale.bandSize / 2 };
p.width = { value: config.mark.tickThickness };
p.height = size(model.encoding().size, model.scaleName(channel_1.SIZE), config, (model.scale(channel_1.Y) || {}).bandSize);
}
if (model.has(channel_1.Y)) {
p.yc = {
scale: model.scaleName(channel_1.Y),
field: model.field(channel_1.Y, { binSuffix: '_mid' })
};
}
else {
p.yc = { value: model.config().scale.bandSize / 2 };
}
if (model.config().mark.orient === 'horizontal') {
p.width = model.has(channel_1.SIZE) ? {
scale: model.scaleName(channel_1.SIZE),
field: model.field(channel_1.SIZE)
} : {
value: sizeValue(model, channel_1.X)
};
p.height = { value: model.config().mark.tickThickness };
}
else {
p.width = { value: model.config().mark.tickThickness };
p.height = model.has(channel_1.SIZE) ? {
scale: model.scaleName(channel_1.SIZE),
field: model.field(channel_1.SIZE)
} : {
value: sizeValue(model, channel_1.Y)
};
}
common_1.applyColorAndOpacity(p, model);

@@ -53,17 +29,50 @@ return p;

tick.properties = properties;
function sizeValue(model, channel) {
var fieldDef = model.fieldDef(channel_1.SIZE);
if (fieldDef && fieldDef.value !== undefined) {
return fieldDef.value;
function x(fieldDef, scaleName, config) {
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { binSuffix: '_mid' })
};
}
else if (fieldDef.value) {
return { value: fieldDef.value };
}
}
var scaleConfig = model.config().scale;
var markConfig = model.config().mark;
if (markConfig.tickSize) {
return markConfig.tickSize;
return { value: config.scale.bandSize / 2 };
}
function y(fieldDef, scaleName, config) {
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: fielddef_1.field(fieldDef, { binSuffix: '_mid' })
};
}
else if (fieldDef.value) {
return { value: fieldDef.value };
}
}
var bandSize = model.has(channel) ?
model.scale(channel).bandSize :
scaleConfig.bandSize;
return bandSize / 1.5;
return { value: config.scale.bandSize / 2 };
}
function size(fieldDef, scaleName, config, scaleBandSize) {
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: fieldDef.field
};
}
else if (fieldDef.value !== undefined) {
return { value: fieldDef.value };
}
}
if (config.mark.tickSize) {
return { value: config.mark.tickSize };
}
var bandSize = scaleBandSize !== undefined ?
scaleBandSize :
config.scale.bandSize;
return { value: bandSize / 1.5 };
}
function labels(model) {

@@ -70,0 +79,0 @@ return undefined;

@@ -1,2 +0,5 @@

import {X, Y, SIZE, Channel} from '../../channel';
import {X, Y, SIZE} from '../../channel';
import {FieldDef, field} from '../../fielddef';
import {Config} from '../../config';
import {VgValueRef} from '../../vega.schema';

@@ -13,42 +16,16 @@ import {UnitModel} from '../unit';

let p: any = {};
const config = model.config();
// TODO: support explicit value
// x
if (model.has(X)) {
p.xc = {
scale: model.scaleName(X),
field: model.field(X, { binSuffix: '_mid' })
};
} else {
p.xc = { value: model.config().scale.bandSize / 2 };
}
p.xc = x(model.encoding().x, model.scaleName(X), config);
// y
if (model.has(Y)) {
p.yc = {
scale: model.scaleName(Y),
field: model.field(Y, { binSuffix: '_mid' })
};
} else {
p.yc = { value: model.config().scale.bandSize / 2 };
}
p.yc = y(model.encoding().y, model.scaleName(Y), config);
if (model.config().mark.orient === 'horizontal') {
p.width = model.has(SIZE)? {
scale: model.scaleName(SIZE),
field: model.field(SIZE)
} : {
value: sizeValue(model, X)
};
p.height = { value: model.config().mark.tickThickness };
if (config.mark.orient === 'horizontal') {
p.width = size(model.encoding().size, model.scaleName(SIZE), config, (model.scale(X) || {}).bandSize);
p.height = { value: config.mark.tickThickness };
} else {
p.width = { value: model.config().mark.tickThickness };
p.height = model.has(SIZE)? {
scale: model.scaleName(SIZE),
field: model.field(SIZE)
} : {
value: sizeValue(model, Y)
};
p.width = { value: config.mark.tickThickness };
p.height = size(model.encoding().size, model.scaleName(SIZE), config, (model.scale(Y) || {}).bandSize);
}

@@ -60,18 +37,50 @@

function sizeValue(model: UnitModel, channel: Channel) {
const fieldDef = model.fieldDef(SIZE);
if (fieldDef && fieldDef.value !== undefined) {
return fieldDef.value;
function x(fieldDef: FieldDef, scaleName: string, config: Config): VgValueRef {
// x
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: field(fieldDef, { binSuffix: '_mid' })
};
} else if (fieldDef.value) {
return {value: fieldDef.value};
}
}
return { value: config.scale.bandSize / 2 };
}
const scaleConfig = model.config().scale;
const markConfig = model.config().mark;
function y(fieldDef: FieldDef, scaleName: string, config: Config): VgValueRef {
// y
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: field(fieldDef, { binSuffix: '_mid' })
};
} else if (fieldDef.value) {
return {value: fieldDef.value};
}
}
return { value: config.scale.bandSize / 2 };
}
if (markConfig.tickSize) {
return markConfig.tickSize;
function size(fieldDef: FieldDef, scaleName: string, config: Config, scaleBandSize: number): VgValueRef {
if (fieldDef) {
if (fieldDef.field) {
return {
scale: scaleName,
field: fieldDef.field
};
} else if (fieldDef.value !== undefined) {
return { value: fieldDef.value };
}
}
const bandSize = model.has(channel) ?
model.scale(channel).bandSize :
scaleConfig.bandSize;
return bandSize / 1.5;
if (config.mark.tickSize) {
return { value: config.mark.tickSize };
}
const bandSize = scaleBandSize !== undefined ?
scaleBandSize :
config.scale.bandSize;
return { value: bandSize / 1.5 };
}

@@ -78,0 +87,0 @@

@@ -9,3 +9,3 @@ // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#11-ambient-declarations

import {FieldDef, field, isMeasure} from '../fielddef';
import {Mark, BAR, TEXT as TEXT_MARK, RULE, TICK} from '../mark';
import {Mark, BAR, TEXT as TEXTMARK, RULE, TICK} from '../mark';
import {Scale, ScaleType, NiceTime} from '../scale';

@@ -385,3 +385,3 @@ import {TimeUnit} from '../timeunit';

return {range: [model.config().mark.barThinSize, model.scale(dimension).bandSize]};
} else if (unitModel.mark() === TEXT_MARK) {
} else if (unitModel.mark() === TEXTMARK) {
return {range: scaleConfig.fontSizeRange };

@@ -388,0 +388,0 @@ } else if (unitModel.mark() === RULE) {

@@ -13,11 +13,22 @@ import {ScaleConfig, FacetScaleConfig, defaultScaleConfig, defaultFacetScaleConfig} from './scale';

/**
* The fill color.
* @format color
*/
fill?: string;
/** The fill opacity (value between [0,1]). */
fillOpacity?: number;
/** The stroke color. */
stroke?: string;
/** The stroke opacity (value between [0,1]). */
strokeOpacity?: number;
/** The stroke width, in pixels. */
strokeWidth?: number;
strokeOpacity?: number;
/** An array of alternating stroke, space lengths for creating dashed or dotted lines. */
strokeDash?: number[];
/** The offset (in pixels) into which to begin drawing with the stroke dash array. */

@@ -38,5 +49,12 @@ strokeDashOffset?: number;

export interface FacetConfig {
/** Facet Scale Config */
scale?: FacetScaleConfig;
/** Facet Axis Config */
axis?: AxisConfig;
/** Facet Grid Config */
grid?: FacetGridConfig;
/** Facet Cell Config */
cell?: CellConfig;

@@ -143,2 +161,3 @@ }

filled?: boolean;
/**

@@ -149,2 +168,3 @@ * Default color.

color?: string;
/**

@@ -155,2 +175,3 @@ * Default Fill Color. This has higher precedence than config.color

fill?: string;
/**

@@ -162,3 +183,2 @@ * Default Stroke Color. This has higher precedence than config.color

// ---------- Opacity ----------

@@ -188,2 +208,3 @@ /**

strokeWidth?: number;
/**

@@ -193,2 +214,3 @@ * An array of alternating stroke, space lengths for creating dashed or dotted lines.

strokeDash?: number[];
/**

@@ -244,2 +266,3 @@ * The offset (in pixels) into which to begin drawing with the stroke dash array.

barSize?: number;
/**

@@ -371,2 +394,3 @@ * The size of the bars on continuous scales.

numberFormat?: string;
/**

@@ -377,8 +401,18 @@ * Default datetime format for axis and legend labels. The format can be set directly on each axis and legend.

/** Cell Config */
cell?: CellConfig;
/** Mark Config */
mark?: MarkConfig;
/** Scale Config */
scale?: ScaleConfig;
/** Axis Config */
axis?: AxisConfig;
/** Legend Config */
legend?: LegendConfig;
/** Facet Config */
facet?: FacetConfig;

@@ -385,0 +419,0 @@ }

@@ -14,2 +14,8 @@ /*

formatType?: DataFormat;
/**
* A URL from which to load the data set. Use the formatType property
* to ensure the loaded data is correctly parsed.
*/
url?: string;

@@ -16,0 +22,0 @@ /**

@@ -8,13 +8,65 @@ // utility for encoding mapping

export interface UnitEncoding {
/**
* X coordinates for `point`, `circle`, `square`,
* `line`, `rule`, `text`, and `tick`
* (or to width and height for `bar` and `area` marks).
*/
x?: PositionChannelDef;
/**
* Y coordinates for `point`, `circle`, `square`,
* `line`, `rule`, `text`, and `tick`
* (or to width and height for `bar` and `area` marks).
*/
y?: PositionChannelDef;
/**
* Color of the marks – either fill or stroke color based on mark type.
* (By default, fill color for `area`, `bar`, `tick`, `text`, `circle`, and `square` /
* stroke color for `line` and `point`.)
*/
color?: ChannelDefWithLegend;
/**
* Opacity of the marks – either can be a value or in a range.
*/
opacity?: ChannelDefWithLegend;
/**
* Size of the mark.
* - For `point`, `square` and `circle`
* – the symbol size, or pixel area of the mark.
* - For `bar` and `tick` – the bar and tick's size.
* - For `text` – the text's font size.
* - Size is currently unsupported for `line` and `area`.
*/
size?: ChannelDefWithLegend;
/**
* The symbol's shape (only for `point` marks). The supported values are
* `"circle"` (default), `"square"`, `"cross"`, `"diamond"`, `"triangle-up"`,
* or `"triangle-down"`.
*/
shape?: ChannelDefWithLegend; // TODO: maybe distinguish ordinal-only
/**
* Additional levels of detail for grouping data in aggregate views and
* in line and area marks without mapping data to a specific visual channel.
*/
detail?: FieldDef | FieldDef[];
/**
* Text of the `text` mark.
*/
text?: FieldDef;
label?: FieldDef;
/**
* Order of data points in line marks.
*/
path?: OrderChannelDef | OrderChannelDef[];
/**
* Layer order for non-stacked marks, or stack order for stacked marks.
*/
order?: OrderChannelDef | OrderChannelDef[];

@@ -25,3 +77,10 @@ }

export interface Encoding extends UnitEncoding {
/**
* Vertical facets for trellis plots.
*/
row?: FacetChannelDef;
/**
* Horizontal facets for trellis plots.
*/
column?: FacetChannelDef;

@@ -28,0 +87,0 @@ }

@@ -19,12 +19,42 @@ // utility for a field definition object

export interface FieldDef {
/**
* Name of the field from which to pull a data value.
*/
field?: string;
/**
* The encoded field's type of measurement. This can be either a full type
* name (`"quantitative"`, `"temporal"`, `"ordinal"`, and `"nominal"`)
* or an initial character of the type name (`"Q"`, `"T"`, `"O"`, `"N"`).
* This property is case insensitive.
*/
type?: Type;
/**
* A constant value in visual domain.
*/
value?: number | string | boolean;
// function
/**
* Time unit for a `temporal` field (e.g., `year`, `yearmonth`, `month`, `hour`).
*/
timeUnit?: TimeUnit;
/**
* Flag for binning a `quantitative` field, or a bin property object
* for binning parameters.
*/
bin?: boolean | Bin;
/**
* Aggregation function for the field
* (e.g., `mean`, `sum`, `median`, `min`, `max`, `count`).
*/
aggregate?: AggregateOp;
// metadata
/**
* Title for axis or legend.
*/
title?: string;

@@ -31,0 +61,0 @@ }

@@ -19,6 +19,26 @@ /* Utilities for a Vega-Lite specificiation */

export interface BaseSpec {
/**
* Name of the visualization for later reference.
*/
name?: string;
/**
* An optional description of this mark for commenting purpose.
* This property has no effect on the output visualization.
*/
description?: string;
/**
* An object describing the data source
*/
data?: Data;
/**
* An object describing filter and new field calculation.
*/
transform?: Transform;
/**
* Configuration object
*/
config?: Config;

@@ -28,3 +48,12 @@ }

export interface UnitSpec extends BaseSpec {
/**
* The mark type.
* One of `"bar"`, `"circle"`, `"square"`, `"tick"`, `"line"`,
* `"area"`, `"point"`, `"rule"`, and `"text"`.
*/
mark: Mark;
/**
* A key-value mapping between encoding channels and definition of fields.
*/
encoding?: UnitEncoding;

@@ -44,5 +73,11 @@ }

/**
* A name for the specification. The name is used to annotate marks, scale names, and more.
* The mark type.
* One of `"bar"`, `"circle"`, `"square"`, `"tick"`, `"line"`,
* `"area"`, `"point"`, `"rule"`, and `"text"`.
*/
mark: Mark;
/**
* A key-value mapping between encoding channels and definition of fields.
*/
encoding?: Encoding;

@@ -57,2 +92,5 @@ }

export interface LayerSpec extends BaseSpec {
/**
* Unit specs that will be layered.
*/
layers: UnitSpec[];

@@ -59,0 +97,0 @@ }

@@ -0,1 +1,4 @@

/**
* Top-level transform object.
*/
export interface Transform {

@@ -16,3 +19,5 @@ /**

// TODO move all Vega interfaces to one central position
/**
* Formula object for calculate.
*/
export interface Formula {

@@ -19,0 +24,0 @@ /**

@@ -28,2 +28,15 @@ import {isArray} from './util';

export type VgValueRef = {
value?: any,
field?: string | {
datum?: string,
group?: string,
parent?: string
} ,
scale?: string, // TODO: object
mult?: number,
offset?: number,
band?: boolean
}
export type UnionedDomain = {

@@ -30,0 +43,0 @@ fields: VgDataRef[]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc