Tesseract: fast n-dimensional filtering and grouping of records in the browser
Square has released Tesseract, a JavaScript library for filtering and grouping datasets in the browser.
A tesseract represents a multi-dimensional dataset and contain arrays of JavaScript objects or primitives:
var payments = tesseract([
{date: "2011-11-14T16:17:54Z", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "2011-11-14T16:20:19Z", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "2011-11-14T16:28:54Z", quantity: 1, total: 300, tip: 200, type: "visa"},
...
]);
A tesseract dimension is created by providing an accessor function that does not modify the underlying collection:
// Create a new dimension
var paymentsByTotal = payments.dimension(function(d) { return d.total; });
Dimensions can be then be filtered:
paymentsByTotal.filter([100, 200]); // selects payments whose total is between 100 and 200
paymentsByTotal.filter(120); // selects payments whose total equals 120
paymentsByTotal.filter(null); // selects all payments
Check out the API docs wiki or source for advanced filtering, grouping and other features.
Discussion
Sign in or Join to comment or subscribe