-
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.
feat(open-alex): Create graph about the share of retractactions by co…
…untry
- Loading branch information
Showing
3 changed files
with
93 additions
and
38 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
client/src/pages/open-alex/charts/retracted-by-country-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,48 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import Highcharts from 'highcharts'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
|
||
export default function RetractedByCountryShare() { | ||
const { data: data1, isLoading: isLoading1 } = useQuery({ | ||
queryKey: ['GetOpeAlexRetractions'], | ||
queryFn: () => fetch('https://api.openalex.org/works?page=1&filter=is_retracted:true&group_by=authorships.countries').then((response) => response.json()) | ||
}); | ||
|
||
const { data: data2, isLoading: isLoading2 } = useQuery({ | ||
queryKey: ['GetOpeAlexPublications'], | ||
queryFn: () => fetch('https://api.openalex.org/works?page=1&group_by=authorships.countries').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, | ||
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 retracted publications by country (top 20)' }, | ||
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-by-country.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 RetractedByCountry() { | ||
const { data, isLoading } = useQuery({ | ||
queryKey: ['GetOpeAlexRetractions'], | ||
queryFn: () => fetch('https://api.openalex.org/works?page=1&filter=is_retracted:true&group_by=authorships.countries').then((response) => response.json()) | ||
}); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const series = (data?.group_by?.slice(0, 20) ?? []).map((country) => ({ | ||
color: country.key === 'FR' ? '#cc0000' : '#808080', | ||
name: country.key_display_name, | ||
y: country.count, | ||
})); | ||
const categories = series.map((country) => country.name); | ||
|
||
const options = { | ||
chart: { type: 'column' }, | ||
legend: { enabled: false }, | ||
title: { text: 'Number of retracted publications by country (top 20)' }, | ||
xAxis: { categories, title: { text: 'Country' } }, | ||
yAxis: { title: { text: 'Number of retracted 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,42 +1,11 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import Highcharts from 'highcharts'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
import RetractedByCountry from './charts/retracted-by-country'; | ||
import RetractedByCountryShare from './charts/retracted-by-country-share' | ||
|
||
export default function Welcome() { | ||
const GetHorizon2020Participation = () => { | ||
const url = 'https://api.openalex.org/works?page=1&filter=is_retracted:true&group_by=authorships.countries'; | ||
return fetch(url).then((response) => response.json()); | ||
} | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: ['GetOpeAlexRetractions'], | ||
queryFn: () => GetHorizon2020Participation() | ||
}); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const series = (data?.group_by?.slice(0, 20) ?? []).map((country) => ({ | ||
color: country.key === 'FR' ? '#cc0000' : '#808080', | ||
name: country.key_display_name, | ||
y: country.count, | ||
})); | ||
const categories = series.map((country) => country.name); | ||
|
||
const options = { | ||
chart: { type: 'column' }, | ||
legend: { enabled: false }, | ||
title: { text: 'Number of retracted publications by country (top 20)' }, | ||
xAxis: { categories, title: { text: 'Country' } }, | ||
yAxis: { title: { text: 'Number of publications' } }, | ||
series: [{ data: series }], | ||
}; | ||
|
||
return ( | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={options} | ||
/> | ||
) | ||
<> | ||
<RetractedByCountry /> | ||
<RetractedByCountryShare /> | ||
</> | ||
); | ||
} |