@splunk/visualizations 27.0.0 → 27.2.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 (89) hide show
  1. package/Area.config.js +269 -122
  2. package/Area.config.js.map +4 -4
  3. package/Area.js +1065 -209
  4. package/Area.js.map +4 -4
  5. package/Bar.config.js +266 -82
  6. package/Bar.config.js.map +4 -4
  7. package/Bar.js +1065 -171
  8. package/Bar.js.map +4 -4
  9. package/Bubble.config.js +127 -1
  10. package/Bubble.config.js.map +4 -4
  11. package/Bubble.js +323 -80
  12. package/Bubble.js.map +4 -4
  13. package/ChoroplethSvg.js +64 -37
  14. package/ChoroplethSvg.js.map +4 -4
  15. package/Column.config.js +271 -82
  16. package/Column.config.js.map +4 -4
  17. package/Column.js +1070 -171
  18. package/Column.js.map +4 -4
  19. package/Ellipse.js +44 -14
  20. package/Ellipse.js.map +4 -4
  21. package/Events.js +172 -527
  22. package/Events.js.map +4 -4
  23. package/FillerGauge.js +45 -15
  24. package/FillerGauge.js.map +4 -4
  25. package/Image.js +42 -12
  26. package/Image.js.map +4 -4
  27. package/Line.config.js +271 -119
  28. package/Line.config.js.map +4 -4
  29. package/Line.js +1067 -206
  30. package/Line.js.map +4 -4
  31. package/LinkGraph.js +584 -545
  32. package/LinkGraph.js.map +4 -4
  33. package/Map.config.js +114 -72
  34. package/Map.config.js.map +4 -4
  35. package/Map.js +177 -94
  36. package/Map.js.map +4 -4
  37. package/Markdown.js +46 -16
  38. package/Markdown.js.map +4 -4
  39. package/MarkerGauge.js +42 -12
  40. package/MarkerGauge.js.map +4 -4
  41. package/ParallelCoordinates.js +123 -87
  42. package/ParallelCoordinates.js.map +4 -4
  43. package/Pie.js +198 -81
  44. package/Pie.js.map +4 -4
  45. package/Punchcard.js +241 -38
  46. package/Punchcard.js.map +4 -4
  47. package/Rectangle.js +56 -26
  48. package/Rectangle.js.map +4 -4
  49. package/Sankey.js +68 -38
  50. package/Sankey.js.map +4 -4
  51. package/Scatter.config.js +127 -1
  52. package/Scatter.config.js.map +4 -4
  53. package/Scatter.js +323 -80
  54. package/Scatter.js.map +4 -4
  55. package/SingleValue.config.js +43 -67
  56. package/SingleValue.config.js.map +4 -4
  57. package/SingleValue.js +1434 -1356
  58. package/SingleValue.js.map +4 -4
  59. package/SingleValueBasic.js +1 -1
  60. package/SingleValueBasic.js.map +3 -3
  61. package/SingleValueIcon.config.js +45 -69
  62. package/SingleValueIcon.config.js.map +4 -4
  63. package/SingleValueIcon.js +1739 -1407
  64. package/SingleValueIcon.js.map +4 -4
  65. package/SingleValueRadial.config.js +43 -67
  66. package/SingleValueRadial.config.js.map +4 -4
  67. package/SingleValueRadial.js +1366 -1273
  68. package/SingleValueRadial.js.map +4 -4
  69. package/SparkLine.js +1 -1
  70. package/SparkLine.js.map +3 -3
  71. package/TRELLIS.md +16 -15
  72. package/Table.js +65 -30
  73. package/Table.js.map +4 -4
  74. package/Timeline.config.js +418 -0
  75. package/Timeline.config.js.map +7 -0
  76. package/Timeline.js +3074 -0
  77. package/Timeline.js.map +7 -0
  78. package/common/Charting.js +133 -27
  79. package/common/Charting.js.map +4 -4
  80. package/common/OptionsDoc.js +8 -3
  81. package/common/OptionsDoc.js.map +2 -2
  82. package/common/utils/mapUtils.js.map +2 -2
  83. package/common/utils/singleValueUtils.js +26 -15
  84. package/common/utils/singleValueUtils.js.map +2 -2
  85. package/common/utils/trellisUtils.js +41 -1
  86. package/common/utils/trellisUtils.js.map +2 -2
  87. package/common/withDashboardViz.js +42 -12
  88. package/common/withDashboardViz.js.map +4 -4
  89. package/package.json +49 -38
@@ -60,7 +60,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
60
60
  ));
61
61
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
62
62
 
63
- // src/SingleValueRadial/SingleValueRadial.tsx
63
+ // src/SingleValueRadial/index.ts
64
64
  var SingleValueRadial_exports = {};
65
65
  __export(SingleValueRadial_exports, {
66
66
  PureSingleValueRadial: () => PureSingleValueRadial,
@@ -117,23 +117,23 @@ var defaultImport5 = __toESM(require("styled-components"));
117
117
  __reExport(styled_components_exports, require("styled-components"));
118
118
  var styled_components_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
119
119
 
120
- // esm-externals:lodash
121
- var lodash_exports = {};
122
- __export(lodash_exports, {
123
- default: () => lodash_default
120
+ // esm-externals:lodash/pick
121
+ var pick_exports2 = {};
122
+ __export(pick_exports2, {
123
+ default: () => pick_default2
124
124
  });
125
- var defaultImport6 = __toESM(require("lodash"));
126
- __reExport(lodash_exports, require("lodash"));
127
- var lodash_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
125
+ var defaultImport6 = __toESM(require("lodash/pick"));
126
+ __reExport(pick_exports2, require("lodash/pick"));
127
+ var pick_default2 = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
128
128
 
129
- // esm-externals:@splunk/visualization-context/FeatureFlagContext
130
- var FeatureFlagContext_exports = {};
131
- __export(FeatureFlagContext_exports, {
132
- default: () => FeatureFlagContext_default
129
+ // esm-externals:lodash/isEmpty
130
+ var isEmpty_exports = {};
131
+ __export(isEmpty_exports, {
132
+ default: () => isEmpty_default
133
133
  });
134
- var defaultImport7 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
135
- __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
136
- var FeatureFlagContext_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
134
+ var defaultImport7 = __toESM(require("lodash/isEmpty"));
135
+ __reExport(isEmpty_exports, require("lodash/isEmpty"));
136
+ var isEmpty_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
137
137
 
138
138
  // esm-externals:@splunk/visualizations-shared/style
139
139
  var style_exports = {};
@@ -153,15 +153,6 @@ var defaultImport9 = __toESM(require("@splunk/visualizations-shared/SizeAwareWra
153
153
  __reExport(SizeAwareWrapper_exports, require("@splunk/visualizations-shared/SizeAwareWrapper"));
154
154
  var SizeAwareWrapper_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;
155
155
 
156
- // esm-externals:@splunk/visualization-schemas
157
- var visualization_schemas_exports = {};
158
- __export(visualization_schemas_exports, {
159
- default: () => visualization_schemas_default
160
- });
161
- var defaultImport10 = __toESM(require("@splunk/visualization-schemas"));
162
- __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
163
- var visualization_schemas_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
164
-
165
156
  // src/common/components/VizStyleWrapper.jsx
166
157
  var VizStyleWrapper = styled_components_default.div.attrs(({ dataTestKey }) => ({
167
158
  "data-test": dataTestKey,
@@ -209,6 +200,15 @@ var TrellisTitle = (props) => {
209
200
  );
210
201
  };
211
202
 
203
+ // esm-externals:lodash
204
+ var lodash_exports = {};
205
+ __export(lodash_exports, {
206
+ default: () => lodash_default
207
+ });
208
+ var defaultImport10 = __toESM(require("lodash"));
209
+ __reExport(lodash_exports, require("lodash"));
210
+ var lodash_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
211
+
212
212
  // esm-externals:@splunk/visualizations-shared/numberUtils
213
213
  var numberUtils_exports = {};
214
214
  __export(numberUtils_exports, {
@@ -337,13 +337,13 @@ var computeText = ({
337
337
  return text;
338
338
  };
339
339
  var getMajorText = ({
340
- majorValue,
340
+ majorValueDisplay,
341
341
  numberPrecision,
342
342
  shouldUseThousandSeparators,
343
343
  shouldAbbreviateMajorValue
344
344
  }) => computeText({
345
- value: majorValue === null ? "N/A" : majorValue,
346
- // if majorValue is null, use `N/A`.
345
+ value: majorValueDisplay === null ? "N/A" : majorValueDisplay,
346
+ // if majorValueDisplay is null, use `N/A`.
347
347
  numberPrecision,
348
348
  shouldUseThousandSeparators,
349
349
  shouldAbbreviateValue: shouldAbbreviateMajorValue
@@ -410,6 +410,7 @@ var getMajorAndTrend = ({
410
410
  width,
411
411
  height,
412
412
  majorValue,
413
+ majorValueDisplay,
413
414
  trendValue,
414
415
  majorFontSize,
415
416
  trendFontSize,
@@ -424,7 +425,7 @@ var getMajorAndTrend = ({
424
425
  const textContentWidth = width * 0.9;
425
426
  const textContentHeight = height * 0.9;
426
427
  const majorText = getMajorText({
427
- majorValue,
428
+ majorValueDisplay,
428
429
  numberPrecision,
429
430
  shouldUseThousandSeparators,
430
431
  shouldAbbreviateMajorValue
@@ -482,6 +483,7 @@ var computeSingleValueRadialContent = ({
482
483
  containerWidth,
483
484
  containerHeight,
484
485
  majorValue,
486
+ majorValueDisplay,
485
487
  trendValue,
486
488
  majorFontSize,
487
489
  trendFontSize,
@@ -495,6 +497,7 @@ var computeSingleValueRadialContent = ({
495
497
  }) => {
496
498
  let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
497
499
  majorValue,
500
+ majorValueDisplay: majorValueDisplay || majorValue,
498
501
  trendValue,
499
502
  majorFontSize,
500
503
  trendFontSize,
@@ -511,13 +514,14 @@ var computeSingleValueRadialContent = ({
511
514
  let smallVizProps = {};
512
515
  if (smallViz) {
513
516
  const truncateValue = minimallyTruncateStringToWidth({
514
- text: majorValue,
517
+ text: majorValueDisplay || majorValue,
515
518
  fontWeight: "bold",
516
519
  fontSize: 12,
517
520
  containerWidth
518
521
  });
519
522
  ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({
520
- majorValue: truncateValue,
523
+ majorValueDisplay: truncateValue,
524
+ majorValue,
521
525
  trendValue,
522
526
  majorFontSize,
523
527
  trendFontSize,
@@ -605,16 +609,16 @@ var changeColor = (color, ratio) => {
605
609
  };
606
610
  var lighten = (color) => changeColor(color, 1.3);
607
611
  var darken = (color) => changeColor(color, 0.5);
608
- var handleValueClickCallback = (ev, majorValue, majorValueField, trendValue, onValueClick, trellisEnabled = false, trellisSplityBy = "", trellisKey = "") => {
609
- let payload = {
612
+ var handleValueClickCallback = (ev, majorValue, majorValueField, trendValue, onValueClick, trellisEnabled = false, trellisSplitBy = "", trellisKey = "") => onValueClick(__spreadProps(__spreadValues({}, ev), {
613
+ payload: __spreadValues({
610
614
  trendValue,
611
615
  value: majorValue,
612
616
  name: majorValueField
613
- };
614
- if (trellisEnabled) {
615
- payload = __spreadProps(__spreadValues({}, payload), { "trellis.name": trellisSplityBy, "trellis.value": trellisKey });
616
- }
617
- return onValueClick(__spreadProps(__spreadValues({}, ev), { payload }));
617
+ }, trellisEnabled && { "trellis.name": trellisSplitBy, "trellis.value": trellisKey })
618
+ }));
619
+ var getTrendColorWithPercent = (options) => {
620
+ const shouldUsePercentTrendColor = options.trendColor === "> trendValue | rangeValue(trendColorEditorConfig)" && options.trendDisplay === "percent";
621
+ return shouldUsePercentTrendColor ? { trendColor: "> trendValuePercent | rangeValue(trendColorEditorConfig)" } : {};
618
622
  };
619
623
 
620
624
  // esm-externals:@splunk/react-icons/enterprise/ArrowUp
@@ -1510,10 +1514,38 @@ RadialContent.propTypes = __spreadProps(__spreadValues({}, SingleValueBasic_defa
1510
1514
  });
1511
1515
  var RadialLayout_default = RadialContent;
1512
1516
 
1517
+ // esm-externals:@splunk/visualization-context/FeatureFlagContext
1518
+ var FeatureFlagContext_exports = {};
1519
+ __export(FeatureFlagContext_exports, {
1520
+ default: () => FeatureFlagContext_default
1521
+ });
1522
+ var defaultImport19 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
1523
+ __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
1524
+ var FeatureFlagContext_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
1525
+
1526
+ // esm-externals:@splunk/visualization-schemas
1527
+ var visualization_schemas_exports = {};
1528
+ __export(visualization_schemas_exports, {
1529
+ default: () => visualization_schemas_default
1530
+ });
1531
+ var defaultImport20 = __toESM(require("@splunk/visualization-schemas"));
1532
+ __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
1533
+ var visualization_schemas_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
1534
+
1535
+ // src/common/hooks/useTrellisEnabled.ts
1536
+ var useTrellisFeatureFlagOn = () => {
1537
+ const context = (0, react_exports.useContext)(FeatureFlagContext_default);
1538
+ return Boolean(context == null ? void 0 : context.visualizations_enableTrellis);
1539
+ };
1540
+ var useTrellisEnabled = (layoutType = visualization_schemas_exports.LAYOUT_TYPE.Off) => {
1541
+ const trellisFeatureEnabled = useTrellisFeatureFlagOn();
1542
+ return trellisFeatureEnabled && layoutType === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
1543
+ };
1544
+
1513
1545
  // src/SingleValueRadial/PureSingleValueRadial/SingleValueRadial.jsx
1514
1546
  var Container = styled_components_default.div`
1515
1547
  overflow: hidden;
1516
- ${(props) => (0, style_exports.toDimension)((0, lodash_exports.pick)(props, ["width", "height"]))};
1548
+ ${(props) => (0, style_exports.toDimension)(pick_default2(props, ["width", "height"]))};
1517
1549
  `;
1518
1550
  var SingleValueRadial = (_a) => {
1519
1551
  var props = __objRest(_a, []);
@@ -1525,6 +1557,7 @@ var SingleValueRadial = (_a) => {
1525
1557
  gaugeRanges,
1526
1558
  majorFontSize,
1527
1559
  majorValue,
1560
+ majorValueDisplay,
1528
1561
  majorValueField,
1529
1562
  minValue,
1530
1563
  maxValue,
@@ -1566,11 +1599,7 @@ var SingleValueRadial = (_a) => {
1566
1599
  const radialColors = getRadialColors({ backgroundEnabled, backgroundColor });
1567
1600
  const radialBackgroundColor = props.radialBackgroundColor || radialColors.background;
1568
1601
  const radialStrokeColor = props.radialStrokeColor || radialColors.stroke;
1569
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
1570
- const isTrellisFeatureFlagOn = Boolean(
1571
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
1572
- );
1573
- const trellisEnabled = isTrellisFeatureFlagOn && splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
1602
+ const trellisEnabled = useTrellisEnabled(splitByLayout);
1574
1603
  const handleValueClick = (0, react_exports.useCallback)(
1575
1604
  (ev) => handleValueClickCallback(
1576
1605
  ev,
@@ -1620,6 +1649,7 @@ var SingleValueRadial = (_a) => {
1620
1649
  smallVizProps
1621
1650
  } = computeSingleValueRadialContent({
1622
1651
  majorValue,
1652
+ majorValueDisplay,
1623
1653
  trendValue,
1624
1654
  majorFontSize,
1625
1655
  trendFontSize,
@@ -1636,7 +1666,7 @@ var SingleValueRadial = (_a) => {
1636
1666
  shouldAbbreviateMajorValue,
1637
1667
  smallViz: !showRadialGraph
1638
1668
  });
1639
- if (!(0, lodash_exports.isEmpty)(smallVizProps)) {
1669
+ if (!isEmpty_default(smallVizProps)) {
1640
1670
  ({ trendDisplay, unit } = smallVizProps);
1641
1671
  }
1642
1672
  const progress = getRadialProgress(majorValue - minValue, minValue, maxValue);
@@ -1698,6 +1728,7 @@ SingleValueRadial.propTypes = {
1698
1728
  height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
1699
1729
  style: prop_types_exports.object,
1700
1730
  majorValue: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
1731
+ majorValueDisplay: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
1701
1732
  majorValueField: prop_types_exports.string,
1702
1733
  majorColor: prop_types_exports.string,
1703
1734
  majorFontSize: prop_types_exports.number,
@@ -1752,81 +1783,81 @@ var getSettingsFromThemedProps_exports = {};
1752
1783
  __export(getSettingsFromThemedProps_exports, {
1753
1784
  default: () => getSettingsFromThemedProps_default
1754
1785
  });
1755
- var defaultImport19 = __toESM(require("@splunk/themes/getSettingsFromThemedProps"));
1786
+ var defaultImport21 = __toESM(require("@splunk/themes/getSettingsFromThemedProps"));
1756
1787
  __reExport(getSettingsFromThemedProps_exports, require("@splunk/themes/getSettingsFromThemedProps"));
1757
- var getSettingsFromThemedProps_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
1788
+ var getSettingsFromThemedProps_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
1758
1789
 
1759
1790
  // esm-externals:@splunk/visualization-encoding/Options
1760
1791
  var Options_exports = {};
1761
1792
  __export(Options_exports, {
1762
1793
  default: () => Options_default
1763
1794
  });
1764
- var defaultImport20 = __toESM(require("@splunk/visualization-encoding/Options"));
1795
+ var defaultImport22 = __toESM(require("@splunk/visualization-encoding/Options"));
1765
1796
  __reExport(Options_exports, require("@splunk/visualization-encoding/Options"));
1766
- var Options_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
1797
+ var Options_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
1767
1798
 
1768
1799
  // esm-externals:@splunk/visualizations-shared/SanitizeProps
1769
1800
  var SanitizeProps_exports = {};
1770
1801
  __export(SanitizeProps_exports, {
1771
1802
  default: () => SanitizeProps_default
1772
1803
  });
1773
- var defaultImport21 = __toESM(require("@splunk/visualizations-shared/SanitizeProps"));
1804
+ var defaultImport23 = __toESM(require("@splunk/visualizations-shared/SanitizeProps"));
1774
1805
  __reExport(SanitizeProps_exports, require("@splunk/visualizations-shared/SanitizeProps"));
1775
- var SanitizeProps_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
1806
+ var SanitizeProps_default = "default" in defaultImport23 ? defaultImport23.default : defaultImport23;
1776
1807
 
1777
1808
  // esm-externals:@splunk/visualization-context/TimezoneContext
1778
1809
  var TimezoneContext_exports = {};
1779
1810
  __export(TimezoneContext_exports, {
1780
1811
  default: () => TimezoneContext_default
1781
1812
  });
1782
- var defaultImport22 = __toESM(require("@splunk/visualization-context/TimezoneContext"));
1813
+ var defaultImport24 = __toESM(require("@splunk/visualization-context/TimezoneContext"));
1783
1814
  __reExport(TimezoneContext_exports, require("@splunk/visualization-context/TimezoneContext"));
1784
- var TimezoneContext_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
1815
+ var TimezoneContext_default = "default" in defaultImport24 ? defaultImport24.default : defaultImport24;
1785
1816
 
1786
1817
  // esm-externals:@splunk/moment
1787
1818
  var moment_exports = {};
1788
1819
  __export(moment_exports, {
1789
1820
  default: () => moment_default
1790
1821
  });
1791
- var defaultImport23 = __toESM(require("@splunk/moment"));
1822
+ var defaultImport25 = __toESM(require("@splunk/moment"));
1792
1823
  __reExport(moment_exports, require("@splunk/moment"));
1793
- var moment_default = "default" in defaultImport23 ? defaultImport23.default : defaultImport23;
1824
+ var moment_default = "default" in defaultImport25 ? defaultImport25.default : defaultImport25;
1794
1825
 
1795
1826
  // esm-externals:@splunk/visualizations-shared/hocUtils
1796
1827
  var hocUtils_exports = {};
1797
1828
  __export(hocUtils_exports, {
1798
1829
  default: () => hocUtils_default
1799
1830
  });
1800
- var defaultImport24 = __toESM(require("@splunk/visualizations-shared/hocUtils"));
1831
+ var defaultImport26 = __toESM(require("@splunk/visualizations-shared/hocUtils"));
1801
1832
  __reExport(hocUtils_exports, require("@splunk/visualizations-shared/hocUtils"));
1802
- var hocUtils_default = "default" in defaultImport24 ? defaultImport24.default : defaultImport24;
1833
+ var hocUtils_default = "default" in defaultImport26 ? defaultImport26.default : defaultImport26;
1803
1834
 
1804
1835
  // esm-externals:@splunk/visualizations-shared/JSONSchemaUtils
1805
1836
  var JSONSchemaUtils_exports = {};
1806
1837
  __export(JSONSchemaUtils_exports, {
1807
1838
  default: () => JSONSchemaUtils_default
1808
1839
  });
1809
- var defaultImport25 = __toESM(require("@splunk/visualizations-shared/JSONSchemaUtils"));
1840
+ var defaultImport27 = __toESM(require("@splunk/visualizations-shared/JSONSchemaUtils"));
1810
1841
  __reExport(JSONSchemaUtils_exports, require("@splunk/visualizations-shared/JSONSchemaUtils"));
1811
- var JSONSchemaUtils_default = "default" in defaultImport25 ? defaultImport25.default : defaultImport25;
1842
+ var JSONSchemaUtils_default = "default" in defaultImport27 ? defaultImport27.default : defaultImport27;
1812
1843
 
1813
1844
  // esm-externals:@splunk/async-dynamic-options-evaluator
1814
1845
  var async_dynamic_options_evaluator_exports = {};
1815
1846
  __export(async_dynamic_options_evaluator_exports, {
1816
1847
  default: () => async_dynamic_options_evaluator_default
1817
1848
  });
1818
- var defaultImport26 = __toESM(require("@splunk/async-dynamic-options-evaluator"));
1849
+ var defaultImport28 = __toESM(require("@splunk/async-dynamic-options-evaluator"));
1819
1850
  __reExport(async_dynamic_options_evaluator_exports, require("@splunk/async-dynamic-options-evaluator"));
1820
- var async_dynamic_options_evaluator_default = "default" in defaultImport26 ? defaultImport26.default : defaultImport26;
1851
+ var async_dynamic_options_evaluator_default = "default" in defaultImport28 ? defaultImport28.default : defaultImport28;
1821
1852
 
1822
1853
  // esm-externals:@splunk/ui-utils/id
1823
1854
  var id_exports = {};
1824
1855
  __export(id_exports, {
1825
1856
  default: () => id_default
1826
1857
  });
1827
- var defaultImport27 = __toESM(require("@splunk/ui-utils/id"));
1858
+ var defaultImport29 = __toESM(require("@splunk/ui-utils/id"));
1828
1859
  __reExport(id_exports, require("@splunk/ui-utils/id"));
1829
- var id_default = "default" in defaultImport27 ? defaultImport27.default : defaultImport27;
1860
+ var id_default = "default" in defaultImport29 ? defaultImport29.default : defaultImport29;
1830
1861
 
1831
1862
  // src/common/interfaces/VizActionHandler.ts
1832
1863
  var DefaultVizActionHandler = class {
@@ -2034,18 +2065,18 @@ var Message_exports = {};
2034
2065
  __export(Message_exports, {
2035
2066
  default: () => Message_default
2036
2067
  });
2037
- var defaultImport28 = __toESM(require("@splunk/visualizations-shared/Message"));
2068
+ var defaultImport30 = __toESM(require("@splunk/visualizations-shared/Message"));
2038
2069
  __reExport(Message_exports, require("@splunk/visualizations-shared/Message"));
2039
- var Message_default = "default" in defaultImport28 ? defaultImport28.default : defaultImport28;
2070
+ var Message_default = "default" in defaultImport30 ? defaultImport30.default : defaultImport30;
2040
2071
 
2041
2072
  // esm-externals:@splunk/visualizations-shared/colorUtils
2042
2073
  var colorUtils_exports = {};
2043
2074
  __export(colorUtils_exports, {
2044
2075
  default: () => colorUtils_default
2045
2076
  });
2046
- var defaultImport29 = __toESM(require("@splunk/visualizations-shared/colorUtils"));
2077
+ var defaultImport31 = __toESM(require("@splunk/visualizations-shared/colorUtils"));
2047
2078
  __reExport(colorUtils_exports, require("@splunk/visualizations-shared/colorUtils"));
2048
- var colorUtils_default = "default" in defaultImport29 ? defaultImport29.default : defaultImport29;
2079
+ var colorUtils_default = "default" in defaultImport31 ? defaultImport31.default : defaultImport31;
2049
2080
 
2050
2081
  // src/common/hocs/FixedSizeContainer.tsx
2051
2082
  var Item = styled_components_default.div.attrs(({ width }) => ({
@@ -2092,7 +2123,7 @@ var withFixedSizeContainer = (Viz) => {
2092
2123
  FixSizeItem,
2093
2124
  {
2094
2125
  "data-test": "fix-size-item",
2095
- "data-splunk-visualization-version": "27.0.0 - 9bf093b7d",
2126
+ "data-splunk-visualization-version": "27.2.0 - 2e7eda8d4",
2096
2127
  width,
2097
2128
  height,
2098
2129
  backgroundColor
@@ -2158,7 +2189,7 @@ var Cover = styled_components_default.div`
2158
2189
  bottom: 0;
2159
2190
  `;
2160
2191
  var Blocker = styled_components_default.div.attrs({
2161
- "data-splunk-visualization-version": "27.0.0 - 9bf093b7d"
2192
+ "data-splunk-visualization-version": "27.2.0 - 2e7eda8d4"
2162
2193
  })`
2163
2194
  position: relative;
2164
2195
  width: 100%;
@@ -2621,9 +2652,9 @@ var FeatureFlags_exports = {};
2621
2652
  __export(FeatureFlags_exports, {
2622
2653
  default: () => FeatureFlags_default
2623
2654
  });
2624
- var defaultImport30 = __toESM(require("@splunk/visualization-context/FeatureFlags"));
2655
+ var defaultImport32 = __toESM(require("@splunk/visualization-context/FeatureFlags"));
2625
2656
  __reExport(FeatureFlags_exports, require("@splunk/visualization-context/FeatureFlags"));
2626
- var FeatureFlags_default = "default" in defaultImport30 ? defaultImport30.default : defaultImport30;
2657
+ var FeatureFlags_default = "default" in defaultImport32 ? defaultImport32.default : defaultImport32;
2627
2658
 
2628
2659
  // src/common/utils/featureFlagUtils.ts
2629
2660
  var getFeatureFlag = (context, flagName) => {
@@ -2636,1254 +2667,1297 @@ var getFeatureFlag = (context, flagName) => {
2636
2667
  return false;
2637
2668
  };
2638
2669
 
2639
- // src/common/withDashboardViz.tsx
2640
- var withDashboardViz = (opts) => {
2641
- const {
2642
- ReactViz,
2643
- vizConfig,
2644
- computeVizProps: computeVizProps2 = () => {
2645
- },
2646
- disableEditModeCover,
2647
- useIconPlaceholder
2648
- } = opts;
2649
- const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
2650
- const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
2651
- const DashboardViz = (props) => {
2652
- var _a;
2653
- const {
2654
- mode,
2655
- hasEventHandlers,
2656
- dataSources,
2657
- // type of { [key: string]: DataSource }
2658
- options,
2659
- context = {},
2660
- width,
2661
- height,
2662
- onComputedProps,
2663
- onEventTrigger,
2664
- theme,
2665
- onRequestParamsChange
2666
- } = props;
2667
- const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
2668
- if (serializedTimezone) {
2669
- if (!moment_default.getDefaultSplunkTimezone()) {
2670
- moment_default.setDefaultSplunkTimezone(serializedTimezone);
2670
+ // esm-externals:@splunk/visualizations-shared/trellisUtils
2671
+ var trellisUtils_exports = {};
2672
+ __export(trellisUtils_exports, {
2673
+ default: () => trellisUtils_default
2674
+ });
2675
+ var defaultImport33 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
2676
+ __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
2677
+ var trellisUtils_default = "default" in defaultImport33 ? defaultImport33.default : defaultImport33;
2678
+
2679
+ // src/common/utils/trellisUtils.ts
2680
+ var AGGREGATIONS = "aggregations";
2681
+ var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
2682
+ var _a, _b, _c, _d;
2683
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2684
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2685
+ let splitDataSources = null;
2686
+ let errorCode = null;
2687
+ if (fields && fields.length) {
2688
+ splitDataSources = {};
2689
+ for (let i = 0; i < fields.length; i += 1) {
2690
+ const fieldName = fields[i].name;
2691
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
2692
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
2693
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2694
+ );
2695
+ splitDataSources[fieldName].primary.data.fields = [fields[i]];
2696
+ splitDataSources[fieldName].primary.data.columns = [columns[i]];
2671
2697
  }
2672
2698
  }
2673
- const themeFunc = (themeVar) => {
2674
- var _a2, _b;
2675
- return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
2676
- };
2677
- const bgColorFromTheme = themeFunc("defaultBackgroundColor");
2678
- const {
2679
- family: currentThemeFamily,
2680
- colorScheme: currentThemeColorScheme,
2681
- density: currentThemeDensity
2682
- } = getSettingsFromThemedProps_default({ theme });
2683
- let evaluatedOptions = {};
2684
- const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
2685
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2686
- const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
2687
- const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
2688
- const [dataFramesInState, setDataFramesInState] = react_exports.useState();
2689
- const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
2690
- Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
2691
- );
2692
- const isDownsamplingEnabledByFeatureFlag = Boolean(
2693
- featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
2694
- );
2695
- const isMounted = react_exports.useRef(true);
2696
- const optionsToEvaluate = react_exports.useMemo(
2697
- () => ({
2698
- context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
2699
- options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
2700
- }),
2701
- [options, context]
2702
- );
2703
- const [threshold, setThreshold] = react_exports.useState(Number(width));
2704
- const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
2705
- setThreshold(newThreshold);
2706
- }, []);
2707
- const isDownsamplingEnabled = react_exports.useMemo(() => {
2708
- return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
2709
- }, [isDownsamplingEnabledByFeatureFlag]);
2710
- const downsamplingProps = react_exports.useMemo(() => {
2711
- if (!isDownsamplingEnabled) {
2712
- return {};
2713
- }
2714
- return {
2715
- onDownsamplingThresholdChange,
2716
- originalDataSources: dataSources
2717
- };
2718
- }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
2719
- const downsampledDataSources = useDownsampleDataSources_default({
2720
- options: optionsToEvaluate.options,
2721
- context: optionsToEvaluate.context,
2722
- dataSources,
2723
- threshold,
2724
- isDownsamplingEnabled
2725
- });
2726
- evaluatedOptions = useDeepMemo(() => {
2727
- try {
2728
- if (useAsyncEvaluatedOptions) {
2729
- const asyncDynamicOptionsEvaluatorParams = {
2730
- visualizationID,
2731
- props,
2732
- options: optionsToEvaluate,
2733
- dataSources: downsampledDataSources,
2734
- theme: vizConfig.themes,
2735
- bypassCloneDeepOptionScope: Boolean(
2736
- getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
2737
- ),
2738
- lazyLoadingDataFrame: Boolean(
2739
- getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
2740
- )
2741
- };
2742
- async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
2743
- setEvaluatedOptionsAsync(results.results);
2744
- }).catch(() => {
2745
- if (isMounted.current) {
2746
- setUseAsyncEvaluatedOptions(false);
2747
- }
2748
- });
2749
- } else {
2750
- let dataFrames = dataFramesInState;
2751
- if (downsampledDataSources !== dataSourcesInState) {
2752
- setDataSourcesInState(downsampledDataSources);
2753
- dataFrames = Options_exports.Options.dataFrameFromDataSource(
2754
- downsampledDataSources,
2755
- getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
2756
- );
2757
- setDataFramesInState(dataFrames);
2758
- }
2759
- const result = Options_exports.Options.evaluate(
2760
- optionsToEvaluate,
2761
- downsampledDataSources,
2762
- themeFunc,
2763
- dataFrames,
2764
- getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
2765
- );
2766
- return result;
2699
+ } else {
2700
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2701
+ }
2702
+ return { splitDataSources, errorCode };
2703
+ };
2704
+ var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
2705
+ var _a, _b, _c, _d;
2706
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2707
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2708
+ let splitDataSources = null;
2709
+ let splitByFields = [];
2710
+ let errorCode = null;
2711
+ if (typeof fields[0] !== "string") {
2712
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2713
+ }
2714
+ if (splitByFields && splitByFields.length > 0) {
2715
+ splitDataSources = {};
2716
+ splitByFields.forEach((splitByField) => {
2717
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
2718
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2719
+ );
2720
+ splitDataSources[splitByField].primary.data.fields = [fields[0]];
2721
+ splitDataSources[splitByField].primary.data.columns = [columns[0]];
2722
+ fields.forEach((field, idx) => {
2723
+ const fieldName = field == null ? void 0 : field.name;
2724
+ if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
2725
+ splitDataSources[splitByField].primary.data.fields.push(field);
2726
+ splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
2767
2727
  }
2768
- } catch (e) {
2769
- console.error(`unexpected error evaluating options: ${e.message}`);
2770
- return {};
2771
- }
2772
- return {};
2773
- }, [
2774
- currentThemeFamily,
2775
- currentThemeColorScheme,
2776
- currentThemeDensity,
2777
- optionsToEvaluate,
2778
- downsampledDataSources,
2779
- serializedTimezone,
2780
- useAsyncEvaluatedOptions
2781
- ]);
2782
- const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
2783
- const isTrellisFeatureFlagOn = Boolean(
2784
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2785
- );
2786
- let clonedEvaluatedOptions = evaluatedOptionsToUse;
2787
- if (isTrellisFeatureFlagOn && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.splitByLayout) === "trellis" /* TRELLIS */) {
2788
- clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
2789
- backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
2790
2728
  });
2791
- }
2792
- react_exports.useEffect(() => {
2793
- onComputedProps(clonedEvaluatedOptions);
2794
2729
  });
2795
- react_exports.useEffect(() => {
2796
- return () => {
2797
- if (useAsyncEvaluatedOptions) {
2798
- isMounted.current = false;
2799
- async_dynamic_options_evaluator_default.reset(visualizationID);
2800
- }
2801
- };
2802
- }, []);
2803
- const { requiredProps = [], supports } = vizConfig;
2804
- const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
2805
- if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
2806
- return /* @__PURE__ */ react_exports.createElement(
2807
- MissingPropsMessage_default,
2808
- {
2809
- "data-test": "missing-props-message",
2810
- width,
2811
- height,
2812
- missingProps: missing,
2813
- backgroundColor: bgColorFromTheme
2814
- }
2730
+ } else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
2731
+ splitDataSources = {};
2732
+ for (let i = 1; i < fields.length; i += 1) {
2733
+ const fieldName = fields[i].name;
2734
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
2735
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
2736
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2737
+ );
2738
+ splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
2739
+ splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
2740
+ }
2741
+ }
2742
+ } else {
2743
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2744
+ }
2745
+ return { splitDataSources, errorCode };
2746
+ };
2747
+ var dataSourcesSplitByAggregationsStats = (dataSource) => {
2748
+ var _a, _b, _c, _d;
2749
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2750
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2751
+ let splitDataSources = null;
2752
+ let splitByFields = [];
2753
+ let errorCode = null;
2754
+ if (typeof fields[0] !== "string") {
2755
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
2756
+ }
2757
+ if (splitByFields && splitByFields.length > 0) {
2758
+ splitDataSources = {};
2759
+ splitByFields.forEach((splitByField) => {
2760
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
2761
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2815
2762
  );
2763
+ splitDataSources[splitByField].primary.data.fields = [fields[0]];
2764
+ splitDataSources[splitByField].primary.data.columns = [columns[0]];
2765
+ const idx = fields.findIndex((field) => field.name === splitByField);
2766
+ if (idx > 0) {
2767
+ splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
2768
+ splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
2769
+ }
2770
+ });
2771
+ } else {
2772
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2773
+ }
2774
+ return { splitDataSources, errorCode };
2775
+ };
2776
+ var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
2777
+ var _a, _b, _c, _d, _e;
2778
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2779
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2780
+ let splitDataSources = null;
2781
+ let splitByFields = [];
2782
+ let errorCode = null;
2783
+ if (typeof fields[0] !== "string") {
2784
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
2785
+ }
2786
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2787
+ splitDataSources = {};
2788
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2789
+ const valueKeys = [];
2790
+ for (let i = 1; i < fields.length; i += 1) {
2791
+ if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
2792
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
2793
+ }
2816
2794
  }
2817
- const eventCallbackProps = {};
2818
- if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
2819
- const supportedEvents = vizConfig.events;
2820
- Object.keys(supportedEvents).forEach((eventName) => {
2821
- const { parentKeys, payloadKeys } = supportedEvents[eventName];
2822
- const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
2823
- let payload = {};
2824
- if (Array.isArray(payloadKeys) && payloadKeys.length) {
2825
- payloadKeys.forEach((p) => {
2826
- payload[p] = evaluatedOptionsToUse[p];
2827
- });
2828
- }
2829
- eventCallbackProps[eventCallbackPropName] = (ev) => {
2830
- if (ev && ev.payload) {
2831
- payload = ev.payload;
2832
- }
2833
- return onEventTrigger({ originalEvent: ev, payload, type: eventName });
2834
- };
2835
- if (parentKeys) {
2836
- for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
2837
- const newObject = {};
2838
- newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
2839
- eventCallbackProps[eventCallbackPropName] = newObject;
2795
+ valueKeys.forEach((val) => {
2796
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2797
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2798
+ );
2799
+ splitDataSources[val].primary.data.fields = [
2800
+ { name: fields[0].name },
2801
+ ...dataSourceKeys.map((k) => ({
2802
+ name: k
2803
+ }))
2804
+ ];
2805
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
2806
+ dataSourceKeys.forEach((dsKey) => {
2807
+ fields.forEach((field, idx) => {
2808
+ if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
2809
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
2840
2810
  }
2841
- }
2811
+ });
2842
2812
  });
2813
+ });
2814
+ } else {
2815
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2816
+ }
2817
+ return { splitDataSources, errorCode };
2818
+ };
2819
+ var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
2820
+ var _a, _b, _c, _d;
2821
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2822
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2823
+ let splitDataSources = null;
2824
+ let splitByFields = [];
2825
+ let errorCode = null;
2826
+ if (typeof fields[0] !== "string") {
2827
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
2828
+ }
2829
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2830
+ splitDataSources = {};
2831
+ const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
2832
+ const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
2833
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2834
+ const nonDataSourceAggregations = [];
2835
+ if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
2836
+ for (let i = 1; i < fields.length; i += 1) {
2837
+ nonDataSourceAggregations.push(fields[i].name);
2838
+ }
2843
2839
  }
2844
- const computedVizProps = computeVizProps2(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
2845
- themeFunc
2846
- }));
2847
- let dataSourceMetadata = {};
2848
- const OptionKey = "paginateDataSourceKey";
2849
- const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
2850
- if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
2851
- const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
2852
- const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
2853
- const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
2854
- const sortParams = getSortingParams({
2855
- requestParams,
2856
- meta,
2857
- onRequestParamsChange: handleRequestParamsChange
2840
+ if (splitByFieldIdx === 0) {
2841
+ const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
2842
+ valueKeys.forEach((val, idx) => {
2843
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2844
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2845
+ );
2846
+ splitDataSources[val].primary.data.fields = [];
2847
+ if (otherSplitBy.length) {
2848
+ splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
2849
+ }
2850
+ if (dataSourceKeys.length) {
2851
+ const columnValues = [[]];
2852
+ splitDataSources[val].primary.data.fields = [
2853
+ ...splitDataSources[val].primary.data.fields,
2854
+ ...dataSourceKeys.map((k) => ({
2855
+ name: k
2856
+ }))
2857
+ ];
2858
+ dataSourceKeys.forEach(() => {
2859
+ columnValues.push([]);
2860
+ });
2861
+ for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
2862
+ columnValues[0].push(
2863
+ fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
2864
+ );
2865
+ dataSourceKeys.forEach((dskey, dsIndx) => {
2866
+ const mul = (fields.length - 1) / dataSourceKeys.length;
2867
+ columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
2868
+ });
2869
+ }
2870
+ splitDataSources[val].primary.data.columns = columnValues;
2871
+ } else if (nonDataSourceAggregations.length) {
2872
+ const columnValues = [];
2873
+ fields.forEach((aggregationField, fieldIdx) => {
2874
+ if (fieldIdx > 0) {
2875
+ splitDataSources[val].primary.data.fields.push(aggregationField);
2876
+ columnValues.push([columns[fieldIdx][idx]]);
2877
+ }
2878
+ });
2879
+ splitDataSources[val].primary.data.columns = columnValues;
2880
+ }
2858
2881
  });
2859
- const paginatorParams = getPaginationParams({
2860
- requestParams,
2861
- meta,
2862
- onRequestParamsChange: handleRequestParamsChange
2882
+ } else {
2883
+ const valueKeys = [];
2884
+ for (let i = 1; i < fields.length; i += 1) {
2885
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
2886
+ }
2887
+ valueKeys.forEach((val) => {
2888
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2889
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2890
+ );
2891
+ splitDataSources[val].primary.data.fields = [
2892
+ { name: otherSplitBy[0] },
2893
+ ...dataSourceKeys.map((k) => ({
2894
+ name: k
2895
+ }))
2896
+ ];
2897
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
2898
+ dataSourceKeys.forEach((dsKey) => {
2899
+ fields.forEach((field, idx) => {
2900
+ if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
2901
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
2902
+ }
2903
+ });
2904
+ });
2863
2905
  });
2864
- dataSourceMetadata = {
2865
- sortParams,
2866
- paginatorParams
2867
- };
2868
- }
2869
- if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
2870
- return null;
2871
2906
  }
2872
- return /* @__PURE__ */ react_exports.createElement(
2873
- SanitizedReactViz,
2874
- __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
2875
- mode,
2876
- width,
2877
- height
2878
- }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
2879
- );
2880
- };
2881
- DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
2882
- DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
2883
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
2884
- theme: {}
2885
- });
2886
- DashboardViz.config = vizConfig;
2887
- return (0, styled_components_exports.withTheme)(
2888
- withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
2889
- );
2907
+ } else {
2908
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2909
+ }
2910
+ return { splitDataSources, errorCode };
2890
2911
  };
2891
- var withDashboardViz_default = withDashboardViz;
2892
-
2893
- // esm-externals:@splunk/visualization-color-palettes/editors/PresetPalettes
2894
- var PresetPalettes_exports = {};
2895
- __export(PresetPalettes_exports, {
2896
- default: () => PresetPalettes_default
2897
- });
2898
- var defaultImport31 = __toESM(require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
2899
- __reExport(PresetPalettes_exports, require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
2900
- var PresetPalettes_default = "default" in defaultImport31 ? defaultImport31.default : defaultImport31;
2901
-
2902
- // esm-externals:@splunk/visualization-icons
2903
- var visualization_icons_exports = {};
2904
- __export(visualization_icons_exports, {
2905
- default: () => visualization_icons_default
2906
- });
2907
- var defaultImport32 = __toESM(require("@splunk/visualization-icons"));
2908
- __reExport(visualization_icons_exports, require("@splunk/visualization-icons"));
2909
- var visualization_icons_default = "default" in defaultImport32 ? defaultImport32.default : defaultImport32;
2910
-
2911
- // esm-externals:@splunk/visualization-icons/placeholders
2912
- var placeholders_exports = {};
2913
- __export(placeholders_exports, {
2914
- default: () => placeholders_default
2915
- });
2916
- var defaultImport33 = __toESM(require("@splunk/visualization-icons/placeholders"));
2917
- __reExport(placeholders_exports, require("@splunk/visualization-icons/placeholders"));
2918
- var placeholders_default = "default" in defaultImport33 ? defaultImport33.default : defaultImport33;
2919
-
2920
- // esm-externals:@splunk/visualizations-shared/configUtils
2921
- var configUtils_exports = {};
2922
- __export(configUtils_exports, {
2923
- default: () => configUtils_default
2924
- });
2925
- var defaultImport34 = __toESM(require("@splunk/visualizations-shared/configUtils"));
2926
- __reExport(configUtils_exports, require("@splunk/visualizations-shared/configUtils"));
2927
- var configUtils_default = "default" in defaultImport34 ? defaultImport34.default : defaultImport34;
2928
-
2929
- // src/common/editorConfig/StaticMajorAndTrendLayout.js
2930
- var StaticMajorAndTrendLayout = [
2931
- [
2932
- {
2933
- label: (0, i18n_exports._)("Unit position"),
2934
- // todo: we need a new editor combining unit and position
2935
- option: "unitPosition",
2936
- editor: "editor.select",
2937
- editorProps: {
2938
- values: [
2939
- { label: (0, i18n_exports._)("Before"), value: "before" },
2940
- { label: (0, i18n_exports._)("After"), value: "after" }
2941
- ]
2942
- },
2943
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2944
- },
2945
- {
2946
- label: (0, i18n_exports._)("Unit label"),
2947
- option: "unit",
2948
- editor: "editor.text",
2949
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2950
- }
2951
- ],
2952
- [
2953
- {
2954
- label: (0, i18n_exports._)("Precision"),
2955
- option: "numberPrecision",
2956
- editor: "editor.number",
2957
- editorProps: {
2958
- min: 0,
2959
- max: 20
2960
- },
2961
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2962
- }
2963
- ]
2964
- ];
2965
- var StaticMajorAndTrendLayout_default = StaticMajorAndTrendLayout;
2966
-
2967
- // src/common/utils/configUtils.ts
2968
- function enhanceConfig(vizConfig) {
2969
- const enhancedConfig = __spreadValues({}, vizConfig);
2970
- enhancedConfig.editorConfig = vizConfig.editorConfig.map(
2971
- (config3) => {
2972
- return __spreadProps(__spreadValues({}, config3), { open: config3.open || false });
2973
- }
2974
- );
2975
- return enhancedConfig;
2976
- }
2977
- function hasCompatibleContexts(vizContext, presetContext) {
2978
- const presetContextKeys = Object.keys(presetContext);
2979
- return presetContextKeys.every(
2980
- (contextKey) => presetContext[contextKey] === void 0 && vizContext[contextKey] === void 0 || presetContext[contextKey] !== void 0 && vizContext[contextKey] !== void 0
2981
- );
2982
- }
2983
- function hasCompatibleOptions(vizOptions, presetOptions) {
2984
- const presetOptionKeys = Object.keys(presetOptions);
2985
- return presetOptionKeys.every(
2986
- (optionKey) => (0, configUtils_exports.isDynamicOption)(presetOptions[optionKey]) === (0, configUtils_exports.isDynamicOption)(vizOptions[optionKey])
2987
- );
2988
- }
2989
- function getInitialPreset(vizContext, vizOptions, presets2) {
2990
- return presets2.find((preset) => {
2991
- const presetContext = (0, lodash_exports.get)(preset, ["value", "context"], {});
2992
- const presetOptions = (0, lodash_exports.get)(preset, ["value", "options"], {});
2993
- const presetContextKeys = Object.keys(presetContext);
2994
- const presetOptionKeys = Object.keys(presetOptions);
2995
- if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
2996
- return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
2997
- });
2998
- }
2999
-
3000
- // src/common/editorConfig/DynamicMajorColorAndGaugeEditor.js
3001
- var getDynamicMajorColorAndGaugeEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
3002
- label: (0, i18n_exports._)("Major value and gauge"),
3003
- option: "majorColor",
3004
- context: "majorColorEditorConfig",
3005
- editor: "editor.dynamicColor",
3006
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.majorColor),
3007
- editorProps: {
3008
- labelPosition: "top",
3009
- flyoutTitle: (0, i18n_exports._)("Dynamic coloring: major value"),
3010
- formatters: [
3011
- {
3012
- label: (0, i18n_exports._)("Ranges"),
3013
- value: "rangeValue",
3014
- defaults: {
3015
- majorValue: defaultContext2.majorColorConfig
3016
- }
3017
- }
3018
- ],
3019
- dataSelectors: [
3020
- {
3021
- label: (0, i18n_exports._)("Major value"),
3022
- value: "majorValue"
3023
- }
3024
- ],
3025
- defaultPalettesConfig: defaultPalettesConfig2
3026
- }
3027
- });
3028
-
3029
- // src/common/editorConfig/DynamicTrendColorEditor.js
3030
- var getDynamicTrendColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
3031
- label: (0, i18n_exports._)("Trend value"),
3032
- option: "trendColor",
3033
- context: "trendColorEditorConfig",
3034
- editor: "editor.dynamicColor",
3035
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.trendColor),
3036
- editorProps: {
3037
- labelPosition: "top",
3038
- flyoutTitle: (0, i18n_exports._)("Dynamic coloring: trend value"),
3039
- formatters: [
3040
- {
3041
- label: (0, i18n_exports._)("Ranges"),
3042
- value: "rangeValue",
3043
- defaults: {
3044
- trendValue: defaultContext2.trendColorConfig
3045
- }
3046
- }
3047
- ],
3048
- dataSelectors: [
3049
- {
3050
- label: (0, i18n_exports._)("Trend value"),
3051
- value: "trendValue"
3052
- }
3053
- ],
3054
- defaultPalettesConfig: defaultPalettesConfig2
2912
+ var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
2913
+ var _a, _b, _c, _d, _e, _f;
2914
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2915
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2916
+ let splitDataSources = null;
2917
+ let splitByFields = [];
2918
+ let errorCode = null;
2919
+ if (typeof fields[0] !== "string") {
2920
+ splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
3055
2921
  }
3056
- });
3057
-
3058
- // src/common/editorConfig/DynamicBackgroundColorEditor.js
3059
- var getDynamicBackgroundColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
3060
- label: (0, i18n_exports._)("Background color"),
3061
- option: "backgroundColor",
3062
- context: "backgroundColorEditorConfig",
3063
- editor: "editor.dynamicColor",
3064
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.backgroundColor),
3065
- editorProps: {
3066
- labelPosition: "top",
3067
- flyoutTitle: (0, i18n_exports._)("Dynamic coloring: background"),
3068
- formatters: [
3069
- {
3070
- label: (0, i18n_exports._)("Ranges"),
3071
- value: "rangeValue",
3072
- defaults: {
3073
- majorValue: defaultContext2.majorColorConfig,
3074
- trendValue: defaultContext2.trendColorConfig
3075
- }
3076
- },
3077
- {
3078
- label: (0, i18n_exports._)("Matches"),
3079
- value: "matchValue",
3080
- defaults: {
3081
- majorValue: defaultContext2.majorColorMatchConfig
3082
- }
3083
- }
3084
- ],
3085
- dataSelectors: [
3086
- {
3087
- label: (0, i18n_exports._)("Major Value"),
3088
- value: "majorValue"
3089
- },
3090
- {
3091
- label: (0, i18n_exports._)("Trend"),
3092
- value: "trendValue"
2922
+ const splitByIndex = fields == null ? void 0 : fields.findIndex(
2923
+ (field) => field === splitBy || field.name === splitBy
2924
+ );
2925
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2926
+ const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
2927
+ splitDataSources = {};
2928
+ splitByColumn.forEach((val, idx) => {
2929
+ if (!splitDataSources[val]) {
2930
+ splitDataSources[val] = [idx];
2931
+ } else {
2932
+ splitDataSources[val].push(idx);
3093
2933
  }
3094
- ],
3095
- defaultPalettesConfig: defaultPalettesConfig2
3096
- }
3097
- });
3098
-
3099
- // src/common/editorConfig/StaticMajorColorEditor.js
3100
- var StaticMajorColorEditor = {
3101
- label: (0, i18n_exports._)("Major value"),
3102
- option: "majorColor",
3103
- editor: "editor.color",
3104
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.majorColor)
3105
- };
3106
- var StaticMajorColorEditor_default = StaticMajorColorEditor;
3107
-
3108
- // src/common/editorConfig/StaticTrendColorEditor.js
3109
- var StaticTrendColorEditor = {
3110
- label: (0, i18n_exports._)("Trend value"),
3111
- option: "trendColor",
3112
- editor: "editor.color",
3113
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.trendColor),
3114
- isDisabled: ({ options }) => options.trendDisplay === "off"
3115
- };
3116
- var StaticTrendColorEditor_default = StaticTrendColorEditor;
3117
-
3118
- // src/common/editorConfig/StaticBackgroundColorEditor.js
3119
- var StaticBackgroundColorEditor = {
3120
- label: (0, i18n_exports._)("Background color"),
3121
- option: "backgroundColor",
3122
- editor: "editor.color",
3123
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.backgroundColor)
3124
- };
3125
- var StaticBackgroundColorEditor_default = StaticBackgroundColorEditor;
3126
-
3127
- // src/common/editorConfig/RadialBackgroundColor.ts
3128
- var radialBackground = ({ label, themes: themes3, labelPosition }) => [
3129
- {
3130
- label: (0, i18n_exports._)(label || "Radial background"),
3131
- option: "radialBackgroundColor",
3132
- editor: "editor.color",
3133
- editorProps: {
3134
- labelPosition: labelPosition || "top",
3135
- themes: themes3
3136
- }
3137
- }
3138
- ];
3139
- var RadialBackgroundColor_default = radialBackground;
3140
-
3141
- // src/common/editorConfig/TrellisEditors.ts
3142
- var TrellisEditorConfig = [
3143
- [
3144
- {
3145
- label: (0, i18n_exports._)("Trellis layout"),
3146
- option: "splitByLayout",
3147
- editor: "editor.toggle",
3148
- showEditor: () => {
3149
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3150
- const isTrellisFeatureFlagOn = Boolean(
3151
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3152
- );
3153
- return isTrellisFeatureFlagOn;
3154
- }
3155
- }
3156
- ],
3157
- [
3158
- {
3159
- label: (0, i18n_exports._)("Split by"),
3160
- option: "trellisSplitBy",
3161
- editor: "editor.trellisSplitBy",
3162
- editorProps: {
3163
- dataSourceKey: "primary"
3164
- },
3165
- showEditor: ({ options }) => {
3166
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3167
- const isTrellisFeatureFlagOn = Boolean(
3168
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3169
- );
3170
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3171
- }
3172
- }
3173
- ],
3174
- [
3175
- {
3176
- label: (0, i18n_exports._)("Number of columns"),
3177
- option: "trellisColumns",
3178
- editor: "editor.number",
3179
- editorProps: {
3180
- min: 1
3181
- },
3182
- placeholder: (0, i18n_exports._)("Auto"),
3183
- showEditor: ({ options }) => {
3184
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3185
- const isTrellisFeatureFlagOn = Boolean(
3186
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3187
- );
3188
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3189
- }
3190
- }
3191
- ],
3192
- [
3193
- {
3194
- label: (0, i18n_exports._)("Min column width"),
3195
- option: "trellisMinColumnWidth",
3196
- editor: "editor.number",
3197
- editorProps: {
3198
- min: 1
3199
- },
3200
- showEditor: ({ options }) => {
3201
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3202
- const isTrellisFeatureFlagOn = Boolean(
3203
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3204
- );
3205
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3206
- }
3207
- },
3208
- {
3209
- label: (0, i18n_exports._)("Row height"),
3210
- option: "trellisRowHeight",
3211
- editor: "editor.number",
3212
- editorProps: {
3213
- min: 1
3214
- },
3215
- showEditor: ({ options }) => {
3216
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3217
- const isTrellisFeatureFlagOn = Boolean(
3218
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3219
- );
3220
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3221
- }
3222
- }
3223
- ],
3224
- [
3225
- {
3226
- label: (0, i18n_exports._)("Max number of components per page"),
3227
- option: "trellisPageCount",
3228
- editor: "editor.number",
3229
- editorProps: {
3230
- min: 1
3231
- },
3232
- showEditor: ({ options }) => {
3233
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3234
- const isTrellisFeatureFlagOn = Boolean(
3235
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3236
- );
3237
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3238
- }
3239
- }
3240
- ]
3241
- ];
3242
- var TrellisBackgroundColorEditor = {
3243
- label: (0, i18n_exports._)("Trellis background"),
3244
- option: "trellisBackgroundColor",
3245
- editor: "editor.color",
3246
- showEditor: ({ options }) => {
3247
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3248
- const isTrellisFeatureFlagOn = Boolean(
3249
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
3250
- );
3251
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3252
- }
3253
- };
3254
-
3255
- // src/SingleValueRadial/config.ts
3256
- var dataContract = {
3257
- requiredDataSources: [
3258
- {
3259
- name: "primary",
3260
- description: "DataSource that powers the visualization"
3261
- }
3262
- ],
3263
- optionalDataSources: [],
3264
- initialRequestParams: {
3265
- primary: { offset: 0, count: 1e4 }
3266
- }
3267
- };
3268
- var size = {
3269
- initialWidth: 250,
3270
- initialHeight: 250
3271
- };
3272
- var defaultContext = {
3273
- majorColorConfig: [
3274
- { to: 20, value: "#D41F1F" },
3275
- { from: 20, to: 40, value: "#D94E17" },
3276
- { from: 40, to: 60, value: "#CBA700" },
3277
- { from: 60, to: 80, value: "#669922" },
3278
- { from: 80, value: "#118832" }
3279
- ],
3280
- majorColorMatchConfig: [{ match: "", value: "#5C33FF" }],
3281
- trendColorConfig: [
3282
- {
3283
- to: 0,
3284
- value: "#9E2520"
3285
- },
3286
- {
3287
- from: 0,
3288
- value: "#1C6B2D"
3289
- }
3290
- ]
3291
- };
3292
- var basePresetContext = {
3293
- majorColorEditorConfig: void 0,
3294
- trendColorEditorConfig: void 0,
3295
- backgroundColorEditorConfig: void 0
3296
- };
3297
- var basePresetOptions = {
3298
- majorColor: void 0,
3299
- trendColor: void 0,
3300
- backgroundColor: void 0
3301
- };
3302
- var presets = [
3303
- {
3304
- // dummy context variables to allow for resetting of unused context states
3305
- label: (0, i18n_exports._)("None"),
3306
- name: "singleValueRadial.none",
3307
- value: {
3308
- context: __spreadValues({}, basePresetContext),
3309
- options: __spreadValues({}, basePresetOptions)
3310
- }
3311
- },
3312
- {
3313
- label: (0, i18n_exports._)("Major value and gauge"),
3314
- name: "singleValueRadial.majorValue",
3315
- value: {
3316
- context: __spreadProps(__spreadValues({}, basePresetContext), {
3317
- majorColorEditorConfig: defaultContext.majorColorConfig
3318
- }),
3319
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
3320
- majorColor: "> majorValue | rangeValue(majorColorEditorConfig)"
3321
- })
3322
- }
3323
- },
3324
- {
3325
- label: (0, i18n_exports._)("Major value, trend value, and gauge"),
3326
- name: "singleValueRadial.majorValueAndTrend",
3327
- value: {
3328
- context: __spreadProps(__spreadValues({}, basePresetContext), {
3329
- majorColorEditorConfig: defaultContext.majorColorConfig,
3330
- trendColorEditorConfig: defaultContext.trendColorConfig
3331
- }),
3332
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
3333
- majorColor: "> majorValue | rangeValue(majorColorEditorConfig)",
3334
- trendColor: "> trendValue | rangeValue(trendColorEditorConfig)"
3335
- })
3336
- }
3337
- },
3338
- {
3339
- label: (0, i18n_exports._)("Trend value"),
3340
- name: "singleValueRadial.trend",
3341
- value: {
3342
- context: __spreadProps(__spreadValues({}, basePresetContext), {
3343
- trendColorEditorConfig: defaultContext.trendColorConfig
3344
- }),
3345
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
3346
- trendColor: "> trendValue | rangeValue(trendColorEditorConfig)"
3347
- })
3348
- }
3349
- },
3350
- {
3351
- label: (0, i18n_exports._)("Background"),
3352
- name: "singleValueRadial.background",
3353
- value: {
3354
- context: __spreadProps(__spreadValues({}, basePresetContext), {
3355
- backgroundColorEditorConfig: defaultContext.majorColorConfig
3356
- }),
3357
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
3358
- backgroundColor: "> majorValue | rangeValue(backgroundColorEditorConfig)"
3359
- })
3360
- }
3361
- }
3362
- ];
3363
- var themes = {
3364
- defaultFontColor: (props) => pick_default({
3365
- enterprise: {
3366
- dark: variables_default.white(props),
3367
- light: variables_default.black(props)
3368
- },
3369
- prisma: variables_default.contentColorActive(props)
3370
- })(props),
3371
- defaultBackgroundColor: (props) => pick_default({
3372
- enterprise: {
3373
- dark: variables_default.black(props),
3374
- light: variables_default.white(props)
3375
- },
3376
- prisma: variables_default.backgroundColorSidebar(props)
3377
- })(props),
3378
- defaultRadialBackgroundColor: (props) => pick_default({
3379
- enterprise: {
3380
- dark: "rgba(255, 255, 255, 0.15)",
3381
- light: "rgba(0, 0, 0, 0.1)"
3382
- },
3383
- prisma: variables_default.interactiveColorBackgroundDisabled(props)
3384
- })(props)
3385
- };
3386
- var editorConfig = [
3387
- {
3388
- label: (0, i18n_exports._)("Data configurations"),
3389
- layout: [
3390
- [
3391
- {
3392
- label: (0, i18n_exports._)("Value"),
3393
- editor: "editor.columnSelector",
3394
- option: "majorValue",
3395
- context: "valuesContext",
3396
- editorProps: {
3397
- dataSourceKey: "primary",
3398
- prepareValue: (definition) => {
3399
- const {
3400
- options: { majorValue: baseSPL }
3401
- } = definition;
3402
- return {
3403
- context: {},
3404
- options: {
3405
- majorValue: `${baseSPL} | lastPoint()`,
3406
- trendValue: `${baseSPL} | delta(-2)`
3407
- }
3408
- };
3409
- }
3410
- },
3411
- isDisabled: ({ options }) => options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis
3412
- }
3413
- ]
3414
- ]
3415
- },
3416
- {
3417
- label: (0, i18n_exports._)("Data display"),
3418
- layout: [
3419
- ...StaticMajorAndTrendLayout_default,
3420
- [
3421
- {
3422
- label: (0, i18n_exports._)("Trend display"),
3423
- option: "trendDisplay",
3424
- editor: "editor.select",
3425
- editorProps: {
3426
- values: [
3427
- { label: (0, i18n_exports._)("Percent"), value: "percent" },
3428
- { label: (0, i18n_exports._)("Absolute"), value: "absolute" },
3429
- { label: (0, i18n_exports._)("Off"), value: "off" }
3430
- ]
3431
- },
3432
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
3433
- }
3434
- ],
3435
- [
3436
- {
3437
- label: (0, i18n_exports._)("Min"),
3438
- option: "minValue",
3439
- editor: "editor.number"
3440
- },
3441
- {
3442
- label: (0, i18n_exports._)("Max"),
3443
- option: "maxValue",
3444
- editor: "editor.number"
3445
- }
3446
- ],
3447
- ...TrellisEditorConfig
3448
- ]
3449
- },
3450
- {
3451
- label: (0, i18n_exports._)("Color and style"),
3452
- layout: [
3453
- [
3454
- {
3455
- label: (0, i18n_exports._)("Dynamic elements"),
3456
- key: "presetSelector",
3457
- editor: "editor.presetSelector",
3458
- editorProps: {
3459
- presets,
3460
- value: ({ context, options }) => {
3461
- const initialPreset = getInitialPreset(context, options, presets);
3462
- return initialPreset && initialPreset.label || null;
3463
- }
3464
- }
2934
+ });
2935
+ const cloneFields = (0, lodash_exports.cloneDeep)(fields);
2936
+ cloneFields.splice(splitByIndex, 1);
2937
+ const valueKeys = Object.keys(splitDataSources);
2938
+ valueKeys.forEach((val) => {
2939
+ const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
2940
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2941
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2942
+ );
2943
+ splitDataSources[val].primary.data.fields = cloneFields;
2944
+ splitDataSources[val].primary.data.columns = [];
2945
+ columns.forEach((col, idx) => {
2946
+ if (idx !== splitByIndex) {
2947
+ const newCol = valIndices.map((valIdx) => col[valIdx]);
2948
+ splitDataSources[val].primary.data.columns.push(newCol);
3465
2949
  }
3466
- ],
3467
- [
3468
- __spreadProps(__spreadValues({}, StaticMajorColorEditor_default), {
3469
- editorProps: {
3470
- themes
2950
+ });
2951
+ });
2952
+ } else {
2953
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2954
+ }
2955
+ return { splitDataSources, errorCode };
2956
+ };
2957
+ var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
2958
+ let result = null;
2959
+ try {
2960
+ if (splitMode === trellisUtils_exports.TIMECHART) {
2961
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
2962
+ } else if (splitMode === trellisUtils_exports.STATS) {
2963
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
2964
+ } else if (splitMode === trellisUtils_exports.CHART) {
2965
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
2966
+ } else if (splitMode === trellisUtils_exports.UNKNOWN) {
2967
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
2968
+ }
2969
+ } catch (ex) {
2970
+ console.error("getTrellisDataSourcesBySplitMode ", ex);
2971
+ result = { splitDataSources: null, errorCode: "UNKNOWN" };
2972
+ }
2973
+ return result;
2974
+ };
2975
+ var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
2976
+ if (isTrellisOn && !options.legendDisplay) {
2977
+ return {
2978
+ legendDisplay: "off"
2979
+ };
2980
+ }
2981
+ return {};
2982
+ };
2983
+ var calculateSharedMinMax = (splitData) => {
2984
+ let max = -Infinity;
2985
+ let min = Infinity;
2986
+ Object.keys(splitData).forEach((splitByKey) => {
2987
+ const datasources = splitData[splitByKey];
2988
+ Object.keys(datasources).forEach((datasourceName) => {
2989
+ const dataColumns = datasources[datasourceName].data.columns;
2990
+ dataColumns.forEach((column) => {
2991
+ column.forEach((point) => {
2992
+ const pointNumber = Number(point);
2993
+ if (pointNumber > max) {
2994
+ max = pointNumber;
3471
2995
  }
3472
- })
3473
- ],
3474
- [getDynamicMajorColorAndGaugeEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3475
- [
3476
- __spreadProps(__spreadValues({}, StaticTrendColorEditor_default), {
3477
- editorProps: {
3478
- themes
2996
+ if (pointNumber < min) {
2997
+ min = pointNumber;
3479
2998
  }
3480
- })
3481
- ],
3482
- [getDynamicTrendColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3483
- [
3484
- {
3485
- label: (0, i18n_exports._)("Major value abbreviation"),
3486
- option: "shouldAbbreviateMajorValue",
3487
- editor: "editor.checkbox"
2999
+ });
3000
+ });
3001
+ });
3002
+ });
3003
+ return [min, max];
3004
+ };
3005
+ var determineMinMax = (splitData, trellisSharedScale, yAxisMin, yAxisMax, stackMode) => {
3006
+ if (!trellisSharedScale || stackMode === "stacked100" || yAxisMin !== "auto" && yAxisMax !== "auto")
3007
+ return [yAxisMin, yAxisMax];
3008
+ const [sharedMin, sharedMax] = calculateSharedMinMax(splitData);
3009
+ const shouldUseSharedMax = sharedMax !== -Infinity && yAxisMax === "auto";
3010
+ const shouldUseSharedMin = sharedMin !== Infinity && yAxisMin === "auto";
3011
+ return [shouldUseSharedMin ? sharedMin : yAxisMin, shouldUseSharedMax ? sharedMax : yAxisMax];
3012
+ };
3013
+
3014
+ // src/common/withDashboardViz.tsx
3015
+ var withDashboardViz = (opts) => {
3016
+ const {
3017
+ ReactViz,
3018
+ vizConfig,
3019
+ computeVizProps: computeVizProps2 = () => {
3020
+ },
3021
+ computeVizPropsBeforeEval: computeVizPropsBeforeEval2 = () => {
3022
+ },
3023
+ disableEditModeCover,
3024
+ useIconPlaceholder
3025
+ } = opts;
3026
+ const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
3027
+ const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
3028
+ const DashboardViz = (props) => {
3029
+ var _a;
3030
+ const {
3031
+ mode,
3032
+ hasEventHandlers,
3033
+ dataSources,
3034
+ // type of { [key: string]: DataSource }
3035
+ options,
3036
+ context = {},
3037
+ width,
3038
+ height,
3039
+ onComputedProps,
3040
+ onEventTrigger,
3041
+ theme,
3042
+ onRequestParamsChange
3043
+ } = props;
3044
+ const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
3045
+ if (serializedTimezone) {
3046
+ if (!moment_default.getDefaultSplunkTimezone()) {
3047
+ moment_default.setDefaultSplunkTimezone(serializedTimezone);
3048
+ }
3049
+ }
3050
+ const themeFunc = (themeVar) => {
3051
+ var _a2, _b;
3052
+ return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
3053
+ };
3054
+ const bgColorFromTheme = themeFunc("defaultBackgroundColor");
3055
+ const {
3056
+ family: currentThemeFamily,
3057
+ colorScheme: currentThemeColorScheme,
3058
+ density: currentThemeDensity
3059
+ } = getSettingsFromThemedProps_default({ theme });
3060
+ let evaluatedOptions = {};
3061
+ const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
3062
+ const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3063
+ const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
3064
+ const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
3065
+ const [dataFramesInState, setDataFramesInState] = react_exports.useState();
3066
+ const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
3067
+ Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
3068
+ );
3069
+ const isDownsamplingEnabledByFeatureFlag = Boolean(
3070
+ featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
3071
+ );
3072
+ const isTrellisFeatureFlagOn2 = Boolean(
3073
+ featureFlagContext && featureFlagContext.visualizations_enableTrellis
3074
+ );
3075
+ 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 */;
3076
+ const isMounted = react_exports.useRef(true);
3077
+ const optionsToEvaluate = react_exports.useMemo(() => {
3078
+ var _a2;
3079
+ const legendDisplay = turnOffLegendDisplayWhenTrellisIsOn(isTrellisOn, options);
3080
+ const computedOptions = (_a2 = computeVizPropsBeforeEval2(options)) != null ? _a2 : {};
3081
+ return {
3082
+ context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
3083
+ options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)(
3084
+ {},
3085
+ legendDisplay,
3086
+ computedOptions,
3087
+ options,
3088
+ defaultOptions
3089
+ )
3090
+ };
3091
+ }, [isTrellisOn, options, context]);
3092
+ const [threshold, setThreshold] = react_exports.useState(Number(width));
3093
+ const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
3094
+ setThreshold(newThreshold);
3095
+ }, []);
3096
+ const isDownsamplingEnabled = react_exports.useMemo(() => {
3097
+ return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
3098
+ }, [isDownsamplingEnabledByFeatureFlag]);
3099
+ const downsamplingProps = react_exports.useMemo(() => {
3100
+ if (!isDownsamplingEnabled) {
3101
+ return {};
3102
+ }
3103
+ return {
3104
+ onDownsamplingThresholdChange,
3105
+ originalDataSources: dataSources
3106
+ };
3107
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
3108
+ const downsampledDataSources = useDownsampleDataSources_default({
3109
+ options: optionsToEvaluate.options,
3110
+ context: optionsToEvaluate.context,
3111
+ dataSources,
3112
+ threshold,
3113
+ isDownsamplingEnabled
3114
+ });
3115
+ evaluatedOptions = useDeepMemo(() => {
3116
+ try {
3117
+ if (useAsyncEvaluatedOptions) {
3118
+ const asyncDynamicOptionsEvaluatorParams = {
3119
+ visualizationID,
3120
+ props,
3121
+ options: optionsToEvaluate,
3122
+ dataSources: downsampledDataSources,
3123
+ theme: vizConfig.themes,
3124
+ bypassCloneDeepOptionScope: Boolean(
3125
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
3126
+ ),
3127
+ lazyLoadingDataFrame: Boolean(
3128
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
3129
+ )
3130
+ };
3131
+ async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
3132
+ setEvaluatedOptionsAsync(results.results);
3133
+ }).catch(() => {
3134
+ if (isMounted.current) {
3135
+ setUseAsyncEvaluatedOptions(false);
3136
+ }
3137
+ });
3138
+ } else {
3139
+ let dataFrames = dataFramesInState;
3140
+ if (downsampledDataSources !== dataSourcesInState) {
3141
+ setDataSourcesInState(downsampledDataSources);
3142
+ dataFrames = Options_exports.Options.dataFrameFromDataSource(
3143
+ downsampledDataSources,
3144
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
3145
+ );
3146
+ setDataFramesInState(dataFrames);
3147
+ }
3148
+ const result = Options_exports.Options.evaluate(
3149
+ optionsToEvaluate,
3150
+ downsampledDataSources,
3151
+ themeFunc,
3152
+ dataFrames,
3153
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
3154
+ );
3155
+ return result;
3488
3156
  }
3489
- ],
3490
- [
3157
+ } catch (e) {
3158
+ console.error(`unexpected error evaluating options: ${e.message}`);
3159
+ return {};
3160
+ }
3161
+ return {};
3162
+ }, [
3163
+ currentThemeFamily,
3164
+ currentThemeColorScheme,
3165
+ currentThemeDensity,
3166
+ optionsToEvaluate,
3167
+ downsampledDataSources,
3168
+ serializedTimezone,
3169
+ useAsyncEvaluatedOptions
3170
+ ]);
3171
+ const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
3172
+ let clonedEvaluatedOptions = evaluatedOptionsToUse;
3173
+ if (isTrellisOn) {
3174
+ clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
3175
+ backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
3176
+ });
3177
+ }
3178
+ react_exports.useEffect(() => {
3179
+ onComputedProps(clonedEvaluatedOptions);
3180
+ });
3181
+ react_exports.useEffect(() => {
3182
+ return () => {
3183
+ if (useAsyncEvaluatedOptions) {
3184
+ isMounted.current = false;
3185
+ async_dynamic_options_evaluator_default.reset(visualizationID);
3186
+ }
3187
+ };
3188
+ }, []);
3189
+ const { requiredProps = [], supports } = vizConfig;
3190
+ const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
3191
+ if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
3192
+ return /* @__PURE__ */ react_exports.createElement(
3193
+ MissingPropsMessage_default,
3491
3194
  {
3492
- label: (0, i18n_exports._)("Trend value abbreviation"),
3493
- option: "shouldAbbreviateTrendValue",
3494
- editor: "editor.checkbox"
3195
+ "data-test": "missing-props-message",
3196
+ width,
3197
+ height,
3198
+ missingProps: missing,
3199
+ backgroundColor: bgColorFromTheme
3495
3200
  }
3496
- ],
3497
- RadialBackgroundColor_default({ themes }),
3498
- [
3499
- __spreadProps(__spreadValues({}, StaticBackgroundColorEditor_default), {
3500
- editorProps: {
3501
- themes
3201
+ );
3202
+ }
3203
+ const eventCallbackProps = {};
3204
+ if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
3205
+ const supportedEvents = vizConfig.events;
3206
+ Object.keys(supportedEvents).forEach((eventName) => {
3207
+ const { parentKeys, payloadKeys } = supportedEvents[eventName];
3208
+ const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
3209
+ let payload = {};
3210
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
3211
+ payloadKeys.forEach((p) => {
3212
+ payload[p] = evaluatedOptionsToUse[p];
3213
+ });
3214
+ }
3215
+ eventCallbackProps[eventCallbackPropName] = (ev) => {
3216
+ if (ev && ev.payload) {
3217
+ payload = ev.payload;
3502
3218
  }
3503
- })
3504
- ],
3505
- [
3506
- __spreadProps(__spreadValues({}, TrellisBackgroundColorEditor), {
3507
- editorProps: {
3508
- themes
3219
+ return onEventTrigger({ originalEvent: ev, payload, type: eventName });
3220
+ };
3221
+ if (parentKeys) {
3222
+ for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
3223
+ const newObject = {};
3224
+ newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
3225
+ eventCallbackProps[eventCallbackPropName] = newObject;
3509
3226
  }
3510
- })
3511
- ],
3512
- [getDynamicBackgroundColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3513
- [
3514
- {
3515
- label: (0, i18n_exports._)("Show gauge ranges"),
3516
- option: "isGaugeOn",
3517
- editor: "editor.toggle",
3518
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.majorColor)
3519
3227
  }
3520
- ]
3521
- ]
3522
- }
3523
- ];
3524
- var config = {
3525
- /**
3526
- * unique viz key
3527
- */
3528
- key: "splunk.singlevalueradial",
3529
- /**
3530
- * viz name
3531
- */
3532
- name: (0, i18n_exports._)("Single value radial"),
3533
- category: "Single Value" /* SINGLE_VALUE */,
3534
- /**
3535
- * viz icon
3536
- */
3537
- icon: visualization_icons_exports.SingleValueRadial,
3538
- placeholderIcon: placeholders_exports.SingleValueRadial,
3539
- dataContract,
3540
- size,
3541
- defaultContext,
3542
- optionsSchema: visualization_schemas_exports.singleValueRadialOptionsSchema,
3543
- editorConfig,
3544
- events: {
3545
- "value.click": {
3546
- description: "trigger when user clicks major value",
3547
- payloadKeys: ["majorValue", "trendValue"]
3228
+ });
3548
3229
  }
3549
- },
3550
- supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "events" /* EVENTS */, "placeholder" /* PLACEHOLDER */, "trellis" /* TRELLIS */],
3551
- themes
3230
+ const computedVizProps = computeVizProps2(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
3231
+ themeFunc
3232
+ }));
3233
+ let dataSourceMetadata = {};
3234
+ const OptionKey = "paginateDataSourceKey";
3235
+ const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
3236
+ if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
3237
+ const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
3238
+ const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
3239
+ const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
3240
+ const sortParams = getSortingParams({
3241
+ requestParams,
3242
+ meta,
3243
+ onRequestParamsChange: handleRequestParamsChange
3244
+ });
3245
+ const paginatorParams = getPaginationParams({
3246
+ requestParams,
3247
+ meta,
3248
+ onRequestParamsChange: handleRequestParamsChange
3249
+ });
3250
+ dataSourceMetadata = {
3251
+ sortParams,
3252
+ paginatorParams
3253
+ };
3254
+ }
3255
+ if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
3256
+ return null;
3257
+ }
3258
+ return /* @__PURE__ */ react_exports.createElement(
3259
+ SanitizedReactViz,
3260
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
3261
+ mode,
3262
+ width,
3263
+ height
3264
+ }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
3265
+ );
3266
+ };
3267
+ DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
3268
+ DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
3269
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
3270
+ theme: {}
3271
+ });
3272
+ DashboardViz.config = vizConfig;
3273
+ return (0, styled_components_exports.withTheme)(
3274
+ withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
3275
+ );
3552
3276
  };
3553
- var config_default = enhanceConfig(config);
3277
+ var withDashboardViz_default = withDashboardViz;
3554
3278
 
3555
- // esm-externals:@splunk/react-ui/Paginator
3556
- var Paginator_exports = {};
3557
- __export(Paginator_exports, {
3558
- default: () => Paginator_default
3279
+ // esm-externals:@splunk/visualization-color-palettes/editors/PresetPalettes
3280
+ var PresetPalettes_exports = {};
3281
+ __export(PresetPalettes_exports, {
3282
+ default: () => PresetPalettes_default
3283
+ });
3284
+ var defaultImport34 = __toESM(require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
3285
+ __reExport(PresetPalettes_exports, require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
3286
+ var PresetPalettes_default = "default" in defaultImport34 ? defaultImport34.default : defaultImport34;
3287
+
3288
+ // esm-externals:@splunk/visualization-icons
3289
+ var visualization_icons_exports = {};
3290
+ __export(visualization_icons_exports, {
3291
+ default: () => visualization_icons_default
3292
+ });
3293
+ var defaultImport35 = __toESM(require("@splunk/visualization-icons"));
3294
+ __reExport(visualization_icons_exports, require("@splunk/visualization-icons"));
3295
+ var visualization_icons_default = "default" in defaultImport35 ? defaultImport35.default : defaultImport35;
3296
+
3297
+ // esm-externals:@splunk/visualization-icons/placeholders
3298
+ var placeholders_exports = {};
3299
+ __export(placeholders_exports, {
3300
+ default: () => placeholders_default
3301
+ });
3302
+ var defaultImport36 = __toESM(require("@splunk/visualization-icons/placeholders"));
3303
+ __reExport(placeholders_exports, require("@splunk/visualization-icons/placeholders"));
3304
+ var placeholders_default = "default" in defaultImport36 ? defaultImport36.default : defaultImport36;
3305
+
3306
+ // esm-externals:@splunk/visualizations-shared/configUtils
3307
+ var configUtils_exports = {};
3308
+ __export(configUtils_exports, {
3309
+ default: () => configUtils_default
3310
+ });
3311
+ var defaultImport37 = __toESM(require("@splunk/visualizations-shared/configUtils"));
3312
+ __reExport(configUtils_exports, require("@splunk/visualizations-shared/configUtils"));
3313
+ var configUtils_default = "default" in defaultImport37 ? defaultImport37.default : defaultImport37;
3314
+
3315
+ // src/common/editorConfig/StaticMajorAndTrendLayout.js
3316
+ var StaticMajorAndTrendLayout = [
3317
+ [
3318
+ {
3319
+ label: (0, i18n_exports._)("Unit position"),
3320
+ // todo: we need a new editor combining unit and position
3321
+ option: "unitPosition",
3322
+ editor: "editor.select",
3323
+ editorProps: {
3324
+ values: [
3325
+ { label: (0, i18n_exports._)("Before"), value: "before" },
3326
+ { label: (0, i18n_exports._)("After"), value: "after" }
3327
+ ]
3328
+ },
3329
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
3330
+ },
3331
+ {
3332
+ label: (0, i18n_exports._)("Unit label"),
3333
+ option: "unit",
3334
+ editor: "editor.text",
3335
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
3336
+ }
3337
+ ],
3338
+ [
3339
+ {
3340
+ label: (0, i18n_exports._)("Precision"),
3341
+ option: "numberPrecision",
3342
+ editor: "editor.number",
3343
+ editorProps: {
3344
+ min: 0,
3345
+ max: 20
3346
+ },
3347
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
3348
+ }
3349
+ ]
3350
+ ];
3351
+ var StaticMajorAndTrendLayout_default = StaticMajorAndTrendLayout;
3352
+
3353
+ // src/common/utils/configUtils.ts
3354
+ function enhanceConfig(vizConfig) {
3355
+ const enhancedConfig = __spreadValues({}, vizConfig);
3356
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map(
3357
+ (config3) => {
3358
+ return __spreadProps(__spreadValues({}, config3), { open: config3.open || false });
3359
+ }
3360
+ );
3361
+ return enhancedConfig;
3362
+ }
3363
+ function hasCompatibleContexts(vizContext, presetContext) {
3364
+ const presetContextKeys = Object.keys(presetContext);
3365
+ return presetContextKeys.every(
3366
+ (contextKey) => presetContext[contextKey] === void 0 && vizContext[contextKey] === void 0 || presetContext[contextKey] !== void 0 && vizContext[contextKey] !== void 0
3367
+ );
3368
+ }
3369
+ function hasCompatibleOptions(vizOptions, presetOptions) {
3370
+ const presetOptionKeys = Object.keys(presetOptions);
3371
+ return presetOptionKeys.every(
3372
+ (optionKey) => (0, configUtils_exports.isDynamicOption)(presetOptions[optionKey]) === (0, configUtils_exports.isDynamicOption)(vizOptions[optionKey])
3373
+ );
3374
+ }
3375
+ function getInitialPreset(vizContext, vizOptions, presets2) {
3376
+ return presets2.find((preset) => {
3377
+ const presetContext = (0, lodash_exports.get)(preset, ["value", "context"], {});
3378
+ const presetOptions = (0, lodash_exports.get)(preset, ["value", "options"], {});
3379
+ const presetContextKeys = Object.keys(presetContext);
3380
+ const presetOptionKeys = Object.keys(presetOptions);
3381
+ if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
3382
+ return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
3383
+ });
3384
+ }
3385
+
3386
+ // src/common/editorConfig/DynamicMajorColorAndGaugeEditor.js
3387
+ var getDynamicMajorColorAndGaugeEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
3388
+ label: (0, i18n_exports._)("Major value and gauge"),
3389
+ option: "majorColor",
3390
+ context: "majorColorEditorConfig",
3391
+ editor: "editor.dynamicColor",
3392
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.majorColor),
3393
+ editorProps: {
3394
+ labelPosition: "top",
3395
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: major value"),
3396
+ formatters: [
3397
+ {
3398
+ label: (0, i18n_exports._)("Ranges"),
3399
+ value: "rangeValue",
3400
+ defaults: {
3401
+ majorValue: defaultContext2.majorColorConfig
3402
+ }
3403
+ }
3404
+ ],
3405
+ dataSelectors: [
3406
+ {
3407
+ label: (0, i18n_exports._)("Major value"),
3408
+ value: "majorValue"
3409
+ }
3410
+ ],
3411
+ defaultPalettesConfig: defaultPalettesConfig2
3412
+ }
3413
+ });
3414
+
3415
+ // src/common/editorConfig/DynamicTrendColorEditor.js
3416
+ var getDynamicTrendColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
3417
+ label: (0, i18n_exports._)("Trend value"),
3418
+ option: "trendColor",
3419
+ context: "trendColorEditorConfig",
3420
+ editor: "editor.dynamicColor",
3421
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.trendColor),
3422
+ editorProps: {
3423
+ labelPosition: "top",
3424
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: trend value"),
3425
+ formatters: [
3426
+ {
3427
+ label: (0, i18n_exports._)("Ranges"),
3428
+ value: "rangeValue",
3429
+ defaults: {
3430
+ trendValue: defaultContext2.trendColorConfig
3431
+ }
3432
+ }
3433
+ ],
3434
+ dataSelectors: [
3435
+ {
3436
+ label: (0, i18n_exports._)("Trend value"),
3437
+ value: "trendValue"
3438
+ }
3439
+ ],
3440
+ defaultPalettesConfig: defaultPalettesConfig2
3441
+ }
3559
3442
  });
3560
- var defaultImport35 = __toESM(require("@splunk/react-ui/Paginator"));
3561
- __reExport(Paginator_exports, require("@splunk/react-ui/Paginator"));
3562
- var Paginator_default = "default" in defaultImport35 ? defaultImport35.default : defaultImport35;
3563
3443
 
3564
- // esm-externals:@splunk/themes
3565
- var themes_exports = {};
3566
- __export(themes_exports, {
3567
- default: () => themes_default
3444
+ // src/common/editorConfig/DynamicBackgroundColorEditor.js
3445
+ var getDynamicBackgroundColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
3446
+ label: (0, i18n_exports._)("Background color"),
3447
+ option: "backgroundColor",
3448
+ context: "backgroundColorEditorConfig",
3449
+ editor: "editor.dynamicColor",
3450
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.backgroundColor),
3451
+ editorProps: {
3452
+ labelPosition: "top",
3453
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: background"),
3454
+ formatters: [
3455
+ {
3456
+ label: (0, i18n_exports._)("Ranges"),
3457
+ value: "rangeValue",
3458
+ defaults: {
3459
+ majorValue: defaultContext2.majorColorConfig,
3460
+ trendValue: defaultContext2.trendColorConfig
3461
+ }
3462
+ },
3463
+ {
3464
+ label: (0, i18n_exports._)("Matches"),
3465
+ value: "matchValue",
3466
+ defaults: {
3467
+ majorValue: defaultContext2.majorColorMatchConfig
3468
+ }
3469
+ }
3470
+ ],
3471
+ dataSelectors: [
3472
+ {
3473
+ label: (0, i18n_exports._)("Major Value"),
3474
+ value: "majorValue"
3475
+ },
3476
+ {
3477
+ label: (0, i18n_exports._)("Trend"),
3478
+ value: "trendValue"
3479
+ }
3480
+ ],
3481
+ defaultPalettesConfig: defaultPalettesConfig2
3482
+ }
3568
3483
  });
3569
- var defaultImport36 = __toESM(require("@splunk/themes"));
3570
- __reExport(themes_exports, require("@splunk/themes"));
3571
- var themes_default = "default" in defaultImport36 ? defaultImport36.default : defaultImport36;
3572
3484
 
3573
- // esm-externals:@splunk/themes/useSplunkTheme
3574
- var useSplunkTheme_exports = {};
3575
- __export(useSplunkTheme_exports, {
3576
- default: () => useSplunkTheme_default
3577
- });
3578
- var defaultImport37 = __toESM(require("@splunk/themes/useSplunkTheme"));
3579
- __reExport(useSplunkTheme_exports, require("@splunk/themes/useSplunkTheme"));
3580
- var useSplunkTheme_default = "default" in defaultImport37 ? defaultImport37.default : defaultImport37;
3485
+ // src/common/editorConfig/StaticMajorColorEditor.js
3486
+ var StaticMajorColorEditor = {
3487
+ label: (0, i18n_exports._)("Major value"),
3488
+ option: "majorColor",
3489
+ editor: "editor.color",
3490
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.majorColor)
3491
+ };
3492
+ var StaticMajorColorEditor_default = StaticMajorColorEditor;
3581
3493
 
3582
- // esm-externals:@splunk/visualizations-shared/trellisUtils
3583
- var trellisUtils_exports = {};
3584
- __export(trellisUtils_exports, {
3585
- default: () => trellisUtils_default
3586
- });
3587
- var defaultImport38 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
3588
- __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
3589
- var trellisUtils_default = "default" in defaultImport38 ? defaultImport38.default : defaultImport38;
3494
+ // src/common/editorConfig/StaticTrendColorEditor.js
3495
+ var StaticTrendColorEditor = {
3496
+ label: (0, i18n_exports._)("Trend value"),
3497
+ option: "trendColor",
3498
+ editor: "editor.color",
3499
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.trendColor),
3500
+ isDisabled: ({ options }) => options.trendDisplay === "off"
3501
+ };
3502
+ var StaticTrendColorEditor_default = StaticTrendColorEditor;
3590
3503
 
3591
- // src/common/utils/trellisUtils.ts
3592
- var AGGREGATIONS = "aggregations";
3593
- var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
3594
- var _a, _b, _c, _d;
3595
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3596
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3597
- let splitDataSources = null;
3598
- let errorCode = null;
3599
- if (fields && fields.length) {
3600
- splitDataSources = {};
3601
- for (let i = 0; i < fields.length; i += 1) {
3602
- const fieldName = fields[i].name;
3603
- if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
3604
- splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
3605
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3606
- );
3607
- splitDataSources[fieldName].primary.data.fields = [fields[i]];
3608
- splitDataSources[fieldName].primary.data.columns = [columns[i]];
3609
- }
3504
+ // src/common/editorConfig/StaticBackgroundColorEditor.js
3505
+ var StaticBackgroundColorEditor = {
3506
+ label: (0, i18n_exports._)("Background color"),
3507
+ option: "backgroundColor",
3508
+ editor: "editor.color",
3509
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.backgroundColor)
3510
+ };
3511
+ var StaticBackgroundColorEditor_default = StaticBackgroundColorEditor;
3512
+
3513
+ // src/common/editorConfig/RadialBackgroundColor.ts
3514
+ var radialBackground = ({ label, themes: themes3, labelPosition }) => [
3515
+ {
3516
+ label: (0, i18n_exports._)(label || "Radial background"),
3517
+ option: "radialBackgroundColor",
3518
+ editor: "editor.color",
3519
+ editorProps: {
3520
+ labelPosition: labelPosition || "top",
3521
+ themes: themes3
3610
3522
  }
3611
- } else {
3612
- errorCode = "INVALID_SPLIT_BY_FIELD";
3613
3523
  }
3614
- return { splitDataSources, errorCode };
3524
+ ];
3525
+ var RadialBackgroundColor_default = radialBackground;
3526
+
3527
+ // src/common/editorConfig/TrellisEditors.ts
3528
+ var isTrellisFeatureFlagOn = ({ featureFlags }) => {
3529
+ return Boolean(featureFlags == null ? void 0 : featureFlags.visualizations_enableTrellis);
3615
3530
  };
3616
- var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
3617
- var _a, _b, _c, _d;
3618
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3619
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3620
- let splitDataSources = null;
3621
- let splitByFields = [];
3622
- let errorCode = null;
3623
- if (typeof fields[0] !== "string") {
3624
- splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
3625
- }
3626
- if (splitByFields && splitByFields.length > 0) {
3627
- splitDataSources = {};
3628
- splitByFields.forEach((splitByField) => {
3629
- splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
3630
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3631
- );
3632
- splitDataSources[splitByField].primary.data.fields = [fields[0]];
3633
- splitDataSources[splitByField].primary.data.columns = [columns[0]];
3634
- fields.forEach((field, idx) => {
3635
- const fieldName = field == null ? void 0 : field.name;
3636
- if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
3637
- splitDataSources[splitByField].primary.data.fields.push(field);
3638
- splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
3639
- }
3640
- });
3641
- });
3642
- } else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
3643
- splitDataSources = {};
3644
- for (let i = 1; i < fields.length; i += 1) {
3645
- const fieldName = fields[i].name;
3646
- if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
3647
- splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
3648
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3649
- );
3650
- splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
3651
- splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
3531
+ var isTrellisEnabled = ({ options, featureFlags }) => {
3532
+ const { splitByLayout = visualization_schemas_exports.LAYOUT_TYPE.Off } = options;
3533
+ return isTrellisFeatureFlagOn({ featureFlags }) && splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
3534
+ };
3535
+ var TrellisEditorConfig = [
3536
+ [
3537
+ {
3538
+ label: (0, i18n_exports._)("Trellis layout"),
3539
+ option: "splitByLayout",
3540
+ editor: "editor.toggle",
3541
+ showEditor: isTrellisFeatureFlagOn
3542
+ }
3543
+ ],
3544
+ [
3545
+ {
3546
+ label: (0, i18n_exports._)("Split by"),
3547
+ option: "trellisSplitBy",
3548
+ editor: "editor.trellisSplitBy",
3549
+ editorProps: {
3550
+ dataSourceKey: "primary"
3551
+ },
3552
+ showEditor: isTrellisEnabled
3553
+ }
3554
+ ],
3555
+ [
3556
+ {
3557
+ label: (0, i18n_exports._)("Number of columns"),
3558
+ option: "trellisColumns",
3559
+ editor: "editor.number",
3560
+ editorProps: {
3561
+ min: 1
3562
+ },
3563
+ placeholder: (0, i18n_exports._)("Auto"),
3564
+ showEditor: isTrellisEnabled
3565
+ }
3566
+ ],
3567
+ [
3568
+ {
3569
+ label: (0, i18n_exports._)("Min column width"),
3570
+ option: "trellisMinColumnWidth",
3571
+ editor: "editor.number",
3572
+ editorProps: {
3573
+ min: 1
3574
+ },
3575
+ showEditor: isTrellisEnabled
3576
+ },
3577
+ {
3578
+ label: (0, i18n_exports._)("Row height"),
3579
+ option: "trellisRowHeight",
3580
+ editor: "editor.number",
3581
+ editorProps: {
3582
+ min: 1
3583
+ },
3584
+ showEditor: isTrellisEnabled
3585
+ }
3586
+ ],
3587
+ [
3588
+ {
3589
+ label: (0, i18n_exports._)("Max number of components per page"),
3590
+ option: "trellisPageCount",
3591
+ editor: "editor.number",
3592
+ editorProps: {
3593
+ min: 1
3594
+ },
3595
+ showEditor: isTrellisEnabled
3596
+ }
3597
+ ]
3598
+ ];
3599
+ var TimechartTrellisEditorConfig = [
3600
+ [
3601
+ {
3602
+ label: (0, i18n_exports._)("Trellis layout"),
3603
+ option: "splitByLayout",
3604
+ editor: "editor.toggle",
3605
+ showEditor: isTrellisFeatureFlagOn,
3606
+ // add help text for timecharts
3607
+ editorProps: {
3608
+ help: (0, i18n_exports._)(
3609
+ "Y2-axis and overlay field configurations are not supported when trellis is enabled."
3610
+ ),
3611
+ helpFormat: "under"
3652
3612
  }
3653
3613
  }
3654
- } else {
3655
- errorCode = "INVALID_SPLIT_BY_FIELD";
3656
- }
3657
- return { splitDataSources, errorCode };
3614
+ ],
3615
+ ...TrellisEditorConfig.slice(1),
3616
+ [
3617
+ {
3618
+ label: (0, i18n_exports._)("Shared y-axis scale"),
3619
+ option: "trellisSharedScale",
3620
+ editor: "editor.checkbox",
3621
+ showEditor: isTrellisEnabled
3622
+ }
3623
+ ]
3624
+ ];
3625
+ var TrellisBackgroundColorEditor = {
3626
+ label: (0, i18n_exports._)("Trellis background"),
3627
+ option: "trellisBackgroundColor",
3628
+ editor: "editor.color",
3629
+ showEditor: isTrellisEnabled
3630
+ };
3631
+
3632
+ // src/SingleValueRadial/config.ts
3633
+ var dataContract = {
3634
+ requiredDataSources: [
3635
+ {
3636
+ name: "primary",
3637
+ description: "DataSource that powers the visualization"
3638
+ }
3639
+ ],
3640
+ optionalDataSources: [],
3641
+ initialRequestParams: {
3642
+ primary: { offset: 0, count: 1e4 }
3643
+ }
3644
+ };
3645
+ var size = {
3646
+ initialWidth: 250,
3647
+ initialHeight: 250
3648
+ };
3649
+ var defaultContext = {
3650
+ majorColorConfig: [
3651
+ { to: 20, value: "#D41F1F" },
3652
+ { from: 20, to: 40, value: "#D94E17" },
3653
+ { from: 40, to: 60, value: "#CBA700" },
3654
+ { from: 60, to: 80, value: "#669922" },
3655
+ { from: 80, value: "#118832" }
3656
+ ],
3657
+ majorColorMatchConfig: [{ match: "", value: "#5C33FF" }],
3658
+ trendColorConfig: [
3659
+ {
3660
+ to: 0,
3661
+ value: "#9E2520"
3662
+ },
3663
+ {
3664
+ from: 0,
3665
+ value: "#1C6B2D"
3666
+ }
3667
+ ],
3668
+ trendValueCopy: "> trendValue",
3669
+ divisor: "> majorValue | subtract(trendValueCopy) | divideBy(100)",
3670
+ trendValuePercent: "> trendValue | divideBy(divisor)"
3658
3671
  };
3659
- var dataSourcesSplitByAggregationsStats = (dataSource) => {
3660
- var _a, _b, _c, _d;
3661
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3662
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3663
- let splitDataSources = null;
3664
- let splitByFields = [];
3665
- let errorCode = null;
3666
- if (typeof fields[0] !== "string") {
3667
- splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
3668
- }
3669
- if (splitByFields && splitByFields.length > 0) {
3670
- splitDataSources = {};
3671
- splitByFields.forEach((splitByField) => {
3672
- splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
3673
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3674
- );
3675
- splitDataSources[splitByField].primary.data.fields = [fields[0]];
3676
- splitDataSources[splitByField].primary.data.columns = [columns[0]];
3677
- const idx = fields.findIndex((field) => field.name === splitByField);
3678
- if (idx > 0) {
3679
- splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
3680
- splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
3681
- }
3682
- });
3683
- } else {
3684
- errorCode = "INVALID_SPLIT_BY_FIELD";
3685
- }
3686
- return { splitDataSources, errorCode };
3672
+ var basePresetContext = {
3673
+ majorColorEditorConfig: void 0,
3674
+ trendColorEditorConfig: void 0,
3675
+ backgroundColorEditorConfig: void 0
3687
3676
  };
3688
- var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
3689
- var _a, _b, _c, _d, _e;
3690
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3691
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3692
- let splitDataSources = null;
3693
- let splitByFields = [];
3694
- let errorCode = null;
3695
- if (typeof fields[0] !== "string") {
3696
- splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
3697
- }
3698
- if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
3699
- splitDataSources = {};
3700
- const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
3701
- const valueKeys = [];
3702
- for (let i = 1; i < fields.length; i += 1) {
3703
- if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
3704
- valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
3705
- }
3677
+ var basePresetOptions = {
3678
+ majorColor: void 0,
3679
+ trendColor: void 0,
3680
+ backgroundColor: void 0
3681
+ };
3682
+ var presets = [
3683
+ {
3684
+ // dummy context variables to allow for resetting of unused context states
3685
+ label: (0, i18n_exports._)("None"),
3686
+ name: "singleValueRadial.none",
3687
+ value: {
3688
+ context: __spreadValues({}, basePresetContext),
3689
+ options: __spreadValues({}, basePresetOptions)
3690
+ }
3691
+ },
3692
+ {
3693
+ label: (0, i18n_exports._)("Major value and gauge"),
3694
+ name: "singleValueRadial.majorValue",
3695
+ value: {
3696
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3697
+ majorColorEditorConfig: defaultContext.majorColorConfig
3698
+ }),
3699
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3700
+ majorColor: "> majorValue | rangeValue(majorColorEditorConfig)"
3701
+ })
3702
+ }
3703
+ },
3704
+ {
3705
+ label: (0, i18n_exports._)("Major value, trend value, and gauge"),
3706
+ name: "singleValueRadial.majorValueAndTrend",
3707
+ value: {
3708
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3709
+ majorColorEditorConfig: defaultContext.majorColorConfig,
3710
+ trendColorEditorConfig: defaultContext.trendColorConfig
3711
+ }),
3712
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3713
+ majorColor: "> majorValue | rangeValue(majorColorEditorConfig)",
3714
+ trendColor: "> trendValue | rangeValue(trendColorEditorConfig)"
3715
+ })
3716
+ }
3717
+ },
3718
+ {
3719
+ label: (0, i18n_exports._)("Trend value"),
3720
+ name: "singleValueRadial.trend",
3721
+ value: {
3722
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3723
+ trendColorEditorConfig: defaultContext.trendColorConfig
3724
+ }),
3725
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3726
+ trendColor: "> trendValue | rangeValue(trendColorEditorConfig)"
3727
+ })
3728
+ }
3729
+ },
3730
+ {
3731
+ label: (0, i18n_exports._)("Background"),
3732
+ name: "singleValueRadial.background",
3733
+ value: {
3734
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3735
+ backgroundColorEditorConfig: defaultContext.majorColorConfig
3736
+ }),
3737
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3738
+ backgroundColor: "> majorValue | rangeValue(backgroundColorEditorConfig)"
3739
+ })
3706
3740
  }
3707
- valueKeys.forEach((val) => {
3708
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3709
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3710
- );
3711
- splitDataSources[val].primary.data.fields = [
3712
- { name: fields[0].name },
3713
- ...dataSourceKeys.map((k) => ({
3714
- name: k
3715
- }))
3716
- ];
3717
- splitDataSources[val].primary.data.columns = [[...columns[0]]];
3718
- dataSourceKeys.forEach((dsKey) => {
3719
- fields.forEach((field, idx) => {
3720
- if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
3721
- splitDataSources[val].primary.data.columns.push([...columns[idx]]);
3722
- }
3723
- });
3724
- });
3725
- });
3726
- } else {
3727
- errorCode = "INVALID_SPLIT_BY_FIELD";
3728
3741
  }
3729
- return { splitDataSources, errorCode };
3742
+ ];
3743
+ var themes = {
3744
+ defaultFontColor: (props) => pick_default({
3745
+ enterprise: {
3746
+ dark: variables_default.white(props),
3747
+ light: variables_default.black(props)
3748
+ },
3749
+ prisma: variables_default.contentColorActive(props)
3750
+ })(props),
3751
+ defaultBackgroundColor: (props) => pick_default({
3752
+ enterprise: {
3753
+ dark: variables_default.black(props),
3754
+ light: variables_default.white(props)
3755
+ },
3756
+ prisma: variables_default.backgroundColorSidebar(props)
3757
+ })(props),
3758
+ defaultRadialBackgroundColor: (props) => pick_default({
3759
+ enterprise: {
3760
+ dark: "rgba(255, 255, 255, 0.15)",
3761
+ light: "rgba(0, 0, 0, 0.1)"
3762
+ },
3763
+ prisma: variables_default.interactiveColorBackgroundDisabled(props)
3764
+ })(props)
3730
3765
  };
3731
- var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
3732
- var _a, _b, _c, _d;
3733
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3734
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3735
- let splitDataSources = null;
3736
- let splitByFields = [];
3737
- let errorCode = null;
3738
- if (typeof fields[0] !== "string") {
3739
- splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
3740
- }
3741
- if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
3742
- splitDataSources = {};
3743
- const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
3744
- const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
3745
- const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
3746
- const nonDataSourceAggregations = [];
3747
- if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
3748
- for (let i = 1; i < fields.length; i += 1) {
3749
- nonDataSourceAggregations.push(fields[i].name);
3750
- }
3751
- }
3752
- if (splitByFieldIdx === 0) {
3753
- const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
3754
- valueKeys.forEach((val, idx) => {
3755
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3756
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3757
- );
3758
- splitDataSources[val].primary.data.fields = [];
3759
- if (otherSplitBy.length) {
3760
- splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
3761
- }
3762
- if (dataSourceKeys.length) {
3763
- const columnValues = [[]];
3764
- splitDataSources[val].primary.data.fields = [
3765
- ...splitDataSources[val].primary.data.fields,
3766
- ...dataSourceKeys.map((k) => ({
3767
- name: k
3768
- }))
3769
- ];
3770
- dataSourceKeys.forEach(() => {
3771
- columnValues.push([]);
3772
- });
3773
- for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
3774
- columnValues[0].push(
3775
- fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
3776
- );
3777
- dataSourceKeys.forEach((dskey, dsIndx) => {
3778
- const mul = (fields.length - 1) / dataSourceKeys.length;
3779
- columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
3780
- });
3781
- }
3782
- splitDataSources[val].primary.data.columns = columnValues;
3783
- } else if (nonDataSourceAggregations.length) {
3784
- const columnValues = [];
3785
- fields.forEach((aggregationField, fieldIdx) => {
3786
- if (fieldIdx > 0) {
3787
- splitDataSources[val].primary.data.fields.push(aggregationField);
3788
- columnValues.push([columns[fieldIdx][idx]]);
3766
+ var editorConfig = [
3767
+ {
3768
+ label: (0, i18n_exports._)("Data configurations"),
3769
+ layout: [
3770
+ [
3771
+ {
3772
+ label: (0, i18n_exports._)("Value"),
3773
+ editor: "editor.columnSelector",
3774
+ option: "majorValue",
3775
+ context: "valuesContext",
3776
+ editorProps: {
3777
+ dataSourceKey: "primary",
3778
+ prepareValue: (definition) => {
3779
+ const {
3780
+ options: { majorValue: baseSPL }
3781
+ } = definition;
3782
+ return {
3783
+ context: {},
3784
+ options: {
3785
+ majorValue: `${baseSPL} | lastPoint()`,
3786
+ trendValue: `${baseSPL} | delta(-2)`
3787
+ }
3788
+ };
3789
3789
  }
3790
- });
3791
- splitDataSources[val].primary.data.columns = columnValues;
3790
+ },
3791
+ isDisabled: ({ options }) => options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis
3792
3792
  }
3793
- });
3794
- } else {
3795
- const valueKeys = [];
3796
- for (let i = 1; i < fields.length; i += 1) {
3797
- valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
3798
- }
3799
- valueKeys.forEach((val) => {
3800
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3801
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3802
- );
3803
- splitDataSources[val].primary.data.fields = [
3804
- { name: otherSplitBy[0] },
3805
- ...dataSourceKeys.map((k) => ({
3806
- name: k
3807
- }))
3808
- ];
3809
- splitDataSources[val].primary.data.columns = [[...columns[0]]];
3810
- dataSourceKeys.forEach((dsKey) => {
3811
- fields.forEach((field, idx) => {
3812
- if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
3813
- splitDataSources[val].primary.data.columns.push([...columns[idx]]);
3793
+ ]
3794
+ ]
3795
+ },
3796
+ {
3797
+ label: (0, i18n_exports._)("Data display"),
3798
+ layout: [
3799
+ ...StaticMajorAndTrendLayout_default,
3800
+ [
3801
+ {
3802
+ label: (0, i18n_exports._)("Trend display"),
3803
+ option: "trendDisplay",
3804
+ editor: "editor.select",
3805
+ editorProps: {
3806
+ values: [
3807
+ { label: (0, i18n_exports._)("Percent"), value: "percent" },
3808
+ { label: (0, i18n_exports._)("Absolute"), value: "absolute" },
3809
+ { label: (0, i18n_exports._)("Off"), value: "off" }
3810
+ ]
3811
+ },
3812
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
3813
+ }
3814
+ ],
3815
+ [
3816
+ {
3817
+ label: (0, i18n_exports._)("Min"),
3818
+ option: "minValue",
3819
+ editor: "editor.number"
3820
+ },
3821
+ {
3822
+ label: (0, i18n_exports._)("Max"),
3823
+ option: "maxValue",
3824
+ editor: "editor.number"
3825
+ }
3826
+ ],
3827
+ ...TrellisEditorConfig
3828
+ ]
3829
+ },
3830
+ {
3831
+ label: (0, i18n_exports._)("Color and style"),
3832
+ layout: [
3833
+ [
3834
+ {
3835
+ label: (0, i18n_exports._)("Dynamic elements"),
3836
+ key: "presetSelector",
3837
+ editor: "editor.presetSelector",
3838
+ editorProps: {
3839
+ presets,
3840
+ value: ({ context, options }) => {
3841
+ const initialPreset = getInitialPreset(context, options, presets);
3842
+ return initialPreset && initialPreset.label || null;
3814
3843
  }
3815
- });
3816
- });
3817
- });
3818
- }
3819
- } else {
3820
- errorCode = "INVALID_SPLIT_BY_FIELD";
3821
- }
3822
- return { splitDataSources, errorCode };
3823
- };
3824
- var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
3825
- var _a, _b, _c, _d, _e, _f;
3826
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3827
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3828
- let splitDataSources = null;
3829
- let splitByFields = [];
3830
- let errorCode = null;
3831
- if (typeof fields[0] !== "string") {
3832
- splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
3833
- }
3834
- const splitByIndex = fields == null ? void 0 : fields.findIndex(
3835
- (field) => field === splitBy || field.name === splitBy
3836
- );
3837
- if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
3838
- const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
3839
- splitDataSources = {};
3840
- splitByColumn.forEach((val, idx) => {
3841
- if (!splitDataSources[val]) {
3842
- splitDataSources[val] = [idx];
3843
- } else {
3844
- splitDataSources[val].push(idx);
3845
- }
3846
- });
3847
- const cloneFields = (0, lodash_exports.cloneDeep)(fields);
3848
- cloneFields.splice(splitByIndex, 1);
3849
- const valueKeys = Object.keys(splitDataSources);
3850
- valueKeys.forEach((val) => {
3851
- const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
3852
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3853
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3854
- );
3855
- splitDataSources[val].primary.data.fields = cloneFields;
3856
- splitDataSources[val].primary.data.columns = [];
3857
- columns.forEach((col, idx) => {
3858
- if (idx !== splitByIndex) {
3859
- const newCol = valIndices.map((valIdx) => col[valIdx]);
3860
- splitDataSources[val].primary.data.columns.push(newCol);
3844
+ }
3861
3845
  }
3862
- });
3863
- });
3864
- } else {
3865
- errorCode = "INVALID_SPLIT_BY_FIELD";
3846
+ ],
3847
+ [
3848
+ __spreadProps(__spreadValues({}, StaticMajorColorEditor_default), {
3849
+ editorProps: {
3850
+ themes
3851
+ }
3852
+ })
3853
+ ],
3854
+ [getDynamicMajorColorAndGaugeEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3855
+ [
3856
+ __spreadProps(__spreadValues({}, StaticTrendColorEditor_default), {
3857
+ editorProps: {
3858
+ themes
3859
+ }
3860
+ })
3861
+ ],
3862
+ [getDynamicTrendColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3863
+ [
3864
+ {
3865
+ label: (0, i18n_exports._)("Major value abbreviation"),
3866
+ option: "shouldAbbreviateMajorValue",
3867
+ editor: "editor.checkbox"
3868
+ }
3869
+ ],
3870
+ [
3871
+ {
3872
+ label: (0, i18n_exports._)("Trend value abbreviation"),
3873
+ option: "shouldAbbreviateTrendValue",
3874
+ editor: "editor.checkbox"
3875
+ }
3876
+ ],
3877
+ RadialBackgroundColor_default({ themes }),
3878
+ [
3879
+ __spreadProps(__spreadValues({}, StaticBackgroundColorEditor_default), {
3880
+ editorProps: {
3881
+ themes
3882
+ }
3883
+ })
3884
+ ],
3885
+ [
3886
+ __spreadProps(__spreadValues({}, TrellisBackgroundColorEditor), {
3887
+ editorProps: {
3888
+ themes
3889
+ }
3890
+ })
3891
+ ],
3892
+ [getDynamicBackgroundColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3893
+ [
3894
+ {
3895
+ label: (0, i18n_exports._)("Show gauge ranges"),
3896
+ option: "isGaugeOn",
3897
+ editor: "editor.toggle",
3898
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.majorColor)
3899
+ }
3900
+ ]
3901
+ ]
3866
3902
  }
3867
- return { splitDataSources, errorCode };
3868
- };
3869
- var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
3870
- let result = null;
3871
- try {
3872
- if (splitMode === trellisUtils_exports.TIMECHART) {
3873
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
3874
- } else if (splitMode === trellisUtils_exports.STATS) {
3875
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
3876
- } else if (splitMode === trellisUtils_exports.CHART) {
3877
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
3878
- } else if (splitMode === trellisUtils_exports.UNKNOWN) {
3879
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
3903
+ ];
3904
+ var config = {
3905
+ /**
3906
+ * unique viz key
3907
+ */
3908
+ key: "splunk.singlevalueradial",
3909
+ /**
3910
+ * viz name
3911
+ */
3912
+ name: (0, i18n_exports._)("Single value radial"),
3913
+ category: "Single Value" /* SINGLE_VALUE */,
3914
+ /**
3915
+ * viz icon
3916
+ */
3917
+ icon: visualization_icons_exports.SingleValueRadial,
3918
+ placeholderIcon: placeholders_exports.SingleValueRadial,
3919
+ dataContract,
3920
+ size,
3921
+ defaultContext,
3922
+ optionsSchema: visualization_schemas_exports.singleValueRadialOptionsSchema,
3923
+ editorConfig,
3924
+ events: {
3925
+ "value.click": {
3926
+ description: "trigger when user clicks major value",
3927
+ payloadKeys: ["majorValue", "trendValue"]
3880
3928
  }
3881
- } catch (ex) {
3882
- console.error("getTrellisDataSourcesBySplitMode ", ex);
3883
- result = { splitDataSources: null, errorCode: "UNKNOWN" };
3884
- }
3885
- return result;
3929
+ },
3930
+ supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "events" /* EVENTS */, "placeholder" /* PLACEHOLDER */, "trellis" /* TRELLIS */],
3931
+ themes
3886
3932
  };
3933
+ var config_default = enhanceConfig(config);
3934
+
3935
+ // esm-externals:@splunk/react-ui/Paginator
3936
+ var Paginator_exports = {};
3937
+ __export(Paginator_exports, {
3938
+ default: () => Paginator_default
3939
+ });
3940
+ var defaultImport38 = __toESM(require("@splunk/react-ui/Paginator"));
3941
+ __reExport(Paginator_exports, require("@splunk/react-ui/Paginator"));
3942
+ var Paginator_default = "default" in defaultImport38 ? defaultImport38.default : defaultImport38;
3943
+
3944
+ // esm-externals:@splunk/themes
3945
+ var themes_exports = {};
3946
+ __export(themes_exports, {
3947
+ default: () => themes_default
3948
+ });
3949
+ var defaultImport39 = __toESM(require("@splunk/themes"));
3950
+ __reExport(themes_exports, require("@splunk/themes"));
3951
+ var themes_default = "default" in defaultImport39 ? defaultImport39.default : defaultImport39;
3952
+
3953
+ // esm-externals:@splunk/themes/useSplunkTheme
3954
+ var useSplunkTheme_exports = {};
3955
+ __export(useSplunkTheme_exports, {
3956
+ default: () => useSplunkTheme_default
3957
+ });
3958
+ var defaultImport40 = __toESM(require("@splunk/themes/useSplunkTheme"));
3959
+ __reExport(useSplunkTheme_exports, require("@splunk/themes/useSplunkTheme"));
3960
+ var useSplunkTheme_default = "default" in defaultImport40 ? defaultImport40.default : defaultImport40;
3887
3961
 
3888
3962
  // src/common/hocs/withTrellis.tsx
3889
3963
  var TrellisContainer = styled_components_default.div`
@@ -3947,7 +4021,11 @@ var withTrellis = (Viz) => {
3947
4021
  trellisMinColumnWidth,
3948
4022
  trellisRowHeight,
3949
4023
  splitByLayout,
3950
- trellisSplitBy
4024
+ trellisSplitBy,
4025
+ trellisSharedScale,
4026
+ stackMode,
4027
+ yAxisMin,
4028
+ yAxisMax
3951
4029
  } = mergedOptions;
3952
4030
  const colCount = trellisColumns > 0 ? trellisColumns : defaultOptions.trellisColumns;
3953
4031
  const pageCount = +trellisPageCount > 0 ? +trellisPageCount : defaultOptions.trellisPageCount;
@@ -4018,10 +4096,10 @@ var withTrellis = (Viz) => {
4018
4096
  [pageNum, pagedData]
4019
4097
  );
4020
4098
  const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
4021
- const isTrellisFeatureFlagOn = Boolean(
4099
+ const isTrellisFeatureFlagOn2 = Boolean(
4022
4100
  featureFlagContext && featureFlagContext.visualizations_enableTrellis
4023
4101
  );
4024
- if (!isTrellisFeatureFlagOn || !splitByLayout || splitByLayout !== visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
4102
+ if (!isTrellisFeatureFlagOn2 || !splitByLayout || splitByLayout !== visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
4025
4103
  return /* @__PURE__ */ react_exports.createElement(Viz, __spreadValues({}, opts));
4026
4104
  }
4027
4105
  if (splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
@@ -4050,6 +4128,13 @@ var withTrellis = (Viz) => {
4050
4128
  splitByKeys = splitByKeysModified;
4051
4129
  totalPages = splitByKeysModified ? Math.ceil(splitByKeysModified.length / pageCount) : 0;
4052
4130
  }
4131
+ const [calculatedMin, calculatedMax] = determineMinMax(
4132
+ modifiedDataSourceBySplitBy,
4133
+ trellisSharedScale,
4134
+ yAxisMin,
4135
+ yAxisMax,
4136
+ stackMode
4137
+ );
4053
4138
  return /* @__PURE__ */ react_exports.createElement(TrellisContainer, { height, width, backgroundColor: trellisBackgroundColor }, /* @__PURE__ */ react_exports.createElement(
4054
4139
  TrellisContainerGrid,
4055
4140
  {
@@ -4058,7 +4143,7 @@ var withTrellis = (Viz) => {
4058
4143
  colMinWidth,
4059
4144
  rowHeight
4060
4145
  },
4061
- pagedData && pagedData.map((splitByKey, idx) => /* @__PURE__ */ react_exports.createElement(
4146
+ pagedData == null ? void 0 : pagedData.map((splitByKey, idx) => /* @__PURE__ */ react_exports.createElement(
4062
4147
  "div",
4063
4148
  {
4064
4149
  className: "child",
@@ -4079,7 +4164,10 @@ var withTrellis = (Viz) => {
4079
4164
  trellisKey: splitByKey,
4080
4165
  trellisSplitBy: currTrellisSplitBy,
4081
4166
  dataSources: modifiedDataSourceBySplitBy[splitByKey],
4082
- options,
4167
+ options: __spreadProps(__spreadValues({}, options), {
4168
+ yAxisMin: calculatedMin,
4169
+ yAxisMax: calculatedMax
4170
+ }),
4083
4171
  key: `viz-${idx.toString()}`,
4084
4172
  height: containerHeight,
4085
4173
  width: containerWidth
@@ -4113,11 +4201,16 @@ var computeVizProps = (_a) => {
4113
4201
  var _b = _a, { trellisKey } = _b, props = __objRest(_b, ["trellisKey"]);
4114
4202
  return __spreadValues({ trellisKey }, props);
4115
4203
  };
4204
+ var computeVizPropsBeforeEval = (options) => {
4205
+ const trendColor = getTrendColorWithPercent(options);
4206
+ return __spreadValues({}, trendColor);
4207
+ };
4116
4208
  var viz = withTrellis_default(
4117
4209
  withDashboardViz_default({
4118
4210
  ReactViz: SingleValueRadial_default,
4119
4211
  vizConfig: config_default,
4120
- computeVizProps
4212
+ computeVizProps,
4213
+ computeVizPropsBeforeEval
4121
4214
  })
4122
4215
  );
4123
4216
  var { themes: themes2 } = config_default;