diff --git a/client/src/pages/trends/components/evolution-chart/index.tsx b/client/src/pages/trends/components/evolution-chart/index.tsx deleted file mode 100644 index 18f16e7..0000000 --- a/client/src/pages/trends/components/evolution-chart/index.tsx +++ /dev/null @@ -1,82 +0,0 @@ -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 ( - - ) -} - -export default function TrendsEvolutionChart() { - const { trends: evolution } = useEvolution() - const { trends } = useTrends() - - console.log("evolution", evolution) - console.log("trends", trends) - - return {} -} diff --git a/client/src/pages/trends/hooks/useEvolution.ts b/client/src/pages/trends/hooks/useEvolution.ts deleted file mode 100644 index a134a46..0000000 --- a/client/src/pages/trends/hooks/useEvolution.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { useMemo } from "react" -import { useQuery } from "@tanstack/react-query" -import { getPublicationsEvolution } from "../../../api/trends/publications" -import { useTrendsContext } from "../context" -import useUrl from "../../search/hooks/useUrl" -import { MAX_YEAR, MIN_YEAR } from "../config/years" -import { rangeArray } from "../../../utils/helpers" - -export default function useEvolution() { - const { currentQuery, currentFilters, filters } = useUrl() - const { model, source, normalized } = useTrendsContext() - - const trendsYears = { - min: Number(currentFilters?.year?.values?.[0]?.value || MIN_YEAR), - max: Number(currentFilters?.year?.values?.[1]?.value || MAX_YEAR), - } - - const { data, error, isFetching } = useQuery({ - queryKey: ["evolution", source, model, currentQuery, model, filters, normalized], - queryFn: () => - getPublicationsEvolution({ - model: model, - query: currentQuery, - years: rangeArray(trendsYears.min, trendsYears.max), - filters: filters, - normalized: normalized, - }), - }) - - const values = useMemo(() => { - return { - trends: data, - trendsYears: trendsYears, - isFetching: isFetching, - error: error, - } - }, [data, trendsYears, isFetching, error]) - - return values -}