-
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.
Merge commit '7ded1996f267d9e88301f9d06c1aea43e33a61f6' into staging
- Loading branch information
Showing
13 changed files
with
310 additions
and
56 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
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
82 changes: 82 additions & 0 deletions
82
client/src/pages/trends/components/evolution-chart/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,82 @@ | ||
import { Container } from "@dataesr/dsfr-plus" | ||
import useEvolution from "../../hooks/useEvolution" | ||
import { rangeArray } from "../../../../utils/helpers" | ||
import { useIntl } from "react-intl" | ||
import AnalyticsGraph from "../../../../components/analytics-graph" | ||
import useTrends from "../../hooks/useTrends" | ||
|
||
function LineChart({ data, source }) { | ||
const intl = useIntl() | ||
const { | ||
trendsYears: { min, max }, | ||
} = useEvolution() | ||
const range = rangeArray(min, max) | ||
|
||
if (!data) return null | ||
|
||
const highchartsOptions = { | ||
chart: { | ||
type: "line", | ||
height: "500px", | ||
}, | ||
xAxis: { | ||
accessibility: { | ||
description: intl.formatMessage({ id: "trends.line-chart.xAxis.accessibility.description" }, { min: min, max: max }), | ||
}, | ||
tickInterval: 1, // one year | ||
}, | ||
yAxis: { | ||
accessibility: { | ||
description: intl.formatMessage( | ||
{ id: "trends.line-chart.yAxis.accessibility.description" }, | ||
{ | ||
source: intl.formatMessage({ id: `trends.select-source.${source}` }).toLowerCase(), | ||
} | ||
), | ||
}, | ||
title: { | ||
text: intl.formatMessage( | ||
{ id: "trends.line-chart.yAxis.title.text" }, | ||
{ | ||
source: intl.formatMessage({ id: `trends.select-source.${source}` }).toLowerCase(), | ||
} | ||
), | ||
}, | ||
}, | ||
plotOptions: { | ||
series: { | ||
pointStart: min, | ||
pointInterval: 1, // one year | ||
}, | ||
}, | ||
legend: { enabled: true }, | ||
series: Object.values(data).map((d: any) => ({ | ||
name: d.label, | ||
data: range.map((year) => d?.count?.[year] || 0), | ||
marker: { enabled: false }, | ||
})), | ||
} | ||
|
||
return ( | ||
<AnalyticsGraph | ||
title={intl.formatMessage({ id: "trends.line-chart.title" }, { label: data.label })} | ||
description={intl.formatMessage( | ||
{ id: `trends.line-chart.description.${source}` }, | ||
{ | ||
label: data.label, | ||
} | ||
)} | ||
options={highchartsOptions} | ||
/> | ||
) | ||
} | ||
|
||
export default function TrendsEvolutionChart() { | ||
const { trends: evolution } = useEvolution() | ||
const { trends } = useTrends() | ||
|
||
console.log("evolution", evolution) | ||
console.log("trends", trends) | ||
|
||
return <Container className="fr-mt-5w">{<LineChart data={evolution} source="publications" />}</Container> | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// import { useSuspenseQuery } from "@tanstack/react-query" | ||
import { useMemo } from "react" | ||
import data from "./openalex_topic_mapping_table.json" | ||
|
||
export function getOpenAlexMapping() { | ||
// const { data } = useSuspenseQuery({ | ||
// queryKey: ["bso", "locals"], | ||
// queryFn: () => fetch("./openalex_topic_mapping_table.json").then((response) => (response.ok ? response.json() : {})), | ||
// }) | ||
|
||
const values = useMemo(() => { | ||
return data | ||
}, [data]) | ||
|
||
return values | ||
} |
1 change: 1 addition & 0 deletions
1
client/src/pages/trends/config/openalex_topic_mapping_table.json
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 +1,3 @@ | ||
export const CURRENT_YEAR = new Date().getFullYear() | ||
export const CURRENT_YEAR = /*new Date().getFullYear()*/ 2024 | ||
export const MAX_YEAR = CURRENT_YEAR - 1 | ||
export const MIN_YEAR = MAX_YEAR - 10 | ||
export const MIN_YEAR = 2013 |
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.