@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
package/MarkerGauge.js ADDED
@@ -0,0 +1,3758 @@
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 = 188);
91
+ /******/ })
92
+ /************************************************************************/
93
+ /******/ ([
94
+ /* 0 */
95
+ /***/ (function(module, exports) {
96
+
97
+ module.exports = require("prop-types");
98
+
99
+ /***/ }),
100
+ /* 1 */
101
+ /***/ (function(module, exports) {
102
+
103
+ module.exports = require("react");
104
+
105
+ /***/ }),
106
+ /* 2 */
107
+ /***/ (function(module, exports) {
108
+
109
+ module.exports = require("lodash");
110
+
111
+ /***/ }),
112
+ /* 3 */
113
+ /***/ (function(module, exports) {
114
+
115
+ module.exports = require("@splunk/ui-utils/i18n");
116
+
117
+ /***/ }),
118
+ /* 4 */
119
+ /***/ (function(module, exports) {
120
+
121
+ module.exports = require("styled-components");
122
+
123
+ /***/ }),
124
+ /* 5 */
125
+ /***/ (function(module, exports, __webpack_require__) {
126
+
127
+ "use strict";
128
+
129
+
130
+ Object.defineProperty(exports, "__esModule", {
131
+ value: true
132
+ });
133
+ exports.VizBehavior = void 0;
134
+ var VizBehavior;
135
+
136
+ (function (VizBehavior) {
137
+ /**
138
+ * Dynamic Options Behavior.
139
+ * This allows visualization options to be powered by data
140
+ *
141
+ * **Example**
142
+ *
143
+ * sparklineValues: ">primary|seriesByIndex(0)"
144
+ * would configure sparklineValues with an array of data points
145
+ * coming from the first series in the primary datasource
146
+ *
147
+ */
148
+ VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
149
+ VizBehavior["EVENTS"] = "events";
150
+ /**
151
+ * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
152
+ * missing.
153
+ * @type {string}
154
+ */
155
+
156
+ VizBehavior["PLACEHOLDER"] = "placeholder";
157
+ VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
158
+ })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
159
+
160
+ /***/ }),
161
+ /* 6 */
162
+ /***/ (function(module, exports) {
163
+
164
+ module.exports = require("@babel/runtime/helpers/defineProperty");
165
+
166
+ /***/ }),
167
+ /* 7 */
168
+ /***/ (function(module, exports, __webpack_require__) {
169
+
170
+ "use strict";
171
+
172
+
173
+ var _typeof = __webpack_require__(22);
174
+
175
+ Object.defineProperty(exports, "__esModule", {
176
+ value: true
177
+ });
178
+ exports.deepMergeWithArrayOverrides = exports.extendStaticWrapperProps = void 0;
179
+
180
+ var lodash_1 = __webpack_require__(2);
181
+ /**
182
+ * @method extendStaticWrapperProps
183
+ * @param {Object} props
184
+ * @param {DashboardVizType} props.Wrapper
185
+ * @param {DashboardVizType} props.Visualization
186
+ */
187
+
188
+
189
+ var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
190
+ var Wrapper = _ref.Wrapper,
191
+ Visualization = _ref.Visualization;
192
+ var extendProperties = ['propTypes', 'defaultProps', 'config'];
193
+ extendProperties.forEach(function (prop) {
194
+ if (Visualization[prop]) {
195
+ Wrapper[prop] = Visualization[prop];
196
+ }
197
+ });
198
+ };
199
+
200
+ exports.extendStaticWrapperProps = extendStaticWrapperProps;
201
+ /**
202
+ * helper to deeply merge objects while preserving arrays in earlier source objects
203
+ * deeply nested primitive keys are merged similarly to lodash's defaultsDeep, while keys with arrays will be preserved if already present in the resultant merged object
204
+ * this prevents default arrays from appending values to user-defined arrays (this occurs if the default array is longer than the user-defined one)
205
+ *
206
+ * @method deepMergeWithArrayOverrides
207
+ * @param {Object} initial - target object to merge values into
208
+ * @param {Object[]} sources - other default options to be merged into the resultant object if no explicit value is provided, with earlier args taking precedence over later ones
209
+ *
210
+ * @returns {Object}
211
+ */
212
+
213
+ var deepMergeWithArrayOverrides = function deepMergeWithArrayOverrides(initial) {
214
+ var clone = lodash_1.cloneDeep(initial);
215
+
216
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
217
+ sources[_key - 1] = arguments[_key];
218
+ }
219
+
220
+ sources.forEach(function (sourceToApply) {
221
+ Object.keys(sourceToApply).forEach(function (sourceKey) {
222
+ if (!clone.hasOwnProperty(sourceKey)) {
223
+ clone[sourceKey] = lodash_1.cloneDeep(sourceToApply[sourceKey]);
224
+ } // object merging excluding arrays
225
+
226
+
227
+ if (clone[sourceKey] && _typeof(clone[sourceKey]) === 'object' && !Array.isArray(clone[sourceKey]) && _typeof(sourceToApply[sourceKey]) === 'object') {
228
+ clone[sourceKey] = exports.deepMergeWithArrayOverrides(clone[sourceKey], sourceToApply[sourceKey]);
229
+ }
230
+ });
231
+ });
232
+ return clone;
233
+ };
234
+
235
+ exports.deepMergeWithArrayOverrides = deepMergeWithArrayOverrides;
236
+
237
+ /***/ }),
238
+ /* 8 */
239
+ /***/ (function(module, exports, __webpack_require__) {
240
+
241
+ "use strict";
242
+
243
+
244
+ var _defineProperty = __webpack_require__(6);
245
+
246
+ var __rest = this && this.__rest || function (s, e) {
247
+ var t = {};
248
+
249
+ for (var p in s) {
250
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
251
+ }
252
+
253
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
254
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
255
+ }
256
+ return t;
257
+ };
258
+
259
+ Object.defineProperty(exports, "__esModule", {
260
+ value: true
261
+ });
262
+ exports.generatePrecisionValues = exports.getInitialPreset = exports.isDynamicOption = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;
263
+
264
+ var lodash_1 = __webpack_require__(2);
265
+
266
+ var schemaUtils_1 = __webpack_require__(14);
267
+
268
+ var VizBehavior_1 = __webpack_require__(5);
269
+
270
+ var dynamicOptionsDSLType = {
271
+ type: 'string',
272
+ pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
273
+ };
274
+ /**
275
+ * Helper function to extend an options schema with dynamic options DSL
276
+ * @param optionsSchema a visualization's options schema
277
+ * @returns an updated options schema that additionally allows strings starting with > for each option
278
+ */
279
+
280
+ function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
281
+ var enhancedOptionsSchema = {};
282
+ Object.keys(optionsSchema).forEach(function (key) {
283
+ var _a = optionsSchema[key],
284
+ title = _a.title,
285
+ description = _a.description,
286
+ readOnly = _a.readOnly,
287
+ writeOnly = _a.writeOnly,
288
+ examples = _a.examples,
289
+ defaultValue = _a.default,
290
+ type = _a.type,
291
+ properties = _a.properties,
292
+ patternProperties = _a.patternProperties,
293
+ remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);
294
+
295
+ var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
296
+ title: title
297
+ }), description !== undefined && {
298
+ description: description
299
+ }), readOnly !== undefined && {
300
+ readOnly: readOnly
301
+ }), writeOnly !== undefined && {
302
+ writeOnly: writeOnly
303
+ }), examples !== undefined && {
304
+ examples: examples
305
+ }), defaultValue !== undefined && {
306
+ default: defaultValue
307
+ });
308
+
309
+ if (type === 'object') {
310
+ enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
311
+ type: type
312
+ }), properties && {
313
+ properties: enhanceOptionsSchemaWithDynamicOptions(properties)
314
+ });
315
+
316
+ if (patternProperties) {
317
+ var enhancedPatternProperties = {};
318
+ Object.keys(patternProperties).forEach(function (key) {
319
+ enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, key, patternProperties[key])));
320
+ });
321
+ enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
322
+ }
323
+ } else {
324
+ enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
325
+ anyOf: [Object.assign(Object.assign({}, type !== undefined && {
326
+ type: type
327
+ }), remainingSchemaEntry), dynamicOptionsDSLType]
328
+ });
329
+ }
330
+ });
331
+ return enhancedOptionsSchema;
332
+ }
333
+
334
+ exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
335
+ /**
336
+ * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
337
+ * @param vizConfig a Visualization Config
338
+ * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
339
+ */
340
+
341
+ function enhanceConfig(vizConfig) {
342
+ var enhancedConfig = vizConfig;
343
+
344
+ if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
345
+ enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
346
+ }
347
+
348
+ return enhancedConfig;
349
+ }
350
+
351
+ exports.enhanceConfig = enhanceConfig;
352
+
353
+ function isDynamicOption(option) {
354
+ return option && typeof option === 'string' && option.trim().startsWith('>') || false;
355
+ }
356
+
357
+ exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
358
+ // this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset
359
+
360
+ /**
361
+ * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
362
+ * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
363
+ * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
364
+ * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
365
+ *
366
+ * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
367
+ */
368
+
369
+ function hasCompatibleContexts(vizContext, presetContext) {
370
+ var presetContextKeys = Object.keys(presetContext);
371
+ return presetContextKeys.every(function (contextKey) {
372
+ return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
373
+ });
374
+ }
375
+ /**
376
+ * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
377
+ */
378
+
379
+
380
+ function hasCompatibleOptions(vizOptions, presetOptions) {
381
+ var presetOptionKeys = Object.keys(presetOptions);
382
+ return presetOptionKeys.every(function (optionKey) {
383
+ return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
384
+ });
385
+ }
386
+ /**
387
+ * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
388
+ * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
389
+ *
390
+ * @param {Object} vizContext - the current vizContext definition
391
+ * @param {Object} vizOptions - the current vizOptions definition
392
+ * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
393
+ */
394
+
395
+
396
+ function getInitialPreset(vizContext, vizOptions, presets) {
397
+ return presets.find(function (preset) {
398
+ var presetContext = lodash_1.get(preset, ['value', 'context'], {});
399
+ var presetOptions = lodash_1.get(preset, ['value', 'options'], {});
400
+ var presetContextKeys = Object.keys(presetContext);
401
+ var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
402
+ // if not, then the preset is invalid in config.ts
403
+
404
+ if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
405
+ return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
406
+ });
407
+ }
408
+
409
+ exports.getInitialPreset = getInitialPreset;
410
+ /**
411
+ * generates number precision values for a Select editor
412
+ *
413
+ * @param {Number} numPrecisionValues - number of integer precision values to generate
414
+ * @returns {{ label: string; value; string }[]} array of { label, value } tuples
415
+ */
416
+
417
+ function generatePrecisionValues(numPrecisionValues) {
418
+ return lodash_1.range(0, numPrecisionValues + 1).map(function (i) {
419
+ return {
420
+ label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
421
+ value: i
422
+ };
423
+ });
424
+ }
425
+
426
+ exports.generatePrecisionValues = generatePrecisionValues;
427
+
428
+ /***/ }),
429
+ /* 9 */
430
+ /***/ (function(module, exports) {
431
+
432
+ module.exports = require("@splunk/visualizations-shared/Message");
433
+
434
+ /***/ }),
435
+ /* 10 */
436
+ /***/ (function(module, exports) {
437
+
438
+ module.exports = require("@babel/runtime/helpers/classCallCheck");
439
+
440
+ /***/ }),
441
+ /* 11 */
442
+ /***/ (function(module, exports) {
443
+
444
+ module.exports = require("@splunk/visualizations-shared/colorUtils");
445
+
446
+ /***/ }),
447
+ /* 12 */
448
+ /***/ (function(module, exports, __webpack_require__) {
449
+
450
+ "use strict";
451
+
452
+
453
+ Object.defineProperty(exports, "__esModule", {
454
+ value: true
455
+ });
456
+
457
+ var React = __webpack_require__(1);
458
+
459
+ var styled_components_1 = __webpack_require__(4);
460
+
461
+ var SizeAwareWrapper_1 = __webpack_require__(17);
462
+
463
+ var style_1 = __webpack_require__(13);
464
+
465
+ var colorUtils_1 = __webpack_require__(11);
466
+
467
+ var Item = styled_components_1.default.div.attrs(function (_ref) {
468
+ var width = _ref.width;
469
+ return {
470
+ style: {
471
+ width: style_1.toPx(width)
472
+ }
473
+ };
474
+ }).withConfig({
475
+ displayName: "FixedSizeContainer__Item",
476
+ componentId: "sc-1yhgpod-0"
477
+ })(["position:relative;background-color:", "};"], function (props) {
478
+ return colorUtils_1.isColor(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
479
+ }); // Use `.attrs()` for highly dynamic styles. Ref: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
480
+
481
+ var FixSizeItem = styled_components_1.default.div.attrs(function (_ref2) {
482
+ var width = _ref2.width,
483
+ height = _ref2.height;
484
+ return {
485
+ style: Object.assign(Object.assign({}, width && {
486
+ width: style_1.toPx(width)
487
+ }), height && {
488
+ height: style_1.toPx(height)
489
+ })
490
+ };
491
+ }).withConfig({
492
+ displayName: "FixedSizeContainer__FixSizeItem",
493
+ componentId: "sc-1yhgpod-1"
494
+ })(["position:relative;flex-direction:column;flex:1;display:flex;background-color:", "};"], function (props) {
495
+ return colorUtils_1.isColor(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
496
+ });
497
+ var ItemContent = styled_components_1.default.div.withConfig({
498
+ displayName: "FixedSizeContainer__ItemContent",
499
+ componentId: "sc-1yhgpod-2"
500
+ })(["position:relative;min-height:100px;width:100%;"]);
501
+ var FixSizeItemContent = styled_components_1.default.div.withConfig({
502
+ displayName: "FixedSizeContainer__FixSizeItemContent",
503
+ componentId: "sc-1yhgpod-3"
504
+ })(["min-height:0px;flex:1;position:relative;box-sizing:border-box;"]);
505
+
506
+ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
507
+ var FixedSizeContainer = function FixedSizeContainer(props) {
508
+ var width = props.width,
509
+ height = props.height,
510
+ backgroundColor = props.backgroundColor;
511
+
512
+ if (!height) {
513
+ return React.createElement(Item, {
514
+ "data-test": "item",
515
+ width: width,
516
+ backgroundColor: backgroundColor
517
+ }, React.createElement(ItemContent, null, React.createElement(Viz, Object.assign({}, props))));
518
+ }
519
+
520
+ return React.createElement(FixSizeItem, {
521
+ "data-test": "fix-size-item",
522
+ width: width,
523
+ height: height,
524
+ backgroundColor: backgroundColor
525
+ }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, null, function (_ref3) {
526
+ var newWidth = _ref3.width,
527
+ newHeight = _ref3.height;
528
+ return React.createElement(Viz, Object.assign({}, props, {
529
+ width: newWidth,
530
+ height: newHeight
531
+ }));
532
+ })));
533
+ };
534
+
535
+ FixedSizeContainer.displayName = 'withFixedSizeContainer';
536
+ return FixedSizeContainer;
537
+ };
538
+
539
+ exports.default = withFixedSizeContainer;
540
+
541
+ /***/ }),
542
+ /* 13 */
543
+ /***/ (function(module, exports) {
544
+
545
+ module.exports = require("@splunk/visualizations-shared/style");
546
+
547
+ /***/ }),
548
+ /* 14 */
549
+ /***/ (function(module, exports) {
550
+
551
+ module.exports = require("@splunk/visualizations-shared/schemaUtils");
552
+
553
+ /***/ }),
554
+ /* 15 */,
555
+ /* 16 */
556
+ /***/ (function(module, exports) {
557
+
558
+ module.exports = require("@babel/runtime/helpers/createClass");
559
+
560
+ /***/ }),
561
+ /* 17 */
562
+ /***/ (function(module, exports) {
563
+
564
+ module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
565
+
566
+ /***/ }),
567
+ /* 18 */,
568
+ /* 19 */
569
+ /***/ (function(module, exports) {
570
+
571
+ module.exports = require("@splunk/themes/variables");
572
+
573
+ /***/ }),
574
+ /* 20 */
575
+ /***/ (function(module, exports) {
576
+
577
+ module.exports = require("@splunk/visualizations-shared/numberUtils");
578
+
579
+ /***/ }),
580
+ /* 21 */
581
+ /***/ (function(module, exports) {
582
+
583
+ module.exports = require("@splunk/themes/pick");
584
+
585
+ /***/ }),
586
+ /* 22 */
587
+ /***/ (function(module, exports) {
588
+
589
+ module.exports = require("@babel/runtime/helpers/typeof");
590
+
591
+ /***/ }),
592
+ /* 23 */
593
+ /***/ (function(module, exports, __webpack_require__) {
594
+
595
+ "use strict";
596
+
597
+
598
+ var _defineProperty = __webpack_require__(6);
599
+
600
+ Object.defineProperty(exports, "__esModule", {
601
+ value: true
602
+ });
603
+ exports.getSortingParams = exports.SortParamsPropTypes = void 0;
604
+
605
+ var T = __webpack_require__(0);
606
+
607
+ var lodash_1 = __webpack_require__(2);
608
+
609
+ var DataSource_1 = __webpack_require__(33);
610
+
611
+ exports.SortParamsPropTypes = T.shape({
612
+ currentSortKey: T.string,
613
+ currentSortDir: T.oneOf(DataSource_1.validSortDirs),
614
+ onSort: T.func
615
+ });
616
+
617
+ var getSortingParams = function getSortingParams(_ref) {
618
+ var requestParams = _ref.requestParams,
619
+ onRequestParamsChange = _ref.onRequestParamsChange;
620
+ var currentSortKey;
621
+ var currentSortDir;
622
+ var nextSortDirMap = {
623
+ asc: 'desc',
624
+ desc: 'asc',
625
+ none: 'asc'
626
+ };
627
+ var onSort;
628
+
629
+ if (lodash_1.isFunction(onRequestParamsChange)) {
630
+ if (requestParams && lodash_1.has(requestParams, 'sort')) {
631
+ currentSortKey = Object.keys(requestParams.sort).shift();
632
+ currentSortDir = requestParams.sort[currentSortKey];
633
+ } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
634
+
635
+
636
+ onSort = function onSort(e, _ref2) {
637
+ var sortKey = _ref2.sortKey,
638
+ sortDir = _ref2.sortDir;
639
+
640
+ if (typeof sortKey === 'string') {
641
+ var nextSortDir = lodash_1.has(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
642
+ onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
643
+ offset: 0,
644
+ sort: _defineProperty({}, sortKey, nextSortDir)
645
+ }));
646
+ } else {
647
+ onRequestParamsChange(requestParams);
648
+ }
649
+ };
650
+ }
651
+
652
+ return {
653
+ currentSortKey: currentSortKey,
654
+ currentSortDir: currentSortDir,
655
+ onSort: onSort
656
+ };
657
+ };
658
+
659
+ exports.getSortingParams = getSortingParams;
660
+
661
+ /***/ }),
662
+ /* 24 */
663
+ /***/ (function(module, exports, __webpack_require__) {
664
+
665
+ "use strict";
666
+
667
+
668
+ Object.defineProperty(exports, "__esModule", {
669
+ value: true
670
+ });
671
+ exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
672
+
673
+ var T = __webpack_require__(0);
674
+
675
+ var lodash_1 = __webpack_require__(2);
676
+
677
+ exports.PaginatorParamsPropTypes = T.shape({
678
+ isPaging: T.bool,
679
+ current: T.number,
680
+ totalPages: T.number,
681
+ onChange: T.func
682
+ });
683
+
684
+ var getPaginationParams = function getPaginationParams(_ref) {
685
+ var requestParams = _ref.requestParams,
686
+ meta = _ref.meta,
687
+ onRequestParamsChange = _ref.onRequestParamsChange;
688
+ var totalCount = meta && meta.totalCount || 0;
689
+ var offset = requestParams && requestParams.offset || 0;
690
+ var count = requestParams && requestParams.count;
691
+ var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
692
+ var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
693
+ var isPaging = totalPages > 1 && lodash_1.isFunction(onRequestParamsChange);
694
+
695
+ var onChangeHandler = function onChangeHandler(e, _ref2) {
696
+ var page = _ref2.page,
697
+ countArg = _ref2.count;
698
+ var newParams = lodash_1.cloneDeep(requestParams);
699
+
700
+ if (typeof countArg === 'number') {
701
+ newParams.count = countArg;
702
+ newParams.offset = 0;
703
+ }
704
+
705
+ var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
706
+
707
+ if (typeof page === 'number' && page > 0) {
708
+ newParams.count = pageCount;
709
+ newParams.offset = (page - 1) * pageCount;
710
+ }
711
+
712
+ onRequestParamsChange(newParams);
713
+ };
714
+
715
+ return {
716
+ isPaging: isPaging,
717
+ current: current,
718
+ totalPages: totalPages,
719
+ onChange: lodash_1.isFunction(onRequestParamsChange) ? onChangeHandler : lodash_1.noop
720
+ };
721
+ };
722
+
723
+ exports.getPaginationParams = getPaginationParams;
724
+
725
+ /***/ }),
726
+ /* 25 */
727
+ /***/ (function(module, exports, __webpack_require__) {
728
+
729
+ "use strict";
730
+
731
+
732
+ Object.defineProperty(exports, "__esModule", {
733
+ value: true
734
+ });
735
+ exports.shouldShowIconPlaceholder = void 0;
736
+
737
+ var React = __webpack_require__(1);
738
+
739
+ var T = __webpack_require__(0);
740
+
741
+ var lodash_1 = __webpack_require__(2);
742
+
743
+ var i18n_1 = __webpack_require__(3);
744
+
745
+ var Message_1 = __webpack_require__(9);
746
+
747
+ var FixedSizeContainer_1 = __webpack_require__(12);
748
+ /**
749
+ * @method shouldShowIconPlaceholder
750
+ * @param {object} dataSources
751
+ * @param {boolean} loading
752
+ * @returns {boolean}
753
+ */
754
+
755
+
756
+ var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
757
+ var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
758
+ var data = lodash_1.get(dataSources, 'primary.data.columns[0]', undefined);
759
+ var noData = data === undefined;
760
+ var fields = lodash_1.get(dataSources, 'primary.data.fields[0]', undefined);
761
+ var noFields = fields === undefined;
762
+ return loading || noData || noFields;
763
+ };
764
+
765
+ exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
766
+ var propTypes = {
767
+ icon: T.func,
768
+ width: T.oneOfType([T.string, T.number]),
769
+ height: T.oneOfType([T.string, T.number]),
770
+ backgroundColor: T.string
771
+ };
772
+ /**
773
+ * @method IconPlaceholder
774
+ * @param {IconPlaceholderProps} props
775
+ * @returns {React.ReactElement}
776
+ */
777
+
778
+ var IconPlaceholder = function IconPlaceholder(props) {
779
+ var width = props.width,
780
+ height = props.height,
781
+ icon = props.icon;
782
+
783
+ if (icon) {
784
+ return React.createElement(icon, {
785
+ style: {
786
+ left: '50%',
787
+ top: '50%',
788
+ color: 'grey',
789
+ position: 'absolute',
790
+ transform: 'translate(-50%, -50%)'
791
+ },
792
+ width: '50%',
793
+ height: '50%'
794
+ });
795
+ }
796
+
797
+ return React.createElement(Message_1.default, {
798
+ width: width,
799
+ height: height,
800
+ level: "warning",
801
+ message: i18n_1._('No DataSource Connected')
802
+ });
803
+ };
804
+
805
+ IconPlaceholder.propTypes = propTypes;
806
+ IconPlaceholder.defaultProps = {
807
+ width: '100%',
808
+ height: 250
809
+ };
810
+ exports.default = FixedSizeContainer_1.default(IconPlaceholder);
811
+
812
+ /***/ }),
813
+ /* 26 */
814
+ /***/ (function(module, exports, __webpack_require__) {
815
+
816
+ "use strict";
817
+
818
+
819
+ Object.defineProperty(exports, "__esModule", {
820
+ value: true
821
+ });
822
+ exports.VizCategory = void 0;
823
+ var VizCategory;
824
+
825
+ (function (VizCategory) {
826
+ VizCategory["SINGLE_VALUE"] = "Single Value";
827
+ VizCategory["TRENDS"] = "Trends";
828
+ VizCategory["COMPARISONS"] = "Comparisons";
829
+ VizCategory["TABLE"] = "Table";
830
+ VizCategory["GAUGE"] = "Gauge";
831
+ VizCategory["DISTRIBUTIONS"] = "Distributions";
832
+ VizCategory["CHOROPLETH"] = "Choropleth Maps";
833
+ VizCategory["SHAPES"] = "Shapes";
834
+ VizCategory["MISC"] = "misc";
835
+ VizCategory["FLOW"] = "Flow";
836
+ VizCategory["CORRELATION"] = "Correlation";
837
+ VizCategory["SPATIAL"] = "Spatial";
838
+ })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
839
+
840
+ /***/ }),
841
+ /* 27 */
842
+ /***/ (function(module, exports, __webpack_require__) {
843
+
844
+ "use strict";
845
+
846
+
847
+ Object.defineProperty(exports, "__esModule", {
848
+ value: true
849
+ });
850
+
851
+ var React = __webpack_require__(1);
852
+
853
+ var lodash_1 = __webpack_require__(2);
854
+
855
+ var getSettingsFromThemedProps_1 = __webpack_require__(28);
856
+
857
+ var Options_1 = __webpack_require__(29);
858
+
859
+ var SanitizeProps_1 = __webpack_require__(30);
860
+
861
+ var styled_components_1 = __webpack_require__(4);
862
+
863
+ var SplunkVisualization_1 = __webpack_require__(31);
864
+
865
+ var VizBehavior_1 = __webpack_require__(5);
866
+
867
+ var getSorting_1 = __webpack_require__(23);
868
+
869
+ var getPagination_1 = __webpack_require__(24);
870
+
871
+ var useDeepMemo_1 = __webpack_require__(34);
872
+
873
+ var JSONSchemaUtils_1 = __webpack_require__(35);
874
+
875
+ var MissingPropsMessage_1 = __webpack_require__(36);
876
+
877
+ var withEditModeCover_1 = __webpack_require__(37);
878
+
879
+ var withPlaceholder_1 = __webpack_require__(38);
880
+
881
+ var hocUtils_1 = __webpack_require__(7);
882
+ /**
883
+ * hoc that wraps a pure react visualization in a Dashboard visualization
884
+ * @param {DashboardVizOpts} opts
885
+ * @returns {HOC}
886
+ */
887
+
888
+
889
+ var withDashboardViz = function withDashboardViz(opts) {
890
+ var ReactViz = opts.ReactViz,
891
+ vizConfig = opts.vizConfig,
892
+ _opts$computeVizProps = opts.computeVizProps,
893
+ computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
894
+ useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
895
+
896
+ var SanitizedReactViz = SanitizeProps_1.withSanitizedProps(ReactViz);
897
+ var defaultOptions = JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default');
898
+
899
+ var DashboardViz = function DashboardViz(props) {
900
+ var mode = props.mode,
901
+ hasEventHandlers = props.hasEventHandlers,
902
+ dataSources = props.dataSources,
903
+ options = props.options,
904
+ _props$context = props.context,
905
+ context = _props$context === void 0 ? {} : _props$context,
906
+ width = props.width,
907
+ height = props.height,
908
+ onComputedProps = props.onComputedProps,
909
+ onEventTrigger = props.onEventTrigger,
910
+ theme = props.theme,
911
+ onRequestParamsChange = props.onRequestParamsChange;
912
+
913
+ var themeFunc = function themeFunc(themeVar) {
914
+ var _a, _b;
915
+
916
+ return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
917
+ };
918
+
919
+ var bgColorFromTheme = themeFunc('defaultBackgroundColor');
920
+
921
+ var _getSettingsFromTheme = getSettingsFromThemedProps_1.default({
922
+ theme: theme
923
+ }),
924
+ currentThemeFamily = _getSettingsFromTheme.family,
925
+ currentThemeColorScheme = _getSettingsFromTheme.colorScheme,
926
+ currentThemeDensity = _getSettingsFromTheme.density;
927
+
928
+ var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
929
+
930
+ evaluatedOptions = useDeepMemo_1.useDeepMemo(function () {
931
+ try {
932
+ return Options_1.Options.evaluate({
933
+ context: lodash_1.defaultsDeep({}, context, vizConfig.defaultContext),
934
+ options: hocUtils_1.deepMergeWithArrayOverrides({}, options, defaultOptions)
935
+ }, dataSources, themeFunc);
936
+ } catch (e) {
937
+ console.error("unexpected error evaluating options: + ".concat(e.message));
938
+ return {};
939
+ }
940
+ }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources]); // useEffect hook needs to be initialized before any early returns
941
+ // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
942
+
943
+ React.useEffect(function () {
944
+ onComputedProps(evaluatedOptions);
945
+ }); // present warning message if any required props are missing
946
+
947
+ var _vizConfig$requiredPr = vizConfig.requiredProps,
948
+ requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
949
+ supports = vizConfig.supports;
950
+ var missing = MissingPropsMessage_1.missingKeys(requiredProps, evaluatedOptions);
951
+
952
+ if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER)) {
953
+ return React.createElement(MissingPropsMessage_1.default, {
954
+ "data-test": "missing-props-message",
955
+ width: width,
956
+ height: height,
957
+ missingProps: missing,
958
+ backgroundColor: bgColorFromTheme
959
+ });
960
+ } // events
961
+
962
+
963
+ var eventCallbackProps = {};
964
+
965
+ if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
966
+ var supportedEvents = vizConfig.events;
967
+ Object.keys(supportedEvents).forEach(function (eventName) {
968
+ var eventCallbackPropName = lodash_1.camelCase("on.".concat(eventName));
969
+ eventCallbackProps[eventCallbackPropName] = null; // todo: refactor single value and single value icon to send payload from viz
970
+ // then remove these lines
971
+
972
+ var payloadKeys = supportedEvents[eventName].payloadKeys;
973
+ var payload = {};
974
+
975
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
976
+ payloadKeys.forEach(function (p) {
977
+ return payload[p] = evaluatedOptions[p];
978
+ });
979
+ }
980
+
981
+ eventCallbackProps[eventCallbackPropName] = function (ev) {
982
+ if (ev && ev.payload) {
983
+ payload = ev.payload;
984
+ }
985
+
986
+ return onEventTrigger({
987
+ originalEvent: ev,
988
+ payload: payload,
989
+ type: eventName
990
+ });
991
+ };
992
+ });
993
+ } // compute pure viz props which are not from options
994
+
995
+
996
+ var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptions), eventCallbackProps), {
997
+ themeFunc: themeFunc
998
+ }));
999
+ /**
1000
+ * PAGE_AND_SORT behavior
1001
+ *
1002
+ * Some visualizations, like table, requires metadata about the datasource,
1003
+ * like total number of results, current count, offset, and sort, for rendering
1004
+ * paginator and sorting direction. In this approach, the visualization
1005
+ * allow users to set 'paginateDataSourceKey' to select which datasource
1006
+ * should the visualization extract the metadata from. It defaults to 'primary' datasource.
1007
+ * The visualization config should set the PAGE_AND_SORT behavior to receive
1008
+ * 'requestParams', 'meta' and onRequestParams callback as props.
1009
+ *
1010
+ * In future, we could automatically detect which all datasources are being used
1011
+ * and bind those magically to pagination/sorting behavior.
1012
+ */
1013
+
1014
+ var dataSourceMetadata = {};
1015
+ var OptionKey = 'paginateDataSourceKey';
1016
+ var paginateDataSourceKey = lodash_1.has(evaluatedOptions, OptionKey) && evaluatedOptions[OptionKey] || 'primary';
1017
+
1018
+ if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && lodash_1.has(dataSources, paginateDataSourceKey)) {
1019
+ var requestParams = lodash_1.get(dataSources, [paginateDataSourceKey, 'requestParams'], {});
1020
+ var meta = lodash_1.get(dataSources, [paginateDataSourceKey, 'meta'], {});
1021
+
1022
+ var handleRequestParamsChange = function handleRequestParamsChange(payload) {
1023
+ return onRequestParamsChange(paginateDataSourceKey, payload);
1024
+ };
1025
+
1026
+ var sortParams = getSorting_1.getSortingParams({
1027
+ requestParams: requestParams,
1028
+ meta: meta,
1029
+ onRequestParamsChange: handleRequestParamsChange
1030
+ });
1031
+ var paginatorParams = getPagination_1.getPaginationParams({
1032
+ requestParams: requestParams,
1033
+ meta: meta,
1034
+ onRequestParamsChange: handleRequestParamsChange
1035
+ });
1036
+ dataSourceMetadata = {
1037
+ sortParams: sortParams,
1038
+ paginatorParams: paginatorParams
1039
+ };
1040
+ }
1041
+
1042
+ return React.createElement(SanitizedReactViz, Object.assign({
1043
+ mode: mode,
1044
+ width: width,
1045
+ height: height
1046
+ }, evaluatedOptions, computedVizProps, eventCallbackProps, dataSourceMetadata));
1047
+ };
1048
+
1049
+ DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
1050
+ DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
1051
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1052
+ theme: {}
1053
+ }); // attach viz config
1054
+
1055
+ DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
1056
+
1057
+ return styled_components_1.withTheme(withPlaceholder_1.default(withEditModeCover_1.default(DashboardViz), useIconPlaceholder));
1058
+ };
1059
+
1060
+ exports.default = withDashboardViz;
1061
+
1062
+ /***/ }),
1063
+ /* 28 */
1064
+ /***/ (function(module, exports) {
1065
+
1066
+ module.exports = require("@splunk/themes/getSettingsFromThemedProps");
1067
+
1068
+ /***/ }),
1069
+ /* 29 */
1070
+ /***/ (function(module, exports) {
1071
+
1072
+ module.exports = require("@splunk/visualization-encoding/Options");
1073
+
1074
+ /***/ }),
1075
+ /* 30 */
1076
+ /***/ (function(module, exports) {
1077
+
1078
+ module.exports = require("@splunk/visualizations-shared/SanitizeProps");
1079
+
1080
+ /***/ }),
1081
+ /* 31 */
1082
+ /***/ (function(module, exports, __webpack_require__) {
1083
+
1084
+ "use strict";
1085
+
1086
+
1087
+ var _classCallCheck = __webpack_require__(10);
1088
+
1089
+ Object.defineProperty(exports, "__esModule", {
1090
+ value: true
1091
+ });
1092
+ exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
1093
+ /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
1094
+
1095
+ var T = __webpack_require__(0);
1096
+
1097
+ var lodash_1 = __webpack_require__(2);
1098
+
1099
+ var VizActionHandler_1 = __webpack_require__(32); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
1100
+
1101
+
1102
+ exports.INITIAL_WIDTH = 250;
1103
+ exports.INITIAL_HEIGHT = 250;
1104
+ /**
1105
+ * A Splunk visualization
1106
+ */
1107
+
1108
+ var SplunkVisualization = function SplunkVisualization() {
1109
+ _classCallCheck(this, SplunkVisualization);
1110
+ };
1111
+
1112
+ SplunkVisualization.propTypes = {
1113
+ /**
1114
+ * display mode
1115
+ */
1116
+ mode: T.oneOf(['view', 'edit', 'export']).isRequired,
1117
+
1118
+ /**
1119
+ * width in pixel or string, defaults to 100%
1120
+ */
1121
+ width: T.oneOfType([T.string, T.number]).isRequired,
1122
+
1123
+ /**
1124
+ * height in pixel or string
1125
+ */
1126
+ height: T.oneOfType([T.string, T.number]).isRequired,
1127
+
1128
+ /**
1129
+ * visualization context used for dynamic option evaluation
1130
+ */
1131
+ context: T.object,
1132
+
1133
+ /**
1134
+ * visualization formatting options
1135
+ */
1136
+ options: T.object,
1137
+
1138
+ /**
1139
+ * A callback to update formatting options
1140
+ */
1141
+ onOptionsChange: T.func,
1142
+
1143
+ /**
1144
+ * datasource state which include data and request params, object key indicate the datasource type.
1145
+ */
1146
+ dataSources: T.objectOf(T.shape({
1147
+ /**
1148
+ * current request params
1149
+ */
1150
+ requestParams: T.object,
1151
+
1152
+ /**
1153
+ * current dataset
1154
+ */
1155
+ data: T.shape({
1156
+ fields: T.array,
1157
+ columns: T.array
1158
+ }),
1159
+
1160
+ /**
1161
+ * error
1162
+ */
1163
+ error: T.shape({
1164
+ level: T.string,
1165
+ message: T.string
1166
+ }),
1167
+
1168
+ /**
1169
+ * meta data that came with the dataset
1170
+ */
1171
+ meta: T.object
1172
+ })),
1173
+
1174
+ /**
1175
+ * A callback to trigger event
1176
+ */
1177
+ onEventTrigger: T.func,
1178
+
1179
+ /**
1180
+ * Inform viz if there are handlers listening to events
1181
+ */
1182
+ hasEventHandlers: T.bool,
1183
+
1184
+ /**
1185
+ * A callback to communicate computed props to a consumer
1186
+ */
1187
+ onComputedProps: T.func,
1188
+
1189
+ /**
1190
+ * A callback to obtain visualization api
1191
+ */
1192
+ vizActionHandlerRef: T.func,
1193
+ loading: T.bool,
1194
+ theme: T.object,
1195
+
1196
+ /**
1197
+ * A callback to request new data with updated request params
1198
+ */
1199
+ onRequestParamsChange: T.func
1200
+ };
1201
+ /**
1202
+ *
1203
+ */
1204
+
1205
+ SplunkVisualization.defaultProps = {
1206
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
1207
+ width: '100%',
1208
+ height: exports.INITIAL_HEIGHT,
1209
+ dataSources: {},
1210
+ onEventTrigger: function onEventTrigger() {
1211
+ return {};
1212
+ },
1213
+ mode: 'view',
1214
+ hasEventHandlers: false,
1215
+ options: {},
1216
+ context: {},
1217
+ onOptionsChange: function onOptionsChange() {
1218
+ return {};
1219
+ },
1220
+ vizActionHandlerRef: function vizActionHandlerRef() {
1221
+ return new VizActionHandler_1.DefaultVizActionHandler();
1222
+ },
1223
+ onComputedProps: function onComputedProps() {
1224
+ return {};
1225
+ },
1226
+ loading: false,
1227
+ onRequestParamsChange: lodash_1.noop
1228
+ };
1229
+ exports.default = SplunkVisualization;
1230
+
1231
+ /***/ }),
1232
+ /* 32 */
1233
+ /***/ (function(module, exports, __webpack_require__) {
1234
+
1235
+ "use strict";
1236
+
1237
+
1238
+ var _classCallCheck = __webpack_require__(10);
1239
+
1240
+ var _createClass = __webpack_require__(16);
1241
+
1242
+ Object.defineProperty(exports, "__esModule", {
1243
+ value: true
1244
+ });
1245
+ exports.DefaultVizActionHandler = void 0;
1246
+
1247
+ var DefaultVizActionHandler = /*#__PURE__*/function () {
1248
+ function DefaultVizActionHandler() {
1249
+ _classCallCheck(this, DefaultVizActionHandler);
1250
+ }
1251
+
1252
+ _createClass(DefaultVizActionHandler, [{
1253
+ key: "focus",
1254
+ value: function focus() {//noop
1255
+ }
1256
+ }, {
1257
+ key: "snapshot",
1258
+ value: function snapshot() {
1259
+ return null; //noop
1260
+ }
1261
+ }]);
1262
+
1263
+ return DefaultVizActionHandler;
1264
+ }();
1265
+
1266
+ exports.DefaultVizActionHandler = DefaultVizActionHandler;
1267
+
1268
+ /***/ }),
1269
+ /* 33 */
1270
+ /***/ (function(module, exports, __webpack_require__) {
1271
+
1272
+ "use strict";
1273
+
1274
+
1275
+ Object.defineProperty(exports, "__esModule", {
1276
+ value: true
1277
+ });
1278
+ exports.validSortDirs = void 0;
1279
+ exports.validSortDirs = ['asc', 'desc', 'none'];
1280
+
1281
+ /***/ }),
1282
+ /* 34 */
1283
+ /***/ (function(module, exports, __webpack_require__) {
1284
+
1285
+ "use strict";
1286
+
1287
+
1288
+ Object.defineProperty(exports, "__esModule", {
1289
+ value: true
1290
+ });
1291
+ exports.useDeepMemo = void 0;
1292
+
1293
+ var react_1 = __webpack_require__(1);
1294
+
1295
+ var lodash_1 = __webpack_require__(2);
1296
+ /**
1297
+ * This hook evaluates and stores the result of a passed function and only
1298
+ * re-evaluates the function when passed dependencies change.
1299
+ *
1300
+ * It is different from the internal React useMemo in the following aspects:
1301
+ * - it only stores the last evaluated result
1302
+ * - it uses a deep equality check to determine if dependencies have changed
1303
+ *
1304
+ * Inspired by apollo-client's useDeepMemo
1305
+ *
1306
+ * @param fn the function to be executed and
1307
+ * @param dependencies an array of dependencies
1308
+ */
1309
+
1310
+
1311
+ var useDeepMemo = function useDeepMemo(fn, dependencies) {
1312
+ var ref = react_1.useRef();
1313
+
1314
+ if (!ref.current || !lodash_1.isEqual(dependencies, ref.current.dependencies)) {
1315
+ ref.current = {
1316
+ dependencies: dependencies,
1317
+ value: fn()
1318
+ };
1319
+ }
1320
+
1321
+ return ref.current.value;
1322
+ };
1323
+
1324
+ exports.useDeepMemo = useDeepMemo;
1325
+
1326
+ /***/ }),
1327
+ /* 35 */
1328
+ /***/ (function(module, exports, __webpack_require__) {
1329
+
1330
+ "use strict";
1331
+
1332
+
1333
+ Object.defineProperty(exports, "__esModule", {
1334
+ value: true
1335
+ });
1336
+ exports.pickFieldFromJSONSchema = void 0;
1337
+
1338
+ var lodash_1 = __webpack_require__(2);
1339
+
1340
+ var pickFieldFromJSONSchema = function pickFieldFromJSONSchema(optionsSchema) {
1341
+ var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
1342
+ return Object.keys(optionsSchema).reduce(function (accum, k) {
1343
+ if (lodash_1.has(optionsSchema[k], fieldName)) {
1344
+ accum[k] = optionsSchema[k][fieldName];
1345
+ } else if (lodash_1.get(optionsSchema, [k, 'type']) === 'object' && lodash_1.has(optionsSchema[k], 'properties')) {
1346
+ var nestedSchema = exports.pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);
1347
+
1348
+ if (!lodash_1.isEmpty(nestedSchema)) {
1349
+ accum[k] = nestedSchema;
1350
+ }
1351
+ }
1352
+
1353
+ return accum;
1354
+ }, {});
1355
+ };
1356
+
1357
+ exports.pickFieldFromJSONSchema = pickFieldFromJSONSchema;
1358
+
1359
+ /***/ }),
1360
+ /* 36 */
1361
+ /***/ (function(module, exports, __webpack_require__) {
1362
+
1363
+ "use strict";
1364
+
1365
+
1366
+ Object.defineProperty(exports, "__esModule", {
1367
+ value: true
1368
+ });
1369
+ exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
1370
+
1371
+ var React = __webpack_require__(1);
1372
+
1373
+ var T = __webpack_require__(0);
1374
+
1375
+ var i18n_1 = __webpack_require__(3);
1376
+
1377
+ var Message_1 = __webpack_require__(9);
1378
+
1379
+ var FixedSizeContainer_1 = __webpack_require__(12);
1380
+ /**
1381
+ * @method isMissing
1382
+ * @param {any} v
1383
+ * @returns {boolean} true if the input value === null or undefined
1384
+ */
1385
+
1386
+
1387
+ var isMissing = function isMissing(v) {
1388
+ return v === null || v === undefined;
1389
+ };
1390
+
1391
+ exports.isMissing = isMissing;
1392
+ /**
1393
+ * @method misskingKeys
1394
+ * @param {string[]} keys
1395
+ * @param {object} target
1396
+ * @returns {string[]} the keys of missing required props
1397
+ */
1398
+
1399
+ var missingKeys = function missingKeys(keys, target) {
1400
+ return keys.filter(function (k) {
1401
+ return exports.isMissing(target[k]);
1402
+ });
1403
+ };
1404
+
1405
+ exports.missingKeys = missingKeys;
1406
+ var propTypes = {
1407
+ width: T.oneOfType([T.string, T.number]),
1408
+ height: T.oneOfType([T.string, T.number]),
1409
+ backgroundColor: T.string,
1410
+ missingProps: T.arrayOf(T.string)
1411
+ };
1412
+ /**
1413
+ * @method MissingPropsMessage
1414
+ * @param {MissingPropsProps} props
1415
+ * @returns {React.ReactElement}
1416
+ */
1417
+
1418
+ var MissingPropsMessage = function MissingPropsMessage(props) {
1419
+ var width = props.width,
1420
+ height = props.height,
1421
+ missingProps = props.missingProps;
1422
+ return React.createElement(Message_1.default, {
1423
+ "data-test": "message",
1424
+ width: width,
1425
+ height: height,
1426
+ message: i18n_1._("Missing property: ".concat(missingProps.join(', ')))
1427
+ });
1428
+ };
1429
+
1430
+ exports.MissingPropsMessage = MissingPropsMessage;
1431
+ exports.MissingPropsMessage.propTypes = propTypes;
1432
+ exports.MissingPropsMessage.defaultProps = {
1433
+ width: '100%',
1434
+ height: 250
1435
+ };
1436
+ exports.default = FixedSizeContainer_1.default(exports.MissingPropsMessage);
1437
+
1438
+ /***/ }),
1439
+ /* 37 */
1440
+ /***/ (function(module, exports, __webpack_require__) {
1441
+
1442
+ "use strict";
1443
+
1444
+
1445
+ Object.defineProperty(exports, "__esModule", {
1446
+ value: true
1447
+ });
1448
+
1449
+ var React = __webpack_require__(1);
1450
+
1451
+ var styled_components_1 = __webpack_require__(4);
1452
+
1453
+ var hocUtils_1 = __webpack_require__(7);
1454
+
1455
+ var Cover = styled_components_1.default.div.withConfig({
1456
+ displayName: "withEditModeCover__Cover",
1457
+ componentId: "sc-1gsbnxb-0"
1458
+ })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
1459
+ var Blocker = styled_components_1.default.div.withConfig({
1460
+ displayName: "withEditModeCover__Blocker",
1461
+ componentId: "sc-1gsbnxb-1"
1462
+ })(["position:relative;width:100%;height:100%;"]);
1463
+ /**
1464
+ * HOC that renders a cover layer in edit mode
1465
+ * @method withEditModeCover
1466
+ * @param {ExtendedDashViz} Visualization
1467
+ * @returns {ExtendedDashViz} Wrapper
1468
+ */
1469
+
1470
+ var withEditModeCover = function withEditModeCover(Visualization) {
1471
+ var Wrapper = function Wrapper(props) {
1472
+ var mode = props.mode;
1473
+ return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), mode === 'edit' && React.createElement(Cover, {
1474
+ "data-test": "edit-mode-cover"
1475
+ }));
1476
+ };
1477
+
1478
+ hocUtils_1.extendStaticWrapperProps({
1479
+ Wrapper: Wrapper,
1480
+ Visualization: Visualization
1481
+ });
1482
+ return Wrapper;
1483
+ };
1484
+
1485
+ exports.default = withEditModeCover;
1486
+
1487
+ /***/ }),
1488
+ /* 38 */
1489
+ /***/ (function(module, exports, __webpack_require__) {
1490
+
1491
+ "use strict";
1492
+
1493
+
1494
+ Object.defineProperty(exports, "__esModule", {
1495
+ value: true
1496
+ });
1497
+
1498
+ var React = __webpack_require__(1);
1499
+
1500
+ var colorUtils_1 = __webpack_require__(11);
1501
+
1502
+ var IconPlaceholder_1 = __webpack_require__(25);
1503
+
1504
+ var VizBehavior_1 = __webpack_require__(5);
1505
+
1506
+ var hocUtils_1 = __webpack_require__(7);
1507
+
1508
+ var withPlaceholder = function withPlaceholder(Visualization) {
1509
+ var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
1510
+ var config = Visualization.config;
1511
+ var themes = config.themes;
1512
+
1513
+ var Wrapper = function Wrapper(props) {
1514
+ var _a;
1515
+
1516
+ var dataSources = props.dataSources,
1517
+ loading = props.loading,
1518
+ options = props.options,
1519
+ height = props.height,
1520
+ width = props.width;
1521
+ var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
1522
+ var bgColorFromTheme = colorUtils_1.isColor(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
1523
+
1524
+ if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
1525
+ return React.createElement(IconPlaceholder_1.default, {
1526
+ "data-test": "icon-placeholder",
1527
+ icon: config.icon,
1528
+ width: width,
1529
+ height: height,
1530
+ backgroundColor: bgColorFromTheme
1531
+ });
1532
+ }
1533
+
1534
+ return React.createElement(Visualization, Object.assign({}, props));
1535
+ };
1536
+
1537
+ hocUtils_1.extendStaticWrapperProps({
1538
+ Wrapper: Wrapper,
1539
+ Visualization: Visualization
1540
+ });
1541
+ return Wrapper;
1542
+ };
1543
+
1544
+ exports.default = withPlaceholder;
1545
+
1546
+ /***/ }),
1547
+ /* 39 */
1548
+ /***/ (function(module, exports) {
1549
+
1550
+ module.exports = require("@babel/runtime/helpers/toConsumableArray");
1551
+
1552
+ /***/ }),
1553
+ /* 40 */
1554
+ /***/ (function(module, exports) {
1555
+
1556
+ module.exports = require("@splunk/visualizations-shared/colorConstants");
1557
+
1558
+ /***/ }),
1559
+ /* 41 */,
1560
+ /* 42 */,
1561
+ /* 43 */
1562
+ /***/ (function(module, exports) {
1563
+
1564
+ module.exports = require("@babel/runtime/helpers/extends");
1565
+
1566
+ /***/ }),
1567
+ /* 44 */
1568
+ /***/ (function(module, exports, __webpack_require__) {
1569
+
1570
+ "use strict";
1571
+
1572
+
1573
+ Object.defineProperty(exports, "__esModule", {
1574
+ value: true
1575
+ });
1576
+
1577
+ var i18n_1 = __webpack_require__(3);
1578
+
1579
+ var background = function background(_ref) {
1580
+ var label = _ref.label,
1581
+ themes = _ref.themes,
1582
+ labelPosition = _ref.labelPosition;
1583
+ return [{
1584
+ label: i18n_1._(label || 'Background'),
1585
+ option: 'backgroundColor',
1586
+ editor: 'editor.color',
1587
+ editorProps: {
1588
+ labelPosition: labelPosition || 'top',
1589
+ themes: themes
1590
+ }
1591
+ }];
1592
+ };
1593
+
1594
+ exports.default = background;
1595
+
1596
+ /***/ }),
1597
+ /* 45 */,
1598
+ /* 46 */,
1599
+ /* 47 */,
1600
+ /* 48 */,
1601
+ /* 49 */,
1602
+ /* 50 */,
1603
+ /* 51 */,
1604
+ /* 52 */,
1605
+ /* 53 */,
1606
+ /* 54 */,
1607
+ /* 55 */,
1608
+ /* 56 */,
1609
+ /* 57 */,
1610
+ /* 58 */,
1611
+ /* 59 */,
1612
+ /* 60 */,
1613
+ /* 61 */,
1614
+ /* 62 */,
1615
+ /* 63 */,
1616
+ /* 64 */,
1617
+ /* 65 */,
1618
+ /* 66 */,
1619
+ /* 67 */,
1620
+ /* 68 */,
1621
+ /* 69 */,
1622
+ /* 70 */,
1623
+ /* 71 */
1624
+ /***/ (function(module, exports, __webpack_require__) {
1625
+
1626
+ "use strict";
1627
+
1628
+
1629
+ var _toConsumableArray = __webpack_require__(39);
1630
+
1631
+ Object.defineProperty(exports, "__esModule", {
1632
+ value: true
1633
+ });
1634
+ 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;
1635
+
1636
+ var lodash_1 = __webpack_require__(2);
1637
+
1638
+ var colorConstants_1 = __webpack_require__(40);
1639
+
1640
+ var i18n_1 = __webpack_require__(3);
1641
+
1642
+ exports.GAUGE_THICKNESS = 50;
1643
+ exports.FILL_THICKNESS = 38;
1644
+ var GRADIENT_STOP_OFFSET_MIN = 0;
1645
+ var GRADIENT_STOP_OFFSET_MAX = 100;
1646
+ /**
1647
+ * get width for the whole gauge viz for horizontal or vertical view
1648
+ * @method getGaugeWidth
1649
+ * @param {Object} input
1650
+ * @param {Number} containerWidth
1651
+ * @param {String} orientation
1652
+ * @return {Number} width
1653
+ */
1654
+
1655
+ var getGaugeWidth = function getGaugeWidth(_ref) {
1656
+ var containerWidth = _ref.containerWidth,
1657
+ orientation = _ref.orientation;
1658
+ return orientation === 'vertical' ? exports.GAUGE_THICKNESS : containerWidth * 0.8;
1659
+ };
1660
+
1661
+ exports.getGaugeWidth = getGaugeWidth;
1662
+ /**
1663
+ * get height for the whole gauge viz for horizontal or vertical view
1664
+ * @method getGaugeHeight
1665
+ * @param {Object} input
1666
+ * @param {Number} containerHeight
1667
+ * @param {String} orientation
1668
+ * @return {Number} height
1669
+ */
1670
+
1671
+ var getGaugeHeight = function getGaugeHeight(_ref2) {
1672
+ var containerHeight = _ref2.containerHeight,
1673
+ orientation = _ref2.orientation;
1674
+ return orientation === 'vertical' ? containerHeight * 0.8 : exports.GAUGE_THICKNESS;
1675
+ };
1676
+
1677
+ exports.getGaugeHeight = getGaugeHeight;
1678
+ /**
1679
+ * get how long the gauge shoud be.
1680
+ * In horizontal view, gauge length equals to gauge width. In vertical view, it equals to gauge height.
1681
+ * @method getGaugeLength
1682
+ * @param {Object} input
1683
+ * @param {Number} input.containerWidth
1684
+ * @param {Number} input.containerHeight
1685
+ * @param {String} input.orientation
1686
+ * @return {Number} gaugeLength
1687
+ */
1688
+
1689
+ var getGaugeLength = function getGaugeLength(_ref3) {
1690
+ var containerWidth = _ref3.containerWidth,
1691
+ containerHeight = _ref3.containerHeight,
1692
+ orientation = _ref3.orientation;
1693
+ return orientation === 'vertical' ? exports.getGaugeHeight({
1694
+ containerHeight: containerHeight,
1695
+ orientation: orientation
1696
+ }) : exports.getGaugeWidth({
1697
+ containerWidth: containerWidth,
1698
+ orientation: orientation
1699
+ });
1700
+ };
1701
+
1702
+ exports.getGaugeLength = getGaugeLength;
1703
+ /**
1704
+ * get start x and y for rendering gauge
1705
+ * @method getGaugeStartPosition
1706
+ * @param {Object} input
1707
+ * @param {Number} containerWidth
1708
+ * @param {Number} containerHeight
1709
+ * @param {Number} gaugeLength
1710
+ * @param {String} orientation
1711
+ * @return {Object} position
1712
+ * @return {Number} position.gaugeStartX
1713
+ * @return {Number} position.gaugeStartY
1714
+ */
1715
+
1716
+ var getGaugeStartPosition = function getGaugeStartPosition(_ref4) {
1717
+ var containerWidth = _ref4.containerWidth,
1718
+ containerHeight = _ref4.containerHeight,
1719
+ gaugeLength = _ref4.gaugeLength,
1720
+ orientation = _ref4.orientation;
1721
+ // for horizontal view
1722
+ var gaugeStartX = (containerWidth - gaugeLength) / 2.0;
1723
+ var gaugeStartY = (containerHeight - exports.GAUGE_THICKNESS) / 2.0;
1724
+
1725
+ if (orientation === 'vertical') {
1726
+ gaugeStartX = (containerWidth - exports.GAUGE_THICKNESS) / 2.0;
1727
+ gaugeStartY = (containerHeight - gaugeLength) / 2.0;
1728
+ }
1729
+
1730
+ return {
1731
+ gaugeStartX: gaugeStartX,
1732
+ gaugeStartY: gaugeStartY
1733
+ };
1734
+ };
1735
+
1736
+ exports.getGaugeStartPosition = getGaugeStartPosition;
1737
+ /**
1738
+ * get dimensions for the whole gauge viz,
1739
+ * which can be useful to calculate background bar and major ticks positions.
1740
+ * @method getGaugeDimensions
1741
+ * @param {Object} input
1742
+ * @param {Number} input.containerWidth
1743
+ * @param {Number} input.containerHeight
1744
+ * @param {String} input.orientation 'horizontal' or 'vertical'
1745
+ * @return {Object} gaugeDimensions
1746
+ * @return {Number} gaugeDimensions.gaugeLength how long the gauge shoud be in horizontal or vertical orientation.
1747
+ * @return {Number} gaugeDimensions.gaugeStartX start x to render gauge
1748
+ * @return {Number} gaugeDimensions.gaugeStartY start y to render gauge
1749
+ * @return {Number} gaugeDimensions.gaugeWidth natural width of gauge
1750
+ * @return {Number} gaugeDimensions.gaugeHeight natural height of gauge
1751
+ */
1752
+
1753
+ var getGaugeDimensions = function getGaugeDimensions(_ref5) {
1754
+ var containerWidth = _ref5.containerWidth,
1755
+ containerHeight = _ref5.containerHeight,
1756
+ orientation = _ref5.orientation;
1757
+ var gaugeLength = exports.getGaugeLength({
1758
+ containerWidth: containerWidth,
1759
+ containerHeight: containerHeight,
1760
+ orientation: orientation
1761
+ });
1762
+
1763
+ var _exports$getGaugeStar = exports.getGaugeStartPosition({
1764
+ containerWidth: containerWidth,
1765
+ containerHeight: containerHeight,
1766
+ gaugeLength: gaugeLength,
1767
+ orientation: orientation
1768
+ }),
1769
+ gaugeStartX = _exports$getGaugeStar.gaugeStartX,
1770
+ gaugeStartY = _exports$getGaugeStar.gaugeStartY;
1771
+
1772
+ var gaugeWidth = exports.getGaugeWidth({
1773
+ containerWidth: containerWidth,
1774
+ orientation: orientation
1775
+ });
1776
+ var gaugeHeight = exports.getGaugeHeight({
1777
+ containerHeight: containerHeight,
1778
+ orientation: orientation
1779
+ });
1780
+ return {
1781
+ gaugeLength: gaugeLength,
1782
+ gaugeStartX: gaugeStartX,
1783
+ gaugeStartY: gaugeStartY,
1784
+ gaugeWidth: gaugeWidth,
1785
+ gaugeHeight: gaugeHeight
1786
+ };
1787
+ };
1788
+
1789
+ exports.getGaugeDimensions = getGaugeDimensions;
1790
+ /**
1791
+ * if gaugeColor is not specified, auto assign a gauge color to the fill bar
1792
+ * based on how much percentage the value is taken between min and max
1793
+ * @method assignGaugeColor
1794
+ * @params
1795
+ * */
1796
+
1797
+ var assignGaugeColor = function assignGaugeColor(_ref6) {
1798
+ var value = _ref6.value,
1799
+ min = _ref6.min,
1800
+ max = _ref6.max;
1801
+ var rate = (value - min) / (max - min);
1802
+
1803
+ if (rate <= 0.3) {
1804
+ return colorConstants_1.SEMANTIC_SUCCESS;
1805
+ }
1806
+
1807
+ if (rate > 0.3 && rate <= 0.6) {
1808
+ return colorConstants_1.SEMANTIC_WARNING;
1809
+ }
1810
+
1811
+ return colorConstants_1.SEMANTIC_ERROR;
1812
+ };
1813
+
1814
+ exports.assignGaugeColor = assignGaugeColor;
1815
+ /**
1816
+ * get inner bar length in gauge
1817
+ * @method getGaugeBarLength
1818
+ * @param {Object} input
1819
+ * @param {Number} input.gaugeLength
1820
+ * @param {Number} input.value
1821
+ * @param {Number} input.min
1822
+ * @param {Number} input.max
1823
+ * @return {Number} gaugeBarLength
1824
+ */
1825
+
1826
+ var getGaugeBarLength = function getGaugeBarLength(_ref7) {
1827
+ var gaugeLength = _ref7.gaugeLength,
1828
+ value = _ref7.value,
1829
+ min = _ref7.min,
1830
+ max = _ref7.max;
1831
+
1832
+ if (max < min) {
1833
+ return null;
1834
+ }
1835
+
1836
+ if (value >= max) {
1837
+ return gaugeLength;
1838
+ }
1839
+
1840
+ if (value < min) {
1841
+ return 0;
1842
+ }
1843
+
1844
+ return gaugeLength * (value - min) / (max - min);
1845
+ };
1846
+
1847
+ exports.getGaugeBarLength = getGaugeBarLength;
1848
+ /**
1849
+ * get x and y position for rendering inner bar in gauge
1850
+ * @method getGaugeBarStartPositions
1851
+ * @param {Object} input
1852
+ * @param {Number} input.gaugeStartX
1853
+ * @param {Number} input.gaugeStartY
1854
+ * @param {Number} input.gaugeWidth
1855
+ * @param {Number} input.gaugeHeight
1856
+ * @param {Number} input.gaugeBarLength
1857
+ * @param {String} input.orientation
1858
+ * @return {Object} position
1859
+ * @return {Number} position.gaugeBarX
1860
+ * @return {Number} position.gaugeBarY
1861
+ */
1862
+
1863
+ var getGaugeBarStartPositions = function getGaugeBarStartPositions(_ref8) {
1864
+ var gaugeStartX = _ref8.gaugeStartX,
1865
+ gaugeStartY = _ref8.gaugeStartY,
1866
+ gaugeWidth = _ref8.gaugeWidth,
1867
+ gaugeHeight = _ref8.gaugeHeight,
1868
+ gaugeBarLength = _ref8.gaugeBarLength,
1869
+ orientation = _ref8.orientation;
1870
+ var gaugeBarX = gaugeStartX;
1871
+ var gaugeBarY = gaugeStartY;
1872
+
1873
+ if (orientation === 'vertical') {
1874
+ gaugeBarX += (gaugeWidth - exports.FILL_THICKNESS) / 2;
1875
+ gaugeBarY += gaugeHeight - gaugeBarLength;
1876
+ } else {
1877
+ gaugeBarY += (gaugeHeight - exports.FILL_THICKNESS) / 2;
1878
+ }
1879
+
1880
+ return {
1881
+ gaugeBarX: gaugeBarX,
1882
+ gaugeBarY: gaugeBarY
1883
+ };
1884
+ };
1885
+
1886
+ exports.getGaugeBarStartPositions = getGaugeBarStartPositions;
1887
+ /**
1888
+ * get width of inner bar in gauge
1889
+ * @method getGaugeBarWidth
1890
+ * @param {Object} input
1891
+ * @param {Number} input.gaugeBarLength
1892
+ * @param {String} orientation
1893
+ * @return {Number} gaugeBarWidth
1894
+ */
1895
+
1896
+ var getGaugeBarWidth = function getGaugeBarWidth(_ref9) {
1897
+ var gaugeBarLength = _ref9.gaugeBarLength,
1898
+ orientation = _ref9.orientation;
1899
+ return orientation === 'vertical' ? exports.FILL_THICKNESS : gaugeBarLength;
1900
+ };
1901
+
1902
+ exports.getGaugeBarWidth = getGaugeBarWidth;
1903
+ /**
1904
+ * get height of inner bar in gauge
1905
+ * @method getGaugeBarWidth
1906
+ * @param {Object} input
1907
+ * @param {Number} input.gaugeBarLength
1908
+ * @param {String} orientation
1909
+ * @return {Number} gaugeBarHeight
1910
+ */
1911
+
1912
+ var getGaugeBarHeight = function getGaugeBarHeight(_ref10) {
1913
+ var gaugeBarLength = _ref10.gaugeBarLength,
1914
+ orientation = _ref10.orientation;
1915
+ return orientation === 'vertical' ? gaugeBarLength : exports.FILL_THICKNESS;
1916
+ };
1917
+
1918
+ exports.getGaugeBarHeight = getGaugeBarHeight;
1919
+ /**
1920
+ * get dimensions for the fill bar in the gauge
1921
+ * @method getFillBarDimensions
1922
+ * @param {Object} input
1923
+ * @param {Number} input.gaugeLength
1924
+ * @param {Number} input.gaugeStartX
1925
+ * @param {Number} input.gaugeStartY
1926
+ * @param {Number} input.gaugeWidth,
1927
+ * @param {Number} input.gaugeHeight,
1928
+ * @param {Number} input.value,
1929
+ * @param {Number} input.min,
1930
+ * @param {Number} input.max,
1931
+ * @param {String} input.orientation
1932
+ * @return {Object} fillBarDimensions
1933
+ * @return {Number} fillBarDimensions.fillBarLength
1934
+ * @return {Number} fillBarDimensions.fillBarX
1935
+ * @return {Number} fillBarDimensions.fillBarY
1936
+ * @return {Number} fillBarDimensions.fillBarWidth
1937
+ * @return {Number} fillBarDimensions.fillBarHeight
1938
+ */
1939
+
1940
+ var getFillBarDimensions = function getFillBarDimensions(_ref11) {
1941
+ var gaugeLength = _ref11.gaugeLength,
1942
+ gaugeStartX = _ref11.gaugeStartX,
1943
+ gaugeStartY = _ref11.gaugeStartY,
1944
+ gaugeWidth = _ref11.gaugeWidth,
1945
+ gaugeHeight = _ref11.gaugeHeight,
1946
+ value = _ref11.value,
1947
+ min = _ref11.min,
1948
+ max = _ref11.max,
1949
+ orientation = _ref11.orientation;
1950
+ var gaugeBarLength = exports.getGaugeBarLength({
1951
+ gaugeLength: gaugeLength,
1952
+ value: value,
1953
+ max: max,
1954
+ min: min
1955
+ });
1956
+
1957
+ var _exports$getGaugeBarS = exports.getGaugeBarStartPositions({
1958
+ gaugeStartX: gaugeStartX,
1959
+ gaugeStartY: gaugeStartY,
1960
+ gaugeWidth: gaugeWidth,
1961
+ gaugeHeight: gaugeHeight,
1962
+ gaugeBarLength: gaugeBarLength,
1963
+ orientation: orientation
1964
+ }),
1965
+ fillBarX = _exports$getGaugeBarS.gaugeBarX,
1966
+ fillBarY = _exports$getGaugeBarS.gaugeBarY;
1967
+
1968
+ var fillBarWidth = exports.getGaugeBarWidth({
1969
+ gaugeBarLength: gaugeBarLength,
1970
+ orientation: orientation
1971
+ });
1972
+ var fillBarHeight = exports.getGaugeBarHeight({
1973
+ gaugeBarLength: gaugeBarLength,
1974
+ orientation: orientation
1975
+ });
1976
+ return {
1977
+ fillBarLength: gaugeBarLength,
1978
+ fillBarX: fillBarX,
1979
+ fillBarY: fillBarY,
1980
+ fillBarWidth: fillBarWidth,
1981
+ fillBarHeight: fillBarHeight
1982
+ };
1983
+ };
1984
+
1985
+ exports.getFillBarDimensions = getFillBarDimensions;
1986
+ /**
1987
+ * get position x and y for value marker in filler gauge
1988
+ * @method getFillerGaugeValueMarkerPositions
1989
+ * @param {Object} input
1990
+ * @param {Number} input.fillBarX
1991
+ * @param {Number} input.fillBarY
1992
+ * @param {Number} input.fillBarLength
1993
+ * @param {String} input.orientation
1994
+ * @return {Object} position
1995
+ * @return {Number} position.valueMarkerX
1996
+ * @return {Number} position.valueMarkerY
1997
+ */
1998
+
1999
+ var getFillerGaugeValueMarkerPositions = function getFillerGaugeValueMarkerPositions(_ref12) {
2000
+ var fillBarX = _ref12.fillBarX,
2001
+ fillBarY = _ref12.fillBarY,
2002
+ fillBarLength = _ref12.fillBarLength,
2003
+ orientation = _ref12.orientation;
2004
+ var valueMarkerX = fillBarX;
2005
+ var valueMarkerY = fillBarY;
2006
+
2007
+ if (orientation === 'vertical') {
2008
+ valueMarkerX -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
2009
+ } else {
2010
+ valueMarkerX += fillBarLength;
2011
+ valueMarkerY -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
2012
+ }
2013
+
2014
+ return {
2015
+ valueMarkerX: valueMarkerX,
2016
+ valueMarkerY: valueMarkerY
2017
+ };
2018
+ };
2019
+
2020
+ exports.getFillerGaugeValueMarkerPositions = getFillerGaugeValueMarkerPositions;
2021
+ /**
2022
+ * get dimensions for the marker bar in the gauge
2023
+ * @method getMarkerBarDimensions
2024
+ * @param {Object} input
2025
+ * @param {Number} input.gaugeLength
2026
+ * @param {Number} input.gaugeStartX
2027
+ * @param {Number} input.gaugeStartY
2028
+ * @param {Number} input.gaugeWidth,
2029
+ * @param {Number} input.gaugeHeight,
2030
+ * @param {String} input.orientation
2031
+ * @return {Object} markerBarDimensions
2032
+ * @return {Number} markerBarDimensions.markerBarLength
2033
+ * @return {Number} markerBarDimensions.markerBarX
2034
+ * @return {Number} markerBarDimensions.markerBarY
2035
+ * @return {Number} markerBarDimensions.markerBarWidth
2036
+ * @return {Number} markerBarDimensions.markerBarHeight
2037
+ */
2038
+
2039
+ var getMarkerBarDimensions = function getMarkerBarDimensions(_ref13) {
2040
+ var gaugeLength = _ref13.gaugeLength,
2041
+ gaugeStartX = _ref13.gaugeStartX,
2042
+ gaugeStartY = _ref13.gaugeStartY,
2043
+ gaugeWidth = _ref13.gaugeWidth,
2044
+ gaugeHeight = _ref13.gaugeHeight,
2045
+ orientation = _ref13.orientation;
2046
+ var gaugeBarLength = gaugeLength; // For marker gauge, inner marker bar spans the entire gauge
2047
+
2048
+ var _exports$getGaugeBarS2 = exports.getGaugeBarStartPositions({
2049
+ gaugeStartX: gaugeStartX,
2050
+ gaugeStartY: gaugeStartY,
2051
+ gaugeWidth: gaugeWidth,
2052
+ gaugeHeight: gaugeHeight,
2053
+ gaugeBarLength: gaugeBarLength,
2054
+ orientation: orientation
2055
+ }),
2056
+ markerBarX = _exports$getGaugeBarS2.gaugeBarX,
2057
+ markerBarY = _exports$getGaugeBarS2.gaugeBarY;
2058
+
2059
+ var markerBarWidth = exports.getGaugeBarWidth({
2060
+ gaugeBarLength: gaugeBarLength,
2061
+ orientation: orientation
2062
+ });
2063
+ var markerBarHeight = exports.getGaugeBarHeight({
2064
+ gaugeBarLength: gaugeBarLength,
2065
+ orientation: orientation
2066
+ });
2067
+ return {
2068
+ markerBarLength: gaugeBarLength,
2069
+ markerBarX: markerBarX,
2070
+ markerBarY: markerBarY,
2071
+ markerBarWidth: markerBarWidth,
2072
+ markerBarHeight: markerBarHeight
2073
+ };
2074
+ };
2075
+
2076
+ exports.getMarkerBarDimensions = getMarkerBarDimensions;
2077
+ /**
2078
+ * get position x and y for value marker in marker gauge
2079
+ * @method getMarkerGaugeValueMarkerPositions
2080
+ * @param {Object} input
2081
+ * @param {Number} input.markerBarX
2082
+ * @param {Number} input.markerBarY
2083
+ * @param {Number} input.markerBarHeight
2084
+ * @param {Number} input.markerBarLength
2085
+ * @param {Number} input.value
2086
+ * @param {Number} input.min
2087
+ * @param {Number} input.max
2088
+ * @param {String} input.orientation
2089
+ * @return {Object} position
2090
+ * @return {Number} position.valueMarkerX
2091
+ * @return {Number} position.valueMarkerY
2092
+ */
2093
+
2094
+ var getMarkerGaugeValueMarkerPositions = function getMarkerGaugeValueMarkerPositions(_ref14) {
2095
+ var markerBarX = _ref14.markerBarX,
2096
+ markerBarY = _ref14.markerBarY,
2097
+ markerBarHeight = _ref14.markerBarHeight,
2098
+ gaugeLength = _ref14.markerBarLength,
2099
+ orientation = _ref14.orientation,
2100
+ value = _ref14.value,
2101
+ min = _ref14.min,
2102
+ max = _ref14.max;
2103
+ var valueMarkerX = markerBarX;
2104
+ var valueMarkerY = markerBarY;
2105
+
2106
+ if (orientation === 'vertical') {
2107
+ valueMarkerY += markerBarHeight - exports.getGaugeBarLength({
2108
+ gaugeLength: gaugeLength,
2109
+ value: value,
2110
+ max: max,
2111
+ min: min
2112
+ });
2113
+ valueMarkerX -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
2114
+ } else {
2115
+ valueMarkerX += exports.getGaugeBarLength({
2116
+ gaugeLength: gaugeLength,
2117
+ value: value,
2118
+ max: max,
2119
+ min: min
2120
+ });
2121
+ valueMarkerY -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
2122
+ }
2123
+
2124
+ return {
2125
+ valueMarkerX: valueMarkerX,
2126
+ valueMarkerY: valueMarkerY
2127
+ };
2128
+ };
2129
+
2130
+ exports.getMarkerGaugeValueMarkerPositions = getMarkerGaugeValueMarkerPositions;
2131
+ /**
2132
+ * sort the ranges in ascending order
2133
+ * @method getSortedRanges
2134
+ * @param {Array} ranges
2135
+ * @return {Array} sortedRanges
2136
+ */
2137
+
2138
+ var getSortedRanges = function getSortedRanges(ranges) {
2139
+ return ranges.sort(function (a, b) {
2140
+ return a.from - b.from;
2141
+ });
2142
+ };
2143
+
2144
+ exports.getSortedRanges = getSortedRanges;
2145
+ /**
2146
+ * validate whether ranges prop is valid - continuous ranges, range.to < range.from, range.from != range.to
2147
+ * @method validateRanges
2148
+ * @param {Array} ranges
2149
+ * @return {String} error
2150
+ */
2151
+
2152
+ var validateRanges = function validateRanges(ranges) {
2153
+ if (!ranges.length) {
2154
+ return i18n_1._('Prop "ranges" is missing entries');
2155
+ } // check whether a range has "from" >= "to" eg: 10 - 10, 100 - 10, -20 - -10 are invalid
2156
+
2157
+
2158
+ if (ranges.some(function (range) {
2159
+ return range.from >= range.to;
2160
+ })) {
2161
+ return i18n_1._('Prop "ranges" has invalid entries: invalid range');
2162
+ } // check whether ranges have duplicate "from/to" eg: 0 - 50, 25 - 50
2163
+
2164
+
2165
+ if (ranges.length !== lodash_1.uniqBy(ranges, 'to').length || ranges.length !== lodash_1.uniqBy(ranges, 'from').length) {
2166
+ return i18n_1._('Prop "ranges" has invalid entries: duplicate values');
2167
+ }
2168
+
2169
+ var sortedRanges = exports.getSortedRanges(ranges); // check whether ranges are continuous eg: 0 - 10, 10 - 20, 20 - 30
2170
+
2171
+ for (var i = 1; i < sortedRanges.length; i += 1) {
2172
+ if (sortedRanges[i].from !== sortedRanges[i - 1].to) {
2173
+ return i18n_1._('Prop "ranges" has invalid entries: discontinuous ranges');
2174
+ }
2175
+ }
2176
+
2177
+ return null;
2178
+ };
2179
+
2180
+ exports.validateRanges = validateRanges;
2181
+ /**
2182
+ * calculate min and max value of gauge
2183
+ * @method getGaugeRange
2184
+ * @param {Array} ranges
2185
+ * @return {Object} gaugeRange
2186
+ * @return {Number} gaugeRange.min
2187
+ * @return {Number} gaugeRange.max
2188
+ */
2189
+
2190
+ var getGaugeRange = function getGaugeRange(ranges) {
2191
+ var min = Math.min.apply(Math, _toConsumableArray(ranges.map(function (range) {
2192
+ return range.from;
2193
+ })));
2194
+ var max = Math.max.apply(Math, _toConsumableArray(ranges.map(function (range) {
2195
+ return range.to;
2196
+ })));
2197
+ return {
2198
+ min: min,
2199
+ max: max
2200
+ };
2201
+ };
2202
+
2203
+ exports.getGaugeRange = getGaugeRange;
2204
+ /**
2205
+ * calculate stop offsets for linear gradient
2206
+ * @method getGradientStopOffsets
2207
+ * @param {Array} ranges
2208
+ * @param {String} orientation
2209
+ * @return {Array} cumulativeOffsets
2210
+ */
2211
+
2212
+ var getGradientStopOffsets = function getGradientStopOffsets(_ref15) {
2213
+ var ranges = _ref15.ranges,
2214
+ orientation = _ref15.orientation;
2215
+
2216
+ var _exports$getGaugeRang = exports.getGaugeRange(ranges),
2217
+ min = _exports$getGaugeRang.min,
2218
+ max = _exports$getGaugeRang.max;
2219
+
2220
+ var offsetScale = (GRADIENT_STOP_OFFSET_MAX - GRADIENT_STOP_OFFSET_MIN) / (max - min);
2221
+ var offsets = ranges.map(function (range) {
2222
+ return Math.abs(range.from - range.to) * offsetScale;
2223
+ }); // When orientation is vertical, since the gauge starts from bottom to top, linear gradient should be reversed
2224
+
2225
+ offsets = orientation === 'vertical' ? offsets.reverse() : offsets;
2226
+ var cumulativeOffsets = [];
2227
+ offsets.reduce(function (accumulator, currentValue, idx) {
2228
+ cumulativeOffsets[idx] = accumulator + currentValue;
2229
+ return cumulativeOffsets[idx];
2230
+ }, 0);
2231
+ return cumulativeOffsets;
2232
+ };
2233
+
2234
+ exports.getGradientStopOffsets = getGradientStopOffsets;
2235
+ /**
2236
+ * calculate stop colors for linear gradient
2237
+ * @method getGradientStopColors
2238
+ * @param {Array} ranges
2239
+ * @param {String} orientation
2240
+ * @return {Array} stopColors
2241
+ */
2242
+
2243
+ var getGradientStopColors = function getGradientStopColors(_ref16) {
2244
+ var ranges = _ref16.ranges,
2245
+ orientation = _ref16.orientation;
2246
+ var stopColors = ranges.map(function (range) {
2247
+ return range.value;
2248
+ }); // When orientation is vertical, since the gauge starts from bottom to top, linear gradient should be reversed
2249
+
2250
+ return orientation === 'vertical' ? stopColors.reverse() : stopColors;
2251
+ };
2252
+
2253
+ exports.getGradientStopColors = getGradientStopColors;
2254
+ /**
2255
+ * calculate linear gradient stops from ranges
2256
+ * @method getGradientStops
2257
+ * @param {Object} input
2258
+ * @param {Array} ranges
2259
+ * @param {String} orientation
2260
+ * @return {Array} stops
2261
+ */
2262
+
2263
+ var getGradientStops = function getGradientStops(_ref17) {
2264
+ var ranges = _ref17.ranges,
2265
+ orientation = _ref17.orientation;
2266
+ var stops = [];
2267
+ var offsets = exports.getGradientStopOffsets({
2268
+ ranges: ranges,
2269
+ orientation: orientation
2270
+ });
2271
+ var stopColors = exports.getGradientStopColors({
2272
+ ranges: ranges,
2273
+ orientation: orientation
2274
+ }); // Initialize stops with the first color stop
2275
+
2276
+ stops.push({
2277
+ offset: "".concat(offsets[0], "%"),
2278
+ stopColor: stopColors[0]
2279
+ }); // Add the remaining color stops with gradient change at each stop
2280
+
2281
+ for (var i = 1; i < ranges.length; i += 1) {
2282
+ stops.push({
2283
+ offset: "".concat(offsets[i - 1], "%"),
2284
+ stopColor: stopColors[i]
2285
+ });
2286
+ stops.push({
2287
+ offset: "".concat(offsets[i], "%"),
2288
+ stopColor: stopColors[i]
2289
+ });
2290
+ }
2291
+
2292
+ return stops;
2293
+ };
2294
+
2295
+ exports.getGradientStops = getGradientStops;
2296
+ /**
2297
+ * calculate linear gradient dimensions
2298
+ * @method getGradientDimensions
2299
+ * @param {String} orientation
2300
+ * @return {Object} dimensions
2301
+ * @return {String} dimensions.x1
2302
+ * @return {String} dimensions.y1
2303
+ * @return {String} dimensions.x2
2304
+ * @return {String} dimensions.y2
2305
+ */
2306
+
2307
+ var getGradientDimensions = function getGradientDimensions(orientation) {
2308
+ var x1 = '0%';
2309
+ var y1 = '0%';
2310
+ var x2 = orientation === 'horizontal' ? '100%' : '0%';
2311
+ var y2 = orientation === 'horizontal' ? '0%' : '100%';
2312
+ return {
2313
+ x1: x1,
2314
+ y1: y1,
2315
+ x2: x2,
2316
+ y2: y2
2317
+ };
2318
+ };
2319
+
2320
+ exports.getGradientDimensions = getGradientDimensions; // map for new options names to old option names
2321
+
2322
+ var gaugeOptionsMapping = {
2323
+ majorTickInterval: 'majorUnit',
2324
+ gaugeRanges: 'ranges'
2325
+ };
2326
+ /**
2327
+ * Helper method to update the option names which can be mapped to pure component options
2328
+ * @method mapToOldKey
2329
+ * @param {Object} options
2330
+ * @returns {Object}
2331
+ */
2332
+
2333
+ var mapToOldKey = function mapToOldKey(options) {
2334
+ return lodash_1.mapKeys(options, function (val, key) {
2335
+ return gaugeOptionsMapping[key] ? gaugeOptionsMapping[key] : key;
2336
+ });
2337
+ };
2338
+
2339
+ exports.mapToOldKey = mapToOldKey;
2340
+ /**
2341
+ * Helper method to map labelDisplay and valueDisplay options to pure component option names
2342
+ * @method mapToOldKey
2343
+ * @param {string} labelOrValue
2344
+ * @param {Object} options
2345
+ * @returns {Object}
2346
+ */
2347
+
2348
+ var mapValueLabelDisplay = function mapValueLabelDisplay(labelOrValue, options) {
2349
+ var rangeOrValue = labelOrValue === 'value' ? 'Value' : 'Range';
2350
+ var showKey = labelOrValue === 'value' ? 'showValue' : 'showLabels';
2351
+ var percentKey = "usePercentage".concat(rangeOrValue);
2352
+ var optionString = "".concat(labelOrValue, "Display");
2353
+ var newOptions = Object.assign({}, options);
2354
+
2355
+ if (newOptions[optionString]) {
2356
+ if (newOptions[optionString] === 'number') {
2357
+ newOptions[showKey] = true;
2358
+ newOptions[percentKey] = false;
2359
+ } else if (newOptions[optionString] === 'percentage') {
2360
+ newOptions[showKey] = true;
2361
+ newOptions[percentKey] = true;
2362
+ } else {
2363
+ newOptions[showKey] = false;
2364
+ newOptions[percentKey] = false;
2365
+ }
2366
+ }
2367
+
2368
+ return lodash_1.omit(newOptions, [optionString]);
2369
+ };
2370
+
2371
+ exports.mapValueLabelDisplay = mapValueLabelDisplay;
2372
+ /**
2373
+ * Chained helper for mapping the option properties (and values) we expose in config.ts into property values that pure component accepts
2374
+ * This is for options that has new key name and can not directly be mapped with pure component props
2375
+ * @method convertToGaugeProperties
2376
+ * @param {Object} originalOptions
2377
+ * @returns {Object}
2378
+ */
2379
+
2380
+ var convertToGaugeProperties = function convertToGaugeProperties(originalOptions) {
2381
+ return lodash_1.chain(exports.mapToOldKey(originalOptions)).thru(function (options) {
2382
+ return exports.mapValueLabelDisplay('label', options);
2383
+ }).thru(function (options) {
2384
+ return exports.mapValueLabelDisplay('value', options);
2385
+ }).value();
2386
+ };
2387
+
2388
+ exports.convertToGaugeProperties = convertToGaugeProperties;
2389
+
2390
+ /***/ }),
2391
+ /* 72 */,
2392
+ /* 73 */,
2393
+ /* 74 */,
2394
+ /* 75 */,
2395
+ /* 76 */,
2396
+ /* 77 */,
2397
+ /* 78 */,
2398
+ /* 79 */,
2399
+ /* 80 */,
2400
+ /* 81 */,
2401
+ /* 82 */,
2402
+ /* 83 */,
2403
+ /* 84 */,
2404
+ /* 85 */,
2405
+ /* 86 */,
2406
+ /* 87 */,
2407
+ /* 88 */,
2408
+ /* 89 */,
2409
+ /* 90 */
2410
+ /***/ (function(module, exports, __webpack_require__) {
2411
+
2412
+ "use strict";
2413
+
2414
+
2415
+ Object.defineProperty(exports, "__esModule", {
2416
+ value: true
2417
+ });
2418
+
2419
+ var i18n_1 = __webpack_require__(3);
2420
+
2421
+ var gauge = {
2422
+ label: i18n_1._('Gauge Settings'),
2423
+ layout: [[{
2424
+ label: i18n_1._('Value Display'),
2425
+ option: 'valueDisplay',
2426
+ editor: 'editor.radioBar',
2427
+ editorProps: {
2428
+ values: [{
2429
+ label: i18n_1._('Number'),
2430
+ value: 'number'
2431
+ }, {
2432
+ label: i18n_1._('Percentage'),
2433
+ value: 'percentage'
2434
+ }, {
2435
+ label: i18n_1._('Off'),
2436
+ value: 'off'
2437
+ }]
2438
+ }
2439
+ }], [{
2440
+ label: i18n_1._('Label Display'),
2441
+ option: 'labelDisplay',
2442
+ editor: 'editor.radioBar',
2443
+ editorProps: {
2444
+ values: [{
2445
+ label: i18n_1._('Numbers'),
2446
+ value: 'number'
2447
+ }, {
2448
+ label: i18n_1._('Percentages'),
2449
+ value: 'percentage'
2450
+ }, {
2451
+ label: i18n_1._('Off'),
2452
+ value: 'off'
2453
+ }]
2454
+ }
2455
+ }], [{
2456
+ label: i18n_1._('Orientation'),
2457
+ option: 'orientation',
2458
+ editor: 'editor.radioBar',
2459
+ editorProps: {
2460
+ values: [{
2461
+ label: i18n_1._('Vertical'),
2462
+ value: 'vertical'
2463
+ }, {
2464
+ label: i18n_1._('Horizontal'),
2465
+ value: 'horizontal'
2466
+ }]
2467
+ }
2468
+ }]]
2469
+ };
2470
+ exports.default = gauge;
2471
+
2472
+ /***/ }),
2473
+ /* 91 */
2474
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2475
+
2476
+ "use strict";
2477
+ __webpack_require__.r(__webpack_exports__);
2478
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MajorTick", function() { return MajorTick; });
2479
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionMajorTick", function() { return positionMajorTick; });
2480
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43);
2481
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
2482
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
2483
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
2484
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
2485
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
2486
+ /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
2487
+ /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
2488
+ /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20);
2489
+ /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+ var DEFAULT_NUM_OF_TICKS = 5;
2496
+ var TICK_LENGTH_DELTA = 5;
2497
+ var TICK_LABEL_PADDING_FACTOR = 3.2;
2498
+ var MajorTickLine = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.line.withConfig({
2499
+ displayName: "GaugeMajorTicks__MajorTickLine",
2500
+ componentId: "mchiad-0"
2501
+ })(["stroke:", ";stroke-width:2px;stroke-dasharray:", ";"], function (props) {
2502
+ return props.majorTickStrokeColor;
2503
+ }, function (props) {
2504
+ return props.index === 0 ? 0 : 3;
2505
+ });
2506
+ var MajorTickLabel = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.text.withConfig({
2507
+ displayName: "GaugeMajorTicks__MajorTickLabel",
2508
+ componentId: "mchiad-1"
2509
+ })(["font-size:12px;font-family:Splunk Platform Sans,sans-serif;line-height:19px;fill:", ";text-anchor:middle;text-align:center;"], function (props) {
2510
+ return props.majorTickFillColor;
2511
+ });
2512
+ var MajorTick = function MajorTick(_ref) {
2513
+ var index = _ref.index,
2514
+ x1 = _ref.x1,
2515
+ y1 = _ref.y1,
2516
+ x2 = _ref.x2,
2517
+ y2 = _ref.y2,
2518
+ showLabels = _ref.showLabels,
2519
+ label = _ref.label,
2520
+ labelX = _ref.labelX,
2521
+ labelY = _ref.labelY,
2522
+ majorTickStrokeColor = _ref.majorTickStrokeColor,
2523
+ majorTickFillColor = _ref.majorTickFillColor;
2524
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTickLine, {
2525
+ index: index,
2526
+ x1: x1,
2527
+ y1: y1,
2528
+ x2: x2,
2529
+ y2: y2,
2530
+ majorTickStrokeColor: majorTickStrokeColor
2531
+ }), showLabels && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTickLabel, {
2532
+ x: labelX,
2533
+ y: labelY,
2534
+ majorTickFillColor: majorTickFillColor
2535
+ }, Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["isNumerial"])(label) ? Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(label, 0, {
2536
+ useThousandSeparators: true,
2537
+ useTrendUnits: true
2538
+ }) : label));
2539
+ };
2540
+ MajorTick.propTypes = {
2541
+ index: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2542
+ x1: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2543
+ y1: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2544
+ x2: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2545
+ y2: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2546
+ showLabels: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
2547
+ label: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number]),
2548
+ labelX: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2549
+ labelY: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2550
+ majorTickStrokeColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
2551
+ majorTickFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
2552
+ };
2553
+ /**
2554
+ * calculate position for each major tick
2555
+ * @method positionMajorTick
2556
+ * @param {Object} input
2557
+ * @param {Number} input.width
2558
+ * @param {Number} input.height
2559
+ * @param {Number} input.startX start x for rendering the first major tick
2560
+ * @param {Number} input.startY start y for rendering the first major tick
2561
+ * @param {String} input.orientation
2562
+ * @param {Number} input.numOfTicks how many ticks need to render
2563
+ * @param {Number} input.i index of major tick
2564
+ * @return {Object} MajorTick positions
2565
+ */
2566
+
2567
+ var positionMajorTick = function positionMajorTick(_ref2) {
2568
+ var width = _ref2.width,
2569
+ height = _ref2.height,
2570
+ startX = _ref2.startX,
2571
+ startY = _ref2.startY,
2572
+ orientation = _ref2.orientation,
2573
+ numOfTicks = _ref2.numOfTicks,
2574
+ i = _ref2.i;
2575
+ var x1 = startX;
2576
+ var y1 = startY;
2577
+ var x2 = startX;
2578
+ var y2 = startY;
2579
+ var labelX = startX;
2580
+ var labelY;
2581
+
2582
+ if (orientation === 'vertical') {
2583
+ var y = height / numOfTicks * (numOfTicks - i) + startY;
2584
+ x1 -= TICK_LENGTH_DELTA;
2585
+ y1 = y;
2586
+ x2 += width + TICK_LENGTH_DELTA;
2587
+ y2 = y;
2588
+ labelX += width + TICK_LENGTH_DELTA * TICK_LABEL_PADDING_FACTOR;
2589
+ labelY = y;
2590
+ } else {
2591
+ var x = width / numOfTicks * i + startX;
2592
+ x1 = x;
2593
+ y1 -= TICK_LENGTH_DELTA;
2594
+ x2 = x;
2595
+ y2 += height + TICK_LENGTH_DELTA;
2596
+ labelX = x;
2597
+ labelY = y2 + 16;
2598
+ }
2599
+
2600
+ return {
2601
+ x1: x1,
2602
+ y1: y1,
2603
+ x2: x2,
2604
+ y2: y2,
2605
+ labelX: labelX,
2606
+ labelY: labelY
2607
+ };
2608
+ };
2609
+
2610
+ var MajorTicks = function MajorTicks(_ref3) {
2611
+ var props = _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _ref3);
2612
+
2613
+ var width = props.width,
2614
+ height = props.height,
2615
+ startX = props.startX,
2616
+ startY = props.startY,
2617
+ min = props.min,
2618
+ max = props.max,
2619
+ majorUnit = props.majorUnit,
2620
+ orientation = props.orientation,
2621
+ showLabels = props.showLabels,
2622
+ usePercentageRange = props.usePercentageRange,
2623
+ majorTickFillColor = props.majorTickFillColor,
2624
+ majorTickStrokeColor = props.majorTickStrokeColor;
2625
+ var range = max - min;
2626
+ var numOfTicks = majorUnit === 'auto' || Number.isNaN(Number(majorUnit)) || majorUnit <= 0 ? DEFAULT_NUM_OF_TICKS : range / majorUnit;
2627
+ var majorTicks = [];
2628
+
2629
+ for (var i = 0; i <= numOfTicks; i += 1) {
2630
+ var _positionMajorTick = positionMajorTick({
2631
+ width: width,
2632
+ height: height,
2633
+ startX: startX,
2634
+ startY: startY,
2635
+ orientation: orientation,
2636
+ numOfTicks: numOfTicks,
2637
+ i: i
2638
+ }),
2639
+ x1 = _positionMajorTick.x1,
2640
+ y1 = _positionMajorTick.y1,
2641
+ x2 = _positionMajorTick.x2,
2642
+ y2 = _positionMajorTick.y2,
2643
+ labelX = _positionMajorTick.labelX,
2644
+ labelY = _positionMajorTick.labelY;
2645
+
2646
+ var label = usePercentageRange ? "".concat(parseInt((i / numOfTicks - min / range) * 100, 10), "%") : parseInt(min + range / numOfTicks * i, 10);
2647
+ majorTicks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTick, {
2648
+ key: i,
2649
+ index: i,
2650
+ x1: x1,
2651
+ y1: y1,
2652
+ x2: x2,
2653
+ y2: y2,
2654
+ showLabels: showLabels,
2655
+ label: label,
2656
+ labelX: labelX,
2657
+ labelY: labelY,
2658
+ majorTickFillColor: majorTickFillColor,
2659
+ majorTickStrokeColor: majorTickStrokeColor
2660
+ }));
2661
+ } // if the gauge is not divided evenly, put the last tick at the end of the gauge
2662
+
2663
+
2664
+ if (!Number.isInteger(numOfTicks)) {
2665
+ var extraNumOfTicks = Math.ceil(numOfTicks);
2666
+
2667
+ var _positionMajorTick2 = positionMajorTick({
2668
+ width: width,
2669
+ height: height,
2670
+ startX: startX,
2671
+ startY: startY,
2672
+ orientation: orientation,
2673
+ numOfTicks: extraNumOfTicks,
2674
+ i: extraNumOfTicks
2675
+ }),
2676
+ _x = _positionMajorTick2.x1,
2677
+ _y = _positionMajorTick2.y1,
2678
+ _x2 = _positionMajorTick2.x2,
2679
+ _y2 = _positionMajorTick2.y2,
2680
+ _labelX = _positionMajorTick2.labelX,
2681
+ _labelY = _positionMajorTick2.labelY;
2682
+
2683
+ majorTicks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTick, {
2684
+ key: extraNumOfTicks,
2685
+ id: extraNumOfTicks,
2686
+ x1: _x,
2687
+ y1: _y,
2688
+ x2: _x2,
2689
+ y2: _y2,
2690
+ showLabels: showLabels,
2691
+ label: usePercentageRange ? '100%' : max,
2692
+ labelX: _labelX,
2693
+ labelY: _labelY,
2694
+ majorTickFillColor: majorTickFillColor,
2695
+ majorTickStrokeColor: majorTickStrokeColor
2696
+ }));
2697
+ }
2698
+
2699
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, majorTicks);
2700
+ };
2701
+
2702
+ MajorTicks.propTypes = {
2703
+ width: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2704
+ height: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2705
+ startX: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2706
+ startY: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2707
+ min: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2708
+ max: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2709
+ majorUnit: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number]),
2710
+ orientation: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
2711
+ showLabels: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
2712
+ usePercentageRange: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
2713
+ majorTickFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
2714
+ majorTickStrokeColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
2715
+ };
2716
+ MajorTicks.defaultProps = {
2717
+ min: 0,
2718
+ max: 100,
2719
+ majorUnit: 'auto',
2720
+ orientation: 'horizontal',
2721
+ showLabels: true,
2722
+ usePercentageRange: false
2723
+ };
2724
+ /* harmony default export */ __webpack_exports__["default"] = (MajorTicks);
2725
+
2726
+ /***/ }),
2727
+ /* 92 */
2728
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
2729
+
2730
+ "use strict";
2731
+ __webpack_require__.r(__webpack_exports__);
2732
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionValueMarkerRect", function() { return positionValueMarkerRect; });
2733
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionLabel", function() { return positionLabel; });
2734
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43);
2735
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
2736
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
2737
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
2738
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
2739
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
2740
+ /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
2741
+ /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
2742
+ /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20);
2743
+ /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);
2744
+
2745
+
2746
+
2747
+
2748
+
2749
+ var MARKER_THICKNESS = 15;
2750
+ var MARKER_INNER_LENGTH = 30;
2751
+ var MARKER_LABEL_WIDTH = 60;
2752
+ var MARKER_LABEL_HEIGHT = 25;
2753
+ var RADIUS = 2;
2754
+ var DELTA_LENGTH = 12;
2755
+ var ValueMarkerRect = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.path.withConfig({
2756
+ displayName: "GaugeValueMarker__ValueMarkerRect",
2757
+ componentId: "sc-1bxkeao-0"
2758
+ })(["stroke-width:2px;fill:", ";"], function (props) {
2759
+ return props.valueMarkerFillColor;
2760
+ });
2761
+ var ValueMarkerLabelRect = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.rect.withConfig({
2762
+ displayName: "GaugeValueMarker__ValueMarkerLabelRect",
2763
+ componentId: "sc-1bxkeao-1"
2764
+ })(["fill:", ";"], function (props) {
2765
+ return props.valueMarkerFillColor;
2766
+ });
2767
+ var ValueMarkerLabel = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.text.withConfig({
2768
+ displayName: "GaugeValueMarker__ValueMarkerLabel",
2769
+ componentId: "sc-1bxkeao-2"
2770
+ })(["fill:", ";font-size:14px;font-family:Splunk Platform Sans,sans-serif;line-height:16px;text-anchor:middle;text-align:center;dominant-baseline:middle;"], function (props) {
2771
+ return props.valueMarkerLabelFillColor;
2772
+ });
2773
+ /**
2774
+ * calculate the path of Value Marker shape
2775
+ * @method positionValueMarkerRect
2776
+ * @param {Object} input
2777
+ * @param {Number} input.x
2778
+ * @param {Number} input.y
2779
+ * @param {String} input.orientation
2780
+ * @param {Number} input.valueMarkerRectLength
2781
+ * @return {String} d containing a series of path commands that define the path to be
2782
+ */
2783
+
2784
+ var positionValueMarkerRect = function positionValueMarkerRect(_ref) {
2785
+ var x = _ref.x,
2786
+ y = _ref.y,
2787
+ orientation = _ref.orientation,
2788
+ valueMarkerRectLength = _ref.valueMarkerRectLength;
2789
+ var hLength = MARKER_THICKNESS;
2790
+ var vLength = valueMarkerRectLength;
2791
+ var markerStartX = x - MARKER_THICKNESS;
2792
+ var markerStartY = y;
2793
+ var innerHLength = hLength / 3;
2794
+ var innerVLength = MARKER_INNER_LENGTH;
2795
+ var innerStartX = markerStartX + innerHLength;
2796
+ var innerStartY = markerStartY + 7;
2797
+
2798
+ if (orientation === 'vertical') {
2799
+ hLength = valueMarkerRectLength;
2800
+ vLength = MARKER_THICKNESS;
2801
+ markerStartX = x;
2802
+ innerHLength = MARKER_INNER_LENGTH;
2803
+ innerVLength = vLength / 3;
2804
+ innerStartX = markerStartX + 7;
2805
+ innerStartY = markerStartY + innerVLength;
2806
+ }
2807
+
2808
+ return "M".concat(markerStartX, ",").concat(markerStartY, "h").concat(hLength, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 1 ").concat(RADIUS, ",").concat(RADIUS, "v").concat(vLength - 2 * RADIUS, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 1 ").concat(-RADIUS, ",").concat(RADIUS, "h").concat(-hLength, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 1 ").concat(-RADIUS, ",").concat(-RADIUS, "v").concat(2 * RADIUS - vLength, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 1 ").concat(RADIUS, ",").concat(-RADIUS, "z") + "M".concat(innerStartX, ",").concat(innerStartY, "v").concat(innerVLength - RADIUS, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 0 ").concat(RADIUS, ",").concat(RADIUS, "h").concat(innerHLength - 2 * RADIUS, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 0 ").concat(RADIUS, ",").concat(-RADIUS, "v").concat(RADIUS - innerVLength, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 0 ").concat(-RADIUS, ",").concat(-RADIUS, "h").concat(2 * RADIUS - innerHLength, "a").concat(RADIUS, ",").concat(RADIUS, " 0 0 0 ").concat(-RADIUS, ",").concat(RADIUS, "z");
2809
+ };
2810
+ /**
2811
+ * calculate the position of value marker label
2812
+ * @method positionLabel
2813
+ * @param {Object} input
2814
+ * @param {Number} input.x
2815
+ * @param {Number} input.y
2816
+ * @param {Number} input.length gauge thickness
2817
+ * @param {String} input.orientation
2818
+ * @return {Object} positions
2819
+ * @return {Number} positions.labelRectX x of value marker label rect
2820
+ * @return {Number} positions.labelRectY y of value marker label rect
2821
+ * @return {Number} positions.labelX x of value marker label text
2822
+ * @return {Number} positions.labelY y of value marker label text
2823
+ */
2824
+
2825
+ var positionLabel = function positionLabel(_ref2) {
2826
+ var x = _ref2.x,
2827
+ y = _ref2.y,
2828
+ length = _ref2.length,
2829
+ orientation = _ref2.orientation; // for horizontal view
2830
+
2831
+ var labelRectX = x - MARKER_THICKNESS / 2 - MARKER_LABEL_WIDTH / 2;
2832
+ var labelRectY = y + length;
2833
+
2834
+ if (orientation === 'vertical') {
2835
+ labelRectX = x + length;
2836
+ labelRectY = y - (MARKER_LABEL_HEIGHT - MARKER_THICKNESS) / 2;
2837
+ }
2838
+
2839
+ var labelX = labelRectX + MARKER_LABEL_WIDTH / 2;
2840
+ var labelY = labelRectY + MARKER_LABEL_HEIGHT / 2;
2841
+ return {
2842
+ labelRectX: labelRectX,
2843
+ labelRectY: labelRectY,
2844
+ labelX: labelX,
2845
+ labelY: labelY
2846
+ };
2847
+ };
2848
+
2849
+ var ValueMarker = function ValueMarker(_ref3) {
2850
+ var props = _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _ref3);
2851
+
2852
+ var x = props.x,
2853
+ y = props.y,
2854
+ length = props.length,
2855
+ min = props.min,
2856
+ max = props.max,
2857
+ value = props.value,
2858
+ orientation = props.orientation,
2859
+ showValue = props.showValue,
2860
+ usePercentageValue = props.usePercentageValue,
2861
+ valueMarkerFillColor = props.valueMarkerFillColor,
2862
+ valueMarkerLabelFillColor = props.valueMarkerLabelFillColor;
2863
+ var valueMarkerRectLength = length + DELTA_LENGTH;
2864
+
2865
+ var _positionLabel = positionLabel({
2866
+ x: x,
2867
+ y: y,
2868
+ length: length,
2869
+ orientation: orientation
2870
+ }),
2871
+ labelRectX = _positionLabel.labelRectX,
2872
+ labelRectY = _positionLabel.labelRectY,
2873
+ labelX = _positionLabel.labelX,
2874
+ labelY = _positionLabel.labelY;
2875
+
2876
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(ValueMarkerRect, {
2877
+ "data-test": "value-marker-rect",
2878
+ d: positionValueMarkerRect({
2879
+ x: x,
2880
+ y: y,
2881
+ orientation: orientation,
2882
+ valueMarkerRectLength: valueMarkerRectLength
2883
+ }),
2884
+ valueMarkerFillColor: valueMarkerFillColor
2885
+ }), showValue && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(ValueMarkerLabelRect, {
2886
+ "data-test": "value-marker-label-rect",
2887
+ x: labelRectX,
2888
+ y: labelRectY,
2889
+ width: MARKER_LABEL_WIDTH,
2890
+ height: MARKER_LABEL_HEIGHT,
2891
+ rx: RADIUS,
2892
+ ry: RADIUS,
2893
+ valueMarkerFillColor: valueMarkerFillColor
2894
+ }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(ValueMarkerLabel, {
2895
+ "data-test": "value-marker-label",
2896
+ x: labelX,
2897
+ y: labelY,
2898
+ valueMarkerLabelFillColor: valueMarkerLabelFillColor
2899
+ }, usePercentageValue ? "".concat((value / (max - min) * 100).toFixed(2), "%") : Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(value, 0, {
2900
+ useThousandSeparators: true,
2901
+ useTrendUnits: true
2902
+ }))));
2903
+ };
2904
+
2905
+ ValueMarker.propTypes = {
2906
+ x: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2907
+ y: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2908
+ length: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2909
+ min: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2910
+ max: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2911
+ value: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
2912
+ orientation: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
2913
+ showValue: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
2914
+ usePercentageValue: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
2915
+ valueMarkerFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
2916
+ valueMarkerLabelFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
2917
+ };
2918
+ ValueMarker.defaultProps = {
2919
+ min: 0,
2920
+ max: 100,
2921
+ orientation: 'horizontal',
2922
+ showValue: true,
2923
+ usePercentageValue: false
2924
+ };
2925
+ /* harmony default export */ __webpack_exports__["default"] = (ValueMarker);
2926
+
2927
+ /***/ }),
2928
+ /* 93 */,
2929
+ /* 94 */,
2930
+ /* 95 */,
2931
+ /* 96 */,
2932
+ /* 97 */,
2933
+ /* 98 */,
2934
+ /* 99 */,
2935
+ /* 100 */,
2936
+ /* 101 */,
2937
+ /* 102 */,
2938
+ /* 103 */,
2939
+ /* 104 */,
2940
+ /* 105 */,
2941
+ /* 106 */,
2942
+ /* 107 */,
2943
+ /* 108 */,
2944
+ /* 109 */,
2945
+ /* 110 */,
2946
+ /* 111 */,
2947
+ /* 112 */,
2948
+ /* 113 */,
2949
+ /* 114 */,
2950
+ /* 115 */,
2951
+ /* 116 */,
2952
+ /* 117 */,
2953
+ /* 118 */,
2954
+ /* 119 */,
2955
+ /* 120 */,
2956
+ /* 121 */,
2957
+ /* 122 */
2958
+ /***/ (function(module, exports, __webpack_require__) {
2959
+
2960
+ "use strict";
2961
+
2962
+
2963
+ var __rest = this && this.__rest || function (s, e) {
2964
+ var t = {};
2965
+
2966
+ for (var p in s) {
2967
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2968
+ }
2969
+
2970
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2971
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2972
+ }
2973
+ return t;
2974
+ };
2975
+
2976
+ Object.defineProperty(exports, "__esModule", {
2977
+ value: true
2978
+ });
2979
+ exports.config = exports.computeVizProps = exports.PureMarkerGauge = void 0;
2980
+
2981
+ var lodash_1 = __webpack_require__(2);
2982
+
2983
+ var MarkerGauge_1 = __webpack_require__(189);
2984
+
2985
+ var config_1 = __webpack_require__(191);
2986
+
2987
+ exports.config = config_1.default;
2988
+
2989
+ var withDashboardViz_1 = __webpack_require__(27);
2990
+
2991
+ var gaugeUtils_1 = __webpack_require__(71);
2992
+
2993
+ exports.PureMarkerGauge = MarkerGauge_1.default;
2994
+ var validOptions = Object.keys(config_1.default.optionsSchema);
2995
+
2996
+ var computeVizProps = function computeVizProps(_a) {
2997
+ var props = __rest(_a, []);
2998
+
2999
+ var options = lodash_1.chain(props).pick(validOptions).thru(gaugeUtils_1.convertToGaugeProperties).value();
3000
+ var defaultColors = {
3001
+ fillColor: config_1.default.themes.defaultFillColor(props),
3002
+ majorTickFillColor: config_1.default.themes.majorTickFillColor(props),
3003
+ majorTickStrokeColor: config_1.default.themes.majorTickStrokeColor(props),
3004
+ valueMarkerFillColor: config_1.default.themes.valueMarkerFillColor(props),
3005
+ valueMarkerLabelFillColor: config_1.default.themes.valueMarkerLabelFillColor(props)
3006
+ };
3007
+ return Object.assign(Object.assign({}, options), defaultColors);
3008
+ };
3009
+
3010
+ exports.computeVizProps = computeVizProps;
3011
+ var viz = withDashboardViz_1.default({
3012
+ ReactViz: MarkerGauge_1.default,
3013
+ computeVizProps: exports.computeVizProps,
3014
+ vizConfig: config_1.default
3015
+ });
3016
+ exports.default = viz;
3017
+
3018
+ /***/ }),
3019
+ /* 123 */,
3020
+ /* 124 */,
3021
+ /* 125 */,
3022
+ /* 126 */,
3023
+ /* 127 */,
3024
+ /* 128 */,
3025
+ /* 129 */,
3026
+ /* 130 */,
3027
+ /* 131 */,
3028
+ /* 132 */,
3029
+ /* 133 */,
3030
+ /* 134 */,
3031
+ /* 135 */,
3032
+ /* 136 */,
3033
+ /* 137 */,
3034
+ /* 138 */,
3035
+ /* 139 */,
3036
+ /* 140 */,
3037
+ /* 141 */,
3038
+ /* 142 */,
3039
+ /* 143 */,
3040
+ /* 144 */,
3041
+ /* 145 */,
3042
+ /* 146 */,
3043
+ /* 147 */,
3044
+ /* 148 */,
3045
+ /* 149 */,
3046
+ /* 150 */,
3047
+ /* 151 */,
3048
+ /* 152 */,
3049
+ /* 153 */,
3050
+ /* 154 */,
3051
+ /* 155 */,
3052
+ /* 156 */,
3053
+ /* 157 */,
3054
+ /* 158 */,
3055
+ /* 159 */,
3056
+ /* 160 */,
3057
+ /* 161 */,
3058
+ /* 162 */,
3059
+ /* 163 */,
3060
+ /* 164 */,
3061
+ /* 165 */,
3062
+ /* 166 */,
3063
+ /* 167 */,
3064
+ /* 168 */,
3065
+ /* 169 */,
3066
+ /* 170 */,
3067
+ /* 171 */,
3068
+ /* 172 */,
3069
+ /* 173 */,
3070
+ /* 174 */,
3071
+ /* 175 */,
3072
+ /* 176 */,
3073
+ /* 177 */,
3074
+ /* 178 */,
3075
+ /* 179 */,
3076
+ /* 180 */,
3077
+ /* 181 */,
3078
+ /* 182 */,
3079
+ /* 183 */,
3080
+ /* 184 */,
3081
+ /* 185 */,
3082
+ /* 186 */,
3083
+ /* 187 */,
3084
+ /* 188 */
3085
+ /***/ (function(module, exports, __webpack_require__) {
3086
+
3087
+ "use strict";
3088
+
3089
+
3090
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
3091
+ if (k2 === undefined) k2 = k;
3092
+ Object.defineProperty(o, k2, {
3093
+ enumerable: true,
3094
+ get: function get() {
3095
+ return m[k];
3096
+ }
3097
+ });
3098
+ } : function (o, m, k, k2) {
3099
+ if (k2 === undefined) k2 = k;
3100
+ o[k2] = m[k];
3101
+ });
3102
+
3103
+ var __exportStar = this && this.__exportStar || function (m, exports) {
3104
+ for (var p in m) {
3105
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3106
+ }
3107
+ };
3108
+
3109
+ Object.defineProperty(exports, "__esModule", {
3110
+ value: true
3111
+ });
3112
+ exports.default = void 0;
3113
+
3114
+ __exportStar(__webpack_require__(122), exports);
3115
+
3116
+ var MarkerGauge_1 = __webpack_require__(122);
3117
+
3118
+ Object.defineProperty(exports, "default", {
3119
+ enumerable: true,
3120
+ get: function get() {
3121
+ return MarkerGauge_1.default;
3122
+ }
3123
+ });
3124
+
3125
+ /***/ }),
3126
+ /* 189 */
3127
+ /***/ (function(module, exports, __webpack_require__) {
3128
+
3129
+ "use strict";
3130
+
3131
+
3132
+ var __rest = this && this.__rest || function (s, e) {
3133
+ var t = {};
3134
+
3135
+ for (var p in s) {
3136
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
3137
+ }
3138
+
3139
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3140
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
3141
+ }
3142
+ return t;
3143
+ };
3144
+
3145
+ Object.defineProperty(exports, "__esModule", {
3146
+ value: true
3147
+ });
3148
+
3149
+ var React = __webpack_require__(1);
3150
+
3151
+ var react_1 = __webpack_require__(1);
3152
+
3153
+ var T = __webpack_require__(0);
3154
+
3155
+ var styled_components_1 = __webpack_require__(4);
3156
+
3157
+ var lodash_1 = __webpack_require__(2);
3158
+
3159
+ var i18n_1 = __webpack_require__(3);
3160
+
3161
+ var style_1 = __webpack_require__(13);
3162
+
3163
+ var SizeAwareWrapper_1 = __webpack_require__(17);
3164
+
3165
+ var Message_1 = __webpack_require__(9);
3166
+
3167
+ var id_1 = __webpack_require__(190);
3168
+
3169
+ var gaugeUtils_1 = __webpack_require__(71);
3170
+
3171
+ var GaugeMajorTicks_1 = __webpack_require__(91);
3172
+
3173
+ var GaugeValueMarker_1 = __webpack_require__(92);
3174
+
3175
+ var MAX_VERTICAL_CONTAINER_WIDTH = 200;
3176
+ var MIN_VERTICAL_CONTAINER_HEIGHT = 200;
3177
+ var MIN_HORIZONTAL_CONTAINER_WIDTH = 200;
3178
+ var MIN_HORIZONTAL_CONTAINER_HEIGHT = 100;
3179
+ var Container = styled_components_1.default.div.withConfig({
3180
+ displayName: "MarkerGauge__Container",
3181
+ componentId: "sc-10z02va-0"
3182
+ })(["overflow:hidden;", ";background-color:", ";"], function (props) {
3183
+ return style_1.toDimension(lodash_1.pick(props, ['width', 'height']));
3184
+ }, function (props) {
3185
+ return props.backgroundColor;
3186
+ });
3187
+ var MarkerGaugeWrapper = styled_components_1.default.div.withConfig({
3188
+ displayName: "MarkerGauge__MarkerGaugeWrapper",
3189
+ componentId: "sc-10z02va-1"
3190
+ })(["display:flex;justify-content:center;flex-direction:row;width:100%;height:100%;background-color:", ";"], function (props) {
3191
+ return props.backgroundColor;
3192
+ });
3193
+ var MarkerGaugeContainer = styled_components_1.default.div.withConfig({
3194
+ displayName: "MarkerGauge__MarkerGaugeContainer",
3195
+ componentId: "sc-10z02va-2"
3196
+ })(["overflow:hidden;position:relative;", ";"], function (props) {
3197
+ return style_1.toDimension(lodash_1.pick(props, ['width', 'height']));
3198
+ });
3199
+ var MarkerGaugeSVG = styled_components_1.default.svg.withConfig({
3200
+ displayName: "MarkerGauge__MarkerGaugeSVG",
3201
+ componentId: "sc-10z02va-3"
3202
+ })(["", ";"], function (props) {
3203
+ return style_1.toDimension(lodash_1.pick(props, ['width', 'height']));
3204
+ });
3205
+ var BackgroundBar = styled_components_1.default.rect.attrs({
3206
+ 'data-test': 'background-bar-rect'
3207
+ }).withConfig({
3208
+ displayName: "MarkerGauge__BackgroundBar",
3209
+ componentId: "sc-10z02va-4"
3210
+ })(["fill:", ";"], function (props) {
3211
+ return props.fillColor;
3212
+ });
3213
+ var MarkerBar = styled_components_1.default.rect.attrs({
3214
+ 'data-test': 'marker-bar-rect'
3215
+ }).withConfig({
3216
+ displayName: "MarkerGauge__MarkerBar",
3217
+ componentId: "sc-10z02va-5"
3218
+ })([""]);
3219
+
3220
+ var MarkerGauge = function MarkerGauge(_a) {
3221
+ var props = __rest(_a, []);
3222
+
3223
+ var width = props.width,
3224
+ height = props.height,
3225
+ value = props.value,
3226
+ orientation = props.orientation,
3227
+ majorUnit = props.majorUnit,
3228
+ showLabels = props.showLabels,
3229
+ showValue = props.showValue,
3230
+ usePercentageRange = props.usePercentageRange,
3231
+ usePercentageValue = props.usePercentageValue,
3232
+ backgroundColor = props.backgroundColor,
3233
+ fillColor = props.fillColor,
3234
+ ranges = props.ranges,
3235
+ majorTickFillColor = props.majorTickFillColor,
3236
+ majorTickStrokeColor = props.majorTickStrokeColor,
3237
+ valueMarkerFillColor = props.valueMarkerFillColor,
3238
+ valueMarkerLabelFillColor = props.valueMarkerLabelFillColor;
3239
+ /**
3240
+ * Standard error message render
3241
+ */
3242
+
3243
+ var errorMessage = react_1.useCallback(function (containerWidth, containerHeight, err, errID) {
3244
+ return React.createElement(Message_1.default, {
3245
+ width: containerWidth,
3246
+ height: containerHeight,
3247
+ message: err,
3248
+ level: "info",
3249
+ id: errID
3250
+ });
3251
+ }, []);
3252
+ var errorId = react_1.useMemo(function () {
3253
+ return id_1.createDOMID();
3254
+ }, []);
3255
+ /**
3256
+ * Pre-calculate linearGradientId, error, sortedRanges, gauge range and linear gradient
3257
+ */
3258
+
3259
+ var error = react_1.useMemo(function () {
3260
+ return gaugeUtils_1.validateRanges(ranges);
3261
+ }, [ranges]);
3262
+ var sortedRanges = react_1.useMemo(function () {
3263
+ return gaugeUtils_1.getSortedRanges(ranges);
3264
+ }, [ranges]);
3265
+
3266
+ var _react_1$useMemo = react_1.useMemo(function () {
3267
+ return gaugeUtils_1.getGaugeRange(sortedRanges);
3268
+ }, [sortedRanges]),
3269
+ min = _react_1$useMemo.min,
3270
+ max = _react_1$useMemo.max;
3271
+
3272
+ var linearGradientId = react_1.useMemo(function () {
3273
+ return id_1.createDOMID('marker');
3274
+ }, []);
3275
+ var linearGradient = react_1.useMemo(function () {
3276
+ var stops = gaugeUtils_1.getGradientStops({
3277
+ ranges: sortedRanges,
3278
+ orientation: orientation
3279
+ });
3280
+
3281
+ var _gaugeUtils_1$getGrad = gaugeUtils_1.getGradientDimensions(orientation),
3282
+ x1 = _gaugeUtils_1$getGrad.x1,
3283
+ y1 = _gaugeUtils_1$getGrad.y1,
3284
+ x2 = _gaugeUtils_1$getGrad.x2,
3285
+ y2 = _gaugeUtils_1$getGrad.y2;
3286
+
3287
+ var linearGradientStops = stops.map(function (stop) {
3288
+ return React.createElement("stop", {
3289
+ key: "".concat(stop.offset, "_").concat(stop.stopColor),
3290
+ offset: stop.offset,
3291
+ stopColor: stop.stopColor
3292
+ });
3293
+ });
3294
+ return React.createElement("linearGradient", {
3295
+ id: linearGradientId,
3296
+ x1: x1,
3297
+ y1: y1,
3298
+ x2: x2,
3299
+ y2: y2
3300
+ }, linearGradientStops);
3301
+ }, [sortedRanges, orientation, linearGradientId]);
3302
+ /**
3303
+ * Calculate marker gauge dimensions
3304
+ */
3305
+
3306
+ var calculateMarkerGaugeDimensions = react_1.useCallback(function (containerWidth, containerHeight) {
3307
+ var _gaugeUtils_1$getGaug = gaugeUtils_1.getGaugeDimensions({
3308
+ containerWidth: containerWidth,
3309
+ containerHeight: containerHeight,
3310
+ orientation: orientation
3311
+ }),
3312
+ gaugeLength = _gaugeUtils_1$getGaug.gaugeLength,
3313
+ gaugeStartX = _gaugeUtils_1$getGaug.gaugeStartX,
3314
+ gaugeStartY = _gaugeUtils_1$getGaug.gaugeStartY,
3315
+ gaugeWidth = _gaugeUtils_1$getGaug.gaugeWidth,
3316
+ gaugeHeight = _gaugeUtils_1$getGaug.gaugeHeight;
3317
+
3318
+ var _gaugeUtils_1$getMark = gaugeUtils_1.getMarkerBarDimensions({
3319
+ gaugeLength: gaugeLength,
3320
+ gaugeStartX: gaugeStartX,
3321
+ gaugeStartY: gaugeStartY,
3322
+ gaugeWidth: gaugeWidth,
3323
+ gaugeHeight: gaugeHeight,
3324
+ orientation: orientation
3325
+ }),
3326
+ markerBarLength = _gaugeUtils_1$getMark.markerBarLength,
3327
+ markerBarX = _gaugeUtils_1$getMark.markerBarX,
3328
+ markerBarY = _gaugeUtils_1$getMark.markerBarY,
3329
+ markerBarWidth = _gaugeUtils_1$getMark.markerBarWidth,
3330
+ markerBarHeight = _gaugeUtils_1$getMark.markerBarHeight;
3331
+
3332
+ var _gaugeUtils_1$getMark2 = gaugeUtils_1.getMarkerGaugeValueMarkerPositions({
3333
+ markerBarX: markerBarX,
3334
+ markerBarY: markerBarY,
3335
+ markerBarHeight: markerBarHeight,
3336
+ markerBarLength: markerBarLength,
3337
+ orientation: orientation,
3338
+ value: value,
3339
+ min: min,
3340
+ max: max
3341
+ }),
3342
+ valueMarkerX = _gaugeUtils_1$getMark2.valueMarkerX,
3343
+ valueMarkerY = _gaugeUtils_1$getMark2.valueMarkerY;
3344
+
3345
+ return {
3346
+ markerBarX: markerBarX,
3347
+ markerBarY: markerBarY,
3348
+ markerBarWidth: markerBarWidth,
3349
+ markerBarHeight: markerBarHeight,
3350
+ valueMarkerX: valueMarkerX,
3351
+ valueMarkerY: valueMarkerY,
3352
+ gaugeStartX: gaugeStartX,
3353
+ gaugeStartY: gaugeStartY,
3354
+ gaugeWidth: gaugeWidth,
3355
+ gaugeHeight: gaugeHeight
3356
+ };
3357
+ }, [orientation, value, min, max]);
3358
+ var renderVisualization = react_1.useCallback(function (_ref) {
3359
+ var containerWidth = _ref.width,
3360
+ containerHeight = _ref.height;
3361
+
3362
+ // todo: need change the size when get design for smaller space
3363
+ // 58 is the title & description header height in dashboard visualization
3364
+ if ((containerWidth < MAX_VERTICAL_CONTAINER_WIDTH || containerHeight + 58 < MIN_VERTICAL_CONTAINER_HEIGHT) && orientation === 'vertical' || (containerWidth < MIN_HORIZONTAL_CONTAINER_WIDTH || containerHeight < MIN_HORIZONTAL_CONTAINER_HEIGHT) && orientation === 'horizontal') {
3365
+ return errorMessage(containerWidth, containerHeight, i18n_1._('Too small to render content'), errorId);
3366
+ }
3367
+
3368
+ if (error) {
3369
+ return errorMessage(containerWidth, containerHeight, error, errorId);
3370
+ }
3371
+
3372
+ var _calculateMarkerGauge = calculateMarkerGaugeDimensions(containerWidth, containerHeight),
3373
+ markerBarX = _calculateMarkerGauge.markerBarX,
3374
+ markerBarY = _calculateMarkerGauge.markerBarY,
3375
+ markerBarWidth = _calculateMarkerGauge.markerBarWidth,
3376
+ markerBarHeight = _calculateMarkerGauge.markerBarHeight,
3377
+ valueMarkerX = _calculateMarkerGauge.valueMarkerX,
3378
+ valueMarkerY = _calculateMarkerGauge.valueMarkerY,
3379
+ gaugeStartX = _calculateMarkerGauge.gaugeStartX,
3380
+ gaugeStartY = _calculateMarkerGauge.gaugeStartY,
3381
+ gaugeWidth = _calculateMarkerGauge.gaugeWidth,
3382
+ gaugeHeight = _calculateMarkerGauge.gaugeHeight;
3383
+
3384
+ return React.createElement(MarkerGaugeWrapper, {
3385
+ backgroundColor: backgroundColor
3386
+ }, React.createElement(MarkerGaugeContainer, {
3387
+ width: containerWidth,
3388
+ height: containerHeight
3389
+ }, React.createElement(MarkerGaugeSVG, {
3390
+ width: containerWidth,
3391
+ height: containerHeight
3392
+ }, linearGradient, React.createElement(BackgroundBar, {
3393
+ x: gaugeStartX,
3394
+ y: gaugeStartY,
3395
+ width: gaugeWidth,
3396
+ height: gaugeHeight,
3397
+ fillColor: fillColor
3398
+ }), React.createElement(GaugeMajorTicks_1.default, {
3399
+ width: gaugeWidth,
3400
+ height: gaugeHeight,
3401
+ startX: gaugeStartX,
3402
+ startY: gaugeStartY,
3403
+ min: min,
3404
+ max: max,
3405
+ majorUnit: majorUnit,
3406
+ orientation: orientation,
3407
+ showLabels: showLabels,
3408
+ usePercentageRange: usePercentageRange,
3409
+ majorTickFillColor: majorTickFillColor,
3410
+ majorTickStrokeColor: majorTickStrokeColor
3411
+ }), React.createElement(MarkerBar, {
3412
+ x: markerBarX,
3413
+ y: markerBarY,
3414
+ width: markerBarWidth,
3415
+ height: markerBarHeight,
3416
+ fill: "url(#".concat(linearGradientId, ")")
3417
+ }), React.createElement(GaugeValueMarker_1.default, {
3418
+ x: valueMarkerX,
3419
+ y: valueMarkerY,
3420
+ length: gaugeUtils_1.GAUGE_THICKNESS,
3421
+ min: min,
3422
+ max: max,
3423
+ value: value,
3424
+ orientation: orientation,
3425
+ showValue: showValue,
3426
+ usePercentageValue: usePercentageValue,
3427
+ valueMarkerFillColor: valueMarkerFillColor,
3428
+ valueMarkerLabelFillColor: valueMarkerLabelFillColor
3429
+ }))));
3430
+ }, [orientation, error, calculateMarkerGaugeDimensions, backgroundColor, linearGradient, fillColor, min, max, majorUnit, showLabels, usePercentageRange, majorTickFillColor, majorTickStrokeColor, linearGradientId, value, showValue, usePercentageValue, valueMarkerFillColor, valueMarkerLabelFillColor, errorMessage, errorId]);
3431
+ return React.createElement(Container, {
3432
+ width: width,
3433
+ height: height,
3434
+ backgroundColor: backgroundColor
3435
+ }, React.createElement(SizeAwareWrapper_1.default, null, function (containerDimension) {
3436
+ return renderVisualization(containerDimension);
3437
+ }));
3438
+ };
3439
+
3440
+ MarkerGauge.propTypes = {
3441
+ width: T.oneOfType([T.string, T.number]),
3442
+ height: T.oneOfType([T.string, T.number]),
3443
+ value: T.number,
3444
+ // valueFieldName: T.string, // todo: need add it back when displaying name later
3445
+ orientation: T.oneOf(['horizontal', 'vertical']),
3446
+ majorUnit: T.oneOfType([T.string, T.number]),
3447
+ showLabels: T.bool,
3448
+ showValue: T.bool,
3449
+ usePercentageRange: T.bool,
3450
+ usePercentageValue: T.bool,
3451
+ backgroundColor: T.string,
3452
+ fillColor: T.string,
3453
+ ranges: T.arrayOf(T.shape({
3454
+ from: T.number.isRequired,
3455
+ to: T.number.isRequired,
3456
+ value: T.string.isRequired
3457
+ })),
3458
+ majorTickFillColor: T.string,
3459
+ majorTickStrokeColor: T.string,
3460
+ valueMarkerFillColor: T.string,
3461
+ valueMarkerLabelFillColor: T.string
3462
+ };
3463
+ MarkerGauge.defaultProps = {
3464
+ width: '100%',
3465
+ height: 250,
3466
+ orientation: 'vertical',
3467
+ majorUnit: 'auto',
3468
+ showLabels: true,
3469
+ showValue: true,
3470
+ usePercentageRange: false,
3471
+ usePercentageValue: false,
3472
+ backgroundColor: 'transparent',
3473
+ value: 0,
3474
+ fillColor: '#f2f4f5',
3475
+ majorTickFillColor: '#3c444d',
3476
+ majorTickStrokeColor: '#6b7785',
3477
+ valueMarkerFillColor: '#3c444d',
3478
+ valueMarkerLabelFillColor: '#f2f4f5',
3479
+ ranges: [{
3480
+ from: 0,
3481
+ to: 50,
3482
+ value: '#4BEBA8'
3483
+ }, {
3484
+ from: 50,
3485
+ to: 90,
3486
+ value: '#F4DF7A'
3487
+ }, {
3488
+ from: 90,
3489
+ to: 100,
3490
+ value: '#CB3B43'
3491
+ }]
3492
+ };
3493
+ exports.default = MarkerGauge;
3494
+
3495
+ /***/ }),
3496
+ /* 190 */
3497
+ /***/ (function(module, exports) {
3498
+
3499
+ module.exports = require("@splunk/ui-utils/id");
3500
+
3501
+ /***/ }),
3502
+ /* 191 */
3503
+ /***/ (function(module, exports, __webpack_require__) {
3504
+
3505
+ "use strict";
3506
+
3507
+
3508
+ Object.defineProperty(exports, "__esModule", {
3509
+ value: true
3510
+ });
3511
+
3512
+ var i18n_1 = __webpack_require__(3);
3513
+
3514
+ var GaugeMarker_1 = __webpack_require__(192);
3515
+
3516
+ var schemaUtils_1 = __webpack_require__(14);
3517
+
3518
+ var variables_1 = __webpack_require__(19);
3519
+
3520
+ var pick_1 = __webpack_require__(21);
3521
+
3522
+ var Gauge_1 = __webpack_require__(90);
3523
+
3524
+ var VizBehavior_1 = __webpack_require__(5);
3525
+
3526
+ var VizCategory_1 = __webpack_require__(26);
3527
+
3528
+ var configUtils_1 = __webpack_require__(8);
3529
+
3530
+ var BackgroundColor_1 = __webpack_require__(44);
3531
+
3532
+ var dataContract = {
3533
+ requiredDataSources: [{
3534
+ name: 'primary',
3535
+ description: 'DataSource that powers the visualization'
3536
+ }],
3537
+ optionalDataSources: [],
3538
+ initialRequestParams: {
3539
+ primary: {
3540
+ offset: 0,
3541
+ count: 10000
3542
+ }
3543
+ }
3544
+ };
3545
+ var size = {
3546
+ initialWidth: 300,
3547
+ initialHeight: 300
3548
+ };
3549
+ var defaultContext = {};
3550
+ var optionsSchema = {
3551
+ backgroundColor: {
3552
+ description: 'Specify the color used for the background. The default for enterprise light is "#ffffff". The default for enterprise dark is "#000000". The default for prisma dark is "#0b0c0e".',
3553
+ type: 'string',
3554
+ pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
3555
+ default: '> themes.defaultBackgroundColor'
3556
+ },
3557
+ gaugeRanges: {
3558
+ description: 'Specify the overall range of the gauge as a series of continuous, color-coded subranges. For example, [{"from": 0, "to": 20, "value": "#4BEBA8"}, {"from": 20, "to": 50, "value": "#F4DF7A"}].',
3559
+ default: [{
3560
+ from: 0,
3561
+ to: 50,
3562
+ value: '#118832'
3563
+ }, {
3564
+ from: 50,
3565
+ to: 90,
3566
+ value: '#CBA700'
3567
+ }, {
3568
+ from: 90,
3569
+ to: 100,
3570
+ value: '#D41F1F'
3571
+ }],
3572
+ type: 'array',
3573
+ items: {
3574
+ type: 'object',
3575
+ properties: {
3576
+ from: {
3577
+ type: 'number',
3578
+ description: 'Starting value for range.'
3579
+ },
3580
+ to: {
3581
+ type: 'number',
3582
+ description: 'Ending value for range.'
3583
+ },
3584
+ value: {
3585
+ description: 'Color for sub range.',
3586
+ type: 'string',
3587
+ pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN // insert pattern for color variables - #HEX etc
3588
+
3589
+ }
3590
+ },
3591
+ required: ['from', 'to', 'value'],
3592
+ additionalProperties: false
3593
+ }
3594
+ },
3595
+ labelDisplay: {
3596
+ description: 'Specify whether to display the labels as numbers, percentages, or off.',
3597
+ default: 'number',
3598
+ type: 'string',
3599
+ pattern: schemaUtils_1.getPattern(['number', 'percentage', 'off'])
3600
+ },
3601
+ majorTickInterval: {
3602
+ description: 'Specify, in pixels, the spacing between major tick marks.',
3603
+ default: 'auto',
3604
+ type: ['string', 'number']
3605
+ },
3606
+ orientation: {
3607
+ description: 'Specify the axis orientation of the gauge.',
3608
+ default: 'vertical',
3609
+ type: 'string',
3610
+ pattern: schemaUtils_1.getPattern(['horizontal', 'vertical'])
3611
+ },
3612
+ value: {
3613
+ description: 'Specify the dataSource applied to the value of the marker gauge.',
3614
+ type: 'string',
3615
+ default: '> primary | seriesByType("number") | lastPoint()'
3616
+ },
3617
+ valueDisplay: {
3618
+ description: 'Specify whether to display the value as a number, percentage, or off.',
3619
+ default: 'number',
3620
+ type: 'string',
3621
+ pattern: schemaUtils_1.getPattern(['number', 'percentage', 'off'])
3622
+ }
3623
+ };
3624
+ var themes = {
3625
+ defaultFillColor: function defaultFillColor(props) {
3626
+ return pick_1.default({
3627
+ enterprise: variables_1.default.backgroundColorHover(props),
3628
+ prisma: variables_1.default.neutral100(props)
3629
+ })(props);
3630
+ },
3631
+ defaultBackgroundColor: function defaultBackgroundColor(props) {
3632
+ return pick_1.default({
3633
+ enterprise: {
3634
+ dark: variables_1.default.black(props),
3635
+ light: variables_1.default.backgroundColor(props)
3636
+ },
3637
+ prisma: variables_1.default.backgroundColorSidebar(props)
3638
+ })(props);
3639
+ },
3640
+ majorTickFillColor: function majorTickFillColor(props) {
3641
+ return pick_1.default({
3642
+ enterprise: {
3643
+ light: variables_1.default.gray30(props),
3644
+ dark: variables_1.default.textGray(props) // was #D7DAE0
3645
+
3646
+ },
3647
+ prisma: {
3648
+ // TODO: missed colors :(
3649
+ light: variables_1.default.neutral100(props),
3650
+ dark: variables_1.default.contentColorMuted(props) // was #D7DAE0; contentColor
3651
+
3652
+ }
3653
+ })(props);
3654
+ },
3655
+ majorTickStrokeColor: function majorTickStrokeColor(props) {
3656
+ return pick_1.default({
3657
+ enterprise: {
3658
+ light: variables_1.default.textGray(props),
3659
+ dark: variables_1.default.contentColorMuted(props)
3660
+ },
3661
+ prisma: variables_1.default.contentColorMuted(props)
3662
+ })(props);
3663
+ },
3664
+ valueMarkerFillColor: function valueMarkerFillColor(props) {
3665
+ return pick_1.default({
3666
+ enterprise: variables_1.default.textColor(props),
3667
+ prisma: {
3668
+ dark: variables_1.default.white(props),
3669
+ light: variables_1.default.black(props)
3670
+ }
3671
+ })(props);
3672
+ },
3673
+ valueMarkerLabelFillColor: function valueMarkerLabelFillColor(props) {
3674
+ return pick_1.default({
3675
+ enterprise: {
3676
+ light: variables_1.default.gray96(props),
3677
+ dark: variables_1.default.black(props)
3678
+ },
3679
+ prisma: variables_1.default.black(props)
3680
+ })(props);
3681
+ }
3682
+ };
3683
+ var editorConfig = [{
3684
+ label: i18n_1._('Select Data Field'),
3685
+ layout: [[{
3686
+ label: '',
3687
+ editor: 'editor.columnSelector',
3688
+ option: 'value',
3689
+ context: 'defaultContext',
3690
+ editorProps: {
3691
+ dataSourceKey: 'primary',
3692
+ prepareValue: function prepareValue(definition) {
3693
+ var value = definition.options.value;
3694
+ return {
3695
+ context: {},
3696
+ options: {
3697
+ value: "".concat(value, " | lastPoint()")
3698
+ }
3699
+ };
3700
+ }
3701
+ }
3702
+ }]]
3703
+ }, Gauge_1.default, {
3704
+ label: i18n_1._('Coloring'),
3705
+ open: true,
3706
+ layout: [[{
3707
+ label: i18n_1._('Gauge Ranges'),
3708
+ option: 'gaugeRanges',
3709
+ editor: 'editor.threshold',
3710
+ editorProps: {
3711
+ openRanges: false,
3712
+ isTogglable: false // Can not disable thresholds
3713
+
3714
+ }
3715
+ }], BackgroundColor_1.default({
3716
+ themes: themes,
3717
+ labelPosition: 'top'
3718
+ })]
3719
+ }];
3720
+ /**
3721
+ * visualization configuration
3722
+ */
3723
+
3724
+ var config = {
3725
+ /**
3726
+ * unique viz key
3727
+ */
3728
+ key: 'splunk.markergauge',
3729
+
3730
+ /**
3731
+ * viz name
3732
+ */
3733
+ name: 'MarkerGauge',
3734
+ category: VizCategory_1.VizCategory.GAUGE,
3735
+
3736
+ /**
3737
+ * viz icon
3738
+ */
3739
+ icon: GaugeMarker_1.default,
3740
+ dataContract: dataContract,
3741
+ size: size,
3742
+ defaultContext: defaultContext,
3743
+ optionsSchema: optionsSchema,
3744
+ editorConfig: editorConfig,
3745
+ supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER],
3746
+ themes: themes
3747
+ };
3748
+ exports.default = configUtils_1.enhanceConfig(config);
3749
+
3750
+ /***/ }),
3751
+ /* 192 */
3752
+ /***/ (function(module, exports) {
3753
+
3754
+ module.exports = require("@splunk/react-icons/GaugeMarker");
3755
+
3756
+ /***/ })
3757
+ /******/ ]);
3758
+ //# sourceMappingURL=MarkerGauge.js.map