forked from rwjblue/pivot.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
simple_example.html
50 lines (47 loc) · 2.69 KB
/
simple_example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
<head>
<title>Pivot.js</title>
<link rel="stylesheet" href="./lib/css/pivot.css" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- jquery_pivot must be loaded after pivot.js and jQuery -->
<script type="text/javascript" src="./pivot.js"></script>
<script type="text/javascript" src="./jquery_pivot.js"></script>
<script type="text/javascript">
$(document).ready(function() {
csv = "currency_symbol,currency_code,last_name,first_name,zip_code,billed_amount,last_billed_date\n" +
"SG$,SGD,Jackson,Robert,34471,100.00,\"Tue, 24 Jan 2012 00:00:00 +0000\"\n" +
"€,EUR,Smith,Jon,34471,173.20,\"Mon, 13 Feb 2012 00:00:00 +0000\"\n" +
"US$,USD,Jackson,Jon,34474,262.42,\"Mon, 5 Mar 2012 00:00:00 +0000\"\n" +
"US$,USD,Jackson,Susan,34476,7.45,\"Thu, 15 Dec 2011 00:00:00 +0000\"\n" +
"SG$,SGD,Fornea,Chris,34474,62.98,\"Mon, 30 Jan 2012 00:00:00 +0000\"\n" +
"SG$,SGD,Fornea,Shelly,39401,124.63,\"Fri, 17 Feb 2012 00:00:00 +0000\""
fields = [
{ name: 'currency_symbol', type: 'string', filterable: false, rowLabelable: false, columnLabelable: false },
{ name: 'currency_code', type: 'string', filterable: true, rowLabelable: true, columnLabelable: false },
{ name: 'first_name', type: 'string', filterable: true },
{ name: 'last_name', type: 'string', filterable: true },
{ name: 'zip_code', type: 'integer', filterable: true, columnLabelable: true },
{ name: 'pseudo_zip', type: 'integer', filterable: true, pseudo: true, pseudoFunction: function (row) { return row.zip_code + 1 } },
{ name: 'billed_amount', type: 'currency', summarizable: 'max' },
{ name: 'last_billed_date', type: 'date', filterable: true },
{
name: 'last_billed_yyyy_mm', type: 'string', filterable: true, pseudo: true, columnLabelable: true,
pseudoFunction: function (row) {
var date = new Date(row.last_billed_date);
return date.getFullYear() + '_' + pivot.utils().padLeft((date.getMonth() + 1), 2, '0')
}
}
]
$('#pivot-menu-container').pivot_display('setup', { csv: csv, fields: fields, defaultCurrencySymbol: '$', currencySymbolField: 'currency_symbol' });
});
</script>
</head>
<body>
<div>
<div>
<div id="pivot-menu-container"></div>
<div id="results"></div>
</div>
</div>
</body>