datavis-glide 4.0.0-PRE.0

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.
Files changed (62) hide show
  1. package/LICENSE +45 -0
  2. package/README.md +129 -0
  3. package/datavis.js +101 -0
  4. package/dist/wcdatavis.css +1957 -0
  5. package/dist/wcdatavis.min.js +1 -0
  6. package/global-jquery.js +4 -0
  7. package/ie-fixes.js +13 -0
  8. package/index.js +70 -0
  9. package/meteor.js +1 -0
  10. package/package.json +102 -0
  11. package/src/flags.js +6 -0
  12. package/src/graph.js +1079 -0
  13. package/src/graph_renderer.js +85 -0
  14. package/src/grid.js +2777 -0
  15. package/src/grid_control.js +1957 -0
  16. package/src/grid_filter.js +1073 -0
  17. package/src/grid_renderer.js +276 -0
  18. package/src/group_fun_win.js +121 -0
  19. package/src/lang/en-US.js +188 -0
  20. package/src/lang/es-MX.js +188 -0
  21. package/src/lang/fr-FR.js +188 -0
  22. package/src/lang/id-ID.js +188 -0
  23. package/src/lang/nl-NL.js +188 -0
  24. package/src/lang/pt-BR.js +188 -0
  25. package/src/lang/ru-RU.js +188 -0
  26. package/src/lang/th-TH.js +188 -0
  27. package/src/lang/vi-VN.js +188 -0
  28. package/src/lang/zh-Hans-CN.js +188 -0
  29. package/src/operations_palette.js +176 -0
  30. package/src/prefs_modules.js +132 -0
  31. package/src/reg/graph_renderer.js +17 -0
  32. package/src/renderers/graph/chartjs.js +457 -0
  33. package/src/renderers/graph/google.js +584 -0
  34. package/src/renderers/graph/jit.js +61 -0
  35. package/src/renderers/graph/svelte-gantt.js +168 -0
  36. package/src/renderers/grid/dummy.js +79 -0
  37. package/src/renderers/grid/handlebars.js +217 -0
  38. package/src/renderers/grid/squirrelly.js +215 -0
  39. package/src/renderers/grid/table/group_detail.js +1404 -0
  40. package/src/renderers/grid/table/group_summary.js +380 -0
  41. package/src/renderers/grid/table/pivot.js +915 -0
  42. package/src/renderers/grid/table/plain.js +1592 -0
  43. package/src/renderers/grid/table.js +2510 -0
  44. package/src/trans.js +101 -0
  45. package/src/ui/collapsible.js +234 -0
  46. package/src/ui/filters/date.js +283 -0
  47. package/src/ui/grid_filter.js +398 -0
  48. package/src/ui/popup_menu.js +224 -0
  49. package/src/ui/popup_window.js +572 -0
  50. package/src/ui/slider.js +156 -0
  51. package/src/ui/tabs.js +202 -0
  52. package/src/ui/templates.js +131 -0
  53. package/src/ui/toolbar.js +63 -0
  54. package/src/ui/toolbars/grid.js +873 -0
  55. package/src/ui/windows/col_config.js +341 -0
  56. package/src/ui/windows/debug.js +164 -0
  57. package/src/ui/windows/grid_table_opts.js +139 -0
  58. package/src/util/handlebars.js +158 -0
  59. package/src/util/jquery.js +630 -0
  60. package/src/util/misc.js +1058 -0
  61. package/src/util/squirrelly.js +155 -0
  62. package/wcdatavis.css +1601 -0
@@ -0,0 +1,380 @@
1
+ // Imports {{{1
2
+
3
+ import _ from 'underscore';
4
+ import jQuery from 'jquery';
5
+
6
+ import {
7
+ format,
8
+ getProp,
9
+ makeSubclass,
10
+ mixinLogging,
11
+ setPropDef,
12
+ setTableCell,
13
+ } from '../../../util/misc.js';
14
+
15
+ import {ComputedView} from 'datavis-ace';
16
+
17
+ import {GridRenderer} from '../../../grid_renderer.js';
18
+ import GridTable from '../table.js';
19
+
20
+ // GridTableGroupSummary {{{1
21
+ // Constructor {{{2
22
+
23
+ /**
24
+ * @class
25
+ * @extends GridTable
26
+ */
27
+
28
+ var GridTableGroupSummary = makeSubclass('GridTableGroupSummary', GridTable, function (grid, defn, view, features, opts, timing, id) {
29
+ var self = this;
30
+
31
+ self.super['GridTable'].ctor.apply(self, arguments);
32
+
33
+ self.features.limit = false;
34
+ self.features.rowSelect = false;
35
+ self.features.footer = false;
36
+ self.features.columnResize = false;
37
+ self.features.columnReorder = false;
38
+
39
+ self.logDebug(self.makeLogTag() + ' Constructing grid table; features = %O', features);
40
+
41
+ setPropDef(['rowVals', 'addCols', 'groupAggregates'], self.opts, 'displayOrder');
42
+ });
43
+
44
+ mixinLogging(GridTableGroupSummary);
45
+
46
+ // #canRender {{{2
47
+
48
+ /**
49
+ * Responds whether or not this grid table can render the type of data requested.
50
+ *
51
+ * @param {string} what
52
+ * The kind of data the caller wants us to show. Must be one of: plain, group, or pivot.
53
+ *
54
+ * @return {boolean}
55
+ * True if this grid table can render that kind of data, false if it can't.
56
+ */
57
+
58
+ GridTableGroupSummary.prototype.canRender = function (what) {
59
+ return ['group'].indexOf(what) >= 0;
60
+ };
61
+
62
+ // #drawHeader {{{2
63
+
64
+ GridTableGroupSummary.prototype.drawHeader = function (columns, data, typeInfo, opts) {
65
+ var self = this,
66
+ tr = jQuery('<tr>'),
67
+ headingSpan,
68
+ headingTh,
69
+ headingThControls,
70
+ headingThContainer;
71
+
72
+ self.csv.addRow();
73
+
74
+ _.each(self.opts.displayOrder, function (what, displayOrderIndex) {
75
+ if (typeof what === 'string') {
76
+ if (what === 'rowVals') {
77
+ _.each(data.groupFields, function (field, fieldIdx) {
78
+ var fcc = self.colConfig.get(field) || {};
79
+ var headingText = fcc.displayText || field;
80
+
81
+ // headingTh <TH>
82
+ // headingThContainer <DIV>
83
+ // headingThSpan <SPAN>
84
+ // headingThControls <DIV>
85
+
86
+ headingSpan = jQuery('<span>', {
87
+ 'class': 'wcdv_heading_title',
88
+ 'data-wcdv-field': field,
89
+ 'data-wcdv-draggable-origin': 'GRID_TABLE_HEADER',
90
+ })
91
+ .text(headingText)
92
+ ._makeDraggableField();
93
+
94
+ headingThControls = jQuery('<div>');
95
+
96
+ headingThContainer = jQuery('<div>')
97
+ .addClass('wcdv_heading_container')
98
+ .append(headingSpan, headingThControls);
99
+
100
+ headingTh = jQuery('<th>', { scope: 'col' })
101
+ .append(headingThContainer);
102
+
103
+ self.csv.addCol(fcc.displayText || field);
104
+
105
+ self._addSortingToHeader(data, 'vertical', {groupFieldIndex: fieldIdx}, headingThControls.get(0), getProp(data, 'agg', 'info', 'group'));
106
+
107
+ self.setCss(headingTh, field);
108
+
109
+ self.ui.thMap[field] = headingTh;
110
+ tr.append(headingTh);
111
+ });
112
+ }
113
+ else if (what === 'groupAggregates') {
114
+ self.drawHeader_aggregates(data, tr, displayOrderIndex, self.opts.displayOrder.length);
115
+ }
116
+ else if (what === 'addCols') {
117
+ self.drawHeader_addCols(tr, typeInfo, opts);
118
+ }
119
+ }
120
+ });
121
+
122
+ // Add the row for this pivot field to the THEAD.
123
+ self.ui.thead.append(tr);
124
+ };
125
+
126
+ // #drawBody {{{2
127
+
128
+ GridTableGroupSummary.prototype.drawBody = function (data, typeInfo, columns, cont, opts) {
129
+ var self = this;
130
+ var ai = self._getAggInfo(data);
131
+ var aggType, aggInfo, rowAgg;
132
+
133
+ self._setupFullValueWin(data);
134
+
135
+ _.each(data.data, function (rowGroup, groupNum) {
136
+ var tr = document.createElement('tr');
137
+ tr.setAttribute('data-wcdv-rvi', groupNum);
138
+
139
+ self.csv.addRow();
140
+
141
+ _.each(self.opts.displayOrder, function (what, displayOrderIndex) {
142
+ if (typeof what === 'string') {
143
+ if (what === 'rowVals') {
144
+ self.drawBody_rowVals(data, tr, groupNum);
145
+ }
146
+ else if (what === 'groupAggregates') {
147
+ self.drawBody_groupAggregates(data, tr, groupNum, displayOrderIndex, self.opts.displayOrder.length);
148
+ }
149
+ else if (what === 'addCols') {
150
+ // Generate the user's custom-defined additional columns. If the `value` function returns an
151
+ // Element or jQuery instance, we just put that in the <TD> that we make. Otherwise (e.g. it
152
+ // returns a string or number) we format it according to the type of the field that the pivot
153
+ // function was operating on.
154
+ //
155
+ // EXAMPLE:
156
+ //
157
+ // Aggregate Function = sum
158
+ // Aggregate Field = Amount : number -> $0,0.00
159
+ //
160
+ // If the `value` function adds up the sums, yielding a grand total of them all, then we format
161
+ // that using Numeral exactly as specified for the "Amount" field.
162
+
163
+ if (self.opts.addCols == null || self.opts.addCols.length === 0) {
164
+ return;
165
+ }
166
+
167
+ _.each(self.opts.addCols, function (addCol) {
168
+ var td = document.createElement('td');
169
+ var addColResult = addCol.value(data.data, groupNum, rowAgg, aggType);
170
+ var addColText;
171
+
172
+ if (addColResult instanceof jQuery) {
173
+ addColResult = addColResult.get(0);
174
+ }
175
+
176
+ if (addColResult instanceof Element) {
177
+ td.appendChild(addColResult);
178
+ self.csv.addCol(addColResult.innerText);
179
+ }
180
+ else {
181
+ if (aggInfo.instance.inheritFormatting) {
182
+ addColText = format(aggInfo.colConfig[0], aggInfo.typeInfo[0], addColResult, {
183
+ alwaysFormat: true
184
+ });
185
+ }
186
+ else {
187
+ addColText = format(null, null, addColResult, {
188
+ alwaysFormat: true,
189
+ decode: false
190
+ });
191
+ }
192
+ td.innerText = addColText;
193
+ self.csv.addCol(addColText);
194
+ }
195
+
196
+ if (getProp(opts, 'pivotConfig', 'aggField')) {
197
+ self.setAlignment(td, self.colConfig.get(opts.pivotConfig.aggField), typeInfo.get(opts.pivotConfig.aggField));
198
+ }
199
+
200
+ tr.appendChild(td);
201
+ });
202
+ }
203
+ }
204
+ });
205
+
206
+ self.ui.tbody.append(tr);
207
+ });
208
+
209
+ var renderTotalRow = function () {
210
+ var tr;
211
+
212
+ tr = jQuery('<tr>', {'class': 'wcdv_btd'});
213
+ self.csv.addRow();
214
+
215
+ _.each(self.opts.displayOrder, function (what) {
216
+ switch (what) {
217
+ case 'rowVals':
218
+ for (var i = 0; i < data.groupFields.length - 1; i += 1) {
219
+ self.csv.addCol('');
220
+ }
221
+ self.csv.addCol('Total');
222
+
223
+ var span = jQuery('<span>', {'class': 'wcdv_heading_title'})
224
+ .text('Total');
225
+ var headingThControls = jQuery('<div>');
226
+ var headingThContainer = jQuery('<div>')
227
+ .addClass('wcdv_heading_container')
228
+ .append(span, headingThControls);
229
+ var th = jQuery('<th>')
230
+ .attr({'colspan': data.groupFields.length})
231
+ .append(headingThContainer)
232
+ .appendTo(tr);
233
+
234
+ break;
235
+ case 'groupAggregates':
236
+ _.each(ai.all, function (aggInfo, aiAllIndex) {
237
+ var aggResult = data.agg.results.all[aggInfo.aggNum];
238
+
239
+ var td = document.createElement('td');
240
+ td.setAttribute('data-wcdv-agg-scope', 'all');
241
+ td.setAttribute('data-wcdv-agg-num', aggInfo.aggNum);
242
+
243
+ var text;
244
+
245
+ if (aggResult instanceof jQuery) {
246
+ aggResult = aggResult.get(0);
247
+ }
248
+
249
+ if (aggResult instanceof Element) {
250
+ td.appendChild(aggResult);
251
+ self.csv.addCol(aggResult.innerText);
252
+ }
253
+ else {
254
+ if (aggInfo.instance.inheritFormatting) {
255
+ text = format(aggInfo.colConfig[0], aggInfo.typeInfo[0], aggResult, {
256
+ overrideType: aggInfo.instance.getType()
257
+ });
258
+ setTableCell(td, text, {
259
+ field: aggInfo.fields[0],
260
+ colConfig: aggInfo.colConfig[0],
261
+ typeInfo: aggInfo.typeInfo[0]
262
+ });
263
+ }
264
+ else {
265
+ text = format(null, null, aggResult, {
266
+ overrideType: aggInfo.instance.getType(),
267
+ decode: false
268
+ });
269
+ setTableCell(td, text);
270
+ }
271
+ self.csv.addCol(td.innerText);
272
+ }
273
+
274
+ if (self.opts.drawInternalBorders || ai.all.length > 1) {
275
+ td.classList.add(aiAllIndex === 0 ? 'wcdv_pivot_aggregate_boundary' : 'wcdv_pivot_colval_boundary');
276
+ }
277
+
278
+ self.setAlignment(td, aggInfo.colConfig[0], aggInfo.typeInfo[0], aggInfo.instance.getType());
279
+
280
+ tr.append(td);
281
+ });
282
+ break;
283
+ case 'addCols':
284
+ if (self.opts.addCols == null || self.opts.addCols.length === 0) {
285
+ break;
286
+ }
287
+ _.each(self.opts.addCols, function (addCol) {
288
+ self.csv.addCol('');
289
+ tr.append(document.createElement('td'));
290
+ });
291
+ }
292
+ });
293
+
294
+ tr.appendTo(self.ui.tbody);
295
+ };
296
+
297
+ if (ai.all.length > 0) {
298
+ renderTotalRow();
299
+ }
300
+
301
+ if (self.features.floatingHeader) {
302
+ switch (getProp(self.defn, 'table', 'floatingHeader', 'method')) {
303
+ case 'tabletool':
304
+ window.TableTool.update();
305
+ break;
306
+ }
307
+ }
308
+
309
+ self.csv.finish(function () {
310
+ self.logDebug(self.makeLogTag() + ' Finished generating CSV file', self.toString());
311
+ self.csvLock.unlock();
312
+ self.fire('generateCsvProgress', null, 100);
313
+ self.fire('csvReady');
314
+ });
315
+
316
+ if (typeof cont === 'function') {
317
+ return cont();
318
+ }
319
+ };
320
+
321
+ // #drawFooter {{{2
322
+
323
+ GridTableGroupSummary.prototype.drawFooter = function (columns, data, typeInfo) {
324
+ var self = this;
325
+ var tr, td;
326
+ var colspan;
327
+
328
+ // Create the footer row to show aggregate functions.
329
+
330
+ tr = jQuery('<tr>');
331
+
332
+ // Add the "select all" checkbox when row selection is enabled.
333
+
334
+ if (self.features.rowSelect) {
335
+ self.ui.checkAll_tfoot = jQuery('<input>', { 'name': 'checkAll', 'type': 'checkbox' })
336
+ .on('change', function (evt) {
337
+ self.checkAll(evt);
338
+ });
339
+ jQuery('<td>', {'class': 'wcdv_group_col_spacer'}).append(self.ui.checkAll_tfoot).appendTo(tr);
340
+ }
341
+
342
+ // Create a new footer row for an external footer that we've absorbed into the grid.
343
+
344
+ if (self.opts.footer != null && self.opts.stealGridFooter) {
345
+ tr.append(jQuery('<td>', {'colspan': data.groupFields.length + self._getAggInfo(data).group.length}).append(self.opts.footer));
346
+ }
347
+
348
+ if (tr.children().length > 0) {
349
+ self.ui.tfoot.append(tr);
350
+ }
351
+ };
352
+
353
+ // #addWorkHandler {{{2
354
+
355
+ GridTableGroupSummary.prototype.addWorkHandler = function () {
356
+ var self = this;
357
+
358
+ self.view.on(ComputedView.events.workEnd, function (info, ops) {
359
+ if (self._destroyed) { return; }
360
+ self.logDebug(self.makeLogTag('handler(workEnd)') + ' ComputedView has finished doing work');
361
+
362
+ if (!ops.group || ops.pivot) {
363
+ self.fire('unableToRender', null, ops);
364
+ return;
365
+ }
366
+
367
+ self.logDebug(self.makeLogTag('handler(workEnd)') + ' Redrawing because the view has done work');
368
+ self.draw(self.root);
369
+ }, { who: self });
370
+ };
371
+
372
+ // Registry {{{1
373
+
374
+ GridRenderer.registry.set('table_group_summary', GridTableGroupSummary);
375
+
376
+ // Exports {{{1
377
+
378
+ export {
379
+ GridTableGroupSummary
380
+ };