@splunk/visualizations 26.4.1 → 27.0.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 (152) hide show
  1. package/Area.config.js +1262 -1600
  2. package/Area.config.js.map +7 -1
  3. package/Area.js +3002 -4930
  4. package/Area.js.map +7 -1
  5. package/Bar.config.js +1247 -1574
  6. package/Bar.config.js.map +7 -1
  7. package/Bar.js +2921 -4843
  8. package/Bar.js.map +7 -1
  9. package/Bubble.config.js +896 -1213
  10. package/Bubble.config.js.map +7 -1
  11. package/Bubble.js +2517 -4483
  12. package/Bubble.js.map +7 -1
  13. package/ChoroplethSvg.config.js +282 -582
  14. package/ChoroplethSvg.config.js.map +7 -1
  15. package/ChoroplethSvg.js +2004 -3810
  16. package/ChoroplethSvg.js.map +7 -1
  17. package/Column.config.js +1208 -1541
  18. package/Column.config.js.map +7 -1
  19. package/Column.js +2930 -4886
  20. package/Column.js.map +7 -1
  21. package/Ellipse.config.js +443 -774
  22. package/Ellipse.config.js.map +7 -1
  23. package/Ellipse.js +1651 -3341
  24. package/Ellipse.js.map +7 -1
  25. package/Events.config.js +207 -492
  26. package/Events.config.js.map +7 -1
  27. package/Events.js +2615 -4649
  28. package/Events.js.map +7 -1
  29. package/FillerGauge.config.js +420 -775
  30. package/FillerGauge.config.js.map +7 -1
  31. package/FillerGauge.js +2137 -4578
  32. package/FillerGauge.js.map +7 -1
  33. package/Image.config.js +144 -411
  34. package/Image.config.js.map +7 -1
  35. package/Image.js +1395 -3048
  36. package/Image.js.map +7 -1
  37. package/Line.config.js +1278 -1625
  38. package/Line.config.js.map +7 -1
  39. package/Line.js +2954 -4926
  40. package/Line.js.map +7 -1
  41. package/LinkGraph.config.js +390 -632
  42. package/LinkGraph.config.js.map +7 -1
  43. package/LinkGraph.js +5243 -6190
  44. package/LinkGraph.js.map +7 -1
  45. package/MIGRATION.md +6 -0
  46. package/Map.config.js +501 -801
  47. package/Map.config.js.map +7 -1
  48. package/Map.js +3369 -5676
  49. package/Map.js.map +7 -1
  50. package/Markdown.config.js +232 -528
  51. package/Markdown.config.js.map +7 -1
  52. package/Markdown.js +1645 -3216
  53. package/Markdown.js.map +7 -1
  54. package/MarkerGauge.config.js +308 -613
  55. package/MarkerGauge.config.js.map +7 -1
  56. package/MarkerGauge.js +2189 -4535
  57. package/MarkerGauge.js.map +7 -1
  58. package/ParallelCoordinates.config.js +282 -581
  59. package/ParallelCoordinates.config.js.map +7 -1
  60. package/ParallelCoordinates.js +2023 -4720
  61. package/ParallelCoordinates.js.map +7 -1
  62. package/Pie.config.js +278 -547
  63. package/Pie.config.js.map +7 -1
  64. package/Pie.js +1996 -3990
  65. package/Pie.js.map +7 -1
  66. package/Punchcard.config.js +291 -578
  67. package/Punchcard.config.js.map +7 -1
  68. package/Punchcard.js +2709 -5042
  69. package/Punchcard.js.map +7 -1
  70. package/Rectangle.config.js +455 -770
  71. package/Rectangle.config.js.map +7 -1
  72. package/Rectangle.js +1638 -3262
  73. package/Rectangle.js.map +7 -1
  74. package/Sankey.config.js +291 -626
  75. package/Sankey.config.js.map +7 -1
  76. package/Sankey.js +2737 -4909
  77. package/Sankey.js.map +7 -1
  78. package/Scatter.config.js +876 -1194
  79. package/Scatter.config.js.map +7 -1
  80. package/Scatter.js +2529 -4477
  81. package/Scatter.js.map +7 -1
  82. package/SingleValue.config.js +819 -1251
  83. package/SingleValue.config.js.map +7 -1
  84. package/SingleValue.js +4203 -7413
  85. package/SingleValue.js.map +7 -1
  86. package/SingleValueBasic.js +382 -1527
  87. package/SingleValueBasic.js.map +7 -1
  88. package/SingleValueIcon.config.js +781 -1207
  89. package/SingleValueIcon.config.js.map +7 -1
  90. package/SingleValueIcon.js +3350 -6285
  91. package/SingleValueIcon.js.map +7 -1
  92. package/SingleValueRadial.config.js +708 -1119
  93. package/SingleValueRadial.config.js.map +7 -1
  94. package/SingleValueRadial.js +3808 -6965
  95. package/SingleValueRadial.js.map +7 -1
  96. package/SparkLine.js +439 -746
  97. package/SparkLine.js.map +7 -1
  98. package/Table.config.js +565 -879
  99. package/Table.config.js.map +7 -1
  100. package/Table.js +3277 -5381
  101. package/Table.js.map +7 -1
  102. package/common/Charting.js +481 -1468
  103. package/common/Charting.js.map +7 -1
  104. package/common/ChartingApi.js +46 -170
  105. package/common/ChartingApi.js.map +7 -1
  106. package/common/DocExampleWithVizSandbox.js +270 -473
  107. package/common/DocExampleWithVizSandbox.js.map +7 -1
  108. package/common/EventsDoc.js +172 -464
  109. package/common/EventsDoc.js.map +7 -1
  110. package/common/GaugeMajorTicks.js +249 -347
  111. package/common/GaugeMajorTicks.js.map +7 -1
  112. package/common/GaugeValueMarker.js +201 -311
  113. package/common/GaugeValueMarker.js.map +7 -1
  114. package/common/OptionsDoc.js +347 -912
  115. package/common/OptionsDoc.js.map +7 -1
  116. package/common/OverviewDoc.js +435 -769
  117. package/common/OverviewDoc.js.map +7 -1
  118. package/common/SplunkVisualization.js +116 -259
  119. package/common/SplunkVisualization.js.map +7 -1
  120. package/common/SplunkVisualizationApi.js +40 -156
  121. package/common/SplunkVisualizationApi.js.map +7 -1
  122. package/common/ThemesDoc.js +271 -420
  123. package/common/ThemesDoc.js.map +7 -1
  124. package/common/chartingUtils.js +140 -312
  125. package/common/chartingUtils.js.map +7 -1
  126. package/common/docUtils.js +148 -266
  127. package/common/docUtils.js.map +7 -1
  128. package/common/gaugeUtils.js +280 -808
  129. package/common/gaugeUtils.js.map +7 -1
  130. package/common/shapeUtils.js +106 -211
  131. package/common/shapeUtils.js.map +7 -1
  132. package/common/utils/configUtils.js +126 -252
  133. package/common/utils/configUtils.js.map +7 -1
  134. package/common/utils/dataUtils.js +217 -812
  135. package/common/utils/dataUtils.js.map +7 -1
  136. package/common/utils/featureFlagUtils.js +53 -133
  137. package/common/utils/featureFlagUtils.js.map +7 -1
  138. package/common/utils/hocUtils.js +32 -122
  139. package/common/utils/hocUtils.js.map +7 -1
  140. package/common/utils/mapUtils.js +502 -1337
  141. package/common/utils/mapUtils.js.map +7 -1
  142. package/common/utils/singleValueUtils.js +462 -1010
  143. package/common/utils/singleValueUtils.js.map +7 -1
  144. package/common/utils/testHelper.js +92 -146
  145. package/common/utils/testHelper.js.map +7 -1
  146. package/common/utils/trellisUtils.js +237 -489
  147. package/common/utils/trellisUtils.js.map +7 -1
  148. package/common/utils/urlUtils.js +28 -112
  149. package/common/utils/urlUtils.js.map +7 -1
  150. package/common/withDashboardViz.js +1168 -2438
  151. package/common/withDashboardViz.js.map +7 -1
  152. package/package.json +52 -43
@@ -1,1080 +1,591 @@
1
- /*!
2
- * Copyright © 2024 Splunk Inc.
3
- * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
- * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
- */
6
- module.exports =
7
- /******/ (function(modules) { // webpackBootstrap
8
- /******/ // The module cache
9
- /******/ var installedModules = {};
10
- /******/
11
- /******/ // The require function
12
- /******/ function __webpack_require__(moduleId) {
13
- /******/
14
- /******/ // Check if module is in cache
15
- /******/ if(installedModules[moduleId]) {
16
- /******/ return installedModules[moduleId].exports;
17
- /******/ }
18
- /******/ // Create a new module (and put it into the cache)
19
- /******/ var module = installedModules[moduleId] = {
20
- /******/ i: moduleId,
21
- /******/ l: false,
22
- /******/ exports: {}
23
- /******/ };
24
- /******/
25
- /******/ // Execute the module function
26
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
- /******/
28
- /******/ // Flag the module as loaded
29
- /******/ module.l = true;
30
- /******/
31
- /******/ // Return the exports of the module
32
- /******/ return module.exports;
33
- /******/ }
34
- /******/
35
- /******/
36
- /******/ // expose the modules object (__webpack_modules__)
37
- /******/ __webpack_require__.m = modules;
38
- /******/
39
- /******/ // expose the module cache
40
- /******/ __webpack_require__.c = installedModules;
41
- /******/
42
- /******/ // define getter function for harmony exports
43
- /******/ __webpack_require__.d = function(exports, name, getter) {
44
- /******/ if(!__webpack_require__.o(exports, name)) {
45
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
- /******/ }
47
- /******/ };
48
- /******/
49
- /******/ // define __esModule on exports
50
- /******/ __webpack_require__.r = function(exports) {
51
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
- /******/ }
54
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
- /******/ };
56
- /******/
57
- /******/ // create a fake namespace object
58
- /******/ // mode & 1: value is a module id, require it
59
- /******/ // mode & 2: merge all properties of value into the ns
60
- /******/ // mode & 4: return value when already ns object
61
- /******/ // mode & 8|1: behave like require
62
- /******/ __webpack_require__.t = function(value, mode) {
63
- /******/ if(mode & 1) value = __webpack_require__(value);
64
- /******/ if(mode & 8) return value;
65
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
- /******/ var ns = Object.create(null);
67
- /******/ __webpack_require__.r(ns);
68
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
- /******/ return ns;
71
- /******/ };
72
- /******/
73
- /******/ // getDefaultExport function for compatibility with non-harmony modules
74
- /******/ __webpack_require__.n = function(module) {
75
- /******/ var getter = module && module.__esModule ?
76
- /******/ function getDefault() { return module['default']; } :
77
- /******/ function getModuleExports() { return module; };
78
- /******/ __webpack_require__.d(getter, 'a', getter);
79
- /******/ return getter;
80
- /******/ };
81
- /******/
82
- /******/ // Object.prototype.hasOwnProperty.call
83
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
- /******/
85
- /******/ // __webpack_public_path__
86
- /******/ __webpack_require__.p = "";
87
- /******/
88
- /******/
89
- /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 54);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ({
94
-
95
- /***/ 0:
96
- /***/ (function(module, exports) {
97
-
98
- module.exports = require("lodash");
99
-
100
- /***/ }),
101
-
102
- /***/ 1:
103
- /***/ (function(module, exports) {
104
-
105
- module.exports = require("@splunk/visualizations-shared/numberUtils");
106
-
107
- /***/ }),
108
-
109
- /***/ 3:
110
- /***/ (function(module, exports) {
111
-
112
- module.exports = require("@babel/runtime/helpers/defineProperty");
113
-
114
- /***/ }),
115
-
116
- /***/ 5:
117
- /***/ (function(module, exports) {
118
-
119
- module.exports = require("@splunk/visualizations-shared/domUtils");
120
-
121
- /***/ }),
122
-
123
- /***/ 54:
124
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
125
-
126
- "use strict";
127
- __webpack_require__.r(__webpack_exports__);
128
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_FONT", function() { return DEFAULT_FONT; });
129
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_FONT_FAMILY", function() { return DEFAULT_FONT_FAMILY; });
130
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SVR_PADDING", function() { return SVR_PADDING; });
131
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAligment", function() { return getAligment; });
132
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldShowTrend", function() { return shouldShowTrend; });
133
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isLoadingOrNoColumns", function() { return isLoadingOrNoColumns; });
134
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFormattedColor", function() { return getFormattedColor; });
135
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBackground", function() { return hasBackground; });
136
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isIdenticalColor", function() { return isIdenticalColor; });
137
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDefaultColorWithBg", function() { return getDefaultColorWithBg; });
138
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorColor", function() { return getMajorColor; });
139
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendColor", function() { return getTrendColor; });
140
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeColors", function() { return computeColors; });
141
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeText", function() { return computeText; });
142
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorText", function() { return getMajorText; });
143
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendText", function() { return getTrendText; });
144
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeFontSize", function() { return computeFontSize; });
145
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorFontSize", function() { return getMajorFontSize; });
146
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendFontSize", function() { return getTrendFontSize; });
147
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUnderLabelHeight", function() { return getUnderLabelHeight; });
148
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUnderLabel", function() { return getUnderLabel; });
149
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorAndTrend", function() { return getMajorAndTrend; });
150
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateVizInSmallSpace", function() { return updateVizInSmallSpace; });
151
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeSingleValueContent", function() { return computeSingleValueContent; });
152
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "minimallyTruncateStringToWidth", function() { return minimallyTruncateStringToWidth; });
153
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeSingleValueRadialContent", function() { return computeSingleValueRadialContent; });
154
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getGraphColors", function() { return getGraphColors; });
155
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjustRGB", function() { return adjustRGB; });
156
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lighten", function() { return lighten; });
157
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "darken", function() { return darken; });
158
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "handleValueClickCallback", function() { return handleValueClickCallback; });
159
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
160
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
161
- /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
162
- /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
163
- /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
164
- /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__);
165
- /* harmony import */ var _splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
166
- /* harmony import */ var _splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__);
167
- /* harmony import */ var _splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6);
168
- /* harmony import */ var _splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__);
169
- /* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9);
170
- /* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__);
171
-
172
-
173
- function ownKeys(object, enumerableOnly) {
174
- var keys = Object.keys(object);
175
-
176
- if (Object.getOwnPropertySymbols) {
177
- var symbols = Object.getOwnPropertySymbols(object);
178
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
179
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
180
- });
181
- keys.push.apply(keys, symbols);
182
- }
183
-
184
- return keys;
185
- }
186
-
187
- function _objectSpread(target) {
188
- for (var i = 1; i < arguments.length; i++) {
189
- var source = arguments[i] != null ? arguments[i] : {};
190
-
191
- if (i % 2) {
192
- ownKeys(Object(source), true).forEach(function (key) {
193
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
194
- });
195
- } else if (Object.getOwnPropertyDescriptors) {
196
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
197
- } else {
198
- ownKeys(Object(source)).forEach(function (key) {
199
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
200
- });
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
201
23
  }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __export = (target, all) => {
28
+ for (var name in all)
29
+ __defProp(target, name, { get: all[name], enumerable: true });
30
+ };
31
+ var __copyProps = (to, from, except, desc) => {
32
+ if (from && typeof from === "object" || typeof from === "function") {
33
+ for (let key of __getOwnPropNames(from))
34
+ if (!__hasOwnProp.call(to, key) && key !== except)
35
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
202
36
  }
203
-
204
- return target;
205
- }
206
-
207
-
208
-
209
-
210
-
211
-
37
+ return to;
38
+ };
39
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
40
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
41
+ // If the importer is in node compatibility mode or this is not an ESM
42
+ // file that has been converted to a CommonJS file using a Babel-
43
+ // compatible transform (i.e. "__esModule" has not been set), then set
44
+ // "default" to the CommonJS "module.exports" for node compatibility.
45
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
46
+ mod
47
+ ));
48
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
+
50
+ // src/common/utils/singleValueUtils.js
51
+ var singleValueUtils_exports = {};
52
+ __export(singleValueUtils_exports, {
53
+ DEFAULT_FONT: () => DEFAULT_FONT,
54
+ DEFAULT_FONT_FAMILY: () => DEFAULT_FONT_FAMILY,
55
+ SVR_PADDING: () => SVR_PADDING,
56
+ adjustRGB: () => adjustRGB,
57
+ computeColors: () => computeColors,
58
+ computeFontSize: () => computeFontSize,
59
+ computeSingleValueContent: () => computeSingleValueContent,
60
+ computeSingleValueRadialContent: () => computeSingleValueRadialContent,
61
+ computeText: () => computeText,
62
+ darken: () => darken,
63
+ getAligment: () => getAligment,
64
+ getDefaultColorWithBg: () => getDefaultColorWithBg,
65
+ getFormattedColor: () => getFormattedColor,
66
+ getGraphColors: () => getGraphColors,
67
+ getMajorAndTrend: () => getMajorAndTrend,
68
+ getMajorColor: () => getMajorColor,
69
+ getMajorFontSize: () => getMajorFontSize,
70
+ getMajorText: () => getMajorText,
71
+ getTrendColor: () => getTrendColor,
72
+ getTrendFontSize: () => getTrendFontSize,
73
+ getTrendText: () => getTrendText,
74
+ getUnderLabel: () => getUnderLabel,
75
+ getUnderLabelHeight: () => getUnderLabelHeight,
76
+ handleValueClickCallback: () => handleValueClickCallback,
77
+ hasBackground: () => hasBackground,
78
+ isIdenticalColor: () => isIdenticalColor,
79
+ isLoadingOrNoColumns: () => isLoadingOrNoColumns,
80
+ lighten: () => lighten,
81
+ minimallyTruncateStringToWidth: () => minimallyTruncateStringToWidth,
82
+ shouldShowTrend: () => shouldShowTrend,
83
+ updateVizInSmallSpace: () => updateVizInSmallSpace
84
+ });
85
+ module.exports = __toCommonJS(singleValueUtils_exports);
86
+
87
+ // esm-externals:lodash
88
+ var lodash_exports = {};
89
+ __export(lodash_exports, {
90
+ default: () => lodash_default
91
+ });
92
+ var defaultImport = __toESM(require("lodash"));
93
+ __reExport(lodash_exports, require("lodash"));
94
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
95
+
96
+ // esm-externals:@splunk/visualizations-shared/numberUtils
97
+ var numberUtils_exports = {};
98
+ __export(numberUtils_exports, {
99
+ default: () => numberUtils_default
100
+ });
101
+ var defaultImport2 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
102
+ __reExport(numberUtils_exports, require("@splunk/visualizations-shared/numberUtils"));
103
+ var numberUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
104
+
105
+ // esm-externals:@splunk/visualizations-shared/domUtils
106
+ var domUtils_exports = {};
107
+ __export(domUtils_exports, {
108
+ default: () => domUtils_default
109
+ });
110
+ var defaultImport3 = __toESM(require("@splunk/visualizations-shared/domUtils"));
111
+ __reExport(domUtils_exports, require("@splunk/visualizations-shared/domUtils"));
112
+ var domUtils_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
113
+
114
+ // esm-externals:@splunk/visualizations-shared/propUtils
115
+ var propUtils_exports = {};
116
+ __export(propUtils_exports, {
117
+ default: () => propUtils_default
118
+ });
119
+ var defaultImport4 = __toESM(require("@splunk/visualizations-shared/propUtils"));
120
+ __reExport(propUtils_exports, require("@splunk/visualizations-shared/propUtils"));
121
+ var propUtils_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
122
+
123
+ // esm-externals:@splunk/visualizations-shared/colorConstants
124
+ var colorConstants_exports = {};
125
+ __export(colorConstants_exports, {
126
+ default: () => colorConstants_default
127
+ });
128
+ var defaultImport5 = __toESM(require("@splunk/visualizations-shared/colorConstants"));
129
+ __reExport(colorConstants_exports, require("@splunk/visualizations-shared/colorConstants"));
130
+ var colorConstants_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
131
+
132
+ // src/common/utils/singleValueUtils.js
212
133
  var DEFAULT_FONT = 12;
213
134
  var DEFAULT_FONT_FAMILY = '"Splunk Platform Sans", "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif';
214
- var SVR_PADDING = {
215
- top: 12,
216
- bottom: 12,
217
- left: 16,
218
- right: 16
219
- };
220
- var getAligment = function getAligment(align) {
221
- var alignMap = {
222
- left: 'start',
223
- center: 'center',
224
- right: 'end'
135
+ var SVR_PADDING = { top: 12, bottom: 12, left: 16, right: 16 };
136
+ var getAligment = (align) => {
137
+ const alignMap = {
138
+ left: "start",
139
+ center: "center",
140
+ right: "end"
225
141
  };
226
- return alignMap[align] || 'center';
227
- };
228
- /**
229
- * @method shouldShowTrend
230
- * @param {String} trendDisplay
231
- * @returns {Bool}
232
- */
233
-
234
- var shouldShowTrend = function shouldShowTrend(trendDisplay) {
235
- return trendDisplay === 'absolute' || trendDisplay === 'percent';
142
+ return alignMap[align] || "center";
236
143
  };
237
- /**
238
- * @method isLoadingOrNoColumns
239
- * @param {Object} dataSources
240
- * @param {Boolean} loading
241
- * @returns {Boolean} return true if loading or without columns in dataSources
242
- */
243
-
244
- var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
245
- var data = Object(lodash__WEBPACK_IMPORTED_MODULE_1__["get"])(dataSources, 'primary.data.columns[0]', undefined);
246
- var noColumns = data === undefined;
144
+ var shouldShowTrend = (trendDisplay) => trendDisplay === "absolute" || trendDisplay === "percent";
145
+ var isLoadingOrNoColumns = (dataSources, loading) => {
146
+ const data = (0, lodash_exports.get)(dataSources, "primary.data.columns[0]", void 0);
147
+ const noColumns = data === void 0;
247
148
  return loading || noColumns;
248
149
  };
249
- /**
250
- * Retrieve the valid formatted color
251
- * @method getFormattedColor
252
- * @param {String} color
253
- * @param {String} defaultColor
254
- * @returns {String} the formatted color
255
- */
256
-
257
- var getFormattedColor = function getFormattedColor(color, defaultColor) {
258
- return Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(color) || Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(defaultColor);
259
- };
260
- /**
261
- * Determines if there is a background color
262
- * @method hasBackground
263
- * @param {String} backgroundColor
264
- * @returns true for non-transparent background color
265
- */
266
-
267
- var hasBackground = function hasBackground(backgroundColor) {
268
- return !!backgroundColor && backgroundColor !== 'transparent';
269
- };
270
- /**
271
- * @method isIdenticalColor
272
- * @param {String} colorA
273
- * @param {String} colorB
274
- * @returns {Boolean}
275
- */
276
-
277
- var isIdenticalColor = function isIdenticalColor(colorA, colorB) {
278
- 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());
279
- };
280
- /*
281
- * @method getDefaultColorWithBg
282
- * @param {Object} props
283
- * @param {String} props.backgroundColor
284
- * @param {String} props.defaultFontColor
285
- * @param {String} props.defaultBlockFontColor
286
- * @returns {String} defaultColor
287
- */
288
-
289
- var getDefaultColorWithBg = function getDefaultColorWithBg(_ref) {
290
- var backgroundColor = _ref.backgroundColor,
291
- defaultFontColor = _ref.defaultFontColor,
292
- defaultBlockFontColor = _ref.defaultBlockFontColor;
293
- return isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;
294
- };
295
- /*
296
- * @method getMajorColor
297
- * return formatted majorColor.
298
- * @param {Object} props
299
- * @param {String} props.majorColor
300
- * @param {String} props.backgroundColor
301
- * @param {String} props.defaultFontColor
302
- * @param {String} props.defaultBlockFontColor
303
- * @returns {String} majorColor
304
- */
305
-
306
- var getMajorColor = function getMajorColor(_ref2) {
307
- var majorColor = _ref2.majorColor,
308
- backgroundColor = _ref2.backgroundColor,
309
- defaultFontColor = _ref2.defaultFontColor,
310
- defaultBlockFontColor = _ref2.defaultBlockFontColor; // If backgroundColor is set, but no majorColor,
311
- // the default majorColor will turn to be defaultBlockFontColor.
312
- // eg: major color will turn to be white in enterprise mode.
313
- // however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.
314
-
150
+ var getFormattedColor = (color, defaultColor) => (0, propUtils_exports.formatColor)(color) || (0, propUtils_exports.formatColor)(defaultColor);
151
+ var hasBackground = (backgroundColor) => !!backgroundColor && backgroundColor !== "transparent";
152
+ var isIdenticalColor = (colorA, colorB) => !!colorA && !!colorB && (0, propUtils_exports.formatColor)(colorA.toLowerCase()) === (0, propUtils_exports.formatColor)(colorB.toLowerCase());
153
+ var getDefaultColorWithBg = ({ backgroundColor, defaultFontColor, defaultBlockFontColor }) => isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;
154
+ var getMajorColor = ({ majorColor, backgroundColor, defaultFontColor, defaultBlockFontColor }) => {
315
155
  if (hasBackground(backgroundColor) && !majorColor) {
316
156
  return getDefaultColorWithBg({
317
- backgroundColor: backgroundColor,
318
- defaultFontColor: defaultFontColor,
319
- defaultBlockFontColor: defaultBlockFontColor
157
+ backgroundColor,
158
+ defaultFontColor,
159
+ defaultBlockFontColor
320
160
  });
321
161
  }
322
-
323
162
  return getFormattedColor(majorColor, defaultFontColor);
324
163
  };
325
- /**
326
- * Get the color for the trend components
327
- * @method getTrendColor
328
- * @param {Object} props
329
- * @param {String} props.trendColor The trendColor value determined from encoding
330
- * @param {Number} props.trendValue
331
- * @param {Number} props.majorValue
332
- * @param {String} props.customizedBgColor
333
- * @param {String} props.trendDisplay absolute || percent || off
334
- * @param {Object} defaultColors
335
- * @returns {String} trendColor
336
- */
337
-
338
- var getTrendColor = function getTrendColor(_ref3) {
339
- var trendColor = _ref3.trendColor,
340
- trendValue = _ref3.trendValue,
341
- majorValue = _ref3.majorValue,
342
- customizedBgColor = _ref3.customizedBgColor,
343
- trendDisplay = _ref3.trendDisplay,
344
- defaultColors = _ref3.defaultColors;
345
-
164
+ var getTrendColor = ({
165
+ trendColor,
166
+ trendValue,
167
+ majorValue,
168
+ customizedBgColor,
169
+ trendDisplay,
170
+ defaultColors
171
+ }) => {
346
172
  if (trendColor) {
347
173
  return trendColor;
348
174
  }
349
-
350
175
  if (Number.isNaN(Number(trendValue))) {
351
- return undefined;
176
+ return void 0;
352
177
  }
353
-
354
- var defaultFontColor = defaultColors.defaultFontColor,
355
- defaultBlockFontColor = defaultColors.defaultBlockFontColor,
356
- defaultBackgroundColor = defaultColors.defaultBackgroundColor; // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor
357
-
178
+ const { defaultFontColor, defaultBlockFontColor, defaultBackgroundColor } = defaultColors;
358
179
  if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
359
180
  return defaultBlockFontColor;
360
- } // if trendDisplay is percent, and trendValue === value
361
- // the trend percent = trendValue / (value - trendValue) will return Infinity
362
-
363
-
364
- var isInvalidTrend = trendDisplay === 'percent' && trendValue === parseFloat(majorValue);
365
-
181
+ }
182
+ const isInvalidTrend = trendDisplay === "percent" && trendValue === parseFloat(majorValue);
366
183
  if (trendValue === 0 || isInvalidTrend) {
367
184
  return defaultFontColor;
368
185
  }
369
-
370
- return trendValue > 0 ? _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_GREEN"] : _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_RED"];
186
+ return trendValue > 0 ? colorConstants_exports.DELTA_GREEN : colorConstants_exports.DELTA_RED;
371
187
  };
372
- /**
373
- * Computes visualization properties for display component
374
- * @method computeColors
375
- * @param {Object} props all viz props
376
- * @param {Object} defaultColors defaultColors from theme
377
- * @returns {Object} result
378
- * @returns {Boolean} backgroundEnabled
379
- * @returns {String} backgroundColor
380
- * @returns {String} majorColor
381
- * @returns {String} trendColor
382
- * @returns {String} underLabelColor
383
- */
384
-
385
- var computeColors = function computeColors(props, defaultColors) {
386
- var backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
387
- var backgroundEnabled = hasBackground(backgroundColor);
388
- var majorColor = getMajorColor({
188
+ var computeColors = (props, defaultColors) => {
189
+ const backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
190
+ const backgroundEnabled = hasBackground(backgroundColor);
191
+ const majorColor = getMajorColor({
389
192
  majorColor: props.majorColor,
390
- backgroundColor: backgroundColor,
193
+ backgroundColor,
391
194
  defaultFontColor: defaultColors.defaultFontColor,
392
195
  defaultBlockFontColor: defaultColors.defaultBlockFontColor
393
196
  });
394
- var trendColor = getTrendColor({
197
+ const trendColor = getTrendColor({
395
198
  trendColor: props.trendColor,
396
199
  trendValue: props.trendValue,
397
200
  majorValue: props.majorValue,
398
201
  customizedBgColor: props.backgroundColor,
399
202
  trendDisplay: props.trendDisplay,
400
- defaultColors: defaultColors
401
- }); // todo: need change it to not depend on majorColor
402
-
403
- var underLabelColor = majorColor;
203
+ defaultColors
204
+ });
205
+ const underLabelColor = majorColor;
404
206
  return {
405
- backgroundColor: backgroundColor,
406
- backgroundEnabled: backgroundEnabled,
407
- majorColor: majorColor,
408
- trendColor: trendColor,
409
- underLabelColor: underLabelColor
207
+ backgroundColor,
208
+ backgroundEnabled,
209
+ majorColor,
210
+ trendColor,
211
+ underLabelColor
410
212
  };
411
213
  };
412
- /**
413
- * Format and return the value (major/trend)
414
- * @method computeText
415
- * @param {Object} props
416
- * @param {Number} props.value // The major/trend value
417
- * @param {Number} props.numberPrecision
418
- * @param {Bool} props.shouldUseThousandSeparators
419
- * @param {Bool} props.shouldAbbreviateValue
420
- * @returns {Number} major or trend text
421
- */
422
-
423
- var computeText = function computeText(_ref4) {
424
- var value = _ref4.value,
425
- numberPrecision = _ref4.numberPrecision,
426
- shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
427
- shouldAbbreviateValue = _ref4.shouldAbbreviateValue;
428
- 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, {
214
+ var computeText = ({
215
+ value,
216
+ numberPrecision,
217
+ shouldUseThousandSeparators,
218
+ shouldAbbreviateValue
219
+ }) => {
220
+ let text = (0, numberUtils_exports.isNumerial)(value) ? (0, numberUtils_exports.formatNumber)(value, numberPrecision, {
429
221
  useThousandSeparators: shouldUseThousandSeparators,
430
222
  // todo: need update formatNumber
431
223
  useTrendUnits: shouldAbbreviateValue
432
- }) : value; // When text is undefined, return empty string
433
-
434
- text = text || '';
224
+ }) : value;
225
+ text = text || "";
435
226
  return text;
436
227
  };
437
- /*
438
- * @method getMajorText
439
- * @param {Object} props
440
- * @param {Number} props.majorValue
441
- * @param {Number} props.numberPrecision
442
- * @param {Bool} props.shouldUseThousandSeparators
443
- * @param {Bool} props.shouldAbbreviateMajorValue
444
- * @returns {String} majorText
445
- */
446
-
447
- var getMajorText = function getMajorText(_ref5) {
448
- var majorValue = _ref5.majorValue,
449
- numberPrecision = _ref5.numberPrecision,
450
- shouldUseThousandSeparators = _ref5.shouldUseThousandSeparators,
451
- shouldAbbreviateMajorValue = _ref5.shouldAbbreviateMajorValue;
452
- return computeText({
453
- value: majorValue === null ? 'N/A' : majorValue,
454
- // if majorValue is null, use `N/A`.
455
- numberPrecision: numberPrecision,
456
- shouldUseThousandSeparators: shouldUseThousandSeparators,
457
- shouldAbbreviateValue: shouldAbbreviateMajorValue
228
+ var getMajorText = ({
229
+ majorValue,
230
+ numberPrecision,
231
+ shouldUseThousandSeparators,
232
+ shouldAbbreviateMajorValue
233
+ }) => computeText({
234
+ value: majorValue === null ? "N/A" : majorValue,
235
+ // if majorValue is null, use `N/A`.
236
+ numberPrecision,
237
+ shouldUseThousandSeparators,
238
+ shouldAbbreviateValue: shouldAbbreviateMajorValue
239
+ });
240
+ var getTrendText = ({
241
+ majorValue,
242
+ trendValue,
243
+ trendDisplay,
244
+ numberPrecision,
245
+ shouldUseThousandSeparators,
246
+ shouldAbbreviateTrendValue
247
+ }) => {
248
+ const compute = (value) => computeText({
249
+ value,
250
+ numberPrecision,
251
+ shouldUseThousandSeparators,
252
+ shouldAbbreviateValue: shouldAbbreviateTrendValue
458
253
  });
459
- };
460
- /*
461
- * @method getTrendText
462
- * @param {Object} props
463
- * @param {Number} props.majorValue
464
- * @param {Number} props.trendValue
465
- * @param {String} props.trendDisplay
466
- * @param {Number} props.numberPrecision
467
- * @param {Bool} props.shouldUseThousandSeparators
468
- * @param {Bool} props.shouldAbbreviateTrendValue
469
- * @returns {String} trendText
470
- */
471
-
472
- var getTrendText = function getTrendText(_ref6) {
473
- var majorValue = _ref6.majorValue,
474
- trendValue = _ref6.trendValue,
475
- trendDisplay = _ref6.trendDisplay,
476
- numberPrecision = _ref6.numberPrecision,
477
- shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
478
- shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
479
-
480
- var compute = function compute(value) {
481
- return computeText({
482
- value: value,
483
- numberPrecision: numberPrecision,
484
- shouldUseThousandSeparators: shouldUseThousandSeparators,
485
- shouldAbbreviateValue: shouldAbbreviateTrendValue
486
- });
487
- };
488
-
489
- if (trendValue === '' || !Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue)) {
490
- return '';
254
+ if (trendValue === "" || !(0, numberUtils_exports.isNumerial)(trendValue)) {
255
+ return "";
491
256
  }
492
-
493
- var showPercent = trendDisplay === 'percent';
494
-
257
+ const showPercent = trendDisplay === "percent";
495
258
  if (!showPercent) {
496
259
  return compute(trendValue);
497
260
  }
498
-
499
- var diff = Math.abs(trendValue - majorValue);
500
- var val = Math.round(trendValue / diff * 100);
501
-
261
+ const diff = Math.abs(trendValue - majorValue);
262
+ let val = Math.round(trendValue / diff * 100);
502
263
  if (trendValue === 0 && diff === 0) {
503
264
  val = 0;
504
265
  }
505
-
506
266
  if (!Number.isFinite(val)) {
507
- return 'N/A';
267
+ return "N/A";
508
268
  }
509
-
510
- var text = compute(val);
511
- return "".concat(text, "%");
269
+ const text = compute(val);
270
+ return `${text}%`;
512
271
  };
513
- /**
514
- * Helper to determine the font size for an element
515
- * @method computeFontSize
516
- * @param {String} text The string to find a size for
517
- * @param {Object} dimensions
518
- * @param {Number} dimensions.width The width of the container
519
- * @param {Number} dimensions.height The height of the container
520
- * @param {String} [fontFamily='"Splunk Platform Sans" ...'] The font being used
521
- * @param {String} [fontWeight='normal'] Boldness of font
522
- * @returns {Number} The size to use for fontSize styles
523
- */
524
-
525
- var computeFontSize = function computeFontSize(text, _ref7) {
526
- var width = _ref7.width,
527
- height = _ref7.height;
528
- var fontFamily = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_FONT_FAMILY;
529
- var fontWeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'normal';
530
- var widthInDefaultFont = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(DEFAULT_FONT, "px ").concat(fontFamily));
531
- var fontSize = Math.min(width / widthInDefaultFont * DEFAULT_FONT, height / DEFAULT_FONT * DEFAULT_FONT);
272
+ var computeFontSize = (text, { width, height }, fontFamily = DEFAULT_FONT_FAMILY, fontWeight = "normal") => {
273
+ const widthInDefaultFont = (0, domUtils_exports.computeTextSize)(text, `${fontWeight} ${DEFAULT_FONT}px ${fontFamily}`);
274
+ const fontSize = Math.min(
275
+ width / widthInDefaultFont * DEFAULT_FONT,
276
+ height / DEFAULT_FONT * DEFAULT_FONT
277
+ );
532
278
  return parseInt(fontSize, 10);
533
279
  };
534
- /*
535
- * @method getMajorFontSize
536
- * @param {Object} props
537
- * @param {Number} props.width
538
- * @param {Number} props.height
539
- * @param {String} props.unit
540
- * @param {String} props.majorText
541
- * @param {Number} props.spaceRatio
542
- * @returns {Number} majorFontSize
543
- */
544
-
545
- var getMajorFontSize = function getMajorFontSize(_ref8) {
546
- var width = _ref8.width,
547
- height = _ref8.height,
548
- unit = _ref8.unit,
549
- majorText = _ref8.majorText,
550
- _ref8$spaceRatio = _ref8.spaceRatio,
551
- spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
552
- var majorTextCalc = unit ? "".concat(unit).concat(majorText) : majorText;
280
+ var getMajorFontSize = ({ width, height, unit, majorText, spaceRatio = 1 }) => {
281
+ const majorTextCalc = unit ? `${unit}${majorText}` : majorText;
553
282
  return computeFontSize(majorTextCalc, {
554
283
  width: width * spaceRatio,
555
- height: height
284
+ height
556
285
  });
557
286
  };
558
- /*
559
- * @method getTrendFontSize
560
- * @param {Object} props
561
- * @param {Number} props.width
562
- * @param {Number} props.height
563
- * @param {String} props.trendText
564
- * @param {Number} props.spaceRatio
565
- * @returns {Number} trendFontSize
566
- */
567
-
568
- var getTrendFontSize = function getTrendFontSize(_ref9) {
569
- var width = _ref9.width,
570
- height = _ref9.height,
571
- trendText = _ref9.trendText,
572
- _ref9$spaceRatio = _ref9.spaceRatio,
573
- spaceRatio = _ref9$spaceRatio === void 0 ? 1 : _ref9$spaceRatio;
574
- var trendFontSize = 12;
575
-
287
+ var getTrendFontSize = ({ width, height, trendText, spaceRatio = 1 }) => {
288
+ let trendFontSize = 12;
576
289
  if (spaceRatio > 0) {
577
290
  trendFontSize = computeFontSize(trendText, {
578
291
  width: width * spaceRatio,
579
- height: height
292
+ height
580
293
  });
581
294
  trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
582
295
  }
583
-
584
296
  return trendFontSize;
585
297
  };
586
- /*
587
- * The height of underLabel should no more than 12px
588
- * @param {Number} height
589
- * @return {Number} height || DEFAULT_FONT
590
- */
591
-
592
- var getUnderLabelHeight = function getUnderLabelHeight(height) {
593
- return height > DEFAULT_FONT ? DEFAULT_FONT : height;
594
- };
595
- /*
596
- * @param {Object} config
597
- * @param {String} underLabel
598
- * @param {Number} width width of underLabel
599
- * @param {Number} height height of underLabel
600
- * @param {Number} fond size of underLabel
601
- */
602
-
603
- var getUnderLabel = function getUnderLabel(_ref10) {
604
- var underLabel = _ref10.underLabel,
605
- width = _ref10.width,
606
- height = _ref10.height;
607
- return (// todo: may need truncate underLabel later
608
- computeFontSize(underLabel, {
609
- width: width,
610
- height: height
611
- })
612
- );
613
- };
614
- /**
615
- * Compute value and font size for major and trend
616
- * @method getMajorAndTrend
617
- * @param {Object} props
618
- * @param {Number} props.width // Width of the text container
619
- * @param {Number} props.height // Height of the text container
620
- * @param {Number} props.majorValue // Major value
621
- * @param {Number} props.trendValue // Trend value
622
- * @param {Number} props.majorFontSize
623
- * @param {Number} props.trendFontSize
624
- * @param {String} props.trendDisplay
625
- * @param {String} props.unit // Unit for the value
626
- * @param {Number} props.numberPrecision
627
- * @param {Bool} props.shouldUseThousandSeparators
628
- * @param {Bool} props.shouldAbbreviateTrendValue
629
- * @param {Bool} props.shouldAbbreviateMajorValue
630
- * @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size
631
- */
632
-
633
- var getMajorAndTrend = function getMajorAndTrend(_ref11) {
634
- var width = _ref11.width,
635
- height = _ref11.height,
636
- majorValue = _ref11.majorValue,
637
- trendValue = _ref11.trendValue,
638
- majorFontSize = _ref11.majorFontSize,
639
- trendFontSize = _ref11.trendFontSize,
640
- trendDisplay = _ref11.trendDisplay,
641
- unit = _ref11.unit,
642
- numberPrecision = _ref11.numberPrecision,
643
- shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
644
- shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue,
645
- shouldAbbreviateMajorValue = _ref11.shouldAbbreviateMajorValue;
646
- var majorTextSpaceRatio = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
647
- var textContentWidth = width * 0.9;
648
- var textContentHeight = height * 0.9;
649
- var majorText = getMajorText({
650
- majorValue: majorValue,
651
- numberPrecision: numberPrecision,
652
- shouldUseThousandSeparators: shouldUseThousandSeparators,
653
- shouldAbbreviateMajorValue: shouldAbbreviateMajorValue
298
+ var getUnderLabelHeight = (height) => height > DEFAULT_FONT ? DEFAULT_FONT : height;
299
+ var getUnderLabel = ({ underLabel, width, height }) => (
300
+ // todo: may need truncate underLabel later
301
+ computeFontSize(underLabel, {
302
+ width,
303
+ height
304
+ })
305
+ );
306
+ var getMajorAndTrend = ({
307
+ width,
308
+ height,
309
+ majorValue,
310
+ trendValue,
311
+ majorFontSize,
312
+ trendFontSize,
313
+ trendDisplay,
314
+ unit,
315
+ numberPrecision,
316
+ shouldUseThousandSeparators,
317
+ shouldAbbreviateTrendValue,
318
+ shouldAbbreviateMajorValue
319
+ }) => {
320
+ const majorTextSpaceRatio = (0, numberUtils_exports.isNumerial)(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
321
+ const textContentWidth = width * 0.9;
322
+ const textContentHeight = height * 0.9;
323
+ const majorText = getMajorText({
324
+ majorValue,
325
+ numberPrecision,
326
+ shouldUseThousandSeparators,
327
+ shouldAbbreviateMajorValue
654
328
  });
655
- var majorTextFontSize = majorFontSize || getMajorFontSize({
329
+ const majorTextFontSize = majorFontSize || getMajorFontSize({
656
330
  width: textContentWidth,
657
331
  height: textContentHeight,
658
- unit: unit,
659
- majorText: majorText,
332
+ unit,
333
+ majorText,
660
334
  spaceRatio: majorTextSpaceRatio
661
335
  });
662
- var trendText = getTrendText({
663
- majorValue: majorValue,
664
- trendValue: trendValue,
665
- trendDisplay: trendDisplay,
666
- numberPrecision: numberPrecision,
667
- shouldUseThousandSeparators: shouldUseThousandSeparators,
668
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
336
+ const trendText = getTrendText({
337
+ majorValue,
338
+ trendValue,
339
+ trendDisplay,
340
+ numberPrecision,
341
+ shouldUseThousandSeparators,
342
+ shouldAbbreviateTrendValue
669
343
  });
670
- var trendTextFontSize = trendFontSize || getTrendFontSize({
344
+ const trendTextFontSize = trendFontSize || getTrendFontSize({
671
345
  width: textContentWidth,
672
346
  height: textContentHeight,
673
- trendText: trendText,
347
+ trendText,
674
348
  spaceRatio: 1 - majorTextSpaceRatio
675
349
  });
676
350
  return {
677
- majorText: majorText,
678
- majorTextFontSize: majorTextFontSize,
679
- trendText: trendText,
680
- trendTextFontSize: trendTextFontSize
351
+ majorText,
352
+ majorTextFontSize,
353
+ trendText,
354
+ trendTextFontSize
681
355
  };
682
356
  };
683
- /*
684
- * @method updateVizInSmallSpace
685
- * @param {Object} props
686
- * @param {Number} props.width // Width of the text container
687
- * @param {Number} props.height // Height of the text container
688
- * @param {Object} props.toRemoveList
689
- * @param {Number} props.majorValue // Major value
690
- * @param {Number} props.trendValue // Trend value
691
- * @param {Number} props.majorFontSize
692
- * @param {Number} props.trendFontSize
693
- * @param {Number} props.majorTextFontSize
694
- * @param {String} props.unit // Unit for the value
695
- * @param {Number} props.numberPrecision
696
- * @param {Bool} props.shouldUseThousandSeparators
697
- * @param {Bool} props.shouldAbbreviateTrendValue
698
- * @returns {Object} results
699
- * @returns {Object} results.newMajorAndTrend
700
- * @returns {Object} results.updatedProps
701
- */
702
-
703
- var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
704
- var width = _ref12.width,
705
- height = _ref12.height,
706
- toRemoveList = _ref12.toRemoveList,
707
- majorValue = _ref12.majorValue,
708
- trendValue = _ref12.trendValue,
709
- majorFontSize = _ref12.majorFontSize,
710
- trendFontSize = _ref12.trendFontSize,
711
- majorTextFontSize = _ref12.majorTextFontSize,
712
- unit = _ref12.unit,
713
- numberPrecision = _ref12.numberPrecision,
714
- shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
715
- shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
716
- var removeIndex = 0;
717
- var newProps = {}; // options need to be updated
718
-
719
- var newMajorAndTrend = {};
720
- var newTextSize = majorTextFontSize; // remove info on viz to make textFontSize >= 12px;
721
-
357
+ var updateVizInSmallSpace = ({
358
+ width,
359
+ height,
360
+ toRemoveList,
361
+ majorValue,
362
+ trendValue,
363
+ majorFontSize,
364
+ trendFontSize,
365
+ majorTextFontSize,
366
+ unit,
367
+ numberPrecision,
368
+ shouldUseThousandSeparators,
369
+ shouldAbbreviateTrendValue
370
+ }) => {
371
+ let removeIndex = 0;
372
+ let newProps = {};
373
+ let newMajorAndTrend = {};
374
+ let newTextSize = majorTextFontSize;
722
375
  while (newTextSize < 12 && removeIndex < toRemoveList.length) {
723
- var toRemove = toRemoveList[removeIndex];
724
- newProps = _objectSpread(_objectSpread({}, newProps), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, toRemove.key, toRemove.value));
725
- newMajorAndTrend = getMajorAndTrend(_objectSpread({
726
- majorValue: majorValue,
727
- trendValue: trendValue,
728
- majorFontSize: majorFontSize,
729
- trendFontSize: trendFontSize,
730
- width: width,
731
- height: height,
732
- unit: unit,
733
- numberPrecision: numberPrecision,
734
- shouldUseThousandSeparators: shouldUseThousandSeparators,
735
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
376
+ const toRemove = toRemoveList[removeIndex];
377
+ newProps = __spreadValues(__spreadValues({}, newProps), {
378
+ [toRemove.key]: toRemove.value
379
+ });
380
+ newMajorAndTrend = getMajorAndTrend(__spreadValues({
381
+ majorValue,
382
+ trendValue,
383
+ majorFontSize,
384
+ trendFontSize,
385
+ width,
386
+ height,
387
+ unit,
388
+ numberPrecision,
389
+ shouldUseThousandSeparators,
390
+ shouldAbbreviateTrendValue
736
391
  }, newProps));
737
392
  newTextSize = newMajorAndTrend.majorTextFontSize;
738
393
  removeIndex += 1;
739
- } // truncate text if textFontSize is still less than 12
740
-
741
-
394
+ }
742
395
  if (newTextSize < 12) {
743
- var truncateValue = "".concat(majorValue.toString().slice(0, 3), "...");
744
- newMajorAndTrend = getMajorAndTrend(_objectSpread({
396
+ const truncateValue = `${majorValue.toString().slice(0, 3)}...`;
397
+ newMajorAndTrend = getMajorAndTrend(__spreadValues({
745
398
  majorValue: truncateValue,
746
- trendValue: trendValue,
747
- majorFontSize: majorFontSize,
748
- trendFontSize: trendFontSize,
749
- width: width,
750
- height: height,
751
- unit: unit,
752
- numberPrecision: numberPrecision,
753
- shouldUseThousandSeparators: shouldUseThousandSeparators,
754
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
399
+ trendValue,
400
+ majorFontSize,
401
+ trendFontSize,
402
+ width,
403
+ height,
404
+ unit,
405
+ numberPrecision,
406
+ shouldUseThousandSeparators,
407
+ shouldAbbreviateTrendValue
755
408
  }, newProps));
756
409
  }
757
-
758
- return {
759
- newMajorAndTrend: newMajorAndTrend,
760
- updatedProps: newProps
761
- };
410
+ return { newMajorAndTrend, updatedProps: newProps };
762
411
  };
763
- /*
764
- * @method computeSingleValueContent
765
- * @param {Object} props
766
- * @param {Number} props.contentWidth
767
- * @param {Number} props.contentHeight
768
- * @param {Number} props.containerWidth
769
- * @param {Number} props.containerHeight
770
- * @param {Number} props.majorValue // Major value
771
- * @param {Number} props.trendValue // Trend value
772
- * @param {Number} props.majorFontSize
773
- * @param {Number} props.trendFontSize
774
- * @param {String} props.trendDisplay
775
- * @param {String} props.unit // Unit for the value
776
- * @param {Number} props.numberPrecision
777
- * @param {Bool} props.shouldUseThousandSeparators
778
- * @param {Bool} props.shouldAbbreviateTrendValue
779
- * @param {Bool} props.shouldAbbreviateMajorValue
780
- * @param {Object} props.toRemoveList
781
- * @returns {Object} results
782
- * @returns {String} results.majorText
783
- * @returns {String} results.trendText
784
- * @returns {Number} results.majorTextFontSize
785
- * @returns {Number} results.trendTextFontSize
786
- * @returns {String} results.majorValueTitle
787
- * @returns {Object} results.smallVizProps
788
- */
789
-
790
- var computeSingleValueContent = function computeSingleValueContent(_ref13) {
791
- var contentWidth = _ref13.contentWidth,
792
- contentHeight = _ref13.contentHeight,
793
- containerWidth = _ref13.containerWidth,
794
- containerHeight = _ref13.containerHeight,
795
- majorValue = _ref13.majorValue,
796
- trendValue = _ref13.trendValue,
797
- majorFontSize = _ref13.majorFontSize,
798
- trendFontSize = _ref13.trendFontSize,
799
- trendDisplay = _ref13.trendDisplay,
800
- unit = _ref13.unit,
801
- numberPrecision = _ref13.numberPrecision,
802
- shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
803
- shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
804
- shouldAbbreviateMajorValue = _ref13.shouldAbbreviateMajorValue,
805
- toRemoveList = _ref13.toRemoveList;
806
-
807
- var _getMajorAndTrend = getMajorAndTrend({
808
- majorValue: majorValue,
809
- trendValue: trendValue,
810
- majorFontSize: majorFontSize,
811
- trendFontSize: trendFontSize,
812
- trendDisplay: trendDisplay,
412
+ var computeSingleValueContent = ({
413
+ contentWidth,
414
+ contentHeight,
415
+ containerWidth,
416
+ containerHeight,
417
+ majorValue,
418
+ trendValue,
419
+ majorFontSize,
420
+ trendFontSize,
421
+ trendDisplay,
422
+ unit,
423
+ numberPrecision,
424
+ shouldUseThousandSeparators,
425
+ shouldAbbreviateTrendValue,
426
+ shouldAbbreviateMajorValue,
427
+ toRemoveList
428
+ }) => {
429
+ let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
430
+ majorValue,
431
+ trendValue,
432
+ majorFontSize,
433
+ trendFontSize,
434
+ trendDisplay,
813
435
  width: contentWidth,
814
436
  height: contentHeight,
815
- unit: unit,
816
- numberPrecision: numberPrecision,
817
- shouldUseThousandSeparators: shouldUseThousandSeparators,
818
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue,
819
- shouldAbbreviateMajorValue: shouldAbbreviateMajorValue
820
- }),
821
- majorText = _getMajorAndTrend.majorText,
822
- trendText = _getMajorAndTrend.trendText,
823
- majorTextFontSize = _getMajorAndTrend.majorTextFontSize,
824
- trendTextFontSize = _getMajorAndTrend.trendTextFontSize;
825
-
826
- var majorValueTitle = majorText;
827
- var smallVizProps = {}; // update viz in small space
828
- // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit
829
- // or truncate major value to make the major font size >= 12
830
-
437
+ unit,
438
+ numberPrecision,
439
+ shouldUseThousandSeparators,
440
+ shouldAbbreviateTrendValue,
441
+ shouldAbbreviateMajorValue
442
+ });
443
+ const majorValueTitle = majorText;
444
+ let smallVizProps = {};
831
445
  if (majorTextFontSize < 12) {
832
- var _updateVizInSmallSpac = updateVizInSmallSpace({
446
+ const { newMajorAndTrend, updatedProps } = updateVizInSmallSpace({
833
447
  width: containerWidth,
834
448
  height: containerHeight,
835
- toRemoveList: toRemoveList,
836
- majorValue: majorValue,
837
- trendValue: trendValue,
838
- majorFontSize: majorFontSize,
839
- trendFontSize: trendFontSize,
840
- majorTextFontSize: majorTextFontSize,
841
- unit: unit,
842
- numberPrecision: numberPrecision,
843
- shouldUseThousandSeparators: shouldUseThousandSeparators,
844
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
845
- }),
846
- newMajorAndTrend = _updateVizInSmallSpac.newMajorAndTrend,
847
- updatedProps = _updateVizInSmallSpac.updatedProps;
848
-
849
- majorText = newMajorAndTrend.majorText;
850
- trendText = newMajorAndTrend.trendText;
851
- majorTextFontSize = newMajorAndTrend.majorTextFontSize;
852
- trendTextFontSize = newMajorAndTrend.trendTextFontSize;
449
+ toRemoveList,
450
+ majorValue,
451
+ trendValue,
452
+ majorFontSize,
453
+ trendFontSize,
454
+ majorTextFontSize,
455
+ unit,
456
+ numberPrecision,
457
+ shouldUseThousandSeparators,
458
+ shouldAbbreviateTrendValue
459
+ });
460
+ ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = newMajorAndTrend);
853
461
  smallVizProps = updatedProps;
854
462
  }
855
-
856
463
  return {
857
- majorText: majorText,
858
- trendText: trendText,
859
- majorTextFontSize: majorTextFontSize,
860
- trendTextFontSize: trendTextFontSize,
861
- majorValueTitle: majorValueTitle,
862
- smallVizProps: smallVizProps
464
+ majorText,
465
+ trendText,
466
+ majorTextFontSize,
467
+ trendTextFontSize,
468
+ majorValueTitle,
469
+ smallVizProps
863
470
  };
864
471
  };
865
- var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_ref14) {
866
- var text = _ref14.text,
867
- _ref14$fontSize = _ref14.fontSize,
868
- fontSize = _ref14$fontSize === void 0 ? DEFAULT_FONT : _ref14$fontSize,
869
- _ref14$fontFamily = _ref14.fontFamily,
870
- fontFamily = _ref14$fontFamily === void 0 ? DEFAULT_FONT_FAMILY : _ref14$fontFamily,
871
- _ref14$fontWeight = _ref14.fontWeight,
872
- fontWeight = _ref14$fontWeight === void 0 ? 'normal' : _ref14$fontWeight,
873
- containerWidth = _ref14.containerWidth;
874
- var textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily));
875
- var modifiedText = text;
876
- 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.
877
-
472
+ var minimallyTruncateStringToWidth = ({
473
+ text,
474
+ fontSize = DEFAULT_FONT,
475
+ fontFamily = DEFAULT_FONT_FAMILY,
476
+ fontWeight = "normal",
477
+ containerWidth
478
+ }) => {
479
+ let textWidth = (0, domUtils_exports.computeTextSize)(text, `${fontWeight} ${fontSize}px ${fontFamily}`);
480
+ let modifiedText = text;
481
+ const ellipsesLength = (0, domUtils_exports.computeTextSize)("...", `${fontWeight} ${fontSize}px ${fontFamily}`);
878
482
  if (containerWidth - ellipsesLength > 0 && textWidth > containerWidth) {
879
- // Truncates the content such that the truncated value + ellipses fit within the allocated space for the ellipses.
880
- // `textWidth > containerWidth - ellipsesLength` condition checks if text + ellipses exceeds container width.
881
- // `text.length > 1` condition included to keep at least the first number.
882
483
  while (textWidth + ellipsesLength > containerWidth && modifiedText.length > 1) {
883
484
  modifiedText = modifiedText.substring(0, modifiedText.length - 1);
884
- textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(modifiedText, "normal ".concat(fontSize, "px ").concat(fontFamily));
485
+ textWidth = (0, domUtils_exports.computeTextSize)(modifiedText, `normal ${fontSize}px ${fontFamily}`);
885
486
  }
886
-
887
- modifiedText = "".concat(modifiedText, "...");
487
+ modifiedText = `${modifiedText}...`;
888
488
  }
889
-
890
489
  return modifiedText;
891
490
  };
892
- /*
893
- * @method computeSingleValueRadialContent
894
- * @param {Object} props
895
- * @param {Number} props.contentWidth
896
- * @param {Number} props.contentHeight
897
- * @param {Number} props.containerWidth
898
- * @param {Number} props.containerHeight
899
- * @param {Number} props.majorValue // Major value
900
- * @param {Number} props.trendValue // Trend value
901
- * @param {Number} props.majorFontSize
902
- * @param {Number} props.trendFontSize
903
- * @param {String} props.trendDisplay
904
- * @param {String} props.unit // Unit for the value
905
- * @param {Number} props.numberPrecision
906
- * @param {Bool} props.shouldUseThousandSeparators
907
- * @param {Bool} props.shouldAbbreviateTrendValue
908
- * @param {Bool} props.shouldAbbreviateMajorValue,
909
- * @param {Object} props.toRemoveList
910
- * @param {Bool} props.smallViz
911
- * @returns {Object} results
912
- * @returns {String} results.majorText
913
- * @returns {String} results.trendText
914
- * @returns {Number} results.majorTextFontSize
915
- * @returns {Number} results.trendTextFontSize
916
- * @returns {String} results.majorValueTitle
917
- * @returns {Object} results.smallVizProps
918
- */
919
-
920
- var computeSingleValueRadialContent = function computeSingleValueRadialContent(_ref15) {
921
- var contentWidth = _ref15.contentWidth,
922
- contentHeight = _ref15.contentHeight,
923
- containerWidth = _ref15.containerWidth,
924
- containerHeight = _ref15.containerHeight,
925
- majorValue = _ref15.majorValue,
926
- trendValue = _ref15.trendValue,
927
- majorFontSize = _ref15.majorFontSize,
928
- trendFontSize = _ref15.trendFontSize,
929
- trendDisplay = _ref15.trendDisplay,
930
- unit = _ref15.unit,
931
- numberPrecision = _ref15.numberPrecision,
932
- shouldUseThousandSeparators = _ref15.shouldUseThousandSeparators,
933
- shouldAbbreviateTrendValue = _ref15.shouldAbbreviateTrendValue,
934
- shouldAbbreviateMajorValue = _ref15.shouldAbbreviateMajorValue,
935
- smallViz = _ref15.smallViz;
936
-
937
- var _getMajorAndTrend2 = getMajorAndTrend({
938
- majorValue: majorValue,
939
- trendValue: trendValue,
940
- majorFontSize: majorFontSize,
941
- trendFontSize: trendFontSize,
942
- trendDisplay: trendDisplay,
491
+ var computeSingleValueRadialContent = ({
492
+ contentWidth,
493
+ contentHeight,
494
+ containerWidth,
495
+ containerHeight,
496
+ majorValue,
497
+ trendValue,
498
+ majorFontSize,
499
+ trendFontSize,
500
+ trendDisplay,
501
+ unit,
502
+ numberPrecision,
503
+ shouldUseThousandSeparators,
504
+ shouldAbbreviateTrendValue,
505
+ shouldAbbreviateMajorValue,
506
+ smallViz
507
+ }) => {
508
+ let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
509
+ majorValue,
510
+ trendValue,
511
+ majorFontSize,
512
+ trendFontSize,
513
+ trendDisplay,
943
514
  width: contentWidth,
944
515
  height: contentHeight,
945
- unit: unit,
946
- numberPrecision: numberPrecision,
947
- shouldUseThousandSeparators: shouldUseThousandSeparators,
948
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue,
949
- shouldAbbreviateMajorValue: shouldAbbreviateMajorValue
950
- }),
951
- majorText = _getMajorAndTrend2.majorText,
952
- trendText = _getMajorAndTrend2.trendText,
953
- majorTextFontSize = _getMajorAndTrend2.majorTextFontSize,
954
- trendTextFontSize = _getMajorAndTrend2.trendTextFontSize;
955
-
956
- var majorValueTitle = majorText;
957
- var smallVizProps = {}; // custom logic for viz in small space
958
- // if not showing the radial graph (if `smallViz` is true), then compute truncated major value
959
- // and font sizes
960
-
516
+ unit,
517
+ numberPrecision,
518
+ shouldUseThousandSeparators,
519
+ shouldAbbreviateTrendValue,
520
+ shouldAbbreviateMajorValue
521
+ });
522
+ const majorValueTitle = majorText;
523
+ let smallVizProps = {};
961
524
  if (smallViz) {
962
- var truncateValue = minimallyTruncateStringToWidth({
525
+ const truncateValue = minimallyTruncateStringToWidth({
963
526
  text: majorValue,
964
- fontWeight: 'bold',
527
+ fontWeight: "bold",
965
528
  fontSize: 12,
966
- containerWidth: containerWidth
529
+ containerWidth
967
530
  });
968
-
969
- var _getMajorAndTrend3 = getMajorAndTrend({
531
+ ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
970
532
  majorValue: truncateValue,
971
- trendValue: trendValue,
972
- majorFontSize: majorFontSize,
973
- trendFontSize: trendFontSize,
533
+ trendValue,
534
+ majorFontSize,
535
+ trendFontSize,
974
536
  width: containerWidth,
975
537
  height: containerHeight,
976
- unit: unit,
977
- trendDisplay: trendDisplay,
978
- numberPrecision: numberPrecision,
979
- shouldUseThousandSeparators: shouldUseThousandSeparators,
980
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue,
981
- shouldAbbreviateMajorValue: shouldAbbreviateMajorValue
982
- });
983
-
984
- majorText = _getMajorAndTrend3.majorText;
985
- trendText = _getMajorAndTrend3.trendText;
986
- majorTextFontSize = _getMajorAndTrend3.majorTextFontSize;
987
- trendTextFontSize = _getMajorAndTrend3.trendTextFontSize;
538
+ unit,
539
+ trendDisplay,
540
+ numberPrecision,
541
+ shouldUseThousandSeparators,
542
+ shouldAbbreviateTrendValue,
543
+ shouldAbbreviateMajorValue
544
+ }));
988
545
  smallVizProps = {
989
- trendDisplay: trendDisplay,
990
- unit: unit
546
+ trendDisplay,
547
+ unit
991
548
  };
992
549
  }
993
-
994
550
  return {
995
- majorText: majorText,
996
- trendText: trendText,
997
- majorTextFontSize: majorTextFontSize,
998
- trendTextFontSize: trendTextFontSize,
999
- majorValueTitle: majorValueTitle,
1000
- smallVizProps: smallVizProps
551
+ majorText,
552
+ trendText,
553
+ majorTextFontSize,
554
+ trendTextFontSize,
555
+ majorValueTitle,
556
+ smallVizProps
1001
557
  };
1002
558
  };
1003
- /**
1004
- * Get the colors for a graph
1005
- *
1006
- * @method getGraphColors
1007
- * @param {Object} options
1008
- * @param {Bool} options.backgroundEnabled // Flag to turn on color mode
1009
- * @param {String} options.backgroundColor // The current background color, overrides trend background color
1010
- * @param {Object} options.defaultColors // Default colors by severity
1011
- * @param {Function} options.customColorFormatter // must return { background, stroke } given a color
1012
- * @returns {Object} { background, stroke } colors
1013
- * @private
1014
- */
1015
-
1016
- var getGraphColors = function getGraphColors(_ref16) {
1017
- var backgroundEnabled = _ref16.backgroundEnabled,
1018
- backgroundColor = _ref16.backgroundColor,
1019
- defaultColors = _ref16.defaultColors,
1020
- customColorFormatter = _ref16.customColorFormatter; // Only do custom colors in block mode
1021
-
559
+ var getGraphColors = ({
560
+ backgroundEnabled,
561
+ backgroundColor,
562
+ defaultColors,
563
+ customColorFormatter
564
+ }) => {
1022
565
  if (backgroundEnabled) {
1023
- // Check if the user defined colors to use
1024
- if (backgroundColor && typeof customColorFormatter === 'function') {
566
+ if (backgroundColor && typeof customColorFormatter === "function") {
1025
567
  return customColorFormatter(backgroundColor);
1026
568
  }
1027
569
  }
1028
-
1029
570
  return defaultColors.none;
1030
571
  };
1031
- /**
1032
- * Adjust rgb value if it equals to 0 or 255
1033
- * @method adjustRGB
1034
- * @param {Number} rgb [0 - 255]
1035
- * @param {Number} delta
1036
- * @returns {Number} adjusted rgb
1037
- * @private
1038
- */
1039
-
1040
- var adjustRGB = function adjustRGB(rgb, delta) {
572
+ var adjustRGB = (rgb, delta) => {
1041
573
  if (rgb === 255) {
1042
574
  return rgb - delta;
1043
575
  }
1044
-
1045
576
  if (rgb === 0) {
1046
577
  return rgb + delta;
1047
578
  }
1048
-
1049
579
  return rgb;
1050
580
  };
1051
- /**
1052
- * Modifies colors by multiplying by a given ratio
1053
- * @method changeColor
1054
- * @param {String} color // Color to modify
1055
- * @param {Number} ratio // Float to modify color
1056
- * @returns {String} new color
1057
- * @private
1058
- */
1059
-
1060
- var changeColor = function changeColor(color, ratio) {
1061
- var hex = color.replace(/(0x|#)/, '');
1062
- var r = parseInt(hex.substr(0, 2), 16);
1063
- var g = parseInt(hex.substr(2, 2), 16);
1064
- var b = parseInt(hex.substr(4, 2), 16); // Multiply by given ratio, make sure is between 0 and 255;
1065
-
1066
- var newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
1067
- var newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
1068
- var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0); // If the color is not changed
1069
- // case 1: the color is (0, 0 0)
1070
- // lighten color (80, 80, 80)
1071
- // darken color (40, 40, 40)
1072
- // case 2: the color is (255, 255, 255)
1073
- // lighten color (235, 235, 235)
1074
- // darken color (175, 175, 175)
1075
- // case 3: the color is e.g. (0, 255, 0)
1076
- // new color (20, 235, 20)
1077
-
581
+ var changeColor = (color, ratio) => {
582
+ const hex = color.replace(/(0x|#)/, "");
583
+ const r = parseInt(hex.substr(0, 2), 16);
584
+ const g = parseInt(hex.substr(2, 2), 16);
585
+ const b = parseInt(hex.substr(4, 2), 16);
586
+ let newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
587
+ let newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
588
+ let newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);
1078
589
  if (newR === r && newG === g && newB === b) {
1079
590
  if (newR === 0 && newG === 0 && newB === 0) {
1080
591
  if (ratio > 1) {
@@ -1102,78 +613,19 @@ var changeColor = function changeColor(color, ratio) {
1102
613
  newB = adjustRGB(newB, 20);
1103
614
  }
1104
615
  }
1105
-
1106
- return "#".concat(newR.toString(16).padStart(2, 0)) + "".concat(newG.toString(16).padStart(2, 0)) + "".concat(newB.toString(16).padStart(2, 0));
616
+ return `#${newR.toString(16).padStart(2, 0)}${newG.toString(16).padStart(2, 0)}${newB.toString(16).padStart(2, 0)}`;
1107
617
  };
1108
- /**
1109
- * Lighten a given color
1110
- * @method lighten
1111
- * @param {String} color
1112
- * @returns {String}
1113
- * @private
1114
- */
1115
-
1116
-
1117
- var lighten = function lighten(color) {
1118
- return changeColor(color, 1.3);
1119
- };
1120
- /**
1121
- * Darkens a given color
1122
- * @method darken
1123
- * @param {String} color
1124
- * @returns {String}
1125
- * @private
1126
- */
1127
-
1128
- var darken = function darken(color) {
1129
- return changeColor(color, 0.5);
1130
- };
1131
- /** consistent token structure: handle callback to add value and name in event payload
1132
- * @method handleValueClickCallback
1133
- * @param {Object} ev
1134
- * @param {String | Number} majorValue
1135
- * @param {String} majorValueField
1136
- * @param {Number} trendValue
1137
- * @param {Function} onValueClick
1138
- */
1139
-
1140
- var handleValueClickCallback = function handleValueClickCallback(ev, majorValue, majorValueField, trendValue, onValueClick) {
1141
- var trellisEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
1142
- var trellisSplityBy = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
1143
- var trellisKey = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : '';
1144
- var payload = {
1145
- trendValue: trendValue,
618
+ var lighten = (color) => changeColor(color, 1.3);
619
+ var darken = (color) => changeColor(color, 0.5);
620
+ var handleValueClickCallback = (ev, majorValue, majorValueField, trendValue, onValueClick, trellisEnabled = false, trellisSplityBy = "", trellisKey = "") => {
621
+ let payload = {
622
+ trendValue,
1146
623
  value: majorValue,
1147
624
  name: majorValueField
1148
625
  };
1149
-
1150
626
  if (trellisEnabled) {
1151
- payload = _objectSpread(_objectSpread({}, payload), {}, {
1152
- 'trellis.name': trellisSplityBy,
1153
- 'trellis.value': trellisKey
1154
- });
627
+ payload = __spreadProps(__spreadValues({}, payload), { "trellis.name": trellisSplityBy, "trellis.value": trellisKey });
1155
628
  }
1156
-
1157
- return onValueClick(_objectSpread(_objectSpread({}, ev), {}, {
1158
- payload: payload
1159
- }));
629
+ return onValueClick(__spreadProps(__spreadValues({}, ev), { payload }));
1160
630
  };
1161
-
1162
- /***/ }),
1163
-
1164
- /***/ 6:
1165
- /***/ (function(module, exports) {
1166
-
1167
- module.exports = require("@splunk/visualizations-shared/propUtils");
1168
-
1169
- /***/ }),
1170
-
1171
- /***/ 9:
1172
- /***/ (function(module, exports) {
1173
-
1174
- module.exports = require("@splunk/visualizations-shared/colorConstants");
1175
-
1176
- /***/ })
1177
-
1178
- /******/ });
1179
- //# sourceMappingURL=singleValueUtils.js.map
631
+ //# sourceMappingURL=singleValueUtils.js.map