tsichart-core 1.0.5 → 2.0.0-beta.1

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 (135) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +80 -0
  3. package/dist/index.d.ts +1744 -0
  4. package/dist/index.js +14284 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +14209 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/{tsiclient.css → styles/index.css} +9498 -9497
  9. package/dist/styles/index.css.map +1 -0
  10. package/package.json +115 -124
  11. package/README.MD +0 -171
  12. package/dist/AggregateExpression.d.ts +0 -13
  13. package/dist/AggregateExpression.js +0 -70
  14. package/dist/AvailabilityChart-C8ewvn3T.js +0 -488
  15. package/dist/AvailabilityChart.d.ts +0 -59
  16. package/dist/AvailabilityChart.js +0 -26
  17. package/dist/ChartComponent-Dg8P-BTZ.js +0 -302
  18. package/dist/ChartComponent-ONNW31RL.d.ts +0 -80
  19. package/dist/ChartComponentData-DBW8_FnY.d.ts +0 -47
  20. package/dist/ChartDataOptions-CNTSB636.js +0 -49
  21. package/dist/ChartDataOptions-D0BJuRZy.d.ts +0 -38
  22. package/dist/ChartVisualizationComponent-CTs5Q_sg.js +0 -23
  23. package/dist/ChartVisualizationComponent-CpR8xZla.d.ts +0 -8
  24. package/dist/ColorPicker-0p6vkATj.js +0 -120
  25. package/dist/ColorPicker.d.ts +0 -28
  26. package/dist/ColorPicker.js +0 -6
  27. package/dist/Component-BgifJdKl.js +0 -401
  28. package/dist/Component-DXwYPoSo.d.ts +0 -226
  29. package/dist/ContextMenu-wqGGgAzp.js +0 -197
  30. package/dist/DateTimeButton-D7N8XG0S.js +0 -38
  31. package/dist/DateTimeButton-DfJL5kvr.d.ts +0 -16
  32. package/dist/DateTimeButtonRange-BM_J646m.js +0 -71
  33. package/dist/DateTimeButtonRange.d.ts +0 -19
  34. package/dist/DateTimeButtonRange.js +0 -15
  35. package/dist/DateTimeButtonSingle-BxMSitQG.js +0 -48
  36. package/dist/DateTimeButtonSingle.d.ts +0 -17
  37. package/dist/DateTimeButtonSingle.js +0 -14
  38. package/dist/DateTimePicker-BgTi-DY9.js +0 -532
  39. package/dist/DateTimePicker.d.ts +0 -69
  40. package/dist/DateTimePicker.js +0 -13
  41. package/dist/EllipsisMenu-CxJ0LoVm.js +0 -116
  42. package/dist/EllipsisMenu.d.ts +0 -20
  43. package/dist/EllipsisMenu.js +0 -6
  44. package/dist/Enums-DWpaQlXk.d.ts +0 -12
  45. package/dist/EventsTable-CsnBvvIW.js +0 -553
  46. package/dist/EventsTable.d.ts +0 -34
  47. package/dist/EventsTable.js +0 -10
  48. package/dist/GeoProcessGraphic-CUBMHIHX.js +0 -145
  49. package/dist/GeoProcessGraphic.d.ts +0 -34
  50. package/dist/GeoProcessGraphic.js +0 -7
  51. package/dist/Grid-uoHKTet9.js +0 -874
  52. package/dist/Grid.d.ts +0 -43
  53. package/dist/Grid.js +0 -6
  54. package/dist/GroupedBarChart-Bc3cGhgz.js +0 -579
  55. package/dist/GroupedBarChart.d.ts +0 -22
  56. package/dist/GroupedBarChart.js +0 -17
  57. package/dist/GroupedBarChartData-B7BTM9JH.d.ts +0 -20
  58. package/dist/GroupedBarChartData-Ml5JJimg.js +0 -121
  59. package/dist/Heatmap-5gFc_AVW.js +0 -524
  60. package/dist/Heatmap.d.ts +0 -31
  61. package/dist/Heatmap.js +0 -14
  62. package/dist/Hierarchy-C5ueDsus.js +0 -260
  63. package/dist/Hierarchy.d.ts +0 -39
  64. package/dist/Hierarchy.js +0 -6
  65. package/dist/HierarchyNavigation-C3Pwt0D6.js +0 -336
  66. package/dist/HierarchyNavigation.d.ts +0 -34
  67. package/dist/HierarchyNavigation.js +0 -6
  68. package/dist/HistoryPlayback-D09bter3.js +0 -175
  69. package/dist/HistoryPlayback-DmJ6u7lU.d.ts +0 -68
  70. package/dist/Interfaces-R_1l9lIT.d.ts +0 -6
  71. package/dist/Legend-gCIrAytG.js +0 -497
  72. package/dist/LineChart-CzDp5ULB.js +0 -3181
  73. package/dist/LineChart.d.ts +0 -163
  74. package/dist/LineChart.js +0 -18
  75. package/dist/ModelAutocomplete-lU71Ndju.js +0 -100
  76. package/dist/ModelAutocomplete.d.ts +0 -12
  77. package/dist/ModelAutocomplete.js +0 -7
  78. package/dist/ModelSearch-OF4DygOJ.js +0 -189
  79. package/dist/ModelSearch.d.ts +0 -23
  80. package/dist/ModelSearch.js +0 -9
  81. package/dist/PieChart-XLc9Itne.js +0 -258
  82. package/dist/PieChart.d.ts +0 -26
  83. package/dist/PieChart.js +0 -17
  84. package/dist/PlaybackControls-DbG9gExy.js +0 -195
  85. package/dist/PlaybackControls.d.ts +0 -39
  86. package/dist/PlaybackControls.js +0 -13
  87. package/dist/ProcessGraphic-Cft1b4Mf.js +0 -154
  88. package/dist/ProcessGraphic.d.ts +0 -31
  89. package/dist/ProcessGraphic.js +0 -7
  90. package/dist/ScatterPlot-CdnqSHq2.js +0 -924
  91. package/dist/ScatterPlot.d.ts +0 -115
  92. package/dist/ScatterPlot.js +0 -17
  93. package/dist/SingleDateTimePicker-Ddr-ogTk.js +0 -213
  94. package/dist/SingleDateTimePicker.d.ts +0 -45
  95. package/dist/SingleDateTimePicker.js +0 -12
  96. package/dist/Slider-CX0nvlqx.js +0 -186
  97. package/dist/Slider.d.ts +0 -31
  98. package/dist/Slider.js +0 -6
  99. package/dist/TemporalXAxisComponent-DXmMekYq.js +0 -129
  100. package/dist/TemporalXAxisComponent-PIeiJYUr.d.ts +0 -23
  101. package/dist/TimezonePicker-CQpXR5eb.js +0 -58
  102. package/dist/TimezonePicker.d.ts +0 -16
  103. package/dist/TimezonePicker.js +0 -10
  104. package/dist/Tooltip-C13k0eeH.js +0 -104
  105. package/dist/TsqExpression.d.ts +0 -36
  106. package/dist/TsqExpression.js +0 -89
  107. package/dist/UXClient-Bn1afElm.js +0 -230
  108. package/dist/UXClient.d.ts +0 -74
  109. package/dist/UXClient.js +0 -47
  110. package/dist/Utils-BcQeZOM3.d.ts +0 -104
  111. package/dist/Utils-DDGqSryb.js +0 -1138
  112. package/dist/Utils.d.ts +0 -7
  113. package/dist/Utils.js +0 -7
  114. package/dist/_tslib-BYFmvNeL.js +0 -96
  115. package/dist/pikaday-jh_aVtJs.js +0 -1252
  116. package/dist/tsiclient.cjs.js +0 -3
  117. package/dist/tsiclient.cjs.js.LICENSE.txt +0 -19
  118. package/dist/tsiclient.cjs.js.map +0 -1
  119. package/dist/tsiclient.d.ts +0 -46
  120. package/dist/tsiclient.esm.js +0 -3
  121. package/dist/tsiclient.esm.js.LICENSE.txt +0 -19
  122. package/dist/tsiclient.esm.js.map +0 -1
  123. package/dist/tsiclient.js +0 -58
  124. package/dist/tsiclient.min.css +0 -6
  125. package/dist/tsiclient.min.css.map +0 -1
  126. package/dist/tsiclient.umd.js +0 -3
  127. package/dist/tsiclient.umd.js.LICENSE.txt +0 -19
  128. package/dist/tsiclient.umd.js.map +0 -1
  129. package/dist/tsiclient.umd.min.js +0 -3
  130. package/dist/tsiclient.umd.min.js.LICENSE.txt +0 -19
  131. package/dist/tsiclient.umd.min.js.map +0 -1
  132. package/tsiclient.css +0 -17323
  133. package/tsiclient.d.ts +0 -46
  134. package/tsiclient.js +0 -58
  135. package/tsiclient.min.css +0 -6
@@ -1,1138 +0,0 @@
1
- import * as d3 from 'd3';
2
- import moment from 'moment-timezone';
3
-
4
- var KeyCodes;
5
- (function (KeyCodes) {
6
- KeyCodes[KeyCodes["Tab"] = 9] = "Tab";
7
- KeyCodes[KeyCodes["Esc"] = 27] = "Esc";
8
- KeyCodes[KeyCodes["Enter"] = 13] = "Enter";
9
- KeyCodes[KeyCodes["Up"] = 38] = "Up";
10
- KeyCodes[KeyCodes["Down"] = 40] = "Down";
11
- })(KeyCodes || (KeyCodes = {}));
12
- // search api params
13
- var InstancesSort;
14
- (function (InstancesSort) {
15
- InstancesSort["DisplayName"] = "DisplayName";
16
- InstancesSort["Rank"] = "Rank";
17
- })(InstancesSort || (InstancesSort = {}));
18
- var HierarchiesExpand;
19
- (function (HierarchiesExpand) {
20
- HierarchiesExpand["UntilChildren"] = "UntilChildren";
21
- HierarchiesExpand["OneLevel"] = "OneLevel";
22
- })(HierarchiesExpand || (HierarchiesExpand = {}));
23
- var HierarchiesSort;
24
- (function (HierarchiesSort) {
25
- HierarchiesSort["Name"] = "Name";
26
- HierarchiesSort["CumulativeInstanceCount"] = "CumulativeInstanceCount";
27
- })(HierarchiesSort || (HierarchiesSort = {}));
28
- var MetadataPropertyTypes;
29
- (function (MetadataPropertyTypes) {
30
- MetadataPropertyTypes["Double"] = "Double";
31
- MetadataPropertyTypes["String"] = "String";
32
- MetadataPropertyTypes["DateTime"] = "DateTime";
33
- MetadataPropertyTypes["Long"] = "Long";
34
- })(MetadataPropertyTypes || (MetadataPropertyTypes = {}));
35
- var ShiftTypes;
36
- (function (ShiftTypes) {
37
- ShiftTypes["startAt"] = "Start at";
38
- ShiftTypes["shifted"] = "shifted";
39
- })(ShiftTypes || (ShiftTypes = {}));
40
- var InterpolationFunctions;
41
- (function (InterpolationFunctions) {
42
- InterpolationFunctions["None"] = "";
43
- InterpolationFunctions["CurveLinear"] = "curveLinear";
44
- InterpolationFunctions["CurveStep"] = "curveStep";
45
- InterpolationFunctions["CurveStepBefore"] = "curveStepBefore";
46
- InterpolationFunctions["CurveStepAfter"] = "curveStepAfter";
47
- InterpolationFunctions["CurveBasis"] = "curveBasis";
48
- InterpolationFunctions["CurveCardinal"] = "curveCardinal";
49
- InterpolationFunctions["CurveMonotoneX"] = "curveMonotoneX";
50
- InterpolationFunctions["CurveCatmullRom"] = "curveCatmullRom";
51
- })(InterpolationFunctions || (InterpolationFunctions = {}));
52
- var ErrorCodes;
53
- (function (ErrorCodes) {
54
- ErrorCodes["InvalidInput"] = "InvalidInput";
55
- ErrorCodes["PartialSuccess"] = "PartialSuccess";
56
- })(ErrorCodes || (ErrorCodes = {}));
57
- // Linechart stack states
58
- var YAxisStates;
59
- (function (YAxisStates) {
60
- YAxisStates["Stacked"] = "stacked";
61
- YAxisStates["Shared"] = "shared";
62
- YAxisStates["Overlap"] = "overlap";
63
- })(YAxisStates || (YAxisStates = {}));
64
- var DataTypes;
65
- (function (DataTypes) {
66
- DataTypes["Numeric"] = "numeric";
67
- DataTypes["Categorical"] = "categorical";
68
- DataTypes["Events"] = "events";
69
- })(DataTypes || (DataTypes = {}));
70
- var EventElementTypes;
71
- (function (EventElementTypes) {
72
- EventElementTypes["Diamond"] = "diamond";
73
- EventElementTypes["Teardrop"] = "teardrop";
74
- })(EventElementTypes || (EventElementTypes = {}));
75
- var TooltipMeasureFormat;
76
- (function (TooltipMeasureFormat) {
77
- TooltipMeasureFormat["Enveloped"] = "Enveloped";
78
- TooltipMeasureFormat["SingleValue"] = "SingleValue";
79
- TooltipMeasureFormat["Scatter"] = "Scatter";
80
- })(TooltipMeasureFormat || (TooltipMeasureFormat = {}));
81
- var valueTypes;
82
- (function (valueTypes) {
83
- valueTypes["String"] = "String";
84
- valueTypes["Double"] = "Double";
85
- valueTypes["Long"] = "Long";
86
- valueTypes["Dynamic"] = "Dynamic";
87
- valueTypes["Boolean"] = "Boolean";
88
- valueTypes["DateTime"] = "DateTime";
89
- })(valueTypes || (valueTypes = {}));
90
-
91
- var DefaultHierarchyNavigationOptions = {
92
- instancesPageSize: 10,
93
- hierarchiesPageSize: 10,
94
- isInstancesRecursive: false,
95
- isInstancesHighlighted: false,
96
- instancesSort: InstancesSort.DisplayName,
97
- hierarchiesExpand: HierarchiesExpand.OneLevel,
98
- hierarchiesSort: HierarchiesSort.Name
99
- };
100
- var nullTsidDisplayString = "null";
101
- var swimlaneLabelConstants = {
102
- leftMarginOffset: 40,
103
- swimLaneLabelHeightPadding: 8,
104
- labelLeftPadding: 28
105
- };
106
- var CharactersToEscapeForExactSearchInstance = ['"', '`', '\'', '!', '(', ')', '^', '[', '{', ':', ']', '}', '~', '/', '\\', '@', '#', '$', '%', '&', '*', ';', '=', '.', '_', '-', '<', '>', ',', '?'];
107
- var NONNUMERICTOPMARGIN = 8;
108
- var LINECHARTTOPPADDING = 16;
109
- var GRIDCONTAINERCLASS = 'tsi-gridContainer';
110
- var LINECHARTCHARTMARGINS = {
111
- top: 40,
112
- bottom: 40,
113
- left: 70,
114
- right: 60
115
- };
116
- var LINECHARTXOFFSET = 8;
117
- var MARKERVALUENUMERICHEIGHT = 20;
118
- var VALUEBARHEIGHT = 3;
119
- var SERIESLABELWIDTH = 92;
120
-
121
- var Utils = /** @class */ (function () {
122
- function Utils() {
123
- }
124
- Utils.formatYAxisNumber = function (val) {
125
- if (Math.abs(val) < 1000000) {
126
- if (Math.abs(val) < .0000001)
127
- return d3.format('.2n')(val); // scientific for less than 1 billionth
128
- else {
129
- // grouped thousands with 7 significant digits, trim insginificant trailing 0s
130
- var formatted = d3.format(',.7r')(val);
131
- if (formatted.indexOf('.') != -1) {
132
- var lastChar = formatted[formatted.length - 1];
133
- while (lastChar == '0') {
134
- formatted = formatted.slice(0, -1);
135
- lastChar = formatted[formatted.length - 1];
136
- }
137
- if (lastChar == '.')
138
- formatted = formatted.slice(0, -1);
139
- }
140
- return formatted;
141
- }
142
- }
143
- else if (Math.abs(val) >= 1000000 && Math.abs(val) < 1000000000)
144
- return d3.format('.3s')(val); // suffix of M for millions
145
- else if (Math.abs(val) >= 1000000000 && Math.abs(val) < 1000000000000)
146
- return d3.format('.3s')(val).slice(0, -1) + 'B'; // suffix of B for billions
147
- return d3.format('.2n')(val); // scientific for everything else
148
- };
149
- Utils.getStackStates = function () {
150
- return YAxisStates;
151
- };
152
- // format [0-9]+[ms|s|m|h|d], convert to millis
153
- Utils.parseTimeInput = function (inputString) {
154
- inputString = inputString.toLowerCase();
155
- var getNumber = function (inputString, charsFromEnd) {
156
- var startAt = inputString.indexOf('pt') !== -1 ? 2 : (inputString.indexOf('p') !== -1 ? 1 : 0);
157
- return Number(inputString.slice(startAt, inputString.length - charsFromEnd));
158
- };
159
- if (inputString.indexOf('ms') == inputString.length - 2) {
160
- return getNumber(inputString, 2);
161
- }
162
- if (inputString.indexOf('s') == inputString.length - 1) {
163
- return getNumber(inputString, 1) * 1000;
164
- }
165
- if (inputString.indexOf('m') == inputString.length - 1) {
166
- return getNumber(inputString, 1) * 60 * 1000;
167
- }
168
- if (inputString.indexOf('h') == inputString.length - 1) {
169
- return getNumber(inputString, 1) * 60 * 60 * 1000;
170
- }
171
- if (inputString.indexOf('d') == inputString.length - 1) {
172
- return getNumber(inputString, 1) * 24 * 60 * 60 * 1000;
173
- }
174
- return -1;
175
- };
176
- Utils.findClosestTime = function (prevMillis, timeMap) {
177
- var minDistance = Infinity;
178
- var closestValue = null;
179
- Object.keys(timeMap).forEach(function (intervalCenterString) {
180
- var intervalCenter = Number(intervalCenterString);
181
- if (Math.abs(intervalCenter - prevMillis) < minDistance) {
182
- minDistance = Math.abs(intervalCenter - prevMillis);
183
- closestValue = intervalCenter;
184
- }
185
- });
186
- return closestValue;
187
- };
188
- Utils.getValueOfVisible = function (d, visibleMeasure) {
189
- if (d.measures) {
190
- if (d.measures[visibleMeasure] != null || d.measures[visibleMeasure] != undefined)
191
- return d.measures[visibleMeasure];
192
- }
193
- return null;
194
- };
195
- Utils.isStartAt = function (startAtString, searchSpan) {
196
- if (startAtString === void 0) { startAtString = null; }
197
- if (searchSpan === void 0) { searchSpan = null; }
198
- return (startAtString !== null && searchSpan !== null && searchSpan.from !== null);
199
- };
200
- Utils.parseShift = function (shiftString, startAtString, searchSpan) {
201
- if (startAtString === void 0) { startAtString = null; }
202
- if (searchSpan === void 0) { searchSpan = null; }
203
- if (this.isStartAt(startAtString, searchSpan)) {
204
- return (new Date(startAtString)).valueOf() - (new Date(searchSpan.from)).valueOf();
205
- }
206
- if (shiftString === undefined || shiftString === null || shiftString.length === 0) {
207
- return 0;
208
- }
209
- var millis;
210
- if (shiftString[0] === '-' || shiftString[0] === '+') {
211
- millis = (shiftString[0] === '-' ? -1 : 1) * this.parseTimeInput(shiftString.slice(1, shiftString.length));
212
- }
213
- else {
214
- millis = this.parseTimeInput(shiftString);
215
- }
216
- return -millis;
217
- };
218
- Utils.adjustStartMillisToAbsoluteZero = function (fromMillis, bucketSize) {
219
- var epochAdjustment = 62135596800000;
220
- return Math.floor((fromMillis + epochAdjustment) / bucketSize) * bucketSize - epochAdjustment;
221
- };
222
- Utils.bucketSizeToTsqInterval = function (bucketSize) {
223
- if (!bucketSize) {
224
- return null;
225
- }
226
- var bucketSizeInMillis = Utils.parseTimeInput(bucketSize);
227
- var padLeadingZeroes = function (number) {
228
- var numberAsString = String(number);
229
- if (numberAsString.length < 3)
230
- numberAsString = (numberAsString.length === 2 ? '0' : '00') + numberAsString;
231
- return numberAsString;
232
- };
233
- if (bucketSizeInMillis < 1000) {
234
- bucketSize = (bucketSize.toLowerCase().indexOf('d') !== -1) ? 'd.' : '.' + padLeadingZeroes(bucketSizeInMillis) + "s";
235
- }
236
- var prefix = bucketSize.toLowerCase().indexOf('d') !== -1 ? 'P' : 'PT';
237
- return (prefix + bucketSize).toUpperCase();
238
- };
239
- Utils.createEntityKey = function (aggName, aggIndex) {
240
- return encodeURIComponent(aggName).split(".").join("_") + "_" + aggIndex;
241
- };
242
- Utils.getColorForValue = function (chartDataOptions, value) {
243
- if (chartDataOptions.valueMapping && (chartDataOptions.valueMapping[value] !== undefined)) {
244
- return chartDataOptions.valueMapping[value].color;
245
- }
246
- return null;
247
- };
248
- Utils.rollUpContiguous = function (data) {
249
- var areEquivalentBuckets = function (d1, d2) {
250
- if (!d1.measures || !d2.measures) {
251
- return false;
252
- }
253
- if (Object.keys(d1.measures).length !== Object.keys(d2.measures).length) {
254
- return false;
255
- }
256
- return Object.keys(d1.measures).reduce(function (p, c, i) {
257
- return p && (d1.measures[c] === d2.measures[c]);
258
- }, true);
259
- };
260
- return data.filter(function (d, i) {
261
- if (i !== 0) {
262
- return !areEquivalentBuckets(d, data[i - 1]);
263
- }
264
- return true;
265
- });
266
- };
267
- Utils.formatOffsetMinutes = function (offset) {
268
- return (offset < 0 ? '-' : '+') +
269
- Math.floor(offset / 60) + ':' +
270
- (offset % 60 < 10 ? '0' : '') + (offset % 60) + '';
271
- };
272
- Utils.getOffsetMinutes = function (offset, millis) {
273
- if (offset == 'Local') {
274
- return -moment.tz.zone(moment.tz.guess()).parse(millis);
275
- }
276
- if (typeof offset == 'string' && isNaN(offset)) {
277
- return -moment.tz.zone(offset).parse(millis);
278
- }
279
- else {
280
- return offset;
281
- }
282
- };
283
- Utils.offsetUTC = function (date) {
284
- var offsettedDate = new Date(date.valueOf() - date.getTimezoneOffset() * 60 * 1000);
285
- return offsettedDate;
286
- };
287
- // inverse of getOffsetMinutes, this is the conversion factor of an offsettedTime to UTC in minutes
288
- Utils.getMinutesToUTC = function (offset, millisInOffset) {
289
- if (offset == 'Local') {
290
- return moment.tz.zone(moment.tz.guess()).utcOffset(millisInOffset);
291
- }
292
- if (typeof offset == 'string' && isNaN(offset)) {
293
- return moment.tz.zone(offset).utcOffset(millisInOffset);
294
- }
295
- else {
296
- return -offset;
297
- }
298
- };
299
- Utils.addOffsetGuess = function (timezoneName) {
300
- var timezone = moment.tz(new Date(), timezoneName.split(' ').join('_'));
301
- var formatted = timezone.format('Z');
302
- return "UTC" + formatted;
303
- };
304
- Utils.timezoneAbbreviation = function (timezoneName) {
305
- var abbr = moment.tz(new Date(), timezoneName).format('z');
306
- if (abbr[0] === '-' || abbr[0] === '+')
307
- return '';
308
- return abbr;
309
- };
310
- Utils.createTimezoneAbbreviation = function (offset) {
311
- var timezone = Utils.parseTimezoneName(offset);
312
- var timezoneAbbreviation = Utils.timezoneAbbreviation(timezone);
313
- return (timezoneAbbreviation.length !== 0 ? timezoneAbbreviation : Utils.addOffsetGuess(timezone));
314
- };
315
- Utils.parseTimezoneName = function (timezoneRaw) {
316
- if (!isNaN(timezoneRaw)) {
317
- if (timezoneRaw === 0) {
318
- return 'UTC';
319
- }
320
- return '';
321
- }
322
- if (timezoneRaw == 'Local') {
323
- return moment.tz.guess();
324
- }
325
- return timezoneRaw !== null ? timezoneRaw.split(' ').join('_') : '';
326
- };
327
- Utils.convertTimezoneToLabel = function (timezone, locdLocal) {
328
- if (locdLocal === void 0) { locdLocal = 'Local'; }
329
- var timezoneName = this.parseTimezoneName(timezone);
330
- var localPrefix = '';
331
- var offsetPrefix = '';
332
- if (timezone == 'Local') {
333
- localPrefix = locdLocal + ' - ';
334
- }
335
- if (timezone !== 'UTC') {
336
- offsetPrefix = ' (' + this.addOffsetGuess(timezoneName) + ')';
337
- }
338
- var timezoneAbbreviation = this.timezoneAbbreviation(timezoneName);
339
- var timezoneSuffix = (timezoneAbbreviation && timezoneAbbreviation.length !== 0 && timezoneAbbreviation !== 'UTC') ? ': ' + timezoneAbbreviation : '';
340
- return offsetPrefix + " " + localPrefix + timezoneName.replace(/_/g, ' ') + timezoneSuffix;
341
- };
342
- Utils.rangeTimeFormat = function (rangeMillis) {
343
- var oneSecond = 1000;
344
- var oneMinute = 60 * 1000;
345
- var oneHour = oneMinute * 60;
346
- var oneDay = oneHour * 24;
347
- var days = Math.floor(rangeMillis / oneDay);
348
- var hours = Math.floor(rangeMillis / oneHour) % 24;
349
- var minutes = Math.floor(rangeMillis / oneMinute) % 60;
350
- var seconds = Math.floor(rangeMillis / oneSecond) % 60;
351
- var millis = Math.floor(rangeMillis % 1000);
352
- if (rangeMillis >= oneDay) {
353
- return days + "d " + (hours > 0 ? (hours + "h") : "");
354
- }
355
- else if (rangeMillis >= oneHour) {
356
- return hours + "h " + (minutes > 0 ? (minutes + "m") : "");
357
- }
358
- else if (rangeMillis >= oneMinute) {
359
- return minutes + "m " + (seconds > 0 ? (seconds + "s") : "");
360
- }
361
- else if (rangeMillis >= oneSecond) {
362
- return seconds + (millis != 0 ? "." + millis : "") + "s";
363
- }
364
- return millis + "ms";
365
- };
366
- Utils.subDateTimeFormat = function (is24HourTime, usesSeconds, usesMillis) {
367
- return (is24HourTime ? "HH" : "hh") + ":mm" + (usesSeconds ? (":ss" + (usesMillis ? ".SSS" : "")) : "") + (is24HourTime ? "" : " A");
368
- };
369
- Utils.timeFormat = function (usesSeconds, usesMillis, offset, is24HourTime, shiftMillis, timeFormat, locale) {
370
- var _this = this;
371
- if (usesSeconds === void 0) { usesSeconds = false; }
372
- if (usesMillis === void 0) { usesMillis = false; }
373
- if (offset === void 0) { offset = 0; }
374
- if (is24HourTime === void 0) { is24HourTime = true; }
375
- if (shiftMillis === void 0) { shiftMillis = null; }
376
- if (timeFormat === void 0) { timeFormat = null; }
377
- if (locale === void 0) { locale = 'en'; }
378
- return function (d) {
379
- if (shiftMillis !== 0) {
380
- d = new Date(d.valueOf() + shiftMillis);
381
- }
382
- var stringFormat;
383
- if (timeFormat !== null) {
384
- stringFormat = timeFormat;
385
- }
386
- else {
387
- stringFormat = "L " + _this.subDateTimeFormat(is24HourTime, usesSeconds, usesMillis);
388
- }
389
- if (typeof offset == 'string' && isNaN(offset)) {
390
- return moment.tz(d, 'UTC').tz(offset === 'Local' ? moment.tz.guess() : offset).locale(locale).format(stringFormat);
391
- }
392
- else {
393
- return moment.tz(d, "UTC").utcOffset(offset).locale(locale).format(stringFormat);
394
- }
395
- };
396
- };
397
- Utils.splitTimeLabel = function (text) {
398
- var shouldSplit = function (str) {
399
- var splitLines = str.split(' ');
400
- return !((splitLines.length === 1) || (splitLines.length === 2 && (splitLines[1] === 'AM' || splitLines[1] === 'PM')));
401
- };
402
- text.each(function () {
403
- if (this.children == undefined || this.children.length == 0) { // don't split already split labels
404
- var text = d3.select(this);
405
- var lines = text.text().split(" ");
406
- var dy = parseFloat(text.attr("dy"));
407
- if (shouldSplit(text.text())) {
408
- var newFirstLine = lines[0] + (lines.length === 3 ? (' ' + lines[1]) : '');
409
- var newSecondLine = lines[lines.length - 1];
410
- text.text(null).append("tspan")
411
- .attr("x", 0)
412
- .attr("y", text.attr("y"))
413
- .attr("dy", dy + "em")
414
- .text(newFirstLine);
415
- text.append("tspan")
416
- .attr("x", 0)
417
- .attr("y", text.attr("y"))
418
- .attr("dy", (dy + dy * 1.4) + "em")
419
- .text(newSecondLine);
420
- }
421
- }
422
- });
423
- };
424
- Utils.getUTCHours = function (d, is24HourTime) {
425
- if (is24HourTime === void 0) { is24HourTime = true; }
426
- var hours = d.getUTCHours();
427
- if (!is24HourTime) {
428
- if (hours == 0)
429
- hours = 12;
430
- if (hours > 12)
431
- hours = hours - 12;
432
- }
433
- return hours;
434
- };
435
- Utils.UTCTwelveHourFormat = function (d) {
436
- var hours = String(this.getUTCHours(d));
437
- var minutes = (d.getUTCMinutes() < 10 ? "0" : "") + String(d.getUTCMinutes());
438
- var amPm = (d.getUTCHours() < 12) ? "AM" : "PM";
439
- return hours + ":" + minutes + " " + amPm;
440
- };
441
- Utils.getAgVisible = function (displayState, aggI, splitBy) {
442
- return (displayState[aggI].visible) ? displayState[aggI].splitBys[splitBy].visible : false;
443
- };
444
- Utils.getAgVisibleMeasure = function (displayState, aggI, splitBy) {
445
- return displayState[aggI].splitBys[splitBy].visibleType;
446
- };
447
- Utils.createSeriesTypeIcon = function (seriesType, selection) {
448
- var g = selection.append("g")
449
- .style("position", "absolute");
450
- if (seriesType == "event") {
451
- g.attr("transform", "translate(7.5,0)")
452
- .append("rect")
453
- .attr("width", 7)
454
- .attr("height", 7)
455
- .attr("transform", "rotate(45)");
456
- }
457
- else if (seriesType == "state") {
458
- g.append("rect")
459
- .attr("width", 15)
460
- .attr("height", 10);
461
- }
462
- else { // fxn
463
- g.append("path")
464
- .attr("d", "M0 5 Q 4 0, 8 5 T 16 5")
465
- .attr("fill", "none");
466
- }
467
- };
468
- Utils.strip = function (text) {
469
- var div = document.createElement('div');
470
- div.innerHTML = text;
471
- var textContent = div.textContent || div.innerText || '';
472
- return textContent;
473
- };
474
- Utils.stripForConcat = function (text) {
475
- var specialCharacters = ['"', "'", '?', '<', '>', ';'];
476
- specialCharacters.forEach(function (c) { text = text.split(c).join(''); });
477
- return text;
478
- };
479
- Utils.setSeriesLabelSubtitleText = function (subtitle, isInFocus) {
480
- if (isInFocus === void 0) { isInFocus = false; }
481
- var subtitleDatum = subtitle.data()[0];
482
- if (!subtitle.select('.tsi-splitBy').empty()) {
483
- var textAfterSplitByExists = subtitleDatum.timeShift !== '' || subtitleDatum.variableAlias;
484
- var splitByString = "".concat(subtitleDatum.splitBy).concat((textAfterSplitByExists && !isInFocus) ? ', ' : '');
485
- Utils.appendFormattedElementsFromString(subtitle.select('.tsi-splitBy'), splitByString);
486
- }
487
- if (subtitle.select('.tsi-timeShift')) {
488
- subtitle.select('.tsi-timeShift')
489
- .text(function (d) {
490
- return "".concat(subtitleDatum.timeShift).concat((subtitleDatum.variableAlias && !isInFocus) ? ', ' : '');
491
- });
492
- }
493
- if (subtitle.select('.tsi-variableAlias')) {
494
- subtitle.select('.tsi-variableAlias')
495
- .text(function (d) { return subtitleDatum.variableAlias; });
496
- }
497
- };
498
- Utils.revertAllSubtitleText = function (markerValues, opacity) {
499
- if (opacity === void 0) { opacity = 1; }
500
- var self = this;
501
- markerValues.classed('tsi-isExpanded', false)
502
- .style('opacity', opacity)
503
- .each(function () {
504
- self.setSeriesLabelSubtitleText(d3.select(this).selectAll('.tsi-tooltipSubtitle'), false);
505
- });
506
- };
507
- Utils.generateColors = function (numColors, includeColors) {
508
- if (includeColors === void 0) { includeColors = null; }
509
- var defaultColors = ['#008272', '#D869CB', '#FF8C00', '#8FE6D7', '#3195E3', '#F7727E', '#E0349E', '#C8E139', '#60B9AE',
510
- '#93CFFB', '#854CC7', '#258225', '#0078D7', '#FF2828', '#FFF100'];
511
- var postDefaultColors = d3.scaleSequential(d3.interpolateCubehelixDefault).domain([defaultColors.length - .5, numColors - .5]);
512
- var colors = [];
513
- var colorsIndex = 0;
514
- if (includeColors) { //add the colors we want to include first
515
- for (var i = 0; i < includeColors.length && colorsIndex < numColors; i++) {
516
- var color = includeColors[i];
517
- if (colors.indexOf(color) === -1) {
518
- colors.push(color);
519
- colorsIndex++;
520
- }
521
- }
522
- }
523
- for (var i = 0; colorsIndex < numColors; i++) {
524
- if (i < defaultColors.length) {
525
- if (colors.indexOf(defaultColors[i]) === -1) {
526
- colors.push(defaultColors[i]);
527
- colorsIndex++;
528
- }
529
- }
530
- else if (colors.indexOf(postDefaultColors(i)) === -1) {
531
- colors.push(postDefaultColors(i));
532
- colorsIndex++;
533
- }
534
- }
535
- return colors;
536
- };
537
- Utils.convertFromLocal = function (date) {
538
- return new Date(date.valueOf() - date.getTimezoneOffset() * 60 * 1000);
539
- };
540
- Utils.adjustDateFromTimezoneOffset = function (date) {
541
- var dateCopy = new Date(date.valueOf());
542
- dateCopy.setTime(dateCopy.getTime() + dateCopy.getTimezoneOffset() * 60 * 1000);
543
- return dateCopy;
544
- };
545
- Utils.offsetFromUTC = function (date, offset) {
546
- if (offset === void 0) { offset = 0; }
547
- var offsetMinutes = Utils.getOffsetMinutes(offset, date.valueOf());
548
- var dateCopy = new Date(date.valueOf() + offsetMinutes * 60 * 1000);
549
- return dateCopy;
550
- };
551
- Utils.offsetToUTC = function (date, offset) {
552
- if (offset === void 0) { offset = 0; }
553
- var offsetMinutes = Utils.getOffsetMinutes(offset, date.valueOf());
554
- var dateCopy = new Date(date.valueOf() - offsetMinutes * 60 * 1000);
555
- return dateCopy;
556
- };
557
- Utils.parseUserInputDateTime = function (timeText, offset) {
558
- var dateTimeFormat = "L " + this.subDateTimeFormat(true, true, true);
559
- var parsedDate = moment(timeText, dateTimeFormat).toDate();
560
- var utcDate = this.offsetToUTC(this.convertFromLocal(parsedDate), offset);
561
- return utcDate.valueOf();
562
- };
563
- Utils.getBrighterColor = function (color) {
564
- var hclColor = d3.hcl(color);
565
- if (hclColor.l < 80) {
566
- return hclColor.brighter().toString();
567
- }
568
- return hclColor.toString();
569
- };
570
- Utils.createSplitByColors = function (displayState, aggKey, ignoreIsOnlyAgg) {
571
- if (ignoreIsOnlyAgg === void 0) { ignoreIsOnlyAgg = false; }
572
- if (Object.keys(displayState[aggKey]["splitBys"]).length == 1)
573
- return [displayState[aggKey].color];
574
- var isOnlyAgg = Object.keys(displayState).reduce(function (accum, currAgg) {
575
- if (currAgg == aggKey)
576
- return accum;
577
- if (displayState[currAgg]["visible"] == false)
578
- return accum && true;
579
- return false;
580
- }, true);
581
- if (isOnlyAgg && !ignoreIsOnlyAgg) {
582
- return this.generateColors(Object.keys(displayState[aggKey]["splitBys"]).length);
583
- }
584
- var aggColor = displayState[aggKey].color;
585
- var interpolateColor = d3.scaleLinear().domain([0, Object.keys(displayState[aggKey]["splitBys"]).length])
586
- .range([d3.hcl(aggColor).darker().l, d3.hcl(aggColor).brighter().l]);
587
- var colors = [];
588
- for (var i = 0; i < Object.keys(displayState[aggKey]["splitBys"]).length; i++) {
589
- var newColor = d3.hcl(aggColor);
590
- newColor.l = interpolateColor(i);
591
- colors.push(newColor.formatHex());
592
- }
593
- return colors;
594
- };
595
- Utils.colorSplitBy = function (displayState, splitByIndex, aggKey, ignoreIsOnlyAgg) {
596
- if (ignoreIsOnlyAgg === void 0) { ignoreIsOnlyAgg = false; }
597
- if (Object.keys(displayState[aggKey]["splitBys"]).length == 1)
598
- return displayState[aggKey].color;
599
- var isOnlyAgg = Object.keys(displayState).reduce(function (accum, currAgg) {
600
- if (currAgg == aggKey)
601
- return accum;
602
- if (displayState[currAgg]["visible"] == false)
603
- return accum && true;
604
- return false;
605
- }, true);
606
- if (isOnlyAgg && !ignoreIsOnlyAgg) {
607
- var splitByColors = this.generateColors(Object.keys(displayState[aggKey]["splitBys"]).length);
608
- return splitByColors[splitByIndex];
609
- }
610
- var aggColor = displayState[aggKey].color;
611
- var interpolateColor = d3.scaleLinear().domain([0, Object.keys(displayState[aggKey]["splitBys"]).length])
612
- .range([d3.hcl(aggColor).darker().l, d3.hcl(aggColor).brighter().l]);
613
- var newColor = d3.hcl(aggColor);
614
- newColor.l = interpolateColor(splitByIndex);
615
- return newColor.formatHex();
616
- };
617
- Utils.getTheme = function (theme) {
618
- return theme ? 'tsi-' + theme : 'tsi-dark';
619
- };
620
- Utils.clearSelection = function () {
621
- var sel = window.getSelection ? window.getSelection() : document.selection;
622
- if (sel) {
623
- if (sel.removeAllRanges) {
624
- sel.removeAllRanges();
625
- }
626
- else if (sel.empty) {
627
- sel.empty();
628
- }
629
- }
630
- };
631
- Utils.mark = function (filter, text) {
632
- if (filter.length == 0)
633
- return text;
634
- var regExp = new RegExp(filter, 'gi');
635
- return text.replace(regExp, function (m) { return '<mark>' + m + '</mark>'; });
636
- };
637
- Utils.hash = function (str) {
638
- var hash = 5381, i = str.length;
639
- while (i) {
640
- hash = (hash * 33) ^ str.charCodeAt(--i);
641
- }
642
- /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
643
- * integers. Since we want the results to be always positive, convert the
644
- * signed int to an unsigned by doing an unsigned bitshift. */
645
- return hash >>> 0;
646
- };
647
- Utils.guid = function () {
648
- var s4 = function () {
649
- return Math.floor((1 + Math.random()) * 0x10000)
650
- .toString(16)
651
- .substring(1);
652
- };
653
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
654
- s4() + '-' + s4() + s4() + s4();
655
- };
656
- Utils.createValueFilter = function (aggregateKey, splitBy) {
657
- return function (d, j) {
658
- var currAggKey;
659
- var currSplitBy;
660
- if (d.aggregateKey) {
661
- currAggKey = d.aggregateKey;
662
- currSplitBy = d.splitBy;
663
- }
664
- else if (d && d.length) {
665
- currAggKey = d[0].aggregateKey;
666
- currSplitBy = d[0].splitBy;
667
- }
668
- else
669
- return true;
670
- return (currAggKey == aggregateKey && (splitBy == null || splitBy == currSplitBy));
671
- };
672
- };
673
- Utils.downloadCSV = function (csvString, csvName) {
674
- if (csvName === void 0) { csvName = "Table"; }
675
- var blob = new Blob([csvString], { type: 'text/csv;charset=utf-8;' });
676
- var blobURL = window.URL.createObjectURL(blob);
677
- var link = document.createElement("a");
678
- link.setAttribute("href", blobURL);
679
- link.setAttribute("download", csvName + ".csv");
680
- link.setAttribute("tabindex", "0");
681
- link.innerHTML = "";
682
- document.body.appendChild(link);
683
- link.click();
684
- };
685
- Utils.sanitizeString = function (str, type) {
686
- if (str === null || str === undefined) {
687
- return "";
688
- }
689
- if (type !== valueTypes.Double && type !== valueTypes.Long) {
690
- var jsonifiedString = type === valueTypes.Dynamic ? JSON.stringify(str) : String(str);
691
- if (jsonifiedString.indexOf(',') !== -1 || jsonifiedString.indexOf('"') !== -1 || jsonifiedString.indexOf('\n') !== -1 || type === valueTypes.Dynamic) {
692
- var replacedString = jsonifiedString.replace(/"/g, '""');
693
- return '"' + replacedString + '"';
694
- }
695
- }
696
- return str;
697
- };
698
- Utils.focusOnEllipsisButton = function (renderTarget) {
699
- var ellipsisContainer = d3.select(renderTarget).select(".tsi-ellipsisContainerDiv");
700
- if (!ellipsisContainer.empty()) {
701
- ellipsisContainer.select(".tsi-ellipsisButton").node().focus();
702
- }
703
- };
704
- Utils.createDownloadEllipsisOption = function (csvStringGenerator, action, downloadLabel) {
705
- if (action === void 0) { action = function () { }; }
706
- if (downloadLabel === void 0) { downloadLabel = "Download as CSV"; }
707
- return {
708
- iconClass: "download",
709
- label: downloadLabel,
710
- action: function () {
711
- Utils.downloadCSV(csvStringGenerator());
712
- action();
713
- },
714
- description: ""
715
- };
716
- };
717
- Utils.createControlPanel = function (renderTarget, legendWidth, topChartMargin, chartOptions) {
718
- d3.select(renderTarget).selectAll(".tsi-chartControlsPanel").remove();
719
- var controlPanelWidth = Math.max(1, d3.select(renderTarget).node().clientWidth -
720
- (chartOptions.legend == "shown" ? legendWidth : 0));
721
- var chartControlsPanel = d3.select(renderTarget).append("div")
722
- .attr("class", "tsi-chartControlsPanel")
723
- .style("width", controlPanelWidth + "px")
724
- .style("top", Math.max((topChartMargin - 32), 0) + "px");
725
- return chartControlsPanel;
726
- };
727
- Utils.escapeQuotesCommasAndNewlines = function (stringToEscape) {
728
- var escapedString = "";
729
- if (stringToEscape && (stringToEscape.indexOf("\"") != -1 ||
730
- stringToEscape.indexOf(",") != -1 ||
731
- stringToEscape.indexOf("\n") != -1)) {
732
- stringToEscape = stringToEscape.replace(/"/g, "\"\"");
733
- escapedString += "\"";
734
- escapedString += stringToEscape;
735
- escapedString += "\"";
736
- return escapedString;
737
- }
738
- else {
739
- return stringToEscape;
740
- }
741
- };
742
- Utils.getNonNumericHeight = function (rawHeight) {
743
- return rawHeight + NONNUMERICTOPMARGIN;
744
- };
745
- Utils.getControlPanelWidth = function (renderTarget, legendWidth, isLegendShown) {
746
- return Math.max(1, d3.select(renderTarget).node().clientWidth -
747
- (isLegendShown ? legendWidth : 0));
748
- };
749
- Utils.getValueOrDefault = function (chartOptionsObj, propertyName, defaultValue) {
750
- if (defaultValue === void 0) { defaultValue = null; }
751
- var propertyValue = chartOptionsObj[propertyName];
752
- if (propertyValue == undefined) {
753
- if (this[propertyName] == undefined)
754
- return defaultValue;
755
- return this[propertyName];
756
- }
757
- return propertyValue;
758
- };
759
- Utils.safeNotNullOrUndefined = function (valueLambda) {
760
- try {
761
- var value = valueLambda();
762
- return !(value === null || value === undefined);
763
- }
764
- catch (err) {
765
- return false;
766
- }
767
- };
768
- Utils.getAggKeys = function (data) {
769
- var aggregateCounterMap = {};
770
- return data.map(function (aggregate) {
771
- var aggName = Object.keys(aggregate)[0];
772
- var aggKey;
773
- if (aggregateCounterMap[aggName]) {
774
- aggKey = Utils.createEntityKey(aggName, aggregateCounterMap[aggName]);
775
- aggregateCounterMap[aggName] += 1;
776
- }
777
- else {
778
- aggKey = Utils.createEntityKey(aggName, 0);
779
- aggregateCounterMap[aggName] = 1;
780
- }
781
- return aggKey;
782
- });
783
- };
784
- Utils.roundToMillis = function (rawTo, bucketSize) {
785
- return Math.ceil((rawTo + 62135596800000) / (bucketSize)) * (bucketSize) - 62135596800000;
786
- };
787
- Utils.mergeSeriesForScatterPlot = function (chartData, scatterMeasures) {
788
- var _a;
789
- var _this = this;
790
- var xMeasure = chartData[scatterMeasures.X_MEASURE], yMeasure = chartData[scatterMeasures.Y_MEASURE], rMeasure = chartData[scatterMeasures.R_MEASURE];
791
- var measureNames = Utils.getScatterPlotMeasureNames(chartData, scatterMeasures);
792
- // Create data label
793
- var xLabel = xMeasure.additionalFields.Variable.substring(0, 15) + (xMeasure.additionalFields.Variable.length > 15 ? "... vs" : " vs");
794
- var yLabel = " " + yMeasure.additionalFields.Variable.substring(0, 15) + (yMeasure.additionalFields.Variable.length > 15 ? "... " : "");
795
- var rLabel = (rMeasure != null ? " vs " + rMeasure.additionalFields.Variable.substring(0, 15) + (rMeasure.additionalFields.Variable.length > 15 ? "... " : "") : "");
796
- var dataTitle = xLabel + yLabel + rLabel;
797
- // Initialize scatter plot data object
798
- var scatterData = (_a = {},
799
- _a[dataTitle] = {
800
- "": {}
801
- },
802
- _a);
803
- // Create measure types
804
- var measureTypes = {
805
- X_MEASURE_TYPE: 'avg' in xMeasure.measureTypes ? xMeasure.measureTypes['avg'] : xMeasure.measureTypes[0],
806
- Y_MEASURE_TYPE: 'avg' in yMeasure.measureTypes ? yMeasure.measureTypes['avg'] : yMeasure.measureTypes[0],
807
- R_MEASURE_TYPE: null
808
- };
809
- // Takes query and returns normalized time data
810
- var normalizeTimestampKeys = function (query) {
811
- var newTS = {};
812
- Object.keys(query.data[query.alias][""]).forEach(function (key) {
813
- var oldTime = new Date(key).valueOf();
814
- var timeShift = query.timeShift != "" ? _this.parseShift(query.timeShift, query.startAt, query.searchSpan) : 0;
815
- // Calculate real timeshift based on bucket snapping
816
- var bucketShiftInMillis = _this.adjustStartMillisToAbsoluteZero(timeShift, _this.parseShift(query.searchSpan.bucketSize));
817
- var normalizedTime = oldTime - bucketShiftInMillis;
818
- var timestamp = new Date(normalizedTime).toISOString();
819
- newTS[timestamp] = query.data[query.alias][""][key];
820
- });
821
- return newTS;
822
- };
823
- // Normalize timestamp data
824
- xMeasure.data[xMeasure.alias][""] = normalizeTimestampKeys(xMeasure);
825
- yMeasure.data[yMeasure.alias][""] = normalizeTimestampKeys(yMeasure);
826
- if (rMeasure) {
827
- rMeasure.data[rMeasure.alias][""] = normalizeTimestampKeys(rMeasure);
828
- measureTypes.R_MEASURE_TYPE = 'avg' in rMeasure.measureTypes ? rMeasure.measureTypes['avg'] : rMeasure.measureTypes[0];
829
- }
830
- // For each timestamp in X data mix measures of other series
831
- Object.keys(xMeasure.data[xMeasure.alias][""]).forEach(function (key) {
832
- if (key in yMeasure.data[yMeasure.alias][""]) {
833
- var measures = {};
834
- measures[measureNames.X_MEASURE] = xMeasure.data[xMeasure.alias][""][key][measureTypes.X_MEASURE_TYPE];
835
- measures[measureNames.Y_MEASURE] = yMeasure.data[yMeasure.alias][""][key][measureTypes.Y_MEASURE_TYPE];
836
- // Add optional R measure
837
- if (rMeasure != null && key in rMeasure.data[rMeasure.alias][""]) {
838
- measures[measureNames.R_MEASURE] = rMeasure.data[rMeasure.alias][""][key][measureTypes.R_MEASURE_TYPE];
839
- }
840
- // Discard timestamps with null valued measures
841
- if (xMeasure.data[xMeasure.alias][""][key][measureTypes.X_MEASURE_TYPE] && yMeasure.data[yMeasure.alias][""][key][measureTypes.Y_MEASURE_TYPE]) {
842
- if (rMeasure != null) {
843
- if (key in rMeasure.data[rMeasure.alias][""] && rMeasure.data[rMeasure.alias][""][key][measureTypes.R_MEASURE_TYPE])
844
- scatterData[dataTitle][""][key] = measures;
845
- }
846
- else {
847
- scatterData[dataTitle][""][key] = measures;
848
- }
849
- }
850
- }
851
- });
852
- return scatterData;
853
- };
854
- Utils.getScatterPlotMeasureNames = function (chartData, scatterMeasures) {
855
- var uniqueNameMap = {};
856
- var xMeasureName = chartData[scatterMeasures.X_MEASURE].alias + " " + chartData[scatterMeasures.X_MEASURE].additionalFields.Variable +
857
- (chartData[scatterMeasures.X_MEASURE].timeShift == "" ? "" : " " + chartData[scatterMeasures.X_MEASURE].timeShift);
858
- uniqueNameMap[xMeasureName] = 1;
859
- var yMeasureName = chartData[scatterMeasures.Y_MEASURE].alias + " " + chartData[scatterMeasures.Y_MEASURE].additionalFields.Variable +
860
- (chartData[scatterMeasures.Y_MEASURE].timeShift == "" ? "" : " " + chartData[scatterMeasures.Y_MEASURE].timeShift);
861
- if (yMeasureName in uniqueNameMap) {
862
- var tempName = yMeasureName;
863
- yMeasureName += " (" + uniqueNameMap[yMeasureName].toString() + ")";
864
- uniqueNameMap[tempName] = uniqueNameMap[tempName] + 1;
865
- }
866
- else {
867
- uniqueNameMap[yMeasureName] = 1;
868
- }
869
- var rMeasureName = chartData[scatterMeasures.R_MEASURE] ? chartData[scatterMeasures.R_MEASURE].alias + " " + chartData[scatterMeasures.R_MEASURE].additionalFields.Variable +
870
- (chartData[scatterMeasures.R_MEASURE].timeShift == "" ? "" : " " + chartData[scatterMeasures.R_MEASURE].timeShift) : null;
871
- if (rMeasureName != null) {
872
- if (rMeasureName in uniqueNameMap) {
873
- rMeasureName += " (" + uniqueNameMap[rMeasureName].toString() + ")";
874
- }
875
- }
876
- return {
877
- X_MEASURE: xMeasureName,
878
- Y_MEASURE: yMeasureName,
879
- R_MEASURE: rMeasureName ? rMeasureName : null
880
- };
881
- };
882
- Utils.getMinWarmTime = function (warmStoreFrom, retentionString) {
883
- var minWarmTime = new Date(warmStoreFrom);
884
- if (retentionString !== null) {
885
- var retentionPeriod = Utils.parseTimeInput(retentionString);
886
- minWarmTime = new Date(Math.max(minWarmTime.valueOf(), (Date.now() - retentionPeriod)));
887
- }
888
- return minWarmTime;
889
- };
890
- Utils.standardizeTSStrings = function (rawData) {
891
- var convertedData = [];
892
- rawData.forEach(function (dG, i) {
893
- var dGName = Object.keys(dG)[0];
894
- var dataGroup = dG[dGName];
895
- var convertedDataGroup = {};
896
- var dataGroupKeyedObject = {};
897
- dataGroupKeyedObject[dGName] = convertedDataGroup;
898
- convertedData.push(dataGroupKeyedObject);
899
- if (dataGroup) {
900
- Object.keys(dataGroup).forEach(function (seriesName) {
901
- convertedDataGroup[seriesName] = {};
902
- if (dataGroup[seriesName]) {
903
- Object.keys(dataGroup[seriesName]).forEach(function (rawTS) {
904
- var isoString;
905
- try {
906
- isoString = (new Date(rawTS)).toISOString();
907
- convertedDataGroup[seriesName][isoString] = dataGroup[seriesName][rawTS];
908
- }
909
- catch (RangeError) {
910
- console.log("".concat(rawTS, " is not a valid ISO time"));
911
- }
912
- });
913
- }
914
- });
915
- }
916
- });
917
- return convertedData;
918
- };
919
- // takes in an availability distribution and a min and max date, returns a tuple, where the first is the new distribution
920
- // excluding values out of the range, and the second is all excluded values
921
- Utils.cullValuesOutOfRange = function (availabilityDistribution, minDateString, maxDateString) {
922
- var dateZero = '0000-01-01T00:00:00Z';
923
- var minDateValue = new Date(minDateString).valueOf();
924
- var maxDateValue = new Date(maxDateString).valueOf();
925
- if (new Date(availabilityDistribution.range.from).valueOf() < minDateValue ||
926
- new Date(availabilityDistribution.range.to).valueOf() > maxDateValue) {
927
- var inRangeValues_1 = {};
928
- var outOfRangeValues_1 = {};
929
- var highestNotOverMaxString_1 = dateZero;
930
- var highestNotOverMaxValue_1 = (new Date(highestNotOverMaxString_1)).valueOf();
931
- var lowestAboveMinValue_1 = Infinity;
932
- Object.keys(availabilityDistribution.distribution).forEach(function (bucketKey) {
933
- var bucketValue = (new Date(bucketKey)).valueOf();
934
- if (bucketValue > maxDateValue || bucketValue < minDateValue) {
935
- outOfRangeValues_1[bucketKey] = availabilityDistribution.distribution[bucketKey];
936
- }
937
- else {
938
- inRangeValues_1[bucketKey] = availabilityDistribution.distribution[bucketKey];
939
- if (bucketValue > highestNotOverMaxValue_1) {
940
- highestNotOverMaxValue_1 = bucketValue;
941
- highestNotOverMaxString_1 = bucketKey;
942
- }
943
- if (bucketValue < lowestAboveMinValue_1) {
944
- lowestAboveMinValue_1 = bucketValue;
945
- }
946
- }
947
- });
948
- var bucketSize = this.parseTimeInput(availabilityDistribution.intervalSize);
949
- if (highestNotOverMaxString_1 !== dateZero) { // a value exists
950
- var nowMillis = new Date().valueOf();
951
- if (highestNotOverMaxValue_1 < nowMillis && (highestNotOverMaxValue_1 + bucketSize) > nowMillis) {
952
- // the new end value was before now, but after adding bucket size, its after now
953
- // so we set it to now to avoid setting it to a date in the future
954
- availabilityDistribution.range.to = new Date(nowMillis).toISOString();
955
- }
956
- else {
957
- availabilityDistribution.range.to = new Date(highestNotOverMaxValue_1 + bucketSize).toISOString();
958
- }
959
- }
960
- else {
961
- var rangeToValue = (new Date(availabilityDistribution.range.to)).valueOf();
962
- if (minDateValue > rangeToValue) { // entire window is to the right of distribution range
963
- availabilityDistribution.range.to = maxDateString;
964
- }
965
- else {
966
- var toValue = Math.min(maxDateValue + bucketSize, (new Date(availabilityDistribution.range.to)).valueOf()); //clamped to maxDateString passed in
967
- availabilityDistribution.range.to = (new Date(toValue)).toISOString();
968
- }
969
- }
970
- if (lowestAboveMinValue_1 !== Infinity) { // a value exists
971
- availabilityDistribution.range.from = (new Date(lowestAboveMinValue_1)).toISOString();
972
- }
973
- else {
974
- var rangeFromValue = (new Date(availabilityDistribution.range.from)).valueOf();
975
- if (maxDateValue < (new Date(availabilityDistribution.range.from)).valueOf()) { // entire window is to the left of distribution range
976
- availabilityDistribution.range.from = minDateString;
977
- }
978
- else {
979
- var fromValue = Math.max(minDateValue, rangeFromValue); // clamped to minDateString passed in
980
- availabilityDistribution.range.from = (new Date(fromValue)).toISOString();
981
- }
982
- }
983
- availabilityDistribution.distribution = inRangeValues_1;
984
- return [availabilityDistribution, outOfRangeValues_1];
985
- }
986
- return [availabilityDistribution, {}];
987
- };
988
- Utils.mergeAvailabilities = function (warmAvailability, coldAvailability, retentionString) {
989
- if (retentionString === void 0) { retentionString = null; }
990
- var warmStoreRange = warmAvailability.range;
991
- var minWarmTime = this.getMinWarmTime(warmStoreRange.from, retentionString);
992
- var warmStoreToMillis = new Date(warmStoreRange.to).valueOf();
993
- var coldStoreToMillis = new Date(coldAvailability.range.to).valueOf();
994
- // snap warm availability to cold availability if its ahead of cold
995
- var maxWarmTime = new Date(Math.min(warmStoreToMillis, coldStoreToMillis));
996
- var mergedAvailability = Object.assign({}, coldAvailability);
997
- mergedAvailability.warmStoreRange = [minWarmTime.toISOString(), maxWarmTime.toISOString()];
998
- if (retentionString !== null) {
999
- mergedAvailability.retentionPeriod = retentionString;
1000
- }
1001
- return mergedAvailability;
1002
- };
1003
- Utils.languageGuess = function () {
1004
- return navigator.languages && navigator.languages[0] || // Chrome / Firefox
1005
- navigator.language; // All browsers
1006
- };
1007
- Utils.memorySizeOf = function (obj) {
1008
- var bytes = 0;
1009
- var sizeOf = function (obj) {
1010
- if (obj !== null && obj !== undefined) {
1011
- switch (typeof obj) {
1012
- case 'number':
1013
- bytes += 8;
1014
- break;
1015
- case 'string':
1016
- bytes += obj.length * 2;
1017
- break;
1018
- case 'boolean':
1019
- bytes += 4;
1020
- break;
1021
- case 'object':
1022
- var objClass = Object.prototype.toString.call(obj).slice(8, -1);
1023
- if (objClass === 'Object' || objClass === 'Array') {
1024
- for (var key in obj) {
1025
- if (!obj.hasOwnProperty(key)) {
1026
- continue;
1027
- }
1028
- sizeOf(key);
1029
- sizeOf(obj[key]);
1030
- }
1031
- }
1032
- else {
1033
- bytes += obj.toString().length * 2;
1034
- }
1035
- break;
1036
- }
1037
- }
1038
- return bytes;
1039
- };
1040
- return sizeOf(obj);
1041
- };
1042
- Utils.guidForNullTSID = Utils.guid();
1043
- Utils.equalToEventTarget = (function (current, event) {
1044
- return (current == event.target);
1045
- });
1046
- Utils.isKeyDownAndNotEnter = function (e) {
1047
- if (e && e.type && e.type === 'keydown') {
1048
- var key = e.which || e.keyCode;
1049
- if (key !== 13) {
1050
- return true;
1051
- }
1052
- else {
1053
- e.preventDefault();
1054
- }
1055
- }
1056
- return false;
1057
- };
1058
- Utils.getInstanceKey = function (instance) {
1059
- return Utils.instanceHasEmptyTSID(instance) ? Utils.guid() : instance.timeSeriesId.map(function (id) { return id === null ? Utils.guidForNullTSID : id; }).join();
1060
- };
1061
- Utils.stripNullGuid = function (str) {
1062
- return str.replace(Utils.guidForNullTSID, nullTsidDisplayString);
1063
- };
1064
- Utils.getTimeSeriesIdString = function (instance) {
1065
- return instance.timeSeriesId.map(function (id) { return id === null ? nullTsidDisplayString : id; }).join(', ');
1066
- };
1067
- Utils.getTimeSeriesIdToDisplay = function (instance, emptyDisplayString) {
1068
- return Utils.instanceHasEmptyTSID(instance) ? emptyDisplayString : instance.timeSeriesId.map(function (id) { return id === null ? Utils.guidForNullTSID : id; }).join(', ');
1069
- };
1070
- Utils.getHighlightedTimeSeriesIdToDisplay = function (instance) {
1071
- var _a;
1072
- return (_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.timeSeriesId.map(function (id, idx) { return instance.timeSeriesId[idx] === null ? Utils.guidForNullTSID : id; }).join(', ');
1073
- };
1074
- Utils.instanceHasEmptyTSID = function (instance) {
1075
- return !instance.timeSeriesId || instance.timeSeriesId.length === 0;
1076
- };
1077
- // appends dom elements of stripped strings including hits (for instance search results) and mono classed spans (for null tsid)
1078
- Utils.appendFormattedElementsFromString = function (targetElem, str, options) {
1079
- if (options === void 0) { options = null; }
1080
- var data = [];
1081
- var splitByNullGuid = function (str) {
1082
- var data = [];
1083
- var splittedByNull = str.split(Utils.guidForNullTSID);
1084
- splittedByNull.forEach(function (s, i) {
1085
- if (i === 0) {
1086
- if (s) {
1087
- data.push({ str: s });
1088
- }
1089
- }
1090
- else {
1091
- data.push({ str: nullTsidDisplayString, isNull: true });
1092
- if (s) {
1093
- data.push({ str: s });
1094
- }
1095
- }
1096
- });
1097
- return data;
1098
- };
1099
- var splitByTag = options && options.splitByTag ? options.splitByTag : 'hit';
1100
- var splittedByHit = str.split("<".concat(splitByTag, ">"));
1101
- splittedByHit.forEach(function (s, i) {
1102
- if (i === 0) {
1103
- data = data.concat(splitByNullGuid(s));
1104
- }
1105
- else {
1106
- var splittedByHitClose = s.split("</".concat(splitByTag, ">"));
1107
- data.push({ str: splittedByHitClose[0], isHit: true });
1108
- data = data.concat(splitByNullGuid(splittedByHitClose[1]));
1109
- }
1110
- });
1111
- var additionalClassName = options && options.additionalClassName ? options.additionalClassName : '';
1112
- var children = targetElem.selectAll('.tsi-formattedChildren').data(data);
1113
- children.enter()
1114
- .append(function (d) {
1115
- return d.isHit ? document.createElement('mark')
1116
- : options && options.inSvg ? document.createElementNS('http://www.w3.org/2000/svg', 'tspan')
1117
- : document.createElement('span');
1118
- })
1119
- .classed('tsi-formattedChildren', true)
1120
- .merge(children)
1121
- .classed('tsi-baseMono', function (d) { return d.isNull; })
1122
- .classed(additionalClassName, options && options.additionalClassName)
1123
- .text(function (d) { return d.str; });
1124
- children.exit().remove();
1125
- };
1126
- Utils.escapedTsidForExactSearch = function (tsid) {
1127
- var escapedTsid = tsid || '';
1128
- if (tsid) {
1129
- CharactersToEscapeForExactSearchInstance.forEach(function (c) {
1130
- escapedTsid = escapedTsid.split(c).join('+');
1131
- });
1132
- }
1133
- return escapedTsid;
1134
- };
1135
- return Utils;
1136
- }());
1137
-
1138
- export { DataTypes as D, EventElementTypes as E, GRIDCONTAINERCLASS as G, InterpolationFunctions as I, KeyCodes as K, LINECHARTTOPPADDING as L, MARKERVALUENUMERICHEIGHT as M, NONNUMERICTOPMARGIN as N, ShiftTypes as S, TooltipMeasureFormat as T, Utils as U, VALUEBARHEIGHT as V, YAxisStates as Y, DefaultHierarchyNavigationOptions as a, LINECHARTXOFFSET as b, LINECHARTCHARTMARGINS as c, SERIESLABELWIDTH as d, swimlaneLabelConstants as s, valueTypes as v };