I have an excel file with a table and chart.

The plan is to have power automate come in, remove any rows in the table, and then add fresh data to the table, which feeds the chart.
From there, I can't get the wright syntax for the script in Excel to grab the chart image.
The chart is called Chart3

sheet is just sheet1
i am trying to take the sample code from MS, and remove anything dealing with updating the table or the table itself, but I keep running into errors.
I dont care about the table since Power Automate will update the table, I just need the image of the chart. the chart will be larger than this sample also.
can anyone assist? I am trying to modify the below sample from the MS documentation.
function main(workbook: ExcelScript.Workbook): ReportImages {
// Recalculate the workbook to ensure all tables and charts are updated.
workbook.getApplication().calculate(ExcelScript.CalculationType.full);
// Get the data from the "InvoiceAmounts" table.
let sheet1 = workbook.getWorksheet("Sheet1");
const table = workbook.getWorksheet('InvoiceAmounts').getTables()[0];
const rows = table.getRange().getTexts();
// Get only the "Customer Name" and "Amount due" columns, then remove the "Total" row.
const selectColumns = rows.map((row) => {
return [row[2], row[5]];
});
table.setShowTotals(true);
selectColumns.splice(selectColumns.length-1, 1);
console.log(selectColumns);
// Delete the "ChartSheet" worksheet if it's present, then recreate it.
workbook.getWorksheet('ChartSheet')?.delete();
const chartSheet = workbook.addWorksheet('ChartSheet');
// Add the selected data to the new worksheet.
const targetRange = chartSheet.getRange('A1').getResizedRange(selectColumns.length-1, selectColumns[0].length-1);
targetRange.setValues(selectColumns);
// Insert the chart on sheet 'ChartSheet' at cell "D1".
let chart_2 = chartSheet.addChart(ExcelScript.ChartType.columnClustered, targetRange);
chart_2.setPosition('D1');
// Get images of the chart and table, then return them for a Power Automate flow.
const chartImage = chart_2.getImage();
const tableImage = table.getRange().getImage();
return {chartImage, tableImage};
}
// The interface for table and chart images.
interface ReportImages {
chartImage: string
tableImage: string
}