Code Monkey home page Code Monkey logo

phppivot's Introduction

PHPivot

A flexible Pivot Table library for PHP.

#Example01

#Supported Features:

  • Nested (infinite) rows and columns
  • Sum and Count Functions
  • Generate HTML Table
    • Ignore empty rows [ setIgnoreBlankValues ]
  • Filters (Equal, Not Equal)
    • Filters support UNIX Wildcards (shell patterns), like *, ?, [ae], etc. (see php.net/fnmatch )
    • Support for Multiple Values matched as ALL(AND)/OR(ANY)/NONE(NOR) (MATCH_ALL, MATCH_NONE, MATCH_ANY)
    • Additional User-Defined functions as Filters
      • addCustomFilter( user_defined_filter_function, $extra_params = null )
        • @user_defined_filter_function($recordset, $rowID, $extra_params = null) -> should return true whenever a row should be INCLUDED.
    • User-defined "filters" can be setup using calculated columns and regular filters!
  • Calculated Columns
    • User defined functions.
    • They can return an array with "key-value" pairs, resulting in multiple calculated columns,named as CALC_COL_NAME_KEY
  • Sorting(Ascending by default, Descending, User defined functions)
    • Different Row and Column Sorting methods
    • Can give array argument for multiple level/different sorting
    • User-defined sorting functions
      • @user-defined-sorting-function($a,$b) -> should return $a < $b as boolean
  • Display as:
    • Actual Values
    • Percentage of col/row

#Features that need migration to the latest version/TODOs

  • Display as: -Percentage of deepest level (@fix)
  • Color Coding (background) of data: (@fix)
    • Low->High/High->Low gradient
  • "Pivot Comparison" mechanism

#Usage example:

require 'PHPivot.php';

//@table: an associative array containing rows of columns (like JSON)
function printPivotHTML(){
    $filmsByActorAndGenre = PHPivot::create($data)
            ->setPivotRowFields('Actor')
            ->setPivotColumnFields('Genre')
            ->setPivotValueFields('Genre',PHPivot::PIVOT_VALUE_COUNT, PHPivot::DISPLAY_AS_VALUE_AND_PERC_ROW, 'Frequency of Genre in each year')
            ->addFilter('Genre','', PHPivot::COMPARE_NOT_EQUAL) //Filter out blanks/unknown genre
            ->generate();
    echo $filmsByActorAndGenre->toHtml();
}

phppivot's People

Contributors

mhadjimichael avatar yopai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.