Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix(widget): format stock values and changes for better readability (#2836)

Andreaa29556ee8ec5
diff --git a/packages/widgets/src/stocks/component.tsx b/packages/widgets/src/stocks/component.tsx
index 326301d54..c5dfe15d6 100644
--- a/packages/widgets/src/stocks/component.tsx
+++ b/packages/widgets/src/stocks/component.tsx
@@ -67,12 +67,13 @@ export default function StockPriceWidget({ options, width, height }: WidgetCompo
</Stack>
<Title pos="absolute" bottom={10} right={10} order={width > 280 ? 1 : 2} fw={700}>
- {round(stockValues[stockValues.length - 1] ?? 0)}
+ {new Intl.NumberFormat().format(round(stockValues[stockValues.length - 1] ?? 0))}
</Title>
{width > 280 && (
<Text pos="absolute" top={10} right={10} size="xl" fw={700}>
- {Math.abs(stockValuesChange)} ({Math.abs(stockValuesChangePercentage)}%)
+ {new Intl.NumberFormat().format(stockValuesChange)} ({stockValuesChange > 0 ? "+" : ""}
+ {new Intl.NumberFormat().format(stockValuesChangePercentage)}%)
</Text>
)}