The PivotEngine class has a simple and powerful object model that allows you to create, edit, and persist views programmatically.
To create views, follow these steps:
Views are designed to answer questions. Let's pretend we have data about people and items that they purchase at a store. Our data may have the following fields…
{
date, // date of purchase
Person, // person who bought
Category, // type of item bought
Amount // price spent by buyer
}
To answer this question, we can add the 'Amount' to the valueFields list and add 'Person' to the rowFields list.
ng.valueFields.push('Amount');
ng.rowFields.push('Person');
How might you answer the following questions using the technique above?
Once you have created one or more views, you can use a PivotPanel control to allow users to edit them, and you can use the PivotEngine.viewDefinition property to convert view definitions to strings to you can save and restore them easily.