-
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
3 changed files
with
44 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function GetLegend(legendArray: [string, string][]) { | ||
return ( | ||
<ul className="legend"> | ||
{legendArray.map((item) => ( | ||
<li | ||
style={{ display: "flex", alignItems: "center", marginBottom: "5px" }} | ||
> | ||
<div | ||
style={{ | ||
width: "20px", | ||
height: "20px", | ||
background: item[1], | ||
marginRight: "10px", | ||
}} | ||
></div> | ||
<span>{item[0]}</span> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} |
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
32 changes: 12 additions & 20 deletions
32
...opean-projects/components/pages/general/positioning/charts/top-10-beneficiaries/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 |
---|---|---|
@@ -1,39 +1,31 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useSearchParams } from "react-router-dom"; | ||
|
||
import Template from "./template"; | ||
import { GetData } from "./query"; | ||
import { getDefaultParams } from "./utils"; | ||
import { GetLegend } from "../../../../../legend"; | ||
import options from "./options"; | ||
|
||
import ChartWrapper from "../../../../../chart-wrapper"; | ||
import { getDefaultParams } from "./utils"; | ||
import Template from "./template"; | ||
|
||
export default function Top10Beneficiaries() { | ||
const [searchParams] = useSearchParams(); | ||
const params = getDefaultParams(searchParams); | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: ["Top10Beneficiaries", params], | ||
queryFn: () => GetData(params) | ||
}) | ||
queryFn: () => GetData(params), | ||
}); | ||
|
||
if (isLoading || !data) return <Template /> | ||
if (isLoading || !data) return <Template />; | ||
return ( | ||
<ChartWrapper | ||
id="top10beneficiaries" | ||
options={options(data, searchParams.get('country_code') ?? null)} | ||
legend={( | ||
<ul className="legend"> | ||
<li style={{ display: "flex", alignItems: "center", marginBottom: "5px" }}> | ||
<div style={{ width: "20px", height: "20px", background: "#233E41", marginRight: "10px" }}></div> | ||
<span>Total des subventions en euros €</span> | ||
</li> | ||
<li style={{ display: "flex", alignItems: "center", marginBottom: "5px" }}> | ||
<div style={{ width: "20px", height: "20px", background: "#D75521", marginRight: "10px" }}></div> | ||
<span>Poids du cumul des subventions (%)</span> | ||
</li> | ||
</ul> | ||
)} | ||
options={options(data, searchParams.get("country_code") ?? null)} | ||
legend={GetLegend([ | ||
["Total des subventions en euros €", "#233E41"], | ||
["Poids du cumul des subventions (%)", "#D75521"], | ||
])} | ||
/> | ||
); | ||
} | ||
} |