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

View File

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

View File

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