/* This file holds utility functions for the regression line options. Adopted code for curve fitting from https://github.com/Tom-Alexander/regression-js Currently we only support linear and polynomial regression. */ import * as React from 'react'; import { CheckIcon, ColorSwatch, Group, Input, SegmentedControl, Select, Stack, Text, rem } from '@mantine/core'; import fitCurve from 'fit-curve'; import { corrcoeff, ftest, spearmancoeff } from 'jstat'; import { ERegressionLineType, IRegressionFitOptions, IRegressionLineOptions, IRegressionResult } from './interfaces'; import { HelpHoverCard } from '../../components/HelpHoverCard'; type RegressionData = Array>; const DEFAULT_CURVE_FIT_OPTIONS: IRegressionFitOptions = { order: 2, precision: 3 }; interface RegressionLineOptionsProps { callback: (s: IRegressionLineOptions) => void; currentSelected: IRegressionLineOptions | null; showColorPicker?: boolean; } export function RegressionLineOptions({ callback, currentSelected, showColorPicker }: RegressionLineOptionsProps) { return (