@splunk/visualizations 26.1.2 → 26.2.1
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 +2 -1
- package/Area.config.js.map +1 -1
- package/Area.js +1562 -433
- package/Area.js.map +1 -1
- package/Bar.config.js +1 -0
- package/Bar.config.js.map +1 -1
- package/Bar.js +1555 -430
- package/Bar.js.map +1 -1
- package/Bubble.config.js +1 -0
- package/Bubble.config.js.map +1 -1
- package/Bubble.js +1580 -455
- package/Bubble.js.map +1 -1
- package/ChoroplethSvg.config.js +1 -0
- package/ChoroplethSvg.config.js.map +1 -1
- package/ChoroplethSvg.js +1421 -352
- package/ChoroplethSvg.js.map +1 -1
- package/Column.config.js +2 -1
- package/Column.config.js.map +1 -1
- package/Column.js +1564 -435
- package/Column.js.map +1 -1
- package/Ellipse.config.js +1 -0
- package/Ellipse.config.js.map +1 -1
- package/Ellipse.js +1342 -297
- package/Ellipse.js.map +1 -1
- package/Events.config.js +4 -0
- package/Events.config.js.map +1 -1
- package/Events.js +1503 -489
- package/Events.js.map +1 -1
- package/FEATUREFLAGS.md +3 -0
- package/FillerGauge.config.js +1 -0
- package/FillerGauge.config.js.map +1 -1
- package/FillerGauge.js +1406 -345
- package/FillerGauge.js.map +1 -1
- package/Image.config.js +1 -0
- package/Image.config.js.map +1 -1
- package/Image.js +2355 -1183
- package/Image.js.map +1 -1
- package/Line.config.js +2 -1
- package/Line.config.js.map +1 -1
- package/Line.js +1562 -433
- package/Line.js.map +1 -1
- package/LinkGraph.config.js +1 -0
- package/LinkGraph.config.js.map +1 -1
- package/LinkGraph.js +18499 -24296
- package/LinkGraph.js.map +1 -1
- package/Map.config.js +1 -0
- package/Map.config.js.map +1 -1
- package/Map.js +2556 -1527
- package/Map.js.map +1 -1
- package/Markdown.config.js +1 -0
- package/Markdown.config.js.map +1 -1
- package/Markdown.js +1952 -883
- package/Markdown.js.map +1 -1
- package/MarkerGauge.config.js +1 -0
- package/MarkerGauge.config.js.map +1 -1
- package/MarkerGauge.js +4049 -2965
- package/MarkerGauge.js.map +1 -1
- package/ParallelCoordinates.config.js +1 -0
- package/ParallelCoordinates.config.js.map +1 -1
- package/ParallelCoordinates.js +3286 -2215
- package/ParallelCoordinates.js.map +1 -1
- package/Pie.config.js +1 -0
- package/Pie.config.js.map +1 -1
- package/Pie.js +2187 -1036
- package/Pie.js.map +1 -1
- package/Punchcard.config.js +1 -0
- package/Punchcard.config.js.map +1 -1
- package/Punchcard.js +3397 -2299
- package/Punchcard.js.map +1 -1
- package/Rectangle.config.js +1 -0
- package/Rectangle.config.js.map +1 -1
- package/Rectangle.js +2181 -1112
- package/Rectangle.js.map +1 -1
- package/Sankey.config.js +1 -0
- package/Sankey.config.js.map +1 -1
- package/Sankey.js +3275 -2199
- package/Sankey.js.map +1 -1
- package/Scatter.config.js +1 -0
- package/Scatter.config.js.map +1 -1
- package/Scatter.js +3551 -2400
- package/Scatter.js.map +1 -1
- package/SingleValue.config.js +27 -0
- package/SingleValue.config.js.map +1 -1
- package/SingleValue.js +5551 -4397
- package/SingleValue.js.map +1 -1
- package/SingleValueBasic.js +1227 -1209
- package/SingleValueBasic.js.map +1 -1
- package/SingleValueIcon.config.js +27 -0
- package/SingleValueIcon.config.js.map +1 -1
- package/SingleValueIcon.js +2850 -1696
- package/SingleValueIcon.js.map +1 -1
- package/SingleValueRadial.config.js +1 -0
- package/SingleValueRadial.config.js.map +1 -1
- package/SingleValueRadial.js +6334 -5215
- package/SingleValueRadial.js.map +1 -1
- package/SparkLine.js +96 -96
- package/SparkLine.js.map +1 -1
- package/Table.config.js +172 -7
- package/Table.config.js.map +1 -1
- package/Table.js +3500 -2195
- package/Table.js.map +1 -1
- package/common/Charting.js +1009 -82
- package/common/Charting.js.map +1 -1
- package/common/ChartingApi.js +4 -4
- package/common/ChartingApi.js.map +1 -1
- package/common/DocExampleWithVizSandbox.js +54 -57
- package/common/DocExampleWithVizSandbox.js.map +1 -1
- package/common/EventsDoc.js +40 -40
- package/common/EventsDoc.js.map +1 -1
- package/common/GaugeMajorTicks.js +15 -13
- package/common/GaugeMajorTicks.js.map +1 -1
- package/common/GaugeValueMarker.js +12 -12
- package/common/GaugeValueMarker.js.map +1 -1
- package/common/OptionsDoc.js +34 -34
- package/common/OptionsDoc.js.map +1 -1
- package/common/OverviewDoc.js +124 -103
- package/common/OverviewDoc.js.map +1 -1
- package/common/SplunkVisualization.js +49 -49
- package/common/SplunkVisualization.js.map +1 -1
- package/common/SplunkVisualizationApi.js +4 -4
- package/common/SplunkVisualizationApi.js.map +1 -1
- package/common/ThemesDoc.js +31 -31
- package/common/ThemesDoc.js.map +1 -1
- package/common/chartingUtils.js +24 -8
- package/common/chartingUtils.js.map +1 -1
- package/common/docUtils.js +4 -4
- package/common/docUtils.js.map +1 -1
- package/common/gaugeUtils.js +16 -16
- package/common/gaugeUtils.js.map +1 -1
- package/common/shapeUtils.js +36 -36
- package/common/shapeUtils.js.map +1 -1
- package/common/utils/configUtils.js +48 -47
- package/common/utils/configUtils.js.map +1 -1
- package/common/utils/dataUtils.js +832 -6
- package/common/utils/dataUtils.js.map +1 -1
- package/common/utils/featureFlagUtils.js +139 -0
- package/common/utils/featureFlagUtils.js.map +1 -0
- package/common/utils/hocUtils.js +2 -2
- package/common/utils/hocUtils.js.map +1 -1
- package/common/utils/layoutUtils.js +2 -2
- package/common/utils/layoutUtils.js.map +1 -1
- package/common/utils/mapUtils.js +77 -54
- package/common/utils/mapUtils.js.map +1 -1
- package/common/utils/singleValueUtils.js +28 -19
- package/common/utils/singleValueUtils.js.map +1 -1
- package/common/utils/testHelper.js +10 -10
- package/common/utils/testHelper.js.map +1 -1
- package/common/utils/trellisUtils.js +6 -6
- package/common/utils/trellisUtils.js.map +1 -1
- package/common/utils/urlUtils.js +2 -2
- package/common/utils/urlUtils.js.map +1 -1
- package/common/withDashboardViz.js +1313 -235
- package/common/withDashboardViz.js.map +1 -1
- package/package.json +14 -13
- package/__mocks__/fileMock.js +0 -2
- package/__mocks__/styleMock.js +0 -2
- package/babel.config.js +0 -11
- package/jest.config.js +0 -8
- package/loki.config.js +0 -14
package/SingleValueBasic.js
CHANGED
|
@@ -87,7 +87,7 @@ module.exports =
|
|
|
87
87
|
/******/
|
|
88
88
|
/******/
|
|
89
89
|
/******/ // Load entry module and return exports
|
|
90
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
90
|
+
/******/ return __webpack_require__(__webpack_require__.s = 104);
|
|
91
91
|
/******/ })
|
|
92
92
|
/************************************************************************/
|
|
93
93
|
/******/ ({
|
|
@@ -95,783 +95,866 @@ module.exports =
|
|
|
95
95
|
/***/ 0:
|
|
96
96
|
/***/ (function(module, exports) {
|
|
97
97
|
|
|
98
|
-
module.exports = require("prop-types");
|
|
99
|
-
|
|
100
|
-
/***/ }),
|
|
101
|
-
|
|
102
|
-
/***/ 1:
|
|
103
|
-
/***/ (function(module, exports) {
|
|
104
|
-
|
|
105
98
|
module.exports = require("react");
|
|
106
99
|
|
|
107
100
|
/***/ }),
|
|
108
101
|
|
|
109
|
-
/***/
|
|
102
|
+
/***/ 1:
|
|
110
103
|
/***/ (function(module, exports) {
|
|
111
104
|
|
|
112
|
-
module.exports = require("
|
|
105
|
+
module.exports = require("prop-types");
|
|
113
106
|
|
|
114
107
|
/***/ }),
|
|
115
108
|
|
|
116
|
-
/***/
|
|
109
|
+
/***/ 104:
|
|
117
110
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
118
111
|
|
|
119
112
|
"use strict";
|
|
113
|
+
// ESM COMPAT FLAG
|
|
120
114
|
__webpack_require__.r(__webpack_exports__);
|
|
121
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_FONT", function() { return DEFAULT_FONT; });
|
|
122
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_FONT_FAMILY", function() { return DEFAULT_FONT_FAMILY; });
|
|
123
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SVR_PADDING", function() { return SVR_PADDING; });
|
|
124
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldShowTrend", function() { return shouldShowTrend; });
|
|
125
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isLoadingOrNoColumns", function() { return isLoadingOrNoColumns; });
|
|
126
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFormattedColor", function() { return getFormattedColor; });
|
|
127
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBackground", function() { return hasBackground; });
|
|
128
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isIdenticalColor", function() { return isIdenticalColor; });
|
|
129
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDefaultColorWithBg", function() { return getDefaultColorWithBg; });
|
|
130
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorColor", function() { return getMajorColor; });
|
|
131
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendColor", function() { return getTrendColor; });
|
|
132
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeColors", function() { return computeColors; });
|
|
133
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeText", function() { return computeText; });
|
|
134
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorText", function() { return getMajorText; });
|
|
135
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendText", function() { return getTrendText; });
|
|
136
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeFontSize", function() { return computeFontSize; });
|
|
137
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorFontSize", function() { return getMajorFontSize; });
|
|
138
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendFontSize", function() { return getTrendFontSize; });
|
|
139
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUnderLabelHeight", function() { return getUnderLabelHeight; });
|
|
140
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUnderLabel", function() { return getUnderLabel; });
|
|
141
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorAndTrend", function() { return getMajorAndTrend; });
|
|
142
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateVizInSmallSpace", function() { return updateVizInSmallSpace; });
|
|
143
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeSingleValueContent", function() { return computeSingleValueContent; });
|
|
144
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "minimallyTruncateStringToWidth", function() { return minimallyTruncateStringToWidth; });
|
|
145
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeSingleValueRadialContent", function() { return computeSingleValueRadialContent; });
|
|
146
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getGraphColors", function() { return getGraphColors; });
|
|
147
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjustRGB", function() { return adjustRGB; });
|
|
148
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lighten", function() { return lighten; });
|
|
149
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "darken", function() { return darken; });
|
|
150
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "handleValueClickCallback", function() { return handleValueClickCallback; });
|
|
151
|
-
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
|
|
152
|
-
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
|
|
153
|
-
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
154
|
-
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
|
|
155
|
-
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31);
|
|
156
|
-
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__);
|
|
157
|
-
/* harmony import */ var _splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(54);
|
|
158
|
-
/* harmony import */ var _splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__);
|
|
159
|
-
/* harmony import */ var _splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(29);
|
|
160
|
-
/* harmony import */ var _splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__);
|
|
161
|
-
/* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(49);
|
|
162
|
-
/* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__);
|
|
163
115
|
|
|
116
|
+
// EXPORTS
|
|
117
|
+
__webpack_require__.d(__webpack_exports__, "SingleValueTrendValue", function() { return /* binding */ SingleValueTrendValue; });
|
|
164
118
|
|
|
165
|
-
|
|
166
|
-
|
|
119
|
+
// EXTERNAL MODULE: external "@babel/runtime/helpers/extends"
|
|
120
|
+
var extends_ = __webpack_require__(70);
|
|
121
|
+
var extends_default = /*#__PURE__*/__webpack_require__.n(extends_);
|
|
167
122
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
172
|
-
});
|
|
173
|
-
keys.push.apply(keys, symbols);
|
|
174
|
-
}
|
|
123
|
+
// EXTERNAL MODULE: external "react"
|
|
124
|
+
var external_react_ = __webpack_require__(0);
|
|
125
|
+
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
175
126
|
|
|
176
|
-
|
|
177
|
-
|
|
127
|
+
// EXTERNAL MODULE: external "prop-types"
|
|
128
|
+
var external_prop_types_ = __webpack_require__(1);
|
|
129
|
+
var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_);
|
|
178
130
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
131
|
+
// EXTERNAL MODULE: external "styled-components"
|
|
132
|
+
var external_styled_components_ = __webpack_require__(4);
|
|
133
|
+
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
182
134
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
|
|
186
|
-
});
|
|
187
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
188
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
189
|
-
} else {
|
|
190
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
191
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
135
|
+
// EXTERNAL MODULE: ./src/common/utils/singleValueUtils.js
|
|
136
|
+
var singleValueUtils = __webpack_require__(20);
|
|
195
137
|
|
|
196
|
-
|
|
197
|
-
|
|
138
|
+
// EXTERNAL MODULE: external "@splunk/react-icons/enterprise/ArrowUp"
|
|
139
|
+
var ArrowUp_ = __webpack_require__(108);
|
|
140
|
+
var ArrowUp_default = /*#__PURE__*/__webpack_require__.n(ArrowUp_);
|
|
198
141
|
|
|
142
|
+
// EXTERNAL MODULE: external "@splunk/react-icons/enterprise/ArrowDown"
|
|
143
|
+
var ArrowDown_ = __webpack_require__(109);
|
|
144
|
+
var ArrowDown_default = /*#__PURE__*/__webpack_require__.n(ArrowDown_);
|
|
199
145
|
|
|
146
|
+
// EXTERNAL MODULE: external "@splunk/ui-utils/i18n"
|
|
147
|
+
var i18n_ = __webpack_require__(2);
|
|
200
148
|
|
|
149
|
+
// CONCATENATED MODULE: ./src/SingleValueBasic/TrendValue.jsx
|
|
201
150
|
|
|
202
151
|
|
|
203
152
|
|
|
204
|
-
var DEFAULT_FONT = 12;
|
|
205
|
-
var DEFAULT_FONT_FAMILY = '"Splunk Platform Sans", "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif';
|
|
206
|
-
var SVR_PADDING = {
|
|
207
|
-
top: 12,
|
|
208
|
-
bottom: 12,
|
|
209
|
-
left: 16,
|
|
210
|
-
right: 16
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* @method shouldShowTrend
|
|
214
|
-
* @param {String} trendDisplay
|
|
215
|
-
* @returns {Bool}
|
|
216
|
-
*/
|
|
217
153
|
|
|
218
|
-
var shouldShowTrend = function shouldShowTrend(trendDisplay) {
|
|
219
|
-
return trendDisplay === 'absolute' || trendDisplay === 'percent';
|
|
220
|
-
};
|
|
221
|
-
/**
|
|
222
|
-
* @method isLoadingOrNoColumns
|
|
223
|
-
* @param {Object} dataSources
|
|
224
|
-
* @param {Boolean} loading
|
|
225
|
-
* @returns {Boolean} return true if loading or without columns in dataSources
|
|
226
|
-
*/
|
|
227
154
|
|
|
228
|
-
var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
|
|
229
|
-
var data = Object(lodash__WEBPACK_IMPORTED_MODULE_1__["get"])(dataSources, 'primary.data.columns[0]', undefined);
|
|
230
|
-
var noColumns = data === undefined;
|
|
231
|
-
return loading || noColumns;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* Retrieve the valid formatted color
|
|
235
|
-
* @method getFormattedColor
|
|
236
|
-
* @param {String} color
|
|
237
|
-
* @param {String} defaultColor
|
|
238
|
-
* @returns {String} the formatted color
|
|
239
|
-
*/
|
|
240
155
|
|
|
241
|
-
var getFormattedColor = function getFormattedColor(color, defaultColor) {
|
|
242
|
-
return Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(color) || Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(defaultColor);
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* Determines if there is a background color
|
|
246
|
-
* @method hasBackground
|
|
247
|
-
* @param {String} backgroundColor
|
|
248
|
-
* @returns true for non-transparent background color
|
|
249
|
-
*/
|
|
250
156
|
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
157
|
+
var Column = external_styled_components_default.a.div.withConfig({
|
|
158
|
+
displayName: "TrendValue__Column",
|
|
159
|
+
componentId: "yd2lvy-0"
|
|
160
|
+
})(["display:flex;flex-direction:row;justify-content:", ";height:", "px;", ";"], function (props) {
|
|
161
|
+
return props.justify || 'flex-end';
|
|
162
|
+
}, function (props) {
|
|
163
|
+
return props.size || 12;
|
|
164
|
+
}, function (props) {
|
|
165
|
+
return props.size ? "margin: 0 ".concat(parseInt(props.size, 10) * 0.2 || 5, "px;") : '';
|
|
166
|
+
});
|
|
167
|
+
var Text = external_styled_components_default.a.div.withConfig({
|
|
168
|
+
displayName: "TrendValue__Text",
|
|
169
|
+
componentId: "yd2lvy-1"
|
|
170
|
+
})(["white-space:nowrap;font-size:", "px;color:", ";font-family:", ";height:", "px;line-height:", "px;display:flex;align-self:baseline;", ";"], function (props) {
|
|
171
|
+
return props.size || 12;
|
|
172
|
+
}, function (props) {
|
|
173
|
+
return props.color || '#000';
|
|
174
|
+
}, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
|
|
175
|
+
return props.size || 12;
|
|
176
|
+
}, function (props) {
|
|
177
|
+
return props.size || 12;
|
|
178
|
+
}, function (props) {
|
|
179
|
+
return props.size ? "margin-left: ".concat(parseInt(props.size, 10) * 0.2 || 5, "px;") : '';
|
|
180
|
+
});
|
|
260
181
|
|
|
261
|
-
var
|
|
262
|
-
|
|
182
|
+
var TrendValue_SingleValueContent = function SingleValueContent(_ref) {
|
|
183
|
+
var fontSize = _ref.fontSize,
|
|
184
|
+
color = _ref.color,
|
|
185
|
+
value = _ref.value,
|
|
186
|
+
text = _ref.text;
|
|
187
|
+
var TrendIndicator = false;
|
|
188
|
+
var ariaLabel = false;
|
|
189
|
+
|
|
190
|
+
if (parseFloat(value, 10) > 0) {
|
|
191
|
+
TrendIndicator = ArrowUp_default.a;
|
|
192
|
+
ariaLabel = Object(i18n_["_"])('increase');
|
|
193
|
+
} else if (parseFloat(value, 10) < 0) {
|
|
194
|
+
TrendIndicator = ArrowDown_default.a;
|
|
195
|
+
ariaLabel = Object(i18n_["_"])('decrease');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return /*#__PURE__*/external_react_default.a.createElement(Column, {
|
|
199
|
+
justify: "flex-end",
|
|
200
|
+
size: fontSize
|
|
201
|
+
}, /*#__PURE__*/external_react_default.a.createElement(Text, {
|
|
202
|
+
"data-test": "trendValueIndicator",
|
|
203
|
+
size: fontSize,
|
|
204
|
+
color: color
|
|
205
|
+
}, TrendIndicator && /*#__PURE__*/external_react_default.a.createElement(TrendIndicator, {
|
|
206
|
+
"aria-label": ariaLabel
|
|
207
|
+
})), /*#__PURE__*/external_react_default.a.createElement(Text, {
|
|
208
|
+
"data-test": "trendValue",
|
|
209
|
+
size: fontSize,
|
|
210
|
+
color: color
|
|
211
|
+
}, "".concat(text)));
|
|
263
212
|
};
|
|
264
|
-
/*
|
|
265
|
-
* @method getDefaultColorWithBg
|
|
266
|
-
* @param {Object} props
|
|
267
|
-
* @param {String} props.backgroundColor
|
|
268
|
-
* @param {String} props.defaultFontColor
|
|
269
|
-
* @param {String} props.defaultBlockFontColor
|
|
270
|
-
* @returns {String} defaultColor
|
|
271
|
-
*/
|
|
272
213
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
214
|
+
TrendValue_SingleValueContent.propTypes = {
|
|
215
|
+
fontSize: external_prop_types_default.a.number,
|
|
216
|
+
color: external_prop_types_default.a.string,
|
|
217
|
+
value: external_prop_types_default.a.oneOfType([external_prop_types_default.a.string, external_prop_types_default.a.number]),
|
|
218
|
+
text: external_prop_types_default.a.string
|
|
278
219
|
};
|
|
279
|
-
/*
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
* @param {String} props.majorColor
|
|
284
|
-
* @param {String} props.backgroundColor
|
|
285
|
-
* @param {String} props.defaultFontColor
|
|
286
|
-
* @param {String} props.defaultBlockFontColor
|
|
287
|
-
* @returns {String} majorColor
|
|
288
|
-
*/
|
|
220
|
+
/* harmony default export */ var TrendValue = (TrendValue_SingleValueContent);
|
|
221
|
+
// EXTERNAL MODULE: external "cssesc"
|
|
222
|
+
var external_cssesc_ = __webpack_require__(110);
|
|
223
|
+
var external_cssesc_default = /*#__PURE__*/__webpack_require__.n(external_cssesc_);
|
|
289
224
|
|
|
290
|
-
|
|
291
|
-
var majorColor = _ref2.majorColor,
|
|
292
|
-
backgroundColor = _ref2.backgroundColor,
|
|
293
|
-
defaultFontColor = _ref2.defaultFontColor,
|
|
294
|
-
defaultBlockFontColor = _ref2.defaultBlockFontColor; // If backgroundColor is set, but no majorColor,
|
|
295
|
-
// the default majorColor will turn to be defaultBlockFontColor.
|
|
296
|
-
// eg: major color will turn to be white in enterprise mode.
|
|
297
|
-
// however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.
|
|
225
|
+
// CONCATENATED MODULE: ./src/SingleValueBasic/MajorValue.jsx
|
|
298
226
|
|
|
299
|
-
if (hasBackground(backgroundColor) && !majorColor) {
|
|
300
|
-
return getDefaultColorWithBg({
|
|
301
|
-
backgroundColor: backgroundColor,
|
|
302
|
-
defaultFontColor: defaultFontColor,
|
|
303
|
-
defaultBlockFontColor: defaultBlockFontColor
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
227
|
|
|
307
|
-
return getFormattedColor(majorColor, defaultFontColor);
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* Get the color for the trend components
|
|
311
|
-
* @method getTrendColor
|
|
312
|
-
* @param {Object} props
|
|
313
|
-
* @param {String} props.trendColor The trendColor value determined from encoding
|
|
314
|
-
* @param {Number} props.trendValue
|
|
315
|
-
* @param {Number} props.majorValue
|
|
316
|
-
* @param {String} props.customizedBgColor
|
|
317
|
-
* @param {String} props.trendDisplay absolute || percent || off
|
|
318
|
-
* @param {Object} defaultColors
|
|
319
|
-
* @returns {String} trendColor
|
|
320
|
-
*/
|
|
321
228
|
|
|
322
|
-
var getTrendColor = function getTrendColor(_ref3) {
|
|
323
|
-
var trendColor = _ref3.trendColor,
|
|
324
|
-
trendValue = _ref3.trendValue,
|
|
325
|
-
majorValue = _ref3.majorValue,
|
|
326
|
-
customizedBgColor = _ref3.customizedBgColor,
|
|
327
|
-
trendDisplay = _ref3.trendDisplay,
|
|
328
|
-
defaultColors = _ref3.defaultColors;
|
|
329
229
|
|
|
330
|
-
if (trendColor) {
|
|
331
|
-
return trendColor;
|
|
332
|
-
}
|
|
333
230
|
|
|
334
|
-
|
|
335
|
-
|
|
231
|
+
var Row = external_styled_components_default.a.div.withConfig({
|
|
232
|
+
displayName: "MajorValue__Row",
|
|
233
|
+
componentId: "shlzpv-0"
|
|
234
|
+
})(["display:flex;flex-direction:row;align-items:flex-end;justify-content:left;height:", "px;line-height:", "px;"], function (props) {
|
|
235
|
+
return props.size;
|
|
236
|
+
}, function (props) {
|
|
237
|
+
return props.size;
|
|
238
|
+
});
|
|
239
|
+
var MajorValue_Text = external_styled_components_default.a.div.withConfig({
|
|
240
|
+
displayName: "MajorValue__Text",
|
|
241
|
+
componentId: "shlzpv-1"
|
|
242
|
+
})(["white-space:nowrap;height:100%;font-size:", "px;color:", ";font-family:", ";font-weight:bold;&:hover{text-decoration:", ";cursor:", ";}", ""], function (props) {
|
|
243
|
+
return props.size || 12;
|
|
244
|
+
}, function (props) {
|
|
245
|
+
return props.color;
|
|
246
|
+
}, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
|
|
247
|
+
return props.showUnderline ? 'underline' : 'inherit';
|
|
248
|
+
}, function (props) {
|
|
249
|
+
return props.showUnderline ? 'pointer' : 'inherit';
|
|
250
|
+
}, function (props) {
|
|
251
|
+
if (!props.pseudoContent || !props.pseudoContentPosition) {
|
|
252
|
+
return '';
|
|
336
253
|
}
|
|
337
254
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
|
|
343
|
-
return defaultBlockFontColor;
|
|
344
|
-
} // if trendDisplay is percent, and trendValue === value
|
|
345
|
-
// the trend percent = trendValue / (value - trendValue) will return Infinity
|
|
255
|
+
return "&:".concat(props.pseudoContentPosition, " {\n // by default this pseudo element would inherit text-decoration from main element\n // and text-decoration could not be overwritten.\n // adding display: inline-block makes text decoration independent from main element.\n // => the unit will not be underlined if a user hovers over the main value\n display: inline-block;\n font-size: ").concat(props.pseudoContentFontSize, "px;\n position: relative;\n font-weight: normal;\n content: ").concat(props.pseudoContent, ";\n }");
|
|
256
|
+
});
|
|
257
|
+
var validUnitPositions = ['before', 'after'];
|
|
346
258
|
|
|
259
|
+
var MajorValue_SingleValueContent = function SingleValueContent(_ref) {
|
|
260
|
+
var color = _ref.color,
|
|
261
|
+
fontSize = _ref.fontSize,
|
|
262
|
+
unitPosition = _ref.unitPosition,
|
|
263
|
+
title = _ref.title,
|
|
264
|
+
value = _ref.value,
|
|
265
|
+
onValueClick = _ref.onValueClick,
|
|
266
|
+
unit = _ref.unit;
|
|
267
|
+
var sanitizedUnit;
|
|
268
|
+
var sanitizedUnitPosition;
|
|
347
269
|
|
|
348
|
-
|
|
270
|
+
if (typeof unit === 'string') {
|
|
271
|
+
sanitizedUnit = external_cssesc_default()(unit, {
|
|
272
|
+
wrap: true,
|
|
273
|
+
quotes: 'double'
|
|
274
|
+
});
|
|
349
275
|
|
|
350
|
-
|
|
351
|
-
|
|
276
|
+
if (typeof unitPosition === 'string' && validUnitPositions.includes(unitPosition)) {
|
|
277
|
+
sanitizedUnitPosition = unitPosition;
|
|
278
|
+
} else {
|
|
279
|
+
sanitizedUnitPosition = 'after';
|
|
280
|
+
}
|
|
352
281
|
}
|
|
353
282
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
* @method computeColors
|
|
359
|
-
* @param {Object} props all viz props
|
|
360
|
-
* @param {Object} defaultColors defaultColors from theme
|
|
361
|
-
* @returns {Object} result
|
|
362
|
-
* @returns {Boolean} backgroundEnabled
|
|
363
|
-
* @returns {String} backgroundColor
|
|
364
|
-
* @returns {String} majorColor
|
|
365
|
-
* @returns {String} trendColor
|
|
366
|
-
* @returns {String} underLabelColor
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
var computeColors = function computeColors(props, defaultColors) {
|
|
370
|
-
var backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
|
|
371
|
-
var backgroundEnabled = hasBackground(backgroundColor);
|
|
372
|
-
var majorColor = getMajorColor({
|
|
373
|
-
majorColor: props.majorColor,
|
|
374
|
-
backgroundColor: backgroundColor,
|
|
375
|
-
defaultFontColor: defaultColors.defaultFontColor,
|
|
376
|
-
defaultBlockFontColor: defaultColors.defaultBlockFontColor
|
|
377
|
-
});
|
|
378
|
-
var trendColor = getTrendColor({
|
|
379
|
-
trendColor: props.trendColor,
|
|
380
|
-
trendValue: props.trendValue,
|
|
381
|
-
majorValue: props.majorValue,
|
|
382
|
-
customizedBgColor: props.backgroundColor,
|
|
383
|
-
trendDisplay: props.trendDisplay,
|
|
384
|
-
defaultColors: defaultColors
|
|
385
|
-
}); // todo: need change it to not depend on majorColor
|
|
283
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
284
|
+
if (e.keyCode !== 13) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
386
287
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
backgroundColor: backgroundColor,
|
|
390
|
-
backgroundEnabled: backgroundEnabled,
|
|
391
|
-
majorColor: majorColor,
|
|
392
|
-
trendColor: trendColor,
|
|
393
|
-
underLabelColor: underLabelColor
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
onValueClick(e);
|
|
394
290
|
};
|
|
395
|
-
};
|
|
396
|
-
/**
|
|
397
|
-
* Format and return the value (major/trend)
|
|
398
|
-
* @method computeText
|
|
399
|
-
* @param {Object} props
|
|
400
|
-
* @param {Number} props.value // The major/trend value
|
|
401
|
-
* @param {Number} props.numberPrecision
|
|
402
|
-
* @param {Bool} props.shouldUseThousandSeparators
|
|
403
|
-
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
404
|
-
* @returns {Number} major or trend text
|
|
405
|
-
*/
|
|
406
|
-
|
|
407
|
-
var computeText = function computeText(_ref4) {
|
|
408
|
-
var value = _ref4.value,
|
|
409
|
-
numberPrecision = _ref4.numberPrecision,
|
|
410
|
-
shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
|
|
411
|
-
shouldAbbreviateTrendValue = _ref4.shouldAbbreviateTrendValue;
|
|
412
|
-
var text = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(value) ? Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["formatNumber"])(value, numberPrecision, {
|
|
413
|
-
useThousandSeparators: shouldUseThousandSeparators,
|
|
414
|
-
// todo: need update formatNumber
|
|
415
|
-
useTrendUnits: shouldAbbreviateTrendValue
|
|
416
|
-
}) : value; // When text is undefined, return empty string
|
|
417
291
|
|
|
418
|
-
|
|
419
|
-
|
|
292
|
+
return /*#__PURE__*/external_react_default.a.createElement(Row, {
|
|
293
|
+
size: fontSize
|
|
294
|
+
}, /*#__PURE__*/external_react_default.a.createElement(MajorValue_Text, {
|
|
295
|
+
"data-test": "majorValue",
|
|
296
|
+
color: color,
|
|
297
|
+
onClick: function onClick(e) {
|
|
298
|
+
return typeof onValueClick === 'function' && onValueClick(e);
|
|
299
|
+
},
|
|
300
|
+
showUnderline: !!onValueClick,
|
|
301
|
+
size: fontSize,
|
|
302
|
+
title: title,
|
|
303
|
+
pseudoContent: sanitizedUnit,
|
|
304
|
+
pseudoContentPosition: sanitizedUnitPosition,
|
|
305
|
+
pseudoContentFontSize: fontSize * 0.6,
|
|
306
|
+
tabIndex: "0",
|
|
307
|
+
role: "button",
|
|
308
|
+
onKeyDown: handleKeyDown
|
|
309
|
+
}, value));
|
|
420
310
|
};
|
|
421
|
-
/*
|
|
422
|
-
* @method getMajorText
|
|
423
|
-
* @param {Object} props
|
|
424
|
-
* @param {Number} props.majorValue
|
|
425
|
-
* @param {Number} props.numberPrecision
|
|
426
|
-
* @param {Bool} props.shouldUseThousandSeparators
|
|
427
|
-
* @returns {String} majorText
|
|
428
|
-
*/
|
|
429
311
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
439
|
-
shouldAbbreviateTrendValue: false
|
|
440
|
-
});
|
|
312
|
+
MajorValue_SingleValueContent.propTypes = {
|
|
313
|
+
color: external_prop_types_default.a.string,
|
|
314
|
+
fontSize: external_prop_types_default.a.number,
|
|
315
|
+
unit: external_prop_types_default.a.string,
|
|
316
|
+
unitPosition: external_prop_types_default.a.oneOf(validUnitPositions),
|
|
317
|
+
value: external_prop_types_default.a.oneOfType([external_prop_types_default.a.string, external_prop_types_default.a.number]),
|
|
318
|
+
title: external_prop_types_default.a.oneOfType([external_prop_types_default.a.string, external_prop_types_default.a.number]),
|
|
319
|
+
onValueClick: external_prop_types_default.a.oneOfType([external_prop_types_default.a.bool, external_prop_types_default.a.func])
|
|
441
320
|
};
|
|
442
|
-
/*
|
|
443
|
-
|
|
444
|
-
* @param {Object} props
|
|
445
|
-
* @param {Number} props.majorValue
|
|
446
|
-
* @param {Number} props.trendValue
|
|
447
|
-
* @param {String} props.trendDisplay
|
|
448
|
-
* @param {Number} props.numberPrecision
|
|
449
|
-
* @param {Bool} props.shouldUseThousandSeparators
|
|
450
|
-
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
451
|
-
* @returns {String} trendText
|
|
452
|
-
*/
|
|
321
|
+
/* harmony default export */ var MajorValue = (MajorValue_SingleValueContent);
|
|
322
|
+
// CONCATENATED MODULE: ./src/SingleValueBasic/SingleValueBasic.jsx
|
|
453
323
|
|
|
454
|
-
var getTrendText = function getTrendText(_ref6) {
|
|
455
|
-
var majorValue = _ref6.majorValue,
|
|
456
|
-
trendValue = _ref6.trendValue,
|
|
457
|
-
trendDisplay = _ref6.trendDisplay,
|
|
458
|
-
numberPrecision = _ref6.numberPrecision,
|
|
459
|
-
shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
|
|
460
|
-
shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
|
|
461
324
|
|
|
462
|
-
var compute = function compute(value) {
|
|
463
|
-
return computeText({
|
|
464
|
-
value: value,
|
|
465
|
-
numberPrecision: numberPrecision,
|
|
466
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
467
|
-
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
325
|
|
|
471
|
-
if (trendValue === '' || !Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue)) {
|
|
472
|
-
return '';
|
|
473
|
-
}
|
|
474
326
|
|
|
475
|
-
var showPercent = trendDisplay === 'percent';
|
|
476
327
|
|
|
477
|
-
if (!showPercent) {
|
|
478
|
-
return compute(trendValue);
|
|
479
|
-
}
|
|
480
328
|
|
|
481
|
-
var diff = Math.abs(trendValue - majorValue);
|
|
482
|
-
var val = Math.round(trendValue / diff * 100);
|
|
483
329
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
330
|
+
var SingleValueBasic_Column = external_styled_components_default.a.div.withConfig({
|
|
331
|
+
displayName: "SingleValueBasic__Column",
|
|
332
|
+
componentId: "k0nwrx-0"
|
|
333
|
+
})(["display:flex;flex-direction:column;align-self:center;justify-content:center;"]);
|
|
334
|
+
var SingleValueBasic_Row = external_styled_components_default.a.div.withConfig({
|
|
335
|
+
displayName: "SingleValueBasic__Row",
|
|
336
|
+
componentId: "k0nwrx-1"
|
|
337
|
+
})(["display:flex;flex-direction:row;align-items:", ";justify-content:", ";"], function (props) {
|
|
338
|
+
return props.alignItems || 'center';
|
|
339
|
+
}, function (props) {
|
|
340
|
+
return Object(singleValueUtils["getAligment"])(props.align);
|
|
341
|
+
});
|
|
342
|
+
var SingleValueBasic_Text = external_styled_components_default.a.div.withConfig({
|
|
343
|
+
displayName: "SingleValueBasic__Text",
|
|
344
|
+
componentId: "k0nwrx-2"
|
|
345
|
+
})(["font-weight:normal;white-space:nowrap;font-size:", "px;color:", ";font-family:", ";height:", "px;line-height:1.2;margin:", ";"], function (props) {
|
|
346
|
+
return props.size || 12;
|
|
347
|
+
}, function (props) {
|
|
348
|
+
return props.color || '#000';
|
|
349
|
+
}, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
|
|
350
|
+
return props.size || 12;
|
|
351
|
+
}, function (props) {
|
|
352
|
+
return props.margin || 'inherit';
|
|
353
|
+
});
|
|
487
354
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
355
|
+
var SingleValueBasic_SingleValueBasic = function SingleValueBasic(_ref) {
|
|
356
|
+
var props = extends_default()({}, _ref);
|
|
491
357
|
|
|
492
|
-
var
|
|
493
|
-
|
|
358
|
+
var majorColor = props.majorColor,
|
|
359
|
+
majorTextFontSize = props.majorTextFontSize,
|
|
360
|
+
majorText = props.majorText,
|
|
361
|
+
majorValueTitle = props.majorValueTitle,
|
|
362
|
+
trendColor = props.trendColor,
|
|
363
|
+
trendTextFontSize = props.trendTextFontSize,
|
|
364
|
+
trendText = props.trendText,
|
|
365
|
+
showTrendIndicator = props.showTrendIndicator,
|
|
366
|
+
unit = props.unit,
|
|
367
|
+
unitPosition = props.unitPosition,
|
|
368
|
+
underLabel = props.underLabel,
|
|
369
|
+
underLabelFontSize = props.underLabelFontSize,
|
|
370
|
+
underLabelColor = props.underLabelColor,
|
|
371
|
+
onValueClick = props.onValueClick,
|
|
372
|
+
align = props.align;
|
|
373
|
+
var trendIndicatorEnabled = trendText !== '' && showTrendIndicator;
|
|
374
|
+
return /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Column, null, /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Row, {
|
|
375
|
+
alignItems: "baseline",
|
|
376
|
+
align: align,
|
|
377
|
+
"data-test": "single-value-row-align-".concat(Object(singleValueUtils["getAligment"])(align))
|
|
378
|
+
}, /*#__PURE__*/external_react_default.a.createElement(MajorValue, {
|
|
379
|
+
color: majorColor,
|
|
380
|
+
fontSize: majorTextFontSize,
|
|
381
|
+
unit: unit,
|
|
382
|
+
unitPosition: unitPosition,
|
|
383
|
+
value: majorText,
|
|
384
|
+
title: majorValueTitle,
|
|
385
|
+
onValueClick: onValueClick
|
|
386
|
+
}), trendIndicatorEnabled &&
|
|
387
|
+
/*#__PURE__*/
|
|
388
|
+
// Passing the same value for value and text is a temporary hold until completion of https://jira.splunk.com/browse/SCP-21371
|
|
389
|
+
external_react_default.a.createElement(TrendValue, {
|
|
390
|
+
fontSize: trendTextFontSize,
|
|
391
|
+
color: trendColor,
|
|
392
|
+
value: trendText,
|
|
393
|
+
text: trendText
|
|
394
|
+
})), underLabel && /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Row, {
|
|
395
|
+
justify: "center",
|
|
396
|
+
align: align,
|
|
397
|
+
"data-test": "single-value-row-align-".concat(Object(singleValueUtils["getAligment"])(align))
|
|
398
|
+
}, /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Text, {
|
|
399
|
+
"data-test": "underLabel",
|
|
400
|
+
size: underLabelFontSize,
|
|
401
|
+
color: underLabelColor,
|
|
402
|
+
margin: "0 6px"
|
|
403
|
+
}, underLabel)));
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
SingleValueBasic_SingleValueBasic.propTypes = {
|
|
407
|
+
majorText: external_prop_types_default.a.string,
|
|
408
|
+
majorColor: external_prop_types_default.a.string,
|
|
409
|
+
majorTextFontSize: external_prop_types_default.a.number,
|
|
410
|
+
majorValueTitle: external_prop_types_default.a.string,
|
|
411
|
+
trendText: external_prop_types_default.a.string,
|
|
412
|
+
trendTextFontSize: external_prop_types_default.a.number,
|
|
413
|
+
trendColor: external_prop_types_default.a.string,
|
|
414
|
+
showTrendIndicator: external_prop_types_default.a.bool,
|
|
415
|
+
unit: external_prop_types_default.a.string,
|
|
416
|
+
unitPosition: external_prop_types_default.a.oneOf(['before', 'after']),
|
|
417
|
+
underLabel: external_prop_types_default.a.string,
|
|
418
|
+
underLabelFontSize: external_prop_types_default.a.number,
|
|
419
|
+
underLabelColor: external_prop_types_default.a.string,
|
|
420
|
+
onValueClick: external_prop_types_default.a.oneOfType([external_prop_types_default.a.bool, external_prop_types_default.a.func]),
|
|
421
|
+
align: external_prop_types_default.a.string
|
|
422
|
+
};
|
|
423
|
+
var SingleValueTrendValue = TrendValue;
|
|
424
|
+
/* harmony default export */ var src_SingleValueBasic_SingleValueBasic = __webpack_exports__["default"] = (SingleValueBasic_SingleValueBasic);
|
|
425
|
+
|
|
426
|
+
/***/ }),
|
|
427
|
+
|
|
428
|
+
/***/ 108:
|
|
429
|
+
/***/ (function(module, exports) {
|
|
430
|
+
|
|
431
|
+
module.exports = require("@splunk/react-icons/enterprise/ArrowUp");
|
|
432
|
+
|
|
433
|
+
/***/ }),
|
|
434
|
+
|
|
435
|
+
/***/ 109:
|
|
436
|
+
/***/ (function(module, exports) {
|
|
437
|
+
|
|
438
|
+
module.exports = require("@splunk/react-icons/enterprise/ArrowDown");
|
|
439
|
+
|
|
440
|
+
/***/ }),
|
|
441
|
+
|
|
442
|
+
/***/ 11:
|
|
443
|
+
/***/ (function(module, exports) {
|
|
444
|
+
|
|
445
|
+
module.exports = require("@splunk/visualizations-shared/numberUtils");
|
|
446
|
+
|
|
447
|
+
/***/ }),
|
|
448
|
+
|
|
449
|
+
/***/ 110:
|
|
450
|
+
/***/ (function(module, exports) {
|
|
451
|
+
|
|
452
|
+
module.exports = require("cssesc");
|
|
453
|
+
|
|
454
|
+
/***/ }),
|
|
455
|
+
|
|
456
|
+
/***/ 2:
|
|
457
|
+
/***/ (function(module, exports) {
|
|
458
|
+
|
|
459
|
+
module.exports = require("@splunk/ui-utils/i18n");
|
|
460
|
+
|
|
461
|
+
/***/ }),
|
|
462
|
+
|
|
463
|
+
/***/ 20:
|
|
464
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
465
|
+
|
|
466
|
+
"use strict";
|
|
467
|
+
__webpack_require__.r(__webpack_exports__);
|
|
468
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_FONT", function() { return DEFAULT_FONT; });
|
|
469
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_FONT_FAMILY", function() { return DEFAULT_FONT_FAMILY; });
|
|
470
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SVR_PADDING", function() { return SVR_PADDING; });
|
|
471
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAligment", function() { return getAligment; });
|
|
472
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldShowTrend", function() { return shouldShowTrend; });
|
|
473
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isLoadingOrNoColumns", function() { return isLoadingOrNoColumns; });
|
|
474
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFormattedColor", function() { return getFormattedColor; });
|
|
475
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBackground", function() { return hasBackground; });
|
|
476
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isIdenticalColor", function() { return isIdenticalColor; });
|
|
477
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDefaultColorWithBg", function() { return getDefaultColorWithBg; });
|
|
478
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorColor", function() { return getMajorColor; });
|
|
479
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendColor", function() { return getTrendColor; });
|
|
480
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeColors", function() { return computeColors; });
|
|
481
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeText", function() { return computeText; });
|
|
482
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorText", function() { return getMajorText; });
|
|
483
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendText", function() { return getTrendText; });
|
|
484
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeFontSize", function() { return computeFontSize; });
|
|
485
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorFontSize", function() { return getMajorFontSize; });
|
|
486
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTrendFontSize", function() { return getTrendFontSize; });
|
|
487
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUnderLabelHeight", function() { return getUnderLabelHeight; });
|
|
488
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUnderLabel", function() { return getUnderLabel; });
|
|
489
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMajorAndTrend", function() { return getMajorAndTrend; });
|
|
490
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateVizInSmallSpace", function() { return updateVizInSmallSpace; });
|
|
491
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeSingleValueContent", function() { return computeSingleValueContent; });
|
|
492
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "minimallyTruncateStringToWidth", function() { return minimallyTruncateStringToWidth; });
|
|
493
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeSingleValueRadialContent", function() { return computeSingleValueRadialContent; });
|
|
494
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getGraphColors", function() { return getGraphColors; });
|
|
495
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjustRGB", function() { return adjustRGB; });
|
|
496
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lighten", function() { return lighten; });
|
|
497
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "darken", function() { return darken; });
|
|
498
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "handleValueClickCallback", function() { return handleValueClickCallback; });
|
|
499
|
+
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
|
|
500
|
+
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
|
|
501
|
+
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
502
|
+
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
|
|
503
|
+
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
|
|
504
|
+
/* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__);
|
|
505
|
+
/* harmony import */ var _splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(76);
|
|
506
|
+
/* harmony import */ var _splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__);
|
|
507
|
+
/* harmony import */ var _splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(36);
|
|
508
|
+
/* harmony import */ var _splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__);
|
|
509
|
+
/* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(71);
|
|
510
|
+
/* harmony import */ var _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__);
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
function ownKeys(object, enumerableOnly) {
|
|
514
|
+
var keys = Object.keys(object);
|
|
515
|
+
|
|
516
|
+
if (Object.getOwnPropertySymbols) {
|
|
517
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
518
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
519
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
520
|
+
});
|
|
521
|
+
keys.push.apply(keys, symbols);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return keys;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function _objectSpread(target) {
|
|
528
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
529
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
530
|
+
|
|
531
|
+
if (i % 2) {
|
|
532
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
533
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]);
|
|
534
|
+
});
|
|
535
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
536
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
537
|
+
} else {
|
|
538
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
539
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return target;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
var DEFAULT_FONT = 12;
|
|
553
|
+
var DEFAULT_FONT_FAMILY = '"Splunk Platform Sans", "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif';
|
|
554
|
+
var SVR_PADDING = {
|
|
555
|
+
top: 12,
|
|
556
|
+
bottom: 12,
|
|
557
|
+
left: 16,
|
|
558
|
+
right: 16
|
|
559
|
+
};
|
|
560
|
+
var getAligment = function getAligment(align) {
|
|
561
|
+
var alignMap = {
|
|
562
|
+
left: 'start',
|
|
563
|
+
center: 'center',
|
|
564
|
+
right: 'end'
|
|
565
|
+
};
|
|
566
|
+
return alignMap[align] || 'center';
|
|
494
567
|
};
|
|
495
568
|
/**
|
|
496
|
-
*
|
|
497
|
-
* @
|
|
498
|
-
* @
|
|
499
|
-
* @param {Object} dimensions
|
|
500
|
-
* @param {Number} dimensions.width The width of the container
|
|
501
|
-
* @param {Number} dimensions.height The height of the container
|
|
502
|
-
* @param {String} [fontFamily='"Splunk Platform Sans" ...'] The font being used
|
|
503
|
-
* @param {String} [fontWeight='normal'] Boldness of font
|
|
504
|
-
* @returns {Number} The size to use for fontSize styles
|
|
569
|
+
* @method shouldShowTrend
|
|
570
|
+
* @param {String} trendDisplay
|
|
571
|
+
* @returns {Bool}
|
|
505
572
|
*/
|
|
506
573
|
|
|
507
|
-
var
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
574
|
+
var shouldShowTrend = function shouldShowTrend(trendDisplay) {
|
|
575
|
+
return trendDisplay === 'absolute' || trendDisplay === 'percent';
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
* @method isLoadingOrNoColumns
|
|
579
|
+
* @param {Object} dataSources
|
|
580
|
+
* @param {Boolean} loading
|
|
581
|
+
* @returns {Boolean} return true if loading or without columns in dataSources
|
|
582
|
+
*/
|
|
583
|
+
|
|
584
|
+
var isLoadingOrNoColumns = function isLoadingOrNoColumns(dataSources, loading) {
|
|
585
|
+
var data = Object(lodash__WEBPACK_IMPORTED_MODULE_1__["get"])(dataSources, 'primary.data.columns[0]', undefined);
|
|
586
|
+
var noColumns = data === undefined;
|
|
587
|
+
return loading || noColumns;
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* Retrieve the valid formatted color
|
|
591
|
+
* @method getFormattedColor
|
|
592
|
+
* @param {String} color
|
|
593
|
+
* @param {String} defaultColor
|
|
594
|
+
* @returns {String} the formatted color
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
var getFormattedColor = function getFormattedColor(color, defaultColor) {
|
|
598
|
+
return Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(color) || Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(defaultColor);
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* Determines if there is a background color
|
|
602
|
+
* @method hasBackground
|
|
603
|
+
* @param {String} backgroundColor
|
|
604
|
+
* @returns true for non-transparent background color
|
|
605
|
+
*/
|
|
606
|
+
|
|
607
|
+
var hasBackground = function hasBackground(backgroundColor) {
|
|
608
|
+
return !!backgroundColor && backgroundColor !== 'transparent';
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* @method isIdenticalColor
|
|
612
|
+
* @param {String} colorA
|
|
613
|
+
* @param {String} colorB
|
|
614
|
+
* @returns {Boolean}
|
|
615
|
+
*/
|
|
616
|
+
|
|
617
|
+
var isIdenticalColor = function isIdenticalColor(colorA, colorB) {
|
|
618
|
+
return !!colorA && !!colorB && Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(colorA.toLowerCase()) === Object(_splunk_visualizations_shared_propUtils__WEBPACK_IMPORTED_MODULE_4__["formatColor"])(colorB.toLowerCase());
|
|
515
619
|
};
|
|
516
620
|
/*
|
|
517
|
-
* @method
|
|
621
|
+
* @method getDefaultColorWithBg
|
|
518
622
|
* @param {Object} props
|
|
519
|
-
* @param {
|
|
520
|
-
* @param {
|
|
521
|
-
* @param {String} props.
|
|
522
|
-
* @
|
|
523
|
-
* @param {Number} props.spaceRatio
|
|
524
|
-
* @returns {Number} majorFontSize
|
|
623
|
+
* @param {String} props.backgroundColor
|
|
624
|
+
* @param {String} props.defaultFontColor
|
|
625
|
+
* @param {String} props.defaultBlockFontColor
|
|
626
|
+
* @returns {String} defaultColor
|
|
525
627
|
*/
|
|
526
628
|
|
|
527
|
-
var
|
|
528
|
-
var
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
_ref8$spaceRatio = _ref8.spaceRatio,
|
|
533
|
-
spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
|
|
534
|
-
var majorTextCalc = unit ? "".concat(unit).concat(majorText) : majorText;
|
|
535
|
-
return computeFontSize(majorTextCalc, {
|
|
536
|
-
width: width * spaceRatio,
|
|
537
|
-
height: height
|
|
538
|
-
});
|
|
629
|
+
var getDefaultColorWithBg = function getDefaultColorWithBg(_ref) {
|
|
630
|
+
var backgroundColor = _ref.backgroundColor,
|
|
631
|
+
defaultFontColor = _ref.defaultFontColor,
|
|
632
|
+
defaultBlockFontColor = _ref.defaultBlockFontColor;
|
|
633
|
+
return isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;
|
|
539
634
|
};
|
|
540
635
|
/*
|
|
541
|
-
* @method
|
|
636
|
+
* @method getMajorColor
|
|
637
|
+
* return formatted majorColor.
|
|
542
638
|
* @param {Object} props
|
|
543
|
-
* @param {
|
|
544
|
-
* @param {
|
|
545
|
-
* @param {String} props.
|
|
546
|
-
* @param {
|
|
547
|
-
* @returns {
|
|
639
|
+
* @param {String} props.majorColor
|
|
640
|
+
* @param {String} props.backgroundColor
|
|
641
|
+
* @param {String} props.defaultFontColor
|
|
642
|
+
* @param {String} props.defaultBlockFontColor
|
|
643
|
+
* @returns {String} majorColor
|
|
548
644
|
*/
|
|
549
645
|
|
|
550
|
-
var
|
|
551
|
-
var
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
646
|
+
var getMajorColor = function getMajorColor(_ref2) {
|
|
647
|
+
var majorColor = _ref2.majorColor,
|
|
648
|
+
backgroundColor = _ref2.backgroundColor,
|
|
649
|
+
defaultFontColor = _ref2.defaultFontColor,
|
|
650
|
+
defaultBlockFontColor = _ref2.defaultBlockFontColor; // If backgroundColor is set, but no majorColor,
|
|
651
|
+
// the default majorColor will turn to be defaultBlockFontColor.
|
|
652
|
+
// eg: major color will turn to be white in enterprise mode.
|
|
653
|
+
// however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.
|
|
654
|
+
|
|
655
|
+
if (hasBackground(backgroundColor) && !majorColor) {
|
|
656
|
+
return getDefaultColorWithBg({
|
|
657
|
+
backgroundColor: backgroundColor,
|
|
658
|
+
defaultFontColor: defaultFontColor,
|
|
659
|
+
defaultBlockFontColor: defaultBlockFontColor
|
|
562
660
|
});
|
|
563
|
-
trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
|
|
564
661
|
}
|
|
565
662
|
|
|
566
|
-
return
|
|
663
|
+
return getFormattedColor(majorColor, defaultFontColor);
|
|
567
664
|
};
|
|
568
|
-
|
|
569
|
-
*
|
|
570
|
-
* @
|
|
571
|
-
* @
|
|
665
|
+
/**
|
|
666
|
+
* Get the color for the trend components
|
|
667
|
+
* @method getTrendColor
|
|
668
|
+
* @param {Object} props
|
|
669
|
+
* @param {String} props.trendColor The trendColor value determined from encoding
|
|
670
|
+
* @param {Number} props.trendValue
|
|
671
|
+
* @param {Number} props.majorValue
|
|
672
|
+
* @param {String} props.customizedBgColor
|
|
673
|
+
* @param {String} props.trendDisplay absolute || percent || off
|
|
674
|
+
* @param {Object} defaultColors
|
|
675
|
+
* @returns {String} trendColor
|
|
572
676
|
*/
|
|
573
677
|
|
|
574
|
-
var
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
* @param {Number} height height of underLabel
|
|
582
|
-
* @param {Number} fond size of underLabel
|
|
583
|
-
*/
|
|
678
|
+
var getTrendColor = function getTrendColor(_ref3) {
|
|
679
|
+
var trendColor = _ref3.trendColor,
|
|
680
|
+
trendValue = _ref3.trendValue,
|
|
681
|
+
majorValue = _ref3.majorValue,
|
|
682
|
+
customizedBgColor = _ref3.customizedBgColor,
|
|
683
|
+
trendDisplay = _ref3.trendDisplay,
|
|
684
|
+
defaultColors = _ref3.defaultColors;
|
|
584
685
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
686
|
+
if (trendColor) {
|
|
687
|
+
return trendColor;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (Number.isNaN(Number(trendValue))) {
|
|
691
|
+
return undefined;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
var defaultFontColor = defaultColors.defaultFontColor,
|
|
695
|
+
defaultBlockFontColor = defaultColors.defaultBlockFontColor,
|
|
696
|
+
defaultBackgroundColor = defaultColors.defaultBackgroundColor; // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor
|
|
697
|
+
|
|
698
|
+
if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
|
|
699
|
+
return defaultBlockFontColor;
|
|
700
|
+
} // if trendDisplay is percent, and trendValue === value
|
|
701
|
+
// the trend percent = trendValue / (value - trendValue) will return Infinity
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
var isInvalidTrend = trendDisplay === 'percent' && trendValue === parseFloat(majorValue);
|
|
705
|
+
|
|
706
|
+
if (trendValue === 0 || isInvalidTrend) {
|
|
707
|
+
return defaultFontColor;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return trendValue > 0 ? _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_GREEN"] : _splunk_visualizations_shared_colorConstants__WEBPACK_IMPORTED_MODULE_5__["DELTA_RED"];
|
|
595
711
|
};
|
|
596
712
|
/**
|
|
597
|
-
*
|
|
598
|
-
* @method
|
|
599
|
-
* @param {Object} props
|
|
600
|
-
* @param {
|
|
601
|
-
* @
|
|
602
|
-
* @
|
|
603
|
-
* @
|
|
604
|
-
* @
|
|
605
|
-
* @
|
|
606
|
-
* @
|
|
607
|
-
* @param {String} props.unit // Unit for the value
|
|
608
|
-
* @param {Number} props.numberPrecision
|
|
609
|
-
* @param {Bool} props.shouldUseThousandSeparators
|
|
610
|
-
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
611
|
-
* @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size
|
|
713
|
+
* Computes visualization properties for display component
|
|
714
|
+
* @method computeColors
|
|
715
|
+
* @param {Object} props all viz props
|
|
716
|
+
* @param {Object} defaultColors defaultColors from theme
|
|
717
|
+
* @returns {Object} result
|
|
718
|
+
* @returns {Boolean} backgroundEnabled
|
|
719
|
+
* @returns {String} backgroundColor
|
|
720
|
+
* @returns {String} majorColor
|
|
721
|
+
* @returns {String} trendColor
|
|
722
|
+
* @returns {String} underLabelColor
|
|
612
723
|
*/
|
|
613
724
|
|
|
614
|
-
var
|
|
615
|
-
var
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
unit = _ref11.unit,
|
|
623
|
-
numberPrecision = _ref11.numberPrecision,
|
|
624
|
-
shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
|
|
625
|
-
shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue;
|
|
626
|
-
var majorTextSpaceRatio = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
|
|
627
|
-
var textContentWidth = width * 0.9;
|
|
628
|
-
var textContentHeight = height * 0.9;
|
|
629
|
-
var majorText = getMajorText({
|
|
630
|
-
majorValue: majorValue,
|
|
631
|
-
numberPrecision: numberPrecision,
|
|
632
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators
|
|
633
|
-
});
|
|
634
|
-
var majorTextFontSize = majorFontSize || getMajorFontSize({
|
|
635
|
-
width: textContentWidth,
|
|
636
|
-
height: textContentHeight,
|
|
637
|
-
unit: unit,
|
|
638
|
-
majorText: majorText,
|
|
639
|
-
spaceRatio: majorTextSpaceRatio
|
|
640
|
-
});
|
|
641
|
-
var trendText = getTrendText({
|
|
642
|
-
majorValue: majorValue,
|
|
643
|
-
trendValue: trendValue,
|
|
644
|
-
trendDisplay: trendDisplay,
|
|
645
|
-
numberPrecision: numberPrecision,
|
|
646
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
647
|
-
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
648
|
-
});
|
|
649
|
-
var trendTextFontSize = trendFontSize || getTrendFontSize({
|
|
650
|
-
width: textContentWidth,
|
|
651
|
-
height: textContentHeight,
|
|
652
|
-
trendText: trendText,
|
|
653
|
-
spaceRatio: 1 - majorTextSpaceRatio
|
|
725
|
+
var computeColors = function computeColors(props, defaultColors) {
|
|
726
|
+
var backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);
|
|
727
|
+
var backgroundEnabled = hasBackground(backgroundColor);
|
|
728
|
+
var majorColor = getMajorColor({
|
|
729
|
+
majorColor: props.majorColor,
|
|
730
|
+
backgroundColor: backgroundColor,
|
|
731
|
+
defaultFontColor: defaultColors.defaultFontColor,
|
|
732
|
+
defaultBlockFontColor: defaultColors.defaultBlockFontColor
|
|
654
733
|
});
|
|
734
|
+
var trendColor = getTrendColor({
|
|
735
|
+
trendColor: props.trendColor,
|
|
736
|
+
trendValue: props.trendValue,
|
|
737
|
+
majorValue: props.majorValue,
|
|
738
|
+
customizedBgColor: props.backgroundColor,
|
|
739
|
+
trendDisplay: props.trendDisplay,
|
|
740
|
+
defaultColors: defaultColors
|
|
741
|
+
}); // todo: need change it to not depend on majorColor
|
|
742
|
+
|
|
743
|
+
var underLabelColor = majorColor;
|
|
655
744
|
return {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
745
|
+
backgroundColor: backgroundColor,
|
|
746
|
+
backgroundEnabled: backgroundEnabled,
|
|
747
|
+
majorColor: majorColor,
|
|
748
|
+
trendColor: trendColor,
|
|
749
|
+
underLabelColor: underLabelColor
|
|
660
750
|
};
|
|
661
751
|
};
|
|
662
|
-
|
|
663
|
-
*
|
|
752
|
+
/**
|
|
753
|
+
* Format and return the value (major/trend)
|
|
754
|
+
* @method computeText
|
|
664
755
|
* @param {Object} props
|
|
665
|
-
* @param {Number} props.
|
|
666
|
-
* @param {Number} props.height // Height of the text container
|
|
667
|
-
* @param {Object} props.toRemoveList
|
|
668
|
-
* @param {Number} props.majorValue // Major value
|
|
669
|
-
* @param {Number} props.trendValue // Trend value
|
|
670
|
-
* @param {Number} props.majorFontSize
|
|
671
|
-
* @param {Number} props.trendFontSize
|
|
672
|
-
* @param {Number} props.majorTextFontSize
|
|
673
|
-
* @param {String} props.unit // Unit for the value
|
|
756
|
+
* @param {Number} props.value // The major/trend value
|
|
674
757
|
* @param {Number} props.numberPrecision
|
|
675
758
|
* @param {Bool} props.shouldUseThousandSeparators
|
|
676
759
|
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
677
|
-
* @returns {
|
|
678
|
-
* @returns {Object} results.newMajorAndTrend
|
|
679
|
-
* @returns {Object} results.updatedProps
|
|
760
|
+
* @returns {Number} major or trend text
|
|
680
761
|
*/
|
|
681
762
|
|
|
682
|
-
var
|
|
683
|
-
var
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
numberPrecision = _ref12.numberPrecision,
|
|
693
|
-
shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
|
|
694
|
-
shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
|
|
695
|
-
var removeIndex = 0;
|
|
696
|
-
var newProps = {}; // options need to be updated
|
|
697
|
-
|
|
698
|
-
var newMajorAndTrend = {};
|
|
699
|
-
var newTextSize = majorTextFontSize; // remove info on viz to make textFontSize >= 12px;
|
|
700
|
-
|
|
701
|
-
while (newTextSize < 12 && removeIndex < toRemoveList.length) {
|
|
702
|
-
var toRemove = toRemoveList[removeIndex];
|
|
703
|
-
newProps = _objectSpread(_objectSpread({}, newProps), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, toRemove.key, toRemove.value));
|
|
704
|
-
newMajorAndTrend = getMajorAndTrend(_objectSpread({
|
|
705
|
-
majorValue: majorValue,
|
|
706
|
-
trendValue: trendValue,
|
|
707
|
-
majorFontSize: majorFontSize,
|
|
708
|
-
trendFontSize: trendFontSize,
|
|
709
|
-
width: width,
|
|
710
|
-
height: height,
|
|
711
|
-
unit: unit,
|
|
712
|
-
numberPrecision: numberPrecision,
|
|
713
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
714
|
-
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
715
|
-
}, newProps));
|
|
716
|
-
newTextSize = newMajorAndTrend.majorTextFontSize;
|
|
717
|
-
removeIndex += 1;
|
|
718
|
-
} // truncate text if textFontSize is still less than 12
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (newTextSize < 12) {
|
|
722
|
-
var truncateValue = "".concat(majorValue.toString().slice(0, 3), "...");
|
|
723
|
-
newMajorAndTrend = getMajorAndTrend(_objectSpread({
|
|
724
|
-
majorValue: truncateValue,
|
|
725
|
-
trendValue: trendValue,
|
|
726
|
-
majorFontSize: majorFontSize,
|
|
727
|
-
trendFontSize: trendFontSize,
|
|
728
|
-
width: width,
|
|
729
|
-
height: height,
|
|
730
|
-
unit: unit,
|
|
731
|
-
numberPrecision: numberPrecision,
|
|
732
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
733
|
-
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
734
|
-
}, newProps));
|
|
735
|
-
}
|
|
763
|
+
var computeText = function computeText(_ref4) {
|
|
764
|
+
var value = _ref4.value,
|
|
765
|
+
numberPrecision = _ref4.numberPrecision,
|
|
766
|
+
shouldUseThousandSeparators = _ref4.shouldUseThousandSeparators,
|
|
767
|
+
shouldAbbreviateTrendValue = _ref4.shouldAbbreviateTrendValue;
|
|
768
|
+
var text = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(value) ? Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["formatNumber"])(value, numberPrecision, {
|
|
769
|
+
useThousandSeparators: shouldUseThousandSeparators,
|
|
770
|
+
// todo: need update formatNumber
|
|
771
|
+
useTrendUnits: shouldAbbreviateTrendValue
|
|
772
|
+
}) : value; // When text is undefined, return empty string
|
|
736
773
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
updatedProps: newProps
|
|
740
|
-
};
|
|
774
|
+
text = text || '';
|
|
775
|
+
return text;
|
|
741
776
|
};
|
|
742
777
|
/*
|
|
743
|
-
* @method
|
|
778
|
+
* @method getMajorText
|
|
744
779
|
* @param {Object} props
|
|
745
|
-
* @param {Number} props.
|
|
746
|
-
* @param {Number} props.contentHeight
|
|
747
|
-
* @param {Number} props.containerWidth
|
|
748
|
-
* @param {Number} props.containerHeight
|
|
749
|
-
* @param {Number} props.majorValue // Major value
|
|
750
|
-
* @param {Number} props.trendValue // Trend value
|
|
751
|
-
* @param {Number} props.majorFontSize
|
|
752
|
-
* @param {Number} props.trendFontSize
|
|
753
|
-
* @param {String} props.trendDisplay
|
|
754
|
-
* @param {String} props.unit // Unit for the value
|
|
780
|
+
* @param {Number} props.majorValue
|
|
755
781
|
* @param {Number} props.numberPrecision
|
|
756
782
|
* @param {Bool} props.shouldUseThousandSeparators
|
|
757
|
-
* @
|
|
758
|
-
* @param {Object} props.toRemoveList
|
|
759
|
-
* @returns {Object} results
|
|
760
|
-
* @returns {String} results.majorText
|
|
761
|
-
* @returns {String} results.trendText
|
|
762
|
-
* @returns {Number} results.majorTextFontSize
|
|
763
|
-
* @returns {Number} results.trendTextFontSize
|
|
764
|
-
* @returns {String} results.majorValueTitle
|
|
765
|
-
* @returns {Object} results.smallVizProps
|
|
783
|
+
* @returns {String} majorText
|
|
766
784
|
*/
|
|
767
785
|
|
|
768
|
-
var
|
|
769
|
-
var
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
majorFontSize = _ref13.majorFontSize,
|
|
776
|
-
trendFontSize = _ref13.trendFontSize,
|
|
777
|
-
trendDisplay = _ref13.trendDisplay,
|
|
778
|
-
unit = _ref13.unit,
|
|
779
|
-
numberPrecision = _ref13.numberPrecision,
|
|
780
|
-
shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
|
|
781
|
-
shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
|
|
782
|
-
toRemoveList = _ref13.toRemoveList;
|
|
783
|
-
|
|
784
|
-
var _getMajorAndTrend = getMajorAndTrend({
|
|
785
|
-
majorValue: majorValue,
|
|
786
|
-
trendValue: trendValue,
|
|
787
|
-
majorFontSize: majorFontSize,
|
|
788
|
-
trendFontSize: trendFontSize,
|
|
789
|
-
trendDisplay: trendDisplay,
|
|
790
|
-
width: contentWidth,
|
|
791
|
-
height: contentHeight,
|
|
792
|
-
unit: unit,
|
|
786
|
+
var getMajorText = function getMajorText(_ref5) {
|
|
787
|
+
var majorValue = _ref5.majorValue,
|
|
788
|
+
numberPrecision = _ref5.numberPrecision,
|
|
789
|
+
shouldUseThousandSeparators = _ref5.shouldUseThousandSeparators;
|
|
790
|
+
return computeText({
|
|
791
|
+
value: majorValue === null ? 'N/A' : majorValue,
|
|
792
|
+
// if majorValue is null, use `N/A`.
|
|
793
793
|
numberPrecision: numberPrecision,
|
|
794
794
|
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
795
|
-
shouldAbbreviateTrendValue:
|
|
796
|
-
})
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
795
|
+
shouldAbbreviateTrendValue: false
|
|
796
|
+
});
|
|
797
|
+
};
|
|
798
|
+
/*
|
|
799
|
+
* @method getTrendText
|
|
800
|
+
* @param {Object} props
|
|
801
|
+
* @param {Number} props.majorValue
|
|
802
|
+
* @param {Number} props.trendValue
|
|
803
|
+
* @param {String} props.trendDisplay
|
|
804
|
+
* @param {Number} props.numberPrecision
|
|
805
|
+
* @param {Bool} props.shouldUseThousandSeparators
|
|
806
|
+
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
807
|
+
* @returns {String} trendText
|
|
808
|
+
*/
|
|
801
809
|
|
|
802
|
-
|
|
803
|
-
var
|
|
804
|
-
|
|
805
|
-
|
|
810
|
+
var getTrendText = function getTrendText(_ref6) {
|
|
811
|
+
var majorValue = _ref6.majorValue,
|
|
812
|
+
trendValue = _ref6.trendValue,
|
|
813
|
+
trendDisplay = _ref6.trendDisplay,
|
|
814
|
+
numberPrecision = _ref6.numberPrecision,
|
|
815
|
+
shouldUseThousandSeparators = _ref6.shouldUseThousandSeparators,
|
|
816
|
+
shouldAbbreviateTrendValue = _ref6.shouldAbbreviateTrendValue;
|
|
806
817
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
height: containerHeight,
|
|
811
|
-
toRemoveList: toRemoveList,
|
|
812
|
-
majorValue: majorValue,
|
|
813
|
-
trendValue: trendValue,
|
|
814
|
-
majorFontSize: majorFontSize,
|
|
815
|
-
trendFontSize: trendFontSize,
|
|
816
|
-
majorTextFontSize: majorTextFontSize,
|
|
817
|
-
unit: unit,
|
|
818
|
+
var compute = function compute(value) {
|
|
819
|
+
return computeText({
|
|
820
|
+
value: value,
|
|
818
821
|
numberPrecision: numberPrecision,
|
|
819
822
|
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
820
823
|
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
821
|
-
})
|
|
822
|
-
|
|
823
|
-
updatedProps = _updateVizInSmallSpac.updatedProps;
|
|
824
|
+
});
|
|
825
|
+
};
|
|
824
826
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
majorTextFontSize = newMajorAndTrend.majorTextFontSize;
|
|
828
|
-
trendTextFontSize = newMajorAndTrend.trendTextFontSize;
|
|
829
|
-
smallVizProps = updatedProps;
|
|
827
|
+
if (trendValue === '' || !Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue)) {
|
|
828
|
+
return '';
|
|
830
829
|
}
|
|
831
830
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
831
|
+
var showPercent = trendDisplay === 'percent';
|
|
832
|
+
|
|
833
|
+
if (!showPercent) {
|
|
834
|
+
return compute(trendValue);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
var diff = Math.abs(trendValue - majorValue);
|
|
838
|
+
var val = Math.round(trendValue / diff * 100);
|
|
839
|
+
|
|
840
|
+
if (trendValue === 0 && diff === 0) {
|
|
841
|
+
val = 0;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
if (!Number.isFinite(val)) {
|
|
845
|
+
return 'N/A';
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
var text = compute(val);
|
|
849
|
+
return "".concat(text, "%");
|
|
840
850
|
};
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
var ellipsesLength = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])('...', "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily)); // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.
|
|
851
|
+
/**
|
|
852
|
+
* Helper to determine the font size for an element
|
|
853
|
+
* @method computeFontSize
|
|
854
|
+
* @param {String} text The string to find a size for
|
|
855
|
+
* @param {Object} dimensions
|
|
856
|
+
* @param {Number} dimensions.width The width of the container
|
|
857
|
+
* @param {Number} dimensions.height The height of the container
|
|
858
|
+
* @param {String} [fontFamily='"Splunk Platform Sans" ...'] The font being used
|
|
859
|
+
* @param {String} [fontWeight='normal'] Boldness of font
|
|
860
|
+
* @returns {Number} The size to use for fontSize styles
|
|
861
|
+
*/
|
|
853
862
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
863
|
+
var computeFontSize = function computeFontSize(text, _ref7) {
|
|
864
|
+
var width = _ref7.width,
|
|
865
|
+
height = _ref7.height;
|
|
866
|
+
var fontFamily = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_FONT_FAMILY;
|
|
867
|
+
var fontWeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'normal';
|
|
868
|
+
var widthInDefaultFont = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(DEFAULT_FONT, "px ").concat(fontFamily));
|
|
869
|
+
var fontSize = Math.min(width / widthInDefaultFont * DEFAULT_FONT, height / DEFAULT_FONT * DEFAULT_FONT);
|
|
870
|
+
return parseInt(fontSize, 10);
|
|
871
|
+
};
|
|
872
|
+
/*
|
|
873
|
+
* @method getMajorFontSize
|
|
874
|
+
* @param {Object} props
|
|
875
|
+
* @param {Number} props.width
|
|
876
|
+
* @param {Number} props.height
|
|
877
|
+
* @param {String} props.unit
|
|
878
|
+
* @param {String} props.majorText
|
|
879
|
+
* @param {Number} props.spaceRatio
|
|
880
|
+
* @returns {Number} majorFontSize
|
|
881
|
+
*/
|
|
862
882
|
|
|
863
|
-
|
|
883
|
+
var getMajorFontSize = function getMajorFontSize(_ref8) {
|
|
884
|
+
var width = _ref8.width,
|
|
885
|
+
height = _ref8.height,
|
|
886
|
+
unit = _ref8.unit,
|
|
887
|
+
majorText = _ref8.majorText,
|
|
888
|
+
_ref8$spaceRatio = _ref8.spaceRatio,
|
|
889
|
+
spaceRatio = _ref8$spaceRatio === void 0 ? 1 : _ref8$spaceRatio;
|
|
890
|
+
var majorTextCalc = unit ? "".concat(unit).concat(majorText) : majorText;
|
|
891
|
+
return computeFontSize(majorTextCalc, {
|
|
892
|
+
width: width * spaceRatio,
|
|
893
|
+
height: height
|
|
894
|
+
});
|
|
895
|
+
};
|
|
896
|
+
/*
|
|
897
|
+
* @method getTrendFontSize
|
|
898
|
+
* @param {Object} props
|
|
899
|
+
* @param {Number} props.width
|
|
900
|
+
* @param {Number} props.height
|
|
901
|
+
* @param {String} props.trendText
|
|
902
|
+
* @param {Number} props.spaceRatio
|
|
903
|
+
* @returns {Number} trendFontSize
|
|
904
|
+
*/
|
|
905
|
+
|
|
906
|
+
var getTrendFontSize = function getTrendFontSize(_ref9) {
|
|
907
|
+
var width = _ref9.width,
|
|
908
|
+
height = _ref9.height,
|
|
909
|
+
trendText = _ref9.trendText,
|
|
910
|
+
_ref9$spaceRatio = _ref9.spaceRatio,
|
|
911
|
+
spaceRatio = _ref9$spaceRatio === void 0 ? 1 : _ref9$spaceRatio;
|
|
912
|
+
var trendFontSize = 12;
|
|
913
|
+
|
|
914
|
+
if (spaceRatio > 0) {
|
|
915
|
+
trendFontSize = computeFontSize(trendText, {
|
|
916
|
+
width: width * spaceRatio,
|
|
917
|
+
height: height
|
|
918
|
+
});
|
|
919
|
+
trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
|
|
864
920
|
}
|
|
865
921
|
|
|
866
|
-
return
|
|
922
|
+
return trendFontSize;
|
|
923
|
+
};
|
|
924
|
+
/*
|
|
925
|
+
* The height of underLabel should no more than 12px
|
|
926
|
+
* @param {Number} height
|
|
927
|
+
* @return {Number} height || DEFAULT_FONT
|
|
928
|
+
*/
|
|
929
|
+
|
|
930
|
+
var getUnderLabelHeight = function getUnderLabelHeight(height) {
|
|
931
|
+
return height > DEFAULT_FONT ? DEFAULT_FONT : height;
|
|
932
|
+
};
|
|
933
|
+
/*
|
|
934
|
+
* @param {Object} config
|
|
935
|
+
* @param {String} underLabel
|
|
936
|
+
* @param {Number} width width of underLabel
|
|
937
|
+
* @param {Number} height height of underLabel
|
|
938
|
+
* @param {Number} fond size of underLabel
|
|
939
|
+
*/
|
|
940
|
+
|
|
941
|
+
var getUnderLabel = function getUnderLabel(_ref10) {
|
|
942
|
+
var underLabel = _ref10.underLabel,
|
|
943
|
+
width = _ref10.width,
|
|
944
|
+
height = _ref10.height;
|
|
945
|
+
return (// todo: may need truncate underLabel later
|
|
946
|
+
computeFontSize(underLabel, {
|
|
947
|
+
width: width,
|
|
948
|
+
height: height
|
|
949
|
+
})
|
|
950
|
+
);
|
|
867
951
|
};
|
|
868
|
-
|
|
869
|
-
*
|
|
952
|
+
/**
|
|
953
|
+
* Compute value and font size for major and trend
|
|
954
|
+
* @method getMajorAndTrend
|
|
870
955
|
* @param {Object} props
|
|
871
|
-
* @param {Number} props.
|
|
872
|
-
* @param {Number} props.
|
|
873
|
-
* @param {Number} props.containerWidth
|
|
874
|
-
* @param {Number} props.containerHeight
|
|
956
|
+
* @param {Number} props.width // Width of the text container
|
|
957
|
+
* @param {Number} props.height // Height of the text container
|
|
875
958
|
* @param {Number} props.majorValue // Major value
|
|
876
959
|
* @param {Number} props.trendValue // Trend value
|
|
877
960
|
* @param {Number} props.majorFontSize
|
|
@@ -881,642 +964,577 @@ var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_re
|
|
|
881
964
|
* @param {Number} props.numberPrecision
|
|
882
965
|
* @param {Bool} props.shouldUseThousandSeparators
|
|
883
966
|
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
884
|
-
* @
|
|
885
|
-
* @param {Bool} props.smallViz
|
|
886
|
-
* @returns {Object} results
|
|
887
|
-
* @returns {String} results.majorText
|
|
888
|
-
* @returns {String} results.trendText
|
|
889
|
-
* @returns {Number} results.majorTextFontSize
|
|
890
|
-
* @returns {Number} results.trendTextFontSize
|
|
891
|
-
* @returns {String} results.majorValueTitle
|
|
892
|
-
* @returns {Object} results.smallVizProps
|
|
967
|
+
* @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size
|
|
893
968
|
*/
|
|
894
969
|
|
|
895
|
-
var
|
|
896
|
-
var
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
970
|
+
var getMajorAndTrend = function getMajorAndTrend(_ref11) {
|
|
971
|
+
var width = _ref11.width,
|
|
972
|
+
height = _ref11.height,
|
|
973
|
+
majorValue = _ref11.majorValue,
|
|
974
|
+
trendValue = _ref11.trendValue,
|
|
975
|
+
majorFontSize = _ref11.majorFontSize,
|
|
976
|
+
trendFontSize = _ref11.trendFontSize,
|
|
977
|
+
trendDisplay = _ref11.trendDisplay,
|
|
978
|
+
unit = _ref11.unit,
|
|
979
|
+
numberPrecision = _ref11.numberPrecision,
|
|
980
|
+
shouldUseThousandSeparators = _ref11.shouldUseThousandSeparators,
|
|
981
|
+
shouldAbbreviateTrendValue = _ref11.shouldAbbreviateTrendValue;
|
|
982
|
+
var majorTextSpaceRatio = Object(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_2__["isNumerial"])(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;
|
|
983
|
+
var textContentWidth = width * 0.9;
|
|
984
|
+
var textContentHeight = height * 0.9;
|
|
985
|
+
var majorText = getMajorText({
|
|
986
|
+
majorValue: majorValue,
|
|
987
|
+
numberPrecision: numberPrecision,
|
|
988
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators
|
|
989
|
+
});
|
|
990
|
+
var majorTextFontSize = majorFontSize || getMajorFontSize({
|
|
991
|
+
width: textContentWidth,
|
|
992
|
+
height: textContentHeight,
|
|
993
|
+
unit: unit,
|
|
994
|
+
majorText: majorText,
|
|
995
|
+
spaceRatio: majorTextSpaceRatio
|
|
996
|
+
});
|
|
997
|
+
var trendText = getTrendText({
|
|
912
998
|
majorValue: majorValue,
|
|
913
999
|
trendValue: trendValue,
|
|
914
|
-
majorFontSize: majorFontSize,
|
|
915
|
-
trendFontSize: trendFontSize,
|
|
916
1000
|
trendDisplay: trendDisplay,
|
|
917
|
-
width: contentWidth,
|
|
918
|
-
height: contentHeight,
|
|
919
|
-
unit: unit,
|
|
920
1001
|
numberPrecision: numberPrecision,
|
|
921
1002
|
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
922
1003
|
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
923
|
-
})
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
var smallVizProps = {}; // custom logic for viz in small space
|
|
931
|
-
// if not showing the radial graph (if `smallViz` is true), then compute truncated major value
|
|
932
|
-
// and font sizes
|
|
933
|
-
|
|
934
|
-
if (smallViz) {
|
|
935
|
-
var truncateValue = minimallyTruncateStringToWidth({
|
|
936
|
-
text: majorValue,
|
|
937
|
-
fontWeight: 'bold',
|
|
938
|
-
fontSize: 12,
|
|
939
|
-
containerWidth: containerWidth
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
var _getMajorAndTrend3 = getMajorAndTrend({
|
|
943
|
-
majorValue: truncateValue,
|
|
944
|
-
trendValue: trendValue,
|
|
945
|
-
majorFontSize: majorFontSize,
|
|
946
|
-
trendFontSize: trendFontSize,
|
|
947
|
-
width: containerWidth,
|
|
948
|
-
height: containerHeight,
|
|
949
|
-
unit: unit,
|
|
950
|
-
trendDisplay: trendDisplay,
|
|
951
|
-
numberPrecision: numberPrecision,
|
|
952
|
-
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
953
|
-
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
majorText = _getMajorAndTrend3.majorText;
|
|
957
|
-
trendText = _getMajorAndTrend3.trendText;
|
|
958
|
-
majorTextFontSize = _getMajorAndTrend3.majorTextFontSize;
|
|
959
|
-
trendTextFontSize = _getMajorAndTrend3.trendTextFontSize;
|
|
960
|
-
smallVizProps = {
|
|
961
|
-
trendDisplay: trendDisplay,
|
|
962
|
-
unit: unit
|
|
963
|
-
};
|
|
964
|
-
}
|
|
965
|
-
|
|
1004
|
+
});
|
|
1005
|
+
var trendTextFontSize = trendFontSize || getTrendFontSize({
|
|
1006
|
+
width: textContentWidth,
|
|
1007
|
+
height: textContentHeight,
|
|
1008
|
+
trendText: trendText,
|
|
1009
|
+
spaceRatio: 1 - majorTextSpaceRatio
|
|
1010
|
+
});
|
|
966
1011
|
return {
|
|
967
1012
|
majorText: majorText,
|
|
968
|
-
trendText: trendText,
|
|
969
1013
|
majorTextFontSize: majorTextFontSize,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
smallVizProps: smallVizProps
|
|
1014
|
+
trendText: trendText,
|
|
1015
|
+
trendTextFontSize: trendTextFontSize
|
|
973
1016
|
};
|
|
974
1017
|
};
|
|
975
|
-
|
|
976
|
-
*
|
|
977
|
-
*
|
|
978
|
-
* @
|
|
979
|
-
* @param {
|
|
980
|
-
* @param {
|
|
981
|
-
* @param {
|
|
982
|
-
* @param {
|
|
983
|
-
* @param {
|
|
984
|
-
* @
|
|
985
|
-
* @
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
if (backgroundEnabled) {
|
|
995
|
-
// Check if the user defined colors to use
|
|
996
|
-
if (backgroundColor && typeof customColorFormatter === 'function') {
|
|
997
|
-
return customColorFormatter(backgroundColor);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
return defaultColors.none;
|
|
1002
|
-
};
|
|
1003
|
-
/**
|
|
1004
|
-
* Adjust rgb value if it equals to 0 or 255
|
|
1005
|
-
* @method adjustRGB
|
|
1006
|
-
* @param {Number} rgb [0 - 255]
|
|
1007
|
-
* @param {Number} delta
|
|
1008
|
-
* @returns {Number} adjusted rgb
|
|
1009
|
-
* @private
|
|
1010
|
-
*/
|
|
1011
|
-
|
|
1012
|
-
var adjustRGB = function adjustRGB(rgb, delta) {
|
|
1013
|
-
if (rgb === 255) {
|
|
1014
|
-
return rgb - delta;
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
if (rgb === 0) {
|
|
1018
|
-
return rgb + delta;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
return rgb;
|
|
1022
|
-
};
|
|
1023
|
-
/**
|
|
1024
|
-
* Modifies colors by multiplying by a given ratio
|
|
1025
|
-
* @method changeColor
|
|
1026
|
-
* @param {String} color // Color to modify
|
|
1027
|
-
* @param {Number} ratio // Float to modify color
|
|
1028
|
-
* @returns {String} new color
|
|
1029
|
-
* @private
|
|
1030
|
-
*/
|
|
1031
|
-
|
|
1032
|
-
var changeColor = function changeColor(color, ratio) {
|
|
1033
|
-
var hex = color.replace(/(0x|#)/, '');
|
|
1034
|
-
var r = parseInt(hex.substr(0, 2), 16);
|
|
1035
|
-
var g = parseInt(hex.substr(2, 2), 16);
|
|
1036
|
-
var b = parseInt(hex.substr(4, 2), 16); // Multiply by given ratio, make sure is between 0 and 255;
|
|
1037
|
-
|
|
1038
|
-
var newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
|
|
1039
|
-
var newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
|
|
1040
|
-
var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0); // If the color is not changed
|
|
1041
|
-
// case 1: the color is (0, 0 0)
|
|
1042
|
-
// lighten color (80, 80, 80)
|
|
1043
|
-
// darken color (40, 40, 40)
|
|
1044
|
-
// case 2: the color is (255, 255, 255)
|
|
1045
|
-
// lighten color (235, 235, 235)
|
|
1046
|
-
// darken color (175, 175, 175)
|
|
1047
|
-
// case 3: the color is e.g. (0, 255, 0)
|
|
1048
|
-
// new color (20, 235, 20)
|
|
1049
|
-
|
|
1050
|
-
if (newR === r && newG === g && newB === b) {
|
|
1051
|
-
if (newR === 0 && newG === 0 && newB === 0) {
|
|
1052
|
-
if (ratio > 1) {
|
|
1053
|
-
newR = adjustRGB(newR, 80);
|
|
1054
|
-
newG = adjustRGB(newG, 80);
|
|
1055
|
-
newB = adjustRGB(newB, 80);
|
|
1056
|
-
} else {
|
|
1057
|
-
newR = adjustRGB(newR, 40);
|
|
1058
|
-
newG = adjustRGB(newG, 40);
|
|
1059
|
-
newB = adjustRGB(newB, 40);
|
|
1060
|
-
}
|
|
1061
|
-
} else if (newR === 255 && newG === 255 && newB === 255) {
|
|
1062
|
-
if (ratio > 1) {
|
|
1063
|
-
newR = adjustRGB(newR, 20);
|
|
1064
|
-
newG = adjustRGB(newG, 20);
|
|
1065
|
-
newB = adjustRGB(newB, 20);
|
|
1066
|
-
} else {
|
|
1067
|
-
newR = adjustRGB(newR, 80);
|
|
1068
|
-
newG = adjustRGB(newG, 80);
|
|
1069
|
-
newB = adjustRGB(newB, 80);
|
|
1070
|
-
}
|
|
1071
|
-
} else {
|
|
1072
|
-
newR = adjustRGB(newR, 20);
|
|
1073
|
-
newG = adjustRGB(newG, 20);
|
|
1074
|
-
newB = adjustRGB(newB, 20);
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
return "#".concat(newR.toString(16).padStart(2, 0)) + "".concat(newG.toString(16).padStart(2, 0)) + "".concat(newB.toString(16).padStart(2, 0));
|
|
1079
|
-
};
|
|
1080
|
-
/**
|
|
1081
|
-
* Lighten a given color
|
|
1082
|
-
* @method lighten
|
|
1083
|
-
* @param {String} color
|
|
1084
|
-
* @returns {String}
|
|
1085
|
-
* @private
|
|
1018
|
+
/*
|
|
1019
|
+
* @method updateVizInSmallSpace
|
|
1020
|
+
* @param {Object} props
|
|
1021
|
+
* @param {Number} props.width // Width of the text container
|
|
1022
|
+
* @param {Number} props.height // Height of the text container
|
|
1023
|
+
* @param {Object} props.toRemoveList
|
|
1024
|
+
* @param {Number} props.majorValue // Major value
|
|
1025
|
+
* @param {Number} props.trendValue // Trend value
|
|
1026
|
+
* @param {Number} props.majorFontSize
|
|
1027
|
+
* @param {Number} props.trendFontSize
|
|
1028
|
+
* @param {Number} props.majorTextFontSize
|
|
1029
|
+
* @param {String} props.unit // Unit for the value
|
|
1030
|
+
* @param {Number} props.numberPrecision
|
|
1031
|
+
* @param {Bool} props.shouldUseThousandSeparators
|
|
1032
|
+
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
1033
|
+
* @returns {Object} results
|
|
1034
|
+
* @returns {Object} results.newMajorAndTrend
|
|
1035
|
+
* @returns {Object} results.updatedProps
|
|
1086
1036
|
*/
|
|
1087
1037
|
|
|
1038
|
+
var updateVizInSmallSpace = function updateVizInSmallSpace(_ref12) {
|
|
1039
|
+
var width = _ref12.width,
|
|
1040
|
+
height = _ref12.height,
|
|
1041
|
+
toRemoveList = _ref12.toRemoveList,
|
|
1042
|
+
majorValue = _ref12.majorValue,
|
|
1043
|
+
trendValue = _ref12.trendValue,
|
|
1044
|
+
majorFontSize = _ref12.majorFontSize,
|
|
1045
|
+
trendFontSize = _ref12.trendFontSize,
|
|
1046
|
+
majorTextFontSize = _ref12.majorTextFontSize,
|
|
1047
|
+
unit = _ref12.unit,
|
|
1048
|
+
numberPrecision = _ref12.numberPrecision,
|
|
1049
|
+
shouldUseThousandSeparators = _ref12.shouldUseThousandSeparators,
|
|
1050
|
+
shouldAbbreviateTrendValue = _ref12.shouldAbbreviateTrendValue;
|
|
1051
|
+
var removeIndex = 0;
|
|
1052
|
+
var newProps = {}; // options need to be updated
|
|
1088
1053
|
|
|
1089
|
-
var
|
|
1090
|
-
|
|
1091
|
-
};
|
|
1092
|
-
/**
|
|
1093
|
-
* Darkens a given color
|
|
1094
|
-
* @method darken
|
|
1095
|
-
* @param {String} color
|
|
1096
|
-
* @returns {String}
|
|
1097
|
-
* @private
|
|
1098
|
-
*/
|
|
1054
|
+
var newMajorAndTrend = {};
|
|
1055
|
+
var newTextSize = majorTextFontSize; // remove info on viz to make textFontSize >= 12px;
|
|
1099
1056
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1057
|
+
while (newTextSize < 12 && removeIndex < toRemoveList.length) {
|
|
1058
|
+
var toRemove = toRemoveList[removeIndex];
|
|
1059
|
+
newProps = _objectSpread(_objectSpread({}, newProps), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, toRemove.key, toRemove.value));
|
|
1060
|
+
newMajorAndTrend = getMajorAndTrend(_objectSpread({
|
|
1061
|
+
majorValue: majorValue,
|
|
1062
|
+
trendValue: trendValue,
|
|
1063
|
+
majorFontSize: majorFontSize,
|
|
1064
|
+
trendFontSize: trendFontSize,
|
|
1065
|
+
width: width,
|
|
1066
|
+
height: height,
|
|
1067
|
+
unit: unit,
|
|
1068
|
+
numberPrecision: numberPrecision,
|
|
1069
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
1070
|
+
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
1071
|
+
}, newProps));
|
|
1072
|
+
newTextSize = newMajorAndTrend.majorTextFontSize;
|
|
1073
|
+
removeIndex += 1;
|
|
1074
|
+
} // truncate text if textFontSize is still less than 12
|
|
1111
1075
|
|
|
1112
|
-
var handleValueClickCallback = function handleValueClickCallback(ev, majorValue, majorValueField, trendValue, onValueClick) {
|
|
1113
|
-
var trellisEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
1114
|
-
var trellisSplityBy = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
|
|
1115
|
-
var trellisKey = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : '';
|
|
1116
|
-
var payload = {
|
|
1117
|
-
trendValue: trendValue,
|
|
1118
|
-
value: majorValue,
|
|
1119
|
-
name: majorValueField
|
|
1120
|
-
};
|
|
1121
1076
|
|
|
1122
|
-
if (
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1077
|
+
if (newTextSize < 12) {
|
|
1078
|
+
var truncateValue = "".concat(majorValue.toString().slice(0, 3), "...");
|
|
1079
|
+
newMajorAndTrend = getMajorAndTrend(_objectSpread({
|
|
1080
|
+
majorValue: truncateValue,
|
|
1081
|
+
trendValue: trendValue,
|
|
1082
|
+
majorFontSize: majorFontSize,
|
|
1083
|
+
trendFontSize: trendFontSize,
|
|
1084
|
+
width: width,
|
|
1085
|
+
height: height,
|
|
1086
|
+
unit: unit,
|
|
1087
|
+
numberPrecision: numberPrecision,
|
|
1088
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
1089
|
+
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
1090
|
+
}, newProps));
|
|
1127
1091
|
}
|
|
1128
1092
|
|
|
1129
|
-
return
|
|
1130
|
-
|
|
1131
|
-
|
|
1093
|
+
return {
|
|
1094
|
+
newMajorAndTrend: newMajorAndTrend,
|
|
1095
|
+
updatedProps: newProps
|
|
1096
|
+
};
|
|
1132
1097
|
};
|
|
1098
|
+
/*
|
|
1099
|
+
* @method computeSingleValueContent
|
|
1100
|
+
* @param {Object} props
|
|
1101
|
+
* @param {Number} props.contentWidth
|
|
1102
|
+
* @param {Number} props.contentHeight
|
|
1103
|
+
* @param {Number} props.containerWidth
|
|
1104
|
+
* @param {Number} props.containerHeight
|
|
1105
|
+
* @param {Number} props.majorValue // Major value
|
|
1106
|
+
* @param {Number} props.trendValue // Trend value
|
|
1107
|
+
* @param {Number} props.majorFontSize
|
|
1108
|
+
* @param {Number} props.trendFontSize
|
|
1109
|
+
* @param {String} props.trendDisplay
|
|
1110
|
+
* @param {String} props.unit // Unit for the value
|
|
1111
|
+
* @param {Number} props.numberPrecision
|
|
1112
|
+
* @param {Bool} props.shouldUseThousandSeparators
|
|
1113
|
+
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
1114
|
+
* @param {Object} props.toRemoveList
|
|
1115
|
+
* @returns {Object} results
|
|
1116
|
+
* @returns {String} results.majorText
|
|
1117
|
+
* @returns {String} results.trendText
|
|
1118
|
+
* @returns {Number} results.majorTextFontSize
|
|
1119
|
+
* @returns {Number} results.trendTextFontSize
|
|
1120
|
+
* @returns {String} results.majorValueTitle
|
|
1121
|
+
* @returns {Object} results.smallVizProps
|
|
1122
|
+
*/
|
|
1133
1123
|
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
/***/ 31:
|
|
1151
|
-
/***/ (function(module, exports) {
|
|
1152
|
-
|
|
1153
|
-
module.exports = require("@splunk/visualizations-shared/numberUtils");
|
|
1154
|
-
|
|
1155
|
-
/***/ }),
|
|
1156
|
-
|
|
1157
|
-
/***/ 4:
|
|
1158
|
-
/***/ (function(module, exports) {
|
|
1159
|
-
|
|
1160
|
-
module.exports = require("styled-components");
|
|
1161
|
-
|
|
1162
|
-
/***/ }),
|
|
1163
|
-
|
|
1164
|
-
/***/ 48:
|
|
1165
|
-
/***/ (function(module, exports) {
|
|
1166
|
-
|
|
1167
|
-
module.exports = require("@babel/runtime/helpers/extends");
|
|
1168
|
-
|
|
1169
|
-
/***/ }),
|
|
1170
|
-
|
|
1171
|
-
/***/ 49:
|
|
1172
|
-
/***/ (function(module, exports) {
|
|
1173
|
-
|
|
1174
|
-
module.exports = require("@splunk/visualizations-shared/colorConstants");
|
|
1175
|
-
|
|
1176
|
-
/***/ }),
|
|
1177
|
-
|
|
1178
|
-
/***/ 54:
|
|
1179
|
-
/***/ (function(module, exports) {
|
|
1180
|
-
|
|
1181
|
-
module.exports = require("@splunk/visualizations-shared/domUtils");
|
|
1182
|
-
|
|
1183
|
-
/***/ }),
|
|
1184
|
-
|
|
1185
|
-
/***/ 7:
|
|
1186
|
-
/***/ (function(module, exports) {
|
|
1187
|
-
|
|
1188
|
-
module.exports = require("@babel/runtime/helpers/defineProperty");
|
|
1189
|
-
|
|
1190
|
-
/***/ }),
|
|
1191
|
-
|
|
1192
|
-
/***/ 81:
|
|
1193
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1194
|
-
|
|
1195
|
-
"use strict";
|
|
1196
|
-
// ESM COMPAT FLAG
|
|
1197
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1198
|
-
|
|
1199
|
-
// EXPORTS
|
|
1200
|
-
__webpack_require__.d(__webpack_exports__, "SingleValueTrendValue", function() { return /* binding */ SingleValueTrendValue; });
|
|
1201
|
-
|
|
1202
|
-
// EXTERNAL MODULE: external "@babel/runtime/helpers/extends"
|
|
1203
|
-
var extends_ = __webpack_require__(48);
|
|
1204
|
-
var extends_default = /*#__PURE__*/__webpack_require__.n(extends_);
|
|
1205
|
-
|
|
1206
|
-
// EXTERNAL MODULE: external "react"
|
|
1207
|
-
var external_react_ = __webpack_require__(1);
|
|
1208
|
-
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
1209
|
-
|
|
1210
|
-
// EXTERNAL MODULE: external "prop-types"
|
|
1211
|
-
var external_prop_types_ = __webpack_require__(0);
|
|
1212
|
-
var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_);
|
|
1213
|
-
|
|
1214
|
-
// EXTERNAL MODULE: external "styled-components"
|
|
1215
|
-
var external_styled_components_ = __webpack_require__(4);
|
|
1216
|
-
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
1124
|
+
var computeSingleValueContent = function computeSingleValueContent(_ref13) {
|
|
1125
|
+
var contentWidth = _ref13.contentWidth,
|
|
1126
|
+
contentHeight = _ref13.contentHeight,
|
|
1127
|
+
containerWidth = _ref13.containerWidth,
|
|
1128
|
+
containerHeight = _ref13.containerHeight,
|
|
1129
|
+
majorValue = _ref13.majorValue,
|
|
1130
|
+
trendValue = _ref13.trendValue,
|
|
1131
|
+
majorFontSize = _ref13.majorFontSize,
|
|
1132
|
+
trendFontSize = _ref13.trendFontSize,
|
|
1133
|
+
trendDisplay = _ref13.trendDisplay,
|
|
1134
|
+
unit = _ref13.unit,
|
|
1135
|
+
numberPrecision = _ref13.numberPrecision,
|
|
1136
|
+
shouldUseThousandSeparators = _ref13.shouldUseThousandSeparators,
|
|
1137
|
+
shouldAbbreviateTrendValue = _ref13.shouldAbbreviateTrendValue,
|
|
1138
|
+
toRemoveList = _ref13.toRemoveList;
|
|
1217
1139
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1140
|
+
var _getMajorAndTrend = getMajorAndTrend({
|
|
1141
|
+
majorValue: majorValue,
|
|
1142
|
+
trendValue: trendValue,
|
|
1143
|
+
majorFontSize: majorFontSize,
|
|
1144
|
+
trendFontSize: trendFontSize,
|
|
1145
|
+
trendDisplay: trendDisplay,
|
|
1146
|
+
width: contentWidth,
|
|
1147
|
+
height: contentHeight,
|
|
1148
|
+
unit: unit,
|
|
1149
|
+
numberPrecision: numberPrecision,
|
|
1150
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
1151
|
+
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
1152
|
+
}),
|
|
1153
|
+
majorText = _getMajorAndTrend.majorText,
|
|
1154
|
+
trendText = _getMajorAndTrend.trendText,
|
|
1155
|
+
majorTextFontSize = _getMajorAndTrend.majorTextFontSize,
|
|
1156
|
+
trendTextFontSize = _getMajorAndTrend.trendTextFontSize;
|
|
1220
1157
|
|
|
1221
|
-
|
|
1222
|
-
var
|
|
1223
|
-
|
|
1158
|
+
var majorValueTitle = majorText;
|
|
1159
|
+
var smallVizProps = {}; // update viz in small space
|
|
1160
|
+
// if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit
|
|
1161
|
+
// or truncate major value to make the major font size >= 12
|
|
1224
1162
|
|
|
1225
|
-
|
|
1226
|
-
var
|
|
1227
|
-
|
|
1163
|
+
if (majorTextFontSize < 12) {
|
|
1164
|
+
var _updateVizInSmallSpac = updateVizInSmallSpace({
|
|
1165
|
+
width: containerWidth,
|
|
1166
|
+
height: containerHeight,
|
|
1167
|
+
toRemoveList: toRemoveList,
|
|
1168
|
+
majorValue: majorValue,
|
|
1169
|
+
trendValue: trendValue,
|
|
1170
|
+
majorFontSize: majorFontSize,
|
|
1171
|
+
trendFontSize: trendFontSize,
|
|
1172
|
+
majorTextFontSize: majorTextFontSize,
|
|
1173
|
+
unit: unit,
|
|
1174
|
+
numberPrecision: numberPrecision,
|
|
1175
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
1176
|
+
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
1177
|
+
}),
|
|
1178
|
+
newMajorAndTrend = _updateVizInSmallSpac.newMajorAndTrend,
|
|
1179
|
+
updatedProps = _updateVizInSmallSpac.updatedProps;
|
|
1228
1180
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1181
|
+
majorText = newMajorAndTrend.majorText;
|
|
1182
|
+
trendText = newMajorAndTrend.trendText;
|
|
1183
|
+
majorTextFontSize = newMajorAndTrend.majorTextFontSize;
|
|
1184
|
+
trendTextFontSize = newMajorAndTrend.trendTextFontSize;
|
|
1185
|
+
smallVizProps = updatedProps;
|
|
1186
|
+
}
|
|
1231
1187
|
|
|
1232
|
-
|
|
1188
|
+
return {
|
|
1189
|
+
majorText: majorText,
|
|
1190
|
+
trendText: trendText,
|
|
1191
|
+
majorTextFontSize: majorTextFontSize,
|
|
1192
|
+
trendTextFontSize: trendTextFontSize,
|
|
1193
|
+
majorValueTitle: majorValueTitle,
|
|
1194
|
+
smallVizProps: smallVizProps
|
|
1195
|
+
};
|
|
1196
|
+
};
|
|
1197
|
+
var minimallyTruncateStringToWidth = function minimallyTruncateStringToWidth(_ref14) {
|
|
1198
|
+
var text = _ref14.text,
|
|
1199
|
+
_ref14$fontSize = _ref14.fontSize,
|
|
1200
|
+
fontSize = _ref14$fontSize === void 0 ? DEFAULT_FONT : _ref14$fontSize,
|
|
1201
|
+
_ref14$fontFamily = _ref14.fontFamily,
|
|
1202
|
+
fontFamily = _ref14$fontFamily === void 0 ? DEFAULT_FONT_FAMILY : _ref14$fontFamily,
|
|
1203
|
+
_ref14$fontWeight = _ref14.fontWeight,
|
|
1204
|
+
fontWeight = _ref14$fontWeight === void 0 ? 'normal' : _ref14$fontWeight,
|
|
1205
|
+
containerWidth = _ref14.containerWidth;
|
|
1206
|
+
var textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(text, "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily));
|
|
1207
|
+
var modifiedText = text;
|
|
1208
|
+
var ellipsesLength = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])('...', "".concat(fontWeight, " ").concat(fontSize, "px ").concat(fontFamily)); // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.
|
|
1233
1209
|
|
|
1210
|
+
if (containerWidth - ellipsesLength > 0 && textWidth > containerWidth) {
|
|
1211
|
+
// Truncates the content such that the truncated value + ellipses fit within the allocated space for the ellipses.
|
|
1212
|
+
// `textWidth > containerWidth - ellipsesLength` condition checks if text + ellipses exceeds container width.
|
|
1213
|
+
// `text.length > 1` condition included to keep at least the first number.
|
|
1214
|
+
while (textWidth + ellipsesLength > containerWidth && modifiedText.length > 1) {
|
|
1215
|
+
modifiedText = modifiedText.substring(0, modifiedText.length - 1);
|
|
1216
|
+
textWidth = Object(_splunk_visualizations_shared_domUtils__WEBPACK_IMPORTED_MODULE_3__["computeTextSize"])(modifiedText, "normal ".concat(fontSize, "px ").concat(fontFamily));
|
|
1217
|
+
}
|
|
1234
1218
|
|
|
1219
|
+
modifiedText = "".concat(modifiedText, "...");
|
|
1220
|
+
}
|
|
1235
1221
|
|
|
1222
|
+
return modifiedText;
|
|
1223
|
+
};
|
|
1224
|
+
/*
|
|
1225
|
+
* @method computeSingleValueRadialContent
|
|
1226
|
+
* @param {Object} props
|
|
1227
|
+
* @param {Number} props.contentWidth
|
|
1228
|
+
* @param {Number} props.contentHeight
|
|
1229
|
+
* @param {Number} props.containerWidth
|
|
1230
|
+
* @param {Number} props.containerHeight
|
|
1231
|
+
* @param {Number} props.majorValue // Major value
|
|
1232
|
+
* @param {Number} props.trendValue // Trend value
|
|
1233
|
+
* @param {Number} props.majorFontSize
|
|
1234
|
+
* @param {Number} props.trendFontSize
|
|
1235
|
+
* @param {String} props.trendDisplay
|
|
1236
|
+
* @param {String} props.unit // Unit for the value
|
|
1237
|
+
* @param {Number} props.numberPrecision
|
|
1238
|
+
* @param {Bool} props.shouldUseThousandSeparators
|
|
1239
|
+
* @param {Bool} props.shouldAbbreviateTrendValue
|
|
1240
|
+
* @param {Object} props.toRemoveList
|
|
1241
|
+
* @param {Bool} props.smallViz
|
|
1242
|
+
* @returns {Object} results
|
|
1243
|
+
* @returns {String} results.majorText
|
|
1244
|
+
* @returns {String} results.trendText
|
|
1245
|
+
* @returns {Number} results.majorTextFontSize
|
|
1246
|
+
* @returns {Number} results.trendTextFontSize
|
|
1247
|
+
* @returns {String} results.majorValueTitle
|
|
1248
|
+
* @returns {Object} results.smallVizProps
|
|
1249
|
+
*/
|
|
1236
1250
|
|
|
1251
|
+
var computeSingleValueRadialContent = function computeSingleValueRadialContent(_ref15) {
|
|
1252
|
+
var contentWidth = _ref15.contentWidth,
|
|
1253
|
+
contentHeight = _ref15.contentHeight,
|
|
1254
|
+
containerWidth = _ref15.containerWidth,
|
|
1255
|
+
containerHeight = _ref15.containerHeight,
|
|
1256
|
+
majorValue = _ref15.majorValue,
|
|
1257
|
+
trendValue = _ref15.trendValue,
|
|
1258
|
+
majorFontSize = _ref15.majorFontSize,
|
|
1259
|
+
trendFontSize = _ref15.trendFontSize,
|
|
1260
|
+
trendDisplay = _ref15.trendDisplay,
|
|
1261
|
+
unit = _ref15.unit,
|
|
1262
|
+
numberPrecision = _ref15.numberPrecision,
|
|
1263
|
+
shouldUseThousandSeparators = _ref15.shouldUseThousandSeparators,
|
|
1264
|
+
shouldAbbreviateTrendValue = _ref15.shouldAbbreviateTrendValue,
|
|
1265
|
+
smallViz = _ref15.smallViz;
|
|
1237
1266
|
|
|
1267
|
+
var _getMajorAndTrend2 = getMajorAndTrend({
|
|
1268
|
+
majorValue: majorValue,
|
|
1269
|
+
trendValue: trendValue,
|
|
1270
|
+
majorFontSize: majorFontSize,
|
|
1271
|
+
trendFontSize: trendFontSize,
|
|
1272
|
+
trendDisplay: trendDisplay,
|
|
1273
|
+
width: contentWidth,
|
|
1274
|
+
height: contentHeight,
|
|
1275
|
+
unit: unit,
|
|
1276
|
+
numberPrecision: numberPrecision,
|
|
1277
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
1278
|
+
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
1279
|
+
}),
|
|
1280
|
+
majorText = _getMajorAndTrend2.majorText,
|
|
1281
|
+
trendText = _getMajorAndTrend2.trendText,
|
|
1282
|
+
majorTextFontSize = _getMajorAndTrend2.majorTextFontSize,
|
|
1283
|
+
trendTextFontSize = _getMajorAndTrend2.trendTextFontSize;
|
|
1238
1284
|
|
|
1285
|
+
var majorValueTitle = majorText;
|
|
1286
|
+
var smallVizProps = {}; // custom logic for viz in small space
|
|
1287
|
+
// if not showing the radial graph (if `smallViz` is true), then compute truncated major value
|
|
1288
|
+
// and font sizes
|
|
1239
1289
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
}, function (props) {
|
|
1248
|
-
return props.size ? "margin: 0 ".concat(parseInt(props.size, 10) * 0.2 || 5, "px;") : '';
|
|
1249
|
-
});
|
|
1250
|
-
var Text = external_styled_components_default.a.div.withConfig({
|
|
1251
|
-
displayName: "TrendValue__Text",
|
|
1252
|
-
componentId: "yd2lvy-1"
|
|
1253
|
-
})(["white-space:nowrap;font-size:", "px;color:", ";font-family:", ";height:", "px;line-height:", "px;display:flex;align-self:baseline;", ";"], function (props) {
|
|
1254
|
-
return props.size || 12;
|
|
1255
|
-
}, function (props) {
|
|
1256
|
-
return props.color || '#000';
|
|
1257
|
-
}, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
|
|
1258
|
-
return props.size || 12;
|
|
1259
|
-
}, function (props) {
|
|
1260
|
-
return props.size || 12;
|
|
1261
|
-
}, function (props) {
|
|
1262
|
-
return props.size ? "margin-left: ".concat(parseInt(props.size, 10) * 0.2 || 5, "px;") : '';
|
|
1263
|
-
});
|
|
1290
|
+
if (smallViz) {
|
|
1291
|
+
var truncateValue = minimallyTruncateStringToWidth({
|
|
1292
|
+
text: majorValue,
|
|
1293
|
+
fontWeight: 'bold',
|
|
1294
|
+
fontSize: 12,
|
|
1295
|
+
containerWidth: containerWidth
|
|
1296
|
+
});
|
|
1264
1297
|
|
|
1265
|
-
var
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1298
|
+
var _getMajorAndTrend3 = getMajorAndTrend({
|
|
1299
|
+
majorValue: truncateValue,
|
|
1300
|
+
trendValue: trendValue,
|
|
1301
|
+
majorFontSize: majorFontSize,
|
|
1302
|
+
trendFontSize: trendFontSize,
|
|
1303
|
+
width: containerWidth,
|
|
1304
|
+
height: containerHeight,
|
|
1305
|
+
unit: unit,
|
|
1306
|
+
trendDisplay: trendDisplay,
|
|
1307
|
+
numberPrecision: numberPrecision,
|
|
1308
|
+
shouldUseThousandSeparators: shouldUseThousandSeparators,
|
|
1309
|
+
shouldAbbreviateTrendValue: shouldAbbreviateTrendValue
|
|
1310
|
+
});
|
|
1272
1311
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1312
|
+
majorText = _getMajorAndTrend3.majorText;
|
|
1313
|
+
trendText = _getMajorAndTrend3.trendText;
|
|
1314
|
+
majorTextFontSize = _getMajorAndTrend3.majorTextFontSize;
|
|
1315
|
+
trendTextFontSize = _getMajorAndTrend3.trendTextFontSize;
|
|
1316
|
+
smallVizProps = {
|
|
1317
|
+
trendDisplay: trendDisplay,
|
|
1318
|
+
unit: unit
|
|
1319
|
+
};
|
|
1279
1320
|
}
|
|
1280
1321
|
|
|
1281
|
-
return
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1289
|
-
"aria-label": ariaLabel
|
|
1290
|
-
})), /*#__PURE__*/external_react_default.a.createElement(Text, {
|
|
1291
|
-
"data-test": "trendValue",
|
|
1292
|
-
size: fontSize,
|
|
1293
|
-
color: color
|
|
1294
|
-
}, "".concat(text)));
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
|
-
TrendValue_SingleValueContent.propTypes = {
|
|
1298
|
-
fontSize: external_prop_types_default.a.number,
|
|
1299
|
-
color: external_prop_types_default.a.string,
|
|
1300
|
-
value: external_prop_types_default.a.oneOfType([external_prop_types_default.a.string, external_prop_types_default.a.number]),
|
|
1301
|
-
text: external_prop_types_default.a.string
|
|
1322
|
+
return {
|
|
1323
|
+
majorText: majorText,
|
|
1324
|
+
trendText: trendText,
|
|
1325
|
+
majorTextFontSize: majorTextFontSize,
|
|
1326
|
+
trendTextFontSize: trendTextFontSize,
|
|
1327
|
+
majorValueTitle: majorValueTitle,
|
|
1328
|
+
smallVizProps: smallVizProps
|
|
1329
|
+
};
|
|
1302
1330
|
};
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
//
|
|
1309
|
-
|
|
1331
|
+
/**
|
|
1332
|
+
* Get the colors for a graph
|
|
1333
|
+
*
|
|
1334
|
+
* @method getGraphColors
|
|
1335
|
+
* @param {Object} options
|
|
1336
|
+
* @param {Bool} options.backgroundEnabled // Flag to turn on color mode
|
|
1337
|
+
* @param {String} options.backgroundColor // The current background color, overrides trend background color
|
|
1338
|
+
* @param {Object} options.defaultColors // Default colors by severity
|
|
1339
|
+
* @param {Function} options.customColorFormatter // must return { background, stroke } given a color
|
|
1340
|
+
* @returns {Object} { background, stroke } colors
|
|
1341
|
+
* @private
|
|
1342
|
+
*/
|
|
1310
1343
|
|
|
1344
|
+
var getGraphColors = function getGraphColors(_ref16) {
|
|
1345
|
+
var backgroundEnabled = _ref16.backgroundEnabled,
|
|
1346
|
+
backgroundColor = _ref16.backgroundColor,
|
|
1347
|
+
defaultColors = _ref16.defaultColors,
|
|
1348
|
+
customColorFormatter = _ref16.customColorFormatter; // Only do custom colors in block mode
|
|
1311
1349
|
|
|
1350
|
+
if (backgroundEnabled) {
|
|
1351
|
+
// Check if the user defined colors to use
|
|
1352
|
+
if (backgroundColor && typeof customColorFormatter === 'function') {
|
|
1353
|
+
return customColorFormatter(backgroundColor);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1312
1356
|
|
|
1357
|
+
return defaultColors.none;
|
|
1358
|
+
};
|
|
1359
|
+
/**
|
|
1360
|
+
* Adjust rgb value if it equals to 0 or 255
|
|
1361
|
+
* @method adjustRGB
|
|
1362
|
+
* @param {Number} rgb [0 - 255]
|
|
1363
|
+
* @param {Number} delta
|
|
1364
|
+
* @returns {Number} adjusted rgb
|
|
1365
|
+
* @private
|
|
1366
|
+
*/
|
|
1313
1367
|
|
|
1314
|
-
var
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
})(["display:flex;flex-direction:row;align-items:flex-end;justify-content:left;height:", "px;line-height:", "px;"], function (props) {
|
|
1318
|
-
return props.size;
|
|
1319
|
-
}, function (props) {
|
|
1320
|
-
return props.size;
|
|
1321
|
-
});
|
|
1322
|
-
var MajorValue_Text = external_styled_components_default.a.div.withConfig({
|
|
1323
|
-
displayName: "MajorValue__Text",
|
|
1324
|
-
componentId: "shlzpv-1"
|
|
1325
|
-
})(["white-space:nowrap;height:100%;font-size:", "px;color:", ";font-family:", ";font-weight:bold;&:hover{text-decoration:", ";cursor:", ";}", ""], function (props) {
|
|
1326
|
-
return props.size || 12;
|
|
1327
|
-
}, function (props) {
|
|
1328
|
-
return props.color;
|
|
1329
|
-
}, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
|
|
1330
|
-
return props.showUnderline ? 'underline' : 'inherit';
|
|
1331
|
-
}, function (props) {
|
|
1332
|
-
return props.showUnderline ? 'pointer' : 'inherit';
|
|
1333
|
-
}, function (props) {
|
|
1334
|
-
if (!props.pseudoContent || !props.pseudoContentPosition) {
|
|
1335
|
-
return '';
|
|
1368
|
+
var adjustRGB = function adjustRGB(rgb, delta) {
|
|
1369
|
+
if (rgb === 255) {
|
|
1370
|
+
return rgb - delta;
|
|
1336
1371
|
}
|
|
1337
1372
|
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1373
|
+
if (rgb === 0) {
|
|
1374
|
+
return rgb + delta;
|
|
1375
|
+
}
|
|
1341
1376
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1377
|
+
return rgb;
|
|
1378
|
+
};
|
|
1379
|
+
/**
|
|
1380
|
+
* Modifies colors by multiplying by a given ratio
|
|
1381
|
+
* @method changeColor
|
|
1382
|
+
* @param {String} color // Color to modify
|
|
1383
|
+
* @param {Number} ratio // Float to modify color
|
|
1384
|
+
* @returns {String} new color
|
|
1385
|
+
* @private
|
|
1386
|
+
*/
|
|
1352
1387
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1388
|
+
var changeColor = function changeColor(color, ratio) {
|
|
1389
|
+
var hex = color.replace(/(0x|#)/, '');
|
|
1390
|
+
var r = parseInt(hex.substr(0, 2), 16);
|
|
1391
|
+
var g = parseInt(hex.substr(2, 2), 16);
|
|
1392
|
+
var b = parseInt(hex.substr(4, 2), 16); // Multiply by given ratio, make sure is between 0 and 255;
|
|
1358
1393
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1394
|
+
var newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
|
|
1395
|
+
var newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
|
|
1396
|
+
var newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0); // If the color is not changed
|
|
1397
|
+
// case 1: the color is (0, 0 0)
|
|
1398
|
+
// lighten color (80, 80, 80)
|
|
1399
|
+
// darken color (40, 40, 40)
|
|
1400
|
+
// case 2: the color is (255, 255, 255)
|
|
1401
|
+
// lighten color (235, 235, 235)
|
|
1402
|
+
// darken color (175, 175, 175)
|
|
1403
|
+
// case 3: the color is e.g. (0, 255, 0)
|
|
1404
|
+
// new color (20, 235, 20)
|
|
1405
|
+
|
|
1406
|
+
if (newR === r && newG === g && newB === b) {
|
|
1407
|
+
if (newR === 0 && newG === 0 && newB === 0) {
|
|
1408
|
+
if (ratio > 1) {
|
|
1409
|
+
newR = adjustRGB(newR, 80);
|
|
1410
|
+
newG = adjustRGB(newG, 80);
|
|
1411
|
+
newB = adjustRGB(newB, 80);
|
|
1412
|
+
} else {
|
|
1413
|
+
newR = adjustRGB(newR, 40);
|
|
1414
|
+
newG = adjustRGB(newG, 40);
|
|
1415
|
+
newB = adjustRGB(newB, 40);
|
|
1416
|
+
}
|
|
1417
|
+
} else if (newR === 255 && newG === 255 && newB === 255) {
|
|
1418
|
+
if (ratio > 1) {
|
|
1419
|
+
newR = adjustRGB(newR, 20);
|
|
1420
|
+
newG = adjustRGB(newG, 20);
|
|
1421
|
+
newB = adjustRGB(newB, 20);
|
|
1422
|
+
} else {
|
|
1423
|
+
newR = adjustRGB(newR, 80);
|
|
1424
|
+
newG = adjustRGB(newG, 80);
|
|
1425
|
+
newB = adjustRGB(newB, 80);
|
|
1426
|
+
}
|
|
1361
1427
|
} else {
|
|
1362
|
-
|
|
1428
|
+
newR = adjustRGB(newR, 20);
|
|
1429
|
+
newG = adjustRGB(newG, 20);
|
|
1430
|
+
newB = adjustRGB(newB, 20);
|
|
1363
1431
|
}
|
|
1364
1432
|
}
|
|
1365
1433
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1434
|
+
return "#".concat(newR.toString(16).padStart(2, 0)) + "".concat(newG.toString(16).padStart(2, 0)) + "".concat(newB.toString(16).padStart(2, 0));
|
|
1435
|
+
};
|
|
1436
|
+
/**
|
|
1437
|
+
* Lighten a given color
|
|
1438
|
+
* @method lighten
|
|
1439
|
+
* @param {String} color
|
|
1440
|
+
* @returns {String}
|
|
1441
|
+
* @private
|
|
1442
|
+
*/
|
|
1370
1443
|
|
|
1371
|
-
e.preventDefault();
|
|
1372
|
-
onValueClick(e);
|
|
1373
|
-
};
|
|
1374
1444
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}, /*#__PURE__*/external_react_default.a.createElement(MajorValue_Text, {
|
|
1378
|
-
"data-test": "majorValue",
|
|
1379
|
-
color: color,
|
|
1380
|
-
onClick: function onClick(e) {
|
|
1381
|
-
return typeof onValueClick === 'function' && onValueClick(e);
|
|
1382
|
-
},
|
|
1383
|
-
showUnderline: !!onValueClick,
|
|
1384
|
-
size: fontSize,
|
|
1385
|
-
title: title,
|
|
1386
|
-
pseudoContent: sanitizedUnit,
|
|
1387
|
-
pseudoContentPosition: sanitizedUnitPosition,
|
|
1388
|
-
pseudoContentFontSize: fontSize * 0.6,
|
|
1389
|
-
tabIndex: "0",
|
|
1390
|
-
role: "button",
|
|
1391
|
-
onKeyDown: handleKeyDown
|
|
1392
|
-
}, value));
|
|
1445
|
+
var lighten = function lighten(color) {
|
|
1446
|
+
return changeColor(color, 1.3);
|
|
1393
1447
|
};
|
|
1448
|
+
/**
|
|
1449
|
+
* Darkens a given color
|
|
1450
|
+
* @method darken
|
|
1451
|
+
* @param {String} color
|
|
1452
|
+
* @returns {String}
|
|
1453
|
+
* @private
|
|
1454
|
+
*/
|
|
1394
1455
|
|
|
1395
|
-
|
|
1396
|
-
color
|
|
1397
|
-
fontSize: external_prop_types_default.a.number,
|
|
1398
|
-
unit: external_prop_types_default.a.string,
|
|
1399
|
-
unitPosition: external_prop_types_default.a.oneOf(validUnitPositions),
|
|
1400
|
-
value: external_prop_types_default.a.oneOfType([external_prop_types_default.a.string, external_prop_types_default.a.number]),
|
|
1401
|
-
title: external_prop_types_default.a.oneOfType([external_prop_types_default.a.string, external_prop_types_default.a.number]),
|
|
1402
|
-
onValueClick: external_prop_types_default.a.oneOfType([external_prop_types_default.a.bool, external_prop_types_default.a.func])
|
|
1456
|
+
var darken = function darken(color) {
|
|
1457
|
+
return changeColor(color, 0.5);
|
|
1403
1458
|
};
|
|
1404
|
-
|
|
1405
|
-
|
|
1459
|
+
/** consistent token structure: handle callback to add value and name in event payload
|
|
1460
|
+
* @method handleValueClickCallback
|
|
1461
|
+
* @param {Object} ev
|
|
1462
|
+
* @param {String | Number} majorValue
|
|
1463
|
+
* @param {String} majorValueField
|
|
1464
|
+
* @param {Number} trendValue
|
|
1465
|
+
* @param {Function} onValueClick
|
|
1466
|
+
*/
|
|
1406
1467
|
|
|
1468
|
+
var handleValueClickCallback = function handleValueClickCallback(ev, majorValue, majorValueField, trendValue, onValueClick) {
|
|
1469
|
+
var trellisEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
1470
|
+
var trellisSplityBy = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
|
|
1471
|
+
var trellisKey = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : '';
|
|
1472
|
+
var payload = {
|
|
1473
|
+
trendValue: trendValue,
|
|
1474
|
+
value: majorValue,
|
|
1475
|
+
name: majorValueField
|
|
1476
|
+
};
|
|
1407
1477
|
|
|
1478
|
+
if (trellisEnabled) {
|
|
1479
|
+
payload = _objectSpread(_objectSpread({}, payload), {}, {
|
|
1480
|
+
'trellis.name': trellisSplityBy,
|
|
1481
|
+
'trellis.value': trellisKey
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1408
1484
|
|
|
1485
|
+
return onValueClick(_objectSpread(_objectSpread({}, ev), {}, {
|
|
1486
|
+
payload: payload
|
|
1487
|
+
}));
|
|
1488
|
+
};
|
|
1409
1489
|
|
|
1490
|
+
/***/ }),
|
|
1410
1491
|
|
|
1492
|
+
/***/ 3:
|
|
1493
|
+
/***/ (function(module, exports) {
|
|
1411
1494
|
|
|
1495
|
+
module.exports = require("lodash");
|
|
1412
1496
|
|
|
1413
|
-
|
|
1414
|
-
displayName: "SingleValueBasic__Column",
|
|
1415
|
-
componentId: "k0nwrx-0"
|
|
1416
|
-
})(["display:flex;flex-direction:column;align-self:center;justify-content:center;"]);
|
|
1417
|
-
var SingleValueBasic_Row = external_styled_components_default.a.div.withConfig({
|
|
1418
|
-
displayName: "SingleValueBasic__Row",
|
|
1419
|
-
componentId: "k0nwrx-1"
|
|
1420
|
-
})(["display:flex;flex-direction:row;align-items:", ";justify-content:center;"], function (props) {
|
|
1421
|
-
return props.align || 'center';
|
|
1422
|
-
});
|
|
1423
|
-
var SingleValueBasic_Text = external_styled_components_default.a.div.withConfig({
|
|
1424
|
-
displayName: "SingleValueBasic__Text",
|
|
1425
|
-
componentId: "k0nwrx-2"
|
|
1426
|
-
})(["font-weight:normal;white-space:nowrap;font-size:", "px;color:", ";font-family:", ";height:", "px;line-height:1.2;"], function (props) {
|
|
1427
|
-
return props.size || 12;
|
|
1428
|
-
}, function (props) {
|
|
1429
|
-
return props.color || '#000';
|
|
1430
|
-
}, singleValueUtils["DEFAULT_FONT_FAMILY"], function (props) {
|
|
1431
|
-
return props.size || 12;
|
|
1432
|
-
});
|
|
1497
|
+
/***/ }),
|
|
1433
1498
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1499
|
+
/***/ 36:
|
|
1500
|
+
/***/ (function(module, exports) {
|
|
1436
1501
|
|
|
1437
|
-
|
|
1438
|
-
majorTextFontSize = props.majorTextFontSize,
|
|
1439
|
-
majorText = props.majorText,
|
|
1440
|
-
majorValueTitle = props.majorValueTitle,
|
|
1441
|
-
trendColor = props.trendColor,
|
|
1442
|
-
trendTextFontSize = props.trendTextFontSize,
|
|
1443
|
-
trendText = props.trendText,
|
|
1444
|
-
showTrendIndicator = props.showTrendIndicator,
|
|
1445
|
-
unit = props.unit,
|
|
1446
|
-
unitPosition = props.unitPosition,
|
|
1447
|
-
underLabel = props.underLabel,
|
|
1448
|
-
underLabelFontSize = props.underLabelFontSize,
|
|
1449
|
-
underLabelColor = props.underLabelColor,
|
|
1450
|
-
onValueClick = props.onValueClick;
|
|
1451
|
-
var trendIndicatorEnabled = trendText !== '' && showTrendIndicator;
|
|
1452
|
-
return /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Column, null, /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Row, {
|
|
1453
|
-
align: "baseline"
|
|
1454
|
-
}, /*#__PURE__*/external_react_default.a.createElement(MajorValue, {
|
|
1455
|
-
"data-test": "MajorValue",
|
|
1456
|
-
color: majorColor,
|
|
1457
|
-
fontSize: majorTextFontSize,
|
|
1458
|
-
unit: unit,
|
|
1459
|
-
unitPosition: unitPosition,
|
|
1460
|
-
value: majorText,
|
|
1461
|
-
title: majorValueTitle,
|
|
1462
|
-
onValueClick: onValueClick
|
|
1463
|
-
}), trendIndicatorEnabled &&
|
|
1464
|
-
/*#__PURE__*/
|
|
1465
|
-
// Passing the same value for value and text is a temporary hold until completion of https://jira.splunk.com/browse/SCP-21371
|
|
1466
|
-
external_react_default.a.createElement(TrendValue, {
|
|
1467
|
-
"data-test": "TrendIndicator",
|
|
1468
|
-
fontSize: trendTextFontSize,
|
|
1469
|
-
color: trendColor,
|
|
1470
|
-
value: trendText,
|
|
1471
|
-
text: trendText
|
|
1472
|
-
})), underLabel && /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Row, {
|
|
1473
|
-
justify: "center"
|
|
1474
|
-
}, /*#__PURE__*/external_react_default.a.createElement(SingleValueBasic_Text, {
|
|
1475
|
-
"data-test": "underLabel",
|
|
1476
|
-
size: underLabelFontSize,
|
|
1477
|
-
color: underLabelColor
|
|
1478
|
-
}, underLabel)));
|
|
1479
|
-
};
|
|
1502
|
+
module.exports = require("@splunk/visualizations-shared/propUtils");
|
|
1480
1503
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
trendTextFontSize: external_prop_types_default.a.number,
|
|
1488
|
-
trendColor: external_prop_types_default.a.string,
|
|
1489
|
-
showTrendIndicator: external_prop_types_default.a.bool,
|
|
1490
|
-
unit: external_prop_types_default.a.string,
|
|
1491
|
-
unitPosition: external_prop_types_default.a.oneOf(['before', 'after']),
|
|
1492
|
-
underLabel: external_prop_types_default.a.string,
|
|
1493
|
-
underLabelFontSize: external_prop_types_default.a.number,
|
|
1494
|
-
underLabelColor: external_prop_types_default.a.string,
|
|
1495
|
-
onValueClick: external_prop_types_default.a.oneOfType([external_prop_types_default.a.bool, external_prop_types_default.a.func])
|
|
1496
|
-
};
|
|
1497
|
-
var SingleValueTrendValue = TrendValue;
|
|
1498
|
-
/* harmony default export */ var src_SingleValueBasic_SingleValueBasic = __webpack_exports__["default"] = (SingleValueBasic_SingleValueBasic);
|
|
1504
|
+
/***/ }),
|
|
1505
|
+
|
|
1506
|
+
/***/ 4:
|
|
1507
|
+
/***/ (function(module, exports) {
|
|
1508
|
+
|
|
1509
|
+
module.exports = require("styled-components");
|
|
1499
1510
|
|
|
1500
1511
|
/***/ }),
|
|
1501
1512
|
|
|
1502
|
-
/***/
|
|
1513
|
+
/***/ 70:
|
|
1503
1514
|
/***/ (function(module, exports) {
|
|
1504
1515
|
|
|
1505
|
-
module.exports = require("@
|
|
1516
|
+
module.exports = require("@babel/runtime/helpers/extends");
|
|
1506
1517
|
|
|
1507
1518
|
/***/ }),
|
|
1508
1519
|
|
|
1509
|
-
/***/
|
|
1520
|
+
/***/ 71:
|
|
1510
1521
|
/***/ (function(module, exports) {
|
|
1511
1522
|
|
|
1512
|
-
module.exports = require("@splunk/
|
|
1523
|
+
module.exports = require("@splunk/visualizations-shared/colorConstants");
|
|
1513
1524
|
|
|
1514
1525
|
/***/ }),
|
|
1515
1526
|
|
|
1516
|
-
/***/
|
|
1527
|
+
/***/ 76:
|
|
1517
1528
|
/***/ (function(module, exports) {
|
|
1518
1529
|
|
|
1519
|
-
module.exports = require("
|
|
1530
|
+
module.exports = require("@splunk/visualizations-shared/domUtils");
|
|
1531
|
+
|
|
1532
|
+
/***/ }),
|
|
1533
|
+
|
|
1534
|
+
/***/ 9:
|
|
1535
|
+
/***/ (function(module, exports) {
|
|
1536
|
+
|
|
1537
|
+
module.exports = require("@babel/runtime/helpers/defineProperty");
|
|
1520
1538
|
|
|
1521
1539
|
/***/ })
|
|
1522
1540
|
|