mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 00:21:58 +08:00
fix: y-axis time unit (#1081)
This commit is contained in:
parent
6c505f9e86
commit
1a2ef4fde6
@ -4,34 +4,39 @@ export const getYAxisFormattedValue = (
|
|||||||
value: string,
|
value: string,
|
||||||
format: string,
|
format: string,
|
||||||
): string => {
|
): string => {
|
||||||
let numberValue: number = parseInt(value, 10);
|
|
||||||
let decimalPrecision: number | undefined;
|
let decimalPrecision: number | undefined;
|
||||||
|
const parsedValue = getValueFormat(format)(
|
||||||
|
parseFloat(value),
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
const decimalSplitted = value.split('.');
|
const decimalSplitted = parsedValue.text.split('.');
|
||||||
if (decimalSplitted.length === 1) {
|
if (decimalSplitted.length === 1) {
|
||||||
decimalPrecision = 0;
|
decimalPrecision = 0;
|
||||||
} else {
|
} else {
|
||||||
const decimalDigits = decimalSplitted[1].split('');
|
const decimalDigits = decimalSplitted[1].split('');
|
||||||
decimalPrecision = decimalDigits.length;
|
decimalPrecision = decimalDigits.length;
|
||||||
let nonZeroCtr = 0;
|
|
||||||
for (let idx = 0; idx < decimalDigits.length; idx += 1) {
|
for (let idx = 0; idx < decimalDigits.length; idx += 1) {
|
||||||
if (decimalDigits[idx] !== '0') {
|
if (decimalDigits[idx] !== '0') {
|
||||||
nonZeroCtr += 1;
|
decimalPrecision = idx + 1;
|
||||||
if (nonZeroCtr >= 2) {
|
break;
|
||||||
decimalPrecision = idx + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
numberValue = parseFloat(value);
|
|
||||||
}
|
}
|
||||||
return formattedValueToString(
|
return formattedValueToString(
|
||||||
getValueFormat(format)(numberValue, decimalPrecision, undefined, undefined),
|
getValueFormat(format)(
|
||||||
|
parseFloat(value),
|
||||||
|
decimalPrecision,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
return `${numberValue}`;
|
return `${parseFloat(value)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getToolTipValue = (value: string, format: string): string => {
|
export const getToolTipValue = (value: string, format: string): string => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user