-
Notifications
You must be signed in to change notification settings - Fork 0
Fix(Webapp): Apply All4Trees Feedback #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arnaudfnr
wants to merge
8
commits into
main
Choose a base branch
from
arnaudfnr/fix-a4t-feedback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f0de1f8
Fix(UI): All4Trees Feedback
arnaudfnr 65cec75
Continue applying feedback
arnaudfnr 5630802
Improve pie & bar charts rendering
arnaudfnr c054e6b
Last fixes
arnaudfnr c791826
Update Coordo and some fake indicators
arnaudfnr 16ae571
Fix all4trees & David reviews part 1
arnaudfnr c9122ed
increase icon size
arnaudfnr 2cc7ef8
Improve indicator-section readability, mark chart components
arnaudfnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 37 additions & 17 deletions
54
webapp/src/features/charts/biodiversity/chart-relative-abundance.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,73 @@ | ||
| import type { LayerMetadata } from "node_modules/coordo/coordo-ts/src/types"; | ||
| import type { FC } from "react"; | ||
|
|
||
| import { useTranslation } from "@shared/i18n"; | ||
| import { findCategoricalLabel } from "@shared/lib/utils"; | ||
| import { findCategoricalLabel, precise } from "@shared/lib/utils"; | ||
| import type { ChartConfig } from "@shared/ui/chart"; | ||
|
|
||
| import type { ChartComponentType } from "../components/chart-component"; | ||
| import { PieChartCategorical } from "../components/pie-chart-categorical"; | ||
|
|
||
| type PieChartProps = { | ||
| data: [string, number][]; | ||
| metadata: LayerMetadata; | ||
| }; | ||
|
|
||
| export const ChartRelativeAbundance: FC<PieChartProps> = ({ | ||
| export const ChartRelativeAbundance: ChartComponentType<PieChartProps> = ({ | ||
| data, | ||
| metadata, | ||
| }) => { | ||
| const { t } = useTranslation("translations"); | ||
| const chartData = data.map((element, index) => ({ | ||
| fill: `var(--chart-${(index % 4) + 1})`, | ||
| name: element[0], | ||
| value: element[1], | ||
| })); | ||
| const smallCategoriesSum = Number( | ||
| precise( | ||
| data | ||
| .filter(([_, value]) => value < 5) | ||
| .reduce((acc, [_, value]) => acc + value, 0), | ||
| ), | ||
| ); | ||
| const chartData = data | ||
| .filter(([name, value]) => name !== "0" && (data.length < 6 || value >= 5)) | ||
| .map((element, index) => ({ | ||
| fill: `var(--chart-${(index % 5) + 1})`, | ||
| name: element[0], | ||
| value: element[1], | ||
| })); | ||
|
|
||
| let chartConfig: ChartConfig = {}; | ||
| data.forEach((element) => { | ||
| chartData.forEach((element) => { | ||
| chartConfig = { | ||
| ...chartConfig, | ||
| [element[0]]: { | ||
| [element.name]: { | ||
| label: | ||
| findCategoricalLabel(metadata, "ess_arb", element[0]) || | ||
| t( | ||
| "indicators.biodiversity.sections.treeDiversity.relativeAbundance.other", | ||
| ), | ||
| findCategoricalLabel(metadata, "ess_arb", element.name) || | ||
| element.name, | ||
| }, | ||
| other: { | ||
| label: t( | ||
| "indicators.biodiversity.sections.treeDiversity.relativeAbundance.other", | ||
| ), | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| if (data.length >= 6 && smallCategoriesSum > 0) { | ||
| chartData.push({ | ||
| fill: `var(--chart-6)`, | ||
| name: "other", | ||
| value: smallCategoriesSum, | ||
| }); | ||
| } | ||
|
|
||
| return ( | ||
| <PieChartCategorical | ||
| chartConfig={chartConfig} | ||
| chartData={chartData} | ||
| description={t( | ||
| "indicators.biodiversity.sections.treeDiversity.relativeAbundance.description", | ||
| )} | ||
| title={t( | ||
| "indicators.biodiversity.sections.treeDiversity.relativeAbundance.title", | ||
| )} | ||
| unit="%" | ||
| withLabel | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| ChartRelativeAbundance.isChartComponent = true; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need an approval to merge this branch ?