diff --git a/examples/pivot.js b/examples/pivot.js
index 5f6b199d..0be1891f 100644
--- a/examples/pivot.js
+++ b/examples/pivot.js
@@ -570,18 +570,18 @@
return len;
};
pivotTableRenderer = function(pivotData) {
- var aggregator, c, colKey, colKeys, cols, i, j, r, result, rowKey, rowKeys, rows, th, totalAggregator, tr, txt, val, x;
- cols = pivotData.colAttrs;
- rows = pivotData.rowAttrs;
+ var aggregator, c, colAttrs, colKey, colKeys, i, j, r, result, rowAttrs, rowKey, rowKeys, th, totalAggregator, tr, txt, val, x;
+ colAttrs = pivotData.colAttrs;
+ rowAttrs = pivotData.rowAttrs;
rowKeys = pivotData.getRowKeys();
colKeys = pivotData.getColKeys();
result = $("
");
- for (j in cols) {
- if (!__hasProp.call(cols, j)) continue;
- c = cols[j];
+ for (j in colAttrs) {
+ if (!__hasProp.call(colAttrs, j)) continue;
+ c = colAttrs[j];
tr = $("");
- if (parseInt(j) === 0 && rows.length !== 0) {
- tr.append($("").attr("colspan", rows.length).attr("rowspan", cols.length));
+ if (parseInt(j) === 0 && rowAttrs.length !== 0) {
+ tr.append($(" | ").attr("colspan", rowAttrs.length).attr("rowspan", colAttrs.length));
}
tr.append($(" | ").text(c));
for (i in colKeys) {
@@ -590,26 +590,26 @@
x = spanSize(colKeys, parseInt(i), parseInt(j));
if (x !== -1) {
th = $(" | ").text(colKey[j]).attr("colspan", x);
- if (parseInt(j) === cols.length - 1 && rows.length !== 0) {
+ if (parseInt(j) === colAttrs.length - 1 && rowAttrs.length !== 0) {
th.attr("rowspan", 2);
}
tr.append(th);
}
}
if (parseInt(j) === 0) {
- tr.append($(" | ").text("Totals").attr("rowspan", cols.length + (rows.length === 0 ? 0 : 1)));
+ tr.append($(" | ").text("Totals").attr("rowspan", colAttrs.length + (rowAttrs.length === 0 ? 0 : 1)));
}
result.append(tr);
}
- if (rows.length !== 0) {
+ if (rowAttrs.length !== 0) {
tr = $(" |
");
- for (i in rows) {
- if (!__hasProp.call(rows, i)) continue;
- r = rows[i];
+ for (i in rowAttrs) {
+ if (!__hasProp.call(rowAttrs, i)) continue;
+ r = rowAttrs[i];
tr.append($("").text(r));
}
th = $(" | ");
- if (cols.length === 0) {
+ if (colAttrs.length === 0) {
th.addClass("pvtTotalLabel").text("Totals");
}
tr.append(th);
@@ -625,7 +625,7 @@
x = spanSize(rowKeys, parseInt(i), parseInt(j));
if (x !== -1) {
th = $(" | ").text(txt).attr("rowspan", x);
- if (parseInt(j) === rows.length - 1 && cols.length !== 0) {
+ if (parseInt(j) === rowAttrs.length - 1 && colAttrs.length !== 0) {
th.attr("colspan", 2);
}
tr.append(th);
@@ -645,7 +645,7 @@
}
tr = $(" |
");
th = $("").text("Totals");
- th.attr("colspan", rows.length + (cols.length === 0 ? 0 : 1));
+ th.attr("colspan", rowAttrs.length + (colAttrs.length === 0 ? 0 : 1));
tr.append(th);
for (j in colKeys) {
if (!__hasProp.call(colKeys, j)) continue;
diff --git a/pivot.coffee b/pivot.coffee
index ce200a46..25ac3238 100644
--- a/pivot.coffee
+++ b/pivot.coffee
@@ -287,8 +287,8 @@ spanSize = (arr, i, j) ->
return len
pivotTableRenderer = (pivotData) ->
- cols = pivotData.colAttrs
- rows = pivotData.rowAttrs
+ colAttrs = pivotData.colAttrs
+ rowAttrs = pivotData.rowAttrs
rowKeys = pivotData.getRowKeys()
colKeys = pivotData.getColKeys()
@@ -296,32 +296,32 @@ pivotTableRenderer = (pivotData) ->
result = $("")
#the first few rows are for col headers
- for own j, c of cols
+ for own j, c of colAttrs
tr = $("")
- if parseInt(j) == 0 and rows.length != 0
+ if parseInt(j) == 0 and rowAttrs.length != 0
tr.append $("")
- .attr("colspan", rows.length)
- .attr("rowspan", cols.length)
+ .attr("colspan", rowAttrs.length)
+ .attr("rowspan", colAttrs.length)
tr.append $(" | ").text(c)
for own i, colKey of colKeys
x = spanSize(colKeys, parseInt(i), parseInt(j))
if x != -1
th = $(" | ").text(colKey[j]).attr("colspan", x)
- if parseInt(j) == cols.length-1 and rows.length != 0
+ if parseInt(j) == colAttrs.length-1 and rowAttrs.length != 0
th.attr("rowspan", 2)
tr.append th
if parseInt(j) == 0
tr.append $(" | ").text("Totals")
- .attr("rowspan", cols.length + (if rows.length ==0 then 0 else 1))
+ .attr("rowspan", colAttrs.length + (if rowAttrs.length ==0 then 0 else 1))
result.append tr
#then a row for row header headers
- if rows.length !=0
+ if rowAttrs.length !=0
tr = $(" | ")
- for own i, r of rows
+ for own i, r of rowAttrs
tr.append $("").text(r)
th = $(" | ")
- if cols.length ==0
+ if colAttrs.length ==0
th.addClass("pvtTotalLabel").text("Totals")
tr.append th
result.append tr
@@ -333,7 +333,7 @@ pivotTableRenderer = (pivotData) ->
x = spanSize(rowKeys, parseInt(i), parseInt(j))
if x != -1
th = $(" | ").text(txt).attr("rowspan", x)
- if parseInt(j) == rows.length-1 and cols.length !=0
+ if parseInt(j) == rowAttrs.length-1 and colAttrs.length !=0
th.attr("colspan",2)
tr.append th
for own j, colKey of colKeys
@@ -354,7 +354,7 @@ pivotTableRenderer = (pivotData) ->
#finally, the row for col totals, and a grand total
tr = $(" | ")
th = $("").text("Totals")
- th.attr("colspan", rows.length + (if cols.length == 0 then 0 else 1))
+ th.attr("colspan", rowAttrs.length + (if colAttrs.length == 0 then 0 else 1))
tr.append th
for own j, colKey of colKeys
totalAggregator = pivotData.getAggregator([], colKey)
| |