Managing data filtering, and grouping, simply.
A full interactive example can be found here
TODO: convert Makefile to gulpfile
Quick Example
var DM = // create new data manaager // assumed myData is an array of objects containg the data. // filter the object class by "Fruit" // filter also by date range // Gets the total invoiced grouped by day between the 15th and 24th (inclusive) for only product class 1Avar dailyTotals = DM all // get all data for the group
API Summary
- dataManager
-
schema(schema definition:Object) : dataManager
Set the schema definition for this data manager instance.
-
setData(data:Object) : dataManager
Set the data to be managed.
-
filter(field:String, filter:Array|String ) : dataManager
Filter a field by some data. Single and multiple values, and ranges are supported. Single value : "abc" Multiple values : ["abc","def"] Value range : [[100,200]]
-
group(field:String, group:String ) : group
Get the fields grouped set.
-
getDimension(field:String) : dimension
Get the dimension configuration and access to the crossfilter dimension.
-
all() : groupSummary
Get the reduced summary of the entire data set.
-
** Events supported by dataManager: Supported events: 'dataChanged','schemaChanged','filterChanged','dimensionCreated','groupCreated'
Example of using events:
DM = DM DM DM DM // we're expecting a single field. No filters or grouping. // output to console: The schema changed {"a":{}} DM // output to console: Data changed DM // filter 'a' dimension by the value 'two' // output to console: New dimension created for "a" var filtered = DMtopInfinity // get the 'a' dimension, with no limit to count. // data returned: ["{"a":"two"}", "{"a":"two"}"]
-
group
-
all()
Get all data for the grouped set
-
order(value: Function)
change the sort order function of the grouping
-
orderNatural()
set the ordering using the natural return of the reduced value
-
reduce(add: Function, remove: Function, initial: Object)
set the reduce functions (this is done automatically from the schema definition)
-
reduceCount() : void
set the reduce function to count the number of rows in group.
-
reduceSum(value: String|Function)
set the reduce function to sum a row, or call a function to return a value to add to the total.
-
size() : int
Get the number of group keys.
-
top(num: int) : Array
Get the top NUM records from the group based on the sort order.
-
-
dimension
-
column: String
Name of the column in data set that this filter represents.
-
dimension: Object
Direct access to the crossfilter dimension object.
-
filter(data:Array|String) : dimension
Filter this dimension by the provided data. Single value : "abc" Multiple values : ["abc","def"] Value range : [[100,200]]
-
group: function (group:String) : group
get grouping for this dimension by this object.
-