racker/glimpse.js — pull request #52 by jverghese (2013-02-27 02:58:16+00:00)
Title: New Data model - stage 1

Need to add more tests.

* Incorporated new data collection into the graph.
* Added extendable data and dimension selectors/manipulators:
* Adds avg, min, max label derived from data in the example graph - purely through the graph api call.

Data can now be of two types:
1) Standard
2) Derived

Derived data for difference quotient is of the form:
```javascript
{
id: 'latencyDfwROC',
title: 'Difference Quotient (DFW)',
sources: 'latencyDfw',
derivation: function(sources) {
return sources.diffQuotient().get();
}
}
```

The source above may be comma-delimited ids of existing data sources or * to indicate all non-derived data sources.
The derivation function is given a data selection of the source(s) to easily manipulate it.

Data selections deal with the entire data source(s) and transform it. Operations include things like computing derivativates etc

Dimensions on the other hand select a particular dimension from source(s) and perform calculations on it. Operations such as min, max, concat, avg, extent etc

Example stats for a avg/min/max:
```javascript
{
id: 'stats',
sources: '*',
derivation: function(sources) {
var points = sources.dim('latency').concat();
return {
min: points.min().round().get(),
max: points.max().round().get(),
avg: points.avg().round().get()
};
}
```

Label component using it:
```javascript
.component({
type: 'label',
dataId: 'stats',
text: function(d) {
return 'Min/Max/Avg: ' + d.min + '/' + d.max + '/' + d.avg
},
position: 'center-left',
target: '.gl-footer'
})
```

Stage 2 will be:
Incorporate dimensions into the api (breaking change) -- this will enable a number of features.
Refactor domain to become a simple derived data source.
Add filter by domain dimension operator.