Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "vega", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Vega Runtime", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
vg = (function(d3, topojson) { // take d3 & topojson as imports | ||
var vg = { | ||
version: "1.3.0", // semantic versioning | ||
version: "1.3.1", // semantic versioning | ||
d3: d3, // stash d3 for use in property functions | ||
topojson: topojson // stash topojson similarly | ||
}; |
@@ -22,17 +22,7 @@ vg.Model = (function() { | ||
keys = this._defs.data.defs.map(vg.accessor("name")), | ||
i, j, len, k, src; | ||
for (i=0, len=keys.length; i<len; ++i) { | ||
len = keys.length, i, k; | ||
for (i=0; i<len; ++i) { | ||
if (!data[k=keys[i]]) continue; | ||
this._data[k] = tx[k] | ||
? tx[k](data[k], this._data, this._defs.marks) | ||
: data[k]; | ||
src = this._defs.data.source[k] || []; | ||
for (j=0; j<src.length; ++j) { | ||
this._data[src[j]] = tx[src[j]] | ||
? tx[src[j]](this._data[k], this._data, this._defs.marks) | ||
: this._data[k] | ||
} | ||
this.ingest(k, tx, data[k]); | ||
} | ||
@@ -43,2 +33,20 @@ | ||
prototype.ingest = function(name, tx, input) { | ||
this._data[name] = tx[name] | ||
? tx[name](input, this._data, this._defs.marks) | ||
: input; | ||
this.dependencies(name, tx); | ||
}; | ||
prototype.dependencies = function(name, tx) { | ||
var source = this._defs.data.source[name], | ||
data = this._data[name], | ||
n = source ? source.length : 0, i, x; | ||
for (i=0; i<n; ++i) { | ||
x = vg_data_duplicate(data); | ||
if (vg.isTree(data)) vg_make_tree(x); | ||
this.ingest(source[i], tx, x); | ||
} | ||
}; | ||
prototype.width = function(width) { | ||
@@ -85,3 +93,3 @@ if (this._defs) this._defs.width = width; | ||
vg.scene.visit(this._scene, function(item) { | ||
if (item.axes) item.axes.forEach(function(s) { s.reset(); }); | ||
if (item.axes) item.axes.forEach(function(axis) { axis.reset(); }); | ||
}); | ||
@@ -88,0 +96,0 @@ } |
vg.data = {}; | ||
vg.data.ingestAll = function(data) { | ||
if (vg.isTree(data)) { | ||
var t = vg.data.ingestTree(data[0], data.children); | ||
t.__vgtree__ = true; | ||
t.nodes = function() { return vg_tree_nodes(this, []); } | ||
return t; | ||
} else { | ||
return data.map(vg.data.ingest); | ||
} | ||
return vg.isTree(data) | ||
? vg_make_tree(vg.data.ingestTree(data[0], data.children)) | ||
: data.map(vg.data.ingest); | ||
}; | ||
@@ -33,2 +28,9 @@ | ||
function vg_make_tree(d) { | ||
d.__vgtree__ = true; | ||
d.nodes = function() { return vg_tree_nodes(this, []); }; | ||
return d; | ||
} | ||
function vg_tree_nodes(root, nodes) { | ||
@@ -40,4 +42,20 @@ var c = root.values, | ||
return nodes; | ||
}; | ||
} | ||
function vg_data_duplicate(d) { | ||
var x=d, i, n; | ||
if (vg.isArray(d)) { | ||
x = []; | ||
for (i=0, n=d.length; i<n; ++i) { | ||
x.push(vg_data_duplicate(d[i])); | ||
} | ||
} else if (vg.isObject(d)) { | ||
x = {}; | ||
for (i in d) { | ||
x[i] = vg_data_duplicate(d[i]); | ||
} | ||
} | ||
return x; | ||
} | ||
vg.data.mapper = function(func) { | ||
@@ -44,0 +62,0 @@ return function(data) { |
@@ -33,3 +33,10 @@ vg.data.cross = function() { | ||
cross.output = function(map) { | ||
vg.keys(output).forEach(function(k) { | ||
if (map[k] !== undefined) { output[k] = map[k]; } | ||
}); | ||
return cross; | ||
}; | ||
return cross; | ||
}; | ||
}; |
@@ -22,3 +22,3 @@ vg.data.facet = function() { | ||
}); | ||
if (sort) obj.values.sort(sort); | ||
if (sort) sort(obj.values); | ||
return result; | ||
@@ -47,3 +47,3 @@ } | ||
for (i=0, len=vals.length; i<len; ++i) { | ||
vals[i].values.sort(sort); | ||
sort(vals[i].values); | ||
} | ||
@@ -61,3 +61,3 @@ } | ||
facet.sort = function(s) { | ||
sort = vg.comparator(s); | ||
sort = vg.data.sort().by(s); | ||
return facet; | ||
@@ -64,0 +64,0 @@ }; |
@@ -16,3 +16,3 @@ vg.parse.properties = (function() { | ||
if (vars.x2) { | ||
if (vars.x2 && !(vars.width && vars.x)) { | ||
if (vars.width) { | ||
@@ -27,3 +27,3 @@ code += "\n o.x = (o.x2 - o.width);"; | ||
if (vars.y2) { | ||
if (vars.y2 && !(vars.height && vars.y)) { | ||
if (vars.height) { | ||
@@ -30,0 +30,0 @@ code += "\n o.y = (o.y2 - o.height);"; |
@@ -8,2 +8,4 @@ vg.scene.bounds = (function() { | ||
halfpi = Math.PI / 2, | ||
sqrt3 = Math.sqrt(3), | ||
tan30 = Math.tan(30 * Math.PI / 180), | ||
gfx = null; | ||
@@ -10,0 +12,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
494869
12429
7