@splunk/visualizations 28.7.0 → 28.9.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 (375) hide show
  1. package/Area.config.js +2 -4
  2. package/Area.config.js.map +2 -2
  3. package/Area.js +245 -147
  4. package/Area.js.map +4 -4
  5. package/Bar.config.js +2 -4
  6. package/Bar.config.js.map +2 -2
  7. package/Bar.js +246 -148
  8. package/Bar.js.map +4 -4
  9. package/Bubble/Bubble.d.ts +3 -1
  10. package/Bubble/Bubble.d.ts.map +1 -1
  11. package/Bubble.js +216 -108
  12. package/Bubble.js.map +4 -4
  13. package/CHANGELOG.external.md +56 -0
  14. package/ChoroplethSvg/ChoroplethSvg.d.ts +3 -1
  15. package/ChoroplethSvg/ChoroplethSvg.d.ts.map +1 -1
  16. package/ChoroplethSvg/PureChoroplethSvg/PureChoroplethSvg.d.ts.map +1 -1
  17. package/ChoroplethSvg/PureChoroplethSvg/SvgMutator.d.ts.map +1 -1
  18. package/ChoroplethSvg.js +638 -209
  19. package/ChoroplethSvg.js.map +4 -4
  20. package/Column.config.js +2 -4
  21. package/Column.config.js.map +2 -2
  22. package/Column.js +246 -148
  23. package/Column.js.map +4 -4
  24. package/Ellipse/Ellipse.d.ts +3 -1
  25. package/Ellipse/Ellipse.d.ts.map +1 -1
  26. package/Ellipse.js +216 -105
  27. package/Ellipse.js.map +4 -4
  28. package/Events/Events.d.ts +5 -3
  29. package/Events/Events.d.ts.map +1 -1
  30. package/Events/PureEvents/FieldSummaryTooltip.d.ts.map +1 -1
  31. package/Events/PureEvents/PureEvents.d.ts +0 -1
  32. package/Events/PureEvents/PureEvents.d.ts.map +1 -1
  33. package/Events.js +270 -157
  34. package/Events.js.map +4 -4
  35. package/FillerGauge.js +251 -143
  36. package/FillerGauge.js.map +4 -4
  37. package/Image/Image.d.ts +3 -1
  38. package/Image/Image.d.ts.map +1 -1
  39. package/Image.js +217 -106
  40. package/Image.js.map +4 -4
  41. package/Line.config.js +2 -4
  42. package/Line.config.js.map +2 -2
  43. package/Line.js +246 -148
  44. package/Line.js.map +4 -4
  45. package/LinkGraph/LinkGraph.d.ts +3 -1
  46. package/LinkGraph/LinkGraph.d.ts.map +1 -1
  47. package/LinkGraph/PureLinkGraph/PureLinkGraphUtils.d.ts.map +1 -1
  48. package/LinkGraph/PureLinkGraph/components/Node.d.ts.map +1 -1
  49. package/LinkGraph.config.js +1 -1
  50. package/LinkGraph.config.js.map +2 -2
  51. package/LinkGraph.js +802 -682
  52. package/LinkGraph.js.map +4 -4
  53. package/Map/Map.d.ts +10 -9
  54. package/Map/Map.d.ts.map +1 -1
  55. package/Map/PureMap/BubbleLayer.d.ts.map +1 -1
  56. package/Map/PureMap/ClusterLayer.d.ts.map +1 -1
  57. package/Map/PureMap/MapUtils.d.ts.map +1 -1
  58. package/Map/PureMap/MarkerWrapper.d.ts.map +1 -1
  59. package/Map/PureMap/PureMap.d.ts +8 -65
  60. package/Map/PureMap/PureMap.d.ts.map +1 -1
  61. package/Map.config.js +1 -1
  62. package/Map.config.js.map +2 -2
  63. package/Map.js +363 -313
  64. package/Map.js.map +4 -4
  65. package/Markdown/Markdown.d.ts +9 -1
  66. package/Markdown/Markdown.d.ts.map +1 -1
  67. package/Markdown/config.d.ts.map +1 -1
  68. package/Markdown.config.js +6 -1
  69. package/Markdown.config.js.map +2 -2
  70. package/Markdown.js +226 -95
  71. package/Markdown.js.map +3 -3
  72. package/MarkerGauge.js +247 -137
  73. package/MarkerGauge.js.map +4 -4
  74. package/NetworkGraph/PureNetworkGraph/PureNetworkGraph.d.ts.map +1 -1
  75. package/NetworkGraph/PureNetworkGraph/components/NetworkGraphSvg.d.ts +1 -0
  76. package/NetworkGraph/PureNetworkGraph/components/NetworkGraphSvg.d.ts.map +1 -1
  77. package/NetworkGraph/PureNetworkGraph/components/Node.d.ts +1 -0
  78. package/NetworkGraph/PureNetworkGraph/components/Node.d.ts.map +1 -1
  79. package/NetworkGraph/PureNetworkGraph/utils/networkGraphUtils.d.ts +3 -5
  80. package/NetworkGraph/PureNetworkGraph/utils/networkGraphUtils.d.ts.map +1 -1
  81. package/NetworkGraph.config.js +4 -2
  82. package/NetworkGraph.config.js.map +2 -2
  83. package/NetworkGraph.js +327 -188
  84. package/NetworkGraph.js.map +4 -4
  85. package/ParallelCoordinates/ParallelCoordinates.d.ts +3 -1
  86. package/ParallelCoordinates/ParallelCoordinates.d.ts.map +1 -1
  87. package/ParallelCoordinates.js +239 -128
  88. package/ParallelCoordinates.js.map +4 -4
  89. package/Pie/config.d.ts.map +1 -1
  90. package/Pie/pieUtils.d.ts.map +1 -1
  91. package/Pie.config.js +4 -2
  92. package/Pie.config.js.map +2 -2
  93. package/Pie.js +228 -125
  94. package/Pie.js.map +3 -3
  95. package/ProcessTree/ProcessTree.d.ts +3 -1
  96. package/ProcessTree/ProcessTree.d.ts.map +1 -1
  97. package/ProcessTree/PureProcessTree/PureProcessTree.d.ts +1 -0
  98. package/ProcessTree/PureProcessTree/PureProcessTree.d.ts.map +1 -1
  99. package/ProcessTree/PureProcessTree/components/ProcessTreeLeftPanel.d.ts +1 -0
  100. package/ProcessTree/PureProcessTree/components/ProcessTreeLeftPanel.d.ts.map +1 -1
  101. package/ProcessTree/PureProcessTree/hooks/useProcessTreeGraphData.d.ts +2 -1
  102. package/ProcessTree/PureProcessTree/hooks/useProcessTreeGraphData.d.ts.map +1 -1
  103. package/ProcessTree/PureProcessTree/utils/iconLoader.d.ts +2 -0
  104. package/ProcessTree/PureProcessTree/utils/iconLoader.d.ts.map +1 -1
  105. package/ProcessTree/PureProcessTree/utils/processTreeUtils.d.ts +5 -1
  106. package/ProcessTree/PureProcessTree/utils/processTreeUtils.d.ts.map +1 -1
  107. package/ProcessTree.js +435 -192
  108. package/ProcessTree.js.map +4 -4
  109. package/Punchcard/Punchcard.d.ts +3 -1
  110. package/Punchcard/Punchcard.d.ts.map +1 -1
  111. package/Punchcard.js +238 -129
  112. package/Punchcard.js.map +4 -4
  113. package/Rectangle/Rectangle.d.ts +3 -1
  114. package/Rectangle/Rectangle.d.ts.map +1 -1
  115. package/Rectangle.js +218 -116
  116. package/Rectangle.js.map +4 -4
  117. package/RichText/PureRichText/Editor/EditorPanel.d.ts +1 -4
  118. package/RichText/PureRichText/Editor/EditorPanel.d.ts.map +1 -1
  119. package/RichText/PureRichText/Editor/hooks/useConfigPanelFocus.d.ts +14 -0
  120. package/RichText/PureRichText/Editor/hooks/useConfigPanelFocus.d.ts.map +1 -0
  121. package/RichText/PureRichText/Editor/hooks/useEditorPanelSync.d.ts +15 -0
  122. package/RichText/PureRichText/Editor/hooks/useEditorPanelSync.d.ts.map +1 -0
  123. package/RichText/PureRichText/Editor/hooks/useLinkHandlers.d.ts.map +1 -1
  124. package/RichText/PureRichText/Editor/hooks/usePortalTarget.d.ts +9 -0
  125. package/RichText/PureRichText/Editor/hooks/usePortalTarget.d.ts.map +1 -0
  126. package/RichText/PureRichText/InnerEditor.d.ts +20 -4
  127. package/RichText/PureRichText/InnerEditor.d.ts.map +1 -1
  128. package/RichText/PureRichText/PureRichText.d.ts +21 -9
  129. package/RichText/PureRichText/PureRichText.d.ts.map +1 -1
  130. package/RichText/PureRichText/PureRichTextContext.d.ts +3 -6
  131. package/RichText/PureRichText/PureRichTextContext.d.ts.map +1 -1
  132. package/RichText/PureRichText/RichTextStyles.d.ts +5 -4
  133. package/RichText/PureRichText/RichTextStyles.d.ts.map +1 -1
  134. package/RichText/PureRichText/activeInstance.d.ts +6 -7
  135. package/RichText/PureRichText/activeInstance.d.ts.map +1 -1
  136. package/RichText/PureRichText/config.d.ts.map +1 -1
  137. package/RichText/PureRichText/hooks/useContentSave.d.ts +6 -0
  138. package/RichText/PureRichText/hooks/useContentSave.d.ts.map +1 -1
  139. package/RichText/PureRichText/hooks/useContentSync.d.ts +13 -1
  140. package/RichText/PureRichText/hooks/useContentSync.d.ts.map +1 -1
  141. package/RichText/PureRichText/hooks/useDashboardKeyboardNav.d.ts +2 -7
  142. package/RichText/PureRichText/hooks/useDashboardKeyboardNav.d.ts.map +1 -1
  143. package/RichText/PureRichText/hooks/useEditorSetup.d.ts +8 -4
  144. package/RichText/PureRichText/hooks/useEditorSetup.d.ts.map +1 -1
  145. package/RichText/PureRichText/hooks/useFakeHighlight.d.ts +1 -16
  146. package/RichText/PureRichText/hooks/useFakeHighlight.d.ts.map +1 -1
  147. package/RichText/PureRichText/hooks/useFocusHandlers.d.ts +2 -4
  148. package/RichText/PureRichText/hooks/useFocusHandlers.d.ts.map +1 -1
  149. package/RichText/PureRichText/hooks/useKeyboardShortcuts.d.ts.map +1 -1
  150. package/RichText/PureRichText/hooks/useMouseHandlers.d.ts +3 -7
  151. package/RichText/PureRichText/hooks/useMouseHandlers.d.ts.map +1 -1
  152. package/RichText/PureRichText/hooks/useStepFontSize.d.ts +2 -2
  153. package/RichText/PureRichText/hooks/useStepLineSpacing.d.ts +2 -3
  154. package/RichText/PureRichText/hooks/useStepLineSpacing.d.ts.map +1 -1
  155. package/RichText/PureRichText/hooks/useTokenMap.d.ts +31 -40
  156. package/RichText/PureRichText/hooks/useTokenMap.d.ts.map +1 -1
  157. package/RichText/PureRichText/renderers/ElementRenderer.d.ts +2 -5
  158. package/RichText/PureRichText/renderers/ElementRenderer.d.ts.map +1 -1
  159. package/RichText/PureRichText/renderers/LeafRenderer.d.ts +0 -4
  160. package/RichText/PureRichText/renderers/LeafRenderer.d.ts.map +1 -1
  161. package/RichText/PureRichText/types.d.ts +21 -0
  162. package/RichText/PureRichText/types.d.ts.map +1 -1
  163. package/RichText/PureRichText/utils/slateUtils.d.ts +26 -2
  164. package/RichText/PureRichText/utils/slateUtils.d.ts.map +1 -1
  165. package/RichText/RichText.d.ts +5 -1
  166. package/RichText/RichText.d.ts.map +1 -1
  167. package/RichText/config.d.ts.map +1 -1
  168. package/RichText.config.js +19 -1
  169. package/RichText.config.js.map +2 -2
  170. package/RichText.js +2311 -835
  171. package/RichText.js.map +4 -4
  172. package/Sankey/PureSankey/PureSankey.d.ts +2 -0
  173. package/Sankey/PureSankey/PureSankey.d.ts.map +1 -1
  174. package/Sankey/PureSankey/SankeyLink.d.ts +3 -1
  175. package/Sankey/PureSankey/SankeyLink.d.ts.map +1 -1
  176. package/Sankey/PureSankey/SankeyNode.d.ts +5 -2
  177. package/Sankey/PureSankey/SankeyNode.d.ts.map +1 -1
  178. package/Sankey/PureSankey/SankeyUtils.d.ts.map +1 -1
  179. package/Sankey/Sankey.d.ts +3 -1
  180. package/Sankey/Sankey.d.ts.map +1 -1
  181. package/Sankey.js +508 -219
  182. package/Sankey.js.map +4 -4
  183. package/Scatter.config.js +3 -5
  184. package/Scatter.config.js.map +2 -2
  185. package/Scatter.js +244 -146
  186. package/Scatter.js.map +4 -4
  187. package/SingleValue/SingleValue.d.ts.map +1 -1
  188. package/SingleValue.js +273 -173
  189. package/SingleValue.js.map +4 -4
  190. package/SingleValueBasic.js +4 -4
  191. package/SingleValueBasic.js.map +2 -2
  192. package/SingleValueIcon/SingleValueIcon.d.ts.map +1 -1
  193. package/SingleValueIcon.js +264 -164
  194. package/SingleValueIcon.js.map +4 -4
  195. package/SingleValueRadial.js +267 -167
  196. package/SingleValueRadial.js.map +4 -4
  197. package/SparkLine/SparkLine.d.ts.map +1 -1
  198. package/SparkLine.js.map +2 -2
  199. package/Table/PureTable.d.ts +2 -0
  200. package/Table/PureTable.d.ts.map +1 -1
  201. package/Table/Table.d.ts +2 -5
  202. package/Table/Table.d.ts.map +1 -1
  203. package/Table/config.d.ts.map +1 -1
  204. package/Table/hooks.d.ts.map +1 -1
  205. package/Table.config.js +8 -1
  206. package/Table.config.js.map +2 -2
  207. package/Table.js +374 -270
  208. package/Table.js.map +4 -4
  209. package/Timeline/PureTimeline/PureTimeline.d.ts +6 -5
  210. package/Timeline/PureTimeline/PureTimeline.d.ts.map +1 -1
  211. package/Timeline/PureTimeline/src/CursorPlugin.d.ts +1 -0
  212. package/Timeline/PureTimeline/src/CursorPlugin.d.ts.map +1 -1
  213. package/Timeline/PureTimeline/src/TimelineLegend.d.ts +10 -7
  214. package/Timeline/PureTimeline/src/TimelineLegend.d.ts.map +1 -1
  215. package/Timeline/PureTimeline/src/TimelineTooltip.d.ts +5 -1
  216. package/Timeline/PureTimeline/src/TimelineTooltip.d.ts.map +1 -1
  217. package/Timeline/PureTimeline/src/TimelineUplot.d.ts +19 -2
  218. package/Timeline/PureTimeline/src/TimelineUplot.d.ts.map +1 -1
  219. package/Timeline/PureTimeline/src/TimelineYAxis.d.ts.map +1 -1
  220. package/Timeline/PureTimeline/src/XAxisPlugin.d.ts +1 -0
  221. package/Timeline/PureTimeline/src/XAxisPlugin.d.ts.map +1 -1
  222. package/Timeline/PureTimeline/src/utils/timelineUtils.d.ts +8 -0
  223. package/Timeline/PureTimeline/src/utils/timelineUtils.d.ts.map +1 -1
  224. package/Timeline/Timeline.d.ts +3 -1
  225. package/Timeline/Timeline.d.ts.map +1 -1
  226. package/Timeline.config.js +2 -2
  227. package/Timeline.config.js.map +2 -2
  228. package/Timeline.js +713 -351
  229. package/Timeline.js.map +4 -4
  230. package/Treemap/PureTreemap/components/PureTreemap.d.ts +42 -0
  231. package/Treemap/PureTreemap/components/PureTreemap.d.ts.map +1 -0
  232. package/Treemap/PureTreemap/components/TreemapBreadcrumb.d.ts +10 -0
  233. package/Treemap/PureTreemap/components/TreemapBreadcrumb.d.ts.map +1 -0
  234. package/Treemap/PureTreemap/components/TreemapChildCell.d.ts +28 -0
  235. package/Treemap/PureTreemap/components/TreemapChildCell.d.ts.map +1 -0
  236. package/Treemap/PureTreemap/components/TreemapHeader.d.ts +19 -0
  237. package/Treemap/PureTreemap/components/TreemapHeader.d.ts.map +1 -0
  238. package/Treemap/PureTreemap/components/TreemapHoverTarget.d.ts +17 -0
  239. package/Treemap/PureTreemap/components/TreemapHoverTarget.d.ts.map +1 -0
  240. package/Treemap/PureTreemap/components/TreemapLegend.d.ts +20 -0
  241. package/Treemap/PureTreemap/components/TreemapLegend.d.ts.map +1 -0
  242. package/Treemap/PureTreemap/components/TreemapNode.d.ts +5 -0
  243. package/Treemap/PureTreemap/components/TreemapNode.d.ts.map +1 -0
  244. package/Treemap/PureTreemap/components/TreemapParentNode.d.ts +10 -0
  245. package/Treemap/PureTreemap/components/TreemapParentNode.d.ts.map +1 -0
  246. package/Treemap/PureTreemap/components/TreemapStandaloneNode.d.ts +6 -0
  247. package/Treemap/PureTreemap/components/TreemapStandaloneNode.d.ts.map +1 -0
  248. package/Treemap/PureTreemap/components/TreemapTooltip.d.ts +17 -0
  249. package/Treemap/PureTreemap/components/TreemapTooltip.d.ts.map +1 -0
  250. package/Treemap/PureTreemap/mockdata/data.d.ts +90 -0
  251. package/Treemap/PureTreemap/mockdata/data.d.ts.map +1 -0
  252. package/Treemap/PureTreemap/utils/treemapColorUtils.d.ts +67 -0
  253. package/Treemap/PureTreemap/utils/treemapColorUtils.d.ts.map +1 -0
  254. package/Treemap/PureTreemap/utils/treemapDataColorUtils.d.ts +5 -0
  255. package/Treemap/PureTreemap/utils/treemapDataColorUtils.d.ts.map +1 -0
  256. package/Treemap/PureTreemap/utils/treemapDataUtils.d.ts +14 -0
  257. package/Treemap/PureTreemap/utils/treemapDataUtils.d.ts.map +1 -0
  258. package/Treemap/PureTreemap/utils/treemapLayout.d.ts +49 -0
  259. package/Treemap/PureTreemap/utils/treemapLayout.d.ts.map +1 -0
  260. package/Treemap/PureTreemap/utils/treemapNodeUtils.d.ts +81 -0
  261. package/Treemap/PureTreemap/utils/treemapNodeUtils.d.ts.map +1 -0
  262. package/Treemap/PureTreemap/utils/treemapTypes.d.ts +37 -0
  263. package/Treemap/PureTreemap/utils/treemapTypes.d.ts.map +1 -0
  264. package/Treemap/PureTreemap/utils/treemapUtils.d.ts +76 -0
  265. package/Treemap/PureTreemap/utils/treemapUtils.d.ts.map +1 -0
  266. package/Treemap/Treemap.d.ts +14 -0
  267. package/Treemap/Treemap.d.ts.map +1 -0
  268. package/Treemap/config.d.ts +4 -0
  269. package/Treemap/config.d.ts.map +1 -0
  270. package/Treemap/index.d.ts +3 -0
  271. package/Treemap/index.d.ts.map +1 -0
  272. package/Treemap.config.js +465 -0
  273. package/Treemap.config.js.map +7 -0
  274. package/Treemap.js +6349 -0
  275. package/Treemap.js.map +7 -0
  276. package/common/Charting.js +8 -10
  277. package/common/Charting.js.map +2 -2
  278. package/common/ChartingApi.d.ts.map +1 -1
  279. package/common/ChartingApi.js +5 -2
  280. package/common/ChartingApi.js.map +2 -2
  281. package/common/DocExampleWithVizSandbox.js +3 -3
  282. package/common/DocExampleWithVizSandbox.js.map +2 -2
  283. package/common/GaugeMajorTicks.js.map +2 -2
  284. package/common/GaugeValueMarker.js +1 -0
  285. package/common/GaugeValueMarker.js.map +2 -2
  286. package/common/OptionsDoc.js +1 -1
  287. package/common/OptionsDoc.js.map +2 -2
  288. package/common/OverviewDoc.js +3 -3
  289. package/common/OverviewDoc.js.map +2 -2
  290. package/common/ThemesDoc.js.map +2 -2
  291. package/common/TimeSeriesChartWrapper.js +10 -9
  292. package/common/TimeSeriesChartWrapper.js.map +2 -2
  293. package/common/chartingUtils.d.ts.map +1 -1
  294. package/common/chartingUtils.js +12 -11
  295. package/common/chartingUtils.js.map +2 -2
  296. package/common/components/IconPlaceholder.d.ts.map +1 -1
  297. package/common/docUtils.d.ts.map +1 -1
  298. package/common/docUtils.js +16 -14
  299. package/common/docUtils.js.map +2 -2
  300. package/common/editorConfig/AxesChartDataDisplay.d.ts.map +1 -1
  301. package/common/gaugeUtils.d.ts.map +1 -1
  302. package/common/gaugeUtils.js +11 -5
  303. package/common/gaugeUtils.js.map +2 -2
  304. package/common/hocs/FixedSizeContainer.d.ts.map +1 -1
  305. package/common/hooks/useDynamicHeight.d.ts +67 -0
  306. package/common/hooks/useDynamicHeight.d.ts.map +1 -0
  307. package/common/hooks/useSorting.d.ts.map +1 -1
  308. package/common/interfaces/VizCategory.d.ts +2 -1
  309. package/common/interfaces/VizCategory.d.ts.map +1 -1
  310. package/common/interfaces/VizEvent.d.ts +7 -0
  311. package/common/interfaces/VizEvent.d.ts.map +1 -1
  312. package/common/utils/dataUtils.d.ts.map +1 -1
  313. package/common/utils/dataUtils.js +6 -10
  314. package/common/utils/dataUtils.js.map +2 -2
  315. package/common/utils/featureFlagUtils.js +2 -2
  316. package/common/utils/featureFlagUtils.js.map +2 -2
  317. package/common/utils/focusUtils.js +1 -1
  318. package/common/utils/focusUtils.js.map +2 -2
  319. package/common/utils/mapUtils.d.ts.map +1 -1
  320. package/common/utils/mapUtils.js +14 -18
  321. package/common/utils/mapUtils.js.map +2 -2
  322. package/common/utils/singleValueUtils.js +22 -25
  323. package/common/utils/singleValueUtils.js.map +2 -2
  324. package/common/utils/textUtils.d.ts.map +1 -1
  325. package/common/utils/textUtils.js +37 -23
  326. package/common/utils/textUtils.js.map +2 -2
  327. package/common/utils/trellisUtils.d.ts.map +1 -1
  328. package/common/utils/trellisUtils.js +18 -17
  329. package/common/utils/trellisUtils.js.map +2 -2
  330. package/common/utils/urlUtils.js.map +2 -2
  331. package/common/utils/visualizationTheme.d.ts +15 -0
  332. package/common/utils/visualizationTheme.d.ts.map +1 -0
  333. package/common/utils/visualizationTheme.js +72 -0
  334. package/common/utils/visualizationTheme.js.map +7 -0
  335. package/common/withDashboardViz.d.ts +3 -1
  336. package/common/withDashboardViz.d.ts.map +1 -1
  337. package/common/withDashboardViz.js +216 -105
  338. package/common/withDashboardViz.js.map +4 -4
  339. package/docs-llm/INDEX.md +1 -0
  340. package/docs-llm/area/options.md +84 -84
  341. package/docs-llm/bar/options.md +77 -77
  342. package/docs-llm/bubble/options.md +51 -51
  343. package/docs-llm/choropleth-svg/options.md +5 -5
  344. package/docs-llm/column/options.md +82 -82
  345. package/docs-llm/ellipse/options.md +6 -6
  346. package/docs-llm/events/options.md +6 -6
  347. package/docs-llm/filler-gauge/options.md +16 -16
  348. package/docs-llm/image/options.md +3 -3
  349. package/docs-llm/line/options.md +82 -82
  350. package/docs-llm/link-graph/options.md +16 -16
  351. package/docs-llm/map/options.md +12 -12
  352. package/docs-llm/markdown/options.md +7 -7
  353. package/docs-llm/marker-gauge/options.md +16 -16
  354. package/docs-llm/network-graph/options.md +39 -39
  355. package/docs-llm/parallel-coordinates/options.md +4 -4
  356. package/docs-llm/pie/examples-json.md +195 -0
  357. package/docs-llm/pie/examples-react.md +123 -0
  358. package/docs-llm/pie/options.md +23 -23
  359. package/docs-llm/process-tree/options.md +23 -22
  360. package/docs-llm/punchcard/options.md +23 -23
  361. package/docs-llm/pure-rich-text/options.md +6 -5
  362. package/docs-llm/rectangle/options.md +9 -9
  363. package/docs-llm/rich-text/options.md +6 -5
  364. package/docs-llm/sankey/options.md +9 -9
  365. package/docs-llm/scatter/options.md +57 -57
  366. package/docs-llm/single-value/options.md +39 -39
  367. package/docs-llm/single-value-icon/options.md +33 -33
  368. package/docs-llm/single-value-radial/options.md +31 -31
  369. package/docs-llm/table/options.md +14 -13
  370. package/docs-llm/timeline/options.md +17 -17
  371. package/docs-llm/treemap/examples-json.md +5 -0
  372. package/docs-llm/treemap/examples-react.md +5 -0
  373. package/docs-llm/treemap/options.md +26 -0
  374. package/docs-llm/treemap/overview.md +27 -0
  375. package/package.json +31 -30
@@ -181,7 +181,7 @@ var getTrendColor = ({
181
181
  if (hasBackground(customizedBgColor) && !isIdenticalColor(customizedBgColor, defaultBackgroundColor) && !isIdenticalColor(customizedBgColor, defaultBlockFontColor)) {
182
182
  return defaultBlockFontColor;
183
183
  }
184
- const isInvalidTrend = trendDisplay === "percent" && trendValue === parseFloat(majorValue);
184
+ const isInvalidTrend = trendDisplay === "percent" && trendValue === Number.parseFloat(majorValue);
185
185
  if (trendValue === 0 || isInvalidTrend) {
186
186
  return defaultFontColor;
187
187
  }
@@ -222,7 +222,7 @@ var computeText = ({
222
222
  let text = (0, numberUtils_exports.isNumerial)(value) ? (0, numberUtils_exports.formatNumber)(value, numberPrecision, {
223
223
  useThousandSeparators: shouldUseThousandSeparators,
224
224
  useTrendUnits: shouldAbbreviateValue
225
- }) : value;
225
+ }) : String(value != null ? value : "");
226
226
  text = text || "";
227
227
  return text;
228
228
  };
@@ -252,23 +252,20 @@ var getTrendText = ({
252
252
  shouldUseThousandSeparators,
253
253
  shouldAbbreviateValue: shouldAbbreviateTrendValue
254
254
  });
255
- if (trendValue === "" || !(0, numberUtils_exports.isNumerial)(trendValue)) {
256
- return "";
257
- }
255
+ let trendText = "";
258
256
  const showPercent = trendDisplay === "percent";
259
- if (!showPercent) {
260
- return compute(trendValue);
261
- }
262
- const diff = Math.abs(trendValue - majorValue);
263
- let val = trendValue / diff * 100;
264
- if (trendValue === 0 && diff === 0) {
265
- val = 0;
266
- }
267
- if (!Number.isFinite(val)) {
268
- return "N/A";
257
+ const isValidTrend = trendValue !== "" && (0, numberUtils_exports.isNumerial)(trendValue);
258
+ if (isValidTrend && !showPercent) {
259
+ trendText = compute(trendValue);
260
+ } else if (isValidTrend && showPercent) {
261
+ const diff = Math.abs(trendValue - majorValue);
262
+ let val = trendValue / diff * 100;
263
+ if (trendValue === 0 && diff === 0) {
264
+ val = 0;
265
+ }
266
+ trendText = Number.isFinite(val) ? `${compute(val)}%` : "N/A";
269
267
  }
270
- const text = compute(val);
271
- return `${text}%`;
268
+ return trendText;
272
269
  };
273
270
  var computeFontSize = (text, { width, height }, fontFamily = DEFAULT_FONT_FAMILY, fontWeight = "normal") => {
274
271
  const widthInDefaultFont = (0, domUtils_exports.computeTextSize)(text, `${fontWeight} ${DEFAULT_FONT}px ${fontFamily}`);
@@ -276,7 +273,7 @@ var computeFontSize = (text, { width, height }, fontFamily = DEFAULT_FONT_FAMILY
276
273
  width / widthInDefaultFont * DEFAULT_FONT,
277
274
  height / DEFAULT_FONT * DEFAULT_FONT
278
275
  );
279
- return parseInt(fontSize, 10);
276
+ return Number.parseInt(fontSize, 10);
280
277
  };
281
278
  var getMajorFontSize = ({ width, height, unit, majorText, spaceRatio = 1 }) => {
282
279
  const majorTextCalc = unit ? `${unit}${majorText}` : majorText;
@@ -292,11 +289,11 @@ var getTrendFontSize = ({ width, height, trendText, spaceRatio = 1 }) => {
292
289
  width: width * spaceRatio,
293
290
  height
294
291
  });
295
- trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;
292
+ trendFontSize = Number.parseInt(trendFontSize, 10) * spaceRatio;
296
293
  }
297
294
  return trendFontSize;
298
295
  };
299
- var getUnderLabelHeight = (height) => height > DEFAULT_FONT ? DEFAULT_FONT : height;
296
+ var getUnderLabelHeight = (height) => Math.min(height, DEFAULT_FONT);
300
297
  var getUnderLabel = ({ underLabel, width, height }) => computeFontSize(underLabel, {
301
298
  width,
302
299
  height
@@ -374,7 +371,7 @@ var updateVizInSmallSpace = ({
374
371
  let newTextSize = majorTextFontSize;
375
372
  while (newTextSize < 12 && removeIndex < toRemoveList.length) {
376
373
  const toRemove = toRemoveList[removeIndex];
377
- newProps = __spreadValues(__spreadValues({}, newProps), {
374
+ newProps = __spreadProps(__spreadValues({}, newProps), {
378
375
  [toRemove.key]: toRemove.value
379
376
  });
380
377
  newMajorAndTrend = getMajorAndTrend(__spreadValues({
@@ -597,9 +594,9 @@ var getUnchangedColorDelta = (r, g, b, ratio) => {
597
594
  };
598
595
  var changeColor = (color, ratio) => {
599
596
  const hex = color.replace(/(0x|#)/, "");
600
- const r = parseInt(hex.substr(0, 2), 16);
601
- const g = parseInt(hex.substr(2, 2), 16);
602
- const b = parseInt(hex.substr(4, 2), 16);
597
+ const r = Number.parseInt(hex.substr(0, 2), 16);
598
+ const g = Number.parseInt(hex.substr(2, 2), 16);
599
+ const b = Number.parseInt(hex.substr(4, 2), 16);
603
600
  let newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);
604
601
  let newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);
605
602
  let newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);
@@ -609,7 +606,7 @@ var changeColor = (color, ratio) => {
609
606
  newG = adjustRGB(newG, delta);
610
607
  newB = adjustRGB(newB, delta);
611
608
  }
612
- return `#${newR.toString(16).padStart(2, 0)}${newG.toString(16).padStart(2, 0)}${newB.toString(16).padStart(2, 0)}`;
609
+ return `#${newR.toString(16).padStart(2, "0")}${newG.toString(16).padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`;
613
610
  };
614
611
  var lighten = (color) => changeColor(color, 1.3);
615
612
  var darken = (color) => changeColor(color, 0.5);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/common/utils/singleValueUtils.js", "esm-externals:lodash", "esm-externals:@splunk/visualizations-shared/numberUtils", "esm-externals:@splunk/visualizations-shared/domUtils", "esm-externals:@splunk/visualizations-shared/propUtils", "esm-externals:@splunk/visualizations-shared/colorConstants"],
4
- "sourcesContent": ["import { get } from 'lodash';\nimport { isNumerial, formatNumber } from '@splunk/visualizations-shared/numberUtils';\nimport { computeTextSize } from '@splunk/visualizations-shared/domUtils';\nimport { formatColor } from '@splunk/visualizations-shared/propUtils';\nimport { DELTA_GREEN, DELTA_RED } from '@splunk/visualizations-shared/colorConstants';\n\nexport const DEFAULT_FONT = 12;\nexport const DEFAULT_FONT_FAMILY =\n '\"Splunk Platform Sans\", \"Proxima Nova\", \"Helvetica Neue\", Helvetica, Arial, sans-serif';\n\nexport const SVR_PADDING = { top: 12, bottom: 12, left: 16, right: 16 };\n\nexport const getAligment = align => {\n const alignMap = {\n left: 'start',\n center: 'center',\n right: 'end',\n };\n return alignMap[align] || 'center';\n};\n\n/**\n * @method shouldShowTrend\n * @param {String} trendDisplay\n * @returns {Bool}\n */\nexport const shouldShowTrend = trendDisplay => trendDisplay === 'absolute' || trendDisplay === 'percent';\n\n/**\n * @method isLoadingOrNoColumns\n * @param {Object} dataSources\n * @param {Boolean} loading\n * @returns {Boolean} return true if loading or without columns in dataSources\n */\nexport const isLoadingOrNoColumns = (dataSources, loading) => {\n const data = get(dataSources, 'primary.data.columns[0]', undefined);\n const noColumns = data === undefined;\n return loading || noColumns;\n};\n\n/**\n * Retrieve the valid formatted color\n * @method getFormattedColor\n * @param {String} color\n * @param {String} defaultColor\n * @returns {String} the formatted color\n */\nexport const getFormattedColor = (color, defaultColor) => formatColor(color) || formatColor(defaultColor);\n\n/**\n * Determines if there is a background color\n * @method hasBackground\n * @param {String} backgroundColor\n * @returns true for non-transparent background color\n */\nexport const hasBackground = backgroundColor => !!backgroundColor && backgroundColor !== 'transparent';\n\n/**\n * @method isIdenticalColor\n * @param {String} colorA\n * @param {String} colorB\n * @returns {Boolean}\n */\nexport const isIdenticalColor = (colorA, colorB) =>\n !!colorA && !!colorB && formatColor(colorA.toLowerCase()) === formatColor(colorB.toLowerCase());\n\n/*\n * @method getDefaultColorWithBg\n * @param {Object} props\n * @param {String} props.backgroundColor\n * @param {String} props.defaultFontColor\n * @param {String} props.defaultBlockFontColor\n * @returns {String} defaultColor\n */\nexport const getDefaultColorWithBg = ({ backgroundColor, defaultFontColor, defaultBlockFontColor }) =>\n isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;\n\n/*\n * @method getMajorColor\n * return formatted majorColor.\n * @param {Object} props\n * @param {String} props.majorColor\n * @param {String} props.backgroundColor\n * @param {String} props.defaultFontColor\n * @param {String} props.defaultBlockFontColor\n * @returns {String} majorColor\n */\nexport const getMajorColor = ({ majorColor, backgroundColor, defaultFontColor, defaultBlockFontColor }) => {\n // If backgroundColor is set, but no majorColor,\n // the default majorColor will turn to be defaultBlockFontColor.\n // eg: major color will turn to be white in enterprise mode.\n // however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.\n if (hasBackground(backgroundColor) && !majorColor) {\n return getDefaultColorWithBg({\n backgroundColor,\n defaultFontColor,\n defaultBlockFontColor,\n });\n }\n\n return getFormattedColor(majorColor, defaultFontColor);\n};\n\n/**\n * Get the color for the trend components\n * @method getTrendColor\n * @param {Object} props\n * @param {String} props.trendColor The trendColor value determined from encoding\n * @param {Number} props.trendValue\n * @param {Number} props.majorValue\n * @param {String} props.customizedBgColor\n * @param {String} props.trendDisplay absolute || percent || off\n * @param {Object} defaultColors\n * @returns {String} trendColor\n */\nexport const getTrendColor = ({\n trendColor,\n trendValue,\n majorValue,\n customizedBgColor,\n trendDisplay,\n defaultColors,\n}) => {\n if (trendColor) {\n return trendColor;\n }\n\n if (Number.isNaN(Number(trendValue))) {\n return undefined;\n }\n\n const { defaultFontColor, defaultBlockFontColor, defaultBackgroundColor } = defaultColors;\n\n // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor\n if (\n hasBackground(customizedBgColor) &&\n !isIdenticalColor(customizedBgColor, defaultBackgroundColor) &&\n !isIdenticalColor(customizedBgColor, defaultBlockFontColor)\n ) {\n return defaultBlockFontColor;\n }\n\n // if trendDisplay is percent, and trendValue === value\n // the trend percent = trendValue / (value - trendValue) will return Infinity\n const isInvalidTrend = trendDisplay === 'percent' && trendValue === parseFloat(majorValue);\n\n if (trendValue === 0 || isInvalidTrend) {\n return defaultFontColor;\n }\n\n return trendValue > 0 ? DELTA_GREEN : DELTA_RED;\n};\n\n/**\n * Computes visualization properties for display component\n * @method computeColors\n * @param {Object} props all viz props\n * @param {Object} defaultColors defaultColors from theme\n * @returns {Object} result\n * @returns {Boolean} backgroundEnabled\n * @returns {String} backgroundColor\n * @returns {String} majorColor\n * @returns {String} trendColor\n * @returns {String} underLabelColor\n */\nexport const computeColors = (props, defaultColors) => {\n const backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);\n const backgroundEnabled = hasBackground(backgroundColor);\n const majorColor = getMajorColor({\n majorColor: props.majorColor,\n backgroundColor,\n defaultFontColor: defaultColors.defaultFontColor,\n defaultBlockFontColor: defaultColors.defaultBlockFontColor,\n });\n const trendColor = getTrendColor({\n trendColor: props.trendColor,\n trendValue: props.trendValue,\n majorValue: props.majorValue,\n customizedBgColor: props.backgroundColor,\n trendDisplay: props.trendDisplay,\n defaultColors,\n });\n const underLabelColor = getFormattedColor(props.underLabelColor, majorColor);\n\n return {\n backgroundColor,\n backgroundEnabled,\n majorColor,\n trendColor,\n underLabelColor,\n };\n};\n\n/**\n * Format and return the value (major/trend)\n * @method computeText\n * @param {Object} props\n * @param {Number} props.value // The major/trend value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateValue\n * @returns {Number} major or trend text\n */\nexport const computeText = ({\n value,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateValue,\n}) => {\n let text = isNumerial(value)\n ? formatNumber(value, numberPrecision, {\n useThousandSeparators: shouldUseThousandSeparators,\n useTrendUnits: shouldAbbreviateValue,\n })\n : value;\n // When text is undefined, return empty string\n text = text || '';\n return text;\n};\n\n/*\n * @method getMajorText\n * @param {Object} props\n * @param {Number} props.majorValue\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateMajorValue\n * @returns {String} majorText\n */\nexport const getMajorText = ({\n majorValueDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateMajorValue,\n}) =>\n computeText({\n value: majorValueDisplay === null ? 'N/A' : majorValueDisplay, // if majorValueDisplay is null, use `N/A`.\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateValue: shouldAbbreviateMajorValue,\n });\n\n/*\n * @method getTrendText\n * @param {Object} props\n * @param {Number} props.majorValue\n * @param {Number} props.trendValue\n * @param {String} props.trendDisplay\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @returns {String} trendText\n */\nexport const getTrendText = ({\n majorValue,\n trendValue,\n trendDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n}) => {\n const compute = value =>\n computeText({\n value,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateValue: shouldAbbreviateTrendValue,\n });\n\n if (trendValue === '' || !isNumerial(trendValue)) {\n return '';\n }\n const showPercent = trendDisplay === 'percent';\n if (!showPercent) {\n return compute(trendValue);\n }\n\n const diff = Math.abs(trendValue - majorValue);\n let val = (trendValue / diff) * 100;\n if (trendValue === 0 && diff === 0) {\n val = 0;\n }\n\n if (!Number.isFinite(val)) {\n return 'N/A';\n }\n const text = compute(val);\n\n return `${text}%`;\n};\n\n/**\n * Helper to determine the font size for an element\n * @method computeFontSize\n * @param {String} text The string to find a size for\n * @param {Object} dimensions\n * @param {Number} dimensions.width The width of the container\n * @param {Number} dimensions.height The height of the container\n * @param {String} [fontFamily='\"Splunk Platform Sans\" ...'] The font being used\n * @param {String} [fontWeight='normal'] Boldness of font\n * @returns {Number} The size to use for fontSize styles\n */\nexport const computeFontSize = (\n text,\n { width, height },\n fontFamily = DEFAULT_FONT_FAMILY,\n fontWeight = 'normal'\n) => {\n const widthInDefaultFont = computeTextSize(text, `${fontWeight} ${DEFAULT_FONT}px ${fontFamily}`);\n const fontSize = Math.min(\n (width / widthInDefaultFont) * DEFAULT_FONT,\n (height / DEFAULT_FONT) * DEFAULT_FONT\n );\n return parseInt(fontSize, 10);\n};\n\n/*\n * @method getMajorFontSize\n * @param {Object} props\n * @param {Number} props.width\n * @param {Number} props.height\n * @param {String} props.unit\n * @param {String} props.majorText\n * @param {Number} props.spaceRatio\n * @returns {Number} majorFontSize\n */\nexport const getMajorFontSize = ({ width, height, unit, majorText, spaceRatio = 1 }) => {\n const majorTextCalc = unit ? `${unit}${majorText}` : majorText;\n return computeFontSize(majorTextCalc, {\n width: width * spaceRatio,\n height,\n });\n};\n\n/*\n * @method getTrendFontSize\n * @param {Object} props\n * @param {Number} props.width\n * @param {Number} props.height\n * @param {String} props.trendText\n * @param {Number} props.spaceRatio\n * @returns {Number} trendFontSize\n */\nexport const getTrendFontSize = ({ width, height, trendText, spaceRatio = 1 }) => {\n let trendFontSize = 12;\n if (spaceRatio > 0) {\n trendFontSize = computeFontSize(trendText, {\n width: width * spaceRatio,\n height,\n });\n trendFontSize = parseInt(trendFontSize, 10) * spaceRatio;\n }\n return trendFontSize;\n};\n\n/*\n * The height of underLabel should no more than 12px\n * @param {Number} height\n * @return {Number} height || DEFAULT_FONT\n */\nexport const getUnderLabelHeight = height => (height > DEFAULT_FONT ? DEFAULT_FONT : height);\n\n/*\n * @param {Object} config\n * @param {String} underLabel\n * @param {Number} width width of underLabel\n * @param {Number} height height of underLabel\n * @param {Number} fond size of underLabel\n */\nexport const getUnderLabel = ({ underLabel, width, height }) =>\n computeFontSize(underLabel, {\n width,\n height,\n });\n\n/**\n * Compute value and font size for major and trend\n * @method getMajorAndTrend\n * @param {Object} props\n * @param {Number} props.width // Width of the text container\n * @param {Number} props.height // Height of the text container\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.majorValueDisplay // Major value display\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {String} props.trendDisplay\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @param {Bool} props.shouldAbbreviateMajorValue\n * @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size\n */\nexport const getMajorAndTrend = ({\n width,\n height,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n}) => {\n const majorTextSpaceRatio = isNumerial(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;\n const textContentWidth = width * 0.9;\n const textContentHeight = height * 0.9;\n\n // use majorValueDisplay here for display only\n const majorText = getMajorText({\n majorValueDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateMajorValue,\n });\n\n const majorTextFontSize =\n majorFontSize ||\n getMajorFontSize({\n width: textContentWidth,\n height: textContentHeight,\n unit,\n majorText,\n spaceRatio: majorTextSpaceRatio,\n });\n\n // use majorValue here for calculations\n const trendText = getTrendText({\n majorValue,\n trendValue,\n trendDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n });\n\n const trendTextFontSize =\n trendFontSize ||\n getTrendFontSize({\n width: textContentWidth,\n height: textContentHeight,\n trendText,\n spaceRatio: 1 - majorTextSpaceRatio,\n });\n\n return {\n majorText,\n majorTextFontSize,\n trendText,\n trendTextFontSize,\n };\n};\n\n/*\n * @method updateVizInSmallSpace\n * @param {Object} props\n * @param {Number} props.width // Width of the text container\n * @param {Number} props.height // Height of the text container\n * @param {Object} props.toRemoveList\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {Number} props.majorTextFontSize\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @returns {Object} results\n * @returns {Object} results.newMajorAndTrend\n * @returns {Object} results.updatedProps\n */\nexport const updateVizInSmallSpace = ({\n width,\n height,\n toRemoveList,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n majorTextFontSize,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n}) => {\n let removeIndex = 0;\n let newProps = {}; // options need to be updated\n let newMajorAndTrend = {};\n let newTextSize = majorTextFontSize;\n\n // remove info on viz to make textFontSize >= 12px;\n while (newTextSize < 12 && removeIndex < toRemoveList.length) {\n const toRemove = toRemoveList[removeIndex];\n newProps = {\n ...newProps,\n ...{\n [toRemove.key]: toRemove.value,\n },\n };\n\n newMajorAndTrend = getMajorAndTrend({\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n width,\n height,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n ...newProps,\n });\n\n newTextSize = newMajorAndTrend.majorTextFontSize;\n removeIndex += 1;\n }\n\n // truncate text if textFontSize is still less than 12\n if (newTextSize < 12) {\n const truncateValue = `${(majorValueDisplay || majorValue).toString().slice(0, 3)}...`;\n newMajorAndTrend = getMajorAndTrend({\n majorValue,\n majorValueDisplay: truncateValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n width,\n height,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n ...newProps,\n });\n }\n\n return { newMajorAndTrend, updatedProps: newProps };\n};\n\n/*\n * @method computeSingleValueContent\n * @param {Object} props\n * @param {Number} props.contentWidth\n * @param {Number} props.contentHeight\n * @param {Number} props.containerWidth\n * @param {Number} props.containerHeight\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.majorValueDisplay // Major value display\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {String} props.trendDisplay\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @param {Bool} props.shouldAbbreviateMajorValue\n * @param {Object} props.toRemoveList\n * @returns {Object} results\n * @returns {String} results.majorText\n * @returns {String} results.trendText\n * @returns {Number} results.majorTextFontSize\n * @returns {Number} results.trendTextFontSize\n * @returns {String} results.majorValueTitle\n * @returns {Object} results.smallVizProps\n */\nexport const computeSingleValueContent = ({\n contentWidth,\n contentHeight,\n containerWidth,\n containerHeight,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n toRemoveList,\n}) => {\n let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({\n majorValue,\n majorValueDisplay: majorValueDisplay || majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n width: contentWidth,\n height: contentHeight,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n });\n const majorValueTitle = majorText;\n let smallVizProps = {};\n\n // update viz in small space\n // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit\n // or truncate major value to make the major font size >= 12\n if (majorTextFontSize < 12) {\n const { newMajorAndTrend, updatedProps } = updateVizInSmallSpace({\n width: containerWidth,\n height: containerHeight,\n toRemoveList,\n majorValue,\n majorValueDisplay: majorValueDisplay || majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n majorTextFontSize,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n });\n\n ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = newMajorAndTrend);\n smallVizProps = updatedProps;\n }\n return {\n majorText,\n trendText,\n majorTextFontSize,\n trendTextFontSize,\n majorValueTitle,\n smallVizProps,\n };\n};\n\nexport const minimallyTruncateStringToWidth = ({\n text,\n fontSize = DEFAULT_FONT,\n fontFamily = DEFAULT_FONT_FAMILY,\n fontWeight = 'normal',\n containerWidth,\n}) => {\n let textWidth = computeTextSize(text, `${fontWeight} ${fontSize}px ${fontFamily}`);\n let modifiedText = text;\n\n const ellipsesLength = computeTextSize('...', `${fontWeight} ${fontSize}px ${fontFamily}`);\n // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.\n if (containerWidth - ellipsesLength > 0 && textWidth > containerWidth) {\n // Truncates the content such that the truncated value + ellipses fit within the allocated space for the ellipses.\n // `textWidth > containerWidth - ellipsesLength` condition checks if text + ellipses exceeds container width.\n // `text.length > 1` condition included to keep at least the first number.\n while (textWidth + ellipsesLength > containerWidth && modifiedText.length > 1) {\n modifiedText = modifiedText.substring(0, modifiedText.length - 1);\n textWidth = computeTextSize(modifiedText, `normal ${fontSize}px ${fontFamily}`);\n }\n\n modifiedText = `${modifiedText}...`;\n }\n\n return modifiedText;\n};\n\n/*\n * @method computeSingleValueRadialContent\n * @param {Object} props\n * @param {Number} props.contentWidth\n * @param {Number} props.contentHeight\n * @param {Number} props.containerWidth\n * @param {Number} props.containerHeight\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {String} props.trendDisplay\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @param {Bool} props.shouldAbbreviateMajorValue,\n * @param {Object} props.toRemoveList\n * @param {Bool} props.smallViz\n * @returns {Object} results\n * @returns {String} results.majorText\n * @returns {String} results.trendText\n * @returns {Number} results.majorTextFontSize\n * @returns {Number} results.trendTextFontSize\n * @returns {String} results.majorValueTitle\n * @returns {Object} results.smallVizProps\n */\nexport const computeSingleValueRadialContent = ({\n contentWidth,\n contentHeight,\n containerWidth,\n containerHeight,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n smallViz,\n}) => {\n let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({\n majorValue,\n majorValueDisplay: majorValueDisplay || majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n width: contentWidth,\n height: contentHeight,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n });\n\n const majorValueTitle = majorText;\n let smallVizProps = {};\n\n // custom logic for viz in small space\n // if not showing the radial graph (if `smallViz` is true), then compute truncated major value\n // and font sizes\n if (smallViz) {\n const truncateValue = minimallyTruncateStringToWidth({\n text: majorValueDisplay || majorValue,\n fontWeight: 'bold',\n fontSize: 12,\n containerWidth,\n });\n\n ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({\n majorValueDisplay: truncateValue,\n majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n width: containerWidth,\n height: containerHeight,\n unit,\n trendDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n }));\n\n smallVizProps = {\n trendDisplay,\n unit,\n };\n }\n\n return {\n majorText,\n trendText,\n majorTextFontSize,\n trendTextFontSize,\n majorValueTitle,\n smallVizProps,\n };\n};\n\n/**\n * Get the colors for a graph\n *\n * @method getGraphColors\n * @param {Object} options\n * @param {Bool} options.backgroundEnabled // Flag to turn on color mode\n * @param {String} options.backgroundColor // The current background color, overrides trend background color\n * @param {Object} options.defaultColors // Default colors by severity\n * @param {Function} options.customColorFormatter // must return { background, stroke } given a color\n * @returns {Object} { background, stroke } colors\n * @private\n */\nexport const getGraphColors = ({\n backgroundEnabled,\n backgroundColor,\n defaultColors,\n customColorFormatter,\n}) => {\n // Only do custom colors in block mode\n if (backgroundEnabled) {\n // Check if the user defined colors to use\n if (backgroundColor && typeof customColorFormatter === 'function') {\n return customColorFormatter(backgroundColor);\n }\n }\n\n return defaultColors.none;\n};\n\n/**\n * Adjust rgb value if it equals to 0 or 255\n * @method adjustRGB\n * @param {Number} rgb [0 - 255]\n * @param {Number} delta\n * @returns {Number} adjusted rgb\n * @private\n */\nexport const adjustRGB = (rgb, delta) => {\n if (rgb === 255) {\n return rgb - delta;\n }\n\n if (rgb === 0) {\n return rgb + delta;\n }\n\n return rgb;\n};\n\nconst getUnchangedColorDelta = (r, g, b, ratio) => {\n if (r === 0 && g === 0 && b === 0) {\n return ratio > 1 ? 80 : 40;\n }\n if (r === 255 && g === 255 && b === 255) {\n return ratio > 1 ? 20 : 80;\n }\n return 20;\n};\n\n/**\n * Modifies colors by multiplying by a given ratio\n * @method changeColor\n * @param {String} color // Color to modify\n * @param {Number} ratio // Float to modify color\n * @returns {String} new color\n * @private\n */\nconst changeColor = (color, ratio) => {\n const hex = color.replace(/(0x|#)/, '');\n const r = parseInt(hex.substr(0, 2), 16);\n const g = parseInt(hex.substr(2, 2), 16);\n const b = parseInt(hex.substr(4, 2), 16);\n\n // Multiply by given ratio, make sure is between 0 and 255;\n let newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);\n let newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);\n let newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);\n\n // If the color is not changed, apply a fixed adjustment\n if (newR === r && newG === g && newB === b) {\n const delta = getUnchangedColorDelta(newR, newG, newB, ratio);\n newR = adjustRGB(newR, delta);\n newG = adjustRGB(newG, delta);\n newB = adjustRGB(newB, delta);\n }\n\n return (\n `#${newR.toString(16).padStart(2, 0)}` +\n `${newG.toString(16).padStart(2, 0)}` +\n `${newB.toString(16).padStart(2, 0)}`\n );\n};\n\n/**\n * Lighten a given color\n * @method lighten\n * @param {String} color\n * @returns {String}\n * @private\n */\nexport const lighten = color => changeColor(color, 1.3);\n\n/**\n * Darkens a given color\n * @method darken\n * @param {String} color\n * @returns {String}\n * @private\n */\nexport const darken = color => changeColor(color, 0.5);\n\n/** consistent token structure: handle callback to add value and name in event payload\n * @method handleValueClickCallback\n * @param {Object} ev\n * @param {String | Number} majorValue\n * @param {String} majorValueField\n * @param {Number} trendValue\n * @param {Function} onValueClick\n * @param {Object} trellisContext\n * @param {Boolean} trellisContext.trellisEnabled\n * @param {String} trellisContext.trellisSplitBy\n * @param {String} trellisContext.trellisKey\n */\nexport const handleValueClickCallback = (\n ev,\n majorValue,\n majorValueField,\n trendValue,\n onValueClick,\n trellisContext = {}\n) => {\n const { trellisEnabled = false, trellisSplitBy = '', trellisKey = '' } = trellisContext;\n\n return onValueClick({\n ...ev,\n payload: {\n trendValue,\n value: majorValue,\n name: majorValueField,\n ...(trellisEnabled && {\n 'trellis.name': trellisSplitBy,\n 'trellis.value': trellisKey,\n }),\n },\n });\n};\n\n/** handle trend color when trend display is percent\n * @method getTrendColorWithPercent\n * @param {Object} options\n * @returns {Object}\n */\nexport const getTrendColorWithPercent = options => {\n const shouldUsePercentTrendColor =\n options.trendColor === '> trendValue | rangeValue(trendColorEditorConfig)' &&\n options.trendDisplay === 'percent';\n\n return shouldUsePercentTrendColor\n ? {\n trendColor: '> trendValuePercent | rangeValue(trendColorEditorConfig)',\n }\n : {};\n};\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/numberUtils\";\nexport * from \"@splunk/visualizations-shared/numberUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/domUtils\";\nexport * from \"@splunk/visualizations-shared/domUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/propUtils\";\nexport * from \"@splunk/visualizations-shared/propUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/colorConstants\";\nexport * from \"@splunk/visualizations-shared/colorConstants\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,2BAAc;AACd,IAAO,iBAAS,aAAa,gBAA8B,wBAAU;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAA,iBAA+B;AAC/B,gCAAc;AACd,IAAO,sBAAS,aAAaA,iBAA8B,yBAAUA;;;ACHrE;AAAA;AAAA;AAAA;AACA,IAAAC,iBAA+B;AAC/B,6B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,IAAI,KAAK,GAAG,GAAG,GAAG,CAAC;AAG3D,MAAI,SAAS,KAAK,SAAS,KAAK,SAAS,GAAG;AACxC,UAAM,QAAQ,uBAAuB,MAAM,MAAM,MAAM,KAAK;AAC5D,WAAO,UAAU,MAAM,KAAK;AAC5B,WAAO,UAAU,MAAM,KAAK;AAC5B,WAAO,UAAU,MAAM,KAAK;AAAA,EAChC;AAEA,SACI,IAAI,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,CAAC,CAAC,GACjC,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,CAAC,CAAC,GAChC,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,CAAC,CAAC;AAE3C;AASO,IAAM,UAAU,WAAS,YAAY,OAAO,GAAG;AAS/C,IAAM,SAAS,WAAS,YAAY,OAAO,GAAG;AAc9C,IAAM,2BAA2B,CACpC,IACA,YACA,iBACA,YACA,cACA,iBAAiB,CAAC,MACjB;AACD,QAAM,EAAE,iBAAiB,OAAO,iBAAiB,IAAI,aAAa,GAAG,IAAI;AAEzE,SAAO,aAAa,iCACb,KADa;AAAA,IAEhB,SAAS;AAAA,MACL;AAAA,MACA,OAAO;AAAA,MACP,MAAM;AAAA,OACF,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACrB;AAAA,EAER,EAAC;AACL;AAOO,IAAM,2BAA2B,aAAW;AAC/C,QAAM,6BACF,QAAQ,eAAe,uDACvB,QAAQ,iBAAiB;AAE7B,SAAO,6BACD;AAAA,IACI,YAAY;AAAA,EAChB,IACA,CAAC;AACX;",
4
+ "sourcesContent": ["import { get } from 'lodash';\nimport { isNumerial, formatNumber } from '@splunk/visualizations-shared/numberUtils';\nimport { computeTextSize } from '@splunk/visualizations-shared/domUtils';\nimport { formatColor } from '@splunk/visualizations-shared/propUtils';\nimport { DELTA_GREEN, DELTA_RED } from '@splunk/visualizations-shared/colorConstants';\n\nexport const DEFAULT_FONT = 12;\nexport const DEFAULT_FONT_FAMILY =\n '\"Splunk Platform Sans\", \"Proxima Nova\", \"Helvetica Neue\", Helvetica, Arial, sans-serif';\n\nexport const SVR_PADDING = { top: 12, bottom: 12, left: 16, right: 16 };\n\nexport const getAligment = align => {\n const alignMap = {\n left: 'start',\n center: 'center',\n right: 'end',\n };\n return alignMap[align] || 'center';\n};\n\n/**\n * @method shouldShowTrend\n * @param {String} trendDisplay\n * @returns {Bool}\n */\nexport const shouldShowTrend = trendDisplay => trendDisplay === 'absolute' || trendDisplay === 'percent';\n\n/**\n * @method isLoadingOrNoColumns\n * @param {Object} dataSources\n * @param {Boolean} loading\n * @returns {Boolean} return true if loading or without columns in dataSources\n */\nexport const isLoadingOrNoColumns = (dataSources, loading) => {\n const data = get(dataSources, 'primary.data.columns[0]', undefined);\n const noColumns = data === undefined;\n return loading || noColumns;\n};\n\n/**\n * Retrieve the valid formatted color\n * @method getFormattedColor\n * @param {String} color\n * @param {String} defaultColor\n * @returns {String} the formatted color\n */\nexport const getFormattedColor = (color, defaultColor) => formatColor(color) || formatColor(defaultColor);\n\n/**\n * Determines if there is a background color\n * @method hasBackground\n * @param {String} backgroundColor\n * @returns true for non-transparent background color\n */\nexport const hasBackground = backgroundColor => !!backgroundColor && backgroundColor !== 'transparent';\n\n/**\n * @method isIdenticalColor\n * @param {String} colorA\n * @param {String} colorB\n * @returns {Boolean}\n */\nexport const isIdenticalColor = (colorA, colorB) =>\n !!colorA && !!colorB && formatColor(colorA.toLowerCase()) === formatColor(colorB.toLowerCase());\n\n/*\n * @method getDefaultColorWithBg\n * @param {Object} props\n * @param {String} props.backgroundColor\n * @param {String} props.defaultFontColor\n * @param {String} props.defaultBlockFontColor\n * @returns {String} defaultColor\n */\nexport const getDefaultColorWithBg = ({ backgroundColor, defaultFontColor, defaultBlockFontColor }) =>\n isIdenticalColor(backgroundColor, defaultBlockFontColor) ? defaultFontColor : defaultBlockFontColor;\n\n/*\n * @method getMajorColor\n * return formatted majorColor.\n * @param {Object} props\n * @param {String} props.majorColor\n * @param {String} props.backgroundColor\n * @param {String} props.defaultFontColor\n * @param {String} props.defaultBlockFontColor\n * @returns {String} majorColor\n */\nexport const getMajorColor = ({ majorColor, backgroundColor, defaultFontColor, defaultBlockFontColor }) => {\n // If backgroundColor is set, but no majorColor,\n // the default majorColor will turn to be defaultBlockFontColor.\n // eg: major color will turn to be white in enterprise mode.\n // however, if the bgColor is the same as defaultBlockFontColor, use defaultFontColor.\n if (hasBackground(backgroundColor) && !majorColor) {\n return getDefaultColorWithBg({\n backgroundColor,\n defaultFontColor,\n defaultBlockFontColor,\n });\n }\n\n return getFormattedColor(majorColor, defaultFontColor);\n};\n\n/**\n * Get the color for the trend components\n * @method getTrendColor\n * @param {Object} props\n * @param {String} props.trendColor The trendColor value determined from encoding\n * @param {Number} props.trendValue\n * @param {Number} props.majorValue\n * @param {String} props.customizedBgColor\n * @param {String} props.trendDisplay absolute || percent || off\n * @param {Object} defaultColors\n * @returns {String} trendColor\n */\nexport const getTrendColor = ({\n trendColor,\n trendValue,\n majorValue,\n customizedBgColor,\n trendDisplay,\n defaultColors,\n}) => {\n if (trendColor) {\n return trendColor;\n }\n\n if (Number.isNaN(Number(trendValue))) {\n return undefined;\n }\n\n const { defaultFontColor, defaultBlockFontColor, defaultBackgroundColor } = defaultColors;\n\n // if user defined a backgroundColor, the default trend color will be defaultBlockFontColor\n if (\n hasBackground(customizedBgColor) &&\n !isIdenticalColor(customizedBgColor, defaultBackgroundColor) &&\n !isIdenticalColor(customizedBgColor, defaultBlockFontColor)\n ) {\n return defaultBlockFontColor;\n }\n\n // if trendDisplay is percent, and trendValue === value\n // the trend percent = trendValue / (value - trendValue) will return Infinity\n const isInvalidTrend = trendDisplay === 'percent' && trendValue === Number.parseFloat(majorValue);\n\n if (trendValue === 0 || isInvalidTrend) {\n return defaultFontColor;\n }\n\n return trendValue > 0 ? DELTA_GREEN : DELTA_RED;\n};\n\n/**\n * Computes visualization properties for display component\n * @method computeColors\n * @param {Object} props all viz props\n * @param {Object} defaultColors defaultColors from theme\n * @returns {Object} result\n * @returns {Boolean} backgroundEnabled\n * @returns {String} backgroundColor\n * @returns {String} majorColor\n * @returns {String} trendColor\n * @returns {String} underLabelColor\n */\nexport const computeColors = (props, defaultColors) => {\n const backgroundColor = getFormattedColor(props.backgroundColor, defaultColors.defaultBackgroundColor);\n const backgroundEnabled = hasBackground(backgroundColor);\n const majorColor = getMajorColor({\n majorColor: props.majorColor,\n backgroundColor,\n defaultFontColor: defaultColors.defaultFontColor,\n defaultBlockFontColor: defaultColors.defaultBlockFontColor,\n });\n const trendColor = getTrendColor({\n trendColor: props.trendColor,\n trendValue: props.trendValue,\n majorValue: props.majorValue,\n customizedBgColor: props.backgroundColor,\n trendDisplay: props.trendDisplay,\n defaultColors,\n });\n const underLabelColor = getFormattedColor(props.underLabelColor, majorColor);\n\n return {\n backgroundColor,\n backgroundEnabled,\n majorColor,\n trendColor,\n underLabelColor,\n };\n};\n\n/**\n * Format and return the value (major/trend)\n * @method computeText\n * @param {Object} props\n * @param {Number} props.value // The major/trend value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateValue\n * @returns {Number} major or trend text\n */\nexport const computeText = ({\n value,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateValue,\n}) => {\n let text = isNumerial(value)\n ? formatNumber(value, numberPrecision, {\n useThousandSeparators: shouldUseThousandSeparators,\n useTrendUnits: shouldAbbreviateValue,\n })\n : String(value ?? '');\n // When text is undefined, return empty string\n text = text || '';\n return text;\n};\n\n/*\n * @method getMajorText\n * @param {Object} props\n * @param {Number} props.majorValue\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateMajorValue\n * @returns {String} majorText\n */\nexport const getMajorText = ({\n majorValueDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateMajorValue,\n}) =>\n computeText({\n value: majorValueDisplay === null ? 'N/A' : majorValueDisplay, // if majorValueDisplay is null, use `N/A`.\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateValue: shouldAbbreviateMajorValue,\n });\n\n/*\n * @method getTrendText\n * @param {Object} props\n * @param {Number} props.majorValue\n * @param {Number} props.trendValue\n * @param {String} props.trendDisplay\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @returns {String} trendText\n */\nexport const getTrendText = ({\n majorValue,\n trendValue,\n trendDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n}) => {\n const compute = value =>\n computeText({\n value,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateValue: shouldAbbreviateTrendValue,\n });\n\n let trendText = '';\n const showPercent = trendDisplay === 'percent';\n const isValidTrend = trendValue !== '' && isNumerial(trendValue);\n\n if (isValidTrend && !showPercent) {\n trendText = compute(trendValue);\n } else if (isValidTrend && showPercent) {\n const diff = Math.abs(trendValue - majorValue);\n let val = (trendValue / diff) * 100;\n if (trendValue === 0 && diff === 0) {\n val = 0;\n }\n\n trendText = Number.isFinite(val) ? `${compute(val)}%` : 'N/A';\n }\n\n return trendText;\n};\n\n/**\n * Helper to determine the font size for an element\n * @method computeFontSize\n * @param {String} text The string to find a size for\n * @param {Object} dimensions\n * @param {Number} dimensions.width The width of the container\n * @param {Number} dimensions.height The height of the container\n * @param {String} [fontFamily='\"Splunk Platform Sans\" ...'] The font being used\n * @param {String} [fontWeight='normal'] Boldness of font\n * @returns {Number} The size to use for fontSize styles\n */\nexport const computeFontSize = (\n text,\n { width, height },\n fontFamily = DEFAULT_FONT_FAMILY,\n fontWeight = 'normal'\n) => {\n const widthInDefaultFont = computeTextSize(text, `${fontWeight} ${DEFAULT_FONT}px ${fontFamily}`);\n const fontSize = Math.min(\n (width / widthInDefaultFont) * DEFAULT_FONT,\n (height / DEFAULT_FONT) * DEFAULT_FONT\n );\n return Number.parseInt(fontSize, 10);\n};\n\n/*\n * @method getMajorFontSize\n * @param {Object} props\n * @param {Number} props.width\n * @param {Number} props.height\n * @param {String} props.unit\n * @param {String} props.majorText\n * @param {Number} props.spaceRatio\n * @returns {Number} majorFontSize\n */\nexport const getMajorFontSize = ({ width, height, unit, majorText, spaceRatio = 1 }) => {\n const majorTextCalc = unit ? `${unit}${majorText}` : majorText;\n return computeFontSize(majorTextCalc, {\n width: width * spaceRatio,\n height,\n });\n};\n\n/*\n * @method getTrendFontSize\n * @param {Object} props\n * @param {Number} props.width\n * @param {Number} props.height\n * @param {String} props.trendText\n * @param {Number} props.spaceRatio\n * @returns {Number} trendFontSize\n */\nexport const getTrendFontSize = ({ width, height, trendText, spaceRatio = 1 }) => {\n let trendFontSize = 12;\n if (spaceRatio > 0) {\n trendFontSize = computeFontSize(trendText, {\n width: width * spaceRatio,\n height,\n });\n trendFontSize = Number.parseInt(trendFontSize, 10) * spaceRatio;\n }\n return trendFontSize;\n};\n\n/*\n * The height of underLabel should no more than 12px\n * @param {Number} height\n * @return {Number} height || DEFAULT_FONT\n */\nexport const getUnderLabelHeight = height => Math.min(height, DEFAULT_FONT);\n\n/*\n * @param {Object} config\n * @param {String} underLabel\n * @param {Number} width width of underLabel\n * @param {Number} height height of underLabel\n * @param {Number} fond size of underLabel\n */\nexport const getUnderLabel = ({ underLabel, width, height }) =>\n computeFontSize(underLabel, {\n width,\n height,\n });\n\n/**\n * Compute value and font size for major and trend\n * @method getMajorAndTrend\n * @param {Object} props\n * @param {Number} props.width // Width of the text container\n * @param {Number} props.height // Height of the text container\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.majorValueDisplay // Major value display\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {String} props.trendDisplay\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @param {Bool} props.shouldAbbreviateMajorValue\n * @returns {Number, Number, Number, Number} Major text, trend text, major text size, trend text size\n */\nexport const getMajorAndTrend = ({\n width,\n height,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n}) => {\n const majorTextSpaceRatio = isNumerial(trendValue) && shouldShowTrend(trendDisplay) ? 0.6 : 1;\n const textContentWidth = width * 0.9;\n const textContentHeight = height * 0.9;\n\n // use majorValueDisplay here for display only\n const majorText = getMajorText({\n majorValueDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateMajorValue,\n });\n\n const majorTextFontSize =\n majorFontSize ||\n getMajorFontSize({\n width: textContentWidth,\n height: textContentHeight,\n unit,\n majorText,\n spaceRatio: majorTextSpaceRatio,\n });\n\n // use majorValue here for calculations\n const trendText = getTrendText({\n majorValue,\n trendValue,\n trendDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n });\n\n const trendTextFontSize =\n trendFontSize ||\n getTrendFontSize({\n width: textContentWidth,\n height: textContentHeight,\n trendText,\n spaceRatio: 1 - majorTextSpaceRatio,\n });\n\n return {\n majorText,\n majorTextFontSize,\n trendText,\n trendTextFontSize,\n };\n};\n\n/*\n * @method updateVizInSmallSpace\n * @param {Object} props\n * @param {Number} props.width // Width of the text container\n * @param {Number} props.height // Height of the text container\n * @param {Object} props.toRemoveList\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {Number} props.majorTextFontSize\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @returns {Object} results\n * @returns {Object} results.newMajorAndTrend\n * @returns {Object} results.updatedProps\n */\nexport const updateVizInSmallSpace = ({\n width,\n height,\n toRemoveList,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n majorTextFontSize,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n}) => {\n let removeIndex = 0;\n let newProps = {}; // options need to be updated\n let newMajorAndTrend = {};\n let newTextSize = majorTextFontSize;\n\n // remove info on viz to make textFontSize >= 12px;\n while (newTextSize < 12 && removeIndex < toRemoveList.length) {\n const toRemove = toRemoveList[removeIndex];\n newProps = {\n ...newProps,\n [toRemove.key]: toRemove.value,\n };\n\n newMajorAndTrend = getMajorAndTrend({\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n width,\n height,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n ...newProps,\n });\n\n newTextSize = newMajorAndTrend.majorTextFontSize;\n removeIndex += 1;\n }\n\n // truncate text if textFontSize is still less than 12\n if (newTextSize < 12) {\n const truncateValue = `${(majorValueDisplay || majorValue).toString().slice(0, 3)}...`;\n newMajorAndTrend = getMajorAndTrend({\n majorValue,\n majorValueDisplay: truncateValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n width,\n height,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n ...newProps,\n });\n }\n\n return { newMajorAndTrend, updatedProps: newProps };\n};\n\n/*\n * @method computeSingleValueContent\n * @param {Object} props\n * @param {Number} props.contentWidth\n * @param {Number} props.contentHeight\n * @param {Number} props.containerWidth\n * @param {Number} props.containerHeight\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.majorValueDisplay // Major value display\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {String} props.trendDisplay\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @param {Bool} props.shouldAbbreviateMajorValue\n * @param {Object} props.toRemoveList\n * @returns {Object} results\n * @returns {String} results.majorText\n * @returns {String} results.trendText\n * @returns {Number} results.majorTextFontSize\n * @returns {Number} results.trendTextFontSize\n * @returns {String} results.majorValueTitle\n * @returns {Object} results.smallVizProps\n */\nexport const computeSingleValueContent = ({\n contentWidth,\n contentHeight,\n containerWidth,\n containerHeight,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n toRemoveList,\n}) => {\n let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({\n majorValue,\n majorValueDisplay: majorValueDisplay || majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n width: contentWidth,\n height: contentHeight,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n });\n const majorValueTitle = majorText;\n let smallVizProps = {};\n\n // update viz in small space\n // if textFontSize is less than 12, remove extra info like sparkline, trendvalue, unit\n // or truncate major value to make the major font size >= 12\n if (majorTextFontSize < 12) {\n const { newMajorAndTrend, updatedProps } = updateVizInSmallSpace({\n width: containerWidth,\n height: containerHeight,\n toRemoveList,\n majorValue,\n majorValueDisplay: majorValueDisplay || majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n majorTextFontSize,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n });\n\n ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = newMajorAndTrend);\n smallVizProps = updatedProps;\n }\n return {\n majorText,\n trendText,\n majorTextFontSize,\n trendTextFontSize,\n majorValueTitle,\n smallVizProps,\n };\n};\n\nexport const minimallyTruncateStringToWidth = ({\n text,\n fontSize = DEFAULT_FONT,\n fontFamily = DEFAULT_FONT_FAMILY,\n fontWeight = 'normal',\n containerWidth,\n}) => {\n let textWidth = computeTextSize(text, `${fontWeight} ${fontSize}px ${fontFamily}`);\n let modifiedText = text;\n\n const ellipsesLength = computeTextSize('...', `${fontWeight} ${fontSize}px ${fontFamily}`);\n // `containerWidth - ellipsesLength > 0` condition ensures space even exists for text.\n if (containerWidth - ellipsesLength > 0 && textWidth > containerWidth) {\n // Truncates the content such that the truncated value + ellipses fit within the allocated space for the ellipses.\n // `textWidth > containerWidth - ellipsesLength` condition checks if text + ellipses exceeds container width.\n // `text.length > 1` condition included to keep at least the first number.\n while (textWidth + ellipsesLength > containerWidth && modifiedText.length > 1) {\n modifiedText = modifiedText.substring(0, modifiedText.length - 1);\n textWidth = computeTextSize(modifiedText, `normal ${fontSize}px ${fontFamily}`);\n }\n\n modifiedText = `${modifiedText}...`;\n }\n\n return modifiedText;\n};\n\n/*\n * @method computeSingleValueRadialContent\n * @param {Object} props\n * @param {Number} props.contentWidth\n * @param {Number} props.contentHeight\n * @param {Number} props.containerWidth\n * @param {Number} props.containerHeight\n * @param {Number} props.majorValue // Major value\n * @param {Number} props.trendValue // Trend value\n * @param {Number} props.majorFontSize\n * @param {Number} props.trendFontSize\n * @param {String} props.trendDisplay\n * @param {String} props.unit // Unit for the value\n * @param {Number} props.numberPrecision\n * @param {Bool} props.shouldUseThousandSeparators\n * @param {Bool} props.shouldAbbreviateTrendValue\n * @param {Bool} props.shouldAbbreviateMajorValue,\n * @param {Object} props.toRemoveList\n * @param {Bool} props.smallViz\n * @returns {Object} results\n * @returns {String} results.majorText\n * @returns {String} results.trendText\n * @returns {Number} results.majorTextFontSize\n * @returns {Number} results.trendTextFontSize\n * @returns {String} results.majorValueTitle\n * @returns {Object} results.smallVizProps\n */\nexport const computeSingleValueRadialContent = ({\n contentWidth,\n contentHeight,\n containerWidth,\n containerHeight,\n majorValue,\n majorValueDisplay,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n smallViz,\n}) => {\n let { majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({\n majorValue,\n majorValueDisplay: majorValueDisplay || majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n trendDisplay,\n width: contentWidth,\n height: contentHeight,\n unit,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n });\n\n const majorValueTitle = majorText;\n let smallVizProps = {};\n\n // custom logic for viz in small space\n // if not showing the radial graph (if `smallViz` is true), then compute truncated major value\n // and font sizes\n if (smallViz) {\n const truncateValue = minimallyTruncateStringToWidth({\n text: majorValueDisplay || majorValue,\n fontWeight: 'bold',\n fontSize: 12,\n containerWidth,\n });\n\n ({ majorText, trendText, majorTextFontSize, trendTextFontSize } = getMajorAndTrend({\n majorValueDisplay: truncateValue,\n majorValue,\n trendValue,\n majorFontSize,\n trendFontSize,\n width: containerWidth,\n height: containerHeight,\n unit,\n trendDisplay,\n numberPrecision,\n shouldUseThousandSeparators,\n shouldAbbreviateTrendValue,\n shouldAbbreviateMajorValue,\n }));\n\n smallVizProps = {\n trendDisplay,\n unit,\n };\n }\n\n return {\n majorText,\n trendText,\n majorTextFontSize,\n trendTextFontSize,\n majorValueTitle,\n smallVizProps,\n };\n};\n\n/**\n * Get the colors for a graph\n *\n * @method getGraphColors\n * @param {Object} options\n * @param {Bool} options.backgroundEnabled // Flag to turn on color mode\n * @param {String} options.backgroundColor // The current background color, overrides trend background color\n * @param {Object} options.defaultColors // Default colors by severity\n * @param {Function} options.customColorFormatter // must return { background, stroke } given a color\n * @returns {Object} { background, stroke } colors\n * @private\n */\nexport const getGraphColors = ({\n backgroundEnabled,\n backgroundColor,\n defaultColors,\n customColorFormatter,\n}) => {\n // Only do custom colors in block mode\n if (backgroundEnabled) {\n // Check if the user defined colors to use\n if (backgroundColor && typeof customColorFormatter === 'function') {\n return customColorFormatter(backgroundColor);\n }\n }\n\n return defaultColors.none;\n};\n\n/**\n * Adjust rgb value if it equals to 0 or 255\n * @method adjustRGB\n * @param {Number} rgb [0 - 255]\n * @param {Number} delta\n * @returns {Number} adjusted rgb\n * @private\n */\nexport const adjustRGB = (rgb, delta) => {\n if (rgb === 255) {\n return rgb - delta;\n }\n\n if (rgb === 0) {\n return rgb + delta;\n }\n\n return rgb;\n};\n\nconst getUnchangedColorDelta = (r, g, b, ratio) => {\n if (r === 0 && g === 0 && b === 0) {\n return ratio > 1 ? 80 : 40;\n }\n if (r === 255 && g === 255 && b === 255) {\n return ratio > 1 ? 20 : 80;\n }\n return 20;\n};\n\n/**\n * Modifies colors by multiplying by a given ratio\n * @method changeColor\n * @param {String} color // Color to modify\n * @param {Number} ratio // Float to modify color\n * @returns {String} new color\n * @private\n */\nconst changeColor = (color, ratio) => {\n const hex = color.replace(/(0x|#)/, '');\n const r = Number.parseInt(hex.substr(0, 2), 16);\n const g = Number.parseInt(hex.substr(2, 2), 16);\n const b = Number.parseInt(hex.substr(4, 2), 16);\n\n // Multiply by given ratio, make sure is between 0 and 255;\n let newR = Math.max(Math.min(Math.floor(r * ratio), 255), 0);\n let newG = Math.max(Math.min(Math.floor(g * ratio), 255), 0);\n let newB = Math.max(Math.min(Math.floor(b * ratio), 255), 0);\n\n // If the color is not changed, apply a fixed adjustment\n if (newR === r && newG === g && newB === b) {\n const delta = getUnchangedColorDelta(newR, newG, newB, ratio);\n newR = adjustRGB(newR, delta);\n newG = adjustRGB(newG, delta);\n newB = adjustRGB(newB, delta);\n }\n\n return (\n `#${newR.toString(16).padStart(2, '0')}` +\n `${newG.toString(16).padStart(2, '0')}` +\n `${newB.toString(16).padStart(2, '0')}`\n );\n};\n\n/**\n * Lighten a given color\n * @method lighten\n * @param {String} color\n * @returns {String}\n * @private\n */\nexport const lighten = color => changeColor(color, 1.3);\n\n/**\n * Darkens a given color\n * @method darken\n * @param {String} color\n * @returns {String}\n * @private\n */\nexport const darken = color => changeColor(color, 0.5);\n\n/** consistent token structure: handle callback to add value and name in event payload\n * @method handleValueClickCallback\n * @param {Object} ev\n * @param {String | Number} majorValue\n * @param {String} majorValueField\n * @param {Number} trendValue\n * @param {Function} onValueClick\n * @param {Object} trellisContext\n * @param {Boolean} trellisContext.trellisEnabled\n * @param {String} trellisContext.trellisSplitBy\n * @param {String} trellisContext.trellisKey\n */\nexport const handleValueClickCallback = (\n ev,\n majorValue,\n majorValueField,\n trendValue,\n onValueClick,\n trellisContext = {}\n) => {\n const { trellisEnabled = false, trellisSplitBy = '', trellisKey = '' } = trellisContext;\n\n return onValueClick({\n ...ev,\n payload: {\n trendValue,\n value: majorValue,\n name: majorValueField,\n ...(trellisEnabled && {\n 'trellis.name': trellisSplitBy,\n 'trellis.value': trellisKey,\n }),\n },\n });\n};\n\n/** handle trend color when trend display is percent\n * @method getTrendColorWithPercent\n * @param {Object} options\n * @returns {Object}\n */\nexport const getTrendColorWithPercent = options => {\n const shouldUsePercentTrendColor =\n options.trendColor === '> trendValue | rangeValue(trendColorEditorConfig)' &&\n options.trendDisplay === 'percent';\n\n return shouldUsePercentTrendColor\n ? {\n trendColor: '> trendValuePercent | rangeValue(trendColorEditorConfig)',\n }\n : {};\n};\n", "\nimport * as defaultImport from \"lodash\";\nexport * from \"lodash\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/numberUtils\";\nexport * from \"@splunk/visualizations-shared/numberUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/domUtils\";\nexport * from \"@splunk/visualizations-shared/domUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/propUtils\";\nexport * from \"@splunk/visualizations-shared/propUtils\";\nexport default ('default' in defaultImport ? defaultImport.default : defaultImport);\n", "\nimport * as defaultImport from \"@splunk/visualizations-shared/colorConstants\";\nexport * from \"@splunk/visualizations-shared/colorCon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jB;AACD,QAAM,EAAE,iBAAiB,OAAO,iBAAiB,IAAI,aAAa,GAAG,IAAI;AAEzE,SAAO,aAAa,iCACb,KADa;AAAA,IAEhB,SAAS;AAAA,MACL;AAAA,MACA,OAAO;AAAA,MACP,MAAM;AAAA,OACF,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACrB;AAAA,EAER,EAAC;AACL;AAOO,IAAM,2BAA2B,aAAW;AAC/C,QAAM,6BACF,QAAQ,eAAe,uDACvB,QAAQ,iBAAiB;AAE7B,SAAO,6BACD;AAAA,IACI,YAAY;AAAA,EAChB,IACA,CAAC;AACX;",
6
6
  "names": ["defaultImport", "defaultImport", "defaultImport", "defaultImport"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"textUtils.d.ts","sourceRoot":"","sources":["../../src/common/utils/textUtils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,8GACmF,CAAC;AAEhH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAM7D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,gBAAgB,aAAa,GAAG,gBAAgB,GAAG,eAAe,EAClE,aAAgC,KACjC,MA4CF,CAAC"}
1
+ {"version":3,"file":"textUtils.d.ts","sourceRoot":"","sources":["../../src/common/utils/textUtils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,8GACmF,CAAC;AAEhH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAM7D,CAAC;AAkDF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,gBAAgB,aAAa,GAAG,gBAAgB,GAAG,eAAe,EAClE,aAAgC,KACjC,MAyBF,CAAC"}
@@ -36,40 +36,54 @@ var computeTextWidth = (text, font) => {
36
36
  const measure = context.measureText(text);
37
37
  return measure.width;
38
38
  };
39
+ var truncateEnd = (text, context, maxWidth, ellipsis) => {
40
+ for (let i = text.length - 1; i > 0; i -= 1) {
41
+ const truncatedText = text.slice(0, i) + ellipsis;
42
+ if (context.measureText(truncatedText).width <= maxWidth) {
43
+ return truncatedText;
44
+ }
45
+ }
46
+ return ellipsis;
47
+ };
48
+ var truncateStart = (text, context, maxWidth, ellipsis) => {
49
+ for (let i = 0; i < text.length; i += 1) {
50
+ const truncatedText = ellipsis + text.slice(i);
51
+ if (context.measureText(truncatedText).width <= maxWidth) {
52
+ return truncatedText;
53
+ }
54
+ }
55
+ return ellipsis;
56
+ };
57
+ var truncateMiddle = (text, context, maxWidth, ellipsis) => {
58
+ const ellipsisWidth = context.measureText(ellipsis).width;
59
+ for (let i = 0; i < text.length / 2; i += 1) {
60
+ const left = text.slice(0, Math.floor(text.length / 2) - i);
61
+ const right = text.slice(Math.ceil(text.length / 2) + i);
62
+ const truncatedText = left + ellipsis + right;
63
+ if (context.measureText(left).width + ellipsisWidth + context.measureText(right).width <= maxWidth) {
64
+ return truncatedText;
65
+ }
66
+ }
67
+ return ellipsis;
68
+ };
39
69
  var truncateText = (text, maxWidth, truncationType, font = `10px ${VIZ_FONT_FAMILY}`) => {
40
70
  const canvas = document.createElement("canvas");
41
71
  const context = canvas.getContext("2d");
42
72
  if (!context) return text;
43
73
  context.font = font;
44
74
  const ellipsis = "...";
45
- const ellipsisWidth = context.measureText(ellipsis).width;
46
75
  const fullTextWidth = context.measureText(text).width;
47
76
  if (fullTextWidth <= maxWidth) {
48
77
  return text;
49
78
  }
50
79
  if (truncationType === "ellipsisEnd") {
51
- for (let i = text.length - 1; i > 0; i -= 1) {
52
- const truncatedText = text.slice(0, i) + ellipsis;
53
- if (context.measureText(truncatedText).width <= maxWidth) {
54
- return truncatedText;
55
- }
56
- }
57
- } else if (truncationType === "ellipsisStart") {
58
- for (let i = 0; i < text.length; i += 1) {
59
- const truncatedText = ellipsis + text.slice(i);
60
- if (context.measureText(truncatedText).width <= maxWidth) {
61
- return truncatedText;
62
- }
63
- }
64
- } else if (truncationType === "ellipsisMiddle") {
65
- for (let i = 0; i < text.length / 2; i += 1) {
66
- const left = text.slice(0, Math.floor(text.length / 2) - i);
67
- const right = text.slice(Math.ceil(text.length / 2) + i);
68
- const truncatedText = left + ellipsis + right;
69
- if (context.measureText(left).width + ellipsisWidth + context.measureText(right).width <= maxWidth) {
70
- return truncatedText;
71
- }
72
- }
80
+ return truncateEnd(text, context, maxWidth, ellipsis);
81
+ }
82
+ if (truncationType === "ellipsisStart") {
83
+ return truncateStart(text, context, maxWidth, ellipsis);
84
+ }
85
+ if (truncationType === "ellipsisMiddle") {
86
+ return truncateMiddle(text, context, maxWidth, ellipsis);
73
87
  }
74
88
  return ellipsis;
75
89
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/common/utils/textUtils.ts"],
4
- "sourcesContent": ["export const VIZ_FONT_FAMILY =\n \"'Splunk Platform Sans', 'Splunk Data Sans', Roboto, Droid, 'Helvetica Neue', Helvetica, Arial, sans-serif\";\n\n/**\n * Return text width\n * @method computeTextWidth\n * @param {String} text\n * @param {String} font\n * @returns {Number} width of text with font\n */\nexport const computeTextWidth = (text: string, font: string): number => {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n context.font = font;\n const measure = context.measureText(text);\n return measure.width;\n};\n\n/**\n * Return truncated text\n * @method truncateText\n * @param {String} text\n * @param {Number} maxWidth\n * @param {String} truncationType\n * @param {String} font\n * @returns {String} truncated text\n */\nexport const truncateText = (\n text: string,\n maxWidth: number,\n truncationType: 'ellipsisEnd' | 'ellipsisMiddle' | 'ellipsisStart',\n font = `10px ${VIZ_FONT_FAMILY}`\n): string => {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n if (!context) return text;\n\n context.font = font;\n\n const ellipsis = '...';\n const ellipsisWidth = context.measureText(ellipsis).width;\n const fullTextWidth = context.measureText(text).width;\n\n if (fullTextWidth <= maxWidth) {\n return text;\n }\n\n if (truncationType === 'ellipsisEnd') {\n for (let i = text.length - 1; i > 0; i -= 1) {\n const truncatedText = text.slice(0, i) + ellipsis;\n if (context.measureText(truncatedText).width <= maxWidth) {\n return truncatedText;\n }\n }\n } else if (truncationType === 'ellipsisStart') {\n for (let i = 0; i < text.length; i += 1) {\n const truncatedText = ellipsis + text.slice(i);\n if (context.measureText(truncatedText).width <= maxWidth) {\n return truncatedText;\n }\n }\n } else if (truncationType === 'ellipsisMiddle') {\n for (let i = 0; i < text.length / 2; i += 1) {\n const left = text.slice(0, Math.floor(text.length / 2) - i);\n const right = text.slice(Math.ceil(text.length / 2) + i);\n const truncatedText = left + ellipsis + right;\n if (\n context.measureText(left).width + ellipsisWidth + context.measureText(right).width <=\n maxWidth\n ) {\n return truncatedText;\n }\n }\n }\n\n return ellipsis;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,kBACT;AASG,IAAM,mBAAmB,CAAC,MAAc,SAAyB;AACpE,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,QAAM,UAAU,OAAO,WAAW,IAAI;AACtC,UAAQ,OAAO;AACf,QAAM,UAAU,QAAQ,YAAY,IAAI;AACxC,SAAO,QAAQ;AACnB;AAWO,IAAM,eAAe,CACxB,MACA,UACA,gBACA,OAAO,QAAQ,eAAe,OACrB;AACT,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,QAAM,UAAU,OAAO,WAAW,IAAI;AACtC,MAAI,CAAC,QAAS,QAAO;AAErB,UAAQ,OAAO;AAEf,QAAM,WAAW;AACjB,QAAM,gBAAgB,QAAQ,YAAY,QAAQ,EAAE;AACpD,QAAM,gBAAgB,QAAQ,YAAY,IAAI,EAAE;AAEhD,MAAI,iBAAiB,UAAU;AAC3B,WAAO;AAAA,EACX;AAEA,MAAI,mBAAmB,eAAe;AAClC,aAAS,IAAI,KAAK,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG;AACzC,YAAM,gBAAgB,KAAK,MAAM,GAAG,CAAC,IAAI;AACzC,UAAI,QAAQ,YAAY,aAAa,EAAE,SAAS,UAAU;AACtD,eAAO;AAAA,MACX;AAAA,IACJ;AAAA,EACJ,WAAW,mBAAmB,iBAAiB;AAC3C,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACrC,YAAM,gBAAgB,WAAW,KAAK,MAAM,CAAC;AAC7C,UAAI,QAAQ,YAAY,aAAa,EAAE,SAAS,UAAU;AACtD,eAAO;AAAA,MACX;AAAA,IACJ;AAAA,EACJ,WAAW,mBAAmB,kBAAkB;AAC5C,aAAS,IAAI,GAAG,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG;AACzC,YAAM,OAAO,KAAK,MAAM,GAAG,KAAK,MAAM,KAAK,SAAS,CAAC,IAAI,CAAC;AAC1D,YAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,KAAK,SAAS,CAAC,IAAI,CAAC;AACvD,YAAM,gBAAgB,OAAO,WAAW;AACxC,UACI,QAAQ,YAAY,IAAI,EAAE,QAAQ,gBAAgB,QAAQ,YAAY,KAAK,EAAE,SAC7E,UACF;AACE,eAAO;AAAA,MACX;AAAA,IACJ;AAAA,EACJ;AAEA,SAAO;AACX;",
4
+ "sourcesContent": ["export const VIZ_FONT_FAMILY =\n \"'Splunk Platform Sans', 'Splunk Data Sans', Roboto, Droid, 'Helvetica Neue', Helvetica, Arial, sans-serif\";\n\n/**\n * Return text width\n * @method computeTextWidth\n * @param {String} text\n * @param {String} font\n * @returns {Number} width of text with font\n */\nexport const computeTextWidth = (text: string, font: string): number => {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n context.font = font;\n const measure = context.measureText(text);\n return measure.width;\n};\n\nconst truncateEnd = (\n text: string,\n context: CanvasRenderingContext2D,\n maxWidth: number,\n ellipsis: string\n): string => {\n for (let i = text.length - 1; i > 0; i -= 1) {\n const truncatedText = text.slice(0, i) + ellipsis;\n if (context.measureText(truncatedText).width <= maxWidth) {\n return truncatedText;\n }\n }\n return ellipsis;\n};\n\nconst truncateStart = (\n text: string,\n context: CanvasRenderingContext2D,\n maxWidth: number,\n ellipsis: string\n): string => {\n for (let i = 0; i < text.length; i += 1) {\n const truncatedText = ellipsis + text.slice(i);\n if (context.measureText(truncatedText).width <= maxWidth) {\n return truncatedText;\n }\n }\n return ellipsis;\n};\n\nconst truncateMiddle = (\n text: string,\n context: CanvasRenderingContext2D,\n maxWidth: number,\n ellipsis: string\n): string => {\n const ellipsisWidth = context.measureText(ellipsis).width;\n for (let i = 0; i < text.length / 2; i += 1) {\n const left = text.slice(0, Math.floor(text.length / 2) - i);\n const right = text.slice(Math.ceil(text.length / 2) + i);\n const truncatedText = left + ellipsis + right;\n if (context.measureText(left).width + ellipsisWidth + context.measureText(right).width <= maxWidth) {\n return truncatedText;\n }\n }\n return ellipsis;\n};\n\n/**\n * Return truncated text\n * @method truncateText\n * @param {String} text\n * @param {Number} maxWidth\n * @param {String} truncationType\n * @param {String} font\n * @returns {String} truncated text\n */\nexport const truncateText = (\n text: string,\n maxWidth: number,\n truncationType: 'ellipsisEnd' | 'ellipsisMiddle' | 'ellipsisStart',\n font = `10px ${VIZ_FONT_FAMILY}`\n): string => {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n if (!context) return text;\n\n context.font = font;\n\n const ellipsis = '...';\n const fullTextWidth = context.measureText(text).width;\n\n if (fullTextWidth <= maxWidth) {\n return text;\n }\n\n if (truncationType === 'ellipsisEnd') {\n return truncateEnd(text, context, maxWidth, ellipsis);\n }\n if (truncationType === 'ellipsisStart') {\n return truncateStart(text, context, maxWidth, ellipsis);\n }\n if (truncationType === 'ellipsisMiddle') {\n return truncateMiddle(text, context, maxWidth, ellipsis);\n }\n\n return ellipsis;\n};\n"],
5
+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CAAgC,GACzC,WAAW,aAAa,EACxB,aAAa;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,EAC3C,gBAAgB,MAAM,KACvB,eA8BF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,GAC5C,aAAa,OAAO,EACpB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAOvB,CAAC;AAqCF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GACxB,WAAW,eAAe,EAC1B,oBAAoB,OAAO,EAC3B,UAAU,MAAM,GAAG,MAAM,EACzB,UAAU,MAAM,GAAG,MAAM,EACzB,YAAY,MAAM,wBAWrB,CAAC"}
@@ -284,7 +284,7 @@ var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
284
284
  splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
285
285
  }
286
286
  if (splitByFields == null ? void 0 : splitByFields.includes(splitBy)) {
287
- const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
287
+ const splitByFieldIdx = splitByFields.indexOf(splitBy);
288
288
  const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
289
289
  const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
290
290
  const nonDataSourceAggregations = [];
@@ -318,17 +318,17 @@ var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
318
318
  let splitByFields = [];
319
319
  let errorCode = null;
320
320
  if (fields.length > 0) {
321
- splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
321
+ splitByFields = splitMode === trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields);
322
322
  }
323
323
  const splitByIndex = fields.findIndex((field) => field.name === splitBy);
324
324
  if (splitByFields == null ? void 0 : splitByFields.includes(splitBy)) {
325
325
  const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
326
326
  splitDataSources = {};
327
327
  splitByColumn.forEach((val, idx) => {
328
- if (!splitDataSources[val]) {
329
- splitDataSources[val] = [idx];
330
- } else {
328
+ if (splitDataSources[val]) {
331
329
  splitDataSources[val].push(idx);
330
+ } else {
331
+ splitDataSources[val] = [idx];
332
332
  }
333
333
  });
334
334
  const cloneFields = (0, lodash_exports.cloneDeep)(fields);
@@ -379,27 +379,28 @@ var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
379
379
  }
380
380
  return {};
381
381
  };
382
+ var extendMinMaxWithColumn = (column, range) => column.reduce((acc, point) => {
383
+ const pointNumber = Number(point);
384
+ if (Number.isNaN(pointNumber)) {
385
+ return acc;
386
+ }
387
+ return {
388
+ min: Math.min(pointNumber, acc.min),
389
+ max: Math.max(pointNumber, acc.max)
390
+ };
391
+ }, range);
382
392
  var calculateSharedMinMax = (splitData) => {
383
- let max = -Infinity;
384
- let min = Infinity;
393
+ let range = { min: Infinity, max: -Infinity };
385
394
  Object.keys(splitData).forEach((splitByKey) => {
386
395
  const datasources = splitData[splitByKey];
387
396
  Object.keys(datasources).forEach((datasourceName) => {
388
397
  const dataColumns = datasources[datasourceName].data.columns;
389
398
  dataColumns.forEach((column) => {
390
- column.forEach((point) => {
391
- const pointNumber = Number(point);
392
- if (pointNumber > max) {
393
- max = pointNumber;
394
- }
395
- if (pointNumber < min) {
396
- min = pointNumber;
397
- }
398
- });
399
+ range = extendMinMaxWithColumn(column, range);
399
400
  });
400
401
  });
401
402
  });
402
- return [min, max];
403
+ return [range.min, range.max];
403
404
  };
404
405
  var determineMinMax = (splitData, trellisSharedScale, yAxisMin, yAxisMax, stackMode) => {
405
406
  if (!trellisSharedScale || stackMode === "stacked100" || yAxisMin !== "auto" && yAxisMax !== "auto")