-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
521 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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
1 change: 1 addition & 0 deletions
1
...nents/pages/general/projects-types/charts/projects-types-1/options-subventions_values.tsx
This file contains 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 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
4 changes: 2 additions & 2 deletions
4
...rojects/components/pages/general/projects-types/charts/projects-types-piliers-1/query.tsx
This file contains 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
128 changes: 128 additions & 0 deletions
128
...rojects/components/pages/general/projects-types/charts/projects-types-piliers-2/index.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useSearchParams } from "react-router-dom"; | ||
|
||
import Template from "./template"; | ||
import { GetData } from "./query"; | ||
import optionsSubventionsValuesEvaluated from "./options-subventions_values_evaluated"; | ||
import optionsSubventionsValuesEvaluatedRates from "./options-subventions_values_evaluated_rates"; | ||
|
||
import ChartWrapper from "../../../../../chart-wrapper"; | ||
import { getDefaultParams } from "./utils"; | ||
import { Container, Row, Col, Title } from "@dataesr/dsfr-plus"; | ||
|
||
export default function ProjectsTypesPiliers2() { | ||
const [searchParams] = useSearchParams(); | ||
const params = getDefaultParams(searchParams); | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: ["projectsTypesPiliers2", params], | ||
queryFn: () => GetData(params), | ||
}); | ||
|
||
if (isLoading || !data) return <Template />; | ||
|
||
return ( | ||
<Container fluid> | ||
<Row> | ||
<Col> | ||
<Title as="h3" look="h5"> | ||
Projets évalués | ||
</Title> | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col> | ||
<ChartWrapper | ||
id="projectsTypesPiliers2" | ||
options={optionsSubventionsValuesEvaluated(data)} | ||
legend={ | ||
<ul className="legend"> | ||
<li | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
marginBottom: "5px", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: "#A558A0", | ||
marginRight: "10px", | ||
}} | ||
></div> | ||
<span>Europe plus innovante</span> | ||
</li> | ||
<li | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
marginBottom: "5px", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: "#21AB8E", | ||
marginRight: "10px", | ||
}} | ||
></div> | ||
<span>Excellence scientifique</span> | ||
</li> | ||
<li | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
marginBottom: "5px", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: "#223F3A", | ||
marginRight: "10px", | ||
}} | ||
></div> | ||
<span> | ||
Problématiques mondiales et compétitivité industrielle | ||
européenne | ||
</span> | ||
</li> | ||
<li | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
marginBottom: "5px", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: "#E4794A", | ||
marginRight: "10px", | ||
}} | ||
></div> | ||
<span> | ||
Élargir la participation et renforcer l'espace européen de | ||
la recherche | ||
</span> | ||
</li> | ||
</ul> | ||
} | ||
/> | ||
</Col> | ||
<Col> | ||
<ChartWrapper | ||
id="projectsTypesPiliers2Rates" | ||
options={optionsSubventionsValuesEvaluatedRates(data)} | ||
legend={null} | ||
/> | ||
</Col> | ||
</Row> | ||
</Container> | ||
); | ||
} |
84 changes: 84 additions & 0 deletions
84
...l/projects-types/charts/projects-types-piliers-2/options-subventions_values_evaluated.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
export default function Options(data) { | ||
if (!data) return null; | ||
|
||
const filteredData = data.filter((item) => item.country !== "all")[0].data; | ||
|
||
const years = new Set(); | ||
filteredData.forEach((item) => years.add(item.year)); | ||
|
||
return { | ||
chart: { | ||
type: "line", | ||
height: 500, | ||
backgroundColor: "transparent", | ||
}, | ||
title: { text: "" }, | ||
legend: { enabled: false }, | ||
credits: { enabled: false }, | ||
|
||
xAxis: { | ||
categories: Array.from(years), | ||
crosshair: true, | ||
accessibility: { | ||
description: "Years", | ||
}, | ||
}, | ||
yAxis: { | ||
min: 0, | ||
title: { | ||
text: "(M€)", | ||
}, | ||
}, | ||
tooltip: { | ||
valueSuffix: " (M€)", | ||
}, | ||
plotOptions: { | ||
line: { | ||
dataLabels: { | ||
enabled: true, | ||
formatter: function (this: Highcharts.TooltipFormatterContextObject) { | ||
return (this.y as number).toFixed(1); | ||
}, | ||
}, | ||
}, | ||
}, | ||
series: [ | ||
{ | ||
name: "Europe plus innovante", | ||
data: filteredData | ||
.filter((item) => item.pilier_name_fr === "Europe plus innovante") | ||
.map((item) => item.total_evaluated / 1000000), | ||
color: "#A558A0", | ||
}, | ||
{ | ||
name: "Excellence scientifique", | ||
data: filteredData | ||
.filter((item) => item.pilier_name_fr === "Excellence scientifique") | ||
.map((item) => item.total_evaluated / 1000000), | ||
color: "#21AB8E", | ||
}, | ||
{ | ||
name: "Problématiques mondiales et compétitivité industrielle européenne", | ||
data: filteredData | ||
.filter( | ||
(item) => | ||
item.pilier_name_fr === | ||
"Problématiques mondiales et compétitivité industrielle européenne" | ||
) | ||
.map((item) => item.total_evaluated / 1000000), | ||
color: "#223F3A", | ||
}, | ||
{ | ||
name: "Élargir la participation et renforcer l'espace européen de la recherche", | ||
data: filteredData | ||
.filter( | ||
(item) => | ||
item.pilier_name_fr === | ||
"Élargir la participation et renforcer l'espace européen de la recherche" | ||
) | ||
.map((item) => item.total_evaluated / 1000000), | ||
color: "#E4794A", | ||
}, | ||
], | ||
}; | ||
} |
121 changes: 121 additions & 0 deletions
121
...ects-types/charts/projects-types-piliers-2/options-subventions_values_evaluated_rates.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
export default function Options(data) { | ||
if (!data) return null; | ||
|
||
const filteredDataCountry = data.filter((item) => item.country !== "all")[0] | ||
.data; | ||
const filteredDataAll = data.filter((item) => item.country === "all")[0].data; | ||
|
||
const years = new Set(); | ||
filteredDataCountry.forEach((item) => years.add(item.year)); | ||
|
||
return { | ||
chart: { | ||
type: "line", | ||
height: 500, | ||
backgroundColor: "transparent", | ||
}, | ||
title: { text: "" }, | ||
legend: { enabled: false }, | ||
credits: { enabled: false }, | ||
|
||
xAxis: { | ||
categories: Array.from(years), | ||
crosshair: true, | ||
accessibility: { | ||
description: "Years", | ||
}, | ||
}, | ||
yAxis: { | ||
min: 0, | ||
title: { | ||
text: "(%)", | ||
}, | ||
}, | ||
tooltip: { | ||
valueSuffix: " (M€)", | ||
}, | ||
plotOptions: { | ||
line: { | ||
dataLabels: { | ||
enabled: true, | ||
formatter: function (this: Highcharts.TooltipFormatterContextObject) { | ||
return (this.y as number).toFixed(1) + " %"; | ||
}, | ||
}, | ||
}, | ||
}, | ||
series: [ | ||
{ | ||
name: "Europe plus innovante", | ||
data: filteredDataCountry | ||
.filter((item) => item.pilier_name_fr === "Europe plus innovante") | ||
.map( | ||
(item) => | ||
Math.round( | ||
((item.total_evaluated * 100) / | ||
filteredDataAll.find( | ||
(itemAll) => | ||
itemAll.year === item.year && | ||
itemAll.pilier_name_fr === item.pilier_name_fr | ||
).total_evaluated) * | ||
10 | ||
) / 10 | ||
), | ||
color: "#A558A0", | ||
}, | ||
{ | ||
name: "Excellence scientifique", | ||
data: filteredDataCountry | ||
.filter((item) => item.pilier_name_fr === "Excellence scientifique") | ||
.map( | ||
(item) => | ||
(item.total_evaluated * 100) / | ||
filteredDataAll.find( | ||
(itemAll) => | ||
itemAll.year === item.year && | ||
itemAll.pilier_name_fr === item.pilier_name_fr | ||
).total_evaluated | ||
), | ||
color: "#21AB8E", | ||
}, | ||
{ | ||
name: "Problématiques mondiales et compétitivité industrielle européenne", | ||
data: filteredDataCountry | ||
.filter( | ||
(item) => | ||
item.pilier_name_fr === | ||
"Problématiques mondiales et compétitivité industrielle européenne" | ||
) | ||
.map( | ||
(item) => | ||
(item.total_evaluated * 100) / | ||
filteredDataAll.find( | ||
(itemAll) => | ||
itemAll.year === item.year && | ||
itemAll.pilier_name_fr === item.pilier_name_fr | ||
).total_evaluated | ||
), | ||
color: "#223F3A", | ||
}, | ||
{ | ||
name: "Élargir la participation et renforcer l'espace européen de la recherche", | ||
data: filteredDataCountry | ||
.filter( | ||
(item) => | ||
item.pilier_name_fr === | ||
"Élargir la participation et renforcer l'espace européen de la recherche" | ||
) | ||
.map( | ||
(item) => | ||
(item.total_evaluated * 100) / | ||
filteredDataAll.find( | ||
(itemAll) => | ||
itemAll.year === item.year && | ||
itemAll.pilier_name_fr === item.pilier_name_fr | ||
).total_evaluated | ||
), | ||
color: "#E4794A", | ||
}, | ||
], | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
...rojects/components/pages/general/projects-types/charts/projects-types-piliers-2/query.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { VITE_APP_SERVER_URL } = import.meta.env; | ||
|
||
export async function GetData(params: string) { | ||
let url = `${VITE_APP_SERVER_URL}/european-projects/general-objectives-and-projects-types-piliers-subventions-2`; | ||
if (params !== "") { | ||
url = `${VITE_APP_SERVER_URL}/european-projects/general-objectives-and-projects-types-piliers-subventions-2?${params}`; | ||
} | ||
|
||
return fetch(url).then((response) => response.json()); | ||
} |
Oops, something went wrong.