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