from typing import Tuple
import math


def get_graph_dimen(fields: dict, uniq_cnt_threshold: int) -> Tuple[int,int]:
    """
    Helper function to first figure out how many graphs we'll be
    displaying, and then based on that determine the appropriate
    row and column count for display
    """

    graph_cnt = 0
    for field in fields:
        if fields[field]["cardinality"] <= uniq_cnt_threshold:
            graph_cnt += 1
    
    col_cnt = 1    
    if uniq_cnt_threshold <= 50:
        col_cnt = min(3, graph_cnt)
    elif uniq_cnt_threshold <= 100:
        col_cnt = min(2, graph_cnt)
    else:
        col_cnt = 1
    row_cnt = math.ceil(graph_cnt/col_cnt)    
            
    return row_cnt, col_cnt