@splunk/visualizations 27.3.0 → 27.4.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 (62) hide show
  1. package/Area.config.js +17 -3
  2. package/Area.config.js.map +2 -2
  3. package/Area.js +19 -5
  4. package/Area.js.map +2 -2
  5. package/Bar.config.js +17 -3
  6. package/Bar.config.js.map +3 -3
  7. package/Bar.js +19 -5
  8. package/Bar.js.map +3 -3
  9. package/Bubble.config.js +1 -1
  10. package/Bubble.config.js.map +2 -2
  11. package/Bubble.js +3 -3
  12. package/Bubble.js.map +2 -2
  13. package/CHANGELOG.external.md +1610 -0
  14. package/ChoroplethSvg.js +2 -2
  15. package/Column.config.js +17 -3
  16. package/Column.config.js.map +3 -3
  17. package/Column.js +19 -5
  18. package/Column.js.map +3 -3
  19. package/Ellipse.js +2 -2
  20. package/Events.js +2 -2
  21. package/FillerGauge.config.js +8 -28
  22. package/FillerGauge.config.js.map +2 -2
  23. package/FillerGauge.js +10 -30
  24. package/FillerGauge.js.map +2 -2
  25. package/Image.js +2 -2
  26. package/Line.config.js +17 -3
  27. package/Line.config.js.map +3 -3
  28. package/Line.js +19 -5
  29. package/Line.js.map +3 -3
  30. package/LinkGraph.js +2 -2
  31. package/Map.config.js +11 -0
  32. package/Map.config.js.map +2 -2
  33. package/Map.js +64 -27
  34. package/Map.js.map +2 -2
  35. package/Markdown.js +2 -2
  36. package/MarkerGauge.config.js +8 -25
  37. package/MarkerGauge.config.js.map +2 -2
  38. package/MarkerGauge.js +10 -27
  39. package/MarkerGauge.js.map +2 -2
  40. package/ParallelCoordinates.js +2 -2
  41. package/Pie.config.js +123 -3
  42. package/Pie.config.js.map +3 -3
  43. package/Pie.js +736 -16
  44. package/Pie.js.map +4 -4
  45. package/Punchcard.js +2 -2
  46. package/Rectangle.js +2 -2
  47. package/Sankey.js +2 -2
  48. package/Scatter.config.js +313 -113
  49. package/Scatter.config.js.map +4 -4
  50. package/Scatter.js +922 -125
  51. package/Scatter.js.map +4 -4
  52. package/SingleValue.js +2 -2
  53. package/SingleValueIcon.js +2 -2
  54. package/SingleValueRadial.js +2 -2
  55. package/TRELLIS.md +12 -3
  56. package/Table.js +2 -2
  57. package/Timeline.js +81 -63
  58. package/Timeline.js.map +4 -4
  59. package/common/utils/mapUtils.js +16 -8
  60. package/common/utils/mapUtils.js.map +2 -2
  61. package/common/withDashboardViz.js +2 -2
  62. package/package.json +17 -17
package/Pie.js CHANGED
@@ -1070,6 +1070,111 @@ var background = ({
1070
1070
  ];
1071
1071
  var BackgroundColor_default = background;
1072
1072
 
1073
+ // src/common/editorConfig/TrellisEditors.ts
1074
+ var isTrellisFeatureFlagOn = ({ featureFlags }) => {
1075
+ return Boolean(featureFlags == null ? void 0 : featureFlags.visualizations_enableTrellis);
1076
+ };
1077
+ var isTrellisEnabled = ({ options, featureFlags }) => {
1078
+ const { splitByLayout = visualization_schemas_exports.LAYOUT_TYPE.Off } = options;
1079
+ return isTrellisFeatureFlagOn({ featureFlags }) && splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
1080
+ };
1081
+ var TrellisEditorConfig = [
1082
+ [
1083
+ {
1084
+ label: (0, i18n_exports._)("Trellis layout"),
1085
+ option: "splitByLayout",
1086
+ editor: "editor.toggle",
1087
+ showEditor: isTrellisFeatureFlagOn
1088
+ }
1089
+ ],
1090
+ [
1091
+ {
1092
+ label: (0, i18n_exports._)("Split by"),
1093
+ option: "trellisSplitBy",
1094
+ editor: "editor.trellisSplitBy",
1095
+ editorProps: {
1096
+ dataSourceKey: "primary"
1097
+ },
1098
+ showEditor: isTrellisEnabled
1099
+ }
1100
+ ],
1101
+ [
1102
+ {
1103
+ label: (0, i18n_exports._)("Number of columns"),
1104
+ option: "trellisColumns",
1105
+ editor: "editor.number",
1106
+ editorProps: {
1107
+ min: 1
1108
+ },
1109
+ placeholder: (0, i18n_exports._)("Auto"),
1110
+ showEditor: isTrellisEnabled
1111
+ }
1112
+ ],
1113
+ [
1114
+ {
1115
+ label: (0, i18n_exports._)("Min column width"),
1116
+ option: "trellisMinColumnWidth",
1117
+ editor: "editor.number",
1118
+ editorProps: {
1119
+ min: 1
1120
+ },
1121
+ showEditor: isTrellisEnabled
1122
+ },
1123
+ {
1124
+ label: (0, i18n_exports._)("Row height"),
1125
+ option: "trellisRowHeight",
1126
+ editor: "editor.number",
1127
+ editorProps: {
1128
+ min: 1
1129
+ },
1130
+ showEditor: isTrellisEnabled
1131
+ }
1132
+ ],
1133
+ [
1134
+ {
1135
+ label: (0, i18n_exports._)("Max number of components per page"),
1136
+ option: "trellisPageCount",
1137
+ editor: "editor.number",
1138
+ editorProps: {
1139
+ min: 1
1140
+ },
1141
+ showEditor: isTrellisEnabled
1142
+ }
1143
+ ]
1144
+ ];
1145
+ var TimechartTrellisEditorConfig = [
1146
+ [
1147
+ {
1148
+ label: (0, i18n_exports._)("Trellis layout"),
1149
+ option: "splitByLayout",
1150
+ editor: "editor.toggle",
1151
+ showEditor: isTrellisFeatureFlagOn,
1152
+ // add help text for timecharts
1153
+ editorProps: {
1154
+ help: (0, i18n_exports._)(
1155
+ "Y2-axis and overlay field configurations are not supported when trellis is enabled."
1156
+ ),
1157
+ helpFormat: "under"
1158
+ }
1159
+ }
1160
+ ],
1161
+ ...TrellisEditorConfig.slice(1),
1162
+ [
1163
+ {
1164
+ label: (0, i18n_exports._)("Shared y-axis scale"),
1165
+ option: "trellisSharedScale",
1166
+ editor: "editor.checkbox",
1167
+ showEditor: isTrellisEnabled
1168
+ }
1169
+ ]
1170
+ ];
1171
+ var TrellisBackgroundColorEditor = {
1172
+ label: (0, i18n_exports._)("Trellis background"),
1173
+ option: "trellisBackgroundColor",
1174
+ editor: "editor.color",
1175
+ showEditor: isTrellisEnabled
1176
+ };
1177
+
1073
1178
  // src/Pie/config.ts
1074
1179
  var dataContract = {
1075
1180
  requiredDataSources: [
@@ -1101,6 +1206,13 @@ var themes = {
1101
1206
  light: variables_default.backgroundColor(props)
1102
1207
  },
1103
1208
  prisma: variables_default.backgroundColorSidebar(props)
1209
+ })(props),
1210
+ defaultFontColor: (props) => pick_default({
1211
+ enterprise: {
1212
+ dark: variables_default.textColor(props),
1213
+ light: variables_default.textColor(props)
1214
+ },
1215
+ prisma: variables_default.contentColorDefault(props)
1104
1216
  })(props)
1105
1217
  };
1106
1218
  var editorConfig = [
@@ -1186,7 +1298,8 @@ var editorConfig = [
1186
1298
  option: "collapseLabel",
1187
1299
  editor: "editor.text"
1188
1300
  }
1189
- ]
1301
+ ],
1302
+ ...TrellisEditorConfig
1190
1303
  ]
1191
1304
  },
1192
1305
  {
@@ -1199,7 +1312,14 @@ var editorConfig = [
1199
1312
  editor: "editor.seriesColors"
1200
1313
  }
1201
1314
  ],
1202
- BackgroundColor_default({ themes })
1315
+ BackgroundColor_default({ themes }),
1316
+ [
1317
+ __spreadProps(__spreadValues({}, TrellisBackgroundColorEditor), {
1318
+ editorProps: {
1319
+ themes
1320
+ }
1321
+ })
1322
+ ]
1203
1323
  ]
1204
1324
  }
1205
1325
  ];
@@ -1228,7 +1348,7 @@ var config = {
1228
1348
  description: "triggered when user clicks on a point in the pie chart"
1229
1349
  }
1230
1350
  },
1231
- supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "placeholder" /* PLACEHOLDER */, "events" /* EVENTS */],
1351
+ supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "placeholder" /* PLACEHOLDER */, "events" /* EVENTS */, "trellis" /* TRELLIS */],
1232
1352
  themes
1233
1353
  };
1234
1354
  var config_default = enhanceConfig(config);
@@ -1557,7 +1677,7 @@ var withFixedSizeContainer = (Viz) => {
1557
1677
  FixSizeItem,
1558
1678
  {
1559
1679
  "data-test": "fix-size-item",
1560
- "data-splunk-visualization-version": "27.3.0 - bd2e687fd",
1680
+ "data-splunk-visualization-version": "27.4.0 - 92ef39d5c",
1561
1681
  width,
1562
1682
  height,
1563
1683
  backgroundColor
@@ -1623,7 +1743,7 @@ var Cover = styled_components_default.div`
1623
1743
  bottom: 0;
1624
1744
  `;
1625
1745
  var Blocker = styled_components_default.div.attrs({
1626
- "data-splunk-visualization-version": "27.3.0 - bd2e687fd"
1746
+ "data-splunk-visualization-version": "27.4.0 - 92ef39d5c"
1627
1747
  })`
1628
1748
  position: relative;
1629
1749
  width: 100%;
@@ -1895,6 +2015,309 @@ __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisU
1895
2015
  var trellisUtils_default = "default" in defaultImport35 ? defaultImport35.default : defaultImport35;
1896
2016
 
1897
2017
  // src/common/utils/trellisUtils.ts
2018
+ var AGGREGATIONS = "aggregations";
2019
+ var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
2020
+ var _a, _b, _c, _d;
2021
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2022
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2023
+ let splitDataSources = null;
2024
+ let errorCode = null;
2025
+ if (fields && fields.length) {
2026
+ splitDataSources = {};
2027
+ for (let i = 0; i < fields.length; i += 1) {
2028
+ const fieldName = fields[i].name;
2029
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
2030
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
2031
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2032
+ );
2033
+ splitDataSources[fieldName].primary.data.fields = [fields[i]];
2034
+ splitDataSources[fieldName].primary.data.columns = [columns[i]];
2035
+ }
2036
+ }
2037
+ } else {
2038
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2039
+ }
2040
+ return { splitDataSources, errorCode };
2041
+ };
2042
+ var toFieldEntries = (fields) => {
2043
+ return fields.map((field) => {
2044
+ if (typeof field === "string") {
2045
+ return { name: field };
2046
+ }
2047
+ return field;
2048
+ });
2049
+ };
2050
+ var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
2051
+ var _a, _b, _c, _d;
2052
+ const fields = toFieldEntries((_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields);
2053
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2054
+ let splitDataSources = null;
2055
+ let splitByFields = [];
2056
+ let errorCode = null;
2057
+ if (typeof fields[0] !== "string") {
2058
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2059
+ }
2060
+ if (splitByFields && splitByFields.length > 0) {
2061
+ splitDataSources = {};
2062
+ splitByFields.forEach((splitByField) => {
2063
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
2064
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2065
+ );
2066
+ splitDataSources[splitByField].primary.data.fields = [fields[0]];
2067
+ splitDataSources[splitByField].primary.data.columns = [columns[0]];
2068
+ fields.forEach((field, idx) => {
2069
+ const fieldName = field == null ? void 0 : field.name;
2070
+ if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
2071
+ splitDataSources[splitByField].primary.data.fields.push(field);
2072
+ splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
2073
+ }
2074
+ });
2075
+ });
2076
+ } else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
2077
+ splitDataSources = {};
2078
+ for (let i = 1; i < fields.length; i += 1) {
2079
+ const fieldName = fields[i].name;
2080
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
2081
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
2082
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2083
+ );
2084
+ splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
2085
+ splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
2086
+ }
2087
+ }
2088
+ } else {
2089
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2090
+ }
2091
+ return { splitDataSources, errorCode };
2092
+ };
2093
+ var dataSourcesSplitByAggregationsStats = (dataSource) => {
2094
+ var _a, _b, _c, _d;
2095
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2096
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2097
+ let splitDataSources = null;
2098
+ let splitByFields = [];
2099
+ let errorCode = null;
2100
+ if (typeof fields[0] !== "string") {
2101
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
2102
+ }
2103
+ if (splitByFields && splitByFields.length > 0) {
2104
+ splitDataSources = {};
2105
+ splitByFields.forEach((splitByField) => {
2106
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
2107
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2108
+ );
2109
+ splitDataSources[splitByField].primary.data.fields = [fields[0]];
2110
+ splitDataSources[splitByField].primary.data.columns = [columns[0]];
2111
+ const idx = fields.findIndex((field) => field.name === splitByField);
2112
+ if (idx > 0) {
2113
+ splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
2114
+ splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
2115
+ }
2116
+ });
2117
+ } else {
2118
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2119
+ }
2120
+ return { splitDataSources, errorCode };
2121
+ };
2122
+ var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
2123
+ var _a, _b, _c, _d, _e;
2124
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2125
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2126
+ let splitDataSources = null;
2127
+ let splitByFields = [];
2128
+ let errorCode = null;
2129
+ if (typeof fields[0] !== "string") {
2130
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
2131
+ }
2132
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2133
+ splitDataSources = {};
2134
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2135
+ const valueKeys = [];
2136
+ for (let i = 1; i < fields.length; i += 1) {
2137
+ if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
2138
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
2139
+ }
2140
+ }
2141
+ valueKeys.forEach((val) => {
2142
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2143
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2144
+ );
2145
+ splitDataSources[val].primary.data.fields = [
2146
+ { name: fields[0].name },
2147
+ ...dataSourceKeys.map((k) => ({
2148
+ name: k
2149
+ }))
2150
+ ];
2151
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
2152
+ dataSourceKeys.forEach((dsKey) => {
2153
+ fields.forEach((field, idx) => {
2154
+ if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
2155
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
2156
+ }
2157
+ });
2158
+ });
2159
+ });
2160
+ } else {
2161
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2162
+ }
2163
+ return { splitDataSources, errorCode };
2164
+ };
2165
+ var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
2166
+ var _a, _b, _c, _d;
2167
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2168
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2169
+ let splitDataSources = null;
2170
+ let splitByFields = [];
2171
+ let errorCode = null;
2172
+ if (typeof fields[0] !== "string") {
2173
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
2174
+ }
2175
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2176
+ splitDataSources = {};
2177
+ const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
2178
+ const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
2179
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2180
+ const nonDataSourceAggregations = [];
2181
+ if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
2182
+ for (let i = 1; i < fields.length; i += 1) {
2183
+ nonDataSourceAggregations.push(fields[i].name);
2184
+ }
2185
+ }
2186
+ if (splitByFieldIdx === 0) {
2187
+ const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
2188
+ valueKeys.forEach((val, idx) => {
2189
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2190
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2191
+ );
2192
+ splitDataSources[val].primary.data.fields = [];
2193
+ if (otherSplitBy.length) {
2194
+ splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
2195
+ }
2196
+ if (dataSourceKeys.length) {
2197
+ const columnValues = [[]];
2198
+ splitDataSources[val].primary.data.fields = [
2199
+ ...splitDataSources[val].primary.data.fields,
2200
+ ...dataSourceKeys.map((k) => ({
2201
+ name: k
2202
+ }))
2203
+ ];
2204
+ dataSourceKeys.forEach(() => {
2205
+ columnValues.push([]);
2206
+ });
2207
+ for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
2208
+ columnValues[0].push(
2209
+ fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
2210
+ );
2211
+ dataSourceKeys.forEach((dskey, dsIndx) => {
2212
+ const mul = (fields.length - 1) / dataSourceKeys.length;
2213
+ columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
2214
+ });
2215
+ }
2216
+ splitDataSources[val].primary.data.columns = columnValues;
2217
+ } else if (nonDataSourceAggregations.length) {
2218
+ const columnValues = [];
2219
+ fields.forEach((aggregationField, fieldIdx) => {
2220
+ if (fieldIdx > 0) {
2221
+ splitDataSources[val].primary.data.fields.push(aggregationField);
2222
+ columnValues.push([columns[fieldIdx][idx]]);
2223
+ }
2224
+ });
2225
+ splitDataSources[val].primary.data.columns = columnValues;
2226
+ }
2227
+ });
2228
+ } else {
2229
+ const valueKeys = [];
2230
+ for (let i = 1; i < fields.length; i += 1) {
2231
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
2232
+ }
2233
+ valueKeys.forEach((val) => {
2234
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2235
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2236
+ );
2237
+ splitDataSources[val].primary.data.fields = [
2238
+ { name: otherSplitBy[0] },
2239
+ ...dataSourceKeys.map((k) => ({
2240
+ name: k
2241
+ }))
2242
+ ];
2243
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
2244
+ dataSourceKeys.forEach((dsKey) => {
2245
+ fields.forEach((field, idx) => {
2246
+ if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
2247
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
2248
+ }
2249
+ });
2250
+ });
2251
+ });
2252
+ }
2253
+ } else {
2254
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2255
+ }
2256
+ return { splitDataSources, errorCode };
2257
+ };
2258
+ var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
2259
+ var _a, _b, _c, _d, _e, _f;
2260
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2261
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2262
+ let splitDataSources = null;
2263
+ let splitByFields = [];
2264
+ let errorCode = null;
2265
+ if (typeof fields[0] !== "string") {
2266
+ splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
2267
+ }
2268
+ const splitByIndex = fields == null ? void 0 : fields.findIndex(
2269
+ (field) => field === splitBy || field.name === splitBy
2270
+ );
2271
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2272
+ const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
2273
+ splitDataSources = {};
2274
+ splitByColumn.forEach((val, idx) => {
2275
+ if (!splitDataSources[val]) {
2276
+ splitDataSources[val] = [idx];
2277
+ } else {
2278
+ splitDataSources[val].push(idx);
2279
+ }
2280
+ });
2281
+ const cloneFields = (0, lodash_exports.cloneDeep)(fields);
2282
+ cloneFields.splice(splitByIndex, 1);
2283
+ const valueKeys = Object.keys(splitDataSources);
2284
+ valueKeys.forEach((val) => {
2285
+ const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
2286
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2287
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2288
+ );
2289
+ splitDataSources[val].primary.data.fields = cloneFields;
2290
+ splitDataSources[val].primary.data.columns = [];
2291
+ columns.forEach((col, idx) => {
2292
+ if (idx !== splitByIndex) {
2293
+ const newCol = valIndices.map((valIdx) => col[valIdx]);
2294
+ splitDataSources[val].primary.data.columns.push(newCol);
2295
+ }
2296
+ });
2297
+ });
2298
+ } else {
2299
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2300
+ }
2301
+ return { splitDataSources, errorCode };
2302
+ };
2303
+ var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
2304
+ let result = null;
2305
+ try {
2306
+ if (splitMode === trellisUtils_exports.TIMECHART) {
2307
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
2308
+ } else if (splitMode === trellisUtils_exports.STATS) {
2309
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
2310
+ } else if (splitMode === trellisUtils_exports.CHART) {
2311
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
2312
+ } else if (splitMode === trellisUtils_exports.UNKNOWN) {
2313
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
2314
+ }
2315
+ } catch (ex) {
2316
+ console.error("getTrellisDataSourcesBySplitMode ", ex);
2317
+ result = { splitDataSources: null, errorCode: "UNKNOWN" };
2318
+ }
2319
+ return result;
2320
+ };
1898
2321
  var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
1899
2322
  if (isTrellisOn && !options.legendDisplay) {
1900
2323
  return {
@@ -1903,6 +2326,36 @@ var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
1903
2326
  }
1904
2327
  return {};
1905
2328
  };
2329
+ var calculateSharedMinMax = (splitData) => {
2330
+ let max = -Infinity;
2331
+ let min = Infinity;
2332
+ Object.keys(splitData).forEach((splitByKey) => {
2333
+ const datasources = splitData[splitByKey];
2334
+ Object.keys(datasources).forEach((datasourceName) => {
2335
+ const dataColumns = datasources[datasourceName].data.columns;
2336
+ dataColumns.forEach((column) => {
2337
+ column.forEach((point) => {
2338
+ const pointNumber = Number(point);
2339
+ if (pointNumber > max) {
2340
+ max = pointNumber;
2341
+ }
2342
+ if (pointNumber < min) {
2343
+ min = pointNumber;
2344
+ }
2345
+ });
2346
+ });
2347
+ });
2348
+ });
2349
+ return [min, max];
2350
+ };
2351
+ var determineMinMax = (splitData, trellisSharedScale, yAxisMin, yAxisMax, stackMode) => {
2352
+ if (!trellisSharedScale || stackMode === "stacked100" || yAxisMin !== "auto" && yAxisMax !== "auto")
2353
+ return [yAxisMin, yAxisMax];
2354
+ const [sharedMin, sharedMax] = calculateSharedMinMax(splitData);
2355
+ const shouldUseSharedMax = sharedMax !== -Infinity && yAxisMax === "auto";
2356
+ const shouldUseSharedMin = sharedMin !== Infinity && yAxisMin === "auto";
2357
+ return [shouldUseSharedMin ? sharedMin : yAxisMin, shouldUseSharedMax ? sharedMax : yAxisMax];
2358
+ };
1906
2359
 
1907
2360
  // src/common/withDashboardViz.tsx
1908
2361
  var withDashboardViz = (opts) => {
@@ -1962,10 +2415,10 @@ var withDashboardViz = (opts) => {
1962
2415
  const isDownsamplingEnabledByFeatureFlag = Boolean(
1963
2416
  featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
1964
2417
  );
1965
- const isTrellisFeatureFlagOn = Boolean(
2418
+ const isTrellisFeatureFlagOn2 = Boolean(
1966
2419
  featureFlagContext && featureFlagContext.visualizations_enableTrellis
1967
2420
  );
1968
- const isTrellisOn = isTrellisFeatureFlagOn && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (options == null ? void 0 : options.splitByLayout) === "trellis" /* TRELLIS */;
2421
+ const isTrellisOn = isTrellisFeatureFlagOn2 && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (options == null ? void 0 : options.splitByLayout) === "trellis" /* TRELLIS */;
1969
2422
  const isMounted = react_exports.useRef(true);
1970
2423
  const optionsToEvaluate = react_exports.useMemo(() => {
1971
2424
  var _a2;
@@ -2278,6 +2731,258 @@ var truncateData = (dataSet, truncationLimit) => {
2278
2731
  return truncatedData;
2279
2732
  };
2280
2733
 
2734
+ // esm-externals:@splunk/react-ui/Paginator
2735
+ var Paginator_exports = {};
2736
+ __export(Paginator_exports, {
2737
+ default: () => Paginator_default
2738
+ });
2739
+ var defaultImport38 = __toESM(require("@splunk/react-ui/Paginator"));
2740
+ __reExport(Paginator_exports, require("@splunk/react-ui/Paginator"));
2741
+ var Paginator_default = "default" in defaultImport38 ? defaultImport38.default : defaultImport38;
2742
+
2743
+ // esm-externals:@splunk/themes
2744
+ var themes_exports = {};
2745
+ __export(themes_exports, {
2746
+ default: () => themes_default
2747
+ });
2748
+ var defaultImport39 = __toESM(require("@splunk/themes"));
2749
+ __reExport(themes_exports, require("@splunk/themes"));
2750
+ var themes_default = "default" in defaultImport39 ? defaultImport39.default : defaultImport39;
2751
+
2752
+ // src/common/hocs/withTrellis.tsx
2753
+ var TrellisContainer = styled_components_default.div`
2754
+ overflow: hidden;
2755
+ display: flex;
2756
+ flex-direction: column;
2757
+ background-color: ${(props) => props.backgroundColor};
2758
+ ${(props) => (0, style_exports.toDimension)((0, lodash_exports.pick)(props, ["width", "height"]))};
2759
+ > [data-test='paginator'] {
2760
+ align-self: flex-end;
2761
+ margin-bottom: 10px;
2762
+ }
2763
+ `;
2764
+ var TrellisContainerGrid = styled_components_default.div`
2765
+ display: grid;
2766
+ height: ${(props) => {
2767
+ return `${props.height}px`;
2768
+ }};
2769
+ gap: 10px 10px;
2770
+ grid-template-columns: ${(props) => {
2771
+ return props.colCount ? `repeat(${props.colCount}, minmax(${props.colMinWidth}px, 1fr))` : `repeat(auto-fit, minmax(${props.colMinWidth}px, 1fr))`;
2772
+ }};
2773
+ overflow: auto;
2774
+ justify-items: stretch;
2775
+ grid-auto-rows: ${(props) => `${props.rowHeight}px`};
2776
+ .child {
2777
+ height: ${(props) => `${props.rowHeight}px`};
2778
+ }
2779
+ `;
2780
+ var showErrorMessage = (errorCode, width, height) => {
2781
+ if (errorCode === "INVALID_SPLIT_BY_FIELD") {
2782
+ return /* @__PURE__ */ react_exports.createElement(
2783
+ Message_default,
2784
+ {
2785
+ width,
2786
+ height,
2787
+ message: (0, i18n_exports._)("Select a valid trellis split by field"),
2788
+ level: "info"
2789
+ }
2790
+ );
2791
+ }
2792
+ if (errorCode === "UNKNOWN_DATA_SPLIT_MODE") {
2793
+ return /* @__PURE__ */ react_exports.createElement(Message_default, { width, height, message: (0, i18n_exports._)("Unknown data split mode"), level: "info" });
2794
+ }
2795
+ return /* @__PURE__ */ react_exports.createElement(Message_default, { width, height, message: (0, i18n_exports._)("Error render in trellis"), level: "info" });
2796
+ };
2797
+ var withTrellis = (Viz) => {
2798
+ const VizWithTrellis = (opts) => {
2799
+ const cachedHandleResize = react_exports.useCallback((w, h) => {
2800
+ setContainerWidth(w);
2801
+ setContainerHeight(h);
2802
+ }, []);
2803
+ const [containerWidth, setContainerWidth] = react_exports.useState(Number(opts.width));
2804
+ const [containerHeight, setContainerHeight] = react_exports.useState(Number(opts.height));
2805
+ const _a = opts, { options = {}, height, width } = _a, otherProps = __objRest(_a, ["options", "height", "width"]);
2806
+ const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(Viz.config.optionsSchema, "default");
2807
+ const mergedOptions = (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions);
2808
+ const {
2809
+ trellisColumns,
2810
+ trellisPageCount,
2811
+ trellisMinColumnWidth,
2812
+ trellisRowHeight,
2813
+ splitByLayout,
2814
+ trellisSplitBy,
2815
+ trellisSharedScale,
2816
+ stackMode,
2817
+ yAxisMin,
2818
+ yAxisMax
2819
+ } = mergedOptions;
2820
+ const colCount = trellisColumns > 0 ? trellisColumns : defaultOptions.trellisColumns;
2821
+ const pageCount = +trellisPageCount > 0 ? +trellisPageCount : defaultOptions.trellisPageCount;
2822
+ const colMinWidth = trellisMinColumnWidth > 0 ? trellisMinColumnWidth : defaultOptions.trellisMinColumnWidth;
2823
+ const rowHeight = trellisRowHeight > 0 ? trellisRowHeight : defaultOptions.trellisRowHeight;
2824
+ const [pageNum, setPageNum] = (0, react_exports.useState)(1);
2825
+ const [pagedData, setPagedData] = (0, react_exports.useState)(null);
2826
+ let splitByKeys = [];
2827
+ let totalPages = 0;
2828
+ let showPaginator = false;
2829
+ const { dataSources } = otherProps;
2830
+ const theme = {
2831
+ splunkThemeV1: useSplunkTheme_default()
2832
+ };
2833
+ const {
2834
+ family: currentThemeFamily,
2835
+ colorScheme: currentThemeColorScheme,
2836
+ density: currentThemeDensity
2837
+ } = (0, themes_exports.getSettingsFromThemedProps)({ theme });
2838
+ const trellisBackgroundColor = (0, react_exports.useMemo)(() => {
2839
+ const themeFunc = (themeVar) => {
2840
+ var _a2, _b;
2841
+ return (_b = (_a2 = Viz.config.themes)[themeVar]) == null ? void 0 : _b.call(_a2, {
2842
+ trellisBackgroundColor: mergedOptions.trellisBackgroundColor,
2843
+ theme
2844
+ });
2845
+ };
2846
+ const evaluated = Options_exports.Options.evaluate(
2847
+ {
2848
+ context: Viz.config.context,
2849
+ options: { trellisBackgroundColor: mergedOptions.trellisBackgroundColor }
2850
+ },
2851
+ {},
2852
+ themeFunc
2853
+ );
2854
+ return evaluated.trellisBackgroundColor;
2855
+ }, [
2856
+ mergedOptions.trellisBackgroundColor,
2857
+ currentThemeFamily,
2858
+ currentThemeColorScheme,
2859
+ currentThemeDensity
2860
+ ]);
2861
+ const columns = (0, lodash_exports.get)(dataSources, "primary.data.columns", void 0);
2862
+ const fields = (0, lodash_exports.get)(dataSources, "primary.data.fields", void 0);
2863
+ const noColumns = columns === void 0;
2864
+ const noFields = fields === void 0;
2865
+ const updateDataDisplay = (currPage) => {
2866
+ if (!showPaginator) {
2867
+ setPagedData(splitByKeys);
2868
+ setPageNum(1);
2869
+ } else {
2870
+ const startIdx = pageCount * (currPage - 1);
2871
+ const paged = splitByKeys.slice(startIdx, startIdx + pageCount);
2872
+ setPagedData(paged);
2873
+ }
2874
+ };
2875
+ (0, react_exports.useEffect)(() => {
2876
+ setPageNum(1);
2877
+ updateDataDisplay(1);
2878
+ }, [pageCount, trellisSplitBy]);
2879
+ (0, react_exports.useEffect)(() => {
2880
+ updateDataDisplay(pageNum);
2881
+ }, [columns, fields, trellisSplitBy, pageNum, splitByLayout]);
2882
+ const handlePageChange = (0, react_exports.useCallback)(
2883
+ (event, { page }) => {
2884
+ setPageNum(page);
2885
+ },
2886
+ [pageNum, pagedData]
2887
+ );
2888
+ const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2889
+ const isTrellisFeatureFlagOn2 = Boolean(
2890
+ featureFlagContext && featureFlagContext.visualizations_enableTrellis
2891
+ );
2892
+ if (!isTrellisFeatureFlagOn2 || !splitByLayout || splitByLayout !== visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
2893
+ return /* @__PURE__ */ react_exports.createElement(Viz, __spreadValues({}, opts));
2894
+ }
2895
+ if (splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
2896
+ if (noColumns || noFields) {
2897
+ return /* @__PURE__ */ react_exports.createElement(Message_default, { width, height, message: (0, i18n_exports._)("Loading"), level: "info" });
2898
+ }
2899
+ let currTrellisSplitBy = trellisSplitBy;
2900
+ if (!trellisSplitBy || trellisSplitBy.length === 0) {
2901
+ const splitByPossibleFields = (0, trellisUtils_exports.getAllPossibleSplitByFields)(fields);
2902
+ currTrellisSplitBy = splitByPossibleFields.fields && splitByPossibleFields.fields.length ? splitByPossibleFields.fields[0] : AGGREGATIONS;
2903
+ }
2904
+ const splitMode = (0, trellisUtils_exports.getTrellisDataSplitterMode)(fields);
2905
+ const dataSplitResult = getTrellisDataSourcesBySplitMode(
2906
+ splitMode,
2907
+ dataSources,
2908
+ currTrellisSplitBy
2909
+ );
2910
+ const modifiedDataSourceBySplitBy = dataSplitResult == null ? void 0 : dataSplitResult.splitDataSources;
2911
+ const dataSplitErrorCode = dataSplitResult == null ? void 0 : dataSplitResult.errorCode;
2912
+ if (!modifiedDataSourceBySplitBy || Object.keys(modifiedDataSourceBySplitBy).length === 0 || dataSplitErrorCode) {
2913
+ return showErrorMessage(dataSplitErrorCode, width, height);
2914
+ }
2915
+ const splitByKeysModified = modifiedDataSourceBySplitBy ? Object.keys(modifiedDataSourceBySplitBy) : [];
2916
+ if (splitByKeysModified) {
2917
+ showPaginator = splitByKeysModified.length > pageCount;
2918
+ splitByKeys = splitByKeysModified;
2919
+ totalPages = splitByKeysModified ? Math.ceil(splitByKeysModified.length / pageCount) : 0;
2920
+ }
2921
+ const [calculatedMin, calculatedMax] = determineMinMax(
2922
+ modifiedDataSourceBySplitBy,
2923
+ trellisSharedScale,
2924
+ yAxisMin,
2925
+ yAxisMax,
2926
+ stackMode
2927
+ );
2928
+ return /* @__PURE__ */ react_exports.createElement(TrellisContainer, { height, width, backgroundColor: trellisBackgroundColor }, /* @__PURE__ */ react_exports.createElement(
2929
+ TrellisContainerGrid,
2930
+ {
2931
+ height,
2932
+ colCount,
2933
+ colMinWidth,
2934
+ rowHeight
2935
+ },
2936
+ pagedData == null ? void 0 : pagedData.map((splitByKey, idx) => /* @__PURE__ */ react_exports.createElement(
2937
+ "div",
2938
+ {
2939
+ className: "child",
2940
+ "data-test": "trellis-child",
2941
+ key: `div-child-${idx.toString()}`
2942
+ },
2943
+ /* @__PURE__ */ react_exports.createElement(
2944
+ SizeAwareWrapper_default,
2945
+ {
2946
+ width,
2947
+ height,
2948
+ onResize: cachedHandleResize
2949
+ }
2950
+ ),
2951
+ /* @__PURE__ */ react_exports.createElement(
2952
+ Viz,
2953
+ __spreadProps(__spreadValues({}, otherProps), {
2954
+ trellisKey: splitByKey,
2955
+ trellisSplitBy: currTrellisSplitBy,
2956
+ dataSources: modifiedDataSourceBySplitBy[splitByKey],
2957
+ options: __spreadProps(__spreadValues({}, options), {
2958
+ yAxisMin: calculatedMin,
2959
+ yAxisMax: calculatedMax
2960
+ }),
2961
+ key: `viz-${idx.toString()}`,
2962
+ height: containerHeight,
2963
+ width: containerWidth
2964
+ })
2965
+ )
2966
+ ))
2967
+ ), showPaginator && totalPages >= pageNum && /* @__PURE__ */ react_exports.createElement(
2968
+ Paginator_default,
2969
+ {
2970
+ onChange: handlePageChange,
2971
+ current: pageNum,
2972
+ alwaysShowLastPageLink: true,
2973
+ totalPages
2974
+ }
2975
+ ));
2976
+ }
2977
+ return null;
2978
+ };
2979
+ VizWithTrellis.propTypes = Viz.proptypes;
2980
+ VizWithTrellis.defaultProps = Viz.defaultProps;
2981
+ VizWithTrellis.config = Viz.config;
2982
+ return VizWithTrellis;
2983
+ };
2984
+ var withTrellis_default = withTrellis;
2985
+
2281
2986
  // src/Pie/Pie.tsx
2282
2987
  var validOptions = Object.keys(config_default.optionsSchema);
2283
2988
  var PieInnerSize = 0.7;
@@ -2288,16 +2993,29 @@ var computeVizProps = (_a) => {
2288
2993
  label,
2289
2994
  value,
2290
2995
  showDonutHole,
2291
- visualizationApiRef
2996
+ visualizationApiRef,
2997
+ trellisKey,
2998
+ trellisSplitBy,
2999
+ themeFunc
2292
3000
  } = _b, otherOptions = __objRest(_b, [
2293
3001
  "dataSources",
2294
3002
  "onEventTrigger",
2295
3003
  "label",
2296
3004
  "value",
2297
3005
  "showDonutHole",
2298
- "visualizationApiRef"
3006
+ "visualizationApiRef",
3007
+ "trellisKey",
3008
+ "trellisSplitBy",
3009
+ "themeFunc"
2299
3010
  ]);
2300
- const computedProps = { visualizationApiRef, onEventTrigger };
3011
+ const defaultFontColor = themeFunc("defaultFontColor");
3012
+ const computedProps = {
3013
+ visualizationApiRef,
3014
+ onEventTrigger,
3015
+ trellisKey,
3016
+ trellisSplitBy,
3017
+ defaultFontColor
3018
+ };
2301
3019
  const { labelField, valueField, hasEventHandlers } = otherOptions;
2302
3020
  computedProps.options = (0, lodash_exports.chain)(otherOptions).pick(validOptions).thru(convertToPieSCProperties).thru((options) => __spreadProps(__spreadValues({}, (0, simpleXMLOptions_exports.getSimpleXMLOptionsForProps)(options)), { chart: "pie" })).value();
2303
3021
  const truncationLimit = computedProps.options["chart.resultTruncationLimit"];
@@ -2333,12 +3051,14 @@ var computeVizProps = (_a) => {
2333
3051
  return computedProps;
2334
3052
  };
2335
3053
  var showPlaceHolderIcon = (dataSources, loading, options) => shouldShowIconPlaceholder(dataSources, loading) || invalidOptionField("value", dataSources, options, config_default) || invalidOptionField("label", dataSources, options, config_default) || allInvalidDataValues(dataSources, options, config_default);
2336
- var Pie = withDashboardViz_default({
2337
- ReactViz: Charting_default,
2338
- computeVizProps,
2339
- useIconPlaceholder: (dataSources, loading, options) => showPlaceHolderIcon(dataSources, loading, options),
2340
- vizConfig: config_default
2341
- });
3054
+ var Pie = withTrellis_default(
3055
+ withDashboardViz_default({
3056
+ ReactViz: Charting_default,
3057
+ computeVizProps,
3058
+ useIconPlaceholder: (dataSources, loading, options) => showPlaceHolderIcon(dataSources, loading, options),
3059
+ vizConfig: config_default
3060
+ })
3061
+ );
2342
3062
  var themes2 = null;
2343
3063
  var Pie_default = Pie;
2344
3064
  //# sourceMappingURL=Pie.js.map