@datarailsshared/dr_renderer 1.2.50 → 1.2.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/dataformatter.js +1 -1
- package/src/dr_pivottable.js +80 -57
- package/src/highcharts_renderer.js +618 -162
- package/src/published_items_renderer.js +6 -8
package/package.json
CHANGED
package/src/dataformatter.js
CHANGED
|
@@ -1004,7 +1004,7 @@ var DataFormatterImpl = function () {
|
|
|
1004
1004
|
// Call function
|
|
1005
1005
|
result = this.memoized[pattern].call(this, n, type);
|
|
1006
1006
|
|
|
1007
|
-
if (result.value === result.pattern) {
|
|
1007
|
+
if (result.value === result.pattern && !(String(n) === '0' && result.value.includes('0'))) {
|
|
1008
1008
|
result.value = n;
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
package/src/dr_pivottable.js
CHANGED
|
@@ -3,7 +3,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
3
3
|
var slice = [].slice;
|
|
4
4
|
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
5
5
|
|
|
6
|
-
var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, NovixRenderer;
|
|
6
|
+
var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, largeToSmallSortByAbsolute, NovixRenderer;
|
|
7
7
|
|
|
8
8
|
var delim = " , ";
|
|
9
9
|
const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
|
|
@@ -133,75 +133,88 @@ let initDRPivotTable = function($, window, document) {
|
|
|
133
133
|
return key;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
let newProcessKey = function (record, totals, keys, attrs, getAggregator) {
|
|
137
|
-
var addKey, attr, flatKey, k, key, len, ref;
|
|
138
|
-
key = [];
|
|
139
|
-
addKey = false;
|
|
140
|
-
for (k = 0, len = attrs.length; k < len; k++) {
|
|
141
|
-
attr = attrs[k];
|
|
142
|
-
if (record.hasOwnProperty(attr)) {
|
|
143
|
-
key.push((ref = record[attr]));
|
|
144
|
-
flatKey = key.join(delim);
|
|
145
|
-
}
|
|
146
|
-
if (totals[flatKey] && totals[flatKey].isChangeable) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (!flatKey) return [];
|
|
150
|
-
if (!totals[flatKey]) {
|
|
151
|
-
totals[flatKey] = getAggregator(key.slice());
|
|
152
|
-
addKey = true;
|
|
153
|
-
} else {
|
|
154
|
-
totals[flatKey] = getAggregator(key.slice());
|
|
155
|
-
totals[flatKey].push(record);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (addKey) {
|
|
159
|
-
keys.push(key);
|
|
160
|
-
}
|
|
161
|
-
return key;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
136
|
DRPivotData.prototype.processRecord = function(record, useTotalsCalculation) {
|
|
165
|
-
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
|
166
|
-
rowKey = [];
|
|
167
|
-
colKey = [];
|
|
168
137
|
if (useTotalsCalculation) {
|
|
169
|
-
|
|
138
|
+
if (!this.notFirst) {
|
|
139
|
+
this.keysLength = Object.keys(record).length - 1;
|
|
140
|
+
this.notFirst = true;
|
|
141
|
+
}
|
|
142
|
+
let getRowAggregator = (function(_this) {
|
|
170
143
|
return function(key) {
|
|
171
144
|
return _this.aggregator(_this, key, []);
|
|
172
145
|
};
|
|
173
|
-
})(this)
|
|
174
|
-
|
|
146
|
+
})(this);
|
|
147
|
+
let getColAggregator = (function(_this) {
|
|
175
148
|
return function(key) {
|
|
176
149
|
return _this.aggregator(_this, [], key);
|
|
177
150
|
};
|
|
178
|
-
})(this)
|
|
151
|
+
})(this);
|
|
179
152
|
|
|
180
|
-
|
|
181
|
-
|
|
153
|
+
let rowKey = [];
|
|
154
|
+
for (k = 0; k < this.rowAttrs.length; k++) {
|
|
155
|
+
let attr = this.rowAttrs[k];
|
|
156
|
+
if (record.hasOwnProperty(attr)) {
|
|
157
|
+
rowKey.push((ref = record[attr]) != null ? ref : "null");
|
|
158
|
+
}
|
|
182
159
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
160
|
+
|
|
161
|
+
let colKey = [];
|
|
162
|
+
for (k = 0; k < this.colAttrs.length; k++) {
|
|
163
|
+
let attr = this.colAttrs[k];
|
|
164
|
+
if (record.hasOwnProperty(attr)) {
|
|
165
|
+
colKey.push((ref = record[attr]) != null ? ref : "null");
|
|
166
|
+
}
|
|
186
167
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
168
|
+
|
|
169
|
+
let flatRowKey = rowKey.join(delim);
|
|
170
|
+
let flatColKey = colKey.join(delim);
|
|
171
|
+
|
|
172
|
+
if (this.keysLength === rowKey.length + colKey.length) {
|
|
173
|
+
if (!this.rowKeys.some(rKey => rKey.join(delim) === flatRowKey)) {
|
|
174
|
+
this.rowKeys.push(rowKey);
|
|
175
|
+
}
|
|
176
|
+
if (!this.colKeys.some(cKey => cKey.join(delim) === flatColKey)) {
|
|
177
|
+
this.colKeys.push(colKey);
|
|
178
|
+
}
|
|
190
179
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
180
|
+
|
|
181
|
+
if (!colKey.length && !rowKey.length) {
|
|
182
|
+
this.allTotal.push(record);
|
|
183
|
+
} else if (!colKey.length && rowKey.length) {
|
|
184
|
+
if (!this.rowTotals[flatRowKey]) {
|
|
185
|
+
this.rowTotals[flatRowKey] = getRowAggregator(rowKey.slice());
|
|
186
|
+
this.rowTotals[flatRowKey].push(record);
|
|
187
|
+
}
|
|
188
|
+
} else if (!rowKey.length && colKey.length) {
|
|
189
|
+
if (!this.colTotals[flatColKey]) {
|
|
190
|
+
this.colTotals[flatColKey] = getColAggregator(rowKey.slice());
|
|
191
|
+
this.colTotals[flatColKey].push(record);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
if (!this.tree[flatRowKey]) {
|
|
195
|
+
this.tree[flatRowKey] = {};
|
|
196
|
+
}
|
|
197
|
+
this.tree[flatRowKey][flatColKey] = this.aggregator(this, rowKey, colKey);
|
|
198
|
+
this.tree[flatRowKey][flatColKey].push(record);
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
203
201
|
}
|
|
204
202
|
|
|
203
|
+
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
|
204
|
+
rowKey = [];
|
|
205
|
+
colKey = [];
|
|
206
|
+
this.allTotal.push(record);
|
|
207
|
+
rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
|
|
208
|
+
return function(key) {
|
|
209
|
+
return _this.aggregator(_this, key, []);
|
|
210
|
+
};
|
|
211
|
+
})(this));
|
|
212
|
+
colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
|
|
213
|
+
return function(key) {
|
|
214
|
+
return _this.aggregator(_this, [], key);
|
|
215
|
+
};
|
|
216
|
+
})(this));
|
|
217
|
+
|
|
205
218
|
m = rowKey.length - 1;
|
|
206
219
|
n = colKey.length - 1;
|
|
207
220
|
if (m < 0 || n < 0) {
|
|
@@ -340,7 +353,11 @@ let initDRPivotTable = function($, window, document) {
|
|
|
340
353
|
};
|
|
341
354
|
};
|
|
342
355
|
|
|
343
|
-
|
|
356
|
+
largeToSmallSortByAbsolute = function (as, bs) {
|
|
357
|
+
return largeToSmallSort(as , bs, true);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
largeToSmallSort = function(as, bs, is_abs = false) {
|
|
344
361
|
var a, a1, b, b1, rd, rx, rz;
|
|
345
362
|
rx = /(\d+)|(\D+)/g;
|
|
346
363
|
rd = /\d/;
|
|
@@ -352,6 +369,11 @@ let initDRPivotTable = function($, window, document) {
|
|
|
352
369
|
if (isNaN(bs)) {
|
|
353
370
|
return 1;
|
|
354
371
|
}
|
|
372
|
+
|
|
373
|
+
if (is_abs) {
|
|
374
|
+
return Math.abs(bs) - Math.abs(as);
|
|
375
|
+
}
|
|
376
|
+
|
|
355
377
|
return bs - as;
|
|
356
378
|
}
|
|
357
379
|
a = String(as).toLowerCase();
|
|
@@ -2217,6 +2239,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2217
2239
|
$.pivotUtilities.getFormattedNumber = getFormattedNumber;
|
|
2218
2240
|
$.pivotUtilities.sortDateStrings = sortDateStrings;
|
|
2219
2241
|
$.pivotUtilities.largeToSmallSort = largeToSmallSort;
|
|
2242
|
+
$.pivotUtilities.largeToSmallSortByAbsolute = largeToSmallSortByAbsolute;
|
|
2220
2243
|
$.pivotUtilities.getPivotDataModel = function(input, opts){ return new DRPivotData(input, opts); }
|
|
2221
2244
|
$.pivotUtilities.getPivotTableFormula = function(rowData, opts, func, colFields, rowFields, aggregationDefaults, utils) {
|
|
2222
2245
|
let totalStr = 'Grand Totals';
|