Skip to content

Task(#72): Display Real Data in Popup#96

Open
arnaudfnr wants to merge 7 commits intomainfrom
arnaudfnr/feat-72/Display_real_data_popup
Open

Task(#72): Display Real Data in Popup#96
arnaudfnr wants to merge 7 commits intomainfrom
arnaudfnr/feat-72/Display_real_data_popup

Conversation

@arnaudfnr
Copy link
Copy Markdown
Collaborator

  • I added and reorganized indicators in the config.json to match with most of what we need for the popup.
  • Now data is groupped By 'for' and 'cod' , 'cod' being the "placette code", hence the correct data point to agregate. We now have almost 30 data points on the map ! However the group by with 2 columns introduced bugs on coordo side.
  • I extended BiodiversityData type with new keys, and ensure all float number are formatted correctly using a new utility function precise
  • I gave a better title to Popups , but had to harcode forests names. When Feat/map context with use map hook #82 will be merge maybe it will be easier to retrieve them from layerMetada using the hook.

Comment on lines 121 to +132
<Radar
dataKey="benef"
fill="var(--color-benef)"
stroke="var(--color-benef)"
{...radarConfig}
/>
<Radar
dataKey="temoin"
fill="var(--color-temoin)"
stroke="var(--color-temoin)"
{...radarConfig}
/>
{
<Radar
dataKey="temoin"
fill="var(--color-temoin)"
stroke="var(--color-temoin)"
{...radarConfig}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still make sense having both temoin and benef, back to our discussion ? Is the backend returing a single set of data or 2 for the comparison ?

Comment on lines +58 to +61
indicatorKeys.forEach((key) => {
const value = data[key];
data[key] = precise(value) as BiodiversityData[typeof key];
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a good practice to update in place data, coming directly from coordo-ts. It should be considered as Immutable.

Object.fromEntries(
  Ojbect.entries(data).map( 
    ([key, value]) => [key, indicatorKeys.contains(key) ? precise(value) : value]
  )
)

speciesRichnessTaxon3: 24,
},
title: "Point #se-4", // to replace
title: `Placette n°${data.cod} dans la forêt ${forests.find((f) => f.value === data.for)?.label || "n°" + data.for}`,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be internationalized. You can inject dynamic value in a string

  • fr: "title": "Placette n°{{ code }} dans la forêt {{ label }}",
  • en: "title": "Point n°{{ code }} in the forest {{ label }}", (to refine)

and then in the code

t("title", { code: data.code, label: forests.find((f) => f.value === data.for)?.label || `n°${data.for}`})

Comment on lines +8 to +12
export function precise(value: number) {
if (!value || Number.isNaN(value)) return 0;
if (value > 999) return Number(value.toFixed(1));
return Number(value.toFixed(2));
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability (I think there is even a biome rule that can enforce having consistent return with brackets) + redundant type

Suggested change
export function precise(value: number) {
if (!value || Number.isNaN(value)) return 0;
if (value > 999) return Number(value.toFixed(1));
return Number(value.toFixed(2));
}
export function precise(value?: number | null) {
if (!value || Number.isNaN(value)){
return 0;
}
if (value > 999){
return value.toFixed(1);
}
return value.toFixed(2);
}

Copy link
Copy Markdown
Collaborator

@david-bretaud-dev david-bretaud-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, little suggestion or question, but good to go IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants