vega-lite-api
Version:
A JavaScript API for Vega-Lite.
322 lines (283 loc) • 6.61 kB
JavaScript
import {BaseObject, annotate, assign, copy, flat, get, init, isArray, isIterable, isString, merge, raw, set} from './__util__';
import {lookupData} from './lookupData';
import {mark} from './mark';
import {layer} from './layer';
import {hconcat} from './hconcat';
import {vconcat} from './vconcat';
import {_facet} from './_facet';
import {_repeat} from './_repeat';
import {render, toSpec, toString, toView} from './__view__';
class Data extends BaseObject {
constructor(...args) {
super();
init(this);
if (args[0] !== undefined) set(this, "data", isArray(args[0]) ? {values: raw(args[0])} : isIterable(args[0]) ? {values: raw(args[0])} : isString(args[0]) ? {url: args[0]} : args[0]);
}
align(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "align", value);
return obj;
} else {
return get(this, "align");
}
}
autosize(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "autosize", value);
return obj;
} else {
return get(this, "autosize");
}
}
background(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "background", value);
return obj;
} else {
return get(this, "background");
}
}
bounds(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "bounds", value);
return obj;
} else {
return get(this, "bounds");
}
}
center(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "center", value);
return obj;
} else {
return get(this, "center");
}
}
config(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "config", value);
return obj;
} else {
return get(this, "config");
}
}
datasets(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "datasets", value);
return obj;
} else {
return get(this, "datasets");
}
}
description(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "description", value);
return obj;
} else {
return get(this, "description");
}
}
height(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "height", value);
return obj;
} else {
return get(this, "height");
}
}
name(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "name", value);
return obj;
} else {
return get(this, "name");
}
}
padding(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "padding", value);
return obj;
} else {
return get(this, "padding");
}
}
resolve(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "resolve", value);
return obj;
} else {
return get(this, "resolve");
}
}
spacing(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "spacing", value);
return obj;
} else {
return get(this, "spacing");
}
}
title(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "title", value);
return obj;
} else {
return get(this, "title");
}
}
usermeta(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "usermeta", value);
return obj;
} else {
return get(this, "usermeta");
}
}
view(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "view", value);
return obj;
} else {
return get(this, "view");
}
}
width(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "width", value);
return obj;
} else {
return get(this, "width");
}
}
select(...value) {
if (arguments.length) {
const obj = copy(this);
value = flat(value);
value = annotate(value, 1);
set(obj, "params", value);
return obj;
} else {
return get(this, "params");
}
}
project(value) {
if (arguments.length) {
const obj = copy(this);
set(obj, "projection", value);
return obj;
} else {
return get(this, "projection");
}
}
encode(...values) {
if (values.length === 1 && Array.isArray(values[0])) {
values = values[0];
}
if (values.length) {
const val = get(this, "encoding");
const obj = copy(this);
if (val) values = [val].concat(values);
set(obj, "encoding", merge(1, values));
return obj;
} else {
return get(this, "encoding");
}
}
data(value) {
if (arguments.length) {
const obj = copy(this);
value = isArray(value) ? {values: raw(value)} : isIterable(value) ? {values: raw(value)} : isString(value) ? {url: value} : value;
set(obj, "data", value);
return obj;
} else {
return get(this, "data");
}
}
params(...value) {
if (arguments.length) {
const obj = copy(this);
value = flat(value);
value = annotate(value, 1);
set(obj, "params", value);
return obj;
} else {
return get(this, "params");
}
}
transform(...value) {
if (arguments.length) {
const obj = copy(this);
value = flat(value);
set(obj, "transform", value);
return obj;
} else {
return get(this, "transform");
}
}
fields(...values) {
let obj = lookupData();
obj = assign(obj, this);
return obj.fields(...values);
}
key(...values) {
let obj = lookupData();
obj = assign(obj, this);
return obj.key(...values);
}
mark(...values) {
const obj = mark(...values);
return assign(obj, this);
}
layer(...values) {
const obj = layer(...values);
return assign(obj, this);
}
hconcat(...values) {
const obj = hconcat(...values);
return assign(obj, this);
}
vconcat(...values) {
const obj = vconcat(...values);
return assign(obj, this);
}
facet(...values) {
const obj = _facet(...values);
return assign(obj, this);
}
repeat(...values) {
const obj = _repeat(...values);
return assign(obj, this);
}
render(...values) {
return render.apply(this, values);
}
toView(...values) {
return toView.apply(this, values);
}
toSpec(...values) {
return toSpec.apply(this, values);
}
toString(...values) {
return toString.apply(this, values);
}
}
export function data(...args) {
return new Data(...args);
}