Conditional formatting of column based on the max/min values within the column

Hello, I have just started using Streamlit and AgGrid and think it is great. One aspect I would like to implement is to use a heat map for each column to highlight extreme values. I have seen many example of using fix values to conditional format a column such as

function(params){
    if (params.value == '0') {
        return {
            'color': 'black', 
            'backgroundColor': 'orange',
        }
    }
    if (params.value < '0') {
        return{
            'color': 'white',
            'backgroundColor': 'red',
        }
    }
    if (params.value > '0') {
        return{
            'color': 'white',
            'backgroundColor': 'green',
        }
    }
}

but what I would like is to dynamically scale the values based on the max / min in the column to conditionally format each cell rather than the fixed values in the jscode.

Does anyone have any suggestions of how to approach this.

Many thanks

David