Skip to content

Postprocessing Data

hanzo2001 edited this page May 30, 2016 · 3 revisions

Introduction

The postprocessing phase does not work on raw data but on the DataView (docs). The DataView is an object from the GoogleAPI and is responsible for determining what is to be presented from the DataTable. An added bonus is the possibility to add calculated "virtual" columns on the fly.

Applying a postprocessor

Every processor, either post or pre, is invoked through a call-object with two members (params is optional):

{
    call : 'method_name',
    params : [ param1 , ... ]
}

The invocation object must be defined on the main option object's postprocessors and the method being invoked must exist before creating the chart, otherwise the invocation will be ignored.

For clarity, the postprocessor is invoked as follows:

$.fn.CreateChart.postprocessors.<method_name>.apply(DataView, params);

Adding a new postprocessor

As with the preprocessors, a postprocessor is defined in the same manner, it follows the same rules and can be accomplished as follows.

$.fn.CreateChart.postprocessors.<method_name> = function ( <params> ) {
    var dataView = this;
    ...
};

The context is set to the DataView, the params are optional but their order matters.

Current postprocessors

Name Signature Description
addColumnSum function(label) Adds a new calculated column that computes the sum of every number element in a row. The label is an optional parameter. Do not combine with addColumnAvg.
addColumnAvg function(label) Adds a new calculated column that computes the average of every number element in a row. The label is an optional parameter. Do not combine with addColumnSum.

Clone this wiki locally