Skip to content

Commit

Permalink
refactor(dashboard): rm try catch from formatAdditionalMetric
Browse files Browse the repository at this point in the history
  • Loading branch information
GerilLeto committed Dec 19, 2023
1 parent 7bacb63 commit f3508df
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import { formatNumber, parseDataKey } from '~/utils';
import { IBoxplotChartConf } from '../../type';

const formatAdditionalMetric = (v: number) => {
try {
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
} catch (error) {
return v;
}
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
};

export function getAdditionalMetrics(config: IBoxplotChartConf, dataItem: AnyObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ import { ICalendarHeatmapConf } from '../type';
import { ValueFormattersType } from './formatters';

const formatAdditionalMetric = (v: number) => {
try {
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
} catch (error) {
return v;
}
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
};

interface IGetRows {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ import { IHeatmapConf } from '../type';
import { LabelFormattersType, ValueFormattersType } from './formatters';

const formatAdditionalMetric = (v: number) => {
try {
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
} catch (error) {
return v;
}
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
};

interface IGetRows {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ import { TMericoHeatmapConf } from '../../type';
import { LabelFormattersType, ValueFormattersType } from './formatters';

const formatAdditionalMetric = (v: number) => {
try {
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
} catch (error) {
return v;
}
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
};

interface IGetRows {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ function getXAxisLabel(params: AnyObject[], conf: IScatterChartConf) {
}

const formatAdditionalMetric = (v: number) => {
try {
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
} catch (error) {
return v;
}
return formatNumber(v, {
output: 'number',
trimMantissa: true,
mantissa: 2,
absolute: false,
});
};

export function getTooltip(conf: IScatterChartConf, labelFormatters: Record<string, (p: $TSFixMe) => string>) {
Expand Down

0 comments on commit f3508df

Please sign in to comment.