UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

12 lines (11 loc) 413 B
import { measureText } from '@jbrowse/core/util'; const LEGEND_FONT_SIZE = 10; const LEGEND_BOX_SIZE = 12; const LEGEND_PADDING = 3; export function calculateSvgLegendWidth(items) { if (items.length === 0) { return 0; } const maxLabelWidth = Math.max(...items.map(item => measureText(item.label, LEGEND_FONT_SIZE))); return LEGEND_BOX_SIZE + 8 + maxLabelWidth + LEGEND_PADDING * 2 + 20; }