swimlane/ngx-charts

View on GitHub
projects/swimlane/ngx-charts/src/lib/utils/calculate-width.ts

Summary

Maintainability
A
0 mins
Test Coverage
export function calculateTextWidth(fontFamilyKey: Record<string, any>, text: string, defaultWidth = 8) {
  return text.split('').reduce((acc, curr) => {
    const width = fontFamilyKey[curr] || defaultWidth;
    return acc + width;
  }, 0);
}