@@ -14,11 +14,13 @@ interface QueriesActivityChartsProps {
1414 expanded : boolean ;
1515}
1616
17+ const ACTIVITY_CHART_HEIGHT = 292 ;
18+
1719export function QueriesActivityCharts ( { tenantName, expanded} : QueriesActivityChartsProps ) {
1820 const [ autoRefreshInterval ] = useAutoRefreshInterval ( ) ;
1921 const [ queriesTimeFrame , setQueriesTimeFrame ] = React . useState < TimeFrame > ( '1h' ) ;
2022 const [ latenciesTimeFrame , setLatenciesTimeFrame ] = React . useState < TimeFrame > ( '1h' ) ;
21- const [ areChartsHidden , setAreChartsHidden ] = React . useState ( true ) ;
23+ const [ hasChartsLoaded , setHasChartsLoaded ] = React . useState ( false ) ;
2224
2325 // Extract chart configurations from defaultDashboardConfig
2426 const getChartByTarget = ( target : string ) => {
@@ -36,12 +38,12 @@ export function QueriesActivityCharts({tenantName, expanded}: QueriesActivityCha
3638 return null ;
3739 }
3840
39- // Refetch data only if charts successfully loaded
40- const shouldRefresh = areChartsHidden ? 0 : autoRefreshInterval ;
41+ // Refetch data only if charts have successfully loaded at least once
42+ const shouldRefresh = hasChartsLoaded ? autoRefreshInterval : 0 ;
4143
4244 const handleChartDataStatusChange = React . useCallback ( ( status : ChartDataStatus ) => {
4345 if ( status === 'success' ) {
44- setAreChartsHidden ( false ) ;
46+ setHasChartsLoaded ( true ) ;
4547 }
4648 } , [ ] ) ;
4749
@@ -66,18 +68,18 @@ export function QueriesActivityCharts({tenantName, expanded}: QueriesActivityCha
6668 }
6769
6870 return (
69- < div className = { b ( 'charts' ) } style = { { display : areChartsHidden ? 'none' : undefined } } >
71+ < div className = { b ( 'charts' ) } >
7072 < div className = { b ( 'chart-container' ) } >
7173 < MetricChart
7274 database = { tenantName }
7375 title = { queriesChartConfig . title }
7476 metrics = { queriesChartConfig . metrics }
7577 timeFrame = { queriesTimeFrame }
7678 autorefresh = { shouldRefresh }
77- height = { 260 }
79+ height = { ACTIVITY_CHART_HEIGHT }
7880 chartOptions = { queriesChartConfig . options }
7981 onChartDataStatusChange = { handleChartDataStatusChange }
80- isChartVisible = { ! areChartsHidden }
82+ isChartVisible = { hasChartsLoaded }
8183 noBorder = { true }
8284 fullWidth = { true }
8385 withTimeframeSelector = { true }
@@ -93,10 +95,10 @@ export function QueriesActivityCharts({tenantName, expanded}: QueriesActivityCha
9395 metrics = { latenciesChartConfig . metrics }
9496 timeFrame = { latenciesTimeFrame }
9597 autorefresh = { shouldRefresh }
96- height = { 260 }
98+ height = { ACTIVITY_CHART_HEIGHT }
9799 chartOptions = { latenciesChartConfig . options }
98100 onChartDataStatusChange = { handleChartDataStatusChange }
99- isChartVisible = { ! areChartsHidden }
101+ isChartVisible = { hasChartsLoaded }
100102 noBorder = { true }
101103 fullWidth = { true }
102104 withTimeframeSelector = { true }
0 commit comments