Update chart tooltips to use the correct language formatting
Modify `chart.tsx` to import and utilize `useTranslation` and `formatNumber` for locale-aware tooltip value formatting, replacing hardcoded US English number formatting. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 4cdc0cd7-7821-4410-a349-dc57c6975820 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/WWIlFT7 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import * as React from "react"
|
||||
import * as RechartsPrimitive from "recharts"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { formatNumber } from "@/lib/i18n-format"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
@@ -130,6 +132,8 @@ const ChartTooltipContent = React.forwardRef<
|
||||
ref
|
||||
) => {
|
||||
const { config } = useChart()
|
||||
const { i18n: i18nInstance } = useTranslation()
|
||||
const lang = i18nInstance.language
|
||||
|
||||
const tooltipLabel = React.useMemo(() => {
|
||||
if (hideLabel || !payload?.length) {
|
||||
@@ -240,7 +244,7 @@ const ChartTooltipContent = React.forwardRef<
|
||||
</div>
|
||||
{item.value && (
|
||||
<span className="font-mono font-medium tabular-nums text-foreground">
|
||||
{new Intl.NumberFormat("en-US-u-nu-latn", { numberingSystem: "latn" }).format(Number(item.value))}
|
||||
{formatNumber(Number(item.value), lang)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user