@splunk/visualizations 26.0.0 → 26.1.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 +103 -19
- package/Area.config.js.map +1 -1
- package/Area.js +646 -243
- package/Area.js.map +1 -1
- package/Bar.config.js +105 -21
- package/Bar.config.js.map +1 -1
- package/Bar.js +653 -237
- package/Bar.js.map +1 -1
- package/Bubble.config.js +95 -21
- package/Bubble.config.js.map +1 -1
- package/Bubble.js +635 -229
- package/Bubble.js.map +1 -1
- package/ChoroplethSvg.config.js +66 -15
- package/ChoroplethSvg.config.js.map +1 -1
- package/ChoroplethSvg.js +589 -211
- package/ChoroplethSvg.js.map +1 -1
- package/Column.config.js +104 -19
- package/Column.config.js.map +1 -1
- package/Column.js +666 -239
- package/Column.js.map +1 -1
- package/Ellipse.config.js +83 -18
- package/Ellipse.config.js.map +1 -1
- package/Ellipse.js +444 -156
- package/Ellipse.js.map +1 -1
- package/Events.config.js +101 -19
- package/Events.config.js.map +1 -1
- package/Events.js +792 -322
- package/Events.js.map +1 -1
- package/FillerGauge.config.js +97 -28
- package/FillerGauge.config.js.map +1 -1
- package/FillerGauge.js +786 -390
- package/FillerGauge.js.map +1 -1
- package/Image.config.js +63 -19
- package/Image.config.js.map +1 -1
- package/Image.js +439 -164
- package/Image.js.map +1 -1
- package/Line.config.js +107 -23
- package/Line.config.js.map +1 -1
- package/Line.js +841 -456
- package/Line.js.map +1 -1
- package/LinkGraph.config.js +73 -23
- package/LinkGraph.config.js.map +1 -1
- package/LinkGraph.js +653 -230
- package/LinkGraph.js.map +1 -1
- package/MIGRATION.md +1082 -0
- package/Map.config.js +244 -99
- package/Map.config.js.map +1 -1
- package/Map.js +1223 -612
- package/Map.js.map +1 -1
- package/Markdown.config.js +71 -21
- package/Markdown.config.js.map +1 -1
- package/Markdown.js +477 -202
- package/Markdown.js.map +1 -1
- package/MarkerGauge.config.js +80 -22
- package/MarkerGauge.config.js.map +1 -1
- package/MarkerGauge.js +819 -418
- package/MarkerGauge.js.map +1 -1
- package/ParallelCoordinates.config.js +73 -19
- package/ParallelCoordinates.config.js.map +1 -1
- package/ParallelCoordinates.js +870 -491
- package/ParallelCoordinates.js.map +1 -1
- package/Pie.config.js +76 -23
- package/Pie.config.js.map +1 -1
- package/Pie.js +643 -233
- package/Pie.js.map +1 -1
- package/Punchcard.config.js +82 -30
- package/Punchcard.config.js.map +1 -1
- package/Punchcard.js +863 -387
- package/Punchcard.js.map +1 -1
- package/Rectangle.config.js +86 -20
- package/Rectangle.config.js.map +1 -1
- package/Rectangle.js +449 -159
- package/Rectangle.js.map +1 -1
- package/Sankey.config.js +85 -23
- package/Sankey.config.js.map +1 -1
- package/Sankey.js +895 -349
- package/Sankey.js.map +1 -1
- package/Scatter.config.js +97 -23
- package/Scatter.config.js.map +1 -1
- package/Scatter.js +639 -234
- package/Scatter.js.map +1 -1
- package/SingleValue.config.js +95 -25
- package/SingleValue.config.js.map +1 -1
- package/SingleValue.js +1198 -656
- package/SingleValue.js.map +1 -1
- package/SingleValueBasic.js +287 -226
- package/SingleValueBasic.js.map +1 -1
- package/SingleValueIcon.config.js +93 -23
- package/SingleValueIcon.config.js.map +1 -1
- package/SingleValueIcon.js +991 -522
- package/SingleValueIcon.js.map +1 -1
- package/SingleValueRadial.config.js +100 -27
- package/SingleValueRadial.config.js.map +1 -1
- package/SingleValueRadial.js +1185 -624
- package/SingleValueRadial.js.map +1 -1
- package/SparkLine.js +127 -68
- package/SparkLine.js.map +1 -1
- package/Table.config.js +74 -21
- package/Table.config.js.map +1 -1
- package/Table.js +827 -329
- package/Table.js.map +1 -1
- package/common/Charting.js +152 -69
- package/common/Charting.js.map +1 -1
- package/common/ChartingApi.js +25 -14
- package/common/ChartingApi.js.map +1 -1
- package/common/DocExampleWithVizSandbox.js +530 -0
- package/common/DocExampleWithVizSandbox.js.map +1 -0
- package/common/EventsDoc.js +139 -104
- package/common/EventsDoc.js.map +1 -1
- package/common/GaugeMajorTicks.js +79 -69
- package/common/GaugeMajorTicks.js.map +1 -1
- package/common/GaugeValueMarker.js +54 -45
- package/common/GaugeValueMarker.js.map +1 -1
- package/common/OptionsDoc.js +178 -87
- package/common/OptionsDoc.js.map +1 -1
- package/common/OverviewDoc.js +530 -68
- package/common/OverviewDoc.js.map +1 -1
- package/common/SplunkVisualization.js +47 -20
- package/common/SplunkVisualization.js.map +1 -1
- package/common/SplunkVisualizationApi.js +15 -9
- package/common/SplunkVisualizationApi.js.map +1 -1
- package/common/ThemesDoc.js +57 -44
- package/common/ThemesDoc.js.map +1 -1
- package/common/chartingUtils.js +52 -20
- package/common/chartingUtils.js.map +1 -1
- package/common/docUtils.js +139 -7
- package/common/docUtils.js.map +1 -1
- package/common/gaugeUtils.js +185 -102
- package/common/gaugeUtils.js.map +1 -1
- package/common/shapeUtils.js +28 -16
- package/common/shapeUtils.js.map +1 -1
- package/common/utils/configUtils.js +50 -15
- package/common/utils/configUtils.js.map +1 -1
- package/common/utils/dataUtils.js +8 -3
- package/common/utils/dataUtils.js.map +1 -1
- package/common/utils/hocUtils.js +4 -2
- package/common/utils/hocUtils.js.map +1 -1
- package/common/utils/layoutUtils.js +2 -1
- package/common/utils/layoutUtils.js.map +1 -1
- package/common/utils/mapUtils.js +288 -128
- package/common/utils/mapUtils.js.map +1 -1
- package/common/utils/singleValueUtils.js +242 -197
- package/common/utils/singleValueUtils.js.map +1 -1
- package/common/utils/testHelper.js +10 -1
- package/common/utils/testHelper.js.map +1 -1
- package/common/utils/trellisUtils.js +62 -1
- package/common/utils/trellisUtils.js.map +1 -1
- package/common/utils/urlUtils.js +3 -1
- package/common/utils/urlUtils.js.map +1 -1
- package/common/withDashboardViz.js +389 -192
- package/common/withDashboardViz.js.map +1 -1
- package/package.json +18 -26
package/SparkLine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright ©
|
|
2
|
+
* Copyright © 2024 Splunk Inc.
|
|
3
3
|
* SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
|
|
4
4
|
* in part without a valid written license from Splunk Inc. is PROHIBITED.
|
|
5
5
|
*/
|
|
@@ -183,7 +183,7 @@ module.exports = require("@babel/runtime/helpers/possibleConstructorReturn");
|
|
|
183
183
|
|
|
184
184
|
/***/ }),
|
|
185
185
|
|
|
186
|
-
/***/
|
|
186
|
+
/***/ 88:
|
|
187
187
|
/***/ (function(module, exports) {
|
|
188
188
|
|
|
189
189
|
module.exports = require("@babel/runtime/helpers/assertThisInitialized");
|
|
@@ -208,7 +208,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
208
208
|
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
|
|
209
209
|
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18);
|
|
210
210
|
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);
|
|
211
|
-
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
211
|
+
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(88);
|
|
212
212
|
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3__);
|
|
213
213
|
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(71);
|
|
214
214
|
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__);
|
|
@@ -240,24 +240,31 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
240
240
|
|
|
241
241
|
|
|
242
242
|
|
|
243
|
+
|
|
243
244
|
function _createSuper(Derived) {
|
|
244
245
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
246
|
+
|
|
245
247
|
return function _createSuperInternal() {
|
|
246
248
|
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(Derived),
|
|
247
|
-
|
|
249
|
+
result;
|
|
250
|
+
|
|
248
251
|
if (hasNativeReflectConstruct) {
|
|
249
252
|
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(this).constructor;
|
|
253
|
+
|
|
250
254
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
251
255
|
} else {
|
|
252
256
|
result = Super.apply(this, arguments);
|
|
253
257
|
}
|
|
258
|
+
|
|
254
259
|
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default()(this, result);
|
|
255
260
|
};
|
|
256
261
|
}
|
|
262
|
+
|
|
257
263
|
function _isNativeReflectConstruct() {
|
|
258
264
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
259
265
|
if (Reflect.construct.sham) return false;
|
|
260
266
|
if (typeof Proxy === "function") return true;
|
|
267
|
+
|
|
261
268
|
try {
|
|
262
269
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
263
270
|
return true;
|
|
@@ -272,6 +279,7 @@ function _isNativeReflectConstruct() {
|
|
|
272
279
|
|
|
273
280
|
|
|
274
281
|
|
|
282
|
+
|
|
275
283
|
var StyledSvg = styled_components__WEBPACK_IMPORTED_MODULE_11___default.a.svg.withConfig({
|
|
276
284
|
displayName: "SparkLine__StyledSvg",
|
|
277
285
|
componentId: "sc-5oplra-0"
|
|
@@ -280,21 +288,29 @@ var StyledTooltip = styled_components__WEBPACK_IMPORTED_MODULE_11___default.a.di
|
|
|
280
288
|
displayName: "SparkLine__StyledTooltip",
|
|
281
289
|
componentId: "sc-5oplra-1"
|
|
282
290
|
})(["padding:3px 8px;font-size:12px;"]);
|
|
291
|
+
|
|
283
292
|
var SparkLine = /*#__PURE__*/function (_Component) {
|
|
284
293
|
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(SparkLine, _Component);
|
|
294
|
+
|
|
285
295
|
var _super = _createSuper(SparkLine);
|
|
296
|
+
|
|
286
297
|
function SparkLine(props) {
|
|
287
298
|
var _this;
|
|
299
|
+
|
|
288
300
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, SparkLine);
|
|
301
|
+
|
|
289
302
|
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
290
303
|
rest[_key - 1] = arguments[_key];
|
|
291
304
|
}
|
|
305
|
+
|
|
292
306
|
_this = _super.call.apply(_super, [this, props].concat(rest));
|
|
307
|
+
|
|
293
308
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3___default()(_this), "handleCursorMount", function (el) {
|
|
294
309
|
_this.setState({
|
|
295
310
|
anchor: el
|
|
296
311
|
});
|
|
297
312
|
});
|
|
313
|
+
|
|
298
314
|
_this.state = {
|
|
299
315
|
anchor: null,
|
|
300
316
|
currentPointX: null,
|
|
@@ -305,69 +321,75 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
305
321
|
_this.titleId = Object(_splunk_ui_utils_id__WEBPACK_IMPORTED_MODULE_14__["createDOMID"])();
|
|
306
322
|
return _this;
|
|
307
323
|
}
|
|
324
|
+
|
|
308
325
|
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(SparkLine, [{
|
|
309
326
|
key: "getMax",
|
|
310
327
|
value: function getMax() {
|
|
311
328
|
var _this2 = this;
|
|
329
|
+
|
|
312
330
|
var _this$props = this.props,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
331
|
+
data = _this$props.data,
|
|
332
|
+
acceptNull = _this$props.acceptNull,
|
|
333
|
+
yMax = _this$props.yMax;
|
|
334
|
+
|
|
316
335
|
var dataMax = function dataMax() {
|
|
317
336
|
return acceptNull ? Object(lodash__WEBPACK_IMPORTED_MODULE_10__["max"])(_this2.fillNull(data)) : Object(lodash__WEBPACK_IMPORTED_MODULE_10__["max"])(data);
|
|
318
337
|
};
|
|
338
|
+
|
|
319
339
|
return yMax !== undefined ? yMax : dataMax();
|
|
320
340
|
}
|
|
321
341
|
}, {
|
|
322
342
|
key: "getMin",
|
|
323
343
|
value: function getMin() {
|
|
324
344
|
var _this3 = this;
|
|
345
|
+
|
|
325
346
|
var _this$props2 = this.props,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
347
|
+
data = _this$props2.data,
|
|
348
|
+
acceptNull = _this$props2.acceptNull,
|
|
349
|
+
yMin = _this$props2.yMin;
|
|
350
|
+
|
|
329
351
|
var dataMin = function dataMin() {
|
|
330
352
|
return acceptNull ? Object(lodash__WEBPACK_IMPORTED_MODULE_10__["min"])(_this3.fillNull(data)) : Object(lodash__WEBPACK_IMPORTED_MODULE_10__["min"])(data);
|
|
331
353
|
};
|
|
354
|
+
|
|
332
355
|
return yMin !== undefined ? yMin : dataMin();
|
|
333
356
|
}
|
|
334
|
-
|
|
335
357
|
/**
|
|
336
358
|
* Gets unit value of x axis.
|
|
337
359
|
* @param {Number} xMargin - margin of x axis.
|
|
338
360
|
* @return {Number} unit value of x axis.
|
|
339
361
|
* @private
|
|
340
362
|
*/
|
|
363
|
+
|
|
341
364
|
}, {
|
|
342
365
|
key: "getXUnit",
|
|
343
366
|
value: function getXUnit(xMargin) {
|
|
344
367
|
var _this$props3 = this.props,
|
|
345
|
-
|
|
346
|
-
|
|
368
|
+
data = _this$props3.data,
|
|
369
|
+
width = _this$props3.width; // Calculate xUnit. Width substract the left margin and right margin, then divide by data length.
|
|
370
|
+
|
|
347
371
|
var xUnit = (width - xMargin * 2) / (data.length > 1 ? data.length - 1 : 1);
|
|
348
372
|
return Math.max(0, xUnit);
|
|
349
373
|
}
|
|
350
|
-
|
|
351
374
|
/**
|
|
352
375
|
* Gets unit value of y axis.
|
|
353
376
|
* @param {String} yMargin - margin of y axis.
|
|
354
377
|
* @return {Number} unit value of y axis.
|
|
355
378
|
* @private
|
|
356
379
|
*/
|
|
380
|
+
|
|
357
381
|
}, {
|
|
358
382
|
key: "getYUnit",
|
|
359
383
|
value: function getYUnit(yMargin) {
|
|
360
384
|
var height = this.props.height;
|
|
361
385
|
var maxValue = this.getMax();
|
|
362
|
-
var minValue = this.getMin();
|
|
363
|
-
|
|
364
|
-
// Calculate yUnit. Height substract the upper margin and bottom margin, then divide by value range of values in data.
|
|
386
|
+
var minValue = this.getMin(); // Calculate yUnit. Height substract the upper margin and bottom margin, then divide by value range of values in data.
|
|
365
387
|
// if the maxValue equals minValue, means all values in data are the same, then, we need to set the YUnit at the mid value of Height.
|
|
366
388
|
// So, draws sparkline right in the mid of the container.
|
|
389
|
+
|
|
367
390
|
var yUnit = (height - yMargin * 2) / (maxValue - minValue || 2);
|
|
368
391
|
return Math.max(0, yUnit);
|
|
369
392
|
}
|
|
370
|
-
|
|
371
393
|
/**
|
|
372
394
|
* Get a list of arrays of points for drawing lines, based on acceptNull property
|
|
373
395
|
* @method getSegmentSets
|
|
@@ -375,6 +397,7 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
375
397
|
* @param {Array} points
|
|
376
398
|
* @returns {Array} List of datapoint sets used for drawing lines
|
|
377
399
|
*/
|
|
400
|
+
|
|
378
401
|
}, {
|
|
379
402
|
key: "getSegmentSets",
|
|
380
403
|
value: function getSegmentSets(data, points) {
|
|
@@ -387,19 +410,20 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
387
410
|
// need at least 2 points to draw a segment
|
|
388
411
|
if (currentLine.length > 1) {
|
|
389
412
|
lines.push(currentLine);
|
|
390
|
-
}
|
|
391
|
-
|
|
413
|
+
} // reset for the next segment
|
|
414
|
+
|
|
415
|
+
|
|
392
416
|
currentLine = [];
|
|
393
417
|
} else {
|
|
394
418
|
// data is good, add point data
|
|
395
419
|
currentLine.push(points[idx]);
|
|
396
420
|
}
|
|
397
|
-
});
|
|
421
|
+
}); // Add the last line
|
|
398
422
|
|
|
399
|
-
// Add the last line
|
|
400
423
|
if (currentLine.length > 1) {
|
|
401
424
|
lines.push(currentLine);
|
|
402
425
|
}
|
|
426
|
+
|
|
403
427
|
return lines;
|
|
404
428
|
}
|
|
405
429
|
}, {
|
|
@@ -415,7 +439,6 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
415
439
|
return value === null ? 0 : value;
|
|
416
440
|
});
|
|
417
441
|
}
|
|
418
|
-
|
|
419
442
|
/**
|
|
420
443
|
* Converts data to points in svg
|
|
421
444
|
* @param {Number} xMargin - margin of x axis.
|
|
@@ -423,6 +446,7 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
423
446
|
* @return {Array} points coordination.
|
|
424
447
|
* @private
|
|
425
448
|
*/
|
|
449
|
+
|
|
426
450
|
}, {
|
|
427
451
|
key: "dataToPoints",
|
|
428
452
|
value: function dataToPoints(xMargin, yMargin) {
|
|
@@ -440,7 +464,6 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
440
464
|
return [p.x, p.y];
|
|
441
465
|
});
|
|
442
466
|
}
|
|
443
|
-
|
|
444
467
|
/**
|
|
445
468
|
* Renders rect area for helping figure out which is the nearest point so that
|
|
446
469
|
* render related cursor and tooltip.
|
|
@@ -449,16 +472,20 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
449
472
|
* @return {Array} array of svg rect objects
|
|
450
473
|
* @private
|
|
451
474
|
*/
|
|
475
|
+
|
|
452
476
|
}, {
|
|
453
477
|
key: "renderRect",
|
|
454
478
|
value: function renderRect(points, xMargin) {
|
|
455
479
|
var _this4 = this;
|
|
480
|
+
|
|
456
481
|
var _this$props4 = this.props,
|
|
457
|
-
|
|
458
|
-
|
|
482
|
+
data = _this$props4.data,
|
|
483
|
+
height = _this$props4.height;
|
|
459
484
|
var xUnit = this.getXUnit(xMargin);
|
|
460
485
|
return points.map(function (p, i) {
|
|
461
|
-
return
|
|
486
|
+
return (
|
|
487
|
+
/*#__PURE__*/
|
|
488
|
+
|
|
462
489
|
/* eslint-disable react/no-array-index-key */
|
|
463
490
|
react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("rect", {
|
|
464
491
|
// eslint-disable-line jsx-a11y/mouse-events-have-key-events
|
|
@@ -481,33 +508,32 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
481
508
|
}
|
|
482
509
|
})
|
|
483
510
|
/* eslint-enable react/no-array-index-key */
|
|
511
|
+
|
|
484
512
|
);
|
|
485
513
|
});
|
|
486
|
-
}
|
|
514
|
+
} // Renders area chart
|
|
487
515
|
|
|
488
|
-
// Renders area chart
|
|
489
516
|
}, {
|
|
490
517
|
key: "renderArea",
|
|
491
518
|
value: function renderArea(points) {
|
|
492
519
|
var _this$props5 = this.props,
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
520
|
+
data = _this$props5.data,
|
|
521
|
+
fillColor = _this$props5.fillColor,
|
|
522
|
+
fillOpacity = _this$props5.fillOpacity,
|
|
523
|
+
height = _this$props5.height,
|
|
524
|
+
isArea = _this$props5.isArea;
|
|
525
|
+
|
|
498
526
|
if (!isArea || points.length === 0) {
|
|
499
527
|
return null;
|
|
500
528
|
}
|
|
529
|
+
|
|
501
530
|
var segments = this.getSegmentSets(data, points);
|
|
502
531
|
segments = segments.map(function (s) {
|
|
503
|
-
return s.concat([[s[s.length - 1][0], height],
|
|
504
|
-
//
|
|
505
|
-
[s[0][0], height],
|
|
506
|
-
// over to below first data point
|
|
532
|
+
return s.concat([[s[s.length - 1][0], height], // down to bottom of graph
|
|
533
|
+
[s[0][0], height], // over to below first data point
|
|
507
534
|
s[0] // up to first data point to close the box
|
|
508
535
|
]);
|
|
509
536
|
});
|
|
510
|
-
|
|
511
537
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", {
|
|
512
538
|
"data-test": "area"
|
|
513
539
|
}, segments.map(function (s) {
|
|
@@ -527,11 +553,11 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
527
553
|
key: "renderCursor",
|
|
528
554
|
value: function renderCursor() {
|
|
529
555
|
var _this$props6 = this.props,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
556
|
+
cursorStroke = _this$props6.cursorStroke,
|
|
557
|
+
cursorStrokeWidth = _this$props6.cursorStrokeWidth,
|
|
558
|
+
cursorStrokeLinecap = _this$props6.cursorStrokeLinecap,
|
|
559
|
+
cursorStrokeDasharray = _this$props6.cursorStrokeDasharray,
|
|
560
|
+
height = _this$props6.height;
|
|
535
561
|
return this.state.rectArea !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("line", {
|
|
536
562
|
"data-test": "cursor",
|
|
537
563
|
ref: this.handleCursorMount,
|
|
@@ -560,7 +586,6 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
560
586
|
animation: false
|
|
561
587
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement(StyledTooltip, null, this.state.anchor !== null ? this.state.tooltip : undefined));
|
|
562
588
|
}
|
|
563
|
-
|
|
564
589
|
/**
|
|
565
590
|
* Renders one or more svg circles to highlight values on the sparkline
|
|
566
591
|
* @method renderEndDots
|
|
@@ -570,14 +595,15 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
570
595
|
* @returns {Object} React representation of SVG group
|
|
571
596
|
* @private
|
|
572
597
|
*/
|
|
598
|
+
|
|
573
599
|
}, {
|
|
574
600
|
key: "renderEndDots",
|
|
575
601
|
value: function renderEndDots(points, dotsToShow, xMargin) {
|
|
576
602
|
var _this$props7 = this.props,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
603
|
+
endDotFillColor = _this$props7.endDotFillColor,
|
|
604
|
+
endDotRadius = _this$props7.endDotRadius,
|
|
605
|
+
endDotStroke = _this$props7.endDotStroke,
|
|
606
|
+
endDotStrokeWidth = _this$props7.endDotStrokeWidth;
|
|
581
607
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", null, points.slice(-dotsToShow).map(function (point) {
|
|
582
608
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("circle", {
|
|
583
609
|
key: "end-dot".concat(point[0]).concat(point[1]),
|
|
@@ -593,21 +619,21 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
593
619
|
});
|
|
594
620
|
}));
|
|
595
621
|
}
|
|
596
|
-
|
|
597
622
|
/**
|
|
598
623
|
* Renders the line(s) above the area graph
|
|
599
624
|
* @method renderPolyline
|
|
600
625
|
* @param {Array} points
|
|
601
626
|
* @returns {Object} SVG Group of polylines
|
|
602
627
|
*/
|
|
628
|
+
|
|
603
629
|
}, {
|
|
604
630
|
key: "renderPolyline",
|
|
605
631
|
value: function renderPolyline(points) {
|
|
606
632
|
var _this$props8 = this.props,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
633
|
+
data = _this$props8.data,
|
|
634
|
+
lineColor = _this$props8.lineColor,
|
|
635
|
+
lineLength = _this$props8.lineLength,
|
|
636
|
+
lineStrokeWidth = _this$props8.lineStrokeWidth;
|
|
611
637
|
var linePoints = Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(lineLength) && lineLength > 0 ? lineLength : points.length;
|
|
612
638
|
var lines = this.getSegmentSets(data.slice(-linePoints), points.slice(-linePoints));
|
|
613
639
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", {
|
|
@@ -631,24 +657,26 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
631
657
|
key: "render",
|
|
632
658
|
value: function render() {
|
|
633
659
|
var _this5 = this;
|
|
660
|
+
|
|
634
661
|
var _this$props9 = this.props,
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
662
|
+
data = _this$props9.data,
|
|
663
|
+
elementRef = _this$props9.elementRef,
|
|
664
|
+
showTooltip = _this$props9.showTooltip,
|
|
665
|
+
showEndDot = _this$props9.showEndDot,
|
|
666
|
+
endDotRadius = _this$props9.endDotRadius,
|
|
667
|
+
endDotStrokeWidth = _this$props9.endDotStrokeWidth,
|
|
668
|
+
endDotCount = _this$props9.endDotCount,
|
|
669
|
+
height = _this$props9.height,
|
|
670
|
+
isArea = _this$props9.isArea,
|
|
671
|
+
lineStrokeWidth = _this$props9.lineStrokeWidth,
|
|
672
|
+
width = _this$props9.width,
|
|
673
|
+
title = _this$props9.title;
|
|
674
|
+
|
|
647
675
|
if (data.length === 0) {
|
|
648
676
|
return null;
|
|
649
|
-
}
|
|
677
|
+
} // Calculate horizontal and vertical margin so that fit line or end dot.
|
|
678
|
+
|
|
650
679
|
|
|
651
|
-
// Calculate horizontal and vertical margin so that fit line or end dot.
|
|
652
680
|
var xMargin = endDotRadius + endDotStrokeWidth / 2;
|
|
653
681
|
var yMargin = Math.max(lineStrokeWidth / 2, endDotRadius + endDotStrokeWidth / 2);
|
|
654
682
|
var points = this.dataToPoints(xMargin, yMargin);
|
|
@@ -678,84 +706,114 @@ var SparkLine = /*#__PURE__*/function (_Component) {
|
|
|
678
706
|
}, title || Object(_splunk_ui_utils_i18n__WEBPACK_IMPORTED_MODULE_13__["_"])('Source count over time sparkline trend')), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", null, this.renderCursor(), this.renderPolyline(points), this.renderArea(points), dotsToShow ? this.renderEndDots(points, dotsToShow, xMargin) : null, showTooltip ? this.renderRect(points, xMargin) : null, showTooltip ? this.renderTooltip() : null)));
|
|
679
707
|
}
|
|
680
708
|
}]);
|
|
709
|
+
|
|
681
710
|
return SparkLine;
|
|
682
711
|
}(react__WEBPACK_IMPORTED_MODULE_9__["Component"]);
|
|
712
|
+
|
|
683
713
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(SparkLine, "propTypes", {
|
|
684
714
|
/**
|
|
685
715
|
* If true, data can contain `null` as a value and is treated as `0`. If false, this throws error when data contains `null`.
|
|
686
716
|
*/
|
|
687
717
|
acceptNull: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
|
|
718
|
+
|
|
688
719
|
/** Array of numbers. These data numbers are converted to points and show on sparkline. */
|
|
689
720
|
data: function data(props) {
|
|
690
721
|
if (!Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isArray"])(props.data)) {
|
|
691
722
|
return new Error('Data provided to Sparkline must be an array.');
|
|
692
723
|
}
|
|
724
|
+
|
|
693
725
|
if (props.acceptNull && !props.data.every(function (value) {
|
|
694
726
|
return Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isNull"])(value) || Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(value);
|
|
695
727
|
})) {
|
|
696
728
|
return new Error('Data provided to Sparkline must be finite numbers or null.');
|
|
697
729
|
}
|
|
730
|
+
|
|
698
731
|
if (!props.acceptNull && !props.data.every(function (value) {
|
|
699
732
|
return Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(value);
|
|
700
733
|
})) {
|
|
701
734
|
return new Error('Data provided to Sparkline must be finite numbers.');
|
|
702
735
|
}
|
|
736
|
+
|
|
703
737
|
return null;
|
|
704
738
|
},
|
|
739
|
+
|
|
705
740
|
/** A React ref which is set to the DOM element when the component mounts and `null` when it unmounts. */
|
|
706
741
|
elementRef: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.func, prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.object]),
|
|
742
|
+
|
|
707
743
|
/** Sets the number of end dots to display. When showEndDot is set to `true`, endDotCount is at least 1. If set to a positive value, this overrides showEndDot. */
|
|
708
744
|
endDotCount: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
745
|
+
|
|
709
746
|
/** Fills color to the end dot. */
|
|
710
747
|
endDotFillColor: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
748
|
+
|
|
711
749
|
/**
|
|
712
750
|
* Sets end dot radius. End dot radius must be less than or equal to the margin. By default, its value equals the margin.
|
|
713
751
|
*/
|
|
714
752
|
endDotRadius: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
753
|
+
|
|
715
754
|
/** Sets end dot circle stroke color. */
|
|
716
755
|
endDotStroke: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
756
|
+
|
|
717
757
|
/** Sets end dot circle stroke width in pixels. */
|
|
718
758
|
endDotStrokeWidth: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
759
|
+
|
|
719
760
|
/** Fills color to area. */
|
|
720
761
|
fillColor: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
762
|
+
|
|
721
763
|
/** Fills opacity to area. Value must be in 0 ~ 1. */
|
|
722
764
|
fillOpacity: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
765
|
+
|
|
723
766
|
/** Sets cursor stroke color. */
|
|
724
767
|
cursorStroke: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
768
|
+
|
|
725
769
|
/** Sets cursor stroke width in pixels. */
|
|
726
770
|
cursorStrokeWidth: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
771
|
+
|
|
727
772
|
/** Sets cursor line cap style. */
|
|
728
773
|
cursorStrokeLinecap: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.oneOf(['butt', 'round', 'square']),
|
|
774
|
+
|
|
729
775
|
/** Sets cursor dash array style. */
|
|
730
776
|
cursorStrokeDasharray: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
777
|
+
|
|
731
778
|
/**
|
|
732
779
|
* Container height. If this value is specified, sparkline calculates the size using this height. If height isn't specified,
|
|
733
780
|
* sparkline figures out the container height by itself.
|
|
734
781
|
*/
|
|
735
782
|
height: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number.isRequired,
|
|
783
|
+
|
|
736
784
|
/** When set to `true`, sparkline shows as area. */
|
|
737
785
|
isArea: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
|
|
786
|
+
|
|
738
787
|
/** The sparkline line color. */
|
|
739
788
|
lineColor: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
|
|
789
|
+
|
|
740
790
|
/** Allows user to draw only the last data points for the line. */
|
|
741
791
|
lineLength: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
792
|
+
|
|
742
793
|
/** The sparkline line stroke width in pixels. */
|
|
743
794
|
lineStrokeWidth: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
795
|
+
|
|
744
796
|
/** Enable to show end dot. */
|
|
745
797
|
showEndDot: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
|
|
798
|
+
|
|
746
799
|
/** Enable to show tooltip. */
|
|
747
800
|
showTooltip: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
|
|
801
|
+
|
|
748
802
|
/** Sets the data value range and maximum value shown on sparkline. */
|
|
749
803
|
yMax: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
804
|
+
|
|
750
805
|
/** Sets the data value range and minimum value shown on sparkline. */
|
|
751
806
|
yMin: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
|
|
807
|
+
|
|
752
808
|
/**
|
|
753
809
|
* The width of the container.
|
|
754
810
|
*/
|
|
755
811
|
width: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number.isRequired,
|
|
812
|
+
|
|
756
813
|
/** Sets the a11y title text on sparkline. */
|
|
757
814
|
title: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string
|
|
758
815
|
});
|
|
816
|
+
|
|
759
817
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(SparkLine, "defaultProps", {
|
|
760
818
|
acceptNull: false,
|
|
761
819
|
data: [],
|
|
@@ -776,6 +834,7 @@ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(Spa
|
|
|
776
834
|
lineColor: '#65a637',
|
|
777
835
|
lineStrokeWidth: 1
|
|
778
836
|
});
|
|
837
|
+
|
|
779
838
|
/* harmony default export */ __webpack_exports__["default"] = (SparkLine);
|
|
780
839
|
|
|
781
840
|
/***/ })
|