-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Input Formats
The input data is a set of records with attributes rather than rows with columns, as the pivot table output has rows and columns and having separate nomenclature keeps things from getting confusing.
###Arrays of objects
One object per record, the object's keys are the attribute names.
<script>
var input = [
{
"attr1": "value1_attr1",
"attr2": "value1_attr2",
//...
},
{
"attr1": "value2_attr1",
"attr2": "value2_attr2",
//...
},
//...
];
</script>
###Arrays of arrays
One sub-array per record, the first sub-array contains the attribute names.
<script>
var input = [
["attr1", "attr2"],
["value1_attr1", "value1_attr2"],
["value2_attr1", "value2_attr2"],
//...
];
</script>
###Functions that call back
The function will be called with a callback that takes two parameters: attribute name and value.
<script>
var input = function(callback) {
callback({
"attr1": "value1_attr1",
"attr2": "value1_attr2",
//...
});
callback({
"attr1": "value2_attr1",
"attr2": "value2_attr2",
//...
};
//...
};
</script>
###jQuery References to Simple Tables
If there exists in the DOM a table with a thead
and tbody
then a jQuery reference to that table will be accepted as input. Attribute names are assumed to be in th
elements in thead
and values are assumed to be in td
elements in tbody
.
<script>
var input = $("#input");
</script>
<table id="input">
<thead>
<tr>
<th>attr1</th>
<th>attr2</th>
<!-- etc... -->
</tr>
</thead>
<tbody>
<tr>
<td>value1_attr1</td>
<td>value1_attr2</td>
</tr>
<tr>
<td>value2_attr1</td>
<td>value2_attr2</td>
</tr>
<!-- etc... -->
</tbody>
</table>