@perses-dev/components 0.30.0 → 0.32.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 (187) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.d.ts +11 -0
  2. package/dist/ContentWithLegend/ContentWithLegend.d.ts.map +1 -0
  3. package/dist/ContentWithLegend/ContentWithLegend.js +65 -0
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -0
  5. package/dist/ContentWithLegend/index.d.ts +2 -0
  6. package/dist/ContentWithLegend/index.d.ts.map +1 -0
  7. package/dist/ContentWithLegend/index.js +15 -0
  8. package/dist/ContentWithLegend/index.js.map +1 -0
  9. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +68 -0
  10. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -0
  11. package/dist/ContentWithLegend/model/content-with-legend-model.js +90 -0
  12. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -0
  13. package/dist/EChart/EChart.d.ts.map +1 -1
  14. package/dist/EChart/EChart.js +9 -1
  15. package/dist/EChart/EChart.js.map +1 -1
  16. package/dist/Legend/CompactLegend.d.ts +6 -4
  17. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  18. package/dist/Legend/CompactLegend.js +4 -1
  19. package/dist/Legend/CompactLegend.js.map +1 -1
  20. package/dist/Legend/Legend.d.ts +11 -9
  21. package/dist/Legend/Legend.d.ts.map +1 -1
  22. package/dist/Legend/Legend.js +70 -21
  23. package/dist/Legend/Legend.js.map +1 -1
  24. package/dist/Legend/ListLegend.d.ts +5 -8
  25. package/dist/Legend/ListLegend.d.ts.map +1 -1
  26. package/dist/Legend/ListLegend.js +17 -103
  27. package/dist/Legend/ListLegend.js.map +1 -1
  28. package/dist/Legend/ListLegendItem.d.ts +8 -8
  29. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  30. package/dist/Legend/ListLegendItem.js +9 -12
  31. package/dist/Legend/ListLegendItem.js.map +1 -1
  32. package/dist/Legend/TableLegend.d.ts +12 -0
  33. package/dist/Legend/TableLegend.d.ts.map +1 -0
  34. package/dist/Legend/TableLegend.js +61 -0
  35. package/dist/Legend/TableLegend.js.map +1 -0
  36. package/dist/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  37. package/dist/LegendOptionsEditor/LegendOptionsEditor.js +35 -3
  38. package/dist/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  39. package/dist/LineChart/LineChart.d.ts +2 -1
  40. package/dist/LineChart/LineChart.d.ts.map +1 -1
  41. package/dist/LineChart/LineChart.js +83 -36
  42. package/dist/LineChart/LineChart.js.map +1 -1
  43. package/dist/StatChart/StatChart.d.ts.map +1 -1
  44. package/dist/StatChart/StatChart.js +8 -1
  45. package/dist/StatChart/StatChart.js.map +1 -1
  46. package/dist/Table/InnerTable.d.ts +9 -0
  47. package/dist/Table/InnerTable.d.ts.map +1 -0
  48. package/dist/Table/InnerTable.js +38 -0
  49. package/dist/Table/InnerTable.js.map +1 -0
  50. package/dist/Table/Table.d.ts +10 -0
  51. package/dist/Table/Table.d.ts.map +1 -0
  52. package/dist/Table/Table.js +101 -0
  53. package/dist/Table/Table.js.map +1 -0
  54. package/dist/Table/TableBody.d.ts +6 -0
  55. package/dist/Table/TableBody.d.ts.map +1 -0
  56. package/dist/Table/TableBody.js +23 -0
  57. package/dist/Table/TableBody.js.map +1 -0
  58. package/dist/Table/TableCell.d.ts +18 -0
  59. package/dist/Table/TableCell.d.ts.map +1 -0
  60. package/dist/Table/TableCell.js +91 -0
  61. package/dist/Table/TableCell.js.map +1 -0
  62. package/dist/Table/TableCheckbox.d.ts +9 -0
  63. package/dist/Table/TableCheckbox.d.ts.map +1 -0
  64. package/dist/Table/TableCheckbox.js +49 -0
  65. package/dist/Table/TableCheckbox.js.map +1 -0
  66. package/dist/Table/TableHead.d.ts +6 -0
  67. package/dist/Table/TableHead.d.ts.map +1 -0
  68. package/dist/Table/TableHead.js +23 -0
  69. package/dist/Table/TableHead.js.map +1 -0
  70. package/dist/Table/TableRow.d.ts +9 -0
  71. package/dist/Table/TableRow.d.ts.map +1 -0
  72. package/dist/Table/TableRow.js +29 -0
  73. package/dist/Table/TableRow.js.map +1 -0
  74. package/dist/Table/VirtualizedTable.d.ts +11 -0
  75. package/dist/Table/VirtualizedTable.d.ts.map +1 -0
  76. package/dist/Table/VirtualizedTable.js +152 -0
  77. package/dist/Table/VirtualizedTable.js.map +1 -0
  78. package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
  79. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
  80. package/dist/Table/VirtualizedTableContainer.js +24 -0
  81. package/dist/Table/VirtualizedTableContainer.js.map +1 -0
  82. package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
  83. package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
  84. package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
  85. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
  86. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
  87. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
  88. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
  89. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
  90. package/dist/Table/index.d.ts +4 -0
  91. package/dist/Table/index.d.ts.map +1 -0
  92. package/dist/Table/index.js +16 -0
  93. package/dist/Table/index.js.map +1 -0
  94. package/dist/Table/model/table-model.d.ts +83 -0
  95. package/dist/Table/model/table-model.d.ts.map +1 -0
  96. package/dist/Table/model/table-model.js +73 -0
  97. package/dist/Table/model/table-model.js.map +1 -0
  98. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
  99. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
  100. package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
  101. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  102. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +6 -5
  103. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
  104. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +48 -21
  105. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
  106. package/dist/TimeSeriesTooltip/TooltipContent.d.ts +3 -3
  107. package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
  108. package/dist/TimeSeriesTooltip/TooltipContent.js +28 -67
  109. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  110. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts +12 -0
  111. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -0
  112. package/dist/TimeSeriesTooltip/TooltipHeader.js +163 -0
  113. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -0
  114. package/dist/TimeSeriesTooltip/index.d.ts +2 -1
  115. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  116. package/dist/TimeSeriesTooltip/index.js +2 -1
  117. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  118. package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
  119. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
  120. package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
  121. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
  122. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +17 -17
  123. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  124. package/dist/TimeSeriesTooltip/tooltip-model.js +7 -2
  125. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  126. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  127. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  128. package/dist/TimeSeriesTooltip/utils.js +6 -5
  129. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  130. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +70 -0
  131. package/dist/cjs/ContentWithLegend/index.js +28 -0
  132. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +100 -0
  133. package/dist/cjs/EChart/EChart.js +9 -1
  134. package/dist/cjs/Legend/CompactLegend.js +4 -1
  135. package/dist/cjs/Legend/Legend.js +70 -21
  136. package/dist/cjs/Legend/ListLegend.js +17 -103
  137. package/dist/cjs/Legend/ListLegendItem.js +8 -11
  138. package/dist/cjs/Legend/TableLegend.js +67 -0
  139. package/dist/cjs/LegendOptionsEditor/LegendOptionsEditor.js +34 -2
  140. package/dist/cjs/LineChart/LineChart.js +83 -36
  141. package/dist/cjs/StatChart/StatChart.js +8 -1
  142. package/dist/cjs/Table/InnerTable.js +44 -0
  143. package/dist/cjs/Table/Table.js +102 -0
  144. package/dist/cjs/Table/TableBody.js +29 -0
  145. package/dist/cjs/Table/TableCell.js +97 -0
  146. package/dist/cjs/Table/TableCheckbox.js +55 -0
  147. package/dist/cjs/Table/TableHead.js +29 -0
  148. package/dist/cjs/Table/TableRow.js +35 -0
  149. package/dist/cjs/Table/VirtualizedTable.js +155 -0
  150. package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
  151. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
  152. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
  153. package/dist/cjs/Table/index.js +33 -0
  154. package/dist/cjs/Table/model/table-model.js +80 -0
  155. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
  156. package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +45 -57
  157. package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +26 -65
  158. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +174 -0
  159. package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
  160. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
  161. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +13 -3
  162. package/dist/cjs/TimeSeriesTooltip/utils.js +5 -4
  163. package/dist/cjs/context/SnackbarProvider.js +66 -0
  164. package/dist/cjs/index.js +3 -0
  165. package/dist/cjs/model/legend.js +37 -2
  166. package/dist/cjs/theme/palette/grey.js +6 -2
  167. package/dist/context/SnackbarProvider.d.ts +23 -0
  168. package/dist/context/SnackbarProvider.d.ts.map +1 -0
  169. package/dist/context/SnackbarProvider.js +59 -0
  170. package/dist/context/SnackbarProvider.js.map +1 -0
  171. package/dist/index.d.ts +3 -0
  172. package/dist/index.d.ts.map +1 -1
  173. package/dist/index.js +3 -0
  174. package/dist/index.js.map +1 -1
  175. package/dist/model/legend.d.ts +19 -5
  176. package/dist/model/legend.d.ts.map +1 -1
  177. package/dist/model/legend.js +31 -1
  178. package/dist/model/legend.js.map +1 -1
  179. package/dist/theme/palette/grey.d.ts.map +1 -1
  180. package/dist/theme/palette/grey.js +6 -2
  181. package/dist/theme/palette/grey.js.map +1 -1
  182. package/package.json +6 -6
  183. package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
  184. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
  185. package/dist/TimeSeriesTooltip/focused-series.js +0 -110
  186. package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
  187. package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -116
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\nimport { Box, Divider, Stack, Typography } from '@mui/material';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { FocusedSeriesArray } from './focused-series';\nimport { SeriesInfo } from './SeriesInfo';\n\nexport interface TooltipContentProps {\n focusedSeries: FocusedSeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { focusedSeries, wrapLabels } = props;\n const { formatWithUserTimeZone } = useTimeZone();\n\n const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;\n\n const formatTimeSeriesHeader = (timeMs: number) => {\n const date = new Date(timeMs);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n\n return (\n <>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </>\n );\n };\n\n const sortedFocusedSeries = useMemo(() => {\n if (focusedSeries === null) return null;\n return focusedSeries.sort((a, b) => (a.y > b.y ? -1 : 1));\n }, [focusedSeries]);\n\n if (sortedFocusedSeries !== null && seriesTime !== null) {\n return (\n <Stack py={1} px={1.5} spacing={0.5}>\n <Typography variant=\"caption\">{formatTimeSeriesHeader(seriesTime)}</Typography>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={{\n display: 'table',\n }}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n />\n );\n })}\n </Box>\n </Stack>\n );\n } else {\n return <></>;\n }\n}\n"],"names":["useMemo","Box","Divider","Stack","Typography","useTimeZone","SeriesInfo","TooltipContent","props","focusedSeries","wrapLabels","formatWithUserTimeZone","seriesTime","date","formatTimeSeriesHeader","timeMs","Date","formattedDate","formattedTime","variant","sx","theme","color","palette","common","white","strong","sortedFocusedSeries","sort","a","b","y","py","px","spacing","borderColor","grey","display","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","key","toString","totalSeries","length"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChE,SAASC,WAAW,QAAQ,6BAA6B,CAAC;AAE1D,SAASC,UAAU,QAAQ,cAAc,CAAC;AAO1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,aAAa,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAC5C,MAAM,EAAEG,sBAAsB,CAAA,EAAE,GAAGN,WAAW,EAAE,AAAC;IAEjD,MAAMO,UAAU,GAAGH,aAAa,IAAIA,aAAa,CAAC,CAAC,CAAC,IAAIA,aAAa,CAAC,CAAC,CAAC,CAACI,IAAI,GAAGJ,aAAa,CAAC,CAAC,CAAC,CAACI,IAAI,GAAG,IAAI,AAAC;IAE7G,MAAMC,sBAAsB,GAAG,CAACC,MAAc,GAAK;QACjD,MAAMF,IAAI,GAAG,IAAIG,IAAI,CAACD,MAAM,CAAC,AAAC;QAC9B,MAAME,aAAa,GAAGN,sBAAsB,CAACE,IAAI,EAAE,iBAAiB,CAAC,AAAC;QACtE,MAAMK,aAAa,GAAGP,sBAAsB,CAACE,IAAI,EAAE,UAAU,CAAC,AAAC;QAE/D,qBACE;;8BACE,KAACT,U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AEW,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAK;wBAC5F,IAAIJ,QAAQ,KAAK,IAAI,IAAIC,SAAS,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;wBACzD,MAAMI,GAAG,GAAGJ,SAAS,CAACK,QAAQ,EAAE,GAAGN,QAAQ,CAACM,QAAQ,EAAE,AAAC;wBAEvD,qBACE,KAACvC,UAAU;4BAETmC,UAAU,EAAEA,UAAU;4BACtBV,CAAC,EAAEA,CAAC;4BACJW,UAAU,EAAEA,UAAU;4BACtBC,WAAW,EAAEA,WAAW;4BACxBG,WAAW,EAAEnB,mBAAmB,CAACoB,MAAM;4BACvCrC,UAAU,EAAEA,UAAU;2BANjBkC,GAAG,CAOR,CACF;oBACJ,CAAC,CAAC;kBACE;;UACA,CACR;IACJ,OAAO;QACL,qBAAO,mBAAK,CAAC;IACf,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\nimport { Box } from '@mui/material';\nimport { NearbySeriesArray } from './nearby-series';\nimport { SeriesInfo } from './SeriesInfo';\n\nexport interface TooltipContentProps {\n series: NearbySeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { series, wrapLabels } = props;\n\n const sortedFocusedSeries = useMemo(() => {\n if (series === null) return null;\n return series.sort((a, b) => (a.y > b.y ? -1 : 1));\n }, [series]);\n\n if (series === null || sortedFocusedSeries === null) {\n return null;\n }\n // TODO: use react-virtuoso to improve performance\n return (\n <Box\n sx={(theme) => ({\n display: 'table',\n padding: theme.spacing(0.5, 2),\n })}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n emphasizeText={isClosestToCursor}\n />\n );\n })}\n </Box>\n );\n}\n"],"names":["useMemo","Box","SeriesInfo","TooltipContent","props","series","wrapLabels","sortedFocusedSeries","sort","a","b","y","sx","theme","display","padding","spacing","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","isClosestToCursor","key","toString","totalSeries","length","emphasizeText"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAO1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,MAAM,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAErC,MAAMG,mBAAmB,GAAGP,OAAO,CAAC,IAAM;QACxC,IAAIK,MAAM,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;QACjC,OAAOA,MAAM,CAACG,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,GAAMD,CAAC,CAACE,CAAC,GAAGD,CAAC,CAACC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,AAAC,CAAC,CAAC;IACrD,CAAC,EAAE;QAACN,MAAM;KAAC,CAAC,AAAC;IAEb,IAAIA,MAAM,KAAK,IAAI,IAAIE,mBAAmB,KAAK,IAAI,EAAE;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,kDAAkD;IAClD,qBACE,KAACN,GAAG;QACFW,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;gBACdC,OAAO,EAAE,OAAO;gBAChBC,OAAO,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;aAC/B,CAAA,AAAC;kBAEDT,mBAAmB,CAACU,GAAG,CAAC,CAAC,EAAEC,QAAQ,CAAA,EAAEC,SAAS,CAAA,EAAEC,UAAU,CAAA,EAAET,CAAC,CAAA,EAAEU,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAEC,iBAAiB,CAAA,EAAE,GAAK;YAC/G,IAAIL,QAAQ,KAAK,IAAI,IAAIC,SAAS,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;YACzD,MAAMK,GAAG,GAAGL,SAAS,CAACM,QAAQ,EAAE,GAAGP,QAAQ,CAACO,QAAQ,EAAE,AAAC;YAEvD,qBACE,KAACvB,UAAU;gBAETkB,UAAU,EAAEA,UAAU;gBACtBT,CAAC,EAAEA,CAAC;gBACJU,UAAU,EAAEA,UAAU;gBACtBC,WAAW,EAAEA,WAAW;gBACxBI,WAAW,EAAEnB,mBAAmB,CAACoB,MAAM;gBACvCrB,UAAU,EAAEA,UAAU;gBACtBsB,aAAa,EAAEL,iBAAiB;eAP3BC,GAAG,CAQR,CACF;QACJ,CAAC,CAAC;MACE,CACN;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { NearbySeriesArray } from './nearby-series';
3
+ export interface TooltipHeaderProps {
4
+ nearbySeries: NearbySeriesArray;
5
+ totalSeries: number;
6
+ isTooltipPinned: boolean;
7
+ showAllSeries: boolean;
8
+ onShowAllClick?: (checked: boolean) => void;
9
+ onUnpinClick?: () => void;
10
+ }
11
+ export declare const TooltipHeader: import("react").NamedExoticComponent<TooltipHeaderProps>;
12
+ //# sourceMappingURL=TooltipHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipHeader.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TooltipHeader.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,eAAO,MAAM,aAAa,0DAwHxB,CAAC"}
@@ -0,0 +1,163 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Box, Divider, Typography, Stack, Switch } from '@mui/material';
15
+ import Pin from 'mdi-material-ui/Pin';
16
+ import PinOutline from 'mdi-material-ui/PinOutline';
17
+ import { memo } from 'react';
18
+ import { useTimeZone } from '../context/TimeZoneProvider';
19
+ import { TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_MAX_WIDTH } from './tooltip-model';
20
+ export const TooltipHeader = /*#__PURE__*/ memo(function TooltipHeader({ nearbySeries , totalSeries , isTooltipPinned , showAllSeries , onShowAllClick , onUnpinClick }) {
21
+ var ref;
22
+ const { formatWithUserTimeZone } = useTimeZone();
23
+ var ref1;
24
+ const seriesTimeMs = (ref1 = (ref = nearbySeries[0]) === null || ref === void 0 ? void 0 : ref.date) !== null && ref1 !== void 0 ? ref1 : null;
25
+ if (seriesTimeMs === null) {
26
+ return null;
27
+ }
28
+ const formatTimeSeriesHeader = (timeMs)=>{
29
+ const date = new Date(timeMs);
30
+ const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');
31
+ const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');
32
+ return /*#__PURE__*/ _jsxs(Box, {
33
+ children: [
34
+ /*#__PURE__*/ _jsx(Typography, {
35
+ variant: "caption",
36
+ sx: (theme)=>({
37
+ color: theme.palette.common.white
38
+ }),
39
+ children: formattedDate
40
+ }),
41
+ /*#__PURE__*/ _jsx(Typography, {
42
+ variant: "caption",
43
+ children: /*#__PURE__*/ _jsx("strong", {
44
+ children: formattedTime
45
+ })
46
+ })
47
+ ]
48
+ });
49
+ };
50
+ // TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT
51
+ const showAllSeriesToggle = totalSeries > 5;
52
+ var ref2;
53
+ return /*#__PURE__*/ _jsxs(Box, {
54
+ sx: (theme)=>{
55
+ var ref;
56
+ return {
57
+ width: '100%',
58
+ maxWidth: TOOLTIP_MAX_WIDTH,
59
+ padding: theme.spacing(1.5, 2, 0.5, 2),
60
+ backgroundColor: (ref2 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref2 !== void 0 ? ref2 : TOOLTIP_BG_COLOR_FALLBACK,
61
+ position: 'sticky',
62
+ top: 0,
63
+ left: 0
64
+ };
65
+ },
66
+ children: [
67
+ /*#__PURE__*/ _jsxs(Box, {
68
+ sx: {
69
+ width: '100%',
70
+ display: 'flex',
71
+ justifyContent: 'start',
72
+ alignItems: 'center',
73
+ paddingBottom: 0.5
74
+ },
75
+ children: [
76
+ formatTimeSeriesHeader(seriesTimeMs),
77
+ /*#__PURE__*/ _jsxs(Stack, {
78
+ direction: "row",
79
+ gap: 1,
80
+ sx: {
81
+ marginLeft: 'auto'
82
+ },
83
+ children: [
84
+ showAllSeriesToggle && /*#__PURE__*/ _jsxs(Stack, {
85
+ direction: "row",
86
+ gap: 0.5,
87
+ alignItems: "center",
88
+ sx: {
89
+ textAlign: 'right'
90
+ },
91
+ children: [
92
+ /*#__PURE__*/ _jsx(Typography, {
93
+ sx: {
94
+ fontSize: 11
95
+ },
96
+ children: "Show All"
97
+ }),
98
+ /*#__PURE__*/ _jsx(Switch, {
99
+ checked: showAllSeries,
100
+ size: "small",
101
+ onChange: (_, checked)=>{
102
+ if (onShowAllClick !== undefined) {
103
+ return onShowAllClick(checked);
104
+ }
105
+ },
106
+ sx: (theme)=>({
107
+ '& .MuiSwitch-switchBase': {
108
+ color: theme.palette.common.white
109
+ },
110
+ '& .MuiSwitch-track': {
111
+ backgroundColor: theme.palette.common.white
112
+ }
113
+ })
114
+ })
115
+ ]
116
+ }),
117
+ /*#__PURE__*/ _jsxs(Stack, {
118
+ direction: "row",
119
+ alignItems: "center",
120
+ children: [
121
+ /*#__PURE__*/ _jsxs(Typography, {
122
+ sx: {
123
+ marginRight: 0.5,
124
+ fontSize: 11,
125
+ verticalAlign: 'middle'
126
+ },
127
+ children: [
128
+ "Click to ",
129
+ isTooltipPinned ? 'Unpin' : 'Pin'
130
+ ]
131
+ }),
132
+ isTooltipPinned ? /*#__PURE__*/ _jsx(Pin, {
133
+ onClick: ()=>{
134
+ if (onUnpinClick !== undefined) {
135
+ onUnpinClick();
136
+ }
137
+ },
138
+ sx: {
139
+ fontSize: 16,
140
+ cursor: 'pointer'
141
+ }
142
+ }) : /*#__PURE__*/ _jsx(PinOutline, {
143
+ sx: {
144
+ fontSize: 16
145
+ }
146
+ })
147
+ ]
148
+ })
149
+ ]
150
+ })
151
+ ]
152
+ }),
153
+ /*#__PURE__*/ _jsx(Divider, {
154
+ sx: (theme)=>({
155
+ width: '100%',
156
+ borderColor: theme.palette.grey['500']
157
+ })
158
+ })
159
+ ]
160
+ });
161
+ });
162
+
163
+ //# sourceMappingURL=TooltipHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipHeader.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Divider, Typography, Stack, Switch } from '@mui/material';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport { memo } from 'react';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { NearbySeriesArray } from './nearby-series';\nimport { TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_MAX_WIDTH } from './tooltip-model';\n\nexport interface TooltipHeaderProps {\n nearbySeries: NearbySeriesArray;\n totalSeries: number;\n isTooltipPinned: boolean;\n showAllSeries: boolean;\n onShowAllClick?: (checked: boolean) => void;\n onUnpinClick?: () => void;\n}\n\nexport const TooltipHeader = memo(function TooltipHeader({\n nearbySeries,\n totalSeries,\n isTooltipPinned,\n showAllSeries,\n onShowAllClick,\n onUnpinClick,\n}: TooltipHeaderProps) {\n const { formatWithUserTimeZone } = useTimeZone();\n\n const seriesTimeMs = nearbySeries[0]?.date ?? null;\n if (seriesTimeMs === null) {\n return null;\n }\n\n const formatTimeSeriesHeader = (timeMs: number) => {\n const date = new Date(timeMs);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n return (\n <Box>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </Box>\n );\n };\n\n // TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT\n const showAllSeriesToggle = totalSeries > 5;\n\n return (\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box\n sx={{\n width: '100%',\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n paddingBottom: 0.5,\n }}\n >\n {formatTimeSeriesHeader(seriesTimeMs)}\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }}>\n {showAllSeriesToggle && (\n <Stack direction=\"row\" gap={0.5} alignItems=\"center\" sx={{ textAlign: 'right' }}>\n <Typography sx={{ fontSize: 11 }}>Show All</Typography>\n <Switch\n checked={showAllSeries}\n size=\"small\"\n onChange={(_, checked) => {\n if (onShowAllClick !== undefined) {\n return onShowAllClick(checked);\n }\n }}\n sx={(theme) => ({\n '& .MuiSwitch-switchBase': {\n color: theme.palette.common.white,\n },\n '& .MuiSwitch-track': {\n backgroundColor: theme.palette.common.white,\n },\n })}\n />\n </Stack>\n )}\n <Stack direction=\"row\" alignItems=\"center\">\n <Typography\n sx={{\n marginRight: 0.5,\n fontSize: 11,\n verticalAlign: 'middle',\n }}\n >\n Click to {isTooltipPinned ? 'Unpin' : 'Pin'}\n </Typography>\n {isTooltipPinned ? (\n <Pin\n onClick={() => {\n if (onUnpinClick !== undefined) {\n onUnpinClick();\n }\n }}\n sx={{\n fontSize: 16,\n cursor: 'pointer',\n }}\n />\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n </Stack>\n </Box>\n <Divider\n sx={(theme) => ({\n width: '100%',\n borderColor: theme.palette.grey['500'],\n })}\n />\n </Box>\n );\n});\n"],"names":["Box","Divider","Typography","Stack","Switch","Pin","PinOutline","memo","useTimeZone","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","TooltipHeader","nearbySeries","totalSeries","isTooltipPinned","showAllSeries","onShowAllClick","onUnpinClick","formatWithUserTimeZone","seriesTimeMs","date","formatTimeSeriesHeader","timeMs","Date","formattedDate","formattedTime","variant","sx","theme","color","palette","common","white","strong","showAllSeriesToggle","width","maxWidth","padding","spacing","backgroundColor","designSystem","grey","position","top","left","display","justifyContent","alignItems","paddingBottom","direction","gap","marginLeft","textAlign","fontSize","checked","size","onChange","_","undefined","marginRight","verticalAlign","onClick","cursor","borderColor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACxE,OAAOC,GAAG,MAAM,qBAAqB,CAAC;AACtC,OAAOC,UAAU,MAAM,4BAA4B,CAAC;AACpD,SAASC,IAAI,QAAQ,OAAO,CAAC;AAC7B,SAASC,WAAW,QAAQ,6BAA6B,CAAC;AAE1D,SAASC,yBAAyB,EAAEC,iBAAiB,QAAQ,iBAAiB,CAAC;AAW/E,OAAO,MAAMC,aAAa,iBAAGJ,IAAI,CAAC,SAASI,aAAa,CAAC,EACvDC,YAAY,CAAA,EACZC,WAAW,CAAA,EACXC,eAAe,CAAA,EACfC,aAAa,CAAA,EACbC,cAAc,CAAA,EACdC,YAAY,CAAA,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,OAAO,CAAC,CAAC;4CACjC,CAAC;wCACH,CAAC;wCACD3B,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;gDACd,yBAAyB,EAAE;oDACzBC,KAAK,EAAED,KAAK,CAACE,OAAO,CAACC,MAAM,CAACC,KAAK;iDAClC;gDACD,oBAAoB,EAAE;oDACpBO,eAAe,EAAEX,KAAK,CAACE,OAAO,CAACC,MAAM,CAACC,KAAK;iDAC5C;6CACF,CAAA,AAAC;sCACF;;8BACI,AACT;0CACD,MAAC7B,KAAK;gCAAC8C,SAAS,EAAC,KAAK;gCAACF,UAAU,EAAC,QAAQ;;kDACxC,MAAC7C,UAAU;wCACTyB,EAAE,EAAE;4CACFgC,WAAW,EAAE,GAAG;4CAChBN,QAAQ,EAAE,EAAE;4CACZO,aAAa,EAAE,QAAQ;yCACxB;;4CACF,WACU;4CAAC9C,eAAe,GAAG,OAAO,GAAG,KAAK;;sCAChC;oCACZA,eAAe,iBACd,KAACT,GAAG;wCACFwD,OAAO,EAAE,IAAM;4CACb,IAAI5C,YAAY,KAAKyC,SAAS,EAAE;gDAC9BzC,YAAY,EAAE,CAAC;4CACjB,CAAC;wCACH,CAAC;wCACDU,EAAE,EAAE;4CACF0B,QAAQ,EAAE,EAAE;4CACZS,MAAM,EAAE,SAAS;yCAClB;sCACD,iBAEF,KAACxD,UAAU;wCAACqB,EAAE,EAAE;4CAAE0B,QAAQ,EAAE,EAAE;yCAAE;sCAAI,AACrC;;8BACK;;sBACF;;cACJ;0BACN,KAACpD,OAAO;gBACN0B,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdO,KAAK,EAAE,MAAM;wBACb4B,WAAW,EAAEnC,KAAK,CAACE,OAAO,CAACW,IAAI,CAAC,KAAK,CAAC;qBACvC,CAAA,AAAC;cACF;;MACE,CACN;AACJ,CAAC,CAAC,CAAC"}
@@ -3,7 +3,8 @@ export * from './SeriesInfo';
3
3
  export * from './SeriesLabelsStack';
4
4
  export * from './SeriesMarker';
5
5
  export * from './TooltipContent';
6
- export * from './focused-series';
6
+ export * from './TooltipHeader';
7
+ export * from './nearby-series';
7
8
  export * from './tooltip-model';
8
9
  export * from './utils';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
@@ -15,7 +15,8 @@ export * from './SeriesInfo';
15
15
  export * from './SeriesLabelsStack';
16
16
  export * from './SeriesMarker';
17
17
  export * from './TooltipContent';
18
- export * from './focused-series';
18
+ export * from './TooltipHeader';
19
+ export * from './nearby-series';
19
20
  export * from './tooltip-model';
20
21
  export * from './utils';
21
22
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeSeriesTooltip';\nexport * from './SeriesInfo';\nexport * from './SeriesLabelsStack';\nexport * from './SeriesMarker';\nexport * from './TooltipContent';\nexport * from './focused-series';\nexport * from './tooltip-model';\nexport * from './utils';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeSeriesTooltip';\nexport * from './SeriesInfo';\nexport * from './SeriesLabelsStack';\nexport * from './SeriesMarker';\nexport * from './TooltipContent';\nexport * from './TooltipHeader';\nexport * from './nearby-series';\nexport * from './tooltip-model';\nexport * from './utils';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { ECharts as EChartsInstance } from 'echarts/core';
2
+ import { UnitOptions, EChartsDataFormat } from '../model';
3
+ import { CursorCoordinates, CursorData } from './tooltip-model';
4
+ export declare const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5;
5
+ export declare const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30;
6
+ export declare const SHOW_FEWER_SERIES_LIMIT = 5;
7
+ export interface NearbySeriesInfo {
8
+ seriesIdx: number | null;
9
+ datumIdx: number | null;
10
+ seriesName: string;
11
+ date: number;
12
+ markerColor: string;
13
+ x: number;
14
+ y: number;
15
+ formattedY: string;
16
+ isClosestToCursor: boolean;
17
+ }
18
+ export declare type NearbySeriesArray = NearbySeriesInfo[];
19
+ /**
20
+ * Returns formatted series data for the points that are close to the user's cursor
21
+ * Adjust yBuffer to increase or decrease number of series shown
22
+ */
23
+ export declare function checkforNearbySeries(data: EChartsDataFormat, pointInGrid: number[], yBuffer: number, chart?: EChartsInstance, unit?: UnitOptions): NearbySeriesArray;
24
+ /**
25
+ * Uses mouse position to determine whether user is hovering over a chart canvas
26
+ * If yes, convert from pixel values to logical cartesian coordinates and return all nearby series
27
+ */
28
+ export declare function getNearbySeriesData({ mousePos, pinnedPos, chartData, chart, unit, showAllSeries, }: {
29
+ mousePos: CursorData['coords'];
30
+ pinnedPos: CursorCoordinates | null;
31
+ chartData: EChartsDataFormat;
32
+ chart?: EChartsInstance;
33
+ unit?: UnitOptions;
34
+ showAllSeries?: boolean;
35
+ }): NearbySeriesArray;
36
+ export declare function isWithinPercentageRange({ valueToCheck, baseValue, percentage, }: {
37
+ valueToCheck: number;
38
+ baseValue: number;
39
+ percentage: number;
40
+ }): boolean;
41
+ export declare function getYBuffer({ yInterval, totalSeries, showAllSeries, }: {
42
+ yInterval: number;
43
+ totalSeries: number;
44
+ showAllSeries?: boolean;
45
+ }): number;
46
+ //# sourceMappingURL=nearby-series.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nearby-series.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/nearby-series.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAe,WAAW,EAAE,iBAAiB,EAA+B,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGhE,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,eAAO,MAAM,gCAAgC,KAAK,CAAC;AACnD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,oBAAY,iBAAiB,GAAG,gBAAgB,EAAE,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,eAAe,EACvB,IAAI,CAAC,EAAE,WAAW,GACjB,iBAAiB,CAiGnB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,EACL,IAAI,EACJ,aAAqB,GACtB,EAAE;IACD,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC/B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,qBAkDA;AAKD,wBAAgB,uBAAuB,CAAC,EACtC,YAAY,EACZ,SAAS,EACT,UAAU,GACX,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAKV;AAKD,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,WAAW,EACX,aAAqB,GACtB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,UAgBA"}
@@ -0,0 +1,200 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { formatValue, OPTIMIZED_MODE_SERIES_LIMIT } from '../model';
14
+ // increase multipliers to show more series in tooltip
15
+ export const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show in tooltip (higher == more series shown)
16
+ export const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor
17
+ export const SHOW_FEWER_SERIES_LIMIT = 5;
18
+ /**
19
+ * Returns formatted series data for the points that are close to the user's cursor
20
+ * Adjust yBuffer to increase or decrease number of series shown
21
+ */ export function checkforNearbySeries(data, pointInGrid, yBuffer, chart, unit) {
22
+ const currentNearbySeriesData = [];
23
+ var ref;
24
+ const cursorX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
25
+ var ref1;
26
+ const cursorY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
27
+ if (cursorX === null || cursorY === null) {
28
+ return currentNearbySeriesData;
29
+ }
30
+ const nearbySeriesIndexes = [];
31
+ const emphasizedSeriesIndexes = [];
32
+ const nonEmphasizedSeriesIndexes = [];
33
+ const totalSeries = data.timeSeries.length;
34
+ if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
35
+ for(let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++){
36
+ const currentSeries = data.timeSeries[seriesIdx];
37
+ if (currentNearbySeriesData.length >= OPTIMIZED_MODE_SERIES_LIMIT) break;
38
+ if (currentSeries !== undefined) {
39
+ const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
40
+ var _color;
41
+ const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
42
+ if (Array.isArray(currentSeries.data)) {
43
+ for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
44
+ var _datumIdx;
45
+ const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
46
+ const yValue = currentSeries.data[datumIdx];
47
+ // ensure null values not displayed in tooltip
48
+ if (yValue !== undefined && yValue !== null && cursorX === datumIdx) {
49
+ if (yValue !== '-' && cursorY <= yValue + yBuffer && cursorY >= yValue - yBuffer) {
50
+ // show fewer bold series in tooltip when many total series
51
+ const minPercentRange = totalSeries > SHOW_FEWER_SERIES_LIMIT ? 2 : 5;
52
+ const percentRangeToCheck = Math.max(minPercentRange, 100 / totalSeries);
53
+ const isClosestToCursor = isWithinPercentageRange({
54
+ valueToCheck: cursorY,
55
+ baseValue: yValue,
56
+ percentage: percentRangeToCheck
57
+ });
58
+ if (isClosestToCursor) {
59
+ emphasizedSeriesIndexes.push(seriesIdx);
60
+ } else {
61
+ nonEmphasizedSeriesIndexes.push(seriesIdx);
62
+ // ensure series not close to cursor are not highlighted
63
+ if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
64
+ chart.dispatchAction({
65
+ type: 'downplay',
66
+ seriesIndex: seriesIdx
67
+ });
68
+ }
69
+ }
70
+ // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
71
+ const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
72
+ const formattedY = formatValue(yValue, unit);
73
+ currentNearbySeriesData.push({
74
+ seriesIdx: seriesIdx,
75
+ datumIdx: datumIdx,
76
+ seriesName: currentSeriesName,
77
+ date: xValueMilliSeconds,
78
+ x: xValue,
79
+ y: yValue,
80
+ formattedY: formattedY,
81
+ markerColor: markerColor.toString(),
82
+ isClosestToCursor
83
+ });
84
+ nearbySeriesIndexes.push(seriesIdx);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
93
+ // Clears emphasis state of all lines that are not emphasized.
94
+ // Emphasized is a subset of just the nearby series that are closest to cursor.
95
+ chart.dispatchAction({
96
+ type: 'downplay',
97
+ seriesIndex: nonEmphasizedSeriesIndexes
98
+ });
99
+ // https://echarts.apache.org/en/api.html#action.highlight
100
+ if (emphasizedSeriesIndexes.length > 0) {
101
+ // Fadeout opacity of all series not closest to cursor.
102
+ chart.dispatchAction({
103
+ type: 'highlight',
104
+ seriesIndex: emphasizedSeriesIndexes,
105
+ notBlur: false
106
+ });
107
+ } else {
108
+ // When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.
109
+ chart.dispatchAction({
110
+ type: 'highlight',
111
+ seriesIndex: nearbySeriesIndexes,
112
+ notBlur: true
113
+ });
114
+ }
115
+ }
116
+ return currentNearbySeriesData;
117
+ }
118
+ /**
119
+ * Uses mouse position to determine whether user is hovering over a chart canvas
120
+ * If yes, convert from pixel values to logical cartesian coordinates and return all nearby series
121
+ */ export function getNearbySeriesData({ mousePos , pinnedPos , chartData , chart , unit , showAllSeries =false }) {
122
+ if (chart === undefined || mousePos === null) return [];
123
+ // prevents multiple tooltips showing from adjacent charts unless tooltip is pinned
124
+ let cursorTargetMatchesChart = false;
125
+ if (mousePos.target !== null) {
126
+ const currentParent = mousePos.target.parentElement;
127
+ if (currentParent !== null) {
128
+ const currentGrandparent = currentParent.parentElement;
129
+ if (currentGrandparent !== null) {
130
+ const chartDom = chart.getDom();
131
+ if (chartDom === currentGrandparent) {
132
+ cursorTargetMatchesChart = true;
133
+ }
134
+ }
135
+ }
136
+ }
137
+ // allows moving cursor inside tooltip without it fading away
138
+ if (pinnedPos !== null) {
139
+ mousePos = pinnedPos;
140
+ cursorTargetMatchesChart = true;
141
+ }
142
+ if (cursorTargetMatchesChart === false) return [];
143
+ if (chart['_model'] === undefined) return [];
144
+ const chartModel = chart['_model'];
145
+ const yInterval = chartModel.getComponent('yAxis').axis.scale._interval;
146
+ const totalSeries = chartData.timeSeries.length;
147
+ const yBuffer = getYBuffer({
148
+ yInterval,
149
+ totalSeries,
150
+ showAllSeries
151
+ });
152
+ var _x, _y;
153
+ const pointInPixel = [
154
+ (_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
155
+ (_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
156
+ ];
157
+ if (chart.containPixel('grid', pointInPixel)) {
158
+ const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
159
+ if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
160
+ return checkforNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);
161
+ }
162
+ }
163
+ // clear all highlighted series when cursor exits canvas
164
+ // https://echarts.apache.org/en/api.html#action.downplay
165
+ for(let i = 0; i < totalSeries; i++){
166
+ if ((chart === null || chart === void 0 ? void 0 : chart.dispatchAction) !== undefined) {
167
+ chart.dispatchAction({
168
+ type: 'downplay',
169
+ seriesIndex: i
170
+ });
171
+ }
172
+ }
173
+ return [];
174
+ }
175
+ /*
176
+ * Check if two numbers are within a specified percentage range
177
+ */ export function isWithinPercentageRange({ valueToCheck , baseValue , percentage }) {
178
+ const range = percentage / 100 * baseValue;
179
+ const lowerBound = baseValue - range;
180
+ const upperBound = baseValue + range;
181
+ return valueToCheck >= lowerBound && valueToCheck <= upperBound;
182
+ }
183
+ /*
184
+ * Get range to check within for nearby series to show in tooltip.
185
+ */ export function getYBuffer({ yInterval , totalSeries , showAllSeries =false }) {
186
+ if (showAllSeries) {
187
+ return yInterval * 10; // roughly correlates with grid so entire canvas is searched
188
+ }
189
+ // never let nearby series range be less than roughly the size of a single tick
190
+ const yBufferMin = yInterval * 0.3;
191
+ // tooltip trigger area gets smaller with more series
192
+ if (totalSeries > SHOW_FEWER_SERIES_LIMIT) {
193
+ const adjustedBuffer = yInterval * DYNAMIC_NEARBY_SERIES_MULTIPLIER / totalSeries;
194
+ return Math.max(yBufferMin, adjustedBuffer);
195
+ }
196
+ // increase multiplier to expand nearby series range
197
+ return Math.max(yBufferMin, yInterval * INCREASE_NEARBY_SERIES_MULTIPLIER);
198
+ }
199
+
200
+ //# sourceMappingURL=nearby-series.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/nearby-series.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { formatValue, UnitOptions, EChartsDataFormat, OPTIMIZED_MODE_SERIES_LIMIT } from '../model';\nimport { CursorCoordinates, CursorData } from './tooltip-model';\n\n// increase multipliers to show more series in tooltip\nexport const INCREASE_NEARBY_SERIES_MULTIPLIER = 5.5; // adjusts how many series show in tooltip (higher == more series shown)\nexport const DYNAMIC_NEARBY_SERIES_MULTIPLIER = 30; // used for adjustment after series number divisor\nexport const SHOW_FEWER_SERIES_LIMIT = 5;\n\nexport interface NearbySeriesInfo {\n seriesIdx: number | null;\n datumIdx: number | null;\n seriesName: string;\n date: number;\n markerColor: string;\n x: number;\n y: number;\n formattedY: string;\n isClosestToCursor: boolean;\n}\n\nexport type NearbySeriesArray = NearbySeriesInfo[];\n\n/**\n * Returns formatted series data for the points that are close to the user's cursor\n * Adjust yBuffer to increase or decrease number of series shown\n */\nexport function checkforNearbySeries(\n data: EChartsDataFormat,\n pointInGrid: number[],\n yBuffer: number,\n chart?: EChartsInstance,\n unit?: UnitOptions\n): NearbySeriesArray {\n const currentNearbySeriesData: NearbySeriesArray = [];\n const cursorX: number | null = pointInGrid[0] ?? null;\n const cursorY: number | null = pointInGrid[1] ?? null;\n\n if (cursorX === null || cursorY === null) {\n return currentNearbySeriesData;\n }\n\n const nearbySeriesIndexes: number[] = [];\n const emphasizedSeriesIndexes: number[] = [];\n const nonEmphasizedSeriesIndexes: number[] = [];\n const totalSeries = data.timeSeries.length;\n if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {\n for (let seriesIdx = 0; seriesIdx < totalSeries; seriesIdx++) {\n const currentSeries = data.timeSeries[seriesIdx];\n if (currentNearbySeriesData.length >= OPTIMIZED_MODE_SERIES_LIMIT) break;\n if (currentSeries !== undefined) {\n const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';\n const markerColor = currentSeries.color ?? '#000';\n if (Array.isArray(currentSeries.data)) {\n for (let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++) {\n const xValue = data.xAxis[datumIdx] ?? 0;\n const yValue = currentSeries.data[datumIdx];\n // ensure null values not displayed in tooltip\n if (yValue !== undefined && yValue !== null && cursorX === datumIdx) {\n if (yValue !== '-' && cursorY <= yValue + yBuffer && cursorY >= yValue - yBuffer) {\n // show fewer bold series in tooltip when many total series\n const minPercentRange = totalSeries > SHOW_FEWER_SERIES_LIMIT ? 2 : 5;\n const percentRangeToCheck = Math.max(minPercentRange, 100 / totalSeries);\n const isClosestToCursor = isWithinPercentageRange({\n valueToCheck: cursorY,\n baseValue: yValue,\n percentage: percentRangeToCheck,\n });\n if (isClosestToCursor) {\n emphasizedSeriesIndexes.push(seriesIdx);\n } else {\n nonEmphasizedSeriesIndexes.push(seriesIdx);\n // ensure series not close to cursor are not highlighted\n if (chart?.dispatchAction !== undefined) {\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: seriesIdx,\n });\n }\n }\n\n // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201\n const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;\n const formattedY = formatValue(yValue, unit);\n currentNearbySeriesData.push({\n seriesIdx: seriesIdx,\n datumIdx: datumIdx,\n seriesName: currentSeriesName,\n date: xValueMilliSeconds,\n x: xValue,\n y: yValue,\n formattedY: formattedY,\n markerColor: markerColor.toString(),\n isClosestToCursor,\n });\n nearbySeriesIndexes.push(seriesIdx);\n }\n }\n }\n }\n }\n }\n }\n if (chart?.dispatchAction !== undefined) {\n // Clears emphasis state of all lines that are not emphasized.\n // Emphasized is a subset of just the nearby series that are closest to cursor.\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: nonEmphasizedSeriesIndexes,\n });\n\n // https://echarts.apache.org/en/api.html#action.highlight\n if (emphasizedSeriesIndexes.length > 0) {\n // Fadeout opacity of all series not closest to cursor.\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: emphasizedSeriesIndexes,\n notBlur: false,\n });\n } else {\n // When no emphasized series with bold text, notBlur allows opacity fadeout to not trigger.\n chart.dispatchAction({\n type: 'highlight',\n seriesIndex: nearbySeriesIndexes,\n notBlur: true,\n });\n }\n }\n\n return currentNearbySeriesData;\n}\n\n/**\n * Uses mouse position to determine whether user is hovering over a chart canvas\n * If yes, convert from pixel values to logical cartesian coordinates and return all nearby series\n */\nexport function getNearbySeriesData({\n mousePos,\n pinnedPos,\n chartData,\n chart,\n unit,\n showAllSeries = false,\n}: {\n mousePos: CursorData['coords'];\n pinnedPos: CursorCoordinates | null;\n chartData: EChartsDataFormat;\n chart?: EChartsInstance;\n unit?: UnitOptions;\n showAllSeries?: boolean;\n}) {\n if (chart === undefined || mousePos === null) return [];\n\n // prevents multiple tooltips showing from adjacent charts unless tooltip is pinned\n let cursorTargetMatchesChart = false;\n if (mousePos.target !== null) {\n const currentParent = (<HTMLElement>mousePos.target).parentElement;\n if (currentParent !== null) {\n const currentGrandparent = currentParent.parentElement;\n if (currentGrandparent !== null) {\n const chartDom = chart.getDom();\n if (chartDom === currentGrandparent) {\n cursorTargetMatchesChart = true;\n }\n }\n }\n }\n\n // allows moving cursor inside tooltip without it fading away\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n cursorTargetMatchesChart = true;\n }\n\n if (cursorTargetMatchesChart === false) return [];\n\n if (chart['_model'] === undefined) return [];\n const chartModel = chart['_model'];\n const yInterval = chartModel.getComponent('yAxis').axis.scale._interval;\n const totalSeries = chartData.timeSeries.length;\n const yBuffer = getYBuffer({ yInterval, totalSeries, showAllSeries });\n const pointInPixel = [mousePos.plotCanvas.x ?? 0, mousePos.plotCanvas.y ?? 0];\n if (chart.containPixel('grid', pointInPixel)) {\n const pointInGrid = chart.convertFromPixel('grid', pointInPixel);\n if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {\n return checkforNearbySeries(chartData, pointInGrid, yBuffer, chart, unit);\n }\n }\n\n // clear all highlighted series when cursor exits canvas\n // https://echarts.apache.org/en/api.html#action.downplay\n for (let i = 0; i < totalSeries; i++) {\n if (chart?.dispatchAction !== undefined) {\n chart.dispatchAction({\n type: 'downplay',\n seriesIndex: i,\n });\n }\n }\n return [];\n}\n\n/*\n * Check if two numbers are within a specified percentage range\n */\nexport function isWithinPercentageRange({\n valueToCheck,\n baseValue,\n percentage,\n}: {\n valueToCheck: number;\n baseValue: number;\n percentage: number;\n}): boolean {\n const range = (percentage / 100) * baseValue;\n const lowerBound = baseValue - range;\n const upperBound = baseValue + range;\n return valueToCheck >= lowerBound && valueToCheck <= upperBound;\n}\n\n/*\n * Get range to check within for nearby series to show in tooltip.\n */\nexport function getYBuffer({\n yInterval,\n totalSeries,\n showAllSeries = false,\n}: {\n yInterval: number;\n totalSeries: number;\n showAllSeries?: boolean;\n}) {\n if (showAllSeries) {\n return yInterval * 10; // roughly correlates with grid so entire canvas is searched\n }\n\n // never let nearby series range be less than roughly the size of a single tick\n const yBufferMin = yInterval * 0.3;\n\n // tooltip trigger area gets smaller with more series\n if (totalSeries > SHOW_FEWER_SERIES_LIMIT) {\n const adjustedBuffer = (yInterval * DYNAMIC_NEARBY_SERIES_MULTIPLIER) / totalSeries;\n return Math.max(yBufferMin, adjustedBuffer);\n }\n\n // increase multiplier to expand nearby series range\n return Math.max(yBufferMin, yInterval * INCREASE_NEARBY_SERIES_MULTIPLIER);\n}\n"],"names":["formatValue","OPTIMIZED_MODE_SERIES_LIMIT","INCREASE_NEARBY_SERIES_MULTIPLIER","DYNAMIC_NEARBY_SERIES_MULTIPLIER","SHOW_FEWER_SERIES_LIMIT","checkforNearbySeries","data","pointInGrid","yBuffer","chart","unit","currentNearbySeriesData","cursorX","cursorY","nearbySeriesIndexes","emphasizedSeriesIndexes","nonEmphasizedSeriesIndexes","totalSeries","timeSeries","length","Array","isArray","xAxis","seriesIdx","currentSeries","undefined","currentSeriesName","name","toString","markerColor","color","datumIdx","xValue","yValue","minPercentRange","percentRangeToCheck","Math","max","isClosestToCursor","isWithinPercentageRange","valueToCheck","baseValue","percentage","push","dispatchAction","type","seriesIndex","xValueMilliSeconds","formattedY","seriesName","date","x","y","notBlur","getNearbySeriesData","mousePos","pinnedPos","chartData","showAllSeries","cursorTargetMatchesChart","target","currentParent","parentElement","currentGrandparent","chartDom","getDom","chartModel","yInterval","getComponent","axis","scale","_interval","getYBuffer","pointInPixel","plotCanvas","containPixel","convertFromPixel","i","range","lowerBound","upperBound","yBufferMin","adjustedBuffer"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,WAAW,EAAkCC,2BAA2B,QAAQ,UAAU,CAAC;AAGpG,sDAAsD;AACtD,OAAO,MAAMC,iCAAiC,GAAG,GAAG,CAAC,CAAC,wEAAwE;AAC9H,OAAO,MAAMC,gCAAgC,GAAG,EAAE,CAAC,CAAC,kDAAkD;AACtG,OAAO,MAAMC,uBAAuB,GAAG,CAAC,CAAC;AAgBzC;;;CAGC,GACD,OAAO,SAASC,oBAAoB,CAClCC,IAAuB,EACvBC,WAAqB,EACrBC,OAAe,EACfC,KAAuB,EACvBC,IAAkB,EACC;IACnB,MAAMC,uBAAuB,GAAsB,EAAE,AAAC;QACvBJ,GAAc;IAA7C,MAAMK,OAAO,GAAkBL,CAAAA,GAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,GAAc,cAAdA,GAAc,GAAI,IAAI,AAAC;QACvBA,IAAc;IAA7C,MAAMM,OAAO,GAAkBN,CAAAA,IAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,IAAc,cAAdA,IAAc,GAAI,IAAI,AAAC;IAEtD,IAAIK,OAAO,KAAK,IAAI,IAAIC,OAAO,K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C,SAAS,CAAA,EACTC,UAAU,CAAA,EAKX,EAAW;IACV,MAAMoC,KAAK,GAAG,AAACpC,UAAU,GAAG,GAAG,GAAID,SAAS,AAAC;IAC7C,MAAMsC,UAAU,GAAGtC,SAAS,GAAGqC,KAAK,AAAC;IACrC,MAAME,UAAU,GAAGvC,SAAS,GAAGqC,KAAK,AAAC;IACrC,OAAOtC,YAAY,IAAIuC,UAAU,IAAIvC,YAAY,IAAIwC,UAAU,CAAC;AAClE,CAAC;AAED;;CAEC,GACD,OAAO,SAASR,UAAU,CAAC,EACzBL,SAAS,CAAA,EACTlD,WAAW,CAAA,EACXyC,aAAa,EAAG,KAAK,CAAA,EAKtB,EAAE;IACD,IAAIA,aAAa,EAAE;QACjB,OAAOS,SAAS,GAAG,EAAE,CAAC,CAAC,4DAA4D;IACrF,CAAC;IAED,+EAA+E;IAC/E,MAAMc,UAAU,GAAGd,SAAS,GAAG,GAAG,AAAC;IAEnC,qDAAqD;IACrD,IAAIlD,WAAW,GAAGb,uBAAuB,EAAE;QACzC,MAAM8E,cAAc,GAAG,AAACf,SAAS,GAAGhE,gCAAgC,GAAIc,WAAW,AAAC;QACpF,OAAOmB,IAAI,CAACC,GAAG,CAAC4C,UAAU,EAAEC,cAAc,CAAC,CAAC;IAC9C,CAAC;IAED,oDAAoD;IACpD,OAAO9C,IAAI,CAACC,GAAG,CAAC4C,UAAU,EAAEd,SAAS,GAAGjE,iCAAiC,CAAC,CAAC;AAC7E,CAAC"}
@@ -1,8 +1,13 @@
1
- import { FocusedSeriesArray } from './focused-series';
1
+ import { NearbySeriesArray } from './nearby-series';
2
+ export declare const TOOLTIP_MIN_WIDTH = 375;
2
3
  export declare const TOOLTIP_MAX_WIDTH = 650;
3
- export declare const TOOLTIP_MAX_HEIGHT = 400;
4
+ export declare const TOOLTIP_MAX_HEIGHT = 650;
4
5
  export declare const TOOLTIP_LABELS_MAX_WIDTH: number;
5
- export declare const TOOLTIP_MAX_ITEMS = 50;
6
+ export declare const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;
7
+ export declare const FALLBACK_CHART_WIDTH = 750;
8
+ export declare const NEARBY_SERIES_DESCRIPTION = "nearby series showing in tooltip";
9
+ export declare const EMPHASIZED_SERIES_DESCRIPTION = "emphasized series showing as bold in tooltip";
10
+ export declare const TOOLTIP_BG_COLOR_FALLBACK = "#2E313E";
6
11
  export declare const TOOLTIP_DATE_FORMAT: Intl.DateTimeFormat;
7
12
  export declare const defaultCursorData: {
8
13
  coords: {
@@ -35,20 +40,15 @@ export declare const emptyTooltipData: {
35
40
  };
36
41
  focusedSeries: null;
37
42
  };
43
+ export interface Coordinate {
44
+ x: number;
45
+ y: number;
46
+ }
38
47
  export interface CursorCoordinates {
39
- page: {
40
- x: number;
41
- y: number;
42
- };
43
- client: {
44
- x: number;
45
- y: number;
46
- };
47
- plotCanvas: {
48
- x: number;
49
- y: number;
50
- };
51
- zrender: {
48
+ page: Coordinate;
49
+ client: Coordinate;
50
+ plotCanvas: Coordinate;
51
+ zrender?: {
52
52
  x?: number;
53
53
  y?: number;
54
54
  };
@@ -59,7 +59,7 @@ export interface CursorData {
59
59
  chartWidth?: number;
60
60
  }
61
61
  export interface TooltipData {
62
- focusedSeries: FocusedSeriesArray | null;
62
+ focusedSeries: NearbySeriesArray | null;
63
63
  cursor: CursorData;
64
64
  }
65
65
  declare type ZREventProperties = {