@splunk/visualizations 26.4.1 → 27.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 (153) hide show
  1. package/Area.config.js +1399 -1590
  2. package/Area.config.js.map +7 -1
  3. package/Area.js +3750 -4822
  4. package/Area.js.map +7 -1
  5. package/Bar.config.js +1423 -1566
  6. package/Bar.config.js.map +7 -1
  7. package/Bar.js +3856 -4884
  8. package/Bar.js.map +7 -1
  9. package/Bubble.config.js +1009 -1200
  10. package/Bubble.config.js.map +7 -1
  11. package/Bubble.js +2768 -4491
  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 +2032 -3808
  16. package/ChoroplethSvg.js.map +7 -1
  17. package/Column.config.js +1390 -1534
  18. package/Column.config.js.map +7 -1
  19. package/Column.js +3849 -4906
  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 +1667 -3327
  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 +2643 -4647
  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 +2164 -4575
  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 +1423 -3046
  36. package/Image.js.map +7 -1
  37. package/Line.config.js +1421 -1616
  38. package/Line.config.js.map +7 -1
  39. package/Line.js +3790 -4901
  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 +5272 -6185
  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 +3382 -5659
  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 +1671 -3212
  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 +2215 -4531
  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 +2057 -4718
  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 +2107 -3984
  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 +2734 -5037
  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 +1664 -3258
  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 +2766 -4908
  77. package/Sankey.js.map +7 -1
  78. package/Scatter.config.js +988 -1180
  79. package/Scatter.config.js.map +7 -1
  80. package/Scatter.js +2801 -4506
  81. package/Scatter.js.map +7 -1
  82. package/SingleValue.config.js +794 -1250
  83. package/SingleValue.config.js.map +7 -1
  84. package/SingleValue.js +4185 -7327
  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 +757 -1207
  89. package/SingleValueIcon.config.js.map +7 -1
  90. package/SingleValueIcon.js +3427 -6293
  91. package/SingleValueIcon.js.map +7 -1
  92. package/SingleValueRadial.config.js +686 -1121
  93. package/SingleValueRadial.config.js.map +7 -1
  94. package/SingleValueRadial.js +3923 -6994
  95. package/SingleValueRadial.js.map +7 -1
  96. package/SparkLine.js +439 -746
  97. package/SparkLine.js.map +7 -1
  98. package/TRELLIS.md +16 -15
  99. package/Table.config.js +565 -879
  100. package/Table.config.js.map +7 -1
  101. package/Table.js +3260 -5334
  102. package/Table.js.map +7 -1
  103. package/common/Charting.js +617 -1498
  104. package/common/Charting.js.map +7 -1
  105. package/common/ChartingApi.js +46 -170
  106. package/common/ChartingApi.js.map +7 -1
  107. package/common/DocExampleWithVizSandbox.js +270 -473
  108. package/common/DocExampleWithVizSandbox.js.map +7 -1
  109. package/common/EventsDoc.js +172 -464
  110. package/common/EventsDoc.js.map +7 -1
  111. package/common/GaugeMajorTicks.js +249 -347
  112. package/common/GaugeMajorTicks.js.map +7 -1
  113. package/common/GaugeValueMarker.js +201 -311
  114. package/common/GaugeValueMarker.js.map +7 -1
  115. package/common/OptionsDoc.js +351 -911
  116. package/common/OptionsDoc.js.map +7 -1
  117. package/common/OverviewDoc.js +435 -769
  118. package/common/OverviewDoc.js.map +7 -1
  119. package/common/SplunkVisualization.js +116 -259
  120. package/common/SplunkVisualization.js.map +7 -1
  121. package/common/SplunkVisualizationApi.js +40 -156
  122. package/common/SplunkVisualizationApi.js.map +7 -1
  123. package/common/ThemesDoc.js +271 -420
  124. package/common/ThemesDoc.js.map +7 -1
  125. package/common/chartingUtils.js +140 -312
  126. package/common/chartingUtils.js.map +7 -1
  127. package/common/docUtils.js +148 -266
  128. package/common/docUtils.js.map +7 -1
  129. package/common/gaugeUtils.js +280 -808
  130. package/common/gaugeUtils.js.map +7 -1
  131. package/common/shapeUtils.js +106 -211
  132. package/common/shapeUtils.js.map +7 -1
  133. package/common/utils/configUtils.js +126 -252
  134. package/common/utils/configUtils.js.map +7 -1
  135. package/common/utils/dataUtils.js +217 -812
  136. package/common/utils/dataUtils.js.map +7 -1
  137. package/common/utils/featureFlagUtils.js +53 -133
  138. package/common/utils/featureFlagUtils.js.map +7 -1
  139. package/common/utils/hocUtils.js +32 -122
  140. package/common/utils/hocUtils.js.map +7 -1
  141. package/common/utils/mapUtils.js +502 -1337
  142. package/common/utils/mapUtils.js.map +7 -1
  143. package/common/utils/singleValueUtils.js +466 -1013
  144. package/common/utils/singleValueUtils.js.map +7 -1
  145. package/common/utils/testHelper.js +92 -146
  146. package/common/utils/testHelper.js.map +7 -1
  147. package/common/utils/trellisUtils.js +277 -489
  148. package/common/utils/trellisUtils.js.map +7 -1
  149. package/common/utils/urlUtils.js +28 -112
  150. package/common/utils/urlUtils.js.map +7 -1
  151. package/common/withDashboardViz.js +1191 -2431
  152. package/common/withDashboardViz.js.map +7 -1
  153. package/package.json +53 -45
@@ -1,1080 +1,592 @@
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
+ getTrendColorWithPercent: () => getTrendColorWithPercent,
73
+ getTrendFontSize: () => getTrendFontSize,
74
+ getTrendText: () => getTrendText,
75
+ getUnderLabel: () => getUnderLabel,
76
+ getUnderLabelHeight: () => getUnderLabelHeight,
77
+ handleValueClickCallback: () => handleValueClickCallback,
78
+ hasBackground: () => hasBackground,
79
+ isIdenticalColor: () => isIdenticalColor,
80
+ isLoadingOrNoColumns: () => isLoadingOrNoColumns,
81
+ lighten: () => lighten,
82
+ minimallyTruncateStringToWidth: () => minimallyTruncateStringToWidth,
83
+ shouldShowTrend: () => shouldShowTrend,
84
+ updateVizInSmallSpace: () => updateVizInSmallSpace
85
+ });
86
+ module.exports = __toCommonJS(singleValueUtils_exports);
87
+
88
+ // esm-externals:lodash
89
+ var lodash_exports = {};
90
+ __export(lodash_exports, {
91
+ default: () => lodash_default
92
+ });
93
+ var defaultImport = __toESM(require("lodash"));
94
+ __reExport(lodash_exports, require("lodash"));
95
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
96
+
97
+ // esm-externals:@splunk/visualizations-shared/numberUtils
98
+ var numberUtils_exports = {};
99
+ __export(numberUtils_exports, {
100
+ default: () => numberUtils_default
101
+ });
102
+ var defaultImport2 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
103
+ __reExport(numberUtils_exports, require("@splunk/visualizations-shared/numberUtils"));
104
+ var numberUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
105
+
106
+ // esm-externals:@splunk/visualizations-shared/domUtils
107
+ var domUtils_exports = {};
108
+ __export(domUtils_exports, {
109
+ default: () => domUtils_default
110
+ });
111
+ var defaultImport3 = __toESM(require("@splunk/visualizations-shared/domUtils"));
112
+ __reExport(domUtils_exports, require("@splunk/visualizations-shared/domUtils"));
113
+ var domUtils_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
114
+
115
+ // esm-externals:@splunk/visualizations-shared/propUtils
116
+ var propUtils_exports = {};
117
+ __export(propUtils_exports, {
118
+ default: () => propUtils_default
119
+ });
120
+ var defaultImport4 = __toESM(require("@splunk/visualizations-shared/propUtils"));
121
+ __reExport(propUtils_exports, require("@splunk/visualizations-shared/propUtils"));
122
+ var propUtils_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
123
+
124
+ // esm-externals:@splunk/visualizations-shared/colorConstants
125
+ var colorConstants_exports = {};
126
+ __export(colorConstants_exports, {
127
+ default: () => colorConstants_default
128
+ });
129
+ var defaultImport5 = __toESM(require("@splunk/visualizations-shared/colorConstants"));
130
+ __reExport(colorConstants_exports, require("@splunk/visualizations-shared/colorConstants"));
131
+ var colorConstants_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
132
+
133
+ // src/common/utils/singleValueUtils.js
212
134
  var DEFAULT_FONT = 12;
213
135
  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'
136
+ var SVR_PADDING = { top: 12, bottom: 12, left: 16, right: 16 };
137
+ var getAligment = (align) => {
138
+ const alignMap = {
139
+ left: "start",
140
+ center: "center",
141
+ right: "end"
225
142
  };
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';
143
+ return alignMap[align] || "center";
236
144
  };
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;
145
+ var shouldShowTrend = (trendDisplay) => trendDisplay === "absolute" || trendDisplay === "percent";
146
+ var isLoadingOrNoColumns = (dataSources, loading) => {
147
+ const data = (0, lodash_exports.get)(dataSources, "primary.data.columns[0]", void 0);
148
+ const noColumns = data === void 0;
247
149
  return loading || noColumns;
248
150
  };
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
-
151
+ var getFormattedColor = (color, defaultColor) => (0, propUtils_exports.formatColor)(color) || (0, propUtils_exports.formatColor)(defaultColor);
152
+ var hasBackground = (backgroundColor) => !!backgroundColor && backgroundColor !== "transparent";
153
+ var isIdenticalColor = (colorA, colorB) => !!colorA && !!colorB && (0, propUtils_exports.formatColor)(colorA.toLowerCase()) === (0, propUtils_exports.formatColor)(colorB.toLowerCase());
154
+ var getDefaultColorWithBg = ({ backgroundColor, defaultFontColor, defaultBlockFontColor }) => isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;
155
+ var getMajorColor = ({ majorColor, backgroundColor, defaultFontColor, defaultBlockFontColor }) => {
315
156
  if (hasBackground(backgroundColor) && !majorColor) {
316
157
  return getDefaultColorWithBg({
317
- backgroundColor: backgroundColor,
318
- defaultFontColor: defaultFontColor,
319
- defaultBlockFontColor: defaultBlockFontColor
158
+ backgroundColor,
159
+ defaultFontColor,
160
+ defaultBlockFontColor
320
161
  });
321
162
  }
322
-
323
163
  return getFormattedColor(majorColor, defaultFontColor);
324
164
  };
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
-
165
+ var getTrendColor = ({
166
+ trendColor,
167
+ trendValue,
168
+ majorValue,
169
+ customizedBgColor,
170
+ trendDisplay,
171
+ defaultColors
172
+ }) => {
346
173
  if (trendColor) {
347
174
  return trendColor;
348
175
  }
349
-
350
176
  if (Number.isNaN(Number(trendValue))) {
351
- return undefined;
177
+ return void 0;
352
178
  }
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
-
179
+ const { defaultFontColor, defaultBlockFontColor, defaultBackgroundColor } = defaultColors;
358
180
  if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
359
181
  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
-
182
+ }
183
+ const isInvalidTrend = trendDisplay === "percent" && trendValue === parseFloat(majorValue);
366
184
  if (trendValue === 0 || isInvalidTrend) {
367
185
  return defaultFontColor;
368
186
  }
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"];
187
+ return trendValue > 0 ? colorConstants_exports.DELTA_GREEN : colorConstants_exports.DELTA_RED;
371
188
  };
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({
189
+ var computeColors = (props, defaultColors) => {
190
+ const backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
191
+ const backgroundEnabled = hasBackground(backgroundColor);
192
+ const majorColor = getMajorColor({
389
193
  majorColor: props.majorColor,
390
- backgroundColor: backgroundColor,
194
+ backgroundColor,
391
195
  defaultFontColor: defaultColors.defaultFontColor,
392
196
  defaultBlockFontColor: defaultColors.defaultBlockFontColor
393
197
  });
394
- var trendColor = getTrendColor({
198
+ const trendColor = getTrendColor({
395
199
  trendColor: props.trendColor,
396
200
  trendValue: props.trendValue,
397
201
  majorValue: props.majorValue,
398
202
  customizedBgColor: props.backgroundColor,
399
203
  trendDisplay: props.trendDisplay,
400
- defaultColors: defaultColors
401
- }); // todo: need change it to not depend on majorColor
402
-
403
- var underLabelColor = majorColor;
204
+ defaultColors
205
+ });
206
+ const underLabelColor = majorColor;
404
207
  return {
405
- backgroundColor: backgroundColor,
406
- backgroundEnabled: backgroundEnabled,
407
- majorColor: majorColor,
408
- trendColor: trendColor,
409
- underLabelColor: underLabelColor
208
+ backgroundColor,
209
+ backgroundEnabled,
210
+ majorColor,
211
+ trendColor,
212
+ underLabelColor
410
213
  };
411
214
  };
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, {
215
+ var computeText = ({
216
+ value,
217
+ numberPrecision,
218
+ shouldUseThousandSeparators,
219
+ shouldAbbreviateValue
220
+ }) => {
221
+ let text = (0, numberUtils_exports.isNumerial)(value) ? (0, numberUtils_exports.formatNumber)(value, numberPrecision, {
429
222
  useThousandSeparators: shouldUseThousandSeparators,
430
223
  // todo: need update formatNumber
431
224
  useTrendUnits: shouldAbbreviateValue
432
- }) : value; // When text is undefined, return empty string
433
-
434
- text = text || '';
225
+ }) : value;
226
+ text = text || "";
435
227
  return text;
436
228
  };
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
229
+ var getMajorText = ({
230
+ majorValue,
231
+ numberPrecision,
232
+ shouldUseThousandSeparators,
233
+ shouldAbbreviateMajorValue
234
+ }) => computeText({
235
+ value: majorValue === null ? "N/A" : majorValue,
236
+ // if majorValue is null, use `N/A`.
237
+ numberPrecision,
238
+ shouldUseThousandSeparators,
239
+ shouldAbbreviateValue: shouldAbbreviateMajorValue
240
+ });
241
+ var getTrendText = ({
242
+ majorValue,
243
+ trendValue,
244
+ trendDisplay,
245
+ numberPrecision,
246
+ shouldUseThousandSeparators,
247
+ shouldAbbreviateTrendValue
248
+ }) => {
249
+ const compute = (value) => computeText({
250
+ value,
251
+ numberPrecision,
252
+ shouldUseThousandSeparators,
253
+ shouldAbbreviateValue: shouldAbbreviateTrendValue
458
254
  });
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 '';
255
+ if (trendValue === "" || !(0, numberUtils_exports.isNumerial)(trendValue)) {
256
+ return "";
491
257
  }
492
-
493
- var showPercent = trendDisplay === 'percent';
494
-
258
+ const showPercent = trendDisplay === "percent";
495
259
  if (!showPercent) {
496
260
  return compute(trendValue);
497
261
  }
498
-
499
- var diff = Math.abs(trendValue - majorValue);
500
- var val = Math.round(trendValue / diff * 100);
501
-
262
+ const diff = Math.abs(trendValue - majorValue);
263
+ let val = Math.round(trendValue / diff * 100);
502
264
  if (trendValue === 0 && diff === 0) {
503
265
  val = 0;
504
266
  }
505
-
506
267
  if (!Number.isFinite(val)) {
507
- return 'N/A';
268
+ return "N/A";
508
269
  }
509
-
510
- var text = compute(val);
511
- return "".concat(text, "%");
270
+ const text = compute(val);
271
+ return `${text}%`;
512
272
  };
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);
273
+ var computeFontSize = (text, { width, height }, fontFamily = DEFAULT_FONT_FAMILY, fontWeight = "normal") => {
274
+ const widthInDefaultFont = (0, domUtils_exports.computeTextSize)(text, `${fontWeight} ${DEFAULT_FONT}px ${fontFamily}`);
275
+ const fontSize = Math.min(
276
+ width / widthInDefaultFont * DEFAULT_FONT,
277
+ height / DEFAULT_FONT * DEFAULT_FONT
278
+ );
532
279
  return parseInt(fontSize, 10);
533
280
  };
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;
281
+ var getMajorFontSize = ({ width, height, unit, majorText, spaceRatio = 1 }) => {
282
+ const majorTextCalc = unit ? `${unit}${majorText}` : majorText;
553
283
  return computeFontSize(majorTextCalc, {
554
284
  width: width * spaceRatio,
555
- height: height
285
+ height
556
286
  });
557
287
  };
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
-
288
+ var getTrendFontSize = ({ width, height, trendText, spaceRatio = 1 }) => {
289
+ let trendFontSize = 12;
576
290
  if (spaceRatio > 0) {
577
291
  trendFontSize = computeFontSize(trendText, {
578
292
  width: width * spaceRatio,
579
- height: height
293
+ height
580
294
  });
581
295
  trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
582
296
  }
583
-
584
297
  return trendFontSize;
585
298
  };
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
299
+ var getUnderLabelHeight = (height) => height > DEFAULT_FONT ? DEFAULT_FONT : height;
300
+ var getUnderLabel = ({ underLabel, width, height }) => (
301
+ // todo: may need truncate underLabel later
302
+ computeFontSize(underLabel, {
303
+ width,
304
+ height
305
+ })
306
+ );
307
+ var getMajorAndTrend = ({
308
+ width,
309
+ height,
310
+ majorValue,
311
+ trendValue,
312
+ majorFontSize,
313
+ trendFontSize,
314
+ trendDisplay,
315
+ unit,
316
+ numberPrecision,
317
+ shouldUseThousandSeparators,
318
+ shouldAbbreviateTrendValue,
319
+ shouldAbbreviateMajorValue
320
+ }) => {
321
+ const majorTextSpaceRatio = (0, numberUtils_exports.isNumerial)(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
322
+ const textContentWidth = width * 0.9;
323
+ const textContentHeight = height * 0.9;
324
+ const majorText = getMajorText({
325
+ majorValue,
326
+ numberPrecision,
327
+ shouldUseThousandSeparators,
328
+ shouldAbbreviateMajorValue
654
329
  });
655
- var majorTextFontSize = majorFontSize || getMajorFontSize({
330
+ const majorTextFontSize = majorFontSize || getMajorFontSize({
656
331
  width: textContentWidth,
657
332
  height: textContentHeight,
658
- unit: unit,
659
- majorText: majorText,
333
+ unit,
334
+ majorText,
660
335
  spaceRatio: majorTextSpaceRatio
661
336
  });
662
- var trendText = getTrendText({
663
- majorValue: majorValue,
664
- trendValue: trendValue,
665
- trendDisplay: trendDisplay,
666
- numberPrecision: numberPrecision,
667
- shouldUseThousandSeparators: shouldUseThousandSeparators,
668
- shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
337
+ const trendText = getTrendText({
338
+ majorValue,
339
+ trendValue,
340
+ trendDisplay,
341
+ numberPrecision,
342
+ shouldUseThousandSeparators,
343
+ shouldAbbreviateTrendValue
669
344
  });
670
- var trendTextFontSize = trendFontSize || getTrendFontSize({
345
+ const trendTextFontSize = trendFontSize || getTrendFontSize({
671
346
  width: textContentWidth,
672
347
  height: textContentHeight,
673
- trendText: trendText,
348
+ trendText,
674
349
  spaceRatio: 1 - majorTextSpaceRatio
675
350
  });
676
351
  return {
677
- majorText: majorText,
678
- majorTextFontSize: majorTextFontSize,
679
- trendText: trendText,
680
- trendTextFontSize: trendTextFontSize
352
+ majorText,
353
+ majorTextFontSize,
354
+ trendText,
355
+ trendTextFontSize
681
356
  };
682
357
  };
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
-
358
+ var updateVizInSmallSpace = ({
359
+ width,
360
+ height,
361
+ toRemoveList,
362
+ majorValue,
363
+ trendValue,
364
+ majorFontSize,
365
+ trendFontSize,
366
+ majorTextFontSize,
367
+ unit,
368
+ numberPrecision,
369
+ shouldUseThousandSeparators,
370
+ shouldAbbreviateTrendValue
371
+ }) => {
372
+ let removeIndex = 0;
373
+ let newProps = {};
374
+ let newMajorAndTrend = {};
375
+ let newTextSize = majorTextFontSize;
722
376
  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
377
+ const toRemove = toRemoveList[removeIndex];
378
+ newProps = __spreadValues(__spreadValues({}, newProps), {
379
+ [toRemove.key]: toRemove.value
380
+ });
381
+ newMajorAndTrend = getMajorAndTrend(__spreadValues({
382
+ majorValue,
383
+ trendValue,
384
+ majorFontSize,
385
+ trendFontSize,
386
+ width,
387
+ height,
388
+ unit,
389
+ numberPrecision,
390
+ shouldUseThousandSeparators,
391
+ shouldAbbreviateTrendValue
736
392
  }, newProps));
737
393
  newTextSize = newMajorAndTrend.majorTextFontSize;
738
394
  removeIndex += 1;
739
- } // truncate text if textFontSize is still less than 12
740
-
741
-
395
+ }
742
396
  if (newTextSize < 12) {
743
- var truncateValue = "".concat(majorValue.toString().slice(0, 3), "...");
744
- newMajorAndTrend = getMajorAndTrend(_objectSpread({
397
+ const truncateValue = `${majorValue.toString().slice(0, 3)}...`;
398
+ newMajorAndTrend = getMajorAndTrend(__spreadValues({
745
399
  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
400
+ trendValue,
401
+ majorFontSize,
402
+ trendFontSize,
403
+ width,
404
+ height,
405
+ unit,
406
+ numberPrecision,
407
+ shouldUseThousandSeparators,
408
+ shouldAbbreviateTrendValue
755
409
  }, newProps));
756
410
  }
757
-
758
- return {
759
- newMajorAndTrend: newMajorAndTrend,
760
- updatedProps: newProps
761
- };
411
+ return { newMajorAndTrend, updatedProps: newProps };
762
412
  };
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,
413
+ var computeSingleValueContent = ({
414
+ contentWidth,
415
+ contentHeight,
416
+ containerWidth,
417
+ containerHeight,
418
+ majorValue,
419
+ trendValue,
420
+ majorFontSize,
421
+ trendFontSize,
422
+ trendDisplay,
423
+ unit,
424
+ numberPrecision,
425
+ shouldUseThousandSeparators,
426
+ shouldAbbreviateTrendValue,
427
+ shouldAbbreviateMajorValue,
428
+ toRemoveList
429
+ }) => {
430
+ let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
431
+ majorValue,
432
+ trendValue,
433
+ majorFontSize,
434
+ trendFontSize,
435
+ trendDisplay,
813
436
  width: contentWidth,
814
437
  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
-
438
+ unit,
439
+ numberPrecision,
440
+ shouldUseThousandSeparators,
441
+ shouldAbbreviateTrendValue,
442
+ shouldAbbreviateMajorValue
443
+ });
444
+ const majorValueTitle = majorText;
445
+ let smallVizProps = {};
831
446
  if (majorTextFontSize < 12) {
832
- var _updateVizInSmallSpac = updateVizInSmallSpace({
447
+ const { newMajorAndTrend, updatedProps } = updateVizInSmallSpace({
833
448
  width: containerWidth,
834
449
  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;
450
+ toRemoveList,
451
+ majorValue,
452
+ trendValue,
453
+ majorFontSize,
454
+ trendFontSize,
455
+ majorTextFontSize,
456
+ unit,
457
+ numberPrecision,
458
+ shouldUseThousandSeparators,
459
+ shouldAbbreviateTrendValue
460
+ });
461
+ ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = newMajorAndTrend);
853
462
  smallVizProps = updatedProps;
854
463
  }
855
-
856
464
  return {
857
- majorText: majorText,
858
- trendText: trendText,
859
- majorTextFontSize: majorTextFontSize,
860
- trendTextFontSize: trendTextFontSize,
861
- majorValueTitle: majorValueTitle,
862
- smallVizProps: smallVizProps
465
+ majorText,
466
+ trendText,
467
+ majorTextFontSize,
468
+ trendTextFontSize,
469
+ majorValueTitle,
470
+ smallVizProps
863
471
  };
864
472
  };
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
-
473
+ var minimallyTruncateStringToWidth = ({
474
+ text,
475
+ fontSize = DEFAULT_FONT,
476
+ fontFamily = DEFAULT_FONT_FAMILY,
477
+ fontWeight = "normal",
478
+ containerWidth
479
+ }) => {
480
+ let textWidth = (0, domUtils_exports.computeTextSize)(text, `${fontWeight} ${fontSize}px ${fontFamily}`);
481
+ let modifiedText = text;
482
+ const ellipsesLength = (0, domUtils_exports.computeTextSize)("...", `${fontWeight} ${fontSize}px ${fontFamily}`);
878
483
  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
484
  while (textWidth + ellipsesLength > containerWidth && modifiedText.length > 1) {
883
485
  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));
486
+ textWidth = (0, domUtils_exports.computeTextSize)(modifiedText, `normal ${fontSize}px ${fontFamily}`);
885
487
  }
886
-
887
- modifiedText = "".concat(modifiedText, "...");
488
+ modifiedText = `${modifiedText}...`;
888
489
  }
889
-
890
490
  return modifiedText;
891
491
  };
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,
492
+ var computeSingleValueRadialContent = ({
493
+ contentWidth,
494
+ contentHeight,
495
+ containerWidth,
496
+ containerHeight,
497
+ majorValue,
498
+ trendValue,
499
+ majorFontSize,
500
+ trendFontSize,
501
+ trendDisplay,
502
+ unit,
503
+ numberPrecision,
504
+ shouldUseThousandSeparators,
505
+ shouldAbbreviateTrendValue,
506
+ shouldAbbreviateMajorValue,
507
+ smallViz
508
+ }) => {
509
+ let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
510
+ majorValue,
511
+ trendValue,
512
+ majorFontSize,
513
+ trendFontSize,
514
+ trendDisplay,
943
515
  width: contentWidth,
944
516
  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
-
517
+ unit,
518
+ numberPrecision,
519
+ shouldUseThousandSeparators,
520
+ shouldAbbreviateTrendValue,
521
+ shouldAbbreviateMajorValue
522
+ });
523
+ const majorValueTitle = majorText;
524
+ let smallVizProps = {};
961
525
  if (smallViz) {
962
- var truncateValue = minimallyTruncateStringToWidth({
526
+ const truncateValue = minimallyTruncateStringToWidth({
963
527
  text: majorValue,
964
- fontWeight: 'bold',
528
+ fontWeight: "bold",
965
529
  fontSize: 12,
966
- containerWidth: containerWidth
530
+ containerWidth
967
531
  });
968
-
969
- var _getMajorAndTrend3 = getMajorAndTrend({
532
+ ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
970
533
  majorValue: truncateValue,
971
- trendValue: trendValue,
972
- majorFontSize: majorFontSize,
973
- trendFontSize: trendFontSize,
534
+ trendValue,
535
+ majorFontSize,
536
+ trendFontSize,
974
537
  width: containerWidth,
975
538
  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;
539
+ unit,
540
+ trendDisplay,
541
+ numberPrecision,
542
+ shouldUseThousandSeparators,
543
+ shouldAbbreviateTrendValue,
544
+ shouldAbbreviateMajorValue
545
+ }));
988
546
  smallVizProps = {
989
- trendDisplay: trendDisplay,
990
- unit: unit
547
+ trendDisplay,
548
+ unit
991
549
  };
992
550
  }
993
-
994
551
  return {
995
- majorText: majorText,
996
- trendText: trendText,
997
- majorTextFontSize: majorTextFontSize,
998
- trendTextFontSize: trendTextFontSize,
999
- majorValueTitle: majorValueTitle,
1000
- smallVizProps: smallVizProps
552
+ majorText,
553
+ trendText,
554
+ majorTextFontSize,
555
+ trendTextFontSize,
556
+ majorValueTitle,
557
+ smallVizProps
1001
558
  };
1002
559
  };
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
-
560
+ var getGraphColors = ({
561
+ backgroundEnabled,
562
+ backgroundColor,
563
+ defaultColors,
564
+ customColorFormatter
565
+ }) => {
1022
566
  if (backgroundEnabled) {
1023
- // Check if the user defined colors to use
1024
- if (backgroundColor && typeof customColorFormatter === 'function') {
567
+ if (backgroundColor && typeof customColorFormatter === "function") {
1025
568
  return customColorFormatter(backgroundColor);
1026
569
  }
1027
570
  }
1028
-
1029
571
  return defaultColors.none;
1030
572
  };
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) {
573
+ var adjustRGB = (rgb, delta) => {
1041
574
  if (rgb === 255) {
1042
575
  return rgb - delta;
1043
576
  }
1044
-
1045
577
  if (rgb === 0) {
1046
578
  return rgb + delta;
1047
579
  }
1048
-
1049
580
  return rgb;
1050
581
  };
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
-
582
+ var changeColor = (color, ratio) => {
583
+ const hex = color.replace(/(0x|#)/, "");
584
+ const r = parseInt(hex.substr(0, 2), 16);
585
+ const g = parseInt(hex.substr(2, 2), 16);
586
+ const b = parseInt(hex.substr(4, 2), 16);
587
+ let newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
588
+ let newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
589
+ let newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);
1078
590
  if (newR === r && newG === g && newB === b) {
1079
591
  if (newR === 0 && newG === 0 && newB === 0) {
1080
592
  if (ratio > 1) {
@@ -1102,78 +614,19 @@ var changeColor = function changeColor(color, ratio) {
1102
614
  newB = adjustRGB(newB, 20);
1103
615
  }
1104
616
  }
1105
-
1106
- return "#".concat(newR.toString(16).padStart(2, 0)) + "".concat(newG.toString(16).padStart(2, 0)) + "".concat(newB.toString(16).padStart(2, 0));
1107
- };
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);
617
+ return `#${newR.toString(16).padStart(2, 0)}${newG.toString(16).padStart(2, 0)}${newB.toString(16).padStart(2, 0)}`;
1119
618
  };
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,
619
+ var lighten = (color) => changeColor(color, 1.3);
620
+ var darken = (color) => changeColor(color, 0.5);
621
+ var handleValueClickCallback = (ev, majorValue, majorValueField, trendValue, onValueClick, trellisEnabled = false, trellisSplitBy = "", trellisKey = "") => onValueClick(__spreadProps(__spreadValues({}, ev), {
622
+ payload: __spreadValues({
623
+ trendValue,
1146
624
  value: majorValue,
1147
625
  name: majorValueField
1148
- };
1149
-
1150
- if (trellisEnabled) {
1151
- payload = _objectSpread(_objectSpread({}, payload), {}, {
1152
- 'trellis.name': trellisSplityBy,
1153
- 'trellis.value': trellisKey
1154
- });
1155
- }
1156
-
1157
- return onValueClick(_objectSpread(_objectSpread({}, ev), {}, {
1158
- payload: payload
1159
- }));
626
+ }, trellisEnabled && { "trellis.name": trellisSplitBy, "trellis.value": trellisKey })
627
+ }));
628
+ var getTrendColorWithPercent = (options) => {
629
+ const shouldUsePercentTrendColor = options.trendColor === "> trendValue | rangeValue(trendColorEditorConfig)" && options.trendDisplay === "percent";
630
+ return shouldUsePercentTrendColor ? { trendColor: "> trendValuePercent | rangeValue(trendColorEditorConfig)" } : {};
1160
631
  };
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
632
+ //# sourceMappingURL=singleValueUtils.js.map