Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions backend/configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@
"resource": "inventaire_id",
"layerType": "symbol",
"columns": {
"geom": "gps.merge().centroid()",
"id": "_id",
"for": "for",
"cod": "cod",
"geom": "gps.merge().centroid()",
"taille_placette": "20^2*pi()/10000",
"projet": "trim('A Kob Ale')",
"biomass_volume": "ind.sum(0.0673 * (dens_bois.value * (dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10)^2 * haut)^0.976 if etat = 1) / (20^2 * pi() / 10000) / 1000",
"tree_density": "count(1 if ind.etat = 1) / (20^2 * pi() / 10000)",
"tree_pop": "count(1 if ind.etat = 1)",
Expand All @@ -52,14 +55,14 @@
"epf_tree_density": "count(1 if ind.etat = 1) / (20^2 * pi() / 10000) / 100",
"epf_necromass_pied": "ind.sum(0.0673 * (dens_bois_mort.dens_bois * (dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10)^2 * haut)^0.976 if etat = 2)",
"epf_necromass_sol": "ind.sum(3.1415926535 / 3 * ((dhp_b / 2)^2 + ((dhp_e / 2)^2 + dhp_b / 2 + dhp_e / 2) * longueur * dens_bois_mort.dens_bois) if etat = 3)",
"epf_deadWood": "((ind.sum(0.0673 * (dens_bois_mort.dens_bois * (dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10)^2 * haut)^0.976 if etat = 2) + ind.sum(3.1415926535 / 3 * ((dhp_b / 2)^2 + ((dhp_e / 2)^2 + dhp_b / 2 + dhp_e / 2) * longueur * dens_bois_mort.dens_bois) if etat = 3)) / ind.sum(0.0673 * (dens_bois.value * (dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10)^2 * haut)^0.976 if etat = 1)) * 10",
"epf_deadWood": "((ind.sum(0.0673 * (dens_bois_mort.dens_bois * (dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10)^2 * haut)^0.976 if etat = 2) + ind.sum(pi() / 3 * ((dhp_b / 2)^2 + ((dhp_e / 2)^2 + dhp_b / 2 + dhp_e / 2) * longueur * dens_bois_mort.dens_bois) if etat = 3)) / ind.sum(0.0673 * (dens_bois.value * (dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10)^2 * haut)^0.976 if etat = 1)) * 10",
"epf_tree_diversity": "shannon(ind.ess_arb) / 5 * 10",
"epf_spatial_distribution": "ind.categorical_gini(zon) * 10",
"epf_diameter_distribution": "ind.gini(dhp1 + dhp2 + dhp3 + dhp4 + dhp5 + dhp6 + dhp7 + dhp8 + dhp9 + dhp10) * 10",
"epf_vertical_distribution": "gini(ind.haut) * 10",
"epf_dominant_height": "ind.avg(haut if haut > percentile(haut, 80)) * 10 / 40",
"epf_microhabitats": "ind.list(dmh).flatten().list_unique() * 10 / 16",
"soil_structure": "sum(ep1*int(not1) + ep2*int(not2) + ep3*int(not3) + ep4*int(not4) + ep5*int(not5)) / sum(ep1 + ep2 + ep3 + ep4 + ep5) * 2",
"soil_structure": "sum(ep1*int(not1) + ep2*int(not2) + ep3*int(not3) + ep4*int(not4) + ep5*int(not5)) / (sum(ep1 + ep2 + ep3 + ep4 + ep5) if sum(ep1 + ep2 + ep3 + ep4 + ep5) > 0 else 1) * 2",
"soil_composition": "count(1)",
"ero_rainfall_and_wind": "meteo.concat_ws('-', pluv, vent)",
"ero_couv_slope_and_cover": "inventaire_external.concat_ws('-', pent, couv)",
Expand Down Expand Up @@ -91,6 +94,7 @@
"groupby": ["admi2"],
"columns": {
"geom": "centroid(merge(point(socio_eco_gps.long, socio_eco_gps.latit)))",
"household_nb": "count(_id)",
"population": "sum(hab)",
"energyType": "count(ener)",
"boughtWoodEnergy": "count(1)",
Expand All @@ -101,7 +105,7 @@
"otherEnergy": "count(1)",
"woodEnergyConsumption": "count(1)",
"woodEnergyNeeds": "count(1)",
"woodCollectionTime:": "count(1)",
"woodCollectionTime": "count(1)",
"timberNeeds": "count(1)",
"foodDiversity": "count(1)",
"autoConsumtionNeeds": "count(1)",
Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asgiref==3.8.1
coordo @ git+https://github.com/dataforgoodfr/Coordonnees.git@0.3.0#subdirectory=coordo-py
coordo @ git+https://github.com/dataforgoodfr/Coordonnees.git@arnaudfnr/fix-null-values-in-formulas#subdirectory=coordo-py
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.

Do you need an approval to merge this branch ?

Django>=4.2.27
djangorestframework==3.16.0
djangorestframework_simplejwt==5.5.1
Expand Down
4 changes: 2 additions & 2 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"chart.js": "^4.5.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"coordo": "github:dataforgoodfr/Coordonnees#0.3.0",
"coordo": "github:dataforgoodfr/Coordonnees#arnaudfnr/fix-null-values-in-formulas",
"i18next": "^25.8.0",
"i18next-browser-languagedetector": "^8.2.0",
"i18next-http-backend": "^3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/app/styles/all4trees.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
/* ========================================================================
COULEURS AJUSTEES - POUR UNE MEILLEURE UI
======================================================================== */
--custom-color-green-dark: #1a2420;
--custom-color-green-dark: #102017;
--custom-color-green-main: #007a55;
--custom-color-green-pastel: #d0fae5;
--custom-color-grey-light: #e5e7eb;
--custom-color-blue-dark: #192637;
--custom-color-blue-dark: #192430;
--custom-color-blue-light: #52a4ff;

--custom-color-socio-eco: #1447e6; /* Same as in socio-eco-icon */
Expand Down
1 change: 0 additions & 1 deletion webapp/src/app/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
overflow: hidden !important;
color: var(--popover-foreground) !important;
background: var(--popover) !important;
border: 1px solid var(--border) !important;
border-radius: var(--radius) !important;
box-shadow: 0 40px 120px rgba(0, 0, 0, 0.25) !important;
}
Expand Down
13 changes: 7 additions & 6 deletions webapp/src/app/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@
--input: #ffffff;
--ring: var(--a4t-color-vert-kelly);

--chart-1: var(--a4t-color-bleu);
--chart-2: var(--a4t-color-vert-de-gris);
--chart-3: var(--a4t-color-vert-kelly);
--chart-4: var(--a4t-color-citrouille);
--chart-5: var(--a4t-color-jaune-vert);
--chart-1: var(--a4t-color-vert-kelly);
--chart-2: var(--a4t-color-citrouille);
--chart-3: var(--a4t-color-bleu);
--chart-4: #895bf5;
--chart-5: #f04646;
--chart-6: var(--a4t-color-onyx);

--sidebar: var(--a4t-color-alabaster);
--sidebar-foreground: var(--a4t-color-alabaster);
Expand All @@ -75,7 +76,7 @@
--background: var(--custom-color-green-dark);
--foreground: var(--a4t-color-alabaster);

--card: var(--a4t-color-nuit);
--card: var(--custom-color-blue-dark);
--card-foreground: var(--a4t-color-alabaster);

--popover: var(--a4t-color-nuit);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { FC } from "react";

import { useTranslation } from "@i18n";

import type { ChartComponentType } from "../components/chart-component";
import { ChartRadarWithBenefAndControl } from "../components/radar-benef-control";

type Data = {
Expand All @@ -20,10 +19,9 @@ type ChartForestPotentialProps = {
temoin?: Data;
};

export const ChartForestPotential: FC<ChartForestPotentialProps> = ({
benef,
temoin,
}) => {
export const ChartForestPotential: ChartComponentType<
ChartForestPotentialProps
> = ({ benef, temoin }) => {
const { t } = useTranslation("translations");

const chartData: Array<{
Expand Down Expand Up @@ -99,3 +97,5 @@ export const ChartForestPotential: FC<ChartForestPotentialProps> = ({
/>
);
};

ChartForestPotential.isChartComponent = true;
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;
Loading
Loading