@@ -86,16 +86,18 @@ const buildTooltipData = function (
8686 true
8787 )
8888
89- const value = graphData . plot [ data . dataIndex ]
89+ const value = data && graphData . plot ?. [ data . dataIndex ]
9090
9191 const formatter = MetricFormatterShort [ metric ]
92- const comparisonValue = graphData . comparison_plot ?. [ comparisonData . dataIndex ]
92+ const comparisonValue =
93+ comparisonData && graphData . comparison_plot ?. [ comparisonData . dataIndex ]
9394 const comparisonDifference =
9495 label &&
9596 comparisonData &&
97+ value &&
9698 calculatePercentageDifference ( comparisonValue , value )
9799
98- const formattedValue = formatter ( value )
100+ const formattedValue = value && formatter ( value )
99101 const formattedComparisonValue = comparisonData && formatter ( comparisonValue )
100102
101103 return {
@@ -151,6 +153,11 @@ export default function GraphTooltip(graphData, metric, dashboardState, theme) {
151153 tooltipModel
152154 )
153155
156+ if ( ! tooltipData . label ) {
157+ tooltipEl . style . display = 'none'
158+ return
159+ }
160+
154161 tooltipRoot . render (
155162 < aside className = "text-gray-100 flex flex-col gap-1.5" >
156163 < div className = "flex justify-between items-center" >
@@ -167,32 +174,30 @@ export default function GraphTooltip(graphData, metric, dashboardState, theme) {
167174 ) : null }
168175 </ div >
169176
170- { tooltipData . label ? (
171- < div className = "flex flex-col" >
177+ < div className = "flex flex-col" >
178+ < div className = "flex flex-row justify-between items-center text-sm" >
179+ < span className = "flex items-center mr-4" >
180+ < div
181+ className = "size-2 mr-2 rounded-full"
182+ style = { { backgroundColor : 'rgba(101,116,205)' } }
183+ > </ div >
184+ < span > { tooltipData . label } </ span >
185+ </ span >
186+ < span className = "font-bold" > { tooltipData . formattedValue } </ span >
187+ </ div >
188+
189+ { tooltipData . comparisonLabel ? (
172190 < div className = "flex flex-row justify-between items-center text-sm" >
173191 < span className = "flex items-center mr-4" >
174- < div
175- className = "size-2 mr-2 rounded-full"
176- style = { { backgroundColor : 'rgba(101,116,205)' } }
177- > </ div >
178- < span > { tooltipData . label } </ span >
192+ < div className = "size-2 mr-2 rounded-full bg-gray-500" > </ div >
193+ < span > { tooltipData . comparisonLabel } </ span >
194+ </ span >
195+ < span className = "font-bold" >
196+ { tooltipData . formattedComparisonValue }
179197 </ span >
180- < span className = "font-bold" > { tooltipData . formattedValue } </ span >
181198 </ div >
182-
183- { tooltipData . comparisonLabel ? (
184- < div className = "flex flex-row justify-between items-center text-sm" >
185- < span className = "flex items-center mr-4" >
186- < div className = "size-2 mr-2 rounded-full bg-gray-500" > </ div >
187- < span > { tooltipData . comparisonLabel } </ span >
188- </ span >
189- < span className = "font-bold" >
190- { tooltipData . formattedComparisonValue }
191- </ span >
192- </ div >
193- ) : null }
194- </ div >
195- ) : null }
199+ ) : null }
200+ </ div >
196201
197202 { [ 'month' , 'day' ] . includes ( graphData . interval ) && (
198203 < >
0 commit comments