@deephaven/chart 0.15.5-vite.12 → 0.15.6-vite.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/Chart.d.ts +84 -85
  2. package/dist/Chart.d.ts.map +1 -1
  3. package/dist/Chart.js +56 -49
  4. package/dist/Chart.js.map +1 -1
  5. package/dist/ChartModel.d.ts +30 -22
  6. package/dist/ChartModel.d.ts.map +1 -1
  7. package/dist/ChartModel.js +18 -9
  8. package/dist/ChartModel.js.map +1 -1
  9. package/dist/ChartModelFactory.d.ts +67 -43
  10. package/dist/ChartModelFactory.d.ts.map +1 -1
  11. package/dist/ChartModelFactory.js +27 -27
  12. package/dist/ChartModelFactory.js.map +1 -1
  13. package/dist/ChartTestUtils.d.ts +16 -15
  14. package/dist/ChartTestUtils.d.ts.map +1 -1
  15. package/dist/ChartTestUtils.js +5 -0
  16. package/dist/ChartTestUtils.js.map +1 -1
  17. package/dist/ChartTheme.d.ts +17 -17
  18. package/dist/ChartTheme.d.ts.map +1 -1
  19. package/dist/ChartTheme.js.map +1 -1
  20. package/dist/ChartUtils.d.ts +252 -225
  21. package/dist/ChartUtils.d.ts.map +1 -1
  22. package/dist/ChartUtils.js +219 -174
  23. package/dist/ChartUtils.js.map +1 -1
  24. package/dist/FigureChartModel.d.ts +70 -106
  25. package/dist/FigureChartModel.d.ts.map +1 -1
  26. package/dist/FigureChartModel.js +90 -36
  27. package/dist/FigureChartModel.js.map +1 -1
  28. package/dist/MockChartModel.d.ts +11 -209
  29. package/dist/MockChartModel.d.ts.map +1 -1
  30. package/dist/declaration.d.js +2 -0
  31. package/dist/declaration.d.js.map +1 -0
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +2 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/isFigureChartModel.d.ts +4 -0
  37. package/dist/isFigureChartModel.d.ts.map +1 -0
  38. package/dist/isFigureChartModel.js +4 -0
  39. package/dist/isFigureChartModel.js.map +1 -0
  40. package/dist/plotly/Plotly.d.ts +1 -0
  41. package/package.json +11 -8
@@ -8,17 +8,35 @@ import Log from '@deephaven/log';
8
8
  import { TableUtils } from '@deephaven/jsapi-utils';
9
9
  import dh from '@deephaven/jsapi-shim';
10
10
  import set from 'lodash.set';
11
+ import { assertNotNull } from '@deephaven/utils';
12
+ import ChartTheme from "./ChartTheme.js";
11
13
  var log = Log.module('ChartUtils');
12
14
  var DAYS = Object.freeze(dh.calendar.DayOfWeek.values());
13
15
  var BUSINESS_COLUMN_TYPE = 'io.deephaven.time.DateTime';
14
16
  var MILLIS_PER_HOUR = 3600000;
15
17
  var NANOS_PER_MILLI = 1000000;
16
18
 
19
+ function isDateWrapper(value) {
20
+ return value.asDate !== undefined;
21
+ }
22
+
23
+ function isLongWrapper(value) {
24
+ return value.asNumber !== undefined;
25
+ }
26
+
27
+ function isDateTimeColumnFormatter(value) {
28
+ return value.dhTimeZone !== undefined;
29
+ }
30
+
31
+ function isRangedPlotlyAxis(value) {
32
+ return value != null && value.range && !value.autorange;
33
+ }
34
+
17
35
  class ChartUtils {
18
36
  /**
19
37
  * Converts the Iris plot style into a plotly chart type
20
- * @param {String} plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle
21
- * @param {boolean} isBusinessTime If the plot is using business time for an axis
38
+ * @param plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle
39
+ * @param isBusinessTime If the plot is using business time for an axis
22
40
  */
23
41
  static getPlotlyChartType(plotStyle, isBusinessTime) {
24
42
  switch (plotStyle) {
@@ -49,12 +67,12 @@ class ChartUtils {
49
67
  return 'ohlc';
50
68
 
51
69
  default:
52
- return null;
70
+ return undefined;
53
71
  }
54
72
  }
55
73
  /**
56
74
  * Converts the Iris plot style into a plotly chart mode
57
- * @param {String} plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle.*
75
+ * @param plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle.*
58
76
  */
59
77
 
60
78
 
@@ -67,13 +85,13 @@ class ChartUtils {
67
85
  return 'lines';
68
86
 
69
87
  default:
70
- return null;
88
+ return undefined;
71
89
  }
72
90
  }
73
91
  /**
74
92
  * Get the property to set on the series data for plotly
75
- * @param {dh.plot.SeriesPlotStyle} plotStyle The plot style of the series
76
- * @param {dh.plot.SourceType} sourceType The source type for the series
93
+ * @param plotStyle The plot style of the series
94
+ * @param sourceType The source type for the series
77
95
  */
78
96
 
79
97
 
@@ -210,11 +228,11 @@ class ChartUtils {
210
228
  /**
211
229
  * Generate the plotly error bar data from the passed in data.
212
230
  * Iris passes in the values as absolute, plotly needs them as relative.
213
- * @param {Array[Number]} x The main data array
214
- * @param {Array[Number]} xLow The absolute low values
215
- * @param {Array[Number]} xHigh
231
+ * @param x The main data array
232
+ * @param xLow The absolute low values
233
+ * @param xHigh
216
234
  *
217
- * @returns {Object} The error_x object required by plotly, or null if none is required
235
+ * @returns The error_x object required by plotly, or null if none is required
218
236
  */
219
237
 
220
238
 
@@ -230,12 +248,12 @@ class ChartUtils {
230
248
  }
231
249
 
232
250
  static getPlotlyDateFormat(formatter, columnType, formatPattern) {
233
- var tickformat = formatPattern == null ? null : formatPattern.replace('%', '%%').replace(/S{9}/g, '%9f').replace(/S{8}/g, '%8f').replace(/S{7}/g, '%7f').replace(/S{6}/g, '%6f').replace(/S{5}/g, '%5f').replace(/S{4}/g, '%4f').replace(/S{3}/g, '%3f').replace(/S{2}/g, '%2f').replace(/S{1}/g, '%1f').replace(/y{4}/g, '%Y').replace(/y{2}/g, '%y').replace(/M{4}/g, '%B').replace(/M{3}/g, '%b').replace(/M{2}/g, '%m').replace(/M{1}/g, '%-m').replace(/E{4,}/g, '%A').replace(/E{1,}/g, '%a').replace(/d{2}/g, '%d').replace(/([^%]|^)d{1}/g, '$1%-d').replace(/H{2}/g, '%H').replace(/h{2}/g, '%I').replace(/h{1}/g, '%-I').replace(/m{2}/g, '%M').replace(/s{2}/g, '%S').replace("'T'", 'T').replace(' z', ''); // timezone added as suffix if necessary
251
+ var tickformat = formatPattern == null ? undefined : formatPattern.replace('%', '%%').replace(/S{9}/g, '%9f').replace(/S{8}/g, '%8f').replace(/S{7}/g, '%7f').replace(/S{6}/g, '%6f').replace(/S{5}/g, '%5f').replace(/S{4}/g, '%4f').replace(/S{3}/g, '%3f').replace(/S{2}/g, '%2f').replace(/S{1}/g, '%1f').replace(/y{4}/g, '%Y').replace(/y{2}/g, '%y').replace(/M{4}/g, '%B').replace(/M{3}/g, '%b').replace(/M{2}/g, '%m').replace(/M{1}/g, '%-m').replace(/E{4,}/g, '%A').replace(/E{1,}/g, '%a').replace(/d{2}/g, '%d').replace(/([^%]|^)d{1}/g, '$1%-d').replace(/H{2}/g, '%H').replace(/h{2}/g, '%I').replace(/h{1}/g, '%-I').replace(/m{2}/g, '%M').replace(/s{2}/g, '%S').replace("'T'", 'T').replace(' z', ''); // timezone added as suffix if necessary
234
252
 
235
- var ticksuffix = null;
236
- var dataFormatter = formatter.getColumnTypeFormatter(columnType);
253
+ var ticksuffix;
254
+ var dataFormatter = formatter === null || formatter === void 0 ? void 0 : formatter.getColumnTypeFormatter(columnType);
237
255
 
238
- if (dataFormatter.dhTimeZone != null && dataFormatter.showTimeZone) {
256
+ if (dataFormatter != null && isDateTimeColumnFormatter(dataFormatter) && dataFormatter.dhTimeZone != null && dataFormatter.showTimeZone) {
239
257
  ticksuffix = dh.i18n.DateTimeFormat.format(' z', new Date(), dataFormatter.dhTimeZone);
240
258
  }
241
259
 
@@ -260,7 +278,9 @@ class ChartUtils {
260
278
 
261
279
 
262
280
  var subpatterns = formatPattern.split(';');
263
- var [, prefix, placeholderDigits, zeroDigits,, decimalDigits, optionalDecimalDigits, numberType, percentSign, suffix] = subpatterns[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);
281
+ var matchArray = subpatterns[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);
282
+ assertNotNull(matchArray);
283
+ var [, prefix, placeholderDigits, zeroDigits,, decimalDigits, optionalDecimalDigits, numberType, percentSign, suffix] = matchArray;
264
284
  var paddingLength = zeroDigits.replace(',', '').length;
265
285
  var isCommaSeparated = placeholderDigits.indexOf(',') >= 0 || zeroDigits.indexOf(',') >= 0;
266
286
  var comma = isCommaSeparated ? ',' : '';
@@ -284,8 +304,8 @@ class ChartUtils {
284
304
  }
285
305
  /**
286
306
  * Gets the plotly axis formatting information from the source passed in
287
- * @param {dh.plot.Source} source The Source to get the formatter information from
288
- * @param {Formatter} formatter The current formatter for formatting data
307
+ * @param source The Source to get the formatter information from
308
+ * @param formatter The current formatter for formatting data
289
309
  */
290
310
 
291
311
 
@@ -314,8 +334,8 @@ class ChartUtils {
314
334
  } else {
315
335
  axisFormat = {
316
336
  type: 'category',
317
- tickformat: null,
318
- ticksuffix: null
337
+ tickformat: undefined,
338
+ ticksuffix: undefined
319
339
  };
320
340
  }
321
341
  }
@@ -325,9 +345,9 @@ class ChartUtils {
325
345
  /**
326
346
  * Adds tick spacing for an axis that has gapBetweenMajorTicks defined.
327
347
  *
328
- * @param {object} axisFormat the current axis format, may be null
329
- * @param {object} axis the current axis
330
- * @param {boolean} isDateType indicates if the columns is a date type
348
+ * @param axisFormat the current axis format, may be null
349
+ * @param axis the current axis
350
+ * @param isDateType indicates if the columns is a date type
331
351
  */
332
352
 
333
353
 
@@ -359,9 +379,9 @@ class ChartUtils {
359
379
  }
360
380
  /**
361
381
  * Retrieve the data source for a given axis in a chart
362
- * @param {dh.plot.Chart} chart The chart to get the source for
363
- * @param {dh.plot.Axis} axis The axis to find the source for
364
- * @returns {dh.plot.Source} The first source matching this axis
382
+ * @param chart The chart to get the source for
383
+ * @param axis The axis to find the source for
384
+ * @returns The first source matching this axis
365
385
  */
366
386
 
367
387
 
@@ -382,9 +402,9 @@ class ChartUtils {
382
402
  }
383
403
  /**
384
404
  * Get visibility setting for the series object
385
- * @param {string} name The series name to get the visibility for
386
- * @param {object} settings Chart settings
387
- * @returns {boolean|string} True for visible series and 'legendonly' for hidden
405
+ * @param name The series name to get the visibility for
406
+ * @param settings Chart settings
407
+ * @returns True for visible series and 'legendonly' for hidden
388
408
  */
389
409
 
390
410
 
@@ -399,8 +419,8 @@ class ChartUtils {
399
419
  }
400
420
  /**
401
421
  * Get hidden labels array from chart settings
402
- * @param {object} settings Chart settings
403
- * @returns {string[]} Array of hidden series names
422
+ * @param settings Chart settings
423
+ * @returns Array of hidden series names
404
424
  */
405
425
 
406
426
 
@@ -413,7 +433,7 @@ class ChartUtils {
413
433
  }
414
434
  /**
415
435
  * Create a default series data object. Apply styling to the object afterward.
416
- * @returns {Object} A simple series data object with no styling
436
+ * @returns A simple series data object with no styling
417
437
  */
418
438
 
419
439
 
@@ -428,15 +448,16 @@ class ChartUtils {
428
448
  }
429
449
  /**
430
450
  * Create a data series (trace) for use with plotly
431
- * @param {dh.plot.Series} series The series to create the series data with
432
- * @param {Map<dh.plot.AxisType, dh.plot.Axis[]>} axisTypeMap The map of axes grouped by type
433
- * @param {boolean|string} seriesVisibility Visibility setting for the series
434
- * @param {Object} theme The theme properties for the plot. See ChartTheme.js for an example
435
- * @returns {Object} The series data (trace) object for use with plotly.
451
+ * @param series The series to create the series data with
452
+ * @param axisTypeMap The map of axes grouped by type
453
+ * @param seriesVisibility Visibility setting for the series
454
+ * @param theme The theme properties for the plot. See ChartTheme.js for an example
455
+ * @returns The series data (trace) object for use with plotly.
436
456
  */
437
457
 
438
458
 
439
- static makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility, theme) {
459
+ static makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility) {
460
+ var theme = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ChartTheme;
440
461
  var {
441
462
  name,
442
463
  plotStyle,
@@ -464,24 +485,27 @@ class ChartUtils {
464
485
  for (var k = 0; k < sources.length; k += 1) {
465
486
  var source = sources[k];
466
487
  var {
467
- axis,
488
+ axis: _axis,
468
489
  type: sourceType
469
490
  } = source;
470
491
  var dataAttributeName = ChartUtils.getPlotlyProperty(plotStyle, sourceType);
471
492
  set(seriesData, dataAttributeName, []);
472
- var axisProperty = axis ? ChartUtils.getAxisPropertyName(axis.type) : null;
493
+ var axisProperty = _axis ? ChartUtils.getAxisPropertyName(_axis.type) : null;
473
494
 
474
495
  if (axisProperty != null) {
475
- var axes = axisTypeMap.get(axis.type);
476
- var axisIndex = axes.indexOf(axis);
477
- var axisIndexString = axisIndex > 0 ? "".concat(axisIndex + 1) : '';
478
- seriesData["".concat(axisProperty, "axis")] = "".concat(axisProperty).concat(axisIndexString);
496
+ var axes = axisTypeMap.get(_axis.type);
497
+
498
+ if (axes) {
499
+ var axisIndex = axes.indexOf(_axis);
500
+ var axisIndexString = axisIndex > 0 ? "".concat(axisIndex + 1) : '';
501
+ seriesData["".concat(axisProperty, "axis")] = "".concat(axisProperty).concat(axisIndexString);
502
+ }
479
503
  }
480
504
  }
481
505
  }
482
506
 
483
507
  static addStylingToSeriesData(seriesDataParam, plotStyle) {
484
- var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
508
+ var theme = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ChartTheme;
485
509
  var lineColor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
486
510
  var shapeColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
487
511
  var seriesVisibility = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
@@ -522,7 +546,10 @@ class ChartUtils {
522
546
  }
523
547
  };
524
548
  } else if (plotStyle === dh.plot.SeriesPlotStyle.PIE) {
525
- seriesData.textinfo = 'label+percent';
549
+ seriesData.textinfo = 'label+percent'; // TODO Open DefinitelyTyped/Plotly PR to mark family and size as optional
550
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/plotly.js/lib/traces/pie.d.ts#L6
551
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
552
+
526
553
  seriesData.outsidetextfont = {
527
554
  color: theme.title_color
528
555
  };
@@ -533,7 +560,11 @@ class ChartUtils {
533
560
  packing: 'squarify',
534
561
  pad: 0
535
562
  };
536
- seriesData.textposition = 'middle center';
563
+ seriesData.textposition = 'middle center'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
564
+
565
+ seriesData.outsidetextfont = {
566
+ color: theme.title_color
567
+ };
537
568
  }
538
569
 
539
570
  if (lineColor != null) {
@@ -557,9 +588,9 @@ class ChartUtils {
557
588
  /**
558
589
  * Retrieve the axis formats from the provided figure.
559
590
  * Currently defaults to just the x/y axes.
560
- * @param {dh.plot.Figure} figure The figure to get the axis formats for
561
- * @param {Formatter} formatter The formatter to use when getting the axis format
562
- * @returns {Map<string, object>} A map of axis layout property names to axis formats
591
+ * @param figure The figure to get the axis formats for
592
+ * @param formatter The formatter to use when getting the axis format
593
+ * @returns A map of axis layout property names to axis formats
563
594
  */
564
595
 
565
596
 
@@ -587,20 +618,22 @@ class ChartUtils {
587
618
  for (var k = 0; k < axisSources.length; k += 1) {
588
619
  var source = axisSources[k];
589
620
  var {
590
- axis
621
+ axis: _axis2
591
622
  } = source;
592
623
  var {
593
624
  type: axisType
594
- } = axis;
625
+ } = _axis2;
595
626
  var typeAxes = axisTypeMap.get(axisType);
596
- var axisIndex = typeAxes.indexOf(axis);
627
+ assertNotNull(typeAxes);
628
+ var axisIndex = typeAxes.indexOf(_axis2);
597
629
  var axisProperty = ChartUtils.getAxisPropertyName(axisType);
598
- var axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, axisIndex);
599
630
 
600
- if (axisFormats.has(axisLayoutProperty)) {
601
- log.debug("".concat(axisLayoutProperty, " already added."));
602
- } else {
603
- var _ret = function () {
631
+ if (axisProperty != null) {
632
+ var axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, axisIndex);
633
+
634
+ if (axisFormats.has(axisLayoutProperty)) {
635
+ log.debug("".concat(axisLayoutProperty, " already added."));
636
+ } else {
604
637
  log.debug("Adding ".concat(axisLayoutProperty, " to axisFormats."));
605
638
  var axisFormat = ChartUtils.getPlotlyAxisFormat(source, formatter);
606
639
 
@@ -610,47 +643,51 @@ class ChartUtils {
610
643
  axisFormats.set(axisLayoutProperty, axisFormat);
611
644
  var {
612
645
  businessCalendar
613
- } = axis;
646
+ } = _axis2;
614
647
 
615
648
  if (businessCalendar) {
616
- var _formatter$getColumnT;
617
-
618
- axisFormat.rangebreaks = [];
619
- var {
620
- businessPeriods,
621
- businessDays,
622
- holidays,
623
- timeZone: calendarTimeZone
624
- } = businessCalendar;
625
- var formatterTimeZone = formatter === null || formatter === void 0 ? void 0 : (_formatter$getColumnT = formatter.getColumnTypeFormatter(BUSINESS_COLUMN_TYPE)) === null || _formatter$getColumnT === void 0 ? void 0 : _formatter$getColumnT.dhTimeZone;
626
- var timeZoneDiff = formatterTimeZone ? (calendarTimeZone.standardOffset - formatterTimeZone.standardOffset) / 60 : 0;
627
-
628
- if (holidays.length > 0) {
629
- axisFormat.rangebreaks.push(...ChartUtils.createRangeBreakValuesFromHolidays(holidays, calendarTimeZone, formatterTimeZone));
630
- }
631
-
632
- businessPeriods.forEach(period => axisFormat.rangebreaks.push({
633
- pattern: 'hour',
634
- bounds: [ChartUtils.periodToDecimal(period.close) + timeZoneDiff, ChartUtils.periodToDecimal(period.open) + timeZoneDiff]
635
- })); // If there are seven business days, then there is no weekend
636
-
637
- if (businessDays.length < DAYS.length) {
638
- ChartUtils.createBoundsFromDays(businessDays).forEach(weekendBounds => axisFormat.rangebreaks.push({
639
- pattern: 'day of week',
640
- bounds: weekendBounds
641
- }));
642
- }
649
+ (function () {
650
+ var rangebreaks = [];
651
+ var {
652
+ businessPeriods,
653
+ businessDays,
654
+ holidays,
655
+ timeZone: calendarTimeZone
656
+ } = businessCalendar;
657
+ var typeFormatter = formatter === null || formatter === void 0 ? void 0 : formatter.getColumnTypeFormatter(BUSINESS_COLUMN_TYPE);
658
+ var formatterTimeZone = void 0;
659
+
660
+ if (isDateTimeColumnFormatter(typeFormatter)) {
661
+ formatterTimeZone = typeFormatter.dhTimeZone;
662
+ }
663
+
664
+ var timeZoneDiff = formatterTimeZone ? (calendarTimeZone.standardOffset - formatterTimeZone.standardOffset) / 60 : 0;
665
+
666
+ if (holidays.length > 0) {
667
+ rangebreaks.push(...ChartUtils.createRangeBreakValuesFromHolidays(holidays, calendarTimeZone, formatterTimeZone));
668
+ }
669
+
670
+ businessPeriods.forEach(period => rangebreaks.push({
671
+ pattern: 'hour',
672
+ bounds: [ChartUtils.periodToDecimal(period.close) + timeZoneDiff, ChartUtils.periodToDecimal(period.open) + timeZoneDiff]
673
+ })); // If there are seven business days, then there is no weekend
674
+
675
+ if (businessDays.length < DAYS.length) {
676
+ ChartUtils.createBoundsFromDays(businessDays).forEach(weekendBounds => rangebreaks.push({
677
+ pattern: 'day of week',
678
+ bounds: weekendBounds
679
+ }));
680
+ }
681
+
682
+ axisFormat.rangebreaks = rangebreaks;
683
+ })();
643
684
  }
644
685
 
645
686
  if (axisFormats.size === chart.axes.length) {
646
- return {
647
- v: axisFormats
648
- };
687
+ return axisFormats;
649
688
  }
650
689
  }
651
- }();
652
-
653
- if (typeof _ret === "object") return _ret.v;
690
+ }
654
691
  }
655
692
  }
656
693
  }
@@ -672,7 +709,7 @@ class ChartUtils {
672
709
  }
673
710
  /**
674
711
  * Return the plotly axis property name
675
- * @param {dh.plot.AxisType} axisType The axis type to get the property name for
712
+ * @param axisType The axis type to get the property name for
676
713
  */
677
714
 
678
715
 
@@ -690,7 +727,7 @@ class ChartUtils {
690
727
  }
691
728
  /**
692
729
  * Returns the plotly "side" value for the provided axis position
693
- * @param {dh.plot.AxisPosition} axisPosition The Iris AxisPosition of the axis
730
+ * @param axisPosition The Iris AxisPosition of the axis
694
731
  */
695
732
 
696
733
 
@@ -709,13 +746,13 @@ class ChartUtils {
709
746
  return 'right';
710
747
 
711
748
  default:
712
- return null;
749
+ return undefined;
713
750
  }
714
751
  }
715
752
  /**
716
753
  * Retrieve the chart that contains the passed in series from the figure
717
- * @param {dh.plot.Figure} figure The figure to retrieve the chart from
718
- * @param {dh.plot.Series} series The series to get the chart for
754
+ * @param figure The figure to retrieve the chart from
755
+ * @param series The series to get the chart for
719
756
  */
720
757
 
721
758
 
@@ -738,8 +775,8 @@ class ChartUtils {
738
775
  }
739
776
  /**
740
777
  * Get an object mapping axis to their ranges
741
- * @param {object} layout The plotly layout object to get the ranges from
742
- * @returns {object} An object mapping the axis name to it's range
778
+ * @param layout The plotly layout object to get the ranges from
779
+ * @returns An object mapping the axis name to it's range
743
780
  */
744
781
 
745
782
 
@@ -749,10 +786,11 @@ class ChartUtils {
749
786
 
750
787
  for (var i = 0; i < keys.length; i += 1) {
751
788
  var key = keys[i];
789
+ var value = layout[key];
752
790
 
753
- if (layout[key] && layout[key].range && !layout[key].autorange) {
791
+ if (isRangedPlotlyAxis(value)) {
754
792
  // Only want to add the range if it's not autoranged
755
- ranges[key] = [...layout[key].range];
793
+ ranges[key] = [...value.range];
756
794
  }
757
795
  }
758
796
 
@@ -763,11 +801,11 @@ class ChartUtils {
763
801
  * If the axis did not exist in the layout previously, it is created and added.
764
802
  * Any axis that no longer exists in axes is removed.
765
803
  * With Downsampling enabled, will also update the range on the axis itself as appropriate
766
- * @param {object} layoutParam The layout object to update
767
- * @param {dh.plot.Axis[]} axes The axes to update the layout with
768
- * @param {number} plotWidth The width of the plot to calculate the axis sizes for
769
- * @param {number} plotHeight The height of the plot to calculate the axis sizes for
770
- * @param {func} getRangeParser A function to retrieve the range parser for a given axis
804
+ * @param layoutParam The layout object to update
805
+ * @param axes The axes to update the layout with
806
+ * @param plotWidth The width of the plot to calculate the axis sizes for
807
+ * @param plotHeight The height of the plot to calculate the axis sizes for
808
+ * @param getRangeParser A function to retrieve the range parser for a given axis
771
809
  */
772
810
 
773
811
 
@@ -775,7 +813,7 @@ class ChartUtils {
775
813
  var plotWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
776
814
  var plotHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
777
815
  var getRangeParser = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
778
- var theme = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
816
+ var theme = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ChartTheme;
779
817
  var xAxisSize = plotWidth > 0 ? Math.max(ChartUtils.MIN_AXIS_SIZE, Math.min(ChartUtils.AXIS_SIZE_PX / plotHeight, ChartUtils.MAX_AXIS_SIZE)) : ChartUtils.DEFAULT_AXIS_SIZE;
780
818
  var yAxisSize = plotHeight > 0 ? Math.max(ChartUtils.MIN_AXIS_SIZE, Math.min(ChartUtils.AXIS_SIZE_PX / plotWidth, ChartUtils.MAX_AXIS_SIZE)) : ChartUtils.DEFAULT_AXIS_SIZE; // Adjust the bounds based on where the legend is
781
819
  // For now, always assume the legend is shown on the right
@@ -809,10 +847,11 @@ class ChartUtils {
809
847
  var typeAxes = axisTypeMap.get(axisType);
810
848
  var isYAxis = axisType === dh.plot.AxisType.Y;
811
849
  var plotSize = isYAxis ? plotHeight : plotWidth;
850
+ assertNotNull(typeAxes);
812
851
  var axisIndex = 0;
813
852
 
814
853
  for (axisIndex = 0; axisIndex < typeAxes.length; axisIndex += 1) {
815
- var axis = typeAxes[axisIndex];
854
+ var _axis3 = typeAxes[axisIndex];
816
855
 
817
856
  var _axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, axisIndex);
818
857
 
@@ -821,19 +860,23 @@ class ChartUtils {
821
860
  }
822
861
 
823
862
  var layoutAxis = layout[_axisLayoutProperty];
824
- ChartUtils.updateLayoutAxis(layoutAxis, axis, axisIndex, axisPositionMap, xAxisSize, yAxisSize, bounds);
825
- var {
826
- range,
827
- autorange
828
- } = layoutAxis;
829
-
830
- if (getRangeParser && range && !autorange) {
831
- var rangeParser = getRangeParser(axis);
832
- var [rangeStart, rangeEnd] = rangeParser(range);
833
- log.debug('Setting downsample range', plotSize, rangeStart, rangeEnd);
834
- axis.range(plotSize, rangeStart, rangeEnd);
835
- } else {
836
- axis.range(plotSize);
863
+
864
+ if (layoutAxis != null) {
865
+ ChartUtils.updateLayoutAxis(layoutAxis, _axis3, axisIndex, axisPositionMap, xAxisSize, yAxisSize, bounds);
866
+ var {
867
+ range: _range,
868
+ autorange
869
+ } = layoutAxis;
870
+
871
+ if (getRangeParser && _range && !autorange) {
872
+ var rangeParser = getRangeParser(_axis3);
873
+ var [rangeStart, rangeEnd] = rangeParser(_range);
874
+ log.debug('Setting downsample range', plotSize, rangeStart, rangeEnd);
875
+
876
+ _axis3.range(plotSize, rangeStart, rangeEnd);
877
+ } else {
878
+ _axis3.range(plotSize);
879
+ }
837
880
  }
838
881
  }
839
882
 
@@ -850,16 +893,16 @@ class ChartUtils {
850
893
 
851
894
  static getAxisLayoutProperty(axisProperty, axisIndex) {
852
895
  var axisIndexString = axisIndex > 0 ? "".concat(axisIndex + 1) : '';
853
- return "".concat(axisProperty, "axis").concat(axisIndexString);
896
+ return "".concat(axisProperty !== null && axisProperty !== void 0 ? axisProperty : '', "axis").concat(axisIndexString);
854
897
  }
855
898
  /**
856
899
  * Updates the layout axis object in place
857
- * @param {object} layoutAxisParam The plotly layout axis param
858
- * @param {dh.plot.Axis} axis The Iris Axis to update the plotly layout with
859
- * @param {number} axisIndex The type index for this axis
860
- * @param {Map<dh.plot.AxisPosition, dh.plot.Axis>} axisPositionMap All the axes mapped by position
861
- * @param {number} axisSize The size of each axis in percent
862
- * @param {object} bounds The bounds of the axes domains
900
+ * @param layoutAxisParam The plotly layout axis param
901
+ * @param axis The Iris Axis to update the plotly layout with
902
+ * @param axisIndex The type index for this axis
903
+ * @param axisPositionMap All the axes mapped by position
904
+ * @param axisSize The size of each axis in percent
905
+ * @param bounds The bounds of the axes domains
863
906
  */
864
907
 
865
908
 
@@ -867,7 +910,14 @@ class ChartUtils {
867
910
  var isYAxis = axis.type === dh.plot.AxisType.Y;
868
911
  var axisSize = isYAxis ? yAxisSize : xAxisSize;
869
912
  var layoutAxis = layoutAxisParam;
870
- layoutAxis.title.text = axis.label;
913
+
914
+ if (layoutAxis.title !== undefined && typeof layoutAxis.title !== 'string') {
915
+ layoutAxis.title.text = axis.label;
916
+ } else {
917
+ layoutAxis.title = {
918
+ text: axis.label
919
+ };
920
+ }
871
921
 
872
922
  if (axis.log) {
873
923
  layoutAxis.type = 'log';
@@ -876,8 +926,10 @@ class ChartUtils {
876
926
  layoutAxis.side = ChartUtils.getAxisSide(axis.position);
877
927
 
878
928
  if (axisIndex > 0) {
879
- layoutAxis.overlaying = ChartUtils.getAxisPropertyName(axis.type);
880
- var positionAxes = axisPositionMap.get(axis.position);
929
+ var _ChartUtils$getAxisPr, _axisPositionMap$get;
930
+
931
+ layoutAxis.overlaying = (_ChartUtils$getAxisPr = ChartUtils.getAxisPropertyName(axis.type)) !== null && _ChartUtils$getAxisPr !== void 0 ? _ChartUtils$getAxisPr : undefined;
932
+ var positionAxes = (_axisPositionMap$get = axisPositionMap.get(axis.position)) !== null && _axisPositionMap$get !== void 0 ? _axisPositionMap$get : [];
881
933
  var sideIndex = positionAxes.indexOf(axis);
882
934
 
883
935
  if (sideIndex > 0) {
@@ -910,13 +962,13 @@ class ChartUtils {
910
962
  /**
911
963
  * Converts an open or close period to a declimal. e.g '09:30" to 9.5
912
964
  *
913
- * @param {String} period the open or close value of the period
965
+ * @param period the open or close value of the period
914
966
  */
915
967
 
916
968
 
917
969
  static periodToDecimal(period) {
918
970
  var values = period.split(':');
919
- return Number(values[0]) + Number(values[1] / 60);
971
+ return Number(values[0]) + Number(values[1]) / 60;
920
972
  }
921
973
  /**
922
974
  * Creates range break bounds for plotly from business days.
@@ -924,7 +976,7 @@ class ChartUtils {
924
976
  * will result in [[6,1]] meaning close on Saturday and open on Monday.
925
977
  * If you remove Wednesday from the array, then you get two closures [[6, 1], [3, 4]]
926
978
  *
927
- * @param {Array} businessDays the days to display on the x-axis
979
+ * @param businessDays the days to display on the x-axis
928
980
  */
929
981
 
930
982
 
@@ -961,9 +1013,9 @@ class ChartUtils {
961
1013
  /**
962
1014
  * Creates an array of range breaks for all holidays.
963
1015
  *
964
- * @param {Array} holidays an array of holidays
965
- * @param {TimeZone} calendarTimeZone the time zone for the business calendar
966
- * @param {TimeZone} formatterTimeZone the time zone for the formatter
1016
+ * @param holidays an array of holidays
1017
+ * @param calendarTimeZone the time zone for the business calendar
1018
+ * @param formatterTimeZone the time zone for the formatter
967
1019
  */
968
1020
 
969
1021
 
@@ -984,9 +1036,9 @@ class ChartUtils {
984
1036
  /**
985
1037
  * Creates the range break value for a full holiday. A full holiday is day that has no business periods.
986
1038
  *
987
- * @param {Holiday} holiday the full holiday
988
- * @param {TimeZone} calendarTimeZone the time zone for the business calendar
989
- * @param {TimeZone} formatterTimeZone the time zone for the formatter
1039
+ * @param holiday the full holiday
1040
+ * @param calendarTimeZone the time zone for the business calendar
1041
+ * @param formatterTimeZone the time zone for the formatter
990
1042
  */
991
1043
 
992
1044
 
@@ -997,9 +1049,9 @@ class ChartUtils {
997
1049
  * Creates the range break for a partial holiday. A partial holiday is holiday with business periods
998
1050
  * that are different than the default business periods.
999
1051
  *
1000
- * @param {Holiday} holiday the partial holiday
1001
- * @param {TimeZone} calendarTimeZone the time zone for the business calendar
1002
- * @param {TimeZone} formatterTimeZone the time zone for the formatter
1052
+ * @param holiday the partial holiday
1053
+ * @param calendarTimeZone the time zone for the business calendar
1054
+ * @param formatterTimeZone the time zone for the formatter
1003
1055
  */
1004
1056
 
1005
1057
 
@@ -1038,9 +1090,9 @@ class ChartUtils {
1038
1090
  /**
1039
1091
  * Adjusts a date string from the calendar time zone to the formatter time zone.
1040
1092
  *
1041
- * @param {string} dateString the date string
1042
- * @param {TimeZone} calendarTimeZone the time zone for the business calendar
1043
- * @param {TimeZone} formatterTimeZone the time zone for the formatter
1093
+ * @param dateString the date string
1094
+ * @param calendarTimeZone the time zone for the business calendar
1095
+ * @param formatterTimeZone the time zone for the formatter
1044
1096
  */
1045
1097
 
1046
1098
 
@@ -1053,9 +1105,9 @@ class ChartUtils {
1053
1105
  }
1054
1106
  /**
1055
1107
  * Groups an array and returns a map
1056
- * @param {object[]} array The object to group
1057
- * @param {string} property The property name to group by
1058
- * @returns {Map<object, object>} A map containing the items grouped by their values for the property
1108
+ * @param array The object to group
1109
+ * @param property The property name to group by
1110
+ * @returns A map containing the items grouped by their values for the property
1059
1111
  */
1060
1112
 
1061
1113
 
@@ -1068,27 +1120,19 @@ class ChartUtils {
1068
1120
  return result;
1069
1121
  }, new Map());
1070
1122
  }
1071
- /**
1072
- * Update
1073
- */
1074
-
1075
-
1076
- static updateRanges() {}
1077
1123
  /**
1078
1124
  * Unwraps a value provided from API to a value plotly can understand
1079
1125
  * Eg. Unwraps DateWrapper, LongWrapper objects.
1080
1126
  */
1081
1127
 
1082
1128
 
1083
- static unwrapValue(value) {
1084
- var timeZone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1085
-
1129
+ static unwrapValue(value, timeZone) {
1086
1130
  if (value != null) {
1087
- if (value.asDate) {
1131
+ if (isDateWrapper(value)) {
1088
1132
  return dh.i18n.DateTimeFormat.format(ChartUtils.DATE_FORMAT, value, timeZone);
1089
1133
  }
1090
1134
 
1091
- if (value.asNumber) {
1135
+ if (isLongWrapper(value)) {
1092
1136
  return value.asNumber();
1093
1137
  }
1094
1138
  }
@@ -1097,9 +1141,9 @@ class ChartUtils {
1097
1141
  }
1098
1142
  /**
1099
1143
  *
1100
- * @param {any} value The value to wrap up
1101
- * @param {string} columnType The type of column this value is from
1102
- * @param {dh.i18n.TimeZone} timeZone The time zone if applicable
1144
+ * @param value The value to wrap up
1145
+ * @param columnType The type of column this value is from
1146
+ * @param timeZone The time zone if applicable
1103
1147
  */
1104
1148
 
1105
1149
 
@@ -1132,7 +1176,7 @@ class ChartUtils {
1132
1176
  }
1133
1177
 
1134
1178
  static makeLayoutAxis(type) {
1135
- var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1179
+ var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ChartTheme;
1136
1180
  var axis = {
1137
1181
  automargin: true,
1138
1182
  gridcolor: theme.gridcolor,
@@ -1171,12 +1215,13 @@ class ChartUtils {
1171
1215
  /**
1172
1216
  * Parses the colorway property of a theme and returns an array of colors
1173
1217
  * Theme could have a single string with space separated colors or an array of strings representing the colorway
1174
- * @param {ChartTheme} theme The theme to get colorway from
1175
- * @returns {string[]} Colorway array for the theme
1218
+ * @param theme The theme to get colorway from
1219
+ * @returns Colorway array for the theme
1176
1220
  */
1177
1221
 
1178
1222
 
1179
- static getColorwayFromTheme(theme) {
1223
+ static getColorwayFromTheme() {
1224
+ var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ChartTheme;
1180
1225
  var colorway = [];
1181
1226
 
1182
1227
  if (theme.colorway) {
@@ -1193,7 +1238,7 @@ class ChartUtils {
1193
1238
  }
1194
1239
 
1195
1240
  static makeDefaultLayout() {
1196
- var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1241
+ var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ChartTheme;
1197
1242
 
1198
1243
  var layout = _objectSpread(_objectSpread({}, theme), {}, {
1199
1244
  autosize: true,
@@ -1224,7 +1269,7 @@ class ChartUtils {
1224
1269
  }
1225
1270
  /**
1226
1271
  * Hydrate settings from a JSONable object
1227
- * @param {object} settings Dehydrated settings
1272
+ * @param settings Dehydrated settings
1228
1273
  */
1229
1274
 
1230
1275
 
@@ -1248,11 +1293,11 @@ class ChartUtils {
1248
1293
  * This logic will still need to exist to translate existing charts, but could be part of a migration script
1249
1294
  * to translate the data.
1250
1295
  * Change when we decide to add more functionality to the Chart Builder.
1251
- * @param {object} settings The chart builder settings
1252
- * @param {string} settings.title The title for this figure
1253
- * @param {string} settings.xAxis The name of the column to use for the x-axis
1254
- * @param {string[]} settings.series The name of the columns to use for the series of this figure
1255
- * @param {dh.plot.SeriesPlotStyle} settings.type The plot style for this figure
1296
+ * @param settings The chart builder settings
1297
+ * @param settings.title The title for this figure
1298
+ * @param settings.xAxis The name of the column to use for the x-axis
1299
+ * @param settings.series The name of the columns to use for the series of this figure
1300
+ * @param settings.type The plot style for this figure
1256
1301
  */
1257
1302
 
1258
1303