Skip to content

Commit 45d7f8e

Browse files
committed
feat(fundings): Add tab "evolution"
1 parent a8fbe31 commit 45d7f8e

5 files changed

Lines changed: 56 additions & 56 deletions

File tree

client/src/boards/financements-par-aap/charts/overview-by-structure/index.tsx renamed to client/src/boards/financements-par-aap/charts/overview/index.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ import { useSearchParams } from "react-router-dom";
33

44
import DefaultSkeleton from "../../../../components/charts-skeletons/default.tsx";
55
import { useChartColor } from "../../../../hooks/useChartColor.tsx";
6-
import { getI18nLabel } from "../../../../utils";
7-
import ChartWrapperFundings from "../../components/chart-wrapper-fundings";
8-
import { formatCompactNumber, funders, getCssColor, getEsQuery, getYearRangeLabel, pattern } from "../../utils.ts";
6+
import { getI18nLabel } from "../../../../utils.tsx";
7+
import ChartWrapperFundings from "../../components/chart-wrapper-fundings/index.tsx";
98
import i18n from "../../i18n.json";
9+
import { formatCompactNumber, funders, getCssColor, getEsQuery, getYearRangeLabel, pattern } from "../../utils.ts";
1010

1111
const { VITE_APP_ES_INDEX_PARTICIPATIONS, VITE_APP_SERVER_URL } = import.meta.env;
1212

13-
export default function OverviewByStructure({ name }: { name: string | undefined }) {
13+
export default function Overview({ name }: { name: string | undefined }) {
1414
const [searchParams] = useSearchParams()
15+
const region = searchParams.get("region")
1516
const structure = searchParams.get("structure")
1617
const yearMax = searchParams.get("yearMax")
1718
const yearMin = searchParams.get("yearMin")
1819
const color = useChartColor()
1920

2021
const body = {
21-
...getEsQuery({ structures: [structure], yearMax, yearMin }),
22+
...getEsQuery({ regions: [region], structures: [structure], yearMax, yearMin }),
2223
aggregations: {
2324
by_project_type: {
2425
terms: {
@@ -44,7 +45,7 @@ export default function OverviewByStructure({ name }: { name: string | undefined
4445
};
4546

4647
const { data, isLoading } = useQuery({
47-
queryKey: ["fundings-overview-by-structure", structure, yearMax, yearMin],
48+
queryKey: ["fundings-overview", region, structure, yearMax, yearMin],
4849
queryFn: () =>
4950
fetch(`${VITE_APP_SERVER_URL}/elasticsearch?index=${VITE_APP_ES_INDEX_PARTICIPATIONS}`, {
5051
body: JSON.stringify(body),
@@ -69,8 +70,8 @@ export default function OverviewByStructure({ name }: { name: string | undefined
6970

7071
const config = {
7172
comment: { "fr": <>Ce graphique met en regard le volume de projets et les financements perçus associés : la largeur des barres représente le nombre de projets, tandis que leur hauteur correspond au financement perçu. Le type de participation est distingué, en pointillé quand l'établissement est coordinateur, en couleur simple s'il est partenaire non-coordinateur. Le financement perçu approxime la part réelle allouée à chaque établissement partenaire d’un projet (en assimilant consommation et subvention pour le PIA). </> },
72-
id: "overviewByStructure",
73-
integrationURL: `/integration?chart_id=overviewByStructure&${searchParams.toString()}`,
73+
id: "overview",
74+
integrationURL: `/integration?chart_id=overview&${searchParams.toString()}`,
7475
title: `Structure du financement : nombre de projets et financements perçus associés pour les projets auxquels participe ${structure ? "l'établissement" : "la région"} (${name}) ${getYearRangeLabel({ yearMax, yearMin })}`,
7576
};
7677

@@ -134,7 +135,7 @@ export default function OverviewByStructure({ name }: { name: string | undefined
134135
};
135136

136137
return (
137-
<div className={`chart-container chart-container--${color}`} id="overview-by-structure">
138+
<div className={`chart-container chart-container--${color}`} id="overview">
138139
{isLoading ? <DefaultSkeleton height="600px" /> : <ChartWrapperFundings config={config} options={options} />}
139140
</div>
140141
);

client/src/boards/financements-par-aap/charts/projects-by-funder/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default function ProjectsByFunder({ name }: { name: string | undefined })
6868

6969

7070
const { data, isLoading } = useQuery({
71-
queryKey: ["fundings-projects-by-structure", region, structure, yearMax, yearMin],
71+
queryKey: ["fundings-projects-by-funder", region, structure, yearMax, yearMin],
7272
queryFn: () =>
7373
fetch(`${VITE_APP_SERVER_URL}/elasticsearch?index=${VITE_APP_ES_INDEX_PARTICIPATIONS}`, {
7474
body: JSON.stringify(body),
@@ -175,8 +175,8 @@ export default function ProjectsByFunder({ name }: { name: string | undefined })
175175

176176
const config = {
177177
comment: { "fr": <>Ce graphique indique, par financeur, le nombre, les financements globaux et les financements perçus des projets auxquels participe l'établissement {name}. Pour chaque financeur, la barre correspondante est subdivisée en deux en fonction du rôle de l'établissement : la partie pointillée quand l'établissement est coordinateur, en couleur simple quand il est partenaire non coordinateur. Le financement global représente le volume total de financements des projets auxquels participe l'établissement. Le financement perçu approxime la part réelle allouée à chaque établissement partenaire d’un projet (en assimilant consommation et subvention pour le PIA).</> },
178-
id: "projectsByStructure",
179-
integrationURL: `/integration?chart_id=projectsByStructure&${searchParams.toString()}`,
178+
id: "projectsByFunder",
179+
integrationURL: `/integration?chart_id=projectsByFunder&${searchParams.toString()}`,
180180
title,
181181
};
182182

@@ -211,7 +211,7 @@ export default function ProjectsByFunder({ name }: { name: string | undefined })
211211
};
212212

213213
return (
214-
<div className={`chart-container chart-container--${color}`} id="projects-by-structure">
214+
<div className={`chart-container chart-container--${color}`} id="projects-by-funder">
215215
<Title as="h2" look="h6">
216216
{title}
217217
</Title>

client/src/boards/financements-par-aap/pages/structures/charts/projects-over-time-by-structure/index.tsx renamed to client/src/boards/financements-par-aap/charts/projects-over-time/index.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import { Title } from "@dataesr/dsfr-plus";
22
import { useQuery } from "@tanstack/react-query";
3+
import type HighchartsInstance from "highcharts/es-modules/masters/highcharts.src.js";
34
import { useState } from "react";
45
import { useSearchParams } from "react-router-dom";
5-
import type HighchartsInstance from "highcharts/es-modules/masters/highcharts.src.js";
66

7-
import DefaultSkeleton from "../../../../../../components/charts-skeletons/default.tsx";
8-
import { useChartColor } from "../../../../../../hooks/useChartColor.tsx";
9-
import { getI18nLabel } from "../../../../../../utils";
10-
import ChartWrapperFundings from "../../../../components/chart-wrapper-fundings";
11-
import SegmentedControl from "../../../../components/segmented-control";
12-
import i18n from "../../../../i18n.json";
13-
import { formatCompactNumber, funders, getCssColor, getEsQuery, pattern, years } from "../../../../utils.ts";
7+
import DefaultSkeleton from "../../../../components/charts-skeletons/default.tsx";
8+
import { useChartColor } from "../../../../hooks/useChartColor.tsx";
9+
import { getI18nLabel } from "../../../../utils";
10+
import ChartWrapperFundings from "../../components/chart-wrapper-fundings";
11+
import SegmentedControl from "../../components/segmented-control";
12+
import i18n from "../../i18n.json";
13+
import { formatCompactNumber, funders, getCssColor, getEsQuery, pattern, years } from "../../utils.ts";
1414

1515
const { VITE_APP_ES_INDEX_PARTICIPATIONS, VITE_APP_SERVER_URL } = import.meta.env;
1616

17-
export default function ProjectsOverTimeByStructure({ name }: { name: string | undefined }) {
18-
const [selectedControl, setSelectedControl] = useState("projects");
19-
const [searchParams] = useSearchParams();
20-
const structure = searchParams.get("structure");
21-
const color = useChartColor();
17+
export default function ProjectsOverTime({ name }: { name: string | undefined }) {
18+
const [selectedControl, setSelectedControl] = useState("projects")
19+
const [searchParams] = useSearchParams()
20+
const region = searchParams.get("region")
21+
const structure = searchParams.get("structure")
22+
const color = useChartColor()
2223

2324
const body = {
24-
...getEsQuery({ structures: [structure] }),
25+
...getEsQuery({ regions: [region], structures: [structure] }),
2526
aggregations: {
2627
by_project_type: {
2728
terms: {
@@ -72,7 +73,7 @@ export default function ProjectsOverTimeByStructure({ name }: { name: string | u
7273
};
7374

7475
const { data, isLoading } = useQuery({
75-
queryKey: ["funding-projects-over-time-by-structure", structure],
76+
queryKey: ["funding-projects-over-time", region, structure],
7677
queryFn: () =>
7778
fetch(`${VITE_APP_SERVER_URL}/elasticsearch?index=${VITE_APP_ES_INDEX_PARTICIPATIONS}`, {
7879
body: JSON.stringify(body),
@@ -149,35 +150,35 @@ export default function ProjectsOverTimeByStructure({ name }: { name: string | u
149150
// If view by number of projects
150151
let axis = getI18nLabel(i18n, 'number_of_projects_funded');
151152
let series = seriesProject.reverse();
152-
let title = `Evolution temporelle du nombre de projets auxquels participe l'établissement (${name})`;
153+
let title = `Evolution temporelle du nombre de projets auxquels participe ${structure ? "l'établissement" : "la région"} (${name})`;
153154
let tooltip = function (this: any) {
154-
return `<b>${this.y}</b> projets <b>${this.series.name}</b> en <b>${this.x}</b> auxquels prend part <b>${name}</b>`;
155+
return `<b>${this.y}</b> projets <b>${this.series.name}</b> en <b>${this.x}</b> auxquels prend part ${structure ? "l'établissement" : "la région"} <b>${name}</b>`;
155156
};
156157
switch (selectedControl) {
157158
// If view by global amount
158159
case 'amount_global':
159160
axis = getI18nLabel(i18n, 'funding_total');
160161
series = seriesBudget.reverse();
161-
title = `Evolution temporelle des financements globaux pour les projets auxquels participe l'établissement (${name})`;
162+
title = `Evolution temporelle des financements globaux pour les projets auxquels participe ${structure ? "l'établissement" : "la région"} (${name})`;
162163
tooltip = function (this: any) {
163-
return `<b>${formatCompactNumber(this.y)} €</b> ont été financés en <b>${this.x}</b> pour les projets <b>${this.series.name}</b> auxquels participe <b>${name}</b>`;
164+
return `<b>${formatCompactNumber(this.y)} €</b> ont été financés en <b>${this.x}</b> pour les projets <b>${this.series.name}</b> auxquels participe ${structure ? "l'établissement" : "la région"} <b>${name}</b>`;
164165
};
165166
break;
166167
// If view by amount by structure
167168
case 'amount_by_structure':
168169
axis = getI18nLabel(i18n, 'funding_by_structure');
169170
series = seriesParticipation.reverse();
170-
title = `Evolution temporelle des financements perçus pour les projets auxquels participe l'établissement (${name})`;
171+
title = `Evolution temporelle des financements perçus pour les projets auxquels participe ${structure ? "l'établissement" : "la région"} (${name})`;
171172
tooltip = function (this: any) {
172-
return `<b>${formatCompactNumber(this.y)} €</b> ont été perçus en <b>${this.x}</b> pour les projets <b>${this.series.name}</b> auxquels participe <b>${name}</b>`;
173+
return `<b>${formatCompactNumber(this.y)} €</b> ont été perçus en <b>${this.x}</b> pour les projets <b>${this.series.name}</b> auxquels participe ${structure ? "l'établissement" : "la région"} <b>${name}</b>`;
173174
};
174175
break;
175176
};
176177

177178
const config = {
178179
comment: { "fr": <>Ce graphique présente l’évolution temporelle du nombre de projets, des financements globaux et des financements perçus, ventilée par financeur, à travers des lignes empilées permettant d’apprécier la contribution relative de chacun dans le temps. Pour les financements européens, Horizon 2020 couvre la période 2014–2020, tandis que son successeur, Horizon Europe couvre 2021-2027. Le type de participation est distingué, en pointillé quand l'établissement est coordinateur, en couleur simple s'il est partenaire non-coordinateur. Le financement global représente le volume total de financements des projets auxquels participe l'établissement. Le financement perçu approxime la part réelle allouée à chaque établissement partenaire d’un projet (en assimilant consommation et subvention pour le PIA).</> },
179-
id: "projectsOverTimeByStructure",
180-
integrationURL: `/integration?chart_id=projectsOverTimeByStructure&${searchParams.toString()}`,
180+
id: "projectsOverTime",
181+
integrationURL: `/integration?chart_id=projectsOverTime&${searchParams.toString()}`,
181182
title,
182183
};
183184

@@ -204,7 +205,7 @@ export default function ProjectsOverTimeByStructure({ name }: { name: string | u
204205
};
205206

206207
return (
207-
<div className={`chart-container chart-container--${color}`} id="projects-over-time-by-structure">
208+
<div className={`chart-container chart-container--${color}`} id="projects-over-time">
208209
<Title as="h2" look="h6">
209210
{title}
210211
</Title>

client/src/boards/financements-par-aap/pages/region/displayRegion.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { years } from "../../utils";
1515
// import InstrumentsOverTimeForEurope from "./charts/instruments-over-time-for-europe";
1616
// import InternationalPartnersByStructure from "./charts/international-partners-by-structure";
1717
// import LaboratoriesByStructure from "./charts/laboratories-by-structure";
18-
import OverviewByStructure from "../../charts/overview-by-structure";
18+
import Overview from "../../charts/overview";
1919
import ProjectsByFunder from "../../charts/projects-by-funder";
20-
// import ProjectsOverTimeByStructure from "./charts/projects-over-time-by-structure";
20+
import ProjectsOverTime from "../../charts/projects-over-time";
2121
import Cards from "../../components/cards";
2222
// import ProjectsData from "./components/projects-data";
2323

@@ -34,7 +34,7 @@ export default function DisplayRegion() {
3434
const sections = [
3535
{ id: "apercu", label: "Aperçu" },
3636
{ id: "financements", label: "Volume et répartition des financements" },
37-
// { id: "evolution", label: "Evolution temporelle" },
37+
{ id: "evolution", label: "Evolution temporelle" },
3838
// { id: "partenaires", label: "Institutions partenaires" },
3939
// { id: "laboratoires", label: "Laboratoires" },
4040
// { id: "disciplines", label: "Disciplines" },
@@ -187,31 +187,29 @@ export default function DisplayRegion() {
187187
</Row>
188188
<Row gutters>
189189
<Col>
190-
<OverviewByStructure name={region} />
190+
<Overview name={region} />
191191
</Col>
192192
</Row>
193193
</>
194194
)}
195-
{/*
196195
{(section === "evolution") && (
197196
<Row gutters style={{ clear: "both" }}>
198197
<Col>
199-
<ProjectsOverTimeByStructure name={name} />
198+
<ProjectsOverTime name={region} />
200199
</Col>
201200
</Row>
202201
)}
203-
*/}
204202
{/*
205203
{(section === "partenaires") && (
206204
<>
207205
<Row gutters style={{ clear: "both" }}>
208206
<Col>
209-
<FrenchPartnersByStructure name={name} />
207+
<FrenchPartnersByStructure name={region} />
210208
</Col>
211209
</Row>
212210
<Row gutters>
213211
<Col>
214-
<InternationalPartnersByStructure name={name} />
212+
<InternationalPartnersByStructure name={region} />
215213
</Col>
216214
</Row>
217215
</>
@@ -221,7 +219,7 @@ export default function DisplayRegion() {
221219
{(section === "laboratoires") && (
222220
<Row gutters style={{ clear: "both" }}>
223221
<Col>
224-
<LaboratoriesByStructure name={name} />
222+
<LaboratoriesByStructure name={region} />
225223
</Col>
226224
</Row>
227225
)}
@@ -231,12 +229,12 @@ export default function DisplayRegion() {
231229
<>
232230
<Row gutters style={{ clear: "both" }}>
233231
<Col>
234-
<ClassificationsByStructure name={name} />
232+
<ClassificationsByStructure name={region} />
235233
</Col>
236234
</Row>
237235
<Row gutters>
238236
<Col>
239-
<Classifications2ByStructure name={name} />
237+
<Classifications2ByStructure name={region} />
240238
</Col>
241239
</Row>
242240
</>
@@ -247,22 +245,22 @@ export default function DisplayRegion() {
247245
<>
248246
<Row gutters style={{ clear: "both" }}>
249247
<Col>
250-
<InstrumentsForAnr name={name} />
248+
<InstrumentsForAnr name={region} />
251249
</Col>
252250
</Row>
253251
<Row gutters>
254252
<Col>
255-
<InstrumentsForEurope name={name} />
253+
<InstrumentsForEurope name={region} />
256254
</Col>
257255
</Row>
258256
<Row gutters>
259257
<Col>
260-
<InstrumentsOverTimeForAnr name={name} />
258+
<InstrumentsOverTimeForAnr name={region} />
261259
</Col>
262260
</Row>
263261
<Row gutters>
264262
<Col>
265-
<InstrumentsOverTimeForEurope name={name} />
263+
<InstrumentsOverTimeForEurope name={region} />
266264
</Col>
267265
</Row>
268266
</>
@@ -273,7 +271,7 @@ export default function DisplayRegion() {
273271
<>
274272
<Row gutters style={{ clear: "both" }}>
275273
<Col>
276-
<RegionsByStructure name={name} />
274+
<RegionsByStructure name={region} />
277275
</Col>
278276
</Row>
279277
</>

client/src/boards/financements-par-aap/pages/structures/displayStructure.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useNavigate, useSearchParams } from "react-router-dom";
55

66
import Select from "../../../../components/select";
77
import { isInProduction } from "../../../../utils";
8-
import OverviewByStructure from "../../charts/overview-by-structure";
8+
import Overview from "../../charts/overview";
99
import ProjectsByFunder from "../../charts/projects-by-funder";
1010
import Breadcrumb from "../../components/breadcrumb";
1111
import Cards from "../../components/cards";
@@ -229,7 +229,7 @@ export default function DisplayStructure() {
229229
</Row>
230230
<Row gutters>
231231
<Col>
232-
<OverviewByStructure name={name} />
232+
<Overview name={name} />
233233
</Col>
234234
</Row>
235235
</>

0 commit comments

Comments
 (0)