@@ -102,7 +102,7 @@ function loadDashboardData() {
102102 console . log ( 'Dashboard data received:' , data ) ;
103103 dashboardData = data ;
104104 populateWidgets ( data ) ;
105- drawCharts ( data ) ;
105+ drawLatencyChart ( data ) ; // Changed from drawCharts to only draw the latency chart
106106 } )
107107 . catch ( error => console . error ( 'Error loading dashboard data:' , error ) ) ;
108108}
@@ -478,8 +478,8 @@ function updatePagination(pagination) {
478478 } ;
479479}
480480
481- // Draw charts with data
482- function drawCharts ( data ) {
481+ // Draw charts with data - renamed to drawLatencyChart and removed response code chart creation
482+ function drawLatencyChart ( data ) {
483483 const MAX_X_AXIS_POINTS = 40 ; // Increased from 20 to show more granularity for day view
484484 const currentRange = rangeSelector . value ;
485485
@@ -543,8 +543,8 @@ function drawCharts(data) {
543543 }
544544 } ) ;
545545
546- // Update Response Code Chart with dashboard data
547- updateResponseCodeChart ( data . responseCodeOverTime ) ;
546+ // Remove the response code chart update
547+ // updateResponseCodeChart(data.responseCodeOverTime); <- This line is removed
548548}
549549
550550// New function to update just the response code chart
@@ -816,4 +816,37 @@ function setupFilterHandlers() {
816816document . addEventListener ( 'DOMContentLoaded' , ( ) => {
817817 loadData ( ) ;
818818 setupFilterHandlers ( ) ;
819+
820+ // Add event listener for range selector to handle sequential chart updates
821+ rangeSelector . addEventListener ( 'change' , ( ) => {
822+ // Clear the response code chart immediately to avoid confusion
823+ if ( responseCodeChart ) {
824+ responseCodeChart . destroy ( ) ;
825+ responseCodeChart = null ;
826+
827+ // Show loading state in chart
828+ const ctxResponse = document . getElementById ( 'responseCodeChart' ) . getContext ( '2d' ) ;
829+ responseCodeChart = new Chart ( ctxResponse , {
830+ type : 'bar' ,
831+ data : { datasets : [ ] } ,
832+ options : {
833+ maintainAspectRatio : false ,
834+ responsive : true ,
835+ plugins : {
836+ title : {
837+ display : true ,
838+ text : 'Loading data...' ,
839+ padding : { top : 30 }
840+ }
841+ }
842+ }
843+ } ) ;
844+ }
845+
846+ // Load new data
847+ loadData ( ) ;
848+ } ) ;
849+
850+ // Remove the event listener we just added to avoid duplicates
851+ rangeSelector . removeEventListener ( 'change' , loadData ) ;
819852} ) ;
0 commit comments