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