@@ -46,6 +46,7 @@ function updateChart(){
4646//console.log('UPDATECHART*******************');
4747 if ( lastInstanceNo > 0 ) {
4848 const canvas = [ ] ;
49+ removeScatterTables ( ) ;
4950 for ( i = 1 ; i < lastInstanceNo + 1 ; i ++ ) {
5051 canvas [ i ] = document . getElementById ( 'chart' + i ) ;
5152 clearCanvasAndChart ( canvas [ i ] , i ) ;
@@ -184,7 +185,7 @@ function createResetChart(instanceNo) {
184185
185186
186187function displayCharts ( sheetName , instanceNo ) {
187- // totalAreasAvailable = true;
188+ // totalAreasAvailable = true;
188189 if ( sheetName === 'Physical Data' ) {
189190 retData = dataForPSDCharting ( sheetName ) ;
190191 unitTitle = retData [ 'unitTitle' ] ;
@@ -479,6 +480,22 @@ console.log('PAH data reset');
479480 return instanceNo
480481}
481482
483+ function removeScatterTables ( ) {
484+ const chartContainer = document . getElementById ( 'chartContainer' ) ;
485+
486+ // Remove all tables inside chartContainer
487+ const tables = chartContainer . getElementsByTagName ( 'table' ) ;
488+ while ( tables . length > 0 ) {
489+ tables [ 0 ] . remove ( ) ;
490+ }
491+
492+ // Optionally, remove the button container if it exists
493+ const buttonContainer = document . getElementById ( 'chartButtons' ) ;
494+ if ( buttonContainer ) {
495+ buttonContainer . remove ( ) ;
496+ }
497+ }
498+
482499function displayScatterCharts ( sheetName , chartType , subsKey , xAxisLabel , yAxisLabel , containerId , instanceNo ) {
483500//console.log('Sheet Name ',sheetName, 'chartType ', chartType, 'subsKey', subsKey, 'xAxisLael', xAxisLabel, 'yAxisLabel', yAxisLabel, 'containerId', containerId, 'instanceNo', instanceNo);
484501 if ( subsToDisplay [ subsKey ] && completeSheet [ chartType . sheetKey ] ) {
0 commit comments