@hpcc-js/composite 3.4.10 → 3.5.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.
package/src/MultiChart.ts CHANGED
@@ -1,376 +1,376 @@
1
- import { IGraph, INDChart } from "@hpcc-js/api";
2
- import { Database, HTMLWidget, Utility, Widget } from "@hpcc-js/common";
3
- import { map as d3Map } from "d3-collection";
4
- import { requireWidget } from "./Utility.ts";
5
-
6
- declare const require: any;
7
- export class MultiChart extends HTMLWidget {
8
- _allCharts = {};
9
- _chartTypeDefaults;
10
- _chartTypeProperties;
11
- _chartMonitor;
12
- _switchingTo;
13
-
14
- constructor() {
15
- super();
16
- INDChart.call(this);
17
- IGraph.call(this);
18
-
19
- this._tag = "div";
20
-
21
- this._allCharts = {};
22
- this._allChartTypes.forEach(function (item) {
23
- const newItem = JSON.parse(JSON.stringify(item));
24
- newItem.widget = null;
25
- this._allCharts[item.id] = newItem;
26
- this._allCharts[item.display] = newItem;
27
- this._allCharts[item.widgetClass] = newItem;
28
- }, this);
29
- this._chartTypeDefaults = {};
30
- this._chartTypeProperties = {};
31
- }
32
-
33
- fields(): Database.Field[];
34
- fields(_: Database.Field[]): this;
35
- fields(_?: Database.Field[]): Database.Field[] | this {
36
- const retVal = super.fields.apply(this, arguments);
37
- if (this.chart()) {
38
- if (!arguments.length) return this.chart().fields();
39
- this.chart().fields(_);
40
- }
41
- return retVal;
42
- }
43
-
44
- columns(): string[];
45
- columns(_, asDefault?: boolean): this;
46
- columns(_?, asDefault?: boolean) {
47
- const retVal = HTMLWidget.prototype.columns.apply(this, arguments);
48
- if (this.chart()) {
49
- if (!arguments.length) return this.chart().columns();
50
- this.chart().columns(_, asDefault);
51
- }
52
- return retVal;
53
- }
54
-
55
- data(_?) {
56
- const retVal = HTMLWidget.prototype.data.apply(this, arguments);
57
- if (this.chart()) {
58
- if (!arguments.length) return this.chart().data();
59
- this.chart().data(_);
60
- }
61
- return retVal;
62
- }
63
-
64
- hasOverlay() {
65
- return this.chart() && this.chart().hasOverlay();
66
- }
67
-
68
- visible(): boolean;
69
- visible(_: boolean): this;
70
- visible(_?: boolean): boolean | this {
71
- if (!arguments.length) return this.chart() && this.chart().visible();
72
- if (this.chart()) {
73
- this.chart().visible(_);
74
- }
75
- return this;
76
- }
77
-
78
- chartTypeDefaults(): object;
79
- chartTypeDefaults(_: object): this;
80
- chartTypeDefaults(_?: object): object | this {
81
- if (!arguments.length) return this._chartTypeDefaults;
82
- this._chartTypeDefaults = _;
83
- return this;
84
- }
85
-
86
- chartTypeProperties(): object;
87
- chartTypeProperties(_: object): this;
88
- chartTypeProperties(_?: object): object | this {
89
- if (!arguments.length) return this._chartTypeProperties;
90
- this._chartTypeProperties = _;
91
- return this;
92
- }
93
-
94
- getChartDataFamily() {
95
- return this._allCharts[this.chartType()].family;
96
- }
97
-
98
- requireContent(chartType, callback) {
99
- const classInfo = Utility.parseClassID(this._allCharts[chartType].widgetClass);
100
- switch (classInfo.package) {
101
- case "@hpcc-js/chart":
102
- import("@hpcc-js/chart").then(mod => {
103
- callback(new mod[classInfo.widgetID]());
104
- });
105
- break;
106
- case "@hpcc-js/dgrid":
107
- import("@hpcc-js/dgrid").then(mod => {
108
- callback(new mod[classInfo.widgetID]());
109
- });
110
- break;
111
- default:
112
- requireWidget(this._allCharts[chartType].widgetClass).then(function (WidgetClass: any) {
113
- callback(new WidgetClass());
114
- });
115
- }
116
- }
117
-
118
- switchChart(callback) {
119
- if (this._switchingTo === this.chartType()) {
120
- if (callback) {
121
- callback(this);
122
- }
123
- return;
124
- } else if (this._switchingTo) {
125
- console.warn("Attempting switch to: " + this.chartType() + ", before previous switch is complete (" + this._switchingTo + ")");
126
- }
127
- this._switchingTo = this.chartType();
128
- const oldContent = this.chart();
129
- const context = this;
130
- this.requireContent(this.chartType(), function (newContent) {
131
- if (newContent !== oldContent) {
132
- const size = context.size();
133
- newContent
134
- .fields(context.fields())
135
- .data(context.data())
136
- .size(size)
137
- ;
138
-
139
- context.chart(newContent);
140
- if (oldContent) {
141
- oldContent
142
- .size({ width: 1, height: 1 })
143
- .render()
144
- ;
145
- }
146
- }
147
- delete context._switchingTo;
148
- if (callback) {
149
- callback(this);
150
- }
151
- });
152
- }
153
-
154
- update(domNode, element) {
155
- super.update(domNode, element);
156
- const content = element.selectAll(".multiChart").data(this.chart() ? [this.chart()] : [], function (d) { return d._id; });
157
- content.enter().append("div")
158
- .attr("class", "multiChart")
159
- .each(function (d) {
160
- d.target(this);
161
- })
162
- ;
163
-
164
- const currChart = this.chart();
165
- if (currChart) {
166
- for (const key in this._chartTypeDefaults) {
167
- if (currChart[key + "_default"]) {
168
- try {
169
- currChart[key + "_default"](this._chartTypeDefaults[key]);
170
- } catch (e) {
171
- console.warn("Exception Setting Default: " + key);
172
- }
173
- } else {
174
- console.warn("Unknown Default: " + key);
175
- }
176
- }
177
- this._chartTypeDefaults = {};
178
- for (const propKey in this._chartTypeProperties) {
179
- if (currChart[propKey]) {
180
- try {
181
- currChart[propKey](this._chartTypeProperties[propKey]);
182
- } catch (e) {
183
- console.warn("Exception Setting Property: " + propKey);
184
- }
185
- } else {
186
- console.warn("Unknown Property: " + propKey);
187
- }
188
- }
189
- this._chartTypeProperties = {};
190
- }
191
-
192
- const context = this;
193
- content
194
- .each(function (d) { d.resize(context.size()); })
195
- ;
196
-
197
- content.exit().transition()
198
- .each(function (d) { d.target(null); })
199
- .remove()
200
- ;
201
- }
202
-
203
- exit(domNode, element) {
204
- if (this._chartMonitor) {
205
- this._chartMonitor.remove();
206
- delete this._chartMonitor;
207
- }
208
- if (this.chart()) {
209
- this.chart().target(null);
210
- }
211
- super.exit(domNode, element);
212
- }
213
-
214
- render(_callback?) {
215
- if (this.chartType() && (!this.chart() || (this.chart().classID() !== this._allCharts[this.chartType()].widgetClass))) {
216
- const context = this;
217
- const args = arguments;
218
- this.switchChart(function () {
219
- HTMLWidget.prototype.render.apply(context, args);
220
- });
221
- return this;
222
- }
223
- return HTMLWidget.prototype.render.apply(this, arguments);
224
- }
225
- }
226
- MultiChart.prototype._class += " composite_MultiChart";
227
- MultiChart.prototype.implements(INDChart.prototype);
228
- MultiChart.prototype.implements(IGraph.prototype);
229
- export interface ChartMeta {
230
- id: string;
231
- display: string;
232
- widgetClass: string;
233
- widgetPath?: string;
234
- }
235
- export interface MultiChart {
236
- _otherChartTypes: ChartMeta[];
237
- _graphChartTypes: ChartMeta[];
238
- _1DChartTypes: ChartMeta[];
239
- _2DChartTypes: ChartMeta[];
240
- _NDChartTypes: ChartMeta[];
241
- _mapChartTypes: ChartMeta[];
242
- _anyChartTypes: ChartMeta[];
243
- _allChartTypes: ChartMeta[];
244
- _allMap;
245
- _allFamilies: string[];
246
- _allChartTypesMap;
247
- _allChartTypesByClass;
248
-
249
- hideRowOnLegendClick(): boolean;
250
- hideRowOnLegendClick(_: boolean): this;
251
- chartType(): string;
252
- chartType(_: string): this;
253
- chart(): Widget;
254
- chart(_: Widget): this;
255
- chart_access(): Widget;
256
- chart_access(_: Widget): this;
257
-
258
- click(_row, _column, _selected): void;
259
- dblclick(_row, _column, _selected): void;
260
- vertex_click(row, column, selected, more): void;
261
- vertex_dblclick(row, column, selected, more): void;
262
- edge_click(row, column, selected, more): void;
263
- edge_dblclick(row, column, selected, more): void;
264
- }
265
-
266
- MultiChart.prototype._otherChartTypes = [
267
- { id: "FORM", display: "Form", widgetClass: "form_FieldForm" }
268
- ].map(function (item: any) { item.family = "other"; return item; });
269
- MultiChart.prototype._graphChartTypes = [
270
- { id: "GRAPH", display: "Graph", widgetClass: "graph_Graph" },
271
- { id: "ADJACENCY_GRAPH", display: "Graph", widgetClass: "graph_AdjacencyGraph" },
272
- { id: "GRAPHC", display: "GraphC", widgetClass: "graph_GraphC" }
273
- ].map(function (item: any) { item.family = "GRAPH"; return item; });
274
- MultiChart.prototype._1DChartTypes = [
275
- ].map(function (item: any) { item.family = "1D"; return item; });
276
- MultiChart.prototype._2DChartTypes = [
277
- { id: "SUMMARY", display: "Summary", widgetClass: "chart_Summary" },
278
- { id: "BUBBLE", display: "Bubble", widgetClass: "chart_Bubble" },
279
- { id: "PIE", display: "Pie", widgetClass: "chart_Pie" },
280
- { id: "WORD_CLOUD", display: "Word Cloud", widgetClass: "other_WordCloud" }
281
- ].map(function (item: any) { item.family = "2D"; return item; });
282
- MultiChart.prototype._NDChartTypes = [
283
- { id: "COLUMN", display: "Column", widgetClass: "chart_Column" },
284
- { id: "BAR", display: "Bar", widgetClass: "chart_Bar" },
285
- { id: "LINE", display: "Line", widgetClass: "chart_Line" },
286
- { id: "AREA", display: "Area", widgetClass: "chart_Area" },
287
- { id: "STEP", display: "Step", widgetClass: "chart_Step" },
288
- { id: "SCATTER", display: "Scatter", widgetClass: "chart_Scatter" },
289
- { id: "HEXBIN", display: "Hex Bin", widgetClass: "chart_HexBin" }
290
- ].map(function (item: any) { item.family = "ND"; return item; });
291
- MultiChart.prototype._mapChartTypes = [
292
- { id: "CHORO_USSTATES", display: "US State Choropleth", widgetClass: "map_ChoroplethStates" },
293
- { id: "CHORO_USCOUNTIES", display: "US County Choropleth", widgetClass: "map_ChoroplethCounties" },
294
- { id: "CHORO_COUNTRIES", display: "Country Choropleth", widgetClass: "map_ChoroplethCountries" },
295
- { id: "GMAP_CHORO_USCOUNTIES", display: "Google Map US County Choropleth", widgetClass: "map_GMapCounties" },
296
- { id: "GOOGLE_MAP", display: "Google Map", widgetClass: "map_GMapLayered" },
297
- { id: "OPENSTREET", display: "Open Street Map", widgetClass: "map_OpenStreet" }
298
- ].map(function (item: any) { item.family = "map"; return item; });
299
- MultiChart.prototype._anyChartTypes = [
300
- { id: "TABLE", display: "Table", widgetClass: "dgrid_Table" },
301
- { id: "TABLE_LEGACY", display: "Table (legacy)", widgetClass: "other_Table" },
302
- { id: "TABLE_NESTED", display: "Nested Table", widgetClass: "other_NestedTable" },
303
- { id: "TABLE_CALENDAR", display: "Table driven Calendar Heat Map", widgetClass: "other_CalendarHeatMap" },
304
- { id: "TABLE_BULLET", display: "Table driven bullet chart", widgetClass: "chart_Bullet" },
305
- { id: "TABLE_SELECT", display: "Table driven select", widgetClass: "other_Select" },
306
- { id: "TABLE_AUTOCOMPLETE", display: "Table driven auto complete", widgetClass: "other_AutoCompleteText" },
307
- { id: "TABLE_OPPORTUNITY", display: "Table driven opportunity widget", widgetClass: "graph_Opportunity" },
308
- { id: "TABLE_TREE", display: "Table driven tree", widgetClass: "tree_Dendrogram" },
309
- { id: "TABLE_TREEMAP", display: "Table driven Treemap", widgetClass: "tree_Treemap" },
310
- { id: "TABLE_SANKEY", display: "Table driven Sankey", widgetClass: "graph_Sankey" },
311
- { id: "TABLE_GMAP_PIN", display: "Table driven Google Map (pins)", widgetClass: "map_GMapPin" },
312
- { id: "TABLE_GMAP_PINLINE", display: "Table driven Google Map (pins/lines)", widgetClass: "map_GMapPinLine" },
313
- { id: "TABLE_XML_TREE", display: "Table driven XML Tree", widgetClass: "tree_Indented" }
314
- ].map(function (item: any) { item.family = "any"; return item; });
315
- MultiChart.prototype._allChartTypes =
316
- MultiChart.prototype._otherChartTypes.concat(
317
- MultiChart.prototype._graphChartTypes.concat(
318
- MultiChart.prototype._1DChartTypes.concat(
319
- MultiChart.prototype._2DChartTypes.concat(
320
- MultiChart.prototype._NDChartTypes.concat(
321
- MultiChart.prototype._mapChartTypes.concat(
322
- MultiChart.prototype._anyChartTypes
323
- ))))));
324
- MultiChart.prototype._allMap = d3Map(MultiChart.prototype._allChartTypes, function (item: any) { return item.family; });
325
- MultiChart.prototype._allFamilies = MultiChart.prototype._allMap.keys();
326
- MultiChart.prototype._allChartTypesMap = {};
327
- MultiChart.prototype._allChartTypesByClass = {};
328
- MultiChart.prototype._allChartTypes.forEach(function (item) {
329
- item.widgetPath = Utility.widgetPath(item.widgetClass);
330
- MultiChart.prototype._allChartTypesMap[item.id] = item;
331
- MultiChart.prototype._allChartTypesByClass[item.widgetClass] = item;
332
- });
333
-
334
- MultiChart.prototype.publishReset();
335
- MultiChart.prototype.publish("hideRowOnLegendClick", false, "boolean", "Enable/Disable hiding row on legend clicks", null, { tags: ["Basic"] });
336
- MultiChart.prototype.publish("chartType", "BUBBLE", "set", "Chart Type", MultiChart.prototype._allChartTypes.map(function (item) { return item.id; }), { tags: ["Basic"] });
337
- MultiChart.prototype.publish("chart", null, "widget", "Chart", null, { tags: ["Basic"] });
338
-
339
- const _origChart = MultiChart.prototype.chart;
340
- MultiChart.prototype.chart = function (_?) {
341
- const retVal = _origChart.apply(this, arguments);
342
- if (arguments.length) {
343
- const context = this;
344
- if (this._allChartTypesByClass[_.classID()]) {
345
- this.chartType(this._allChartTypesByClass[_.classID()].id);
346
- } else {
347
- console.warn("Unknown Class ID: " + _.classID());
348
- }
349
- _.click = function (_row, _column, _selected) {
350
- context.click.apply(context, arguments);
351
- };
352
- _.dblclick = function (_row, _column, _selected) {
353
- context.dblclick.apply(context, arguments);
354
- };
355
- _.vertex_click = function (row, column, selected, more) {
356
- context.vertex_click.apply(context, arguments);
357
- };
358
- _.vertex_dblclick = function (row, column, selected, more) {
359
- context.vertex_dblclick.apply(context, arguments);
360
- };
361
- _.edge_click = function (row, column, selected, more) {
362
- context.edge_click.apply(context, arguments);
363
- };
364
- _.edge_dblclick = function (row, column, selected, more) {
365
- context.edge_dblclick.apply(context, arguments);
366
- };
367
- if (this._chartMonitor) {
368
- this._chartMonitor.remove();
369
- delete this._chartMonitor;
370
- }
371
- this._chartMonitor = _.monitor(function (key, newVal, oldVal) {
372
- context.broadcast(key, newVal, oldVal, _);
373
- });
374
- }
375
- return retVal;
376
- };
1
+ import { IGraph, INDChart } from "@hpcc-js/api";
2
+ import { Database, HTMLWidget, Utility, Widget } from "@hpcc-js/common";
3
+ import { map as d3Map } from "d3-collection";
4
+ import { requireWidget } from "./Utility.ts";
5
+
6
+ declare const require: any;
7
+ export class MultiChart extends HTMLWidget {
8
+ _allCharts = {};
9
+ _chartTypeDefaults;
10
+ _chartTypeProperties;
11
+ _chartMonitor;
12
+ _switchingTo;
13
+
14
+ constructor() {
15
+ super();
16
+ INDChart.call(this);
17
+ IGraph.call(this);
18
+
19
+ this._tag = "div";
20
+
21
+ this._allCharts = {};
22
+ this._allChartTypes.forEach(function (item) {
23
+ const newItem = JSON.parse(JSON.stringify(item));
24
+ newItem.widget = null;
25
+ this._allCharts[item.id] = newItem;
26
+ this._allCharts[item.display] = newItem;
27
+ this._allCharts[item.widgetClass] = newItem;
28
+ }, this);
29
+ this._chartTypeDefaults = {};
30
+ this._chartTypeProperties = {};
31
+ }
32
+
33
+ fields(): Database.Field[];
34
+ fields(_: Database.Field[]): this;
35
+ fields(_?: Database.Field[]): Database.Field[] | this {
36
+ const retVal = super.fields.apply(this, arguments);
37
+ if (this.chart()) {
38
+ if (!arguments.length) return this.chart().fields();
39
+ this.chart().fields(_);
40
+ }
41
+ return retVal;
42
+ }
43
+
44
+ columns(): string[];
45
+ columns(_, asDefault?: boolean): this;
46
+ columns(_?, asDefault?: boolean) {
47
+ const retVal = HTMLWidget.prototype.columns.apply(this, arguments);
48
+ if (this.chart()) {
49
+ if (!arguments.length) return this.chart().columns();
50
+ this.chart().columns(_, asDefault);
51
+ }
52
+ return retVal;
53
+ }
54
+
55
+ data(_?) {
56
+ const retVal = HTMLWidget.prototype.data.apply(this, arguments);
57
+ if (this.chart()) {
58
+ if (!arguments.length) return this.chart().data();
59
+ this.chart().data(_);
60
+ }
61
+ return retVal;
62
+ }
63
+
64
+ hasOverlay() {
65
+ return this.chart() && this.chart().hasOverlay();
66
+ }
67
+
68
+ visible(): boolean;
69
+ visible(_: boolean): this;
70
+ visible(_?: boolean): boolean | this {
71
+ if (!arguments.length) return this.chart() && this.chart().visible();
72
+ if (this.chart()) {
73
+ this.chart().visible(_);
74
+ }
75
+ return this;
76
+ }
77
+
78
+ chartTypeDefaults(): object;
79
+ chartTypeDefaults(_: object): this;
80
+ chartTypeDefaults(_?: object): object | this {
81
+ if (!arguments.length) return this._chartTypeDefaults;
82
+ this._chartTypeDefaults = _;
83
+ return this;
84
+ }
85
+
86
+ chartTypeProperties(): object;
87
+ chartTypeProperties(_: object): this;
88
+ chartTypeProperties(_?: object): object | this {
89
+ if (!arguments.length) return this._chartTypeProperties;
90
+ this._chartTypeProperties = _;
91
+ return this;
92
+ }
93
+
94
+ getChartDataFamily() {
95
+ return this._allCharts[this.chartType()].family;
96
+ }
97
+
98
+ requireContent(chartType, callback) {
99
+ const classInfo = Utility.parseClassID(this._allCharts[chartType].widgetClass);
100
+ switch (classInfo.package) {
101
+ case "@hpcc-js/chart":
102
+ import("@hpcc-js/chart").then(mod => {
103
+ callback(new mod[classInfo.widgetID]());
104
+ });
105
+ break;
106
+ case "@hpcc-js/dgrid":
107
+ import("@hpcc-js/dgrid").then(mod => {
108
+ callback(new mod[classInfo.widgetID]());
109
+ });
110
+ break;
111
+ default:
112
+ requireWidget(this._allCharts[chartType].widgetClass).then(function (WidgetClass: any) {
113
+ callback(new WidgetClass());
114
+ });
115
+ }
116
+ }
117
+
118
+ switchChart(callback) {
119
+ if (this._switchingTo === this.chartType()) {
120
+ if (callback) {
121
+ callback(this);
122
+ }
123
+ return;
124
+ } else if (this._switchingTo) {
125
+ console.warn("Attempting switch to: " + this.chartType() + ", before previous switch is complete (" + this._switchingTo + ")");
126
+ }
127
+ this._switchingTo = this.chartType();
128
+ const oldContent = this.chart();
129
+ const context = this;
130
+ this.requireContent(this.chartType(), function (newContent) {
131
+ if (newContent !== oldContent) {
132
+ const size = context.size();
133
+ newContent
134
+ .fields(context.fields())
135
+ .data(context.data())
136
+ .size(size)
137
+ ;
138
+
139
+ context.chart(newContent);
140
+ if (oldContent) {
141
+ oldContent
142
+ .size({ width: 1, height: 1 })
143
+ .render()
144
+ ;
145
+ }
146
+ }
147
+ delete context._switchingTo;
148
+ if (callback) {
149
+ callback(this);
150
+ }
151
+ });
152
+ }
153
+
154
+ update(domNode, element) {
155
+ super.update(domNode, element);
156
+ const content = element.selectAll(".multiChart").data(this.chart() ? [this.chart()] : [], function (d) { return d._id; });
157
+ content.enter().append("div")
158
+ .attr("class", "multiChart")
159
+ .each(function (d) {
160
+ d.target(this);
161
+ })
162
+ ;
163
+
164
+ const currChart = this.chart();
165
+ if (currChart) {
166
+ for (const key in this._chartTypeDefaults) {
167
+ if (currChart[key + "_default"]) {
168
+ try {
169
+ currChart[key + "_default"](this._chartTypeDefaults[key]);
170
+ } catch (e) {
171
+ console.warn("Exception Setting Default: " + key);
172
+ }
173
+ } else {
174
+ console.warn("Unknown Default: " + key);
175
+ }
176
+ }
177
+ this._chartTypeDefaults = {};
178
+ for (const propKey in this._chartTypeProperties) {
179
+ if (currChart[propKey]) {
180
+ try {
181
+ currChart[propKey](this._chartTypeProperties[propKey]);
182
+ } catch (e) {
183
+ console.warn("Exception Setting Property: " + propKey);
184
+ }
185
+ } else {
186
+ console.warn("Unknown Property: " + propKey);
187
+ }
188
+ }
189
+ this._chartTypeProperties = {};
190
+ }
191
+
192
+ const context = this;
193
+ content
194
+ .each(function (d) { d.resize(context.size()); })
195
+ ;
196
+
197
+ content.exit().transition()
198
+ .each(function (d) { d.target(null); })
199
+ .remove()
200
+ ;
201
+ }
202
+
203
+ exit(domNode, element) {
204
+ if (this._chartMonitor) {
205
+ this._chartMonitor.remove();
206
+ delete this._chartMonitor;
207
+ }
208
+ if (this.chart()) {
209
+ this.chart().target(null);
210
+ }
211
+ super.exit(domNode, element);
212
+ }
213
+
214
+ render(_callback?) {
215
+ if (this.chartType() && (!this.chart() || (this.chart().classID() !== this._allCharts[this.chartType()].widgetClass))) {
216
+ const context = this;
217
+ const args = arguments;
218
+ this.switchChart(function () {
219
+ HTMLWidget.prototype.render.apply(context, args);
220
+ });
221
+ return this;
222
+ }
223
+ return HTMLWidget.prototype.render.apply(this, arguments);
224
+ }
225
+ }
226
+ MultiChart.prototype._class += " composite_MultiChart";
227
+ MultiChart.prototype.implements(INDChart.prototype);
228
+ MultiChart.prototype.implements(IGraph.prototype);
229
+ export interface ChartMeta {
230
+ id: string;
231
+ display: string;
232
+ widgetClass: string;
233
+ widgetPath?: string;
234
+ }
235
+ export interface MultiChart {
236
+ _otherChartTypes: ChartMeta[];
237
+ _graphChartTypes: ChartMeta[];
238
+ _1DChartTypes: ChartMeta[];
239
+ _2DChartTypes: ChartMeta[];
240
+ _NDChartTypes: ChartMeta[];
241
+ _mapChartTypes: ChartMeta[];
242
+ _anyChartTypes: ChartMeta[];
243
+ _allChartTypes: ChartMeta[];
244
+ _allMap;
245
+ _allFamilies: string[];
246
+ _allChartTypesMap;
247
+ _allChartTypesByClass;
248
+
249
+ hideRowOnLegendClick(): boolean;
250
+ hideRowOnLegendClick(_: boolean): this;
251
+ chartType(): string;
252
+ chartType(_: string): this;
253
+ chart(): Widget;
254
+ chart(_: Widget): this;
255
+ chart_access(): Widget;
256
+ chart_access(_: Widget): this;
257
+
258
+ click(_row, _column, _selected): void;
259
+ dblclick(_row, _column, _selected): void;
260
+ vertex_click(row, column, selected, more): void;
261
+ vertex_dblclick(row, column, selected, more): void;
262
+ edge_click(row, column, selected, more): void;
263
+ edge_dblclick(row, column, selected, more): void;
264
+ }
265
+
266
+ MultiChart.prototype._otherChartTypes = [
267
+ { id: "FORM", display: "Form", widgetClass: "form_FieldForm" }
268
+ ].map(function (item: any) { item.family = "other"; return item; });
269
+ MultiChart.prototype._graphChartTypes = [
270
+ { id: "GRAPH", display: "Graph", widgetClass: "graph_Graph" },
271
+ { id: "ADJACENCY_GRAPH", display: "Graph", widgetClass: "graph_AdjacencyGraph" },
272
+ { id: "GRAPHC", display: "GraphC", widgetClass: "graph_GraphC" }
273
+ ].map(function (item: any) { item.family = "GRAPH"; return item; });
274
+ MultiChart.prototype._1DChartTypes = [
275
+ ].map(function (item: any) { item.family = "1D"; return item; });
276
+ MultiChart.prototype._2DChartTypes = [
277
+ { id: "SUMMARY", display: "Summary", widgetClass: "chart_Summary" },
278
+ { id: "BUBBLE", display: "Bubble", widgetClass: "chart_Bubble" },
279
+ { id: "PIE", display: "Pie", widgetClass: "chart_Pie" },
280
+ { id: "WORD_CLOUD", display: "Word Cloud", widgetClass: "other_WordCloud" }
281
+ ].map(function (item: any) { item.family = "2D"; return item; });
282
+ MultiChart.prototype._NDChartTypes = [
283
+ { id: "COLUMN", display: "Column", widgetClass: "chart_Column" },
284
+ { id: "BAR", display: "Bar", widgetClass: "chart_Bar" },
285
+ { id: "LINE", display: "Line", widgetClass: "chart_Line" },
286
+ { id: "AREA", display: "Area", widgetClass: "chart_Area" },
287
+ { id: "STEP", display: "Step", widgetClass: "chart_Step" },
288
+ { id: "SCATTER", display: "Scatter", widgetClass: "chart_Scatter" },
289
+ { id: "HEXBIN", display: "Hex Bin", widgetClass: "chart_HexBin" }
290
+ ].map(function (item: any) { item.family = "ND"; return item; });
291
+ MultiChart.prototype._mapChartTypes = [
292
+ { id: "CHORO_USSTATES", display: "US State Choropleth", widgetClass: "map_ChoroplethStates" },
293
+ { id: "CHORO_USCOUNTIES", display: "US County Choropleth", widgetClass: "map_ChoroplethCounties" },
294
+ { id: "CHORO_COUNTRIES", display: "Country Choropleth", widgetClass: "map_ChoroplethCountries" },
295
+ { id: "GMAP_CHORO_USCOUNTIES", display: "Google Map US County Choropleth", widgetClass: "map_GMapCounties" },
296
+ { id: "GOOGLE_MAP", display: "Google Map", widgetClass: "map_GMapLayered" },
297
+ { id: "OPENSTREET", display: "Open Street Map", widgetClass: "map_OpenStreet" }
298
+ ].map(function (item: any) { item.family = "map"; return item; });
299
+ MultiChart.prototype._anyChartTypes = [
300
+ { id: "TABLE", display: "Table", widgetClass: "dgrid_Table" },
301
+ { id: "TABLE_LEGACY", display: "Table (legacy)", widgetClass: "other_Table" },
302
+ { id: "TABLE_NESTED", display: "Nested Table", widgetClass: "other_NestedTable" },
303
+ { id: "TABLE_CALENDAR", display: "Table driven Calendar Heat Map", widgetClass: "other_CalendarHeatMap" },
304
+ { id: "TABLE_BULLET", display: "Table driven bullet chart", widgetClass: "chart_Bullet" },
305
+ { id: "TABLE_SELECT", display: "Table driven select", widgetClass: "other_Select" },
306
+ { id: "TABLE_AUTOCOMPLETE", display: "Table driven auto complete", widgetClass: "other_AutoCompleteText" },
307
+ { id: "TABLE_OPPORTUNITY", display: "Table driven opportunity widget", widgetClass: "graph_Opportunity" },
308
+ { id: "TABLE_TREE", display: "Table driven tree", widgetClass: "tree_Dendrogram" },
309
+ { id: "TABLE_TREEMAP", display: "Table driven Treemap", widgetClass: "tree_Treemap" },
310
+ { id: "TABLE_SANKEY", display: "Table driven Sankey", widgetClass: "graph_Sankey" },
311
+ { id: "TABLE_GMAP_PIN", display: "Table driven Google Map (pins)", widgetClass: "map_GMapPin" },
312
+ { id: "TABLE_GMAP_PINLINE", display: "Table driven Google Map (pins/lines)", widgetClass: "map_GMapPinLine" },
313
+ { id: "TABLE_XML_TREE", display: "Table driven XML Tree", widgetClass: "tree_Indented" }
314
+ ].map(function (item: any) { item.family = "any"; return item; });
315
+ MultiChart.prototype._allChartTypes =
316
+ MultiChart.prototype._otherChartTypes.concat(
317
+ MultiChart.prototype._graphChartTypes.concat(
318
+ MultiChart.prototype._1DChartTypes.concat(
319
+ MultiChart.prototype._2DChartTypes.concat(
320
+ MultiChart.prototype._NDChartTypes.concat(
321
+ MultiChart.prototype._mapChartTypes.concat(
322
+ MultiChart.prototype._anyChartTypes
323
+ ))))));
324
+ MultiChart.prototype._allMap = d3Map(MultiChart.prototype._allChartTypes, function (item: any) { return item.family; });
325
+ MultiChart.prototype._allFamilies = MultiChart.prototype._allMap.keys();
326
+ MultiChart.prototype._allChartTypesMap = {};
327
+ MultiChart.prototype._allChartTypesByClass = {};
328
+ MultiChart.prototype._allChartTypes.forEach(function (item) {
329
+ item.widgetPath = Utility.widgetPath(item.widgetClass);
330
+ MultiChart.prototype._allChartTypesMap[item.id] = item;
331
+ MultiChart.prototype._allChartTypesByClass[item.widgetClass] = item;
332
+ });
333
+
334
+ MultiChart.prototype.publishReset();
335
+ MultiChart.prototype.publish("hideRowOnLegendClick", false, "boolean", "Enable/Disable hiding row on legend clicks", null, { tags: ["Basic"] });
336
+ MultiChart.prototype.publish("chartType", "BUBBLE", "set", "Chart Type", MultiChart.prototype._allChartTypes.map(function (item) { return item.id; }), { tags: ["Basic"] });
337
+ MultiChart.prototype.publish("chart", null, "widget", "Chart", null, { tags: ["Basic"] });
338
+
339
+ const _origChart = MultiChart.prototype.chart;
340
+ MultiChart.prototype.chart = function (_?) {
341
+ const retVal = _origChart.apply(this, arguments);
342
+ if (arguments.length) {
343
+ const context = this;
344
+ if (this._allChartTypesByClass[_.classID()]) {
345
+ this.chartType(this._allChartTypesByClass[_.classID()].id);
346
+ } else {
347
+ console.warn("Unknown Class ID: " + _.classID());
348
+ }
349
+ _.click = function (_row, _column, _selected) {
350
+ context.click.apply(context, arguments);
351
+ };
352
+ _.dblclick = function (_row, _column, _selected) {
353
+ context.dblclick.apply(context, arguments);
354
+ };
355
+ _.vertex_click = function (row, column, selected, more) {
356
+ context.vertex_click.apply(context, arguments);
357
+ };
358
+ _.vertex_dblclick = function (row, column, selected, more) {
359
+ context.vertex_dblclick.apply(context, arguments);
360
+ };
361
+ _.edge_click = function (row, column, selected, more) {
362
+ context.edge_click.apply(context, arguments);
363
+ };
364
+ _.edge_dblclick = function (row, column, selected, more) {
365
+ context.edge_dblclick.apply(context, arguments);
366
+ };
367
+ if (this._chartMonitor) {
368
+ this._chartMonitor.remove();
369
+ delete this._chartMonitor;
370
+ }
371
+ this._chartMonitor = _.monitor(function (key, newVal, oldVal) {
372
+ context.broadcast(key, newVal, oldVal, _);
373
+ });
374
+ }
375
+ return retVal;
376
+ };