-
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
11 changed files
with
335 additions
and
71 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
9 changes: 4 additions & 5 deletions
9
...ges/european-projects/components/pages/general/overview/charts/projects-types-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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
const { VITE_APP_SERVER_URL } = import.meta.env; | ||
|
||
export async function GetData(params: string) { | ||
let url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2`; | ||
if (params !== '') { | ||
url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2?${params}`; | ||
let url = `${VITE_APP_SERVER_URL}/european-projects/general-ProjectsTypes-SuccessRateForAmountsByProjectsTypes`; | ||
if (params !== "") { | ||
url = `${VITE_APP_SERVER_URL}/european-projects/general-ProjectsTypes-SuccessRateForAmountsByProjectsTypes?${params}`; | ||
} | ||
|
||
return fetch(url).then((response) => (response.json())) | ||
return fetch(url).then((response) => response.json()); | ||
} | ||
|
72 changes: 72 additions & 0 deletions
72
...mponents/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/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,72 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useSearchParams } from "react-router-dom"; | ||
|
||
import Template from "./template"; | ||
import { GetData } from "./query"; | ||
import options from "./options"; | ||
|
||
import ChartWrapper from "../../../../../chart-wrapper"; | ||
import { getDefaultParams } from "./utils"; | ||
import { Col, Container, Row } from "@dataesr/dsfr-plus"; | ||
|
||
export default function SuccessRateForAmountsByPillar() { | ||
const [searchParams] = useSearchParams(); | ||
const params = getDefaultParams(searchParams); | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: ["successRateForAmountsByPillar", params], | ||
queryFn: () => GetData(params), | ||
}); | ||
|
||
if (isLoading || !data) return <Template />; | ||
return ( | ||
<Container fluid> | ||
<Row> | ||
<Col md={6}> | ||
<ChartWrapper | ||
id="successRateForAmountsByPillar" | ||
options={options(data)} | ||
legend={ | ||
<ul className="legend"> | ||
<li | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
marginBottom: "5px", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: "#6DD897", | ||
marginRight: "10px", | ||
}} | ||
/> | ||
<span>Pays sélectionné</span> | ||
</li> | ||
<li | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
marginBottom: "5px", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: "#09622A", | ||
marginRight: "10px", | ||
}} | ||
/> | ||
<span>UE & Etats associés</span> | ||
</li> | ||
</ul> | ||
} | ||
/> | ||
</Col> | ||
</Row> | ||
</Container> | ||
); | ||
} |
66 changes: 66 additions & 0 deletions
66
...onents/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/options.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,66 @@ | ||
export default function Options(data) { | ||
if (!data) return null; | ||
|
||
// sort selectedCountry by action_id | ||
const selectedCountry = data.selectedCountry | ||
.filter((el) => el.ratio && el.ratio !== 0) | ||
.sort((a, b) => a.id - b.id); | ||
|
||
// sort otherCountries same as selectedCountry | ||
data.otherCountries.sort((a, b) => { | ||
return ( | ||
data.selectedCountry.findIndex((item) => item.id === a.id) - | ||
data.selectedCountry.findIndex((item) => item.id === b.id) | ||
); | ||
}); | ||
|
||
const otherCountriesSorted = selectedCountry.map((item) => { | ||
return data.otherCountries.find((otherItem) => otherItem.id === item.id); | ||
}); | ||
|
||
return { | ||
chart: { | ||
type: "column", | ||
height: 500, | ||
backgroundColor: "transparent", | ||
}, | ||
title: { text: "" }, | ||
legend: { enabled: false }, | ||
credits: { enabled: false }, | ||
|
||
xAxis: { | ||
categories: selectedCountry.map((item) => item.id), | ||
crosshair: true, | ||
accessibility: { | ||
description: "Actions", | ||
}, | ||
}, | ||
yAxis: { | ||
min: 0, | ||
title: { | ||
text: "(%)", | ||
}, | ||
}, | ||
tooltip: { | ||
valueSuffix: " (%)", | ||
}, | ||
plotOptions: { | ||
column: { | ||
pointPadding: 0.2, | ||
borderWidth: 0, | ||
}, | ||
}, | ||
series: [ | ||
{ | ||
name: "Pays", | ||
data: selectedCountry.map((item) => item.ratio), | ||
color: "#6DD897", | ||
}, | ||
{ | ||
name: "UE & Etats associés", | ||
data: otherCountriesSorted.map((item) => item.ratio), | ||
color: "#09622A", | ||
}, | ||
], | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
...mponents/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/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-projectsTypes-successRateForAmountsByPillar`; | ||
if (params !== "") { | ||
url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByPillar?${params}`; | ||
} | ||
|
||
return fetch(url).then((response) => response.json()); | ||
} |
7 changes: 7 additions & 0 deletions
7
...nents/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/template.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,7 @@ | ||
export default function Template() { | ||
return ( | ||
<> | ||
graph template | ||
</> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
...mponents/pages/general/projects-types/charts/success-rate-for-amounts-by-pillar/utils.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,5 @@ | ||
export function getDefaultParams(searchParams) { | ||
const params = [...searchParams].map(([key, value]) => `${key}=${value}`).join('&'); | ||
|
||
return params + '&stage=successful'; | ||
} |
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
9 changes: 4 additions & 5 deletions
9
...ges/general/projects-types/charts/success-rate-for-amounts-by-type-of-financing/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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
const { VITE_APP_SERVER_URL } = import.meta.env; | ||
|
||
export async function GetData(params: string) { | ||
let url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2`; | ||
if (params !== '') { | ||
url = `${VITE_APP_SERVER_URL}/european-projects/analysis-synthese-projects-types-2?${params}`; | ||
let url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByProjectsTypes`; | ||
if (params !== "") { | ||
url = `${VITE_APP_SERVER_URL}/european-projects/general-projectsTypes-successRateForAmountsByProjectsTypes?${params}`; | ||
} | ||
|
||
return fetch(url).then((response) => (response.json())) | ||
return fetch(url).then((response) => response.json()); | ||
} | ||
|
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
Oops, something went wrong.