export function applyDefaultFormat()

in src/utils/data-utils.js [358:376]


export function applyDefaultFormat(tooltipFormat) {
  if (!tooltipFormat || !tooltipFormat.format) {
    return defaultFormatter;
  }

  switch (tooltipFormat.type) {
    case TOOLTIP_FORMAT_TYPES.DECIMAL:
      return d3Format(tooltipFormat.format);
    case TOOLTIP_FORMAT_TYPES.DATE:
    case TOOLTIP_FORMAT_TYPES.DATE_TIME:
      return v => moment.utc(v).format(tooltipFormat.format);
    case TOOLTIP_FORMAT_TYPES.PERCENTAGE:
      return v => `${d3Format(TOOLTIP_FORMATS.DECIMAL_DECIMAL_FIXED_2.format)(v)}%`;
    case TOOLTIP_FORMAT_TYPES.BOOLEAN:
      return getBooleanFormatter(tooltipFormat.format);
    default:
      return defaultFormatter;
  }
}