From 53ac77d4a52df29038f995a2fd831f09e38c1bc0 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Fri, 14 Oct 2022 04:11:20 -0500 Subject: [PATCH] Heatmap: honor dashboard timezone in x axis and fix tooltip time range (#56909) --- .../app/plugins/panel/heatmap/HeatmapHoverView.tsx | 12 ++++++++++-- public/app/plugins/panel/heatmap/HeatmapPanel.tsx | 2 +- public/app/plugins/panel/heatmap/utils.ts | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx index 496a72261ef..5682bc137f3 100644 --- a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx +++ b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx @@ -59,8 +59,16 @@ const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => { const yBucketMin = yDispSrc?.[yMinIdx]; const yBucketMax = yDispSrc?.[yMaxIdx]; - const xBucketMin = xVals?.[index]; - const xBucketMax = xBucketMin + data.xBucketSize; + let xBucketMin: number; + let xBucketMax: number; + + if (data.xLayout === HeatmapCellLayout.le) { + xBucketMax = xVals?.[index]; + xBucketMin = xBucketMax - data.xBucketSize!; + } else { + xBucketMin = xVals?.[index]; + xBucketMax = xBucketMin + data.xBucketSize!; + } const count = countVals?.[index]; diff --git a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx index d65b91820c0..f46a42591e8 100644 --- a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx +++ b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx @@ -138,7 +138,7 @@ export const HeatmapPanel: React.FC = ({ ySizeDivisor: scaleConfig?.type === ScaleDistribution.Log ? +(options.calculation?.yBuckets?.value || 1) : 1, }); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [options, data.structureRev]); + }, [options, timeZone, data.structureRev]); const renderLegend = () => { if (!info.heatmap || !options.legend.show) { diff --git a/public/app/plugins/panel/heatmap/utils.ts b/public/app/plugins/panel/heatmap/utils.ts index 969833b8e39..ffd8a55aeae 100644 --- a/public/app/plugins/panel/heatmap/utils.ts +++ b/public/app/plugins/panel/heatmap/utils.ts @@ -250,6 +250,7 @@ export function prepConfig(opts: PrepConfigOpts) { placement: AxisPlacement.Bottom, isTime: true, theme: theme, + timeZone, }); const yField = dataRef.current?.heatmap?.fields[1]!;