fix the calculator of numbers

This commit is contained in:
Saeed AB 2025-09-27 15:40:19 +03:30
parent 9205653736
commit a6ad3b2bc2
3 changed files with 9 additions and 6 deletions

View File

@ -460,7 +460,7 @@ export function DashboardHome() {
{/* Revenue Card */}
<MetricCard
title="افزایش درآمد مبتنی بر فناوری و نوآوری"
value={dashboardData.topData?.technology_innovation_based_revenue_growth || "0"}
value={dashboardData.topData?.technology_innovation_based_revenue_growth?.replaceAll("," , "") || "0"}
percentValue={dashboardData.topData?.technology_innovation_based_revenue_growth_percent}
percentLabel="درصد به کل درآمد"
/>
@ -468,7 +468,7 @@ export function DashboardHome() {
{/* Cost Reduction Card */}
<MetricCard
title="کاهش هزینه ها مبتنی بر فناوری و نوآوری"
value={Math.round(parseFloat(dashboardData.topData?.technology_innovation_based_cost_reduction?.replace(/,/g, "") || "0") / 1000000)}
value={Math.round(parseFloat(dashboardData.topData?.technology_innovation_based_cost_reduction?.replace(/,/g, "") || "0"))}
percentValue={dashboardData.topData?.technology_innovation_based_cost_reduction_percent || "0"}
percentLabel="درصد به کل هزینه"
/>
@ -562,7 +562,7 @@ export function DashboardHome() {
/,/g,
"",
) || "0",
) / 1000000000,
),
),
)}
</span>
@ -575,7 +575,7 @@ export function DashboardHome() {
/,/g,
"",
) || "0",
) / 1000000000,
),
),
)}
</span>

View File

@ -432,6 +432,7 @@ export function InfoPanel({ selectedCompany }: InfoPanelProps) {
<CardContent className="flex-1 px-6 border-b-2 border-[#3F415A]">
<div className="w-full">
<CustomBarChart
hasPercent={false}
data={barData.map((item) => ({
label: item.label,
value: item.value,
@ -482,7 +483,7 @@ export function InfoPanel({ selectedCompany }: InfoPanelProps) {
/>
<YAxis
stroke="#9ca3af"
fontSize={12}
fontSize={12}
tickMargin={12}
tickLine={false}
axisLine={false}

View File

@ -18,6 +18,7 @@ interface CustomBarChartProps {
showAxisLabels?: boolean;
className?: string;
loading?: boolean;
hasPercent ?: boolean
}
export function CustomBarChart({
@ -28,6 +29,7 @@ export function CustomBarChart({
showAxisLabels = true,
className = "",
loading = false,
hasPercent = true,
}: CustomBarChartProps) {
// استفاده از nice numbers برای محاسبه دامنه مناسب
const values = data.map((item) => item.maxValue || item.value);
@ -107,7 +109,7 @@ export function CustomBarChart({
<span className={`text-base font-normal text-left text-white`}>
{item.valuePrefix || ""}
{formatNumber(parseFloat(displayValue))}%
{formatNumber(parseFloat(displayValue))}{ hasPercent ? "%" : ""}
{item.valueSuffix || ""}
</span>
</div>