Skip to content

Commit 39e139a

Browse files
committed
Merge branch 'master' into dev
This is the latest from nicolaskruchten/pivottable Conflicts: dist/pivot.js dist/pivot.js.map pivot.coffee
2 parents 75fb38c + 3cae6b0 commit 39e139a

39 files changed

+1200
-261
lines changed

c3_renderers.coffee

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
callWithJQuery = (pivotModule) ->
2+
if typeof exports is "object" and typeof module is "object" # CommonJS
3+
pivotModule require("jquery")
4+
else if typeof define is "function" and define.amd # AMD
5+
define ["jquery"], pivotModule
6+
# Plain browser env
7+
else
8+
pivotModule jQuery
9+
10+
callWithJQuery ($) ->
11+
12+
makeC3Chart = (chartType) -> (pivotData, opts) ->
13+
defaults =
14+
localeStrings:
15+
vs: "vs"
16+
by: "by"
17+
18+
opts = $.extend defaults, opts
19+
20+
rowKeys = pivotData.getRowKeys()
21+
rowKeys.push [] if rowKeys.length == 0
22+
colKeys = pivotData.getColKeys()
23+
colKeys.push [] if colKeys.length == 0
24+
25+
headers = (h.join("-") for h in colKeys)
26+
27+
columns = []
28+
for rowKey in rowKeys
29+
rowHeader = rowKey.join("-")
30+
row = [if rowHeader == "" then pivotData.aggregatorName else rowHeader]
31+
for colKey in colKeys
32+
agg = pivotData.getAggregator(rowKey, colKey)
33+
if agg.value()?
34+
row.push agg.value()
35+
else row.push null
36+
columns.push row
37+
38+
result = $("<div>")
39+
params =
40+
bindto: result[0]
41+
size:
42+
height: ($(window).height() / 1.4),
43+
width: ($(window).width() / 1.4)
44+
axis: x:
45+
type: 'category',
46+
categories: headers
47+
data:
48+
columns: columns
49+
if chartType?
50+
params.data.type = chartType
51+
c3.generate params
52+
return result
53+
54+
$.pivotUtilities.c3_renderers =
55+
"Line Chart C3": makeC3Chart()
56+
"Bar Chart C3": makeC3Chart("bar")

dist/c3_renderers.js

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/c3_renderers.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/c3_renderers.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/c3_renderers.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pivot.es.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)