mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-25 23:39:06 +02:00
Add valueFormatter prop to ToggleableTrendChart and ChartTooltipContent so we see more decimals
This commit is contained in:
+16
-10
@@ -135,6 +135,7 @@ type ChartTooltipContentProps = React.ComponentProps<"div"> & {
|
||||
labelKey?: string;
|
||||
color?: string;
|
||||
labelClassName?: string;
|
||||
valueFormatter?: (value: number) => string;
|
||||
};
|
||||
|
||||
const ChartTooltipContent = React.forwardRef<
|
||||
@@ -155,7 +156,8 @@ const ChartTooltipContent = React.forwardRef<
|
||||
formatter,
|
||||
color,
|
||||
nameKey,
|
||||
labelKey
|
||||
labelKey,
|
||||
valueFormatter
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
@@ -302,19 +304,23 @@ const ChartTooltipContent = React.forwardRef<
|
||||
item.name}
|
||||
</span>
|
||||
</div>
|
||||
{item.value && (
|
||||
{item.value !== undefined && (
|
||||
<span className="font-mono font-medium tabular-nums text-foreground">
|
||||
{!isNaN(
|
||||
item.value as number
|
||||
)
|
||||
? new Intl.NumberFormat(
|
||||
navigator.language,
|
||||
{
|
||||
maximumFractionDigits: 0
|
||||
}
|
||||
).format(
|
||||
item.value as number
|
||||
)
|
||||
? valueFormatter
|
||||
? valueFormatter(
|
||||
item.value as number
|
||||
)
|
||||
: new Intl.NumberFormat(
|
||||
navigator.language,
|
||||
{
|
||||
maximumFractionDigits: 0
|
||||
}
|
||||
).format(
|
||||
item.value as number
|
||||
)
|
||||
: item.value.toLocaleString()}
|
||||
</span>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user