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,168 @@
1
+ import _ from 'underscore';
2
+ import moment from 'moment';
3
+ import jQuery from 'jquery';
4
+
5
+ // Promise polyfill for Svelte in IE mode.
6
+ import 'core-js/actual/promise';
7
+
8
+ // CSS.escape() polyfill for Svelte in IE mode.
9
+ import 'css.escape';
10
+
11
+ // import { mount } from 'svelte'; // Svelte 5
12
+ import { SvelteGantt, SvelteGanttTable, SvelteGanttDependencies } from 'svelte-gantt';
13
+
14
+ import {
15
+ makeSubclass,
16
+ mixinLogging,
17
+ } from '../../util/misc.js';
18
+ import {Source} from 'datavis-ace';
19
+
20
+ import { GraphRenderer } from '../../graph_renderer.js';
21
+
22
+ // GraphRendererSvelteGantt {{{1
23
+
24
+ var GraphRendererSvelteGantt = makeSubclass('GraphRendererSvelteGantt', GraphRenderer);
25
+
26
+ mixinLogging(GraphRendererSvelteGantt);
27
+
28
+ // #draw {{{2
29
+
30
+ GraphRendererSvelteGantt.prototype.draw = function () {
31
+ var self = this;
32
+
33
+ self.elt.children().remove();
34
+
35
+ self.view.getData(function (ok, data) {
36
+ self.view.getTypeInfo(function (ok, typeInfo) {
37
+ var rows = []
38
+ , rowMap = {} // Used to keep track of rows we've already created.
39
+ , tasks = []
40
+ , deps = []
41
+ , rowId = 0
42
+ , taskId = 0
43
+ , depId = 0
44
+ , minDate = null
45
+ , maxDate = null;
46
+
47
+ var makeDate = function (x) {
48
+ return typeof x === 'string' ? moment(x).valueOf() :
49
+ moment.isMoment(x) ? x.valueOf() :
50
+ null;
51
+ };
52
+ var cols = [{
53
+ field: 'Task',
54
+ required: true
55
+ }, {
56
+ field: 'Resource',
57
+ required: true
58
+ }, {
59
+ field: 'Start',
60
+ required: true
61
+ }, {
62
+ field: 'End',
63
+ required: true
64
+ }, {
65
+ field: 'Completion'
66
+ }, {
67
+ field: 'Dependencies'
68
+ }];
69
+
70
+ // Make sure that all the fields that we need are in the data.
71
+
72
+ var missingRequired = false;
73
+ _.each(cols, function (c) {
74
+ if (c.required && !typeInfo.isSet(c.field)) {
75
+ self.logError(self.makeLogTag() + ' Missing required data field: %s', c.field);
76
+ missingRequired = true;
77
+ }
78
+ });
79
+ if (missingRequired) {
80
+ return null;
81
+ }
82
+
83
+ _.each(cols, function (c) {
84
+ // Make sure data is decoded.
85
+ if (typeInfo.isSet(c.field)) {
86
+ Source.decodeAll(data.dataByRowId, c.field, typeInfo);
87
+ }
88
+ });
89
+
90
+ _.each(data.data, function (row) {
91
+ if (rowMap[row.rowData['Resource'].value] == null) {
92
+ rows.push({
93
+ id: rowId,
94
+ name: row.rowData['Resource'].value
95
+ });
96
+ rowMap[row.rowData['Resource'].value] = rowId;
97
+ rowId += 1;
98
+ }
99
+
100
+ var newTask = {
101
+ id: taskId,
102
+ resourceId: rowMap[row.rowData['Resource'].value],
103
+ from: makeDate(row.rowData['Start'].value),
104
+ to: makeDate(row.rowData['End'].value),
105
+ label: row.rowData['Task'].value,
106
+ };
107
+ if (row.rowData['Completion'] != null) {
108
+ newTask.amountDone = row.rowData['Completion'].value;
109
+ }
110
+ tasks.push(newTask);
111
+ taskId += 1;
112
+
113
+ if (row.rowData['Dependencies'] != null && row.rowData['Dependencies'].value.length > 0) {
114
+ _.each(row.rowData['Dependencies'].value.split(','), function (dep) {
115
+ deps.push({
116
+ id: depId,
117
+ fromId: dep - 1,
118
+ toId: newTask.id
119
+ });
120
+ depId += 1;
121
+ });
122
+ }
123
+
124
+ // Track the overall min/max date for the task.
125
+
126
+ if (minDate == null || minDate > newTask.from) {
127
+ minDate = newTask.from;
128
+ }
129
+ if (maxDate == null || maxDate < newTask.to) {
130
+ maxDate = newTask.to;
131
+ }
132
+ });
133
+
134
+ var target = jQuery('<div>').appendTo(self.elt).get(0);
135
+ var props = {
136
+ rows: rows,
137
+ tasks: tasks,
138
+ from: minDate,
139
+ to: maxDate,
140
+ headers: [{
141
+ unit: 'week',
142
+ format: 'dd/MM/yyyy'
143
+ }],
144
+ tableHeaders: [{title: 'Resource', property: 'name'}],
145
+ ganttTableModules: [SvelteGanttTable],
146
+ highlightedDurations: {
147
+ unit: 'day',
148
+ fractions: [0,6]
149
+ },
150
+ dependencies: deps,
151
+ ganttBodyModules: [SvelteGanttDependencies]
152
+ };
153
+
154
+ // Svelte 4
155
+ var gantt = new SvelteGantt({
156
+ target: target,
157
+ props: props
158
+ });
159
+
160
+ // Svelte 5
161
+ // mount(SvelteGantt(self.elt, props));
162
+ });
163
+ }, 'Drawing Svelte-Gantte graph');
164
+ };
165
+
166
+ // Exports {{{1
167
+
168
+ export default GraphRendererSvelteGantt;
@@ -0,0 +1,79 @@
1
+ // Imports {{{1
2
+
3
+ import jQuery from 'jquery';
4
+
5
+ import {
6
+ deepDefaults,
7
+ makeSubclass,
8
+ } from '../../util/misc.js';
9
+
10
+ import {GridRenderer} from '../../grid_renderer.js';
11
+
12
+ // GridRendererDummy {{{1
13
+ // Constructor {{{2
14
+
15
+ /**
16
+ * A dummy grid renderer that can be useful for testing, or as an example of how to start writing a
17
+ * new renderer.
18
+ *
19
+ * @class
20
+ * @extends GridRenderer
21
+ *
22
+ * @property {Grid~Features} features
23
+ *
24
+ * @property {object} defn
25
+ *
26
+ * @property {ComputedView} view
27
+ *
28
+ * @property {Element} root
29
+ *
30
+ * @property {object} colConfig Map associating field name with the configuration of the
31
+ * corresponding column in this grid table.
32
+ *
33
+ * @property {Timing} timing
34
+ *
35
+ * @property {boolean} needsRedraw True if the grid needs to redraw itself when the view is done
36
+ * working.
37
+ */
38
+
39
+ var GridRendererDummy = makeSubclass('GridRendererDummy', GridRenderer, function (grid, defn, view, features, opts, timing, id) {
40
+ var self = this;
41
+
42
+ opts = deepDefaults(opts, {
43
+ msg: 'DUMMY'
44
+ });
45
+
46
+ self.super.ctor.apply(self, arguments);
47
+ });
48
+
49
+ // #canRender {{{2
50
+
51
+ GridRendererDummy.prototype.canRender = function (what) {
52
+ return true;
53
+ };
54
+
55
+ // #draw {{{2
56
+
57
+ GridRendererDummy.prototype.draw = function (root, opts, cont) {
58
+ var self = this
59
+ , args = Array.prototype.slice.call(arguments);
60
+
61
+ return self.super.draw(root, opts, function (ok, data, typeInfo, andThen) {
62
+ if (!ok) {
63
+ return cont();
64
+ }
65
+
66
+ root.append(jQuery('<h1>').text(self.opts.msg));
67
+ return andThen(cont);
68
+ });
69
+ };
70
+
71
+ // Registry {{{2
72
+
73
+ GridRenderer.registry.set('dummy', GridRendererDummy);
74
+
75
+ // Exports {{{2
76
+
77
+ export {
78
+ GridRendererDummy
79
+ };
@@ -0,0 +1,217 @@
1
+ import _ from 'underscore';
2
+
3
+ import jQuery from 'jquery';
4
+
5
+ import {
6
+ format,
7
+ makeSubclass,
8
+ outerHtml,
9
+ } from '../../util/misc.js';
10
+
11
+ import hbUtil from '../../util/handlebars.js';
12
+
13
+ import {GridRenderer} from '../../grid_renderer.js';
14
+
15
+ // GridRendererHandlebars {{{1
16
+
17
+ var GridRendererHandlebars = makeSubclass('GridRendererHandlebars', GridRenderer, function () {
18
+ var self = this;
19
+
20
+ self.super['GridRenderer'].ctor.apply(self, arguments);
21
+
22
+ self.hbEnv = hbUtil.makeEnv();
23
+ });
24
+
25
+ // #_validateFeatures {{{2
26
+
27
+ GridRendererHandlebars.prototype._validateFeatures = function () {
28
+ var self = this;
29
+ self.features.limit = false;
30
+ };
31
+
32
+
33
+ // #canRender {{{2
34
+
35
+ GridRendererHandlebars.prototype.canRender = function (what) {
36
+ return true;
37
+ };
38
+
39
+ // #_draw_plain {{{2
40
+
41
+ GridRendererHandlebars.prototype._draw_plain = function (root, data, typeInfo, opts) {
42
+ var self = this;
43
+ var html = '';
44
+
45
+ if (data.data.length === 0) {
46
+ if (self.empty != null) {
47
+ html += self.empty();
48
+ }
49
+ }
50
+ else {
51
+ if (self.before != null) {
52
+ html += self.before();
53
+ }
54
+
55
+ if (self.item != null) {
56
+ _.each(data.data, function (row) {
57
+ var context = {};
58
+ _.each(row.rowData, function (cell, field) {
59
+ var fcc = self.colConfig.get(field) || {};
60
+ var value = format(fcc, typeInfo.get(field), cell);
61
+ if (value instanceof Element || value instanceof jQuery) {
62
+ value = outerHtml(value);
63
+ }
64
+ context[field] = value;
65
+ });
66
+ html += self.item(context);
67
+ });
68
+ }
69
+
70
+ if (self.after != null) {
71
+ html += self.after();
72
+ }
73
+ }
74
+
75
+ root.html(html);
76
+ };
77
+
78
+ // #_draw_group {{{2
79
+
80
+ GridRendererHandlebars.prototype._draw_group = function (root, data, typeInfo, opts) {
81
+ var self = this;
82
+ var html = '';
83
+
84
+ if (data.data.length === 0) {
85
+ if (self.empty != null) {
86
+ html += self.empty();
87
+ }
88
+ }
89
+ else {
90
+ if (self.before != null) {
91
+ html += self.before();
92
+ }
93
+
94
+ if (self.item != null) {
95
+ _.each(data.data, function (group, rowValIdx) {
96
+ var context = {
97
+ rowValIdx: rowValIdx
98
+ };
99
+ html += self.item(context);
100
+ });
101
+ }
102
+
103
+ if (self.after != null) {
104
+ html += self.after();
105
+ }
106
+ }
107
+
108
+ root.html(html);
109
+ };
110
+
111
+ // #_draw_pivot {{{2
112
+
113
+ GridRendererHandlebars.prototype._draw_pivot = function (root, data, typeInfo, opts) {
114
+ var self = this;
115
+ var html = '';
116
+
117
+ if (data.data.length === 0) {
118
+ if (self.empty != null) {
119
+ html += self.empty();
120
+ }
121
+ }
122
+ else {
123
+ if (self.before != null) {
124
+ html += self.before();
125
+ }
126
+
127
+ if (self.item != null) {
128
+ _.each(data.data, function (group, rowValIdx) {
129
+ _.each(group, function (pivot, colValIdx) {
130
+ var div = jQuery('<div>').appendTo(root);
131
+ var context = {
132
+ rowValIdx: rowValIdx,
133
+ colValIdx: colValIdx
134
+ };
135
+ html += self.item(context);
136
+ });
137
+ });
138
+ }
139
+
140
+ if (self.after != null) {
141
+ html += self.after();
142
+ }
143
+ }
144
+
145
+ root.html(html);
146
+ };
147
+
148
+ // #draw {{{2
149
+
150
+ GridRendererHandlebars.prototype.draw = function (root, cont, opts) {
151
+ var self = this;
152
+
153
+ if (cont != null && typeof cont !== 'function') {
154
+ throw new Error('Call Error: `cont` must be null or a function');
155
+ }
156
+
157
+ return self.super['GridRenderer'].draw(root, opts, function (ok, data, typeInfo) {
158
+ if (!ok) {
159
+ return cont();
160
+ }
161
+
162
+ hbUtil.addHelpers(self.hbEnv, data);
163
+
164
+ var k1 = data.isPlain ? 'plain'
165
+ : data.isGroup ? 'group'
166
+ : data.isPivot ? 'pivot'
167
+ : null;
168
+
169
+ var configKey = data.isPlain ? 'whenPlain'
170
+ : data.isGroup ? 'whenGroup'
171
+ : data.isPivot ? 'whenPivot'
172
+ : null;
173
+
174
+ var config = self.opts[configKey] || {};
175
+
176
+ if (config.empty != null) {
177
+ self.empty = self.hbEnv.compile(config.empty);
178
+ }
179
+
180
+ if (config.before != null) {
181
+ self.before = self.hbEnv.compile(config.before);
182
+ }
183
+
184
+ if (config.item != null) {
185
+ self.item = self.hbEnv.compile(config.item);
186
+ }
187
+
188
+ if (config.after != null) {
189
+ self.after = self.hbEnv.compile(config.after);
190
+ }
191
+
192
+ self['_draw_' + k1](root, data, typeInfo, opts);
193
+
194
+ self.addWorkHandler();
195
+
196
+ self.fire('renderEnd');
197
+ self.drawLock.unlock();
198
+
199
+ if (typeof cont === 'function') {
200
+ return cont();
201
+ }
202
+ });
203
+ };
204
+
205
+ // #addWorkHandler {{{2
206
+
207
+ GridRendererHandlebars.prototype.addWorkHandler = function () {
208
+ var self = this;
209
+
210
+ self.view.on('workEnd', function (info, ops) {
211
+ self.draw(self.root, null, self.drawOpts);
212
+ }, { who: self, limit: 1 });
213
+ };
214
+
215
+ // Registry
216
+
217
+ GridRenderer.registry.set('handlebars', GridRendererHandlebars);
@@ -0,0 +1,215 @@
1
+ import _ from 'underscore';
2
+ import jQuery from 'jquery';
3
+ import * as Sqrl from 'squirrelly/dist/browser/squirrelly.min.js';
4
+
5
+ import {
6
+ deepCopy,
7
+ format,
8
+ makeSubclass,
9
+ outerHtml,
10
+ } from '../../util/misc.js';
11
+
12
+ import sqUtil from '../../util/squirrelly.js';
13
+
14
+ import {GridRenderer} from '../../grid_renderer.js';
15
+
16
+ // GridRendererSquirrelly {{{1
17
+
18
+ var GridRendererSquirrelly = makeSubclass('GridRendererSquirrelly', GridRenderer, function () {
19
+ var self = this;
20
+
21
+ self.super['GridRenderer'].ctor.apply(self, arguments);
22
+
23
+ self.config = deepCopy(Sqrl.defaultConfig);
24
+ self.config.useWith = true;
25
+ });
26
+
27
+ // #_validateFeatures {{{2
28
+
29
+ GridRendererSquirrelly.prototype._validateFeatures = function () {
30
+ var self = this;
31
+ self.features.limit = false;
32
+ };
33
+
34
+
35
+ // #canRender {{{2
36
+
37
+ GridRendererSquirrelly.prototype.canRender = function (what) {
38
+ return true;
39
+ };
40
+
41
+ // #_draw_plain {{{2
42
+
43
+ GridRendererSquirrelly.prototype._draw_plain = function (root, data, typeInfo, opts) {
44
+ var self = this;
45
+ var html = '';
46
+
47
+ if (data.data.length === 0) {
48
+ if (self.empty != null) {
49
+ html += self.empty({}, self.config);
50
+ }
51
+ }
52
+ else {
53
+ if (self.before != null) {
54
+ html += self.before({}, self.config);
55
+ }
56
+
57
+ if (self.item != null) {
58
+ _.each(data.data, function (row) {
59
+ var context = {};
60
+ _.each(row.rowData, function (cell, field) {
61
+ var fcc = self.colConfig.get(field) || {};
62
+ var value = format(fcc, typeInfo.get(field), cell);
63
+ if (value instanceof Element || value instanceof jQuery) {
64
+ value = outerHtml(value);
65
+ }
66
+ context[field] = value;
67
+ });
68
+ html += self.item(context, self.config);
69
+ });
70
+ }
71
+
72
+ if (self.after != null) {
73
+ html += self.after({}, self.config);
74
+ }
75
+ }
76
+
77
+ root.html(html);
78
+ };
79
+
80
+ // #_draw_group {{{2
81
+
82
+ GridRendererSquirrelly.prototype._draw_group = function (root, data, typeInfo, opts) {
83
+ var self = this;
84
+ var html = '';
85
+
86
+ if (data.data.length === 0) {
87
+ if (self.empty != null) {
88
+ html += self.empty();
89
+ }
90
+ }
91
+ else {
92
+ if (self.before != null) {
93
+ html += self.before();
94
+ }
95
+
96
+ if (self.item != null) {
97
+ _.each(data.data, function (group, rowValIdx) {
98
+ var context = {
99
+ rowValIdx: rowValIdx
100
+ };
101
+ html += self.item(context, self.config);
102
+ });
103
+ }
104
+
105
+ if (self.after != null) {
106
+ html += self.after();
107
+ }
108
+ }
109
+
110
+ root.html(html);
111
+ };
112
+
113
+ // #_draw_pivot {{{2
114
+
115
+ GridRendererSquirrelly.prototype._draw_pivot = function (root, data, typeInfo, opts) {
116
+ var self = this;
117
+ var html = '';
118
+
119
+ if (data.data.length === 0) {
120
+ if (self.empty != null) {
121
+ html += self.empty();
122
+ }
123
+ }
124
+ else {
125
+ if (self.before != null) {
126
+ html += self.before();
127
+ }
128
+
129
+ if (self.item != null) {
130
+ _.each(data.data, function (group, rowValIdx) {
131
+ if (self.beforeGroup != null) {
132
+ html += self.beforeGroup();
133
+ }
134
+ _.each(group, function (pivot, colValIdx) {
135
+ var div = jQuery('<div>').appendTo(root);
136
+ var context = {
137
+ rowValIdx: rowValIdx,
138
+ colValIdx: colValIdx
139
+ };
140
+ html += self.item(context, self.config);
141
+ });
142
+ if (self.afterGroup != null) {
143
+ html += self.afterGroup();
144
+ }
145
+ });
146
+ }
147
+
148
+ if (self.after != null) {
149
+ html += self.after();
150
+ }
151
+ }
152
+
153
+ root.html(html);
154
+ };
155
+
156
+ // #draw {{{2
157
+
158
+ GridRendererSquirrelly.prototype.draw = function (root, cont, opts) {
159
+ var self = this;
160
+
161
+ if (cont != null && typeof cont !== 'function') {
162
+ throw new Error('Call Error: `cont` must be null or a function');
163
+ }
164
+
165
+ return self.super['GridRenderer'].draw(root, opts, function (ok, data, typeInfo) {
166
+ if (!ok) {
167
+ return cont();
168
+ }
169
+
170
+ sqUtil.addHelpers(Sqrl.helpers, data);
171
+
172
+ var k1 = data.isPlain ? 'plain'
173
+ : data.isGroup ? 'group'
174
+ : data.isPivot ? 'pivot'
175
+ : null;
176
+
177
+ var configKey = data.isPlain ? 'whenPlain'
178
+ : data.isGroup ? 'whenGroup'
179
+ : data.isPivot ? 'whenPivot'
180
+ : null;
181
+
182
+ var config = self.opts[configKey] || {};
183
+
184
+ _.each(['empty', 'before', 'beforeGroup', 'item', 'afterGroup', 'after'], function (x) {
185
+ if (config[x] != null) {
186
+ self[x] = Sqrl.compile(config[x], self.config);
187
+ }
188
+ });
189
+
190
+ self['_draw_' + k1](root, data, typeInfo, opts);
191
+
192
+ self.addWorkHandler();
193
+
194
+ self.fire('renderEnd');
195
+ self.drawLock.unlock();
196
+
197
+ if (typeof cont === 'function') {
198
+ return cont();
199
+ }
200
+ });
201
+ };
202
+
203
+ // #addWorkHandler {{{2
204
+
205
+ GridRendererSquirrelly.prototype.addWorkHandler = function () {
206
+ var self = this;
207
+
208
+ self.view.on('workEnd', function (info, ops) {
209
+ self.draw(self.root, null, self.drawOpts);
210
+ }, { who: self, limit: 1 });
211
+ };
212
+
213
+ // Registry {{{1
214
+
215
+ GridRenderer.registry.set('squirrelly', GridRendererSquirrelly);