@splunk/visualizations 25.12.0 → 25.13.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.
Files changed (60) hide show
  1. package/Area.js +114 -113
  2. package/Area.js.map +1 -1
  3. package/Bar.js +114 -113
  4. package/Bar.js.map +1 -1
  5. package/Bubble.js +103 -102
  6. package/Bubble.js.map +1 -1
  7. package/ChoroplethSvg.js +207 -123
  8. package/ChoroplethSvg.js.map +1 -1
  9. package/Column.js +116 -113
  10. package/Column.js.map +1 -1
  11. package/Ellipse.js +72 -69
  12. package/Ellipse.js.map +1 -1
  13. package/Events.config.js +1 -1
  14. package/Events.config.js.map +1 -1
  15. package/Events.js +167 -133
  16. package/Events.js.map +1 -1
  17. package/FillerGauge.js +95 -92
  18. package/FillerGauge.js.map +1 -1
  19. package/Image.js +98 -98
  20. package/Image.js.map +1 -1
  21. package/Line.js +116 -113
  22. package/Line.js.map +1 -1
  23. package/LinkGraph.js +659 -656
  24. package/LinkGraph.js.map +1 -1
  25. package/Map.js +341 -332
  26. package/Map.js.map +1 -1
  27. package/Markdown.js +104 -104
  28. package/Markdown.js.map +1 -1
  29. package/MarkerGauge.js +88 -88
  30. package/MarkerGauge.js.map +1 -1
  31. package/ParallelCoordinates.js +110 -110
  32. package/ParallelCoordinates.js.map +1 -1
  33. package/Pie.js +125 -125
  34. package/Pie.js.map +1 -1
  35. package/Punchcard.js +228 -228
  36. package/Punchcard.js.map +1 -1
  37. package/Rectangle.js +111 -111
  38. package/Rectangle.js.map +1 -1
  39. package/Sankey.js +178 -177
  40. package/Sankey.js.map +1 -1
  41. package/Scatter.js +151 -151
  42. package/Scatter.js.map +1 -1
  43. package/SingleValue.js +954 -350
  44. package/SingleValue.js.map +1 -1
  45. package/SingleValueBasic.js +43 -27
  46. package/SingleValueBasic.js.map +1 -1
  47. package/SingleValueIcon.js +432 -431
  48. package/SingleValueIcon.js.map +1 -1
  49. package/SingleValueRadial.js +421 -411
  50. package/SingleValueRadial.js.map +1 -1
  51. package/SparkLine.js +754 -0
  52. package/SparkLine.js.map +1 -0
  53. package/Table.js +726 -122
  54. package/Table.js.map +1 -1
  55. package/common/utils/mapUtils.js +7 -4
  56. package/common/utils/mapUtils.js.map +1 -1
  57. package/common/utils/urlUtils.js +118 -0
  58. package/common/utils/urlUtils.js.map +1 -0
  59. package/common/withDashboardViz.js +2 -2
  60. package/package.json +11 -12
package/SparkLine.js ADDED
@@ -0,0 +1,754 @@
1
+ /*!
2
+ * Copyright © 2018 Splunk Inc.
3
+ * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
+ * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
+ */
6
+ module.exports =
7
+ /******/ (function(modules) { // webpackBootstrap
8
+ /******/ // The module cache
9
+ /******/ var installedModules = {};
10
+ /******/
11
+ /******/ // The require function
12
+ /******/ function __webpack_require__(moduleId) {
13
+ /******/
14
+ /******/ // Check if module is in cache
15
+ /******/ if(installedModules[moduleId]) {
16
+ /******/ return installedModules[moduleId].exports;
17
+ /******/ }
18
+ /******/ // Create a new module (and put it into the cache)
19
+ /******/ var module = installedModules[moduleId] = {
20
+ /******/ i: moduleId,
21
+ /******/ l: false,
22
+ /******/ exports: {}
23
+ /******/ };
24
+ /******/
25
+ /******/ // Execute the module function
26
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
+ /******/
28
+ /******/ // Flag the module as loaded
29
+ /******/ module.l = true;
30
+ /******/
31
+ /******/ // Return the exports of the module
32
+ /******/ return module.exports;
33
+ /******/ }
34
+ /******/
35
+ /******/
36
+ /******/ // expose the modules object (__webpack_modules__)
37
+ /******/ __webpack_require__.m = modules;
38
+ /******/
39
+ /******/ // expose the module cache
40
+ /******/ __webpack_require__.c = installedModules;
41
+ /******/
42
+ /******/ // define getter function for harmony exports
43
+ /******/ __webpack_require__.d = function(exports, name, getter) {
44
+ /******/ if(!__webpack_require__.o(exports, name)) {
45
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
+ /******/ }
47
+ /******/ };
48
+ /******/
49
+ /******/ // define __esModule on exports
50
+ /******/ __webpack_require__.r = function(exports) {
51
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
+ /******/ }
54
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
+ /******/ };
56
+ /******/
57
+ /******/ // create a fake namespace object
58
+ /******/ // mode & 1: value is a module id, require it
59
+ /******/ // mode & 2: merge all properties of value into the ns
60
+ /******/ // mode & 4: return value when already ns object
61
+ /******/ // mode & 8|1: behave like require
62
+ /******/ __webpack_require__.t = function(value, mode) {
63
+ /******/ if(mode & 1) value = __webpack_require__(value);
64
+ /******/ if(mode & 8) return value;
65
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
+ /******/ var ns = Object.create(null);
67
+ /******/ __webpack_require__.r(ns);
68
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
+ /******/ return ns;
71
+ /******/ };
72
+ /******/
73
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
74
+ /******/ __webpack_require__.n = function(module) {
75
+ /******/ var getter = module && module.__esModule ?
76
+ /******/ function getDefault() { return module['default']; } :
77
+ /******/ function getModuleExports() { return module; };
78
+ /******/ __webpack_require__.d(getter, 'a', getter);
79
+ /******/ return getter;
80
+ /******/ };
81
+ /******/
82
+ /******/ // Object.prototype.hasOwnProperty.call
83
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
+ /******/
85
+ /******/ // __webpack_public_path__
86
+ /******/ __webpack_require__.p = "";
87
+ /******/
88
+ /******/
89
+ /******/ // Load entry module and return exports
90
+ /******/ return __webpack_require__(__webpack_require__.s = 95);
91
+ /******/ })
92
+ /************************************************************************/
93
+ /******/ ({
94
+
95
+ /***/ 0:
96
+ /***/ (function(module, exports) {
97
+
98
+ module.exports = require("prop-types");
99
+
100
+ /***/ }),
101
+
102
+ /***/ 1:
103
+ /***/ (function(module, exports) {
104
+
105
+ module.exports = require("react");
106
+
107
+ /***/ }),
108
+
109
+ /***/ 18:
110
+ /***/ (function(module, exports) {
111
+
112
+ module.exports = require("@babel/runtime/helpers/createClass");
113
+
114
+ /***/ }),
115
+
116
+ /***/ 3:
117
+ /***/ (function(module, exports) {
118
+
119
+ module.exports = require("lodash");
120
+
121
+ /***/ }),
122
+
123
+ /***/ 4:
124
+ /***/ (function(module, exports) {
125
+
126
+ module.exports = require("styled-components");
127
+
128
+ /***/ }),
129
+
130
+ /***/ 48:
131
+ /***/ (function(module, exports) {
132
+
133
+ module.exports = require("@babel/runtime/helpers/extends");
134
+
135
+ /***/ }),
136
+
137
+ /***/ 61:
138
+ /***/ (function(module, exports) {
139
+
140
+ module.exports = require("@splunk/react-ui/Popover");
141
+
142
+ /***/ }),
143
+
144
+ /***/ 62:
145
+ /***/ (function(module, exports) {
146
+
147
+ module.exports = require("@babel/runtime/helpers/getPrototypeOf");
148
+
149
+ /***/ }),
150
+
151
+ /***/ 7:
152
+ /***/ (function(module, exports) {
153
+
154
+ module.exports = require("@babel/runtime/helpers/defineProperty");
155
+
156
+ /***/ }),
157
+
158
+ /***/ 70:
159
+ /***/ (function(module, exports) {
160
+
161
+ module.exports = require("@babel/runtime/helpers/inherits");
162
+
163
+ /***/ }),
164
+
165
+ /***/ 71:
166
+ /***/ (function(module, exports) {
167
+
168
+ module.exports = require("@babel/runtime/helpers/possibleConstructorReturn");
169
+
170
+ /***/ }),
171
+
172
+ /***/ 86:
173
+ /***/ (function(module, exports) {
174
+
175
+ module.exports = require("@babel/runtime/helpers/assertThisInitialized");
176
+
177
+ /***/ }),
178
+
179
+ /***/ 9:
180
+ /***/ (function(module, exports) {
181
+
182
+ module.exports = require("@babel/runtime/helpers/classCallCheck");
183
+
184
+ /***/ }),
185
+
186
+ /***/ 95:
187
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
188
+
189
+ "use strict";
190
+ __webpack_require__.r(__webpack_exports__);
191
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(48);
192
+ /* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
193
+ /* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
194
+ /* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
195
+ /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18);
196
+ /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);
197
+ /* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(86);
198
+ /* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3__);
199
+ /* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(70);
200
+ /* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__);
201
+ /* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(71);
202
+ /* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5__);
203
+ /* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(62);
204
+ /* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6__);
205
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7);
206
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7__);
207
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(0);
208
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_8__);
209
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1);
210
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_9__);
211
+ /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(3);
212
+ /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_10__);
213
+ /* harmony import */ var _splunk_react_ui_Popover__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(61);
214
+ /* harmony import */ var _splunk_react_ui_Popover__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_splunk_react_ui_Popover__WEBPACK_IMPORTED_MODULE_11__);
215
+ /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(4);
216
+ /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_12__);
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ function _createSuper(Derived) {
226
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
227
+ return function _createSuperInternal() {
228
+ var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(Derived),
229
+ result;
230
+ if (hasNativeReflectConstruct) {
231
+ var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_6___default()(this).constructor;
232
+ result = Reflect.construct(Super, arguments, NewTarget);
233
+ } else {
234
+ result = Super.apply(this, arguments);
235
+ }
236
+ return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_5___default()(this, result);
237
+ };
238
+ }
239
+ function _isNativeReflectConstruct() {
240
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
241
+ if (Reflect.construct.sham) return false;
242
+ if (typeof Proxy === "function") return true;
243
+ try {
244
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
245
+ return true;
246
+ } catch (e) {
247
+ return false;
248
+ }
249
+ }
250
+
251
+
252
+
253
+
254
+
255
+ var StyledSvg = styled_components__WEBPACK_IMPORTED_MODULE_12___default.a.svg.withConfig({
256
+ displayName: "SparkLine__StyledSvg",
257
+ componentId: "sc-5oplra-0"
258
+ })(["overflow:hidden;"]);
259
+ var StyledTooltip = styled_components__WEBPACK_IMPORTED_MODULE_12___default.a.div.withConfig({
260
+ displayName: "SparkLine__StyledTooltip",
261
+ componentId: "sc-5oplra-1"
262
+ })(["padding:3px 8px;font-size:12px;"]);
263
+ var SparkLine = /*#__PURE__*/function (_Component) {
264
+ _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(SparkLine, _Component);
265
+ var _super = _createSuper(SparkLine);
266
+ function SparkLine(props) {
267
+ var _this;
268
+ _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, SparkLine);
269
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
270
+ rest[_key - 1] = arguments[_key];
271
+ }
272
+ _this = _super.call.apply(_super, [this, props].concat(rest));
273
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_3___default()(_this), "handleCursorMount", function (el) {
274
+ _this.setState({
275
+ anchor: el
276
+ });
277
+ });
278
+ _this.state = {
279
+ anchor: null,
280
+ currentPointX: null,
281
+ open: false,
282
+ rectArea: null,
283
+ tooltip: null
284
+ };
285
+ return _this;
286
+ }
287
+ _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(SparkLine, [{
288
+ key: "getMax",
289
+ value: function getMax() {
290
+ var _this2 = this;
291
+ var _this$props = this.props,
292
+ data = _this$props.data,
293
+ acceptNull = _this$props.acceptNull,
294
+ yMax = _this$props.yMax;
295
+ var dataMax = function dataMax() {
296
+ return acceptNull ? Object(lodash__WEBPACK_IMPORTED_MODULE_10__["max"])(_this2.fillNull(data)) : Object(lodash__WEBPACK_IMPORTED_MODULE_10__["max"])(data);
297
+ };
298
+ return yMax !== undefined ? yMax : dataMax();
299
+ }
300
+ }, {
301
+ key: "getMin",
302
+ value: function getMin() {
303
+ var _this3 = this;
304
+ var _this$props2 = this.props,
305
+ data = _this$props2.data,
306
+ acceptNull = _this$props2.acceptNull,
307
+ yMin = _this$props2.yMin;
308
+ var dataMin = function dataMin() {
309
+ return acceptNull ? Object(lodash__WEBPACK_IMPORTED_MODULE_10__["min"])(_this3.fillNull(data)) : Object(lodash__WEBPACK_IMPORTED_MODULE_10__["min"])(data);
310
+ };
311
+ return yMin !== undefined ? yMin : dataMin();
312
+ }
313
+
314
+ /**
315
+ * Gets unit value of x axis.
316
+ * @param {Number} xMargin - margin of x axis.
317
+ * @return {Number} unit value of x axis.
318
+ * @private
319
+ */
320
+ }, {
321
+ key: "getXUnit",
322
+ value: function getXUnit(xMargin) {
323
+ var _this$props3 = this.props,
324
+ data = _this$props3.data,
325
+ width = _this$props3.width; // Calculate xUnit. Width substract the left margin and right margin, then divide by data length.
326
+ var xUnit = (width - xMargin * 2) / (data.length > 1 ? data.length - 1 : 1);
327
+ return Math.max(0, xUnit);
328
+ }
329
+
330
+ /**
331
+ * Gets unit value of y axis.
332
+ * @param {String} yMargin - margin of y axis.
333
+ * @return {Number} unit value of y axis.
334
+ * @private
335
+ */
336
+ }, {
337
+ key: "getYUnit",
338
+ value: function getYUnit(yMargin) {
339
+ var height = this.props.height;
340
+ var maxValue = this.getMax();
341
+ var minValue = this.getMin();
342
+
343
+ // Calculate yUnit. Height substract the upper margin and bottom margin, then divide by value range of values in data.
344
+ // 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.
345
+ // So, draws sparkline right in the mid of the container.
346
+ var yUnit = (height - yMargin * 2) / (maxValue - minValue || 2);
347
+ return Math.max(0, yUnit);
348
+ }
349
+
350
+ /**
351
+ * Get a list of arrays of points for drawing lines, based on acceptNull property
352
+ * @method getSegmentSets
353
+ * @param {Array} data
354
+ * @param {Array} points
355
+ * @returns {Array} List of datapoint sets used for drawing lines
356
+ */
357
+ }, {
358
+ key: "getSegmentSets",
359
+ value: function getSegmentSets(data, points) {
360
+ var acceptNull = this.props.acceptNull;
361
+ var lines = [];
362
+ var currentLine = [];
363
+ data.forEach(function (p, idx) {
364
+ // Found null data
365
+ if (!acceptNull && Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isNull"])(p)) {
366
+ // need at least 2 points to draw a segment
367
+ if (currentLine.length > 1) {
368
+ lines.push(currentLine);
369
+ }
370
+ // reset for the next segment
371
+ currentLine = [];
372
+ } else {
373
+ // data is good, add point data
374
+ currentLine.push(points[idx]);
375
+ }
376
+ });
377
+
378
+ // Add the last line
379
+ if (currentLine.length > 1) {
380
+ lines.push(currentLine);
381
+ }
382
+ return lines;
383
+ }
384
+ }, {
385
+ key: "fillNull",
386
+ value:
387
+ /**
388
+ * Utility for fill null value with number 0.
389
+ * @private
390
+ */
391
+ function fillNull() {
392
+ var data = this.props.data;
393
+ return data.map(function (value) {
394
+ return value === null ? 0 : value;
395
+ });
396
+ }
397
+
398
+ /**
399
+ * Converts data to points in svg
400
+ * @param {Number} xMargin - margin of x axis.
401
+ * @param {Number} yMargin - margin of x axis.
402
+ * @return {Array} points coordination.
403
+ * @private
404
+ */
405
+ }, {
406
+ key: "dataToPoints",
407
+ value: function dataToPoints(xMargin, yMargin) {
408
+ var data = this.props.data;
409
+ var xUnit = this.getXUnit(xMargin);
410
+ var yUnit = this.getYUnit(yMargin);
411
+ var maxValue = this.getMax();
412
+ var minValue = this.getMin();
413
+ return data.map(function (val, idx) {
414
+ return {
415
+ x: idx * xUnit + xMargin,
416
+ y: maxValue === minValue ? yUnit + yMargin : (maxValue - val) * yUnit + yMargin
417
+ };
418
+ }).map(function (p) {
419
+ return [p.x, p.y];
420
+ });
421
+ }
422
+
423
+ /**
424
+ * Renders rect area for helping figure out which is the nearest point so that
425
+ * render related cursor and tooltip.
426
+ * @param {Array} points - array of points coordination.
427
+ * @param {Number} xMargin - margin of x axis.
428
+ * @return {Array} array of svg rect objects
429
+ * @private
430
+ */
431
+ }, {
432
+ key: "renderRect",
433
+ value: function renderRect(points, xMargin) {
434
+ var _this4 = this;
435
+ var _this$props4 = this.props,
436
+ data = _this$props4.data,
437
+ height = _this$props4.height;
438
+ var xUnit = this.getXUnit(xMargin);
439
+ return points.map(function (p, i) {
440
+ return /*#__PURE__*/(
441
+ /* eslint-disable react/no-array-index-key */
442
+ react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("rect", {
443
+ // eslint-disable-line jsx-a11y/mouse-events-have-key-events
444
+ key: "".concat(i, "_").concat(p[0]),
445
+ "data-test": "rect-".concat(i),
446
+ x: p[0] - xUnit / 2 <= 0 ? 0 : p[0] - xUnit / 2,
447
+ y: 0,
448
+ width: i === 0 && data.length !== 1 ? xUnit / 2 : xUnit,
449
+ height: height,
450
+ style: {
451
+ fillOpacity: 0
452
+ },
453
+ onMouseOver: function onMouseOver(e) {
454
+ _this4.setState({
455
+ open: data[i] !== null,
456
+ rectArea: data[i] === null ? null : e.target,
457
+ tooltip: data[i],
458
+ currentPointX: p[0]
459
+ });
460
+ }
461
+ })
462
+ /* eslint-enable react/no-array-index-key */
463
+ );
464
+ });
465
+ }
466
+
467
+ // Renders area chart
468
+ }, {
469
+ key: "renderArea",
470
+ value: function renderArea(points) {
471
+ var _this$props5 = this.props,
472
+ data = _this$props5.data,
473
+ fillColor = _this$props5.fillColor,
474
+ fillOpacity = _this$props5.fillOpacity,
475
+ height = _this$props5.height,
476
+ isArea = _this$props5.isArea;
477
+ if (!isArea || points.length === 0) {
478
+ return null;
479
+ }
480
+ var segments = this.getSegmentSets(data, points);
481
+ segments = segments.map(function (s) {
482
+ return s.concat([[s[s.length - 1][0], height],
483
+ // down to bottom of graph
484
+ [s[0][0], height],
485
+ // over to below first data point
486
+ s[0] // up to first data point to close the box
487
+ ]);
488
+ });
489
+
490
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", {
491
+ "data-test": "area"
492
+ }, segments.map(function (s) {
493
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("polyline", {
494
+ key: "area".concat(s.join('')),
495
+ points: s.join(' '),
496
+ "data-test": "area-line",
497
+ style: {
498
+ fill: fillColor,
499
+ fillOpacity: fillOpacity,
500
+ strokeWidth: '0'
501
+ }
502
+ });
503
+ }));
504
+ }
505
+ }, {
506
+ key: "renderCursor",
507
+ value: function renderCursor() {
508
+ var _this$props6 = this.props,
509
+ cursorStroke = _this$props6.cursorStroke,
510
+ cursorStrokeWidth = _this$props6.cursorStrokeWidth,
511
+ cursorStrokeLinecap = _this$props6.cursorStrokeLinecap,
512
+ cursorStrokeDasharray = _this$props6.cursorStrokeDasharray,
513
+ height = _this$props6.height;
514
+ return this.state.rectArea !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("line", {
515
+ "data-test": "cursor",
516
+ ref: this.handleCursorMount,
517
+ x1: this.state.currentPointX,
518
+ y1: 0,
519
+ x2: this.state.currentPointX,
520
+ y2: height,
521
+ style: {
522
+ stroke: cursorStroke,
523
+ strokeWidth: cursorStrokeWidth,
524
+ strokeLinecap: cursorStrokeLinecap,
525
+ strokeDasharray: cursorStrokeDasharray
526
+ }
527
+ });
528
+ }
529
+ }, {
530
+ key: "renderTooltip",
531
+ value: function renderTooltip() {
532
+ return this.state.anchor !== null && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement(_splunk_react_ui_Popover__WEBPACK_IMPORTED_MODULE_11___default.a, {
533
+ "data-test": "tooltip",
534
+ open: this.state.open,
535
+ anchor: this.state.anchor,
536
+ "data-test-value": this.state.tooltip,
537
+ appearance: "inverted",
538
+ defaultPlacement: "above",
539
+ animation: false
540
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement(StyledTooltip, null, this.state.anchor !== null ? this.state.tooltip : undefined));
541
+ }
542
+
543
+ /**
544
+ * Renders one or more svg circles to highlight values on the sparkline
545
+ * @method renderEndDots
546
+ * @param {Array[Array[Number]]} points // x,y coordinates of values
547
+ * @param {Number} dotsToShow // number of end dots to display
548
+ * @param {Number} xMargin // used when calculating the dot radius
549
+ * @returns {Object} React representation of SVG group
550
+ * @private
551
+ */
552
+ }, {
553
+ key: "renderEndDots",
554
+ value: function renderEndDots(points, dotsToShow, xMargin) {
555
+ var _this$props7 = this.props,
556
+ endDotFillColor = _this$props7.endDotFillColor,
557
+ endDotRadius = _this$props7.endDotRadius,
558
+ endDotStroke = _this$props7.endDotStroke,
559
+ endDotStrokeWidth = _this$props7.endDotStrokeWidth;
560
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", null, points.slice(-dotsToShow).map(function (point) {
561
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("circle", {
562
+ key: "end-dot".concat(point[0]).concat(point[1]),
563
+ "data-test": "end-dot",
564
+ cx: point[0],
565
+ cy: point[1],
566
+ r: endDotRadius === 0 ? xMargin : endDotRadius,
567
+ style: {
568
+ fill: endDotFillColor,
569
+ stroke: endDotStroke,
570
+ strokeWidth: endDotStrokeWidth
571
+ }
572
+ });
573
+ }));
574
+ }
575
+
576
+ /**
577
+ * Renders the line(s) above the area graph
578
+ * @method renderPolyline
579
+ * @param {Array} points
580
+ * @returns {Object} SVG Group of polylines
581
+ */
582
+ }, {
583
+ key: "renderPolyline",
584
+ value: function renderPolyline(points) {
585
+ var _this$props8 = this.props,
586
+ data = _this$props8.data,
587
+ lineColor = _this$props8.lineColor,
588
+ lineLength = _this$props8.lineLength,
589
+ lineStrokeWidth = _this$props8.lineStrokeWidth;
590
+ var linePoints = Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(lineLength) && lineLength > 0 ? lineLength : points.length;
591
+ var lines = this.getSegmentSets(data.slice(-linePoints), points.slice(-linePoints));
592
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("g", {
593
+ "data-test": "sparkline"
594
+ }, lines.map(function (lineData) {
595
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("polyline", {
596
+ key: "line".concat(lineData.join('')),
597
+ "data-test": "polyline",
598
+ style: {
599
+ fill: 'none',
600
+ stroke: lineColor,
601
+ strokeWidth: lineStrokeWidth,
602
+ strokeLinejoin: 'round',
603
+ strokeLinecap: 'round'
604
+ },
605
+ points: lineData.join(' ')
606
+ });
607
+ }));
608
+ }
609
+ }, {
610
+ key: "render",
611
+ value: function render() {
612
+ var _this5 = this;
613
+ var _this$props9 = this.props,
614
+ data = _this$props9.data,
615
+ elementRef = _this$props9.elementRef,
616
+ showTooltip = _this$props9.showTooltip,
617
+ showEndDot = _this$props9.showEndDot,
618
+ endDotRadius = _this$props9.endDotRadius,
619
+ endDotStrokeWidth = _this$props9.endDotStrokeWidth,
620
+ endDotCount = _this$props9.endDotCount,
621
+ height = _this$props9.height,
622
+ isArea = _this$props9.isArea,
623
+ lineStrokeWidth = _this$props9.lineStrokeWidth,
624
+ width = _this$props9.width;
625
+ if (data.length === 0) {
626
+ return null;
627
+ }
628
+
629
+ // Calculate horizontal and vertical margin so that fit line or end dot.
630
+ var xMargin = endDotRadius + endDotStrokeWidth / 2;
631
+ var yMargin = Math.max(lineStrokeWidth / 2, endDotRadius + endDotStrokeWidth / 2);
632
+ var points = this.dataToPoints(xMargin, yMargin);
633
+ var dotsToShow = Math.max(showEndDot && 1, Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(endDotCount) && endDotCount > 0 && endDotCount);
634
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement("div", _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({
635
+ // eslint-disable-line jsx-a11y/mouse-events-have-key-events
636
+ "data-test": "line",
637
+ "data-test-type": isArea ? 'area' : 'line',
638
+ onMouseOut: function onMouseOut() {
639
+ _this5.setState({
640
+ open: false,
641
+ anchor: null,
642
+ rectArea: null,
643
+ currentPointX: null
644
+ });
645
+ },
646
+ ref: elementRef
647
+ }, Object(lodash__WEBPACK_IMPORTED_MODULE_10__["omit"])(this.props, Object(lodash__WEBPACK_IMPORTED_MODULE_10__["keys"])(SparkLine.propTypes))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_9___default.a.createElement(StyledSvg, {
648
+ height: height,
649
+ width: width
650
+ }, /*#__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)));
651
+ }
652
+ }]);
653
+ return SparkLine;
654
+ }(react__WEBPACK_IMPORTED_MODULE_9__["Component"]);
655
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(SparkLine, "propTypes", {
656
+ /**
657
+ * If true, data can contain `null` as a value and is treated as `0`. If false, this throws error when data contains `null`.
658
+ */
659
+ acceptNull: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
660
+ /** Array of numbers. These data numbers are converted to points and show on sparkline. */
661
+ data: function data(props) {
662
+ if (!Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isArray"])(props.data)) {
663
+ return new Error('Data provided to Sparkline must be an array.');
664
+ }
665
+ if (props.acceptNull && !props.data.every(function (value) {
666
+ return Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isNull"])(value) || Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(value);
667
+ })) {
668
+ return new Error('Data provided to Sparkline must be finite numbers or null.');
669
+ }
670
+ if (!props.acceptNull && !props.data.every(function (value) {
671
+ return Object(lodash__WEBPACK_IMPORTED_MODULE_10__["isFinite"])(value);
672
+ })) {
673
+ return new Error('Data provided to Sparkline must be finite numbers.');
674
+ }
675
+ return null;
676
+ },
677
+ /** A React ref which is set to the DOM element when the component mounts and `null` when it unmounts. */
678
+ 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]),
679
+ /** 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. */
680
+ endDotCount: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
681
+ /** Fills color to the end dot. */
682
+ endDotFillColor: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
683
+ /**
684
+ * Sets end dot radius. End dot radius must be less than or equal to the margin. By default, its value equals the margin.
685
+ */
686
+ endDotRadius: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
687
+ /** Sets end dot circle stroke color. */
688
+ endDotStroke: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
689
+ /** Sets end dot circle stroke width in pixels. */
690
+ endDotStrokeWidth: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
691
+ /** Fills color to area. */
692
+ fillColor: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
693
+ /** Fills opacity to area. Value must be in 0 ~ 1. */
694
+ fillOpacity: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
695
+ /** Sets cursor stroke color. */
696
+ cursorStroke: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
697
+ /** Sets cursor stroke width in pixels. */
698
+ cursorStrokeWidth: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
699
+ /** Sets cursor line cap style. */
700
+ cursorStrokeLinecap: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.oneOf(['butt', 'round', 'square']),
701
+ /** Sets cursor dash array style. */
702
+ cursorStrokeDasharray: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
703
+ /**
704
+ * Container height. If this value is specified, sparkline calculates the size using this height. If height isn't specified,
705
+ * sparkline figures out the container height by itself.
706
+ */
707
+ height: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number.isRequired,
708
+ /** When set to `true`, sparkline shows as area. */
709
+ isArea: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
710
+ /** The sparkline line color. */
711
+ lineColor: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.string,
712
+ /** Allows user to draw only the last data points for the line. */
713
+ lineLength: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
714
+ /** The sparkline line stroke width in pixels. */
715
+ lineStrokeWidth: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
716
+ /** Enable to show end dot. */
717
+ showEndDot: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
718
+ /** Enable to show tooltip. */
719
+ showTooltip: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.bool,
720
+ /** Sets the data value range and maximum value shown on sparkline. */
721
+ yMax: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
722
+ /** Sets the data value range and minimum value shown on sparkline. */
723
+ yMin: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number,
724
+ /**
725
+ * The width of the container.
726
+ */
727
+ width: prop_types__WEBPACK_IMPORTED_MODULE_8___default.a.number.isRequired
728
+ });
729
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()(SparkLine, "defaultProps", {
730
+ acceptNull: false,
731
+ data: [],
732
+ showTooltip: true,
733
+ endDotCount: 0,
734
+ showEndDot: false,
735
+ endDotRadius: 0,
736
+ endDotFillColor: 'white',
737
+ endDotStroke: 'black',
738
+ endDotStrokeWidth: 0,
739
+ fillColor: '#65a637',
740
+ fillOpacity: '.1',
741
+ cursorStroke: '#5184AF',
742
+ cursorStrokeWidth: 3,
743
+ cursorStrokeLinecap: 'square',
744
+ cursorStrokeDasharray: '1, 5',
745
+ isArea: false,
746
+ lineColor: '#65a637',
747
+ lineStrokeWidth: 1
748
+ });
749
+ /* harmony default export */ __webpack_exports__["default"] = (SparkLine);
750
+
751
+ /***/ })
752
+
753
+ /******/ });
754
+ //# sourceMappingURL=SparkLine.js.map