import { XAxisType } from '../libs/dataset'; import { getAbsoluteTime, getRelativeTime } from './timeHelper'; export function xAxisFormatter(xAxisType: XAxisType, hasLabel: boolean) { // return the value of x axis return (value: number) => { if (xAxisType === 'time') { return `${hasLabel ? 'Time: ' : ''}${getAbsoluteTime(value)}`; } else if (xAxisType === 'iter') { return `${hasLabel ? 'Iter: ' : ''}${value}`; } else if (xAxisType === 'relative') { return `${hasLabel ? 'Relative time: ' : ''}${getRelativeTime(value)}`; } }; }