@splunk/visualizations 26.4.1 → 27.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 +1399 -1590
- package/Area.config.js.map +7 -1
- package/Area.js +3750 -4822
- package/Area.js.map +7 -1
- package/Bar.config.js +1423 -1566
- package/Bar.config.js.map +7 -1
- package/Bar.js +3856 -4884
- package/Bar.js.map +7 -1
- package/Bubble.config.js +1009 -1200
- package/Bubble.config.js.map +7 -1
- package/Bubble.js +2768 -4491
- package/Bubble.js.map +7 -1
- package/ChoroplethSvg.config.js +282 -582
- package/ChoroplethSvg.config.js.map +7 -1
- package/ChoroplethSvg.js +2032 -3808
- package/ChoroplethSvg.js.map +7 -1
- package/Column.config.js +1390 -1534
- package/Column.config.js.map +7 -1
- package/Column.js +3849 -4906
- package/Column.js.map +7 -1
- package/Ellipse.config.js +443 -774
- package/Ellipse.config.js.map +7 -1
- package/Ellipse.js +1667 -3327
- package/Ellipse.js.map +7 -1
- package/Events.config.js +207 -492
- package/Events.config.js.map +7 -1
- package/Events.js +2643 -4647
- package/Events.js.map +7 -1
- package/FillerGauge.config.js +420 -775
- package/FillerGauge.config.js.map +7 -1
- package/FillerGauge.js +2164 -4575
- package/FillerGauge.js.map +7 -1
- package/Image.config.js +144 -411
- package/Image.config.js.map +7 -1
- package/Image.js +1423 -3046
- package/Image.js.map +7 -1
- package/Line.config.js +1421 -1616
- package/Line.config.js.map +7 -1
- package/Line.js +3790 -4901
- package/Line.js.map +7 -1
- package/LinkGraph.config.js +390 -632
- package/LinkGraph.config.js.map +7 -1
- package/LinkGraph.js +5272 -6185
- package/LinkGraph.js.map +7 -1
- package/MIGRATION.md +6 -0
- package/Map.config.js +501 -801
- package/Map.config.js.map +7 -1
- package/Map.js +3382 -5659
- package/Map.js.map +7 -1
- package/Markdown.config.js +232 -528
- package/Markdown.config.js.map +7 -1
- package/Markdown.js +1671 -3212
- package/Markdown.js.map +7 -1
- package/MarkerGauge.config.js +308 -613
- package/MarkerGauge.config.js.map +7 -1
- package/MarkerGauge.js +2215 -4531
- package/MarkerGauge.js.map +7 -1
- package/ParallelCoordinates.config.js +282 -581
- package/ParallelCoordinates.config.js.map +7 -1
- package/ParallelCoordinates.js +2057 -4718
- package/ParallelCoordinates.js.map +7 -1
- package/Pie.config.js +278 -547
- package/Pie.config.js.map +7 -1
- package/Pie.js +2107 -3984
- package/Pie.js.map +7 -1
- package/Punchcard.config.js +291 -578
- package/Punchcard.config.js.map +7 -1
- package/Punchcard.js +2734 -5037
- package/Punchcard.js.map +7 -1
- package/Rectangle.config.js +455 -770
- package/Rectangle.config.js.map +7 -1
- package/Rectangle.js +1664 -3258
- package/Rectangle.js.map +7 -1
- package/Sankey.config.js +291 -626
- package/Sankey.config.js.map +7 -1
- package/Sankey.js +2766 -4908
- package/Sankey.js.map +7 -1
- package/Scatter.config.js +988 -1180
- package/Scatter.config.js.map +7 -1
- package/Scatter.js +2801 -4506
- package/Scatter.js.map +7 -1
- package/SingleValue.config.js +794 -1250
- package/SingleValue.config.js.map +7 -1
- package/SingleValue.js +4185 -7327
- package/SingleValue.js.map +7 -1
- package/SingleValueBasic.js +382 -1527
- package/SingleValueBasic.js.map +7 -1
- package/SingleValueIcon.config.js +757 -1207
- package/SingleValueIcon.config.js.map +7 -1
- package/SingleValueIcon.js +3427 -6293
- package/SingleValueIcon.js.map +7 -1
- package/SingleValueRadial.config.js +686 -1121
- package/SingleValueRadial.config.js.map +7 -1
- package/SingleValueRadial.js +3923 -6994
- package/SingleValueRadial.js.map +7 -1
- package/SparkLine.js +439 -746
- package/SparkLine.js.map +7 -1
- package/TRELLIS.md +16 -15
- package/Table.config.js +565 -879
- package/Table.config.js.map +7 -1
- package/Table.js +3260 -5334
- package/Table.js.map +7 -1
- package/common/Charting.js +617 -1498
- package/common/Charting.js.map +7 -1
- package/common/ChartingApi.js +46 -170
- package/common/ChartingApi.js.map +7 -1
- package/common/DocExampleWithVizSandbox.js +270 -473
- package/common/DocExampleWithVizSandbox.js.map +7 -1
- package/common/EventsDoc.js +172 -464
- package/common/EventsDoc.js.map +7 -1
- package/common/GaugeMajorTicks.js +249 -347
- package/common/GaugeMajorTicks.js.map +7 -1
- package/common/GaugeValueMarker.js +201 -311
- package/common/GaugeValueMarker.js.map +7 -1
- package/common/OptionsDoc.js +351 -911
- package/common/OptionsDoc.js.map +7 -1
- package/common/OverviewDoc.js +435 -769
- package/common/OverviewDoc.js.map +7 -1
- package/common/SplunkVisualization.js +116 -259
- package/common/SplunkVisualization.js.map +7 -1
- package/common/SplunkVisualizationApi.js +40 -156
- package/common/SplunkVisualizationApi.js.map +7 -1
- package/common/ThemesDoc.js +271 -420
- package/common/ThemesDoc.js.map +7 -1
- package/common/chartingUtils.js +140 -312
- package/common/chartingUtils.js.map +7 -1
- package/common/docUtils.js +148 -266
- package/common/docUtils.js.map +7 -1
- package/common/gaugeUtils.js +280 -808
- package/common/gaugeUtils.js.map +7 -1
- package/common/shapeUtils.js +106 -211
- package/common/shapeUtils.js.map +7 -1
- package/common/utils/configUtils.js +126 -252
- package/common/utils/configUtils.js.map +7 -1
- package/common/utils/dataUtils.js +217 -812
- package/common/utils/dataUtils.js.map +7 -1
- package/common/utils/featureFlagUtils.js +53 -133
- package/common/utils/featureFlagUtils.js.map +7 -1
- package/common/utils/hocUtils.js +32 -122
- package/common/utils/hocUtils.js.map +7 -1
- package/common/utils/mapUtils.js +502 -1337
- package/common/utils/mapUtils.js.map +7 -1
- package/common/utils/singleValueUtils.js +466 -1013
- package/common/utils/singleValueUtils.js.map +7 -1
- package/common/utils/testHelper.js +92 -146
- package/common/utils/testHelper.js.map +7 -1
- package/common/utils/trellisUtils.js +277 -489
- package/common/utils/trellisUtils.js.map +7 -1
- package/common/utils/urlUtils.js +28 -112
- package/common/utils/urlUtils.js.map +7 -1
- package/common/withDashboardViz.js +1191 -2431
- package/common/withDashboardViz.js.map +7 -1
- package/package.json +53 -45
|
@@ -1,471 +1,264 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 = 58);
|
|
91
|
-
/******/ })
|
|
92
|
-
/************************************************************************/
|
|
93
|
-
/******/ ({
|
|
94
|
-
|
|
95
|
-
/***/ 0:
|
|
96
|
-
/***/ (function(module, exports) {
|
|
97
|
-
|
|
98
|
-
module.exports = require("lodash");
|
|
99
|
-
|
|
100
|
-
/***/ }),
|
|
101
|
-
|
|
102
|
-
/***/ 2:
|
|
103
|
-
/***/ (function(module, exports) {
|
|
104
|
-
|
|
105
|
-
module.exports = require("@babel/runtime/helpers/toConsumableArray");
|
|
106
|
-
|
|
107
|
-
/***/ }),
|
|
108
|
-
|
|
109
|
-
/***/ 58:
|
|
110
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
111
|
-
|
|
112
|
-
"use strict";
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var _toConsumableArray = __webpack_require__(2);
|
|
116
|
-
|
|
117
|
-
Object.defineProperty(exports, "__esModule", {
|
|
118
|
-
value: true
|
|
1
|
+
/* Copyright © 2020 Splunk Inc.
|
|
2
|
+
SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
|
|
3
|
+
in part without a valid written license from Splunk Inc. is PROHIBITED. */
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/common/utils/trellisUtils.ts
|
|
34
|
+
var trellisUtils_exports2 = {};
|
|
35
|
+
__export(trellisUtils_exports2, {
|
|
36
|
+
AGGREGATIONS: () => AGGREGATIONS,
|
|
37
|
+
dataSourcesSplitByAggregationsStats: () => dataSourcesSplitByAggregationsStats,
|
|
38
|
+
dataSourcesSplitByAggregationsTimechartAndChart: () => dataSourcesSplitByAggregationsTimechartAndChart,
|
|
39
|
+
dataSourcesSplitByAggregationsUnknown: () => dataSourcesSplitByAggregationsUnknown,
|
|
40
|
+
dataSourcesSplitByModeChart: () => dataSourcesSplitByModeChart,
|
|
41
|
+
dataSourcesSplitByModeStatsorUnknown: () => dataSourcesSplitByModeStatsorUnknown,
|
|
42
|
+
dataSourcesSplitByModeTimechart: () => dataSourcesSplitByModeTimechart,
|
|
43
|
+
determineMinMax: () => determineMinMax,
|
|
44
|
+
getTrellisDataSourcesBySplitMode: () => getTrellisDataSourcesBySplitMode,
|
|
45
|
+
turnOffLegendDisplayWhenTrellisIsOn: () => turnOffLegendDisplayWhenTrellisIsOn
|
|
119
46
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var lodash_1 = __webpack_require__(0);
|
|
47
|
+
module.exports = __toCommonJS(trellisUtils_exports2);
|
|
123
48
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
49
|
+
// esm-externals:lodash
|
|
50
|
+
var lodash_exports = {};
|
|
51
|
+
__export(lodash_exports, {
|
|
52
|
+
default: () => lodash_default
|
|
53
|
+
});
|
|
54
|
+
var defaultImport = __toESM(require("lodash"));
|
|
55
|
+
__reExport(lodash_exports, require("lodash"));
|
|
56
|
+
var lodash_default = "default" in defaultImport ? defaultImport.default : defaultImport;
|
|
57
|
+
|
|
58
|
+
// esm-externals:@splunk/visualizations-shared/trellisUtils
|
|
59
|
+
var trellisUtils_exports = {};
|
|
60
|
+
__export(trellisUtils_exports, {
|
|
61
|
+
default: () => trellisUtils_default
|
|
62
|
+
});
|
|
63
|
+
var defaultImport2 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
|
|
64
|
+
__reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
|
|
65
|
+
var trellisUtils_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
|
|
135
66
|
|
|
136
|
-
|
|
67
|
+
// src/common/utils/trellisUtils.ts
|
|
68
|
+
var AGGREGATIONS = "aggregations";
|
|
69
|
+
var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
|
|
137
70
|
var _a, _b, _c, _d;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var errorCode = null;
|
|
143
|
-
|
|
71
|
+
const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
|
|
72
|
+
const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
|
|
73
|
+
let splitDataSources = null;
|
|
74
|
+
let errorCode = null;
|
|
144
75
|
if (fields && fields.length) {
|
|
145
76
|
splitDataSources = {};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
77
|
+
for (let i = 0; i < fields.length; i += 1) {
|
|
78
|
+
const fieldName = fields[i].name;
|
|
79
|
+
if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
|
|
80
|
+
splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
|
|
81
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
82
|
+
);
|
|
152
83
|
splitDataSources[fieldName].primary.data.fields = [fields[i]];
|
|
153
84
|
splitDataSources[fieldName].primary.data.columns = [columns[i]];
|
|
154
85
|
}
|
|
155
86
|
}
|
|
156
87
|
} else {
|
|
157
|
-
errorCode =
|
|
88
|
+
errorCode = "INVALID_SPLIT_BY_FIELD";
|
|
158
89
|
}
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
splitDataSources: splitDataSources,
|
|
162
|
-
errorCode: errorCode
|
|
163
|
-
};
|
|
90
|
+
return { splitDataSources, errorCode };
|
|
164
91
|
};
|
|
165
|
-
|
|
166
|
-
exports.dataSourcesSplitByAggregationsUnknown = dataSourcesSplitByAggregationsUnknown;
|
|
167
|
-
|
|
168
|
-
var dataSourcesSplitByAggregationsTimechartAndChart = function dataSourcesSplitByAggregationsTimechartAndChart(dataSource) {
|
|
92
|
+
var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
|
|
169
93
|
var _a, _b, _c, _d;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (typeof fields[0] !== 'string') {
|
|
178
|
-
splitByFields = (0, trellisUtils_1.extractDataSourceAggregationKeysChart)(fields);
|
|
94
|
+
const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
|
|
95
|
+
const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
|
|
96
|
+
let splitDataSources = null;
|
|
97
|
+
let splitByFields = [];
|
|
98
|
+
let errorCode = null;
|
|
99
|
+
if (typeof fields[0] !== "string") {
|
|
100
|
+
splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
|
|
179
101
|
}
|
|
180
|
-
|
|
181
102
|
if (splitByFields && splitByFields.length > 0) {
|
|
182
103
|
splitDataSources = {};
|
|
183
|
-
splitByFields.forEach(
|
|
184
|
-
splitDataSources[splitByField] = (0,
|
|
104
|
+
splitByFields.forEach((splitByField) => {
|
|
105
|
+
splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
|
|
106
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
107
|
+
);
|
|
185
108
|
splitDataSources[splitByField].primary.data.fields = [fields[0]];
|
|
186
109
|
splitDataSources[splitByField].primary.data.columns = [columns[0]];
|
|
187
|
-
fields.forEach(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (fieldName !== '_time' && !(fieldName === null || fieldName === void 0 ? void 0 : fieldName.startsWith('_')) && field.data_source === splitByField) {
|
|
110
|
+
fields.forEach((field, idx) => {
|
|
111
|
+
const fieldName = field == null ? void 0 : field.name;
|
|
112
|
+
if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
|
|
191
113
|
splitDataSources[splitByField].primary.data.fields.push(field);
|
|
192
114
|
splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
|
|
193
115
|
}
|
|
194
116
|
});
|
|
195
117
|
});
|
|
196
118
|
} else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
|
|
197
|
-
// handle where data_source doesnot exist in fields
|
|
198
|
-
// example1 :- index=_internal | timechart count
|
|
199
|
-
// example2 :- index=_internal | timechart max(count) avg(count)
|
|
200
119
|
splitDataSources = {};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
120
|
+
for (let i = 1; i < fields.length; i += 1) {
|
|
121
|
+
const fieldName = fields[i].name;
|
|
122
|
+
if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
|
|
123
|
+
splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
|
|
124
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
125
|
+
);
|
|
207
126
|
splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
|
|
208
127
|
splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
|
|
209
128
|
}
|
|
210
129
|
}
|
|
211
130
|
} else {
|
|
212
|
-
errorCode =
|
|
131
|
+
errorCode = "INVALID_SPLIT_BY_FIELD";
|
|
213
132
|
}
|
|
214
|
-
|
|
215
|
-
return {
|
|
216
|
-
splitDataSources: splitDataSources,
|
|
217
|
-
errorCode: errorCode
|
|
218
|
-
};
|
|
133
|
+
return { splitDataSources, errorCode };
|
|
219
134
|
};
|
|
220
|
-
|
|
221
|
-
exports.dataSourcesSplitByAggregationsTimechartAndChart = dataSourcesSplitByAggregationsTimechartAndChart;
|
|
222
|
-
|
|
223
|
-
var dataSourcesSplitByAggregationsStats = function dataSourcesSplitByAggregationsStats(dataSource) {
|
|
135
|
+
var dataSourcesSplitByAggregationsStats = (dataSource) => {
|
|
224
136
|
var _a, _b, _c, _d;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (typeof fields[0] !== 'string') {
|
|
233
|
-
splitByFields = (0, trellisUtils_1.extractDataSourceAggregationKeysStats)(fields);
|
|
137
|
+
const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
|
|
138
|
+
const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
|
|
139
|
+
let splitDataSources = null;
|
|
140
|
+
let splitByFields = [];
|
|
141
|
+
let errorCode = null;
|
|
142
|
+
if (typeof fields[0] !== "string") {
|
|
143
|
+
splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
|
|
234
144
|
}
|
|
235
|
-
|
|
236
145
|
if (splitByFields && splitByFields.length > 0) {
|
|
237
146
|
splitDataSources = {};
|
|
238
|
-
splitByFields.forEach(
|
|
239
|
-
splitDataSources[splitByField] = (0,
|
|
147
|
+
splitByFields.forEach((splitByField) => {
|
|
148
|
+
splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
|
|
149
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
150
|
+
);
|
|
240
151
|
splitDataSources[splitByField].primary.data.fields = [fields[0]];
|
|
241
152
|
splitDataSources[splitByField].primary.data.columns = [columns[0]];
|
|
242
|
-
|
|
243
|
-
return field.name === splitByField;
|
|
244
|
-
});
|
|
245
|
-
|
|
153
|
+
const idx = fields.findIndex((field) => field.name === splitByField);
|
|
246
154
|
if (idx > 0) {
|
|
247
155
|
splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
|
|
248
156
|
splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
|
|
249
157
|
}
|
|
250
158
|
});
|
|
251
159
|
} else {
|
|
252
|
-
errorCode =
|
|
160
|
+
errorCode = "INVALID_SPLIT_BY_FIELD";
|
|
253
161
|
}
|
|
254
|
-
|
|
255
|
-
return {
|
|
256
|
-
splitDataSources: splitDataSources,
|
|
257
|
-
errorCode: errorCode
|
|
258
|
-
};
|
|
162
|
+
return { splitDataSources, errorCode };
|
|
259
163
|
};
|
|
260
|
-
|
|
261
|
-
exports.dataSourcesSplitByAggregationsStats = dataSourcesSplitByAggregationsStats;
|
|
262
|
-
|
|
263
|
-
var dataSourcesSplitByModeTimechart = function dataSourcesSplitByModeTimechart(dataSource, splitBy) {
|
|
164
|
+
var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
|
|
264
165
|
var _a, _b, _c, _d, _e;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (typeof fields[0] !== 'string') {
|
|
273
|
-
splitByFields = (0, trellisUtils_1.extractSplitByFieldsChartFields)(fields);
|
|
166
|
+
const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
|
|
167
|
+
const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
|
|
168
|
+
let splitDataSources = null;
|
|
169
|
+
let splitByFields = [];
|
|
170
|
+
let errorCode = null;
|
|
171
|
+
if (typeof fields[0] !== "string") {
|
|
172
|
+
splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
|
|
274
173
|
}
|
|
275
|
-
|
|
276
174
|
if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
|
|
277
175
|
splitDataSources = {};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
// not including internal fields
|
|
283
|
-
if (!((_e = fields[i].name) === null || _e === void 0 ? void 0 : _e.startsWith('_'))) {
|
|
176
|
+
const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
|
|
177
|
+
const valueKeys = [];
|
|
178
|
+
for (let i = 1; i < fields.length; i += 1) {
|
|
179
|
+
if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
|
|
284
180
|
valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
|
|
285
181
|
}
|
|
286
182
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
183
|
+
valueKeys.forEach((val) => {
|
|
184
|
+
splitDataSources[val] = (0, lodash_exports.cloneDeep)(
|
|
185
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
186
|
+
);
|
|
187
|
+
splitDataSources[val].primary.data.fields = [
|
|
188
|
+
{ name: fields[0].name },
|
|
189
|
+
...dataSourceKeys.map((k) => ({
|
|
294
190
|
name: k
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
splitDataSources[val].primary.data.columns = [
|
|
298
|
-
dataSourceKeys.forEach(
|
|
299
|
-
fields.forEach(
|
|
191
|
+
}))
|
|
192
|
+
];
|
|
193
|
+
splitDataSources[val].primary.data.columns = [[...columns[0]]];
|
|
194
|
+
dataSourceKeys.forEach((dsKey) => {
|
|
195
|
+
fields.forEach((field, idx) => {
|
|
300
196
|
if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
|
|
301
|
-
splitDataSources[val].primary.data.columns.push(
|
|
197
|
+
splitDataSources[val].primary.data.columns.push([...columns[idx]]);
|
|
302
198
|
}
|
|
303
199
|
});
|
|
304
200
|
});
|
|
305
201
|
});
|
|
306
202
|
} else {
|
|
307
|
-
errorCode =
|
|
203
|
+
errorCode = "INVALID_SPLIT_BY_FIELD";
|
|
308
204
|
}
|
|
309
|
-
|
|
310
|
-
return {
|
|
311
|
-
splitDataSources: splitDataSources,
|
|
312
|
-
errorCode: errorCode
|
|
313
|
-
};
|
|
205
|
+
return { splitDataSources, errorCode };
|
|
314
206
|
};
|
|
315
|
-
|
|
316
|
-
exports.dataSourcesSplitByModeTimechart = dataSourcesSplitByModeTimechart;
|
|
317
|
-
|
|
318
|
-
var dataSourcesSplitByModeChart = function dataSourcesSplitByModeChart(dataSource, splitBy) {
|
|
207
|
+
var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
|
|
319
208
|
var _a, _b, _c, _d;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (typeof fields[0] !== 'string') {
|
|
328
|
-
splitByFields = (0, trellisUtils_1.extractSplitByFieldsChartFields)(fields);
|
|
209
|
+
const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
|
|
210
|
+
const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
|
|
211
|
+
let splitDataSources = null;
|
|
212
|
+
let splitByFields = [];
|
|
213
|
+
let errorCode = null;
|
|
214
|
+
if (typeof fields[0] !== "string") {
|
|
215
|
+
splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
|
|
329
216
|
}
|
|
330
|
-
|
|
331
217
|
if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
|
|
332
218
|
splitDataSources = {};
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
var dataSourceKeys = (0, trellisUtils_1.extractDataSourceAggregationKeysChart)(fields);
|
|
340
|
-
var nonDataSourceAggregations = [];
|
|
341
|
-
|
|
342
|
-
if (!dataSourceKeys.length && fields[0].groupby_rank === '0' && fields.length && !fields[1].groupby_rank) {
|
|
343
|
-
/* check for another aggregation scenario where no key 'data_source' will be returned (applies for both chart and stats cmd)
|
|
344
|
-
For example :-
|
|
345
|
-
index=_internal | chart count by status
|
|
346
|
-
index = "_internal" | chart max(count) avg(count) by status
|
|
347
|
-
index = "_internal" | stats max(count) avg(count) by status
|
|
348
|
-
where field meta info is in this format -
|
|
349
|
-
"fields": [
|
|
350
|
-
{
|
|
351
|
-
"name": "status",
|
|
352
|
-
"groupby_rank": "0"
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
"name": "max(count)"
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
"name": "avg(count)"
|
|
359
|
-
}
|
|
360
|
-
]
|
|
361
|
-
*/
|
|
362
|
-
for (var i = 1; i < fields.length; i += 1) {
|
|
219
|
+
const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
|
|
220
|
+
const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
|
|
221
|
+
const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
|
|
222
|
+
const nonDataSourceAggregations = [];
|
|
223
|
+
if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
|
|
224
|
+
for (let i = 1; i < fields.length; i += 1) {
|
|
363
225
|
nonDataSourceAggregations.push(fields[i].name);
|
|
364
226
|
}
|
|
365
227
|
}
|
|
366
|
-
|
|
367
228
|
if (splitByFieldIdx === 0) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
229
|
+
const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
|
|
230
|
+
valueKeys.forEach((val, idx) => {
|
|
231
|
+
splitDataSources[val] = (0, lodash_exports.cloneDeep)(
|
|
232
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
233
|
+
);
|
|
372
234
|
splitDataSources[val].primary.data.fields = [];
|
|
373
|
-
|
|
374
235
|
if (otherSplitBy.length) {
|
|
375
|
-
splitDataSources[val].primary.data.fields = [{
|
|
376
|
-
name: otherSplitBy[0]
|
|
377
|
-
}]; // there can only be one otherSplitBy for chart cmd
|
|
236
|
+
splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
|
|
378
237
|
}
|
|
379
|
-
|
|
380
238
|
if (dataSourceKeys.length) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
splitDataSources[val].primary.data.fields
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
239
|
+
const columnValues = [[]];
|
|
240
|
+
splitDataSources[val].primary.data.fields = [
|
|
241
|
+
...splitDataSources[val].primary.data.fields,
|
|
242
|
+
...dataSourceKeys.map((k) => ({
|
|
243
|
+
name: k
|
|
244
|
+
}))
|
|
245
|
+
];
|
|
246
|
+
dataSourceKeys.forEach(() => {
|
|
247
|
+
columnValues.push([]);
|
|
248
|
+
});
|
|
249
|
+
for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
|
|
250
|
+
columnValues[0].push(
|
|
251
|
+
fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
|
|
252
|
+
);
|
|
253
|
+
dataSourceKeys.forEach((dskey, dsIndx) => {
|
|
254
|
+
const mul = (fields.length - 1) / dataSourceKeys.length;
|
|
255
|
+
columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
|
|
390
256
|
});
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
* For eg - index = "_internal" | chart avg(count) max(count) by status , user) can result in fields and columns as below where "data_source" keys are "avg(count)" and "max(count)"
|
|
394
|
-
* 'fields' : [
|
|
395
|
-
{
|
|
396
|
-
"name": "status",
|
|
397
|
-
"groupby_rank": "0"
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
"name": "avg(count): userA",
|
|
401
|
-
"data_source": "avg(count)",
|
|
402
|
-
"splitby_field": "user",
|
|
403
|
-
"splitby_value": "userA"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
"name": "avg(count): userB",
|
|
407
|
-
"data_source": "avg(count)",
|
|
408
|
-
"splitby_field": "user",
|
|
409
|
-
"splitby_value": "userB"
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
"name": "avg(count): userC",
|
|
413
|
-
"data_source": "avg(count)",
|
|
414
|
-
"splitby_field": "user",
|
|
415
|
-
"splitby_value": "userC"
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
"name": "max(count): userA",
|
|
419
|
-
"data_source": "max(count)",
|
|
420
|
-
"splitby_field": "user",
|
|
421
|
-
"splitby_value": "userA"
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
"name": "max(count): userB",
|
|
425
|
-
"data_source": "max(count)",
|
|
426
|
-
"splitby_field": "user",
|
|
427
|
-
"splitby_value": "userB"
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
"name": "max(count): userC",
|
|
431
|
-
"data_source": "max(count)",
|
|
432
|
-
"splitby_field": "user",
|
|
433
|
-
"splitby_value": "userC"
|
|
434
|
-
},
|
|
435
|
-
]
|
|
436
|
-
'columns' : [['200','303','304','400'], ['1','2','3','4'], ['10','20','30','40'], ['100','200','300','400'], ['5','6','7','8'], ['50','60','70','80'],['500','600','700','800']]
|
|
437
|
-
In this case when we split row wise, the data_source keys for userA appears in indices [1, 4, ..], the data_source keys for userB appears in indices [2, 5, ..]
|
|
438
|
-
The resulting dataSplit for status '200', will have the fields => ['user','avg(count)', 'max(count)'] columns => [['userA', 'userB', 'userC'],['1','10','100'], ['5', '50', '500'] ]
|
|
439
|
-
For the example above for..loop below will iterate from i= 1 to 3 (Math.ceil((fields.length - 1) / dataSourceKeys.length)). Exclude i = 0 as first column is the splitBy input.
|
|
440
|
-
Since there are 2 data_source keys 'avg(count)' and 'max(count)', dataSourceKeys.forEach loop will collect individual arrays specific to the columnValues[indx] as below.
|
|
441
|
-
columnValues[0] = ['userA', 'userB', 'userC']
|
|
442
|
-
columnValues[1] = ['1','10','100']
|
|
443
|
-
columnValues[2] = ['5', '50', '500']
|
|
444
|
-
*/
|
|
445
|
-
|
|
446
|
-
var _loop = function _loop(_i) {
|
|
447
|
-
columnValues[0].push(fields[_i].splitby_value ? fields[_i].splitby_value : fields[_i].name);
|
|
448
|
-
dataSourceKeys.forEach(function (dskey, dsIndx) {
|
|
449
|
-
var mul = (fields.length - 1) / dataSourceKeys.length; // This line does the index calculation
|
|
450
|
-
|
|
451
|
-
columnValues[dsIndx + 1].push(columns[_i + dsIndx * mul][idx]);
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
for (var _i = 1; _i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); _i += 1) {
|
|
456
|
-
_loop(_i);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
splitDataSources[val].primary.data.columns = columnValues;
|
|
460
|
-
})();
|
|
257
|
+
}
|
|
258
|
+
splitDataSources[val].primary.data.columns = columnValues;
|
|
461
259
|
} else if (nonDataSourceAggregations.length) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
// index=_internal | chart count by status
|
|
465
|
-
// index = "_internal" | chart max(count) avg(count) by status
|
|
466
|
-
// index = "_internal" | stats max(count) avg(count) by status
|
|
467
|
-
var columnValues = [];
|
|
468
|
-
fields.forEach(function (aggregationField, fieldIdx) {
|
|
260
|
+
const columnValues = [];
|
|
261
|
+
fields.forEach((aggregationField, fieldIdx) => {
|
|
469
262
|
if (fieldIdx > 0) {
|
|
470
263
|
splitDataSources[val].primary.data.fields.push(aggregationField);
|
|
471
264
|
columnValues.push([columns[fieldIdx][idx]]);
|
|
@@ -475,139 +268,134 @@ var dataSourcesSplitByModeChart = function dataSourcesSplitByModeChart(dataSourc
|
|
|
475
268
|
}
|
|
476
269
|
});
|
|
477
270
|
} else {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
for (var _i2 = 1; _i2 < fields.length; _i2 += 1) {
|
|
482
|
-
_valueKeys.push(fields[_i2].splitby_value ? fields[_i2].splitby_value : fields[_i2].name);
|
|
271
|
+
const valueKeys = [];
|
|
272
|
+
for (let i = 1; i < fields.length; i += 1) {
|
|
273
|
+
valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
|
|
483
274
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
275
|
+
valueKeys.forEach((val) => {
|
|
276
|
+
splitDataSources[val] = (0, lodash_exports.cloneDeep)(
|
|
277
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
278
|
+
);
|
|
279
|
+
splitDataSources[val].primary.data.fields = [
|
|
280
|
+
{ name: otherSplitBy[0] },
|
|
281
|
+
...dataSourceKeys.map((k) => ({
|
|
491
282
|
name: k
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
splitDataSources[val].primary.data.columns = [
|
|
495
|
-
dataSourceKeys.forEach(
|
|
496
|
-
fields.forEach(
|
|
283
|
+
}))
|
|
284
|
+
];
|
|
285
|
+
splitDataSources[val].primary.data.columns = [[...columns[0]]];
|
|
286
|
+
dataSourceKeys.forEach((dsKey) => {
|
|
287
|
+
fields.forEach((field, idx) => {
|
|
497
288
|
if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
|
|
498
|
-
splitDataSources[val].primary.data.columns.push(
|
|
289
|
+
splitDataSources[val].primary.data.columns.push([...columns[idx]]);
|
|
499
290
|
}
|
|
500
291
|
});
|
|
501
292
|
});
|
|
502
293
|
});
|
|
503
294
|
}
|
|
504
295
|
} else {
|
|
505
|
-
errorCode =
|
|
296
|
+
errorCode = "INVALID_SPLIT_BY_FIELD";
|
|
506
297
|
}
|
|
507
|
-
|
|
508
|
-
return {
|
|
509
|
-
splitDataSources: splitDataSources,
|
|
510
|
-
errorCode: errorCode
|
|
511
|
-
};
|
|
298
|
+
return { splitDataSources, errorCode };
|
|
512
299
|
};
|
|
513
|
-
|
|
514
|
-
exports.dataSourcesSplitByModeChart = dataSourcesSplitByModeChart;
|
|
515
|
-
/**
|
|
516
|
-
* This method does datasplitting for 'stats' and generic cmds('makeresults','table' etc - categoried as 'unknown' splitMode).
|
|
517
|
-
* The main difference is for 'stats' cmd possible splitBy fields have 'group_by_rank' in field meta info, whereas for 'unknown' cmd it can be any fieldnames
|
|
518
|
-
*/
|
|
519
|
-
|
|
520
|
-
var dataSourcesSplitByModeStatsorUnknown = function dataSourcesSplitByModeStatsorUnknown(dataSource, splitBy, splitMode) {
|
|
300
|
+
var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
|
|
521
301
|
var _a, _b, _c, _d, _e, _f;
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (typeof fields[0] !== 'string') {
|
|
530
|
-
splitByFields = splitMode !== trellisUtils_1.UNKNOWN ? (0, trellisUtils_1.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_1.extractSplitByFieldsForUnknown)(fields);
|
|
302
|
+
const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
|
|
303
|
+
const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
|
|
304
|
+
let splitDataSources = null;
|
|
305
|
+
let splitByFields = [];
|
|
306
|
+
let errorCode = null;
|
|
307
|
+
if (typeof fields[0] !== "string") {
|
|
308
|
+
splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
|
|
531
309
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
});
|
|
536
|
-
|
|
310
|
+
const splitByIndex = fields == null ? void 0 : fields.findIndex(
|
|
311
|
+
(field) => field === splitBy || field.name === splitBy
|
|
312
|
+
);
|
|
537
313
|
if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
|
|
538
|
-
|
|
314
|
+
const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
|
|
539
315
|
splitDataSources = {};
|
|
540
|
-
splitByColumn.forEach(
|
|
316
|
+
splitByColumn.forEach((val, idx) => {
|
|
541
317
|
if (!splitDataSources[val]) {
|
|
542
318
|
splitDataSources[val] = [idx];
|
|
543
319
|
} else {
|
|
544
320
|
splitDataSources[val].push(idx);
|
|
545
321
|
}
|
|
546
322
|
});
|
|
547
|
-
|
|
323
|
+
const cloneFields = (0, lodash_exports.cloneDeep)(fields);
|
|
548
324
|
cloneFields.splice(splitByIndex, 1);
|
|
549
|
-
|
|
550
|
-
valueKeys.forEach(
|
|
551
|
-
|
|
552
|
-
splitDataSources[val] = (0,
|
|
325
|
+
const valueKeys = Object.keys(splitDataSources);
|
|
326
|
+
valueKeys.forEach((val) => {
|
|
327
|
+
const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
|
|
328
|
+
splitDataSources[val] = (0, lodash_exports.cloneDeep)(
|
|
329
|
+
(0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
|
|
330
|
+
);
|
|
553
331
|
splitDataSources[val].primary.data.fields = cloneFields;
|
|
554
332
|
splitDataSources[val].primary.data.columns = [];
|
|
555
|
-
columns.forEach(
|
|
333
|
+
columns.forEach((col, idx) => {
|
|
556
334
|
if (idx !== splitByIndex) {
|
|
557
|
-
|
|
558
|
-
return col[valIdx];
|
|
559
|
-
});
|
|
335
|
+
const newCol = valIndices.map((valIdx) => col[valIdx]);
|
|
560
336
|
splitDataSources[val].primary.data.columns.push(newCol);
|
|
561
337
|
}
|
|
562
338
|
});
|
|
563
339
|
});
|
|
564
340
|
} else {
|
|
565
|
-
errorCode =
|
|
341
|
+
errorCode = "INVALID_SPLIT_BY_FIELD";
|
|
566
342
|
}
|
|
567
|
-
|
|
568
|
-
return {
|
|
569
|
-
splitDataSources: splitDataSources,
|
|
570
|
-
errorCode: errorCode
|
|
571
|
-
};
|
|
343
|
+
return { splitDataSources, errorCode };
|
|
572
344
|
};
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
var getTrellisDataSourcesBySplitMode = function getTrellisDataSourcesBySplitMode(splitMode, dataSources, trellisSplitBy) {
|
|
577
|
-
var result = null;
|
|
578
|
-
|
|
345
|
+
var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
|
|
346
|
+
let result = null;
|
|
579
347
|
try {
|
|
580
|
-
if (splitMode ===
|
|
581
|
-
result = trellisSplitBy ===
|
|
582
|
-
} else if (splitMode ===
|
|
583
|
-
result = trellisSplitBy ===
|
|
584
|
-
} else if (splitMode ===
|
|
585
|
-
result = trellisSplitBy ===
|
|
586
|
-
} else if (splitMode ===
|
|
587
|
-
result = trellisSplitBy ===
|
|
348
|
+
if (splitMode === trellisUtils_exports.TIMECHART) {
|
|
349
|
+
result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
|
|
350
|
+
} else if (splitMode === trellisUtils_exports.STATS) {
|
|
351
|
+
result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
|
|
352
|
+
} else if (splitMode === trellisUtils_exports.CHART) {
|
|
353
|
+
result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
|
|
354
|
+
} else if (splitMode === trellisUtils_exports.UNKNOWN) {
|
|
355
|
+
result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
|
|
588
356
|
}
|
|
589
357
|
} catch (ex) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
result = {
|
|
593
|
-
splitDataSources: null,
|
|
594
|
-
errorCode: 'UNKNOWN'
|
|
595
|
-
};
|
|
358
|
+
console.error("getTrellisDataSourcesBySplitMode ", ex);
|
|
359
|
+
result = { splitDataSources: null, errorCode: "UNKNOWN" };
|
|
596
360
|
}
|
|
597
|
-
|
|
598
361
|
return result;
|
|
599
362
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
363
|
+
var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
|
|
364
|
+
if (isTrellisOn && !options.legendDisplay) {
|
|
365
|
+
return {
|
|
366
|
+
legendDisplay: "off"
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
return {};
|
|
370
|
+
};
|
|
371
|
+
var calculateSharedMinMax = (splitData) => {
|
|
372
|
+
let max = -Infinity;
|
|
373
|
+
let min = Infinity;
|
|
374
|
+
Object.keys(splitData).forEach((splitByKey) => {
|
|
375
|
+
const datasources = splitData[splitByKey];
|
|
376
|
+
Object.keys(datasources).forEach((datasourceName) => {
|
|
377
|
+
const dataColumns = datasources[datasourceName].data.columns;
|
|
378
|
+
dataColumns.forEach((column) => {
|
|
379
|
+
column.forEach((point) => {
|
|
380
|
+
const pointNumber = Number(point);
|
|
381
|
+
if (pointNumber > max) {
|
|
382
|
+
max = pointNumber;
|
|
383
|
+
}
|
|
384
|
+
if (pointNumber < min) {
|
|
385
|
+
min = pointNumber;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
return [min, max];
|
|
392
|
+
};
|
|
393
|
+
var determineMinMax = (splitData, trellisSharedScale, yAxisMin, yAxisMax, stackMode) => {
|
|
394
|
+
if (!trellisSharedScale || stackMode === "stacked100" || yAxisMin !== "auto" && yAxisMax !== "auto")
|
|
395
|
+
return [yAxisMin, yAxisMax];
|
|
396
|
+
const [sharedMin, sharedMax] = calculateSharedMinMax(splitData);
|
|
397
|
+
const shouldUseSharedMax = sharedMax !== -Infinity && yAxisMax === "auto";
|
|
398
|
+
const shouldUseSharedMin = sharedMin !== Infinity && yAxisMin === "auto";
|
|
399
|
+
return [shouldUseSharedMin ? sharedMin : yAxisMin, shouldUseSharedMax ? sharedMax : yAxisMax];
|
|
400
|
+
};
|
|
401
|
+
//# sourceMappingURL=trellisUtils.js.map
|