@deephaven/chart 0.15.5 → 0.15.6-vite.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.
@@ -1,124 +1,80 @@
1
- export default FigureChartModel;
1
+ import memoize from 'memoizee';
2
+ import { Axis, Chart, Figure, OneClick, Series, SourceType } from '@deephaven/jsapi-shim';
3
+ import { Range } from '@deephaven/utils';
4
+ import { Layout, PlotData } from 'plotly.js';
5
+ import { Formatter } from '@deephaven/jsapi-utils';
6
+ import ChartModel, { ChartEvent, FilterColumnMap } from './ChartModel';
7
+ import { ChartModelSettings } from './ChartUtils';
8
+ import ChartTheme from './ChartTheme';
2
9
  /**
3
10
  * Takes a Figure object from a widget to make a model for a chart
4
11
  */
5
12
  declare class FigureChartModel extends ChartModel {
6
13
  static ADD_SERIES_DEBOUNCE: number;
7
14
  /**
8
- * @param {dh.plot.Figure} figure The figure object created by the API
9
- * @param {Object} settings Chart settings
15
+ * @param figure The figure object created by the API
16
+ * @param settings Chart settings
10
17
  */
11
- constructor(figure: dh.plot.Figure, settings?: Object, theme?: {});
12
- handleFigureUpdated(event: any): void;
13
- handleFigureDisconnected(event: any): void;
14
- handleFigureReconnected(event: any): void;
15
- handleFigureSeriesAdded(event: any): void;
16
- handleDownsampleStart(event: any): void;
17
- handleDownsampleFinish(event: any): void;
18
- handleDownsampleFail(event: any): void;
19
- handleDownsampleNeeded(event: any): void;
20
- handleRequestFailed(event: any): void;
21
- addPendingSeries(): void;
22
- figure: dh.plot.Figure;
23
- settings: Object;
24
- theme: {};
25
- data: any[];
26
- layout: {
27
- autosize: boolean;
28
- colorway: string[];
29
- font: {
30
- family: string;
31
- };
32
- title: {
33
- font: {
34
- color: any;
35
- };
36
- yanchor: string;
37
- pad: {
38
- t: number;
39
- };
40
- y: number;
41
- };
42
- legend: {
43
- font: {
44
- color: any;
45
- };
46
- };
47
- margin: {
48
- l: number;
49
- r: number;
50
- t: number;
51
- b: number;
52
- pad: number;
53
- };
54
- xaxis: {
55
- automargin: boolean;
56
- gridcolor: any;
57
- linecolor: any;
58
- rangeslider: {
59
- visible: boolean;
60
- };
61
- showline: boolean;
62
- ticklen: number;
63
- tickcolor: any;
64
- tickfont: {
65
- color: any;
66
- };
67
- title: {
68
- font: {
69
- color: any;
70
- };
71
- };
72
- };
73
- yaxis: {
74
- automargin: boolean;
75
- gridcolor: any;
76
- linecolor: any;
77
- rangeslider: {
78
- visible: boolean;
79
- };
80
- showline: boolean;
81
- ticklen: number;
82
- tickcolor: any;
83
- tickfont: {
84
- color: any;
85
- };
86
- title: {
87
- font: {
88
- color: any;
89
- };
90
- };
91
- };
92
- };
93
- seriesDataMap: Map<any, any>;
94
- pendingSeries: any[];
95
- oneClicks: any[];
96
- filterColumnMap: Map<any, any>;
97
- lastFilter: Map<any, any>;
18
+ constructor(figure: Figure, settings?: Partial<ChartModelSettings>, theme?: typeof ChartTheme);
19
+ figure: Figure;
20
+ settings: Partial<ChartModelSettings>;
21
+ theme: typeof ChartTheme;
22
+ data: Partial<PlotData>[];
23
+ layout: Partial<Layout>;
24
+ seriesDataMap: Map<string, Partial<PlotData> & {
25
+ xLow?: number[];
26
+ xHigh?: number[];
27
+ yLow?: number[];
28
+ yHigh?: number[];
29
+ }>;
30
+ pendingSeries: Series[];
31
+ oneClicks: OneClick[];
32
+ filterColumnMap: FilterColumnMap;
33
+ lastFilter: Map<string, string>;
98
34
  isConnected: boolean;
99
- seriesToProcess: Set<any>;
35
+ seriesToProcess: Set<unknown>;
36
+ close(): void;
37
+ getDefaultTitle(): string;
100
38
  initAllSeries(): void;
101
- addSeries(series: any): void;
39
+ addSeries(series: Series): void;
40
+ addPendingSeries: import("lodash").DebouncedFunc<() => void>;
41
+ subscribe(callback: (event: ChartEvent) => void): void;
42
+ unsubscribe(callback: (event: ChartEvent) => void): void;
102
43
  subscribeFigure(): void;
103
44
  unsubscribeFigure(): void;
104
45
  startListeningFigure(): void;
105
46
  stopListeningFigure(): void;
106
47
  getTimeZone: ((columnType: any, formatter: any) => any) & memoize.Memoized<(columnType: any, formatter: any) => any>;
107
- getValueTranslator: ((columnType: any, formatter: any) => (value: any) => any) & memoize.Memoized<(columnType: any, formatter: any) => (value: any) => any>;
48
+ getValueTranslator: ((columnType: any, formatter: any) => (value: unknown) => unknown) & memoize.Memoized<(columnType: any, formatter: any) => (value: unknown) => unknown>;
108
49
  /** Gets the parser for a value with the provided column type */
109
- getValueParser: ((columnType: any, formatter: any) => (value: any) => any) & memoize.Memoized<(columnType: any, formatter: any) => (value: any) => any>;
50
+ getValueParser: ((columnType: any, formatter: any) => (value: unknown) => unknown) & memoize.Memoized<(columnType: any, formatter: any) => (value: unknown) => unknown>;
110
51
  /**
111
52
  * Gets the range parser for a particular column type
112
53
  */
113
- getRangeParser: ((columnType: any, formatter: any) => (range: any) => any[]) & memoize.Memoized<(columnType: any, formatter: any) => (range: any) => any[]>;
54
+ getRangeParser: ((columnType: string, formatter?: Formatter | undefined) => (range: Range) => unknown[]) & memoize.Memoized<(columnType: string, formatter?: Formatter | undefined) => (range: Range) => unknown[]>;
114
55
  /**
115
56
  * Gets the parser for parsing the range from an axis within the given chart
116
57
  */
117
- getAxisRangeParser: ((chart: any, formatter: any) => (axis: any) => (range: any) => any) & memoize.Memoized<(chart: any, formatter: any) => (axis: any) => (range: any) => any>;
58
+ getAxisRangeParser: ((chart: Chart, formatter?: Formatter | undefined) => (axis: Axis) => (range: Range) => unknown[]) & memoize.Memoized<(chart: Chart, formatter?: Formatter | undefined) => (axis: Axis) => (range: Range) => unknown[]>;
59
+ handleDownsampleStart(event: ChartEvent): void;
60
+ handleDownsampleFinish(event: ChartEvent): void;
61
+ handleDownsampleFail(event: ChartEvent): void;
62
+ handleDownsampleNeeded(event: ChartEvent): void;
63
+ handleFigureUpdated(event: ChartEvent): void;
64
+ handleRequestFailed(event: ChartEvent): void;
118
65
  /**
119
66
  * Resubscribe to the figure, should be done if settings change
120
67
  */
121
68
  resubscribe(): void;
69
+ setFormatter(formatter: Formatter): void;
70
+ setDownsamplingDisabled(isDownsamplingDisabled: boolean): void;
71
+ handleFigureDisconnected(event: CustomEvent): void;
72
+ handleFigureReconnected(event: CustomEvent): void;
73
+ handleFigureSeriesAdded(event: {
74
+ detail: Series;
75
+ }): void;
76
+ setDimensions(rect: DOMRect): void;
77
+ setTitle(title: string): void;
122
78
  getPlotWidth(): number;
123
79
  getPlotHeight(): number;
124
80
  updateAxisPositions(): void;
@@ -128,21 +84,29 @@ declare class FigureChartModel extends ChartModel {
128
84
  updateLayoutFormats(): void;
129
85
  /**
130
86
  * Set a specific array for the array of series properties specified.
131
- * @param {dh.Series} series The series to set the data array for.
132
- * @param {dh.plot.SourceType} sourceType The source type within that series to set the data for.
133
- * @param {Any[]} dataArray The array to use for the data for this series source.
87
+ * @param series The series to set the data array for.
88
+ * @param sourceType The source type within that series to set the data for.
89
+ * @param dataArray The array to use for the data for this series source.
134
90
  */
135
- setDataArrayForSeries(series: dh.Series, sourceType: dh.plot.SourceType, dataArray: Any[]): void;
91
+ setDataArrayForSeries(series: Series, sourceType: SourceType, dataArray: unknown[]): void;
136
92
  /**
137
93
  * After setting all the data in the series data, we may need to adjust some other properties
138
94
  * Eg. Calculating the width from the xLow/xHigh values; Plot.ly uses `width` instead of a low/high
139
95
  * value for x.
140
- * @param {dh.Series} series The series to clean the data for
96
+ * @param series The series to clean the data for
97
+ */
98
+ cleanSeries(series: Series): void;
99
+ getData(): Partial<PlotData>[];
100
+ getLayout(): Partial<Layout>;
101
+ getFilterColumnMap(): FilterColumnMap;
102
+ isFilterRequired(): boolean;
103
+ /**
104
+ * Sets the filter on the model. Will only set the values that have changed.
105
+ * @param filterMap Map of filter column names to values
141
106
  */
142
- cleanSeries(series: dh.Series): void;
143
- setFigure(figure: any): void;
144
- updateSettings(settings: any): void;
107
+ setFilter(filterMap: Map<string, string>): void;
108
+ setFigure(figure: Figure): void;
109
+ updateSettings(settings: Partial<ChartModelSettings>): void;
145
110
  }
146
- import ChartModel from "./ChartModel";
147
- import memoize from "memoizee";
111
+ export default FigureChartModel;
148
112
  //# sourceMappingURL=FigureChartModel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FigureChartModel.d.ts","sourceRoot":"","sources":["../src/FigureChartModel.js"],"names":[],"mappings":";AAWA;;GAEG;AACH;IACE,mCAAgC;IAEhC;;;OAGG;IACH,+CAFW,MAAM,cAuChB;IAyRD,sCAqCC;IAgCD,2CAUC;IAED,0CAaC;IAED,0CAOC;IA/HD,wCAIC;IAED,yCAIC;IAED,uCAIC;IAED,yCAIC;IAyCD,sCAEC;IA3OD,yBAWC;IAnHC,uBAAoB;IACpB,iBAAwB;IACxB,UAAkB;IAClB,YAAc;IACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAiD;IACjD,6BAA8B;IAC9B,qBAAuB;IACvB,iBAAmB;IACnB,+BAAgC;IAChC,0BAA2B;IAC3B,qBAAuB;IACvB,0BAAgC;IAuBlC,sBA0BC;IAED,6BAwCC;IAiCD,wBAWC;IAED,0BAEC;IAED,6BAqCC;IAED,4BAqCC;IAED,qHAQG;IAEH,4JAGG;IAEH,gEAAgE;IAChE,wJAGG;IAEH;;OAEG;IACH,4JAMG;IAEH;;OAEG;IACH,gLAOG;IAqEH;;OAEG;IACH,oBAKC;IA2ED,uBASC;IAED,wBASC;IAED,4BAgBC;IAED;;OAEG;IACH,4BAkBC;IAED;;;;;OAKG;IACH,oFAFW,KAAK,QAQf;IAED;;;;;OAKG;IACH,qCA4BC;IAoDD,6BAYC;IAED,oCAEC;CACF"}
1
+ {"version":3,"file":"FigureChartModel.d.ts","sourceRoot":"","sources":["../src/FigureChartModel.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,UAAU,CAAC;AAG/B,OAAW,EACT,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,UAAU,EACX,MAAM,uBAAuB,CAAC;AAE/B,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D,uBAAuB,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAQxD,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAMlC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA4B7B,YAAY,IAAI,MAAM;IAatB,aAAa,IAAI,MAAM;IAavB,mBAAmB,IAAI,IAAI;IAkB3B;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAoB3B;;;;;OAKG;IACH,qBAAqB,CACnB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,OAAO,EAAE,GACnB,IAAI;IAWP;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAyCjC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE;IAI9B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,kBAAkB,IAAI,eAAe;IAIrC,gBAAgB,IAAI,OAAO;IAO3B;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IA2B/C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAc/B,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI;CAG5D;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,3 +1,7 @@
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
+ 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
+
1
5
  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; }
2
6
 
3
7
  /* eslint class-methods-use-this: "off" */
@@ -8,6 +12,7 @@ import dh from '@deephaven/jsapi-shim';
8
12
  import Log from '@deephaven/log';
9
13
  import ChartModel from "./ChartModel.js";
10
14
  import ChartUtils from "./ChartUtils.js";
15
+ import ChartTheme from "./ChartTheme.js";
11
16
  var log = Log.module('FigureChartModel');
12
17
  /**
13
18
  * Takes a Figure object from a widget to make a model for a chart
@@ -15,14 +20,52 @@ var log = Log.module('FigureChartModel');
15
20
 
16
21
  class FigureChartModel extends ChartModel {
17
22
  /**
18
- * @param {dh.plot.Figure} figure The figure object created by the API
19
- * @param {Object} settings Chart settings
23
+ * @param figure The figure object created by the API
24
+ * @param settings Chart settings
20
25
  */
21
26
  constructor(figure) {
22
27
  var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23
- var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
28
+ var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChartTheme;
24
29
  super();
25
30
 
31
+ _defineProperty(this, "figure", void 0);
32
+
33
+ _defineProperty(this, "settings", void 0);
34
+
35
+ _defineProperty(this, "theme", void 0);
36
+
37
+ _defineProperty(this, "data", void 0);
38
+
39
+ _defineProperty(this, "layout", void 0);
40
+
41
+ _defineProperty(this, "seriesDataMap", void 0);
42
+
43
+ _defineProperty(this, "pendingSeries", void 0);
44
+
45
+ _defineProperty(this, "oneClicks", void 0);
46
+
47
+ _defineProperty(this, "filterColumnMap", void 0);
48
+
49
+ _defineProperty(this, "lastFilter", void 0);
50
+
51
+ _defineProperty(this, "isConnected", void 0);
52
+
53
+ _defineProperty(this, "seriesToProcess", void 0);
54
+
55
+ _defineProperty(this, "addPendingSeries", debounce(() => {
56
+ var {
57
+ pendingSeries
58
+ } = this;
59
+
60
+ for (var i = 0; i < pendingSeries.length; i += 1) {
61
+ var series = pendingSeries[i];
62
+ this.addSeries(series);
63
+ series.subscribe(); // We'll get an update with the data after subscribing
64
+ }
65
+
66
+ this.pendingSeries = [];
67
+ }, FigureChartModel.ADD_SERIES_DEBOUNCE));
68
+
26
69
  _defineProperty(this, "getTimeZone", memoize((columnType, formatter) => {
27
70
  if (formatter != null) {
28
71
  var dataFormatter = formatter.getColumnTypeFormatter(columnType);
@@ -74,7 +117,6 @@ class FigureChartModel extends ChartModel {
74
117
  this.handleRequestFailed = this.handleRequestFailed.bind(this); // We need to debounce adding series so we subscribe to them all in the same tick
75
118
  // This should no longer be necessary after IDS-5049 lands
76
119
 
77
- this.addPendingSeries = debounce(this.addPendingSeries.bind(this), FigureChartModel.ADD_SERIES_DEBOUNCE);
78
120
  this.figure = figure;
79
121
  this.settings = settings;
80
122
  this.theme = theme;
@@ -131,7 +173,7 @@ class FigureChartModel extends ChartModel {
131
173
  var allSeriesNames = [...this.seriesDataMap.keys()];
132
174
  var inactiveSeriesNames = allSeriesNames.filter(seriesName => activeSeriesNames.indexOf(seriesName) < 0);
133
175
 
134
- for (var _i = 0; _i < inactiveSeriesNames; _i += 1) {
176
+ for (var _i = 0; _i < inactiveSeriesNames.length; _i += 1) {
135
177
  var seriesName = inactiveSeriesNames[_i];
136
178
  this.seriesDataMap.delete(seriesName);
137
179
  }
@@ -178,22 +220,8 @@ class FigureChartModel extends ChartModel {
178
220
  this.updateLayoutFormats();
179
221
  }
180
222
 
181
- addPendingSeries() {
182
- var {
183
- pendingSeries
184
- } = this;
185
-
186
- for (var i = 0; i < pendingSeries.length; i += 1) {
187
- var series = pendingSeries[i];
188
- this.addSeries(series);
189
- series.subscribe(); // We'll get an update with the data after subscribing
190
- }
191
-
192
- this.pendingSeries = [];
193
- }
194
-
195
- subscribe() {
196
- super.subscribe(...arguments);
223
+ subscribe(callback) {
224
+ super.subscribe(callback);
197
225
 
198
226
  if (this.listeners.length === 1) {
199
227
  // Need to initialize the series here as we may have missed some series when not subscribed
@@ -202,8 +230,8 @@ class FigureChartModel extends ChartModel {
202
230
  }
203
231
  }
204
232
 
205
- unsubscribe() {
206
- super.unsubscribe(...arguments);
233
+ unsubscribe(callback) {
234
+ super.unsubscribe(callback);
207
235
 
208
236
  if (this.listeners.length === 0) {
209
237
  this.unsubscribeFigure();
@@ -332,8 +360,8 @@ class FigureChartModel extends ChartModel {
332
360
  this.resubscribe();
333
361
  }
334
362
 
335
- setDownsamplingDisabled() {
336
- super.setDownsamplingDisabled(...arguments);
363
+ setDownsamplingDisabled(isDownsamplingDisabled) {
364
+ super.setDownsamplingDisabled(isDownsamplingDisabled);
337
365
  this.resubscribe();
338
366
  }
339
367
 
@@ -381,25 +409,44 @@ class FigureChartModel extends ChartModel {
381
409
  // Plotly doesn't handle positioning it correctly, and it's an undocumented feature
382
410
 
383
411
  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;
384
- this.layout.margin.t = ChartUtils.DEFAULT_MARGIN.t + subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT;
385
- this.layout.title.text = title;
386
- this.layout.title.pad.t = ChartUtils.DEFAULT_TITLE_PADDING.t + subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT * 0.5;
412
+ var margin = ChartUtils.DEFAULT_MARGIN.t + subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT;
413
+
414
+ if (this.layout.margin) {
415
+ this.layout.margin.t = margin;
416
+ } else {
417
+ this.layout.margin = {
418
+ t: margin
419
+ };
420
+ }
421
+
422
+ if (typeof this.layout.title === 'string') {
423
+ this.layout.title = title;
424
+ } else {
425
+ this.layout.title = _objectSpread({}, this.layout.title);
426
+ this.layout.title.text = title;
427
+ this.layout.title.pad = _objectSpread({}, this.layout.title.pad);
428
+ this.layout.title.pad.t = ChartUtils.DEFAULT_TITLE_PADDING.t + subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT * 0.5;
429
+ }
387
430
  }
388
431
 
389
432
  getPlotWidth() {
433
+ var _this$layout$margin$l, _this$layout$margin, _this$layout$margin$r, _this$layout$margin2;
434
+
390
435
  if (!this.rect || !this.rect.width) {
391
436
  return 0;
392
437
  }
393
438
 
394
- return Math.max(this.rect.width - this.layout.margin.l - this.layout.margin.r, 0);
439
+ 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);
395
440
  }
396
441
 
397
442
  getPlotHeight() {
443
+ var _this$layout$margin$t, _this$layout$margin3, _this$layout$margin$b, _this$layout$margin4;
444
+
398
445
  if (!this.rect || !this.rect.height) {
399
446
  return 0;
400
447
  }
401
448
 
402
- return Math.max(this.rect.height - this.layout.margin.t - this.layout.margin.b, 0);
449
+ 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);
403
450
  }
404
451
 
405
452
  updateAxisPositions() {
@@ -435,9 +482,9 @@ class FigureChartModel extends ChartModel {
435
482
  }
436
483
  /**
437
484
  * Set a specific array for the array of series properties specified.
438
- * @param {dh.Series} series The series to set the data array for.
439
- * @param {dh.plot.SourceType} sourceType The source type within that series to set the data for.
440
- * @param {Any[]} dataArray The array to use for the data for this series source.
485
+ * @param series The series to set the data array for.
486
+ * @param sourceType The source type within that series to set the data for.
487
+ * @param dataArray The array to use for the data for this series source.
441
488
  */
442
489
 
443
490
 
@@ -448,13 +495,16 @@ class FigureChartModel extends ChartModel {
448
495
  } = series;
449
496
  var seriesData = this.seriesDataMap.get(name);
450
497
  var property = ChartUtils.getPlotlyProperty(plotStyle, sourceType);
451
- set(seriesData, property, dataArray);
498
+
499
+ if (seriesData) {
500
+ set(seriesData, property, dataArray);
501
+ }
452
502
  }
453
503
  /**
454
504
  * After setting all the data in the series data, we may need to adjust some other properties
455
505
  * Eg. Calculating the width from the xLow/xHigh values; Plot.ly uses `width` instead of a low/high
456
506
  * value for x.
457
- * @param {dh.Series} series The series to clean the data for
507
+ * @param series The series to clean the data for
458
508
  */
459
509
 
460
510
 
@@ -465,6 +515,10 @@ class FigureChartModel extends ChartModel {
465
515
  } = series;
466
516
  var seriesData = this.seriesDataMap.get(name);
467
517
 
518
+ if (seriesData == null) {
519
+ return;
520
+ }
521
+
468
522
  if (plotStyle === dh.plot.SeriesPlotStyle.HISTOGRAM) {
469
523
  var {
470
524
  xLow,
@@ -528,7 +582,7 @@ class FigureChartModel extends ChartModel {
528
582
  }
529
583
  /**
530
584
  * Sets the filter on the model. Will only set the values that have changed.
531
- * @param {Map<String, String>} filterMap Map of filter column names to values
585
+ * @param filterMap Map of filter column names to values
532
586
  */
533
587
 
534
588