@splunk/visualizations 25.13.1 → 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 +318 -234
  2. package/Area.config.js.map +1 -1
  3. package/Area.js +1131 -766
  4. package/Area.js.map +1 -1
  5. package/Bar.config.js +317 -233
  6. package/Bar.config.js.map +1 -1
  7. package/Bar.js +1007 -594
  8. package/Bar.js.map +1 -1
  9. package/Bubble.config.js +234 -160
  10. package/Bubble.config.js.map +1 -1
  11. package/Bubble.js +912 -509
  12. package/Bubble.js.map +1 -1
  13. package/ChoroplethSvg.config.js +80 -29
  14. package/ChoroplethSvg.config.js.map +1 -1
  15. package/ChoroplethSvg.js +691 -319
  16. package/ChoroplethSvg.js.map +1 -1
  17. package/Column.config.js +308 -223
  18. package/Column.config.js.map +1 -1
  19. package/Column.js +1011 -587
  20. package/Column.js.map +1 -1
  21. package/Ellipse.config.js +127 -62
  22. package/Ellipse.config.js.map +1 -1
  23. package/Ellipse.js +576 -286
  24. package/Ellipse.js.map +1 -1
  25. package/Events.config.js +111 -29
  26. package/Events.config.js.map +1 -1
  27. package/Events.js +998 -527
  28. package/Events.js.map +1 -1
  29. package/FillerGauge.config.js +142 -73
  30. package/FillerGauge.config.js.map +1 -1
  31. package/FillerGauge.js +962 -572
  32. package/FillerGauge.js.map +1 -1
  33. package/Image.config.js +70 -26
  34. package/Image.config.js.map +1 -1
  35. package/Image.js +524 -253
  36. package/Image.js.map +1 -1
  37. package/Line.config.js +326 -242
  38. package/Line.config.js.map +1 -1
  39. package/Line.js +1022 -606
  40. package/Line.js.map +1 -1
  41. package/LinkGraph.config.js +99 -49
  42. package/LinkGraph.config.js.map +1 -1
  43. package/LinkGraph.js +1184 -762
  44. package/LinkGraph.js.map +1 -1
  45. package/MIGRATION.md +1082 -0
  46. package/Map.config.js +311 -167
  47. package/Map.config.js.map +1 -1
  48. package/Map.js +1479 -873
  49. package/Map.js.map +1 -1
  50. package/Markdown.config.js +93 -43
  51. package/Markdown.config.js.map +1 -1
  52. package/Markdown.js +603 -332
  53. package/Markdown.js.map +1 -1
  54. package/MarkerGauge.config.js +163 -105
  55. package/MarkerGauge.config.js.map +1 -1
  56. package/MarkerGauge.js +1025 -628
  57. package/MarkerGauge.js.map +1 -1
  58. package/ParallelCoordinates.config.js +95 -41
  59. package/ParallelCoordinates.config.js.map +1 -1
  60. package/ParallelCoordinates.js +993 -622
  61. package/ParallelCoordinates.js.map +1 -1
  62. package/Pie.config.js +99 -46
  63. package/Pie.config.js.map +1 -1
  64. package/Pie.js +847 -442
  65. package/Pie.js.map +1 -1
  66. package/Punchcard.config.js +114 -62
  67. package/Punchcard.config.js.map +1 -1
  68. package/Punchcard.js +1097 -633
  69. package/Punchcard.js.map +1 -1
  70. package/Rectangle.config.js +131 -65
  71. package/Rectangle.config.js.map +1 -1
  72. package/Rectangle.js +580 -288
  73. package/Rectangle.js.map +1 -1
  74. package/Sankey.config.js +103 -41
  75. package/Sankey.config.js.map +1 -1
  76. package/Sankey.js +1128 -586
  77. package/Sankey.js.map +1 -1
  78. package/Scatter.config.js +231 -157
  79. package/Scatter.config.js.map +1 -1
  80. package/Scatter.js +904 -504
  81. package/Scatter.js.map +1 -1
  82. package/SingleValue.config.js +212 -142
  83. package/SingleValue.config.js.map +1 -1
  84. package/SingleValue.js +1506 -956
  85. package/SingleValue.js.map +1 -1
  86. package/SingleValueBasic.js +294 -233
  87. package/SingleValueBasic.js.map +1 -1
  88. package/SingleValueIcon.config.js +208 -138
  89. package/SingleValueIcon.config.js.map +1 -1
  90. package/SingleValueIcon.js +1375 -914
  91. package/SingleValueIcon.js.map +1 -1
  92. package/SingleValueRadial.config.js +252 -137
  93. package/SingleValueRadial.config.js.map +1 -1
  94. package/SingleValueRadial.js +2194 -1069
  95. package/SingleValueRadial.js.map +1 -1
  96. package/SparkLine.js +172 -83
  97. package/SparkLine.js.map +1 -1
  98. package/Table.config.js +123 -70
  99. package/Table.config.js.map +1 -1
  100. package/Table.js +1094 -590
  101. package/Table.js.map +1 -1
  102. package/common/Charting.js +147 -75
  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 +91 -36
  107. package/common/EventsDoc.js.map +1 -1
  108. package/common/GaugeMajorTicks.js +70 -60
  109. package/common/GaugeMajorTicks.js.map +1 -1
  110. package/common/GaugeValueMarker.js +45 -36
  111. package/common/GaugeValueMarker.js.map +1 -1
  112. package/common/OptionsDoc.js +177 -86
  113. package/common/OptionsDoc.js.map +1 -1
  114. package/common/OverviewDoc.js +65 -32
  115. package/common/OverviewDoc.js.map +1 -1
  116. package/common/SplunkVisualization.js +34 -7
  117. package/common/SplunkVisualization.js.map +1 -1
  118. package/common/SplunkVisualizationApi.js +10 -4
  119. package/common/SplunkVisualizationApi.js.map +1 -1
  120. package/common/ThemesDoc.js +41 -28
  121. package/common/ThemesDoc.js.map +1 -1
  122. package/common/chartingUtils.js +56 -24
  123. package/common/chartingUtils.js.map +1 -1
  124. package/common/docUtils.js +15 -5
  125. package/common/docUtils.js.map +1 -1
  126. package/common/gaugeUtils.js +238 -155
  127. package/common/gaugeUtils.js.map +1 -1
  128. package/common/shapeUtils.js +34 -16
  129. package/common/shapeUtils.js.map +1 -1
  130. package/common/utils/configUtils.js +59 -23
  131. package/common/utils/configUtils.js.map +1 -1
  132. package/common/utils/dataUtils.js +9 -4
  133. package/common/utils/dataUtils.js.map +1 -1
  134. package/common/utils/hocUtils.js +5 -3
  135. package/common/utils/hocUtils.js.map +1 -1
  136. package/common/utils/layoutUtils.js +3 -2
  137. package/common/utils/layoutUtils.js.map +1 -1
  138. package/common/utils/mapUtils.js +370 -206
  139. package/common/utils/mapUtils.js.map +1 -1
  140. package/common/utils/singleValueUtils.js +243 -198
  141. package/common/utils/singleValueUtils.js.map +1 -1
  142. package/common/utils/testHelper.js +36 -9
  143. package/common/utils/testHelper.js.map +1 -1
  144. package/common/utils/trellisUtils.js +87 -26
  145. package/common/utils/trellisUtils.js.map +1 -1
  146. package/common/utils/urlUtils.js +4 -2
  147. package/common/utils/urlUtils.js.map +1 -1
  148. package/common/withDashboardViz.js +375 -193
  149. package/common/withDashboardViz.js.map +1 -1
  150. package/package.json +25 -27
@@ -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 = 32);
90
+ /******/ return __webpack_require__(__webpack_require__.s = 33);
91
91
  /******/ })
92
92
  /************************************************************************/
93
93
  /******/ ({
@@ -106,7 +106,7 @@ module.exports = require("@babel/runtime/helpers/defineProperty");
106
106
 
107
107
  /***/ }),
108
108
 
109
- /***/ 32:
109
+ /***/ 33:
110
110
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
111
111
 
112
112
  "use strict";
@@ -154,25 +154,38 @@ __webpack_require__.r(__webpack_exports__);
154
154
  /* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
155
155
  /* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__);
156
156
 
157
+
157
158
  function ownKeys(object, enumerableOnly) {
158
159
  var keys = Object.keys(object);
160
+
159
161
  if (Object.getOwnPropertySymbols) {
160
162
  var symbols = Object.getOwnPropertySymbols(object);
161
- enumerableOnly && (symbols = symbols.filter(function (sym) {
163
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
162
164
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
163
- })), keys.push.apply(keys, symbols);
165
+ });
166
+ keys.push.apply(keys, symbols);
164
167
  }
168
+
165
169
  return keys;
166
170
  }
171
+
167
172
  function _objectSpread(target) {
168
173
  for (var i = 1; i < arguments.length; i++) {
169
- var source = null != arguments[i] ? arguments[i] : {};
170
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
171
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
172
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
173
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
174
- });
174
+ var source = arguments[i] != null ? arguments[i] : {};
175
+
176
+ if (i % 2) {
177
+ ownKeys(Object(source), true).forEach(function (key) {
178
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
179
+ });
180
+ } else if (Object.getOwnPropertyDescriptors) {
181
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
182
+ } else {
183
+ ownKeys(Object(source)).forEach(function (key) {
184
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
185
+ });
186
+ }
175
187
  }
188
+
176
189
  return target;
177
190
  }
178
191
 
@@ -180,6 +193,7 @@ function _objectSpread(target) {
180
193
 
181
194
 
182
195
 
196
+
183
197
  var DEFAULT_FONT = 12;
184
198
  var DEFAULT_FONT_FAMILY = '"Splunk Platform Sans", "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif';
185
199
  var SVR_PADDING = {
@@ -188,28 +202,27 @@ var SVR_PADDING = {
188
202
  left: 16,
189
203
  right: 16
190
204
  };
191
-
192
205
  /**
193
206
  * @method shouldShowTrend
194
207
  * @param {String} trendDisplay
195
208
  * @returns {Bool}
196
209
  */
210
+
197
211
  var shouldShowTrend = function shouldShowTrend(trendDisplay) {
198
212
  return trendDisplay === 'absolute' || trendDisplay === 'percent';
199
213
  };
200
-
201
214
  /**
202
215
  * @method isLoadingOrNoColumns
203
216
  * @param {Object} dataSources
204
217
  * @param {Boolean} loading
205
218
  * @returns {Boolean} return true if loading or without columns in dataSources
206
219
  */
220
+
207
221
  var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
208
222
  var data = Object(lodash__WEBPACK_IMPORTED_MODULE_1__["get"])(dataSources, 'primary.data.columns[0]', undefined);
209
223
  var noColumns = data === undefined;
210
224
  return loading || noColumns;
211
225
  };
212
-
213
226
  /**
214
227
  * Retrieve the valid formatted color
215
228
  * @method getFormattedColor
@@ -217,30 +230,30 @@ var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
217
230
  * @param {String} defaultColor
218
231
  * @returns {String} the formatted color
219
232
  */
233
+
220
234
  var getFormattedColor = function getFormattedColor(color, defaultColor) {
221
235
  return Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(color) || Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(defaultColor);
222
236
  };
223
-
224
237
  /**
225
238
  * Determines if there is a background color
226
239
  * @method hasBackground
227
240
  * @param {String} backgroundColor
228
241
  * @returns true for non-transparent background color
229
242
  */
243
+
230
244
  var hasBackground = function hasBackground(backgroundColor) {
231
245
  return !!backgroundColor && backgroundColor !== 'transparent';
232
246
  };
233
-
234
247
  /**
235
248
  * @method isIdenticalColor
236
249
  * @param {String} colorA
237
250
  * @param {String} colorB
238
251
  * @returns {Boolean}
239
252
  */
253
+
240
254
  var isIdenticalColor = function isIdenticalColor(colorA, colorB) {
241
255
  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());
242
256
  };
243
-
244
257
  /*
245
258
  * @method getDefaultColorWithBg
246
259
  * @param {Object} props
@@ -249,13 +262,13 @@ var isIdenticalColor = function isIdenticalColor(colorA, colorB) {
249
262
  * @param {String} props.defaultBlockFontColor
250
263
  * @returns {String} defaultColor
251
264
  */
265
+
252
266
  var getDefaultColorWithBg = function getDefaultColorWithBg(_ref) {
253
267
  var backgroundColor = _ref.backgroundColor,
254
- defaultFontColor = _ref.defaultFontColor,
255
- defaultBlockFontColor = _ref.defaultBlockFontColor;
268
+ defaultFontColor = _ref.defaultFontColor,
269
+ defaultBlockFontColor = _ref.defaultBlockFontColor;
256
270
  return isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;
257
271
  };
258
-
259
272
  /*
260
273
  * @method getMajorColor
261
274
  * return formatted majorColor.
@@ -266,15 +279,16 @@ var getDefaultColorWithBg = function getDefaultColorWithBg(_ref) {
266
279
  * @param {String} props.defaultBlockFontColor
267
280
  * @returns {String} majorColor
268
281
  */
282
+
269
283
  var getMajorColor = function getMajorColor(_ref2) {
270
284
  var majorColor = _ref2.majorColor,
271
- backgroundColor = _ref2.backgroundColor,
272
- defaultFontColor = _ref2.defaultFontColor,
273
- defaultBlockFontColor = _ref2.defaultBlockFontColor;
274
- // If backgroundColor is set, but no majorColor,
285
+ backgroundColor = _ref2.backgroundColor,
286
+ defaultFontColor = _ref2.defaultFontColor,
287
+ defaultBlockFontColor = _ref2.defaultBlockFontColor; // If backgroundColor is set, but no majorColor,
275
288
  // the default majorColor will turn to be defaultBlockFontColor.
276
289
  // eg: major color will turn to be white in enterprise mode.
277
290
  // however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.
291
+
278
292
  if (hasBackground(backgroundColor) && !majorColor) {
279
293
  return getDefaultColorWithBg({
280
294
  backgroundColor: backgroundColor,
@@ -282,9 +296,9 @@ var getMajorColor = function getMajorColor(_ref2) {
282
296
  defaultBlockFontColor: defaultBlockFontColor
283
297
  });
284
298
  }
299
+
285
300
  return getFormattedColor(majorColor, defaultFontColor);
286
301
  };
287
-
288
302
  /**
289
303
  * Get the color for the trend components
290
304
  * @method getTrendColor
@@ -297,35 +311,41 @@ var getMajorColor = function getMajorColor(_ref2) {
297
311
  * @param {Object} defaultColors
298
312
  * @returns {String} trendColor
299
313
  */
314
+
300
315
  var getTrendColor = function getTrendColor(_ref3) {
301
316
  var trendColor = _ref3.trendColor,
302
- trendValue = _ref3.trendValue,
303
- majorValue = _ref3.majorValue,
304
- customizedBgColor = _ref3.customizedBgColor,
305
- trendDisplay = _ref3.trendDisplay,
306
- defaultColors = _ref3.defaultColors;
317
+ trendValue = _ref3.trendValue,
318
+ majorValue = _ref3.majorValue,
319
+ customizedBgColor = _ref3.customizedBgColor,
320
+ trendDisplay = _ref3.trendDisplay,
321
+ defaultColors = _ref3.defaultColors;
322
+
307
323
  if (trendColor) {
308
324
  return trendColor;
309
325
  }
326
+
310
327
  if (Number.isNaN(Number(trendValue))) {
311
328
  return undefined;
312
329
  }
330
+
313
331
  var defaultFontColor = defaultColors.defaultFontColor,
314
- defaultBlockFontColor = defaultColors.defaultBlockFontColor,
315
- defaultBackgroundColor = defaultColors.defaultBackgroundColor; // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor
332
+ defaultBlockFontColor = defaultColors.defaultBlockFontColor,
333
+ defaultBackgroundColor = defaultColors.defaultBackgroundColor; // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor
334
+
316
335
  if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
317
336
  return defaultBlockFontColor;
318
- }
319
-
320
- // if trendDisplay is percent, and trendValue === value
337
+ } // if trendDisplay is percent, and trendValue === value
321
338
  // the trend percent = trendValue / (value - trendValue) will return Infinity
339
+
340
+
322
341
  var isInvalidTrend = trendDisplay === 'percent' && trendValue === parseFloat(majorValue);
342
+
323
343
  if (trendValue === 0 || isInvalidTrend) {
324
344
  return defaultFontColor;
325
345
  }
346
+
326
347
  return trendValue > 0 ? _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_GREEN"] : _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_RED"];
327
348
  };
328
-
329
349
  /**
330
350
  * Computes visualization properties for display component
331
351
  * @method computeColors
@@ -338,6 +358,7 @@ var getTrendColor = function getTrendColor(_ref3) {
338
358
  * @returns {String} trendColor
339
359
  * @returns {String} underLabelColor
340
360
  */
361
+
341
362
  var computeColors = function computeColors(props, defaultColors) {
342
363
  var backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
343
364
  var backgroundEnabled = hasBackground(backgroundColor);
@@ -354,8 +375,8 @@ var computeColors = function computeColors(props, defaultColors) {
354
375
  customizedBgColor: props.backgroundColor,
355
376
  trendDisplay: props.trendDisplay,
356
377
  defaultColors: defaultColors
357
- });
358
- // todo: need change it to not depend on majorColor
378
+ }); // todo: need change it to not depend on majorColor
379
+
359
380
  var underLabelColor = majorColor;
360
381
  return {
361
382
  backgroundColor: backgroundColor,
@@ -365,7 +386,6 @@ var computeColors = function computeColors(props, defaultColors) {
365
386
  underLabelColor: underLabelColor
366
387
  };
367
388
  };
368
-
369
389
  /**
370
390
  * Format and return the value (major/trend)
371
391
  * @method computeText
@@ -376,21 +396,21 @@ var computeColors = function computeColors(props, defaultColors) {
376
396
  * @param {Bool} props.shouldAbbreviateTrendValue
377
397
  * @returns {Number} major or trend text
378
398
  */
399
+
379
400
  var computeText = function computeText(_ref4) {
380
401
  var value = _ref4.value,
381
- numberPrecision = _ref4.numberPrecision,
382
- shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
383
- shouldAbbreviateTrendValue = _ref4.shouldAbbreviateTrendValue;
402
+ numberPrecision = _ref4.numberPrecision,
403
+ shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
404
+ shouldAbbreviateTrendValue = _ref4.shouldAbbreviateTrendValue;
384
405
  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, {
385
406
  useThousandSeparators: shouldUseThousandSeparators,
386
407
  // todo: need update formatNumber
387
408
  useTrendUnits: shouldAbbreviateTrendValue
388
- }) : value;
389
- // When text is undefined, return empty string
409
+ }) : value; // When text is undefined, return empty string
410
+
390
411
  text = text || '';
391
412
  return text;
392
413
  };
393
-
394
414
  /*
395
415
  * @method getMajorText
396
416
  * @param {Object} props
@@ -399,10 +419,11 @@ var computeText = function computeText(_ref4) {
399
419
  * @param {Bool} props.shouldUseThousandSeparators
400
420
  * @returns {String} majorText
401
421
  */
422
+
402
423
  var getMajorText = function getMajorText(_ref5) {
403
424
  var majorValue = _ref5.majorValue,
404
- numberPrecision = _ref5.numberPrecision,
405
- shouldUseThousandSeparators = _ref5.shouldUseThousandSeparators;
425
+ numberPrecision = _ref5.numberPrecision,
426
+ shouldUseThousandSeparators = _ref5.shouldUseThousandSeparators;
406
427
  return computeText({
407
428
  value: majorValue === null ? 'N/A' : majorValue,
408
429
  // if majorValue is null, use `N/A`.
@@ -411,7 +432,6 @@ var getMajorText = function getMajorText(_ref5) {
411
432
  shouldAbbreviateTrendValue: false
412
433
  });
413
434
  };
414
-
415
435
  /*
416
436
  * @method getTrendText
417
437
  * @param {Object} props
@@ -423,13 +443,15 @@ var getMajorText = function getMajorText(_ref5) {
423
443
  * @param {Bool} props.shouldAbbreviateTrendValue
424
444
  * @returns {String} trendText
425
445
  */
446
+
426
447
  var getTrendText = function getTrendText(_ref6) {
427
448
  var majorValue = _ref6.majorValue,
428
- trendValue = _ref6.trendValue,
429
- trendDisplay = _ref6.trendDisplay,
430
- numberPrecision = _ref6.numberPrecision,
431
- shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
432
- shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
449
+ trendValue = _ref6.trendValue,
450
+ trendDisplay = _ref6.trendDisplay,
451
+ numberPrecision = _ref6.numberPrecision,
452
+ shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
453
+ shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
454
+
433
455
  var compute = function compute(value) {
434
456
  return computeText({
435
457
  value: value,
@@ -438,25 +460,31 @@ var getTrendText = function getTrendText(_ref6) {
438
460
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
439
461
  });
440
462
  };
463
+
441
464
  if (trendValue === '' || !Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue)) {
442
465
  return '';
443
466
  }
467
+
444
468
  var showPercent = trendDisplay === 'percent';
469
+
445
470
  if (!showPercent) {
446
471
  return compute(trendValue);
447
472
  }
473
+
448
474
  var diff = Math.abs(trendValue - majorValue);
449
475
  var val = Math.round(trendValue / diff * 100);
476
+
450
477
  if (trendValue === 0 && diff === 0) {
451
478
  val = 0;
452
479
  }
480
+
453
481
  if (!Number.isFinite(val)) {
454
482
  return 'N/A';
455
483
  }
484
+
456
485
  var text = compute(val);
457
486
  return "".concat(text, "%");
458
487
  };
459
-
460
488
  /**
461
489
  * Helper to determine the font size for an element
462
490
  * @method computeFontSize
@@ -468,16 +496,16 @@ var getTrendText = function getTrendText(_ref6) {
468
496
  * @param {String} [fontWeight='normal'] Boldness of font
469
497
  * @returns {Number} The size to use for fontSize styles
470
498
  */
499
+
471
500
  var computeFontSize = function computeFontSize(text, _ref7) {
472
501
  var width = _ref7.width,
473
- height = _ref7.height;
502
+ height = _ref7.height;
474
503
  var fontFamily = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_FONT_FAMILY;
475
504
  var fontWeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'normal';
476
505
  var widthInDefaultFont = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(DEFAULT_FONT, "px ").concat(fontFamily));
477
506
  var fontSize = Math.min(width / widthInDefaultFont * DEFAULT_FONT, height / DEFAULT_FONT * DEFAULT_FONT);
478
507
  return parseInt(fontSize, 10);
479
508
  };
480
-
481
509
  /*
482
510
  * @method getMajorFontSize
483
511
  * @param {Object} props
@@ -488,20 +516,20 @@ var computeFontSize = function computeFontSize(text, _ref7) {
488
516
  * @param {Number} props.spaceRatio
489
517
  * @returns {Number} majorFontSize
490
518
  */
519
+
491
520
  var getMajorFontSize = function getMajorFontSize(_ref8) {
492
521
  var width = _ref8.width,
493
- height = _ref8.height,
494
- unit = _ref8.unit,
495
- majorText = _ref8.majorText,
496
- _ref8$spaceRatio = _ref8.spaceRatio,
497
- spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
522
+ height = _ref8.height,
523
+ unit = _ref8.unit,
524
+ majorText = _ref8.majorText,
525
+ _ref8$spaceRatio = _ref8.spaceRatio,
526
+ spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
498
527
  var majorTextCalc = unit ? "".concat(unit).concat(majorText) : majorText;
499
528
  return computeFontSize(majorTextCalc, {
500
529
  width: width * spaceRatio,
501
530
  height: height
502
531
  });
503
532
  };
504
-
505
533
  /*
506
534
  * @method getTrendFontSize
507
535
  * @param {Object} props
@@ -511,13 +539,15 @@ var getMajorFontSize = function getMajorFontSize(_ref8) {
511
539
  * @param {Number} props.spaceRatio
512
540
  * @returns {Number} trendFontSize
513
541
  */
542
+
514
543
  var getTrendFontSize = function getTrendFontSize(_ref9) {
515
544
  var width = _ref9.width,
516
- height = _ref9.height,
517
- trendText = _ref9.trendText,
518
- _ref9$spaceRatio = _ref9.spaceRatio,
519
- spaceRatio = _ref9$spaceRatio === void 0 ? 1 : _ref9$spaceRatio;
545
+ height = _ref9.height,
546
+ trendText = _ref9.trendText,
547
+ _ref9$spaceRatio = _ref9.spaceRatio,
548
+ spaceRatio = _ref9$spaceRatio === void 0 ? 1 : _ref9$spaceRatio;
520
549
  var trendFontSize = 12;
550
+
521
551
  if (spaceRatio > 0) {
522
552
  trendFontSize = computeFontSize(trendText, {
523
553
  width: width * spaceRatio,
@@ -525,18 +555,18 @@ var getTrendFontSize = function getTrendFontSize(_ref9) {
525
555
  });
526
556
  trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
527
557
  }
558
+
528
559
  return trendFontSize;
529
560
  };
530
-
531
561
  /*
532
562
  * The height of underLabel should no more than 12px
533
563
  * @param {Number} height
534
564
  * @return {Number} height || DEFAULT_FONT
535
565
  */
566
+
536
567
  var getUnderLabelHeight = function getUnderLabelHeight(height) {
537
568
  return height > DEFAULT_FONT ? DEFAULT_FONT : height;
538
569
  };
539
-
540
570
  /*
541
571
  * @param {Object} config
542
572
  * @param {String} underLabel
@@ -544,19 +574,18 @@ var getUnderLabelHeight = function getUnderLabelHeight(height) {
544
574
  * @param {Number} height height of underLabel
545
575
  * @param {Number} fond size of underLabel
546
576
  */
577
+
547
578
  var getUnderLabel = function getUnderLabel(_ref10) {
548
579
  var underLabel = _ref10.underLabel,
549
- width = _ref10.width,
550
- height = _ref10.height;
551
- return (
552
- // todo: may need truncate underLabel later
580
+ width = _ref10.width,
581
+ height = _ref10.height;
582
+ return (// todo: may need truncate underLabel later
553
583
  computeFontSize(underLabel, {
554
584
  width: width,
555
585
  height: height
556
586
  })
557
587
  );
558
588
  };
559
-
560
589
  /**
561
590
  * Compute value and font size for major and trend
562
591
  * @method getMajorAndTrend
@@ -574,18 +603,19 @@ var getUnderLabel = function getUnderLabel(_ref10) {
574
603
  * @param {Bool} props.shouldAbbreviateTrendValue
575
604
  * @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size
576
605
  */
606
+
577
607
  var getMajorAndTrend = function getMajorAndTrend(_ref11) {
578
608
  var width = _ref11.width,
579
- height = _ref11.height,
580
- majorValue = _ref11.majorValue,
581
- trendValue = _ref11.trendValue,
582
- majorFontSize = _ref11.majorFontSize,
583
- trendFontSize = _ref11.trendFontSize,
584
- trendDisplay = _ref11.trendDisplay,
585
- unit = _ref11.unit,
586
- numberPrecision = _ref11.numberPrecision,
587
- shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
588
- shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue;
609
+ height = _ref11.height,
610
+ majorValue = _ref11.majorValue,
611
+ trendValue = _ref11.trendValue,
612
+ majorFontSize = _ref11.majorFontSize,
613
+ trendFontSize = _ref11.trendFontSize,
614
+ trendDisplay = _ref11.trendDisplay,
615
+ unit = _ref11.unit,
616
+ numberPrecision = _ref11.numberPrecision,
617
+ shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
618
+ shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue;
589
619
  var majorTextSpaceRatio = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
590
620
  var textContentWidth = width * 0.9;
591
621
  var textContentHeight = height * 0.9;
@@ -622,7 +652,6 @@ var getMajorAndTrend = function getMajorAndTrend(_ref11) {
622
652
  trendTextFontSize: trendTextFontSize
623
653
  };
624
654
  };
625
-
626
655
  /*
627
656
  * @method updateVizInSmallSpace
628
657
  * @param {Object} props
@@ -642,25 +671,26 @@ var getMajorAndTrend = function getMajorAndTrend(_ref11) {
642
671
  * @returns {Object} results.newMajorAndTrend
643
672
  * @returns {Object} results.updatedProps
644
673
  */
674
+
645
675
  var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
646
676
  var width = _ref12.width,
647
- height = _ref12.height,
648
- toRemoveList = _ref12.toRemoveList,
649
- majorValue = _ref12.majorValue,
650
- trendValue = _ref12.trendValue,
651
- majorFontSize = _ref12.majorFontSize,
652
- trendFontSize = _ref12.trendFontSize,
653
- majorTextFontSize = _ref12.majorTextFontSize,
654
- unit = _ref12.unit,
655
- numberPrecision = _ref12.numberPrecision,
656
- shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
657
- shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
677
+ height = _ref12.height,
678
+ toRemoveList = _ref12.toRemoveList,
679
+ majorValue = _ref12.majorValue,
680
+ trendValue = _ref12.trendValue,
681
+ majorFontSize = _ref12.majorFontSize,
682
+ trendFontSize = _ref12.trendFontSize,
683
+ majorTextFontSize = _ref12.majorTextFontSize,
684
+ unit = _ref12.unit,
685
+ numberPrecision = _ref12.numberPrecision,
686
+ shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
687
+ shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
658
688
  var removeIndex = 0;
659
689
  var newProps = {}; // options need to be updated
690
+
660
691
  var newMajorAndTrend = {};
661
- var newTextSize = majorTextFontSize;
692
+ var newTextSize = majorTextFontSize; // remove info on viz to make textFontSize >= 12px;
662
693
 
663
- // remove info on viz to make textFontSize >= 12px;
664
694
  while (newTextSize < 12 && removeIndex < toRemoveList.length) {
665
695
  var toRemove = toRemoveList[removeIndex];
666
696
  newProps = _objectSpread(_objectSpread({}, newProps), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, toRemove.key, toRemove.value));
@@ -678,9 +708,9 @@ var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
678
708
  }, newProps));
679
709
  newTextSize = newMajorAndTrend.majorTextFontSize;
680
710
  removeIndex += 1;
681
- }
711
+ } // truncate text if textFontSize is still less than 12
712
+
682
713
 
683
- // truncate text if textFontSize is still less than 12
684
714
  if (newTextSize < 12) {
685
715
  var truncateValue = "".concat(majorValue.toString().slice(0, 3), "...");
686
716
  newMajorAndTrend = getMajorAndTrend(_objectSpread({
@@ -696,12 +726,12 @@ var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
696
726
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
697
727
  }, newProps));
698
728
  }
729
+
699
730
  return {
700
731
  newMajorAndTrend: newMajorAndTrend,
701
732
  updatedProps: newProps
702
733
  };
703
734
  };
704
-
705
735
  /*
706
736
  * @method computeSingleValueContent
707
737
  * @param {Object} props
@@ -727,67 +757,71 @@ var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
727
757
  * @returns {String} results.majorValueTitle
728
758
  * @returns {Object} results.smallVizProps
729
759
  */
760
+
730
761
  var computeSingleValueContent = function computeSingleValueContent(_ref13) {
731
762
  var contentWidth = _ref13.contentWidth,
732
- contentHeight = _ref13.contentHeight,
733
- containerWidth = _ref13.containerWidth,
734
- containerHeight = _ref13.containerHeight,
735
- majorValue = _ref13.majorValue,
736
- trendValue = _ref13.trendValue,
737
- majorFontSize = _ref13.majorFontSize,
738
- trendFontSize = _ref13.trendFontSize,
739
- trendDisplay = _ref13.trendDisplay,
740
- unit = _ref13.unit,
741
- numberPrecision = _ref13.numberPrecision,
742
- shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
743
- shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
744
- toRemoveList = _ref13.toRemoveList;
763
+ contentHeight = _ref13.contentHeight,
764
+ containerWidth = _ref13.containerWidth,
765
+ containerHeight = _ref13.containerHeight,
766
+ majorValue = _ref13.majorValue,
767
+ trendValue = _ref13.trendValue,
768
+ majorFontSize = _ref13.majorFontSize,
769
+ trendFontSize = _ref13.trendFontSize,
770
+ trendDisplay = _ref13.trendDisplay,
771
+ unit = _ref13.unit,
772
+ numberPrecision = _ref13.numberPrecision,
773
+ shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
774
+ shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
775
+ toRemoveList = _ref13.toRemoveList;
776
+
745
777
  var _getMajorAndTrend = getMajorAndTrend({
778
+ majorValue: majorValue,
779
+ trendValue: trendValue,
780
+ majorFontSize: majorFontSize,
781
+ trendFontSize: trendFontSize,
782
+ trendDisplay: trendDisplay,
783
+ width: contentWidth,
784
+ height: contentHeight,
785
+ unit: unit,
786
+ numberPrecision: numberPrecision,
787
+ shouldUseThousandSeparators: shouldUseThousandSeparators,
788
+ shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
789
+ }),
790
+ majorText = _getMajorAndTrend.majorText,
791
+ trendText = _getMajorAndTrend.trendText,
792
+ majorTextFontSize = _getMajorAndTrend.majorTextFontSize,
793
+ trendTextFontSize = _getMajorAndTrend.trendTextFontSize;
794
+
795
+ var majorValueTitle = majorText;
796
+ var smallVizProps = {}; // update viz in small space
797
+ // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit
798
+ // or truncate major value to make the major font size >= 12
799
+
800
+ if (majorTextFontSize < 12) {
801
+ var _updateVizInSmallSpac = updateVizInSmallSpace({
802
+ width: containerWidth,
803
+ height: containerHeight,
804
+ toRemoveList: toRemoveList,
746
805
  majorValue: majorValue,
747
806
  trendValue: trendValue,
748
807
  majorFontSize: majorFontSize,
749
808
  trendFontSize: trendFontSize,
750
- trendDisplay: trendDisplay,
751
- width: contentWidth,
752
- height: contentHeight,
809
+ majorTextFontSize: majorTextFontSize,
753
810
  unit: unit,
754
811
  numberPrecision: numberPrecision,
755
812
  shouldUseThousandSeparators: shouldUseThousandSeparators,
756
813
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
757
814
  }),
758
- majorText = _getMajorAndTrend.majorText,
759
- trendText = _getMajorAndTrend.trendText,
760
- majorTextFontSize = _getMajorAndTrend.majorTextFontSize,
761
- trendTextFontSize = _getMajorAndTrend.trendTextFontSize;
762
- var majorValueTitle = majorText;
763
- var smallVizProps = {};
815
+ newMajorAndTrend = _updateVizInSmallSpac.newMajorAndTrend,
816
+ updatedProps = _updateVizInSmallSpac.updatedProps;
764
817
 
765
- // update viz in small space
766
- // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit
767
- // or truncate major value to make the major font size >= 12
768
- if (majorTextFontSize < 12) {
769
- var _updateVizInSmallSpac = updateVizInSmallSpace({
770
- width: containerWidth,
771
- height: containerHeight,
772
- toRemoveList: toRemoveList,
773
- majorValue: majorValue,
774
- trendValue: trendValue,
775
- majorFontSize: majorFontSize,
776
- trendFontSize: trendFontSize,
777
- majorTextFontSize: majorTextFontSize,
778
- unit: unit,
779
- numberPrecision: numberPrecision,
780
- shouldUseThousandSeparators: shouldUseThousandSeparators,
781
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
782
- }),
783
- newMajorAndTrend = _updateVizInSmallSpac.newMajorAndTrend,
784
- updatedProps = _updateVizInSmallSpac.updatedProps;
785
818
  majorText = newMajorAndTrend.majorText;
786
819
  trendText = newMajorAndTrend.trendText;
787
820
  majorTextFontSize = newMajorAndTrend.majorTextFontSize;
788
821
  trendTextFontSize = newMajorAndTrend.trendTextFontSize;
789
822
  smallVizProps = updatedProps;
790
823
  }
824
+
791
825
  return {
792
826
  majorText: majorText,
793
827
  trendText: trendText,
@@ -799,17 +833,17 @@ var computeSingleValueContent = function computeSingleValueContent(_ref13) {
799
833
  };
800
834
  var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_ref14) {
801
835
  var text = _ref14.text,
802
- _ref14$fontSize = _ref14.fontSize,
803
- fontSize = _ref14$fontSize === void 0 ? DEFAULT_FONT : _ref14$fontSize,
804
- _ref14$fontFamily = _ref14.fontFamily,
805
- fontFamily = _ref14$fontFamily === void 0 ? DEFAULT_FONT_FAMILY : _ref14$fontFamily,
806
- _ref14$fontWeight = _ref14.fontWeight,
807
- fontWeight = _ref14$fontWeight === void 0 ? 'normal' : _ref14$fontWeight,
808
- containerWidth = _ref14.containerWidth;
836
+ _ref14$fontSize = _ref14.fontSize,
837
+ fontSize = _ref14$fontSize === void 0 ? DEFAULT_FONT : _ref14$fontSize,
838
+ _ref14$fontFamily = _ref14.fontFamily,
839
+ fontFamily = _ref14$fontFamily === void 0 ? DEFAULT_FONT_FAMILY : _ref14$fontFamily,
840
+ _ref14$fontWeight = _ref14.fontWeight,
841
+ fontWeight = _ref14$fontWeight === void 0 ? 'normal' : _ref14$fontWeight,
842
+ containerWidth = _ref14.containerWidth;
809
843
  var textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily));
810
844
  var modifiedText = text;
811
- var ellipsesLength = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])('...', "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily));
812
- // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.
845
+ 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.
846
+
813
847
  if (containerWidth - ellipsesLength > 0 && textWidth > containerWidth) {
814
848
  // Truncates the content such that the truncated value + ellipses fit within the allocated space for the ellipses.
815
849
  // `textWidth > containerWidth - ellipsesLength` condition checks if text + ellipses exceeds container width.
@@ -818,11 +852,12 @@ var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_re
818
852
  modifiedText = modifiedText.substring(0, modifiedText.length - 1);
819
853
  textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(modifiedText, "normal ".concat(fontSize, "px ").concat(fontFamily));
820
854
  }
855
+
821
856
  modifiedText = "".concat(modifiedText, "...");
822
857
  }
858
+
823
859
  return modifiedText;
824
860
  };
825
-
826
861
  /*
827
862
  * @method computeSingleValueRadialContent
828
863
  * @param {Object} props
@@ -849,44 +884,46 @@ var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_re
849
884
  * @returns {String} results.majorValueTitle
850
885
  * @returns {Object} results.smallVizProps
851
886
  */
887
+
852
888
  var computeSingleValueRadialContent = function computeSingleValueRadialContent(_ref15) {
853
889
  var contentWidth = _ref15.contentWidth,
854
- contentHeight = _ref15.contentHeight,
855
- containerWidth = _ref15.containerWidth,
856
- containerHeight = _ref15.containerHeight,
857
- majorValue = _ref15.majorValue,
858
- trendValue = _ref15.trendValue,
859
- majorFontSize = _ref15.majorFontSize,
860
- trendFontSize = _ref15.trendFontSize,
861
- trendDisplay = _ref15.trendDisplay,
862
- unit = _ref15.unit,
863
- numberPrecision = _ref15.numberPrecision,
864
- shouldUseThousandSeparators = _ref15.shouldUseThousandSeparators,
865
- shouldAbbreviateTrendValue = _ref15.shouldAbbreviateTrendValue,
866
- smallViz = _ref15.smallViz;
890
+ contentHeight = _ref15.contentHeight,
891
+ containerWidth = _ref15.containerWidth,
892
+ containerHeight = _ref15.containerHeight,
893
+ majorValue = _ref15.majorValue,
894
+ trendValue = _ref15.trendValue,
895
+ majorFontSize = _ref15.majorFontSize,
896
+ trendFontSize = _ref15.trendFontSize,
897
+ trendDisplay = _ref15.trendDisplay,
898
+ unit = _ref15.unit,
899
+ numberPrecision = _ref15.numberPrecision,
900
+ shouldUseThousandSeparators = _ref15.shouldUseThousandSeparators,
901
+ shouldAbbreviateTrendValue = _ref15.shouldAbbreviateTrendValue,
902
+ smallViz = _ref15.smallViz;
903
+
867
904
  var _getMajorAndTrend2 = getMajorAndTrend({
868
- majorValue: majorValue,
869
- trendValue: trendValue,
870
- majorFontSize: majorFontSize,
871
- trendFontSize: trendFontSize,
872
- trendDisplay: trendDisplay,
873
- width: contentWidth,
874
- height: contentHeight,
875
- unit: unit,
876
- numberPrecision: numberPrecision,
877
- shouldUseThousandSeparators: shouldUseThousandSeparators,
878
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
879
- }),
880
- majorText = _getMajorAndTrend2.majorText,
881
- trendText = _getMajorAndTrend2.trendText,
882
- majorTextFontSize = _getMajorAndTrend2.majorTextFontSize,
883
- trendTextFontSize = _getMajorAndTrend2.trendTextFontSize;
884
- var majorValueTitle = majorText;
885
- var smallVizProps = {};
905
+ majorValue: majorValue,
906
+ trendValue: trendValue,
907
+ majorFontSize: majorFontSize,
908
+ trendFontSize: trendFontSize,
909
+ trendDisplay: trendDisplay,
910
+ width: contentWidth,
911
+ height: contentHeight,
912
+ unit: unit,
913
+ numberPrecision: numberPrecision,
914
+ shouldUseThousandSeparators: shouldUseThousandSeparators,
915
+ shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
916
+ }),
917
+ majorText = _getMajorAndTrend2.majorText,
918
+ trendText = _getMajorAndTrend2.trendText,
919
+ majorTextFontSize = _getMajorAndTrend2.majorTextFontSize,
920
+ trendTextFontSize = _getMajorAndTrend2.trendTextFontSize;
886
921
 
887
- // custom logic for viz in small space
922
+ var majorValueTitle = majorText;
923
+ var smallVizProps = {}; // custom logic for viz in small space
888
924
  // if not showing the radial graph (if `smallViz` is true), then compute truncated major value
889
925
  // and font sizes
926
+
890
927
  if (smallViz) {
891
928
  var truncateValue = minimallyTruncateStringToWidth({
892
929
  text: majorValue,
@@ -894,6 +931,7 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
894
931
  fontSize: 12,
895
932
  containerWidth: containerWidth
896
933
  });
934
+
897
935
  var _getMajorAndTrend3 = getMajorAndTrend({
898
936
  majorValue: truncateValue,
899
937
  trendValue: trendValue,
@@ -907,6 +945,7 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
907
945
  shouldUseThousandSeparators: shouldUseThousandSeparators,
908
946
  shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
909
947
  });
948
+
910
949
  majorText = _getMajorAndTrend3.majorText;
911
950
  trendText = _getMajorAndTrend3.trendText;
912
951
  majorTextFontSize = _getMajorAndTrend3.majorTextFontSize;
@@ -916,6 +955,7 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
916
955
  unit: unit
917
956
  };
918
957
  }
958
+
919
959
  return {
920
960
  majorText: majorText,
921
961
  trendText: trendText,
@@ -925,7 +965,6 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
925
965
  smallVizProps: smallVizProps
926
966
  };
927
967
  };
928
-
929
968
  /**
930
969
  * Get the colors for a graph
931
970
  *
@@ -938,21 +977,22 @@ var computeSingleValueRadialContent = function computeSingleValueRadialContent(_
938
977
  * @returns {Object} { background, stroke } colors
939
978
  * @private
940
979
  */
980
+
941
981
  var getGraphColors = function getGraphColors(_ref16) {
942
982
  var backgroundEnabled = _ref16.backgroundEnabled,
943
- backgroundColor = _ref16.backgroundColor,
944
- defaultColors = _ref16.defaultColors,
945
- customColorFormatter = _ref16.customColorFormatter;
946
- // Only do custom colors in block mode
983
+ backgroundColor = _ref16.backgroundColor,
984
+ defaultColors = _ref16.defaultColors,
985
+ customColorFormatter = _ref16.customColorFormatter; // Only do custom colors in block mode
986
+
947
987
  if (backgroundEnabled) {
948
988
  // Check if the user defined colors to use
949
989
  if (backgroundColor && typeof customColorFormatter === 'function') {
950
990
  return customColorFormatter(backgroundColor);
951
991
  }
952
992
  }
993
+
953
994
  return defaultColors.none;
954
995
  };
955
-
956
996
  /**
957
997
  * Adjust rgb value if it equals to 0 or 255
958
998
  * @method adjustRGB
@@ -961,16 +1001,18 @@ var getGraphColors = function getGraphColors(_ref16) {
961
1001
  * @returns {Number} adjusted rgb
962
1002
  * @private
963
1003
  */
1004
+
964
1005
  var adjustRGB = function adjustRGB(rgb, delta) {
965
1006
  if (rgb === 255) {
966
1007
  return rgb - delta;
967
1008
  }
1009
+
968
1010
  if (rgb === 0) {
969
1011
  return rgb + delta;
970
1012
  }
1013
+
971
1014
  return rgb;
972
1015
  };
973
-
974
1016
  /**
975
1017
  * Modifies colors by multiplying by a given ratio
976
1018
  * @method changeColor
@@ -979,18 +1021,16 @@ var adjustRGB = function adjustRGB(rgb, delta) {
979
1021
  * @returns {String} new color
980
1022
  * @private
981
1023
  */
1024
+
982
1025
  var changeColor = function changeColor(color, ratio) {
983
1026
  var hex = color.replace(/(0x|#)/, '');
984
1027
  var r = parseInt(hex.substr(0, 2), 16);
985
1028
  var g = parseInt(hex.substr(2, 2), 16);
986
- var b = parseInt(hex.substr(4, 2), 16);
1029
+ var b = parseInt(hex.substr(4, 2), 16); // Multiply by given ratio, make sure is between 0 and 255;
987
1030
 
988
- // Multiply by given ratio, make sure is between 0 and 255;
989
1031
  var newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
990
1032
  var newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
991
- var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);
992
-
993
- // If the color is not changed
1033
+ var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0); // If the color is not changed
994
1034
  // case 1: the color is (0, 0 0)
995
1035
  // lighten color (80, 80, 80)
996
1036
  // darken color (40, 40, 40)
@@ -999,6 +1039,7 @@ var changeColor = function changeColor(color, ratio) {
999
1039
  // darken color (175, 175, 175)
1000
1040
  // case 3: the color is e.g. (0, 255, 0)
1001
1041
  // new color (20, 235, 20)
1042
+
1002
1043
  if (newR === r && newG === g && newB === b) {
1003
1044
  if (newR === 0 && newG === 0 && newB === 0) {
1004
1045
  if (ratio > 1) {
@@ -1026,9 +1067,9 @@ var changeColor = function changeColor(color, ratio) {
1026
1067
  newB = adjustRGB(newB, 20);
1027
1068
  }
1028
1069
  }
1070
+
1029
1071
  return "#".concat(newR.toString(16).padStart(2, 0)) + "".concat(newG.toString(16).padStart(2, 0)) + "".concat(newB.toString(16).padStart(2, 0));
1030
1072
  };
1031
-
1032
1073
  /**
1033
1074
  * Lighten a given color
1034
1075
  * @method lighten
@@ -1036,10 +1077,11 @@ var changeColor = function changeColor(color, ratio) {
1036
1077
  * @returns {String}
1037
1078
  * @private
1038
1079
  */
1080
+
1081
+
1039
1082
  var lighten = function lighten(color) {
1040
1083
  return changeColor(color, 1.3);
1041
1084
  };
1042
-
1043
1085
  /**
1044
1086
  * Darkens a given color
1045
1087
  * @method darken
@@ -1047,10 +1089,10 @@ var lighten = function lighten(color) {
1047
1089
  * @returns {String}
1048
1090
  * @private
1049
1091
  */
1092
+
1050
1093
  var darken = function darken(color) {
1051
1094
  return changeColor(color, 0.5);
1052
1095
  };
1053
-
1054
1096
  /** consistent token structure: handle callback to add value and name in event payload
1055
1097
  * @method handleValueClickCallback
1056
1098
  * @param {Object} ev
@@ -1059,6 +1101,7 @@ var darken = function darken(color) {
1059
1101
  * @param {Number} trendValue
1060
1102
  * @param {Function} onValueClick
1061
1103
  */
1104
+
1062
1105
  var handleValueClickCallback = function handleValueClickCallback(ev, majorValue, majorValueField, trendValue, onValueClick) {
1063
1106
  var trellisEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
1064
1107
  var trellisSplityBy = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
@@ -1068,12 +1111,14 @@ var handleValueClickCallback = function handleValueClickCallback(ev, majorValue,
1068
1111
  value: majorValue,
1069
1112
  name: majorValueField
1070
1113
  };
1114
+
1071
1115
  if (trellisEnabled) {
1072
1116
  payload = _objectSpread(_objectSpread({}, payload), {}, {
1073
1117
  'trellis.name': trellisSplityBy,
1074
1118
  'trellis.value': trellisKey
1075
1119
  });
1076
1120
  }
1121
+
1077
1122
  return onValueClick(_objectSpread(_objectSpread({}, ev), {}, {
1078
1123
  payload: payload
1079
1124
  }));