import moment from 'moment'
/**
* Used by diagnostics module
* Expects echarts serie data item value to be [timestamp, value]
* @param {String} unit i.g 'km'
* @param {Object} options.i18n i18n instance
* @returns {Object} echart series item tooltip formatter handler
*/
export function createEchartDateValueTooltipFormatter(unit = '', options = {}) {
return (params) => {
return `${moment(params.value[0]).format('DD/MM/YYYY HH:mm:ss')}
<br/>
${params.value[1] !== undefined ? params.value[1] : ''} ${
options.i18n !== undefined && options.i18n.te(unit)
? options.i18n.t(unit)
: unit
}
${options.html || ''}
`
}
}
Source