@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,855 +1,357 @@
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 = 98);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ({
94
-
95
- /***/ 22:
96
- /***/ (function(module, exports) {
97
-
98
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
99
-
100
- /***/ }),
101
-
102
- /***/ 3:
103
- /***/ (function(module, exports) {
104
-
105
- module.exports = require("lodash");
106
-
107
- /***/ }),
108
-
109
- /***/ 5:
110
- /***/ (function(module, exports) {
111
-
112
- module.exports = require("@splunk/ui-utils/i18n");
113
-
114
- /***/ }),
115
-
116
- /***/ 98:
117
- /***/ (function(module, exports, __webpack_require__) {
118
-
119
- "use strict";
120
-
121
-
122
- var _toConsumableArray = __webpack_require__(22);
123
-
124
- Object.defineProperty(exports, "__esModule", {
125
- value: true
126
- });
127
- exports.convertToGaugeProperties = exports.mapValueLabelDisplay = exports.mapToOldKey = exports.getGradientDimensions = exports.getGradientStops = exports.getGradientStopColors = exports.getGradientStopOffsets = exports.getGaugeRange = exports.validateRanges = exports.getSortedRanges = exports.getMarkerGaugeValueMarkerPositions = exports.getMarkerBarDimensions = exports.getFillerGaugeValueMarkerPositions = exports.getFillBarDimensions = exports.getGaugeBarHeight = exports.getGaugeBarWidth = exports.getGaugeBarStartPositions = exports.getGaugeBarLength = exports.assignGaugeColor = exports.getGaugeDimensions = exports.getGaugeStartPosition = exports.getGaugeLength = exports.getGaugeHeight = exports.getGaugeWidth = exports.FILL_THICKNESS = exports.GAUGE_THICKNESS = void 0;
128
-
129
- var lodash_1 = __webpack_require__(3);
130
-
131
- var colorConstants_1 = __webpack_require__(99);
132
-
133
- var i18n_1 = __webpack_require__(5);
134
-
135
- exports.GAUGE_THICKNESS = 50;
136
- exports.FILL_THICKNESS = 38;
137
- var GRADIENT_STOP_OFFSET_MIN = 0;
138
- var GRADIENT_STOP_OFFSET_MAX = 100;
139
- /**
140
- * get width for the whole gauge viz for horizontal or vertical view
141
- * @method getGaugeWidth
142
- * @param {Object} input
143
- * @param {Number} containerWidth
144
- * @param {String} orientation
145
- * @return {Number} width
146
- */
147
-
148
- var getGaugeWidth = function getGaugeWidth(_ref) {
149
- var containerWidth = _ref.containerWidth,
150
- orientation = _ref.orientation;
151
- return orientation === 'vertical' ? exports.GAUGE_THICKNESS : containerWidth * 0.8;
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 __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
152
23
  };
153
-
154
- exports.getGaugeWidth = getGaugeWidth;
155
- /**
156
- * get height for the whole gauge viz for horizontal or vertical view
157
- * @method getGaugeHeight
158
- * @param {Object} input
159
- * @param {Number} containerHeight
160
- * @param {String} orientation
161
- * @return {Number} height
162
- */
163
-
164
- var getGaugeHeight = function getGaugeHeight(_ref2) {
165
- var containerHeight = _ref2.containerHeight,
166
- orientation = _ref2.orientation;
167
- return orientation === 'vertical' ? containerHeight * 0.8 : exports.GAUGE_THICKNESS;
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
168
27
  };
169
-
170
- exports.getGaugeHeight = getGaugeHeight;
171
- /**
172
- * get how long the gauge shoud be.
173
- * In horizontal view, gauge length equals to gauge width. In vertical view, it equals to gauge height.
174
- * @method getGaugeLength
175
- * @param {Object} input
176
- * @param {Number} input.containerWidth
177
- * @param {Number} input.containerHeight
178
- * @param {String} input.orientation
179
- * @return {Number} gaugeLength
180
- */
181
-
182
- var getGaugeLength = function getGaugeLength(_ref3) {
183
- var containerWidth = _ref3.containerWidth,
184
- containerHeight = _ref3.containerHeight,
185
- orientation = _ref3.orientation;
186
- return orientation === 'vertical' ? (0, exports.getGaugeHeight)({
187
- containerHeight: containerHeight,
188
- orientation: orientation
189
- }) : (0, exports.getGaugeWidth)({
190
- containerWidth: containerWidth,
191
- orientation: orientation
192
- });
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
193
35
  };
36
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // src/common/gaugeUtils.ts
48
+ var gaugeUtils_exports = {};
49
+ __export(gaugeUtils_exports, {
50
+ FILL_THICKNESS: () => FILL_THICKNESS,
51
+ GAUGE_THICKNESS: () => GAUGE_THICKNESS,
52
+ assignGaugeColor: () => assignGaugeColor,
53
+ convertToGaugeProperties: () => convertToGaugeProperties,
54
+ getFillBarDimensions: () => getFillBarDimensions,
55
+ getFillerGaugeValueMarkerPositions: () => getFillerGaugeValueMarkerPositions,
56
+ getGaugeBarHeight: () => getGaugeBarHeight,
57
+ getGaugeBarLength: () => getGaugeBarLength,
58
+ getGaugeBarStartPositions: () => getGaugeBarStartPositions,
59
+ getGaugeBarWidth: () => getGaugeBarWidth,
60
+ getGaugeDimensions: () => getGaugeDimensions,
61
+ getGaugeHeight: () => getGaugeHeight,
62
+ getGaugeLength: () => getGaugeLength,
63
+ getGaugeRange: () => getGaugeRange,
64
+ getGaugeStartPosition: () => getGaugeStartPosition,
65
+ getGaugeWidth: () => getGaugeWidth,
66
+ getGradientDimensions: () => getGradientDimensions,
67
+ getGradientStopColors: () => getGradientStopColors,
68
+ getGradientStopOffsets: () => getGradientStopOffsets,
69
+ getGradientStops: () => getGradientStops,
70
+ getMarkerBarDimensions: () => getMarkerBarDimensions,
71
+ getMarkerGaugeValueMarkerPositions: () => getMarkerGaugeValueMarkerPositions,
72
+ getSortedRanges: () => getSortedRanges,
73
+ mapToOldKey: () => mapToOldKey,
74
+ mapValueLabelDisplay: () => mapValueLabelDisplay,
75
+ validateRanges: () => validateRanges
76
+ });
77
+ module.exports = __toCommonJS(gaugeUtils_exports);
194
78
 
195
- exports.getGaugeLength = getGaugeLength;
196
- /**
197
- * get start x and y for rendering gauge
198
- * @method getGaugeStartPosition
199
- * @param {Object} input
200
- * @param {Number} containerWidth
201
- * @param {Number} containerHeight
202
- * @param {Number} gaugeLength
203
- * @param {String} orientation
204
- * @return {Object} position
205
- * @return {Number} position.gaugeStartX
206
- * @return {Number} position.gaugeStartY
207
- */
208
-
209
- var getGaugeStartPosition = function getGaugeStartPosition(_ref4) {
210
- var containerWidth = _ref4.containerWidth,
211
- containerHeight = _ref4.containerHeight,
212
- gaugeLength = _ref4.gaugeLength,
213
- orientation = _ref4.orientation;
214
- // for horizontal view
215
- var gaugeStartX = (containerWidth - gaugeLength) / 2.0;
216
- var gaugeStartY = (containerHeight - exports.GAUGE_THICKNESS) / 2.0;
79
+ // esm-externals:lodash
80
+ var lodash_exports = {};
81
+ __export(lodash_exports, {
82
+ default: () => lodash_default
83
+ });
84
+ var defaultImport = __toESM(require("lodash"));
85
+ __reExport(lodash_exports, require("lodash"));
86
+ var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
87
+
88
+ // esm-externals:@splunk/visualizations-shared/colorConstants
89
+ var colorConstants_exports = {};
90
+ __export(colorConstants_exports, {
91
+ default: () => colorConstants_default
92
+ });
93
+ var defaultImport2 = __toESM(require("@splunk/visualizations-shared/colorConstants"));
94
+ __reExport(colorConstants_exports, require("@splunk/visualizations-shared/colorConstants"));
95
+ var colorConstants_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
96
+
97
+ // esm-externals:@splunk/ui-utils/i18n
98
+ var i18n_exports = {};
99
+ __export(i18n_exports, {
100
+ default: () => i18n_default
101
+ });
102
+ var defaultImport3 = __toESM(require("@splunk/ui-utils/i18n"));
103
+ __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
104
+ var i18n_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
217
105
 
218
- if (orientation === 'vertical') {
219
- gaugeStartX = (containerWidth - exports.GAUGE_THICKNESS) / 2.0;
220
- gaugeStartY = (containerHeight - gaugeLength) / 2.0;
106
+ // src/common/gaugeUtils.ts
107
+ var GAUGE_THICKNESS = 50;
108
+ var FILL_THICKNESS = 38;
109
+ var GRADIENT_STOP_OFFSET_MIN = 0;
110
+ var GRADIENT_STOP_OFFSET_MAX = 100;
111
+ var getGaugeWidth = ({ containerWidth, orientation }) => orientation === "vertical" ? GAUGE_THICKNESS : containerWidth * 0.8;
112
+ var getGaugeHeight = ({ containerHeight, orientation }) => orientation === "vertical" ? containerHeight * 0.8 : GAUGE_THICKNESS;
113
+ var getGaugeLength = ({ containerWidth, containerHeight, orientation }) => orientation === "vertical" ? getGaugeHeight({ containerHeight, orientation }) : getGaugeWidth({ containerWidth, orientation });
114
+ var getGaugeStartPosition = ({ containerWidth, containerHeight, gaugeLength, orientation }) => {
115
+ let gaugeStartX = (containerWidth - gaugeLength) / 2;
116
+ let gaugeStartY = (containerHeight - GAUGE_THICKNESS) / 2;
117
+ if (orientation === "vertical") {
118
+ gaugeStartX = (containerWidth - GAUGE_THICKNESS) / 2;
119
+ gaugeStartY = (containerHeight - gaugeLength) / 2;
221
120
  }
222
-
223
- return {
224
- gaugeStartX: gaugeStartX,
225
- gaugeStartY: gaugeStartY
226
- };
121
+ return { gaugeStartX, gaugeStartY };
227
122
  };
228
-
229
- exports.getGaugeStartPosition = getGaugeStartPosition;
230
- /**
231
- * get dimensions for the whole gauge viz,
232
- * which can be useful to calculate background bar and major ticks positions.
233
- * @method getGaugeDimensions
234
- * @param {Object} input
235
- * @param {Number} input.containerWidth
236
- * @param {Number} input.containerHeight
237
- * @param {String} input.orientation 'horizontal' or 'vertical'
238
- * @return {Object} gaugeDimensions
239
- * @return {Number} gaugeDimensions.gaugeLength how long the gauge shoud be in horizontal or vertical orientation.
240
- * @return {Number} gaugeDimensions.gaugeStartX start x to render gauge
241
- * @return {Number} gaugeDimensions.gaugeStartY start y to render gauge
242
- * @return {Number} gaugeDimensions.gaugeWidth natural width of gauge
243
- * @return {Number} gaugeDimensions.gaugeHeight natural height of gauge
244
- */
245
-
246
- var getGaugeDimensions = function getGaugeDimensions(_ref5) {
247
- var containerWidth = _ref5.containerWidth,
248
- containerHeight = _ref5.containerHeight,
249
- orientation = _ref5.orientation;
250
- var gaugeLength = (0, exports.getGaugeLength)({
251
- containerWidth: containerWidth,
252
- containerHeight: containerHeight,
253
- orientation: orientation
254
- });
255
-
256
- var _ref6 = (0, exports.getGaugeStartPosition)({
257
- containerWidth: containerWidth,
258
- containerHeight: containerHeight,
259
- gaugeLength: gaugeLength,
260
- orientation: orientation
261
- }),
262
- gaugeStartX = _ref6.gaugeStartX,
263
- gaugeStartY = _ref6.gaugeStartY;
264
-
265
- var gaugeWidth = (0, exports.getGaugeWidth)({
266
- containerWidth: containerWidth,
267
- orientation: orientation
268
- });
269
- var gaugeHeight = (0, exports.getGaugeHeight)({
270
- containerHeight: containerHeight,
271
- orientation: orientation
123
+ var getGaugeDimensions = ({ containerWidth, containerHeight, orientation }) => {
124
+ const gaugeLength = getGaugeLength({ containerWidth, containerHeight, orientation });
125
+ const { gaugeStartX, gaugeStartY } = getGaugeStartPosition({
126
+ containerWidth,
127
+ containerHeight,
128
+ gaugeLength,
129
+ orientation
272
130
  });
131
+ const gaugeWidth = getGaugeWidth({ containerWidth, orientation });
132
+ const gaugeHeight = getGaugeHeight({ containerHeight, orientation });
273
133
  return {
274
- gaugeLength: gaugeLength,
275
- gaugeStartX: gaugeStartX,
276
- gaugeStartY: gaugeStartY,
277
- gaugeWidth: gaugeWidth,
278
- gaugeHeight: gaugeHeight
134
+ gaugeLength,
135
+ gaugeStartX,
136
+ gaugeStartY,
137
+ gaugeWidth,
138
+ gaugeHeight
279
139
  };
280
140
  };
281
-
282
- exports.getGaugeDimensions = getGaugeDimensions;
283
- /**
284
- * if gaugeColor is not specified, auto assign a gauge color to the fill bar
285
- * based on how much percentage the value is taken between min and max
286
- * @method assignGaugeColor
287
- * @params
288
- * */
289
-
290
- var assignGaugeColor = function assignGaugeColor(_ref7) {
291
- var value = _ref7.value,
292
- min = _ref7.min,
293
- max = _ref7.max;
294
- var rate = (value - min) / (max - min);
295
-
141
+ var assignGaugeColor = ({ value, min, max }) => {
142
+ const rate = (value - min) / (max - min);
296
143
  if (rate <= 0.3) {
297
- return colorConstants_1.SEMANTIC_SUCCESS;
144
+ return colorConstants_exports.SEMANTIC_SUCCESS;
298
145
  }
299
-
300
146
  if (rate > 0.3 && rate <= 0.6) {
301
- return colorConstants_1.SEMANTIC_WARNING;
147
+ return colorConstants_exports.SEMANTIC_WARNING;
302
148
  }
303
-
304
- return colorConstants_1.SEMANTIC_ERROR;
149
+ return colorConstants_exports.SEMANTIC_ERROR;
305
150
  };
306
-
307
- exports.assignGaugeColor = assignGaugeColor;
308
- /**
309
- * get inner bar length in gauge
310
- * @method getGaugeBarLength
311
- * @param {Object} input
312
- * @param {Number} input.gaugeLength
313
- * @param {Number} input.value
314
- * @param {Number} input.min
315
- * @param {Number} input.max
316
- * @return {Number} gaugeBarLength
317
- */
318
-
319
- var getGaugeBarLength = function getGaugeBarLength(_ref8) {
320
- var gaugeLength = _ref8.gaugeLength,
321
- value = _ref8.value,
322
- min = _ref8.min,
323
- max = _ref8.max;
324
-
151
+ var getGaugeBarLength = ({ gaugeLength, value, min, max }) => {
325
152
  if (max < min) {
326
153
  return null;
327
154
  }
328
-
329
155
  if (value >= max) {
330
156
  return gaugeLength;
331
157
  }
332
-
333
158
  if (value < min) {
334
159
  return 0;
335
160
  }
336
-
337
161
  return gaugeLength * (value - min) / (max - min);
338
162
  };
339
-
340
- exports.getGaugeBarLength = getGaugeBarLength;
341
- /**
342
- * get x and y position for rendering inner bar in gauge
343
- * @method getGaugeBarStartPositions
344
- * @param {Object} input
345
- * @param {Number} input.gaugeStartX
346
- * @param {Number} input.gaugeStartY
347
- * @param {Number} input.gaugeWidth
348
- * @param {Number} input.gaugeHeight
349
- * @param {Number} input.gaugeBarLength
350
- * @param {String} input.orientation
351
- * @return {Object} position
352
- * @return {Number} position.gaugeBarX
353
- * @return {Number} position.gaugeBarY
354
- */
355
-
356
- var getGaugeBarStartPositions = function getGaugeBarStartPositions(_ref9) {
357
- var gaugeStartX = _ref9.gaugeStartX,
358
- gaugeStartY = _ref9.gaugeStartY,
359
- gaugeWidth = _ref9.gaugeWidth,
360
- gaugeHeight = _ref9.gaugeHeight,
361
- gaugeBarLength = _ref9.gaugeBarLength,
362
- orientation = _ref9.orientation;
363
- var gaugeBarX = gaugeStartX;
364
- var gaugeBarY = gaugeStartY;
365
-
366
- if (orientation === 'vertical') {
367
- gaugeBarX += (gaugeWidth - exports.FILL_THICKNESS) / 2;
163
+ var getGaugeBarStartPositions = ({
164
+ gaugeStartX,
165
+ gaugeStartY,
166
+ gaugeWidth,
167
+ gaugeHeight,
168
+ gaugeBarLength,
169
+ orientation
170
+ }) => {
171
+ let gaugeBarX = gaugeStartX;
172
+ let gaugeBarY = gaugeStartY;
173
+ if (orientation === "vertical") {
174
+ gaugeBarX += (gaugeWidth - FILL_THICKNESS) / 2;
368
175
  gaugeBarY += gaugeHeight - gaugeBarLength;
369
176
  } else {
370
- gaugeBarY += (gaugeHeight - exports.FILL_THICKNESS) / 2;
177
+ gaugeBarY += (gaugeHeight - FILL_THICKNESS) / 2;
371
178
  }
372
-
373
179
  return {
374
- gaugeBarX: gaugeBarX,
375
- gaugeBarY: gaugeBarY
180
+ gaugeBarX,
181
+ gaugeBarY
376
182
  };
377
183
  };
378
-
379
- exports.getGaugeBarStartPositions = getGaugeBarStartPositions;
380
- /**
381
- * get width of inner bar in gauge
382
- * @method getGaugeBarWidth
383
- * @param {Object} input
384
- * @param {Number} input.gaugeBarLength
385
- * @param {String} orientation
386
- * @return {Number} gaugeBarWidth
387
- */
388
-
389
- var getGaugeBarWidth = function getGaugeBarWidth(_ref10) {
390
- var gaugeBarLength = _ref10.gaugeBarLength,
391
- orientation = _ref10.orientation;
392
- return orientation === 'vertical' ? exports.FILL_THICKNESS : gaugeBarLength;
393
- };
394
-
395
- exports.getGaugeBarWidth = getGaugeBarWidth;
396
- /**
397
- * get height of inner bar in gauge
398
- * @method getGaugeBarWidth
399
- * @param {Object} input
400
- * @param {Number} input.gaugeBarLength
401
- * @param {String} orientation
402
- * @return {Number} gaugeBarHeight
403
- */
404
-
405
- var getGaugeBarHeight = function getGaugeBarHeight(_ref11) {
406
- var gaugeBarLength = _ref11.gaugeBarLength,
407
- orientation = _ref11.orientation;
408
- return orientation === 'vertical' ? gaugeBarLength : exports.FILL_THICKNESS;
409
- };
410
-
411
- exports.getGaugeBarHeight = getGaugeBarHeight;
412
- /**
413
- * get dimensions for the fill bar in the gauge
414
- * @method getFillBarDimensions
415
- * @param {Object} input
416
- * @param {Number} input.gaugeLength
417
- * @param {Number} input.gaugeStartX
418
- * @param {Number} input.gaugeStartY
419
- * @param {Number} input.gaugeWidth,
420
- * @param {Number} input.gaugeHeight,
421
- * @param {Number} input.value,
422
- * @param {Number} input.min,
423
- * @param {Number} input.max,
424
- * @param {String} input.orientation
425
- * @return {Object} fillBarDimensions
426
- * @return {Number} fillBarDimensions.fillBarLength
427
- * @return {Number} fillBarDimensions.fillBarX
428
- * @return {Number} fillBarDimensions.fillBarY
429
- * @return {Number} fillBarDimensions.fillBarWidth
430
- * @return {Number} fillBarDimensions.fillBarHeight
431
- */
432
-
433
- var getFillBarDimensions = function getFillBarDimensions(_ref12) {
434
- var gaugeLength = _ref12.gaugeLength,
435
- gaugeStartX = _ref12.gaugeStartX,
436
- gaugeStartY = _ref12.gaugeStartY,
437
- gaugeWidth = _ref12.gaugeWidth,
438
- gaugeHeight = _ref12.gaugeHeight,
439
- value = _ref12.value,
440
- min = _ref12.min,
441
- max = _ref12.max,
442
- orientation = _ref12.orientation;
443
- var gaugeBarLength = (0, exports.getGaugeBarLength)({
444
- gaugeLength: gaugeLength,
445
- value: value,
446
- max: max,
447
- min: min
448
- });
449
-
450
- var _ref13 = (0, exports.getGaugeBarStartPositions)({
451
- gaugeStartX: gaugeStartX,
452
- gaugeStartY: gaugeStartY,
453
- gaugeWidth: gaugeWidth,
454
- gaugeHeight: gaugeHeight,
455
- gaugeBarLength: gaugeBarLength,
456
- orientation: orientation
457
- }),
458
- fillBarX = _ref13.gaugeBarX,
459
- fillBarY = _ref13.gaugeBarY;
460
-
461
- var fillBarWidth = (0, exports.getGaugeBarWidth)({
462
- gaugeBarLength: gaugeBarLength,
463
- orientation: orientation
464
- });
465
- var fillBarHeight = (0, exports.getGaugeBarHeight)({
466
- gaugeBarLength: gaugeBarLength,
467
- orientation: orientation
184
+ var getGaugeBarWidth = ({ gaugeBarLength, orientation }) => orientation === "vertical" ? FILL_THICKNESS : gaugeBarLength;
185
+ var getGaugeBarHeight = ({ gaugeBarLength, orientation }) => orientation === "vertical" ? gaugeBarLength : FILL_THICKNESS;
186
+ var getFillBarDimensions = ({
187
+ gaugeLength,
188
+ gaugeStartX,
189
+ gaugeStartY,
190
+ gaugeWidth,
191
+ gaugeHeight,
192
+ value,
193
+ min,
194
+ max,
195
+ orientation
196
+ }) => {
197
+ const gaugeBarLength = getGaugeBarLength({ gaugeLength, value, max, min });
198
+ const { gaugeBarX: fillBarX, gaugeBarY: fillBarY } = getGaugeBarStartPositions({
199
+ gaugeStartX,
200
+ gaugeStartY,
201
+ gaugeWidth,
202
+ gaugeHeight,
203
+ gaugeBarLength,
204
+ orientation
468
205
  });
206
+ const fillBarWidth = getGaugeBarWidth({ gaugeBarLength, orientation });
207
+ const fillBarHeight = getGaugeBarHeight({ gaugeBarLength, orientation });
469
208
  return {
470
209
  fillBarLength: gaugeBarLength,
471
- fillBarX: fillBarX,
472
- fillBarY: fillBarY,
473
- fillBarWidth: fillBarWidth,
474
- fillBarHeight: fillBarHeight
210
+ fillBarX,
211
+ fillBarY,
212
+ fillBarWidth,
213
+ fillBarHeight
475
214
  };
476
215
  };
477
-
478
- exports.getFillBarDimensions = getFillBarDimensions;
479
- /**
480
- * get position x and y for value marker in filler gauge
481
- * @method getFillerGaugeValueMarkerPositions
482
- * @param {Object} input
483
- * @param {Number} input.fillBarX
484
- * @param {Number} input.fillBarY
485
- * @param {Number} input.fillBarLength
486
- * @param {String} input.orientation
487
- * @return {Object} position
488
- * @return {Number} position.valueMarkerX
489
- * @return {Number} position.valueMarkerY
490
- */
491
-
492
- var getFillerGaugeValueMarkerPositions = function getFillerGaugeValueMarkerPositions(_ref14) {
493
- var fillBarX = _ref14.fillBarX,
494
- fillBarY = _ref14.fillBarY,
495
- fillBarLength = _ref14.fillBarLength,
496
- orientation = _ref14.orientation;
497
- var valueMarkerX = fillBarX;
498
- var valueMarkerY = fillBarY;
499
-
500
- if (orientation === 'vertical') {
501
- valueMarkerX -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
216
+ var getFillerGaugeValueMarkerPositions = ({ fillBarX, fillBarY, fillBarLength, orientation }) => {
217
+ let valueMarkerX = fillBarX;
218
+ let valueMarkerY = fillBarY;
219
+ if (orientation === "vertical") {
220
+ valueMarkerX -= (GAUGE_THICKNESS - FILL_THICKNESS) / 4;
502
221
  } else {
503
222
  valueMarkerX += fillBarLength;
504
- valueMarkerY -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
223
+ valueMarkerY -= (GAUGE_THICKNESS - FILL_THICKNESS) / 4;
505
224
  }
506
-
507
225
  return {
508
- valueMarkerX: valueMarkerX,
509
- valueMarkerY: valueMarkerY
226
+ valueMarkerX,
227
+ valueMarkerY
510
228
  };
511
229
  };
512
-
513
- exports.getFillerGaugeValueMarkerPositions = getFillerGaugeValueMarkerPositions;
514
- /**
515
- * get dimensions for the marker bar in the gauge
516
- * @method getMarkerBarDimensions
517
- * @param {Object} input
518
- * @param {Number} input.gaugeLength
519
- * @param {Number} input.gaugeStartX
520
- * @param {Number} input.gaugeStartY
521
- * @param {Number} input.gaugeWidth,
522
- * @param {Number} input.gaugeHeight,
523
- * @param {String} input.orientation
524
- * @return {Object} markerBarDimensions
525
- * @return {Number} markerBarDimensions.markerBarLength
526
- * @return {Number} markerBarDimensions.markerBarX
527
- * @return {Number} markerBarDimensions.markerBarY
528
- * @return {Number} markerBarDimensions.markerBarWidth
529
- * @return {Number} markerBarDimensions.markerBarHeight
530
- */
531
-
532
- var getMarkerBarDimensions = function getMarkerBarDimensions(_ref15) {
533
- var gaugeLength = _ref15.gaugeLength,
534
- gaugeStartX = _ref15.gaugeStartX,
535
- gaugeStartY = _ref15.gaugeStartY,
536
- gaugeWidth = _ref15.gaugeWidth,
537
- gaugeHeight = _ref15.gaugeHeight,
538
- orientation = _ref15.orientation;
539
- var gaugeBarLength = gaugeLength; // For marker gauge, inner marker bar spans the entire gauge
540
-
541
- var _ref16 = (0, exports.getGaugeBarStartPositions)({
542
- gaugeStartX: gaugeStartX,
543
- gaugeStartY: gaugeStartY,
544
- gaugeWidth: gaugeWidth,
545
- gaugeHeight: gaugeHeight,
546
- gaugeBarLength: gaugeBarLength,
547
- orientation: orientation
548
- }),
549
- markerBarX = _ref16.gaugeBarX,
550
- markerBarY = _ref16.gaugeBarY;
551
-
552
- var markerBarWidth = (0, exports.getGaugeBarWidth)({
553
- gaugeBarLength: gaugeBarLength,
554
- orientation: orientation
555
- });
556
- var markerBarHeight = (0, exports.getGaugeBarHeight)({
557
- gaugeBarLength: gaugeBarLength,
558
- orientation: orientation
230
+ var getMarkerBarDimensions = ({
231
+ gaugeLength,
232
+ gaugeStartX,
233
+ gaugeStartY,
234
+ gaugeWidth,
235
+ gaugeHeight,
236
+ orientation
237
+ }) => {
238
+ const gaugeBarLength = gaugeLength;
239
+ const { gaugeBarX: markerBarX, gaugeBarY: markerBarY } = getGaugeBarStartPositions({
240
+ gaugeStartX,
241
+ gaugeStartY,
242
+ gaugeWidth,
243
+ gaugeHeight,
244
+ gaugeBarLength,
245
+ orientation
559
246
  });
247
+ const markerBarWidth = getGaugeBarWidth({ gaugeBarLength, orientation });
248
+ const markerBarHeight = getGaugeBarHeight({ gaugeBarLength, orientation });
560
249
  return {
561
250
  markerBarLength: gaugeBarLength,
562
- markerBarX: markerBarX,
563
- markerBarY: markerBarY,
564
- markerBarWidth: markerBarWidth,
565
- markerBarHeight: markerBarHeight
251
+ markerBarX,
252
+ markerBarY,
253
+ markerBarWidth,
254
+ markerBarHeight
566
255
  };
567
256
  };
568
-
569
- exports.getMarkerBarDimensions = getMarkerBarDimensions;
570
- /**
571
- * get position x and y for value marker in marker gauge
572
- * @method getMarkerGaugeValueMarkerPositions
573
- * @param {Object} input
574
- * @param {Number} input.markerBarX
575
- * @param {Number} input.markerBarY
576
- * @param {Number} input.markerBarHeight
577
- * @param {Number} input.markerBarLength
578
- * @param {Number} input.value
579
- * @param {Number} input.min
580
- * @param {Number} input.max
581
- * @param {String} input.orientation
582
- * @return {Object} position
583
- * @return {Number} position.valueMarkerX
584
- * @return {Number} position.valueMarkerY
585
- */
586
-
587
- var getMarkerGaugeValueMarkerPositions = function getMarkerGaugeValueMarkerPositions(_ref17) {
588
- var markerBarX = _ref17.markerBarX,
589
- markerBarY = _ref17.markerBarY,
590
- markerBarHeight = _ref17.markerBarHeight,
591
- gaugeLength = _ref17.markerBarLength,
592
- orientation = _ref17.orientation,
593
- value = _ref17.value,
594
- min = _ref17.min,
595
- max = _ref17.max;
596
- var valueMarkerX = markerBarX;
597
- var valueMarkerY = markerBarY;
598
-
599
- if (orientation === 'vertical') {
600
- valueMarkerY += markerBarHeight - (0, exports.getGaugeBarLength)({
601
- gaugeLength: gaugeLength,
602
- value: value,
603
- max: max,
604
- min: min
605
- });
606
- valueMarkerX -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
257
+ var getMarkerGaugeValueMarkerPositions = ({
258
+ markerBarX,
259
+ markerBarY,
260
+ markerBarHeight,
261
+ markerBarLength: gaugeLength,
262
+ orientation,
263
+ value,
264
+ min,
265
+ max
266
+ }) => {
267
+ let valueMarkerX = markerBarX;
268
+ let valueMarkerY = markerBarY;
269
+ if (orientation === "vertical") {
270
+ valueMarkerY += markerBarHeight - getGaugeBarLength({ gaugeLength, value, max, min });
271
+ valueMarkerX -= (GAUGE_THICKNESS - FILL_THICKNESS) / 4;
607
272
  } else {
608
- valueMarkerX += (0, exports.getGaugeBarLength)({
609
- gaugeLength: gaugeLength,
610
- value: value,
611
- max: max,
612
- min: min
613
- });
614
- valueMarkerY -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
273
+ valueMarkerX += getGaugeBarLength({ gaugeLength, value, max, min });
274
+ valueMarkerY -= (GAUGE_THICKNESS - FILL_THICKNESS) / 4;
615
275
  }
616
-
617
276
  return {
618
- valueMarkerX: valueMarkerX,
619
- valueMarkerY: valueMarkerY
277
+ valueMarkerX,
278
+ valueMarkerY
620
279
  };
621
280
  };
622
-
623
- exports.getMarkerGaugeValueMarkerPositions = getMarkerGaugeValueMarkerPositions;
624
- /**
625
- * sort the ranges in ascending order
626
- * @method getSortedRanges
627
- * @param {Array} ranges
628
- * @return {Array} sortedRanges
629
- */
630
-
631
- var getSortedRanges = function getSortedRanges(ranges) {
632
- return ranges.sort(function (a, b) {
633
- return a.from - b.from;
634
- });
635
- };
636
-
637
- exports.getSortedRanges = getSortedRanges;
638
- /**
639
- * validate whether ranges prop is valid - continuous ranges, range.to < range.from, range.from != range.to
640
- * @method validateRanges
641
- * @param {Array} ranges
642
- * @return {String} error
643
- */
644
-
645
- var validateRanges = function validateRanges(ranges) {
281
+ var getSortedRanges = (ranges) => ranges.sort((a, b) => a.from - b.from);
282
+ var validateRanges = (ranges) => {
646
283
  if (!ranges.length) {
647
- return (0, i18n_1._)('Prop "ranges" is missing entries');
648
- } // check whether a range has "from" >= "to" eg: 10 - 10, 100 - 10, -20 - -10 are invalid
649
-
650
-
651
- if (ranges.some(function (range) {
652
- return range.from >= range.to;
653
- })) {
654
- return (0, i18n_1._)('Prop "ranges" has invalid entries: invalid range');
655
- } // check whether ranges have duplicate "from/to" eg: 0 - 50, 25 - 50
656
-
657
-
658
- if (ranges.length !== (0, lodash_1.uniqBy)(ranges, 'to').length || ranges.length !== (0, lodash_1.uniqBy)(ranges, 'from').length) {
659
- return (0, i18n_1._)('Prop "ranges" has invalid entries: duplicate values');
284
+ return (0, i18n_exports._)('Prop "ranges" is missing entries');
660
285
  }
661
-
662
- var sortedRanges = (0, exports.getSortedRanges)(ranges); // check whether ranges are continuous eg: 0 - 10, 10 - 20, 20 - 30
663
-
664
- for (var i = 1; i < sortedRanges.length; i += 1) {
286
+ if (ranges.some((range) => range.from >= range.to)) {
287
+ return (0, i18n_exports._)('Prop "ranges" has invalid entries: invalid range');
288
+ }
289
+ if (ranges.length !== (0, lodash_exports.uniqBy)(ranges, "to").length || ranges.length !== (0, lodash_exports.uniqBy)(ranges, "from").length) {
290
+ return (0, i18n_exports._)('Prop "ranges" has invalid entries: duplicate values');
291
+ }
292
+ const sortedRanges = getSortedRanges(ranges);
293
+ for (let i = 1; i < sortedRanges.length; i += 1) {
665
294
  if (sortedRanges[i].from !== sortedRanges[i - 1].to) {
666
- return (0, i18n_1._)('Prop "ranges" has invalid entries: discontinuous ranges');
295
+ return (0, i18n_exports._)('Prop "ranges" has invalid entries: discontinuous ranges');
667
296
  }
668
297
  }
669
-
670
298
  return null;
671
299
  };
672
-
673
- exports.validateRanges = validateRanges;
674
- /**
675
- * calculate min and max value of gauge
676
- * @method getGaugeRange
677
- * @param {Array} ranges
678
- * @return {Object} gaugeRange
679
- * @return {Number} gaugeRange.min
680
- * @return {Number} gaugeRange.max
681
- */
682
-
683
- var getGaugeRange = function getGaugeRange(ranges) {
684
- var min = Math.min.apply(Math, _toConsumableArray(ranges.map(function (range) {
685
- return range.from;
686
- })));
687
- var max = Math.max.apply(Math, _toConsumableArray(ranges.map(function (range) {
688
- return range.to;
689
- })));
690
- return {
691
- min: min,
692
- max: max
693
- };
300
+ var getGaugeRange = (ranges) => {
301
+ const min = Math.min(...ranges.map((range) => range.from));
302
+ const max = Math.max(...ranges.map((range) => range.to));
303
+ return { min, max };
694
304
  };
695
-
696
- exports.getGaugeRange = getGaugeRange;
697
- /**
698
- * calculate stop offsets for linear gradient
699
- * @method getGradientStopOffsets
700
- * @param {Array} ranges
701
- * @param {String} orientation
702
- * @return {Array} cumulativeOffsets
703
- */
704
-
705
- var getGradientStopOffsets = function getGradientStopOffsets(_ref18) {
706
- var ranges = _ref18.ranges,
707
- orientation = _ref18.orientation;
708
-
709
- var _ref19 = (0, exports.getGaugeRange)(ranges),
710
- min = _ref19.min,
711
- max = _ref19.max;
712
-
713
- var offsetScale = (GRADIENT_STOP_OFFSET_MAX - GRADIENT_STOP_OFFSET_MIN) / (max - min);
714
- var offsets = ranges.map(function (range) {
715
- return Math.abs(range.from - range.to) * offsetScale;
716
- }); // When orientation is vertical, since the gauge starts from bottom to top, linear gradient should be reversed
717
-
718
- offsets = orientation === 'vertical' ? offsets.reverse() : offsets;
719
- var cumulativeOffsets = [];
720
- offsets.reduce(function (accumulator, currentValue, idx) {
305
+ var getGradientStopOffsets = ({ ranges, orientation }) => {
306
+ const { min, max } = getGaugeRange(ranges);
307
+ const offsetScale = (GRADIENT_STOP_OFFSET_MAX - GRADIENT_STOP_OFFSET_MIN) / (max - min);
308
+ let offsets = ranges.map((range) => Math.abs(range.from - range.to) * offsetScale);
309
+ offsets = orientation === "vertical" ? offsets.reverse() : offsets;
310
+ const cumulativeOffsets = [];
311
+ offsets.reduce((accumulator, currentValue, idx) => {
721
312
  cumulativeOffsets[idx] = accumulator + currentValue;
722
313
  return cumulativeOffsets[idx];
723
314
  }, 0);
724
315
  return cumulativeOffsets;
725
316
  };
726
-
727
- exports.getGradientStopOffsets = getGradientStopOffsets;
728
- /**
729
- * calculate stop colors for linear gradient
730
- * @method getGradientStopColors
731
- * @param {Array} ranges
732
- * @param {String} orientation
733
- * @return {Array} stopColors
734
- */
735
-
736
- var getGradientStopColors = function getGradientStopColors(_ref20) {
737
- var ranges = _ref20.ranges,
738
- orientation = _ref20.orientation;
739
- var stopColors = ranges.map(function (range) {
740
- return range.value;
741
- }); // When orientation is vertical, since the gauge starts from bottom to top, linear gradient should be reversed
742
-
743
- return orientation === 'vertical' ? stopColors.reverse() : stopColors;
317
+ var getGradientStopColors = ({ ranges, orientation }) => {
318
+ const stopColors = ranges.map((range) => range.value);
319
+ return orientation === "vertical" ? stopColors.reverse() : stopColors;
744
320
  };
745
-
746
- exports.getGradientStopColors = getGradientStopColors;
747
- /**
748
- * calculate linear gradient stops from ranges
749
- * @method getGradientStops
750
- * @param {Object} input
751
- * @param {Array} ranges
752
- * @param {String} orientation
753
- * @return {Array} stops
754
- */
755
-
756
- var getGradientStops = function getGradientStops(_ref21) {
757
- var ranges = _ref21.ranges,
758
- orientation = _ref21.orientation;
759
- var stops = [];
760
- var offsets = (0, exports.getGradientStopOffsets)({
761
- ranges: ranges,
762
- orientation: orientation
763
- });
764
- var stopColors = (0, exports.getGradientStopColors)({
765
- ranges: ranges,
766
- orientation: orientation
767
- }); // Initialize stops with the first color stop
768
-
769
- stops.push({
770
- offset: "".concat(offsets[0], "%"),
771
- stopColor: stopColors[0]
772
- }); // Add the remaining color stops with gradient change at each stop
773
-
774
- for (var i = 1; i < ranges.length; i += 1) {
775
- stops.push({
776
- offset: "".concat(offsets[i - 1], "%"),
777
- stopColor: stopColors[i]
778
- });
779
- stops.push({
780
- offset: "".concat(offsets[i], "%"),
781
- stopColor: stopColors[i]
782
- });
321
+ var getGradientStops = ({ ranges, orientation }) => {
322
+ const stops = [];
323
+ const offsets = getGradientStopOffsets({ ranges, orientation });
324
+ const stopColors = getGradientStopColors({ ranges, orientation });
325
+ stops.push({ offset: `${offsets[0]}%`, stopColor: stopColors[0] });
326
+ for (let i = 1; i < ranges.length; i += 1) {
327
+ stops.push({ offset: `${offsets[i - 1]}%`, stopColor: stopColors[i] });
328
+ stops.push({ offset: `${offsets[i]}%`, stopColor: stopColors[i] });
783
329
  }
784
-
785
330
  return stops;
786
331
  };
787
-
788
- exports.getGradientStops = getGradientStops;
789
- /**
790
- * calculate linear gradient dimensions
791
- * @method getGradientDimensions
792
- * @param {String} orientation
793
- * @return {Object} dimensions
794
- * @return {String} dimensions.x1
795
- * @return {String} dimensions.y1
796
- * @return {String} dimensions.x2
797
- * @return {String} dimensions.y2
798
- */
799
-
800
- var getGradientDimensions = function getGradientDimensions(orientation) {
801
- var x1 = '0%';
802
- var y1 = '0%';
803
- var x2 = orientation === 'horizontal' ? '100%' : '0%';
804
- var y2 = orientation === 'horizontal' ? '0%' : '100%';
805
- return {
806
- x1: x1,
807
- y1: y1,
808
- x2: x2,
809
- y2: y2
810
- };
332
+ var getGradientDimensions = (orientation) => {
333
+ const x1 = "0%";
334
+ const y1 = "0%";
335
+ const x2 = orientation === "horizontal" ? "100%" : "0%";
336
+ const y2 = orientation === "horizontal" ? "0%" : "100%";
337
+ return { x1, y1, x2, y2 };
811
338
  };
812
-
813
- exports.getGradientDimensions = getGradientDimensions; // map for new options names to old option names
814
-
815
339
  var gaugeOptionsMapping = {
816
- majorTickInterval: 'majorUnit',
817
- gaugeRanges: 'ranges'
340
+ majorTickInterval: "majorUnit",
341
+ gaugeRanges: "ranges"
818
342
  };
819
- /**
820
- * Helper method to update the option names which can be mapped to pure component options
821
- * @method mapToOldKey
822
- * @param {Object} options
823
- * @returns {Object}
824
- */
825
-
826
- var mapToOldKey = function mapToOldKey(options) {
827
- return (0, lodash_1.mapKeys)(options, function (val, key) {
828
- return gaugeOptionsMapping[key] ? gaugeOptionsMapping[key] : key;
829
- });
830
- };
831
-
832
- exports.mapToOldKey = mapToOldKey;
833
- /**
834
- * Helper method to map labelDisplay and valueDisplay options to pure component option names
835
- * @method mapToOldKey
836
- * @param {string} labelOrValue
837
- * @param {Object} options
838
- * @returns {Object}
839
- */
840
-
841
- var mapValueLabelDisplay = function mapValueLabelDisplay(labelOrValue, options) {
842
- var rangeOrValue = labelOrValue === 'value' ? 'Value' : 'Range';
843
- var showKey = labelOrValue === 'value' ? 'showValue' : 'showLabels';
844
- var percentKey = "usePercentage".concat(rangeOrValue);
845
- var optionString = "".concat(labelOrValue, "Display");
846
- var newOptions = Object.assign({}, options);
847
-
343
+ var mapToOldKey = (options) => (0, lodash_exports.mapKeys)(options, (val, key) => gaugeOptionsMapping[key] ? gaugeOptionsMapping[key] : key);
344
+ var mapValueLabelDisplay = (labelOrValue, options) => {
345
+ const rangeOrValue = labelOrValue === "value" ? "Value" : "Range";
346
+ const showKey = labelOrValue === "value" ? "showValue" : "showLabels";
347
+ const percentKey = `usePercentage${rangeOrValue}`;
348
+ const optionString = `${labelOrValue}Display`;
349
+ const newOptions = __spreadValues({}, options);
848
350
  if (newOptions[optionString]) {
849
- if (newOptions[optionString] === 'number') {
351
+ if (newOptions[optionString] === "number") {
850
352
  newOptions[showKey] = true;
851
353
  newOptions[percentKey] = false;
852
- } else if (newOptions[optionString] === 'percentage') {
354
+ } else if (newOptions[optionString] === "percentage") {
853
355
  newOptions[showKey] = true;
854
356
  newOptions[percentKey] = true;
855
357
  } else {
@@ -857,37 +359,7 @@ var mapValueLabelDisplay = function mapValueLabelDisplay(labelOrValue, options)
857
359
  newOptions[percentKey] = false;
858
360
  }
859
361
  }
860
-
861
- return (0, lodash_1.omit)(newOptions, [optionString]);
362
+ return (0, lodash_exports.omit)(newOptions, [optionString]);
862
363
  };
863
-
864
- exports.mapValueLabelDisplay = mapValueLabelDisplay;
865
- /**
866
- * Chained helper for mapping the option properties (and values) we expose in config.ts into property values that pure component accepts
867
- * This is for options that has new key name and can not directly be mapped with pure component props
868
- * @method convertToGaugeProperties
869
- * @param {Object} originalOptions
870
- * @returns {Object}
871
- */
872
-
873
- var convertToGaugeProperties = function convertToGaugeProperties(originalOptions) {
874
- return (0, lodash_1.chain)((0, exports.mapToOldKey)(originalOptions)).thru(function (options) {
875
- return (0, exports.mapValueLabelDisplay)('label', options);
876
- }).thru(function (options) {
877
- return (0, exports.mapValueLabelDisplay)('value', options);
878
- }).value();
879
- };
880
-
881
- exports.convertToGaugeProperties = convertToGaugeProperties;
882
-
883
- /***/ }),
884
-
885
- /***/ 99:
886
- /***/ (function(module, exports) {
887
-
888
- module.exports = require("@splunk/visualizations-shared/colorConstants");
889
-
890
- /***/ })
891
-
892
- /******/ });
893
- //# sourceMappingURL=gaugeUtils.js.map
364
+ var convertToGaugeProperties = (originalOptions) => (0, lodash_exports.chain)(mapToOldKey(originalOptions)).thru((options) => mapValueLabelDisplay("label", options)).thru((options) => mapValueLabelDisplay("value", options)).value();
365
+ //# sourceMappingURL=gaugeUtils.js.map