@splunk/visualizations 26.1.1 → 26.2.0

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 (159) hide show
  1. package/Area.config.js +2 -1
  2. package/Area.config.js.map +1 -1
  3. package/Area.js +1562 -433
  4. package/Area.js.map +1 -1
  5. package/Bar.config.js +1 -0
  6. package/Bar.config.js.map +1 -1
  7. package/Bar.js +1555 -430
  8. package/Bar.js.map +1 -1
  9. package/Bubble.config.js +1 -0
  10. package/Bubble.config.js.map +1 -1
  11. package/Bubble.js +1580 -455
  12. package/Bubble.js.map +1 -1
  13. package/ChoroplethSvg.config.js +1 -0
  14. package/ChoroplethSvg.config.js.map +1 -1
  15. package/ChoroplethSvg.js +1418 -351
  16. package/ChoroplethSvg.js.map +1 -1
  17. package/Column.config.js +2 -1
  18. package/Column.config.js.map +1 -1
  19. package/Column.js +1564 -435
  20. package/Column.js.map +1 -1
  21. package/Ellipse.config.js +1 -0
  22. package/Ellipse.config.js.map +1 -1
  23. package/Ellipse.js +1342 -297
  24. package/Ellipse.js.map +1 -1
  25. package/Events.config.js +4 -0
  26. package/Events.config.js.map +1 -1
  27. package/Events.js +1503 -489
  28. package/Events.js.map +1 -1
  29. package/FEATUREFLAGS.md +3 -0
  30. package/FillerGauge.config.js +1 -0
  31. package/FillerGauge.config.js.map +1 -1
  32. package/FillerGauge.js +1406 -345
  33. package/FillerGauge.js.map +1 -1
  34. package/Image.config.js +1 -0
  35. package/Image.config.js.map +1 -1
  36. package/Image.js +2355 -1183
  37. package/Image.js.map +1 -1
  38. package/Line.config.js +2 -1
  39. package/Line.config.js.map +1 -1
  40. package/Line.js +1562 -433
  41. package/Line.js.map +1 -1
  42. package/LinkGraph.config.js +1 -0
  43. package/LinkGraph.config.js.map +1 -1
  44. package/LinkGraph.js +2013 -968
  45. package/LinkGraph.js.map +1 -1
  46. package/Map.config.js +1 -0
  47. package/Map.config.js.map +1 -1
  48. package/Map.js +2556 -1527
  49. package/Map.js.map +1 -1
  50. package/Markdown.config.js +1 -0
  51. package/Markdown.config.js.map +1 -1
  52. package/Markdown.js +1952 -883
  53. package/Markdown.js.map +1 -1
  54. package/MarkerGauge.config.js +1 -0
  55. package/MarkerGauge.config.js.map +1 -1
  56. package/MarkerGauge.js +4049 -2965
  57. package/MarkerGauge.js.map +1 -1
  58. package/ParallelCoordinates.config.js +1 -0
  59. package/ParallelCoordinates.config.js.map +1 -1
  60. package/ParallelCoordinates.js +3286 -2215
  61. package/ParallelCoordinates.js.map +1 -1
  62. package/Pie.config.js +1 -0
  63. package/Pie.config.js.map +1 -1
  64. package/Pie.js +2187 -1036
  65. package/Pie.js.map +1 -1
  66. package/Punchcard.config.js +1 -0
  67. package/Punchcard.config.js.map +1 -1
  68. package/Punchcard.js +3397 -2299
  69. package/Punchcard.js.map +1 -1
  70. package/Rectangle.config.js +1 -0
  71. package/Rectangle.config.js.map +1 -1
  72. package/Rectangle.js +2181 -1112
  73. package/Rectangle.js.map +1 -1
  74. package/Sankey.config.js +1 -0
  75. package/Sankey.config.js.map +1 -1
  76. package/Sankey.js +3275 -2199
  77. package/Sankey.js.map +1 -1
  78. package/Scatter.config.js +1 -0
  79. package/Scatter.config.js.map +1 -1
  80. package/Scatter.js +3551 -2400
  81. package/Scatter.js.map +1 -1
  82. package/SingleValue.config.js +27 -0
  83. package/SingleValue.config.js.map +1 -1
  84. package/SingleValue.js +5551 -4397
  85. package/SingleValue.js.map +1 -1
  86. package/SingleValueBasic.js +1227 -1209
  87. package/SingleValueBasic.js.map +1 -1
  88. package/SingleValueIcon.config.js +27 -0
  89. package/SingleValueIcon.config.js.map +1 -1
  90. package/SingleValueIcon.js +2850 -1696
  91. package/SingleValueIcon.js.map +1 -1
  92. package/SingleValueRadial.config.js +1 -0
  93. package/SingleValueRadial.config.js.map +1 -1
  94. package/SingleValueRadial.js +6334 -5215
  95. package/SingleValueRadial.js.map +1 -1
  96. package/SparkLine.js +96 -96
  97. package/SparkLine.js.map +1 -1
  98. package/Table.config.js +172 -7
  99. package/Table.config.js.map +1 -1
  100. package/Table.js +3517 -2212
  101. package/Table.js.map +1 -1
  102. package/common/Charting.js +1009 -82
  103. package/common/Charting.js.map +1 -1
  104. package/common/ChartingApi.js +4 -4
  105. package/common/ChartingApi.js.map +1 -1
  106. package/common/DocExampleWithVizSandbox.js +54 -57
  107. package/common/DocExampleWithVizSandbox.js.map +1 -1
  108. package/common/EventsDoc.js +40 -40
  109. package/common/EventsDoc.js.map +1 -1
  110. package/common/GaugeMajorTicks.js +15 -13
  111. package/common/GaugeMajorTicks.js.map +1 -1
  112. package/common/GaugeValueMarker.js +12 -12
  113. package/common/GaugeValueMarker.js.map +1 -1
  114. package/common/OptionsDoc.js +34 -34
  115. package/common/OptionsDoc.js.map +1 -1
  116. package/common/OverviewDoc.js +124 -103
  117. package/common/OverviewDoc.js.map +1 -1
  118. package/common/SplunkVisualization.js +49 -49
  119. package/common/SplunkVisualization.js.map +1 -1
  120. package/common/SplunkVisualizationApi.js +4 -4
  121. package/common/SplunkVisualizationApi.js.map +1 -1
  122. package/common/ThemesDoc.js +31 -31
  123. package/common/ThemesDoc.js.map +1 -1
  124. package/common/chartingUtils.js +24 -8
  125. package/common/chartingUtils.js.map +1 -1
  126. package/common/docUtils.js +4 -4
  127. package/common/docUtils.js.map +1 -1
  128. package/common/gaugeUtils.js +16 -16
  129. package/common/gaugeUtils.js.map +1 -1
  130. package/common/shapeUtils.js +36 -36
  131. package/common/shapeUtils.js.map +1 -1
  132. package/common/utils/configUtils.js +48 -47
  133. package/common/utils/configUtils.js.map +1 -1
  134. package/common/utils/dataUtils.js +832 -6
  135. package/common/utils/dataUtils.js.map +1 -1
  136. package/common/utils/featureFlagUtils.js +139 -0
  137. package/common/utils/featureFlagUtils.js.map +1 -0
  138. package/common/utils/hocUtils.js +2 -2
  139. package/common/utils/hocUtils.js.map +1 -1
  140. package/common/utils/layoutUtils.js +2 -2
  141. package/common/utils/layoutUtils.js.map +1 -1
  142. package/common/utils/mapUtils.js +77 -54
  143. package/common/utils/mapUtils.js.map +1 -1
  144. package/common/utils/singleValueUtils.js +28 -19
  145. package/common/utils/singleValueUtils.js.map +1 -1
  146. package/common/utils/testHelper.js +10 -10
  147. package/common/utils/testHelper.js.map +1 -1
  148. package/common/utils/trellisUtils.js +6 -6
  149. package/common/utils/trellisUtils.js.map +1 -1
  150. package/common/utils/urlUtils.js +2 -2
  151. package/common/utils/urlUtils.js.map +1 -1
  152. package/common/withDashboardViz.js +1313 -235
  153. package/common/withDashboardViz.js.map +1 -1
  154. package/package.json +13 -12
  155. package/__mocks__/fileMock.js +0 -2
  156. package/__mocks__/styleMock.js +0 -2
  157. package/babel.config.js +0 -11
  158. package/jest.config.js +0 -8
  159. package/loki.config.js +0 -14
@@ -87,7 +87,7 @@ module.exports =
87
87
  /******/
88
88
  /******/
89
89
  /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 83);
90
+ /******/ return __webpack_require__(__webpack_require__.s = 104);
91
91
  /******/ })
92
92
  /************************************************************************/
93
93
  /******/ ([
@@ -118,13 +118,13 @@ module.exports = require("lodash");
118
118
  /* 4 */
119
119
  /***/ (function(module, exports) {
120
120
 
121
- module.exports = require("@splunk/ui-utils/i18n");
121
+ module.exports = require("@babel/runtime/helpers/classCallCheck");
122
122
 
123
123
  /***/ }),
124
124
  /* 5 */
125
125
  /***/ (function(module, exports) {
126
126
 
127
- module.exports = require("@babel/runtime/helpers/classCallCheck");
127
+ module.exports = require("@splunk/ui-utils/i18n");
128
128
 
129
129
  /***/ }),
130
130
  /* 6 */,
@@ -143,61 +143,930 @@ module.exports = require("@babel/runtime/helpers/slicedToArray");
143
143
  /* 9 */
144
144
  /***/ (function(module, exports) {
145
145
 
146
+ module.exports = require("@splunk/visualizations-shared/numberUtils");
147
+
148
+ /***/ }),
149
+ /* 10 */
150
+ /***/ (function(module, exports) {
151
+
146
152
  module.exports = require("@babel/runtime/helpers/defineProperty");
147
153
 
148
154
  /***/ }),
149
- /* 10 */,
150
155
  /* 11 */,
151
156
  /* 12 */,
152
157
  /* 13 */,
153
158
  /* 14 */
159
+ /***/ (function(module, exports, __webpack_require__) {
160
+
161
+ "use strict";
162
+
163
+
164
+ var _classCallCheck = __webpack_require__(4);
165
+
166
+ var _createClass = __webpack_require__(7);
167
+
168
+ Object.defineProperty(exports, "__esModule", {
169
+ value: true
170
+ });
171
+ exports.DefaultVizActionHandler = void 0;
172
+
173
+ var DefaultVizActionHandler = /*#__PURE__*/function () {
174
+ function DefaultVizActionHandler() {
175
+ _classCallCheck(this, DefaultVizActionHandler);
176
+ }
177
+
178
+ _createClass(DefaultVizActionHandler, [{
179
+ key: "focus",
180
+ value: function focus() {// noop
181
+ }
182
+ }, {
183
+ key: "snapshot",
184
+ value: function snapshot() {
185
+ return null; // noop
186
+ }
187
+ }]);
188
+
189
+ return DefaultVizActionHandler;
190
+ }();
191
+
192
+ exports.DefaultVizActionHandler = DefaultVizActionHandler;
193
+
194
+ /***/ }),
195
+ /* 15 */,
196
+ /* 16 */
154
197
  /***/ (function(module, exports) {
155
198
 
156
- module.exports = require("@splunk/visualizations-shared/colorUtils");
199
+ module.exports = require("@splunk/visualizations-shared/colorUtils");
200
+
201
+ /***/ }),
202
+ /* 17 */,
203
+ /* 18 */
204
+ /***/ (function(module, exports, __webpack_require__) {
205
+
206
+ "use strict";
207
+
208
+
209
+ Object.defineProperty(exports, "__esModule", {
210
+ value: true
211
+ });
212
+ exports.VizBehavior = void 0;
213
+ var VizBehavior;
214
+
215
+ (function (VizBehavior) {
216
+ /**
217
+ * Dynamic Options Behavior.
218
+ * This allows visualization options to be powered by data
219
+ *
220
+ * **Example**
221
+ *
222
+ * sparklineValues: ">primary|seriesByIndex(0)"
223
+ * would configure sparklineValues with an array of data points
224
+ * coming from the first series in the primary datasource
225
+ *
226
+ */
227
+ VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
228
+ VizBehavior["EVENTS"] = "events";
229
+ VizBehavior["DOWNSAMPLING"] = "downsampling";
230
+ /**
231
+ * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
232
+ * missing.
233
+ * @type {string}
234
+ */
235
+
236
+ VizBehavior["PLACEHOLDER"] = "placeholder";
237
+ VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
238
+ VizBehavior["TRELLIS"] = "trellis";
239
+ })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
240
+
241
+ /***/ }),
242
+ /* 19 */
243
+ /***/ (function(module, exports, __webpack_require__) {
244
+
245
+ "use strict";
246
+
247
+
248
+ Object.defineProperty(exports, "__esModule", {
249
+ value: true
250
+ });
251
+ exports.VizCategory = void 0;
252
+ var VizCategory;
253
+
254
+ (function (VizCategory) {
255
+ VizCategory["SINGLE_VALUE"] = "Single Value";
256
+ VizCategory["TRENDS"] = "Trends";
257
+ VizCategory["COMPARISONS"] = "Comparisons";
258
+ VizCategory["TABLE"] = "Table";
259
+ VizCategory["GAUGE"] = "Gauge";
260
+ VizCategory["DISTRIBUTIONS"] = "Distributions";
261
+ VizCategory["CHOROPLETH"] = "Choropleth Maps";
262
+ VizCategory["SHAPES"] = "Shapes";
263
+ VizCategory["MISC"] = "misc";
264
+ VizCategory["FLOW"] = "Flow";
265
+ VizCategory["CORRELATION"] = "Correlation";
266
+ VizCategory["SPATIAL"] = "Spatial";
267
+ })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
268
+
269
+ /***/ }),
270
+ /* 20 */,
271
+ /* 21 */,
272
+ /* 22 */
273
+ /***/ (function(module, exports) {
274
+
275
+ module.exports = require("@babel/runtime/helpers/toConsumableArray");
276
+
277
+ /***/ }),
278
+ /* 23 */,
279
+ /* 24 */
280
+ /***/ (function(module, exports) {
281
+
282
+ module.exports = require("@splunk/visualizations-shared/Message");
283
+
284
+ /***/ }),
285
+ /* 25 */
286
+ /***/ (function(module, exports, __webpack_require__) {
287
+
288
+ "use strict";
289
+
290
+
291
+ Object.defineProperty(exports, "__esModule", {
292
+ value: true
293
+ });
294
+ exports.downsampleDataSources = exports.calculateDownsamplingThreshold = exports.calculateThresholdOnRangeSelect = exports.isDownsamplingEnabledForViz = exports.convertToArrOfObjects = void 0;
295
+
296
+ var numberUtils_1 = __webpack_require__(9);
297
+
298
+ var interfaces_1 = __webpack_require__(32); // TODO: utilize this fn in ParallelCoordinates
299
+
300
+
301
+ var convertToArrOfObjects = function convertToArrOfObjects(columns, fields) {
302
+ if (!columns || !columns[0] || !columns[0].length) return [];
303
+ var data = [];
304
+
305
+ var _loop = function _loop(i) {
306
+ var newObj = {};
307
+ fields.forEach(function (field, index) {
308
+ var fieldName = typeof field === 'string' ? field : field.name;
309
+
310
+ if (columns[index][i] === '') {
311
+ newObj[fieldName] = null;
312
+ } else {
313
+ newObj[fieldName] = columns[index][i];
314
+ }
315
+ });
316
+ data.push(newObj);
317
+ };
318
+
319
+ for (var i = 0; i < columns[0].length; i += 1) {
320
+ _loop(i);
321
+ }
322
+
323
+ return data;
324
+ };
325
+
326
+ exports.convertToArrOfObjects = convertToArrOfObjects; // LTTB algorithm which can be used to downsample time series data while striving to maintain
327
+ // the spikes and overall shape of the chart
328
+ // Copied from https://github.com/sveinn-steinarsson/flot-downsample/blob/0815010016fc94b1bbc6a010afb8aad13ada6d0d/jquery.flot.downsample.js
329
+ // Modifications include:
330
+ // 1) Convert to modern JavaScript(use const, let, and use array.push to push to last element of array)
331
+ // 2) Convert to camel case
332
+ // 3) Convert to TS and also return the indices of the points that are in the downsampled result.
333
+ // 4) Add a new parameter preferredDownsampleIndices that correspond to the indices of points
334
+ // that should be used in case of a tie of the max area in a bucket
335
+
336
+ var largestTriangleThreeBuckets = function largestTriangleThreeBuckets(data, threshold, preferredDownsampleIndices) {
337
+ var dataLength = data.length;
338
+ var downsampledIndices = [];
339
+
340
+ if (threshold >= dataLength || threshold === 0) {
341
+ var allIndices = data.map(function (values, index) {
342
+ return index;
343
+ });
344
+ return {
345
+ downsampledData: data,
346
+ downsampledIndices: allIndices
347
+ }; // Nothing to do
348
+ }
349
+
350
+ var sampled = [];
351
+ var sampledIndex = 0; // Bucket size. Leave room for start and end data points
352
+
353
+ var every = (dataLength - 2) / (threshold - 2);
354
+ var a = 0; // Initially a is the first point in the triangle
355
+
356
+ var maxAreaPoint;
357
+ var maxArea;
358
+ var area;
359
+ var nextA;
360
+ sampled.push(data[a]); // Always add the first point
361
+
362
+ downsampledIndices.push(0); // eslint-disable-next-line no-plusplus
363
+
364
+ for (var i = 0; i < threshold - 2; i++) {
365
+ // Calculate point average for next bucket (containing c)
366
+ var avgX = 0;
367
+ var avgY = 0;
368
+ var avgRangeStart = Math.floor((i + 1) * every) + 1;
369
+ var avgRangeEnd = Math.floor((i + 2) * every) + 1;
370
+ avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
371
+ var avgRangeLength = avgRangeEnd - avgRangeStart; // eslint-disable-next-line no-plusplus
372
+
373
+ for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
374
+ avgX += Number(data[avgRangeStart][0]); // * 1 enforces Number (value may be Date)
375
+
376
+ avgY += data[avgRangeStart][1] * 1;
377
+ }
378
+
379
+ avgX /= avgRangeLength;
380
+ avgY /= avgRangeLength; // Get the range for this bucket
381
+
382
+ var rangeOffs = Math.floor((i + 0) * every) + 1;
383
+ var rangeTo = Math.floor((i + 1) * every) + 1; // Point a
384
+
385
+ var pointAX = Number(data[a][0]); // Enforce Number (value may be Date)
386
+
387
+ var pointAY = data[a][1] * 1; // eslint-disable-next-line no-multi-assign
388
+
389
+ maxArea = area = -1;
390
+ var maxAreaIndex = rangeOffs; // eslint-disable-next-line no-plusplus
391
+
392
+ for (; rangeOffs < rangeTo; rangeOffs++) {
393
+ // Calculate triangle area over three buckets
394
+ area = Math.abs((pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)) * 0.5; // Modification: try to downsample the least amount of points possible when there are multiple series
395
+ // If all points in a bucket have the same area, prioritize the one with an x index
396
+ // that also existed from another series so we don't add another point unnecessarily.
397
+ // By default LTTB picks the leftmost point in the bucket
398
+
399
+ if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
400
+ maxArea = area;
401
+ maxAreaPoint = data[rangeOffs];
402
+ nextA = rangeOffs; // Next a is this b
403
+ // Modification: save the index of the point with the most area
404
+
405
+ maxAreaIndex = rangeOffs;
406
+ }
407
+ } // eslint-disable-next-line no-plusplus
408
+
409
+
410
+ sampled[sampledIndex++] = maxAreaPoint; // Pick this point from the bucket
411
+
412
+ downsampledIndices.push(maxAreaIndex);
413
+ a = nextA; // This a is the next a (chosen b)
414
+ } // eslint-disable-next-line no-plusplus
415
+
416
+
417
+ sampled[sampledIndex++] = data[dataLength - 1]; // Always add last
418
+
419
+ downsampledIndices.push(dataLength - 1);
420
+ return {
421
+ downsampledData: sampled,
422
+ downsampledIndices: downsampledIndices
423
+ };
424
+ };
425
+ /**
426
+ * Strictly coerces the entire column to numbers if it only consists of numeric strings or numbers. Also determines
427
+ * if at least one of the values in the column can be loosely coerced to a number.
428
+ * If the column cannot be strictly downsampled (if it contains nulls or non-numeric strings), returns an empty array and
429
+ * returns that it cannot downsample the column.
430
+ */
431
+
432
+
433
+ var strictlyCoerceYColumn = function strictlyCoerceYColumn(column) {
434
+ // Splunk charting allows for numbers in formats such as negative hex that
435
+ // Number() does not support and also allows loose coercion of hex numbers (but not other formats)
436
+ // We want to identify columns which contain at least one value that can be loosely coerced
437
+ var canLooselyCoerceSomeValues = column.findIndex(function (value) {
438
+ return (0, numberUtils_1.startsWithNumber)("".concat(value));
439
+ }) >= 0; // If not all values in column can be strictly coerced to a number, we do not downsample
440
+
441
+ var coercedColumn = [];
442
+ var canDownsampleColumn = !column.some(function (value) {
443
+ var coercedValue = Number(value); // if it can't be parsed or isn't safe, fail
444
+
445
+ if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== 'string' && typeof value !== 'number') {
446
+ return true;
447
+ } // save value and continue to next
448
+
449
+
450
+ coercedColumn.push(coercedValue);
451
+ return false;
452
+ });
453
+ return {
454
+ canDownsampleColumn: canDownsampleColumn,
455
+ canLooselyCoerceSomeValues: canLooselyCoerceSomeValues,
456
+ coercedColumn: canDownsampleColumn ? coercedColumn : []
457
+ };
458
+ };
459
+ /**
460
+ * Tries to coerce the x-column to numbers or dates, if it is eligible for downsampling.
461
+ * Only strictly increasing x-columns are eligible for downsampling.
462
+ * If the column is not eligible for downsampling, returns an empty array.
463
+ */
464
+
465
+
466
+ var strictlyCoerceXColumn = function strictlyCoerceXColumn(column, fieldType) {
467
+ if (fieldType === 'number') {
468
+ var coercedXColumn = column.map(function (xValue) {
469
+ return Number(xValue);
470
+ });
471
+
472
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
473
+ return coercedXColumn;
474
+ }
475
+ } else if (fieldType === 'time') {
476
+ var _coercedXColumn = column.map(function (xValue) {
477
+ return new Date(xValue);
478
+ });
479
+
480
+ if (isColumnStrictlyIncreasing(_coercedXColumn, fieldType)) {
481
+ return _coercedXColumn;
482
+ }
483
+ }
484
+
485
+ return [];
486
+ };
487
+
488
+ var isDownsamplingEnabledForViz = function isDownsamplingEnabledForViz(_ref) {
489
+ var vizConfig = _ref.vizConfig;
490
+
491
+ var _a;
492
+
493
+ return (_a = vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(interfaces_1.VizBehavior.DOWNSAMPLING);
494
+ };
495
+
496
+ exports.isDownsamplingEnabledForViz = isDownsamplingEnabledForViz;
497
+
498
+ var calculateThresholdOnRangeSelect = function calculateThresholdOnRangeSelect(_ref2) {
499
+ var firstIndex = _ref2.firstIndex,
500
+ lastIndex = _ref2.lastIndex,
501
+ dataSources = _ref2.dataSources,
502
+ width = _ref2.width;
503
+
504
+ var _a, _b, _c;
505
+
506
+ var window = lastIndex - firstIndex + 1;
507
+ var ratio = Math.round(Number(((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns[0]) === null || _c === void 0 ? void 0 : _c.length) / window) * 10) / 10;
508
+ return Math.round(ratio * Number(width));
509
+ };
510
+
511
+ exports.calculateThresholdOnRangeSelect = calculateThresholdOnRangeSelect;
512
+ /**
513
+ * Calculates the downsampling threshold based on the range selection. If search zoom is enabled or there is no selection,
514
+ * then returns the width of the visualization.
515
+ *
516
+ * Otherwise calculates the threshold based on the ratio of the window selected compared to the size of the non-downsampled
517
+ * data sources. Returns null if the chart event's dataset does not match the passed in primary data source or if the chart is zoomed
518
+ * in for a categorical chart.
519
+ */
520
+
521
+ var calculateDownsamplingThreshold = function calculateDownsamplingThreshold(_ref3) {
522
+ var enableSearchZoom = _ref3.enableSearchZoom,
523
+ dataSources = _ref3.dataSources,
524
+ selectChartEvent = _ref3.selectChartEvent,
525
+ width = _ref3.width,
526
+ xField = _ref3.xField,
527
+ y2Fields = _ref3.y2Fields;
528
+
529
+ var _a, _b, _c;
530
+
531
+ if (enableSearchZoom || !selectChartEvent) {
532
+ return Number(width);
533
+ }
534
+
535
+ var primaryDataSource = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary;
536
+
537
+ if (!primaryDataSource) {
538
+ return null;
539
+ }
540
+
541
+ var startXIndex = selectChartEvent.startXIndex,
542
+ endXIndex = selectChartEvent.endXIndex,
543
+ currentTarget = selectChartEvent.currentTarget;
544
+
545
+ try {
546
+ var xFieldIndex = (_a = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _a === void 0 ? void 0 : _a.fields.findIndex(function (field) {
547
+ return field.name === xField;
548
+ });
549
+ var downsampledXFieldIndex = (_b = currentTarget.dataSet) === null || _b === void 0 ? void 0 : _b.fields.findIndex(function (field) {
550
+ return field === xField;
551
+ });
552
+
553
+ if (xFieldIndex === -1 || downsampledXFieldIndex === -1) {
554
+ return null;
555
+ }
556
+
557
+ var fullSeries = (_c = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _c === void 0 ? void 0 : _c.columns[xFieldIndex];
558
+ var downsampledSeries = currentTarget.dataSet.seriesList[downsampledXFieldIndex];
559
+ var firstIndex = fullSeries.findIndex(function (x) {
560
+ return downsampledSeries[startXIndex] === x;
561
+ });
562
+ var lastIndex = fullSeries.findIndex(function (x) {
563
+ return downsampledSeries[endXIndex] === x;
564
+ }); // For charts with categorical x-axis (charts with an xField that isn't _time), do not support
565
+ // re-calculating downsampling threshold if the chart is zoomed in until SPL-259458 is fixed
566
+ // Also do not support re-calculating downsampling threshold for zoomed-in charts with y2
567
+ // until SPL-259611 is fixed
568
+
569
+ if (xField !== '_time' || (y2Fields === null || y2Fields === void 0 ? void 0 : y2Fields.length)) {
570
+ return firstIndex === 0 && lastIndex === fullSeries.length - 1 ? width : null;
571
+ }
572
+
573
+ if (firstIndex >= 0 && lastIndex >= 0 && firstIndex <= lastIndex) {
574
+ return (0, exports.calculateThresholdOnRangeSelect)({
575
+ firstIndex: firstIndex,
576
+ lastIndex: lastIndex,
577
+ dataSources: dataSources,
578
+ width: width
579
+ });
580
+ }
581
+ } catch (e) {
582
+ console.error('Error occurred while setting downsample threshold on range select event', e);
583
+ }
584
+
585
+ return null;
586
+ };
587
+
588
+ exports.calculateDownsamplingThreshold = calculateDownsamplingThreshold;
589
+
590
+ var isColumnStrictlyIncreasing = function isColumnStrictlyIncreasing(column, fieldType) {
591
+ return column.every(function (value, index) {
592
+ if (fieldType === 'number') {
593
+ if (Number.isNaN(value)) {
594
+ return false;
595
+ }
596
+ }
597
+
598
+ if (fieldType === 'time') {
599
+ if (Number.isNaN(value.getTime())) {
600
+ return false;
601
+ }
602
+ }
603
+
604
+ if (index === 0) {
605
+ return true;
606
+ }
607
+
608
+ return value > column[index - 1];
609
+ });
610
+ };
611
+ /**
612
+ * Verifies that all of the columns that are displayed in a chart can be downsampled. Valid columns that can be
613
+ * displayed are those that contain at least one number. We can only downsample columns that only consist of numbers.
614
+ *
615
+ * If all columns can be downsampled, returns the x column coerced to time/number and y columns coerced to numbers.
616
+ * If not all columns can be downsampled, then returns empty arrays for both x and y
617
+ */
618
+
619
+
620
+ var tryToCoerceAllDisplayedFields = function tryToCoerceAllDisplayedFields(ds, xField, yFields, fieldTypes) {
621
+ var xColumn = [];
622
+ var yColumns = [];
623
+ var canDownsample = !ds.data.fields.some(function (field, index) {
624
+ var _a, _b;
625
+
626
+ var fieldName = (_a = field.name) !== null && _a !== void 0 ? _a : field;
627
+ var fieldType = (_b = fieldTypes[index]) !== null && _b !== void 0 ? _b : 'unknown';
628
+ var column = ds.data.columns[index];
629
+ var hasDisplayedColumnThatCantBeDownsampled = false;
630
+
631
+ if (fieldName === xField) {
632
+ xColumn = strictlyCoerceXColumn(column, fieldType);
633
+ } else if (yFields.has(fieldName)) {
634
+ var _strictlyCoerceYColum = strictlyCoerceYColumn(ds.data.columns[index]),
635
+ coercedColumn = _strictlyCoerceYColum.coercedColumn,
636
+ canLooselyCoerceSomeValues = _strictlyCoerceYColum.canLooselyCoerceSomeValues,
637
+ canDownsampleColumn = _strictlyCoerceYColum.canDownsampleColumn; // do not perform downsampling if a column can possibly be displayed but cannot
638
+ // be downsampled using LTTB
639
+
640
+
641
+ hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;
642
+
643
+ if (hasDisplayedColumnThatCantBeDownsampled) {
644
+ return true;
645
+ }
646
+
647
+ if (canDownsampleColumn) {
648
+ yColumns.push(coercedColumn);
649
+ }
650
+ }
651
+
652
+ return false;
653
+ });
654
+
655
+ if (canDownsample) {
656
+ return {
657
+ xColumn: xColumn,
658
+ yColumns: yColumns
659
+ };
660
+ }
661
+
662
+ return {
663
+ xColumn: [],
664
+ yColumns: []
665
+ };
666
+ };
667
+
668
+ var pickIndicesFromDataSource = function pickIndicesFromDataSource(ds, indices) {
669
+ var sortedIndices = Array.from(indices).sort(function (a, b) {
670
+ return a - b;
671
+ });
672
+ var slicedColumns = [];
673
+ ds.data.columns.forEach(function (column) {
674
+ var slicedColumn = [];
675
+ sortedIndices.forEach(function (index) {
676
+ slicedColumn.push(column[index]);
677
+ });
678
+ slicedColumns.push(slicedColumn);
679
+ }); // update data columns with downsampled columns
680
+
681
+ return Object.assign(Object.assign({}, ds), {
682
+ data: Object.assign(Object.assign({}, ds.data), {
683
+ columns: slicedColumns
684
+ })
685
+ });
686
+ };
687
+
688
+ var downsampleDataSources = function downsampleDataSources(_ref4) {
689
+ var dataSources = _ref4.dataSources,
690
+ threshold = _ref4.threshold,
691
+ options = _ref4.options;
692
+
693
+ var _a, _b, _c;
694
+
695
+ var primaryDS = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary; // only downsample time series when number of data points are over threshold
696
+
697
+ var numPoints = (_c = (_b = (_a = primaryDS === null || primaryDS === void 0 ? void 0 : primaryDS.data) === null || _a === void 0 ? void 0 : _a.columns[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
698
+
699
+ if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
700
+ return dataSources;
701
+ }
702
+
703
+ var xField = options.xField,
704
+ yFields = options.yFields,
705
+ fieldTypes = options.fieldTypes;
706
+
707
+ if (!xField || !(yFields === null || yFields === void 0 ? void 0 : yFields.length) || !(fieldTypes === null || fieldTypes === void 0 ? void 0 : fieldTypes.length)) {
708
+ return dataSources;
709
+ }
710
+
711
+ var nonInternalYFields = new Set(yFields.filter(function (yField) {
712
+ return !yField.startsWith('_');
713
+ }));
714
+ var maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints); // Do not try to downsample if there are too many downsampled pts
715
+ // At the worst case, each series has non-overlapping downsampled pts
716
+ // which will mean that all points will be included in the downsampled result
717
+ // This will just lead to additional overhead due to coercing each
718
+ // x and y field to number
719
+
720
+ if (maxPointsInDownsample >= numPoints) {
721
+ return dataSources;
722
+ }
723
+
724
+ var _tryToCoerceAllDispla = tryToCoerceAllDisplayedFields(primaryDS, xField, nonInternalYFields, fieldTypes),
725
+ xColumn = _tryToCoerceAllDispla.xColumn,
726
+ yColumns = _tryToCoerceAllDispla.yColumns;
727
+
728
+ if (!yColumns.length || !xColumn.length) {
729
+ return dataSources;
730
+ }
731
+
732
+ var downsampledDataSources = Object.assign({}, dataSources);
733
+ var downsampledIndices = new Set();
734
+ yColumns.forEach(function (yColumn, columnIndex) {
735
+ // perform LTTB downsampling for current series, LTTB takes an [x, y] pair
736
+ var xyPair = yColumn.map(function (yValue, index) {
737
+ return [xColumn[index], yValue];
738
+ });
739
+
740
+ try {
741
+ var _largestTriangleThree = largestTriangleThreeBuckets(xyPair, threshold, downsampledIndices),
742
+ downsampledIndicesForSeries = _largestTriangleThree.downsampledIndices;
743
+
744
+ downsampledIndicesForSeries.forEach(function (downsampleIndex) {
745
+ return downsampledIndices.add(downsampleIndex);
746
+ });
747
+ } catch (e) {
748
+ console.error("Error occurred while downsampling column ".concat(columnIndex), e);
749
+ }
750
+ }); // update data columns with downsampled columns
751
+
752
+ downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
753
+ return downsampledDataSources;
754
+ };
755
+
756
+ exports.downsampleDataSources = downsampleDataSources;
757
+
758
+ /***/ }),
759
+ /* 26 */
760
+ /***/ (function(module, exports, __webpack_require__) {
761
+
762
+ "use strict";
763
+
764
+
765
+ Object.defineProperty(exports, "__esModule", {
766
+ value: true
767
+ });
768
+ exports.validOutputModes = exports.validSegmentationModes = exports.validSortDirs = void 0;
769
+ exports.validSortDirs = ['asc', 'desc', 'none'];
770
+ exports.validSegmentationModes = ['none', 'inner'];
771
+ exports.validOutputModes = ['json_cols', 'json'];
772
+
773
+ /***/ }),
774
+ /* 27 */,
775
+ /* 28 */
776
+ /***/ (function(module, exports) {
777
+
778
+ module.exports = require("@splunk/visualization-context/TimezoneContext");
779
+
780
+ /***/ }),
781
+ /* 29 */
782
+ /***/ (function(module, exports) {
783
+
784
+ module.exports = require("@splunk/visualizations-shared/style");
785
+
786
+ /***/ }),
787
+ /* 30 */,
788
+ /* 31 */
789
+ /***/ (function(module, exports, __webpack_require__) {
790
+
791
+ "use strict";
792
+
793
+
794
+ Object.defineProperty(exports, "__esModule", {
795
+ value: true
796
+ });
797
+
798
+ var react_1 = __webpack_require__(0);
799
+
800
+ function usePrevious(value) {
801
+ var ref = (0, react_1.useRef)();
802
+ (0, react_1.useEffect)(function () {
803
+ ref.current = value;
804
+ });
805
+ return ref.current;
806
+ }
807
+
808
+ exports.default = usePrevious;
809
+
810
+ /***/ }),
811
+ /* 32 */
812
+ /***/ (function(module, exports, __webpack_require__) {
813
+
814
+ "use strict";
815
+
816
+
817
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
818
+ if (k2 === undefined) k2 = k;
819
+ var desc = Object.getOwnPropertyDescriptor(m, k);
820
+
821
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
822
+ desc = {
823
+ enumerable: true,
824
+ get: function get() {
825
+ return m[k];
826
+ }
827
+ };
828
+ }
829
+
830
+ Object.defineProperty(o, k2, desc);
831
+ } : function (o, m, k, k2) {
832
+ if (k2 === undefined) k2 = k;
833
+ o[k2] = m[k];
834
+ });
835
+
836
+ var __exportStar = this && this.__exportStar || function (m, exports) {
837
+ for (var p in m) {
838
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
839
+ }
840
+ };
841
+
842
+ Object.defineProperty(exports, "__esModule", {
843
+ value: true
844
+ });
845
+
846
+ __exportStar(__webpack_require__(33), exports);
847
+
848
+ __exportStar(__webpack_require__(34), exports);
849
+
850
+ __exportStar(__webpack_require__(26), exports);
851
+
852
+ __exportStar(__webpack_require__(35), exports);
853
+
854
+ __exportStar(__webpack_require__(36), exports);
855
+
856
+ __exportStar(__webpack_require__(37), exports);
857
+
858
+ __exportStar(__webpack_require__(38), exports);
859
+
860
+ __exportStar(__webpack_require__(39), exports);
861
+
862
+ __exportStar(__webpack_require__(40), exports);
863
+
864
+ __exportStar(__webpack_require__(41), exports);
865
+
866
+ __exportStar(__webpack_require__(14), exports);
867
+
868
+ __exportStar(__webpack_require__(18), exports);
869
+
870
+ __exportStar(__webpack_require__(19), exports);
871
+
872
+ __exportStar(__webpack_require__(42), exports);
873
+
874
+ __exportStar(__webpack_require__(43), exports);
875
+
876
+ __exportStar(__webpack_require__(44), exports);
877
+
878
+ __exportStar(__webpack_require__(45), exports);
879
+
880
+ __exportStar(__webpack_require__(46), exports);
881
+
882
+ __exportStar(__webpack_require__(47), exports);
883
+
884
+ /***/ }),
885
+ /* 33 */
886
+ /***/ (function(module, exports, __webpack_require__) {
887
+
888
+ "use strict";
889
+
890
+
891
+ Object.defineProperty(exports, "__esModule", {
892
+ value: true
893
+ });
894
+
895
+ /***/ }),
896
+ /* 34 */
897
+ /***/ (function(module, exports, __webpack_require__) {
898
+
899
+ "use strict";
900
+
901
+ /**
902
+ * A data structure used at runtime to wire up a visualization.
903
+ */
904
+
905
+ Object.defineProperty(exports, "__esModule", {
906
+ value: true
907
+ });
908
+
909
+ /***/ }),
910
+ /* 35 */
911
+ /***/ (function(module, exports, __webpack_require__) {
912
+
913
+ "use strict";
914
+
915
+
916
+ Object.defineProperty(exports, "__esModule", {
917
+ value: true
918
+ });
919
+
920
+ /***/ }),
921
+ /* 36 */
922
+ /***/ (function(module, exports, __webpack_require__) {
923
+
924
+ "use strict";
925
+
926
+
927
+ Object.defineProperty(exports, "__esModule", {
928
+ value: true
929
+ });
930
+
931
+ /***/ }),
932
+ /* 37 */
933
+ /***/ (function(module, exports, __webpack_require__) {
934
+
935
+ "use strict";
936
+
937
+
938
+ Object.defineProperty(exports, "__esModule", {
939
+ value: true
940
+ });
941
+
942
+ /***/ }),
943
+ /* 38 */
944
+ /***/ (function(module, exports, __webpack_require__) {
945
+
946
+ "use strict";
947
+
948
+
949
+ Object.defineProperty(exports, "__esModule", {
950
+ value: true
951
+ });
952
+
953
+ /***/ }),
954
+ /* 39 */
955
+ /***/ (function(module, exports, __webpack_require__) {
956
+
957
+ "use strict";
958
+
959
+
960
+ Object.defineProperty(exports, "__esModule", {
961
+ value: true
962
+ });
963
+
964
+ /***/ }),
965
+ /* 40 */
966
+ /***/ (function(module, exports, __webpack_require__) {
967
+
968
+ "use strict";
969
+
970
+
971
+ Object.defineProperty(exports, "__esModule", {
972
+ value: true
973
+ });
974
+
975
+ /***/ }),
976
+ /* 41 */
977
+ /***/ (function(module, exports, __webpack_require__) {
978
+
979
+ "use strict";
980
+
981
+
982
+ Object.defineProperty(exports, "__esModule", {
983
+ value: true
984
+ });
985
+
986
+ /***/ }),
987
+ /* 42 */
988
+ /***/ (function(module, exports, __webpack_require__) {
989
+
990
+ "use strict";
991
+
992
+
993
+ Object.defineProperty(exports, "__esModule", {
994
+ value: true
995
+ });
996
+
997
+ /***/ }),
998
+ /* 43 */
999
+ /***/ (function(module, exports, __webpack_require__) {
1000
+
1001
+ "use strict";
1002
+
1003
+
1004
+ Object.defineProperty(exports, "__esModule", {
1005
+ value: true
1006
+ });
1007
+
1008
+ /***/ }),
1009
+ /* 44 */
1010
+ /***/ (function(module, exports, __webpack_require__) {
1011
+
1012
+ "use strict";
1013
+
1014
+
1015
+ Object.defineProperty(exports, "__esModule", {
1016
+ value: true
1017
+ });
1018
+
1019
+ /***/ }),
1020
+ /* 45 */
1021
+ /***/ (function(module, exports, __webpack_require__) {
1022
+
1023
+ "use strict";
1024
+
1025
+
1026
+ Object.defineProperty(exports, "__esModule", {
1027
+ value: true
1028
+ });
1029
+
1030
+ /***/ }),
1031
+ /* 46 */
1032
+ /***/ (function(module, exports, __webpack_require__) {
1033
+
1034
+ "use strict";
157
1035
 
158
- /***/ }),
159
- /* 15 */,
160
- /* 16 */,
161
- /* 17 */,
162
- /* 18 */,
163
- /* 19 */,
164
- /* 20 */
165
- /***/ (function(module, exports) {
166
1036
 
167
- module.exports = require("@splunk/visualizations-shared/Message");
1037
+ Object.defineProperty(exports, "__esModule", {
1038
+ value: true
1039
+ });
168
1040
 
169
1041
  /***/ }),
170
- /* 21 */,
171
- /* 22 */
172
- /***/ (function(module, exports) {
1042
+ /* 47 */
1043
+ /***/ (function(module, exports, __webpack_require__) {
173
1044
 
174
- module.exports = require("@splunk/visualization-context/TimezoneContext");
1045
+ "use strict";
175
1046
 
176
- /***/ }),
177
- /* 23 */
178
- /***/ (function(module, exports) {
179
1047
 
180
- module.exports = require("@splunk/visualizations-shared/style");
1048
+ Object.defineProperty(exports, "__esModule", {
1049
+ value: true
1050
+ });
181
1051
 
182
1052
  /***/ }),
183
- /* 24 */,
184
- /* 25 */,
185
- /* 26 */,
186
- /* 27 */,
187
- /* 28 */,
188
- /* 29 */,
189
- /* 30 */,
190
- /* 31 */,
191
- /* 32 */,
192
- /* 33 */,
193
- /* 34 */,
194
- /* 35 */
1053
+ /* 48 */,
1054
+ /* 49 */,
1055
+ /* 50 */,
1056
+ /* 51 */,
1057
+ /* 52 */,
1058
+ /* 53 */,
1059
+ /* 54 */,
1060
+ /* 55 */,
1061
+ /* 56 */,
1062
+ /* 57 */,
1063
+ /* 58 */
195
1064
  /***/ (function(module, exports, __webpack_require__) {
196
1065
 
197
1066
  "use strict";
198
1067
 
199
1068
 
200
- var _classCallCheck = __webpack_require__(5);
1069
+ var _classCallCheck = __webpack_require__(4);
201
1070
 
202
1071
  Object.defineProperty(exports, "__esModule", {
203
1072
  value: true
@@ -209,7 +1078,7 @@ var T = __webpack_require__(1);
209
1078
 
210
1079
  var lodash_1 = __webpack_require__(3);
211
1080
 
212
- var VizActionHandler_1 = __webpack_require__(36); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
1081
+ var VizActionHandler_1 = __webpack_require__(14); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
213
1082
 
214
1083
 
215
1084
  exports.INITIAL_WIDTH = 250;
@@ -342,97 +1211,29 @@ SplunkVisualization.defaultProps = {
342
1211
  exports.default = SplunkVisualization;
343
1212
 
344
1213
  /***/ }),
345
- /* 36 */
346
- /***/ (function(module, exports, __webpack_require__) {
347
-
348
- "use strict";
349
-
350
-
351
- var _classCallCheck = __webpack_require__(5);
352
-
353
- var _createClass = __webpack_require__(7);
354
-
355
- Object.defineProperty(exports, "__esModule", {
356
- value: true
357
- });
358
- exports.DefaultVizActionHandler = void 0;
359
-
360
- var DefaultVizActionHandler = /*#__PURE__*/function () {
361
- function DefaultVizActionHandler() {
362
- _classCallCheck(this, DefaultVizActionHandler);
363
- }
364
-
365
- _createClass(DefaultVizActionHandler, [{
366
- key: "focus",
367
- value: function focus() {// noop
368
- }
369
- }, {
370
- key: "snapshot",
371
- value: function snapshot() {
372
- return null; // noop
373
- }
374
- }]);
375
-
376
- return DefaultVizActionHandler;
377
- }();
378
-
379
- exports.DefaultVizActionHandler = DefaultVizActionHandler;
380
-
381
- /***/ }),
382
- /* 37 */,
383
- /* 38 */
1214
+ /* 59 */
384
1215
  /***/ (function(module, exports) {
385
1216
 
386
1217
  module.exports = require("@splunk/themes/variables");
387
1218
 
388
1219
  /***/ }),
389
- /* 39 */,
390
- /* 40 */,
391
- /* 41 */,
392
- /* 42 */
393
- /***/ (function(module, exports, __webpack_require__) {
394
-
395
- "use strict";
396
-
397
-
398
- Object.defineProperty(exports, "__esModule", {
399
- value: true
400
- });
401
- exports.VizBehavior = void 0;
402
- var VizBehavior;
403
-
404
- (function (VizBehavior) {
405
- /**
406
- * Dynamic Options Behavior.
407
- * This allows visualization options to be powered by data
408
- *
409
- * **Example**
410
- *
411
- * sparklineValues: ">primary|seriesByIndex(0)"
412
- * would configure sparklineValues with an array of data points
413
- * coming from the first series in the primary datasource
414
- *
415
- */
416
- VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
417
- VizBehavior["EVENTS"] = "events";
418
- /**
419
- * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
420
- * missing.
421
- * @type {string}
422
- */
1220
+ /* 60 */,
1221
+ /* 61 */,
1222
+ /* 62 */,
1223
+ /* 63 */
1224
+ /***/ (function(module, exports) {
423
1225
 
424
- VizBehavior["PLACEHOLDER"] = "placeholder";
425
- VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
426
- VizBehavior["TRELLIS"] = "trellis";
427
- })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
1226
+ module.exports = require("@splunk/visualization-encoding/Options");
428
1227
 
429
1228
  /***/ }),
430
- /* 43 */
1229
+ /* 64 */
431
1230
  /***/ (function(module, exports, __webpack_require__) {
432
1231
 
433
1232
  "use strict";
434
1233
 
435
1234
 
1235
+ var _slicedToArray = __webpack_require__(8);
1236
+
436
1237
  Object.defineProperty(exports, "__esModule", {
437
1238
  value: true
438
1239
  });
@@ -441,11 +1242,11 @@ var React = __webpack_require__(0);
441
1242
 
442
1243
  var styled_components_1 = __webpack_require__(2);
443
1244
 
444
- var SizeAwareWrapper_1 = __webpack_require__(98);
1245
+ var style_1 = __webpack_require__(29);
445
1246
 
446
- var style_1 = __webpack_require__(23);
1247
+ var colorUtils_1 = __webpack_require__(16);
447
1248
 
448
- var colorUtils_1 = __webpack_require__(14);
1249
+ var SizeAwareWrapper_1 = __webpack_require__(117);
449
1250
 
450
1251
  var Item = styled_components_1.default.div.attrs(function (_ref) {
451
1252
  var width = _ref.width;
@@ -491,6 +1292,20 @@ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
491
1292
  var width = props.width,
492
1293
  height = props.height,
493
1294
  backgroundColor = props.backgroundColor;
1295
+ var cachedHandleResize = React.useCallback(function (w, h) {
1296
+ setContainerWidth(w);
1297
+ setContainerHeight(h);
1298
+ }, []);
1299
+
1300
+ var _React$useState = React.useState(Number(props.width)),
1301
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1302
+ containerWidth = _React$useState2[0],
1303
+ setContainerWidth = _React$useState2[1];
1304
+
1305
+ var _React$useState3 = React.useState(Number(props.height)),
1306
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
1307
+ containerHeight = _React$useState4[0],
1308
+ setContainerHeight = _React$useState4[1];
494
1309
 
495
1310
  if (!height) {
496
1311
  return React.createElement(Item, {
@@ -502,18 +1317,18 @@ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
502
1317
 
503
1318
  return React.createElement(FixSizeItem, {
504
1319
  "data-test": "fix-size-item",
505
- "data-splunk-visualization-version": "26.1.1 - b6df0a015",
1320
+ "data-splunk-visualization-version": "26.2.0 - 49b909915",
506
1321
  width: width,
507
1322
  height: height,
508
1323
  backgroundColor: backgroundColor
509
- }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, null, function (_ref3) {
510
- var newWidth = _ref3.width,
511
- newHeight = _ref3.height;
512
- return React.createElement(Viz, Object.assign({}, props, {
513
- width: newWidth,
514
- height: newHeight
515
- }));
516
- })));
1324
+ }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, {
1325
+ width: width,
1326
+ height: height,
1327
+ onResize: cachedHandleResize
1328
+ }), React.createElement(Viz, Object.assign({}, props, {
1329
+ width: containerWidth,
1330
+ height: containerHeight
1331
+ }))));
517
1332
  };
518
1333
 
519
1334
  FixedSizeContainer.displayName = 'withFixedSizeContainer';
@@ -523,7 +1338,7 @@ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
523
1338
  exports.default = withFixedSizeContainer;
524
1339
 
525
1340
  /***/ }),
526
- /* 44 */
1341
+ /* 65 */
527
1342
  /***/ (function(module, exports, __webpack_require__) {
528
1343
 
529
1344
  "use strict";
@@ -555,27 +1370,6 @@ var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
555
1370
  exports.extendStaticWrapperProps = extendStaticWrapperProps;
556
1371
 
557
1372
  /***/ }),
558
- /* 45 */,
559
- /* 46 */,
560
- /* 47 */,
561
- /* 48 */,
562
- /* 49 */,
563
- /* 50 */,
564
- /* 51 */,
565
- /* 52 */,
566
- /* 53 */,
567
- /* 54 */,
568
- /* 55 */,
569
- /* 56 */,
570
- /* 57 */,
571
- /* 58 */,
572
- /* 59 */,
573
- /* 60 */,
574
- /* 61 */,
575
- /* 62 */,
576
- /* 63 */,
577
- /* 64 */,
578
- /* 65 */,
579
1373
  /* 66 */,
580
1374
  /* 67 */,
581
1375
  /* 68 */,
@@ -593,7 +1387,28 @@ exports.extendStaticWrapperProps = extendStaticWrapperProps;
593
1387
  /* 80 */,
594
1388
  /* 81 */,
595
1389
  /* 82 */,
596
- /* 83 */
1390
+ /* 83 */,
1391
+ /* 84 */,
1392
+ /* 85 */,
1393
+ /* 86 */,
1394
+ /* 87 */,
1395
+ /* 88 */,
1396
+ /* 89 */,
1397
+ /* 90 */,
1398
+ /* 91 */,
1399
+ /* 92 */,
1400
+ /* 93 */,
1401
+ /* 94 */,
1402
+ /* 95 */,
1403
+ /* 96 */,
1404
+ /* 97 */,
1405
+ /* 98 */,
1406
+ /* 99 */,
1407
+ /* 100 */,
1408
+ /* 101 */,
1409
+ /* 102 */,
1410
+ /* 103 */,
1411
+ /* 104 */
597
1412
  /***/ (function(module, exports, __webpack_require__) {
598
1413
 
599
1414
  "use strict";
@@ -609,43 +1424,49 @@ var React = __webpack_require__(0);
609
1424
 
610
1425
  var lodash_1 = __webpack_require__(3);
611
1426
 
612
- var getSettingsFromThemedProps_1 = __webpack_require__(84);
1427
+ var getSettingsFromThemedProps_1 = __webpack_require__(105);
613
1428
 
614
- var Options_1 = __webpack_require__(85);
1429
+ var Options_1 = __webpack_require__(63);
615
1430
 
616
- var SanitizeProps_1 = __webpack_require__(86);
1431
+ var SanitizeProps_1 = __webpack_require__(106);
617
1432
 
618
- var TimezoneContext_1 = __webpack_require__(22);
1433
+ var TimezoneContext_1 = __webpack_require__(28);
619
1434
 
620
- var moment_1 = __webpack_require__(87);
1435
+ var moment_1 = __webpack_require__(107);
621
1436
 
622
- var FeatureFlagContext_1 = __webpack_require__(88);
1437
+ var FeatureFlagContext_1 = __webpack_require__(108);
623
1438
 
624
1439
  var styled_components_1 = __webpack_require__(2);
625
1440
 
626
- var hocUtils_1 = __webpack_require__(89);
1441
+ var hocUtils_1 = __webpack_require__(109);
1442
+
1443
+ var JSONSchemaUtils_1 = __webpack_require__(110);
1444
+
1445
+ var async_dynamic_options_evaluator_1 = __webpack_require__(111);
627
1446
 
628
- var JSONSchemaUtils_1 = __webpack_require__(90);
1447
+ var id_1 = __webpack_require__(112);
629
1448
 
630
- var async_dynamic_options_evaluator_1 = __webpack_require__(91);
1449
+ var SplunkVisualization_1 = __webpack_require__(58);
631
1450
 
632
- var id_1 = __webpack_require__(92);
1451
+ var VizBehavior_1 = __webpack_require__(18);
633
1452
 
634
- var SplunkVisualization_1 = __webpack_require__(35);
1453
+ var getSorting_1 = __webpack_require__(113);
635
1454
 
636
- var VizBehavior_1 = __webpack_require__(42);
1455
+ var getPagination_1 = __webpack_require__(114);
637
1456
 
638
- var getSorting_1 = __webpack_require__(93);
1457
+ var useDeepMemo_1 = __webpack_require__(115);
639
1458
 
640
- var getPagination_1 = __webpack_require__(95);
1459
+ var MissingPropsMessage_1 = __webpack_require__(116);
641
1460
 
642
- var useDeepMemo_1 = __webpack_require__(96);
1461
+ var withEditModeCover_1 = __webpack_require__(118);
643
1462
 
644
- var MissingPropsMessage_1 = __webpack_require__(97);
1463
+ var withPlaceholder_1 = __webpack_require__(119);
645
1464
 
646
- var withEditModeCover_1 = __webpack_require__(99);
1465
+ var useDownsampleDataSources_1 = __webpack_require__(121);
647
1466
 
648
- var withPlaceholder_1 = __webpack_require__(100);
1467
+ var dataUtils_1 = __webpack_require__(25);
1468
+
1469
+ var featureFlagUtils_1 = __webpack_require__(123);
649
1470
  /**
650
1471
  * hoc that wraps a pure react visualization in a Dashboard visualization
651
1472
  * @param {DashboardVizOpts} opts
@@ -736,25 +1557,61 @@ var withDashboardViz = function withDashboardViz(opts) {
736
1557
  dataFramesInState = _React$useState8[0],
737
1558
  setDataFramesInState = _React$useState8[1];
738
1559
 
739
- var _React$useState9 = React.useState(Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_useWebWorkersForDSL)),
1560
+ var _React$useState9 = React.useState(Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_useWebWorkersForDSL'))),
740
1561
  _React$useState10 = _slicedToArray(_React$useState9, 2),
741
1562
  useAsyncEvaluatedOptions = _React$useState10[0],
742
1563
  setUseAsyncEvaluatedOptions = _React$useState10[1];
743
1564
 
1565
+ var isDownsamplingEnabledByFeatureFlag = Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_enableDownsampling);
744
1566
  var isMounted = React.useRef(true);
1567
+ var optionsToEvaluate = React.useMemo(function () {
1568
+ return {
1569
+ context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
1570
+ options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1571
+ };
1572
+ }, [options, context]);
1573
+
1574
+ var _React$useState11 = React.useState(Number(width)),
1575
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
1576
+ threshold = _React$useState12[0],
1577
+ setThreshold = _React$useState12[1];
1578
+
1579
+ var onDownsamplingThresholdChange = React.useCallback(function (newThreshold) {
1580
+ setThreshold(newThreshold);
1581
+ }, []);
1582
+ var isDownsamplingEnabled = React.useMemo(function () {
1583
+ return isDownsamplingEnabledByFeatureFlag && (0, dataUtils_1.isDownsamplingEnabledForViz)({
1584
+ vizConfig: vizConfig
1585
+ });
1586
+ }, [isDownsamplingEnabledByFeatureFlag]);
1587
+ var downsamplingProps = React.useMemo(function () {
1588
+ if (!isDownsamplingEnabled) {
1589
+ return {};
1590
+ }
1591
+
1592
+ return {
1593
+ onDownsamplingThresholdChange: onDownsamplingThresholdChange,
1594
+ originalDataSources: dataSources
1595
+ };
1596
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1597
+ var downsampledDataSources = (0, useDownsampleDataSources_1.default)({
1598
+ options: optionsToEvaluate.options,
1599
+ context: optionsToEvaluate.context,
1600
+ dataSources: dataSources,
1601
+ threshold: threshold,
1602
+ isDownsamplingEnabled: isDownsamplingEnabled
1603
+ });
745
1604
  evaluatedOptions = (0, useDeepMemo_1.useDeepMemo)(function () {
746
1605
  try {
747
1606
  if (useAsyncEvaluatedOptions) {
748
- var optionsToEvaluate = {
749
- context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
750
- options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
751
- };
752
1607
  var asyncDynamicOptionsEvaluatorParams = {
753
1608
  visualizationID: visualizationID,
754
1609
  props: props,
755
1610
  options: optionsToEvaluate,
756
- dataSources: dataSources,
757
- theme: vizConfig.themes
1611
+ dataSources: downsampledDataSources,
1612
+ theme: vizConfig.themes,
1613
+ bypassCloneDeepOptionScope: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope')),
1614
+ lazyLoadingDataFrame: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'))
758
1615
  };
759
1616
  async_dynamic_options_evaluator_1.default.evaluate(asyncDynamicOptionsEvaluatorParams).then(function (results) {
760
1617
  setEvaluatedOptionsAsync(results.results);
@@ -766,16 +1623,14 @@ var withDashboardViz = function withDashboardViz(opts) {
766
1623
  } else {
767
1624
  var dataFrames = dataFramesInState;
768
1625
 
769
- if (dataSources !== dataSourcesInState) {
770
- setDataSourcesInState(dataSources);
771
- dataFrames = Options_1.Options.dataFrameFromDataSource(dataSources);
1626
+ if (downsampledDataSources !== dataSourcesInState) {
1627
+ setDataSourcesInState(downsampledDataSources);
1628
+ dataFrames = Options_1.Options.dataFrameFromDataSource(downsampledDataSources, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'));
772
1629
  setDataFramesInState(dataFrames);
773
1630
  }
774
1631
 
775
- return Options_1.Options.evaluate({
776
- context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
777
- options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
778
- }, dataSources, themeFunc, dataFrames);
1632
+ var result = Options_1.Options.evaluate(optionsToEvaluate, downsampledDataSources, themeFunc, dataFrames, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope'));
1633
+ return result;
779
1634
  }
780
1635
  } catch (e) {
781
1636
  // eslint-disable-next-line no-console
@@ -784,7 +1639,7 @@ var withDashboardViz = function withDashboardViz(opts) {
784
1639
  }
785
1640
 
786
1641
  return {};
787
- }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources, serializedTimezone, useAsyncEvaluatedOptions]);
1642
+ }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, optionsToEvaluate, downsampledDataSources, serializedTimezone, useAsyncEvaluatedOptions]);
788
1643
  var evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync; // trellis specific backgroundColor update for onComputedProps
789
1644
  // if trellis is enabled following these three criteria - 1) trellis feature flag is enabled 2) vizConfig supports array has 'trellis' 3) option 'splitByLayout' is set to 'trellis
790
1645
  // onComputedProps api should return back trellisBackgroundColor value for backgroundColor option to support coloring of sibling panels (for eg:- title/ description on UDF side)
@@ -926,7 +1781,7 @@ var withDashboardViz = function withDashboardViz(opts) {
926
1781
  mode: mode,
927
1782
  width: width,
928
1783
  height: height
929
- }, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
1784
+ }, downsamplingProps, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
930
1785
  };
931
1786
 
932
1787
  DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
@@ -943,67 +1798,61 @@ var withDashboardViz = function withDashboardViz(opts) {
943
1798
  exports.default = withDashboardViz;
944
1799
 
945
1800
  /***/ }),
946
- /* 84 */
1801
+ /* 105 */
947
1802
  /***/ (function(module, exports) {
948
1803
 
949
1804
  module.exports = require("@splunk/themes/getSettingsFromThemedProps");
950
1805
 
951
1806
  /***/ }),
952
- /* 85 */
953
- /***/ (function(module, exports) {
954
-
955
- module.exports = require("@splunk/visualization-encoding/Options");
956
-
957
- /***/ }),
958
- /* 86 */
1807
+ /* 106 */
959
1808
  /***/ (function(module, exports) {
960
1809
 
961
1810
  module.exports = require("@splunk/visualizations-shared/SanitizeProps");
962
1811
 
963
1812
  /***/ }),
964
- /* 87 */
1813
+ /* 107 */
965
1814
  /***/ (function(module, exports) {
966
1815
 
967
1816
  module.exports = require("@splunk/moment");
968
1817
 
969
1818
  /***/ }),
970
- /* 88 */
1819
+ /* 108 */
971
1820
  /***/ (function(module, exports) {
972
1821
 
973
1822
  module.exports = require("@splunk/visualization-context/FeatureFlagContext");
974
1823
 
975
1824
  /***/ }),
976
- /* 89 */
1825
+ /* 109 */
977
1826
  /***/ (function(module, exports) {
978
1827
 
979
1828
  module.exports = require("@splunk/visualizations-shared/hocUtils");
980
1829
 
981
1830
  /***/ }),
982
- /* 90 */
1831
+ /* 110 */
983
1832
  /***/ (function(module, exports) {
984
1833
 
985
1834
  module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
986
1835
 
987
1836
  /***/ }),
988
- /* 91 */
1837
+ /* 111 */
989
1838
  /***/ (function(module, exports) {
990
1839
 
991
1840
  module.exports = require("@splunk/async-dynamic-options-evaluator");
992
1841
 
993
1842
  /***/ }),
994
- /* 92 */
1843
+ /* 112 */
995
1844
  /***/ (function(module, exports) {
996
1845
 
997
1846
  module.exports = require("@splunk/ui-utils/id");
998
1847
 
999
1848
  /***/ }),
1000
- /* 93 */
1849
+ /* 113 */
1001
1850
  /***/ (function(module, exports, __webpack_require__) {
1002
1851
 
1003
1852
  "use strict";
1004
1853
 
1005
1854
 
1006
- var _defineProperty = __webpack_require__(9);
1855
+ var _defineProperty = __webpack_require__(10);
1007
1856
 
1008
1857
  Object.defineProperty(exports, "__esModule", {
1009
1858
  value: true
@@ -1014,7 +1863,7 @@ var T = __webpack_require__(1);
1014
1863
 
1015
1864
  var lodash_1 = __webpack_require__(3);
1016
1865
 
1017
- var DataSource_1 = __webpack_require__(94);
1866
+ var DataSource_1 = __webpack_require__(26);
1018
1867
 
1019
1868
  exports.SortParamsPropTypes = T.shape({
1020
1869
  currentSortKey: T.string,
@@ -1067,22 +1916,7 @@ var getSortingParams = function getSortingParams(_ref) {
1067
1916
  exports.getSortingParams = getSortingParams;
1068
1917
 
1069
1918
  /***/ }),
1070
- /* 94 */
1071
- /***/ (function(module, exports, __webpack_require__) {
1072
-
1073
- "use strict";
1074
-
1075
-
1076
- Object.defineProperty(exports, "__esModule", {
1077
- value: true
1078
- });
1079
- exports.validOutputModes = exports.validSegmentationModes = exports.validSortDirs = void 0;
1080
- exports.validSortDirs = ['asc', 'desc', 'none'];
1081
- exports.validSegmentationModes = ['none', 'inner'];
1082
- exports.validOutputModes = ['json_cols', 'json'];
1083
-
1084
- /***/ }),
1085
- /* 95 */
1919
+ /* 114 */
1086
1920
  /***/ (function(module, exports, __webpack_require__) {
1087
1921
 
1088
1922
  "use strict";
@@ -1146,7 +1980,7 @@ var getPaginationParams = function getPaginationParams(_ref) {
1146
1980
  exports.getPaginationParams = getPaginationParams;
1147
1981
 
1148
1982
  /***/ }),
1149
- /* 96 */
1983
+ /* 115 */
1150
1984
  /***/ (function(module, exports, __webpack_require__) {
1151
1985
 
1152
1986
  "use strict";
@@ -1191,7 +2025,7 @@ var useDeepMemo = function useDeepMemo(fn, dependencies) {
1191
2025
  exports.useDeepMemo = useDeepMemo;
1192
2026
 
1193
2027
  /***/ }),
1194
- /* 97 */
2028
+ /* 116 */
1195
2029
  /***/ (function(module, exports, __webpack_require__) {
1196
2030
 
1197
2031
  "use strict";
@@ -1206,11 +2040,11 @@ var React = __webpack_require__(0);
1206
2040
 
1207
2041
  var T = __webpack_require__(1);
1208
2042
 
1209
- var i18n_1 = __webpack_require__(4);
2043
+ var i18n_1 = __webpack_require__(5);
1210
2044
 
1211
- var Message_1 = __webpack_require__(20);
2045
+ var Message_1 = __webpack_require__(24);
1212
2046
 
1213
- var FixedSizeContainer_1 = __webpack_require__(43);
2047
+ var FixedSizeContainer_1 = __webpack_require__(64);
1214
2048
  /**
1215
2049
  * @method isMissing
1216
2050
  * @param {any} v
@@ -1271,13 +2105,13 @@ exports.MissingPropsMessage.defaultProps = {
1271
2105
  exports.default = (0, FixedSizeContainer_1.default)(exports.MissingPropsMessage);
1272
2106
 
1273
2107
  /***/ }),
1274
- /* 98 */
2108
+ /* 117 */
1275
2109
  /***/ (function(module, exports) {
1276
2110
 
1277
2111
  module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
1278
2112
 
1279
2113
  /***/ }),
1280
- /* 99 */
2114
+ /* 118 */
1281
2115
  /***/ (function(module, exports, __webpack_require__) {
1282
2116
 
1283
2117
  "use strict";
@@ -1291,14 +2125,14 @@ var React = __webpack_require__(0);
1291
2125
 
1292
2126
  var styled_components_1 = __webpack_require__(2);
1293
2127
 
1294
- var hocUtils_1 = __webpack_require__(44);
2128
+ var hocUtils_1 = __webpack_require__(65);
1295
2129
 
1296
2130
  var Cover = styled_components_1.default.div.withConfig({
1297
2131
  displayName: "withEditModeCover__Cover",
1298
2132
  componentId: "sc-1gsbnxb-0"
1299
2133
  })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
1300
2134
  var Blocker = styled_components_1.default.div.attrs({
1301
- 'data-splunk-visualization-version': "26.1.1 - b6df0a015"
2135
+ 'data-splunk-visualization-version': "26.2.0 - 49b909915"
1302
2136
  }).withConfig({
1303
2137
  displayName: "withEditModeCover__Blocker",
1304
2138
  componentId: "sc-1gsbnxb-1"
@@ -1329,7 +2163,7 @@ var withEditModeCover = function withEditModeCover(Visualization, disableEditMod
1329
2163
  exports.default = withEditModeCover;
1330
2164
 
1331
2165
  /***/ }),
1332
- /* 100 */
2166
+ /* 119 */
1333
2167
  /***/ (function(module, exports, __webpack_require__) {
1334
2168
 
1335
2169
  "use strict";
@@ -1341,15 +2175,15 @@ Object.defineProperty(exports, "__esModule", {
1341
2175
 
1342
2176
  var React = __webpack_require__(0);
1343
2177
 
1344
- var colorUtils_1 = __webpack_require__(14);
2178
+ var colorUtils_1 = __webpack_require__(16);
1345
2179
 
1346
- var variables_1 = __webpack_require__(38);
2180
+ var variables_1 = __webpack_require__(59);
1347
2181
 
1348
- var IconPlaceholder_1 = __webpack_require__(101);
2182
+ var IconPlaceholder_1 = __webpack_require__(120);
1349
2183
 
1350
- var VizBehavior_1 = __webpack_require__(42);
2184
+ var VizBehavior_1 = __webpack_require__(18);
1351
2185
 
1352
- var hocUtils_1 = __webpack_require__(44);
2186
+ var hocUtils_1 = __webpack_require__(65);
1353
2187
 
1354
2188
  var withPlaceholder = function withPlaceholder(Visualization) {
1355
2189
  var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
@@ -1393,7 +2227,7 @@ var withPlaceholder = function withPlaceholder(Visualization) {
1393
2227
  exports.default = withPlaceholder;
1394
2228
 
1395
2229
  /***/ }),
1396
- /* 101 */
2230
+ /* 120 */
1397
2231
  /***/ (function(module, exports, __webpack_require__) {
1398
2232
 
1399
2233
  "use strict";
@@ -1410,11 +2244,11 @@ var T = __webpack_require__(1);
1410
2244
 
1411
2245
  var lodash_1 = __webpack_require__(3);
1412
2246
 
1413
- var i18n_1 = __webpack_require__(4);
2247
+ var i18n_1 = __webpack_require__(5);
1414
2248
 
1415
- var Message_1 = __webpack_require__(20);
2249
+ var Message_1 = __webpack_require__(24);
1416
2250
 
1417
- var FixedSizeContainer_1 = __webpack_require__(43);
2251
+ var FixedSizeContainer_1 = __webpack_require__(64);
1418
2252
  /**
1419
2253
  * @method shouldShowIconPlaceholder
1420
2254
  * @param {object} dataSources
@@ -1484,6 +2318,250 @@ IconPlaceholder.defaultProps = {
1484
2318
  };
1485
2319
  exports.default = (0, FixedSizeContainer_1.default)(IconPlaceholder);
1486
2320
 
2321
+ /***/ }),
2322
+ /* 121 */
2323
+ /***/ (function(module, exports, __webpack_require__) {
2324
+
2325
+ "use strict";
2326
+
2327
+
2328
+ var _slicedToArray = __webpack_require__(8);
2329
+
2330
+ Object.defineProperty(exports, "__esModule", {
2331
+ value: true
2332
+ });
2333
+
2334
+ var react_1 = __webpack_require__(0);
2335
+
2336
+ var lodash_1 = __webpack_require__(3);
2337
+
2338
+ var dataUtils_1 = __webpack_require__(25);
2339
+
2340
+ var usePrevious_1 = __webpack_require__(31);
2341
+
2342
+ var useGetXAndYFields_1 = __webpack_require__(122);
2343
+
2344
+ var useDownsampleDataSources = function useDownsampleDataSources(_ref) {
2345
+ var dataSources = _ref.dataSources,
2346
+ options = _ref.options,
2347
+ context = _ref.context,
2348
+ threshold = _ref.threshold,
2349
+ isDownsamplingEnabled = _ref.isDownsamplingEnabled;
2350
+ var isFirstUseEffectCall = (0, react_1.useRef)(true);
2351
+ var xAndYFieldsWithTypes = (0, useGetXAndYFields_1.default)({
2352
+ shouldEvaluateDSL: isDownsamplingEnabled,
2353
+ options: options,
2354
+ context: context,
2355
+ dataSources: dataSources
2356
+ });
2357
+ var previousXAndYFieldsWithTypes = (0, usePrevious_1.default)(xAndYFieldsWithTypes);
2358
+ var previousDataSources = (0, usePrevious_1.default)(dataSources);
2359
+ var previousThreshold = (0, usePrevious_1.default)(threshold);
2360
+
2361
+ var _ref2 = (0, react_1.useState)(function () {
2362
+ return isDownsamplingEnabled ? (0, dataUtils_1.downsampleDataSources)({
2363
+ dataSources: dataSources,
2364
+ threshold: threshold,
2365
+ options: xAndYFieldsWithTypes
2366
+ }) : dataSources;
2367
+ }),
2368
+ _ref3 = _slicedToArray(_ref2, 2),
2369
+ downsampledDataSources = _ref3[0],
2370
+ setDownsampledDataSources = _ref3[1];
2371
+
2372
+ var debouncedDownsampleDataSources = (0, react_1.useMemo)(function () {
2373
+ return (0, lodash_1.debounce)(function (downsampleOptions) {
2374
+ var downsampledResult = (0, dataUtils_1.downsampleDataSources)(downsampleOptions);
2375
+ setDownsampledDataSources(downsampledResult);
2376
+ }, 100, {
2377
+ trailing: true
2378
+ });
2379
+ }, []);
2380
+ (0, react_1.useEffect)(function () {
2381
+ // don't downsample again on the use effect call that happened due to the initial render
2382
+ // this is since we already downsampled as part of the useState call
2383
+ if (isFirstUseEffectCall.current) {
2384
+ isFirstUseEffectCall.current = false;
2385
+ return;
2386
+ }
2387
+
2388
+ if (!isDownsamplingEnabled) {
2389
+ setDownsampledDataSources(dataSources);
2390
+ return;
2391
+ }
2392
+
2393
+ if ((0, lodash_1.isEqual)(previousXAndYFieldsWithTypes, xAndYFieldsWithTypes) && previousDataSources === dataSources && previousThreshold === threshold) {
2394
+ return;
2395
+ } // Debounce the downsampling so we don't have to downsample and execute DSL multiple times
2396
+ // while the viz is being resized
2397
+
2398
+
2399
+ debouncedDownsampleDataSources({
2400
+ dataSources: dataSources,
2401
+ options: xAndYFieldsWithTypes,
2402
+ threshold: threshold
2403
+ }); // need to detect if this runs as part of the initial render
2404
+ }, [dataSources, debouncedDownsampleDataSources, xAndYFieldsWithTypes, threshold, isDownsamplingEnabled, previousXAndYFieldsWithTypes, previousDataSources, previousThreshold]);
2405
+ return downsampledDataSources;
2406
+ };
2407
+
2408
+ exports.default = useDownsampleDataSources;
2409
+
2410
+ /***/ }),
2411
+ /* 122 */
2412
+ /***/ (function(module, exports, __webpack_require__) {
2413
+
2414
+ "use strict";
2415
+
2416
+
2417
+ var _toConsumableArray = __webpack_require__(22);
2418
+
2419
+ Object.defineProperty(exports, "__esModule", {
2420
+ value: true
2421
+ });
2422
+
2423
+ var react_1 = __webpack_require__(0);
2424
+
2425
+ var Options_1 = __webpack_require__(63);
2426
+ /**
2427
+ * Hook that evaluates the DSL for subset of a viz's options needed to determine
2428
+ * its x and y fields as well as the types of all its fields.
2429
+ */
2430
+
2431
+
2432
+ var useGetXAndYFields = function useGetXAndYFields(_ref) {
2433
+ var shouldEvaluateDSL = _ref.shouldEvaluateDSL,
2434
+ options = _ref.options,
2435
+ context = _ref.context,
2436
+ dataSources = _ref.dataSources;
2437
+
2438
+ var _ref2 = (0, react_1.useMemo)(function () {
2439
+ var _a, _b, _c;
2440
+
2441
+ if (!shouldEvaluateDSL) {
2442
+ return {
2443
+ dataSourcesWithOnlyOnePoint: null,
2444
+ dataFrameWithOnlyOnePoint: null
2445
+ };
2446
+ }
2447
+
2448
+ if (!((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns) === null || _c === void 0 ? void 0 : _c.length)) {
2449
+ return {
2450
+ dataSourcesWithOnlyOnePoint: null,
2451
+ dataFrameWithOnlyOnePoint: null
2452
+ };
2453
+ }
2454
+
2455
+ var primaryDS = dataSources.primary;
2456
+ var columnsWithOnlyOnePoint = primaryDS.data.columns.map(function (column) {
2457
+ return [column[0]];
2458
+ });
2459
+ var filteredDataSources = {
2460
+ primary: Object.assign(Object.assign({}, primaryDS), {
2461
+ data: Object.assign(Object.assign({}, primaryDS.data), {
2462
+ columns: columnsWithOnlyOnePoint
2463
+ })
2464
+ })
2465
+ };
2466
+ return {
2467
+ dataSourcesWithOnlyOnePoint: filteredDataSources,
2468
+ dataFrameWithOnlyOnePoint: Options_1.Options.dataFrameFromDataSource(filteredDataSources)
2469
+ };
2470
+ }, [dataSources, shouldEvaluateDSL]),
2471
+ dataSourcesWithOnlyOnePoint = _ref2.dataSourcesWithOnlyOnePoint,
2472
+ dataFrameWithOnlyOnePoint = _ref2.dataFrameWithOnlyOnePoint;
2473
+
2474
+ var xAndYFieldsWithTypes = (0, react_1.useMemo)(function () {
2475
+ try {
2476
+ if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
2477
+ return options;
2478
+ }
2479
+
2480
+ if (!(options === null || options === void 0 ? void 0 : options.x) || !(options === null || options === void 0 ? void 0 : options.y) && !(options === null || options === void 0 ? void 0 : options.y2)) {
2481
+ return options;
2482
+ }
2483
+
2484
+ var optionsToEvaluate = {
2485
+ x: options.x,
2486
+ xField: '> x | getField()',
2487
+ y: options.y,
2488
+ yFields: options.y ? '> y | getField()' : undefined,
2489
+ y2: options.y2,
2490
+ y2Fields: options.y2 ? '> y2 | getField()' : undefined,
2491
+ fieldTypes: '> primary | getType()'
2492
+ };
2493
+
2494
+ var _Options_1$Options$ev = Options_1.Options.evaluate({
2495
+ options: optionsToEvaluate,
2496
+ context: context
2497
+ }, dataSourcesWithOnlyOnePoint, function () {}, dataFrameWithOnlyOnePoint),
2498
+ _Options_1$Options$ev2 = _Options_1$Options$ev.xField,
2499
+ xField = _Options_1$Options$ev2 === void 0 ? '' : _Options_1$Options$ev2,
2500
+ _Options_1$Options$ev3 = _Options_1$Options$ev.yFields,
2501
+ yFields = _Options_1$Options$ev3 === void 0 ? [] : _Options_1$Options$ev3,
2502
+ _Options_1$Options$ev4 = _Options_1$Options$ev.y2Fields,
2503
+ y2Fields = _Options_1$Options$ev4 === void 0 ? [] : _Options_1$Options$ev4,
2504
+ fieldTypes = _Options_1$Options$ev.fieldTypes;
2505
+
2506
+ return {
2507
+ xField: xField,
2508
+ yFields: [].concat(_toConsumableArray(yFields), _toConsumableArray(y2Fields)),
2509
+ fieldTypes: fieldTypes
2510
+ };
2511
+ } catch (e) {
2512
+ return {
2513
+ xField: undefined,
2514
+ yFields: [],
2515
+ fieldTypes: []
2516
+ };
2517
+ }
2518
+ }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
2519
+ return xAndYFieldsWithTypes;
2520
+ };
2521
+
2522
+ exports.default = useGetXAndYFields;
2523
+
2524
+ /***/ }),
2525
+ /* 123 */
2526
+ /***/ (function(module, exports, __webpack_require__) {
2527
+
2528
+ "use strict";
2529
+
2530
+
2531
+ Object.defineProperty(exports, "__esModule", {
2532
+ value: true
2533
+ });
2534
+ exports.getFeatureFlag = void 0;
2535
+
2536
+ var FeatureFlags_1 = __webpack_require__(124);
2537
+
2538
+ var getFeatureFlag = function getFeatureFlag(context, flagName) {
2539
+ // look for feature flag in context first
2540
+ if (context && Object.keys(context).find(function (key) {
2541
+ return key === flagName;
2542
+ })) {
2543
+ return context[flagName];
2544
+ } // fall back to defaults
2545
+
2546
+
2547
+ if (Object.keys(FeatureFlags_1.default).find(function (key) {
2548
+ return key === flagName;
2549
+ })) {
2550
+ return FeatureFlags_1.default[flagName];
2551
+ } // fall back to false
2552
+
2553
+
2554
+ return false;
2555
+ };
2556
+
2557
+ exports.getFeatureFlag = getFeatureFlag;
2558
+
2559
+ /***/ }),
2560
+ /* 124 */
2561
+ /***/ (function(module, exports) {
2562
+
2563
+ module.exports = require("@splunk/visualization-context/FeatureFlags");
2564
+
1487
2565
  /***/ })
1488
2566
  /******/ ]);
1489
2567
  //# sourceMappingURL=withDashboardViz.js.map