@deephaven/chart 0.22.3-beta.18 → 0.22.3-beta.21
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/dist/Chart.js +11 -85
- package/dist/Chart.js.map +1 -1
- package/dist/ChartModel.js +7 -45
- package/dist/ChartModel.js.map +1 -1
- package/dist/ChartModelFactory.js +2 -9
- package/dist/ChartModelFactory.js.map +1 -1
- package/dist/ChartTestUtils.js +0 -14
- package/dist/ChartTestUtils.js.map +1 -1
- package/dist/ChartTheme.js.map +1 -1
- package/dist/ChartUtils.js +72 -273
- package/dist/ChartUtils.js.map +1 -1
- package/dist/FigureChartModel.js +23 -133
- package/dist/FigureChartModel.js.map +1 -1
- package/dist/MockChartModel.js +6 -27
- package/dist/MockChartModel.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isFigureChartModel.js.map +1 -1
- package/dist/plotly/Plot.js +0 -1
- package/dist/plotly/Plot.js.map +1 -1
- package/dist/plotly/Plotly.js +3 -1
- package/dist/plotly/Plotly.js.map +1 -1
- package/package.json +9 -9
package/dist/FigureChartModel.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
/* eslint class-methods-use-this: "off" */
|
|
8
5
|
import memoize from 'memoizee';
|
|
9
6
|
import debounce from 'lodash.debounce';
|
|
@@ -14,10 +11,10 @@ import ChartModel from "./ChartModel.js";
|
|
|
14
11
|
import ChartUtils from "./ChartUtils.js";
|
|
15
12
|
import ChartTheme from "./ChartTheme.js";
|
|
16
13
|
var log = Log.module('FigureChartModel');
|
|
14
|
+
|
|
17
15
|
/**
|
|
18
16
|
* Takes a Figure object from a widget to make a model for a chart
|
|
19
17
|
*/
|
|
20
|
-
|
|
21
18
|
class FigureChartModel extends ChartModel {
|
|
22
19
|
/**
|
|
23
20
|
* @param figure The figure object created by the API
|
|
@@ -27,68 +24,49 @@ class FigureChartModel extends ChartModel {
|
|
|
27
24
|
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
25
|
var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChartTheme;
|
|
29
26
|
super();
|
|
30
|
-
|
|
31
27
|
_defineProperty(this, "figure", void 0);
|
|
32
|
-
|
|
33
28
|
_defineProperty(this, "settings", void 0);
|
|
34
|
-
|
|
35
29
|
_defineProperty(this, "theme", void 0);
|
|
36
|
-
|
|
37
30
|
_defineProperty(this, "data", void 0);
|
|
38
|
-
|
|
39
31
|
_defineProperty(this, "layout", void 0);
|
|
40
|
-
|
|
41
32
|
_defineProperty(this, "seriesDataMap", void 0);
|
|
42
|
-
|
|
43
33
|
_defineProperty(this, "pendingSeries", void 0);
|
|
44
|
-
|
|
45
34
|
_defineProperty(this, "oneClicks", void 0);
|
|
46
|
-
|
|
47
35
|
_defineProperty(this, "filterColumnMap", void 0);
|
|
48
|
-
|
|
49
36
|
_defineProperty(this, "lastFilter", void 0);
|
|
50
|
-
|
|
51
37
|
_defineProperty(this, "isConnected", void 0);
|
|
52
|
-
|
|
53
38
|
_defineProperty(this, "seriesToProcess", void 0);
|
|
54
|
-
|
|
55
39
|
_defineProperty(this, "addPendingSeries", debounce(() => {
|
|
56
40
|
var axes = ChartUtils.getAllAxes(this.figure);
|
|
57
41
|
var {
|
|
58
42
|
pendingSeries
|
|
59
43
|
} = this;
|
|
60
|
-
|
|
61
44
|
for (var i = 0; i < pendingSeries.length; i += 1) {
|
|
62
45
|
var series = pendingSeries[i];
|
|
63
46
|
this.addSeries(series, axes);
|
|
64
|
-
series.subscribe();
|
|
47
|
+
series.subscribe();
|
|
48
|
+
// We'll get an update with the data after subscribing
|
|
65
49
|
}
|
|
66
50
|
|
|
67
51
|
this.pendingSeries = [];
|
|
68
52
|
}, FigureChartModel.ADD_SERIES_DEBOUNCE));
|
|
69
|
-
|
|
70
53
|
_defineProperty(this, "getTimeZone", memoize((columnType, formatter) => {
|
|
71
54
|
if (formatter != null) {
|
|
72
55
|
var dataFormatter = formatter.getColumnTypeFormatter(columnType);
|
|
73
|
-
|
|
74
56
|
if (dataFormatter != null) {
|
|
75
57
|
return dataFormatter.dhTimeZone;
|
|
76
58
|
}
|
|
77
59
|
}
|
|
78
|
-
|
|
79
60
|
return undefined;
|
|
80
61
|
}));
|
|
81
|
-
|
|
82
62
|
_defineProperty(this, "getValueTranslator", memoize((columnType, formatter) => {
|
|
83
63
|
var timeZone = this.getTimeZone(columnType, formatter);
|
|
84
64
|
return value => ChartUtils.unwrapValue(value, timeZone);
|
|
85
65
|
}));
|
|
86
|
-
|
|
87
66
|
_defineProperty(this, "getValueParser", memoize((columnType, formatter) => {
|
|
88
67
|
var timeZone = this.getTimeZone(columnType, formatter);
|
|
89
68
|
return value => ChartUtils.wrapValue(value, columnType, timeZone);
|
|
90
69
|
}));
|
|
91
|
-
|
|
92
70
|
_defineProperty(this, "getRangeParser", memoize((columnType, formatter) => range => {
|
|
93
71
|
var [rangeStart, rangeEnd] = range;
|
|
94
72
|
var valueParser = this.getValueParser(columnType, formatter);
|
|
@@ -96,17 +74,13 @@ class FigureChartModel extends ChartModel {
|
|
|
96
74
|
rangeEnd = valueParser(rangeEnd);
|
|
97
75
|
return [rangeStart, rangeEnd];
|
|
98
76
|
}));
|
|
99
|
-
|
|
100
77
|
_defineProperty(this, "getAxisRangeParser", memoize((chart, formatter) => axis => {
|
|
101
78
|
var source = ChartUtils.getSourceForAxis(chart, axis);
|
|
102
|
-
|
|
103
79
|
if (source) {
|
|
104
80
|
return this.getRangeParser(source.columnType, formatter);
|
|
105
81
|
}
|
|
106
|
-
|
|
107
82
|
return range => range;
|
|
108
83
|
}));
|
|
109
|
-
|
|
110
84
|
this.handleFigureUpdated = this.handleFigureUpdated.bind(this);
|
|
111
85
|
this.handleFigureDisconnected = this.handleFigureDisconnected.bind(this);
|
|
112
86
|
this.handleFigureReconnected = this.handleFigureReconnected.bind(this);
|
|
@@ -138,29 +112,24 @@ class FigureChartModel extends ChartModel {
|
|
|
138
112
|
this.filterColumnMap = new Map();
|
|
139
113
|
this.lastFilter = new Map();
|
|
140
114
|
this.isConnected = true; // Assume figure is connected to start
|
|
141
|
-
|
|
142
115
|
this.seriesToProcess = new Set();
|
|
143
116
|
this.setTitle(this.getDefaultTitle());
|
|
144
117
|
this.initAllSeries();
|
|
145
118
|
this.updateAxisPositions();
|
|
146
119
|
this.startListeningFigure();
|
|
147
120
|
}
|
|
148
|
-
|
|
149
121
|
close() {
|
|
150
122
|
this.figure.close();
|
|
151
123
|
this.addPendingSeries.cancel();
|
|
152
124
|
this.stopListeningFigure();
|
|
153
125
|
}
|
|
154
|
-
|
|
155
126
|
getDefaultTitle() {
|
|
156
127
|
if (this.figure.charts.length > 0) {
|
|
157
128
|
var chart = this.figure.charts[0];
|
|
158
129
|
return chart.title;
|
|
159
130
|
}
|
|
160
|
-
|
|
161
131
|
return '';
|
|
162
132
|
}
|
|
163
|
-
|
|
164
133
|
initAllSeries() {
|
|
165
134
|
this.oneClicks = [];
|
|
166
135
|
this.filterColumnMap.clear();
|
|
@@ -169,49 +138,41 @@ class FigureChartModel extends ChartModel {
|
|
|
169
138
|
} = this.figure;
|
|
170
139
|
var axes = ChartUtils.getAllAxes(this.figure);
|
|
171
140
|
var activeSeriesNames = [];
|
|
172
|
-
|
|
173
141
|
for (var i = 0; i < charts.length; i += 1) {
|
|
174
142
|
var chart = charts[i];
|
|
175
|
-
|
|
176
143
|
for (var j = 0; j < chart.series.length; j += 1) {
|
|
177
144
|
var series = chart.series[j];
|
|
178
145
|
activeSeriesNames.push(series.name);
|
|
179
146
|
this.addSeries(series, axes);
|
|
180
147
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
148
|
+
}
|
|
183
149
|
|
|
150
|
+
// Remove any series that no longer exist
|
|
184
151
|
var allSeriesNames = [...this.seriesDataMap.keys()];
|
|
185
152
|
var inactiveSeriesNames = allSeriesNames.filter(seriesName => activeSeriesNames.indexOf(seriesName) < 0);
|
|
186
|
-
|
|
187
153
|
for (var _i = 0; _i < inactiveSeriesNames.length; _i += 1) {
|
|
188
154
|
var seriesName = inactiveSeriesNames[_i];
|
|
189
155
|
this.seriesDataMap.delete(seriesName);
|
|
190
156
|
}
|
|
191
|
-
|
|
192
157
|
this.seriesToProcess = new Set([...this.seriesDataMap.keys()]);
|
|
193
158
|
}
|
|
159
|
+
|
|
194
160
|
/**
|
|
195
161
|
* Add a series to the model
|
|
196
162
|
* @param series Series object to add
|
|
197
163
|
* @param axes All the axis in this figure
|
|
198
164
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
165
|
addSeries(series, axes) {
|
|
202
166
|
var axisTypeMap = ChartUtils.groupArray(axes, 'type');
|
|
203
167
|
var seriesData = ChartUtils.makeSeriesDataFromSeries(series, axisTypeMap, ChartUtils.getSeriesVisibility(series.name, this.settings), this.theme);
|
|
204
168
|
this.seriesDataMap.set(series.name, seriesData);
|
|
205
169
|
this.data = [...this.seriesDataMap.values()];
|
|
206
|
-
|
|
207
170
|
if (series.plotStyle === dh.plot.SeriesPlotStyle.STACKED_BAR) {
|
|
208
171
|
this.layout.barmode = 'stack';
|
|
209
172
|
} else if (series.plotStyle === dh.plot.SeriesPlotStyle.PIE) {
|
|
210
173
|
this.layout.hiddenlabels = ChartUtils.getHiddenLabels(this.settings);
|
|
211
174
|
}
|
|
212
|
-
|
|
213
175
|
this.layout.showlegend = this.data.length > 1 || series.plotStyle === dh.plot.SeriesPlotStyle.PIE;
|
|
214
|
-
|
|
215
176
|
if (series.oneClick != null) {
|
|
216
177
|
var {
|
|
217
178
|
oneClick
|
|
@@ -219,50 +180,41 @@ class FigureChartModel extends ChartModel {
|
|
|
219
180
|
var {
|
|
220
181
|
columns
|
|
221
182
|
} = oneClick;
|
|
222
|
-
|
|
223
183
|
for (var i = 0; i < columns.length; i += 1) {
|
|
224
184
|
this.filterColumnMap.set(columns[i].name, columns[i]);
|
|
225
185
|
}
|
|
226
|
-
|
|
227
186
|
this.oneClicks.push(oneClick);
|
|
228
187
|
}
|
|
229
|
-
|
|
230
188
|
this.updateLayoutFormats();
|
|
231
|
-
}
|
|
232
|
-
// This should no longer be necessary after IDS-5049 lands
|
|
189
|
+
}
|
|
233
190
|
|
|
191
|
+
// We need to debounce adding series so we subscribe to them all in the same tick
|
|
192
|
+
// This should no longer be necessary after IDS-5049 lands
|
|
234
193
|
|
|
235
194
|
subscribe(callback) {
|
|
236
195
|
super.subscribe(callback);
|
|
237
|
-
|
|
238
196
|
if (this.listeners.length === 1) {
|
|
239
197
|
// Need to initialize the series here as we may have missed some series when not subscribed
|
|
240
198
|
this.initAllSeries();
|
|
241
199
|
this.subscribeFigure();
|
|
242
200
|
}
|
|
243
201
|
}
|
|
244
|
-
|
|
245
202
|
unsubscribe(callback) {
|
|
246
203
|
super.unsubscribe(callback);
|
|
247
|
-
|
|
248
204
|
if (this.listeners.length === 0) {
|
|
249
205
|
this.unsubscribeFigure();
|
|
250
206
|
}
|
|
251
207
|
}
|
|
252
|
-
|
|
253
208
|
subscribeFigure() {
|
|
254
209
|
if (!this.isConnected) {
|
|
255
210
|
log.debug('Ignoring subscribe when figure in disconnected state');
|
|
256
211
|
return;
|
|
257
212
|
}
|
|
258
|
-
|
|
259
213
|
this.figure.subscribe(this.isDownsamplingDisabled ? dh.plot.DownsampleOptions.DISABLE : dh.plot.DownsampleOptions.DEFAULT);
|
|
260
214
|
}
|
|
261
|
-
|
|
262
215
|
unsubscribeFigure() {
|
|
263
216
|
this.figure.unsubscribe();
|
|
264
217
|
}
|
|
265
|
-
|
|
266
218
|
startListeningFigure() {
|
|
267
219
|
this.figure.addEventListener(dh.plot.Figure.EVENT_UPDATED, this.handleFigureUpdated);
|
|
268
220
|
this.figure.addEventListener(dh.plot.Figure.EVENT_SERIES_ADDED, this.handleFigureSeriesAdded);
|
|
@@ -274,7 +226,6 @@ class FigureChartModel extends ChartModel {
|
|
|
274
226
|
this.figure.addEventListener(dh.plot.Figure.EVENT_DOWNSAMPLENEEDED, this.handleDownsampleNeeded);
|
|
275
227
|
this.figure.addEventListener(dh.Client.EVENT_REQUEST_FAILED, this.handleRequestFailed);
|
|
276
228
|
}
|
|
277
|
-
|
|
278
229
|
stopListeningFigure() {
|
|
279
230
|
this.figure.removeEventListener(dh.plot.Figure.EVENT_UPDATED, this.handleFigureUpdated);
|
|
280
231
|
this.figure.removeEventListener(dh.plot.Figure.EVENT_SERIES_ADDED, this.handleFigureSeriesAdded);
|
|
@@ -286,27 +237,22 @@ class FigureChartModel extends ChartModel {
|
|
|
286
237
|
this.figure.removeEventListener(dh.plot.Figure.EVENT_DOWNSAMPLENEEDED, this.handleDownsampleNeeded);
|
|
287
238
|
this.figure.removeEventListener(dh.Client.EVENT_REQUEST_FAILED, this.handleRequestFailed);
|
|
288
239
|
}
|
|
289
|
-
|
|
290
240
|
handleDownsampleStart(event) {
|
|
291
241
|
log.debug('Downsample started', event);
|
|
292
242
|
this.fireDownsampleStart(event.detail);
|
|
293
243
|
}
|
|
294
|
-
|
|
295
244
|
handleDownsampleFinish(event) {
|
|
296
245
|
log.debug('Downsample finished', event);
|
|
297
246
|
this.fireDownsampleFinish(event.detail);
|
|
298
247
|
}
|
|
299
|
-
|
|
300
248
|
handleDownsampleFail(event) {
|
|
301
249
|
log.error('Downsample failed', event);
|
|
302
250
|
this.fireDownsampleFail(event.detail);
|
|
303
251
|
}
|
|
304
|
-
|
|
305
252
|
handleDownsampleNeeded(event) {
|
|
306
253
|
log.info('Downsample needed', event);
|
|
307
254
|
this.fireDownsampleNeeded(event.detail);
|
|
308
255
|
}
|
|
309
|
-
|
|
310
256
|
handleFigureUpdated(event) {
|
|
311
257
|
var {
|
|
312
258
|
detail: figureUpdateEvent
|
|
@@ -315,14 +261,12 @@ class FigureChartModel extends ChartModel {
|
|
|
315
261
|
series: seriesArray
|
|
316
262
|
} = figureUpdateEvent;
|
|
317
263
|
log.debug2('handleFigureUpdated', seriesArray);
|
|
318
|
-
|
|
319
264
|
for (var i = 0; i < seriesArray.length; i += 1) {
|
|
320
265
|
var series = seriesArray[i];
|
|
321
266
|
log.debug2('handleFigureUpdated updating series', series.name);
|
|
322
267
|
var {
|
|
323
268
|
sources
|
|
324
269
|
} = series;
|
|
325
|
-
|
|
326
270
|
for (var j = 0; j < sources.length; j += 1) {
|
|
327
271
|
var source = sources[j];
|
|
328
272
|
var {
|
|
@@ -333,73 +277,61 @@ class FigureChartModel extends ChartModel {
|
|
|
333
277
|
var dataArray = figureUpdateEvent.getArray(series, type, valueTranslator);
|
|
334
278
|
this.setDataArrayForSeries(series, type, dataArray);
|
|
335
279
|
}
|
|
336
|
-
|
|
337
280
|
this.seriesToProcess.delete(series.name);
|
|
338
|
-
|
|
339
281
|
if (this.seriesToProcess.size === 0) {
|
|
340
282
|
this.fireLoadFinished();
|
|
341
283
|
}
|
|
342
|
-
|
|
343
284
|
this.cleanSeries(series);
|
|
344
285
|
}
|
|
345
|
-
|
|
346
286
|
var {
|
|
347
287
|
data
|
|
348
288
|
} = this;
|
|
349
289
|
this.fireUpdate(data);
|
|
350
290
|
}
|
|
351
|
-
|
|
352
291
|
handleRequestFailed(event) {
|
|
353
292
|
log.error('Request failed', event);
|
|
354
293
|
}
|
|
294
|
+
|
|
355
295
|
/**
|
|
356
296
|
* Resubscribe to the figure, should be done if settings change
|
|
357
297
|
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
298
|
resubscribe() {
|
|
361
299
|
if (this.listeners.length > 0) {
|
|
362
300
|
this.unsubscribeFigure();
|
|
363
301
|
this.subscribeFigure();
|
|
364
302
|
}
|
|
365
303
|
}
|
|
366
|
-
|
|
367
304
|
setFormatter(formatter) {
|
|
368
305
|
super.setFormatter(formatter);
|
|
369
|
-
this.updateLayoutFormats();
|
|
370
|
-
// Data may need to be translated again because of the new formatter
|
|
306
|
+
this.updateLayoutFormats();
|
|
371
307
|
|
|
308
|
+
// Unsubscribe and resubscribe to trigger a data update
|
|
309
|
+
// Data may need to be translated again because of the new formatter
|
|
372
310
|
this.resubscribe();
|
|
373
311
|
}
|
|
374
|
-
|
|
375
312
|
setDownsamplingDisabled(isDownsamplingDisabled) {
|
|
376
313
|
super.setDownsamplingDisabled(isDownsamplingDisabled);
|
|
377
314
|
this.resubscribe();
|
|
378
315
|
}
|
|
379
|
-
|
|
380
316
|
handleFigureDisconnected(event) {
|
|
381
317
|
log.debug('Figure disconnected', event);
|
|
382
318
|
this.isConnected = false;
|
|
383
|
-
|
|
384
319
|
if (this.listeners.length > 0) {
|
|
385
320
|
this.unsubscribeFigure();
|
|
386
321
|
}
|
|
387
|
-
|
|
388
322
|
this.fireDisconnect();
|
|
389
323
|
}
|
|
390
|
-
|
|
391
324
|
handleFigureReconnected(event) {
|
|
392
325
|
log.debug('Figure reconnected', event);
|
|
393
|
-
this.isConnected = true;
|
|
326
|
+
this.isConnected = true;
|
|
394
327
|
|
|
328
|
+
// It's possible the series have changed completely, as the query could have been changed
|
|
395
329
|
this.initAllSeries();
|
|
396
330
|
this.fireReconnect();
|
|
397
|
-
|
|
398
331
|
if (this.listeners.length > 0) {
|
|
399
332
|
this.subscribeFigure();
|
|
400
333
|
}
|
|
401
334
|
}
|
|
402
|
-
|
|
403
335
|
handleFigureSeriesAdded(event) {
|
|
404
336
|
var {
|
|
405
337
|
detail: series
|
|
@@ -408,21 +340,18 @@ class FigureChartModel extends ChartModel {
|
|
|
408
340
|
this.pendingSeries.push(series);
|
|
409
341
|
this.addPendingSeries();
|
|
410
342
|
}
|
|
411
|
-
|
|
412
343
|
setDimensions(rect) {
|
|
413
344
|
super.setDimensions(rect);
|
|
414
345
|
this.updateAxisPositions();
|
|
415
346
|
}
|
|
416
|
-
|
|
417
347
|
setTitle(title) {
|
|
418
348
|
var _match$length, _match;
|
|
349
|
+
super.setTitle(title);
|
|
419
350
|
|
|
420
|
-
|
|
351
|
+
// Need to recalculate the padding based on how many lines of text the title is
|
|
421
352
|
// Plotly doesn't handle positioning it correctly, and it's an undocumented feature
|
|
422
|
-
|
|
423
353
|
var subtitleCount = (_match$length = (_match = (title !== null && title !== void 0 ? title : '').match(/<br>/g)) === null || _match === void 0 ? void 0 : _match.length) !== null && _match$length !== void 0 ? _match$length : 0;
|
|
424
354
|
var margin = ChartUtils.DEFAULT_MARGIN.t + subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT;
|
|
425
|
-
|
|
426
355
|
if (this.layout.margin) {
|
|
427
356
|
this.layout.margin.t = margin;
|
|
428
357
|
} else {
|
|
@@ -430,7 +359,6 @@ class FigureChartModel extends ChartModel {
|
|
|
430
359
|
t: margin
|
|
431
360
|
};
|
|
432
361
|
}
|
|
433
|
-
|
|
434
362
|
if (typeof this.layout.title === 'string') {
|
|
435
363
|
this.layout.title = title;
|
|
436
364
|
} else {
|
|
@@ -440,47 +368,37 @@ class FigureChartModel extends ChartModel {
|
|
|
440
368
|
this.layout.title.pad.t = ChartUtils.DEFAULT_TITLE_PADDING.t + subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT * 0.5;
|
|
441
369
|
}
|
|
442
370
|
}
|
|
443
|
-
|
|
444
371
|
getPlotWidth() {
|
|
445
372
|
var _this$layout$margin$l, _this$layout$margin, _this$layout$margin$r, _this$layout$margin2;
|
|
446
|
-
|
|
447
373
|
if (!this.rect || !this.rect.width) {
|
|
448
374
|
return 0;
|
|
449
375
|
}
|
|
450
|
-
|
|
451
376
|
return Math.max(this.rect.width - ((_this$layout$margin$l = (_this$layout$margin = this.layout.margin) === null || _this$layout$margin === void 0 ? void 0 : _this$layout$margin.l) !== null && _this$layout$margin$l !== void 0 ? _this$layout$margin$l : 0) - ((_this$layout$margin$r = (_this$layout$margin2 = this.layout.margin) === null || _this$layout$margin2 === void 0 ? void 0 : _this$layout$margin2.r) !== null && _this$layout$margin$r !== void 0 ? _this$layout$margin$r : 0), 0);
|
|
452
377
|
}
|
|
453
|
-
|
|
454
378
|
getPlotHeight() {
|
|
455
379
|
var _this$layout$margin$t, _this$layout$margin3, _this$layout$margin$b, _this$layout$margin4;
|
|
456
|
-
|
|
457
380
|
if (!this.rect || !this.rect.height) {
|
|
458
381
|
return 0;
|
|
459
382
|
}
|
|
460
|
-
|
|
461
383
|
return Math.max(this.rect.height - ((_this$layout$margin$t = (_this$layout$margin3 = this.layout.margin) === null || _this$layout$margin3 === void 0 ? void 0 : _this$layout$margin3.t) !== null && _this$layout$margin$t !== void 0 ? _this$layout$margin$t : 0) - ((_this$layout$margin$b = (_this$layout$margin4 = this.layout.margin) === null || _this$layout$margin4 === void 0 ? void 0 : _this$layout$margin4.b) !== null && _this$layout$margin$b !== void 0 ? _this$layout$margin$b : 0), 0);
|
|
462
384
|
}
|
|
463
|
-
|
|
464
385
|
updateAxisPositions() {
|
|
465
386
|
var plotWidth = this.getPlotWidth();
|
|
466
387
|
var plotHeight = this.getPlotHeight();
|
|
467
388
|
ChartUtils.updateFigureAxes(this.layout, this.figure, chart => this.getAxisRangeParser(chart, this.formatter), plotWidth, plotHeight, this.theme);
|
|
468
389
|
}
|
|
390
|
+
|
|
469
391
|
/**
|
|
470
392
|
* Updates the format patterns used
|
|
471
393
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
474
394
|
updateLayoutFormats() {
|
|
475
395
|
if (!this.formatter) {
|
|
476
396
|
return;
|
|
477
397
|
}
|
|
478
|
-
|
|
479
398
|
var axisFormats = ChartUtils.getAxisFormats(this.figure, this.formatter);
|
|
480
399
|
axisFormats.forEach((axisFormat, axisLayoutProperty) => {
|
|
481
400
|
log.debug("Assigning ".concat(axisLayoutProperty), this.layout[axisLayoutProperty], axisFormat);
|
|
482
401
|
var props = this.layout[axisLayoutProperty];
|
|
483
|
-
|
|
484
402
|
if (props != null) {
|
|
485
403
|
Object.assign(props, axisFormat);
|
|
486
404
|
} else {
|
|
@@ -488,14 +406,13 @@ class FigureChartModel extends ChartModel {
|
|
|
488
406
|
}
|
|
489
407
|
});
|
|
490
408
|
}
|
|
409
|
+
|
|
491
410
|
/**
|
|
492
411
|
* Set a specific array for the array of series properties specified.
|
|
493
412
|
* @param series The series to set the data array for.
|
|
494
413
|
* @param sourceType The source type within that series to set the data for.
|
|
495
414
|
* @param dataArray The array to use for the data for this series source.
|
|
496
415
|
*/
|
|
497
|
-
|
|
498
|
-
|
|
499
416
|
setDataArrayForSeries(series, sourceType, dataArray) {
|
|
500
417
|
var {
|
|
501
418
|
name,
|
|
@@ -503,43 +420,36 @@ class FigureChartModel extends ChartModel {
|
|
|
503
420
|
} = series;
|
|
504
421
|
var seriesData = this.seriesDataMap.get(name);
|
|
505
422
|
var property = ChartUtils.getPlotlyProperty(plotStyle, sourceType);
|
|
506
|
-
|
|
507
423
|
if (seriesData) {
|
|
508
424
|
set(seriesData, property, dataArray);
|
|
509
425
|
}
|
|
510
426
|
}
|
|
427
|
+
|
|
511
428
|
/**
|
|
512
429
|
* After setting all the data in the series data, we may need to adjust some other properties
|
|
513
430
|
* Eg. Calculating the width from the xLow/xHigh values; Plot.ly uses `width` instead of a low/high
|
|
514
431
|
* value for x.
|
|
515
432
|
* @param series The series to clean the data for
|
|
516
433
|
*/
|
|
517
|
-
|
|
518
|
-
|
|
519
434
|
cleanSeries(series) {
|
|
520
435
|
var {
|
|
521
436
|
name,
|
|
522
437
|
plotStyle
|
|
523
438
|
} = series;
|
|
524
439
|
var seriesData = this.seriesDataMap.get(name);
|
|
525
|
-
|
|
526
440
|
if (seriesData == null) {
|
|
527
441
|
return;
|
|
528
442
|
}
|
|
529
|
-
|
|
530
443
|
if (plotStyle === dh.plot.SeriesPlotStyle.HISTOGRAM) {
|
|
531
444
|
var {
|
|
532
445
|
xLow,
|
|
533
446
|
xHigh
|
|
534
447
|
} = seriesData;
|
|
535
|
-
|
|
536
448
|
if (xLow && xHigh && xLow.length === xHigh.length) {
|
|
537
449
|
var width = [];
|
|
538
|
-
|
|
539
450
|
for (var i = 0; i < xLow.length; i += 1) {
|
|
540
451
|
width.push(xHigh[i] - xLow[i]);
|
|
541
452
|
}
|
|
542
|
-
|
|
543
453
|
seriesData.width = width;
|
|
544
454
|
}
|
|
545
455
|
} else if (plotStyle === dh.plot.SeriesPlotStyle.LINE) {
|
|
@@ -551,11 +461,9 @@ class FigureChartModel extends ChartModel {
|
|
|
551
461
|
yLow,
|
|
552
462
|
yHigh
|
|
553
463
|
} = seriesData;
|
|
554
|
-
|
|
555
464
|
if (_xLow && _xHigh && _xLow !== x) {
|
|
556
465
|
seriesData.error_x = ChartUtils.getPlotlyErrorBars(x, _xLow, _xHigh);
|
|
557
466
|
}
|
|
558
|
-
|
|
559
467
|
if (yLow && yHigh && yLow !== y) {
|
|
560
468
|
seriesData.error_y = ChartUtils.getPlotlyErrorBars(y, yLow, yHigh);
|
|
561
469
|
}
|
|
@@ -564,7 +472,6 @@ class FigureChartModel extends ChartModel {
|
|
|
564
472
|
ids,
|
|
565
473
|
labels
|
|
566
474
|
} = seriesData;
|
|
567
|
-
|
|
568
475
|
if (ids !== undefined && labels === undefined) {
|
|
569
476
|
// If the user only provided IDs, we assign the IDs to the labels property as well automatically
|
|
570
477
|
// Plotly uses the labels primarily, which from our API perspective seems kind of backwards
|
|
@@ -572,61 +479,49 @@ class FigureChartModel extends ChartModel {
|
|
|
572
479
|
}
|
|
573
480
|
}
|
|
574
481
|
}
|
|
575
|
-
|
|
576
482
|
getData() {
|
|
577
483
|
return this.data;
|
|
578
484
|
}
|
|
579
|
-
|
|
580
485
|
getLayout() {
|
|
581
486
|
return this.layout;
|
|
582
487
|
}
|
|
583
|
-
|
|
584
488
|
getFilterColumnMap() {
|
|
585
489
|
return new Map(this.filterColumnMap);
|
|
586
490
|
}
|
|
587
|
-
|
|
588
491
|
isFilterRequired() {
|
|
589
492
|
return this.oneClicks.find(oneClick => oneClick.requireAllFiltersToDisplay) != null;
|
|
590
493
|
}
|
|
494
|
+
|
|
591
495
|
/**
|
|
592
496
|
* Sets the filter on the model. Will only set the values that have changed.
|
|
593
497
|
* @param filterMap Map of filter column names to values
|
|
594
498
|
*/
|
|
595
|
-
|
|
596
|
-
|
|
597
499
|
setFilter(filterMap) {
|
|
598
500
|
var _this = this;
|
|
599
|
-
|
|
600
501
|
if (this.oneClicks.length === 0) {
|
|
601
502
|
log.warn('Trying to set a filter, but no one click!');
|
|
602
503
|
return;
|
|
603
504
|
}
|
|
604
|
-
|
|
605
505
|
log.debug('setFilter', filterMap);
|
|
606
|
-
|
|
607
506
|
var _loop = function _loop(i) {
|
|
608
507
|
var oneClick = _this.oneClicks[i];
|
|
609
508
|
var {
|
|
610
509
|
columns
|
|
611
|
-
} = oneClick;
|
|
612
|
-
|
|
510
|
+
} = oneClick;
|
|
511
|
+
// Need to get all the keys in case a filter was removed
|
|
613
512
|
var keys = new Set([...filterMap.keys(), ..._this.lastFilter.keys()]);
|
|
614
513
|
keys.forEach(key => {
|
|
615
514
|
var value = filterMap.get(key);
|
|
616
|
-
|
|
617
515
|
if (_this.lastFilter.get(key) !== value && columns.find(column => column.name === key) != null) {
|
|
618
516
|
oneClick.setValueForColumn(key, value);
|
|
619
517
|
}
|
|
620
518
|
});
|
|
621
519
|
};
|
|
622
|
-
|
|
623
520
|
for (var i = 0; i < this.oneClicks.length; i += 1) {
|
|
624
521
|
_loop(i);
|
|
625
522
|
}
|
|
626
|
-
|
|
627
523
|
this.lastFilter = new Map(filterMap);
|
|
628
524
|
}
|
|
629
|
-
|
|
630
525
|
setFigure(figure) {
|
|
631
526
|
this.close();
|
|
632
527
|
this.figure = figure;
|
|
@@ -634,19 +529,14 @@ class FigureChartModel extends ChartModel {
|
|
|
634
529
|
this.initAllSeries();
|
|
635
530
|
this.updateAxisPositions();
|
|
636
531
|
this.startListeningFigure();
|
|
637
|
-
|
|
638
532
|
if (this.listeners.length > 0) {
|
|
639
533
|
this.subscribeFigure();
|
|
640
534
|
}
|
|
641
535
|
}
|
|
642
|
-
|
|
643
536
|
updateSettings(settings) {
|
|
644
537
|
this.settings = settings;
|
|
645
538
|
}
|
|
646
|
-
|
|
647
539
|
}
|
|
648
|
-
|
|
649
540
|
_defineProperty(FigureChartModel, "ADD_SERIES_DEBOUNCE", 50);
|
|
650
|
-
|
|
651
541
|
export default FigureChartModel;
|
|
652
542
|
//# sourceMappingURL=FigureChartModel.js.map
|