Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getGraphData = (data: any, activeIndex: number) => {
const { dateField, valueField } = TRENDS[activeIndex]
const formattedCostData = map(data, (x) => ({ date: DateTime.fromISO(x[dateField]).valueOf(), value: x[valueField] }))
const regressionData = map(formattedCostData, (x) => [x.date, x.value])
const regression = linearRegression(regressionData)
const lineFn = linearRegressionLine(regression)
return map(formattedCostData, (x, index) => ({ ...x, trendData: lineFn(first(regressionData[index])) }))
}