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