@deephaven/chart 0.5.0 → 0.5.2-lessredux.14

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