Skip to content

Commit

Permalink
feat(conservation-builder): Add text on chart
Browse files Browse the repository at this point in the history
SKY30-504
  • Loading branch information
clementprdhomme committed Oct 24, 2024
1 parent 1fb8181 commit 0962711
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type StackedHorizontalBarChartProps = {
className: string;
title?: string;
info?: string;
customArea: number;
totalProtectedArea: number;
totalArea: number;
highlightedPercentage: number;
Expand All @@ -28,6 +29,7 @@ const StackedHorizontalBarChart: FCWithMessages<StackedHorizontalBarChartProps>
data,
title,
info,
customArea,
totalProtectedArea,
totalArea,
highlightedPercentage,
Expand All @@ -43,17 +45,24 @@ const StackedHorizontalBarChart: FCWithMessages<StackedHorizontalBarChartProps>
{formatPercentage(locale, highlightedPercentage, { displayPercentageSign: false })}
<span className="pb-1.5 pl-1 text-xs">%</span>
</div>
<div className="flex justify-between text-xs">
<div className="flex items-start justify-between text-xs">
<span className="flex items-center">
{title && title}
{info && <TooltipButton text={info} />}
</span>
<span className="text-right">
{t('marine-protected-area', {
protectedArea: formatKM(locale, totalProtectedArea),
totalArea: formatKM(locale, totalArea),
})}
</span>
<div>
<div className="text-right">
{t('marine-protected-area', {
protectedArea: formatKM(locale, totalProtectedArea),
totalArea: formatKM(locale, totalArea),
})}
</div>
<div className="text-right">
{t('new-added-area', {
area: formatKM(locale, customArea),
})}
</div>
</div>
</div>
<div className="relative my-2 flex h-3.5">
<span className="absolute top-1/2 h-px w-full border-b border-dashed border-black"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ const ModellingWidget: FCWithMessages = () => {
<StackedHorizontalBarChart
key={contribution?.location?.code}
title={locationName}
customArea={contribution?.totalCustomArea}
totalProtectedArea={contribution?.totalProtectedArea}
totalArea={contribution?.totalArea}
highlightedPercentage={contribution?.totalPercentage}
Expand Down Expand Up @@ -365,6 +366,7 @@ const ModellingWidget: FCWithMessages = () => {
</div>
<StackedHorizontalBarChart
title={t('global')}
customArea={globalProtectionStatsData?.totalCustomAreas}
totalProtectedArea={globalProtectionStatsData?.totalProtectedArea}
totalArea={globalProtectionStatsData?.totalArea}
highlightedPercentage={globalProtectionStatsData?.totalPercentage}
Expand Down
3 changes: 2 additions & 1 deletion frontend/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@
"chart-stacked-horizontal-bar": {
"marine-protected-area": "{protectedArea} km² out of {totalArea} km²",
"30%-target": "30% target",
"percentage": "{percentage}%"
"percentage": "{percentage}%",
"new-added-area": "{area} km² of new added area"
},
"tooltip-button": {
"info": "Info",
Expand Down

0 comments on commit 0962711

Please sign in to comment.