-
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
5 changed files
with
95 additions
and
7 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
47 changes: 47 additions & 0 deletions
47
client/src/pages/open-alex/charts/retracted-french-by-year-share.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,47 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import Highcharts from 'highcharts'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
|
||
export default function RetractedFrenchByYearShare() { | ||
const { data: data1, isLoading: isLoading1 } = useQuery({ | ||
queryKey: ['OpenAlexFrenchRetractions'], | ||
queryFn: () => fetch('https://api.openalex.org/works?page=1&filter=is_retracted:true,institutions.country_code:FR,publication_year:2000-&group_by=publication_year').then((response) => response.json()) | ||
}); | ||
|
||
const { data: data2, isLoading: isLoading2 } = useQuery({ | ||
queryKey: ['OpenAlexFrenchPublications'], | ||
queryFn: () => fetch('https://api.openalex.org/works?page=1&filter=institutions.country_code:FR,publication_year:2000-&group_by=publication_year').then((response) => response.json()) | ||
}); | ||
|
||
if (isLoading1 || isLoading2) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const series = (data1?.group_by?.slice(0, 20) ?? []).map((country) => { | ||
const total = data2.group_by.find((item) => item.key === country.key).count; | ||
return ({ | ||
color: country.key === 'FR' ? '#cc0000' : '#808080', | ||
name: country.key_display_name, | ||
total, | ||
y: country.count / total * 10000, | ||
}) | ||
}).sort((a, b) => b.y - a.y); | ||
const categories = series.map((country) => country.name); | ||
|
||
const options = { | ||
chart: { type: 'column' }, | ||
legend: { enabled: false }, | ||
title: { text: 'Part of French retracted publications by publication year since 2000' }, | ||
xAxis: { categories, title: { text: 'Country' } }, | ||
yAxis: { title: { text: 'Part of retracted publications (‱)' } }, | ||
series: [{ data: series }], | ||
plotOptions: { column: { dataLabels: { enabled: true, format: '{y:.2f} %' } } } | ||
}; | ||
|
||
return ( | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={options} | ||
/> | ||
); | ||
} |
38 changes: 38 additions & 0 deletions
38
client/src/pages/open-alex/charts/retracted-french-by-year.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,38 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import Highcharts from 'highcharts'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
|
||
export default function RetractedFrenchByYear() { | ||
const { data, isLoading } = useQuery({ | ||
queryKey: ['OpenAlexFrenchRetractions'], | ||
queryFn: () => fetch('https://api.openalex.org/works?page=1&filter=is_retracted:true,institutions.country_code:FR,publication_year:2000-&group_by=publication_year').then((response) => response.json()) | ||
}); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const series = (data?.group_by ?? []).sort((a, b) => a.key - b.key)?.map((item) => ({ | ||
color: '#808080', | ||
name: item.key, | ||
y: item.count, | ||
})); | ||
const categories = series.map((country) => country.name); | ||
|
||
const options = { | ||
chart: { type: 'column' }, | ||
legend: { enabled: false }, | ||
title: { text: 'Number of French retracted publications by publication year since 2000' }, | ||
xAxis: { categories, title: { text: 'Publication year' } }, | ||
yAxis: { title: { text: 'Number of retracted French publications' } }, | ||
series: [{ data: series }], | ||
plotOptions: { column: { dataLabels: { enabled: true } } } | ||
}; | ||
|
||
return ( | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={options} | ||
/> | ||
); | ||
} |
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,15 @@ | ||
import RetractedByCountry from './charts/retracted-by-country'; | ||
import RetractedByCountryShare from './charts/retracted-by-country-share' | ||
import RetractedByCountryShare from './charts/retracted-by-country-share'; | ||
import RetractedFrenchByYear from './charts/retracted-french-by-year'; | ||
import RetractedFrenchByYearShare from './charts/retracted-french-by-year-share'; | ||
|
||
export default function Welcome() { | ||
return ( | ||
<> | ||
<RetractedByCountry /> | ||
<RetractedByCountryShare /> | ||
<RetractedFrenchByYear /> | ||
<RetractedFrenchByYearShare /> | ||
</> | ||
); | ||
} |