Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
groups.forEach(g => {
const n = g.length;
if (n <= dof) {
pulse.dataflow.warn('Skipping regression with more parameters than data points.');
return;
}
const model = fit(g, _.x, _.y, order);
if (_.params) {
// if parameter vectors requested return those
values.push(ingest({
keys: g.dims,
coef: model.coef,
rSquared: model.rSquared
}));
return;
}
const dom = domain || extent(g, _.x),
add = p => {
const t = {};
for (let i=0; i
prototype.transform = function(_, pulse) {
var out = pulse.fork(pulse.ALL),
list = SortedList(tupleid, this.value, out.materialize(out.ADD).add),
sort = _.sort,
mod = pulse.changed() || (sort &&
(_.modified('sort') || pulse.modified(sort.fields)));
out.visit(out.REM, list.remove);
this.modified(mod);
this.value = out.source = list.data(stableCompare(sort), mod);
// propagate tree root if defined
if (pulse.source && pulse.source.root) {
this.value.root = pulse.source.root;
}
return out;
};
export default function Scale(params) {
Transform.call(this, null, params);
this.modified(true); // always treat as modified
}
var o = trans ? {} : item,
offset = item.mark.def.offset,
orient = item.mark.def.orient,
width = group.width,
height = group.height; // TODO fallback to global w,h?
if (dl.isArray(offset)) {
var ofx = offset[0],
ofy = offset[1];
switch (orient) {
case 'left': { Tuple.set(o, 'x', -ofx); Tuple.set(o, 'y', ofy); break; }
case 'right': { Tuple.set(o, 'x', width + ofx); Tuple.set(o, 'y', ofy); break; }
case 'bottom': { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', height + ofy); break; }
case 'top': { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', -ofy); break; }
default: { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', ofy); }
}
} else {
if (dl.isObject(offset)) {
offset = -group.scale(offset.scale)(offset.value);
}
switch (orient) {
case 'left': { Tuple.set(o, 'x', -offset); Tuple.set(o, 'y', 0); break; }
case 'right': { Tuple.set(o, 'x', width + offset); Tuple.set(o, 'y', 0); break; }
case 'bottom': { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', height + offset); break; }
case 'top': { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', -offset); break; }
default: { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', 0); }
}
}
if (trans) trans.interpolate(item, o);
prototype.interpolate = function(item, values) {
var key, curr, next, interp, list = null;
for (key in values) {
curr = item[key];
next = values[key];
if (curr !== next) {
if (skip[key] || curr === undefined) {
// skip interpolation for specific keys or undefined start values
Tuple.set(item, key, next);
} else if (typeof curr === 'number' && !isFinite(curr)) {
// for NaN or infinite numeric values, skip to final value
Tuple.set(item, key, next);
} else {
// otherwise lookup interpolator
interp = d3.interpolate(curr, next);
interp.property = key;
(list || (list=[])).push(interp);
}
}
}
if (list === null && item.status === Status.EXIT) {
list = []; // ensure exiting items are included
}
var dl = require('datalib'),
log = require('vega-logging'),
df = require('vega-dataflow'),
Node = df.Node, // jshint ignore:line
Tuple = df.Tuple,
Deps = df.Dependencies;
var Types = {
INSERT: "insert",
REMOVE: "remove",
UPSERT: "upsert",
TOGGLE: "toggle",
CLEAR: "clear"
};
var EMPTY = [];
function filter(fields, value, src, dest) {
if ((fields = dl.array(fields)) && !fields.length) {
fields = dl.isObject(value) ? dl.keys(value) : ['data'];
}
var dl = require('datalib'),
df = require('vega-dataflow'),
Node = df.Node, // jshint ignore:line
Deps = df.Dependencies,
Tuple = df.Tuple,
Collector = df.Collector,
log = require('vega-logging'),
Builder = require('./Builder'),
Scale = require('./Scale'),
parseAxes = require('../parse/axes'),
parseLegends = require('../parse/legends');
function GroupBuilder() {
this._children = {};
this._scaler = null;
this._recursor = null;
this._scales = {};
this.scale = scale.bind(this);
return arguments.length ? this.init.apply(this, arguments) : this;
}
var dl = require('datalib'),
log = require('vega-logging'),
Item = require('vega-scenegraph').Item,
df = require('vega-dataflow'),
Node = df.Node, // jshint ignore:line
Deps = df.Dependencies,
Tuple = df.Tuple,
ChangeSet = df.ChangeSet,
Sentinel = {},
Encoder = require('./Encoder'),
Bounder = require('./Bounder'),
parseData = require('../parse/data');
function Builder() {
return arguments.length ? this.init.apply(this, arguments) : this;
}
var Status = Builder.STATUS = {
ENTER: 'enter',
UPDATE: 'update',
EXIT: 'exit'
};
var d3 = require('d3'),
dl = require('datalib'),
log = require('vega-logging'),
Tuple = require('vega-dataflow').Tuple;
var DEPS = ["signals", "scales", "data", "fields"];
function properties(model, mark, spec) {
var config = model.config(),
code = "",
names = dl.keys(spec),
exprs = [], // parsed expressions injected in the generated code
i, len, name, ref, vars = {},
deps = {
signals: {},
scales: {},
data: {},
fields: {},
nested: [],
_nRefs: {}, // Temp stash to de-dupe nested refs.
function update(t) {
var p, idx;
if (res.length < num) {
res.push(t);
} else {
idx = ~~((cnt + 1) * random());
if (idx < res.length && idx >= cap) {
p = res[idx];
if (map[tupleid(p)]) out.rem.push(p); // eviction
res[idx] = t;
}
}
++cnt;
}