• Stars
    star
    782
  • Rank 58,164 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 12 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

Build Pivot Tables from CSV/JSON Data

Welcome to Pivot.js

Pivot.js is a simple way for you to get to your data. It allows for the creation of highly customizable unique table views from your browser.

In data processing, a pivot table is a data summarization tool found in data visualization programs such as spreadsheets or business intelligence software. Among other functions, pivot-table tools can automatically sort, count, total or give the average of the data stored in one table or spreadsheet. It displays the results in a second table (called a "pivot table") showing the summarized data.

In our case, results (or the pivot-table) will be displayed as an HTML table pivoting from the input data (CSV or JSON). Without further ado let's get to usage.

View an example or view the Docs for more information.

Usage

Step one is to initialize the pivot object. It expects the following attributes:

  • csv - which should contain a valid string of comma separated values. It is important to note that you must include a header row in the CSV for pivot to work properly (you'll understand why in a minute).
  • json - which should contain a valid JSON string. At this time this string must be an array of arrays, and not an array of objects (storing the field names with each row consumes significantly more space).
  • fields - which should be an array of objects. This is used to instruct pivot on how to interact with the fields you pass in. It keys off of the header row names. And is formated like so:
 [ {name: 'header-name', type: 'string', optional_attributes: 'optional field' },
 {name: 'header-name', type: 'string', optional_attributes: 'optional field' }]

(See more about fields in Section below)

  • filters (default is empty) - which should contain any filters you would like to restrict your data to. A filter is defined as an object like so:
{zip_code: '34471'}

Those are the options that you should consider. There are other options that are well covered in the spec.

A valid pivot could then be set up from like so.

var field_definitions = [{name: 'last_name',   type: 'string',   filterable: true},
        {name: 'first_name',        type: 'string',   filterable: true},
        {name: 'zip_code',          type: 'integer',  filterable: true},
        {name: 'pseudo_zip',        type: 'integer',  filterable: true },
        {name: 'billed_amount',     type: 'float',    rowLabelable: false},
        {name: 'last_billed_date',  type: 'date',     filterable: true}]

// from csv data:
var csv_string  =  "last_name,first_name,zip_code,billed_amount,last_billed_date\n" +
                   "Jackson,Robert,34471,100.00,\"Tue, 24 Jan 2012 00:00:00 +0000\"\n" +
                   "Jackson,Jonathan,39401,124.63,\"Fri, 17 Feb 2012 00:00:00 +0000\""

pivot.init({csv: csv_string, fields: field_definitions});

// from json data:
var json_string = '[["last_name","first_name","zip_code","billed_amount","last_billed_date"],' +
                    ' ["Jackson", "Robert", 34471, 100.00, "Tue, 24 Jan 2012 00:00:00 +0000"],' +
                    ' ["Smith", "Jon", 34471, 173.20, "Mon, 13 Feb 2012 00:00:00 +0000"]]'

pivot.init({json: json_string, fields: field_definitions});

Wiki

Articles

Authors

Pivot.js is the work of Robert Jackson and Jonathan Jackson.

License

This software is licensed under a modified BSD license.

See LICENSE for more details.

More Repositories

1

ember-cli-content-security-policy

JavaScript
157
star
2

git-repo-info

JavaScript
111
star
3

codemod-cli

JavaScript
89
star
4

singleton_process

Ensure that a given process is only running once. Helpful for ensure that scheduled tasks do not overlap if they run longer than the scheduled interval.
Ruby
68
star
5

ember-cli-pretender

JavaScript
66
star
6

ember-cli-cjs-transform

JavaScript
48
star
7

ember-cli-divshot

JavaScript
45
star
8

sparkles-component

JavaScript
43
star
9

ember-router-helpers

JavaScript
38
star
10

ember-waypoints

Ember CLI Addon for using jQuery-Waypoints
JavaScript
35
star
11

ember-cli-esnext

JavaScript
35
star
12

release-it-yarn-workspaces

JavaScript
32
star
13

create-rwjblue-release-it-setup

JavaScript
30
star
14

ember-native-dom-event-dispatcher

JavaScript
25
star
15

broccoli-timepiece

JavaScript
21
star
16

ember-cli-ic-ajax

JavaScript
21
star
17

ember-holy-futuristic-template-namespacing-batman

JavaScript
21
star
18

X12

X12 Parser - a library to manipulate X12 structures using native Ruby syntax. This is only a github clone of the X12 rubyforge project located at: http://rubyforge.org/projects/x12parser/
Ruby
20
star
19

release-it-lerna-changelog

JavaScript
18
star
20

ember-test-friendly-error-handler

Build testable error handlers that don't throw in production...
JavaScript
15
star
21

ember-git-version

JavaScript
14
star
22

ember-new-computed

JavaScript
14
star
23

validate-peer-dependencies

Validate the peerDependencies of a given package.json have been satisfied.
JavaScript
14
star
24

get-function-location

JavaScript
12
star
25

ember-data-nested-urls

Ruby
12
star
26

ember-live-api

Ember API Docs via Ember App Kit
JavaScript
12
star
27

ember-template-invocation-location

JavaScript
11
star
28

ember-functional-component

Use "pure functions" as components in an Ember app.
JavaScript
11
star
29

container-resolver-namespaces

JavaScript
11
star
30

ember-cli-selenium

JavaScript
11
star
31

no-jquery-app

JavaScript
9
star
32

broccoli-file-creator

JavaScript
8
star
33

ember-template-module-name-remover

JavaScript
7
star
34

--ghost-modules-sample

Test repo to play with new module layout changes...
JavaScript
7
star
35

broccoli-file-remover

JavaScript
7
star
36

__glimmer-demo-using-route-recognizer

TypeScript
7
star
37

dotvim

Lua
6
star
38

pretender-query-param-handler

JavaScript
6
star
39

broccoli-jshint

JavaScript
6
star
40

ember-cli-delay-app-boot

JavaScript
6
star
41

work_days

Calculate the number of work days in a given period.
Ruby
6
star
42

broccoli-string-replace

JavaScript
5
star
43

dotfiles

Shell
4
star
44

rfc232-demo-app

JavaScript
4
star
45

experimental-glimmer-app

TypeScript
4
star
46

ember-title

JavaScript
4
star
47

broccoli-fixturify

JavaScript
3
star
48

broccoli-slow-trees

JavaScript
3
star
49

broccoli-unwatched-tree

JavaScript
3
star
50

broccoli-watched-tree

JavaScript
3
star
51

broccoli-ember-inline-template-compiler

JavaScript
3
star
52

--ember-qunit-5-sample-app

JavaScript
3
star
53

broccoli-export-tree

JavaScript
3
star
54

broccoli-file-mover

JavaScript
3
star
55

cal-rs

`cal` (but better!) in rust
Rust
3
star
56

test-glimmer-playground

JavaScript
2
star
57

lsp-playground

Playground for LSP shenanigans
Rust
2
star
58

ember-cli-symlinking-tests

JavaScript
2
star
59

terminal_server_utilities

Utility functions to make dealing with Microsoft Terminal Servers easier to manage.
Ruby
2
star
60

___demo-babel-config

JavaScript
2
star
61

test-github-device-flow-auth

Rust
2
star
62

broccoli-derequire

JavaScript
2
star
63

broccoli-use-strict-remover

JavaScript
2
star
64

prawn_examples

Example scripts for using the prawn gem.
Ruby
1
star
65

simple-dll

JavaScript
1
star
66

-tracking-rendered-modifier-testbed

JavaScript
1
star
67

octane-app-20190219

JavaScript
1
star
68

--travis-modules-sample

JavaScript
1
star
69

mail_examples

Example scripts using the Mail gem.
Ruby
1
star
70

asset-rev-issue

CSS
1
star
71

pingly

Ping a specified host, logs the output, and calls a block on packet loss.
Ruby
1
star
72

repro-ember-cli-htmlbars-template-modules

JavaScript
1
star
73

_____ember-cli-test

JavaScript
1
star
74

intro-to-ember-suncoast.js-2014-02-19

JavaScript
1
star
75

-demo-disabling-rerendering-in-ssr-mode

JavaScript
1
star
76

___test-embroider-in-addon-development

JavaScript
1
star
77

-demo-of-fastboot-without-fastboot

JavaScript
1
star
78

ember-cli-build-visualizer

JavaScript
1
star
79

ember-holy-futuristic-template-namespacing-batman-codemod

JavaScript
1
star
80

debugging-broccoli

JavaScript
1
star
81

ey-cloud-recipes

A starter repo for custom chef recipes on EY's cloud platform
Ruby
1
star
82

adafter

JavaScript
1
star
83

--new-app-blueprint

JavaScript
1
star
84

testing-ega

JavaScript
1
star
85

htmlbars-test

JavaScript
1
star
86

openai_playground

Rust
1
star
87

log-lint-times

JavaScript
1
star
88

homebrew-tap

Homebrew formulas for my personal projects
Ruby
1
star
89

vimfiles

vimfiles
Vim Script
1
star
90

__demo-including-ts-library

TypeScript
1
star