From eff6e821050f438806fd2dde835235054546062a Mon Sep 17 00:00:00 2001 From: Seungwoo321 Date: Fri, 23 Aug 2024 07:13:42 +0900 Subject: [PATCH] fix: resolve issue #1359 --- dist/pivot.js | 9 +++++++-- dist/pivot.js.map | 2 +- dist/pivot.min.js | 2 +- dist/pivot.min.js.map | 2 +- dist/pivot_spec.js | 25 +++++++++++++++++++++++++ dist/pivot_spec.js.map | 2 +- dist/pivot_spec.min.js | 2 +- dist/pivot_spec.min.js.map | 2 +- src/pivot.coffee | 3 ++- tests/pivot_spec.coffee | 12 ++++++++++++ 10 files changed, 52 insertions(+), 9 deletions(-) diff --git a/dist/pivot.js b/dist/pivot.js index 489e412a..33a5167a 100644 --- a/dist/pivot.js +++ b/dist/pivot.js @@ -520,7 +520,7 @@ rz = /^0/; naturalSort = (function(_this) { return function(as, bs) { - var a, a1, b, b1, nas, nbs; + var a, a1, b, b1, nas, nbs, numDiff; if ((bs != null) && (as == null)) { return -1; } @@ -571,7 +571,12 @@ b1 = b.shift(); if (a1 !== b1) { if (rd.test(a1) && rd.test(b1)) { - return a1.replace(rz, ".0") - b1.replace(rz, ".0"); + numDiff = a1.replace(rz, ".0") - b1.replace(rz, ".0"); + if (numDiff !== 0) { + return numDiff; + } else { + return a1.length - b1.length; + } } else { return (a1 > b1 ? 1 : -1); } diff --git a/dist/pivot.js.map b/dist/pivot.js.map index a45720b3..b7537330 100644 --- a/dist/pivot.js.map +++ b/dist/pivot.js.map @@ -1 +1 @@ -{"version":3,"file":"pivot.js","sources":["pivot.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA,cAAA;IAAA;;;;;EAAA,cAAA,GAAiB,SAAC,WAAD;IACb,IAAG,OAAO,OAAP,KAAkB,QAAlB,IAA+B,OAAO,MAAP,KAAiB,QAAnD;aACI,WAAA,CAAY,OAAA,CAAQ,QAAR,CAAZ,EADJ;KAAA,MAEK,IAAG,OAAO,MAAP,KAAiB,UAAjB,IAAgC,MAAM,CAAC,GAA1C;aACD,MA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tB,CACX;cAAA,UAAA,EAAW,UAAX;cACA,cAAA,EAAe,KADf;cAEA,eAAA,EAAgB,KAFhB;aADW,CAAf;mBAKA,IAAI,CAAC,GAAL,CAAS;cAAA,SAAA,EAAW,CAAX;cAAa,aAAA,EAAe,KAA5B;cAAmC,YAAA,EAAc,QAAjD;aAAT,CAAmE,CAAC,IAApE,CAAyE,OAAzE;UAzBQ,CAAZ;QAhBS;MAAA,CAAA,CAAA,CAAA,IAAA;AA2Cb,WAAsC,gFAAtC;QAAA,UAAA,CAAW,aAAA,GAAc,CAAzB;AAAA;MACA,UAAA,CAAW,oBAAX;AAEA,aAAO;IAlDK;EAxjCL,CAAf;AATA","sourcesContent":["callWithJQuery = (pivotModule) ->\n if typeof exports is \"object\" and typeof module is \"object\" # CommonJS\n pivotModule require(\"jquery\")\n else if typeof define is \"function\" and define.amd # AMD\n define [\"jquery\"], pivotModule\n # Plain browser env\n else\n pivotModule jQuery\n\ncallWithJQuery ($) ->\n\n ###\n Utilities\n ###\n\n addSeparators = (nStr, thousandsSep, decimalSep) ->\n nStr += ''\n x = nStr.split('.')\n x1 = x[0]\n x2 = if x.length > 1 then decimalSep + x[1] else ''\n rgx = /(\\d+)(\\d{3})/\n x1 = x1.replace(rgx, '$1' + thousandsSep + '$2') while rgx.test(x1)\n return x1 + x2\n\n numberFormat = (opts) ->\n defaults =\n digitsAfterDecimal: 2, scaler: 1,\n thousandsSep: \",\", decimalSep: \".\"\n prefix: \"\", suffix: \"\"\n opts = $.extend({}, defaults, opts)\n (x) ->\n return \"\" if isNaN(x) or not isFinite(x)\n result = addSeparators (opts.scaler*x).toFixed(opts.digitsAfterDecimal), opts.thousandsSep, opts.decimalSep\n return \"\"+opts.prefix+result+opts.suffix\n\n #aggregator templates default to US number formatting but this is overrideable\n usFmt = numberFormat()\n usFmtInt = numberFormat(digitsAfterDecimal: 0)\n usFmtPct = numberFormat(digitsAfterDecimal:1, scaler: 100, suffix: \"%\")\n\n aggregatorTemplates =\n count: (formatter=usFmtInt) -> () -> (data, rowKey, colKey) ->\n count: 0\n push: -> @count++\n value: -> @count\n format: formatter\n\n uniques: (fn, formatter=usFmtInt) -> ([attr]) -> (data, rowKey, colKey) ->\n uniq: []\n push: (record) -> @uniq.push(record[attr]) if record[attr] not in @uniq\n value: -> fn(@uniq)\n format: formatter\n numInputs: if attr? then 0 else 1\n\n sum: (formatter=usFmt) -> ([attr]) -> (data, rowKey, colKey) ->\n sum: 0\n push: (record) -> @sum += parseFloat(record[attr]) if not isNaN parseFloat(record[attr])\n value: -> @sum\n format: formatter\n numInputs: if attr? then 0 else 1\n\n extremes: (mode, formatter=usFmt) -> ([attr]) -> (data, rowKey, colKey) ->\n val: null\n sorter: getSort(data?.sorters, attr)\n push: (record) ->\n x = record[attr]\n if mode in [\"min\", \"max\"]\n x = parseFloat(x)\n if not isNaN x then @val = Math[mode](x, @val ? x)\n if mode == \"first\" then @val = x if @sorter(x, @val ? x) <= 0\n if mode == \"last\" then @val = x if @sorter(x, @val ? x) >= 0\n value: -> @val\n format: (x) -> if isNaN(x) then x else formatter(x)\n numInputs: if attr? then 0 else 1\n\n quantile: (q, formatter=usFmt) -> ([attr]) -> (data, rowKey, colKey) ->\n vals: []\n push: (record) ->\n x = parseFloat(record[attr])\n @vals.push(x) if not isNaN(x)\n value: ->\n return null if @vals.length == 0\n @vals.sort((a,b) -> a-b)\n i = (@vals.length-1)*q\n return (@vals[Math.floor(i)] + @vals[Math.ceil(i)])/2.0\n format: formatter\n numInputs: if attr? then 0 else 1\n\n runningStat: (mode=\"mean\", ddof=1, formatter=usFmt) -> ([attr]) -> (data, rowKey, colKey) ->\n n: 0.0, m: 0.0, s: 0.0\n push: (record) ->\n x = parseFloat(record[attr])\n return if isNaN(x)\n @n += 1.0\n if @n == 1.0\n @m = x\n else\n m_new = @m + (x - @m)/@n\n @s = @s + (x - @m)*(x - m_new)\n @m = m_new\n value: ->\n if mode == \"mean\"\n return if @n == 0 then 0/0 else @m\n return 0 if @n <= ddof\n switch mode\n when \"var\" then @s/(@n-ddof)\n when \"stdev\" then Math.sqrt(@s/(@n-ddof))\n format: formatter\n numInputs: if attr? then 0 else 1\n\n sumOverSum: (formatter=usFmt) -> ([num, denom]) -> (data, rowKey, colKey) ->\n sumNum: 0\n sumDenom: 0\n push: (record) ->\n @sumNum += parseFloat(record[num]) if not isNaN parseFloat(record[num])\n @sumDenom += parseFloat(record[denom]) if not isNaN parseFloat(record[denom])\n value: -> @sumNum/@sumDenom\n format: formatter\n numInputs: if num? and denom? then 0 else 2\n\n sumOverSumBound80: (upper=true, formatter=usFmt) -> ([num, denom]) -> (data, rowKey, colKey) ->\n sumNum: 0\n sumDenom: 0\n push: (record) ->\n @sumNum += parseFloat(record[num]) if not isNaN parseFloat(record[num])\n @sumDenom += parseFloat(record[denom]) if not isNaN parseFloat(record[denom])\n value: ->\n sign = if upper then 1 else -1\n (0.821187207574908/@sumDenom + @sumNum/@sumDenom + 1.2815515655446004*sign*\n Math.sqrt(0.410593603787454/ (@sumDenom*@sumDenom) + (@sumNum*(1 - @sumNum/ @sumDenom))/ (@sumDenom*@sumDenom)))/\n (1 + 1.642374415149816/@sumDenom)\n format: formatter\n numInputs: if num? and denom? then 0 else 2\n\n fractionOf: (wrapped, type=\"total\", formatter=usFmtPct) -> (x...) -> (data, rowKey, colKey) ->\n selector: {total:[[],[]],row:[rowKey,[]],col:[[],colKey]}[type]\n inner: wrapped(x...)(data, rowKey, colKey)\n push: (record) -> @inner.push record\n format: formatter\n value: -> @inner.value() / data.getAggregator(@selector...).inner.value()\n numInputs: wrapped(x...)().numInputs\n\n aggregatorTemplates.countUnique = (f) -> aggregatorTemplates.uniques(((x) -> x.length), f)\n aggregatorTemplates.listUnique = (s) -> aggregatorTemplates.uniques(((x) -> x.sort(naturalSort).join(s)), ((x)->x))\n aggregatorTemplates.max = (f) -> aggregatorTemplates.extremes('max', f)\n aggregatorTemplates.min = (f) -> aggregatorTemplates.extremes('min', f)\n aggregatorTemplates.first = (f) -> aggregatorTemplates.extremes('first', f)\n aggregatorTemplates.last = (f) -> aggregatorTemplates.extremes('last', f)\n aggregatorTemplates.median = (f) -> aggregatorTemplates.quantile(0.5, f)\n aggregatorTemplates.average = (f) -> aggregatorTemplates.runningStat(\"mean\", 1, f)\n aggregatorTemplates.var = (ddof, f) -> aggregatorTemplates.runningStat(\"var\", ddof, f)\n aggregatorTemplates.stdev = (ddof, f) -> aggregatorTemplates.runningStat(\"stdev\", ddof, f)\n\n #default aggregators & renderers use US naming and number formatting\n aggregators = do (tpl = aggregatorTemplates) ->\n \"Count\": tpl.count(usFmtInt)\n \"Count Unique Values\": tpl.countUnique(usFmtInt)\n \"List Unique Values\": tpl.listUnique(\", \")\n \"Sum\": tpl.sum(usFmt)\n \"Integer Sum\": tpl.sum(usFmtInt)\n \"Average\": tpl.average(usFmt)\n \"Median\": tpl.median(usFmt)\n \"Sample Variance\": tpl.var(1, usFmt)\n \"Sample Standard Deviation\": tpl.stdev(1, usFmt)\n \"Minimum\": tpl.min(usFmt)\n \"Maximum\": tpl.max(usFmt)\n \"First\": tpl.first(usFmt)\n \"Last\": tpl.last(usFmt)\n \"Sum over Sum\": tpl.sumOverSum(usFmt)\n \"80% Upper Bound\": tpl.sumOverSumBound80(true, usFmt)\n \"80% Lower Bound\": tpl.sumOverSumBound80(false, usFmt)\n \"Sum as Fraction of Total\": tpl.fractionOf(tpl.sum(), \"total\", usFmtPct)\n \"Sum as Fraction of Rows\": tpl.fractionOf(tpl.sum(), \"row\", usFmtPct)\n \"Sum as Fraction of Columns\": tpl.fractionOf(tpl.sum(), \"col\", usFmtPct)\n \"Count as Fraction of Total\": tpl.fractionOf(tpl.count(), \"total\", usFmtPct)\n \"Count as Fraction of Rows\": tpl.fractionOf(tpl.count(), \"row\", usFmtPct)\n \"Count as Fraction of Columns\": tpl.fractionOf(tpl.count(), \"col\", usFmtPct)\n\n renderers =\n \"Table\": (data, opts) -> pivotTableRenderer(data, opts)\n \"Table Barchart\": (data, opts) -> $(pivotTableRenderer(data, opts)).barchart()\n \"Heatmap\": (data, opts) -> $(pivotTableRenderer(data, opts)).heatmap(\"heatmap\", opts)\n \"Row Heatmap\": (data, opts) -> $(pivotTableRenderer(data, opts)).heatmap(\"rowheatmap\", opts)\n \"Col Heatmap\": (data, opts) -> $(pivotTableRenderer(data, opts)).heatmap(\"colheatmap\", opts)\n\n locales =\n en:\n aggregators: aggregators\n renderers: renderers\n localeStrings:\n renderError: \"An error occurred rendering the PivotTable results.\"\n computeError: \"An error occurred computing the PivotTable results.\"\n uiRenderError: \"An error occurred rendering the PivotTable UI.\"\n selectAll: \"Select All\"\n selectNone: \"Select None\"\n tooMany: \"(too many to list)\"\n filterResults: \"Filter values\"\n apply: \"Apply\"\n cancel: \"Cancel\"\n totals: \"Totals\" #for table renderer\n vs: \"vs\" #for gchart renderer\n by: \"by\" #for gchart renderer\n\n #dateFormat deriver l10n requires month and day names to be passed in directly\n mthNamesEn = [\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"]\n dayNamesEn = [\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"]\n zeroPad = (number) -> (\"0\"+number).substr(-2,2)\n\n derivers =\n bin: (col, binWidth) -> (record) -> record[col] - record[col] % binWidth\n dateFormat: (col, formatString, utcOutput=false, mthNames=mthNamesEn, dayNames=dayNamesEn) ->\n utc = if utcOutput then \"UTC\" else \"\"\n (record) -> #thanks http://stackoverflow.com/a/12213072/112871\n date = new Date(Date.parse(record[col]))\n if isNaN(date) then return \"\"\n formatString.replace /%(.)/g, (m, p) ->\n switch p\n when \"y\" then date[\"get#{utc}FullYear\"]()\n when \"m\" then zeroPad(date[\"get#{utc}Month\"]()+1)\n when \"n\" then mthNames[date[\"get#{utc}Month\"]()]\n when \"d\" then zeroPad(date[\"get#{utc}Date\"]())\n when \"w\" then dayNames[date[\"get#{utc}Day\"]()]\n when \"x\" then date[\"get#{utc}Day\"]()\n when \"H\" then zeroPad(date[\"get#{utc}Hours\"]())\n when \"M\" then zeroPad(date[\"get#{utc}Minutes\"]())\n when \"S\" then zeroPad(date[\"get#{utc}Seconds\"]())\n else \"%\" + p\n\n rx = /(\\d+)|(\\D+)/g\n rd = /\\d/\n rz = /^0/\n naturalSort = (as, bs) =>\n #nulls first\n return -1 if bs? and not as?\n return 1 if as? and not bs?\n\n #then raw NaNs\n return -1 if typeof as == \"number\" and isNaN(as)\n return 1 if typeof bs == \"number\" and isNaN(bs)\n\n #numbers and numbery strings group together\n nas = +as\n nbs = +bs\n return -1 if nas < nbs\n return 1 if nas > nbs\n\n #within that, true numbers before numbery strings\n return -1 if typeof as == \"number\" and typeof bs != \"number\"\n return 1 if typeof bs == \"number\" and typeof as != \"number\"\n return 0 if typeof as == \"number\" and typeof bs == \"number\"\n\n # 'Infinity' is a textual number, so less than 'A'\n return -1 if isNaN(nbs) and not isNaN(nas)\n return 1 if isNaN(nas) and not isNaN(nbs)\n\n #finally, \"smart\" string sorting per http://stackoverflow.com/a/4373421/112871\n a = String(as)\n b = String(bs)\n return 0 if a == b\n return (if a > b then 1 else -1) unless rd.test(a) and rd.test(b)\n\n #special treatment for strings containing digits\n a = a.match(rx) #create digits vs non-digit chunks and iterate through\n b = b.match(rx)\n while a.length and b.length\n a1 = a.shift()\n b1 = b.shift()\n if a1 != b1\n if rd.test(a1) and rd.test(b1) #both are digit chunks\n return a1.replace(rz, \".0\") - b1.replace(rz, \".0\")\n else\n return (if a1 > b1 then 1 else -1)\n return a.length - b.length\n\n sortAs = (order) ->\n mapping = {}\n l_mapping = {} # sort lowercased keys similarly\n for i, x of order\n mapping[x] = i\n l_mapping[x.toLowerCase()] = i if typeof x == \"string\"\n (a, b) ->\n if mapping[a]? and mapping[b]? then mapping[a] - mapping[b]\n else if mapping[a]? then -1\n else if mapping[b]? then 1\n else if l_mapping[a]? and l_mapping[b]? then l_mapping[a] - l_mapping[b]\n else if l_mapping[a]? then -1\n else if l_mapping[b]? then 1\n else naturalSort(a,b)\n\n getSort = (sorters, attr) ->\n if sorters?\n if $.isFunction(sorters)\n sort = sorters(attr)\n return sort if $.isFunction(sort)\n else if sorters[attr]?\n return sorters[attr]\n return naturalSort\n\n ###\n Data Model class\n ###\n\n class PivotData\n constructor: (input, opts = {}) ->\n @input = input\n @aggregator = opts.aggregator ? aggregatorTemplates.count()()\n @aggregatorName = opts.aggregatorName ? \"Count\"\n @colAttrs = opts.cols ? []\n @rowAttrs = opts.rows ? []\n @valAttrs = opts.vals ? []\n @sorters = opts.sorters ? {}\n @rowOrder = opts.rowOrder ? \"key_a_to_z\"\n @colOrder = opts.colOrder ? \"key_a_to_z\"\n @derivedAttributes = opts.derivedAttributes ? {}\n @filter = opts.filter ? (-> true)\n @tree = {}\n @rowKeys = []\n @colKeys = []\n @rowTotals = {}\n @colTotals = {}\n @allTotal = @aggregator(this, [], [])\n @sorted = false\n\n # iterate through input, accumulating data for cells\n PivotData.forEachRecord @input, @derivedAttributes, (record) =>\n @processRecord(record) if @filter(record)\n\n #can handle arrays or jQuery selections of tables\n @forEachRecord = (input, derivedAttributes, f) ->\n if $.isEmptyObject derivedAttributes\n addRecord = f\n else\n addRecord = (record) ->\n record[k] = v(record) ? record[k] for k, v of derivedAttributes\n f(record)\n\n #if it's a function, have it call us back\n if $.isFunction(input)\n input(addRecord)\n else if $.isArray(input)\n if $.isArray(input[0]) #array of arrays\n for own i, compactRecord of input when i > 0\n record = {}\n record[k] = compactRecord[j] for own j, k of input[0]\n addRecord(record)\n else #array of objects\n addRecord(record) for record in input\n else if input instanceof $\n tblCols = []\n $(\"thead > tr > th\", input).each (i) -> tblCols.push $(this).text()\n $(\"tbody > tr\", input).each (i) ->\n record = {}\n $(\"td\", this).each (j) -> record[tblCols[j]] = $(this).text()\n addRecord(record)\n else\n throw new Error(\"unknown input format\")\n\n forEachMatchingRecord: (criteria, callback) ->\n PivotData.forEachRecord @input, @derivedAttributes, (record) =>\n return if not @filter(record)\n for k, v of criteria\n return if v != (record[k] ? \"null\")\n callback(record)\n\n arrSort: (attrs) =>\n sortersArr = (getSort(@sorters, a) for a in attrs)\n (a,b) ->\n for own i, sorter of sortersArr\n comparison = sorter(a[i], b[i])\n return comparison if comparison != 0\n return 0\n\n sortKeys: () =>\n if not @sorted\n @sorted = true\n v = (r,c) => @getAggregator(r,c).value()\n switch @rowOrder\n when \"value_a_to_z\" then @rowKeys.sort (a,b) => naturalSort v(a,[]), v(b,[])\n when \"value_z_to_a\" then @rowKeys.sort (a,b) => -naturalSort v(a,[]), v(b,[])\n else @rowKeys.sort @arrSort(@rowAttrs)\n switch @colOrder\n when \"value_a_to_z\" then @colKeys.sort (a,b) => naturalSort v([],a), v([],b)\n when \"value_z_to_a\" then @colKeys.sort (a,b) => -naturalSort v([],a), v([],b)\n else @colKeys.sort @arrSort(@colAttrs)\n\n getColKeys: () =>\n @sortKeys()\n return @colKeys\n\n getRowKeys: () =>\n @sortKeys()\n return @rowKeys\n\n processRecord: (record) -> #this code is called in a tight loop\n colKey = []\n rowKey = []\n colKey.push record[x] ? \"null\" for x in @colAttrs\n rowKey.push record[x] ? \"null\" for x in @rowAttrs\n flatRowKey = rowKey.join(String.fromCharCode(0))\n flatColKey = colKey.join(String.fromCharCode(0))\n\n @allTotal.push record\n\n if rowKey.length != 0\n if not @rowTotals[flatRowKey]\n @rowKeys.push rowKey\n @rowTotals[flatRowKey] = @aggregator(this, rowKey, [])\n @rowTotals[flatRowKey].push record\n\n if colKey.length != 0\n if not @colTotals[flatColKey]\n @colKeys.push colKey\n @colTotals[flatColKey] = @aggregator(this, [], colKey)\n @colTotals[flatColKey].push record\n\n if colKey.length != 0 and rowKey.length != 0\n if not @tree[flatRowKey]\n @tree[flatRowKey] = {}\n if not @tree[flatRowKey][flatColKey]\n @tree[flatRowKey][flatColKey] = @aggregator(this, rowKey, colKey)\n @tree[flatRowKey][flatColKey].push record\n\n getAggregator: (rowKey, colKey) =>\n flatRowKey = rowKey.join(String.fromCharCode(0))\n flatColKey = colKey.join(String.fromCharCode(0))\n if rowKey.length == 0 and colKey.length == 0\n agg = @allTotal\n else if rowKey.length == 0\n agg = @colTotals[flatColKey]\n else if colKey.length == 0\n agg = @rowTotals[flatRowKey]\n else\n agg = @tree[flatRowKey][flatColKey]\n return agg ? {value: (-> null), format: -> \"\"}\n\n #expose these to the outside world\n $.pivotUtilities = {aggregatorTemplates, aggregators, renderers, derivers, locales,\n naturalSort, numberFormat, sortAs, PivotData}\n\n ###\n Default Renderer for hierarchical table layout\n ###\n\n pivotTableRenderer = (pivotData, opts) ->\n\n defaults =\n table:\n clickCallback: null\n rowTotals: true\n colTotals: true\n localeStrings: totals: \"Totals\"\n\n opts = $.extend(true, {}, defaults, opts)\n\n colAttrs = pivotData.colAttrs\n rowAttrs = pivotData.rowAttrs\n rowKeys = pivotData.getRowKeys()\n colKeys = pivotData.getColKeys()\n\n if opts.table.clickCallback\n getClickHandler = (value, rowValues, colValues) ->\n filters = {}\n filters[attr] = colValues[i] for own i, attr of colAttrs when colValues[i]?\n filters[attr] = rowValues[i] for own i, attr of rowAttrs when rowValues[i]?\n return (e) -> opts.table.clickCallback(e, value, filters, pivotData)\n\n #now actually build the output\n result = document.createElement(\"table\")\n result.className = \"pvtTable\"\n\n #helper function for setting row/col-span in pivotTableRenderer\n spanSize = (arr, i, j) ->\n if i != 0\n noDraw = true\n for x in [0..j]\n if arr[i-1][x] != arr[i][x]\n noDraw = false\n if noDraw\n return -1 #do not draw cell\n len = 0\n while i+len < arr.length\n stop = false\n for x in [0..j]\n stop = true if arr[i][x] != arr[i+len][x]\n break if stop\n len++\n return len\n\n #the first few rows are for col headers\n thead = document.createElement(\"thead\")\n for own j, c of colAttrs\n tr = document.createElement(\"tr\")\n if parseInt(j) == 0 and rowAttrs.length != 0\n th = document.createElement(\"th\")\n th.setAttribute(\"colspan\", rowAttrs.length)\n th.setAttribute(\"rowspan\", colAttrs.length)\n tr.appendChild th\n th = document.createElement(\"th\")\n th.className = \"pvtAxisLabel\"\n th.textContent = c\n tr.appendChild th\n for own i, colKey of colKeys\n x = spanSize(colKeys, parseInt(i), parseInt(j))\n if x != -1\n th = document.createElement(\"th\")\n th.className = \"pvtColLabel\"\n th.textContent = colKey[j]\n th.setAttribute(\"colspan\", x)\n if parseInt(j) == colAttrs.length-1 and rowAttrs.length != 0\n th.setAttribute(\"rowspan\", 2)\n tr.appendChild th\n if parseInt(j) == 0 && opts.table.rowTotals\n th = document.createElement(\"th\")\n th.className = \"pvtTotalLabel pvtRowTotalLabel\"\n th.innerHTML = opts.localeStrings.totals\n th.setAttribute(\"rowspan\", colAttrs.length + (if rowAttrs.length ==0 then 0 else 1))\n tr.appendChild th\n thead.appendChild tr\n\n #then a row for row header headers\n if rowAttrs.length !=0\n tr = document.createElement(\"tr\")\n for own i, r of rowAttrs\n th = document.createElement(\"th\")\n th.className = \"pvtAxisLabel\"\n th.textContent = r\n tr.appendChild th\n th = document.createElement(\"th\")\n if colAttrs.length ==0\n th.className = \"pvtTotalLabel pvtRowTotalLabel\"\n th.innerHTML = opts.localeStrings.totals\n tr.appendChild th\n thead.appendChild tr\n result.appendChild thead\n\n #now the actual data rows, with their row headers and totals\n tbody = document.createElement(\"tbody\")\n for own i, rowKey of rowKeys\n tr = document.createElement(\"tr\")\n for own j, txt of rowKey\n x = spanSize(rowKeys, parseInt(i), parseInt(j))\n if x != -1\n th = document.createElement(\"th\")\n th.className = \"pvtRowLabel\"\n th.textContent = txt\n th.setAttribute(\"rowspan\", x)\n if parseInt(j) == rowAttrs.length-1 and colAttrs.length !=0\n th.setAttribute(\"colspan\",2)\n tr.appendChild th\n for own j, colKey of colKeys #this is the tight loop\n aggregator = pivotData.getAggregator(rowKey, colKey)\n val = aggregator.value()\n td = document.createElement(\"td\")\n td.className = \"pvtVal row#{i} col#{j}\"\n td.textContent = aggregator.format(val)\n td.setAttribute(\"data-value\", val)\n if getClickHandler?\n td.onclick = getClickHandler(val, rowKey, colKey)\n tr.appendChild td\n\n if opts.table.rowTotals || colAttrs.length == 0\n totalAggregator = pivotData.getAggregator(rowKey, [])\n val = totalAggregator.value()\n td = document.createElement(\"td\")\n td.className = \"pvtTotal rowTotal\"\n td.textContent = totalAggregator.format(val)\n td.setAttribute(\"data-value\", val)\n if getClickHandler?\n td.onclick = getClickHandler(val, rowKey, [])\n td.setAttribute(\"data-for\", \"row\"+i)\n tr.appendChild td\n tbody.appendChild tr\n\n #finally, the row for col totals, and a grand total\n if opts.table.colTotals || rowAttrs.length == 0\n tr = document.createElement(\"tr\")\n if opts.table.colTotals || rowAttrs.length == 0\n th = document.createElement(\"th\")\n th.className = \"pvtTotalLabel pvtColTotalLabel\"\n th.innerHTML = opts.localeStrings.totals\n th.setAttribute(\"colspan\", rowAttrs.length + (if colAttrs.length == 0 then 0 else 1))\n tr.appendChild th\n for own j, colKey of colKeys\n totalAggregator = pivotData.getAggregator([], colKey)\n val = totalAggregator.value()\n td = document.createElement(\"td\")\n td.className = \"pvtTotal colTotal\"\n td.textContent = totalAggregator.format(val)\n td.setAttribute(\"data-value\", val)\n if getClickHandler?\n td.onclick = getClickHandler(val, [], colKey)\n td.setAttribute(\"data-for\", \"col\"+j)\n tr.appendChild td\n if opts.table.rowTotals || colAttrs.length == 0\n totalAggregator = pivotData.getAggregator([], [])\n val = totalAggregator.value()\n td = document.createElement(\"td\")\n td.className = \"pvtGrandTotal\"\n td.textContent = totalAggregator.format(val)\n td.setAttribute(\"data-value\", val)\n if getClickHandler?\n td.onclick = getClickHandler(val, [], [])\n tr.appendChild td\n tbody.appendChild tr\n result.appendChild tbody\n\n #squirrel this away for later\n result.setAttribute(\"data-numrows\", rowKeys.length)\n result.setAttribute(\"data-numcols\", colKeys.length)\n\n return result\n\n ###\n Pivot Table core: create PivotData object and call Renderer on it\n ###\n\n $.fn.pivot = (input, inputOpts, locale=\"en\") ->\n locale = \"en\" if not locales[locale]?\n defaults =\n cols : [], rows: [], vals: []\n rowOrder: \"key_a_to_z\", colOrder: \"key_a_to_z\"\n dataClass: PivotData\n filter: -> true\n aggregator: aggregatorTemplates.count()()\n aggregatorName: \"Count\"\n sorters: {}\n derivedAttributes: {}\n renderer: pivotTableRenderer\n\n localeStrings = $.extend(true, {}, locales.en.localeStrings, locales[locale].localeStrings)\n localeDefaults =\n rendererOptions: {localeStrings}\n localeStrings: localeStrings\n\n opts = $.extend(true, {}, localeDefaults, $.extend({}, defaults, inputOpts))\n\n result = null\n try\n pivotData = new opts.dataClass(input, opts)\n try\n result = opts.renderer(pivotData, opts.rendererOptions)\n catch e\n console.error(e.stack) if console?\n result = $(\"\").html opts.localeStrings.renderError\n catch e\n console.error(e.stack) if console?\n result = $(\"\").html opts.localeStrings.computeError\n\n x = this[0]\n x.removeChild(x.lastChild) while x.hasChildNodes()\n return @append result\n\n\n ###\n Pivot Table UI: calls Pivot Table core above with options set by user\n ###\n\n $.fn.pivotUI = (input, inputOpts, overwrite = false, locale=\"en\") ->\n locale = \"en\" if not locales[locale]?\n defaults =\n derivedAttributes: {}\n aggregators: locales[locale].aggregators\n renderers: locales[locale].renderers\n hiddenAttributes: []\n hiddenFromAggregators: []\n hiddenFromDragDrop: []\n menuLimit: 500\n cols: [], rows: [], vals: []\n rowOrder: \"key_a_to_z\", colOrder: \"key_a_to_z\"\n dataClass: PivotData\n exclusions: {}\n inclusions: {}\n unusedAttrsVertical: 85\n autoSortUnusedAttrs: false\n onRefresh: null\n showUI: true\n filter: -> true\n sorters: {}\n\n localeStrings = $.extend(true, {}, locales.en.localeStrings, locales[locale].localeStrings)\n localeDefaults =\n rendererOptions: {localeStrings}\n localeStrings: localeStrings\n\n existingOpts = @data \"pivotUIOptions\"\n if not existingOpts? or overwrite\n opts = $.extend(true, {}, localeDefaults, $.extend({}, defaults, inputOpts))\n else\n opts = existingOpts\n\n try\n # do a first pass on the data to cache a materialized copy of any\n # function-valued inputs and to compute dimension cardinalities\n attrValues = {}\n materializedInput = []\n recordsProcessed = 0\n PivotData.forEachRecord input, opts.derivedAttributes, (record) ->\n return unless opts.filter(record)\n materializedInput.push(record)\n for own attr of record\n if not attrValues[attr]?\n attrValues[attr] = {}\n if recordsProcessed > 0\n attrValues[attr][\"null\"] = recordsProcessed\n for attr of attrValues\n value = record[attr] ? \"null\"\n attrValues[attr][value] ?= 0\n attrValues[attr][value]++\n recordsProcessed++\n\n #start building the output\n uiTable = $(\"\", \"class\": \"pvtUi\").attr(\"cellpadding\", 5)\n\n #renderer control\n rendererControl = $(\"\").appendTo(uiTable)\n\n #aggregator menu and value area\n\n aggregator = $(\"\").appendTo(uiTable)\n\n #row axes\n tr2.append $(\"\").append(rendererControl).append(unused)\n\n #render the UI in its default state\n @html uiTable\n\n #set up the UI initial state as requested by moving elements around\n\n for x in opts.cols\n @find(\".pvtCols\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n for x in opts.rows\n @find(\".pvtRows\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n if opts.aggregatorName?\n @find(\".pvtAggregator\").val opts.aggregatorName\n if opts.rendererName?\n @find(\".pvtRenderer\").val opts.rendererName\n\n @find(\".pvtUiCell\").hide() unless opts.showUI\n\n initialRender = true\n\n #set up for refreshing\n refreshDelayed = =>\n subopts =\n derivedAttributes: opts.derivedAttributes\n localeStrings: opts.localeStrings\n rendererOptions: opts.rendererOptions\n sorters: opts.sorters\n cols: [], rows: []\n dataClass: opts.dataClass\n\n numInputsToProcess = opts.aggregators[aggregator.val()]([])().numInputs ? 0\n vals = []\n @find(\".pvtRows li span.pvtAttr\").each -> subopts.rows.push $(this).data(\"attrName\")\n @find(\".pvtCols li span.pvtAttr\").each -> subopts.cols.push $(this).data(\"attrName\")\n @find(\".pvtVals select.pvtAttrDropdown\").each ->\n if numInputsToProcess == 0\n $(this).remove()\n else\n numInputsToProcess--\n vals.push $(this).val() if $(this).val() != \"\"\n\n if numInputsToProcess != 0\n pvtVals = @find(\".pvtVals\")\n for x in [0...numInputsToProcess]\n newDropdown = $(\"
\").addClass(\"pvtUiCell\")\n\n renderer = $(\"\").addClass('pvtAxisContainer pvtUnused pvtUiCell')\n shownAttributes = (a for a of attrValues when a not in opts.hiddenAttributes)\n shownInAggregators = (c for c in shownAttributes when c not in opts.hiddenFromAggregators)\n shownInDragDrop = (c for c in shownAttributes when c not in opts.hiddenFromDragDrop)\n\n\n unusedAttrsVerticalAutoOverride = false\n if opts.unusedAttrsVertical == \"auto\"\n unusedAttrsVerticalAutoCutoff = 120 # legacy support\n else\n unusedAttrsVerticalAutoCutoff = parseInt opts.unusedAttrsVertical\n\n if not isNaN(unusedAttrsVerticalAutoCutoff)\n attrLength = 0\n attrLength += a.length for a in shownInDragDrop\n unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff\n\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n unused.addClass('pvtVertList')\n else\n unused.addClass('pvtHorizList')\n\n for own i, attr of shownInDragDrop\n do (attr) ->\n values = (v for v of attrValues[attr])\n hasExcludedItem = false\n valueList = $(\"
\").addClass('pvtFilterBox').hide()\n\n valueList.append $(\"

\").append(\n $(\"\").text(attr),\n $(\"\").addClass(\"count\").text(\"(#{values.length})\"),\n )\n if values.length > opts.menuLimit\n valueList.append $(\"

\").html(opts.localeStrings.tooMany)\n else\n if values.length > 5\n controls = $(\"

\").appendTo(valueList)\n sorter = getSort(opts.sorters, attr)\n placeholder = opts.localeStrings.filterResults\n $(\"\", {type: \"text\"}).appendTo(controls)\n .attr({placeholder: placeholder, class: \"pvtSearch\"})\n .bind \"keyup\", ->\n filter = $(this).val().toLowerCase().trim()\n accept_gen = (prefix, accepted) -> (v) ->\n real_filter = filter.substring(prefix.length).trim()\n return true if real_filter.length == 0\n return Math.sign(sorter(v.toLowerCase(), real_filter)) in accepted\n accept =\n if filter.indexOf(\">=\") == 0 then accept_gen(\">=\", [1,0])\n else if filter.indexOf(\"<=\") == 0 then accept_gen(\"<=\", [-1,0])\n else if filter.indexOf(\">\") == 0 then accept_gen(\">\", [1])\n else if filter.indexOf(\"<\") == 0 then accept_gen(\"<\", [-1])\n else if filter.indexOf(\"~\") == 0 then (v) ->\n return true if filter.substring(1).trim().length == 0\n v.toLowerCase().match(filter.substring(1))\n else (v) -> v.toLowerCase().indexOf(filter) != -1\n\n valueList.find('.pvtCheckContainer p label span.value').each ->\n if accept($(this).text())\n $(this).parent().parent().show()\n else\n $(this).parent().parent().hide()\n controls.append $(\"
\")\n $(\"

\").addClass('pvtVals pvtUiCell')\n .appendTo(tr1)\n .append(aggregator)\n .append(rowOrderArrow)\n .append(colOrderArrow)\n .append($(\"
\"))\n\n #column axes\n $(\"
\").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1)\n\n tr2 = $(\"
\").addClass('pvtAxisContainer pvtRows pvtUiCell').attr(\"valign\", \"top\")\n\n #the actual pivot table container\n pivotTable = $(\"\")\n .attr(\"valign\", \"top\")\n .addClass('pvtRendererArea')\n .appendTo(tr2)\n\n #finally the renderer dropdown and unused attribs are inserted at the requested location\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n uiTable.find('tr:nth-child(1)').prepend rendererControl\n uiTable.find('tr:nth-child(2)').prepend unused\n else\n uiTable.prepend $(\"
\", \"class\": \"pvtUi\").attr(\"cellpadding\", 5)\n\n #renderer control\n rendererControl = $(\"\").appendTo(uiTable)\n\n #aggregator menu and value area\n\n aggregator = $(\"\").appendTo(uiTable)\n\n #row axes\n tr2.append $(\"\").append(rendererControl).append(unused)\n\n #render the UI in its default state\n @html uiTable\n\n #set up the UI initial state as requested by moving elements around\n\n for x in opts.cols\n @find(\".pvtCols\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n for x in opts.rows\n @find(\".pvtRows\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n if opts.aggregatorName?\n @find(\".pvtAggregator\").val opts.aggregatorName\n if opts.rendererName?\n @find(\".pvtRenderer\").val opts.rendererName\n\n @find(\".pvtUiCell\").hide() unless opts.showUI\n\n initialRender = true\n\n #set up for refreshing\n refreshDelayed = =>\n subopts =\n derivedAttributes: opts.derivedAttributes\n localeStrings: opts.localeStrings\n rendererOptions: opts.rendererOptions\n sorters: opts.sorters\n cols: [], rows: []\n dataClass: opts.dataClass\n\n numInputsToProcess = opts.aggregators[aggregator.val()]([])().numInputs ? 0\n vals = []\n @find(\".pvtRows li span.pvtAttr\").each -> subopts.rows.push $(this).data(\"attrName\")\n @find(\".pvtCols li span.pvtAttr\").each -> subopts.cols.push $(this).data(\"attrName\")\n @find(\".pvtVals select.pvtAttrDropdown\").each ->\n if numInputsToProcess == 0\n $(this).remove()\n else\n numInputsToProcess--\n vals.push $(this).val() if $(this).val() != \"\"\n\n if numInputsToProcess != 0\n pvtVals = @find(\".pvtVals\")\n for x in [0...numInputsToProcess]\n newDropdown = $(\"
\").addClass(\"pvtUiCell\")\n\n renderer = $(\"\").addClass('pvtAxisContainer pvtUnused pvtUiCell')\n shownAttributes = (a for a of attrValues when a not in opts.hiddenAttributes)\n shownInAggregators = (c for c in shownAttributes when c not in opts.hiddenFromAggregators)\n shownInDragDrop = (c for c in shownAttributes when c not in opts.hiddenFromDragDrop)\n\n\n unusedAttrsVerticalAutoOverride = false\n if opts.unusedAttrsVertical == \"auto\"\n unusedAttrsVerticalAutoCutoff = 120 # legacy support\n else\n unusedAttrsVerticalAutoCutoff = parseInt opts.unusedAttrsVertical\n\n if not isNaN(unusedAttrsVerticalAutoCutoff)\n attrLength = 0\n attrLength += a.length for a in shownInDragDrop\n unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff\n\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n unused.addClass('pvtVertList')\n else\n unused.addClass('pvtHorizList')\n\n for own i, attr of shownInDragDrop\n do (attr) ->\n values = (v for v of attrValues[attr])\n hasExcludedItem = false\n valueList = $(\"
\").addClass('pvtFilterBox').hide()\n\n valueList.append $(\"

\").append(\n $(\"\").text(attr),\n $(\"\").addClass(\"count\").text(\"(#{values.length})\"),\n )\n if values.length > opts.menuLimit\n valueList.append $(\"

\").html(opts.localeStrings.tooMany)\n else\n if values.length > 5\n controls = $(\"

\").appendTo(valueList)\n sorter = getSort(opts.sorters, attr)\n placeholder = opts.localeStrings.filterResults\n $(\"\", {type: \"text\"}).appendTo(controls)\n .attr({placeholder: placeholder, class: \"pvtSearch\"})\n .bind \"keyup\", ->\n filter = $(this).val().toLowerCase().trim()\n accept_gen = (prefix, accepted) -> (v) ->\n real_filter = filter.substring(prefix.length).trim()\n return true if real_filter.length == 0\n return Math.sign(sorter(v.toLowerCase(), real_filter)) in accepted\n accept =\n if filter.indexOf(\">=\") == 0 then accept_gen(\">=\", [1,0])\n else if filter.indexOf(\"<=\") == 0 then accept_gen(\"<=\", [-1,0])\n else if filter.indexOf(\">\") == 0 then accept_gen(\">\", [1])\n else if filter.indexOf(\"<\") == 0 then accept_gen(\"<\", [-1])\n else if filter.indexOf(\"~\") == 0 then (v) ->\n return true if filter.substring(1).trim().length == 0\n v.toLowerCase().match(filter.substring(1))\n else (v) -> v.toLowerCase().indexOf(filter) != -1\n\n valueList.find('.pvtCheckContainer p label span.value').each ->\n if accept($(this).text())\n $(this).parent().parent().show()\n else\n $(this).parent().parent().hide()\n controls.append $(\"
\")\n $(\"

\").addClass('pvtVals pvtUiCell')\n .appendTo(tr1)\n .append(aggregator)\n .append(rowOrderArrow)\n .append(colOrderArrow)\n .append($(\"
\"))\n\n #column axes\n $(\"
\").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1)\n\n tr2 = $(\"
\").addClass('pvtAxisContainer pvtRows pvtUiCell').attr(\"valign\", \"top\")\n\n #the actual pivot table container\n pivotTable = $(\"\")\n .attr(\"valign\", \"top\")\n .addClass('pvtRendererArea')\n .appendTo(tr2)\n\n #finally the renderer dropdown and unused attribs are inserted at the requested location\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n uiTable.find('tr:nth-child(1)').prepend rendererControl\n uiTable.find('tr:nth-child(2)').prepend unused\n else\n uiTable.prepend $(\"
",{"class":"pvtUi"}).attr("cellpadding",5),B=t("").appendTo(Y),u=t("").appendTo(Y),Q.append(t("").append(B).append(X)),this.html(Y),q=M.cols,D=0,T=q.length;Dp;et=0<=p?++g:--g){for(i=t("
").addClass("pvtUiCell"),H=t("").addClass("pvtAxisContainer pvtUnused pvtUiCell"),J=function(){var t;t=[];for(s in m)e.call(M.hiddenAttributes,s)<0&&t.push(s);return t}(),G=function(){var t,n,r;for(r=[],t=0,n=J.length;tZ}M.unusedAttrsVertical===!0||tt?X.addClass("pvtVertList"):X.addClass("pvtHorizList"),w=function(n){var r,a,o,i,l,s,u,c,d,p,f,g,v,b,C,y,w,x,S;if(S=function(){var t;t=[];for(C in m[n])t.push(C);return t}(),c=!1,x=t("
").addClass("pvtFilterBox").hide(),x.append(t("

").append(t("").text(n),t("").addClass("count").text("("+S.length+")"))),S.length>M.menuLimit)x.append(t("

").html(M.localeStrings.tooMany));else for(S.length>5&&(i=t("

").appendTo(x),v=h(M.sorters,n),f=M.localeStrings.filterResults,t("",{type:"text"}).appendTo(i).attr({placeholder:f,"class":"pvtSearch"}).bind("keyup",function(){var n,r,a;return a=t(this).val().toLowerCase().trim(),r=function(t,n){return function(r){var o,i;return o=a.substring(t.length).trim(),0===o.length||(i=Math.sign(v(r.toLowerCase(),o)),e.call(n,i)>=0)}},n=0===a.indexOf(">=")?r(">=",[1,0]):0===a.indexOf("<=")?r("<=",[-1,0]):0===a.indexOf(">")?r(">",[1]):0===a.indexOf("<")?r("<",[-1]):0===a.indexOf("~")?function(t){return 0===a.substring(1).trim().length||t.toLowerCase().match(a.substring(1))}:function(t){return t.toLowerCase().indexOf(a)!==-1},x.find(".pvtCheckContainer p label span.value").each(function(){return n(t(this).text())?t(this).parent().parent().show():t(this).parent().parent().hide()})}),i.append(t("
")),t("

").addClass("pvtVals pvtUiCell").appendTo($).append(u).append(P).append(v).append(t("
")),t("
").addClass("pvtAxisContainer pvtHorizList pvtCols pvtUiCell").appendTo($),Q=t("
").addClass("pvtAxisContainer pvtRows pvtUiCell").attr("valign","top")),I=t("").attr("valign","top").addClass("pvtRendererArea").appendTo(Q),M.unusedAttrsVertical===!0||tt?(Y.find("tr:nth-child(1)").prepend(B),Y.find("tr:nth-child(2)").prepend(X)):Y.prepend(t("
",{"class":"pvtUi"}).attr("cellpadding",5),B=t("").appendTo(Y),u=t("").appendTo(Y),Q.append(t("").append(B).append(X)),this.html(Y),q=M.cols,D=0,T=q.length;Dp;et=0<=p?++g:--g){for(i=t("
").addClass("pvtUiCell"),H=t("").addClass("pvtAxisContainer pvtUnused pvtUiCell"),J=function(){var t;t=[];for(s in m)e.call(M.hiddenAttributes,s)<0&&t.push(s);return t}(),G=function(){var t,n,r;for(r=[],t=0,n=J.length;tZ}M.unusedAttrsVertical===!0||tt?X.addClass("pvtVertList"):X.addClass("pvtHorizList"),w=function(n){var r,a,o,i,l,s,u,c,d,p,f,g,v,b,C,y,w,x,S;if(S=function(){var t;t=[];for(C in m[n])t.push(C);return t}(),c=!1,x=t("
").addClass("pvtFilterBox").hide(),x.append(t("

").append(t("").text(n),t("").addClass("count").text("("+S.length+")"))),S.length>M.menuLimit)x.append(t("

").html(M.localeStrings.tooMany));else for(S.length>5&&(i=t("

").appendTo(x),v=h(M.sorters,n),f=M.localeStrings.filterResults,t("",{type:"text"}).appendTo(i).attr({placeholder:f,"class":"pvtSearch"}).bind("keyup",function(){var n,r,a;return a=t(this).val().toLowerCase().trim(),r=function(t,n){return function(r){var o,i;return o=a.substring(t.length).trim(),0===o.length||(i=Math.sign(v(r.toLowerCase(),o)),e.call(n,i)>=0)}},n=0===a.indexOf(">=")?r(">=",[1,0]):0===a.indexOf("<=")?r("<=",[-1,0]):0===a.indexOf(">")?r(">",[1]):0===a.indexOf("<")?r("<",[-1]):0===a.indexOf("~")?function(t){return 0===a.substring(1).trim().length||t.toLowerCase().match(a.substring(1))}:function(t){return t.toLowerCase().indexOf(a)!==-1},x.find(".pvtCheckContainer p label span.value").each(function(){return n(t(this).text())?t(this).parent().parent().show():t(this).parent().parent().hide()})}),i.append(t("
")),t("

").addClass("pvtVals pvtUiCell").appendTo($).append(u).append(P).append(v).append(t("
")),t("
").addClass("pvtAxisContainer pvtHorizList pvtCols pvtUiCell").appendTo($),Q=t("
").addClass("pvtAxisContainer pvtRows pvtUiCell").attr("valign","top")),I=t("").attr("valign","top").addClass("pvtRendererArea").appendTo(Q),M.unusedAttrsVertical===!0||tt?(Y.find("tr:nth-child(1)").prepend(B),Y.find("tr:nth-child(2)").prepend(X)):Y.prepend(t("
\", \"class\": \"pvtUi\").attr(\"cellpadding\", 5)\n\n #renderer control\n rendererControl = $(\"\").appendTo(uiTable)\n\n #aggregator menu and value area\n\n aggregator = $(\"\").appendTo(uiTable)\n\n #row axes\n tr2.append $(\"\").append(rendererControl).append(unused)\n\n #render the UI in its default state\n @html uiTable\n\n #set up the UI initial state as requested by moving elements around\n\n for x in opts.cols\n @find(\".pvtCols\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n for x in opts.rows\n @find(\".pvtRows\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n if opts.aggregatorName?\n @find(\".pvtAggregator\").val opts.aggregatorName\n if opts.rendererName?\n @find(\".pvtRenderer\").val opts.rendererName\n\n @find(\".pvtUiCell\").hide() unless opts.showUI\n\n initialRender = true\n\n #set up for refreshing\n refreshDelayed = =>\n subopts =\n derivedAttributes: opts.derivedAttributes\n localeStrings: opts.localeStrings\n rendererOptions: opts.rendererOptions\n sorters: opts.sorters\n cols: [], rows: []\n dataClass: opts.dataClass\n\n numInputsToProcess = opts.aggregators[aggregator.val()]([])().numInputs ? 0\n vals = []\n @find(\".pvtRows li span.pvtAttr\").each -> subopts.rows.push $(this).data(\"attrName\")\n @find(\".pvtCols li span.pvtAttr\").each -> subopts.cols.push $(this).data(\"attrName\")\n @find(\".pvtVals select.pvtAttrDropdown\").each ->\n if numInputsToProcess == 0\n $(this).remove()\n else\n numInputsToProcess--\n vals.push $(this).val() if $(this).val() != \"\"\n\n if numInputsToProcess != 0\n pvtVals = @find(\".pvtVals\")\n for x in [0...numInputsToProcess]\n newDropdown = $(\"
\").addClass(\"pvtUiCell\")\n\n renderer = $(\"\").addClass('pvtAxisContainer pvtUnused pvtUiCell')\n shownAttributes = (a for a of attrValues when a not in opts.hiddenAttributes)\n shownInAggregators = (c for c in shownAttributes when c not in opts.hiddenFromAggregators)\n shownInDragDrop = (c for c in shownAttributes when c not in opts.hiddenFromDragDrop)\n\n\n unusedAttrsVerticalAutoOverride = false\n if opts.unusedAttrsVertical == \"auto\"\n unusedAttrsVerticalAutoCutoff = 120 # legacy support\n else\n unusedAttrsVerticalAutoCutoff = parseInt opts.unusedAttrsVertical\n\n if not isNaN(unusedAttrsVerticalAutoCutoff)\n attrLength = 0\n attrLength += a.length for a in shownInDragDrop\n unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff\n\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n unused.addClass('pvtVertList')\n else\n unused.addClass('pvtHorizList')\n\n for own i, attr of shownInDragDrop\n do (attr) ->\n values = (v for v of attrValues[attr])\n hasExcludedItem = false\n valueList = $(\"
\").addClass('pvtFilterBox').hide()\n\n valueList.append $(\"

\").append(\n $(\"\").text(attr),\n $(\"\").addClass(\"count\").text(\"(#{values.length})\"),\n )\n if values.length > opts.menuLimit\n valueList.append $(\"

\").html(opts.localeStrings.tooMany)\n else\n if values.length > 5\n controls = $(\"

\").appendTo(valueList)\n sorter = getSort(opts.sorters, attr)\n placeholder = opts.localeStrings.filterResults\n $(\"\", {type: \"text\"}).appendTo(controls)\n .attr({placeholder: placeholder, class: \"pvtSearch\"})\n .bind \"keyup\", ->\n filter = $(this).val().toLowerCase().trim()\n accept_gen = (prefix, accepted) -> (v) ->\n real_filter = filter.substring(prefix.length).trim()\n return true if real_filter.length == 0\n return Math.sign(sorter(v.toLowerCase(), real_filter)) in accepted\n accept =\n if filter.indexOf(\">=\") == 0 then accept_gen(\">=\", [1,0])\n else if filter.indexOf(\"<=\") == 0 then accept_gen(\"<=\", [-1,0])\n else if filter.indexOf(\">\") == 0 then accept_gen(\">\", [1])\n else if filter.indexOf(\"<\") == 0 then accept_gen(\"<\", [-1])\n else if filter.indexOf(\"~\") == 0 then (v) ->\n return true if filter.substring(1).trim().length == 0\n v.toLowerCase().match(filter.substring(1))\n else (v) -> v.toLowerCase().indexOf(filter) != -1\n\n valueList.find('.pvtCheckContainer p label span.value').each ->\n if accept($(this).text())\n $(this).parent().parent().show()\n else\n $(this).parent().parent().hide()\n controls.append $(\"
\")\n $(\"

\").addClass('pvtVals pvtUiCell')\n .appendTo(tr1)\n .append(aggregator)\n .append(rowOrderArrow)\n .append(colOrderArrow)\n .append($(\"
\"))\n\n #column axes\n $(\"
\").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1)\n\n tr2 = $(\"
\").addClass('pvtAxisContainer pvtRows pvtUiCell').attr(\"valign\", \"top\")\n\n #the actual pivot table container\n pivotTable = $(\"\")\n .attr(\"valign\", \"top\")\n .addClass('pvtRendererArea')\n .appendTo(tr2)\n\n #finally the renderer dropdown and unused attribs are inserted at the requested location\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n uiTable.find('tr:nth-child(1)').prepend rendererControl\n uiTable.find('tr:nth-child(2)').prepend unused\n else\n uiTable.prepend $(\"
\", {\n \"class\": \"pvtUi\"\n }).attr(\"cellpadding\", 5);\n rendererControl = $(\"\").appendTo(uiTable);\n aggregator = $(\"\").appendTo(uiTable);\n tr2.append($(\"\").append(rendererControl).append(unused));\n }\n this.html(uiTable);\n ref2 = opts.cols;\n for (n = 0, len2 = ref2.length; n < len2; n++) {\n x = ref2[n];\n this.find(\".pvtCols\").append(this.find(\".axis_\" + ($.inArray(x, shownInDragDrop))));\n }\n ref3 = opts.rows;\n for (o = 0, len3 = ref3.length; o < len3; o++) {\n x = ref3[o];\n this.find(\".pvtRows\").append(this.find(\".axis_\" + ($.inArray(x, shownInDragDrop))));\n }\n if (opts.aggregatorName != null) {\n this.find(\".pvtAggregator\").val(opts.aggregatorName);\n }\n if (opts.rendererName != null) {\n this.find(\".pvtRenderer\").val(opts.rendererName);\n }\n if (!opts.showUI) {\n this.find(\".pvtUiCell\").hide();\n }\n initialRender = true;\n refreshDelayed = (function(_this) {\n return function() {\n var exclusions, inclusions, len4, newDropdown, numInputsToProcess, pivotUIOptions, pvtVals, ref4, ref5, subopts, t, u, unusedAttrsContainer, vals;\n subopts = {\n derivedAttributes: opts.derivedAttributes,\n localeStrings: opts.localeStrings,\n rendererOptions: opts.rendererOptions,\n sorters: opts.sorters,\n cols: [],\n rows: [],\n dataClass: opts.dataClass\n };\n numInputsToProcess = (ref4 = opts.aggregators[aggregator.val()]([])().numInputs) != null ? ref4 : 0;\n vals = [];\n _this.find(\".pvtRows li span.pvtAttr\").each(function() {\n return subopts.rows.push($(this).data(\"attrName\"));\n });\n _this.find(\".pvtCols li span.pvtAttr\").each(function() {\n return subopts.cols.push($(this).data(\"attrName\"));\n });\n _this.find(\".pvtVals select.pvtAttrDropdown\").each(function() {\n if (numInputsToProcess === 0) {\n return $(this).remove();\n } else {\n numInputsToProcess--;\n if ($(this).val() !== \"\") {\n return vals.push($(this).val());\n }\n }\n });\n if (numInputsToProcess !== 0) {\n pvtVals = _this.find(\".pvtVals\");\n for (x = t = 0, ref5 = numInputsToProcess; 0 <= ref5 ? t < ref5 : t > ref5; x = 0 <= ref5 ? ++t : --t) {\n newDropdown = $(\"
\").addClass(\"pvtUiCell\");\n renderer = $(\"\").addClass('pvtAxisContainer pvtUnused pvtUiCell');\n shownAttributes = (function() {\n var results;\n results = [];\n for (a in attrValues) {\n if (indexOf.call(opts.hiddenAttributes, a) < 0) {\n results.push(a);\n }\n }\n return results;\n })();\n shownInAggregators = (function() {\n var l, len1, results;\n results = [];\n for (l = 0, len1 = shownAttributes.length; l < len1; l++) {\n c = shownAttributes[l];\n if (indexOf.call(opts.hiddenFromAggregators, c) < 0) {\n results.push(c);\n }\n }\n return results;\n })();\n shownInDragDrop = (function() {\n var l, len1, results;\n results = [];\n for (l = 0, len1 = shownAttributes.length; l < len1; l++) {\n c = shownAttributes[l];\n if (indexOf.call(opts.hiddenFromDragDrop, c) < 0) {\n results.push(c);\n }\n }\n return results;\n })();\n unusedAttrsVerticalAutoOverride = false;\n if (opts.unusedAttrsVertical === \"auto\") {\n unusedAttrsVerticalAutoCutoff = 120;\n } else {\n unusedAttrsVerticalAutoCutoff = parseInt(opts.unusedAttrsVertical);\n }\n if (!isNaN(unusedAttrsVerticalAutoCutoff)) {\n attrLength = 0;\n for (l = 0, len1 = shownInDragDrop.length; l < len1; l++) {\n a = shownInDragDrop[l];\n attrLength += a.length;\n }\n unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff;\n }\n if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {\n unused.addClass('pvtVertList');\n } else {\n unused.addClass('pvtHorizList');\n }\n fn1 = function(attr) {\n var attrElem, checkContainer, closeFilterBox, controls, filterItem, filterItemExcluded, finalButtons, hasExcludedItem, len2, n, placeholder, ref1, sorter, triangleLink, v, value, valueCount, valueList, values;\n values = (function() {\n var results;\n results = [];\n for (v in attrValues[attr]) {\n results.push(v);\n }\n return results;\n })();\n hasExcludedItem = false;\n valueList = $(\"
\").addClass('pvtFilterBox').hide();\n valueList.append($(\"

\").append($(\"\").text(attr), $(\"\").addClass(\"count\").text(\"(\" + values.length + \")\")));\n if (values.length > opts.menuLimit) {\n valueList.append($(\"

\").html(opts.localeStrings.tooMany));\n } else {\n if (values.length > 5) {\n controls = $(\"

\").appendTo(valueList);\n sorter = getSort(opts.sorters, attr);\n placeholder = opts.localeStrings.filterResults;\n $(\"\", {\n type: \"text\"\n }).appendTo(controls).attr({\n placeholder: placeholder,\n \"class\": \"pvtSearch\"\n }).bind(\"keyup\", function() {\n var accept, accept_gen, filter;\n filter = $(this).val().toLowerCase().trim();\n accept_gen = function(prefix, accepted) {\n return function(v) {\n var real_filter, ref1;\n real_filter = filter.substring(prefix.length).trim();\n if (real_filter.length === 0) {\n return true;\n }\n return ref1 = Math.sign(sorter(v.toLowerCase(), real_filter)), indexOf.call(accepted, ref1) >= 0;\n };\n };\n accept = filter.indexOf(\">=\") === 0 ? accept_gen(\">=\", [1, 0]) : filter.indexOf(\"<=\") === 0 ? accept_gen(\"<=\", [-1, 0]) : filter.indexOf(\">\") === 0 ? accept_gen(\">\", [1]) : filter.indexOf(\"<\") === 0 ? accept_gen(\"<\", [-1]) : filter.indexOf(\"~\") === 0 ? function(v) {\n if (filter.substring(1).trim().length === 0) {\n return true;\n }\n return v.toLowerCase().match(filter.substring(1));\n } : function(v) {\n return v.toLowerCase().indexOf(filter) !== -1;\n };\n return valueList.find('.pvtCheckContainer p label span.value').each(function() {\n if (accept($(this).text())) {\n return $(this).parent().parent().show();\n } else {\n return $(this).parent().parent().hide();\n }\n });\n });\n controls.append($(\"
\"));\n $(\"

\").addClass('pvtVals pvtUiCell').appendTo(tr1).append(aggregator).append(rowOrderArrow).append(colOrderArrow).append($(\"
\"));\n $(\"
\").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1);\n tr2 = $(\"
\").addClass('pvtAxisContainer pvtRows pvtUiCell').attr(\"valign\", \"top\"));\n pivotTable = $(\"\").attr(\"valign\", \"top\").addClass('pvtRendererArea').appendTo(tr2);\n if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {\n uiTable.find('tr:nth-child(1)').prepend(rendererControl);\n uiTable.find('tr:nth-child(2)').prepend(unused);\n } else {\n uiTable.prepend($(\"
\", \"class\": \"pvtUi\").attr(\"cellpadding\", 5)\n\n #renderer control\n rendererControl = $(\"\").appendTo(uiTable)\n\n #aggregator menu and value area\n\n aggregator = $(\"\").appendTo(uiTable)\n\n #row axes\n tr2.append $(\"\").append(rendererControl).append(unused)\n\n #render the UI in its default state\n @html uiTable\n\n #set up the UI initial state as requested by moving elements around\n\n for x in opts.cols\n @find(\".pvtCols\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n for x in opts.rows\n @find(\".pvtRows\").append @find(\".axis_#{$.inArray(x, shownInDragDrop)}\")\n if opts.aggregatorName?\n @find(\".pvtAggregator\").val opts.aggregatorName\n if opts.rendererName?\n @find(\".pvtRenderer\").val opts.rendererName\n\n @find(\".pvtUiCell\").hide() unless opts.showUI\n\n initialRender = true\n\n #set up for refreshing\n refreshDelayed = =>\n subopts =\n derivedAttributes: opts.derivedAttributes\n localeStrings: opts.localeStrings\n rendererOptions: opts.rendererOptions\n sorters: opts.sorters\n cols: [], rows: []\n dataClass: opts.dataClass\n\n numInputsToProcess = opts.aggregators[aggregator.val()]([])().numInputs ? 0\n vals = []\n @find(\".pvtRows li span.pvtAttr\").each -> subopts.rows.push $(this).data(\"attrName\")\n @find(\".pvtCols li span.pvtAttr\").each -> subopts.cols.push $(this).data(\"attrName\")\n @find(\".pvtVals select.pvtAttrDropdown\").each ->\n if numInputsToProcess == 0\n $(this).remove()\n else\n numInputsToProcess--\n vals.push $(this).val() if $(this).val() != \"\"\n\n if numInputsToProcess != 0\n pvtVals = @find(\".pvtVals\")\n for x in [0...numInputsToProcess]\n newDropdown = $(\"
\").addClass(\"pvtUiCell\")\n\n renderer = $(\"\").addClass('pvtAxisContainer pvtUnused pvtUiCell')\n shownAttributes = (a for a of attrValues when a not in opts.hiddenAttributes)\n shownInAggregators = (c for c in shownAttributes when c not in opts.hiddenFromAggregators)\n shownInDragDrop = (c for c in shownAttributes when c not in opts.hiddenFromDragDrop)\n\n\n unusedAttrsVerticalAutoOverride = false\n if opts.unusedAttrsVertical == \"auto\"\n unusedAttrsVerticalAutoCutoff = 120 # legacy support\n else\n unusedAttrsVerticalAutoCutoff = parseInt opts.unusedAttrsVertical\n\n if not isNaN(unusedAttrsVerticalAutoCutoff)\n attrLength = 0\n attrLength += a.length for a in shownInDragDrop\n unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff\n\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n unused.addClass('pvtVertList')\n else\n unused.addClass('pvtHorizList')\n\n for own i, attr of shownInDragDrop\n do (attr) ->\n values = (v for v of attrValues[attr])\n hasExcludedItem = false\n valueList = $(\"
\").addClass('pvtFilterBox').hide()\n\n valueList.append $(\"

\").append(\n $(\"\").text(attr),\n $(\"\").addClass(\"count\").text(\"(#{values.length})\"),\n )\n if values.length > opts.menuLimit\n valueList.append $(\"

\").html(opts.localeStrings.tooMany)\n else\n if values.length > 5\n controls = $(\"

\").appendTo(valueList)\n sorter = getSort(opts.sorters, attr)\n placeholder = opts.localeStrings.filterResults\n $(\"\", {type: \"text\"}).appendTo(controls)\n .attr({placeholder: placeholder, class: \"pvtSearch\"})\n .bind \"keyup\", ->\n filter = $(this).val().toLowerCase().trim()\n accept_gen = (prefix, accepted) -> (v) ->\n real_filter = filter.substring(prefix.length).trim()\n return true if real_filter.length == 0\n return Math.sign(sorter(v.toLowerCase(), real_filter)) in accepted\n accept =\n if filter.indexOf(\">=\") == 0 then accept_gen(\">=\", [1,0])\n else if filter.indexOf(\"<=\") == 0 then accept_gen(\"<=\", [-1,0])\n else if filter.indexOf(\">\") == 0 then accept_gen(\">\", [1])\n else if filter.indexOf(\"<\") == 0 then accept_gen(\"<\", [-1])\n else if filter.indexOf(\"~\") == 0 then (v) ->\n return true if filter.substring(1).trim().length == 0\n v.toLowerCase().match(filter.substring(1))\n else (v) -> v.toLowerCase().indexOf(filter) != -1\n\n valueList.find('.pvtCheckContainer p label span.value').each ->\n if accept($(this).text())\n $(this).parent().parent().show()\n else\n $(this).parent().parent().hide()\n controls.append $(\"
\")\n $(\"

\").addClass('pvtVals pvtUiCell')\n .appendTo(tr1)\n .append(aggregator)\n .append(rowOrderArrow)\n .append(colOrderArrow)\n .append($(\"
\"))\n\n #column axes\n $(\"
\").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1)\n\n tr2 = $(\"
\").addClass('pvtAxisContainer pvtRows pvtUiCell').attr(\"valign\", \"top\")\n\n #the actual pivot table container\n pivotTable = $(\"\")\n .attr(\"valign\", \"top\")\n .addClass('pvtRendererArea')\n .appendTo(tr2)\n\n #finally the renderer dropdown and unused attribs are inserted at the requested location\n if opts.unusedAttrsVertical == true or unusedAttrsVerticalAutoOverride\n uiTable.find('tr:nth-child(1)').prepend rendererControl\n uiTable.find('tr:nth-child(2)').prepend unused\n else\n uiTable.prepend $(\"
\", {\n \"class\": \"pvtUi\"\n }).attr(\"cellpadding\", 5);\n rendererControl = $(\"\").appendTo(uiTable);\n aggregator = $(\"\").appendTo(uiTable);\n tr2.append($(\"\").append(rendererControl).append(unused));\n }\n this.html(uiTable);\n ref2 = opts.cols;\n for (n = 0, len2 = ref2.length; n < len2; n++) {\n x = ref2[n];\n this.find(\".pvtCols\").append(this.find(\".axis_\" + ($.inArray(x, shownInDragDrop))));\n }\n ref3 = opts.rows;\n for (o = 0, len3 = ref3.length; o < len3; o++) {\n x = ref3[o];\n this.find(\".pvtRows\").append(this.find(\".axis_\" + ($.inArray(x, shownInDragDrop))));\n }\n if (opts.aggregatorName != null) {\n this.find(\".pvtAggregator\").val(opts.aggregatorName);\n }\n if (opts.rendererName != null) {\n this.find(\".pvtRenderer\").val(opts.rendererName);\n }\n if (!opts.showUI) {\n this.find(\".pvtUiCell\").hide();\n }\n initialRender = true;\n refreshDelayed = (function(_this) {\n return function() {\n var exclusions, inclusions, len4, newDropdown, numInputsToProcess, pivotUIOptions, pvtVals, ref4, ref5, subopts, t, u, unusedAttrsContainer, vals;\n subopts = {\n derivedAttributes: opts.derivedAttributes,\n localeStrings: opts.localeStrings,\n rendererOptions: opts.rendererOptions,\n sorters: opts.sorters,\n cols: [],\n rows: [],\n dataClass: opts.dataClass\n };\n numInputsToProcess = (ref4 = opts.aggregators[aggregator.val()]([])().numInputs) != null ? ref4 : 0;\n vals = [];\n _this.find(\".pvtRows li span.pvtAttr\").each(function() {\n return subopts.rows.push($(this).data(\"attrName\"));\n });\n _this.find(\".pvtCols li span.pvtAttr\").each(function() {\n return subopts.cols.push($(this).data(\"attrName\"));\n });\n _this.find(\".pvtVals select.pvtAttrDropdown\").each(function() {\n if (numInputsToProcess === 0) {\n return $(this).remove();\n } else {\n numInputsToProcess--;\n if ($(this).val() !== \"\") {\n return vals.push($(this).val());\n }\n }\n });\n if (numInputsToProcess !== 0) {\n pvtVals = _this.find(\".pvtVals\");\n for (x = t = 0, ref5 = numInputsToProcess; 0 <= ref5 ? t < ref5 : t > ref5; x = 0 <= ref5 ? ++t : --t) {\n newDropdown = $(\"
\").addClass(\"pvtUiCell\");\n renderer = $(\"\").addClass('pvtAxisContainer pvtUnused pvtUiCell');\n shownAttributes = (function() {\n var results;\n results = [];\n for (a in attrValues) {\n if (indexOf.call(opts.hiddenAttributes, a) < 0) {\n results.push(a);\n }\n }\n return results;\n })();\n shownInAggregators = (function() {\n var l, len1, results;\n results = [];\n for (l = 0, len1 = shownAttributes.length; l < len1; l++) {\n c = shownAttributes[l];\n if (indexOf.call(opts.hiddenFromAggregators, c) < 0) {\n results.push(c);\n }\n }\n return results;\n })();\n shownInDragDrop = (function() {\n var l, len1, results;\n results = [];\n for (l = 0, len1 = shownAttributes.length; l < len1; l++) {\n c = shownAttributes[l];\n if (indexOf.call(opts.hiddenFromDragDrop, c) < 0) {\n results.push(c);\n }\n }\n return results;\n })();\n unusedAttrsVerticalAutoOverride = false;\n if (opts.unusedAttrsVertical === \"auto\") {\n unusedAttrsVerticalAutoCutoff = 120;\n } else {\n unusedAttrsVerticalAutoCutoff = parseInt(opts.unusedAttrsVertical);\n }\n if (!isNaN(unusedAttrsVerticalAutoCutoff)) {\n attrLength = 0;\n for (l = 0, len1 = shownInDragDrop.length; l < len1; l++) {\n a = shownInDragDrop[l];\n attrLength += a.length;\n }\n unusedAttrsVerticalAutoOverride = attrLength > unusedAttrsVerticalAutoCutoff;\n }\n if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {\n unused.addClass('pvtVertList');\n } else {\n unused.addClass('pvtHorizList');\n }\n fn1 = function(attr) {\n var attrElem, checkContainer, closeFilterBox, controls, filterItem, filterItemExcluded, finalButtons, hasExcludedItem, len2, n, placeholder, ref1, sorter, triangleLink, v, value, valueCount, valueList, values;\n values = (function() {\n var results;\n results = [];\n for (v in attrValues[attr]) {\n results.push(v);\n }\n return results;\n })();\n hasExcludedItem = false;\n valueList = $(\"
\").addClass('pvtFilterBox').hide();\n valueList.append($(\"

\").append($(\"\").text(attr), $(\"\").addClass(\"count\").text(\"(\" + values.length + \")\")));\n if (values.length > opts.menuLimit) {\n valueList.append($(\"

\").html(opts.localeStrings.tooMany));\n } else {\n if (values.length > 5) {\n controls = $(\"

\").appendTo(valueList);\n sorter = getSort(opts.sorters, attr);\n placeholder = opts.localeStrings.filterResults;\n $(\"\", {\n type: \"text\"\n }).appendTo(controls).attr({\n placeholder: placeholder,\n \"class\": \"pvtSearch\"\n }).bind(\"keyup\", function() {\n var accept, accept_gen, filter;\n filter = $(this).val().toLowerCase().trim();\n accept_gen = function(prefix, accepted) {\n return function(v) {\n var real_filter, ref1;\n real_filter = filter.substring(prefix.length).trim();\n if (real_filter.length === 0) {\n return true;\n }\n return ref1 = Math.sign(sorter(v.toLowerCase(), real_filter)), indexOf.call(accepted, ref1) >= 0;\n };\n };\n accept = filter.indexOf(\">=\") === 0 ? accept_gen(\">=\", [1, 0]) : filter.indexOf(\"<=\") === 0 ? accept_gen(\"<=\", [-1, 0]) : filter.indexOf(\">\") === 0 ? accept_gen(\">\", [1]) : filter.indexOf(\"<\") === 0 ? accept_gen(\"<\", [-1]) : filter.indexOf(\"~\") === 0 ? function(v) {\n if (filter.substring(1).trim().length === 0) {\n return true;\n }\n return v.toLowerCase().match(filter.substring(1));\n } : function(v) {\n return v.toLowerCase().indexOf(filter) !== -1;\n };\n return valueList.find('.pvtCheckContainer p label span.value').each(function() {\n if (accept($(this).text())) {\n return $(this).parent().parent().show();\n } else {\n return $(this).parent().parent().hide();\n }\n });\n });\n controls.append($(\"
\"));\n $(\"

\").addClass('pvtVals pvtUiCell').appendTo(tr1).append(aggregator).append(rowOrderArrow).append(colOrderArrow).append($(\"
\"));\n $(\"
\").addClass('pvtAxisContainer pvtHorizList pvtCols pvtUiCell').appendTo(tr1);\n tr2 = $(\"
\").addClass('pvtAxisContainer pvtRows pvtUiCell').attr(\"valign\", \"top\"));\n pivotTable = $(\"\").attr(\"valign\", \"top\").addClass('pvtRendererArea').appendTo(tr2);\n if (opts.unusedAttrsVertical === true || unusedAttrsVerticalAutoOverride) {\n uiTable.find('tr:nth-child(1)').prepend(rendererControl);\n uiTable.find('tr:nth-child(2)').prepend(unused);\n } else {\n uiTable.prepend($(\"
\n \n \n \n \n \n \n \n
ab
1 2
3 4
\n \"\"\"\n pd = new $.pivotUtilities.PivotData tableInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n\n describe \"with rows/cols\", ->\n pd = new $.pivotUtilities.PivotData fixtureData,\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"]\n\n it \"has correctly-ordered row keys\", ->\n expect pd.getRowKeys()\n .toEqual [ [ 'Carol', 'yellow' ], [ 'Jane', 'red' ], [ 'John', 'blue' ], [ 'Nick', 'blue' ] ]\n\n it \"has correctly-ordered col keys\", ->\n expect pd.getColKeys()\n .toEqual [ [ 95, 25 ], [ 102, 14 ], [ 103, 12 ], [ 112, 30 ] ]\n\n it \"can be iterated over\", ->\n numNotNull = 0\n numNull = 0\n for r in pd.getRowKeys()\n for c in pd.getColKeys()\n if pd.getAggregator(r, c).value()?\n numNotNull++\n else\n numNull++\n expect numNotNull\n .toBe 4\n expect numNull\n .toBe 12\n\n it \"returns matching records\", ->\n records = []\n pd.forEachMatchingRecord gender: \"male\", (x) -> records.push(x.name)\n expect records\n .toEqual [\"Nick\", \"John\"]\n\n it \"has a correct spot-checked aggregator\", ->\n agg = pd.getAggregator([ 'Carol', 'yellow' ],[ 102, 14 ])\n val = agg.value()\n expect(val).toBe 1\n expect(agg.format(val)).toBe \"1\"\n\n it \"has a correct grand total aggregator\", ->\n agg = pd.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 4\n expect(agg.format(val)).toBe \"4\"\n\n describe \".aggregatorTemplates\", ->\n\n getVal = (aggregator) ->\n pd = new $.pivotUtilities.PivotData(fixtureData, {aggregator})\n return pd.getAggregator([],[]).value()\n tpl = $.pivotUtilities.aggregatorTemplates\n\n describe \".count\", ->\n it \"works\", ->\n expect getVal(tpl.count()())\n .toBe 4\n\n describe \".countUnique\", ->\n it \"works\", ->\n expect getVal(tpl.countUnique()(['gender']))\n .toBe 2\n\n describe \".listUnique\", ->\n it \"works\", ->\n expect getVal(tpl.listUnique()(['gender']))\n .toBe 'female,male'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".sum\", ->\n it \"works\", ->\n expect getVal(tpl.sum()(['trials']))\n .toBe 412\n\n describe \".min\", ->\n it \"works\", ->\n expect getVal(tpl.min()(['trials']))\n .toBe 95\n\n describe \".max\", ->\n it \"works\", ->\n expect getVal(tpl.max()(['trials']))\n .toBe 112\n\n describe \".first\", ->\n it \"works\", ->\n expect getVal(tpl.first()(['name']))\n .toBe 'Carol'\n\n describe \".last\", ->\n it \"works\", ->\n expect getVal(tpl.last()(['name']))\n .toBe 'Nick'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".median\", ->\n it \"works\", ->\n expect getVal(tpl.median()(['trials']))\n .toBe 102.5\n\n describe \".quantile\", ->\n it \"works\", ->\n expect getVal(tpl.quantile(0)(['trials']))\n .toBe 95\n expect getVal(tpl.quantile(0.1)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(0.25)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(1/3)(['trials']))\n .toBe 102\n expect getVal(tpl.quantile(1)(['trials']))\n .toBe 112\n\n describe \".var\", ->\n it \"works\", ->\n expect getVal(tpl.var()(['trials']))\n .toBe 48.666666666666686\n\n describe \".stdev\", ->\n it \"works\", ->\n expect getVal(tpl.stdev()(['trials']))\n .toBe 6.976149845485451\n\n describe \".sumOverSum\", ->\n it \"works\", ->\n expect getVal(tpl.sumOverSum()(['successes', 'trials']))\n .toBe (12+25+30+14)/(95+102+103+112)\n\n describe \".naturalSort()\", ->\n naturalSort = $.pivotUtilities.naturalSort\n\n sortedArr = [\n null, NaN,\n -Infinity, '-Infinity', -3, '-3', -2, '-2', -1, '-1',\n 0, '2e-1', 1, '01', '1', 2, '002', '002e0', '02', '2', '2e-0',\n 3, 10, '10', '11', '12', '1e2', '112', Infinity, 'Infinity',\n '1a', '2a','12a','20a',\n 'A', 'A', 'NaN', 'a', 'a',\n 'a01', 'a012', 'a02', 'a1', 'a2', 'a12', 'a12', 'a21', 'a21',\n 'b', 'c', 'd', 'null'\n ]\n\n it \"sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)\", ->\n expect sortedArr.slice().sort(naturalSort)\n .toEqual sortedArr\n\n describe \".sortAs()\", ->\n sortAs = $.pivotUtilities.sortAs\n\n it \"sorts with unknown values sorted at the end\", ->\n expect [5,2,3,4,1].sort sortAs([4,3,2])\n .toEqual [4,3,2,1,5]\n\n it \"sorts lowercase after uppercase\", ->\n expect [\"Ab\",\"aA\",\"aa\",\"ab\"].sort sortAs([\"Ab\",\"Aa\"])\n .toEqual [\"Ab\",\"ab\",\"aa\",\"aA\"]\n\n describe \".numberFormat()\", ->\n numberFormat = $.pivotUtilities.numberFormat\n\n it \"formats numbers\", ->\n nf = numberFormat()\n expect nf 1234567.89123456\n .toEqual \"1,234,567.89\"\n\n it \"formats booleans\", ->\n nf = numberFormat()\n expect nf true\n .toEqual \"1.00\"\n\n it \"formats numbers in strings\", ->\n nf = numberFormat()\n expect nf \"1234567.89123456\"\n .toEqual \"1,234,567.89\"\n\n it \"doesn't formats strings\", ->\n nf = numberFormat()\n expect nf \"hi there\"\n .toEqual \"\"\n\n it \"doesn't formats objects\", ->\n nf = numberFormat()\n expect nf {a:1}\n .toEqual \"\"\n\n it \"formats percentages\", ->\n nf = numberFormat(scaler: 100, suffix: \"%\")\n expect nf 0.12345\n .toEqual \"12.35%\"\n\n it \"adds separators\", ->\n nf = numberFormat(thousandsSep: \"a\", decimalSep: \"b\")\n expect nf 1234567.89123456\n .toEqual \"1a234a567b89\"\n\n it \"adds prefixes and suffixes\", ->\n nf = numberFormat(prefix: \"a\", suffix: \"b\")\n expect nf 1234567.89123456\n .toEqual \"a1,234,567.89b\"\n\n it \"scales and rounds\", ->\n nf = numberFormat(digitsAfterDecimal: 3, scaler: 1000)\n expect nf 1234567.89123456\n .toEqual \"1,234,567,891.235\"\n\n describe \".derivers\", ->\n describe \".dateFormat()\", ->\n df = $.pivotUtilities.derivers.dateFormat \"x\", \"abc % %% %%% %a %y %m %n %d %w %x %H %M %S\", true\n\n it \"formats date objects\", ->\n expect df {x: new Date(\"2015-01-02T23:43:11Z\")}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n it \"formats input parsed by Date.parse()\", ->\n expect df {x: \"2015-01-02T23:43:11Z\"}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n expect df {x: \"bla\"}\n .toBe ''\n\n describe \".bin()\", ->\n binner = $.pivotUtilities.derivers.bin \"x\", 10\n\n it \"bins numbers\", ->\n expect binner {x: 11}\n .toBe 10\n\n expect binner {x: 9}\n .toBe 0\n\n expect binner {x: 111}\n .toBe 110\n\n it \"bins booleans\", ->\n expect binner {x: true}\n .toBe 0\n\n it \"bins negative numbers\", ->\n expect binner {x: -12}\n .toBe -10\n\n it \"doesn't bin strings\", ->\n expect binner {x: \"a\"}\n .toBeNaN()\n\n it \"doesn't bin objects\", ->\n expect binner {x: {a:1}}\n .toBeNaN()\n"]} \ No newline at end of file +{"version":3,"file":"pivot_spec.js","sources":["pivot_spec.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA;;EAAA,WAAA,GAAc,CACV,CAAC,MAAD,EAAY,QAAZ,EAAwB,QAAxB,EAAqC,UAArC,EAAqD,QAArD,EAAiE,WAAjE,CADU,EAEV,CAAC,MAAD,EAAY,MAAZ,EAAwB,MAAxB,EAAqC,YAArC,EAAqD,GAArD,EAAiE,EAAjE,CAFU,EAGV,CAAC,MAAD,EAAY,QAAZ,EAAwB,KAAxB,EAAqC,YAArC,EAAqD,EAArD,EAAiE,EAAjE,CAHU,EAIV,CAAC,MAAD,EAAY,MAAZ,EAAwB,MAAxB,EAAqC,YAArC,EAAqD,GAArD,EAAiE,EAAjE,CAJU,EAKV,CAAC,OAAD,EAAY,QAAZ,EAAwB,QAAxB,EAAqC,YAArC,EAAqD,GAArD,EAAiE,EAAjE,CALU;;EAQd,iBAAA,GAAoB;IAChB;MAAC,IAAA,EAAM,MAAP;MAAe,QAAA,EAAU,KAAzB;MAAgC,KAAA,EAAO,EAAvC;KADgB,EAEhB;MAAC,IAAA,EAAM,MAAP;MAAe,QAAA,EAAU,QAAzB;KAFgB,EAGhB;MAAC,IAAA,EAAM,MAAP;MAAe,QAAA,EAAU,MAAzB;MAAiC,KAAA,EAAO,EAAxC;KAHgB,EAIhB;MAAC,IAAA,EAAM,KAAP;MAAc,QAAA,EAAU,IAAxB;MAA8B,KAAA,EAAO,EAArC;KAJgB;;;EAOpB,QAAA,CAAS,aAAT,EAAwB,SAAA;IACpB,QAAA,CAAS,oEAAT,EAAgF,SAAA;AAC5E,UAAA;MAAA,KAAA,GAAQ;MAER,UAAA,CAAW,SAAC,IAAD;eACP,KAAA,GAAQ,CAAA,CAAE,OAAF,CAAU,CAAC,OAAX,CAAmB,WAAnB,EAAgC;UAAA,SAAA,EAAW,IAAX;SAAhC;MADD,CAAX;MAEA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B,CAApB;QAIA,EAAA,CAAG,uBAAH,EAA4B,SAAA;iBACxB,MAAA,CAAO,MAAA,CAAO;YAAC,CAAA,EAAG,CAAC,EAAL;WAAP,CAAP,CACA,CAAC,IADD,CACM,CAAC,EADP;QADwB,CAA5B;QAIA,EAAA,CAAG,qBAAH,EAA0B,SAAA;iBACtB,MAAA,CAAO,MAAA,CAAO;YAAC,CAAA,EAAG,GAAJ;WAAP,CAAP,CACA,CAAC,OADD,CAAA;QADsB,CAA1B;eAIA,EAAA,CAAG,qBAAH,EAA0B,SAAA;iBACtB,MAAA,CAAO,MAAA,CAAO;YAAC,CAAA,EAAG;cAAC,CAAA,EAAE,CAAH;aAAJ;WAAP,CAAP,CACA,CAAC,OADD,CAAA;QADsB,CAA1B;MAzBe,CAAnB;IAfkB,CAAtB;EAnSyB,CAA7B;AAzQA","sourcesContent":["fixtureData = [\n [\"name\", \"gender\", \"colour\", \"birthday\", \"trials\", \"successes\"],\n [\"Nick\", \"male\", \"blue\", \"1982-11-07\", 103, 12],\n [\"Jane\", \"female\", \"red\", \"1982-11-08\", 95, 25],\n [\"John\", \"male\", \"blue\", \"1982-12-08\", 112, 30],\n [\"Carol\", \"female\", \"yellow\", \"1983-12-08\", 102, 14]\n]\n\nraggedFixtureData = [\n {name: \"Nick\", \"colour\": \"red\", \"age\": 34}\n {name: \"Jane\", \"gender\": \"female\"}\n {name: \"John\", \"gender\": \"male\", \"age\": 12}\n {name: \"Jim\", \"gender\": null, \"age\": 12}\n]\n\ndescribe \"$.pivotUI()\", ->\n describe \"with no rows/cols, default count aggregator, default TableRenderer\", ->\n table = null\n\n beforeEach (done) ->\n table = $(\"
\").pivotUI fixtureData, onRefresh: done\n it \"has all the basic UI elements\", (done) ->\n expect table.find(\"td.pvtAxisContainer\").length\n .toBe 3\n expect table.find(\"td.pvtRendererArea\").length\n .toBe 1\n expect table.find(\"td.pvtVals\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").length\n .toBe 1\n expect table.find(\"select.pvtAggregator\").length\n .toBe 1\n expect table.find(\"span.pvtAttr\").length\n .toBe 6\n done()\n\n it \"reflects its inputs\", (done) ->\n expect table.find(\"td.pvtUnused span.pvtAttr\").length\n .toBe 6\n expect table.find(\"select.pvtRenderer\").val()\n .toBe \"Table\"\n expect table.find(\"select.pvtAggregator\").val()\n .toBe \"Count\"\n done()\n\n it \"renders a table\", (done) ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n done()\n\n\n describe \"its renderer output\", ->\n it \"has the correct type and number of cells\", (done) ->\n expect table.find(\"th.pvtTotalLabel\").length\n .toBe 1\n expect table.find(\"td.pvtGrandTotal\").length\n .toBe 1\n done()\n\n it \"has the correct textual representation\", (done) ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\"Totals\", \"4\"].join(\"\")\n done()\n\n it \"has a correct grand total with data value\", (done) ->\n expect table.find(\"td.pvtGrandTotal\").text()\n .toBe \"4\"\n expect table.find(\"td.pvtGrandTotal\").data(\"value\")\n .toBe 4\n done()\n\n describe \"with rows/cols, sum-over-sum aggregator, Heatmap renderer\", ->\n table = null\n\n beforeEach (done) ->\n table = $(\"
\").pivotUI fixtureData,\n rows: [\"gender\"], cols: [\"colour\"]\n aggregatorName: \"Sum over Sum\"\n vals: [\"successes\", \"trials\"]\n rendererName: \"Heatmap\"\n onRefresh: done\n\n it \"has all the basic UI elements\", (done) ->\n expect table.find(\"td.pvtAxisContainer\").length\n .toBe 3\n expect table.find(\"td.pvtRendererArea\").length\n .toBe 1\n expect table.find(\"td.pvtVals\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").length\n .toBe 1\n expect table.find(\"select.pvtAggregator\").length\n .toBe 1\n expect table.find(\"span.pvtAttr\").length\n .toBe 6\n done()\n\n it \"reflects its inputs\", (done) ->\n expect table.find(\"td.pvtUnused span.pvtAttr\").length\n .toBe 4\n expect table.find(\"td.pvtRows span.pvtAttr\").length\n .toBe 1\n expect table.find(\"td.pvtCols span.pvtAttr\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").val()\n .toBe \"Heatmap\"\n expect table.find(\"select.pvtAggregator\").val()\n .toBe \"Sum over Sum\"\n done()\n\n it \"renders a table\", (done) ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n done()\n\n describe \"its renderer output\", ->\n it \"has the correct type and number of cells\", (done) ->\n expect table.find(\"th.pvtAxisLabel\").length\n .toBe 2\n expect table.find(\"th.pvtRowLabel\").length\n .toBe 2\n expect table.find(\"th.pvtColLabel\").length\n .toBe 3\n expect table.find(\"th.pvtTotalLabel\").length\n .toBe 2\n expect table.find(\"td.pvtVal\").length\n .toBe 6\n expect table.find(\"td.pvtTotal\").length\n .toBe 5\n expect table.find(\"td.pvtGrandTotal\").length\n .toBe 1\n done()\n\n it \"has the correct textual representation\", (done) ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"colour\", \"blue\", \"red\", \"yellow\", \"Totals\",\n \"gender\",\n \"female\", \"0.26\", \"0.14\", \"0.20\",\n \"male\", \"0.20\", \"0.20\",\n \"Totals\", \"0.20\", \"0.26\", \"0.14\", \"0.20\"\n ].join(\"\")\n done()\n\n it \"has a correct spot-checked cell with data value\", (done) ->\n expect table.find(\"td.col0.row1\").text()\n .toBe \"0.20\"\n expect table.find(\"td.col0.row1\").data(\"value\")\n .toBe (12+30)/(103+112)\n done()\n\n describe \"with ragged input\", ->\n table = $(\"
\").pivotUI raggedFixtureData, rows: [\"gender\"], cols: [\"age\"]\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"age\", \"12\", \"34\", \"null\", \"Totals\"\n \"gender\",\n \"female\", \"1\", \"1\"\n \"male\", \"1\", \"1\"\n \"null\", \"1\", \"1\", \"2\"\n \"Totals\", \"2\", \"1\", \"1\", \"4\"\n ].join(\"\")\n\ndescribe \"$.pivot()\", ->\n\n describe \"with no rows/cols, default count aggregator, default TableRenderer\", ->\n table = $(\"
\").pivot fixtureData\n\n it \"renders a table\", ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n\n describe \"its renderer output\", ->\n\n it \"has the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\"Totals\", \"4\"].join(\"\")\n\n it \"has a correct grand total with data value\", ->\n expect table.find(\"td.pvtGrandTotal\").text()\n .toBe \"4\"\n expect table.find(\"td.pvtGrandTotal\").data(\"value\")\n .toBe 4\n\n describe \"with rows/cols, sum aggregator, derivedAttributes, filter and sorters\", ->\n {sortAs, derivers, aggregators} = $.pivotUtilities\n table = $(\"
\").pivot fixtureData,\n rows: [\"gender\"], cols: [\"birthyear\"], aggregator: aggregators[\"Sum\"]([\"trialbins\"])\n filter: (record) -> record.name != \"Nick\"\n derivedAttributes:\n birthyear: derivers.dateFormat \"birthday\", \"%y\"\n trialbins: derivers.bin \"trials\", 10\n sorters: (attr) ->\n if attr == \"gender\" then return sortAs([\"male\", \"female\"])\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"birthyear\", \"1982\", \"1983\", \"Totals\"\n \"gender\",\n \"male\", \"110.00\", \"110.00\"\n \"female\", \"90.00\", \"100.00\", \"190.00\"\n \"Totals\", \"200.00\", \"100.00\", \"300.00\"\n ].join(\"\")\n\n describe \"with rows/cols, fraction-of aggregator\", ->\n {aggregators} = $.pivotUtilities\n table = $(\"
\").pivot fixtureData,\n rows: [\"gender\"]\n aggregator: aggregators[\"Sum as Fraction of Total\"]([\"trials\"])\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"gender\", \"Totals\"\n \"female\", \"47.8%\"\n \"male\", \"52.2%\"\n \"Totals\", \"100.0%\"\n ].join(\"\")\n\n describe \"with rows/cols, custom aggregator, custom renderer with options\", ->\n received_PivotData = null\n received_rendererOptions = null\n\n table = $(\"
\").pivot fixtureData,\n rows: [\"name\", \"colour\"], cols: [\"trials\", \"successes\"]\n aggregator: ->\n count2x: 0\n push: -> @count2x +=2\n value: -> @count2x\n format: (x) -> \"formatted \" + x\n renderer: (a,b) ->\n received_PivotData = a\n received_rendererOptions = b\n return $(\"
\").addClass(b.greeting).text(\"world\")\n rendererOptions: {greeting:\"hithere\"}\n\n it \"renders the custom renderer as per options\", ->\n expect table.find(\"div.hithere\").length\n .toBe 1\n\n describe \"its received PivotData object\", ->\n it \"has a correct grand total value and format for custom aggregator\", ->\n agg = received_PivotData.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 8\n expect(agg.format(val)).toBe \"formatted 8\"\n\n\n describe \"with ragged input\", ->\n table = $(\"
\").pivot raggedFixtureData, rows: [\"gender\"], cols: [\"age\"]\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"age\", \"12\", \"34\", \"null\", \"Totals\"\n \"gender\",\n \"female\", \"1\", \"1\"\n \"male\", \"1\", \"1\"\n \"null\", \"1\", \"1\", \"2\"\n \"Totals\", \"2\", \"1\", \"1\", \"4\"\n ].join(\"\")\n\ndescribe \"$.pivotUtilities\", ->\n\n describe \".PivotData()\", ->\n sumOverSumOpts =\n aggregator: $.pivotUtilities.aggregators[\"Sum over Sum\"]([\"a\",\"b\"])\n\n describe \"with no options\", ->\n aoaInput = [ [\"a\",\"b\"], [1,2], [3,4] ]\n pd = new $.pivotUtilities.PivotData aoaInput\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe 2\n\n describe \"with array-of-array input\", ->\n aoaInput = [ [\"a\",\"b\"], [1,2], [3,4] ]\n pd = new $.pivotUtilities.PivotData aoaInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with array-of-object input\", ->\n aosInput = [ {a:1, b:2}, {a:3, b:4} ]\n pd = new $.pivotUtilities.PivotData aosInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with ragged array-of-object input\", ->\n raggedAosInput = [ {a:1}, {b:4}, {a: 3, b: 2} ]\n pd = new $.pivotUtilities.PivotData raggedAosInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with function input\", ->\n functionInput = (record) ->\n record a:1, b:2\n record a:3, b:4\n pd = new $.pivotUtilities.PivotData functionInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with jQuery table element input\", ->\n tableInput = $ \"\"\"\n \n \n \n \n \n \n \n \n
ab
1 2
3 4
\n \"\"\"\n pd = new $.pivotUtilities.PivotData tableInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with a0-a00 input\", ->\n aoaInput = [\n {key: 'a0', ym: '2020-01'},\n {key: 'a0', ym: '2020-02'},\n {key: 'a00', ym: '2020-01'},\n {key: 'a00', ym: '2020-02'}\n ]\n pd = new $.pivotUtilities.PivotData aoaInput, rows: [\"key\", \"ym\"], cols: []\n\n it \"has correctly-ordered row keys\", ->\n expect pd.getRowKeys()\n .toEqual [[\"a0\",\"2020-01\"],[\"a0\",\"2020-02\"],[\"a00\",\"2020-01\"],[\"a00\",\"2020-02\"]]\n\n describe \"with rows/cols\", ->\n pd = new $.pivotUtilities.PivotData fixtureData,\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"]\n\n it \"has correctly-ordered row keys\", ->\n expect pd.getRowKeys()\n .toEqual [ [ 'Carol', 'yellow' ], [ 'Jane', 'red' ], [ 'John', 'blue' ], [ 'Nick', 'blue' ] ]\n\n it \"has correctly-ordered col keys\", ->\n expect pd.getColKeys()\n .toEqual [ [ 95, 25 ], [ 102, 14 ], [ 103, 12 ], [ 112, 30 ] ]\n\n it \"can be iterated over\", ->\n numNotNull = 0\n numNull = 0\n for r in pd.getRowKeys()\n for c in pd.getColKeys()\n if pd.getAggregator(r, c).value()?\n numNotNull++\n else\n numNull++\n expect numNotNull\n .toBe 4\n expect numNull\n .toBe 12\n\n it \"returns matching records\", ->\n records = []\n pd.forEachMatchingRecord gender: \"male\", (x) -> records.push(x.name)\n expect records\n .toEqual [\"Nick\", \"John\"]\n\n it \"has a correct spot-checked aggregator\", ->\n agg = pd.getAggregator([ 'Carol', 'yellow' ],[ 102, 14 ])\n val = agg.value()\n expect(val).toBe 1\n expect(agg.format(val)).toBe \"1\"\n\n it \"has a correct grand total aggregator\", ->\n agg = pd.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 4\n expect(agg.format(val)).toBe \"4\"\n\n describe \".aggregatorTemplates\", ->\n\n getVal = (aggregator) ->\n pd = new $.pivotUtilities.PivotData(fixtureData, {aggregator})\n return pd.getAggregator([],[]).value()\n tpl = $.pivotUtilities.aggregatorTemplates\n\n describe \".count\", ->\n it \"works\", ->\n expect getVal(tpl.count()())\n .toBe 4\n\n describe \".countUnique\", ->\n it \"works\", ->\n expect getVal(tpl.countUnique()(['gender']))\n .toBe 2\n\n describe \".listUnique\", ->\n it \"works\", ->\n expect getVal(tpl.listUnique()(['gender']))\n .toBe 'female,male'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".sum\", ->\n it \"works\", ->\n expect getVal(tpl.sum()(['trials']))\n .toBe 412\n\n describe \".min\", ->\n it \"works\", ->\n expect getVal(tpl.min()(['trials']))\n .toBe 95\n\n describe \".max\", ->\n it \"works\", ->\n expect getVal(tpl.max()(['trials']))\n .toBe 112\n\n describe \".first\", ->\n it \"works\", ->\n expect getVal(tpl.first()(['name']))\n .toBe 'Carol'\n\n describe \".last\", ->\n it \"works\", ->\n expect getVal(tpl.last()(['name']))\n .toBe 'Nick'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".median\", ->\n it \"works\", ->\n expect getVal(tpl.median()(['trials']))\n .toBe 102.5\n\n describe \".quantile\", ->\n it \"works\", ->\n expect getVal(tpl.quantile(0)(['trials']))\n .toBe 95\n expect getVal(tpl.quantile(0.1)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(0.25)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(1/3)(['trials']))\n .toBe 102\n expect getVal(tpl.quantile(1)(['trials']))\n .toBe 112\n\n describe \".var\", ->\n it \"works\", ->\n expect getVal(tpl.var()(['trials']))\n .toBe 48.666666666666686\n\n describe \".stdev\", ->\n it \"works\", ->\n expect getVal(tpl.stdev()(['trials']))\n .toBe 6.976149845485451\n\n describe \".sumOverSum\", ->\n it \"works\", ->\n expect getVal(tpl.sumOverSum()(['successes', 'trials']))\n .toBe (12+25+30+14)/(95+102+103+112)\n\n describe \".naturalSort()\", ->\n naturalSort = $.pivotUtilities.naturalSort\n\n sortedArr = [\n null, NaN,\n -Infinity, '-Infinity', -3, '-3', -2, '-2', -1, '-1',\n 0, '2e-1', 1, '01', '1', 2, '002', '002e0', '02', '2', '2e-0',\n 3, 10, '10', '11', '12', '1e2', '112', Infinity, 'Infinity',\n '1a', '2a','12a','20a',\n 'A', 'A', 'NaN', 'a', 'a',\n 'a01', 'a012', 'a02', 'a1', 'a2', 'a12', 'a12', 'a21', 'a21',\n 'b', 'c', 'd', 'null'\n ]\n\n it \"sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)\", ->\n expect sortedArr.slice().sort(naturalSort)\n .toEqual sortedArr\n\n describe \".sortAs()\", ->\n sortAs = $.pivotUtilities.sortAs\n\n it \"sorts with unknown values sorted at the end\", ->\n expect [5,2,3,4,1].sort sortAs([4,3,2])\n .toEqual [4,3,2,1,5]\n\n it \"sorts lowercase after uppercase\", ->\n expect [\"Ab\",\"aA\",\"aa\",\"ab\"].sort sortAs([\"Ab\",\"Aa\"])\n .toEqual [\"Ab\",\"ab\",\"aa\",\"aA\"]\n\n describe \".numberFormat()\", ->\n numberFormat = $.pivotUtilities.numberFormat\n\n it \"formats numbers\", ->\n nf = numberFormat()\n expect nf 1234567.89123456\n .toEqual \"1,234,567.89\"\n\n it \"formats booleans\", ->\n nf = numberFormat()\n expect nf true\n .toEqual \"1.00\"\n\n it \"formats numbers in strings\", ->\n nf = numberFormat()\n expect nf \"1234567.89123456\"\n .toEqual \"1,234,567.89\"\n\n it \"doesn't formats strings\", ->\n nf = numberFormat()\n expect nf \"hi there\"\n .toEqual \"\"\n\n it \"doesn't formats objects\", ->\n nf = numberFormat()\n expect nf {a:1}\n .toEqual \"\"\n\n it \"formats percentages\", ->\n nf = numberFormat(scaler: 100, suffix: \"%\")\n expect nf 0.12345\n .toEqual \"12.35%\"\n\n it \"adds separators\", ->\n nf = numberFormat(thousandsSep: \"a\", decimalSep: \"b\")\n expect nf 1234567.89123456\n .toEqual \"1a234a567b89\"\n\n it \"adds prefixes and suffixes\", ->\n nf = numberFormat(prefix: \"a\", suffix: \"b\")\n expect nf 1234567.89123456\n .toEqual \"a1,234,567.89b\"\n\n it \"scales and rounds\", ->\n nf = numberFormat(digitsAfterDecimal: 3, scaler: 1000)\n expect nf 1234567.89123456\n .toEqual \"1,234,567,891.235\"\n\n describe \".derivers\", ->\n describe \".dateFormat()\", ->\n df = $.pivotUtilities.derivers.dateFormat \"x\", \"abc % %% %%% %a %y %m %n %d %w %x %H %M %S\", true\n\n it \"formats date objects\", ->\n expect df {x: new Date(\"2015-01-02T23:43:11Z\")}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n it \"formats input parsed by Date.parse()\", ->\n expect df {x: \"2015-01-02T23:43:11Z\"}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n expect df {x: \"bla\"}\n .toBe ''\n\n describe \".bin()\", ->\n binner = $.pivotUtilities.derivers.bin \"x\", 10\n\n it \"bins numbers\", ->\n expect binner {x: 11}\n .toBe 10\n\n expect binner {x: 9}\n .toBe 0\n\n expect binner {x: 111}\n .toBe 110\n\n it \"bins booleans\", ->\n expect binner {x: true}\n .toBe 0\n\n it \"bins negative numbers\", ->\n expect binner {x: -12}\n .toBe -10\n\n it \"doesn't bin strings\", ->\n expect binner {x: \"a\"}\n .toBeNaN()\n\n it \"doesn't bin objects\", ->\n expect binner {x: {a:1}}\n .toBeNaN()\n"]} \ No newline at end of file diff --git a/dist/pivot_spec.min.js b/dist/pivot_spec.min.js index d2eaebb4..56e4931a 100644 --- a/dist/pivot_spec.min.js +++ b/dist/pivot_spec.min.js @@ -1,2 +1,2 @@ -(function(){var t,e;t=[["name","gender","colour","birthday","trials","successes"],["Nick","male","blue","1982-11-07",103,12],["Jane","female","red","1982-11-08",95,25],["John","male","blue","1982-12-08",112,30],["Carol","female","yellow","1983-12-08",102,14]],e=[{name:"Nick",colour:"red",age:34},{name:"Jane",gender:"female"},{name:"John",gender:"male",age:12},{name:"Jim",gender:null,age:12}],describe("$.pivotUI()",function(){return describe("with no rows/cols, default count aggregator, default TableRenderer",function(){var e;return e=null,beforeEach(function(r){return e=$("
").pivotUI(t,{onRefresh:r})}),it("has all the basic UI elements",function(t){return expect(e.find("td.pvtAxisContainer").length).toBe(3),expect(e.find("td.pvtRendererArea").length).toBe(1),expect(e.find("td.pvtVals").length).toBe(1),expect(e.find("select.pvtRenderer").length).toBe(1),expect(e.find("select.pvtAggregator").length).toBe(1),expect(e.find("span.pvtAttr").length).toBe(6),t()}),it("reflects its inputs",function(t){return expect(e.find("td.pvtUnused span.pvtAttr").length).toBe(6),expect(e.find("select.pvtRenderer").val()).toBe("Table"),expect(e.find("select.pvtAggregator").val()).toBe("Count"),t()}),it("renders a table",function(t){return expect(e.find("table.pvtTable").length).toBe(1),t()}),describe("its renderer output",function(){return it("has the correct type and number of cells",function(t){return expect(e.find("th.pvtTotalLabel").length).toBe(1),expect(e.find("td.pvtGrandTotal").length).toBe(1),t()}),it("has the correct textual representation",function(t){return expect(e.find("table.pvtTable").text()).toBe(["Totals","4"].join("")),t()}),it("has a correct grand total with data value",function(t){return expect(e.find("td.pvtGrandTotal").text()).toBe("4"),expect(e.find("td.pvtGrandTotal").data("value")).toBe(4),t()})})}),describe("with rows/cols, sum-over-sum aggregator, Heatmap renderer",function(){var e;return e=null,beforeEach(function(r){return e=$("
").pivotUI(t,{rows:["gender"],cols:["colour"],aggregatorName:"Sum over Sum",vals:["successes","trials"],rendererName:"Heatmap",onRefresh:r})}),it("has all the basic UI elements",function(t){return expect(e.find("td.pvtAxisContainer").length).toBe(3),expect(e.find("td.pvtRendererArea").length).toBe(1),expect(e.find("td.pvtVals").length).toBe(1),expect(e.find("select.pvtRenderer").length).toBe(1),expect(e.find("select.pvtAggregator").length).toBe(1),expect(e.find("span.pvtAttr").length).toBe(6),t()}),it("reflects its inputs",function(t){return expect(e.find("td.pvtUnused span.pvtAttr").length).toBe(4),expect(e.find("td.pvtRows span.pvtAttr").length).toBe(1),expect(e.find("td.pvtCols span.pvtAttr").length).toBe(1),expect(e.find("select.pvtRenderer").val()).toBe("Heatmap"),expect(e.find("select.pvtAggregator").val()).toBe("Sum over Sum"),t()}),it("renders a table",function(t){return expect(e.find("table.pvtTable").length).toBe(1),t()}),describe("its renderer output",function(){return it("has the correct type and number of cells",function(t){return expect(e.find("th.pvtAxisLabel").length).toBe(2),expect(e.find("th.pvtRowLabel").length).toBe(2),expect(e.find("th.pvtColLabel").length).toBe(3),expect(e.find("th.pvtTotalLabel").length).toBe(2),expect(e.find("td.pvtVal").length).toBe(6),expect(e.find("td.pvtTotal").length).toBe(5),expect(e.find("td.pvtGrandTotal").length).toBe(1),t()}),it("has the correct textual representation",function(t){return expect(e.find("table.pvtTable").text()).toBe(["colour","blue","red","yellow","Totals","gender","female","0.26","0.14","0.20","male","0.20","0.20","Totals","0.20","0.26","0.14","0.20"].join("")),t()}),it("has a correct spot-checked cell with data value",function(t){return expect(e.find("td.col0.row1").text()).toBe("0.20"),expect(e.find("td.col0.row1").data("value")).toBe(42/215),t()})})}),describe("with ragged input",function(){var t;return t=$("
").pivotUI(e,{rows:["gender"],cols:["age"]}),it("renders a table with the correct textual representation",function(){return expect(t.find("table.pvtTable").text()).toBe(["age","12","34","null","Totals","gender","female","1","1","male","1","1","null","1","1","2","Totals","2","1","1","4"].join(""))})})}),describe("$.pivot()",function(){return describe("with no rows/cols, default count aggregator, default TableRenderer",function(){var e;return e=$("
").pivot(t),it("renders a table",function(){return expect(e.find("table.pvtTable").length).toBe(1)}),describe("its renderer output",function(){return it("has the correct textual representation",function(){return expect(e.find("table.pvtTable").text()).toBe(["Totals","4"].join(""))}),it("has a correct grand total with data value",function(){return expect(e.find("td.pvtGrandTotal").text()).toBe("4"),expect(e.find("td.pvtGrandTotal").data("value")).toBe(4)})})}),describe("with rows/cols, sum aggregator, derivedAttributes, filter and sorters",function(){var e,r,n,a,o;return n=$.pivotUtilities,a=n.sortAs,r=n.derivers,e=n.aggregators,o=$("
").pivot(t,{rows:["gender"],cols:["birthyear"],aggregator:e.Sum(["trialbins"]),filter:function(t){return"Nick"!==t.name},derivedAttributes:{birthyear:r.dateFormat("birthday","%y"),trialbins:r.bin("trials",10)},sorters:function(t){if("gender"===t)return a(["male","female"])}}),it("renders a table with the correct textual representation",function(){return expect(o.find("table.pvtTable").text()).toBe(["birthyear","1982","1983","Totals","gender","male","110.00","110.00","female","90.00","100.00","190.00","Totals","200.00","100.00","300.00"].join(""))})}),describe("with rows/cols, fraction-of aggregator",function(){var e,r;return e=$.pivotUtilities.aggregators,r=$("
").pivot(t,{rows:["gender"],aggregator:e["Sum as Fraction of Total"](["trials"])}),it("renders a table with the correct textual representation",function(){return expect(r.find("table.pvtTable").text()).toBe(["gender","Totals","female","47.8%","male","52.2%","Totals","100.0%"].join(""))})}),describe("with rows/cols, custom aggregator, custom renderer with options",function(){var e,r,n;return e=null,r=null,n=$("
").pivot(t,{rows:["name","colour"],cols:["trials","successes"],aggregator:function(){return{count2x:0,push:function(){return this.count2x+=2},value:function(){return this.count2x},format:function(t){return"formatted "+t}}},renderer:function(t,n){return e=t,r=n,$("
").addClass(n.greeting).text("world")},rendererOptions:{greeting:"hithere"}}),it("renders the custom renderer as per options",function(){return expect(n.find("div.hithere").length).toBe(1)}),describe("its received PivotData object",function(){return it("has a correct grand total value and format for custom aggregator",function(){var t,r;return t=e.getAggregator([],[]),r=t.value(),expect(r).toBe(8),expect(t.format(r)).toBe("formatted 8")})})}),describe("with ragged input",function(){var t;return t=$("
").pivot(e,{rows:["gender"],cols:["age"]}),it("renders a table with the correct textual representation",function(){return expect(t.find("table.pvtTable").text()).toBe(["age","12","34","null","Totals","gender","female","1","1","male","1","1","null","1","1","2","Totals","2","1","1","4"].join(""))})})}),describe("$.pivotUtilities",function(){return describe(".PivotData()",function(){var e;return e={aggregator:$.pivotUtilities.aggregators["Sum over Sum"](["a","b"])},describe("with no options",function(){var t,e;return t=[["a","b"],[1,2],[3,4]],e=new $.pivotUtilities.PivotData(t),it("has the correct grand total value",function(){return expect(e.getAggregator([],[]).value()).toBe(2)})}),describe("with array-of-array input",function(){var t,r;return t=[["a","b"],[1,2],[3,4]],r=new $.pivotUtilities.PivotData(t,e),it("has the correct grand total value",function(){return expect(r.getAggregator([],[]).value()).toBe(4/6)})}),describe("with array-of-object input",function(){var t,r;return t=[{a:1,b:2},{a:3,b:4}],r=new $.pivotUtilities.PivotData(t,e),it("has the correct grand total value",function(){return expect(r.getAggregator([],[]).value()).toBe(4/6)})}),describe("with ragged array-of-object input",function(){var t,r;return r=[{a:1},{b:4},{a:3,b:2}],t=new $.pivotUtilities.PivotData(r,e),it("has the correct grand total value",function(){return expect(t.getAggregator([],[]).value()).toBe(4/6)})}),describe("with function input",function(){var t,r;return t=function(t){return t({a:1,b:2}),t({a:3,b:4})},r=new $.pivotUtilities.PivotData(t,e),it("has the correct grand total value",function(){return expect(r.getAggregator([],[]).value()).toBe(4/6)})}),describe("with jQuery table element input",function(){var t,r;return r=$("\n \n \n \n \n \n \n \n
ab
1 2
3 4
"),t=new $.pivotUtilities.PivotData(r,e),it("has the correct grand total value",function(){return expect(t.getAggregator([],[]).value()).toBe(4/6)})}),describe("with rows/cols",function(){var e;return e=new $.pivotUtilities.PivotData(t,{rows:["name","colour"],cols:["trials","successes"]}),it("has correctly-ordered row keys",function(){return expect(e.getRowKeys()).toEqual([["Carol","yellow"],["Jane","red"],["John","blue"],["Nick","blue"]])}),it("has correctly-ordered col keys",function(){return expect(e.getColKeys()).toEqual([[95,25],[102,14],[103,12],[112,30]])}),it("can be iterated over",function(){var t,r,n,a,o,i,c,u,s,l;for(i=0,c=0,s=e.getRowKeys(),r=0,a=s.length;r").pivotUI(t,{onRefresh:r})}),it("has all the basic UI elements",function(t){return expect(e.find("td.pvtAxisContainer").length).toBe(3),expect(e.find("td.pvtRendererArea").length).toBe(1),expect(e.find("td.pvtVals").length).toBe(1),expect(e.find("select.pvtRenderer").length).toBe(1),expect(e.find("select.pvtAggregator").length).toBe(1),expect(e.find("span.pvtAttr").length).toBe(6),t()}),it("reflects its inputs",function(t){return expect(e.find("td.pvtUnused span.pvtAttr").length).toBe(6),expect(e.find("select.pvtRenderer").val()).toBe("Table"),expect(e.find("select.pvtAggregator").val()).toBe("Count"),t()}),it("renders a table",function(t){return expect(e.find("table.pvtTable").length).toBe(1),t()}),describe("its renderer output",function(){return it("has the correct type and number of cells",function(t){return expect(e.find("th.pvtTotalLabel").length).toBe(1),expect(e.find("td.pvtGrandTotal").length).toBe(1),t()}),it("has the correct textual representation",function(t){return expect(e.find("table.pvtTable").text()).toBe(["Totals","4"].join("")),t()}),it("has a correct grand total with data value",function(t){return expect(e.find("td.pvtGrandTotal").text()).toBe("4"),expect(e.find("td.pvtGrandTotal").data("value")).toBe(4),t()})})}),describe("with rows/cols, sum-over-sum aggregator, Heatmap renderer",function(){var e;return e=null,beforeEach(function(r){return e=$("
").pivotUI(t,{rows:["gender"],cols:["colour"],aggregatorName:"Sum over Sum",vals:["successes","trials"],rendererName:"Heatmap",onRefresh:r})}),it("has all the basic UI elements",function(t){return expect(e.find("td.pvtAxisContainer").length).toBe(3),expect(e.find("td.pvtRendererArea").length).toBe(1),expect(e.find("td.pvtVals").length).toBe(1),expect(e.find("select.pvtRenderer").length).toBe(1),expect(e.find("select.pvtAggregator").length).toBe(1),expect(e.find("span.pvtAttr").length).toBe(6),t()}),it("reflects its inputs",function(t){return expect(e.find("td.pvtUnused span.pvtAttr").length).toBe(4),expect(e.find("td.pvtRows span.pvtAttr").length).toBe(1),expect(e.find("td.pvtCols span.pvtAttr").length).toBe(1),expect(e.find("select.pvtRenderer").val()).toBe("Heatmap"),expect(e.find("select.pvtAggregator").val()).toBe("Sum over Sum"),t()}),it("renders a table",function(t){return expect(e.find("table.pvtTable").length).toBe(1),t()}),describe("its renderer output",function(){return it("has the correct type and number of cells",function(t){return expect(e.find("th.pvtAxisLabel").length).toBe(2),expect(e.find("th.pvtRowLabel").length).toBe(2),expect(e.find("th.pvtColLabel").length).toBe(3),expect(e.find("th.pvtTotalLabel").length).toBe(2),expect(e.find("td.pvtVal").length).toBe(6),expect(e.find("td.pvtTotal").length).toBe(5),expect(e.find("td.pvtGrandTotal").length).toBe(1),t()}),it("has the correct textual representation",function(t){return expect(e.find("table.pvtTable").text()).toBe(["colour","blue","red","yellow","Totals","gender","female","0.26","0.14","0.20","male","0.20","0.20","Totals","0.20","0.26","0.14","0.20"].join("")),t()}),it("has a correct spot-checked cell with data value",function(t){return expect(e.find("td.col0.row1").text()).toBe("0.20"),expect(e.find("td.col0.row1").data("value")).toBe(42/215),t()})})}),describe("with ragged input",function(){var t;return t=$("
").pivotUI(e,{rows:["gender"],cols:["age"]}),it("renders a table with the correct textual representation",function(){return expect(t.find("table.pvtTable").text()).toBe(["age","12","34","null","Totals","gender","female","1","1","male","1","1","null","1","1","2","Totals","2","1","1","4"].join(""))})})}),describe("$.pivot()",function(){return describe("with no rows/cols, default count aggregator, default TableRenderer",function(){var e;return e=$("
").pivot(t),it("renders a table",function(){return expect(e.find("table.pvtTable").length).toBe(1)}),describe("its renderer output",function(){return it("has the correct textual representation",function(){return expect(e.find("table.pvtTable").text()).toBe(["Totals","4"].join(""))}),it("has a correct grand total with data value",function(){return expect(e.find("td.pvtGrandTotal").text()).toBe("4"),expect(e.find("td.pvtGrandTotal").data("value")).toBe(4)})})}),describe("with rows/cols, sum aggregator, derivedAttributes, filter and sorters",function(){var e,r,n,a,o;return n=$.pivotUtilities,a=n.sortAs,r=n.derivers,e=n.aggregators,o=$("
").pivot(t,{rows:["gender"],cols:["birthyear"],aggregator:e.Sum(["trialbins"]),filter:function(t){return"Nick"!==t.name},derivedAttributes:{birthyear:r.dateFormat("birthday","%y"),trialbins:r.bin("trials",10)},sorters:function(t){if("gender"===t)return a(["male","female"])}}),it("renders a table with the correct textual representation",function(){return expect(o.find("table.pvtTable").text()).toBe(["birthyear","1982","1983","Totals","gender","male","110.00","110.00","female","90.00","100.00","190.00","Totals","200.00","100.00","300.00"].join(""))})}),describe("with rows/cols, fraction-of aggregator",function(){var e,r;return e=$.pivotUtilities.aggregators,r=$("
").pivot(t,{rows:["gender"],aggregator:e["Sum as Fraction of Total"](["trials"])}),it("renders a table with the correct textual representation",function(){return expect(r.find("table.pvtTable").text()).toBe(["gender","Totals","female","47.8%","male","52.2%","Totals","100.0%"].join(""))})}),describe("with rows/cols, custom aggregator, custom renderer with options",function(){var e,r,n;return e=null,r=null,n=$("
").pivot(t,{rows:["name","colour"],cols:["trials","successes"],aggregator:function(){return{count2x:0,push:function(){return this.count2x+=2},value:function(){return this.count2x},format:function(t){return"formatted "+t}}},renderer:function(t,n){return e=t,r=n,$("
").addClass(n.greeting).text("world")},rendererOptions:{greeting:"hithere"}}),it("renders the custom renderer as per options",function(){return expect(n.find("div.hithere").length).toBe(1)}),describe("its received PivotData object",function(){return it("has a correct grand total value and format for custom aggregator",function(){var t,r;return t=e.getAggregator([],[]),r=t.value(),expect(r).toBe(8),expect(t.format(r)).toBe("formatted 8")})})}),describe("with ragged input",function(){var t;return t=$("
").pivot(e,{rows:["gender"],cols:["age"]}),it("renders a table with the correct textual representation",function(){return expect(t.find("table.pvtTable").text()).toBe(["age","12","34","null","Totals","gender","female","1","1","male","1","1","null","1","1","2","Totals","2","1","1","4"].join(""))})})}),describe("$.pivotUtilities",function(){return describe(".PivotData()",function(){var e;return e={aggregator:$.pivotUtilities.aggregators["Sum over Sum"](["a","b"])},describe("with no options",function(){var t,e;return t=[["a","b"],[1,2],[3,4]],e=new $.pivotUtilities.PivotData(t),it("has the correct grand total value",function(){return expect(e.getAggregator([],[]).value()).toBe(2)})}),describe("with array-of-array input",function(){var t,r;return t=[["a","b"],[1,2],[3,4]],r=new $.pivotUtilities.PivotData(t,e),it("has the correct grand total value",function(){return expect(r.getAggregator([],[]).value()).toBe(4/6)})}),describe("with array-of-object input",function(){var t,r;return t=[{a:1,b:2},{a:3,b:4}],r=new $.pivotUtilities.PivotData(t,e),it("has the correct grand total value",function(){return expect(r.getAggregator([],[]).value()).toBe(4/6)})}),describe("with ragged array-of-object input",function(){var t,r;return r=[{a:1},{b:4},{a:3,b:2}],t=new $.pivotUtilities.PivotData(r,e),it("has the correct grand total value",function(){return expect(t.getAggregator([],[]).value()).toBe(4/6)})}),describe("with function input",function(){var t,r;return t=function(t){return t({a:1,b:2}),t({a:3,b:4})},r=new $.pivotUtilities.PivotData(t,e),it("has the correct grand total value",function(){return expect(r.getAggregator([],[]).value()).toBe(4/6)})}),describe("with jQuery table element input",function(){var t,r;return r=$("\n \n \n \n \n \n \n \n
ab
1 2
3 4
"),t=new $.pivotUtilities.PivotData(r,e),it("has the correct grand total value",function(){return expect(t.getAggregator([],[]).value()).toBe(4/6)})}),describe("with a0-a00 input",function(){var t,e;return t=[{key:"a0",ym:"2020-01"},{key:"a0",ym:"2020-02"},{key:"a00",ym:"2020-01"},{key:"a00",ym:"2020-02"}],e=new $.pivotUtilities.PivotData(t,{rows:["key","ym"],cols:[]}),it("has correctly-ordered row keys",function(){return expect(e.getRowKeys()).toEqual([["a0","2020-01"],["a0","2020-02"],["a00","2020-01"],["a00","2020-02"]])})}),describe("with rows/cols",function(){var e;return e=new $.pivotUtilities.PivotData(t,{rows:["name","colour"],cols:["trials","successes"]}),it("has correctly-ordered row keys",function(){return expect(e.getRowKeys()).toEqual([["Carol","yellow"],["Jane","red"],["John","blue"],["Nick","blue"]])}),it("has correctly-ordered col keys",function(){return expect(e.getColKeys()).toEqual([[95,25],[102,14],[103,12],[112,30]])}),it("can be iterated over",function(){var t,r,n,a,o,i,c,u,s,l;for(i=0,c=0,s=e.getRowKeys(),r=0,a=s.length;r\n describe \"with no rows/cols, default count aggregator, default TableRenderer\", ->\n table = null\n\n beforeEach (done) ->\n table = $(\"
\").pivotUI fixtureData, onRefresh: done\n it \"has all the basic UI elements\", (done) ->\n expect table.find(\"td.pvtAxisContainer\").length\n .toBe 3\n expect table.find(\"td.pvtRendererArea\").length\n .toBe 1\n expect table.find(\"td.pvtVals\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").length\n .toBe 1\n expect table.find(\"select.pvtAggregator\").length\n .toBe 1\n expect table.find(\"span.pvtAttr\").length\n .toBe 6\n done()\n\n it \"reflects its inputs\", (done) ->\n expect table.find(\"td.pvtUnused span.pvtAttr\").length\n .toBe 6\n expect table.find(\"select.pvtRenderer\").val()\n .toBe \"Table\"\n expect table.find(\"select.pvtAggregator\").val()\n .toBe \"Count\"\n done()\n\n it \"renders a table\", (done) ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n done()\n\n\n describe \"its renderer output\", ->\n it \"has the correct type and number of cells\", (done) ->\n expect table.find(\"th.pvtTotalLabel\").length\n .toBe 1\n expect table.find(\"td.pvtGrandTotal\").length\n .toBe 1\n done()\n\n it \"has the correct textual representation\", (done) ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\"Totals\", \"4\"].join(\"\")\n done()\n\n it \"has a correct grand total with data value\", (done) ->\n expect table.find(\"td.pvtGrandTotal\").text()\n .toBe \"4\"\n expect table.find(\"td.pvtGrandTotal\").data(\"value\")\n .toBe 4\n done()\n\n describe \"with rows/cols, sum-over-sum aggregator, Heatmap renderer\", ->\n table = null\n\n beforeEach (done) ->\n table = $(\"
\").pivotUI fixtureData,\n rows: [\"gender\"], cols: [\"colour\"]\n aggregatorName: \"Sum over Sum\"\n vals: [\"successes\", \"trials\"]\n rendererName: \"Heatmap\"\n onRefresh: done\n\n it \"has all the basic UI elements\", (done) ->\n expect table.find(\"td.pvtAxisContainer\").length\n .toBe 3\n expect table.find(\"td.pvtRendererArea\").length\n .toBe 1\n expect table.find(\"td.pvtVals\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").length\n .toBe 1\n expect table.find(\"select.pvtAggregator\").length\n .toBe 1\n expect table.find(\"span.pvtAttr\").length\n .toBe 6\n done()\n\n it \"reflects its inputs\", (done) ->\n expect table.find(\"td.pvtUnused span.pvtAttr\").length\n .toBe 4\n expect table.find(\"td.pvtRows span.pvtAttr\").length\n .toBe 1\n expect table.find(\"td.pvtCols span.pvtAttr\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").val()\n .toBe \"Heatmap\"\n expect table.find(\"select.pvtAggregator\").val()\n .toBe \"Sum over Sum\"\n done()\n\n it \"renders a table\", (done) ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n done()\n\n describe \"its renderer output\", ->\n it \"has the correct type and number of cells\", (done) ->\n expect table.find(\"th.pvtAxisLabel\").length\n .toBe 2\n expect table.find(\"th.pvtRowLabel\").length\n .toBe 2\n expect table.find(\"th.pvtColLabel\").length\n .toBe 3\n expect table.find(\"th.pvtTotalLabel\").length\n .toBe 2\n expect table.find(\"td.pvtVal\").length\n .toBe 6\n expect table.find(\"td.pvtTotal\").length\n .toBe 5\n expect table.find(\"td.pvtGrandTotal\").length\n .toBe 1\n done()\n\n it \"has the correct textual representation\", (done) ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"colour\", \"blue\", \"red\", \"yellow\", \"Totals\",\n \"gender\",\n \"female\", \"0.26\", \"0.14\", \"0.20\",\n \"male\", \"0.20\", \"0.20\",\n \"Totals\", \"0.20\", \"0.26\", \"0.14\", \"0.20\"\n ].join(\"\")\n done()\n\n it \"has a correct spot-checked cell with data value\", (done) ->\n expect table.find(\"td.col0.row1\").text()\n .toBe \"0.20\"\n expect table.find(\"td.col0.row1\").data(\"value\")\n .toBe (12+30)/(103+112)\n done()\n\n describe \"with ragged input\", ->\n table = $(\"
\").pivotUI raggedFixtureData, rows: [\"gender\"], cols: [\"age\"]\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"age\", \"12\", \"34\", \"null\", \"Totals\"\n \"gender\",\n \"female\", \"1\", \"1\"\n \"male\", \"1\", \"1\"\n \"null\", \"1\", \"1\", \"2\"\n \"Totals\", \"2\", \"1\", \"1\", \"4\"\n ].join(\"\")\n\ndescribe \"$.pivot()\", ->\n\n describe \"with no rows/cols, default count aggregator, default TableRenderer\", ->\n table = $(\"
\").pivot fixtureData\n\n it \"renders a table\", ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n\n describe \"its renderer output\", ->\n\n it \"has the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\"Totals\", \"4\"].join(\"\")\n\n it \"has a correct grand total with data value\", ->\n expect table.find(\"td.pvtGrandTotal\").text()\n .toBe \"4\"\n expect table.find(\"td.pvtGrandTotal\").data(\"value\")\n .toBe 4\n\n describe \"with rows/cols, sum aggregator, derivedAttributes, filter and sorters\", ->\n {sortAs, derivers, aggregators} = $.pivotUtilities\n table = $(\"
\").pivot fixtureData,\n rows: [\"gender\"], cols: [\"birthyear\"], aggregator: aggregators[\"Sum\"]([\"trialbins\"])\n filter: (record) -> record.name != \"Nick\"\n derivedAttributes:\n birthyear: derivers.dateFormat \"birthday\", \"%y\"\n trialbins: derivers.bin \"trials\", 10\n sorters: (attr) ->\n if attr == \"gender\" then return sortAs([\"male\", \"female\"])\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"birthyear\", \"1982\", \"1983\", \"Totals\"\n \"gender\",\n \"male\", \"110.00\", \"110.00\"\n \"female\", \"90.00\", \"100.00\", \"190.00\"\n \"Totals\", \"200.00\", \"100.00\", \"300.00\"\n ].join(\"\")\n\n describe \"with rows/cols, fraction-of aggregator\", ->\n {aggregators} = $.pivotUtilities\n table = $(\"
\").pivot fixtureData,\n rows: [\"gender\"]\n aggregator: aggregators[\"Sum as Fraction of Total\"]([\"trials\"])\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"gender\", \"Totals\"\n \"female\", \"47.8%\"\n \"male\", \"52.2%\"\n \"Totals\", \"100.0%\"\n ].join(\"\")\n\n describe \"with rows/cols, custom aggregator, custom renderer with options\", ->\n received_PivotData = null\n received_rendererOptions = null\n\n table = $(\"
\").pivot fixtureData,\n rows: [\"name\", \"colour\"], cols: [\"trials\", \"successes\"]\n aggregator: ->\n count2x: 0\n push: -> @count2x +=2\n value: -> @count2x\n format: (x) -> \"formatted \" + x\n renderer: (a,b) ->\n received_PivotData = a\n received_rendererOptions = b\n return $(\"
\").addClass(b.greeting).text(\"world\")\n rendererOptions: {greeting:\"hithere\"}\n\n it \"renders the custom renderer as per options\", ->\n expect table.find(\"div.hithere\").length\n .toBe 1\n\n describe \"its received PivotData object\", ->\n it \"has a correct grand total value and format for custom aggregator\", ->\n agg = received_PivotData.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 8\n expect(agg.format(val)).toBe \"formatted 8\"\n\n\n describe \"with ragged input\", ->\n table = $(\"
\").pivot raggedFixtureData, rows: [\"gender\"], cols: [\"age\"]\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"age\", \"12\", \"34\", \"null\", \"Totals\"\n \"gender\",\n \"female\", \"1\", \"1\"\n \"male\", \"1\", \"1\"\n \"null\", \"1\", \"1\", \"2\"\n \"Totals\", \"2\", \"1\", \"1\", \"4\"\n ].join(\"\")\n\ndescribe \"$.pivotUtilities\", ->\n\n describe \".PivotData()\", ->\n sumOverSumOpts =\n aggregator: $.pivotUtilities.aggregators[\"Sum over Sum\"]([\"a\",\"b\"])\n\n describe \"with no options\", ->\n aoaInput = [ [\"a\",\"b\"], [1,2], [3,4] ]\n pd = new $.pivotUtilities.PivotData aoaInput\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe 2\n\n describe \"with array-of-array input\", ->\n aoaInput = [ [\"a\",\"b\"], [1,2], [3,4] ]\n pd = new $.pivotUtilities.PivotData aoaInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with array-of-object input\", ->\n aosInput = [ {a:1, b:2}, {a:3, b:4} ]\n pd = new $.pivotUtilities.PivotData aosInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with ragged array-of-object input\", ->\n raggedAosInput = [ {a:1}, {b:4}, {a: 3, b: 2} ]\n pd = new $.pivotUtilities.PivotData raggedAosInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with function input\", ->\n functionInput = (record) ->\n record a:1, b:2\n record a:3, b:4\n pd = new $.pivotUtilities.PivotData functionInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with jQuery table element input\", ->\n tableInput = $ \"\"\"\n \n \n \n \n \n \n \n \n
ab
1 2
3 4
\n \"\"\"\n pd = new $.pivotUtilities.PivotData tableInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n\n describe \"with rows/cols\", ->\n pd = new $.pivotUtilities.PivotData fixtureData,\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"]\n\n it \"has correctly-ordered row keys\", ->\n expect pd.getRowKeys()\n .toEqual [ [ 'Carol', 'yellow' ], [ 'Jane', 'red' ], [ 'John', 'blue' ], [ 'Nick', 'blue' ] ]\n\n it \"has correctly-ordered col keys\", ->\n expect pd.getColKeys()\n .toEqual [ [ 95, 25 ], [ 102, 14 ], [ 103, 12 ], [ 112, 30 ] ]\n\n it \"can be iterated over\", ->\n numNotNull = 0\n numNull = 0\n for r in pd.getRowKeys()\n for c in pd.getColKeys()\n if pd.getAggregator(r, c).value()?\n numNotNull++\n else\n numNull++\n expect numNotNull\n .toBe 4\n expect numNull\n .toBe 12\n\n it \"returns matching records\", ->\n records = []\n pd.forEachMatchingRecord gender: \"male\", (x) -> records.push(x.name)\n expect records\n .toEqual [\"Nick\", \"John\"]\n\n it \"has a correct spot-checked aggregator\", ->\n agg = pd.getAggregator([ 'Carol', 'yellow' ],[ 102, 14 ])\n val = agg.value()\n expect(val).toBe 1\n expect(agg.format(val)).toBe \"1\"\n\n it \"has a correct grand total aggregator\", ->\n agg = pd.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 4\n expect(agg.format(val)).toBe \"4\"\n\n describe \".aggregatorTemplates\", ->\n\n getVal = (aggregator) ->\n pd = new $.pivotUtilities.PivotData(fixtureData, {aggregator})\n return pd.getAggregator([],[]).value()\n tpl = $.pivotUtilities.aggregatorTemplates\n\n describe \".count\", ->\n it \"works\", ->\n expect getVal(tpl.count()())\n .toBe 4\n\n describe \".countUnique\", ->\n it \"works\", ->\n expect getVal(tpl.countUnique()(['gender']))\n .toBe 2\n\n describe \".listUnique\", ->\n it \"works\", ->\n expect getVal(tpl.listUnique()(['gender']))\n .toBe 'female,male'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".sum\", ->\n it \"works\", ->\n expect getVal(tpl.sum()(['trials']))\n .toBe 412\n\n describe \".min\", ->\n it \"works\", ->\n expect getVal(tpl.min()(['trials']))\n .toBe 95\n\n describe \".max\", ->\n it \"works\", ->\n expect getVal(tpl.max()(['trials']))\n .toBe 112\n\n describe \".first\", ->\n it \"works\", ->\n expect getVal(tpl.first()(['name']))\n .toBe 'Carol'\n\n describe \".last\", ->\n it \"works\", ->\n expect getVal(tpl.last()(['name']))\n .toBe 'Nick'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".median\", ->\n it \"works\", ->\n expect getVal(tpl.median()(['trials']))\n .toBe 102.5\n\n describe \".quantile\", ->\n it \"works\", ->\n expect getVal(tpl.quantile(0)(['trials']))\n .toBe 95\n expect getVal(tpl.quantile(0.1)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(0.25)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(1/3)(['trials']))\n .toBe 102\n expect getVal(tpl.quantile(1)(['trials']))\n .toBe 112\n\n describe \".var\", ->\n it \"works\", ->\n expect getVal(tpl.var()(['trials']))\n .toBe 48.666666666666686\n\n describe \".stdev\", ->\n it \"works\", ->\n expect getVal(tpl.stdev()(['trials']))\n .toBe 6.976149845485451\n\n describe \".sumOverSum\", ->\n it \"works\", ->\n expect getVal(tpl.sumOverSum()(['successes', 'trials']))\n .toBe (12+25+30+14)/(95+102+103+112)\n\n describe \".naturalSort()\", ->\n naturalSort = $.pivotUtilities.naturalSort\n\n sortedArr = [\n null, NaN,\n -Infinity, '-Infinity', -3, '-3', -2, '-2', -1, '-1',\n 0, '2e-1', 1, '01', '1', 2, '002', '002e0', '02', '2', '2e-0',\n 3, 10, '10', '11', '12', '1e2', '112', Infinity, 'Infinity',\n '1a', '2a','12a','20a',\n 'A', 'A', 'NaN', 'a', 'a',\n 'a01', 'a012', 'a02', 'a1', 'a2', 'a12', 'a12', 'a21', 'a21',\n 'b', 'c', 'd', 'null'\n ]\n\n it \"sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)\", ->\n expect sortedArr.slice().sort(naturalSort)\n .toEqual sortedArr\n\n describe \".sortAs()\", ->\n sortAs = $.pivotUtilities.sortAs\n\n it \"sorts with unknown values sorted at the end\", ->\n expect [5,2,3,4,1].sort sortAs([4,3,2])\n .toEqual [4,3,2,1,5]\n\n it \"sorts lowercase after uppercase\", ->\n expect [\"Ab\",\"aA\",\"aa\",\"ab\"].sort sortAs([\"Ab\",\"Aa\"])\n .toEqual [\"Ab\",\"ab\",\"aa\",\"aA\"]\n\n describe \".numberFormat()\", ->\n numberFormat = $.pivotUtilities.numberFormat\n\n it \"formats numbers\", ->\n nf = numberFormat()\n expect nf 1234567.89123456\n .toEqual \"1,234,567.89\"\n\n it \"formats booleans\", ->\n nf = numberFormat()\n expect nf true\n .toEqual \"1.00\"\n\n it \"formats numbers in strings\", ->\n nf = numberFormat()\n expect nf \"1234567.89123456\"\n .toEqual \"1,234,567.89\"\n\n it \"doesn't formats strings\", ->\n nf = numberFormat()\n expect nf \"hi there\"\n .toEqual \"\"\n\n it \"doesn't formats objects\", ->\n nf = numberFormat()\n expect nf {a:1}\n .toEqual \"\"\n\n it \"formats percentages\", ->\n nf = numberFormat(scaler: 100, suffix: \"%\")\n expect nf 0.12345\n .toEqual \"12.35%\"\n\n it \"adds separators\", ->\n nf = numberFormat(thousandsSep: \"a\", decimalSep: \"b\")\n expect nf 1234567.89123456\n .toEqual \"1a234a567b89\"\n\n it \"adds prefixes and suffixes\", ->\n nf = numberFormat(prefix: \"a\", suffix: \"b\")\n expect nf 1234567.89123456\n .toEqual \"a1,234,567.89b\"\n\n it \"scales and rounds\", ->\n nf = numberFormat(digitsAfterDecimal: 3, scaler: 1000)\n expect nf 1234567.89123456\n .toEqual \"1,234,567,891.235\"\n\n describe \".derivers\", ->\n describe \".dateFormat()\", ->\n df = $.pivotUtilities.derivers.dateFormat \"x\", \"abc % %% %%% %a %y %m %n %d %w %x %H %M %S\", true\n\n it \"formats date objects\", ->\n expect df {x: new Date(\"2015-01-02T23:43:11Z\")}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n it \"formats input parsed by Date.parse()\", ->\n expect df {x: \"2015-01-02T23:43:11Z\"}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n expect df {x: \"bla\"}\n .toBe ''\n\n describe \".bin()\", ->\n binner = $.pivotUtilities.derivers.bin \"x\", 10\n\n it \"bins numbers\", ->\n expect binner {x: 11}\n .toBe 10\n\n expect binner {x: 9}\n .toBe 0\n\n expect binner {x: 111}\n .toBe 110\n\n it \"bins booleans\", ->\n expect binner {x: true}\n .toBe 0\n\n it \"bins negative numbers\", ->\n expect binner {x: -12}\n .toBe -10\n\n it \"doesn't bin strings\", ->\n expect binner {x: \"a\"}\n .toBeNaN()\n\n it \"doesn't bin objects\", ->\n expect binner {x: {a:1}}\n .toBeNaN()\n","(function() {\n var fixtureData, raggedFixtureData;\n\n fixtureData = [[\"name\", \"gender\", \"colour\", \"birthday\", \"trials\", \"successes\"], [\"Nick\", \"male\", \"blue\", \"1982-11-07\", 103, 12], [\"Jane\", \"female\", \"red\", \"1982-11-08\", 95, 25], [\"John\", \"male\", \"blue\", \"1982-12-08\", 112, 30], [\"Carol\", \"female\", \"yellow\", \"1983-12-08\", 102, 14]];\n\n raggedFixtureData = [\n {\n name: \"Nick\",\n \"colour\": \"red\",\n \"age\": 34\n }, {\n name: \"Jane\",\n \"gender\": \"female\"\n }, {\n name: \"John\",\n \"gender\": \"male\",\n \"age\": 12\n }, {\n name: \"Jim\",\n \"gender\": null,\n \"age\": 12\n }\n ];\n\n describe(\"$.pivotUI()\", function() {\n describe(\"with no rows/cols, default count aggregator, default TableRenderer\", function() {\n var table;\n table = null;\n beforeEach(function(done) {\n return table = $(\"
\").pivotUI(fixtureData, {\n onRefresh: done\n });\n });\n it(\"has all the basic UI elements\", function(done) {\n expect(table.find(\"td.pvtAxisContainer\").length).toBe(3);\n expect(table.find(\"td.pvtRendererArea\").length).toBe(1);\n expect(table.find(\"td.pvtVals\").length).toBe(1);\n expect(table.find(\"select.pvtRenderer\").length).toBe(1);\n expect(table.find(\"select.pvtAggregator\").length).toBe(1);\n expect(table.find(\"span.pvtAttr\").length).toBe(6);\n return done();\n });\n it(\"reflects its inputs\", function(done) {\n expect(table.find(\"td.pvtUnused span.pvtAttr\").length).toBe(6);\n expect(table.find(\"select.pvtRenderer\").val()).toBe(\"Table\");\n expect(table.find(\"select.pvtAggregator\").val()).toBe(\"Count\");\n return done();\n });\n it(\"renders a table\", function(done) {\n expect(table.find(\"table.pvtTable\").length).toBe(1);\n return done();\n });\n return describe(\"its renderer output\", function() {\n it(\"has the correct type and number of cells\", function(done) {\n expect(table.find(\"th.pvtTotalLabel\").length).toBe(1);\n expect(table.find(\"td.pvtGrandTotal\").length).toBe(1);\n return done();\n });\n it(\"has the correct textual representation\", function(done) {\n expect(table.find(\"table.pvtTable\").text()).toBe([\"Totals\", \"4\"].join(\"\"));\n return done();\n });\n return it(\"has a correct grand total with data value\", function(done) {\n expect(table.find(\"td.pvtGrandTotal\").text()).toBe(\"4\");\n expect(table.find(\"td.pvtGrandTotal\").data(\"value\")).toBe(4);\n return done();\n });\n });\n });\n describe(\"with rows/cols, sum-over-sum aggregator, Heatmap renderer\", function() {\n var table;\n table = null;\n beforeEach(function(done) {\n return table = $(\"
\").pivotUI(fixtureData, {\n rows: [\"gender\"],\n cols: [\"colour\"],\n aggregatorName: \"Sum over Sum\",\n vals: [\"successes\", \"trials\"],\n rendererName: \"Heatmap\",\n onRefresh: done\n });\n });\n it(\"has all the basic UI elements\", function(done) {\n expect(table.find(\"td.pvtAxisContainer\").length).toBe(3);\n expect(table.find(\"td.pvtRendererArea\").length).toBe(1);\n expect(table.find(\"td.pvtVals\").length).toBe(1);\n expect(table.find(\"select.pvtRenderer\").length).toBe(1);\n expect(table.find(\"select.pvtAggregator\").length).toBe(1);\n expect(table.find(\"span.pvtAttr\").length).toBe(6);\n return done();\n });\n it(\"reflects its inputs\", function(done) {\n expect(table.find(\"td.pvtUnused span.pvtAttr\").length).toBe(4);\n expect(table.find(\"td.pvtRows span.pvtAttr\").length).toBe(1);\n expect(table.find(\"td.pvtCols span.pvtAttr\").length).toBe(1);\n expect(table.find(\"select.pvtRenderer\").val()).toBe(\"Heatmap\");\n expect(table.find(\"select.pvtAggregator\").val()).toBe(\"Sum over Sum\");\n return done();\n });\n it(\"renders a table\", function(done) {\n expect(table.find(\"table.pvtTable\").length).toBe(1);\n return done();\n });\n return describe(\"its renderer output\", function() {\n it(\"has the correct type and number of cells\", function(done) {\n expect(table.find(\"th.pvtAxisLabel\").length).toBe(2);\n expect(table.find(\"th.pvtRowLabel\").length).toBe(2);\n expect(table.find(\"th.pvtColLabel\").length).toBe(3);\n expect(table.find(\"th.pvtTotalLabel\").length).toBe(2);\n expect(table.find(\"td.pvtVal\").length).toBe(6);\n expect(table.find(\"td.pvtTotal\").length).toBe(5);\n expect(table.find(\"td.pvtGrandTotal\").length).toBe(1);\n return done();\n });\n it(\"has the correct textual representation\", function(done) {\n expect(table.find(\"table.pvtTable\").text()).toBe([\"colour\", \"blue\", \"red\", \"yellow\", \"Totals\", \"gender\", \"female\", \"0.26\", \"0.14\", \"0.20\", \"male\", \"0.20\", \"0.20\", \"Totals\", \"0.20\", \"0.26\", \"0.14\", \"0.20\"].join(\"\"));\n return done();\n });\n return it(\"has a correct spot-checked cell with data value\", function(done) {\n expect(table.find(\"td.col0.row1\").text()).toBe(\"0.20\");\n expect(table.find(\"td.col0.row1\").data(\"value\")).toBe((12 + 30) / (103 + 112));\n return done();\n });\n });\n });\n return describe(\"with ragged input\", function() {\n var table;\n table = $(\"
\").pivotUI(raggedFixtureData, {\n rows: [\"gender\"],\n cols: [\"age\"]\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"age\", \"12\", \"34\", \"null\", \"Totals\", \"gender\", \"female\", \"1\", \"1\", \"male\", \"1\", \"1\", \"null\", \"1\", \"1\", \"2\", \"Totals\", \"2\", \"1\", \"1\", \"4\"].join(\"\"));\n });\n });\n });\n\n describe(\"$.pivot()\", function() {\n describe(\"with no rows/cols, default count aggregator, default TableRenderer\", function() {\n var table;\n table = $(\"
\").pivot(fixtureData);\n it(\"renders a table\", function() {\n return expect(table.find(\"table.pvtTable\").length).toBe(1);\n });\n return describe(\"its renderer output\", function() {\n it(\"has the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"Totals\", \"4\"].join(\"\"));\n });\n return it(\"has a correct grand total with data value\", function() {\n expect(table.find(\"td.pvtGrandTotal\").text()).toBe(\"4\");\n return expect(table.find(\"td.pvtGrandTotal\").data(\"value\")).toBe(4);\n });\n });\n });\n describe(\"with rows/cols, sum aggregator, derivedAttributes, filter and sorters\", function() {\n var aggregators, derivers, ref, sortAs, table;\n ref = $.pivotUtilities, sortAs = ref.sortAs, derivers = ref.derivers, aggregators = ref.aggregators;\n table = $(\"
\").pivot(fixtureData, {\n rows: [\"gender\"],\n cols: [\"birthyear\"],\n aggregator: aggregators[\"Sum\"]([\"trialbins\"]),\n filter: function(record) {\n return record.name !== \"Nick\";\n },\n derivedAttributes: {\n birthyear: derivers.dateFormat(\"birthday\", \"%y\"),\n trialbins: derivers.bin(\"trials\", 10)\n },\n sorters: function(attr) {\n if (attr === \"gender\") {\n return sortAs([\"male\", \"female\"]);\n }\n }\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"birthyear\", \"1982\", \"1983\", \"Totals\", \"gender\", \"male\", \"110.00\", \"110.00\", \"female\", \"90.00\", \"100.00\", \"190.00\", \"Totals\", \"200.00\", \"100.00\", \"300.00\"].join(\"\"));\n });\n });\n describe(\"with rows/cols, fraction-of aggregator\", function() {\n var aggregators, table;\n aggregators = $.pivotUtilities.aggregators;\n table = $(\"
\").pivot(fixtureData, {\n rows: [\"gender\"],\n aggregator: aggregators[\"Sum as Fraction of Total\"]([\"trials\"])\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"gender\", \"Totals\", \"female\", \"47.8%\", \"male\", \"52.2%\", \"Totals\", \"100.0%\"].join(\"\"));\n });\n });\n describe(\"with rows/cols, custom aggregator, custom renderer with options\", function() {\n var received_PivotData, received_rendererOptions, table;\n received_PivotData = null;\n received_rendererOptions = null;\n table = $(\"
\").pivot(fixtureData, {\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"],\n aggregator: function() {\n return {\n count2x: 0,\n push: function() {\n return this.count2x += 2;\n },\n value: function() {\n return this.count2x;\n },\n format: function(x) {\n return \"formatted \" + x;\n }\n };\n },\n renderer: function(a, b) {\n received_PivotData = a;\n received_rendererOptions = b;\n return $(\"
\").addClass(b.greeting).text(\"world\");\n },\n rendererOptions: {\n greeting: \"hithere\"\n }\n });\n it(\"renders the custom renderer as per options\", function() {\n return expect(table.find(\"div.hithere\").length).toBe(1);\n });\n return describe(\"its received PivotData object\", function() {\n return it(\"has a correct grand total value and format for custom aggregator\", function() {\n var agg, val;\n agg = received_PivotData.getAggregator([], []);\n val = agg.value();\n expect(val).toBe(8);\n return expect(agg.format(val)).toBe(\"formatted 8\");\n });\n });\n });\n return describe(\"with ragged input\", function() {\n var table;\n table = $(\"
\").pivot(raggedFixtureData, {\n rows: [\"gender\"],\n cols: [\"age\"]\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"age\", \"12\", \"34\", \"null\", \"Totals\", \"gender\", \"female\", \"1\", \"1\", \"male\", \"1\", \"1\", \"null\", \"1\", \"1\", \"2\", \"Totals\", \"2\", \"1\", \"1\", \"4\"].join(\"\"));\n });\n });\n });\n\n describe(\"$.pivotUtilities\", function() {\n describe(\".PivotData()\", function() {\n var sumOverSumOpts;\n sumOverSumOpts = {\n aggregator: $.pivotUtilities.aggregators[\"Sum over Sum\"]([\"a\", \"b\"])\n };\n describe(\"with no options\", function() {\n var aoaInput, pd;\n aoaInput = [[\"a\", \"b\"], [1, 2], [3, 4]];\n pd = new $.pivotUtilities.PivotData(aoaInput);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe(2);\n });\n });\n describe(\"with array-of-array input\", function() {\n var aoaInput, pd;\n aoaInput = [[\"a\", \"b\"], [1, 2], [3, 4]];\n pd = new $.pivotUtilities.PivotData(aoaInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with array-of-object input\", function() {\n var aosInput, pd;\n aosInput = [\n {\n a: 1,\n b: 2\n }, {\n a: 3,\n b: 4\n }\n ];\n pd = new $.pivotUtilities.PivotData(aosInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with ragged array-of-object input\", function() {\n var pd, raggedAosInput;\n raggedAosInput = [\n {\n a: 1\n }, {\n b: 4\n }, {\n a: 3,\n b: 2\n }\n ];\n pd = new $.pivotUtilities.PivotData(raggedAosInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with function input\", function() {\n var functionInput, pd;\n functionInput = function(record) {\n record({\n a: 1,\n b: 2\n });\n return record({\n a: 3,\n b: 4\n });\n };\n pd = new $.pivotUtilities.PivotData(functionInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with jQuery table element input\", function() {\n var pd, tableInput;\n tableInput = $(\"\\n \\n \\n \\n \\n \\n \\n \\n
ab
1 2
3 4
\");\n pd = new $.pivotUtilities.PivotData(tableInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n return describe(\"with rows/cols\", function() {\n var pd;\n pd = new $.pivotUtilities.PivotData(fixtureData, {\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"]\n });\n it(\"has correctly-ordered row keys\", function() {\n return expect(pd.getRowKeys()).toEqual([['Carol', 'yellow'], ['Jane', 'red'], ['John', 'blue'], ['Nick', 'blue']]);\n });\n it(\"has correctly-ordered col keys\", function() {\n return expect(pd.getColKeys()).toEqual([[95, 25], [102, 14], [103, 12], [112, 30]]);\n });\n it(\"can be iterated over\", function() {\n var c, i, j, len, len1, numNotNull, numNull, r, ref, ref1;\n numNotNull = 0;\n numNull = 0;\n ref = pd.getRowKeys();\n for (i = 0, len = ref.length; i < len; i++) {\n r = ref[i];\n ref1 = pd.getColKeys();\n for (j = 0, len1 = ref1.length; j < len1; j++) {\n c = ref1[j];\n if (pd.getAggregator(r, c).value() != null) {\n numNotNull++;\n } else {\n numNull++;\n }\n }\n }\n expect(numNotNull).toBe(4);\n return expect(numNull).toBe(12);\n });\n it(\"returns matching records\", function() {\n var records;\n records = [];\n pd.forEachMatchingRecord({\n gender: \"male\"\n }, function(x) {\n return records.push(x.name);\n });\n return expect(records).toEqual([\"Nick\", \"John\"]);\n });\n it(\"has a correct spot-checked aggregator\", function() {\n var agg, val;\n agg = pd.getAggregator(['Carol', 'yellow'], [102, 14]);\n val = agg.value();\n expect(val).toBe(1);\n return expect(agg.format(val)).toBe(\"1\");\n });\n return it(\"has a correct grand total aggregator\", function() {\n var agg, val;\n agg = pd.getAggregator([], []);\n val = agg.value();\n expect(val).toBe(4);\n return expect(agg.format(val)).toBe(\"4\");\n });\n });\n });\n describe(\".aggregatorTemplates\", function() {\n var getVal, tpl;\n getVal = function(aggregator) {\n var pd;\n pd = new $.pivotUtilities.PivotData(fixtureData, {\n aggregator: aggregator\n });\n return pd.getAggregator([], []).value();\n };\n tpl = $.pivotUtilities.aggregatorTemplates;\n describe(\".count\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.count()())).toBe(4);\n });\n });\n describe(\".countUnique\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.countUnique()(['gender']))).toBe(2);\n });\n });\n describe(\".listUnique\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.listUnique()(['gender']))).toBe('female,male');\n });\n });\n describe(\".average\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.average()(['trials']))).toBe(103);\n });\n });\n describe(\".sum\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.sum()(['trials']))).toBe(412);\n });\n });\n describe(\".min\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.min()(['trials']))).toBe(95);\n });\n });\n describe(\".max\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.max()(['trials']))).toBe(112);\n });\n });\n describe(\".first\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.first()(['name']))).toBe('Carol');\n });\n });\n describe(\".last\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.last()(['name']))).toBe('Nick');\n });\n });\n describe(\".average\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.average()(['trials']))).toBe(103);\n });\n });\n describe(\".median\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.median()(['trials']))).toBe(102.5);\n });\n });\n describe(\".quantile\", function() {\n return it(\"works\", function() {\n expect(getVal(tpl.quantile(0)(['trials']))).toBe(95);\n expect(getVal(tpl.quantile(0.1)(['trials']))).toBe(98.5);\n expect(getVal(tpl.quantile(0.25)(['trials']))).toBe(98.5);\n expect(getVal(tpl.quantile(1 / 3)(['trials']))).toBe(102);\n return expect(getVal(tpl.quantile(1)(['trials']))).toBe(112);\n });\n });\n describe(\".var\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl[\"var\"]()(['trials']))).toBe(48.666666666666686);\n });\n });\n describe(\".stdev\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.stdev()(['trials']))).toBe(6.976149845485451);\n });\n });\n return describe(\".sumOverSum\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.sumOverSum()(['successes', 'trials']))).toBe((12 + 25 + 30 + 14) / (95 + 102 + 103 + 112));\n });\n });\n });\n describe(\".naturalSort()\", function() {\n var naturalSort, sortedArr;\n naturalSort = $.pivotUtilities.naturalSort;\n sortedArr = [null, 0/0, -2e308, '-Infinity', -3, '-3', -2, '-2', -1, '-1', 0, '2e-1', 1, '01', '1', 2, '002', '002e0', '02', '2', '2e-0', 3, 10, '10', '11', '12', '1e2', '112', 2e308, 'Infinity', '1a', '2a', '12a', '20a', 'A', 'A', 'NaN', 'a', 'a', 'a01', 'a012', 'a02', 'a1', 'a2', 'a12', 'a12', 'a21', 'a21', 'b', 'c', 'd', 'null'];\n return it(\"sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)\", function() {\n return expect(sortedArr.slice().sort(naturalSort)).toEqual(sortedArr);\n });\n });\n describe(\".sortAs()\", function() {\n var sortAs;\n sortAs = $.pivotUtilities.sortAs;\n it(\"sorts with unknown values sorted at the end\", function() {\n return expect([5, 2, 3, 4, 1].sort(sortAs([4, 3, 2]))).toEqual([4, 3, 2, 1, 5]);\n });\n return it(\"sorts lowercase after uppercase\", function() {\n return expect([\"Ab\", \"aA\", \"aa\", \"ab\"].sort(sortAs([\"Ab\", \"Aa\"]))).toEqual([\"Ab\", \"ab\", \"aa\", \"aA\"]);\n });\n });\n describe(\".numberFormat()\", function() {\n var numberFormat;\n numberFormat = $.pivotUtilities.numberFormat;\n it(\"formats numbers\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(1234567.89123456)).toEqual(\"1,234,567.89\");\n });\n it(\"formats booleans\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(true)).toEqual(\"1.00\");\n });\n it(\"formats numbers in strings\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(\"1234567.89123456\")).toEqual(\"1,234,567.89\");\n });\n it(\"doesn't formats strings\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(\"hi there\")).toEqual(\"\");\n });\n it(\"doesn't formats objects\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf({\n a: 1\n })).toEqual(\"\");\n });\n it(\"formats percentages\", function() {\n var nf;\n nf = numberFormat({\n scaler: 100,\n suffix: \"%\"\n });\n return expect(nf(0.12345)).toEqual(\"12.35%\");\n });\n it(\"adds separators\", function() {\n var nf;\n nf = numberFormat({\n thousandsSep: \"a\",\n decimalSep: \"b\"\n });\n return expect(nf(1234567.89123456)).toEqual(\"1a234a567b89\");\n });\n it(\"adds prefixes and suffixes\", function() {\n var nf;\n nf = numberFormat({\n prefix: \"a\",\n suffix: \"b\"\n });\n return expect(nf(1234567.89123456)).toEqual(\"a1,234,567.89b\");\n });\n return it(\"scales and rounds\", function() {\n var nf;\n nf = numberFormat({\n digitsAfterDecimal: 3,\n scaler: 1000\n });\n return expect(nf(1234567.89123456)).toEqual(\"1,234,567,891.235\");\n });\n });\n return describe(\".derivers\", function() {\n describe(\".dateFormat()\", function() {\n var df;\n df = $.pivotUtilities.derivers.dateFormat(\"x\", \"abc % %% %%% %a %y %m %n %d %w %x %H %M %S\", true);\n it(\"formats date objects\", function() {\n return expect(df({\n x: new Date(\"2015-01-02T23:43:11Z\")\n })).toBe('abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11');\n });\n return it(\"formats input parsed by Date.parse()\", function() {\n expect(df({\n x: \"2015-01-02T23:43:11Z\"\n })).toBe('abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11');\n return expect(df({\n x: \"bla\"\n })).toBe('');\n });\n });\n return describe(\".bin()\", function() {\n var binner;\n binner = $.pivotUtilities.derivers.bin(\"x\", 10);\n it(\"bins numbers\", function() {\n expect(binner({\n x: 11\n })).toBe(10);\n expect(binner({\n x: 9\n })).toBe(0);\n return expect(binner({\n x: 111\n })).toBe(110);\n });\n it(\"bins booleans\", function() {\n return expect(binner({\n x: true\n })).toBe(0);\n });\n it(\"bins negative numbers\", function() {\n return expect(binner({\n x: -12\n })).toBe(-10);\n });\n it(\"doesn't bin strings\", function() {\n return expect(binner({\n x: \"a\"\n })).toBeNaN();\n });\n return it(\"doesn't bin objects\", function() {\n return expect(binner({\n x: {\n a: 1\n }\n })).toBeNaN();\n });\n });\n });\n });\n\n}).call(this);\n\n//# sourceMappingURL=pivot_spec.js.map\n"]} \ No newline at end of file +{"version":3,"sources":["pivot_spec.coffee","pivot_spec.min.js"],"names":["fixtureData","raggedFixtureData","name","colour","age","gender","describe","table","beforeEach","done","$","pivotUI","onRefresh","it","expect","find","length","toBe","val","text","join","data","rows","cols","aggregatorName","vals","rendererName","pivot","aggregators","derivers","ref","sortAs","pivotUtilities","aggregator","filter","record","derivedAttributes","birthyear","dateFormat","trialbins","bin","sorters","attr","received_PivotData","received_rendererOptions","count2x","push","this","value","format","x","renderer","a","b","addClass","greeting","rendererOptions","agg","getAggregator","sumOverSumOpts","aoaInput","pd","PivotData","aosInput","raggedAosInput","functionInput","tableInput","key","ym","getRowKeys","toEqual","getColKeys","c","i","j","len","len1","numNotNull","numNull","r","ref1","records","forEachMatchingRecord","getVal","tpl","aggregatorTemplates","count","countUnique","listUnique","average","sum","min","max","first","last","median","quantile","stdev","sumOverSum","naturalSort","sortedArr","slice","sort","numberFormat","nf","scaler","suffix","thousandsSep","decimalSep","prefix","digitsAfterDecimal","df","Date","binner","toBeNaN","call"],"mappings":"CAAA,WAAA,GAAAA,GAAAC,CAAAD,KACK,OAAW,SAAY,SAAa,WAAgB,SAAY,cAChE,OAAW,OAAY,OAAa,aAAgB,IAAY,KAChE,OAAW,SAAY,MAAa,aAAgB,GAAY,KAChE,OAAW,OAAY,OAAa,aAAgB,IAAY,KAChE,QAAW,SAAY,SAAa,aAAgB,IAAY,KAGrEC,IACKC,KAAM,OAAQC,OAAU,MAAOC,IAAO,KACtCF,KAAM,OAAQG,OAAU,WACxBH,KAAM,OAAQG,OAAU,OAAQD,IAAO,KACvCF,KAAM,MAAOG,OAAU,KAAMD,IAAO,KAGzCE,SAAS,cAAe,WC8GpB,MD7GAA,UAAS,qEAAuE,WAC5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AAOmG,GAAQ/D,EAAG,MACjBjC,KAAK,IAENH,OAAOmG,GAAQ/D,EAAG,KACjBjC,KAAK,GAENH,OAAOmG,GAAQ/D,EAAG,OACjBjC,KAAK,OAEVJ,GAAG,gBAAiB,WC2BtB,MD1BMC,QAAOmG,GAAQ/D,GAAG,KACjBjC,KAAK,KAEVJ,GAAG,wBAAyB,WC4B9B,MD3BMC,QAAOmG,GAAQ/D,SACdjC,YAELJ,GAAG,sBAAuB,WC6B5B,MD5BMC,QAAOmG,GAAQ/D,EAAG,OACjBgE,YAELrG,GAAG,sBAAuB,WC8B5B,MD7BMC,QAAOmG,GAAQ/D,GAAIE,EAAE,MACpB8D,oBCsCdC,KAAKpE","file":"pivot_spec.min.js","sourcesContent":["fixtureData = [\n [\"name\", \"gender\", \"colour\", \"birthday\", \"trials\", \"successes\"],\n [\"Nick\", \"male\", \"blue\", \"1982-11-07\", 103, 12],\n [\"Jane\", \"female\", \"red\", \"1982-11-08\", 95, 25],\n [\"John\", \"male\", \"blue\", \"1982-12-08\", 112, 30],\n [\"Carol\", \"female\", \"yellow\", \"1983-12-08\", 102, 14]\n]\n\nraggedFixtureData = [\n {name: \"Nick\", \"colour\": \"red\", \"age\": 34}\n {name: \"Jane\", \"gender\": \"female\"}\n {name: \"John\", \"gender\": \"male\", \"age\": 12}\n {name: \"Jim\", \"gender\": null, \"age\": 12}\n]\n\ndescribe \"$.pivotUI()\", ->\n describe \"with no rows/cols, default count aggregator, default TableRenderer\", ->\n table = null\n\n beforeEach (done) ->\n table = $(\"
\").pivotUI fixtureData, onRefresh: done\n it \"has all the basic UI elements\", (done) ->\n expect table.find(\"td.pvtAxisContainer\").length\n .toBe 3\n expect table.find(\"td.pvtRendererArea\").length\n .toBe 1\n expect table.find(\"td.pvtVals\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").length\n .toBe 1\n expect table.find(\"select.pvtAggregator\").length\n .toBe 1\n expect table.find(\"span.pvtAttr\").length\n .toBe 6\n done()\n\n it \"reflects its inputs\", (done) ->\n expect table.find(\"td.pvtUnused span.pvtAttr\").length\n .toBe 6\n expect table.find(\"select.pvtRenderer\").val()\n .toBe \"Table\"\n expect table.find(\"select.pvtAggregator\").val()\n .toBe \"Count\"\n done()\n\n it \"renders a table\", (done) ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n done()\n\n\n describe \"its renderer output\", ->\n it \"has the correct type and number of cells\", (done) ->\n expect table.find(\"th.pvtTotalLabel\").length\n .toBe 1\n expect table.find(\"td.pvtGrandTotal\").length\n .toBe 1\n done()\n\n it \"has the correct textual representation\", (done) ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\"Totals\", \"4\"].join(\"\")\n done()\n\n it \"has a correct grand total with data value\", (done) ->\n expect table.find(\"td.pvtGrandTotal\").text()\n .toBe \"4\"\n expect table.find(\"td.pvtGrandTotal\").data(\"value\")\n .toBe 4\n done()\n\n describe \"with rows/cols, sum-over-sum aggregator, Heatmap renderer\", ->\n table = null\n\n beforeEach (done) ->\n table = $(\"
\").pivotUI fixtureData,\n rows: [\"gender\"], cols: [\"colour\"]\n aggregatorName: \"Sum over Sum\"\n vals: [\"successes\", \"trials\"]\n rendererName: \"Heatmap\"\n onRefresh: done\n\n it \"has all the basic UI elements\", (done) ->\n expect table.find(\"td.pvtAxisContainer\").length\n .toBe 3\n expect table.find(\"td.pvtRendererArea\").length\n .toBe 1\n expect table.find(\"td.pvtVals\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").length\n .toBe 1\n expect table.find(\"select.pvtAggregator\").length\n .toBe 1\n expect table.find(\"span.pvtAttr\").length\n .toBe 6\n done()\n\n it \"reflects its inputs\", (done) ->\n expect table.find(\"td.pvtUnused span.pvtAttr\").length\n .toBe 4\n expect table.find(\"td.pvtRows span.pvtAttr\").length\n .toBe 1\n expect table.find(\"td.pvtCols span.pvtAttr\").length\n .toBe 1\n expect table.find(\"select.pvtRenderer\").val()\n .toBe \"Heatmap\"\n expect table.find(\"select.pvtAggregator\").val()\n .toBe \"Sum over Sum\"\n done()\n\n it \"renders a table\", (done) ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n done()\n\n describe \"its renderer output\", ->\n it \"has the correct type and number of cells\", (done) ->\n expect table.find(\"th.pvtAxisLabel\").length\n .toBe 2\n expect table.find(\"th.pvtRowLabel\").length\n .toBe 2\n expect table.find(\"th.pvtColLabel\").length\n .toBe 3\n expect table.find(\"th.pvtTotalLabel\").length\n .toBe 2\n expect table.find(\"td.pvtVal\").length\n .toBe 6\n expect table.find(\"td.pvtTotal\").length\n .toBe 5\n expect table.find(\"td.pvtGrandTotal\").length\n .toBe 1\n done()\n\n it \"has the correct textual representation\", (done) ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"colour\", \"blue\", \"red\", \"yellow\", \"Totals\",\n \"gender\",\n \"female\", \"0.26\", \"0.14\", \"0.20\",\n \"male\", \"0.20\", \"0.20\",\n \"Totals\", \"0.20\", \"0.26\", \"0.14\", \"0.20\"\n ].join(\"\")\n done()\n\n it \"has a correct spot-checked cell with data value\", (done) ->\n expect table.find(\"td.col0.row1\").text()\n .toBe \"0.20\"\n expect table.find(\"td.col0.row1\").data(\"value\")\n .toBe (12+30)/(103+112)\n done()\n\n describe \"with ragged input\", ->\n table = $(\"
\").pivotUI raggedFixtureData, rows: [\"gender\"], cols: [\"age\"]\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"age\", \"12\", \"34\", \"null\", \"Totals\"\n \"gender\",\n \"female\", \"1\", \"1\"\n \"male\", \"1\", \"1\"\n \"null\", \"1\", \"1\", \"2\"\n \"Totals\", \"2\", \"1\", \"1\", \"4\"\n ].join(\"\")\n\ndescribe \"$.pivot()\", ->\n\n describe \"with no rows/cols, default count aggregator, default TableRenderer\", ->\n table = $(\"
\").pivot fixtureData\n\n it \"renders a table\", ->\n expect table.find(\"table.pvtTable\").length\n .toBe 1\n\n describe \"its renderer output\", ->\n\n it \"has the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\"Totals\", \"4\"].join(\"\")\n\n it \"has a correct grand total with data value\", ->\n expect table.find(\"td.pvtGrandTotal\").text()\n .toBe \"4\"\n expect table.find(\"td.pvtGrandTotal\").data(\"value\")\n .toBe 4\n\n describe \"with rows/cols, sum aggregator, derivedAttributes, filter and sorters\", ->\n {sortAs, derivers, aggregators} = $.pivotUtilities\n table = $(\"
\").pivot fixtureData,\n rows: [\"gender\"], cols: [\"birthyear\"], aggregator: aggregators[\"Sum\"]([\"trialbins\"])\n filter: (record) -> record.name != \"Nick\"\n derivedAttributes:\n birthyear: derivers.dateFormat \"birthday\", \"%y\"\n trialbins: derivers.bin \"trials\", 10\n sorters: (attr) ->\n if attr == \"gender\" then return sortAs([\"male\", \"female\"])\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"birthyear\", \"1982\", \"1983\", \"Totals\"\n \"gender\",\n \"male\", \"110.00\", \"110.00\"\n \"female\", \"90.00\", \"100.00\", \"190.00\"\n \"Totals\", \"200.00\", \"100.00\", \"300.00\"\n ].join(\"\")\n\n describe \"with rows/cols, fraction-of aggregator\", ->\n {aggregators} = $.pivotUtilities\n table = $(\"
\").pivot fixtureData,\n rows: [\"gender\"]\n aggregator: aggregators[\"Sum as Fraction of Total\"]([\"trials\"])\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"gender\", \"Totals\"\n \"female\", \"47.8%\"\n \"male\", \"52.2%\"\n \"Totals\", \"100.0%\"\n ].join(\"\")\n\n describe \"with rows/cols, custom aggregator, custom renderer with options\", ->\n received_PivotData = null\n received_rendererOptions = null\n\n table = $(\"
\").pivot fixtureData,\n rows: [\"name\", \"colour\"], cols: [\"trials\", \"successes\"]\n aggregator: ->\n count2x: 0\n push: -> @count2x +=2\n value: -> @count2x\n format: (x) -> \"formatted \" + x\n renderer: (a,b) ->\n received_PivotData = a\n received_rendererOptions = b\n return $(\"
\").addClass(b.greeting).text(\"world\")\n rendererOptions: {greeting:\"hithere\"}\n\n it \"renders the custom renderer as per options\", ->\n expect table.find(\"div.hithere\").length\n .toBe 1\n\n describe \"its received PivotData object\", ->\n it \"has a correct grand total value and format for custom aggregator\", ->\n agg = received_PivotData.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 8\n expect(agg.format(val)).toBe \"formatted 8\"\n\n\n describe \"with ragged input\", ->\n table = $(\"
\").pivot raggedFixtureData, rows: [\"gender\"], cols: [\"age\"]\n\n it \"renders a table with the correct textual representation\", ->\n expect table.find(\"table.pvtTable\").text()\n .toBe [\n \"age\", \"12\", \"34\", \"null\", \"Totals\"\n \"gender\",\n \"female\", \"1\", \"1\"\n \"male\", \"1\", \"1\"\n \"null\", \"1\", \"1\", \"2\"\n \"Totals\", \"2\", \"1\", \"1\", \"4\"\n ].join(\"\")\n\ndescribe \"$.pivotUtilities\", ->\n\n describe \".PivotData()\", ->\n sumOverSumOpts =\n aggregator: $.pivotUtilities.aggregators[\"Sum over Sum\"]([\"a\",\"b\"])\n\n describe \"with no options\", ->\n aoaInput = [ [\"a\",\"b\"], [1,2], [3,4] ]\n pd = new $.pivotUtilities.PivotData aoaInput\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe 2\n\n describe \"with array-of-array input\", ->\n aoaInput = [ [\"a\",\"b\"], [1,2], [3,4] ]\n pd = new $.pivotUtilities.PivotData aoaInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with array-of-object input\", ->\n aosInput = [ {a:1, b:2}, {a:3, b:4} ]\n pd = new $.pivotUtilities.PivotData aosInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with ragged array-of-object input\", ->\n raggedAosInput = [ {a:1}, {b:4}, {a: 3, b: 2} ]\n pd = new $.pivotUtilities.PivotData raggedAosInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with function input\", ->\n functionInput = (record) ->\n record a:1, b:2\n record a:3, b:4\n pd = new $.pivotUtilities.PivotData functionInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with jQuery table element input\", ->\n tableInput = $ \"\"\"\n \n \n \n \n \n \n \n \n
ab
1 2
3 4
\n \"\"\"\n pd = new $.pivotUtilities.PivotData tableInput, sumOverSumOpts\n\n it \"has the correct grand total value\", ->\n expect pd.getAggregator([],[]).value()\n .toBe (1+3)/(2+4)\n\n describe \"with a0-a00 input\", ->\n aoaInput = [\n {key: 'a0', ym: '2020-01'},\n {key: 'a0', ym: '2020-02'},\n {key: 'a00', ym: '2020-01'},\n {key: 'a00', ym: '2020-02'}\n ]\n pd = new $.pivotUtilities.PivotData aoaInput, rows: [\"key\", \"ym\"], cols: []\n\n it \"has correctly-ordered row keys\", ->\n expect pd.getRowKeys()\n .toEqual [[\"a0\",\"2020-01\"],[\"a0\",\"2020-02\"],[\"a00\",\"2020-01\"],[\"a00\",\"2020-02\"]]\n\n describe \"with rows/cols\", ->\n pd = new $.pivotUtilities.PivotData fixtureData,\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"]\n\n it \"has correctly-ordered row keys\", ->\n expect pd.getRowKeys()\n .toEqual [ [ 'Carol', 'yellow' ], [ 'Jane', 'red' ], [ 'John', 'blue' ], [ 'Nick', 'blue' ] ]\n\n it \"has correctly-ordered col keys\", ->\n expect pd.getColKeys()\n .toEqual [ [ 95, 25 ], [ 102, 14 ], [ 103, 12 ], [ 112, 30 ] ]\n\n it \"can be iterated over\", ->\n numNotNull = 0\n numNull = 0\n for r in pd.getRowKeys()\n for c in pd.getColKeys()\n if pd.getAggregator(r, c).value()?\n numNotNull++\n else\n numNull++\n expect numNotNull\n .toBe 4\n expect numNull\n .toBe 12\n\n it \"returns matching records\", ->\n records = []\n pd.forEachMatchingRecord gender: \"male\", (x) -> records.push(x.name)\n expect records\n .toEqual [\"Nick\", \"John\"]\n\n it \"has a correct spot-checked aggregator\", ->\n agg = pd.getAggregator([ 'Carol', 'yellow' ],[ 102, 14 ])\n val = agg.value()\n expect(val).toBe 1\n expect(agg.format(val)).toBe \"1\"\n\n it \"has a correct grand total aggregator\", ->\n agg = pd.getAggregator([],[])\n val = agg.value()\n expect(val).toBe 4\n expect(agg.format(val)).toBe \"4\"\n\n describe \".aggregatorTemplates\", ->\n\n getVal = (aggregator) ->\n pd = new $.pivotUtilities.PivotData(fixtureData, {aggregator})\n return pd.getAggregator([],[]).value()\n tpl = $.pivotUtilities.aggregatorTemplates\n\n describe \".count\", ->\n it \"works\", ->\n expect getVal(tpl.count()())\n .toBe 4\n\n describe \".countUnique\", ->\n it \"works\", ->\n expect getVal(tpl.countUnique()(['gender']))\n .toBe 2\n\n describe \".listUnique\", ->\n it \"works\", ->\n expect getVal(tpl.listUnique()(['gender']))\n .toBe 'female,male'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".sum\", ->\n it \"works\", ->\n expect getVal(tpl.sum()(['trials']))\n .toBe 412\n\n describe \".min\", ->\n it \"works\", ->\n expect getVal(tpl.min()(['trials']))\n .toBe 95\n\n describe \".max\", ->\n it \"works\", ->\n expect getVal(tpl.max()(['trials']))\n .toBe 112\n\n describe \".first\", ->\n it \"works\", ->\n expect getVal(tpl.first()(['name']))\n .toBe 'Carol'\n\n describe \".last\", ->\n it \"works\", ->\n expect getVal(tpl.last()(['name']))\n .toBe 'Nick'\n\n describe \".average\", ->\n it \"works\", ->\n expect getVal(tpl.average()(['trials']))\n .toBe 103\n\n describe \".median\", ->\n it \"works\", ->\n expect getVal(tpl.median()(['trials']))\n .toBe 102.5\n\n describe \".quantile\", ->\n it \"works\", ->\n expect getVal(tpl.quantile(0)(['trials']))\n .toBe 95\n expect getVal(tpl.quantile(0.1)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(0.25)(['trials']))\n .toBe 98.5\n expect getVal(tpl.quantile(1/3)(['trials']))\n .toBe 102\n expect getVal(tpl.quantile(1)(['trials']))\n .toBe 112\n\n describe \".var\", ->\n it \"works\", ->\n expect getVal(tpl.var()(['trials']))\n .toBe 48.666666666666686\n\n describe \".stdev\", ->\n it \"works\", ->\n expect getVal(tpl.stdev()(['trials']))\n .toBe 6.976149845485451\n\n describe \".sumOverSum\", ->\n it \"works\", ->\n expect getVal(tpl.sumOverSum()(['successes', 'trials']))\n .toBe (12+25+30+14)/(95+102+103+112)\n\n describe \".naturalSort()\", ->\n naturalSort = $.pivotUtilities.naturalSort\n\n sortedArr = [\n null, NaN,\n -Infinity, '-Infinity', -3, '-3', -2, '-2', -1, '-1',\n 0, '2e-1', 1, '01', '1', 2, '002', '002e0', '02', '2', '2e-0',\n 3, 10, '10', '11', '12', '1e2', '112', Infinity, 'Infinity',\n '1a', '2a','12a','20a',\n 'A', 'A', 'NaN', 'a', 'a',\n 'a01', 'a012', 'a02', 'a1', 'a2', 'a12', 'a12', 'a21', 'a21',\n 'b', 'c', 'd', 'null'\n ]\n\n it \"sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)\", ->\n expect sortedArr.slice().sort(naturalSort)\n .toEqual sortedArr\n\n describe \".sortAs()\", ->\n sortAs = $.pivotUtilities.sortAs\n\n it \"sorts with unknown values sorted at the end\", ->\n expect [5,2,3,4,1].sort sortAs([4,3,2])\n .toEqual [4,3,2,1,5]\n\n it \"sorts lowercase after uppercase\", ->\n expect [\"Ab\",\"aA\",\"aa\",\"ab\"].sort sortAs([\"Ab\",\"Aa\"])\n .toEqual [\"Ab\",\"ab\",\"aa\",\"aA\"]\n\n describe \".numberFormat()\", ->\n numberFormat = $.pivotUtilities.numberFormat\n\n it \"formats numbers\", ->\n nf = numberFormat()\n expect nf 1234567.89123456\n .toEqual \"1,234,567.89\"\n\n it \"formats booleans\", ->\n nf = numberFormat()\n expect nf true\n .toEqual \"1.00\"\n\n it \"formats numbers in strings\", ->\n nf = numberFormat()\n expect nf \"1234567.89123456\"\n .toEqual \"1,234,567.89\"\n\n it \"doesn't formats strings\", ->\n nf = numberFormat()\n expect nf \"hi there\"\n .toEqual \"\"\n\n it \"doesn't formats objects\", ->\n nf = numberFormat()\n expect nf {a:1}\n .toEqual \"\"\n\n it \"formats percentages\", ->\n nf = numberFormat(scaler: 100, suffix: \"%\")\n expect nf 0.12345\n .toEqual \"12.35%\"\n\n it \"adds separators\", ->\n nf = numberFormat(thousandsSep: \"a\", decimalSep: \"b\")\n expect nf 1234567.89123456\n .toEqual \"1a234a567b89\"\n\n it \"adds prefixes and suffixes\", ->\n nf = numberFormat(prefix: \"a\", suffix: \"b\")\n expect nf 1234567.89123456\n .toEqual \"a1,234,567.89b\"\n\n it \"scales and rounds\", ->\n nf = numberFormat(digitsAfterDecimal: 3, scaler: 1000)\n expect nf 1234567.89123456\n .toEqual \"1,234,567,891.235\"\n\n describe \".derivers\", ->\n describe \".dateFormat()\", ->\n df = $.pivotUtilities.derivers.dateFormat \"x\", \"abc % %% %%% %a %y %m %n %d %w %x %H %M %S\", true\n\n it \"formats date objects\", ->\n expect df {x: new Date(\"2015-01-02T23:43:11Z\")}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n it \"formats input parsed by Date.parse()\", ->\n expect df {x: \"2015-01-02T23:43:11Z\"}\n .toBe 'abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11'\n\n expect df {x: \"bla\"}\n .toBe ''\n\n describe \".bin()\", ->\n binner = $.pivotUtilities.derivers.bin \"x\", 10\n\n it \"bins numbers\", ->\n expect binner {x: 11}\n .toBe 10\n\n expect binner {x: 9}\n .toBe 0\n\n expect binner {x: 111}\n .toBe 110\n\n it \"bins booleans\", ->\n expect binner {x: true}\n .toBe 0\n\n it \"bins negative numbers\", ->\n expect binner {x: -12}\n .toBe -10\n\n it \"doesn't bin strings\", ->\n expect binner {x: \"a\"}\n .toBeNaN()\n\n it \"doesn't bin objects\", ->\n expect binner {x: {a:1}}\n .toBeNaN()\n","(function() {\n var fixtureData, raggedFixtureData;\n\n fixtureData = [[\"name\", \"gender\", \"colour\", \"birthday\", \"trials\", \"successes\"], [\"Nick\", \"male\", \"blue\", \"1982-11-07\", 103, 12], [\"Jane\", \"female\", \"red\", \"1982-11-08\", 95, 25], [\"John\", \"male\", \"blue\", \"1982-12-08\", 112, 30], [\"Carol\", \"female\", \"yellow\", \"1983-12-08\", 102, 14]];\n\n raggedFixtureData = [\n {\n name: \"Nick\",\n \"colour\": \"red\",\n \"age\": 34\n }, {\n name: \"Jane\",\n \"gender\": \"female\"\n }, {\n name: \"John\",\n \"gender\": \"male\",\n \"age\": 12\n }, {\n name: \"Jim\",\n \"gender\": null,\n \"age\": 12\n }\n ];\n\n describe(\"$.pivotUI()\", function() {\n describe(\"with no rows/cols, default count aggregator, default TableRenderer\", function() {\n var table;\n table = null;\n beforeEach(function(done) {\n return table = $(\"
\").pivotUI(fixtureData, {\n onRefresh: done\n });\n });\n it(\"has all the basic UI elements\", function(done) {\n expect(table.find(\"td.pvtAxisContainer\").length).toBe(3);\n expect(table.find(\"td.pvtRendererArea\").length).toBe(1);\n expect(table.find(\"td.pvtVals\").length).toBe(1);\n expect(table.find(\"select.pvtRenderer\").length).toBe(1);\n expect(table.find(\"select.pvtAggregator\").length).toBe(1);\n expect(table.find(\"span.pvtAttr\").length).toBe(6);\n return done();\n });\n it(\"reflects its inputs\", function(done) {\n expect(table.find(\"td.pvtUnused span.pvtAttr\").length).toBe(6);\n expect(table.find(\"select.pvtRenderer\").val()).toBe(\"Table\");\n expect(table.find(\"select.pvtAggregator\").val()).toBe(\"Count\");\n return done();\n });\n it(\"renders a table\", function(done) {\n expect(table.find(\"table.pvtTable\").length).toBe(1);\n return done();\n });\n return describe(\"its renderer output\", function() {\n it(\"has the correct type and number of cells\", function(done) {\n expect(table.find(\"th.pvtTotalLabel\").length).toBe(1);\n expect(table.find(\"td.pvtGrandTotal\").length).toBe(1);\n return done();\n });\n it(\"has the correct textual representation\", function(done) {\n expect(table.find(\"table.pvtTable\").text()).toBe([\"Totals\", \"4\"].join(\"\"));\n return done();\n });\n return it(\"has a correct grand total with data value\", function(done) {\n expect(table.find(\"td.pvtGrandTotal\").text()).toBe(\"4\");\n expect(table.find(\"td.pvtGrandTotal\").data(\"value\")).toBe(4);\n return done();\n });\n });\n });\n describe(\"with rows/cols, sum-over-sum aggregator, Heatmap renderer\", function() {\n var table;\n table = null;\n beforeEach(function(done) {\n return table = $(\"
\").pivotUI(fixtureData, {\n rows: [\"gender\"],\n cols: [\"colour\"],\n aggregatorName: \"Sum over Sum\",\n vals: [\"successes\", \"trials\"],\n rendererName: \"Heatmap\",\n onRefresh: done\n });\n });\n it(\"has all the basic UI elements\", function(done) {\n expect(table.find(\"td.pvtAxisContainer\").length).toBe(3);\n expect(table.find(\"td.pvtRendererArea\").length).toBe(1);\n expect(table.find(\"td.pvtVals\").length).toBe(1);\n expect(table.find(\"select.pvtRenderer\").length).toBe(1);\n expect(table.find(\"select.pvtAggregator\").length).toBe(1);\n expect(table.find(\"span.pvtAttr\").length).toBe(6);\n return done();\n });\n it(\"reflects its inputs\", function(done) {\n expect(table.find(\"td.pvtUnused span.pvtAttr\").length).toBe(4);\n expect(table.find(\"td.pvtRows span.pvtAttr\").length).toBe(1);\n expect(table.find(\"td.pvtCols span.pvtAttr\").length).toBe(1);\n expect(table.find(\"select.pvtRenderer\").val()).toBe(\"Heatmap\");\n expect(table.find(\"select.pvtAggregator\").val()).toBe(\"Sum over Sum\");\n return done();\n });\n it(\"renders a table\", function(done) {\n expect(table.find(\"table.pvtTable\").length).toBe(1);\n return done();\n });\n return describe(\"its renderer output\", function() {\n it(\"has the correct type and number of cells\", function(done) {\n expect(table.find(\"th.pvtAxisLabel\").length).toBe(2);\n expect(table.find(\"th.pvtRowLabel\").length).toBe(2);\n expect(table.find(\"th.pvtColLabel\").length).toBe(3);\n expect(table.find(\"th.pvtTotalLabel\").length).toBe(2);\n expect(table.find(\"td.pvtVal\").length).toBe(6);\n expect(table.find(\"td.pvtTotal\").length).toBe(5);\n expect(table.find(\"td.pvtGrandTotal\").length).toBe(1);\n return done();\n });\n it(\"has the correct textual representation\", function(done) {\n expect(table.find(\"table.pvtTable\").text()).toBe([\"colour\", \"blue\", \"red\", \"yellow\", \"Totals\", \"gender\", \"female\", \"0.26\", \"0.14\", \"0.20\", \"male\", \"0.20\", \"0.20\", \"Totals\", \"0.20\", \"0.26\", \"0.14\", \"0.20\"].join(\"\"));\n return done();\n });\n return it(\"has a correct spot-checked cell with data value\", function(done) {\n expect(table.find(\"td.col0.row1\").text()).toBe(\"0.20\");\n expect(table.find(\"td.col0.row1\").data(\"value\")).toBe((12 + 30) / (103 + 112));\n return done();\n });\n });\n });\n return describe(\"with ragged input\", function() {\n var table;\n table = $(\"
\").pivotUI(raggedFixtureData, {\n rows: [\"gender\"],\n cols: [\"age\"]\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"age\", \"12\", \"34\", \"null\", \"Totals\", \"gender\", \"female\", \"1\", \"1\", \"male\", \"1\", \"1\", \"null\", \"1\", \"1\", \"2\", \"Totals\", \"2\", \"1\", \"1\", \"4\"].join(\"\"));\n });\n });\n });\n\n describe(\"$.pivot()\", function() {\n describe(\"with no rows/cols, default count aggregator, default TableRenderer\", function() {\n var table;\n table = $(\"
\").pivot(fixtureData);\n it(\"renders a table\", function() {\n return expect(table.find(\"table.pvtTable\").length).toBe(1);\n });\n return describe(\"its renderer output\", function() {\n it(\"has the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"Totals\", \"4\"].join(\"\"));\n });\n return it(\"has a correct grand total with data value\", function() {\n expect(table.find(\"td.pvtGrandTotal\").text()).toBe(\"4\");\n return expect(table.find(\"td.pvtGrandTotal\").data(\"value\")).toBe(4);\n });\n });\n });\n describe(\"with rows/cols, sum aggregator, derivedAttributes, filter and sorters\", function() {\n var aggregators, derivers, ref, sortAs, table;\n ref = $.pivotUtilities, sortAs = ref.sortAs, derivers = ref.derivers, aggregators = ref.aggregators;\n table = $(\"
\").pivot(fixtureData, {\n rows: [\"gender\"],\n cols: [\"birthyear\"],\n aggregator: aggregators[\"Sum\"]([\"trialbins\"]),\n filter: function(record) {\n return record.name !== \"Nick\";\n },\n derivedAttributes: {\n birthyear: derivers.dateFormat(\"birthday\", \"%y\"),\n trialbins: derivers.bin(\"trials\", 10)\n },\n sorters: function(attr) {\n if (attr === \"gender\") {\n return sortAs([\"male\", \"female\"]);\n }\n }\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"birthyear\", \"1982\", \"1983\", \"Totals\", \"gender\", \"male\", \"110.00\", \"110.00\", \"female\", \"90.00\", \"100.00\", \"190.00\", \"Totals\", \"200.00\", \"100.00\", \"300.00\"].join(\"\"));\n });\n });\n describe(\"with rows/cols, fraction-of aggregator\", function() {\n var aggregators, table;\n aggregators = $.pivotUtilities.aggregators;\n table = $(\"
\").pivot(fixtureData, {\n rows: [\"gender\"],\n aggregator: aggregators[\"Sum as Fraction of Total\"]([\"trials\"])\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"gender\", \"Totals\", \"female\", \"47.8%\", \"male\", \"52.2%\", \"Totals\", \"100.0%\"].join(\"\"));\n });\n });\n describe(\"with rows/cols, custom aggregator, custom renderer with options\", function() {\n var received_PivotData, received_rendererOptions, table;\n received_PivotData = null;\n received_rendererOptions = null;\n table = $(\"
\").pivot(fixtureData, {\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"],\n aggregator: function() {\n return {\n count2x: 0,\n push: function() {\n return this.count2x += 2;\n },\n value: function() {\n return this.count2x;\n },\n format: function(x) {\n return \"formatted \" + x;\n }\n };\n },\n renderer: function(a, b) {\n received_PivotData = a;\n received_rendererOptions = b;\n return $(\"
\").addClass(b.greeting).text(\"world\");\n },\n rendererOptions: {\n greeting: \"hithere\"\n }\n });\n it(\"renders the custom renderer as per options\", function() {\n return expect(table.find(\"div.hithere\").length).toBe(1);\n });\n return describe(\"its received PivotData object\", function() {\n return it(\"has a correct grand total value and format for custom aggregator\", function() {\n var agg, val;\n agg = received_PivotData.getAggregator([], []);\n val = agg.value();\n expect(val).toBe(8);\n return expect(agg.format(val)).toBe(\"formatted 8\");\n });\n });\n });\n return describe(\"with ragged input\", function() {\n var table;\n table = $(\"
\").pivot(raggedFixtureData, {\n rows: [\"gender\"],\n cols: [\"age\"]\n });\n return it(\"renders a table with the correct textual representation\", function() {\n return expect(table.find(\"table.pvtTable\").text()).toBe([\"age\", \"12\", \"34\", \"null\", \"Totals\", \"gender\", \"female\", \"1\", \"1\", \"male\", \"1\", \"1\", \"null\", \"1\", \"1\", \"2\", \"Totals\", \"2\", \"1\", \"1\", \"4\"].join(\"\"));\n });\n });\n });\n\n describe(\"$.pivotUtilities\", function() {\n describe(\".PivotData()\", function() {\n var sumOverSumOpts;\n sumOverSumOpts = {\n aggregator: $.pivotUtilities.aggregators[\"Sum over Sum\"]([\"a\", \"b\"])\n };\n describe(\"with no options\", function() {\n var aoaInput, pd;\n aoaInput = [[\"a\", \"b\"], [1, 2], [3, 4]];\n pd = new $.pivotUtilities.PivotData(aoaInput);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe(2);\n });\n });\n describe(\"with array-of-array input\", function() {\n var aoaInput, pd;\n aoaInput = [[\"a\", \"b\"], [1, 2], [3, 4]];\n pd = new $.pivotUtilities.PivotData(aoaInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with array-of-object input\", function() {\n var aosInput, pd;\n aosInput = [\n {\n a: 1,\n b: 2\n }, {\n a: 3,\n b: 4\n }\n ];\n pd = new $.pivotUtilities.PivotData(aosInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with ragged array-of-object input\", function() {\n var pd, raggedAosInput;\n raggedAosInput = [\n {\n a: 1\n }, {\n b: 4\n }, {\n a: 3,\n b: 2\n }\n ];\n pd = new $.pivotUtilities.PivotData(raggedAosInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with function input\", function() {\n var functionInput, pd;\n functionInput = function(record) {\n record({\n a: 1,\n b: 2\n });\n return record({\n a: 3,\n b: 4\n });\n };\n pd = new $.pivotUtilities.PivotData(functionInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with jQuery table element input\", function() {\n var pd, tableInput;\n tableInput = $(\"\\n \\n \\n \\n \\n \\n \\n \\n
ab
1 2
3 4
\");\n pd = new $.pivotUtilities.PivotData(tableInput, sumOverSumOpts);\n return it(\"has the correct grand total value\", function() {\n return expect(pd.getAggregator([], []).value()).toBe((1 + 3) / (2 + 4));\n });\n });\n describe(\"with a0-a00 input\", function() {\n var aoaInput, pd;\n aoaInput = [\n {\n key: 'a0',\n ym: '2020-01'\n }, {\n key: 'a0',\n ym: '2020-02'\n }, {\n key: 'a00',\n ym: '2020-01'\n }, {\n key: 'a00',\n ym: '2020-02'\n }\n ];\n pd = new $.pivotUtilities.PivotData(aoaInput, {\n rows: [\"key\", \"ym\"],\n cols: []\n });\n return it(\"has correctly-ordered row keys\", function() {\n return expect(pd.getRowKeys()).toEqual([[\"a0\", \"2020-01\"], [\"a0\", \"2020-02\"], [\"a00\", \"2020-01\"], [\"a00\", \"2020-02\"]]);\n });\n });\n return describe(\"with rows/cols\", function() {\n var pd;\n pd = new $.pivotUtilities.PivotData(fixtureData, {\n rows: [\"name\", \"colour\"],\n cols: [\"trials\", \"successes\"]\n });\n it(\"has correctly-ordered row keys\", function() {\n return expect(pd.getRowKeys()).toEqual([['Carol', 'yellow'], ['Jane', 'red'], ['John', 'blue'], ['Nick', 'blue']]);\n });\n it(\"has correctly-ordered col keys\", function() {\n return expect(pd.getColKeys()).toEqual([[95, 25], [102, 14], [103, 12], [112, 30]]);\n });\n it(\"can be iterated over\", function() {\n var c, i, j, len, len1, numNotNull, numNull, r, ref, ref1;\n numNotNull = 0;\n numNull = 0;\n ref = pd.getRowKeys();\n for (i = 0, len = ref.length; i < len; i++) {\n r = ref[i];\n ref1 = pd.getColKeys();\n for (j = 0, len1 = ref1.length; j < len1; j++) {\n c = ref1[j];\n if (pd.getAggregator(r, c).value() != null) {\n numNotNull++;\n } else {\n numNull++;\n }\n }\n }\n expect(numNotNull).toBe(4);\n return expect(numNull).toBe(12);\n });\n it(\"returns matching records\", function() {\n var records;\n records = [];\n pd.forEachMatchingRecord({\n gender: \"male\"\n }, function(x) {\n return records.push(x.name);\n });\n return expect(records).toEqual([\"Nick\", \"John\"]);\n });\n it(\"has a correct spot-checked aggregator\", function() {\n var agg, val;\n agg = pd.getAggregator(['Carol', 'yellow'], [102, 14]);\n val = agg.value();\n expect(val).toBe(1);\n return expect(agg.format(val)).toBe(\"1\");\n });\n return it(\"has a correct grand total aggregator\", function() {\n var agg, val;\n agg = pd.getAggregator([], []);\n val = agg.value();\n expect(val).toBe(4);\n return expect(agg.format(val)).toBe(\"4\");\n });\n });\n });\n describe(\".aggregatorTemplates\", function() {\n var getVal, tpl;\n getVal = function(aggregator) {\n var pd;\n pd = new $.pivotUtilities.PivotData(fixtureData, {\n aggregator: aggregator\n });\n return pd.getAggregator([], []).value();\n };\n tpl = $.pivotUtilities.aggregatorTemplates;\n describe(\".count\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.count()())).toBe(4);\n });\n });\n describe(\".countUnique\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.countUnique()(['gender']))).toBe(2);\n });\n });\n describe(\".listUnique\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.listUnique()(['gender']))).toBe('female,male');\n });\n });\n describe(\".average\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.average()(['trials']))).toBe(103);\n });\n });\n describe(\".sum\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.sum()(['trials']))).toBe(412);\n });\n });\n describe(\".min\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.min()(['trials']))).toBe(95);\n });\n });\n describe(\".max\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.max()(['trials']))).toBe(112);\n });\n });\n describe(\".first\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.first()(['name']))).toBe('Carol');\n });\n });\n describe(\".last\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.last()(['name']))).toBe('Nick');\n });\n });\n describe(\".average\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.average()(['trials']))).toBe(103);\n });\n });\n describe(\".median\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.median()(['trials']))).toBe(102.5);\n });\n });\n describe(\".quantile\", function() {\n return it(\"works\", function() {\n expect(getVal(tpl.quantile(0)(['trials']))).toBe(95);\n expect(getVal(tpl.quantile(0.1)(['trials']))).toBe(98.5);\n expect(getVal(tpl.quantile(0.25)(['trials']))).toBe(98.5);\n expect(getVal(tpl.quantile(1 / 3)(['trials']))).toBe(102);\n return expect(getVal(tpl.quantile(1)(['trials']))).toBe(112);\n });\n });\n describe(\".var\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl[\"var\"]()(['trials']))).toBe(48.666666666666686);\n });\n });\n describe(\".stdev\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.stdev()(['trials']))).toBe(6.976149845485451);\n });\n });\n return describe(\".sumOverSum\", function() {\n return it(\"works\", function() {\n return expect(getVal(tpl.sumOverSum()(['successes', 'trials']))).toBe((12 + 25 + 30 + 14) / (95 + 102 + 103 + 112));\n });\n });\n });\n describe(\".naturalSort()\", function() {\n var naturalSort, sortedArr;\n naturalSort = $.pivotUtilities.naturalSort;\n sortedArr = [null, 0/0, -2e308, '-Infinity', -3, '-3', -2, '-2', -1, '-1', 0, '2e-1', 1, '01', '1', 2, '002', '002e0', '02', '2', '2e-0', 3, 10, '10', '11', '12', '1e2', '112', 2e308, 'Infinity', '1a', '2a', '12a', '20a', 'A', 'A', 'NaN', 'a', 'a', 'a01', 'a012', 'a02', 'a1', 'a2', 'a12', 'a12', 'a21', 'a21', 'b', 'c', 'd', 'null'];\n return it(\"sorts naturally (null, NaN, numbers & numbery strings, Alphanum for text strings)\", function() {\n return expect(sortedArr.slice().sort(naturalSort)).toEqual(sortedArr);\n });\n });\n describe(\".sortAs()\", function() {\n var sortAs;\n sortAs = $.pivotUtilities.sortAs;\n it(\"sorts with unknown values sorted at the end\", function() {\n return expect([5, 2, 3, 4, 1].sort(sortAs([4, 3, 2]))).toEqual([4, 3, 2, 1, 5]);\n });\n return it(\"sorts lowercase after uppercase\", function() {\n return expect([\"Ab\", \"aA\", \"aa\", \"ab\"].sort(sortAs([\"Ab\", \"Aa\"]))).toEqual([\"Ab\", \"ab\", \"aa\", \"aA\"]);\n });\n });\n describe(\".numberFormat()\", function() {\n var numberFormat;\n numberFormat = $.pivotUtilities.numberFormat;\n it(\"formats numbers\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(1234567.89123456)).toEqual(\"1,234,567.89\");\n });\n it(\"formats booleans\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(true)).toEqual(\"1.00\");\n });\n it(\"formats numbers in strings\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(\"1234567.89123456\")).toEqual(\"1,234,567.89\");\n });\n it(\"doesn't formats strings\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf(\"hi there\")).toEqual(\"\");\n });\n it(\"doesn't formats objects\", function() {\n var nf;\n nf = numberFormat();\n return expect(nf({\n a: 1\n })).toEqual(\"\");\n });\n it(\"formats percentages\", function() {\n var nf;\n nf = numberFormat({\n scaler: 100,\n suffix: \"%\"\n });\n return expect(nf(0.12345)).toEqual(\"12.35%\");\n });\n it(\"adds separators\", function() {\n var nf;\n nf = numberFormat({\n thousandsSep: \"a\",\n decimalSep: \"b\"\n });\n return expect(nf(1234567.89123456)).toEqual(\"1a234a567b89\");\n });\n it(\"adds prefixes and suffixes\", function() {\n var nf;\n nf = numberFormat({\n prefix: \"a\",\n suffix: \"b\"\n });\n return expect(nf(1234567.89123456)).toEqual(\"a1,234,567.89b\");\n });\n return it(\"scales and rounds\", function() {\n var nf;\n nf = numberFormat({\n digitsAfterDecimal: 3,\n scaler: 1000\n });\n return expect(nf(1234567.89123456)).toEqual(\"1,234,567,891.235\");\n });\n });\n return describe(\".derivers\", function() {\n describe(\".dateFormat()\", function() {\n var df;\n df = $.pivotUtilities.derivers.dateFormat(\"x\", \"abc % %% %%% %a %y %m %n %d %w %x %H %M %S\", true);\n it(\"formats date objects\", function() {\n return expect(df({\n x: new Date(\"2015-01-02T23:43:11Z\")\n })).toBe('abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11');\n });\n return it(\"formats input parsed by Date.parse()\", function() {\n expect(df({\n x: \"2015-01-02T23:43:11Z\"\n })).toBe('abc % %% %%% %a 2015 01 Jan 02 Fri 5 23 43 11');\n return expect(df({\n x: \"bla\"\n })).toBe('');\n });\n });\n return describe(\".bin()\", function() {\n var binner;\n binner = $.pivotUtilities.derivers.bin(\"x\", 10);\n it(\"bins numbers\", function() {\n expect(binner({\n x: 11\n })).toBe(10);\n expect(binner({\n x: 9\n })).toBe(0);\n return expect(binner({\n x: 111\n })).toBe(110);\n });\n it(\"bins booleans\", function() {\n return expect(binner({\n x: true\n })).toBe(0);\n });\n it(\"bins negative numbers\", function() {\n return expect(binner({\n x: -12\n })).toBe(-10);\n });\n it(\"doesn't bin strings\", function() {\n return expect(binner({\n x: \"a\"\n })).toBeNaN();\n });\n return it(\"doesn't bin objects\", function() {\n return expect(binner({\n x: {\n a: 1\n }\n })).toBeNaN();\n });\n });\n });\n });\n\n}).call(this);\n\n//# sourceMappingURL=pivot_spec.js.map\n"]} \ No newline at end of file diff --git a/src/pivot.coffee b/src/pivot.coffee index 45c28261..ae2a048c 100644 --- a/src/pivot.coffee +++ b/src/pivot.coffee @@ -267,7 +267,8 @@ callWithJQuery ($) -> b1 = b.shift() if a1 != b1 if rd.test(a1) and rd.test(b1) #both are digit chunks - return a1.replace(rz, ".0") - b1.replace(rz, ".0") + numDiff = a1.replace(rz, ".0") - b1.replace(rz, ".0") + return if numDiff != 0 then numDiff else a1.length - b1.length else return (if a1 > b1 then 1 else -1) return a.length - b.length diff --git a/tests/pivot_spec.coffee b/tests/pivot_spec.coffee index 3028f86c..c458e9f7 100644 --- a/tests/pivot_spec.coffee +++ b/tests/pivot_spec.coffee @@ -329,6 +329,18 @@ describe "$.pivotUtilities", -> expect pd.getAggregator([],[]).value() .toBe (1+3)/(2+4) + describe "with a0-a00 input", -> + aoaInput = [ + {key: 'a0', ym: '2020-01'}, + {key: 'a0', ym: '2020-02'}, + {key: 'a00', ym: '2020-01'}, + {key: 'a00', ym: '2020-02'} + ] + pd = new $.pivotUtilities.PivotData aoaInput, rows: ["key", "ym"], cols: [] + + it "has correctly-ordered row keys", -> + expect pd.getRowKeys() + .toEqual [["a0","2020-01"],["a0","2020-02"],["a00","2020-01"],["a00","2020-02"]] describe "with rows/cols", -> pd = new $.pivotUtilities.PivotData fixtureData,