UNPKG

@grafana/ui

Version:
1 lines 2.7 kB
{"version":3,"file":"MultiModeGraphTooltip.mjs","sources":["../../../../../src/graveyard/Graph/GraphTooltip/MultiModeGraphTooltip.tsx"],"sourcesContent":["import { getValueFromDimension } from '@grafana/data';\n\nimport { SeriesTable } from '../../../components/VizTooltip';\nimport { FlotPosition } from '../../../components/VizTooltip/VizTooltip';\nimport { getMultiSeriesGraphHoverInfo } from '../utils';\n\nimport { GraphTooltipContentProps } from './types';\n\n/** @deprecated */\ntype Props = GraphTooltipContentProps & {\n // We expect position to figure out correct values when not hovering over a datapoint\n pos: FlotPosition;\n};\n\n/** @deprecated */\nexport const MultiModeGraphTooltip = ({ dimensions, activeDimensions, pos, timeZone }: Props) => {\n let activeSeriesIndex: number | null = null;\n // when no x-axis provided, skip rendering\n if (activeDimensions.xAxis === null) {\n return null;\n }\n\n if (activeDimensions.yAxis) {\n activeSeriesIndex = activeDimensions.yAxis[0];\n }\n\n // when not hovering over a point, time is undefined, and we use pos.x as time\n const time = activeDimensions.xAxis[1]\n ? getValueFromDimension(dimensions.xAxis, activeDimensions.xAxis[0], activeDimensions.xAxis[1])\n : pos.x;\n\n const hoverInfo = getMultiSeriesGraphHoverInfo(dimensions.yAxis.columns, dimensions.xAxis.columns, time, timeZone);\n const timestamp = hoverInfo.time;\n\n const series = hoverInfo.results.map((s, i) => {\n return {\n color: s.color,\n label: s.label,\n value: s.value,\n isActive: activeSeriesIndex === i,\n };\n });\n\n return <SeriesTable series={series} timestamp={timestamp} />;\n};\n\nMultiModeGraphTooltip.displayName = 'MultiModeGraphTooltip';\n"],"names":[],"mappings":";;;;;;;AAeO,MAAM,wBAAwB,CAAC,EAAE,YAAY,gBAAA,EAAkB,GAAA,EAAK,UAAS,KAAa;AAC/F,EAAA,IAAI,iBAAA,GAAmC,IAAA;AAEvC,EAAA,IAAI,gBAAA,CAAiB,UAAU,IAAA,EAAM;AACnC,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,IAAA,iBAAA,GAAoB,gBAAA,CAAiB,MAAM,CAAC,CAAA;AAAA,EAC9C;AAGA,EAAA,MAAM,OAAO,gBAAA,CAAiB,KAAA,CAAM,CAAC,CAAA,GACjC,sBAAsB,UAAA,CAAW,KAAA,EAAO,gBAAA,CAAiB,KAAA,CAAM,CAAC,CAAA,EAAG,gBAAA,CAAiB,MAAM,CAAC,CAAC,IAC5F,GAAA,CAAI,CAAA;AAER,EAAA,MAAM,SAAA,GAAY,6BAA6B,UAAA,CAAW,KAAA,CAAM,SAAS,UAAA,CAAW,KAAA,CAAM,OAAA,EAAS,IAAA,EAAM,QAAQ,CAAA;AACjH,EAAA,MAAM,YAAY,SAAA,CAAU,IAAA;AAE5B,EAAA,MAAM,SAAS,SAAA,CAAU,OAAA,CAAQ,GAAA,CAAI,CAAC,GAAG,CAAA,KAAM;AAC7C,IAAA,OAAO;AAAA,MACL,OAAO,CAAA,CAAE,KAAA;AAAA,MACT,OAAO,CAAA,CAAE,KAAA;AAAA,MACT,OAAO,CAAA,CAAE,KAAA;AAAA,MACT,UAAU,iBAAA,KAAsB;AAAA,KAClC;AAAA,EACF,CAAC,CAAA;AAED,EAAA,uBAAO,GAAA,CAAC,WAAA,EAAA,EAAY,MAAA,EAAgB,SAAA,EAAsB,CAAA;AAC5D;AAEA,qBAAA,CAAsB,WAAA,GAAc,uBAAA;;;;"}