From a7ff6c604076004586b5f8b639474b8098f827f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anne=20L=27H=C3=B4te?= Date: Thu, 8 Feb 2024 11:20:39 +0100 Subject: [PATCH] feat(graph): Add graph for survey --- src/App.js | 18 ++--- src/components/Header/index.js | 18 ++--- src/pages/Declinaisons/Policy/index.js | 93 +++++++++++++++++++++----- src/style/colours.module.scss | 55 ++++++++------- src/translations/en.json | 3 + src/translations/fr.json | 3 + src/utils/chartOptions.js | 29 ++++++++ 7 files changed, 159 insertions(+), 60 deletions(-) diff --git a/src/App.js b/src/App.js index fe0951f6..6a898771 100644 --- a/src/App.js +++ b/src/App.js @@ -252,40 +252,40 @@ function App() { path={urls.communication[key]} /> ))} - {Object.keys(urls.variations).map((key) => ( + {Object.keys(urls.policy).map((key) => ( - + )} exact key={key} - path={urls.variations[key]} + path={urls.policy[key]} /> ))} - {Object.keys(urls.howto).map((key) => ( + {Object.keys(urls.variations).map((key) => ( - + )} exact key={key} - path={urls.howto[key]} + path={urls.variations[key]} /> ))} - {Object.keys(urls.policy).map((key) => ( + {Object.keys(urls.howto).map((key) => ( - + )} exact key={key} - path={urls.policy[key]} + path={urls.howto[key]} /> ))} {Object.keys(urls.opendata).map((key) => ( diff --git a/src/components/Header/index.js b/src/components/Header/index.js index d588f7b1..24457d56 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -531,6 +531,15 @@ function Header() { defaultMessage: 'Les établissements', })} > + } + /> } /> - } - /> ( -
- -
- - -

- -

- -
-
-
-
-); +import GraphComments from '../../../components/Charts/graph-comments'; +import WrapperChart from '../../../components/WrapperChart'; +import customComments from '../../../utils/chartComments'; +import { chartOptions } from '../../../utils/chartOptions'; + +const Policy = () => { + const [chartComments, setChartComments] = useState(''); + + const intl = useIntl(); + const chartRef = useRef(); + + const hasComments = true; + const id = 'other.institution.open-science-policy'; + const idWithDomain = 'other.institution.open-science-policy'; + const optionsGraph = chartOptions[id].getOptions(idWithDomain, intl, [ + { + data: [ + { y: 1, y_percent: 3 }, + { y: 1, y_percent: 3 }, + { y: 3, y_percent: 9 }, + { y: 9, y_percent: 27 }, + { y: 15, y_percent: 52 }, + { y: 22, y_percent: 120 }, + { y: 30, y_percent: 500 }, + { y: 32, y_percent: 500 }, + { y: 37, y_percent: 505 }, + ], + }, + ]); + + useEffect(() => { + setChartComments(customComments({ comments: {} }, idWithDomain, intl)); + }, [idWithDomain, intl]); + + return ( +
+ +
+ + +

+ +

+ +
+ + + + + {hasComments && chartComments && ( + + )} + + + +
+
+
+ ); +}; export default Policy; diff --git a/src/style/colours.module.scss b/src/style/colours.module.scss index 66eba570..e9413310 100644 --- a/src/style/colours.module.scss +++ b/src/style/colours.module.scss @@ -138,37 +138,40 @@ /** Surcharge BSO */ + --acces-ouvert: #62b93a; + --affiliations-etablissements-50: #cdc5e4; + --affiliations-etablissements-75: #a798d1; + --affiliations-etablissements-100: #846dc5; + --affiliations-etablissements-125: #5b4697; + --affiliations-etablissements-150: #351c7d; + --apres: #cf7728; + --black: #000; + --diamond: #5cdce5; + --duree: #9c807e; + --hybrid: #725d3e; --lead-sponsor-highlight: #ef47ca; + --lead-sponsor-privee: #5c356f; + --lead-sponsor-public: #c26eb0; + --negatif: #a20404; + --ouvrir-la-science-blue: #5b29c8; + --ouvrir-la-science-green: #5cf1ce; + --ouvrir-la-science-yellow: #f9ee7a; + --patient-25: #fbe9f4; --patient-50: #fbdff0; --patient-75: #f7b4dc; - --negatif: #a20404; - --affiliations-etablissements-150: #351c7d; - --affiliations-etablissements-125: #5b4697; - --affiliations-etablissements-100: #846dc5; - --affiliations-etablissements-75: #a798d1; - --affiliations-etablissements-50: #cdc5e4; - --lead-sponsor-public: #c26eb0; - --lead-sponsor-privee: #5c356f; --patient-100: #f279c2; - --patient-25: #fbe9f4; --patient-125: #a83a79; - --resultat-ou-publication: #f0cda4; - --resultat-et-publication: #e49a43; - --resultat-100: #cbcf33; - --resultat-75: #e0e287; - --resultat-50: #f1f2c2; - --resultat-25: #fbfceb; - --publication-100: #d06088; - --publication-75: #d487a2; - --publication-50: #e8b6c8; --publication-25: #f5d9e3; - --acces-ouvert: #62b93a; - --diamond: #5cdce5; - --hybrid: #725d3e; - --apres: #cf7728; - --duree: #9c807e; - --white: #fff; - --black: #000; - --thesesfr: #3fc5fc; + --publication-50: #e8b6c8; + --publication-75: #d487a2; + --publication-100: #d06088; + --resultat-25: #fbfceb; + --resultat-50: #f1f2c2; + --resultat-75: #e0e287; + --resultat-100: #cbcf33; + --resultat-et-publication: #e49a43; + --resultat-ou-publication: #f0cda4; --theseshal: #01c7bb; + --thesesfr: #3fc5fc; + --white: #fff; } diff --git a/src/translations/en.json b/src/translations/en.json index 723e6035..f0ec577c 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -900,6 +900,9 @@ "app.national-publi.others.retractions.chart-by-reason.yAxis": "Reason of retraction", "app.national-publi.others.retractions.chart-by-reason.title": "Reason of retraction for French publications", "app.national-publi.others.retractions.chart-by-reason.tooltip": "{point.y} retracted publications for reason {point.reason}", + "app.national-other.institution.open-science-policy.title": "Number of institutions with an open science policy", + "other.institution.open-science-policy.tooltip": "In {point.x}, {point.y} institution(s) had an open science policy,
ie. {point.y_percent}% des respondents.", + "other.institution.open-science-policy.comments": "This gaph shows the evolution of the number of institutions declaring having an open science policy. In green is the PNSO1 (National Plan for Open Science) period between 2018 and 2021, and in yellow is the PNSO2 period between 2021 and 2024. These data come from a survey carried out in early 2024.", "app.navigation.objet-recherche": "Research object navigation", "app.methodologie.publication": "Methodology for monitoring open access to publications", "app.methodologie.publication.description-fr": "Methodology in French (pdf)", diff --git a/src/translations/fr.json b/src/translations/fr.json index b7b791c4..613d4f03 100644 --- a/src/translations/fr.json +++ b/src/translations/fr.json @@ -1094,6 +1094,9 @@ "app.national-publi.others.retractions.chart-by-reason.yAxis": "Raison du retrait", "app.national-publi.others.retractions.chart-by-reason.title": "Raison du retrait des publications françaises", "app.national-publi.others.retractions.chart-by-reason.tooltip": "{point.y} publications retirées pour raison {point.reason}", + "app.national-other.institution.open-science-policy.title": "Evolution du nombre d'établissements qui se sont dotés d'une politique de science ouverte", + "other.institution.open-science-policy.tooltip": "En {point.x}, {point.y} établissement(s) avai(en)t une politique de science ouverte,
soit {point.y_percent} % des répondants.", + "other.institution.open-science-policy.comments": "Ce gaphique présente l'évolution du nombre d'établissements déclarant avoir une politique de science ouverte. On retrouve en vert la période du PNSO1 (Plan National pour la Science Ouverte) entre 2018 et 2021 et en jaune le PNSO2 entre 2021 et 2024. Ces données sont issues d'une enquête réalisée début 2024.", "app.navigation.objet-recherche": "Navigation par objet de recherche", "app.navigation.methodologies": "Navigation dans les méthodologies", "app.methodologie.publication": "Méthodologie pour les publications", diff --git a/src/utils/chartOptions.js b/src/utils/chartOptions.js index aa7915b2..10f9fa62 100644 --- a/src/utils/chartOptions.js +++ b/src/utils/chartOptions.js @@ -4543,4 +4543,33 @@ export const chartOptions = { return options; }, }, + 'other.institution.open-science-policy': { + getOptions: (id, intl, series) => { + const options = getGraphOptions({ id, intl }); + options.xAxis.tickInterval = 1; + options.xAxis.plotBands = [ + { + from: 2018, + to: 2021, + color: getCSSValue('--ouvrir-la-science-green'), + }, + { + from: 2021, + to: 2024, + color: getCSSValue('--ouvrir-la-science-yellow'), + }, + ]; + options.yAxis = getPercentageYAxis(); + options.legend.enabled = false; + options.plotOptions = { + series: { + color: getCSSValue('--ouvrir-la-science-blue'), + pointStart: 2016, + }, + }; + options.series = series; + options.exporting.chartOptions.legend.enabled = false; + return options; + }, + }, };