cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pradeepm93
Frequent Visitor

Hide ZERO value from Auto generated Chart

This is the table

 

Pradeepm93_0-1669387692483.png

 

 

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("TEST");
    const table = workbook.getWorksheet('TEST').getTables('TOTALT')[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[0], row[1]] ;
        
    });
    table.setShowTotals(true);
    selectColumns.splice(selectColumns.length - 11);
    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.pie, targetRange);
    chart_2.setPosition('D5');
    chart_2.getTitle().setVisible(false)
    chart_2.getLegend().setPosition('bottom')
    chart_2.getLegend().getFormat().getFont().setBold(true)
    chart_2.getDataLabels().setShowValue(true)
    chart_2.getDataLabels().getFormat().getFont().setBold(true)
    chart_2.getDataLabels().getAutoText()
    
     
    // 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
}
 
This is the Script that will run to generate a Chart
 
*Pradeepm93_1-1669387737355.png

This is the Chart. I want to Hide the ZERO value. 

 

PLEASE HELP

0 REPLIES 0

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,322)