All files / owid-grapher/grapher/facetChart FacetChartUtils.tsx

85.71% Statements 24/28
66.67% Branches 4/6
100% Functions 2/2
85.71% Lines 24/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x 1x 1x 1x 12x 12x 12x 12x 12x 12x 9x         1x 1x 12x 12x 12x 12x 12x 12x 12x 12x 12x 1x
import { BASE_FONT_SIZE } from "../core/GrapherConstants"
 
// not sure if we want to do something more sophisticated
export const getFontSize = (
    count: number,
    baseFontSize = BASE_FONT_SIZE,
    minSize = 8
): number => {
    if (count <= 2) return Math.max(minSize, baseFontSize * (15 / 16))
    if (count <= 4) return Math.max(minSize, baseFontSize * (14 / 16))
    if (count <= 9) return Math.max(minSize, baseFontSize * (13 / 16))
    if (count <= 16) return Math.max(minSize, baseFontSize * (12 / 16))
    if (count <= 25) return Math.max(minSize, baseFontSize * (11 / 16))
    return minSize
}
 
export const getChartPadding = (
    count: number,
    baseFontSize: number
): { rowPadding: number; columnPadding: number; outerPadding: number } => {
    return {
        rowPadding: Math.round(baseFontSize * 3.5),
        columnPadding: Math.round(baseFontSize),
        outerPadding: 0,
    }
}