import { getThemeStore } from '@src/theme';
import { t } from '@src/translations';
import { SettingField, SettingsTab, SettingsValues } from '@src/types';
export interface RegressionTrendStyle {
lineColor: string;
middleLineColor: string;
upperFillColor: string;
lowerFillColor: string;
showMiddleLine: boolean;
showCorrelation: boolean;
}
export type RegressionTrendSettings = SettingsValues & RegressionTrendStyle;
export function createDefaultSettings(): RegressionTrendSettings {
const { colors } = getThemeStore();
return {
lineColor: colors.chartLineColor,
middleLineColor: colors.chartCandleDown,
upperFillColor: colors.sliderPositiveFill,
lowerFillColor: colors.sliderNegativeFill,
showMiddleLine: true,
showCorrelation: true,
};
}
export function getRegressionTrendSettingsTabs(
settings: RegressionTrendSettings,
): SettingsTab[] {
const styleFields: SettingField[] = [
{
key: 'lineColor',
label: t('Channel color'),
type: 'color',
defaultValue: settings.lineColor,
toolbar: {
control: 'color',
role: 'line',
},
},
{
key: 'middleLineColor',
label: t('Middle line color'),
type: 'color',
defaultValue: settings.middleLineColor,
},
{
key: 'upperFillColor',
label: t('Upper area color'),
type: 'color',
defaultValue: settings.upperFillColor,
toolbar: {
control: 'color',
role: 'fill',
},
},
{
key: 'lowerFillColor',
label: t('Lower area color'),
type: 'color',
defaultValue: settings.lowerFillColor,
toolbar: {
control: 'color',
role: 'fill',
},
},
{
key: 'showMiddleLine',
label: t('Show middle line'),
type: 'boolean',
defaultValue: settings.showMiddleLine,
},
{
key: 'showCorrelation',
label: t('Show correlation'),
type: 'boolean',
defaultValue: settings.showCorrelation,
},
];
return [
{
key: 'style',
label: t('Style'),
fields: styleFields,
},
];
}