Add support for negative bars on bar chart (#15418)
in app: <img width="580" height="591" alt="Screenshot 2025-10-29 at 01 47 51" src="https://github.com/user-attachments/assets/9e16a597-6367-454d-a726-668beac90e04" /> <img width="747" height="582" alt="Screenshot 2025-10-29 at 02 30 15" src="https://github.com/user-attachments/assets/d06eb443-16ac-4394-bf4f-e6063f1ac12f" /> new stories: <img width="569" height="359" alt="Screenshot 2025-10-29 at 01 46 50" src="https://github.com/user-attachments/assets/a4cd33e2-3f15-4b8d-8849-c2d990246dec" /> <img width="564" height="360" alt="Screenshot 2025-10-29 at 01 46 45" src="https://github.com/user-attachments/assets/014a2110-53e4-4f99-afda-1d8c5412a815" /> <img width="604" height="372" alt="Screenshot 2025-10-29 at 01 46 40" src="https://github.com/user-attachments/assets/bf7a73b4-fe29-40b7-b1a0-2894d5cbeccf" /> <img width="635" height="395" alt="Screenshot 2025-10-29 at 01 46 34" src="https://github.com/user-attachments/assets/3cdfd3b9-dc76-4cf2-98e5-8e2a74e02ac6" /> <img width="652" height="408" alt="Screenshot 2025-10-29 at 01 46 30" src="https://github.com/user-attachments/assets/c2837d8d-371f-44ac-b66b-8f41ba69245e" />
This commit is contained in:
+6
-3
@@ -39,20 +39,23 @@ export const formatGraphValue = (
|
||||
return customFormatter(value);
|
||||
}
|
||||
|
||||
const sign = value < 0 ? '-' : '';
|
||||
const absoluteValue = Math.abs(value);
|
||||
|
||||
switch (displayType) {
|
||||
case 'percentage':
|
||||
return `${formatNumber(value * 100, { decimals })}%`;
|
||||
|
||||
case 'shortNumber':
|
||||
return `${prefix}${formatToShortNumber(value)}${suffix}`;
|
||||
return `${sign}${prefix}${formatToShortNumber(absoluteValue)}${suffix}`;
|
||||
|
||||
case 'currency': {
|
||||
const currencyPrefix = prefix || '$';
|
||||
return `${currencyPrefix}${formatNumber(value, { decimals })}${suffix}`;
|
||||
return `${sign}${currencyPrefix}${formatNumber(absoluteValue, { decimals })}${suffix}`;
|
||||
}
|
||||
|
||||
case 'number':
|
||||
default:
|
||||
return `${prefix}${formatNumber(value, { decimals })}${suffix}`;
|
||||
return `${sign}${prefix}${formatNumber(absoluteValue, { decimals })}${suffix}`;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user