• Stars
    star
    1,049
  • Rank 43,923 (Top 0.9 %)
  • Language
    JavaScript
  • Created almost 10 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

authentic

Authentication for microservices.
JavaScript
223
star
2

cssify

Simple middleware for Browserify to add css styles to the browser.
JavaScript
123
star
3

video-download-tool-server

JavaScript
53
star
4

sassify

Require scss files in Browserify
JavaScript
51
star
5

crazy_delicious_coffee_processing

This is the code that goes along with the tutorial: CoffeeScript + Processing.js == Crazy Delicious
JavaScript
51
star
6

BaseJSApp

a starting point for js apps
JavaScript
47
star
7

video-download-tool

VideoDownloadTool.io makes it easy to download videos--but only the parts you want. Enter a video's url, select the beginning and end of your clip, optionally crop the video frame, and download.
JavaScript
42
star
8

node-dataframe

JavaScript
38
star
9

wave-pendulum

simple html 5 wave pendulum using coffeescript and processing.js
CoffeeScript
35
star
10

power-slides

Create powerful slideshows for talks and presentations. Each "slide" is a JS function that can do *anything*.
JavaScript
29
star
11

authentic-server

This is the server component of Authentic. This provides endpoints for signup, login, confirm, and password change.
JavaScript
24
star
12

datavis-la-november-13

JavaScript
21
star
13

perlin-simplex

Simplex Perlin noise
JavaScript
18
star
14

duhstar

Easily see what's taking up disk space. Shows folder and files sorted by size with human readable units.
JavaScript
15
star
15

tailgate

Serve up your music, and listen to it at work or on your phone.
JavaScript
14
star
16

serialize-stream

Stream json, ndjson, or csv.
JavaScript
13
star
17

easy-ears

Easy sound reactivity for Chrome/Webkit
JavaScript
12
star
18

earstream

Streaming audio reactivity in the browser using WebRTC + Web Audio API
JavaScript
11
star
19

authentic-ui

The client-side UI for Authentic. Provides UI for signup, login, and password change
JavaScript
11
star
20

date-range-array

Create an array of dates
JavaScript
10
star
21

s3-rsync

Sync a local directory to S3
JavaScript
9
star
22

korg-nano

A simple module for getting data events from a Korg Nano Kontrol.
JavaScript
8
star
23

rambly-docs

8
star
24

dynamodown

A drop in replacement for LevelDOWN that works with DynamoDB as its storage. Can be used with LevelUP
JavaScript
8
star
25

authentic-service

This is the service component of Authentic. This will help decode tokens so that you can authenticate users within a microservice.
JavaScript
7
star
26

authentic-client

The client component of Authentic. This helps interact with an `authentic-server` so that you can easily signup, confirm, login, and change-password for users. It will also help send tokens to microservices that require authentication.
JavaScript
6
star
27

simplify-gmail-native

Run Simplify / Gmail as a standalone app using Nativefier.
Shell
5
star
28

loading-wave

A simple wave pendulum-like loading animation for the browser
CoffeeScript
5
star
29

y-options

Get Options Quotes
JavaScript
5
star
30

simple-timeseries

A simple timeseries chart using D3.
JavaScript
4
star
31

react-pivot-example-app

Example app using browserify and babelify. Uses wzrd for a dev server.
JavaScript
4
star
32

retrial

Easily retry an async function without mangling it.
JavaScript
4
star
33

hedwig

JavaScript
4
star
34

strippr

Fun with RGB LED strips
JavaScript
3
star
35

visuals-js

JavaScript
3
star
36

twitter_chimes

Windchimes, but with Twitter and CoffeeScript
CoffeeScript
3
star
37

connect-health-check

JavaScript
3
star
38

deltriperno

Delaunay triangulation + Perlin noise
JavaScript
3
star
39

productionize

Simple additions for a production app
JavaScript
3
star
40

pathkey

Generate keys from objects and parse keys back into objects. Useful for working with kv stores like leveldb and redis.
JavaScript
2
star
41

plug-dj-bot

A bot for Plug.dj
JavaScript
2
star
42

turntable_friends

JavaScript
2
star
43

gcp-secret-fetcher

JavaScript
2
star
44

req-logger

Simple HTTP request logging. `responseTime`, `method`, `url`, `statusCode`
JavaScript
2
star
45

level-dynamodb

JavaScript
2
star
46

plug-dj-login

Log in to Plug.dj and get an auth cookie
JavaScript
2
star
47

react-browserify-basics

Basic structure for a react/browserify app
JavaScript
2
star
48

coolkit

CoffeeScript
2
star
49

node-directify

Director.js with easier use with Browserify, plus some added features.
JavaScript
2
star
50

spotx-api

A simple module for accessing SpotX report data.
JavaScript
2
star
51

lkqd-api

A simple module for accessing LKQD report data.
JavaScript
2
star
52

ns-livecoded-audio-visualizer

JavaScript
2
star
53

coding-guidelines

1
star
54

jsonfiles_client

JavaScript
1
star
55

cdo-package

Alphabetizes your dependencies
JavaScript
1
star
56

hypnotable

Stream objects to a table
CoffeeScript
1
star
57

onevideo-api

A simple module for accessing ONE by AOL: Video report data.
JavaScript
1
star
58

perfdemo

JavaScript
1
star
59

healthpoint

Easily expose your http server's health.
JavaScript
1
star
60

video-delay

Display web cam video... but with a delay
JavaScript
1
star
61

animated-giffer

A server to help make animated gifs from a sequence of pngs
JavaScript
1
star
62

bm-casio

Ruby
1
star
63

node-cap-deploy

Ruby
1
star
64

html5slides

1
star
65

jsw-client

The front-end for jsw.bestofjs.com
CoffeeScript
1
star
66

plug-dj-tests

JavaScript
1
star
67

authentic-dynamo-example

JavaScript
1
star
68

test

1
star
69

syynteractive_101

JavaScript
1
star
70

webfiles

Ruby
1
star
71

Reddit-Ticker

Simple JS Reddit News Ticker
JavaScript
1
star
72

sinatra_backbone

a template app for backbone using sinatra, html5 boilerplate, etc...
JavaScript
1
star
73

simple-wiki

JavaScript
1
star
74

react-pivot-mean-slides

Slides for a talk about React-Pivot at MEAN
JavaScript
1
star
75

slides-jsfest-2014

Slides for my JSFest 2014 talk: Winning the Internet with Browserify
JavaScript
1
star
76

logship

JavaScript
1
star
77

rugmi

Simple imgur image upload cli
JavaScript
1
star
78

aider-web

Dockerfile
1
star
79

react-pivot-classic-example

Example using ReactPivot using classic script tags.
HTML
1
star
80

quick-s3

Quickly upload to S3.
CoffeeScript
1
star
81

video-ad-network-multi-api

Pulls reports from multiple video ad networks and attempts to normalize the responses.
JavaScript
1
star
82

hypnotable-footer

Add a footer to your Hypnotable! Great for totals or other reductions of data.
JavaScript
1
star
83

vagrant-ansible-bootstrap

Bring vagrant up ready to be hit with ansible
1
star