postrest 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app.rb +1 -1
- data/public/index.htm +116 -0
- data/public/node_modules/pivottable/CONTRIBUTING.md +19 -0
- data/public/node_modules/pivottable/LICENSE.md +9 -0
- data/public/node_modules/pivottable/ReadMe.md +155 -0
- data/public/node_modules/pivottable/bower.json +31 -0
- data/public/node_modules/pivottable/c3_renderers.coffee +155 -0
- data/public/node_modules/pivottable/d3_renderers.coffee +73 -0
- data/public/node_modules/pivottable/dist/c3_renderers.js +256 -0
- data/public/node_modules/pivottable/dist/c3_renderers.js.map +1 -0
- data/public/node_modules/pivottable/dist/c3_renderers.min.js +2 -0
- data/public/node_modules/pivottable/dist/c3_renderers.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/d3_renderers.js +105 -0
- data/public/node_modules/pivottable/dist/d3_renderers.js.map +1 -0
- data/public/node_modules/pivottable/dist/d3_renderers.min.js +2 -0
- data/public/node_modules/pivottable/dist/d3_renderers.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/export_renderers.js +80 -0
- data/public/node_modules/pivottable/dist/export_renderers.js.map +1 -0
- data/public/node_modules/pivottable/dist/export_renderers.min.js +2 -0
- data/public/node_modules/pivottable/dist/export_renderers.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/gchart_renderers.js +183 -0
- data/public/node_modules/pivottable/dist/gchart_renderers.js.map +1 -0
- data/public/node_modules/pivottable/dist/gchart_renderers.min.js +2 -0
- data/public/node_modules/pivottable/dist/gchart_renderers.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.css +97 -0
- data/public/node_modules/pivottable/dist/pivot.es.js +78 -0
- data/public/node_modules/pivottable/dist/pivot.es.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.es.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.es.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.fr.js +78 -0
- data/public/node_modules/pivottable/dist/pivot.fr.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.fr.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.fr.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.js +1511 -0
- data/public/node_modules/pivottable/dist/pivot.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.min.css +1 -0
- data/public/node_modules/pivottable/dist/pivot.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.nl.js +78 -0
- data/public/node_modules/pivottable/dist/pivot.nl.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.nl.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.nl.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.pt.js +104 -0
- data/public/node_modules/pivottable/dist/pivot.pt.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.pt.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.pt.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.ru.js +78 -0
- data/public/node_modules/pivottable/dist/pivot.ru.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.ru.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.ru.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.tr.js +104 -0
- data/public/node_modules/pivottable/dist/pivot.tr.js.map +1 -0
- data/public/node_modules/pivottable/dist/pivot.tr.min.js +2 -0
- data/public/node_modules/pivottable/dist/pivot.tr.min.js.map +1 -0
- data/public/node_modules/pivottable/dist/tips_data.min.js +247 -0
- data/public/node_modules/pivottable/examples/c3.html +61 -0
- data/public/node_modules/pivottable/examples/d3.html +49 -0
- data/public/node_modules/pivottable/examples/fully_loaded.html +80 -0
- data/public/node_modules/pivottable/examples/gchart.html +53 -0
- data/public/node_modules/pivottable/examples/gh-fork-ribbon.css +140 -0
- data/public/node_modules/pivottable/examples/gh-fork-ribbon.ie.css +78 -0
- data/public/node_modules/pivottable/examples/index.html +85 -0
- data/public/node_modules/pivottable/examples/local.html +74 -0
- data/public/node_modules/pivottable/examples/montreal_2014.csv +366 -0
- data/public/node_modules/pivottable/examples/montreal_2014.html +106 -0
- data/public/node_modules/pivottable/examples/mps.csv +309 -0
- data/public/node_modules/pivottable/examples/mps.html +45 -0
- data/public/node_modules/pivottable/examples/mps.json +1 -0
- data/public/node_modules/pivottable/examples/mps_agg.html +44 -0
- data/public/node_modules/pivottable/examples/mps_csv.html +42 -0
- data/public/node_modules/pivottable/examples/mps_export.html +44 -0
- data/public/node_modules/pivottable/examples/mps_fr.html +40 -0
- data/public/node_modules/pivottable/examples/mps_prepop.html +42 -0
- data/public/node_modules/pivottable/examples/onrefresh.html +52 -0
- data/public/node_modules/pivottable/examples/rcsvs.html +87 -0
- data/public/node_modules/pivottable/examples/scatter.html +53 -0
- data/public/node_modules/pivottable/examples/show_code.js +17 -0
- data/public/node_modules/pivottable/examples/simple.html +41 -0
- data/public/node_modules/pivottable/examples/simple_agg.html +51 -0
- data/public/node_modules/pivottable/examples/simple_function.html +57 -0
- data/public/node_modules/pivottable/examples/simple_ui.html +42 -0
- data/public/node_modules/pivottable/examples/simple_ui_from_table.html +60 -0
- data/public/node_modules/pivottable/export_renderers.coffee +57 -0
- data/public/node_modules/pivottable/gchart_renderers.coffee +111 -0
- data/public/node_modules/pivottable/gulpFile.js +95 -0
- data/public/node_modules/pivottable/images/animation.gif +0 -0
- data/public/node_modules/pivottable/images/filters.png +0 -0
- data/public/node_modules/pivottable/images/gender_age_bins.png +0 -0
- data/public/node_modules/pivottable/images/gender_imbalance.png +0 -0
- data/public/node_modules/pivottable/images/gender_imbalance_instructions.png +0 -0
- data/public/node_modules/pivottable/images/initial_state.png +0 -0
- data/public/node_modules/pivottable/images/province_x_party_heatmap.png +0 -0
- data/public/node_modules/pivottable/images/province_x_party_heatmap_instructions.png +0 -0
- data/public/node_modules/pivottable/images/simple.png +0 -0
- data/public/node_modules/pivottable/images/simple_ui.png +0 -0
- data/public/node_modules/pivottable/images/whats_what.png +0 -0
- data/public/node_modules/pivottable/index.html +14 -0
- data/public/node_modules/pivottable/node_modules/jquery/AUTHORS.txt +278 -0
- data/public/node_modules/pivottable/node_modules/jquery/LICENSE.txt +36 -0
- data/public/node_modules/pivottable/node_modules/jquery/README.md +65 -0
- data/public/node_modules/pivottable/node_modules/jquery/bower.json +14 -0
- data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.js +9842 -0
- data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.min.js +4 -0
- data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.min.map +1 -0
- data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.slim.js +7877 -0
- data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.slim.min.js +4 -0
- data/public/node_modules/pivottable/node_modules/jquery/dist/jquery.slim.min.map +1 -0
- data/public/node_modules/pivottable/node_modules/jquery/package.json +122 -0
- data/public/node_modules/pivottable/node_modules/jquery/sizzle/LICENSE.txt +36 -0
- data/public/node_modules/pivottable/node_modules/jquery/sizzle/dist/sizzle.js +2143 -0
- data/public/node_modules/pivottable/node_modules/jquery/sizzle/dist/sizzle.min.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/sizzle/dist/sizzle.min.map +1 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax.js +845 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/jsonp.js +100 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/load.js +83 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/parseJSON.js +13 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/parseXML.js +27 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/script.js +68 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/var/location.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/var/nonce.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/var/rquery.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/ajax/xhr.js +167 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/attributes.js +11 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/attributes/attr.js +142 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/attributes/classes.js +177 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/attributes/prop.js +125 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/attributes/support.js +36 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/attributes/val.js +177 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/callbacks.js +232 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core.js +494 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/DOMEval.js +14 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/access.js +65 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/init.js +134 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/parseHTML.js +41 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/ready.js +103 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/support.js +18 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/core/var/rsingleTag.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css.js +515 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/addGetHookIf.js +24 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/adjustCSS.js +65 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/curCSS.js +60 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/defaultDisplay.js +72 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/hiddenVisibleSelectors.js +18 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/showHide.js +48 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/support.js +121 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/var/cssExpand.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/var/getStyles.js +15 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/var/isHidden.js +16 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/var/rmargin.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/var/rnumnonpx.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/css/var/swap.js +24 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data.js +187 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data/Data.js +200 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data/accepts.js +20 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data/support.js +23 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data/var/acceptData.js +18 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data/var/dataPriv.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/data/var/dataUser.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/deferred.js +158 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/deferred/exceptionHook.js +19 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/deprecated.js +32 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/dimensions.js +54 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/effects.js +629 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/effects/Tween.js +121 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/effects/animatedSelector.js +13 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/effects/support.js +58 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/event.js +710 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/event/ajax.js +20 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/event/alias.js +27 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/event/focusin.js +53 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/event/support.js +9 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/event/trigger.js +199 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/exports/amd.js +24 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/exports/global.js +26 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/intro.js +44 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/jquery.js +37 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation.js +481 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/_evalUrl.js +20 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/buildFragment.js +102 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/createSafeFragment.js +20 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/getAll.js +21 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/setGlobalEval.js +20 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/support.js +33 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/nodeNames.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rleadingWhitespace.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rscriptType.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/var/rtagName.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/manipulation/wrapMap.js +27 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/offset.js +218 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/outro.js +2 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/queue.js +143 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/queue/delay.js +22 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/selector-native.js +211 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/selector-sizzle.js +14 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/selector.js +1 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/serialize.js +125 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/support.js +63 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/traversing.js +175 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/traversing/findFilter.js +100 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/traversing/var/dir.js +20 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/traversing/var/siblings.js +15 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/arr.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/class2type.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/concat.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/deletedIds.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/document.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/documentElement.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/hasOwn.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/indexOf.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/pnum.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/push.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/rcssNum.js +7 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/rnotwhite.js +3 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/slice.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/support.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/var/toString.js +5 -0
- data/public/node_modules/pivottable/node_modules/jquery/src/wrap.js +79 -0
- data/public/node_modules/pivottable/package.json +70 -0
- data/public/node_modules/pivottable/pivot.coffee +957 -0
- data/public/node_modules/pivottable/pivot.es.coffee +57 -0
- data/public/node_modules/pivottable/pivot.fr.coffee +57 -0
- data/public/node_modules/pivottable/pivot.nl.coffee +55 -0
- data/public/node_modules/pivottable/pivot.pt.coffee +80 -0
- data/public/node_modules/pivottable/pivot.ru.coffee +56 -0
- data/public/node_modules/pivottable/pivot.tr.coffee +80 -0
- data/public/node_modules/pivottable/pivottable.jquery.json +33 -0
- data/public/node_modules/pivottable/tests/boot.js +152 -0
- data/public/node_modules/pivottable/tests/index.html +35 -0
- data/public/node_modules/pivottable/tests/pivot_spec.coffee +458 -0
- data/public/vendor.js +5 -0
- metadata +232 -1
@@ -0,0 +1,73 @@
|
|
1
|
+
callWithJQuery = (pivotModule) ->
|
2
|
+
if typeof exports is "object" and typeof module is "object" # CommonJS
|
3
|
+
pivotModule require("jquery"), require("d3")
|
4
|
+
else if typeof define is "function" and define.amd # AMD
|
5
|
+
define ["jquery", "d3"], pivotModule
|
6
|
+
# Plain browser env
|
7
|
+
else
|
8
|
+
pivotModule jQuery, d3
|
9
|
+
|
10
|
+
callWithJQuery ($, d3) ->
|
11
|
+
|
12
|
+
$.pivotUtilities.d3_renderers = Treemap: (pivotData, opts) ->
|
13
|
+
defaults =
|
14
|
+
localeStrings: {}
|
15
|
+
d3:
|
16
|
+
width: -> $(window).width() / 1.4
|
17
|
+
height: -> $(window).height() / 1.4
|
18
|
+
|
19
|
+
opts = $.extend defaults, opts
|
20
|
+
|
21
|
+
|
22
|
+
result = $("<div>").css(width: "100%", height: "100%")
|
23
|
+
|
24
|
+
tree = name: "All", children: []
|
25
|
+
addToTree = (tree, path, value) ->
|
26
|
+
if path.length == 0
|
27
|
+
tree.value = value
|
28
|
+
return
|
29
|
+
tree.children ?= []
|
30
|
+
x = path.shift()
|
31
|
+
for child in tree.children when child.name == x
|
32
|
+
addToTree(child, path, value)
|
33
|
+
return
|
34
|
+
newChild = name: x
|
35
|
+
addToTree(newChild, path, value)
|
36
|
+
tree.children.push newChild
|
37
|
+
|
38
|
+
for rowKey in pivotData.getRowKeys()
|
39
|
+
value = pivotData.getAggregator(rowKey, []).value()
|
40
|
+
if value?
|
41
|
+
addToTree(tree, rowKey, value)
|
42
|
+
|
43
|
+
color = d3.scale.category10()
|
44
|
+
width = opts.d3.width()
|
45
|
+
height = opts.d3.height()
|
46
|
+
|
47
|
+
treemap = d3.layout.treemap()
|
48
|
+
.size([width, height])
|
49
|
+
.sticky(true)
|
50
|
+
.value( (d) -> d.size )
|
51
|
+
|
52
|
+
d3.select(result[0])
|
53
|
+
.append("div")
|
54
|
+
.style("position", "relative")
|
55
|
+
.style("width", width + "px")
|
56
|
+
.style("height", height + "px")
|
57
|
+
.datum(tree).selectAll(".node")
|
58
|
+
.data(treemap.padding([15,0,0,0]).value( (d) -> d.value ).nodes)
|
59
|
+
.enter().append("div")
|
60
|
+
.attr("class", "node")
|
61
|
+
.style("background", (d) -> if d.children? then "lightgrey" else color(d.name) )
|
62
|
+
.text( (d) -> d.name )
|
63
|
+
.call ->
|
64
|
+
this.style("left", (d) -> d.x+"px" )
|
65
|
+
.style("top", (d) -> d.y+"px" )
|
66
|
+
.style("width", (d) -> Math.max(0, d.dx - 1)+"px" )
|
67
|
+
.style("height",(d) -> Math.max(0, d.dy - 1)+"px" )
|
68
|
+
return
|
69
|
+
|
70
|
+
return result
|
71
|
+
|
72
|
+
|
73
|
+
|
@@ -0,0 +1,256 @@
|
|
1
|
+
(function() {
|
2
|
+
var callWithJQuery;
|
3
|
+
|
4
|
+
callWithJQuery = function(pivotModule) {
|
5
|
+
if (typeof exports === "object" && typeof module === "object") {
|
6
|
+
return pivotModule(require("jquery"), require("c3"));
|
7
|
+
} else if (typeof define === "function" && define.amd) {
|
8
|
+
return define(["jquery", "c3"], pivotModule);
|
9
|
+
} else {
|
10
|
+
return pivotModule(jQuery, c3);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
|
14
|
+
callWithJQuery(function($, c3) {
|
15
|
+
var makeC3Chart;
|
16
|
+
makeC3Chart = function(chartOpts) {
|
17
|
+
if (chartOpts == null) {
|
18
|
+
chartOpts = {};
|
19
|
+
}
|
20
|
+
return function(pivotData, opts) {
|
21
|
+
var agg, attrs, base, base1, base2, base3, base4, base5, colKey, colKeys, columns, dataColumns, defaults, fullAggName, groupByTitle, h, hAxisTitle, headers, i, j, k, l, len, len1, len2, len3, len4, m, numCharsInHAxis, numSeries, params, ref, ref1, ref2, ref3, renderArea, result, rotationAngle, row, rowHeader, rowKey, rowKeys, s, scatterData, series, title, titleText, vAxisTitle, val, vals, x, xs;
|
22
|
+
defaults = {
|
23
|
+
localeStrings: {
|
24
|
+
vs: "vs",
|
25
|
+
by: "by"
|
26
|
+
},
|
27
|
+
c3: {}
|
28
|
+
};
|
29
|
+
opts = $.extend(true, defaults, opts);
|
30
|
+
if ((base = opts.c3).size == null) {
|
31
|
+
base.size = {};
|
32
|
+
}
|
33
|
+
if ((base1 = opts.c3.size).width == null) {
|
34
|
+
base1.width = window.innerWidth / 1.4;
|
35
|
+
}
|
36
|
+
if ((base2 = opts.c3.size).height == null) {
|
37
|
+
base2.height = window.innerHeight / 1.4 - 50;
|
38
|
+
}
|
39
|
+
if (chartOpts.type == null) {
|
40
|
+
chartOpts.type = "line";
|
41
|
+
}
|
42
|
+
rowKeys = pivotData.getRowKeys();
|
43
|
+
if (rowKeys.length === 0) {
|
44
|
+
rowKeys.push([]);
|
45
|
+
}
|
46
|
+
colKeys = pivotData.getColKeys();
|
47
|
+
if (colKeys.length === 0) {
|
48
|
+
colKeys.push([]);
|
49
|
+
}
|
50
|
+
headers = (function() {
|
51
|
+
var i, len, results;
|
52
|
+
results = [];
|
53
|
+
for (i = 0, len = colKeys.length; i < len; i++) {
|
54
|
+
h = colKeys[i];
|
55
|
+
results.push(h.join("-"));
|
56
|
+
}
|
57
|
+
return results;
|
58
|
+
})();
|
59
|
+
rotationAngle = 0;
|
60
|
+
fullAggName = pivotData.aggregatorName;
|
61
|
+
if (pivotData.valAttrs.length) {
|
62
|
+
fullAggName += "(" + (pivotData.valAttrs.join(", ")) + ")";
|
63
|
+
}
|
64
|
+
if (chartOpts.type === "scatter") {
|
65
|
+
scatterData = {
|
66
|
+
x: {},
|
67
|
+
y: {},
|
68
|
+
t: {}
|
69
|
+
};
|
70
|
+
attrs = pivotData.rowAttrs.concat(pivotData.colAttrs);
|
71
|
+
vAxisTitle = (ref = attrs[0]) != null ? ref : "";
|
72
|
+
hAxisTitle = (ref1 = attrs[1]) != null ? ref1 : "";
|
73
|
+
groupByTitle = attrs.slice(2).join("-");
|
74
|
+
titleText = vAxisTitle;
|
75
|
+
if (hAxisTitle !== "") {
|
76
|
+
titleText += " " + opts.localeStrings.vs + " " + hAxisTitle;
|
77
|
+
}
|
78
|
+
if (groupByTitle !== "") {
|
79
|
+
titleText += " " + opts.localeStrings.by + " " + groupByTitle;
|
80
|
+
}
|
81
|
+
for (i = 0, len = rowKeys.length; i < len; i++) {
|
82
|
+
rowKey = rowKeys[i];
|
83
|
+
for (j = 0, len1 = colKeys.length; j < len1; j++) {
|
84
|
+
colKey = colKeys[j];
|
85
|
+
agg = pivotData.getAggregator(rowKey, colKey);
|
86
|
+
if (agg.value() != null) {
|
87
|
+
vals = rowKey.concat(colKey);
|
88
|
+
series = vals.slice(2).join("-");
|
89
|
+
if (series === "") {
|
90
|
+
series = "series";
|
91
|
+
}
|
92
|
+
if ((base3 = scatterData.x)[series] == null) {
|
93
|
+
base3[series] = [];
|
94
|
+
}
|
95
|
+
if ((base4 = scatterData.y)[series] == null) {
|
96
|
+
base4[series] = [];
|
97
|
+
}
|
98
|
+
if ((base5 = scatterData.t)[series] == null) {
|
99
|
+
base5[series] = [];
|
100
|
+
}
|
101
|
+
scatterData.y[series].push((ref2 = vals[0]) != null ? ref2 : 0);
|
102
|
+
scatterData.x[series].push((ref3 = vals[1]) != null ? ref3 : 0);
|
103
|
+
scatterData.t[series].push(agg.format(agg.value()));
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
} else {
|
108
|
+
numCharsInHAxis = 0;
|
109
|
+
for (k = 0, len2 = headers.length; k < len2; k++) {
|
110
|
+
x = headers[k];
|
111
|
+
numCharsInHAxis += x.length;
|
112
|
+
}
|
113
|
+
if (numCharsInHAxis > 50) {
|
114
|
+
rotationAngle = 45;
|
115
|
+
}
|
116
|
+
columns = [];
|
117
|
+
for (l = 0, len3 = rowKeys.length; l < len3; l++) {
|
118
|
+
rowKey = rowKeys[l];
|
119
|
+
rowHeader = rowKey.join("-");
|
120
|
+
row = [rowHeader === "" ? pivotData.aggregatorName : rowHeader];
|
121
|
+
for (m = 0, len4 = colKeys.length; m < len4; m++) {
|
122
|
+
colKey = colKeys[m];
|
123
|
+
val = parseFloat(pivotData.getAggregator(rowKey, colKey).value());
|
124
|
+
if (isFinite(val)) {
|
125
|
+
if (val < 1) {
|
126
|
+
row.push(val.toPrecision(3));
|
127
|
+
} else {
|
128
|
+
row.push(val.toFixed(3));
|
129
|
+
}
|
130
|
+
} else {
|
131
|
+
row.push(null);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
columns.push(row);
|
135
|
+
}
|
136
|
+
vAxisTitle = pivotData.aggregatorName + (pivotData.valAttrs.length ? "(" + (pivotData.valAttrs.join(", ")) + ")" : "");
|
137
|
+
hAxisTitle = pivotData.colAttrs.join("-");
|
138
|
+
titleText = fullAggName;
|
139
|
+
if (hAxisTitle !== "") {
|
140
|
+
titleText += " " + opts.localeStrings.vs + " " + hAxisTitle;
|
141
|
+
}
|
142
|
+
groupByTitle = pivotData.rowAttrs.join("-");
|
143
|
+
if (groupByTitle !== "") {
|
144
|
+
titleText += " " + opts.localeStrings.by + " " + groupByTitle;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
title = $("<p>", {
|
148
|
+
style: "text-align: center; font-weight: bold"
|
149
|
+
});
|
150
|
+
title.text(titleText);
|
151
|
+
params = {
|
152
|
+
axis: {
|
153
|
+
y: {
|
154
|
+
label: vAxisTitle
|
155
|
+
},
|
156
|
+
x: {
|
157
|
+
label: hAxisTitle,
|
158
|
+
tick: {
|
159
|
+
rotate: rotationAngle,
|
160
|
+
multiline: false
|
161
|
+
}
|
162
|
+
}
|
163
|
+
},
|
164
|
+
data: {
|
165
|
+
type: chartOpts.type
|
166
|
+
},
|
167
|
+
tooltip: {
|
168
|
+
grouped: false
|
169
|
+
},
|
170
|
+
color: {
|
171
|
+
pattern: ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707", "#651067", "#329262", "#5574a6", "#3b3eac"]
|
172
|
+
}
|
173
|
+
};
|
174
|
+
$.extend(params, opts.c3);
|
175
|
+
if (chartOpts.type === "scatter") {
|
176
|
+
xs = {};
|
177
|
+
numSeries = 0;
|
178
|
+
dataColumns = [];
|
179
|
+
for (s in scatterData.x) {
|
180
|
+
numSeries += 1;
|
181
|
+
xs[s] = s + "_x";
|
182
|
+
dataColumns.push([s + "_x"].concat(scatterData.x[s]));
|
183
|
+
dataColumns.push([s].concat(scatterData.y[s]));
|
184
|
+
}
|
185
|
+
params.data.xs = xs;
|
186
|
+
params.data.columns = dataColumns;
|
187
|
+
params.axis.x.tick = {
|
188
|
+
fit: false
|
189
|
+
};
|
190
|
+
if (numSeries === 1) {
|
191
|
+
params.legend = {
|
192
|
+
show: false
|
193
|
+
};
|
194
|
+
}
|
195
|
+
params.tooltip.format = {
|
196
|
+
title: function() {
|
197
|
+
return fullAggName;
|
198
|
+
},
|
199
|
+
name: function() {
|
200
|
+
return "";
|
201
|
+
},
|
202
|
+
value: function(a, b, c, d) {
|
203
|
+
return scatterData.t[c][d];
|
204
|
+
}
|
205
|
+
};
|
206
|
+
} else {
|
207
|
+
params.axis.x.type = 'category';
|
208
|
+
params.axis.x.categories = headers;
|
209
|
+
params.data.columns = columns;
|
210
|
+
}
|
211
|
+
if (chartOpts.stacked != null) {
|
212
|
+
params.data.groups = [
|
213
|
+
(function() {
|
214
|
+
var len5, n, results;
|
215
|
+
results = [];
|
216
|
+
for (n = 0, len5 = rowKeys.length; n < len5; n++) {
|
217
|
+
x = rowKeys[n];
|
218
|
+
results.push(x.join("-"));
|
219
|
+
}
|
220
|
+
return results;
|
221
|
+
})()
|
222
|
+
];
|
223
|
+
}
|
224
|
+
renderArea = $("<div>", {
|
225
|
+
style: "display:none;"
|
226
|
+
}).appendTo($("body"));
|
227
|
+
result = $("<div>").appendTo(renderArea);
|
228
|
+
params.bindto = result[0];
|
229
|
+
c3.generate(params);
|
230
|
+
result.detach();
|
231
|
+
renderArea.remove();
|
232
|
+
return $("<div>").append(title, result);
|
233
|
+
};
|
234
|
+
};
|
235
|
+
return $.pivotUtilities.c3_renderers = {
|
236
|
+
"Line Chart": makeC3Chart(),
|
237
|
+
"Bar Chart": makeC3Chart({
|
238
|
+
type: "bar"
|
239
|
+
}),
|
240
|
+
"Stacked Bar Chart": makeC3Chart({
|
241
|
+
type: "bar",
|
242
|
+
stacked: true
|
243
|
+
}),
|
244
|
+
"Area Chart": makeC3Chart({
|
245
|
+
type: "area",
|
246
|
+
stacked: true
|
247
|
+
}),
|
248
|
+
"Scatter Chart": makeC3Chart({
|
249
|
+
type: "scatter"
|
250
|
+
})
|
251
|
+
};
|
252
|
+
});
|
253
|
+
|
254
|
+
}).call(this);
|
255
|
+
|
256
|
+
//# sourceMappingURL=c3_renderers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["c3_renderers.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA;;EAAA,cAAA,GAAiB,SAAC,WAAD;IACb,IAAG,OAAO,OAAP,KAAkB,QAAlB,IAA+B,OAAO,MAAP,KAAiB,QAAnD;aACI,WAAA,CAAY,OAAA,CAAQ,QAAR,CAAZ,EAA+B,OAAA,CAAQ,IAAR,CAA/B,EADJ;KAAA,MAEK,IAAG,OAAO,MAAP,KAAiB,UAAjB,IAAgC,MAAM,CAAC,GAA1C;aACD,MAAA,CAAO,CAAC,QAAD,EAAW,IAAX,CAAP,EAAyB,WAAzB,EADC;KAAA,MAAA;aAID,WAAA,CAAY,MAAZ,EAAoB,EAApB,EAJC;;EAHQ;;EASjB,cAAA,CAAe,SAAC,CAAD,EAA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CAAC,CAAC,cAAc,CAAC,YAAjB,GACI;MAAA,YAAA,EAAc,WAAA,CAAA,CAAd;MACA,WAAA,EAAa,WAAA,CAAY;QAAA,IAAA,EAAM,KAAN;OAAZ,CADb;MAEA,mBAAA,EAAqB,WAAA,CAAY;QAAA,IAAA,EAAM,KAAN;QAAa,OAAA,EAAS,IAAtB;OAAZ,CAFrB;MAGA,YAAA,EAAc,WAAA,CAAY;QAAA,IAAA,EAAM,MAAN;QAAc,OAAA,EAAS,IAAvB;OAAZ,CAHd;MAIA,eAAA,EAAiB,WAAA,CAAY;QAAA,IAAA,EAAM,SAAN;OAAZ,CAJjB;;EA7IO,CAAf;AATA","file":"c3_renderers.js","sourceRoot":"/source/","sourcesContent":["callWithJQuery = (pivotModule) ->\n if typeof exports is \"object\" and typeof module is \"object\" # CommonJS\n pivotModule require(\"jquery\"), require(\"c3\")\n else if typeof define is \"function\" and define.amd # AMD\n define [\"jquery\", \"c3\"], pivotModule\n # Plain browser env\n else\n pivotModule jQuery, c3\n \ncallWithJQuery ($, c3) ->\n\n makeC3Chart = (chartOpts = {}) -> (pivotData, opts) ->\n defaults =\n localeStrings:\n vs: \"vs\"\n by: \"by\"\n c3: {}\n\n opts = $.extend true, defaults, opts\n opts.c3.size ?= {}\n opts.c3.size.width ?= window.innerWidth / 1.4\n opts.c3.size.height ?= window.innerHeight / 1.4 - 50\n chartOpts.type ?= \"line\"\n\n rowKeys = pivotData.getRowKeys()\n rowKeys.push [] if rowKeys.length == 0\n colKeys = pivotData.getColKeys()\n colKeys.push [] if colKeys.length == 0\n\n headers = (h.join(\"-\") for h in colKeys)\n rotationAngle = 0\n\n fullAggName = pivotData.aggregatorName \n if pivotData.valAttrs.length\n fullAggName += \"(#{pivotData.valAttrs.join(\", \")})\"\n\n if chartOpts.type == \"scatter\"\n scatterData = x:{}, y:{}, t:{}\n attrs = pivotData.rowAttrs.concat(pivotData.colAttrs)\n vAxisTitle = attrs[0] ? \"\"\n hAxisTitle = attrs[1] ? \"\" \n groupByTitle = attrs.slice(2).join(\"-\")\n titleText = vAxisTitle\n titleText += \" #{opts.localeStrings.vs} #{hAxisTitle}\" if hAxisTitle != \"\"\n titleText += \" #{opts.localeStrings.by} #{groupByTitle}\" if groupByTitle != \"\"\n for rowKey in rowKeys\n for colKey in colKeys\n agg = pivotData.getAggregator(rowKey, colKey)\n if agg.value()?\n vals = rowKey.concat(colKey)\n series = vals.slice(2).join(\"-\")\n if series == \"\" then series = \"series\"\n scatterData.x[series] ?= []\n scatterData.y[series] ?= []\n scatterData.t[series] ?= []\n scatterData.y[series].push vals[0] ? 0\n scatterData.x[series].push vals[1] ? 0\n scatterData.t[series].push agg.format(agg.value())\n else\n numCharsInHAxis = 0\n for x in headers\n numCharsInHAxis += x.length\n if numCharsInHAxis > 50\n rotationAngle = 45\n\n columns = []\n for rowKey in rowKeys\n rowHeader = rowKey.join(\"-\")\n row = [if rowHeader == \"\" then pivotData.aggregatorName else rowHeader]\n for colKey in colKeys\n val = parseFloat pivotData.getAggregator(rowKey, colKey).value()\n if isFinite(val)\n if val < 1\n row.push val.toPrecision(3)\n else\n row.push val.toFixed(3)\n else\n row.push null\n columns.push row\n\n vAxisTitle = pivotData.aggregatorName+ \n if pivotData.valAttrs.length then \"(#{pivotData.valAttrs.join(\", \")})\" else \"\"\n hAxisTitle = pivotData.colAttrs.join(\"-\")\n\n titleText = fullAggName\n titleText += \" #{opts.localeStrings.vs} #{hAxisTitle}\" if hAxisTitle != \"\"\n groupByTitle = pivotData.rowAttrs.join(\"-\")\n titleText += \" #{opts.localeStrings.by} #{groupByTitle}\" if groupByTitle != \"\"\n \n title = $(\"<p>\", {style: \"text-align: center; font-weight: bold\"})\n title.text(titleText)\n\n params = \n axis: \n y:\n label: vAxisTitle\n x:\n label: hAxisTitle\n tick:\n rotate: rotationAngle\n multiline: false\n data: \n type: chartOpts.type\n tooltip:\n grouped: false\n color: \n pattern: [ \"#3366cc\", \"#dc3912\", \"#ff9900\", \"#109618\",\n \"#990099\", \"#0099c6\", \"#dd4477\", \"#66aa00\",\n \"#b82e2e\", \"#316395\", \"#994499\", \"#22aa99\",\n \"#aaaa11\", \"#6633cc\", \"#e67300\", \"#8b0707\",\n \"#651067\", \"#329262\", \"#5574a6\", \"#3b3eac\" ]\n\n\n $.extend params, opts.c3\n\n if chartOpts.type == \"scatter\"\n xs = {}\n numSeries = 0\n dataColumns = []\n for s of scatterData.x\n numSeries += 1\n xs[s] = s+\"_x\"\n dataColumns.push [s+\"_x\"].concat(scatterData.x[s])\n dataColumns.push [s].concat(scatterData.y[s])\n params.data.xs = xs\n params.data.columns = dataColumns\n params.axis.x.tick = fit: false\n if numSeries == 1\n params.legend = show: false \n params.tooltip.format = \n title: -> fullAggName\n name: -> \"\"\n value: (a,b,c,d) -> scatterData.t[c][d]\n else\n params.axis.x.type= 'category'\n params.axis.x.categories = headers\n params.data.columns = columns\n\n\n if chartOpts.stacked?\n params.data.groups = [x.join(\"-\") for x in rowKeys]\n renderArea = $(\"<div>\", style: \"display:none;\").appendTo $(\"body\")\n result = $(\"<div>\").appendTo renderArea\n params.bindto = result[0]\n c3.generate params\n result.detach()\n renderArea.remove()\n return $(\"<div>\").append title, result\n\n $.pivotUtilities.c3_renderers = \n \"Line Chart\": makeC3Chart()\n \"Bar Chart\": makeC3Chart(type: \"bar\")\n \"Stacked Bar Chart\": makeC3Chart(type: \"bar\", stacked: true)\n \"Area Chart\": makeC3Chart(type: \"area\", stacked: true)\n \"Scatter Chart\": makeC3Chart(type: \"scatter\")\n"]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
(function(){var t;(t=function(t){return"object"==typeof exports&&"object"==typeof module?t(require("jquery"),require("c3")):"function"==typeof define&&define.amd?define(["jquery","c3"],t):t(jQuery,c3)})(function(t,e){var n;return n=function(n){return null==n&&(n={}),function(r,a){var l,o,i,s,c,u,g,p,h,d,f,y,v,x,b,j,m,w,A,S,k,C,q,z,F,N,_,B,K,T,H,L,P,Q,R,U,W,D,E,G,I,J,M,O,V,X,Y,Z,$,tt,et,nt;if(v={localeStrings:{vs:"vs",by:"by"},c3:{}},a=t.extend(!0,v,a),null==(i=a.c3).size&&(i.size={}),null==(s=a.c3.size).width&&(s.width=window.innerWidth/1.4),null==(c=a.c3.size).height&&(c.height=window.innerHeight/1.4-50),null==n.type&&(n.type="line"),J=r.getRowKeys(),0===J.length&&J.push([]),d=r.getColKeys(),0===d.length&&d.push([]),w=function(){var t,e,n;for(n=[],t=0,e=d.length;e>t;t++)j=d[t],n.push(j.join("-"));return n}(),D=0,x=r.aggregatorName,r.valAttrs.length&&(x+="("+r.valAttrs.join(", ")+")"),"scatter"===n.type)for(O={x:{},y:{},t:{}},o=r.rowAttrs.concat(r.colAttrs),Z=null!=(L=o[0])?L:"",m=null!=(P=o[1])?P:"",b=o.slice(2).join("-"),Y=Z,""!==m&&(Y+=" "+a.localeStrings.vs+" "+m),""!==b&&(Y+=" "+a.localeStrings.by+" "+b),A=0,q=J.length;q>A;A++)for(I=J[A],S=0,z=d.length;z>S;S++)h=d[S],l=r.getAggregator(I,h),null!=l.value()&&(tt=I.concat(h),V=tt.slice(2).join("-"),""===V&&(V="series"),null==(u=O.x)[V]&&(u[V]=[]),null==(g=O.y)[V]&&(g[V]=[]),null==(p=O.t)[V]&&(p[V]=[]),O.y[V].push(null!=(Q=tt[0])?Q:0),O.x[V].push(null!=(R=tt[1])?R:0),O.t[V].push(l.format(l.value())));else{for(K=0,k=0,F=w.length;F>k;k++)et=w[k],K+=et.length;for(K>50&&(D=45),f=[],C=0,N=J.length;N>C;C++){for(I=J[C],G=I.join("-"),E=[""===G?r.aggregatorName:G],B=0,_=d.length;_>B;B++)h=d[B],$=parseFloat(r.getAggregator(I,h).value()),isFinite($)?1>$?E.push($.toPrecision(3)):E.push($.toFixed(3)):E.push(null);f.push(E)}Z=r.aggregatorName+(r.valAttrs.length?"("+r.valAttrs.join(", ")+")":""),m=r.colAttrs.join("-"),Y=x,""!==m&&(Y+=" "+a.localeStrings.vs+" "+m),b=r.rowAttrs.join("-"),""!==b&&(Y+=" "+a.localeStrings.by+" "+b)}if(X=t("<p>",{style:"text-align: center; font-weight: bold"}),X.text(Y),H={axis:{y:{label:Z},x:{label:m,tick:{rotate:D,multiline:!1}}},data:{type:n.type},tooltip:{grouped:!1},color:{pattern:["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395","#994499","#22aa99","#aaaa11","#6633cc","#e67300","#8b0707","#651067","#329262","#5574a6","#3b3eac"]}},t.extend(H,a.c3),"scatter"===n.type){nt={},T=0,y=[];for(M in O.x)T+=1,nt[M]=M+"_x",y.push([M+"_x"].concat(O.x[M])),y.push([M].concat(O.y[M]));H.data.xs=nt,H.data.columns=y,H.axis.x.tick={fit:!1},1===T&&(H.legend={show:!1}),H.tooltip.format={title:function(){return x},name:function(){return""},value:function(t,e,n,r){return O.t[n][r]}}}else H.axis.x.type="category",H.axis.x.categories=w,H.data.columns=f;return null!=n.stacked&&(H.data.groups=[function(){var t,e,n;for(n=[],e=0,t=J.length;t>e;e++)et=J[e],n.push(et.join("-"));return n}()]),U=t("<div>",{style:"display:none;"}).appendTo(t("body")),W=t("<div>").appendTo(U),H.bindto=W[0],e.generate(H),W.detach(),U.remove(),t("<div>").append(X,W)}},t.pivotUtilities.c3_renderers={"Line Chart":n(),"Bar Chart":n({type:"bar"}),"Stacked Bar Chart":n({type:"bar",stacked:!0}),"Area Chart":n({type:"area",stacked:!0}),"Scatter Chart":n({type:"scatter"})}})}).call(this);
|
2
|
+
//# sourceMappingURL=c3_renderers.min.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["/source/c3_renderers.coffee","c3_renderers.min.js"],"names":["callWithJQuery","pivotModule","exports","module","require","define","amd","jQuery","c3","$","makeC3Chart","chartOpts","pivotData","opts","agg","attrs","base","base1","base2","base3","base4","base5","colKey","colKeys","columns","dataColumns","defaults","fullAggName","groupByTitle","h","hAxisTitle","headers","i","j","k","l","len","len1","len2","len3","len4","m","numCharsInHAxis","numSeries","params","ref","ref1","ref2","ref3","renderArea","result","rotationAngle","row","rowHeader","rowKey","rowKeys","s","scatterData","series","title","titleText","vAxisTitle","val","vals","x","xs","localeStrings","vs","by","extend","size","width","window","innerWidth","height","innerHeight","type","getRowKeys","length","push","getColKeys","results","join","aggregatorName","valAttrs","y","t","rowAttrs","concat","colAttrs","slice","getAggregator","value","format","parseFloat","isFinite","toPrecision","toFixed","style","text","axis","label","tick","rotate","multiline","data","tooltip","grouped","color","pattern","fit","legend","show","name","a","b","c","d","categories","stacked","groups","len5","n","appendTo","bindto","generate","detach","remove","append","pivotUtilities","c3_renderers","Line Chart","Bar Chart","Stacked Bar Chart","Area Chart","Scatter Chart","call","this"],"mappings":"CAAA,WAAA,GAAAA,IAAAA,EAAiB,SAACC,GACd,MAAqB,gBAAXC,UAAyC,gBAAVC,QACrCF,EAAYG,QAAQ,UAAWA,QAAQ,OAClB,kBAAVC,SAAyBA,OAAOC,IAC3CD,QAAQ,SAAU,MAAOJ,GAGzBA,EAAYM,OAAQC,MAEb,SAACC,EAAGD,GAEf,GAAAE,EC+NA,OD/NAA,GAAc,SAACC,GCQb,MAHiB,OAAbA,IDLSA,MAAmB,SAACC,EAAWC,GAC1C,GAAAC,GAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,GAAAC,GAAAC,EAwBA,IAxBAvC,GACIwC,eACIC,GAAI,KACJC,GAAI,MACR5D,OAEJK,EAAOJ,EAAE4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8D,QAAQb,QACXlC,MAAO,WCkET,MDlEYhC,IACVsF,KAAM,WCoER,MDpEW,IACTrB,MAAO,SAACsB,EAAEC,EAAEC,EAAEC,GCsEhB,MDtEsB5D,GAAY6B,EAAE8B,GAAGC,SAEzCzE,GAAOwD,KAAKpC,EAAEY,KAAM,WACpBhC,EAAOwD,KAAKpC,EAAEsD,WAAavF,EAC3Ba,EAAO6D,KAAKjF,QAAUA,CAW1B,OARG,OAAAb,EAAA4G,UACC3E,EAAO6D,KAAKe,QCwEZ,WACE,GAAIC,GAAMC,EAAGzC,CAEb,KD3EoBA,KAAAyC,EAAA,EAAAD,EAAAlE,EAAAuB,OAAA2C,EAAAC,EAAAA,IC4ElB1D,GAAIT,EAAQmE,GACZzC,EAAQF,KD7EUf,GAAEkB,KAAK,KC+E3B,OAAOD,QD9EbhC,EAAaxC,EAAE,SAASyF,MAAO,kBAAiByB,SAASlH,EAAE,SAC3DyC,EAASzC,EAAE,SAASkH,SAAS1E,GAC7BL,EAAOgF,OAAS1E,EAAO,GACvB1C,EAAGqH,SAASjF,GACZM,EAAO4E,SACP7E,EAAW8E,SACJtH,EAAE,SAASuH,OAAOrE,EAAOT,KAEpCzC,EAAEwH,eAAeC,cACbC,aAAczH,IACd0H,YAAa1H,GAAYkE,KAAM,QAC/ByD,oBAAqB3H,GAAYkE,KAAM,MAAO2C,SAAS,IACvDe,aAAc5H,GAAYkE,KAAM,OAAQ2C,SAAS,IACjDgB,gBAAiB7H,GAAYkE,KAAM,iBCmGxC4D,KAAKC","file":"c3_renderers.min.js","sourcesContent":["callWithJQuery = (pivotModule) ->\n if typeof exports is \"object\" and typeof module is \"object\" # CommonJS\n pivotModule require(\"jquery\"), require(\"c3\")\n else if typeof define is \"function\" and define.amd # AMD\n define [\"jquery\", \"c3\"], pivotModule\n # Plain browser env\n else\n pivotModule jQuery, c3\n \ncallWithJQuery ($, c3) ->\n\n makeC3Chart = (chartOpts = {}) -> (pivotData, opts) ->\n defaults =\n localeStrings:\n vs: \"vs\"\n by: \"by\"\n c3: {}\n\n opts = $.extend true, defaults, opts\n opts.c3.size ?= {}\n opts.c3.size.width ?= window.innerWidth / 1.4\n opts.c3.size.height ?= window.innerHeight / 1.4 - 50\n chartOpts.type ?= \"line\"\n\n rowKeys = pivotData.getRowKeys()\n rowKeys.push [] if rowKeys.length == 0\n colKeys = pivotData.getColKeys()\n colKeys.push [] if colKeys.length == 0\n\n headers = (h.join(\"-\") for h in colKeys)\n rotationAngle = 0\n\n fullAggName = pivotData.aggregatorName \n if pivotData.valAttrs.length\n fullAggName += \"(#{pivotData.valAttrs.join(\", \")})\"\n\n if chartOpts.type == \"scatter\"\n scatterData = x:{}, y:{}, t:{}\n attrs = pivotData.rowAttrs.concat(pivotData.colAttrs)\n vAxisTitle = attrs[0] ? \"\"\n hAxisTitle = attrs[1] ? \"\" \n groupByTitle = attrs.slice(2).join(\"-\")\n titleText = vAxisTitle\n titleText += \" #{opts.localeStrings.vs} #{hAxisTitle}\" if hAxisTitle != \"\"\n titleText += \" #{opts.localeStrings.by} #{groupByTitle}\" if groupByTitle != \"\"\n for rowKey in rowKeys\n for colKey in colKeys\n agg = pivotData.getAggregator(rowKey, colKey)\n if agg.value()?\n vals = rowKey.concat(colKey)\n series = vals.slice(2).join(\"-\")\n if series == \"\" then series = \"series\"\n scatterData.x[series] ?= []\n scatterData.y[series] ?= []\n scatterData.t[series] ?= []\n scatterData.y[series].push vals[0] ? 0\n scatterData.x[series].push vals[1] ? 0\n scatterData.t[series].push agg.format(agg.value())\n else\n numCharsInHAxis = 0\n for x in headers\n numCharsInHAxis += x.length\n if numCharsInHAxis > 50\n rotationAngle = 45\n\n columns = []\n for rowKey in rowKeys\n rowHeader = rowKey.join(\"-\")\n row = [if rowHeader == \"\" then pivotData.aggregatorName else rowHeader]\n for colKey in colKeys\n val = parseFloat pivotData.getAggregator(rowKey, colKey).value()\n if isFinite(val)\n if val < 1\n row.push val.toPrecision(3)\n else\n row.push val.toFixed(3)\n else\n row.push null\n columns.push row\n\n vAxisTitle = pivotData.aggregatorName+ \n if pivotData.valAttrs.length then \"(#{pivotData.valAttrs.join(\", \")})\" else \"\"\n hAxisTitle = pivotData.colAttrs.join(\"-\")\n\n titleText = fullAggName\n titleText += \" #{opts.localeStrings.vs} #{hAxisTitle}\" if hAxisTitle != \"\"\n groupByTitle = pivotData.rowAttrs.join(\"-\")\n titleText += \" #{opts.localeStrings.by} #{groupByTitle}\" if groupByTitle != \"\"\n \n title = $(\"<p>\", {style: \"text-align: center; font-weight: bold\"})\n title.text(titleText)\n\n params = \n axis: \n y:\n label: vAxisTitle\n x:\n label: hAxisTitle\n tick:\n rotate: rotationAngle\n multiline: false\n data: \n type: chartOpts.type\n tooltip:\n grouped: false\n color: \n pattern: [ \"#3366cc\", \"#dc3912\", \"#ff9900\", \"#109618\",\n \"#990099\", \"#0099c6\", \"#dd4477\", \"#66aa00\",\n \"#b82e2e\", \"#316395\", \"#994499\", \"#22aa99\",\n \"#aaaa11\", \"#6633cc\", \"#e67300\", \"#8b0707\",\n \"#651067\", \"#329262\", \"#5574a6\", \"#3b3eac\" ]\n\n\n $.extend params, opts.c3\n\n if chartOpts.type == \"scatter\"\n xs = {}\n numSeries = 0\n dataColumns = []\n for s of scatterData.x\n numSeries += 1\n xs[s] = s+\"_x\"\n dataColumns.push [s+\"_x\"].concat(scatterData.x[s])\n dataColumns.push [s].concat(scatterData.y[s])\n params.data.xs = xs\n params.data.columns = dataColumns\n params.axis.x.tick = fit: false\n if numSeries == 1\n params.legend = show: false \n params.tooltip.format = \n title: -> fullAggName\n name: -> \"\"\n value: (a,b,c,d) -> scatterData.t[c][d]\n else\n params.axis.x.type= 'category'\n params.axis.x.categories = headers\n params.data.columns = columns\n\n\n if chartOpts.stacked?\n params.data.groups = [x.join(\"-\") for x in rowKeys]\n renderArea = $(\"<div>\", style: \"display:none;\").appendTo $(\"body\")\n result = $(\"<div>\").appendTo renderArea\n params.bindto = result[0]\n c3.generate params\n result.detach()\n renderArea.remove()\n return $(\"<div>\").append title, result\n\n $.pivotUtilities.c3_renderers = \n \"Line Chart\": makeC3Chart()\n \"Bar Chart\": makeC3Chart(type: \"bar\")\n \"Stacked Bar Chart\": makeC3Chart(type: \"bar\", stacked: true)\n \"Area Chart\": makeC3Chart(type: \"area\", stacked: true)\n \"Scatter Chart\": makeC3Chart(type: \"scatter\")\n","(function() {\n var callWithJQuery;\n\n callWithJQuery = function(pivotModule) {\n if (typeof exports === \"object\" && typeof module === \"object\") {\n return pivotModule(require(\"jquery\"), require(\"c3\"));\n } else if (typeof define === \"function\" && define.amd) {\n return define([\"jquery\", \"c3\"], pivotModule);\n } else {\n return pivotModule(jQuery, c3);\n }\n };\n\n callWithJQuery(function($, c3) {\n var makeC3Chart;\n makeC3Chart = function(chartOpts) {\n if (chartOpts == null) {\n chartOpts = {};\n }\n return function(pivotData, opts) {\n var agg, attrs, base, base1, base2, base3, base4, base5, colKey, colKeys, columns, dataColumns, defaults, fullAggName, groupByTitle, h, hAxisTitle, headers, i, j, k, l, len, len1, len2, len3, len4, m, numCharsInHAxis, numSeries, params, ref, ref1, ref2, ref3, renderArea, result, rotationAngle, row, rowHeader, rowKey, rowKeys, s, scatterData, series, title, titleText, vAxisTitle, val, vals, x, xs;\n defaults = {\n localeStrings: {\n vs: \"vs\",\n by: \"by\"\n },\n c3: {}\n };\n opts = $.extend(true, defaults, opts);\n if ((base = opts.c3).size == null) {\n base.size = {};\n }\n if ((base1 = opts.c3.size).width == null) {\n base1.width = window.innerWidth / 1.4;\n }\n if ((base2 = opts.c3.size).height == null) {\n base2.height = window.innerHeight / 1.4 - 50;\n }\n if (chartOpts.type == null) {\n chartOpts.type = \"line\";\n }\n rowKeys = pivotData.getRowKeys();\n if (rowKeys.length === 0) {\n rowKeys.push([]);\n }\n colKeys = pivotData.getColKeys();\n if (colKeys.length === 0) {\n colKeys.push([]);\n }\n headers = (function() {\n var i, len, results;\n results = [];\n for (i = 0, len = colKeys.length; i < len; i++) {\n h = colKeys[i];\n results.push(h.join(\"-\"));\n }\n return results;\n })();\n rotationAngle = 0;\n fullAggName = pivotData.aggregatorName;\n if (pivotData.valAttrs.length) {\n fullAggName += \"(\" + (pivotData.valAttrs.join(\", \")) + \")\";\n }\n if (chartOpts.type === \"scatter\") {\n scatterData = {\n x: {},\n y: {},\n t: {}\n };\n attrs = pivotData.rowAttrs.concat(pivotData.colAttrs);\n vAxisTitle = (ref = attrs[0]) != null ? ref : \"\";\n hAxisTitle = (ref1 = attrs[1]) != null ? ref1 : \"\";\n groupByTitle = attrs.slice(2).join(\"-\");\n titleText = vAxisTitle;\n if (hAxisTitle !== \"\") {\n titleText += \" \" + opts.localeStrings.vs + \" \" + hAxisTitle;\n }\n if (groupByTitle !== \"\") {\n titleText += \" \" + opts.localeStrings.by + \" \" + groupByTitle;\n }\n for (i = 0, len = rowKeys.length; i < len; i++) {\n rowKey = rowKeys[i];\n for (j = 0, len1 = colKeys.length; j < len1; j++) {\n colKey = colKeys[j];\n agg = pivotData.getAggregator(rowKey, colKey);\n if (agg.value() != null) {\n vals = rowKey.concat(colKey);\n series = vals.slice(2).join(\"-\");\n if (series === \"\") {\n series = \"series\";\n }\n if ((base3 = scatterData.x)[series] == null) {\n base3[series] = [];\n }\n if ((base4 = scatterData.y)[series] == null) {\n base4[series] = [];\n }\n if ((base5 = scatterData.t)[series] == null) {\n base5[series] = [];\n }\n scatterData.y[series].push((ref2 = vals[0]) != null ? ref2 : 0);\n scatterData.x[series].push((ref3 = vals[1]) != null ? ref3 : 0);\n scatterData.t[series].push(agg.format(agg.value()));\n }\n }\n }\n } else {\n numCharsInHAxis = 0;\n for (k = 0, len2 = headers.length; k < len2; k++) {\n x = headers[k];\n numCharsInHAxis += x.length;\n }\n if (numCharsInHAxis > 50) {\n rotationAngle = 45;\n }\n columns = [];\n for (l = 0, len3 = rowKeys.length; l < len3; l++) {\n rowKey = rowKeys[l];\n rowHeader = rowKey.join(\"-\");\n row = [rowHeader === \"\" ? pivotData.aggregatorName : rowHeader];\n for (m = 0, len4 = colKeys.length; m < len4; m++) {\n colKey = colKeys[m];\n val = parseFloat(pivotData.getAggregator(rowKey, colKey).value());\n if (isFinite(val)) {\n if (val < 1) {\n row.push(val.toPrecision(3));\n } else {\n row.push(val.toFixed(3));\n }\n } else {\n row.push(null);\n }\n }\n columns.push(row);\n }\n vAxisTitle = pivotData.aggregatorName + (pivotData.valAttrs.length ? \"(\" + (pivotData.valAttrs.join(\", \")) + \")\" : \"\");\n hAxisTitle = pivotData.colAttrs.join(\"-\");\n titleText = fullAggName;\n if (hAxisTitle !== \"\") {\n titleText += \" \" + opts.localeStrings.vs + \" \" + hAxisTitle;\n }\n groupByTitle = pivotData.rowAttrs.join(\"-\");\n if (groupByTitle !== \"\") {\n titleText += \" \" + opts.localeStrings.by + \" \" + groupByTitle;\n }\n }\n title = $(\"<p>\", {\n style: \"text-align: center; font-weight: bold\"\n });\n title.text(titleText);\n params = {\n axis: {\n y: {\n label: vAxisTitle\n },\n x: {\n label: hAxisTitle,\n tick: {\n rotate: rotationAngle,\n multiline: false\n }\n }\n },\n data: {\n type: chartOpts.type\n },\n tooltip: {\n grouped: false\n },\n color: {\n pattern: [\"#3366cc\", \"#dc3912\", \"#ff9900\", \"#109618\", \"#990099\", \"#0099c6\", \"#dd4477\", \"#66aa00\", \"#b82e2e\", \"#316395\", \"#994499\", \"#22aa99\", \"#aaaa11\", \"#6633cc\", \"#e67300\", \"#8b0707\", \"#651067\", \"#329262\", \"#5574a6\", \"#3b3eac\"]\n }\n };\n $.extend(params, opts.c3);\n if (chartOpts.type === \"scatter\") {\n xs = {};\n numSeries = 0;\n dataColumns = [];\n for (s in scatterData.x) {\n numSeries += 1;\n xs[s] = s + \"_x\";\n dataColumns.push([s + \"_x\"].concat(scatterData.x[s]));\n dataColumns.push([s].concat(scatterData.y[s]));\n }\n params.data.xs = xs;\n params.data.columns = dataColumns;\n params.axis.x.tick = {\n fit: false\n };\n if (numSeries === 1) {\n params.legend = {\n show: false\n };\n }\n params.tooltip.format = {\n title: function() {\n return fullAggName;\n },\n name: function() {\n return \"\";\n },\n value: function(a, b, c, d) {\n return scatterData.t[c][d];\n }\n };\n } else {\n params.axis.x.type = 'category';\n params.axis.x.categories = headers;\n params.data.columns = columns;\n }\n if (chartOpts.stacked != null) {\n params.data.groups = [\n (function() {\n var len5, n, results;\n results = [];\n for (n = 0, len5 = rowKeys.length; n < len5; n++) {\n x = rowKeys[n];\n results.push(x.join(\"-\"));\n }\n return results;\n })()\n ];\n }\n renderArea = $(\"<div>\", {\n style: \"display:none;\"\n }).appendTo($(\"body\"));\n result = $(\"<div>\").appendTo(renderArea);\n params.bindto = result[0];\n c3.generate(params);\n result.detach();\n renderArea.remove();\n return $(\"<div>\").append(title, result);\n };\n };\n return $.pivotUtilities.c3_renderers = {\n \"Line Chart\": makeC3Chart(),\n \"Bar Chart\": makeC3Chart({\n type: \"bar\"\n }),\n \"Stacked Bar Chart\": makeC3Chart({\n type: \"bar\",\n stacked: true\n }),\n \"Area Chart\": makeC3Chart({\n type: \"area\",\n stacked: true\n }),\n \"Scatter Chart\": makeC3Chart({\n type: \"scatter\"\n })\n };\n });\n\n}).call(this);\n\n//# sourceMappingURL=c3_renderers.js.map\n"],"sourceRoot":"/source/"}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
(function() {
|
2
|
+
var callWithJQuery;
|
3
|
+
|
4
|
+
callWithJQuery = function(pivotModule) {
|
5
|
+
if (typeof exports === "object" && typeof module === "object") {
|
6
|
+
return pivotModule(require("jquery"), require("d3"));
|
7
|
+
} else if (typeof define === "function" && define.amd) {
|
8
|
+
return define(["jquery", "d3"], pivotModule);
|
9
|
+
} else {
|
10
|
+
return pivotModule(jQuery, d3);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
|
14
|
+
callWithJQuery(function($, d3) {
|
15
|
+
return $.pivotUtilities.d3_renderers = {
|
16
|
+
Treemap: function(pivotData, opts) {
|
17
|
+
var addToTree, color, defaults, height, i, len, ref, result, rowKey, tree, treemap, value, width;
|
18
|
+
defaults = {
|
19
|
+
localeStrings: {},
|
20
|
+
d3: {
|
21
|
+
width: function() {
|
22
|
+
return $(window).width() / 1.4;
|
23
|
+
},
|
24
|
+
height: function() {
|
25
|
+
return $(window).height() / 1.4;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
};
|
29
|
+
opts = $.extend(defaults, opts);
|
30
|
+
result = $("<div>").css({
|
31
|
+
width: "100%",
|
32
|
+
height: "100%"
|
33
|
+
});
|
34
|
+
tree = {
|
35
|
+
name: "All",
|
36
|
+
children: []
|
37
|
+
};
|
38
|
+
addToTree = function(tree, path, value) {
|
39
|
+
var child, i, len, newChild, ref, x;
|
40
|
+
if (path.length === 0) {
|
41
|
+
tree.value = value;
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
if (tree.children == null) {
|
45
|
+
tree.children = [];
|
46
|
+
}
|
47
|
+
x = path.shift();
|
48
|
+
ref = tree.children;
|
49
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
50
|
+
child = ref[i];
|
51
|
+
if (!(child.name === x)) {
|
52
|
+
continue;
|
53
|
+
}
|
54
|
+
addToTree(child, path, value);
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
newChild = {
|
58
|
+
name: x
|
59
|
+
};
|
60
|
+
addToTree(newChild, path, value);
|
61
|
+
return tree.children.push(newChild);
|
62
|
+
};
|
63
|
+
ref = pivotData.getRowKeys();
|
64
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
65
|
+
rowKey = ref[i];
|
66
|
+
value = pivotData.getAggregator(rowKey, []).value();
|
67
|
+
if (value != null) {
|
68
|
+
addToTree(tree, rowKey, value);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
color = d3.scale.category10();
|
72
|
+
width = opts.d3.width();
|
73
|
+
height = opts.d3.height();
|
74
|
+
treemap = d3.layout.treemap().size([width, height]).sticky(true).value(function(d) {
|
75
|
+
return d.size;
|
76
|
+
});
|
77
|
+
d3.select(result[0]).append("div").style("position", "relative").style("width", width + "px").style("height", height + "px").datum(tree).selectAll(".node").data(treemap.padding([15, 0, 0, 0]).value(function(d) {
|
78
|
+
return d.value;
|
79
|
+
}).nodes).enter().append("div").attr("class", "node").style("background", function(d) {
|
80
|
+
if (d.children != null) {
|
81
|
+
return "lightgrey";
|
82
|
+
} else {
|
83
|
+
return color(d.name);
|
84
|
+
}
|
85
|
+
}).text(function(d) {
|
86
|
+
return d.name;
|
87
|
+
}).call(function() {
|
88
|
+
this.style("left", function(d) {
|
89
|
+
return d.x + "px";
|
90
|
+
}).style("top", function(d) {
|
91
|
+
return d.y + "px";
|
92
|
+
}).style("width", function(d) {
|
93
|
+
return Math.max(0, d.dx - 1) + "px";
|
94
|
+
}).style("height", function(d) {
|
95
|
+
return Math.max(0, d.dy - 1) + "px";
|
96
|
+
});
|
97
|
+
});
|
98
|
+
return result;
|
99
|
+
}
|
100
|
+
};
|
101
|
+
});
|
102
|
+
|
103
|
+
}).call(this);
|
104
|
+
|
105
|
+
//# sourceMappingURL=d3_renderers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["d3_renderers.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA;;EAAA,cAAA,GAAiB,SAAC,WAAD;IACb,IAAG,OAAO,OAAP,KAAkB,QAAlB,IAA+B,OAAO,MAAP,KAAiB,QAAnD;aACI,WAAA,CAAY,OAAA,CAAQ,QAAR,CAAZ,EAA+B,OAAA,CAAQ,IAAR,CAA/B,EADJ;KAAA,MAEK,IAAG,OAAO,MAAP,KAAiB,UAAjB,IAAgC,MAAM,CAAC,GAA1C;aACD,MAAA,CAAO,CAAC,QAAD,EAAW,IAAX,CAAP,EAAyB,WAAzB,EADC;KAAA,MAAA;aAID,WAAA,CAAY,MAAZ,EAAoB,EAApB,EAJC;;EAHQ;;EASjB,cAAA,CAAe,SAAC,CAAD,EAAI,EAAJ;WAEX,CAAC,CAAC,cAAc,CAAC,YAAjB,GAAgC;MAAA,OAAA,EAAS,SAAC,SAAD,EA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L,CAAW,MAAX,EAAoB,SAAC,CAAD;mBAAO,CAAC,CAAC,CAAF,GAAI;UAAX,CAApB,CACI,CAAC,KADL,CACW,KADX,EACoB,SAAC,CAAD;mBAAO,CAAC,CAAC,CAAF,GAAI;UAAX,CADpB,CAEI,CAAC,KAFL,CAEW,OAFX,EAEoB,SAAC,CAAD;mBAAO,IAAI,CAAC,GAAL,CAAS,CAAT,EAAY,CAAC,CAAC,EAAF,GAAO,CAAnB,CAAA,GAAsB;UAA7B,CAFpB,CAGI,CAAC,KAHL,CAGW,QAHX,EAGoB,SAAC,CAAD;mBAAO,IAAI,CAAC,GAAL,CAAS,CAAT,EAAY,CAAC,CAAC,EAAF,GAAO,CAAnB,CAAA,GAAsB;UAA7B,CAHpB;QADF,CAXV;AAkBA,eAAO;MA1D8B,CAAT;;EAFrB,CAAf;AATA","file":"d3_renderers.js","sourceRoot":"/source/","sourcesContent":["callWithJQuery = (pivotModule) ->\n if typeof exports is \"object\" and typeof module is \"object\" # CommonJS\n pivotModule require(\"jquery\"), require(\"d3\")\n else if typeof define is \"function\" and define.amd # AMD\n define [\"jquery\", \"d3\"], pivotModule\n # Plain browser env\n else\n pivotModule jQuery, d3\n \ncallWithJQuery ($, d3) ->\n\n $.pivotUtilities.d3_renderers = Treemap: (pivotData, opts) ->\n defaults =\n localeStrings: {}\n d3:\n width: -> $(window).width() / 1.4\n height: -> $(window).height() / 1.4\n\n opts = $.extend defaults, opts\n\n\n result = $(\"<div>\").css(width: \"100%\", height: \"100%\")\n\n tree = name: \"All\", children: []\n addToTree = (tree, path, value) ->\n if path.length == 0\n tree.value = value\n return\n tree.children ?= []\n x = path.shift()\n for child in tree.children when child.name == x\n addToTree(child, path, value)\n return\n newChild = name: x\n addToTree(newChild, path, value)\n tree.children.push newChild\n\n for rowKey in pivotData.getRowKeys()\n value = pivotData.getAggregator(rowKey, []).value()\n if value?\n addToTree(tree, rowKey, value)\n\n color = d3.scale.category10()\n width = opts.d3.width()\n height = opts.d3.height()\n\n treemap = d3.layout.treemap()\n .size([width, height])\n .sticky(true)\n .value( (d) -> d.size )\n\n d3.select(result[0])\n .append(\"div\")\n .style(\"position\", \"relative\")\n .style(\"width\", width + \"px\")\n .style(\"height\", height + \"px\")\n .datum(tree).selectAll(\".node\")\n .data(treemap.padding([15,0,0,0]).value( (d) -> d.value ).nodes)\n .enter().append(\"div\")\n .attr(\"class\", \"node\")\n .style(\"background\", (d) -> if d.children? then \"lightgrey\" else color(d.name) )\n .text( (d) -> d.name )\n .call ->\n this.style(\"left\", (d) -> d.x+\"px\" )\n .style(\"top\", (d) -> d.y+\"px\" )\n .style(\"width\", (d) -> Math.max(0, d.dx - 1)+\"px\" )\n .style(\"height\",(d) -> Math.max(0, d.dy - 1)+\"px\" )\n return\n \n return result\n \n\n\n"]}
|