I noticed the fact that crossfilter is useful for data manipulation, not just at client side ( as used in winlose analyzer) but the crossfilter npm module is useful as well ( it is used in comparator ). People are interested to use it but most of the times they are not willing to put extra code for the same. Hence I came up with the idea of making crossfilter config driven and hence named it - crossfilterplus. It is available at https://www.npmjs.com/ package/crossfilterplus :)
One can use the commonly used methods such as dimension, group as standalone as well ( as shown in the following example ) as per their requirement. It can be used through config as well as shown below:
To use it, please do the following:
var crossfilterPlus = require('crossfilterplus')
var data = [
{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"},
{date: "2011-11-14T17:22:59Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-11-14T17:25:45Z", quantity: 2, total: 200, tip: 0, type: "cash"},
{date: "2011-11-14T17:29:52Z", quantity: 1, total: 200, tip: 100, type: "visa"}
]
Example -
#1 Access standalone methods
crossfilterPlus.data(data) // data method helps to create a crossfilter instance on the input dataset
var manipulateData = crossfilterPlus
.dimension(['total','tip'])
.group()
.all()
There is no need to create crossfilter instance and use it everytime to perform operation. crossfilterPlus is able to handle it.
#2 Pass config
Config :-
var config = {
data: data, //required
dimension: ['total','tip'], //could be a string or array or function else it shows a warning - mandatory
aggregate: 'sum', // by default it is count, works for sum. Need to enable more computation here
measure: 'tip' // needed if aggregation is not count
}
I intend to enhance this config more to make it available for sorting and other computations as well. Currently it groups based on the dimension layer.
After preparing the config - crossfilterPlus.build( config) will perform grouping based on the dimension applied over the input with aggregation as per measure and will give same output as manipulateData in #1 :)
For reference to the above approaches, please refer API reference - https://github.com/ Crossfilterplus/ crossfilterplus/wiki/API- reference
It is available at github at - https://github.com/ Crossfilterplus/ crossfilterplus
The future plans for it are as follow:
- Make it more config driven
- Make nested grouping in crossfilterplus
- Try to integrate it with d3plus (https://github.com/
alexandersimoes/d3plus/issues/ 110)
It will be great to have your suggestion as well. Please feel free to raise issues at the github repo as well. Since yesterday, there are +16 downloads :)
No comments:
Post a Comment
Enter your text here .....