Uploaded a tiny but functional pivoting library in JavaScript
https://github.com/deb-sandeep/SimplePivot
<script> function test() { // Define the column names by which we will refer to the pivot groupings var srcColNames = [ "Date", "Subject", "Lesson", "Time" ] ; // The underlying data of the pivot representation var pivotData = [ [ "10-26", "History", "Mughals", 300 ], [ "10-26", "History", "Islam", 200 ], [ "10-27", "Geography", "Climate", 150 ], [ "10-27", "History", "Islam", 250 ] ] ; // Initialize the pivot table by setting the column names and corresponding // data set var pivotTable = new PivotTable() ; pivotTable.setPivotData( srcColNames, pivotData ) ; // Initialize the pivot table by providing // - The row groupings (in this case, group by Subject, then by Lesson // - The column group // - The value which needs to be aggregated pivotTable.initializePivotTable( [ "Subject", "Lesson" ], "Date", "Time" ) ; // Render the pivot table on an existing div pivotTable.renderPivotTable( "pivot_table_div", "Time spent per subject" ) ; } </script>
No comments:
Post a Comment