@perses-dev/components 0.30.0 → 0.31.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 (150) hide show
  1. package/dist/Legend/CompactLegend.d.ts +6 -4
  2. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  3. package/dist/Legend/CompactLegend.js +4 -1
  4. package/dist/Legend/CompactLegend.js.map +1 -1
  5. package/dist/Legend/Legend.d.ts +11 -9
  6. package/dist/Legend/Legend.d.ts.map +1 -1
  7. package/dist/Legend/Legend.js +45 -11
  8. package/dist/Legend/Legend.js.map +1 -1
  9. package/dist/Legend/ListLegend.d.ts +5 -8
  10. package/dist/Legend/ListLegend.d.ts.map +1 -1
  11. package/dist/Legend/ListLegend.js +34 -99
  12. package/dist/Legend/ListLegend.js.map +1 -1
  13. package/dist/Legend/ListLegendItem.d.ts +8 -8
  14. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  15. package/dist/Legend/ListLegendItem.js +9 -12
  16. package/dist/Legend/ListLegendItem.js.map +1 -1
  17. package/dist/LineChart/LineChart.d.ts +2 -1
  18. package/dist/LineChart/LineChart.d.ts.map +1 -1
  19. package/dist/LineChart/LineChart.js +31 -22
  20. package/dist/LineChart/LineChart.js.map +1 -1
  21. package/dist/Table/InnerTable.d.ts +9 -0
  22. package/dist/Table/InnerTable.d.ts.map +1 -0
  23. package/dist/Table/InnerTable.js +38 -0
  24. package/dist/Table/InnerTable.js.map +1 -0
  25. package/dist/Table/Table.d.ts +10 -0
  26. package/dist/Table/Table.d.ts.map +1 -0
  27. package/dist/Table/Table.js +101 -0
  28. package/dist/Table/Table.js.map +1 -0
  29. package/dist/Table/TableBody.d.ts +6 -0
  30. package/dist/Table/TableBody.d.ts.map +1 -0
  31. package/dist/Table/TableBody.js +23 -0
  32. package/dist/Table/TableBody.js.map +1 -0
  33. package/dist/Table/TableCell.d.ts +18 -0
  34. package/dist/Table/TableCell.d.ts.map +1 -0
  35. package/dist/Table/TableCell.js +91 -0
  36. package/dist/Table/TableCell.js.map +1 -0
  37. package/dist/Table/TableCheckbox.d.ts +9 -0
  38. package/dist/Table/TableCheckbox.d.ts.map +1 -0
  39. package/dist/Table/TableCheckbox.js +49 -0
  40. package/dist/Table/TableCheckbox.js.map +1 -0
  41. package/dist/Table/TableHead.d.ts +6 -0
  42. package/dist/Table/TableHead.d.ts.map +1 -0
  43. package/dist/Table/TableHead.js +23 -0
  44. package/dist/Table/TableHead.js.map +1 -0
  45. package/dist/Table/TableRow.d.ts +9 -0
  46. package/dist/Table/TableRow.d.ts.map +1 -0
  47. package/dist/Table/TableRow.js +29 -0
  48. package/dist/Table/TableRow.js.map +1 -0
  49. package/dist/Table/VirtualizedTable.d.ts +11 -0
  50. package/dist/Table/VirtualizedTable.d.ts.map +1 -0
  51. package/dist/Table/VirtualizedTable.js +152 -0
  52. package/dist/Table/VirtualizedTable.js.map +1 -0
  53. package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
  54. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
  55. package/dist/Table/VirtualizedTableContainer.js +24 -0
  56. package/dist/Table/VirtualizedTableContainer.js.map +1 -0
  57. package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
  58. package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
  59. package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
  60. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
  61. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
  62. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
  63. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
  64. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
  65. package/dist/Table/index.d.ts +4 -0
  66. package/dist/Table/index.d.ts.map +1 -0
  67. package/dist/Table/index.js +16 -0
  68. package/dist/Table/index.js.map +1 -0
  69. package/dist/Table/model/table-model.d.ts +83 -0
  70. package/dist/Table/model/table-model.d.ts.map +1 -0
  71. package/dist/Table/model/table-model.js +73 -0
  72. package/dist/Table/model/table-model.js.map +1 -0
  73. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
  74. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
  75. package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
  76. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  77. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +2 -1
  78. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
  79. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +60 -15
  80. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
  81. package/dist/TimeSeriesTooltip/TooltipContent.d.ts +5 -3
  82. package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
  83. package/dist/TimeSeriesTooltip/TooltipContent.js +79 -42
  84. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  85. package/dist/TimeSeriesTooltip/index.d.ts +1 -1
  86. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  87. package/dist/TimeSeriesTooltip/index.js +1 -1
  88. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  89. package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
  90. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
  91. package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
  92. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
  93. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +8 -4
  94. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  95. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -2
  96. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  97. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  98. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  99. package/dist/TimeSeriesTooltip/utils.js +4 -3
  100. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  101. package/dist/cjs/Legend/CompactLegend.js +4 -1
  102. package/dist/cjs/Legend/Legend.js +45 -11
  103. package/dist/cjs/Legend/ListLegend.js +33 -98
  104. package/dist/cjs/Legend/ListLegendItem.js +8 -11
  105. package/dist/cjs/LineChart/LineChart.js +31 -22
  106. package/dist/cjs/Table/InnerTable.js +44 -0
  107. package/dist/cjs/Table/Table.js +102 -0
  108. package/dist/cjs/Table/TableBody.js +29 -0
  109. package/dist/cjs/Table/TableCell.js +97 -0
  110. package/dist/cjs/Table/TableCheckbox.js +55 -0
  111. package/dist/cjs/Table/TableHead.js +29 -0
  112. package/dist/cjs/Table/TableRow.js +35 -0
  113. package/dist/cjs/Table/VirtualizedTable.js +155 -0
  114. package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
  115. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
  116. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
  117. package/dist/cjs/Table/index.js +33 -0
  118. package/dist/cjs/Table/model/table-model.js +80 -0
  119. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
  120. package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +57 -12
  121. package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +83 -41
  122. package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
  123. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
  124. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +11 -3
  125. package/dist/cjs/TimeSeriesTooltip/utils.js +3 -2
  126. package/dist/cjs/context/SnackbarProvider.js +66 -0
  127. package/dist/cjs/index.js +2 -0
  128. package/dist/cjs/model/legend.js +7 -1
  129. package/dist/cjs/theme/palette/grey.js +6 -2
  130. package/dist/context/SnackbarProvider.d.ts +23 -0
  131. package/dist/context/SnackbarProvider.d.ts.map +1 -0
  132. package/dist/context/SnackbarProvider.js +59 -0
  133. package/dist/context/SnackbarProvider.js.map +1 -0
  134. package/dist/index.d.ts +2 -0
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +2 -0
  137. package/dist/index.js.map +1 -1
  138. package/dist/model/legend.d.ts +10 -2
  139. package/dist/model/legend.d.ts.map +1 -1
  140. package/dist/model/legend.js +5 -0
  141. package/dist/model/legend.js.map +1 -1
  142. package/dist/theme/palette/grey.d.ts.map +1 -1
  143. package/dist/theme/palette/grey.js +6 -2
  144. package/dist/theme/palette/grey.js.map +1 -1
  145. package/package.json +6 -6
  146. package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
  147. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
  148. package/dist/TimeSeriesTooltip/focused-series.js +0 -110
  149. package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
  150. package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -116
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeSeriesTooltip.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, Portal } from '@mui/material';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport React, { useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { EChartsDataFormat, UnitOptions } from '../model';\nimport { TooltipContent } from './TooltipContent';\nimport { getFocusedSeriesData } from './focused-series';\nimport { CursorCoordinates, TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, useMousePosition } from './tooltip-model';\nimport { assembleTransform } from './utils';\n\ninterface TimeSeriesTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n chartData: EChartsDataFormat;\n pinTooltip: boolean;\n wrapLabels?: boolean;\n unit?: UnitOptions;\n}\n\nexport const TimeSeriesTooltip = React.memo(function TimeSeriesTooltip({\n chartRef,\n chartData,\n wrapLabels,\n pinTooltip,\n unit,\n}: TimeSeriesTooltipProps) {\n const [pinnedPos, setPinnedPos] = useState<CursorCoordinates | null>(null);\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n\n if (mousePos === null || mousePos.target === null) return null;\n\n // ensure user is hovering over a chart before checking for nearby series\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const focusedSeries = getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit);\n const chartWidth = chart?.getWidth() ?? 750;\n const cursorTransform = assembleTransform(\n mousePos,\n focusedSeries.length,\n chartWidth,\n pinnedPos,\n height ?? 0,\n width ?? 0\n );\n\n if (focusedSeries.length === 0) {\n return null;\n }\n\n if (pinTooltip === true && pinnedPos === null) {\n setPinnedPos(mousePos);\n }\n\n return (\n <Portal>\n <Box\n ref={tooltipRef}\n sx={(theme) => ({\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: TOOLTIP_MAX_HEIGHT,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: '#2E313E', // TODO: use colors from theme, separate styles for dark mode\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n zIndex: theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n })}\n style={{\n transform: cursorTransform,\n }}\n >\n <TooltipContent focusedSeries={focusedSeries} wrapLabels={wrapLabels} />\n </Box>\n </Portal>\n );\n});\n"],"names":["Box","Portal","React","useState","useResizeObserver","TooltipContent","getFocusedSeriesData","TOOLTIP_MAX_HEIGHT","TOOLTIP_MAX_WIDTH","useMousePosition","assembleTransform","TimeSeriesTooltip","memo","chartRef","chartData","wrapLabels","pinTooltip","unit","pinnedPos","setPinnedPos","mousePos","height","width","ref","tooltipRef","target","tagName","chart","current","focusedSeries","chartWidth","getWidth","cursorTransform","length","sx","theme","maxWidth","maxHeight","position","top","left","backgroundColor","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY","style","transform"],"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,MAAM,QAAQ,eAAe,CAAC;AAE5C,OAAOC,KAAK,IAAIC,QAAQ,QAAQ,OAAO,CAAC;AACxC,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAClD,SAASC,oBAAoB,QAAQ,kBAAkB,CAAC;AACxD,SAA4BC,kBAAkB,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,iBAAiB,CAAC;AAC7G,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAU5C,OAAO,MAAMC,iBAAiB,iBAAGT,KAAK,CAACU,IAAI,CAAC,SAASD,iBAAiB,CAAC,EACrEE,QAAQ,CAAA,EACRC,SAAS,CAAA,EACTC,UAAU,CAAA,EACVC,UAAU,CAAA,EACVC,IAAI,CAAA,EACmB,EAAE;IACzB,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGhB,QAAQ,CAA2B,IAAI,CAAC,AAAC;IAC3E,MAAMiB,QAAQ,GAAGX,gBAAgB,EAAE,AAAC;IACpC,MAAM,EAAEY,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAEC,GAAG,EAAEC,UAAU,CAAA,EAAE,GAAGpB,iBAA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GAAG,EAAE,CAAC;oBACNC,IAAI,EAAE,CAAC;oBACPC,eAAe,EAAE,SAAS;oBAC1BC,YAAY,EAAE,KAAK;oBACnBC,KAAK,EAAE,MAAM;oBACbC,QAAQ,EAAE,MAAM;oBAChBC,UAAU,EAAE,SAAS;oBACrBC,OAAO,EAAE,CAAC;oBACVC,UAAU,EAAE,mBAAmB;oBAC/BC,MAAM,EAAEb,KAAK,CAACa,MAAM,CAACC,OAAO;oBAC5BC,QAAQ,EAAE,QAAQ;oBAClB,SAAS,EAAE;wBACTC,SAAS,EAAE,MAAM;qBAClB;iBACF,CAAA,AAAC;YACFC,KAAK,EAAE;gBACLC,SAAS,EAAErB,eAAe;aAC3B;sBAED,cAAA,KAAC3B,cAAc;gBAACwB,aAAa,EAAEA,aAAa;gBAAEd,UAAU,EAAEA,UAAU;cAAI;UACpE;MACC,CACT;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeSeriesTooltip.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, Portal, Typography, Stack, Switch } from '@mui/material';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport React, { useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { EChartsDataFormat, UnitOptions } from '../model';\nimport { TooltipContent } from './TooltipContent';\nimport { getNearbySeriesData } from './nearby-series';\nimport {\n CursorCoordinates,\n FALLBACK_CHART_WIDTH,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MIN_WIDTH,\n TOOLTIP_MAX_WIDTH,\n useMousePosition,\n} from './tooltip-model';\nimport { assembleTransform } from './utils';\n\ninterface TimeSeriesTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n chartData: EChartsDataFormat;\n isTooltipPinned: boolean;\n wrapLabels?: boolean;\n unit?: UnitOptions;\n onUnpinClick?: () => void;\n}\n\nexport const TimeSeriesTooltip = React.memo(function TimeSeriesTooltip({\n chartRef,\n chartData,\n wrapLabels,\n isTooltipPinned,\n unit,\n onUnpinClick,\n}: TimeSeriesTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const [pinnedPos, setPinnedPos] = useState<CursorCoordinates | null>(null);\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n\n if (mousePos === null || mousePos.target === null) return null;\n\n // Ensure user is hovering over a chart before checking for nearby series.\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const chartWidth = chart?.getWidth() ?? FALLBACK_CHART_WIDTH; // Fallback width not likely to every be needed.\n const cursorTransform = assembleTransform(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0);\n\n // Get series nearby the cursor and pass into tooltip content children.\n const focusedSeries = getNearbySeriesData({\n mousePos,\n chartData,\n pinnedPos,\n chart,\n unit,\n showAllSeries,\n });\n if (focusedSeries.length === 0) {\n return null;\n }\n\n if (isTooltipPinned === true && pinnedPos === null) {\n setPinnedPos(mousePos);\n }\n\n // Option for user to see all series instead of only the nearby focused series.\n // Only relevant when there are more total series than are visible.\n const showAllSeriesToggle =\n isTooltipPinned === true &&\n showAllSeries === false &&\n chartData.timeSeries.length > 1 &&\n focusedSeries.length !== chartData.timeSeries.length;\n\n return (\n <Portal>\n <Box\n ref={tooltipRef}\n sx={(theme) => ({\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: TOOLTIP_MAX_HEIGHT,\n padding: theme.spacing(0.5, 2),\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: '#2E313E', // TODO: use colors from theme, separate styles for dark mode\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n zIndex: theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n })}\n style={{\n transform: cursorTransform,\n }}\n >\n <TooltipContent\n series={focusedSeries}\n wrapLabels={wrapLabels}\n isTooltipPinned={isTooltipPinned}\n onUnpinClick={() => {\n setPinnedPos(null);\n if (onUnpinClick !== undefined) {\n onUnpinClick();\n }\n }}\n />\n {showAllSeriesToggle && (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" sx={{ textAlign: 'right' }}>\n <Typography>Show All?</Typography>\n <Switch\n checked={showAllSeries}\n onChange={(_, checked) => setShowAllSeries(checked)}\n sx={(theme) => ({\n '& .MuiSwitch-switchBase': {\n color: theme.palette.common.white,\n },\n })}\n />\n </Stack>\n )}\n </Box>\n </Portal>\n );\n});\n"],"names":["Box","Portal","Typography","Stack","Switch","React","useState","useResizeObserver","TooltipContent","getNearbySeriesData","FALLBACK_CHART_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_MIN_WIDTH","TOOLTIP_MAX_WIDTH","useMousePosition","assembleTransform","TimeSeriesTooltip","memo","chartRef","chartData","wrapLabels","isTooltipPinned","unit","onUnpinClick","showAllSeries","setShowAllSeries","pinnedPos","setPinnedPos","mousePos","height","width","ref","tooltipRef","target","tagName","chart","current","chartWidth","getWidth","cursorTransform","focusedSeries","length","showAllSeriesToggle","timeSeries","sx","theme","minWidth","maxWidth","maxHeight","padding","spacing","position","top","left","backgroundColor","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY","style","transform","series","undefined","direction","gap","alignItems","textAlign","checked","onChange","_","palette","common","white"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6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nD7B,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;oCACd,yBAAyB,EAAE;wCACzBW,KAAK,EAAEX,KAAK,CAAC+B,OAAO,CAACC,MAAM,CAACC,KAAK;qCAClC;iCACF,CAAA,AAAC;0BACF;;kBACI,AACT;;UACG;MACC,CACT;AACJ,CAAC,CAAC,CAAC"}
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { FocusedSeriesArray } from './focused-series';
2
+ import { NearbySeriesArray } from './nearby-series';
3
3
  export interface TooltipContentProps {
4
- focusedSeries: FocusedSeriesArray | null;
4
+ series: NearbySeriesArray | null;
5
+ isTooltipPinned: boolean;
5
6
  wrapLabels?: boolean;
7
+ onUnpinClick: () => void;
6
8
  }
7
- export declare function TooltipContent(props: TooltipContentProps): JSX.Element;
9
+ export declare function TooltipContent(props: TooltipContentProps): JSX.Element | null;
8
10
  //# sourceMappingURL=TooltipContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAqExD"}
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,sBAyFxD"}
@@ -10,20 +10,22 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useMemo } from 'react';
15
+ import PinOutline from 'mdi-material-ui/PinOutline';
16
+ import Pin from 'mdi-material-ui/Pin';
15
17
  import { Box, Divider, Stack, Typography } from '@mui/material';
16
18
  import { useTimeZone } from '../context/TimeZoneProvider';
17
19
  import { SeriesInfo } from './SeriesInfo';
18
20
  export function TooltipContent(props) {
19
- const { focusedSeries , wrapLabels } = props;
21
+ const { series , wrapLabels , isTooltipPinned , onUnpinClick } = props;
20
22
  const { formatWithUserTimeZone } = useTimeZone();
21
- const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;
23
+ const seriesTime = series && series[0] && series[0].date ? series[0].date : null;
22
24
  const formatTimeSeriesHeader = (timeMs)=>{
23
25
  const date = new Date(timeMs);
24
26
  const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');
25
27
  const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');
26
- return /*#__PURE__*/ _jsxs(_Fragment, {
28
+ return /*#__PURE__*/ _jsxs(Box, {
27
29
  children: [
28
30
  /*#__PURE__*/ _jsx(Typography, {
29
31
  variant: "caption",
@@ -42,48 +44,83 @@ export function TooltipContent(props) {
42
44
  });
43
45
  };
44
46
  const sortedFocusedSeries = useMemo(()=>{
45
- if (focusedSeries === null) return null;
46
- return focusedSeries.sort((a, b)=>a.y > b.y ? -1 : 1);
47
+ if (series === null) return null;
48
+ return series.sort((a, b)=>a.y > b.y ? -1 : 1);
47
49
  }, [
48
- focusedSeries
50
+ series
49
51
  ]);
50
- if (sortedFocusedSeries !== null && seriesTime !== null) {
51
- return /*#__PURE__*/ _jsxs(Stack, {
52
- py: 1,
53
- px: 1.5,
54
- spacing: 0.5,
55
- children: [
56
- /*#__PURE__*/ _jsx(Typography, {
57
- variant: "caption",
58
- children: formatTimeSeriesHeader(seriesTime)
59
- }),
60
- /*#__PURE__*/ _jsx(Divider, {
61
- sx: (theme)=>({
62
- borderColor: theme.palette.grey['500']
63
- })
64
- }),
65
- /*#__PURE__*/ _jsx(Box, {
66
- sx: {
67
- display: 'table'
68
- },
69
- children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor })=>{
70
- if (datumIdx === null || seriesIdx === null) return null;
71
- const key = seriesIdx.toString() + datumIdx.toString();
72
- return /*#__PURE__*/ _jsx(SeriesInfo, {
73
- seriesName: seriesName,
74
- y: y,
75
- formattedY: formattedY,
76
- markerColor: markerColor,
77
- totalSeries: sortedFocusedSeries.length,
78
- wrapLabels: wrapLabels
79
- }, key);
52
+ if (sortedFocusedSeries === null || seriesTime === null) {
53
+ return null;
54
+ }
55
+ // TODO: use react-virtuoso to improve performance
56
+ return /*#__PURE__*/ _jsxs(Stack, {
57
+ py: 1,
58
+ spacing: 0.5,
59
+ children: [
60
+ /*#__PURE__*/ _jsxs(Box, {
61
+ sx: {
62
+ display: 'flex',
63
+ justifyContent: 'start',
64
+ alignItems: 'center'
65
+ },
66
+ children: [
67
+ formatTimeSeriesHeader(seriesTime),
68
+ /*#__PURE__*/ _jsxs(Stack, {
69
+ direction: "row",
70
+ gap: 1,
71
+ sx: {
72
+ marginLeft: 'auto'
73
+ },
74
+ children: [
75
+ /*#__PURE__*/ _jsxs(Typography, {
76
+ sx: {
77
+ fontSize: 11
78
+ },
79
+ children: [
80
+ "Click to ",
81
+ isTooltipPinned ? 'Unpin' : 'Pin'
82
+ ]
83
+ }),
84
+ isTooltipPinned ? /*#__PURE__*/ _jsx(Pin, {
85
+ onClick: onUnpinClick,
86
+ sx: {
87
+ fontSize: 16,
88
+ cursor: 'pointer'
89
+ }
90
+ }) : /*#__PURE__*/ _jsx(PinOutline, {
91
+ sx: {
92
+ fontSize: 16
93
+ }
94
+ })
95
+ ]
96
+ })
97
+ ]
98
+ }),
99
+ /*#__PURE__*/ _jsx(Divider, {
100
+ sx: (theme)=>({
101
+ borderColor: theme.palette.grey['500']
80
102
  })
103
+ }),
104
+ /*#__PURE__*/ _jsx(Box, {
105
+ sx: {
106
+ display: 'table'
107
+ },
108
+ children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor , isClosestToCursor })=>{
109
+ if (datumIdx === null || seriesIdx === null) return null;
110
+ const key = seriesIdx.toString() + datumIdx.toString();
111
+ return /*#__PURE__*/ _jsx(SeriesInfo, {
112
+ seriesName: seriesName,
113
+ y: y,
114
+ formattedY: formattedY,
115
+ markerColor: markerColor,
116
+ totalSeries: sortedFocusedSeries.length,
117
+ wrapLabels: wrapLabels,
118
+ emphasizeText: isClosestToCursor
119
+ }, key);
81
120
  })
82
- ]
83
- });
84
- } else {
85
- return /*#__PURE__*/ _jsx(_Fragment, {});
86
- }
121
+ })
122
+ ]
123
+ });
87
124
  }
88
125
 
89
126
  //# sourceMappingURL=TooltipContent.js.map
@@ -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,UAAU;oBACTe,OAAO,EAAC,SAAS;oBACjBC,EA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,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 PinOutline from 'mdi-material-ui/PinOutline';\nimport Pin from 'mdi-material-ui/Pin';\nimport { Box, Divider, Stack, Typography } from '@mui/material';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { NearbySeriesArray } from './nearby-series';\nimport { SeriesInfo } from './SeriesInfo';\n\nexport interface TooltipContentProps {\n series: NearbySeriesArray | null;\n isTooltipPinned: boolean;\n wrapLabels?: boolean;\n onUnpinClick: () => void;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { series, wrapLabels, isTooltipPinned, onUnpinClick } = props;\n const { formatWithUserTimeZone } = useTimeZone();\n\n const seriesTime = series && series[0] && series[0].date ? series[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 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 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 (sortedFocusedSeries === null || seriesTime === null) {\n return null;\n }\n\n // TODO: use react-virtuoso to improve performance\n return (\n <Stack py={1} spacing={0.5}>\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n }}\n >\n {formatTimeSeriesHeader(seriesTime)}\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }}>\n <Typography sx={{ fontSize: 11 }}>Click to {isTooltipPinned ? 'Unpin' : 'Pin'}</Typography>\n {isTooltipPinned ? (\n <Pin onClick={onUnpinClick} sx={{ fontSize: 16, cursor: 'pointer' }} />\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n </Box>\n\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(\n ({ 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 )}\n </Box>\n </Stack>\n );\n}\n"],"names":["useMemo","PinOutline","Pin","Box","Divider","Stack","Typography","useTimeZone","SeriesInfo","TooltipContent","props","series","wrapLabels","isTooltipPinned","onUnpinClick","formatWithUserTimeZone","seriesTime","date","formatTimeSeriesHeader","timeMs","Date","formattedDate","formattedTime","variant","sx","theme","color","palette","common","white","strong","sortedFocusedSeries","sort","a","b","y","py","spacing","display","justifyContent","alignItems","direction","gap","marginLeft","fontSize","onClick","cursor","borderColor","grey","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,OAAOC,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAOC,GAAG,MAAM,qBAAqB,CAAC;AACtC,SAASC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChE,SAASC,WAAW,QAAQ,6BAA6B,CAAC;AAE1D,SAASC,UAAU,QAAQ,cAAc,CAAC;AAS1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,MAAM,CAAA,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGJ,KAAK,AAAC;IACpE,MAAM,EAAEK,sBAAsB,CAAA,EAAE,GAAGR,WAAW,EAAE,AAAC;IAEjD,MAAMS,UAAU,GAAGL,MAAM,IAAIA,MAAM,CAAC,CAAC,CAAC,IAAIA,MAAM,CAAC,CAAC,CAAC,CAACM,IAAI,GAAGN,MAAM,CAAC,CAAC,CAAC,CAACM,IAAI,GAAG,IAAI,A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ACtBjB,CAAC,EAAEA,CAAC;wBACJkB,UAAU,EAAEA,UAAU;wBACtBC,WAAW,EAAEA,WAAW;wBACxBI,WAAW,EAAE3B,mBAAmB,CAAC4B,MAAM;wBACvC/C,UAAU,EAAEA,UAAU;wBACtBgD,aAAa,EAAEL,iBAAiB;uBAP3BC,GAAG,CAQR,CACF;gBACJ,CAAC,CACF;cACG;;MACA,CACR;AACJ,CAAC"}
@@ -3,7 +3,7 @@ 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 './nearby-series';
7
7
  export * from './tooltip-model';
8
8
  export * from './utils';
9
9
  //# 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,SAAS,CAAC"}
@@ -15,7 +15,7 @@ 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 './nearby-series';
19
19
  export * from './tooltip-model';
20
20
  export * from './utils';
21
21
 
@@ -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 './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,SAAS,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { ECharts as EChartsInstance } from 'echarts/core';
2
+ import { UnitOptions, EChartsDataFormat } from '../model';
3
+ import { 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: CursorData['coords'];
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,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,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,UAAU,CAAC,QAAQ,CAAC,CAAC;IAChC,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
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
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 { 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: CursorData['coords'];\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\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\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;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BC,WAAW,EAAE+B,CAAC;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;CAEC,GACD,OAAO,SAAStC,uBAAuB,CAAC,EACtCC,YAAY,CAAA,EACZC,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,12 @@
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 = 600;
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";
6
10
  export declare const TOOLTIP_DATE_FORMAT: Intl.DateTimeFormat;
7
11
  export declare const defaultCursorData: {
8
12
  coords: {
@@ -59,7 +63,7 @@ export interface CursorData {
59
63
  chartWidth?: number;
60
64
  }
61
65
  export interface TooltipData {
62
- focusedSeries: FocusedSeriesArray | null;
66
+ focusedSeries: NearbySeriesArray | null;
63
67
  cursor: CursorData;
64
68
  }
65
69
  declare type ZREventProperties = {