@deephaven/chart 0.78.3 → 0.78.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.d.ts +5 -2
- package/dist/Chart.d.ts.map +1 -1
- package/dist/Chart.js +16 -1
- package/dist/Chart.js.map +1 -1
- package/dist/ChartModel.d.ts +11 -0
- package/dist/ChartModel.d.ts.map +1 -1
- package/dist/ChartModel.js +12 -0
- package/dist/ChartModel.js.map +1 -1
- package/dist/ChartUtils.d.ts +54 -5
- package/dist/ChartUtils.d.ts.map +1 -1
- package/dist/ChartUtils.js +208 -97
- package/dist/ChartUtils.js.map +1 -1
- package/dist/FigureChartModel.d.ts +2 -1
- package/dist/FigureChartModel.d.ts.map +1 -1
- package/dist/FigureChartModel.js +8 -1
- package/dist/FigureChartModel.js.map +1 -1
- package/package.json +4 -4
package/dist/ChartUtils.js
CHANGED
|
@@ -293,6 +293,17 @@ class ChartUtils {
|
|
|
293
293
|
return Number(values[0]) + Number(values[1]) / 60;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Converts a decimal to a period. e.g 9.5 to '09:30'
|
|
298
|
+
*
|
|
299
|
+
* @param decimal the decimal value to
|
|
300
|
+
*/
|
|
301
|
+
static decimalToPeriod(decimal) {
|
|
302
|
+
var hours = Math.floor(decimal);
|
|
303
|
+
var minutes = Math.round((decimal - hours) * 60);
|
|
304
|
+
return "".concat(hours.toString().padStart(2, '0'), ":").concat(minutes.toString().padStart(2, '0'));
|
|
305
|
+
}
|
|
306
|
+
|
|
296
307
|
/**
|
|
297
308
|
* Groups an array and returns a map
|
|
298
309
|
* @param array The object to group
|
|
@@ -337,6 +348,48 @@ class ChartUtils {
|
|
|
337
348
|
} = settings;
|
|
338
349
|
return title;
|
|
339
350
|
}
|
|
351
|
+
static getTimeZoneDiff(calendarTimeZone, formatterTimeZone) {
|
|
352
|
+
return formatterTimeZone ? (calendarTimeZone.standardOffset - formatterTimeZone.standardOffset) / 60 : 0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Creates closed periods for a partial holiday.
|
|
357
|
+
*
|
|
358
|
+
* @param holidayPeriods the business periods for the holiday
|
|
359
|
+
* @param calendarPeriods the business periods for the calendar
|
|
360
|
+
* @returns an array of closed ranges for the partial holiday. Should be the ranges during the regular business hours that are _not_ specified by the holiday periods.
|
|
361
|
+
*/
|
|
362
|
+
static createClosedRangesForPartialHoliday(holidayPeriods, calendarPeriods) {
|
|
363
|
+
// First restrict the periods to only those that are actual business periods.
|
|
364
|
+
var calendarRanges = calendarPeriods.map(period => [ChartUtils.periodToDecimal(period.open), ChartUtils.periodToDecimal(period.close)]);
|
|
365
|
+
calendarRanges.sort((a, b) => a[0] - b[0]);
|
|
366
|
+
if (calendarRanges.length === 0) {
|
|
367
|
+
calendarRanges.push([0, 24]);
|
|
368
|
+
}
|
|
369
|
+
var holidayRanges = holidayPeriods.map(period => [ChartUtils.periodToDecimal(period.open), ChartUtils.periodToDecimal(period.close)]);
|
|
370
|
+
holidayRanges.sort((a, b) => a[0] - b[0]);
|
|
371
|
+
var closedRanges = [];
|
|
372
|
+
|
|
373
|
+
// Separate index cursor for the holiday ranges
|
|
374
|
+
for (var c = 0; c < calendarRanges.length; c += 1) {
|
|
375
|
+
var calendarRange = calendarRanges[c];
|
|
376
|
+
var lastClose = calendarRange[0];
|
|
377
|
+
for (var h = 0; h < holidayRanges.length; h += 1) {
|
|
378
|
+
var holidayRange = holidayRanges[h];
|
|
379
|
+
if (holidayRange[1] > lastClose && holidayRange[0] < calendarRange[1]) {
|
|
380
|
+
if (holidayRange[0] > lastClose) {
|
|
381
|
+
closedRanges.push([lastClose, holidayRange[0]]);
|
|
382
|
+
}
|
|
383
|
+
// eslint-disable-next-line prefer-destructuring
|
|
384
|
+
lastClose = holidayRange[1];
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (lastClose < calendarRange[1]) {
|
|
388
|
+
closedRanges.push([lastClose, calendarRange[1]]);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return closedRanges;
|
|
392
|
+
}
|
|
340
393
|
constructor(dh) {
|
|
341
394
|
_defineProperty(this, "dh", void 0);
|
|
342
395
|
_defineProperty(this, "daysOfWeek", void 0);
|
|
@@ -353,7 +406,6 @@ class ChartUtils {
|
|
|
353
406
|
* @returns A map of axis layout property names to axis formats
|
|
354
407
|
*/
|
|
355
408
|
getAxisFormats(figure, formatter) {
|
|
356
|
-
var _this = this;
|
|
357
409
|
var axisFormats = new Map();
|
|
358
410
|
var nullFormat = {
|
|
359
411
|
tickformat: null,
|
|
@@ -372,74 +424,41 @@ class ChartUtils {
|
|
|
372
424
|
sources
|
|
373
425
|
} = series;
|
|
374
426
|
var axisSources = sources.filter(source => source.axis);
|
|
375
|
-
var
|
|
427
|
+
for (var k = 0; k < axisSources.length; k += 1) {
|
|
376
428
|
var source = axisSources[k];
|
|
377
429
|
var {
|
|
378
|
-
axis
|
|
430
|
+
axis: _axis
|
|
379
431
|
} = source;
|
|
380
432
|
var {
|
|
381
433
|
type: axisType
|
|
382
|
-
} =
|
|
434
|
+
} = _axis;
|
|
383
435
|
var typeAxes = axisTypeMap.get(axisType);
|
|
384
436
|
assertNotNull(typeAxes);
|
|
385
|
-
var axisIndex = typeAxes.indexOf(
|
|
386
|
-
var axisProperty =
|
|
437
|
+
var axisIndex = typeAxes.indexOf(_axis);
|
|
438
|
+
var axisProperty = this.getAxisPropertyName(axisType);
|
|
387
439
|
if (axisProperty != null) {
|
|
388
440
|
var axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, axisIndex);
|
|
389
441
|
if (axisFormats.has(axisLayoutProperty)) {
|
|
390
442
|
log.debug("".concat(axisLayoutProperty, " already added."));
|
|
391
443
|
} else {
|
|
392
444
|
log.debug("Adding ".concat(axisLayoutProperty, " to axisFormats."));
|
|
393
|
-
var axisFormat =
|
|
445
|
+
var axisFormat = this.getPlotlyAxisFormat(source, formatter);
|
|
394
446
|
if (axisFormat === null) {
|
|
395
447
|
axisFormats.set(axisLayoutProperty, nullFormat);
|
|
396
448
|
} else {
|
|
397
449
|
axisFormats.set(axisLayoutProperty, axisFormat);
|
|
398
450
|
var {
|
|
399
451
|
businessCalendar
|
|
400
|
-
} =
|
|
452
|
+
} = _axis;
|
|
401
453
|
if (businessCalendar != null) {
|
|
402
|
-
|
|
403
|
-
var {
|
|
404
|
-
businessPeriods,
|
|
405
|
-
businessDays,
|
|
406
|
-
holidays,
|
|
407
|
-
timeZone: calendarTimeZone
|
|
408
|
-
} = businessCalendar;
|
|
409
|
-
var typeFormatter = formatter === null || formatter === void 0 ? void 0 : formatter.getColumnTypeFormatter(BUSINESS_COLUMN_TYPE);
|
|
410
|
-
var formatterTimeZone;
|
|
411
|
-
if (isDateTimeColumnFormatter(typeFormatter)) {
|
|
412
|
-
formatterTimeZone = typeFormatter.dhTimeZone;
|
|
413
|
-
}
|
|
414
|
-
var timeZoneDiff = formatterTimeZone ? (calendarTimeZone.standardOffset - formatterTimeZone.standardOffset) / 60 : 0;
|
|
415
|
-
if (holidays.length > 0) {
|
|
416
|
-
rangebreaks.push(..._this.createRangeBreakValuesFromHolidays(holidays, calendarTimeZone, formatterTimeZone));
|
|
417
|
-
}
|
|
418
|
-
businessPeriods.forEach(period => rangebreaks.push({
|
|
419
|
-
pattern: 'hour',
|
|
420
|
-
bounds: [ChartUtils.periodToDecimal(period.close) + timeZoneDiff, ChartUtils.periodToDecimal(period.open) + timeZoneDiff]
|
|
421
|
-
}));
|
|
422
|
-
// If there are seven business days, then there is no weekend
|
|
423
|
-
if (businessDays.length < _this.daysOfWeek.length) {
|
|
424
|
-
_this.createBoundsFromDays(businessDays).forEach(weekendBounds => rangebreaks.push({
|
|
425
|
-
pattern: 'day of week',
|
|
426
|
-
bounds: weekendBounds
|
|
427
|
-
}));
|
|
428
|
-
}
|
|
429
|
-
axisFormat.rangebreaks = rangebreaks;
|
|
454
|
+
axisFormat.rangebreaks = this.createRangeBreaksFromBusinessCalendar(businessCalendar, formatter);
|
|
430
455
|
}
|
|
431
456
|
if (axisFormats.size === _chart2.axes.length) {
|
|
432
|
-
return
|
|
433
|
-
v: axisFormats
|
|
434
|
-
};
|
|
457
|
+
return axisFormats;
|
|
435
458
|
}
|
|
436
459
|
}
|
|
437
460
|
}
|
|
438
461
|
}
|
|
439
|
-
};
|
|
440
|
-
for (var k = 0; k < axisSources.length; k += 1) {
|
|
441
|
-
var _ret = _loop();
|
|
442
|
-
if (typeof _ret === "object") return _ret.v;
|
|
443
462
|
}
|
|
444
463
|
}
|
|
445
464
|
}
|
|
@@ -450,16 +469,19 @@ class ChartUtils {
|
|
|
450
469
|
* Converts the Iris plot style into a plotly chart type
|
|
451
470
|
* @param plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle
|
|
452
471
|
* @param isBusinessTime If the plot is using business time for an axis
|
|
472
|
+
* @param allowWebGL If WebGL is allowedd
|
|
453
473
|
*/
|
|
454
474
|
getPlotlyChartType(plotStyle, isBusinessTime) {
|
|
475
|
+
var allowWebGL = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
455
476
|
var {
|
|
456
477
|
dh
|
|
457
478
|
} = this;
|
|
458
479
|
switch (plotStyle) {
|
|
459
480
|
case dh.plot.SeriesPlotStyle.SCATTER:
|
|
460
481
|
case dh.plot.SeriesPlotStyle.LINE:
|
|
461
|
-
// scattergl mode is more performant, but doesn't support the rangebreaks we need for businessTime calendars
|
|
462
|
-
|
|
482
|
+
// scattergl mode is more performant (usually), but doesn't support the rangebreaks we need for businessTime calendars
|
|
483
|
+
// In some cases, WebGL is less performant (like in virtual desktop environments), so we also allow the option of the user explicitly disabling it even if it's supported
|
|
484
|
+
return !isBusinessTime && IS_WEBGL_SUPPORTED && allowWebGL ? 'scattergl' : 'scatter';
|
|
463
485
|
case dh.plot.SeriesPlotStyle.BAR:
|
|
464
486
|
case dh.plot.SeriesPlotStyle.STACKED_BAR:
|
|
465
487
|
return 'bar';
|
|
@@ -625,6 +647,7 @@ class ChartUtils {
|
|
|
625
647
|
*/
|
|
626
648
|
makeSeriesDataFromSeries(series, axisTypeMap, seriesVisibility) {
|
|
627
649
|
var showLegend = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
650
|
+
var allowWebGL = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
628
651
|
var {
|
|
629
652
|
name,
|
|
630
653
|
isLinesVisible,
|
|
@@ -640,7 +663,7 @@ class ChartUtils {
|
|
|
640
663
|
var _source$axis;
|
|
641
664
|
return (_source$axis = source.axis) === null || _source$axis === void 0 ? void 0 : _source$axis.businessCalendar;
|
|
642
665
|
});
|
|
643
|
-
var type = this.getChartType(plotStyle, isBusinessTime);
|
|
666
|
+
var type = this.getChartType(plotStyle, isBusinessTime, allowWebGL);
|
|
644
667
|
var mode = this.getPlotlyChartMode(plotStyle, isLinesVisible !== null && isLinesVisible !== void 0 ? isLinesVisible : undefined, isShapesVisible !== null && isShapesVisible !== void 0 ? isShapesVisible : undefined);
|
|
645
668
|
var orientation = this.getPlotlySeriesOrientation(series);
|
|
646
669
|
var seriesData = ChartUtils.makeSeriesData(type, mode, name, showLegend, orientation);
|
|
@@ -653,16 +676,16 @@ class ChartUtils {
|
|
|
653
676
|
for (var k = 0; k < sources.length; k += 1) {
|
|
654
677
|
var source = sources[k];
|
|
655
678
|
var {
|
|
656
|
-
axis:
|
|
679
|
+
axis: _axis2,
|
|
657
680
|
type: sourceType
|
|
658
681
|
} = source;
|
|
659
682
|
var dataAttributeName = this.getPlotlyProperty(plotStyle, sourceType);
|
|
660
683
|
set(seriesData, dataAttributeName, []);
|
|
661
|
-
var axisProperty =
|
|
684
|
+
var axisProperty = _axis2 != null ? this.getAxisPropertyName(_axis2.type) : null;
|
|
662
685
|
if (axisProperty != null) {
|
|
663
|
-
var axes = axisTypeMap.get(
|
|
686
|
+
var axes = axisTypeMap.get(_axis2.type);
|
|
664
687
|
if (axes) {
|
|
665
|
-
var axisIndex = axes.indexOf(
|
|
688
|
+
var axisIndex = axes.indexOf(_axis2);
|
|
666
689
|
var axisIndexString = axisIndex > 0 ? "".concat(axisIndex + 1) : '';
|
|
667
690
|
seriesData["".concat(axisProperty, "axis")] = "".concat(axisProperty).concat(axisIndexString);
|
|
668
691
|
}
|
|
@@ -736,6 +759,7 @@ class ChartUtils {
|
|
|
736
759
|
}
|
|
737
760
|
}
|
|
738
761
|
getChartType(plotStyle, isBusinessTime) {
|
|
762
|
+
var allowWebGL = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
739
763
|
var {
|
|
740
764
|
dh
|
|
741
765
|
} = this;
|
|
@@ -745,7 +769,7 @@ class ChartUtils {
|
|
|
745
769
|
// plot.ly to calculate the bins and sum values, just convert it to a bar chart
|
|
746
770
|
return 'bar';
|
|
747
771
|
default:
|
|
748
|
-
return this.getPlotlyChartType(plotStyle, isBusinessTime);
|
|
772
|
+
return this.getPlotlyChartType(plotStyle, isBusinessTime, allowWebGL);
|
|
749
773
|
}
|
|
750
774
|
}
|
|
751
775
|
|
|
@@ -953,26 +977,26 @@ class ChartUtils {
|
|
|
953
977
|
assertNotNull(typeAxes);
|
|
954
978
|
assertNotNull(figureTypeAxes);
|
|
955
979
|
for (var chartAxisIndex = 0; chartAxisIndex < typeAxes.length; chartAxisIndex += 1) {
|
|
956
|
-
var
|
|
957
|
-
var figureAxisIndex = figureTypeAxes.indexOf(
|
|
980
|
+
var _axis3 = typeAxes[chartAxisIndex];
|
|
981
|
+
var figureAxisIndex = figureTypeAxes.indexOf(_axis3);
|
|
958
982
|
var axisLayoutProperty = ChartUtils.getAxisLayoutProperty(axisProperty, figureAxisIndex);
|
|
959
983
|
if (layout[axisLayoutProperty] == null) {
|
|
960
984
|
layout[axisLayoutProperty] = {};
|
|
961
985
|
}
|
|
962
986
|
var layoutAxis = layout[axisLayoutProperty];
|
|
963
987
|
if (layoutAxis != null) {
|
|
964
|
-
this.updateLayoutAxis(layoutAxis,
|
|
988
|
+
this.updateLayoutAxis(layoutAxis, _axis3, chartAxisIndex, axisPositionMap, xAxisSize, yAxisSize, bounds);
|
|
965
989
|
var {
|
|
966
990
|
range: _range,
|
|
967
991
|
autorange
|
|
968
992
|
} = layoutAxis;
|
|
969
993
|
if (axisRangeParser != null && _range !== undefined && (autorange === undefined || autorange === false)) {
|
|
970
|
-
var rangeParser = axisRangeParser(
|
|
994
|
+
var rangeParser = axisRangeParser(_axis3);
|
|
971
995
|
var [rangeStart, rangeEnd] = rangeParser(_range);
|
|
972
996
|
log.debug('Setting downsample range', plotSize, rangeStart, rangeEnd);
|
|
973
|
-
|
|
997
|
+
_axis3.range(plotSize, rangeStart, rangeEnd);
|
|
974
998
|
} else {
|
|
975
|
-
|
|
999
|
+
_axis3.range(plotSize);
|
|
976
1000
|
}
|
|
977
1001
|
}
|
|
978
1002
|
}
|
|
@@ -1070,6 +1094,45 @@ class ChartUtils {
|
|
|
1070
1094
|
}
|
|
1071
1095
|
}
|
|
1072
1096
|
|
|
1097
|
+
/**
|
|
1098
|
+
* Creates the bounds for the periods specified.
|
|
1099
|
+
* For example, if you pass in [['09:00', '17:00']], it will return [17, 9] (closing at 5pm, opening at 9am the next day)
|
|
1100
|
+
* If you pass [['09:00', '12:00'], ['13:00', '17:00']], it will return [12, 13] (closing at noon, opening at 1pm) and [17, 9] (closing at 5pm, opening at 9am the next day)
|
|
1101
|
+
* @param periods Periods to map
|
|
1102
|
+
* @param timeZoneDiff Time zone difference in hours
|
|
1103
|
+
* @returns Bounds for the periods in plotly format
|
|
1104
|
+
*/
|
|
1105
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1106
|
+
createBoundsFromPeriods(periods) {
|
|
1107
|
+
var timeZoneDiff = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1108
|
+
if (periods.length === 0) {
|
|
1109
|
+
return [];
|
|
1110
|
+
}
|
|
1111
|
+
var numberPeriods = periods.map(period => [(ChartUtils.periodToDecimal(period.open) + timeZoneDiff) % 24, (ChartUtils.periodToDecimal(period.close) + timeZoneDiff) % 24]).sort((a, b) => a[0] - b[0]);
|
|
1112
|
+
var bounds = [];
|
|
1113
|
+
for (var i = 0; i < numberPeriods.length; i += 1) {
|
|
1114
|
+
var period = numberPeriods[i];
|
|
1115
|
+
var nextPeriod = numberPeriods[(i + 1) % numberPeriods.length];
|
|
1116
|
+
bounds.push([period[1], nextPeriod[0]]);
|
|
1117
|
+
}
|
|
1118
|
+
return bounds;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Creates range breaks for plotly from business periods.
|
|
1123
|
+
* @param periods Business periods to create the breaks for
|
|
1124
|
+
* @param timeZoneDiff Time zone difference in hours
|
|
1125
|
+
* @returns Plotly range breaks for the business periods
|
|
1126
|
+
*/
|
|
1127
|
+
createBreaksFromPeriods(periods) {
|
|
1128
|
+
var timeZoneDiff = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1129
|
+
var bounds = this.createBoundsFromPeriods(periods, timeZoneDiff);
|
|
1130
|
+
return bounds.map(bound => ({
|
|
1131
|
+
pattern: 'hour',
|
|
1132
|
+
bounds: bound
|
|
1133
|
+
}));
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1073
1136
|
/**
|
|
1074
1137
|
* Creates range break bounds for plotly from business days.
|
|
1075
1138
|
* For example a standard business week of ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY']
|
|
@@ -1079,47 +1142,91 @@ class ChartUtils {
|
|
|
1079
1142
|
* @param businessDays the days to display on the x-axis
|
|
1080
1143
|
*/
|
|
1081
1144
|
createBoundsFromDays(businessDays) {
|
|
1145
|
+
var weekLength = this.daysOfWeek.length;
|
|
1146
|
+
// No breaks if all days are business days
|
|
1147
|
+
if (businessDays.length === weekLength) {
|
|
1148
|
+
return [];
|
|
1149
|
+
}
|
|
1082
1150
|
var businessDaysInt = businessDays.map(day => this.daysOfWeek.indexOf(day));
|
|
1083
|
-
var
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
reopenDays.add(adjustedDay);
|
|
1091
|
-
break;
|
|
1092
|
-
}
|
|
1151
|
+
var businessDaysSet = new Set(businessDaysInt);
|
|
1152
|
+
|
|
1153
|
+
// These are the days when business is closed (e.g. Saturday to start the weekend)
|
|
1154
|
+
var closedDays = new Set();
|
|
1155
|
+
for (var i = 0; i < weekLength; i += 1) {
|
|
1156
|
+
if (!businessDaysSet.has(i) && businessDaysSet.has((i - 1 + weekLength) % weekLength)) {
|
|
1157
|
+
closedDays.add(i);
|
|
1093
1158
|
}
|
|
1094
|
-
}
|
|
1159
|
+
}
|
|
1095
1160
|
var boundsArray = [];
|
|
1096
|
-
// For each
|
|
1097
|
-
|
|
1098
|
-
for (var
|
|
1099
|
-
var adjustedDay =
|
|
1100
|
-
if (
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
break;
|
|
1161
|
+
// For each close day, find the next open day
|
|
1162
|
+
closedDays.forEach(closedDay => {
|
|
1163
|
+
for (var _i = 0; _i < weekLength; _i += 1) {
|
|
1164
|
+
var adjustedDay = (closedDay + _i) % weekLength;
|
|
1165
|
+
if (businessDaysSet.has(adjustedDay)) {
|
|
1166
|
+
boundsArray.push([closedDay, adjustedDay]);
|
|
1167
|
+
return;
|
|
1104
1168
|
}
|
|
1105
1169
|
}
|
|
1170
|
+
throw new Error("Unable to find open day for closed day ".concat(closedDay, ", businessDays: ").concat(businessDays));
|
|
1106
1171
|
});
|
|
1107
1172
|
return boundsArray;
|
|
1108
1173
|
}
|
|
1109
1174
|
|
|
1175
|
+
/**
|
|
1176
|
+
* Breaks in plotly for business days
|
|
1177
|
+
* @param businessDays Business days to create the breaks for
|
|
1178
|
+
* @returns Plotly range breaks for the business days
|
|
1179
|
+
*/
|
|
1180
|
+
createBreaksFromDays(businessDays) {
|
|
1181
|
+
var bounds = this.createBoundsFromDays(businessDays);
|
|
1182
|
+
return bounds.map(bound => ({
|
|
1183
|
+
pattern: 'day of week',
|
|
1184
|
+
bounds: bound
|
|
1185
|
+
}));
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Creates range breaks for plotly from a business calendar.
|
|
1190
|
+
* @param businessCalendar Calendar to create the breaks from
|
|
1191
|
+
* @param formatter Formatter to use for time zones
|
|
1192
|
+
* @returns Plotly Rangebreaks for the business calendar
|
|
1193
|
+
*/
|
|
1194
|
+
createRangeBreaksFromBusinessCalendar(businessCalendar, formatter) {
|
|
1195
|
+
var rangebreaks = [];
|
|
1196
|
+
var {
|
|
1197
|
+
businessPeriods,
|
|
1198
|
+
businessDays,
|
|
1199
|
+
holidays,
|
|
1200
|
+
timeZone: calendarTimeZone
|
|
1201
|
+
} = businessCalendar;
|
|
1202
|
+
var typeFormatter = formatter === null || formatter === void 0 ? void 0 : formatter.getColumnTypeFormatter(BUSINESS_COLUMN_TYPE);
|
|
1203
|
+
var formatterTimeZone;
|
|
1204
|
+
if (isDateTimeColumnFormatter(typeFormatter)) {
|
|
1205
|
+
formatterTimeZone = typeFormatter.dhTimeZone;
|
|
1206
|
+
}
|
|
1207
|
+
var timeZoneDiff = ChartUtils.getTimeZoneDiff(calendarTimeZone, formatterTimeZone);
|
|
1208
|
+
if (holidays.length > 0) {
|
|
1209
|
+
rangebreaks.push(...this.createRangeBreakValuesFromHolidays(holidays, calendarTimeZone, formatterTimeZone, businessCalendar));
|
|
1210
|
+
}
|
|
1211
|
+
rangebreaks.push(...this.createBreaksFromPeriods(businessPeriods, timeZoneDiff));
|
|
1212
|
+
rangebreaks.push(...this.createBreaksFromDays(businessDays));
|
|
1213
|
+
return rangebreaks;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1110
1216
|
/**
|
|
1111
1217
|
* Creates an array of range breaks for all holidays.
|
|
1112
1218
|
*
|
|
1113
1219
|
* @param holidays an array of holidays
|
|
1114
1220
|
* @param calendarTimeZone the time zone for the business calendar
|
|
1115
1221
|
* @param formatterTimeZone the time zone for the formatter
|
|
1222
|
+
* @param calendar the calendar the holidays are from
|
|
1116
1223
|
*/
|
|
1117
|
-
createRangeBreakValuesFromHolidays(holidays, calendarTimeZone, formatterTimeZone) {
|
|
1224
|
+
createRangeBreakValuesFromHolidays(holidays, calendarTimeZone, formatterTimeZone, calendar) {
|
|
1118
1225
|
var fullHolidays = [];
|
|
1119
1226
|
var partialHolidays = [];
|
|
1120
1227
|
holidays.forEach(holiday => {
|
|
1121
1228
|
if (holiday.businessPeriods.length > 0) {
|
|
1122
|
-
partialHolidays.push(...this.createPartialHoliday(holiday, calendarTimeZone, formatterTimeZone));
|
|
1229
|
+
partialHolidays.push(...this.createPartialHoliday(holiday, calendarTimeZone, formatterTimeZone, calendar));
|
|
1123
1230
|
} else {
|
|
1124
1231
|
fullHolidays.push(this.createFullHoliday(holiday, calendarTimeZone, formatterTimeZone));
|
|
1125
1232
|
}
|
|
@@ -1147,29 +1254,33 @@ class ChartUtils {
|
|
|
1147
1254
|
* @param holiday the partial holiday
|
|
1148
1255
|
* @param calendarTimeZone the time zone for the business calendar
|
|
1149
1256
|
* @param formatterTimeZone the time zone for the formatter
|
|
1257
|
+
* @param calendar the calendar the holiday is from. Used to check against the default business periods to ensure this holiday needs to be specified
|
|
1258
|
+
*
|
|
1259
|
+
* @returns an array of range breaks for the partial holiday
|
|
1150
1260
|
*/
|
|
1151
|
-
createPartialHoliday(holiday, calendarTimeZone, formatterTimeZone) {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
// closed from close2 to 23:59:59.999999
|
|
1261
|
+
createPartialHoliday(holiday, calendarTimeZone, formatterTimeZone, calendar) {
|
|
1262
|
+
var _calendar$businessPer;
|
|
1263
|
+
if (holiday.businessPeriods.length === 0) {
|
|
1264
|
+
return [];
|
|
1265
|
+
}
|
|
1157
1266
|
var dateString = holiday.date.toString();
|
|
1158
|
-
|
|
1159
|
-
holiday.
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1267
|
+
|
|
1268
|
+
// First check that the holiday is on a business day. If it's not, we can ignore it
|
|
1269
|
+
if (calendar) {
|
|
1270
|
+
var dayOfWeek = new Date(dateString).getDay();
|
|
1271
|
+
var isBusinessDay = calendar.businessDays.includes(this.daysOfWeek[dayOfWeek]);
|
|
1272
|
+
if (!isBusinessDay) {
|
|
1273
|
+
return [];
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
var closedPeriods = ChartUtils.createClosedRangesForPartialHoliday(holiday.businessPeriods, (_calendar$businessPer = calendar === null || calendar === void 0 ? void 0 : calendar.businessPeriods) !== null && _calendar$businessPer !== void 0 ? _calendar$businessPer : []);
|
|
1165
1277
|
var rangeBreaks = [];
|
|
1166
|
-
for (var i = 0; i < closedPeriods.length; i +=
|
|
1167
|
-
var
|
|
1168
|
-
var endClose = closedPeriods[i + 1];
|
|
1278
|
+
for (var i = 0; i < closedPeriods.length; i += 1) {
|
|
1279
|
+
var [closeStart, closeEnd] = closedPeriods[i];
|
|
1169
1280
|
// Skip over any periods where start and close are the same (zero hours)
|
|
1170
|
-
if (
|
|
1171
|
-
var values = [this.adjustDateForTimeZone("".concat(dateString, " ").concat(
|
|
1172
|
-
var dvalue = MILLIS_PER_HOUR * (
|
|
1281
|
+
if (closeStart !== closeEnd) {
|
|
1282
|
+
var values = [this.adjustDateForTimeZone("".concat(dateString, " ").concat(ChartUtils.decimalToPeriod(closeStart), ":00.000000"), calendarTimeZone, formatterTimeZone)];
|
|
1283
|
+
var dvalue = MILLIS_PER_HOUR * (closeEnd - closeStart);
|
|
1173
1284
|
rangeBreaks.push({
|
|
1174
1285
|
values,
|
|
1175
1286
|
dvalue
|