All Projects → davidguttman → React Pivot

davidguttman / React Pivot

React-Pivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Pivot

Sheetify
✨ Modular CSS bundler for browserify
Stars: ✭ 443 (-54.84%)
Mutual labels:  browserify
Browserify Rails
Browserify + Rails = a great way to modularize your legacy JavaScript
Stars: ✭ 701 (-28.54%)
Mutual labels:  browserify
Uicookbook
A few recipes and build workflows for UI dev
Stars: ✭ 19 (-98.06%)
Mutual labels:  browserify
Clipboard Copy
Lightweight copy to clipboard for the web
Stars: ✭ 443 (-54.84%)
Mutual labels:  browserify
Public
Repository for wallaby.js questions and issues
Stars: ✭ 662 (-32.52%)
Mutual labels:  browserify
Yasumi
The easy PHP Library for calculating holidays
Stars: ✭ 788 (-19.67%)
Mutual labels:  calculations
Nghandsontable
Official AngularJS directive for Handsontable
Stars: ✭ 438 (-55.35%)
Mutual labels:  data-grid
Awesome Mad Science
Delightful npm packages that make you say "wow, didn't know that was possible!"
Stars: ✭ 909 (-7.34%)
Mutual labels:  browserify
React Starterify
A minimal React JS application starter kit
Stars: ✭ 669 (-31.8%)
Mutual labels:  browserify
Sample Hazelcast Spring Datagrid
sample spring-boot applications integrated with hazelcast imdg, and providing hot cache with hazelcast and striim
Stars: ✭ 16 (-98.37%)
Mutual labels:  data-grid
React Handsontable
React Data Grid with Spreadsheet Look & Feel. Official React wrapper for Handsontable.
Stars: ✭ 511 (-47.91%)
Mutual labels:  data-grid
Lyo
📦 Node.js to browser - The easy way
Stars: ✭ 624 (-36.39%)
Mutual labels:  browserify
Xhr
A small xhr wrapper
Stars: ✭ 801 (-18.35%)
Mutual labels:  browserify
Drag Drop
HTML5 drag & drop for humans
Stars: ✭ 443 (-54.84%)
Mutual labels:  browserify
Codice Fiscale
Javascript object for managing the italian tax code
Stars: ✭ 9 (-99.08%)
Mutual labels:  calculations
Bitcoinjs Lib
A javascript Bitcoin library for node.js and browsers.
Stars: ✭ 4,418 (+350.36%)
Mutual labels:  browserify
Vue Handsontable Official
Vue Data Grid with Spreadsheet Look & Feel. Official Vue wrapper for Handsontable.
Stars: ✭ 751 (-23.45%)
Mutual labels:  data-grid
Quantities
A library to work with quantities and units.
Stars: ✭ 32 (-96.74%)
Mutual labels:  calculations
Livereactload
Live code editing with Browserify and React
Stars: ✭ 870 (-11.31%)
Mutual labels:  browserify
Reactjs Tmdb App
Responsive React 'The Movie Database' (TMDb) App
Stars: ✭ 830 (-15.39%)
Mutual labels:  browserify

ReactPivot

ReactPivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration. Can be used without React.

Demo: http://davidguttman.github.io/react-pivot/

Demo

Installation & Usage

Default (Browserify/webpack):

npm i -S react-pivot
var React = require('react')
var ReactPivot = require('react-pivot')

React.render(
  <ReactPivot rows={rows}
              dimensions={dimensions}
              reduce={reduce}
              calculations={calculations}
              nPaginateRows={25} />,
  document.body
)

Classic (no React or Browserify):

Download react-pivot-standalone-3.0.0.min.js

<script src='react-pivot-standalone-3.0.0.min.js'></script>
<script>
  ReactPivot(document.body, {
    rows: rows,
    dimensions: dimensions,
    calculations: calculations,
    reduce: reduce
  })
</script>

Custom (Browserify, no React):

var ReactPivot = require('react-pivot/load')

ReactPivot(document.body, {
  rows: rows,
  dimensions: dimensions,
  reduce: reduce,
  calculations: calculations
})

Example

var React = require('react')
var ReactPivot = require('react-pivot')

React.render(
  <ReactPivot rows={rows}
              dimensions={dimensions}
              reduce={reduce}
              calculations={calculations} />,
  document.body
)

ReactPivot requires four arguments: rows, dimensions, reduce and calculations

rows is your data, just an array of objects:

var rows = [
  {"firstName":"Francisco","lastName":"Brekke","state":"NY","transaction":{"amount":"399.73","date":"2012-02-02T08:00:00.000Z","business":"Kozey-Moore","name":"Checking Account 2297","type":"deposit","account":"82741327"}},
  {"firstName":"Francisco","lastName":"Brekke","state":"NY","transaction":{"amount":"768.84","date":"2012-02-02T08:00:00.000Z","business":"Herman-Langworth","name":"Money Market Account 9344","type":"deposit","account":"95753704"}}
]

dimensions is how you want to group your data. Maybe you want to get the total $$ by firstName and have the column title be First Name:

var dimensions = [
  {value: 'firstName', title: 'First Name'}
]

reduce is how you calculate numbers for each group:

var reduce = function(row, memo) {
  memo.amountTotal = (memo.amountTotal || 0) + parseFloat(row.transaction.amount)
  return memo
}

calculations is how you want to display the calculations done in reduce:

var calculations = [
  {
    title: 'Amount', value: 'amountTotal',
    template: function(val, row) {
      return '$' + val.toFixed(2)
    },
    sortBy: function(row) {
      return isNaN(row.amountTotal) ? 0 : row.amountTotal
    }
  }
]

Plug them in and you're good to go!

// Optional: set a default grouping with "activeDimensions"
React.render(
  <ReactPivot rows={rows}
              dimensions={dimensions}
              reduce={reduce}
              calculations={calculations}
              activeDimensions={['First Name']} />,
  document.body
)

See it all together in example/basic.jsx

Optional Arguments

parameter type description default
compact boolean compact rows false
csvDownloadFileName string assign name of document created when user clicks to 'Export CSV' 'table.csv'
csvTemplateFormat boolean apply template formatting to data before csv export false
defaultStyles boolean apply default styles from style.css true
hiddenColumns array columns that should not display []
nPaginateRows number items per page setting 25
solo object item that should be displayed solo null
sortBy string name of column to use for record sort null
sortDir string sort direction, either 'asc' or 'desc' 'asc'
tableClassName string assign css class to table containing react-pivot elements ''
hideDimensionFilter boolean do not render the dimension filter false
hideRows function if provided, rows that are passed to the function will not render unless the return value is true null

TODO

  • Better Pagination
  • Responsive Table

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].