forked from nicolaskruchten/pivottable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gchart.html
56 lines (47 loc) · 2.15 KB
/
gchart.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
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<title>Pivot Demo</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<!-- external libs from cdnjs -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<!-- PivotTable.js libs from ../dist -->
<link rel="stylesheet" type="text/css" href="../dist/pivot.css">
<script type="text/javascript" src="../dist/pivot.js"></script>
<script type="text/javascript" src="../dist/gchart_renderers.js"></script>
<style>
body {font-family: Verdana;}
</style>
<!-- optional: mobile support with jqueryui-touch-punch -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
<!-- for examples only! script to show code to user -->
<script type="text/javascript" src="show_code.js"></script>
</head>
<body>
<script type="text/javascript">
// This example adds Google Chart renderers.
google.load("visualization", "1", {packages:["corechart", "charteditor"]});
$(function(){
var derivers = $.pivotUtilities.derivers;
var renderers = $.extend($.pivotUtilities.renderers,
$.pivotUtilities.gchart_renderers);
$.getJSON("mps.json", function(mps) {
$("#output").pivotUI(mps, {
renderers: renderers,
derivedAttributes: {
"Age Bin": derivers.bin("Age", 10),
"Gender Imbalance": function(mp) {
return mp["Gender"] == "Male" ? 1 : -1;
}
},
cols: ["Age Bin"], rows: ["Gender"],
rendererName: "Area Chart"
});
});
});
</script>
<p><a href="index.html">« back to PivotTable.js examples</a></p>
<div id="output" style="margin: 30px;"></div>
</body>
</html>