@splunk/visualizations 26.0.0 → 26.1.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 (150) hide show
  1. package/Area.config.js +102 -18
  2. package/Area.config.js.map +1 -1
  3. package/Area.js +618 -221
  4. package/Area.js.map +1 -1
  5. package/Bar.config.js +104 -20
  6. package/Bar.config.js.map +1 -1
  7. package/Bar.js +624 -219
  8. package/Bar.js.map +1 -1
  9. package/Bubble.config.js +94 -20
  10. package/Bubble.config.js.map +1 -1
  11. package/Bubble.js +606 -211
  12. package/Bubble.js.map +1 -1
  13. package/ChoroplethSvg.config.js +65 -14
  14. package/ChoroplethSvg.config.js.map +1 -1
  15. package/ChoroplethSvg.js +550 -183
  16. package/ChoroplethSvg.js.map +1 -1
  17. package/Column.config.js +103 -18
  18. package/Column.config.js.map +1 -1
  19. package/Column.js +637 -221
  20. package/Column.js.map +1 -1
  21. package/Ellipse.config.js +82 -17
  22. package/Ellipse.config.js.map +1 -1
  23. package/Ellipse.js +425 -148
  24. package/Ellipse.js.map +1 -1
  25. package/Events.config.js +100 -18
  26. package/Events.config.js.map +1 -1
  27. package/Events.js +752 -293
  28. package/Events.js.map +1 -1
  29. package/FillerGauge.config.js +96 -27
  30. package/FillerGauge.config.js.map +1 -1
  31. package/FillerGauge.js +759 -374
  32. package/FillerGauge.js.map +1 -1
  33. package/Image.config.js +62 -18
  34. package/Image.config.js.map +1 -1
  35. package/Image.js +419 -154
  36. package/Image.js.map +1 -1
  37. package/Line.config.js +106 -22
  38. package/Line.config.js.map +1 -1
  39. package/Line.js +631 -223
  40. package/Line.js.map +1 -1
  41. package/LinkGraph.config.js +72 -22
  42. package/LinkGraph.config.js.map +1 -1
  43. package/LinkGraph.js +632 -219
  44. package/LinkGraph.js.map +1 -1
  45. package/MIGRATION.md +1082 -0
  46. package/Map.config.js +241 -97
  47. package/Map.config.js.map +1 -1
  48. package/Map.js +1195 -595
  49. package/Map.js.map +1 -1
  50. package/Markdown.config.js +70 -20
  51. package/Markdown.config.js.map +1 -1
  52. package/Markdown.js +460 -195
  53. package/Markdown.js.map +1 -1
  54. package/MarkerGauge.config.js +79 -21
  55. package/MarkerGauge.config.js.map +1 -1
  56. package/MarkerGauge.js +802 -411
  57. package/MarkerGauge.js.map +1 -1
  58. package/ParallelCoordinates.config.js +72 -18
  59. package/ParallelCoordinates.config.js.map +1 -1
  60. package/ParallelCoordinates.js +853 -484
  61. package/ParallelCoordinates.js.map +1 -1
  62. package/Pie.config.js +75 -22
  63. package/Pie.config.js.map +1 -1
  64. package/Pie.js +612 -212
  65. package/Pie.js.map +1 -1
  66. package/Punchcard.config.js +81 -29
  67. package/Punchcard.config.js.map +1 -1
  68. package/Punchcard.js +844 -379
  69. package/Punchcard.js.map +1 -1
  70. package/Rectangle.config.js +85 -19
  71. package/Rectangle.config.js.map +1 -1
  72. package/Rectangle.js +432 -152
  73. package/Rectangle.js.map +1 -1
  74. package/Sankey.config.js +84 -22
  75. package/Sankey.config.js.map +1 -1
  76. package/Sankey.js +878 -342
  77. package/Sankey.js.map +1 -1
  78. package/Scatter.config.js +96 -22
  79. package/Scatter.config.js.map +1 -1
  80. package/Scatter.js +607 -212
  81. package/Scatter.js.map +1 -1
  82. package/SingleValue.config.js +94 -24
  83. package/SingleValue.config.js.map +1 -1
  84. package/SingleValue.js +1182 -650
  85. package/SingleValue.js.map +1 -1
  86. package/SingleValueBasic.js +286 -225
  87. package/SingleValueBasic.js.map +1 -1
  88. package/SingleValueIcon.config.js +92 -22
  89. package/SingleValueIcon.config.js.map +1 -1
  90. package/SingleValueIcon.js +965 -506
  91. package/SingleValueIcon.js.map +1 -1
  92. package/SingleValueRadial.config.js +99 -26
  93. package/SingleValueRadial.config.js.map +1 -1
  94. package/SingleValueRadial.js +1167 -616
  95. package/SingleValueRadial.js.map +1 -1
  96. package/SparkLine.js +126 -67
  97. package/SparkLine.js.map +1 -1
  98. package/Table.config.js +73 -20
  99. package/Table.config.js.map +1 -1
  100. package/Table.js +810 -322
  101. package/Table.js.map +1 -1
  102. package/common/Charting.js +107 -35
  103. package/common/Charting.js.map +1 -1
  104. package/common/ChartingApi.js +18 -7
  105. package/common/ChartingApi.js.map +1 -1
  106. package/common/EventsDoc.js +76 -22
  107. package/common/EventsDoc.js.map +1 -1
  108. package/common/GaugeMajorTicks.js +68 -58
  109. package/common/GaugeMajorTicks.js.map +1 -1
  110. package/common/GaugeValueMarker.js +43 -34
  111. package/common/GaugeValueMarker.js.map +1 -1
  112. package/common/OptionsDoc.js +156 -65
  113. package/common/OptionsDoc.js.map +1 -1
  114. package/common/OverviewDoc.js +33 -5
  115. package/common/OverviewDoc.js.map +1 -1
  116. package/common/SplunkVisualization.js +31 -4
  117. package/common/SplunkVisualization.js.map +1 -1
  118. package/common/SplunkVisualizationApi.js +8 -2
  119. package/common/SplunkVisualizationApi.js.map +1 -1
  120. package/common/ThemesDoc.js +27 -14
  121. package/common/ThemesDoc.js.map +1 -1
  122. package/common/chartingUtils.js +44 -12
  123. package/common/chartingUtils.js.map +1 -1
  124. package/common/docUtils.js +11 -1
  125. package/common/docUtils.js.map +1 -1
  126. package/common/gaugeUtils.js +173 -90
  127. package/common/gaugeUtils.js.map +1 -1
  128. package/common/shapeUtils.js +14 -2
  129. package/common/shapeUtils.js.map +1 -1
  130. package/common/utils/configUtils.js +49 -14
  131. package/common/utils/configUtils.js.map +1 -1
  132. package/common/utils/dataUtils.js +7 -2
  133. package/common/utils/dataUtils.js.map +1 -1
  134. package/common/utils/hocUtils.js +3 -1
  135. package/common/utils/hocUtils.js.map +1 -1
  136. package/common/utils/layoutUtils.js +1 -0
  137. package/common/utils/layoutUtils.js.map +1 -1
  138. package/common/utils/mapUtils.js +287 -127
  139. package/common/utils/mapUtils.js.map +1 -1
  140. package/common/utils/singleValueUtils.js +241 -196
  141. package/common/utils/singleValueUtils.js.map +1 -1
  142. package/common/utils/testHelper.js +9 -0
  143. package/common/utils/testHelper.js.map +1 -1
  144. package/common/utils/trellisUtils.js +61 -0
  145. package/common/utils/trellisUtils.js.map +1 -1
  146. package/common/utils/urlUtils.js +2 -0
  147. package/common/utils/urlUtils.js.map +1 -1
  148. package/common/withDashboardViz.js +274 -95
  149. package/common/withDashboardViz.js.map +1 -1
  150. package/package.json +16 -18
@@ -161,25 +161,38 @@ __webpack_require__.r(__webpack_exports__);
161
161
  /* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(49);
162
162
  /* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__);
163
163
 
164
+
164
165
  function ownKeys(object, enumerableOnly) {
165
166
  var keys = Object.keys(object);
167
+
166
168
  if (Object.getOwnPropertySymbols) {
167
169
  var symbols = Object.getOwnPropertySymbols(object);
168
- enumerableOnly && (symbols = symbols.filter(function (sym) {
170
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
169
171
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
170
- })), keys.push.apply(keys, symbols);
172
+ });
173
+ keys.push.apply(keys, symbols);
171
174
  }
175
+
172
176
  return keys;
173
177
  }
178
+
174
179
  function _objectSpread(target) {
175
180
  for (var i = 1; i < arguments.length; i++) {
176
- var source = null != arguments[i] ? arguments[i] : {};
177
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
178
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
179
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
180
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
181
- });
181
+ var source = arguments[i] != null ? arguments[i] : {};
182
+
183
+ if (i % 2) {
184
+ ownKeys(Object(source), true).forEach(function (key) {
185
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
186
+ });
187
+ } else if (Object.getOwnPropertyDescriptors) {
188
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
189
+ } else {
190
+ ownKeys(Object(source)).forEach(function (key) {
191
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
192
+ });
193
+ }
182
194
  }
195
+
183
196
  return target;
184
197
  }
185
198
 
@@ -187,6 +200,7 @@ function _objectSpread(target) {
187
200
 
188
201
 
189
202
 
203
+
190
204
  var DEFAULT_FONT = 12;
191
205
  var DEFAULT_FONT_FAMILY = '"Splunk Platform Sans", "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif';
192
206
  var SVR_PADDING = {
@@ -195,28 +209,27 @@ var SVR_PADDING = {
195
209
  left: 16,
196
210
  right: 16
197
211
  };
198
-
199
212
  /**
200
213
  * @method shouldShowTrend
201
214
  * @param {String} trendDisplay
202
215
  * @returns {Bool}
203
216
  */
217
+
204
218
  var shouldShowTrend = function shouldShowTrend(trendDisplay) {
205
219
  return trendDisplay === 'absolute' || trendDisplay === 'percent';
206
220
  };
207
-
208
221
  /**
209
222
  * @method isLoadingOrNoColumns
210
223
  * @param {Object} dataSources
211
224
  * @param {Boolean} loading
212
225
  * @returns {Boolean} return true if loading or without columns in dataSources
213
226
  */
227
+
214
228
  var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
215
229
  var data = Object(lodash__WEBPACK_IMPORTED_MODULE_1__["get"])(dataSources, 'primary.data.columns[0]', undefined);
216
230
  var noColumns = data === undefined;
217
231
  return loading || noColumns;
218
232
  };
219
-
220
233
  /**
221
234
  * Retrieve the valid formatted color
222
235
  * @method getFormattedColor
@@ -224,30 +237,30 @@ var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
224
237
  * @param {String} defaultColor
225
238
  * @returns {String} the formatted color
226
239
  */
240
+
227
241
  var getFormattedColor = function getFormattedColor(color, defaultColor) {
228
242
  return Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(color) || Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(defaultColor);
229
243
  };
230
-
231
244
  /**
232
245
  * Determines if there is a background color
233
246
  * @method hasBackground
234
247
  * @param {String} backgroundColor
235
248
  * @returns true for non-transparent background color
236
249
  */
250
+
237
251
  var hasBackground = function hasBackground(backgroundColor) {
238
252
  return !!backgroundColor && backgroundColor !== 'transparent';
239
253
  };
240
-
241
254
  /**
242
255
  * @method isIdenticalColor
243
256
  * @param {String} colorA
244
257
  * @param {String} colorB
245
258
  * @returns {Boolean}
246
259
  */
260
+
247
261
  var isIdenticalColor = function isIdenticalColor(colorA, colorB) {
248
262
  return !!colorA && !!colorB && Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(colorA.toLowerCase()) === Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(colorB.toLowerCase());
249
263
  };
250
-
251
264
  /*
252
265
  * @method getDefaultColorWithBg
253
266
  * @param {Object} props
@@ -256,13 +269,13 @@ var isIdenticalColor = function isIdenticalColor(colorA, colorB) {
256
269
  * @param {String} props.defaultBlockFontColor
257
270
  * @returns {String} defaultColor
258
271
  */
272
+
259
273
  var getDefaultColorWithBg = function getDefaultColorWithBg(_ref) {
260
274
  var backgroundColor = _ref.backgroundColor,
261
- defaultFontColor = _ref.defaultFontColor,
262
- defaultBlockFontColor = _ref.defaultBlockFontColor;
275
+ defaultFontColor = _ref.defaultFontColor,
276
+ defaultBlockFontColor = _ref.defaultBlockFontColor;
263
277
  return isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;
264
278
  };
265
-
266
279
  /*
267
280
  * @method getMajorColor
268
281
  * return formatted majorColor.
@@ -273,15 +286,16 @@ var getDefaultColorWithBg = function getDefaultColorWithBg(_ref) {
273
286
  * @param {String} props.defaultBlockFontColor
274
287
  * @returns {String} majorColor
275
288
  */
289
+
276
290
  var getMajorColor = function getMajorColor(_ref2) {
277
291
  var majorColor = _ref2.majorColor,
278
- backgroundColor = _ref2.backgroundColor,
279
- defaultFontColor = _ref2.defaultFontColor,
280
- defaultBlockFontColor = _ref2.defaultBlockFontColor;
281
- // If backgroundColor is set, but no majorColor,
292
+ backgroundColor = _ref2.backgroundColor,
293
+ defaultFontColor = _ref2.defaultFontColor,
294
+ defaultBlockFontColor = _ref2.defaultBlockFontColor; // If backgroundColor is set, but no majorColor,
282
295
  // the default majorColor will turn to be defaultBlockFontColor.
283
296
  // eg: major color will turn to be white in enterprise mode.
284
297
  // however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.
298
+
285
299
  if (hasBackground(backgroundColor) && !majorColor) {
286
300
  return getDefaultColorWithBg({
287
301
  backgroundColor: backgroundColor,
@@ -289,9 +303,9 @@ var getMajorColor = function getMajorColor(_ref2) {
289
303
  defaultBlockFontColor: defaultBlockFontColor
290
304
  });
291
305
  }
306
+
292
307
  return getFormattedColor(majorColor, defaultFontColor);
293
308
  };
294
-
295
309
  /**
296
310
  * Get the color for the trend components
297
311
  * @method getTrendColor
@@ -304,35 +318,41 @@ var getMajorColor = function getMajorColor(_ref2) {
304
318
  * @param {Object} defaultColors
305
319
  * @returns {String} trendColor
306
320
  */
321
+
307
322
  var getTrendColor = function getTrendColor(_ref3) {
308
323
  var trendColor = _ref3.trendColor,
309
- trendValue = _ref3.trendValue,
310
- majorValue = _ref3.majorValue,
311
- customizedBgColor = _ref3.customizedBgColor,
312
- trendDisplay = _ref3.trendDisplay,
313
- defaultColors = _ref3.defaultColors;
324
+ trendValue = _ref3.trendValue,
325
+ majorValue = _ref3.majorValue,
326
+ customizedBgColor = _ref3.customizedBgColor,
327
+ trendDisplay = _ref3.trendDisplay,
328
+ defaultColors = _ref3.defaultColors;
329
+
314
330
  if (trendColor) {
315
331
  return trendColor;
316
332
  }
333
+
317
334
  if (Number.isNaN(Number(trendValue))) {
318
335
  return undefined;
319
336
  }
337
+
320
338
  var defaultFontColor = defaultColors.defaultFontColor,
321
- defaultBlockFontColor = defaultColors.defaultBlockFontColor,
322
- defaultBackgroundColor = defaultColors.defaultBackgroundColor; // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor
339
+ defaultBlockFontColor = defaultColors.defaultBlockFontColor,
340
+ defaultBackgroundColor = defaultColors.defaultBackgroundColor; // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor
341
+
323
342
  if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
324
343
  return defaultBlockFontColor;
325
- }
326
-
327
- // if trendDisplay is percent, and trendValue === value
344
+ } // if trendDisplay is percent, and trendValue === value
328
345
  // the trend percent = trendValue / (value - trendValue) will return Infinity
346
+
347
+
329
348
  var isInvalidTrend = trendDisplay === 'percent' && trendValue === parseFloat(majorValue);
349
+
330
350
  if (trendValue === 0 || isInvalidTrend) {
331
351
  return defaultFontColor;
332
352
  }
353
+
333
354
  return trendValue > 0 ? _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_GREEN"] : _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_RED"];
334
355
  };
335
-
336
356
  /**
337
357
  * Computes visualization properties for display component
338
358
  * @method computeColors
@@ -345,6 +365,7 @@ var getTrendColor = function getTrendColor(_ref3) {
345
365
  * @returns {String} trendColor
346
366
  * @returns {String} underLabelColor
347
367
  */
368
+
348
369
  var computeColors = function computeColors(props, defaultColors) {
349
370
  var backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
350
371
  var backgroundEnabled = hasBackground(backgroundColor);
@@ -361,8 +382,8 @@ var computeColors = function computeColors(props, defaultColors) {
361
382
  customizedBgColor: props.backgroundColor,
362
383
  trendDisplay: props.trendDisplay,
363
384
  defaultColors: defaultColors
364
- });
365
- // todo: need change it to not depend on majorColor
385
+ }); // todo: need change it to not depend on majorColor
386
+
366
387
  var underLabelColor = majorColor;
367
388
  return {
368
389
  backgroundColor: backgroundColor,
@@ -372,7 +393,6 @@ var computeColors = function computeColors(props, defaultColors) {
372
393
  underLabelColor: underLabelColor
373
394
  };
374
395
  };
375
-
376
396
  /**
377
397
  * Format and return the value (major/trend)
378
398
  * @method computeText
@@ -383,21 +403,21 @@ var computeColors = function computeColors(props, defaultColors) {
383
403
  * @param {Bool} props.shouldAbbreviateTrendValue
384
404
  * @returns {Number} major or trend text
385
405
  */
406
+
386
407
  var computeText = function computeText(_ref4) {
387
408
  var value = _ref4.value,
388
- numberPrecision = _ref4.numberPrecision,
389
- shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
390
- shouldAbbreviateTrendValue = _ref4.shouldAbbreviateTrendValue;
409
+ numberPrecision = _ref4.numberPrecision,
410
+ shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
411
+ shouldAbbreviateTrendValue = _ref4.shouldAbbreviateTrendValue;
391
412
  var text = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(value) ? Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["formatNumber"])(value, numberPrecision, {
392
413
  useThousandSeparators: shouldUseThousandSeparators,
393
414
  // todo: need update formatNumber
394
415
  useTrendUnits: shouldAbbreviateTrendValue
395
- }) : value;
396
- // When text is undefined, return empty string
416
+ }) : value; // When text is undefined, return empty string
417
+
397
418
  text = text || '';
398
419
  return text;
399
420
  };
400
-
401
421
  /*
402
422
  * @method getMajorText
403
423
  * @param {Object} props
@@ -406,10 +426,11 @@ var computeText = function computeText(_ref4) {
406
426
  * @param {Bool} props.shouldUseThousandSeparators
407
427
  * @returns {String} majorText
408
428
  */
429
+
409
430
  var getMajorText = function getMajorText(_ref5) {
410
431
  var majorValue = _ref5.majorValue,
411
- numberPrecision = _ref5.numberPrecision,
412
- shouldUseThousandSeparators = _ref5.shouldUseThousandSeparators;
432
+ numberPrecision = _ref5.numberPrecision,
433
+ shouldUseThousandSeparators = _ref5.shouldUseThousandSeparators;
413
434
  return computeText({
414
435
  value: majorValue === null ? 'N/A' : majorValue,
415
436
  // if majorValue is null, use `N/A`.
@@ -418,7 +439,6 @@ var getMajorText = function getMajorText(_ref5) {
418
439
  shouldAbbreviateTrendValue: false
419
440
  });
420
441
  };
421
-
422
442
  /*
423
443
  * @method getTrendText
424
444
  * @param {Object} props
@@ -430,13 +450,15 @@ var getMajorText = function getMajorText(_ref5) {
430
450
  * @param {Bool} props.shouldAbbreviateTrendValue
431
451
  * @returns {String} trendText
432
452
  */
453
+
433
454
  var getTrendText = function getTrendText(_ref6) {
434
455
  var majorValue = _ref6.majorValue,
435
- trendValue = _ref6.trendValue,
436
- trendDisplay = _ref6.trendDisplay,
437
- numberPrecision = _ref6.numberPrecision,
438
- shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
439
- shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
456
+ trendValue = _ref6.trendValue,
457
+ trendDisplay = _ref6.trendDisplay,
458
+ numberPrecision = _ref6.numberPrecision,
459
+ shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
460
+ shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
461
+
440
462
  var compute = function compute(value) {
441
463
  return computeText({
442
464
  value: value,
@@ -445,25 +467,31 @@ var getTrendText = function getTrendText(_ref6) {
445
467
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
446
468
  });
447
469
  };
470
+
448
471
  if (trendValue === '' || !Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue)) {
449
472
  return '';
450
473
  }
474
+
451
475
  var showPercent = trendDisplay === 'percent';
476
+
452
477
  if (!showPercent) {
453
478
  return compute(trendValue);
454
479
  }
480
+
455
481
  var diff = Math.abs(trendValue - majorValue);
456
482
  var val = Math.round(trendValue / diff * 100);
483
+
457
484
  if (trendValue === 0 && diff === 0) {
458
485
  val = 0;
459
486
  }
487
+
460
488
  if (!Number.isFinite(val)) {
461
489
  return 'N/A';
462
490
  }
491
+
463
492
  var text = compute(val);
464
493
  return "".concat(text, "%");
465
494
  };
466
-
467
495
  /**
468
496
  * Helper to determine the font size for an element
469
497
  * @method computeFontSize
@@ -475,16 +503,16 @@ var getTrendText = function getTrendText(_ref6) {
475
503
  * @param {String} [fontWeight='normal'] Boldness of font
476
504
  * @returns {Number} The size to use for fontSize styles
477
505
  */
506
+
478
507
  var computeFontSize = function computeFontSize(text, _ref7) {
479
508
  var width = _ref7.width,
480
- height = _ref7.height;
509
+ height = _ref7.height;
481
510
  var fontFamily = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_FONT_FAMILY;
482
511
  var fontWeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'normal';
483
512
  var widthInDefaultFont = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(DEFAULT_FONT, "px ").concat(fontFamily));
484
513
  var fontSize = Math.min(width / widthInDefaultFont * DEFAULT_FONT, height / DEFAULT_FONT * DEFAULT_FONT);
485
514
  return parseInt(fontSize, 10);
486
515
  };
487
-
488
516
  /*
489
517
  * @method getMajorFontSize
490
518
  * @param {Object} props
@@ -495,20 +523,20 @@ var computeFontSize = function computeFontSize(text, _ref7) {
495
523
  * @param {Number} props.spaceRatio
496
524
  * @returns {Number} majorFontSize
497
525
  */
526
+
498
527
  var getMajorFontSize = function getMajorFontSize(_ref8) {
499
528
  var width = _ref8.width,
500
- height = _ref8.height,
501
- unit = _ref8.unit,
502
- majorText = _ref8.majorText,
503
- _ref8$spaceRatio = _ref8.spaceRatio,
504
- spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
529
+ height = _ref8.height,
530
+ unit = _ref8.unit,
531
+ majorText = _ref8.majorText,
532
+ _ref8$spaceRatio = _ref8.spaceRatio,
533
+ spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
505
534
  var majorTextCalc = unit ? "".concat(unit).concat(majorText) : majorText;
506
535
  return computeFontSize(majorTextCalc, {
507
536
  width: width * spaceRatio,
508
537
  height: height
509
538
  });
510
539
  };
511
-
512
540
  /*
513
541
  * @method getTrendFontSize
514
542
  * @param {Object} props
@@ -518,13 +546,15 @@ var getMajorFontSize = function getMajorFontSize(_ref8) {
518
546
  * @param {Number} props.spaceRatio
519
547
  * @returns {Number} trendFontSize
520
548
  */
549
+
521
550
  var getTrendFontSize = function getTrendFontSize(_ref9) {
522
551
  var width = _ref9.width,
523
- height = _ref9.height,
524
- trendText = _ref9.trendText,
525
- _ref9$spaceRatio = _ref9.spaceRatio,
526
- spaceRatio = _ref9$spaceRatio === void 0 ? 1 : _ref9$spaceRatio;
552
+ height = _ref9.height,
553
+ trendText = _ref9.trendText,
554
+ _ref9$spaceRatio = _ref9.spaceRatio,
555
+ spaceRatio = _ref9$spaceRatio === void 0 ? 1 : _ref9$spaceRatio;
527
556
  var trendFontSize = 12;
557
+
528
558
  if (spaceRatio > 0) {
529
559
  trendFontSize = computeFontSize(trendText, {
530
560
  width: width * spaceRatio,
@@ -532,18 +562,18 @@ var getTrendFontSize = function getTrendFontSize(_ref9) {
532
562
  });
533
563
  trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
534
564
  }
565
+
535
566
  return trendFontSize;
536
567
  };
537
-
538
568
  /*
539
569
  * The height of underLabel should no more than 12px
540
570
  * @param {Number} height
541
571
  * @return {Number} height || DEFAULT_FONT
542
572
  */
573
+
543
574
  var getUnderLabelHeight = function getUnderLabelHeight(height) {
544
575
  return height > DEFAULT_FONT ? DEFAULT_FONT : height;
545
576
  };
546
-
547
577
  /*
548
578
  * @param {Object} config
549
579
  * @param {String} underLabel
@@ -551,19 +581,18 @@ var getUnderLabelHeight = function getUnderLabelHeight(height) {
551
581
  * @param {Number} height height of underLabel
552
582
  * @param {Number} fond size of underLabel
553
583
  */
584
+
554
585
  var getUnderLabel = function getUnderLabel(_ref10) {
555
586
  var underLabel = _ref10.underLabel,
556
- width = _ref10.width,
557
- height = _ref10.height;
558
- return (
559
- // todo: may need truncate underLabel later
587
+ width = _ref10.width,
588
+ height = _ref10.height;
589
+ return (// todo: may need truncate underLabel later
560
590
  computeFontSize(underLabel, {
561
591
  width: width,
562
592
  height: height
563
593
  })
564
594
  );
565
595
  };
566
-
567
596
  /**
568
597
  * Compute value and font size for major and trend
569
598
  * @method getMajorAndTrend
@@ -581,18 +610,19 @@ var getUnderLabel = function getUnderLabel(_ref10) {
581
610
  * @param {Bool} props.shouldAbbreviateTrendValue
582
611
  * @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size
583
612
  */
613
+
584
614
  var getMajorAndTrend = function getMajorAndTrend(_ref11) {
585
615
  var width = _ref11.width,
586
- height = _ref11.height,
587
- majorValue = _ref11.majorValue,
588
- trendValue = _ref11.trendValue,
589
- majorFontSize = _ref11.majorFontSize,
590
- trendFontSize = _ref11.trendFontSize,
591
- trendDisplay = _ref11.trendDisplay,
592
- unit = _ref11.unit,
593
- numberPrecision = _ref11.numberPrecision,
594
- shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
595
- shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue;
616
+ height = _ref11.height,
617
+ majorValue = _ref11.majorValue,
618
+ trendValue = _ref11.trendValue,
619
+ majorFontSize = _ref11.majorFontSize,
620
+ trendFontSize = _ref11.trendFontSize,
621
+ trendDisplay = _ref11.trendDisplay,
622
+ unit = _ref11.unit,
623
+ numberPrecision = _ref11.numberPrecision,
624
+ shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
625
+ shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue;
596
626
  var majorTextSpaceRatio = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
597
627
  var textContentWidth = width * 0.9;
598
628
  var textContentHeight = height * 0.9;
@@ -629,7 +659,6 @@ var getMajorAndTrend = function getMajorAndTrend(_ref11) {
629
659
  trendTextFontSize: trendTextFontSize
630
660
  };
631
661
  };
632
-
633
662
  /*
634
663
  * @method updateVizInSmallSpace
635
664
  * @param {Object} props
@@ -649,25 +678,26 @@ var getMajorAndTrend = function getMajorAndTrend(_ref11) {
649
678
  * @returns {Object} results.newMajorAndTrend
650
679
  * @returns {Object} results.updatedProps
651
680
  */
681
+
652
682
  var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
653
683
  var width = _ref12.width,
654
- height = _ref12.height,
655
- toRemoveList = _ref12.toRemoveList,
656
- majorValue = _ref12.majorValue,
657
- trendValue = _ref12.trendValue,
658
- majorFontSize = _ref12.majorFontSize,
659
- trendFontSize = _ref12.trendFontSize,
660
- majorTextFontSize = _ref12.majorTextFontSize,
661
- unit = _ref12.unit,
662
- numberPrecision = _ref12.numberPrecision,
663
- shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
664
- shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
684
+ height = _ref12.height,
685
+ toRemoveList = _ref12.toRemoveList,
686
+ majorValue = _ref12.majorValue,
687
+ trendValue = _ref12.trendValue,
688
+ majorFontSize = _ref12.majorFontSize,
689
+ trendFontSize = _ref12.trendFontSize,
690
+ majorTextFontSize = _ref12.majorTextFontSize,
691
+ unit = _ref12.unit,
692
+ numberPrecision = _ref12.numberPrecision,
693
+ shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
694
+ shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
665
695
  var removeIndex = 0;
666
696
  var newProps = {}; // options need to be updated
697
+
667
698
  var newMajorAndTrend = {};
668
- var newTextSize = majorTextFontSize;
699
+ var newTextSize = majorTextFontSize; // remove info on viz to make textFontSize >= 12px;
669
700
 
670
- // remove info on viz to make textFontSize >= 12px;
671
701
  while (newTextSize < 12 && removeIndex < toRemoveList.length) {
672
702
  var toRemove = toRemoveList[removeIndex];
673
703
  newProps = _objectSpread(_objectSpread({}, newProps), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, toRemove.key, toRemove.value));
@@ -685,9 +715,9 @@ var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
685
715
  }, newProps));
686
716
  newTextSize = newMajorAndTrend.majorTextFontSize;
687
717
  removeIndex += 1;
688
- }
718
+ } // truncate text if textFontSize is still less than 12
719
+
689
720
 
690
- // truncate text if textFontSize is still less than 12
691
721
  if (newTextSize < 12) {
692
722
  var truncateValue = "".concat(majorValue.toString().slice(0, 3), "...");
693
723
  newMajorAndTrend = getMajorAndTrend(_objectSpread({
@@ -703,12 +733,12 @@ var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
703
733
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
704
734
  }, newProps));
705
735
  }
736
+
706
737
  return {
707
738
  newMajorAndTrend: newMajorAndTrend,
708
739
  updatedProps: newProps
709
740
  };
710
741
  };
711
-
712
742
  /*
713
743
  * @method computeSingleValueContent
714
744
  * @param {Object} props
@@ -734,67 +764,71 @@ var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
734
764
  * @returns {String} results.majorValueTitle
735
765
  * @returns {Object} results.smallVizProps
736
766
  */
767
+
737
768
  var computeSingleValueContent = function computeSingleValueContent(_ref13) {
738
769
  var contentWidth = _ref13.contentWidth,
739
- contentHeight = _ref13.contentHeight,
740
- containerWidth = _ref13.containerWidth,
741
- containerHeight = _ref13.containerHeight,
742
- majorValue = _ref13.majorValue,
743
- trendValue = _ref13.trendValue,
744
- majorFontSize = _ref13.majorFontSize,
745
- trendFontSize = _ref13.trendFontSize,
746
- trendDisplay = _ref13.trendDisplay,
747
- unit = _ref13.unit,
748
- numberPrecision = _ref13.numberPrecision,
749
- shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
750
- shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
751
- toRemoveList = _ref13.toRemoveList;
770
+ contentHeight = _ref13.contentHeight,
771
+ containerWidth = _ref13.containerWidth,
772
+ containerHeight = _ref13.containerHeight,
773
+ majorValue = _ref13.majorValue,
774
+ trendValue = _ref13.trendValue,
775
+ majorFontSize = _ref13.majorFontSize,
776
+ trendFontSize = _ref13.trendFontSize,
777
+ trendDisplay = _ref13.trendDisplay,
778
+ unit = _ref13.unit,
779
+ numberPrecision = _ref13.numberPrecision,
780
+ shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
781
+ shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
782
+ toRemoveList = _ref13.toRemoveList;
783
+
752
784
  var _getMajorAndTrend = getMajorAndTrend({
785
+ majorValue: majorValue,
786
+ trendValue: trendValue,
787
+ majorFontSize: majorFontSize,
788
+ trendFontSize: trendFontSize,
789
+ trendDisplay: trendDisplay,
790
+ width: contentWidth,
791
+ height: contentHeight,
792
+ unit: unit,
793
+ numberPrecision: numberPrecision,
794
+ shouldUseThousandSeparators: shouldUseThousandSeparators,
795
+ shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
796
+ }),
797
+ majorText = _getMajorAndTrend.majorText,
798
+ trendText = _getMajorAndTrend.trendText,
799
+ majorTextFontSize = _getMajorAndTrend.majorTextFontSize,
800
+ trendTextFontSize = _getMajorAndTrend.trendTextFontSize;
801
+
802
+ var majorValueTitle = majorText;
803
+ var smallVizProps = {}; // update viz in small space
804
+ // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit
805
+ // or truncate major value to make the major font size >= 12
806
+
807
+ if (majorTextFontSize < 12) {
808
+ var _updateVizInSmallSpac = updateVizInSmallSpace({
809
+ width: containerWidth,
810
+ height: containerHeight,
811
+ toRemoveList: toRemoveList,
753
812
  majorValue: majorValue,
754
813
  trendValue: trendValue,
755
814
  majorFontSize: majorFontSize,
756
815
  trendFontSize: trendFontSize,
757
- trendDisplay: trendDisplay,
758
- width: contentWidth,
759
- height: contentHeight,
816
+ majorTextFontSize: majorTextFontSize,
760
817
  unit: unit,
761
818
  numberPrecision: numberPrecision,
762
819
  shouldUseThousandSeparators: shouldUseThousandSeparators,
763
820
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
764
821
  }),
765
- majorText = _getMajorAndTrend.majorText,
766
- trendText = _getMajorAndTrend.trendText,
767
- majorTextFontSize = _getMajorAndTrend.majorTextFontSize,
768
- trendTextFontSize = _getMajorAndTrend.trendTextFontSize;
769
- var majorValueTitle = majorText;
770
- var smallVizProps = {};
822
+ newMajorAndTrend = _updateVizInSmallSpac.newMajorAndTrend,
823
+ updatedProps = _updateVizInSmallSpac.updatedProps;
771
824
 
772
- // update viz in small space
773
- // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit
774
- // or truncate major value to make the major font size >= 12
775
- if (majorTextFontSize < 12) {
776
- var _updateVizInSmallSpac = updateVizInSmallSpace({
777
- width: containerWidth,
778
- height: containerHeight,
779
- toRemoveList: toRemoveList,
780
- majorValue: majorValue,
781
- trendValue: trendValue,
782
- majorFontSize: majorFontSize,
783
- trendFontSize: trendFontSize,
784
- majorTextFontSize: majorTextFontSize,
785
- unit: unit,
786
- numberPrecision: numberPrecision,
787
- shouldUseThousandSeparators: shouldUseThousandSeparators,
788
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
789
- }),
790
- newMajorAndTrend = _updateVizInSmallSpac.newMajorAndTrend,
791
- updatedProps = _updateVizInSmallSpac.updatedProps;
792
825
  majorText = newMajorAndTrend.majorText;
793
826
  trendText = newMajorAndTrend.trendText;
794
827
  majorTextFontSize = newMajorAndTrend.majorTextFontSize;
795
828
  trendTextFontSize = newMajorAndTrend.trendTextFontSize;
796
829
  smallVizProps = updatedProps;
797
830
  }
831
+
798
832
  return {
799
833
  majorText: majorText,
800
834
  trendText: trendText,
@@ -806,17 +840,17 @@ var computeSingleValueContent = function computeSingleValueContent(_ref13) {
806
840
  };
807
841
  var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_ref14) {
808
842
  var text = _ref14.text,
809
- _ref14$fontSize = _ref14.fontSize,
810
- fontSize = _ref14$fontSize === void 0 ? DEFAULT_FONT : _ref14$fontSize,
811
- _ref14$fontFamily = _ref14.fontFamily,
812
- fontFamily = _ref14$fontFamily === void 0 ? DEFAULT_FONT_FAMILY : _ref14$fontFamily,
813
- _ref14$fontWeight = _ref14.fontWeight,
814
- fontWeight = _ref14$fontWeight === void 0 ? 'normal' : _ref14$fontWeight,
815
- containerWidth = _ref14.containerWidth;
843
+ _ref14$fontSize = _ref14.fontSize,
844
+ fontSize = _ref14$fontSize === void 0 ? DEFAULT_FONT : _ref14$fontSize,
845
+ _ref14$fontFamily = _ref14.fontFamily,
846
+ fontFamily = _ref14$fontFamily === void 0 ? DEFAULT_FONT_FAMILY : _ref14$fontFamily,
847
+ _ref14$fontWeight = _ref14.fontWeight,
848
+ fontWeight = _ref14$fontWeight === void 0 ? 'normal' : _ref14$fontWeight,
849
+ containerWidth = _ref14.containerWidth;
816
850
  var textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily));
817
851
  var modifiedText = text;
818
- var ellipsesLength = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])('...', "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily));
819
- // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.
852
+ var ellipsesLength = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])('...', "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily)); // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.
853
+
820
854
  if (containerWidth - ellipsesLength > 0 && textWidth > containerWidth) {
821
855
  // Truncates the content such that the truncated value + ellipses fit within the allocated space for the ellipses.
822
856
  // `textWidth > containerWidth - ellipsesLength` condition checks if text + ellipses exceeds container width.
@@ -825,11 +859,12 @@ var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_re
825
859
  modifiedText = modifiedText.substring(0, modifiedText.length - 1);
826
860
  textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(modifiedText, "normal ".concat(fontSize, "px ").concat(fontFamily));
827
861
  }
862
+
828
863
  modifiedText = "".concat(modifiedText, "...");
829
864
  }
865
+
830
866
  return modifiedText;
831
867
  };
832
-
833
868
  /*
834
869
  * @method computeSingleValueRadialContent
835
870
  * @param {Object} props
@@ -856,44 +891,46 @@ var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_re
856
891
  * @returns {String} results.majorValueTitle
857
892
  * @returns {Object} results.smallVizProps
858
893
  */
894
+
859
895
  var computeSingleValueRadialContent = function computeSingleValueRadialContent(_ref15) {
860
896
  var contentWidth = _ref15.contentWidth,
861
- contentHeight = _ref15.contentHeight,
862
- containerWidth = _ref15.containerWidth,
863
- containerHeight = _ref15.containerHeight,
864
- majorValue = _ref15.majorValue,
865
- trendValue = _ref15.trendValue,
866
- majorFontSize = _ref15.majorFontSize,
867
- trendFontSize = _ref15.trendFontSize,
868
- trendDisplay = _ref15.trendDisplay,
869
- unit = _ref15.unit,
870
- numberPrecision = _ref15.numberPrecision,
871
- shouldUseThousandSeparators = _ref15.shouldUseThousandSeparators,
872
- shouldAbbreviateTrendValue = _ref15.shouldAbbreviateTrendValue,
873
- smallViz = _ref15.smallViz;
897
+ contentHeight = _ref15.contentHeight,
898
+ containerWidth = _ref15.containerWidth,
899
+ containerHeight = _ref15.containerHeight,
900
+ majorValue = _ref15.majorValue,
901
+ trendValue = _ref15.trendValue,
902
+ majorFontSize = _ref15.majorFontSize,
903
+ trendFontSize = _ref15.trendFontSize,
904
+ trendDisplay = _ref15.trendDisplay,
905
+ unit = _ref15.unit,
906
+ numberPrecision = _ref15.numberPrecision,
907
+ shouldUseThousandSeparators = _ref15.shouldUseThousandSeparators,
908
+ shouldAbbreviateTrendValue = _ref15.shouldAbbreviateTrendValue,
909
+ smallViz = _ref15.smallViz;
910
+
874
911
  var _getMajorAndTrend2 = getMajorAndTrend({
875
- majorValue: majorValue,
876
- trendValue: trendValue,
877
- majorFontSize: majorFontSize,
878
- trendFontSize: trendFontSize,
879
- trendDisplay: trendDisplay,
880
- width: contentWidth,
881
- height: contentHeight,
882
- unit: unit,
883
- numberPrecision: numberPrecision,
884
- shouldUseThousandSeparators: shouldUseThousandSeparators,
885
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
886
- }),
887
- majorText = _getMajorAndTrend2.majorText,
888
- trendText = _getMajorAndTrend2.trendText,
889
- majorTextFontSize = _getMajorAndTrend2.majorTextFontSize,
890
- trendTextFontSize = _getMajorAndTrend2.trendTextFontSize;
891
- var majorValueTitle = majorText;
892
- var smallVizProps = {};
912
+ majorValue: majorValue,
913
+ trendValue: trendValue,
914
+ majorFontSize: majorFontSize,
915
+ trendFontSize: trendFontSize,
916
+ trendDisplay: trendDisplay,
917
+ width: contentWidth,
918
+ height: contentHeight,
919
+ unit: unit,
920
+ numberPrecision: numberPrecision,
921
+ shouldUseThousandSeparators: shouldUseThousandSeparators,
922
+ shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
923
+ }),
924
+ majorText = _getMajorAndTrend2.majorText,
925
+ trendText = _getMajorAndTrend2.trendText,
926
+ majorTextFontSize = _getMajorAndTrend2.majorTextFontSize,
927
+ trendTextFontSize = _getMajorAndTrend2.trendTextFontSize;
893
928
 
894
- // custom logic for viz in small space
929
+ var majorValueTitle = majorText;
930
+ var smallVizProps = {}; // custom logic for viz in small space
895
931
  // if not showing the radial graph (if `smallViz` is true), then compute truncated major value
896
932
  // and font sizes
933
+
897
934
  if (smallViz) {
898
935
  var truncateValue = minimallyTruncateStringToWidth({
899
936
  text: majorValue,
@@ -901,6 +938,7 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
901
938
  fontSize: 12,
902
939
  containerWidth: containerWidth
903
940
  });
941
+
904
942
  var _getMajorAndTrend3 = getMajorAndTrend({
905
943
  majorValue: truncateValue,
906
944
  trendValue: trendValue,
@@ -914,6 +952,7 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
914
952
  shouldUseThousandSeparators: shouldUseThousandSeparators,
915
953
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
916
954
  });
955
+
917
956
  majorText = _getMajorAndTrend3.majorText;
918
957
  trendText = _getMajorAndTrend3.trendText;
919
958
  majorTextFontSize = _getMajorAndTrend3.majorTextFontSize;
@@ -923,6 +962,7 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
923
962
  unit: unit
924
963
  };
925
964
  }
965
+
926
966
  return {
927
967
  majorText: majorText,
928
968
  trendText: trendText,
@@ -932,7 +972,6 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
932
972
  smallVizProps: smallVizProps
933
973
  };
934
974
  };
935
-
936
975
  /**
937
976
  * Get the colors for a graph
938
977
  *
@@ -945,21 +984,22 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
945
984
  * @returns {Object} { background, stroke } colors
946
985
  * @private
947
986
  */
987
+
948
988
  var getGraphColors = function getGraphColors(_ref16) {
949
989
  var backgroundEnabled = _ref16.backgroundEnabled,
950
- backgroundColor = _ref16.backgroundColor,
951
- defaultColors = _ref16.defaultColors,
952
- customColorFormatter = _ref16.customColorFormatter;
953
- // Only do custom colors in block mode
990
+ backgroundColor = _ref16.backgroundColor,
991
+ defaultColors = _ref16.defaultColors,
992
+ customColorFormatter = _ref16.customColorFormatter; // Only do custom colors in block mode
993
+
954
994
  if (backgroundEnabled) {
955
995
  // Check if the user defined colors to use
956
996
  if (backgroundColor && typeof customColorFormatter === 'function') {
957
997
  return customColorFormatter(backgroundColor);
958
998
  }
959
999
  }
1000
+
960
1001
  return defaultColors.none;
961
1002
  };
962
-
963
1003
  /**
964
1004
  * Adjust rgb value if it equals to 0 or 255
965
1005
  * @method adjustRGB
@@ -968,16 +1008,18 @@ var getGraphColors = function getGraphColors(_ref16) {
968
1008
  * @returns {Number} adjusted rgb
969
1009
  * @private
970
1010
  */
1011
+
971
1012
  var adjustRGB = function adjustRGB(rgb, delta) {
972
1013
  if (rgb === 255) {
973
1014
  return rgb - delta;
974
1015
  }
1016
+
975
1017
  if (rgb === 0) {
976
1018
  return rgb + delta;
977
1019
  }
1020
+
978
1021
  return rgb;
979
1022
  };
980
-
981
1023
  /**
982
1024
  * Modifies colors by multiplying by a given ratio
983
1025
  * @method changeColor
@@ -986,18 +1028,16 @@ var adjustRGB = function adjustRGB(rgb, delta) {
986
1028
  * @returns {String} new color
987
1029
  * @private
988
1030
  */
1031
+
989
1032
  var changeColor = function changeColor(color, ratio) {
990
1033
  var hex = color.replace(/(0x|#)/, '');
991
1034
  var r = parseInt(hex.substr(0, 2), 16);
992
1035
  var g = parseInt(hex.substr(2, 2), 16);
993
- var b = parseInt(hex.substr(4, 2), 16);
1036
+ var b = parseInt(hex.substr(4, 2), 16); // Multiply by given ratio, make sure is between 0 and 255;
994
1037
 
995
- // Multiply by given ratio, make sure is between 0 and 255;
996
1038
  var newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
997
1039
  var newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
998
- var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);
999
-
1000
- // If the color is not changed
1040
+ var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0); // If the color is not changed
1001
1041
  // case 1: the color is (0, 0 0)
1002
1042
  // lighten color (80, 80, 80)
1003
1043
  // darken color (40, 40, 40)
@@ -1006,6 +1046,7 @@ var changeColor = function changeColor(color, ratio) {
1006
1046
  // darken color (175, 175, 175)
1007
1047
  // case 3: the color is e.g. (0, 255, 0)
1008
1048
  // new color (20, 235, 20)
1049
+
1009
1050
  if (newR === r && newG === g && newB === b) {
1010
1051
  if (newR === 0 && newG === 0 && newB === 0) {
1011
1052
  if (ratio > 1) {
@@ -1033,9 +1074,9 @@ var changeColor = function changeColor(color, ratio) {
1033
1074
  newB = adjustRGB(newB, 20);
1034
1075
  }
1035
1076
  }
1077
+
1036
1078
  return "#".concat(newR.toString(16).padStart(2, 0)) + "".concat(newG.toString(16).padStart(2, 0)) + "".concat(newB.toString(16).padStart(2, 0));
1037
1079
  };
1038
-
1039
1080
  /**
1040
1081
  * Lighten a given color
1041
1082
  * @method lighten
@@ -1043,10 +1084,11 @@ var changeColor = function changeColor(color, ratio) {
1043
1084
  * @returns {String}
1044
1085
  * @private
1045
1086
  */
1087
+
1088
+
1046
1089
  var lighten = function lighten(color) {
1047
1090
  return changeColor(color, 1.3);
1048
1091
  };
1049
-
1050
1092
  /**
1051
1093
  * Darkens a given color
1052
1094
  * @method darken
@@ -1054,10 +1096,10 @@ var lighten = function lighten(color) {
1054
1096
  * @returns {String}
1055
1097
  * @private
1056
1098
  */
1099
+
1057
1100
  var darken = function darken(color) {
1058
1101
  return changeColor(color, 0.5);
1059
1102
  };
1060
-
1061
1103
  /** consistent token structure: handle callback to add value and name in event payload
1062
1104
  * @method handleValueClickCallback
1063
1105
  * @param {Object} ev
@@ -1066,6 +1108,7 @@ var darken = function darken(color) {
1066
1108
  * @param {Number} trendValue
1067
1109
  * @param {Function} onValueClick
1068
1110
  */
1111
+
1069
1112
  var handleValueClickCallback = function handleValueClickCallback(ev, majorValue, majorValueField, trendValue, onValueClick) {
1070
1113
  var trellisEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
1071
1114
  var trellisSplityBy = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
@@ -1075,12 +1118,14 @@ var handleValueClickCallback = function handleValueClickCallback(ev, majorValue,
1075
1118
  value: majorValue,
1076
1119
  name: majorValueField
1077
1120
  };
1121
+
1078
1122
  if (trellisEnabled) {
1079
1123
  payload = _objectSpread(_objectSpread({}, payload), {}, {
1080
1124
  'trellis.name': trellisSplityBy,
1081
1125
  'trellis.value': trellisKey
1082
1126
  });
1083
1127
  }
1128
+
1084
1129
  return onValueClick(_objectSpread(_objectSpread({}, ev), {}, {
1085
1130
  payload: payload
1086
1131
  }));
@@ -1174,11 +1219,11 @@ var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(exte
1174
1219
  var singleValueUtils = __webpack_require__(24);
1175
1220
 
1176
1221
  // EXTERNAL MODULE: external "@splunk/react-icons/enterprise/ArrowUp"
1177
- var ArrowUp_ = __webpack_require__(84);
1222
+ var ArrowUp_ = __webpack_require__(85);
1178
1223
  var ArrowUp_default = /*#__PURE__*/__webpack_require__.n(ArrowUp_);
1179
1224
 
1180
1225
  // EXTERNAL MODULE: external "@splunk/react-icons/enterprise/ArrowDown"
1181
- var ArrowDown_ = __webpack_require__(85);
1226
+ var ArrowDown_ = __webpack_require__(86);
1182
1227
  var ArrowDown_default = /*#__PURE__*/__webpack_require__.n(ArrowDown_);
1183
1228
 
1184
1229
  // EXTERNAL MODULE: external "@splunk/ui-utils/i18n"
@@ -1216,13 +1261,15 @@ var Text = external_styled_components_default.a.div.withConfig({
1216
1261
  }, function (props) {
1217
1262
  return props.size ? "margin-left: ".concat(parseInt(props.size, 10) * 0.2 || 5, "px;") : '';
1218
1263
  });
1264
+
1219
1265
  var TrendValue_SingleValueContent = function SingleValueContent(_ref) {
1220
1266
  var fontSize = _ref.fontSize,
1221
- color = _ref.color,
1222
- value = _ref.value,
1223
- text = _ref.text;
1267
+ color = _ref.color,
1268
+ value = _ref.value,
1269
+ text = _ref.text;
1224
1270
  var TrendIndicator = false;
1225
1271
  var ariaLabel = false;
1272
+
1226
1273
  if (parseFloat(value, 10) > 0) {
1227
1274
  TrendIndicator = ArrowUp_default.a;
1228
1275
  ariaLabel = Object(i18n_["_"])('increase');
@@ -1230,6 +1277,7 @@ var TrendValue_SingleValueContent = function SingleValueContent(_ref) {
1230
1277
  TrendIndicator = ArrowDown_default.a;
1231
1278
  ariaLabel = Object(i18n_["_"])('decrease');
1232
1279
  }
1280
+
1233
1281
  return /*#__PURE__*/external_react_default.a.createElement(Column, {
1234
1282
  justify: "flex-end",
1235
1283
  size: fontSize
@@ -1245,6 +1293,7 @@ var TrendValue_SingleValueContent = function SingleValueContent(_ref) {
1245
1293
  color: color
1246
1294
  }, "".concat(text)));
1247
1295
  };
1296
+
1248
1297
  TrendValue_SingleValueContent.propTypes = {
1249
1298
  fontSize: external_prop_types_default.a.number,
1250
1299
  color: external_prop_types_default.a.string,
@@ -1253,7 +1302,7 @@ TrendValue_SingleValueContent.propTypes = {
1253
1302
  };
1254
1303
  /* harmony default export */ var TrendValue = (TrendValue_SingleValueContent);
1255
1304
  // EXTERNAL MODULE: external "cssesc"
1256
- var external_cssesc_ = __webpack_require__(86);
1305
+ var external_cssesc_ = __webpack_require__(87);
1257
1306
  var external_cssesc_default = /*#__PURE__*/__webpack_require__.n(external_cssesc_);
1258
1307
 
1259
1308
  // CONCATENATED MODULE: ./src/SingleValueBasic/MajorValue.jsx
@@ -1285,37 +1334,44 @@ var MajorValue_Text = external_styled_components_default.a.div.withConfig({
1285
1334
  if (!props.pseudoContent || !props.pseudoContentPosition) {
1286
1335
  return '';
1287
1336
  }
1337
+
1288
1338
  return "&:".concat(props.pseudoContentPosition, " {\n // by default this pseudo element would inherit text-decoration from main element\n // and text-decoration could not be overwritten.\n // adding display: inline-block makes text decoration independent from main element.\n // => the unit will not be underlined if a user hovers over the main value\n display: inline-block;\n font-size: ").concat(props.pseudoContentFontSize, "px;\n position: relative;\n font-weight: normal;\n content: ").concat(props.pseudoContent, ";\n }");
1289
1339
  });
1290
1340
  var validUnitPositions = ['before', 'after'];
1341
+
1291
1342
  var MajorValue_SingleValueContent = function SingleValueContent(_ref) {
1292
1343
  var color = _ref.color,
1293
- fontSize = _ref.fontSize,
1294
- unitPosition = _ref.unitPosition,
1295
- title = _ref.title,
1296
- value = _ref.value,
1297
- onValueClick = _ref.onValueClick,
1298
- unit = _ref.unit;
1344
+ fontSize = _ref.fontSize,
1345
+ unitPosition = _ref.unitPosition,
1346
+ title = _ref.title,
1347
+ value = _ref.value,
1348
+ onValueClick = _ref.onValueClick,
1349
+ unit = _ref.unit;
1299
1350
  var sanitizedUnit;
1300
1351
  var sanitizedUnitPosition;
1352
+
1301
1353
  if (typeof unit === 'string') {
1302
1354
  sanitizedUnit = external_cssesc_default()(unit, {
1303
1355
  wrap: true,
1304
1356
  quotes: 'double'
1305
1357
  });
1358
+
1306
1359
  if (typeof unitPosition === 'string' && validUnitPositions.includes(unitPosition)) {
1307
1360
  sanitizedUnitPosition = unitPosition;
1308
1361
  } else {
1309
1362
  sanitizedUnitPosition = 'after';
1310
1363
  }
1311
1364
  }
1365
+
1312
1366
  var handleKeyDown = function handleKeyDown(e) {
1313
1367
  if (e.keyCode !== 13) {
1314
1368
  return;
1315
1369
  }
1370
+
1316
1371
  e.preventDefault();
1317
1372
  onValueClick(e);
1318
1373
  };
1374
+
1319
1375
  return /*#__PURE__*/external_react_default.a.createElement(Row, {
1320
1376
  size: fontSize
1321
1377
  }, /*#__PURE__*/external_react_default.a.createElement(MajorValue_Text, {
@@ -1335,6 +1391,7 @@ var MajorValue_SingleValueContent = function SingleValueContent(_ref) {
1335
1391
  onKeyDown: handleKeyDown
1336
1392
  }, value));
1337
1393
  };
1394
+
1338
1395
  MajorValue_SingleValueContent.propTypes = {
1339
1396
  color: external_prop_types_default.a.string,
1340
1397
  fontSize: external_prop_types_default.a.number,
@@ -1373,22 +1430,24 @@ var SingleValueBasic_Text = external_styled_components_default.a.div.withConfig(
1373
1430
  }, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
1374
1431
  return props.size || 12;
1375
1432
  });
1433
+
1376
1434
  var SingleValueBasic_SingleValueBasic = function SingleValueBasic(_ref) {
1377
1435
  var props = extends_default()({}, _ref);
1436
+
1378
1437
  var majorColor = props.majorColor,
1379
- majorTextFontSize = props.majorTextFontSize,
1380
- majorText = props.majorText,
1381
- majorValueTitle = props.majorValueTitle,
1382
- trendColor = props.trendColor,
1383
- trendTextFontSize = props.trendTextFontSize,
1384
- trendText = props.trendText,
1385
- showTrendIndicator = props.showTrendIndicator,
1386
- unit = props.unit,
1387
- unitPosition = props.unitPosition,
1388
- underLabel = props.underLabel,
1389
- underLabelFontSize = props.underLabelFontSize,
1390
- underLabelColor = props.underLabelColor,
1391
- onValueClick = props.onValueClick;
1438
+ majorTextFontSize = props.majorTextFontSize,
1439
+ majorText = props.majorText,
1440
+ majorValueTitle = props.majorValueTitle,
1441
+ trendColor = props.trendColor,
1442
+ trendTextFontSize = props.trendTextFontSize,
1443
+ trendText = props.trendText,
1444
+ showTrendIndicator = props.showTrendIndicator,
1445
+ unit = props.unit,
1446
+ unitPosition = props.unitPosition,
1447
+ underLabel = props.underLabel,
1448
+ underLabelFontSize = props.underLabelFontSize,
1449
+ underLabelColor = props.underLabelColor,
1450
+ onValueClick = props.onValueClick;
1392
1451
  var trendIndicatorEnabled = trendText !== '' && showTrendIndicator;
1393
1452
  return /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Column, null, /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Row, {
1394
1453
  align: "baseline"
@@ -1401,7 +1460,8 @@ var SingleValueBasic_SingleValueBasic = function SingleValueBasic(_ref) {
1401
1460
  value: majorText,
1402
1461
  title: majorValueTitle,
1403
1462
  onValueClick: onValueClick
1404
- }), trendIndicatorEnabled && /*#__PURE__*/
1463
+ }), trendIndicatorEnabled &&
1464
+ /*#__PURE__*/
1405
1465
  // Passing the same value for value and text is a temporary hold until completion of https://jira.splunk.com/browse/SCP-21371
1406
1466
  external_react_default.a.createElement(TrendValue, {
1407
1467
  "data-test": "TrendIndicator",
@@ -1417,6 +1477,7 @@ var SingleValueBasic_SingleValueBasic = function SingleValueBasic(_ref) {
1417
1477
  color: underLabelColor
1418
1478
  }, underLabel)));
1419
1479
  };
1480
+
1420
1481
  SingleValueBasic_SingleValueBasic.propTypes = {
1421
1482
  majorText: external_prop_types_default.a.string,
1422
1483
  majorColor: external_prop_types_default.a.string,
@@ -1438,21 +1499,21 @@ var SingleValueTrendValue = TrendValue;
1438
1499
 
1439
1500
  /***/ }),
1440
1501
 
1441
- /***/ 84:
1502
+ /***/ 85:
1442
1503
  /***/ (function(module, exports) {
1443
1504
 
1444
1505
  module.exports = require("@splunk/react-icons/enterprise/ArrowUp");
1445
1506
 
1446
1507
  /***/ }),
1447
1508
 
1448
- /***/ 85:
1509
+ /***/ 86:
1449
1510
  /***/ (function(module, exports) {
1450
1511
 
1451
1512
  module.exports = require("@splunk/react-icons/enterprise/ArrowDown");
1452
1513
 
1453
1514
  /***/ }),
1454
1515
 
1455
- /***/ 86:
1516
+ /***/ 87:
1456
1517
  /***/ (function(module, exports) {
1457
1518
 
1458
1519
  module.exports = require("cssesc");