Comparing version 0.0.13 to 0.0.14
@@ -28,16 +28,14 @@ cube.piece.type.area = function(board) { | ||
.attr("class", "time") | ||
.text("Time Range:") | ||
.append("select") | ||
.on("change.area", area.edit) | ||
.on("focus.area", area.focus) | ||
.on("blur.area", area.blur); | ||
.text("Time Range:"); | ||
time.selectAll("option") | ||
time.append("input"); | ||
time.append("select").selectAll("option") | ||
.data([ | ||
{description: "1 Day / 5-Minute", value: 864e5 + "/" + 3e5}, | ||
{description: "3 Days / 5-Minute", value: 3 * 864e5 + "/" + 3e5}, | ||
{description: "7 Days / Hour", value: 7 * 864e5 + "/" + 36e5}, | ||
{description: "14 Days / Hour", value: 14 * 864e5 + "/" + 36e5}, | ||
{description: "30 Days / Hour", value: 30 * 864e5 + "/" + 36e5}, | ||
{description: "30 Days / Day", value: 30 * 864e5 + "/" + 864e5} | ||
{description: "Seconds @ 20", value: 2e4}, | ||
{description: "Minutes @ 5", value: 3e5}, | ||
{description: "Hours", value: 36e5}, | ||
{description: "Days", value: 864e5}, | ||
{description: "Weeks", value: 6048e5}, | ||
{description: "Months", value: 2592e6} | ||
]) | ||
@@ -48,2 +46,7 @@ .enter().append("option") | ||
.text(function(d) { return d.description; }); | ||
time.selectAll("input,select") | ||
.on("change.area", area.edit) | ||
.on("focus.area", area.focus) | ||
.on("blur.area", area.blur) | ||
} else { | ||
@@ -91,3 +94,3 @@ var m = [6, 40, 14, 10], // top, right, bottom, left margins | ||
transition.select(".time select") | ||
.style("width", innerSize[0] - 100 + "px"); | ||
.style("width", innerSize[0] - 174 + "px"); | ||
@@ -153,6 +156,7 @@ } else { | ||
function serialize(json) { | ||
var t = time.property("value").split("/"); | ||
var step = +time.select("select").property("value"), | ||
range = time.select("input").property("value") * cube_piece_areaMultipler(step); | ||
json.type = "area"; | ||
json.query = query.property("value"); | ||
json.time = {range: +t[0], step: +t[1]}; | ||
json.time = {range: range, step: step}; | ||
} | ||
@@ -163,3 +167,4 @@ | ||
query.property("value", json.query); | ||
time.property("value", json.time.range + "/" + json.time.step); | ||
time.select("input").property("value", json.time.range / cube_piece_areaMultipler(json.time.step)); | ||
time.select("select").property("value", json.time.step); | ||
} else { | ||
@@ -243,2 +248,8 @@ var dt1 = json.time.step, | ||
function cube_piece_areaMultipler(step) { | ||
return step / (step === 2e4 ? 20 | ||
: step === 3e5 ? 5 | ||
: 1); | ||
} | ||
function cube_piece_format(domain) { | ||
@@ -245,0 +256,0 @@ var prefix = d3.formatPrefix(Math.max(-domain[0], domain[1]), 2); |
@@ -29,16 +29,14 @@ cube.piece.type.sum = function(board) { | ||
.attr("class", "time") | ||
.text("Time Range:") | ||
.append("select") | ||
.on("change.sum", sum.edit) | ||
.on("focus.sum", sum.focus) | ||
.on("blur.sum", sum.blur); | ||
.text("Time Range:"); | ||
time.selectAll("option") | ||
time.append("input"); | ||
time.append("select").selectAll("option") | ||
.data([ | ||
{description: "5 Minutes / 5-Minute", value: 3e5 + "/" + 3e5}, | ||
{description: "1 Hour / 5-Minute", value: 36e5 + "/" + 3e5}, | ||
{description: "1 Hour / Hour", value: 36e5 + "/" + 36e5}, | ||
{description: "1 Day / 5-Minute", value: 864e5 + "/" + 3e5}, | ||
{description: "1 Day / Hour", value: 864e5 + "/" + 36e5}, | ||
{description: "1 Day / Day", value: 864e5 + "/" + 864e5} | ||
{description: "Seconds @ 20", value: 2e4}, | ||
{description: "Minutes @ 5", value: 3e5}, | ||
{description: "Hours", value: 36e5}, | ||
{description: "Days", value: 864e5}, | ||
{description: "Weeks", value: 6048e5}, | ||
{description: "Months", value: 2592e6} | ||
]) | ||
@@ -49,2 +47,7 @@ .enter().append("option") | ||
.text(function(d) { return d.description; }); | ||
time.selectAll("input,select") | ||
.on("change.sum", sum.edit) | ||
.on("focus.sum", sum.focus) | ||
.on("blur.sum", sum.blur) | ||
} | ||
@@ -62,3 +65,3 @@ | ||
transition.select(".time select") | ||
.style("width", innerSize[0] - 100 + "px"); | ||
.style("width", innerSize[0] - 174 + "px"); | ||
} else { | ||
@@ -83,6 +86,7 @@ transition | ||
function serialize(json) { | ||
var t = time.property("value").split("/"); | ||
var step = +time.select("select").property("value"), | ||
range = time.select("input").property("value") * cube_piece_areaMultipler(step); | ||
json.type = "sum"; | ||
json.query = query.property("value"); | ||
json.time = {range: +t[0], step: +t[1]}; | ||
json.time = {range: range, step: step}; | ||
} | ||
@@ -94,3 +98,4 @@ | ||
query.property("value", json.query); | ||
time.property("value", json.time.range + "/" + json.time.step); | ||
time.select("input").property("value", json.time.range / cube_piece_areaMultipler(json.time.step)); | ||
time.select("select").property("value", json.time.step); | ||
} else { | ||
@@ -97,0 +102,0 @@ var dt = json.time.step, |
@@ -61,9 +61,8 @@ var util = require("util"), | ||
find(start, stop, tier, callback); | ||
find(start, stop, tier, reduce.pyramidal && tier.next, callback); | ||
// The metric is computed recursively, reusing the above variables. | ||
function find(start, stop, tier, callback) { | ||
function find(start, stop, tier, pyramidal, callback) { | ||
var compute = group ? (group.multi ? computeGroups : computeGroup) | ||
: tier.next && reduce.pyramidal ? computePyramidal | ||
: computeFlat; | ||
: pyramidal ? computePyramidal : computeFlat; | ||
@@ -169,3 +168,3 @@ // Query for the desired metric in the cache. | ||
var bins = {}; | ||
find(start, stop, tier.next, function(time, value) { | ||
find(start, stop, tier.next, false, function(time, value) { | ||
var bin = bins[time = tier.floor(time)] || (bins[time] = {size: tier.size(time), values: []}); | ||
@@ -172,0 +171,0 @@ if (bin.values.push(value) === bin.size) { |
var tiers = module.exports = {}; | ||
var second = 1000, | ||
second20 = 20 * second, | ||
minute = 60 * second, | ||
@@ -12,2 +13,9 @@ minute5 = 5 * minute, | ||
tiers[second20] = { | ||
key: second20, | ||
floor: function(d) { return new Date(Math.floor(d / second20) * second20); }, | ||
ceil: tier_ceil, | ||
step: function(d) { return new Date(+d + second20); } | ||
}; | ||
tiers[minute5] = { | ||
@@ -17,3 +25,5 @@ key: minute5, | ||
ceil: tier_ceil, | ||
step: function(d) { return new Date(+d + minute5); } | ||
step: function(d) { return new Date(+d + minute5); }, | ||
next: tiers[second20], | ||
size: function() { return 15; } | ||
}; | ||
@@ -20,0 +30,0 @@ |
{ | ||
"name": "cube", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "A system for time series visualization using MongoDB, Node and D3.", | ||
@@ -5,0 +5,0 @@ "keywords": ["time series", "visualization"], |
@@ -16,10 +16,10 @@ var vows = require("vows"), | ||
keys.sort(function(a, b) { return a - b; }); | ||
assert.deepEqual(keys, [3e5, 36e5, 864e5, 6048e5, 2592e6]); | ||
assert.deepEqual(keys, [2e4, 3e5, 36e5, 864e5, 6048e5, 2592e6]); | ||
} | ||
}, | ||
"minute5": { | ||
topic: tiers[3e5], | ||
"has the key 3e5": function(tier) { | ||
assert.strictEqual(tier.key, 3e5); | ||
"second20": { | ||
topic: tiers[2e4], | ||
"has the key 2e4": function(tier) { | ||
assert.strictEqual(tier.key, 2e4); | ||
}, | ||
@@ -34,2 +34,63 @@ "next is undefined": function(tier) { | ||
"floor": { | ||
"rounds down to 20-seconds": function(tier) { | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 00, 20)), utc(2011, 08, 02, 12, 00, 20)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 00, 21)), utc(2011, 08, 02, 12, 00, 20)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 00, 23)), utc(2011, 08, 02, 12, 00, 20)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 00, 39)), utc(2011, 08, 02, 12, 00, 20)); | ||
assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 00, 40)), utc(2011, 08, 02, 12, 00, 40)); | ||
}, | ||
"does not modify the passed-in date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 00, 21); | ||
assert.deepEqual(tier.floor(date), utc(2011, 08, 02, 12, 00, 20)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 00, 21)); | ||
} | ||
}, | ||
"ceil": { | ||
"rounds up to 5-minutes": function(tier) { | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 00, 20)), utc(2011, 08, 02, 12, 00, 20)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 00, 21)), utc(2011, 08, 02, 12, 00, 40)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 00, 23)), utc(2011, 08, 02, 12, 00, 40)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 00, 39)), utc(2011, 08, 02, 12, 00, 40)); | ||
assert.deepEqual(tier.ceil(utc(2011, 08, 02, 12, 00, 40)), utc(2011, 08, 02, 12, 00, 40)); | ||
}, | ||
"does not modified the specified date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 00, 21); | ||
assert.deepEqual(tier.ceil(date), utc(2011, 08, 02, 12, 00, 40)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 00, 21)); | ||
} | ||
}, | ||
"step": { | ||
"increments time by twenty minutes": function(tier) { | ||
var date = utc(2011, 08, 02, 23, 59, 20); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 02, 23, 59, 40)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 03, 00, 00, 00)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 03, 00, 00, 20)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 03, 00, 00, 40)); | ||
assert.deepEqual(date = tier.step(date), utc(2011, 08, 03, 00, 01, 00)); | ||
}, | ||
"does not round the specified date": function(tier) { | ||
assert.deepEqual(tier.step(utc(2011, 08, 02, 12, 21, 23)), utc(2011, 08, 02, 12, 21, 43)); | ||
}, | ||
"does not modify the specified date": function(tier) { | ||
var date = utc(2011, 08, 02, 12, 20, 00); | ||
assert.deepEqual(tier.step(date), utc(2011, 08, 02, 12, 20, 20)); | ||
assert.deepEqual(date, utc(2011, 08, 02, 12, 20, 00)); | ||
} | ||
} | ||
}, | ||
"minute5": { | ||
topic: tiers[3e5], | ||
"has the key 3e5": function(tier) { | ||
assert.strictEqual(tier.key, 3e5); | ||
}, | ||
"next is the 20-second tier": function(tier) { | ||
assert.equal(tier.next, tiers[2e4]); | ||
}, | ||
"size is 15": function(tier) { | ||
assert.strictEqual(tier.size(), 15); | ||
}, | ||
"floor": { | ||
"rounds down to 5-minutes": function(tier) { | ||
@@ -36,0 +97,0 @@ assert.deepEqual(tier.floor(utc(2011, 08, 02, 12, 20, 00)), utc(2011, 08, 02, 12, 20)); |
Sorry, the diff of this file is not supported yet
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
692782
10287
3