@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.
- package/Area.config.js +36 -30
- package/Area.config.js.map +1 -1
- package/Area.js +243 -203
- package/Area.js.map +1 -1
- package/Bar.config.js +29 -23
- package/Bar.config.js.map +1 -1
- package/Bar.js +233 -193
- package/Bar.js.map +1 -1
- package/Bubble.config.js +36 -23
- package/Bubble.config.js.map +1 -1
- package/Bubble.js +247 -196
- package/Bubble.js.map +1 -1
- package/ChoroplethSvg.config.js +15 -12
- package/ChoroplethSvg.config.js.map +1 -1
- package/ChoroplethSvg.js +201 -148
- package/ChoroplethSvg.js.map +1 -1
- package/Column.config.js +29 -23
- package/Column.config.js.map +1 -1
- package/Column.js +235 -194
- package/Column.js.map +1 -1
- package/Ellipse.config.js +23 -20
- package/Ellipse.config.js.map +1 -1
- package/Ellipse.js +176 -123
- package/Ellipse.js.map +1 -1
- package/FillerGauge.config.js +803 -0
- package/FillerGauge.config.js.map +1 -0
- package/FillerGauge.js +3634 -0
- package/FillerGauge.js.map +1 -0
- package/Image.config.js +13 -6
- package/Image.config.js.map +1 -1
- package/Image.js +260 -200
- package/Image.js.map +1 -1
- package/LICENSE.md +14 -0
- package/Line.config.js +40 -31
- package/Line.config.js.map +1 -1
- package/Line.js +248 -202
- package/Line.js.map +1 -1
- package/LinkGraph.config.js +107 -123
- package/LinkGraph.config.js.map +1 -1
- package/LinkGraph.js +241 -193
- package/LinkGraph.js.map +1 -1
- package/Markdown.config.js +95 -3
- package/Markdown.config.js.map +1 -1
- package/Markdown.js +272 -118
- package/Markdown.js.map +1 -1
- package/MarkerGauge.config.js +750 -0
- package/MarkerGauge.config.js.map +1 -0
- package/MarkerGauge.js +3758 -0
- package/MarkerGauge.js.map +1 -0
- package/ParallelCoordinates.config.js +52 -46
- package/ParallelCoordinates.config.js.map +1 -1
- package/ParallelCoordinates.js +257 -164
- package/ParallelCoordinates.js.map +1 -1
- package/Pie.config.js +61 -46
- package/Pie.config.js.map +1 -1
- package/Pie.js +254 -186
- package/Pie.js.map +1 -1
- package/Punchcard.config.js +279 -39
- package/Punchcard.config.js.map +1 -1
- package/Punchcard.js +825 -193
- package/Punchcard.js.map +1 -1
- package/README.external.md +45 -0
- package/README.md +18 -3
- package/Rectangle.config.js +89 -107
- package/Rectangle.config.js.map +1 -1
- package/Rectangle.js +204 -145
- package/Rectangle.js.map +1 -1
- package/Sankey.config.js +29 -22
- package/Sankey.config.js.map +1 -1
- package/Sankey.js +250 -186
- package/Sankey.js.map +1 -1
- package/Scatter.config.js +39 -28
- package/Scatter.config.js.map +1 -1
- package/Scatter.js +2375 -2434
- package/Scatter.js.map +1 -1
- package/SingleValue.config.js +37 -29
- package/SingleValue.config.js.map +1 -1
- package/SingleValue.js +3108 -3174
- package/SingleValue.js.map +1 -1
- package/SingleValueBasic.js +37 -23
- package/SingleValueBasic.js.map +1 -1
- package/SingleValueIcon.config.js +36 -28
- package/SingleValueIcon.config.js.map +1 -1
- package/SingleValueIcon.js +279 -210
- package/SingleValueIcon.js.map +1 -1
- package/SingleValueRadial.config.js +15 -13
- package/SingleValueRadial.config.js.map +1 -1
- package/SingleValueRadial.js +299 -253
- package/SingleValueRadial.js.map +1 -1
- package/Table.config.js +26 -10
- package/Table.config.js.map +1 -1
- package/Table.js +382 -265
- package/Table.js.map +1 -1
- package/common/Charting.js +33 -30
- package/common/Charting.js.map +1 -1
- package/common/ChartingApi.js +4 -4
- package/common/ChartingApi.js.map +1 -1
- package/common/EventsDoc.js +36 -34
- package/common/EventsDoc.js.map +1 -1
- package/common/GaugeMajorTicks.js +386 -0
- package/common/GaugeMajorTicks.js.map +1 -0
- package/common/GaugeValueMarker.js +333 -0
- package/common/GaugeValueMarker.js.map +1 -0
- package/common/OptionsDoc.js +47 -33
- package/common/OptionsDoc.js.map +1 -1
- package/common/OverviewDoc.js +376 -0
- package/common/OverviewDoc.js.map +1 -0
- package/common/SplunkVisualization.js +6 -6
- package/common/SplunkVisualization.js.map +1 -1
- package/common/SplunkVisualizationApi.js +10 -10
- package/common/SplunkVisualizationApi.js.map +1 -1
- package/common/ThemesDoc.js +55 -72
- package/common/ThemesDoc.js.map +1 -1
- package/common/chartingUtils.js +15 -13
- package/common/chartingUtils.js.map +1 -1
- package/common/docUtils.js +4 -4
- package/common/docUtils.js.map +1 -1
- package/common/gaugeUtils.js +893 -0
- package/common/gaugeUtils.js.map +1 -0
- package/common/shapeUtils.js +8 -8
- package/common/shapeUtils.js.map +1 -1
- package/common/utils/JSONSchemaUtils.js.map +1 -1
- package/common/utils/configUtils.js.map +1 -1
- package/common/utils/hocUtils.js +57 -3
- package/common/utils/hocUtils.js.map +1 -1
- package/common/utils/singleValueUtils.js +24 -10
- package/common/utils/singleValueUtils.js.map +1 -1
- package/common/withDashboardViz.js +158 -95
- package/common/withDashboardViz.js.map +1 -1
- package/package.json +18 -14
- package/common/utils/eventUtils.js +0 -115
- package/common/utils/eventUtils.js.map +0 -1
package/FillerGauge.js
ADDED
|
@@ -0,0 +1,3634 @@
|
|
|
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 = 160);
|
|
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
|
+
/***/ (function(module, exports) {
|
|
1610
|
+
|
|
1611
|
+
module.exports = require("@splunk/visualization-color-palettes/editors/PresetPalettes");
|
|
1612
|
+
|
|
1613
|
+
/***/ }),
|
|
1614
|
+
/* 57 */,
|
|
1615
|
+
/* 58 */,
|
|
1616
|
+
/* 59 */,
|
|
1617
|
+
/* 60 */,
|
|
1618
|
+
/* 61 */,
|
|
1619
|
+
/* 62 */,
|
|
1620
|
+
/* 63 */,
|
|
1621
|
+
/* 64 */,
|
|
1622
|
+
/* 65 */,
|
|
1623
|
+
/* 66 */,
|
|
1624
|
+
/* 67 */,
|
|
1625
|
+
/* 68 */,
|
|
1626
|
+
/* 69 */,
|
|
1627
|
+
/* 70 */,
|
|
1628
|
+
/* 71 */
|
|
1629
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1630
|
+
|
|
1631
|
+
"use strict";
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
var _toConsumableArray = __webpack_require__(39);
|
|
1635
|
+
|
|
1636
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1637
|
+
value: true
|
|
1638
|
+
});
|
|
1639
|
+
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;
|
|
1640
|
+
|
|
1641
|
+
var lodash_1 = __webpack_require__(2);
|
|
1642
|
+
|
|
1643
|
+
var colorConstants_1 = __webpack_require__(40);
|
|
1644
|
+
|
|
1645
|
+
var i18n_1 = __webpack_require__(3);
|
|
1646
|
+
|
|
1647
|
+
exports.GAUGE_THICKNESS = 50;
|
|
1648
|
+
exports.FILL_THICKNESS = 38;
|
|
1649
|
+
var GRADIENT_STOP_OFFSET_MIN = 0;
|
|
1650
|
+
var GRADIENT_STOP_OFFSET_MAX = 100;
|
|
1651
|
+
/**
|
|
1652
|
+
* get width for the whole gauge viz for horizontal or vertical view
|
|
1653
|
+
* @method getGaugeWidth
|
|
1654
|
+
* @param {Object} input
|
|
1655
|
+
* @param {Number} containerWidth
|
|
1656
|
+
* @param {String} orientation
|
|
1657
|
+
* @return {Number} width
|
|
1658
|
+
*/
|
|
1659
|
+
|
|
1660
|
+
var getGaugeWidth = function getGaugeWidth(_ref) {
|
|
1661
|
+
var containerWidth = _ref.containerWidth,
|
|
1662
|
+
orientation = _ref.orientation;
|
|
1663
|
+
return orientation === 'vertical' ? exports.GAUGE_THICKNESS : containerWidth * 0.8;
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1666
|
+
exports.getGaugeWidth = getGaugeWidth;
|
|
1667
|
+
/**
|
|
1668
|
+
* get height for the whole gauge viz for horizontal or vertical view
|
|
1669
|
+
* @method getGaugeHeight
|
|
1670
|
+
* @param {Object} input
|
|
1671
|
+
* @param {Number} containerHeight
|
|
1672
|
+
* @param {String} orientation
|
|
1673
|
+
* @return {Number} height
|
|
1674
|
+
*/
|
|
1675
|
+
|
|
1676
|
+
var getGaugeHeight = function getGaugeHeight(_ref2) {
|
|
1677
|
+
var containerHeight = _ref2.containerHeight,
|
|
1678
|
+
orientation = _ref2.orientation;
|
|
1679
|
+
return orientation === 'vertical' ? containerHeight * 0.8 : exports.GAUGE_THICKNESS;
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1682
|
+
exports.getGaugeHeight = getGaugeHeight;
|
|
1683
|
+
/**
|
|
1684
|
+
* get how long the gauge shoud be.
|
|
1685
|
+
* In horizontal view, gauge length equals to gauge width. In vertical view, it equals to gauge height.
|
|
1686
|
+
* @method getGaugeLength
|
|
1687
|
+
* @param {Object} input
|
|
1688
|
+
* @param {Number} input.containerWidth
|
|
1689
|
+
* @param {Number} input.containerHeight
|
|
1690
|
+
* @param {String} input.orientation
|
|
1691
|
+
* @return {Number} gaugeLength
|
|
1692
|
+
*/
|
|
1693
|
+
|
|
1694
|
+
var getGaugeLength = function getGaugeLength(_ref3) {
|
|
1695
|
+
var containerWidth = _ref3.containerWidth,
|
|
1696
|
+
containerHeight = _ref3.containerHeight,
|
|
1697
|
+
orientation = _ref3.orientation;
|
|
1698
|
+
return orientation === 'vertical' ? exports.getGaugeHeight({
|
|
1699
|
+
containerHeight: containerHeight,
|
|
1700
|
+
orientation: orientation
|
|
1701
|
+
}) : exports.getGaugeWidth({
|
|
1702
|
+
containerWidth: containerWidth,
|
|
1703
|
+
orientation: orientation
|
|
1704
|
+
});
|
|
1705
|
+
};
|
|
1706
|
+
|
|
1707
|
+
exports.getGaugeLength = getGaugeLength;
|
|
1708
|
+
/**
|
|
1709
|
+
* get start x and y for rendering gauge
|
|
1710
|
+
* @method getGaugeStartPosition
|
|
1711
|
+
* @param {Object} input
|
|
1712
|
+
* @param {Number} containerWidth
|
|
1713
|
+
* @param {Number} containerHeight
|
|
1714
|
+
* @param {Number} gaugeLength
|
|
1715
|
+
* @param {String} orientation
|
|
1716
|
+
* @return {Object} position
|
|
1717
|
+
* @return {Number} position.gaugeStartX
|
|
1718
|
+
* @return {Number} position.gaugeStartY
|
|
1719
|
+
*/
|
|
1720
|
+
|
|
1721
|
+
var getGaugeStartPosition = function getGaugeStartPosition(_ref4) {
|
|
1722
|
+
var containerWidth = _ref4.containerWidth,
|
|
1723
|
+
containerHeight = _ref4.containerHeight,
|
|
1724
|
+
gaugeLength = _ref4.gaugeLength,
|
|
1725
|
+
orientation = _ref4.orientation;
|
|
1726
|
+
// for horizontal view
|
|
1727
|
+
var gaugeStartX = (containerWidth - gaugeLength) / 2.0;
|
|
1728
|
+
var gaugeStartY = (containerHeight - exports.GAUGE_THICKNESS) / 2.0;
|
|
1729
|
+
|
|
1730
|
+
if (orientation === 'vertical') {
|
|
1731
|
+
gaugeStartX = (containerWidth - exports.GAUGE_THICKNESS) / 2.0;
|
|
1732
|
+
gaugeStartY = (containerHeight - gaugeLength) / 2.0;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
return {
|
|
1736
|
+
gaugeStartX: gaugeStartX,
|
|
1737
|
+
gaugeStartY: gaugeStartY
|
|
1738
|
+
};
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
exports.getGaugeStartPosition = getGaugeStartPosition;
|
|
1742
|
+
/**
|
|
1743
|
+
* get dimensions for the whole gauge viz,
|
|
1744
|
+
* which can be useful to calculate background bar and major ticks positions.
|
|
1745
|
+
* @method getGaugeDimensions
|
|
1746
|
+
* @param {Object} input
|
|
1747
|
+
* @param {Number} input.containerWidth
|
|
1748
|
+
* @param {Number} input.containerHeight
|
|
1749
|
+
* @param {String} input.orientation 'horizontal' or 'vertical'
|
|
1750
|
+
* @return {Object} gaugeDimensions
|
|
1751
|
+
* @return {Number} gaugeDimensions.gaugeLength how long the gauge shoud be in horizontal or vertical orientation.
|
|
1752
|
+
* @return {Number} gaugeDimensions.gaugeStartX start x to render gauge
|
|
1753
|
+
* @return {Number} gaugeDimensions.gaugeStartY start y to render gauge
|
|
1754
|
+
* @return {Number} gaugeDimensions.gaugeWidth natural width of gauge
|
|
1755
|
+
* @return {Number} gaugeDimensions.gaugeHeight natural height of gauge
|
|
1756
|
+
*/
|
|
1757
|
+
|
|
1758
|
+
var getGaugeDimensions = function getGaugeDimensions(_ref5) {
|
|
1759
|
+
var containerWidth = _ref5.containerWidth,
|
|
1760
|
+
containerHeight = _ref5.containerHeight,
|
|
1761
|
+
orientation = _ref5.orientation;
|
|
1762
|
+
var gaugeLength = exports.getGaugeLength({
|
|
1763
|
+
containerWidth: containerWidth,
|
|
1764
|
+
containerHeight: containerHeight,
|
|
1765
|
+
orientation: orientation
|
|
1766
|
+
});
|
|
1767
|
+
|
|
1768
|
+
var _exports$getGaugeStar = exports.getGaugeStartPosition({
|
|
1769
|
+
containerWidth: containerWidth,
|
|
1770
|
+
containerHeight: containerHeight,
|
|
1771
|
+
gaugeLength: gaugeLength,
|
|
1772
|
+
orientation: orientation
|
|
1773
|
+
}),
|
|
1774
|
+
gaugeStartX = _exports$getGaugeStar.gaugeStartX,
|
|
1775
|
+
gaugeStartY = _exports$getGaugeStar.gaugeStartY;
|
|
1776
|
+
|
|
1777
|
+
var gaugeWidth = exports.getGaugeWidth({
|
|
1778
|
+
containerWidth: containerWidth,
|
|
1779
|
+
orientation: orientation
|
|
1780
|
+
});
|
|
1781
|
+
var gaugeHeight = exports.getGaugeHeight({
|
|
1782
|
+
containerHeight: containerHeight,
|
|
1783
|
+
orientation: orientation
|
|
1784
|
+
});
|
|
1785
|
+
return {
|
|
1786
|
+
gaugeLength: gaugeLength,
|
|
1787
|
+
gaugeStartX: gaugeStartX,
|
|
1788
|
+
gaugeStartY: gaugeStartY,
|
|
1789
|
+
gaugeWidth: gaugeWidth,
|
|
1790
|
+
gaugeHeight: gaugeHeight
|
|
1791
|
+
};
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
exports.getGaugeDimensions = getGaugeDimensions;
|
|
1795
|
+
/**
|
|
1796
|
+
* if gaugeColor is not specified, auto assign a gauge color to the fill bar
|
|
1797
|
+
* based on how much percentage the value is taken between min and max
|
|
1798
|
+
* @method assignGaugeColor
|
|
1799
|
+
* @params
|
|
1800
|
+
* */
|
|
1801
|
+
|
|
1802
|
+
var assignGaugeColor = function assignGaugeColor(_ref6) {
|
|
1803
|
+
var value = _ref6.value,
|
|
1804
|
+
min = _ref6.min,
|
|
1805
|
+
max = _ref6.max;
|
|
1806
|
+
var rate = (value - min) / (max - min);
|
|
1807
|
+
|
|
1808
|
+
if (rate <= 0.3) {
|
|
1809
|
+
return colorConstants_1.SEMANTIC_SUCCESS;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
if (rate > 0.3 && rate <= 0.6) {
|
|
1813
|
+
return colorConstants_1.SEMANTIC_WARNING;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
return colorConstants_1.SEMANTIC_ERROR;
|
|
1817
|
+
};
|
|
1818
|
+
|
|
1819
|
+
exports.assignGaugeColor = assignGaugeColor;
|
|
1820
|
+
/**
|
|
1821
|
+
* get inner bar length in gauge
|
|
1822
|
+
* @method getGaugeBarLength
|
|
1823
|
+
* @param {Object} input
|
|
1824
|
+
* @param {Number} input.gaugeLength
|
|
1825
|
+
* @param {Number} input.value
|
|
1826
|
+
* @param {Number} input.min
|
|
1827
|
+
* @param {Number} input.max
|
|
1828
|
+
* @return {Number} gaugeBarLength
|
|
1829
|
+
*/
|
|
1830
|
+
|
|
1831
|
+
var getGaugeBarLength = function getGaugeBarLength(_ref7) {
|
|
1832
|
+
var gaugeLength = _ref7.gaugeLength,
|
|
1833
|
+
value = _ref7.value,
|
|
1834
|
+
min = _ref7.min,
|
|
1835
|
+
max = _ref7.max;
|
|
1836
|
+
|
|
1837
|
+
if (max < min) {
|
|
1838
|
+
return null;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
if (value >= max) {
|
|
1842
|
+
return gaugeLength;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
if (value < min) {
|
|
1846
|
+
return 0;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
return gaugeLength * (value - min) / (max - min);
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
exports.getGaugeBarLength = getGaugeBarLength;
|
|
1853
|
+
/**
|
|
1854
|
+
* get x and y position for rendering inner bar in gauge
|
|
1855
|
+
* @method getGaugeBarStartPositions
|
|
1856
|
+
* @param {Object} input
|
|
1857
|
+
* @param {Number} input.gaugeStartX
|
|
1858
|
+
* @param {Number} input.gaugeStartY
|
|
1859
|
+
* @param {Number} input.gaugeWidth
|
|
1860
|
+
* @param {Number} input.gaugeHeight
|
|
1861
|
+
* @param {Number} input.gaugeBarLength
|
|
1862
|
+
* @param {String} input.orientation
|
|
1863
|
+
* @return {Object} position
|
|
1864
|
+
* @return {Number} position.gaugeBarX
|
|
1865
|
+
* @return {Number} position.gaugeBarY
|
|
1866
|
+
*/
|
|
1867
|
+
|
|
1868
|
+
var getGaugeBarStartPositions = function getGaugeBarStartPositions(_ref8) {
|
|
1869
|
+
var gaugeStartX = _ref8.gaugeStartX,
|
|
1870
|
+
gaugeStartY = _ref8.gaugeStartY,
|
|
1871
|
+
gaugeWidth = _ref8.gaugeWidth,
|
|
1872
|
+
gaugeHeight = _ref8.gaugeHeight,
|
|
1873
|
+
gaugeBarLength = _ref8.gaugeBarLength,
|
|
1874
|
+
orientation = _ref8.orientation;
|
|
1875
|
+
var gaugeBarX = gaugeStartX;
|
|
1876
|
+
var gaugeBarY = gaugeStartY;
|
|
1877
|
+
|
|
1878
|
+
if (orientation === 'vertical') {
|
|
1879
|
+
gaugeBarX += (gaugeWidth - exports.FILL_THICKNESS) / 2;
|
|
1880
|
+
gaugeBarY += gaugeHeight - gaugeBarLength;
|
|
1881
|
+
} else {
|
|
1882
|
+
gaugeBarY += (gaugeHeight - exports.FILL_THICKNESS) / 2;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
return {
|
|
1886
|
+
gaugeBarX: gaugeBarX,
|
|
1887
|
+
gaugeBarY: gaugeBarY
|
|
1888
|
+
};
|
|
1889
|
+
};
|
|
1890
|
+
|
|
1891
|
+
exports.getGaugeBarStartPositions = getGaugeBarStartPositions;
|
|
1892
|
+
/**
|
|
1893
|
+
* get width of inner bar in gauge
|
|
1894
|
+
* @method getGaugeBarWidth
|
|
1895
|
+
* @param {Object} input
|
|
1896
|
+
* @param {Number} input.gaugeBarLength
|
|
1897
|
+
* @param {String} orientation
|
|
1898
|
+
* @return {Number} gaugeBarWidth
|
|
1899
|
+
*/
|
|
1900
|
+
|
|
1901
|
+
var getGaugeBarWidth = function getGaugeBarWidth(_ref9) {
|
|
1902
|
+
var gaugeBarLength = _ref9.gaugeBarLength,
|
|
1903
|
+
orientation = _ref9.orientation;
|
|
1904
|
+
return orientation === 'vertical' ? exports.FILL_THICKNESS : gaugeBarLength;
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
exports.getGaugeBarWidth = getGaugeBarWidth;
|
|
1908
|
+
/**
|
|
1909
|
+
* get height of inner bar in gauge
|
|
1910
|
+
* @method getGaugeBarWidth
|
|
1911
|
+
* @param {Object} input
|
|
1912
|
+
* @param {Number} input.gaugeBarLength
|
|
1913
|
+
* @param {String} orientation
|
|
1914
|
+
* @return {Number} gaugeBarHeight
|
|
1915
|
+
*/
|
|
1916
|
+
|
|
1917
|
+
var getGaugeBarHeight = function getGaugeBarHeight(_ref10) {
|
|
1918
|
+
var gaugeBarLength = _ref10.gaugeBarLength,
|
|
1919
|
+
orientation = _ref10.orientation;
|
|
1920
|
+
return orientation === 'vertical' ? gaugeBarLength : exports.FILL_THICKNESS;
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
exports.getGaugeBarHeight = getGaugeBarHeight;
|
|
1924
|
+
/**
|
|
1925
|
+
* get dimensions for the fill bar in the gauge
|
|
1926
|
+
* @method getFillBarDimensions
|
|
1927
|
+
* @param {Object} input
|
|
1928
|
+
* @param {Number} input.gaugeLength
|
|
1929
|
+
* @param {Number} input.gaugeStartX
|
|
1930
|
+
* @param {Number} input.gaugeStartY
|
|
1931
|
+
* @param {Number} input.gaugeWidth,
|
|
1932
|
+
* @param {Number} input.gaugeHeight,
|
|
1933
|
+
* @param {Number} input.value,
|
|
1934
|
+
* @param {Number} input.min,
|
|
1935
|
+
* @param {Number} input.max,
|
|
1936
|
+
* @param {String} input.orientation
|
|
1937
|
+
* @return {Object} fillBarDimensions
|
|
1938
|
+
* @return {Number} fillBarDimensions.fillBarLength
|
|
1939
|
+
* @return {Number} fillBarDimensions.fillBarX
|
|
1940
|
+
* @return {Number} fillBarDimensions.fillBarY
|
|
1941
|
+
* @return {Number} fillBarDimensions.fillBarWidth
|
|
1942
|
+
* @return {Number} fillBarDimensions.fillBarHeight
|
|
1943
|
+
*/
|
|
1944
|
+
|
|
1945
|
+
var getFillBarDimensions = function getFillBarDimensions(_ref11) {
|
|
1946
|
+
var gaugeLength = _ref11.gaugeLength,
|
|
1947
|
+
gaugeStartX = _ref11.gaugeStartX,
|
|
1948
|
+
gaugeStartY = _ref11.gaugeStartY,
|
|
1949
|
+
gaugeWidth = _ref11.gaugeWidth,
|
|
1950
|
+
gaugeHeight = _ref11.gaugeHeight,
|
|
1951
|
+
value = _ref11.value,
|
|
1952
|
+
min = _ref11.min,
|
|
1953
|
+
max = _ref11.max,
|
|
1954
|
+
orientation = _ref11.orientation;
|
|
1955
|
+
var gaugeBarLength = exports.getGaugeBarLength({
|
|
1956
|
+
gaugeLength: gaugeLength,
|
|
1957
|
+
value: value,
|
|
1958
|
+
max: max,
|
|
1959
|
+
min: min
|
|
1960
|
+
});
|
|
1961
|
+
|
|
1962
|
+
var _exports$getGaugeBarS = exports.getGaugeBarStartPositions({
|
|
1963
|
+
gaugeStartX: gaugeStartX,
|
|
1964
|
+
gaugeStartY: gaugeStartY,
|
|
1965
|
+
gaugeWidth: gaugeWidth,
|
|
1966
|
+
gaugeHeight: gaugeHeight,
|
|
1967
|
+
gaugeBarLength: gaugeBarLength,
|
|
1968
|
+
orientation: orientation
|
|
1969
|
+
}),
|
|
1970
|
+
fillBarX = _exports$getGaugeBarS.gaugeBarX,
|
|
1971
|
+
fillBarY = _exports$getGaugeBarS.gaugeBarY;
|
|
1972
|
+
|
|
1973
|
+
var fillBarWidth = exports.getGaugeBarWidth({
|
|
1974
|
+
gaugeBarLength: gaugeBarLength,
|
|
1975
|
+
orientation: orientation
|
|
1976
|
+
});
|
|
1977
|
+
var fillBarHeight = exports.getGaugeBarHeight({
|
|
1978
|
+
gaugeBarLength: gaugeBarLength,
|
|
1979
|
+
orientation: orientation
|
|
1980
|
+
});
|
|
1981
|
+
return {
|
|
1982
|
+
fillBarLength: gaugeBarLength,
|
|
1983
|
+
fillBarX: fillBarX,
|
|
1984
|
+
fillBarY: fillBarY,
|
|
1985
|
+
fillBarWidth: fillBarWidth,
|
|
1986
|
+
fillBarHeight: fillBarHeight
|
|
1987
|
+
};
|
|
1988
|
+
};
|
|
1989
|
+
|
|
1990
|
+
exports.getFillBarDimensions = getFillBarDimensions;
|
|
1991
|
+
/**
|
|
1992
|
+
* get position x and y for value marker in filler gauge
|
|
1993
|
+
* @method getFillerGaugeValueMarkerPositions
|
|
1994
|
+
* @param {Object} input
|
|
1995
|
+
* @param {Number} input.fillBarX
|
|
1996
|
+
* @param {Number} input.fillBarY
|
|
1997
|
+
* @param {Number} input.fillBarLength
|
|
1998
|
+
* @param {String} input.orientation
|
|
1999
|
+
* @return {Object} position
|
|
2000
|
+
* @return {Number} position.valueMarkerX
|
|
2001
|
+
* @return {Number} position.valueMarkerY
|
|
2002
|
+
*/
|
|
2003
|
+
|
|
2004
|
+
var getFillerGaugeValueMarkerPositions = function getFillerGaugeValueMarkerPositions(_ref12) {
|
|
2005
|
+
var fillBarX = _ref12.fillBarX,
|
|
2006
|
+
fillBarY = _ref12.fillBarY,
|
|
2007
|
+
fillBarLength = _ref12.fillBarLength,
|
|
2008
|
+
orientation = _ref12.orientation;
|
|
2009
|
+
var valueMarkerX = fillBarX;
|
|
2010
|
+
var valueMarkerY = fillBarY;
|
|
2011
|
+
|
|
2012
|
+
if (orientation === 'vertical') {
|
|
2013
|
+
valueMarkerX -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
|
|
2014
|
+
} else {
|
|
2015
|
+
valueMarkerX += fillBarLength;
|
|
2016
|
+
valueMarkerY -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
return {
|
|
2020
|
+
valueMarkerX: valueMarkerX,
|
|
2021
|
+
valueMarkerY: valueMarkerY
|
|
2022
|
+
};
|
|
2023
|
+
};
|
|
2024
|
+
|
|
2025
|
+
exports.getFillerGaugeValueMarkerPositions = getFillerGaugeValueMarkerPositions;
|
|
2026
|
+
/**
|
|
2027
|
+
* get dimensions for the marker bar in the gauge
|
|
2028
|
+
* @method getMarkerBarDimensions
|
|
2029
|
+
* @param {Object} input
|
|
2030
|
+
* @param {Number} input.gaugeLength
|
|
2031
|
+
* @param {Number} input.gaugeStartX
|
|
2032
|
+
* @param {Number} input.gaugeStartY
|
|
2033
|
+
* @param {Number} input.gaugeWidth,
|
|
2034
|
+
* @param {Number} input.gaugeHeight,
|
|
2035
|
+
* @param {String} input.orientation
|
|
2036
|
+
* @return {Object} markerBarDimensions
|
|
2037
|
+
* @return {Number} markerBarDimensions.markerBarLength
|
|
2038
|
+
* @return {Number} markerBarDimensions.markerBarX
|
|
2039
|
+
* @return {Number} markerBarDimensions.markerBarY
|
|
2040
|
+
* @return {Number} markerBarDimensions.markerBarWidth
|
|
2041
|
+
* @return {Number} markerBarDimensions.markerBarHeight
|
|
2042
|
+
*/
|
|
2043
|
+
|
|
2044
|
+
var getMarkerBarDimensions = function getMarkerBarDimensions(_ref13) {
|
|
2045
|
+
var gaugeLength = _ref13.gaugeLength,
|
|
2046
|
+
gaugeStartX = _ref13.gaugeStartX,
|
|
2047
|
+
gaugeStartY = _ref13.gaugeStartY,
|
|
2048
|
+
gaugeWidth = _ref13.gaugeWidth,
|
|
2049
|
+
gaugeHeight = _ref13.gaugeHeight,
|
|
2050
|
+
orientation = _ref13.orientation;
|
|
2051
|
+
var gaugeBarLength = gaugeLength; // For marker gauge, inner marker bar spans the entire gauge
|
|
2052
|
+
|
|
2053
|
+
var _exports$getGaugeBarS2 = exports.getGaugeBarStartPositions({
|
|
2054
|
+
gaugeStartX: gaugeStartX,
|
|
2055
|
+
gaugeStartY: gaugeStartY,
|
|
2056
|
+
gaugeWidth: gaugeWidth,
|
|
2057
|
+
gaugeHeight: gaugeHeight,
|
|
2058
|
+
gaugeBarLength: gaugeBarLength,
|
|
2059
|
+
orientation: orientation
|
|
2060
|
+
}),
|
|
2061
|
+
markerBarX = _exports$getGaugeBarS2.gaugeBarX,
|
|
2062
|
+
markerBarY = _exports$getGaugeBarS2.gaugeBarY;
|
|
2063
|
+
|
|
2064
|
+
var markerBarWidth = exports.getGaugeBarWidth({
|
|
2065
|
+
gaugeBarLength: gaugeBarLength,
|
|
2066
|
+
orientation: orientation
|
|
2067
|
+
});
|
|
2068
|
+
var markerBarHeight = exports.getGaugeBarHeight({
|
|
2069
|
+
gaugeBarLength: gaugeBarLength,
|
|
2070
|
+
orientation: orientation
|
|
2071
|
+
});
|
|
2072
|
+
return {
|
|
2073
|
+
markerBarLength: gaugeBarLength,
|
|
2074
|
+
markerBarX: markerBarX,
|
|
2075
|
+
markerBarY: markerBarY,
|
|
2076
|
+
markerBarWidth: markerBarWidth,
|
|
2077
|
+
markerBarHeight: markerBarHeight
|
|
2078
|
+
};
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
exports.getMarkerBarDimensions = getMarkerBarDimensions;
|
|
2082
|
+
/**
|
|
2083
|
+
* get position x and y for value marker in marker gauge
|
|
2084
|
+
* @method getMarkerGaugeValueMarkerPositions
|
|
2085
|
+
* @param {Object} input
|
|
2086
|
+
* @param {Number} input.markerBarX
|
|
2087
|
+
* @param {Number} input.markerBarY
|
|
2088
|
+
* @param {Number} input.markerBarHeight
|
|
2089
|
+
* @param {Number} input.markerBarLength
|
|
2090
|
+
* @param {Number} input.value
|
|
2091
|
+
* @param {Number} input.min
|
|
2092
|
+
* @param {Number} input.max
|
|
2093
|
+
* @param {String} input.orientation
|
|
2094
|
+
* @return {Object} position
|
|
2095
|
+
* @return {Number} position.valueMarkerX
|
|
2096
|
+
* @return {Number} position.valueMarkerY
|
|
2097
|
+
*/
|
|
2098
|
+
|
|
2099
|
+
var getMarkerGaugeValueMarkerPositions = function getMarkerGaugeValueMarkerPositions(_ref14) {
|
|
2100
|
+
var markerBarX = _ref14.markerBarX,
|
|
2101
|
+
markerBarY = _ref14.markerBarY,
|
|
2102
|
+
markerBarHeight = _ref14.markerBarHeight,
|
|
2103
|
+
gaugeLength = _ref14.markerBarLength,
|
|
2104
|
+
orientation = _ref14.orientation,
|
|
2105
|
+
value = _ref14.value,
|
|
2106
|
+
min = _ref14.min,
|
|
2107
|
+
max = _ref14.max;
|
|
2108
|
+
var valueMarkerX = markerBarX;
|
|
2109
|
+
var valueMarkerY = markerBarY;
|
|
2110
|
+
|
|
2111
|
+
if (orientation === 'vertical') {
|
|
2112
|
+
valueMarkerY += markerBarHeight - exports.getGaugeBarLength({
|
|
2113
|
+
gaugeLength: gaugeLength,
|
|
2114
|
+
value: value,
|
|
2115
|
+
max: max,
|
|
2116
|
+
min: min
|
|
2117
|
+
});
|
|
2118
|
+
valueMarkerX -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
|
|
2119
|
+
} else {
|
|
2120
|
+
valueMarkerX += exports.getGaugeBarLength({
|
|
2121
|
+
gaugeLength: gaugeLength,
|
|
2122
|
+
value: value,
|
|
2123
|
+
max: max,
|
|
2124
|
+
min: min
|
|
2125
|
+
});
|
|
2126
|
+
valueMarkerY -= (exports.GAUGE_THICKNESS - exports.FILL_THICKNESS) / 4;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
return {
|
|
2130
|
+
valueMarkerX: valueMarkerX,
|
|
2131
|
+
valueMarkerY: valueMarkerY
|
|
2132
|
+
};
|
|
2133
|
+
};
|
|
2134
|
+
|
|
2135
|
+
exports.getMarkerGaugeValueMarkerPositions = getMarkerGaugeValueMarkerPositions;
|
|
2136
|
+
/**
|
|
2137
|
+
* sort the ranges in ascending order
|
|
2138
|
+
* @method getSortedRanges
|
|
2139
|
+
* @param {Array} ranges
|
|
2140
|
+
* @return {Array} sortedRanges
|
|
2141
|
+
*/
|
|
2142
|
+
|
|
2143
|
+
var getSortedRanges = function getSortedRanges(ranges) {
|
|
2144
|
+
return ranges.sort(function (a, b) {
|
|
2145
|
+
return a.from - b.from;
|
|
2146
|
+
});
|
|
2147
|
+
};
|
|
2148
|
+
|
|
2149
|
+
exports.getSortedRanges = getSortedRanges;
|
|
2150
|
+
/**
|
|
2151
|
+
* validate whether ranges prop is valid - continuous ranges, range.to < range.from, range.from != range.to
|
|
2152
|
+
* @method validateRanges
|
|
2153
|
+
* @param {Array} ranges
|
|
2154
|
+
* @return {String} error
|
|
2155
|
+
*/
|
|
2156
|
+
|
|
2157
|
+
var validateRanges = function validateRanges(ranges) {
|
|
2158
|
+
if (!ranges.length) {
|
|
2159
|
+
return i18n_1._('Prop "ranges" is missing entries');
|
|
2160
|
+
} // check whether a range has "from" >= "to" eg: 10 - 10, 100 - 10, -20 - -10 are invalid
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
if (ranges.some(function (range) {
|
|
2164
|
+
return range.from >= range.to;
|
|
2165
|
+
})) {
|
|
2166
|
+
return i18n_1._('Prop "ranges" has invalid entries: invalid range');
|
|
2167
|
+
} // check whether ranges have duplicate "from/to" eg: 0 - 50, 25 - 50
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
if (ranges.length !== lodash_1.uniqBy(ranges, 'to').length || ranges.length !== lodash_1.uniqBy(ranges, 'from').length) {
|
|
2171
|
+
return i18n_1._('Prop "ranges" has invalid entries: duplicate values');
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
var sortedRanges = exports.getSortedRanges(ranges); // check whether ranges are continuous eg: 0 - 10, 10 - 20, 20 - 30
|
|
2175
|
+
|
|
2176
|
+
for (var i = 1; i < sortedRanges.length; i += 1) {
|
|
2177
|
+
if (sortedRanges[i].from !== sortedRanges[i - 1].to) {
|
|
2178
|
+
return i18n_1._('Prop "ranges" has invalid entries: discontinuous ranges');
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
return null;
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
exports.validateRanges = validateRanges;
|
|
2186
|
+
/**
|
|
2187
|
+
* calculate min and max value of gauge
|
|
2188
|
+
* @method getGaugeRange
|
|
2189
|
+
* @param {Array} ranges
|
|
2190
|
+
* @return {Object} gaugeRange
|
|
2191
|
+
* @return {Number} gaugeRange.min
|
|
2192
|
+
* @return {Number} gaugeRange.max
|
|
2193
|
+
*/
|
|
2194
|
+
|
|
2195
|
+
var getGaugeRange = function getGaugeRange(ranges) {
|
|
2196
|
+
var min = Math.min.apply(Math, _toConsumableArray(ranges.map(function (range) {
|
|
2197
|
+
return range.from;
|
|
2198
|
+
})));
|
|
2199
|
+
var max = Math.max.apply(Math, _toConsumableArray(ranges.map(function (range) {
|
|
2200
|
+
return range.to;
|
|
2201
|
+
})));
|
|
2202
|
+
return {
|
|
2203
|
+
min: min,
|
|
2204
|
+
max: max
|
|
2205
|
+
};
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2208
|
+
exports.getGaugeRange = getGaugeRange;
|
|
2209
|
+
/**
|
|
2210
|
+
* calculate stop offsets for linear gradient
|
|
2211
|
+
* @method getGradientStopOffsets
|
|
2212
|
+
* @param {Array} ranges
|
|
2213
|
+
* @param {String} orientation
|
|
2214
|
+
* @return {Array} cumulativeOffsets
|
|
2215
|
+
*/
|
|
2216
|
+
|
|
2217
|
+
var getGradientStopOffsets = function getGradientStopOffsets(_ref15) {
|
|
2218
|
+
var ranges = _ref15.ranges,
|
|
2219
|
+
orientation = _ref15.orientation;
|
|
2220
|
+
|
|
2221
|
+
var _exports$getGaugeRang = exports.getGaugeRange(ranges),
|
|
2222
|
+
min = _exports$getGaugeRang.min,
|
|
2223
|
+
max = _exports$getGaugeRang.max;
|
|
2224
|
+
|
|
2225
|
+
var offsetScale = (GRADIENT_STOP_OFFSET_MAX - GRADIENT_STOP_OFFSET_MIN) / (max - min);
|
|
2226
|
+
var offsets = ranges.map(function (range) {
|
|
2227
|
+
return Math.abs(range.from - range.to) * offsetScale;
|
|
2228
|
+
}); // When orientation is vertical, since the gauge starts from bottom to top, linear gradient should be reversed
|
|
2229
|
+
|
|
2230
|
+
offsets = orientation === 'vertical' ? offsets.reverse() : offsets;
|
|
2231
|
+
var cumulativeOffsets = [];
|
|
2232
|
+
offsets.reduce(function (accumulator, currentValue, idx) {
|
|
2233
|
+
cumulativeOffsets[idx] = accumulator + currentValue;
|
|
2234
|
+
return cumulativeOffsets[idx];
|
|
2235
|
+
}, 0);
|
|
2236
|
+
return cumulativeOffsets;
|
|
2237
|
+
};
|
|
2238
|
+
|
|
2239
|
+
exports.getGradientStopOffsets = getGradientStopOffsets;
|
|
2240
|
+
/**
|
|
2241
|
+
* calculate stop colors for linear gradient
|
|
2242
|
+
* @method getGradientStopColors
|
|
2243
|
+
* @param {Array} ranges
|
|
2244
|
+
* @param {String} orientation
|
|
2245
|
+
* @return {Array} stopColors
|
|
2246
|
+
*/
|
|
2247
|
+
|
|
2248
|
+
var getGradientStopColors = function getGradientStopColors(_ref16) {
|
|
2249
|
+
var ranges = _ref16.ranges,
|
|
2250
|
+
orientation = _ref16.orientation;
|
|
2251
|
+
var stopColors = ranges.map(function (range) {
|
|
2252
|
+
return range.value;
|
|
2253
|
+
}); // When orientation is vertical, since the gauge starts from bottom to top, linear gradient should be reversed
|
|
2254
|
+
|
|
2255
|
+
return orientation === 'vertical' ? stopColors.reverse() : stopColors;
|
|
2256
|
+
};
|
|
2257
|
+
|
|
2258
|
+
exports.getGradientStopColors = getGradientStopColors;
|
|
2259
|
+
/**
|
|
2260
|
+
* calculate linear gradient stops from ranges
|
|
2261
|
+
* @method getGradientStops
|
|
2262
|
+
* @param {Object} input
|
|
2263
|
+
* @param {Array} ranges
|
|
2264
|
+
* @param {String} orientation
|
|
2265
|
+
* @return {Array} stops
|
|
2266
|
+
*/
|
|
2267
|
+
|
|
2268
|
+
var getGradientStops = function getGradientStops(_ref17) {
|
|
2269
|
+
var ranges = _ref17.ranges,
|
|
2270
|
+
orientation = _ref17.orientation;
|
|
2271
|
+
var stops = [];
|
|
2272
|
+
var offsets = exports.getGradientStopOffsets({
|
|
2273
|
+
ranges: ranges,
|
|
2274
|
+
orientation: orientation
|
|
2275
|
+
});
|
|
2276
|
+
var stopColors = exports.getGradientStopColors({
|
|
2277
|
+
ranges: ranges,
|
|
2278
|
+
orientation: orientation
|
|
2279
|
+
}); // Initialize stops with the first color stop
|
|
2280
|
+
|
|
2281
|
+
stops.push({
|
|
2282
|
+
offset: "".concat(offsets[0], "%"),
|
|
2283
|
+
stopColor: stopColors[0]
|
|
2284
|
+
}); // Add the remaining color stops with gradient change at each stop
|
|
2285
|
+
|
|
2286
|
+
for (var i = 1; i < ranges.length; i += 1) {
|
|
2287
|
+
stops.push({
|
|
2288
|
+
offset: "".concat(offsets[i - 1], "%"),
|
|
2289
|
+
stopColor: stopColors[i]
|
|
2290
|
+
});
|
|
2291
|
+
stops.push({
|
|
2292
|
+
offset: "".concat(offsets[i], "%"),
|
|
2293
|
+
stopColor: stopColors[i]
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
return stops;
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2300
|
+
exports.getGradientStops = getGradientStops;
|
|
2301
|
+
/**
|
|
2302
|
+
* calculate linear gradient dimensions
|
|
2303
|
+
* @method getGradientDimensions
|
|
2304
|
+
* @param {String} orientation
|
|
2305
|
+
* @return {Object} dimensions
|
|
2306
|
+
* @return {String} dimensions.x1
|
|
2307
|
+
* @return {String} dimensions.y1
|
|
2308
|
+
* @return {String} dimensions.x2
|
|
2309
|
+
* @return {String} dimensions.y2
|
|
2310
|
+
*/
|
|
2311
|
+
|
|
2312
|
+
var getGradientDimensions = function getGradientDimensions(orientation) {
|
|
2313
|
+
var x1 = '0%';
|
|
2314
|
+
var y1 = '0%';
|
|
2315
|
+
var x2 = orientation === 'horizontal' ? '100%' : '0%';
|
|
2316
|
+
var y2 = orientation === 'horizontal' ? '0%' : '100%';
|
|
2317
|
+
return {
|
|
2318
|
+
x1: x1,
|
|
2319
|
+
y1: y1,
|
|
2320
|
+
x2: x2,
|
|
2321
|
+
y2: y2
|
|
2322
|
+
};
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2325
|
+
exports.getGradientDimensions = getGradientDimensions; // map for new options names to old option names
|
|
2326
|
+
|
|
2327
|
+
var gaugeOptionsMapping = {
|
|
2328
|
+
majorTickInterval: 'majorUnit',
|
|
2329
|
+
gaugeRanges: 'ranges'
|
|
2330
|
+
};
|
|
2331
|
+
/**
|
|
2332
|
+
* Helper method to update the option names which can be mapped to pure component options
|
|
2333
|
+
* @method mapToOldKey
|
|
2334
|
+
* @param {Object} options
|
|
2335
|
+
* @returns {Object}
|
|
2336
|
+
*/
|
|
2337
|
+
|
|
2338
|
+
var mapToOldKey = function mapToOldKey(options) {
|
|
2339
|
+
return lodash_1.mapKeys(options, function (val, key) {
|
|
2340
|
+
return gaugeOptionsMapping[key] ? gaugeOptionsMapping[key] : key;
|
|
2341
|
+
});
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
exports.mapToOldKey = mapToOldKey;
|
|
2345
|
+
/**
|
|
2346
|
+
* Helper method to map labelDisplay and valueDisplay options to pure component option names
|
|
2347
|
+
* @method mapToOldKey
|
|
2348
|
+
* @param {string} labelOrValue
|
|
2349
|
+
* @param {Object} options
|
|
2350
|
+
* @returns {Object}
|
|
2351
|
+
*/
|
|
2352
|
+
|
|
2353
|
+
var mapValueLabelDisplay = function mapValueLabelDisplay(labelOrValue, options) {
|
|
2354
|
+
var rangeOrValue = labelOrValue === 'value' ? 'Value' : 'Range';
|
|
2355
|
+
var showKey = labelOrValue === 'value' ? 'showValue' : 'showLabels';
|
|
2356
|
+
var percentKey = "usePercentage".concat(rangeOrValue);
|
|
2357
|
+
var optionString = "".concat(labelOrValue, "Display");
|
|
2358
|
+
var newOptions = Object.assign({}, options);
|
|
2359
|
+
|
|
2360
|
+
if (newOptions[optionString]) {
|
|
2361
|
+
if (newOptions[optionString] === 'number') {
|
|
2362
|
+
newOptions[showKey] = true;
|
|
2363
|
+
newOptions[percentKey] = false;
|
|
2364
|
+
} else if (newOptions[optionString] === 'percentage') {
|
|
2365
|
+
newOptions[showKey] = true;
|
|
2366
|
+
newOptions[percentKey] = true;
|
|
2367
|
+
} else {
|
|
2368
|
+
newOptions[showKey] = false;
|
|
2369
|
+
newOptions[percentKey] = false;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
return lodash_1.omit(newOptions, [optionString]);
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
exports.mapValueLabelDisplay = mapValueLabelDisplay;
|
|
2377
|
+
/**
|
|
2378
|
+
* Chained helper for mapping the option properties (and values) we expose in config.ts into property values that pure component accepts
|
|
2379
|
+
* This is for options that has new key name and can not directly be mapped with pure component props
|
|
2380
|
+
* @method convertToGaugeProperties
|
|
2381
|
+
* @param {Object} originalOptions
|
|
2382
|
+
* @returns {Object}
|
|
2383
|
+
*/
|
|
2384
|
+
|
|
2385
|
+
var convertToGaugeProperties = function convertToGaugeProperties(originalOptions) {
|
|
2386
|
+
return lodash_1.chain(exports.mapToOldKey(originalOptions)).thru(function (options) {
|
|
2387
|
+
return exports.mapValueLabelDisplay('label', options);
|
|
2388
|
+
}).thru(function (options) {
|
|
2389
|
+
return exports.mapValueLabelDisplay('value', options);
|
|
2390
|
+
}).value();
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2393
|
+
exports.convertToGaugeProperties = convertToGaugeProperties;
|
|
2394
|
+
|
|
2395
|
+
/***/ }),
|
|
2396
|
+
/* 72 */,
|
|
2397
|
+
/* 73 */,
|
|
2398
|
+
/* 74 */,
|
|
2399
|
+
/* 75 */,
|
|
2400
|
+
/* 76 */,
|
|
2401
|
+
/* 77 */,
|
|
2402
|
+
/* 78 */,
|
|
2403
|
+
/* 79 */,
|
|
2404
|
+
/* 80 */,
|
|
2405
|
+
/* 81 */,
|
|
2406
|
+
/* 82 */,
|
|
2407
|
+
/* 83 */,
|
|
2408
|
+
/* 84 */,
|
|
2409
|
+
/* 85 */,
|
|
2410
|
+
/* 86 */,
|
|
2411
|
+
/* 87 */,
|
|
2412
|
+
/* 88 */,
|
|
2413
|
+
/* 89 */,
|
|
2414
|
+
/* 90 */
|
|
2415
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
2416
|
+
|
|
2417
|
+
"use strict";
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2421
|
+
value: true
|
|
2422
|
+
});
|
|
2423
|
+
|
|
2424
|
+
var i18n_1 = __webpack_require__(3);
|
|
2425
|
+
|
|
2426
|
+
var gauge = {
|
|
2427
|
+
label: i18n_1._('Gauge Settings'),
|
|
2428
|
+
layout: [[{
|
|
2429
|
+
label: i18n_1._('Value Display'),
|
|
2430
|
+
option: 'valueDisplay',
|
|
2431
|
+
editor: 'editor.radioBar',
|
|
2432
|
+
editorProps: {
|
|
2433
|
+
values: [{
|
|
2434
|
+
label: i18n_1._('Number'),
|
|
2435
|
+
value: 'number'
|
|
2436
|
+
}, {
|
|
2437
|
+
label: i18n_1._('Percentage'),
|
|
2438
|
+
value: 'percentage'
|
|
2439
|
+
}, {
|
|
2440
|
+
label: i18n_1._('Off'),
|
|
2441
|
+
value: 'off'
|
|
2442
|
+
}]
|
|
2443
|
+
}
|
|
2444
|
+
}], [{
|
|
2445
|
+
label: i18n_1._('Label Display'),
|
|
2446
|
+
option: 'labelDisplay',
|
|
2447
|
+
editor: 'editor.radioBar',
|
|
2448
|
+
editorProps: {
|
|
2449
|
+
values: [{
|
|
2450
|
+
label: i18n_1._('Numbers'),
|
|
2451
|
+
value: 'number'
|
|
2452
|
+
}, {
|
|
2453
|
+
label: i18n_1._('Percentages'),
|
|
2454
|
+
value: 'percentage'
|
|
2455
|
+
}, {
|
|
2456
|
+
label: i18n_1._('Off'),
|
|
2457
|
+
value: 'off'
|
|
2458
|
+
}]
|
|
2459
|
+
}
|
|
2460
|
+
}], [{
|
|
2461
|
+
label: i18n_1._('Orientation'),
|
|
2462
|
+
option: 'orientation',
|
|
2463
|
+
editor: 'editor.radioBar',
|
|
2464
|
+
editorProps: {
|
|
2465
|
+
values: [{
|
|
2466
|
+
label: i18n_1._('Vertical'),
|
|
2467
|
+
value: 'vertical'
|
|
2468
|
+
}, {
|
|
2469
|
+
label: i18n_1._('Horizontal'),
|
|
2470
|
+
value: 'horizontal'
|
|
2471
|
+
}]
|
|
2472
|
+
}
|
|
2473
|
+
}]]
|
|
2474
|
+
};
|
|
2475
|
+
exports.default = gauge;
|
|
2476
|
+
|
|
2477
|
+
/***/ }),
|
|
2478
|
+
/* 91 */
|
|
2479
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2480
|
+
|
|
2481
|
+
"use strict";
|
|
2482
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2483
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MajorTick", function() { return MajorTick; });
|
|
2484
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionMajorTick", function() { return positionMajorTick; });
|
|
2485
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43);
|
|
2486
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
2487
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
2488
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
2489
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
|
|
2490
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
|
|
2491
|
+
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
|
|
2492
|
+
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
|
|
2493
|
+
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20);
|
|
2494
|
+
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
var DEFAULT_NUM_OF_TICKS = 5;
|
|
2501
|
+
var TICK_LENGTH_DELTA = 5;
|
|
2502
|
+
var TICK_LABEL_PADDING_FACTOR = 3.2;
|
|
2503
|
+
var MajorTickLine = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.line.withConfig({
|
|
2504
|
+
displayName: "GaugeMajorTicks__MajorTickLine",
|
|
2505
|
+
componentId: "mchiad-0"
|
|
2506
|
+
})(["stroke:", ";stroke-width:2px;stroke-dasharray:", ";"], function (props) {
|
|
2507
|
+
return props.majorTickStrokeColor;
|
|
2508
|
+
}, function (props) {
|
|
2509
|
+
return props.index === 0 ? 0 : 3;
|
|
2510
|
+
});
|
|
2511
|
+
var MajorTickLabel = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.text.withConfig({
|
|
2512
|
+
displayName: "GaugeMajorTicks__MajorTickLabel",
|
|
2513
|
+
componentId: "mchiad-1"
|
|
2514
|
+
})(["font-size:12px;font-family:Splunk Platform Sans,sans-serif;line-height:19px;fill:", ";text-anchor:middle;text-align:center;"], function (props) {
|
|
2515
|
+
return props.majorTickFillColor;
|
|
2516
|
+
});
|
|
2517
|
+
var MajorTick = function MajorTick(_ref) {
|
|
2518
|
+
var index = _ref.index,
|
|
2519
|
+
x1 = _ref.x1,
|
|
2520
|
+
y1 = _ref.y1,
|
|
2521
|
+
x2 = _ref.x2,
|
|
2522
|
+
y2 = _ref.y2,
|
|
2523
|
+
showLabels = _ref.showLabels,
|
|
2524
|
+
label = _ref.label,
|
|
2525
|
+
labelX = _ref.labelX,
|
|
2526
|
+
labelY = _ref.labelY,
|
|
2527
|
+
majorTickStrokeColor = _ref.majorTickStrokeColor,
|
|
2528
|
+
majorTickFillColor = _ref.majorTickFillColor;
|
|
2529
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTickLine, {
|
|
2530
|
+
index: index,
|
|
2531
|
+
x1: x1,
|
|
2532
|
+
y1: y1,
|
|
2533
|
+
x2: x2,
|
|
2534
|
+
y2: y2,
|
|
2535
|
+
majorTickStrokeColor: majorTickStrokeColor
|
|
2536
|
+
}), showLabels && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTickLabel, {
|
|
2537
|
+
x: labelX,
|
|
2538
|
+
y: labelY,
|
|
2539
|
+
majorTickFillColor: majorTickFillColor
|
|
2540
|
+
}, Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["isNumerial"])(label) ? Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(label, 0, {
|
|
2541
|
+
useThousandSeparators: true,
|
|
2542
|
+
useTrendUnits: true
|
|
2543
|
+
}) : label));
|
|
2544
|
+
};
|
|
2545
|
+
MajorTick.propTypes = {
|
|
2546
|
+
index: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2547
|
+
x1: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2548
|
+
y1: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2549
|
+
x2: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2550
|
+
y2: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2551
|
+
showLabels: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2552
|
+
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]),
|
|
2553
|
+
labelX: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2554
|
+
labelY: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2555
|
+
majorTickStrokeColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
|
|
2556
|
+
majorTickFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
|
|
2557
|
+
};
|
|
2558
|
+
/**
|
|
2559
|
+
* calculate position for each major tick
|
|
2560
|
+
* @method positionMajorTick
|
|
2561
|
+
* @param {Object} input
|
|
2562
|
+
* @param {Number} input.width
|
|
2563
|
+
* @param {Number} input.height
|
|
2564
|
+
* @param {Number} input.startX start x for rendering the first major tick
|
|
2565
|
+
* @param {Number} input.startY start y for rendering the first major tick
|
|
2566
|
+
* @param {String} input.orientation
|
|
2567
|
+
* @param {Number} input.numOfTicks how many ticks need to render
|
|
2568
|
+
* @param {Number} input.i index of major tick
|
|
2569
|
+
* @return {Object} MajorTick positions
|
|
2570
|
+
*/
|
|
2571
|
+
|
|
2572
|
+
var positionMajorTick = function positionMajorTick(_ref2) {
|
|
2573
|
+
var width = _ref2.width,
|
|
2574
|
+
height = _ref2.height,
|
|
2575
|
+
startX = _ref2.startX,
|
|
2576
|
+
startY = _ref2.startY,
|
|
2577
|
+
orientation = _ref2.orientation,
|
|
2578
|
+
numOfTicks = _ref2.numOfTicks,
|
|
2579
|
+
i = _ref2.i;
|
|
2580
|
+
var x1 = startX;
|
|
2581
|
+
var y1 = startY;
|
|
2582
|
+
var x2 = startX;
|
|
2583
|
+
var y2 = startY;
|
|
2584
|
+
var labelX = startX;
|
|
2585
|
+
var labelY;
|
|
2586
|
+
|
|
2587
|
+
if (orientation === 'vertical') {
|
|
2588
|
+
var y = height / numOfTicks * (numOfTicks - i) + startY;
|
|
2589
|
+
x1 -= TICK_LENGTH_DELTA;
|
|
2590
|
+
y1 = y;
|
|
2591
|
+
x2 += width + TICK_LENGTH_DELTA;
|
|
2592
|
+
y2 = y;
|
|
2593
|
+
labelX += width + TICK_LENGTH_DELTA * TICK_LABEL_PADDING_FACTOR;
|
|
2594
|
+
labelY = y;
|
|
2595
|
+
} else {
|
|
2596
|
+
var x = width / numOfTicks * i + startX;
|
|
2597
|
+
x1 = x;
|
|
2598
|
+
y1 -= TICK_LENGTH_DELTA;
|
|
2599
|
+
x2 = x;
|
|
2600
|
+
y2 += height + TICK_LENGTH_DELTA;
|
|
2601
|
+
labelX = x;
|
|
2602
|
+
labelY = y2 + 16;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
return {
|
|
2606
|
+
x1: x1,
|
|
2607
|
+
y1: y1,
|
|
2608
|
+
x2: x2,
|
|
2609
|
+
y2: y2,
|
|
2610
|
+
labelX: labelX,
|
|
2611
|
+
labelY: labelY
|
|
2612
|
+
};
|
|
2613
|
+
};
|
|
2614
|
+
|
|
2615
|
+
var MajorTicks = function MajorTicks(_ref3) {
|
|
2616
|
+
var props = _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _ref3);
|
|
2617
|
+
|
|
2618
|
+
var width = props.width,
|
|
2619
|
+
height = props.height,
|
|
2620
|
+
startX = props.startX,
|
|
2621
|
+
startY = props.startY,
|
|
2622
|
+
min = props.min,
|
|
2623
|
+
max = props.max,
|
|
2624
|
+
majorUnit = props.majorUnit,
|
|
2625
|
+
orientation = props.orientation,
|
|
2626
|
+
showLabels = props.showLabels,
|
|
2627
|
+
usePercentageRange = props.usePercentageRange,
|
|
2628
|
+
majorTickFillColor = props.majorTickFillColor,
|
|
2629
|
+
majorTickStrokeColor = props.majorTickStrokeColor;
|
|
2630
|
+
var range = max - min;
|
|
2631
|
+
var numOfTicks = majorUnit === 'auto' || Number.isNaN(Number(majorUnit)) || majorUnit <= 0 ? DEFAULT_NUM_OF_TICKS : range / majorUnit;
|
|
2632
|
+
var majorTicks = [];
|
|
2633
|
+
|
|
2634
|
+
for (var i = 0; i <= numOfTicks; i += 1) {
|
|
2635
|
+
var _positionMajorTick = positionMajorTick({
|
|
2636
|
+
width: width,
|
|
2637
|
+
height: height,
|
|
2638
|
+
startX: startX,
|
|
2639
|
+
startY: startY,
|
|
2640
|
+
orientation: orientation,
|
|
2641
|
+
numOfTicks: numOfTicks,
|
|
2642
|
+
i: i
|
|
2643
|
+
}),
|
|
2644
|
+
x1 = _positionMajorTick.x1,
|
|
2645
|
+
y1 = _positionMajorTick.y1,
|
|
2646
|
+
x2 = _positionMajorTick.x2,
|
|
2647
|
+
y2 = _positionMajorTick.y2,
|
|
2648
|
+
labelX = _positionMajorTick.labelX,
|
|
2649
|
+
labelY = _positionMajorTick.labelY;
|
|
2650
|
+
|
|
2651
|
+
var label = usePercentageRange ? "".concat(parseInt((i / numOfTicks - min / range) * 100, 10), "%") : parseInt(min + range / numOfTicks * i, 10);
|
|
2652
|
+
majorTicks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTick, {
|
|
2653
|
+
key: i,
|
|
2654
|
+
index: i,
|
|
2655
|
+
x1: x1,
|
|
2656
|
+
y1: y1,
|
|
2657
|
+
x2: x2,
|
|
2658
|
+
y2: y2,
|
|
2659
|
+
showLabels: showLabels,
|
|
2660
|
+
label: label,
|
|
2661
|
+
labelX: labelX,
|
|
2662
|
+
labelY: labelY,
|
|
2663
|
+
majorTickFillColor: majorTickFillColor,
|
|
2664
|
+
majorTickStrokeColor: majorTickStrokeColor
|
|
2665
|
+
}));
|
|
2666
|
+
} // if the gauge is not divided evenly, put the last tick at the end of the gauge
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
if (!Number.isInteger(numOfTicks)) {
|
|
2670
|
+
var extraNumOfTicks = Math.ceil(numOfTicks);
|
|
2671
|
+
|
|
2672
|
+
var _positionMajorTick2 = positionMajorTick({
|
|
2673
|
+
width: width,
|
|
2674
|
+
height: height,
|
|
2675
|
+
startX: startX,
|
|
2676
|
+
startY: startY,
|
|
2677
|
+
orientation: orientation,
|
|
2678
|
+
numOfTicks: extraNumOfTicks,
|
|
2679
|
+
i: extraNumOfTicks
|
|
2680
|
+
}),
|
|
2681
|
+
_x = _positionMajorTick2.x1,
|
|
2682
|
+
_y = _positionMajorTick2.y1,
|
|
2683
|
+
_x2 = _positionMajorTick2.x2,
|
|
2684
|
+
_y2 = _positionMajorTick2.y2,
|
|
2685
|
+
_labelX = _positionMajorTick2.labelX,
|
|
2686
|
+
_labelY = _positionMajorTick2.labelY;
|
|
2687
|
+
|
|
2688
|
+
majorTicks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(MajorTick, {
|
|
2689
|
+
key: extraNumOfTicks,
|
|
2690
|
+
id: extraNumOfTicks,
|
|
2691
|
+
x1: _x,
|
|
2692
|
+
y1: _y,
|
|
2693
|
+
x2: _x2,
|
|
2694
|
+
y2: _y2,
|
|
2695
|
+
showLabels: showLabels,
|
|
2696
|
+
label: usePercentageRange ? '100%' : max,
|
|
2697
|
+
labelX: _labelX,
|
|
2698
|
+
labelY: _labelY,
|
|
2699
|
+
majorTickFillColor: majorTickFillColor,
|
|
2700
|
+
majorTickStrokeColor: majorTickStrokeColor
|
|
2701
|
+
}));
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, majorTicks);
|
|
2705
|
+
};
|
|
2706
|
+
|
|
2707
|
+
MajorTicks.propTypes = {
|
|
2708
|
+
width: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2709
|
+
height: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2710
|
+
startX: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2711
|
+
startY: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2712
|
+
min: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2713
|
+
max: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2714
|
+
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]),
|
|
2715
|
+
orientation: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
|
|
2716
|
+
showLabels: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2717
|
+
usePercentageRange: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2718
|
+
majorTickFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
|
|
2719
|
+
majorTickStrokeColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
|
|
2720
|
+
};
|
|
2721
|
+
MajorTicks.defaultProps = {
|
|
2722
|
+
min: 0,
|
|
2723
|
+
max: 100,
|
|
2724
|
+
majorUnit: 'auto',
|
|
2725
|
+
orientation: 'horizontal',
|
|
2726
|
+
showLabels: true,
|
|
2727
|
+
usePercentageRange: false
|
|
2728
|
+
};
|
|
2729
|
+
/* harmony default export */ __webpack_exports__["default"] = (MajorTicks);
|
|
2730
|
+
|
|
2731
|
+
/***/ }),
|
|
2732
|
+
/* 92 */
|
|
2733
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2734
|
+
|
|
2735
|
+
"use strict";
|
|
2736
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2737
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionValueMarkerRect", function() { return positionValueMarkerRect; });
|
|
2738
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positionLabel", function() { return positionLabel; });
|
|
2739
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43);
|
|
2740
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
2741
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
2742
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
2743
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
|
|
2744
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
|
|
2745
|
+
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
|
|
2746
|
+
/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
|
|
2747
|
+
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(20);
|
|
2748
|
+
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);
|
|
2749
|
+
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
|
|
2753
|
+
|
|
2754
|
+
var MARKER_THICKNESS = 15;
|
|
2755
|
+
var MARKER_INNER_LENGTH = 30;
|
|
2756
|
+
var MARKER_LABEL_WIDTH = 60;
|
|
2757
|
+
var MARKER_LABEL_HEIGHT = 25;
|
|
2758
|
+
var RADIUS = 2;
|
|
2759
|
+
var DELTA_LENGTH = 12;
|
|
2760
|
+
var ValueMarkerRect = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.path.withConfig({
|
|
2761
|
+
displayName: "GaugeValueMarker__ValueMarkerRect",
|
|
2762
|
+
componentId: "sc-1bxkeao-0"
|
|
2763
|
+
})(["stroke-width:2px;fill:", ";"], function (props) {
|
|
2764
|
+
return props.valueMarkerFillColor;
|
|
2765
|
+
});
|
|
2766
|
+
var ValueMarkerLabelRect = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.rect.withConfig({
|
|
2767
|
+
displayName: "GaugeValueMarker__ValueMarkerLabelRect",
|
|
2768
|
+
componentId: "sc-1bxkeao-1"
|
|
2769
|
+
})(["fill:", ";"], function (props) {
|
|
2770
|
+
return props.valueMarkerFillColor;
|
|
2771
|
+
});
|
|
2772
|
+
var ValueMarkerLabel = styled_components__WEBPACK_IMPORTED_MODULE_3___default.a.text.withConfig({
|
|
2773
|
+
displayName: "GaugeValueMarker__ValueMarkerLabel",
|
|
2774
|
+
componentId: "sc-1bxkeao-2"
|
|
2775
|
+
})(["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) {
|
|
2776
|
+
return props.valueMarkerLabelFillColor;
|
|
2777
|
+
});
|
|
2778
|
+
/**
|
|
2779
|
+
* calculate the path of Value Marker shape
|
|
2780
|
+
* @method positionValueMarkerRect
|
|
2781
|
+
* @param {Object} input
|
|
2782
|
+
* @param {Number} input.x
|
|
2783
|
+
* @param {Number} input.y
|
|
2784
|
+
* @param {String} input.orientation
|
|
2785
|
+
* @param {Number} input.valueMarkerRectLength
|
|
2786
|
+
* @return {String} d containing a series of path commands that define the path to be
|
|
2787
|
+
*/
|
|
2788
|
+
|
|
2789
|
+
var positionValueMarkerRect = function positionValueMarkerRect(_ref) {
|
|
2790
|
+
var x = _ref.x,
|
|
2791
|
+
y = _ref.y,
|
|
2792
|
+
orientation = _ref.orientation,
|
|
2793
|
+
valueMarkerRectLength = _ref.valueMarkerRectLength;
|
|
2794
|
+
var hLength = MARKER_THICKNESS;
|
|
2795
|
+
var vLength = valueMarkerRectLength;
|
|
2796
|
+
var markerStartX = x - MARKER_THICKNESS;
|
|
2797
|
+
var markerStartY = y;
|
|
2798
|
+
var innerHLength = hLength / 3;
|
|
2799
|
+
var innerVLength = MARKER_INNER_LENGTH;
|
|
2800
|
+
var innerStartX = markerStartX + innerHLength;
|
|
2801
|
+
var innerStartY = markerStartY + 7;
|
|
2802
|
+
|
|
2803
|
+
if (orientation === 'vertical') {
|
|
2804
|
+
hLength = valueMarkerRectLength;
|
|
2805
|
+
vLength = MARKER_THICKNESS;
|
|
2806
|
+
markerStartX = x;
|
|
2807
|
+
innerHLength = MARKER_INNER_LENGTH;
|
|
2808
|
+
innerVLength = vLength / 3;
|
|
2809
|
+
innerStartX = markerStartX + 7;
|
|
2810
|
+
innerStartY = markerStartY + innerVLength;
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
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");
|
|
2814
|
+
};
|
|
2815
|
+
/**
|
|
2816
|
+
* calculate the position of value marker label
|
|
2817
|
+
* @method positionLabel
|
|
2818
|
+
* @param {Object} input
|
|
2819
|
+
* @param {Number} input.x
|
|
2820
|
+
* @param {Number} input.y
|
|
2821
|
+
* @param {Number} input.length gauge thickness
|
|
2822
|
+
* @param {String} input.orientation
|
|
2823
|
+
* @return {Object} positions
|
|
2824
|
+
* @return {Number} positions.labelRectX x of value marker label rect
|
|
2825
|
+
* @return {Number} positions.labelRectY y of value marker label rect
|
|
2826
|
+
* @return {Number} positions.labelX x of value marker label text
|
|
2827
|
+
* @return {Number} positions.labelY y of value marker label text
|
|
2828
|
+
*/
|
|
2829
|
+
|
|
2830
|
+
var positionLabel = function positionLabel(_ref2) {
|
|
2831
|
+
var x = _ref2.x,
|
|
2832
|
+
y = _ref2.y,
|
|
2833
|
+
length = _ref2.length,
|
|
2834
|
+
orientation = _ref2.orientation; // for horizontal view
|
|
2835
|
+
|
|
2836
|
+
var labelRectX = x - MARKER_THICKNESS / 2 - MARKER_LABEL_WIDTH / 2;
|
|
2837
|
+
var labelRectY = y + length;
|
|
2838
|
+
|
|
2839
|
+
if (orientation === 'vertical') {
|
|
2840
|
+
labelRectX = x + length;
|
|
2841
|
+
labelRectY = y - (MARKER_LABEL_HEIGHT - MARKER_THICKNESS) / 2;
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
var labelX = labelRectX + MARKER_LABEL_WIDTH / 2;
|
|
2845
|
+
var labelY = labelRectY + MARKER_LABEL_HEIGHT / 2;
|
|
2846
|
+
return {
|
|
2847
|
+
labelRectX: labelRectX,
|
|
2848
|
+
labelRectY: labelRectY,
|
|
2849
|
+
labelX: labelX,
|
|
2850
|
+
labelY: labelY
|
|
2851
|
+
};
|
|
2852
|
+
};
|
|
2853
|
+
|
|
2854
|
+
var ValueMarker = function ValueMarker(_ref3) {
|
|
2855
|
+
var props = _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _ref3);
|
|
2856
|
+
|
|
2857
|
+
var x = props.x,
|
|
2858
|
+
y = props.y,
|
|
2859
|
+
length = props.length,
|
|
2860
|
+
min = props.min,
|
|
2861
|
+
max = props.max,
|
|
2862
|
+
value = props.value,
|
|
2863
|
+
orientation = props.orientation,
|
|
2864
|
+
showValue = props.showValue,
|
|
2865
|
+
usePercentageValue = props.usePercentageValue,
|
|
2866
|
+
valueMarkerFillColor = props.valueMarkerFillColor,
|
|
2867
|
+
valueMarkerLabelFillColor = props.valueMarkerLabelFillColor;
|
|
2868
|
+
var valueMarkerRectLength = length + DELTA_LENGTH;
|
|
2869
|
+
|
|
2870
|
+
var _positionLabel = positionLabel({
|
|
2871
|
+
x: x,
|
|
2872
|
+
y: y,
|
|
2873
|
+
length: length,
|
|
2874
|
+
orientation: orientation
|
|
2875
|
+
}),
|
|
2876
|
+
labelRectX = _positionLabel.labelRectX,
|
|
2877
|
+
labelRectY = _positionLabel.labelRectY,
|
|
2878
|
+
labelX = _positionLabel.labelX,
|
|
2879
|
+
labelY = _positionLabel.labelY;
|
|
2880
|
+
|
|
2881
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(ValueMarkerRect, {
|
|
2882
|
+
"data-test": "value-marker-rect",
|
|
2883
|
+
d: positionValueMarkerRect({
|
|
2884
|
+
x: x,
|
|
2885
|
+
y: y,
|
|
2886
|
+
orientation: orientation,
|
|
2887
|
+
valueMarkerRectLength: valueMarkerRectLength
|
|
2888
|
+
}),
|
|
2889
|
+
valueMarkerFillColor: valueMarkerFillColor
|
|
2890
|
+
}), showValue && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("g", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(ValueMarkerLabelRect, {
|
|
2891
|
+
"data-test": "value-marker-label-rect",
|
|
2892
|
+
x: labelRectX,
|
|
2893
|
+
y: labelRectY,
|
|
2894
|
+
width: MARKER_LABEL_WIDTH,
|
|
2895
|
+
height: MARKER_LABEL_HEIGHT,
|
|
2896
|
+
rx: RADIUS,
|
|
2897
|
+
ry: RADIUS,
|
|
2898
|
+
valueMarkerFillColor: valueMarkerFillColor
|
|
2899
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(ValueMarkerLabel, {
|
|
2900
|
+
"data-test": "value-marker-label",
|
|
2901
|
+
x: labelX,
|
|
2902
|
+
y: labelY,
|
|
2903
|
+
valueMarkerLabelFillColor: valueMarkerLabelFillColor
|
|
2904
|
+
}, usePercentageValue ? "".concat((value / (max - min) * 100).toFixed(2), "%") : Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(value, 0, {
|
|
2905
|
+
useThousandSeparators: true,
|
|
2906
|
+
useTrendUnits: true
|
|
2907
|
+
}))));
|
|
2908
|
+
};
|
|
2909
|
+
|
|
2910
|
+
ValueMarker.propTypes = {
|
|
2911
|
+
x: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2912
|
+
y: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2913
|
+
length: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2914
|
+
min: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2915
|
+
max: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2916
|
+
value: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.number,
|
|
2917
|
+
orientation: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
|
|
2918
|
+
showValue: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2919
|
+
usePercentageValue: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.bool,
|
|
2920
|
+
valueMarkerFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string,
|
|
2921
|
+
valueMarkerLabelFillColor: prop_types__WEBPACK_IMPORTED_MODULE_2___default.a.string
|
|
2922
|
+
};
|
|
2923
|
+
ValueMarker.defaultProps = {
|
|
2924
|
+
min: 0,
|
|
2925
|
+
max: 100,
|
|
2926
|
+
orientation: 'horizontal',
|
|
2927
|
+
showValue: true,
|
|
2928
|
+
usePercentageValue: false
|
|
2929
|
+
};
|
|
2930
|
+
/* harmony default export */ __webpack_exports__["default"] = (ValueMarker);
|
|
2931
|
+
|
|
2932
|
+
/***/ }),
|
|
2933
|
+
/* 93 */,
|
|
2934
|
+
/* 94 */,
|
|
2935
|
+
/* 95 */,
|
|
2936
|
+
/* 96 */,
|
|
2937
|
+
/* 97 */,
|
|
2938
|
+
/* 98 */,
|
|
2939
|
+
/* 99 */,
|
|
2940
|
+
/* 100 */,
|
|
2941
|
+
/* 101 */,
|
|
2942
|
+
/* 102 */,
|
|
2943
|
+
/* 103 */,
|
|
2944
|
+
/* 104 */,
|
|
2945
|
+
/* 105 */,
|
|
2946
|
+
/* 106 */,
|
|
2947
|
+
/* 107 */,
|
|
2948
|
+
/* 108 */,
|
|
2949
|
+
/* 109 */,
|
|
2950
|
+
/* 110 */,
|
|
2951
|
+
/* 111 */,
|
|
2952
|
+
/* 112 */,
|
|
2953
|
+
/* 113 */,
|
|
2954
|
+
/* 114 */,
|
|
2955
|
+
/* 115 */,
|
|
2956
|
+
/* 116 */,
|
|
2957
|
+
/* 117 */,
|
|
2958
|
+
/* 118 */,
|
|
2959
|
+
/* 119 */,
|
|
2960
|
+
/* 120 */,
|
|
2961
|
+
/* 121 */,
|
|
2962
|
+
/* 122 */,
|
|
2963
|
+
/* 123 */,
|
|
2964
|
+
/* 124 */,
|
|
2965
|
+
/* 125 */,
|
|
2966
|
+
/* 126 */,
|
|
2967
|
+
/* 127 */,
|
|
2968
|
+
/* 128 */,
|
|
2969
|
+
/* 129 */,
|
|
2970
|
+
/* 130 */,
|
|
2971
|
+
/* 131 */,
|
|
2972
|
+
/* 132 */,
|
|
2973
|
+
/* 133 */,
|
|
2974
|
+
/* 134 */,
|
|
2975
|
+
/* 135 */,
|
|
2976
|
+
/* 136 */,
|
|
2977
|
+
/* 137 */,
|
|
2978
|
+
/* 138 */,
|
|
2979
|
+
/* 139 */,
|
|
2980
|
+
/* 140 */,
|
|
2981
|
+
/* 141 */,
|
|
2982
|
+
/* 142 */,
|
|
2983
|
+
/* 143 */,
|
|
2984
|
+
/* 144 */,
|
|
2985
|
+
/* 145 */,
|
|
2986
|
+
/* 146 */,
|
|
2987
|
+
/* 147 */,
|
|
2988
|
+
/* 148 */,
|
|
2989
|
+
/* 149 */,
|
|
2990
|
+
/* 150 */,
|
|
2991
|
+
/* 151 */,
|
|
2992
|
+
/* 152 */,
|
|
2993
|
+
/* 153 */,
|
|
2994
|
+
/* 154 */,
|
|
2995
|
+
/* 155 */,
|
|
2996
|
+
/* 156 */,
|
|
2997
|
+
/* 157 */,
|
|
2998
|
+
/* 158 */,
|
|
2999
|
+
/* 159 */,
|
|
3000
|
+
/* 160 */
|
|
3001
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3002
|
+
|
|
3003
|
+
"use strict";
|
|
3004
|
+
|
|
3005
|
+
|
|
3006
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
3007
|
+
var t = {};
|
|
3008
|
+
|
|
3009
|
+
for (var p in s) {
|
|
3010
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
3014
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
3015
|
+
}
|
|
3016
|
+
return t;
|
|
3017
|
+
};
|
|
3018
|
+
|
|
3019
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3020
|
+
value: true
|
|
3021
|
+
});
|
|
3022
|
+
exports.themes = exports.computeVizProps = exports.PureFillerGauge = exports.config = void 0;
|
|
3023
|
+
|
|
3024
|
+
var lodash_1 = __webpack_require__(2);
|
|
3025
|
+
|
|
3026
|
+
var config_1 = __webpack_require__(161);
|
|
3027
|
+
|
|
3028
|
+
var withDashboardViz_1 = __webpack_require__(27);
|
|
3029
|
+
|
|
3030
|
+
var FillerGauge_1 = __webpack_require__(164);
|
|
3031
|
+
|
|
3032
|
+
var gaugeUtils_1 = __webpack_require__(71);
|
|
3033
|
+
|
|
3034
|
+
exports.config = config_1.default;
|
|
3035
|
+
exports.PureFillerGauge = FillerGauge_1.default;
|
|
3036
|
+
var validOptions = Object.keys(exports.config.optionsSchema);
|
|
3037
|
+
|
|
3038
|
+
var computeVizProps = function computeVizProps(_a) {
|
|
3039
|
+
var props = __rest(_a, []);
|
|
3040
|
+
|
|
3041
|
+
var options = lodash_1.chain(props).pick(validOptions).thru(gaugeUtils_1.convertToGaugeProperties).value();
|
|
3042
|
+
var defaultColors = {
|
|
3043
|
+
backgroundBarFillColor: exports.config.themes.defaultBackgroundBarFillColor(props),
|
|
3044
|
+
majorTickFillColor: exports.config.themes.majorTickFillColor(props),
|
|
3045
|
+
majorTickStrokeColor: exports.config.themes.majorTickStrokeColor(props),
|
|
3046
|
+
valueMarkerFillColor: exports.config.themes.valueMarkerFillColor(props),
|
|
3047
|
+
valueMarkerLabelFillColor: exports.config.themes.valueMarkerLabelFillColor(props)
|
|
3048
|
+
};
|
|
3049
|
+
return Object.assign(Object.assign({}, options), defaultColors);
|
|
3050
|
+
};
|
|
3051
|
+
|
|
3052
|
+
exports.computeVizProps = computeVizProps;
|
|
3053
|
+
var viz = withDashboardViz_1.default({
|
|
3054
|
+
ReactViz: FillerGauge_1.default,
|
|
3055
|
+
computeVizProps: exports.computeVizProps,
|
|
3056
|
+
vizConfig: config_1.default
|
|
3057
|
+
});
|
|
3058
|
+
exports.themes = config_1.default.themes;
|
|
3059
|
+
exports.default = viz;
|
|
3060
|
+
|
|
3061
|
+
/***/ }),
|
|
3062
|
+
/* 161 */
|
|
3063
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3064
|
+
|
|
3065
|
+
"use strict";
|
|
3066
|
+
|
|
3067
|
+
|
|
3068
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3069
|
+
value: true
|
|
3070
|
+
});
|
|
3071
|
+
|
|
3072
|
+
var i18n_1 = __webpack_require__(3);
|
|
3073
|
+
|
|
3074
|
+
var schemaUtils_1 = __webpack_require__(14);
|
|
3075
|
+
|
|
3076
|
+
var pick_1 = __webpack_require__(21);
|
|
3077
|
+
|
|
3078
|
+
var variables_1 = __webpack_require__(19);
|
|
3079
|
+
|
|
3080
|
+
var PresetPalettes_1 = __webpack_require__(56);
|
|
3081
|
+
|
|
3082
|
+
var GaugeFiller_1 = __webpack_require__(162);
|
|
3083
|
+
|
|
3084
|
+
var VizBehavior_1 = __webpack_require__(5);
|
|
3085
|
+
|
|
3086
|
+
var VizCategory_1 = __webpack_require__(26);
|
|
3087
|
+
|
|
3088
|
+
var configUtils_1 = __webpack_require__(8);
|
|
3089
|
+
|
|
3090
|
+
var Gauge_1 = __webpack_require__(90);
|
|
3091
|
+
|
|
3092
|
+
var BackgroundColor_1 = __webpack_require__(44);
|
|
3093
|
+
|
|
3094
|
+
var DynamicGaugeColorEditor_1 = __webpack_require__(163);
|
|
3095
|
+
|
|
3096
|
+
var dataContract = {
|
|
3097
|
+
requiredDataSources: [{
|
|
3098
|
+
name: 'primary',
|
|
3099
|
+
description: 'DataSource that powers the visualization'
|
|
3100
|
+
}],
|
|
3101
|
+
optionalDataSources: [],
|
|
3102
|
+
initialRequestParams: {
|
|
3103
|
+
primary: {
|
|
3104
|
+
offset: 0,
|
|
3105
|
+
count: 10000
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
};
|
|
3109
|
+
var size = {
|
|
3110
|
+
initialWidth: 300,
|
|
3111
|
+
initialHeight: 300
|
|
3112
|
+
};
|
|
3113
|
+
var defaultContext = {
|
|
3114
|
+
gaugeColorConfig: [{
|
|
3115
|
+
to: 9,
|
|
3116
|
+
value: '#118832'
|
|
3117
|
+
}, {
|
|
3118
|
+
from: 10,
|
|
3119
|
+
to: 29,
|
|
3120
|
+
value: '#669922'
|
|
3121
|
+
}, {
|
|
3122
|
+
from: 30,
|
|
3123
|
+
to: 49,
|
|
3124
|
+
value: '#CBA700'
|
|
3125
|
+
}, {
|
|
3126
|
+
from: 50,
|
|
3127
|
+
to: 69,
|
|
3128
|
+
value: '#D94E17'
|
|
3129
|
+
}, {
|
|
3130
|
+
from: 70,
|
|
3131
|
+
value: '#D41F1F'
|
|
3132
|
+
}]
|
|
3133
|
+
};
|
|
3134
|
+
var optionsSchema = {
|
|
3135
|
+
backgroundColor: {
|
|
3136
|
+
default: '> themes.defaultBackgroundColor',
|
|
3137
|
+
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".',
|
|
3138
|
+
pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
|
|
3139
|
+
type: 'string'
|
|
3140
|
+
},
|
|
3141
|
+
gaugeColor: {
|
|
3142
|
+
default: '> value | rangeValue(gaugeColorConfig)',
|
|
3143
|
+
description: 'Specify the color for the gauge color of the filler gauge. You may use a dataSource to apply the color. The hex value format should be "#FFFFFF".',
|
|
3144
|
+
type: 'string'
|
|
3145
|
+
},
|
|
3146
|
+
labelDisplay: {
|
|
3147
|
+
default: 'number',
|
|
3148
|
+
description: 'Specify whether to display the labels as numbers, percentages, or off.',
|
|
3149
|
+
pattern: schemaUtils_1.getPattern(['number', 'percentage', 'off']),
|
|
3150
|
+
type: 'string'
|
|
3151
|
+
},
|
|
3152
|
+
majorTickInterval: {
|
|
3153
|
+
description: 'Specify, in pixels, the spacing between major tick marks.',
|
|
3154
|
+
default: 'auto',
|
|
3155
|
+
type: ['string', 'number']
|
|
3156
|
+
},
|
|
3157
|
+
orientation: {
|
|
3158
|
+
default: 'vertical',
|
|
3159
|
+
description: 'Specify the axis orientation of the gauge.',
|
|
3160
|
+
pattern: schemaUtils_1.getPattern(['vertical', 'horizontal']),
|
|
3161
|
+
type: 'string'
|
|
3162
|
+
},
|
|
3163
|
+
value: {
|
|
3164
|
+
default: '> primary | seriesByType("number") | lastPoint()',
|
|
3165
|
+
description: 'Specify the dataSource applied to the value of the filler gauge.',
|
|
3166
|
+
type: 'number'
|
|
3167
|
+
},
|
|
3168
|
+
valueDisplay: {
|
|
3169
|
+
default: 'number',
|
|
3170
|
+
description: 'Specify whether to display the value as a number, percentage, or off.',
|
|
3171
|
+
pattern: schemaUtils_1.getPattern(['number', 'percentage', 'off']),
|
|
3172
|
+
type: 'string'
|
|
3173
|
+
}
|
|
3174
|
+
};
|
|
3175
|
+
var themes = {
|
|
3176
|
+
defaultBackgroundColor: function defaultBackgroundColor(props) {
|
|
3177
|
+
return pick_1.default({
|
|
3178
|
+
enterprise: {
|
|
3179
|
+
dark: variables_1.default.black(props),
|
|
3180
|
+
light: variables_1.default.backgroundColor(props)
|
|
3181
|
+
},
|
|
3182
|
+
prisma: variables_1.default.backgroundColorSidebar(props)
|
|
3183
|
+
})(props);
|
|
3184
|
+
},
|
|
3185
|
+
defaultBackgroundBarFillColor: function defaultBackgroundBarFillColor(props) {
|
|
3186
|
+
return pick_1.default({
|
|
3187
|
+
enterprise: variables_1.default.backgroundColorHover(props),
|
|
3188
|
+
prisma: {
|
|
3189
|
+
light: variables_1.default.contentColorActive(props),
|
|
3190
|
+
dark: variables_1.default.neutral100(props)
|
|
3191
|
+
}
|
|
3192
|
+
})(props);
|
|
3193
|
+
},
|
|
3194
|
+
majorTickFillColor: function majorTickFillColor(props) {
|
|
3195
|
+
return pick_1.default({
|
|
3196
|
+
enterprise: {
|
|
3197
|
+
light: variables_1.default.gray30(props),
|
|
3198
|
+
dark: variables_1.default.textGray(props) // was #D7DAE0
|
|
3199
|
+
|
|
3200
|
+
},
|
|
3201
|
+
prisma: {
|
|
3202
|
+
// TODO: missed colors :(
|
|
3203
|
+
light: variables_1.default.neutral100(props),
|
|
3204
|
+
dark: variables_1.default.contentColorMuted(props) // was #D7DAE0; contentColor
|
|
3205
|
+
|
|
3206
|
+
}
|
|
3207
|
+
})(props);
|
|
3208
|
+
},
|
|
3209
|
+
majorTickStrokeColor: function majorTickStrokeColor(props) {
|
|
3210
|
+
return pick_1.default({
|
|
3211
|
+
enterprise: {
|
|
3212
|
+
light: variables_1.default.textGray(props),
|
|
3213
|
+
dark: variables_1.default.contentColorMuted(props)
|
|
3214
|
+
},
|
|
3215
|
+
prisma: variables_1.default.contentColorMuted(props)
|
|
3216
|
+
})(props);
|
|
3217
|
+
},
|
|
3218
|
+
valueMarkerFillColor: function valueMarkerFillColor(props) {
|
|
3219
|
+
return pick_1.default({
|
|
3220
|
+
enterprise: variables_1.default.textColor(props),
|
|
3221
|
+
prisma: {
|
|
3222
|
+
dark: variables_1.default.white(props),
|
|
3223
|
+
light: variables_1.default.black(props)
|
|
3224
|
+
}
|
|
3225
|
+
})(props);
|
|
3226
|
+
},
|
|
3227
|
+
valueMarkerLabelFillColor: function valueMarkerLabelFillColor(props) {
|
|
3228
|
+
return pick_1.default({
|
|
3229
|
+
enterprise: {
|
|
3230
|
+
light: variables_1.default.gray96(props),
|
|
3231
|
+
dark: variables_1.default.black(props)
|
|
3232
|
+
},
|
|
3233
|
+
prisma: variables_1.default.black(props)
|
|
3234
|
+
})(props);
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
var editorConfig = [{
|
|
3238
|
+
label: i18n_1._('Select Data Field'),
|
|
3239
|
+
layout: [[{
|
|
3240
|
+
label: '',
|
|
3241
|
+
editor: 'editor.columnSelector',
|
|
3242
|
+
option: 'value',
|
|
3243
|
+
context: 'defaultContext',
|
|
3244
|
+
editorProps: {
|
|
3245
|
+
dataSourceKey: 'primary',
|
|
3246
|
+
prepareValue: function prepareValue(definition) {
|
|
3247
|
+
var value = definition.options.value;
|
|
3248
|
+
return {
|
|
3249
|
+
context: {},
|
|
3250
|
+
options: {
|
|
3251
|
+
value: "".concat(value, " | lastPoint()")
|
|
3252
|
+
}
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
}]]
|
|
3257
|
+
}, Gauge_1.default, {
|
|
3258
|
+
label: i18n_1._('Coloring'),
|
|
3259
|
+
layout: [[DynamicGaugeColorEditor_1.getDynamicGaugeColorEditor({
|
|
3260
|
+
defaultContext: defaultContext,
|
|
3261
|
+
defaultPalettesConfig: PresetPalettes_1.defaultPalettesConfig
|
|
3262
|
+
})], BackgroundColor_1.default({
|
|
3263
|
+
themes: themes,
|
|
3264
|
+
labelPosition: 'left'
|
|
3265
|
+
})]
|
|
3266
|
+
}];
|
|
3267
|
+
/**
|
|
3268
|
+
* visualization configuration
|
|
3269
|
+
*/
|
|
3270
|
+
|
|
3271
|
+
var config = {
|
|
3272
|
+
/**
|
|
3273
|
+
* unique viz key
|
|
3274
|
+
*/
|
|
3275
|
+
key: 'splunk.fillergauge',
|
|
3276
|
+
|
|
3277
|
+
/**
|
|
3278
|
+
* viz name
|
|
3279
|
+
*/
|
|
3280
|
+
name: 'FillerGauge',
|
|
3281
|
+
category: VizCategory_1.VizCategory.GAUGE,
|
|
3282
|
+
|
|
3283
|
+
/**
|
|
3284
|
+
* viz icon
|
|
3285
|
+
*/
|
|
3286
|
+
icon: GaugeFiller_1.default,
|
|
3287
|
+
dataContract: dataContract,
|
|
3288
|
+
size: size,
|
|
3289
|
+
defaultContext: defaultContext,
|
|
3290
|
+
optionsSchema: optionsSchema,
|
|
3291
|
+
editorConfig: editorConfig,
|
|
3292
|
+
supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER],
|
|
3293
|
+
themes: themes
|
|
3294
|
+
};
|
|
3295
|
+
exports.default = configUtils_1.enhanceConfig(config);
|
|
3296
|
+
|
|
3297
|
+
/***/ }),
|
|
3298
|
+
/* 162 */
|
|
3299
|
+
/***/ (function(module, exports) {
|
|
3300
|
+
|
|
3301
|
+
module.exports = require("@splunk/react-icons/GaugeFiller");
|
|
3302
|
+
|
|
3303
|
+
/***/ }),
|
|
3304
|
+
/* 163 */
|
|
3305
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3306
|
+
|
|
3307
|
+
"use strict";
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3311
|
+
value: true
|
|
3312
|
+
});
|
|
3313
|
+
exports.getDynamicGaugeColorEditor = void 0;
|
|
3314
|
+
|
|
3315
|
+
var i18n_1 = __webpack_require__(3);
|
|
3316
|
+
|
|
3317
|
+
var getDynamicGaugeColorEditor = function getDynamicGaugeColorEditor(_ref) {
|
|
3318
|
+
var defaultContext = _ref.defaultContext,
|
|
3319
|
+
defaultPalettesConfig = _ref.defaultPalettesConfig;
|
|
3320
|
+
return {
|
|
3321
|
+
label: i18n_1._('Gauge'),
|
|
3322
|
+
option: 'gaugeColor',
|
|
3323
|
+
context: 'gaugeColorConfig',
|
|
3324
|
+
editor: 'editor.dynamicColor',
|
|
3325
|
+
editorProps: {
|
|
3326
|
+
labelPosition: 'left',
|
|
3327
|
+
flyoutTitle: i18n_1._('Dynamic Coloring: Gauge'),
|
|
3328
|
+
formatters: [{
|
|
3329
|
+
label: i18n_1._('Ranges'),
|
|
3330
|
+
value: 'rangeValue',
|
|
3331
|
+
defaults: {
|
|
3332
|
+
value: defaultContext.gaugeColorConfig
|
|
3333
|
+
}
|
|
3334
|
+
}],
|
|
3335
|
+
dataSelectors: [{
|
|
3336
|
+
label: i18n_1._('Value'),
|
|
3337
|
+
value: 'value'
|
|
3338
|
+
}],
|
|
3339
|
+
defaultPalettesConfig: defaultPalettesConfig
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
};
|
|
3343
|
+
|
|
3344
|
+
exports.getDynamicGaugeColorEditor = getDynamicGaugeColorEditor;
|
|
3345
|
+
|
|
3346
|
+
/***/ }),
|
|
3347
|
+
/* 164 */
|
|
3348
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3349
|
+
|
|
3350
|
+
"use strict";
|
|
3351
|
+
|
|
3352
|
+
|
|
3353
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
3354
|
+
var t = {};
|
|
3355
|
+
|
|
3356
|
+
for (var p in s) {
|
|
3357
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
3361
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
3362
|
+
}
|
|
3363
|
+
return t;
|
|
3364
|
+
};
|
|
3365
|
+
|
|
3366
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3367
|
+
value: true
|
|
3368
|
+
});
|
|
3369
|
+
exports.AXIS_ORIENTATION_TYPES = void 0;
|
|
3370
|
+
|
|
3371
|
+
var React = __webpack_require__(1);
|
|
3372
|
+
|
|
3373
|
+
var T = __webpack_require__(0);
|
|
3374
|
+
|
|
3375
|
+
var styled_components_1 = __webpack_require__(4);
|
|
3376
|
+
|
|
3377
|
+
var lodash_1 = __webpack_require__(2);
|
|
3378
|
+
|
|
3379
|
+
var i18n_1 = __webpack_require__(3);
|
|
3380
|
+
|
|
3381
|
+
var style_1 = __webpack_require__(13);
|
|
3382
|
+
|
|
3383
|
+
var SizeAwareWrapper_1 = __webpack_require__(17);
|
|
3384
|
+
|
|
3385
|
+
var Message_1 = __webpack_require__(9);
|
|
3386
|
+
|
|
3387
|
+
var gaugeUtils_1 = __webpack_require__(71);
|
|
3388
|
+
|
|
3389
|
+
var GaugeMajorTicks_1 = __webpack_require__(91);
|
|
3390
|
+
|
|
3391
|
+
var GaugeValueMarker_1 = __webpack_require__(92);
|
|
3392
|
+
|
|
3393
|
+
var Container = styled_components_1.default.div.withConfig({
|
|
3394
|
+
displayName: "FillerGauge__Container",
|
|
3395
|
+
componentId: "u356pd-0"
|
|
3396
|
+
})(["overflow:hidden;", ";background-color:", ";"], function (props) {
|
|
3397
|
+
return style_1.toDimension(lodash_1.pick(props, ['width', 'height']));
|
|
3398
|
+
}, function (props) {
|
|
3399
|
+
return props.backgroundColor;
|
|
3400
|
+
});
|
|
3401
|
+
var FillerGaugeWrapper = styled_components_1.default.div.withConfig({
|
|
3402
|
+
displayName: "FillerGauge__FillerGaugeWrapper",
|
|
3403
|
+
componentId: "u356pd-1"
|
|
3404
|
+
})(["display:flex;justify-content:center;flex-direction:row;width:100%;height:100%;background-color:", ";"], function (props) {
|
|
3405
|
+
return props.backgroundColor;
|
|
3406
|
+
});
|
|
3407
|
+
var FillerGaugeContainer = styled_components_1.default.div.withConfig({
|
|
3408
|
+
displayName: "FillerGauge__FillerGaugeContainer",
|
|
3409
|
+
componentId: "u356pd-2"
|
|
3410
|
+
})(["overflow:hidden;position:relative;", ";"], function (props) {
|
|
3411
|
+
return style_1.toDimension(lodash_1.pick(props, ['width', 'height']));
|
|
3412
|
+
});
|
|
3413
|
+
var FillerGaugeSVG = styled_components_1.default.svg.withConfig({
|
|
3414
|
+
displayName: "FillerGauge__FillerGaugeSVG",
|
|
3415
|
+
componentId: "u356pd-3"
|
|
3416
|
+
})(["", ";"], function (props) {
|
|
3417
|
+
return style_1.toDimension(lodash_1.pick(props, ['width', 'height']));
|
|
3418
|
+
});
|
|
3419
|
+
var BackgroundBar = styled_components_1.default.rect.attrs({
|
|
3420
|
+
'data-test': 'background-bar-rect'
|
|
3421
|
+
}).withConfig({
|
|
3422
|
+
displayName: "FillerGauge__BackgroundBar",
|
|
3423
|
+
componentId: "u356pd-4"
|
|
3424
|
+
})(["fill:", ";"], function (props) {
|
|
3425
|
+
return props.backgroundBarFillColor;
|
|
3426
|
+
});
|
|
3427
|
+
var FillBar = styled_components_1.default.rect.attrs({
|
|
3428
|
+
'data-test': 'fill-bar-rect'
|
|
3429
|
+
}).withConfig({
|
|
3430
|
+
displayName: "FillerGauge__FillBar",
|
|
3431
|
+
componentId: "u356pd-5"
|
|
3432
|
+
})(["fill:", ";"], function (props) {
|
|
3433
|
+
return props.color;
|
|
3434
|
+
});
|
|
3435
|
+
var MAX_VERTICAL_CONTAINER_WIDTH = 200;
|
|
3436
|
+
var MIN_VERTICAL_CONTAINER_HEIGHT = 200;
|
|
3437
|
+
var MIN_HORIZONTAL_CONTAINER_WIDTH = 200;
|
|
3438
|
+
var MIN_HORIZONTAL_CONTAINER_HEIGHT = 100;
|
|
3439
|
+
var AXIS_ORIENTATION_TYPES;
|
|
3440
|
+
|
|
3441
|
+
(function (AXIS_ORIENTATION_TYPES) {
|
|
3442
|
+
AXIS_ORIENTATION_TYPES["VERTICAL"] = "vertical";
|
|
3443
|
+
AXIS_ORIENTATION_TYPES["HORIZONTAL"] = "horizontal";
|
|
3444
|
+
})(AXIS_ORIENTATION_TYPES = exports.AXIS_ORIENTATION_TYPES || (exports.AXIS_ORIENTATION_TYPES = {}));
|
|
3445
|
+
|
|
3446
|
+
var FillerGauge = function FillerGauge(_a) {
|
|
3447
|
+
var props = __rest(_a, []);
|
|
3448
|
+
|
|
3449
|
+
var width = props.width,
|
|
3450
|
+
height = props.height,
|
|
3451
|
+
value = props.value,
|
|
3452
|
+
gaugeColor = props.gaugeColor,
|
|
3453
|
+
min = props.min,
|
|
3454
|
+
max = props.max,
|
|
3455
|
+
orientation = props.orientation,
|
|
3456
|
+
majorUnit = props.majorUnit,
|
|
3457
|
+
showLabels = props.showLabels,
|
|
3458
|
+
showValue = props.showValue,
|
|
3459
|
+
usePercentageRange = props.usePercentageRange,
|
|
3460
|
+
usePercentageValue = props.usePercentageValue,
|
|
3461
|
+
backgroundColor = props.backgroundColor,
|
|
3462
|
+
backgroundBarFillColor = props.backgroundBarFillColor,
|
|
3463
|
+
majorTickFillColor = props.majorTickFillColor,
|
|
3464
|
+
majorTickStrokeColor = props.majorTickStrokeColor,
|
|
3465
|
+
valueMarkerFillColor = props.valueMarkerFillColor,
|
|
3466
|
+
valueMarkerLabelFillColor = props.valueMarkerLabelFillColor;
|
|
3467
|
+
|
|
3468
|
+
var renderVisualization = function renderVisualization(_ref) {
|
|
3469
|
+
var containerWidth = _ref.width,
|
|
3470
|
+
containerHeight = _ref.height;
|
|
3471
|
+
|
|
3472
|
+
// todo: need change the size when get design for smaller space
|
|
3473
|
+
// 58 is the title & description header height in dashboard visualization
|
|
3474
|
+
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') {
|
|
3475
|
+
return React.createElement(Message_1.default, {
|
|
3476
|
+
width: containerWidth,
|
|
3477
|
+
height: containerHeight,
|
|
3478
|
+
message: i18n_1._('Too small to render content'),
|
|
3479
|
+
level: "info"
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
var _gaugeUtils_1$getGaug = gaugeUtils_1.getGaugeDimensions({
|
|
3484
|
+
containerWidth: containerWidth,
|
|
3485
|
+
containerHeight: containerHeight,
|
|
3486
|
+
orientation: orientation
|
|
3487
|
+
}),
|
|
3488
|
+
gaugeLength = _gaugeUtils_1$getGaug.gaugeLength,
|
|
3489
|
+
gaugeStartX = _gaugeUtils_1$getGaug.gaugeStartX,
|
|
3490
|
+
gaugeStartY = _gaugeUtils_1$getGaug.gaugeStartY,
|
|
3491
|
+
gaugeWidth = _gaugeUtils_1$getGaug.gaugeWidth,
|
|
3492
|
+
gaugeHeight = _gaugeUtils_1$getGaug.gaugeHeight;
|
|
3493
|
+
|
|
3494
|
+
var _gaugeUtils_1$getFill = gaugeUtils_1.getFillBarDimensions({
|
|
3495
|
+
gaugeLength: gaugeLength,
|
|
3496
|
+
gaugeStartX: gaugeStartX,
|
|
3497
|
+
gaugeStartY: gaugeStartY,
|
|
3498
|
+
gaugeWidth: gaugeWidth,
|
|
3499
|
+
gaugeHeight: gaugeHeight,
|
|
3500
|
+
value: value,
|
|
3501
|
+
min: min,
|
|
3502
|
+
max: max,
|
|
3503
|
+
orientation: orientation
|
|
3504
|
+
}),
|
|
3505
|
+
fillBarLength = _gaugeUtils_1$getFill.fillBarLength,
|
|
3506
|
+
fillBarX = _gaugeUtils_1$getFill.fillBarX,
|
|
3507
|
+
fillBarY = _gaugeUtils_1$getFill.fillBarY,
|
|
3508
|
+
fillBarWidth = _gaugeUtils_1$getFill.fillBarWidth,
|
|
3509
|
+
fillBarHeight = _gaugeUtils_1$getFill.fillBarHeight;
|
|
3510
|
+
|
|
3511
|
+
var _gaugeUtils_1$getFill2 = gaugeUtils_1.getFillerGaugeValueMarkerPositions({
|
|
3512
|
+
fillBarX: fillBarX,
|
|
3513
|
+
fillBarY: fillBarY,
|
|
3514
|
+
fillBarLength: fillBarLength,
|
|
3515
|
+
orientation: orientation
|
|
3516
|
+
}),
|
|
3517
|
+
valueMarkerX = _gaugeUtils_1$getFill2.valueMarkerX,
|
|
3518
|
+
valueMarkerY = _gaugeUtils_1$getFill2.valueMarkerY;
|
|
3519
|
+
|
|
3520
|
+
return React.createElement(FillerGaugeWrapper, {
|
|
3521
|
+
backgroundColor: backgroundColor,
|
|
3522
|
+
"data-test": "FillerGaugeWrapper"
|
|
3523
|
+
}, React.createElement(FillerGaugeContainer, {
|
|
3524
|
+
width: containerWidth,
|
|
3525
|
+
height: containerHeight,
|
|
3526
|
+
"data-test": "FillerGaugeContainer"
|
|
3527
|
+
}, React.createElement(FillerGaugeSVG, {
|
|
3528
|
+
width: containerWidth,
|
|
3529
|
+
height: containerHeight,
|
|
3530
|
+
"data-test": "FillerGaugeSVG"
|
|
3531
|
+
}, React.createElement(BackgroundBar, {
|
|
3532
|
+
x: gaugeStartX,
|
|
3533
|
+
y: gaugeStartY,
|
|
3534
|
+
width: gaugeWidth,
|
|
3535
|
+
height: gaugeHeight,
|
|
3536
|
+
"data-test": "BackgroundBar",
|
|
3537
|
+
backgroundBarFillColor: backgroundBarFillColor
|
|
3538
|
+
}), React.createElement(GaugeMajorTicks_1.default, {
|
|
3539
|
+
width: gaugeWidth,
|
|
3540
|
+
height: gaugeHeight,
|
|
3541
|
+
startX: gaugeStartX,
|
|
3542
|
+
startY: gaugeStartY,
|
|
3543
|
+
min: min,
|
|
3544
|
+
max: max,
|
|
3545
|
+
majorUnit: majorUnit,
|
|
3546
|
+
orientation: orientation,
|
|
3547
|
+
showLabels: showLabels,
|
|
3548
|
+
usePercentageRange: usePercentageRange,
|
|
3549
|
+
majorTickFillColor: majorTickFillColor,
|
|
3550
|
+
majorTickStrokeColor: majorTickStrokeColor
|
|
3551
|
+
}), React.createElement(FillBar, {
|
|
3552
|
+
x: fillBarX,
|
|
3553
|
+
y: fillBarY,
|
|
3554
|
+
width: fillBarWidth,
|
|
3555
|
+
height: fillBarHeight,
|
|
3556
|
+
color: gaugeColor || gaugeUtils_1.assignGaugeColor({
|
|
3557
|
+
value: value,
|
|
3558
|
+
min: min,
|
|
3559
|
+
max: max
|
|
3560
|
+
}),
|
|
3561
|
+
"data-test": "FillBar"
|
|
3562
|
+
}), React.createElement(GaugeValueMarker_1.default, {
|
|
3563
|
+
x: valueMarkerX,
|
|
3564
|
+
y: valueMarkerY,
|
|
3565
|
+
length: gaugeUtils_1.GAUGE_THICKNESS,
|
|
3566
|
+
min: min,
|
|
3567
|
+
max: max,
|
|
3568
|
+
value: value,
|
|
3569
|
+
orientation: orientation,
|
|
3570
|
+
showValue: showValue,
|
|
3571
|
+
usePercentageValue: usePercentageValue,
|
|
3572
|
+
valueMarkerFillColor: valueMarkerFillColor,
|
|
3573
|
+
valueMarkerLabelFillColor: valueMarkerLabelFillColor
|
|
3574
|
+
}))));
|
|
3575
|
+
};
|
|
3576
|
+
|
|
3577
|
+
return React.createElement(Container, {
|
|
3578
|
+
width: width,
|
|
3579
|
+
height: height,
|
|
3580
|
+
backgroundColor: backgroundColor
|
|
3581
|
+
}, React.createElement(SizeAwareWrapper_1.default, null, function (containerDimension) {
|
|
3582
|
+
return renderVisualization(containerDimension);
|
|
3583
|
+
}));
|
|
3584
|
+
};
|
|
3585
|
+
|
|
3586
|
+
var propTypes = {
|
|
3587
|
+
width: T.oneOfType([T.string, T.number]),
|
|
3588
|
+
height: T.oneOfType([T.string, T.number]),
|
|
3589
|
+
value: T.number,
|
|
3590
|
+
gaugeColor: T.string,
|
|
3591
|
+
min: T.number,
|
|
3592
|
+
max: T.number,
|
|
3593
|
+
// valueFieldName: T.string, // todo: need add it back when displaying name later
|
|
3594
|
+
// gaugeColorFieldName: T.string, // todo: may need add it back may not
|
|
3595
|
+
orientation: T.oneOf(['horizontal', 'vertical']),
|
|
3596
|
+
majorUnit: T.oneOfType([T.string, T.number]),
|
|
3597
|
+
showLabels: T.bool,
|
|
3598
|
+
showValue: T.bool,
|
|
3599
|
+
usePercentageRange: T.bool,
|
|
3600
|
+
usePercentageValue: T.bool,
|
|
3601
|
+
backgroundColor: T.string,
|
|
3602
|
+
backgroundBarFillColor: T.string,
|
|
3603
|
+
majorTickFillColor: T.string,
|
|
3604
|
+
majorTickStrokeColor: T.string,
|
|
3605
|
+
valueMarkerFillColor: T.string,
|
|
3606
|
+
valueMarkerLabelFillColor: T.string
|
|
3607
|
+
};
|
|
3608
|
+
var defaultProps = {
|
|
3609
|
+
width: '100%',
|
|
3610
|
+
height: 250,
|
|
3611
|
+
value: undefined,
|
|
3612
|
+
gaugeColor: undefined,
|
|
3613
|
+
orientation: 'vertical',
|
|
3614
|
+
min: 0,
|
|
3615
|
+
max: 100,
|
|
3616
|
+
majorUnit: 'auto',
|
|
3617
|
+
showLabels: true,
|
|
3618
|
+
showValue: true,
|
|
3619
|
+
usePercentageRange: false,
|
|
3620
|
+
usePercentageValue: false,
|
|
3621
|
+
backgroundColor: 'transparent',
|
|
3622
|
+
backgroundBarFillColor: '#f2f4f5',
|
|
3623
|
+
majorTickFillColor: '#3c444d',
|
|
3624
|
+
majorTickStrokeColor: '#6b7785',
|
|
3625
|
+
valueMarkerFillColor: '#3c444d',
|
|
3626
|
+
valueMarkerLabelFillColor: '#f2f4f5'
|
|
3627
|
+
};
|
|
3628
|
+
FillerGauge.propTypes = propTypes;
|
|
3629
|
+
FillerGauge.defaultProps = defaultProps;
|
|
3630
|
+
exports.default = FillerGauge;
|
|
3631
|
+
|
|
3632
|
+
/***/ })
|
|
3633
|
+
/******/ ]);
|
|
3634
|
+
//# sourceMappingURL=FillerGauge.js.map
|