Skip to content

Commit

Permalink
feat(graph): Add graph about ORCID accounts active with at least a pu…
Browse files Browse the repository at this point in the history
…blication
  • Loading branch information
annelhote committed Feb 5, 2024
1 parent b4b19e5 commit 33de825
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const Chart = ({ domain, hasComments, hasFooter, id }) => {
'is_fr_present',
'employment_present.disambiguation_sources.keyword',
20,
'Pas de référentiel',
getCSSValue('--affiliations-etablissements-150'),
);
const { categories, dataGraph } = allData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const Chart = ({ domain, hasComments, hasFooter, id }) => {
'is_fr_present',
'works.source.keyword',
20,
'Pas de source externe',
getCSSValue('--orange-soft-100'),
);
const { categories, dataGraph } = allData;
Expand Down
12 changes: 4 additions & 8 deletions src/components/Charts/orcid/general/get-data-indicator-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function useGetData(
indicator1,
indicator2,
size,
missing,
color,
) {
const intl = useIntl();
Expand All @@ -23,16 +22,14 @@ function useGetData(
const [isError, setError] = useState(false);
const getDataForLastObservationSnap = useCallback(
async (lastObservationSnap) => {
const queries = [];
const queryCurrent = getFetchOptions({
const query = getFetchOptions({
key: 'orcidIndicator',
domain,
parameters: [filter1, indicator1, indicator2, 10, size, missing],
parameters: [filter1, indicator1, indicator2, 10, size],
objectType: ['orcid'],
});
queries.push(Axios.post(ES_ORCID_API_URL, queryCurrent, HEADERS));
const res = await Axios.all(queries);
const data = res[0].data.aggregations.my_indicator1.buckets.filter(
const res = await Axios.post(ES_ORCID_API_URL, query, HEADERS);
const data = res.data.aggregations.my_indicator1.buckets.filter(
(el) => el.doc_count > 0,
)[0];
const total = data.doc_count;
Expand Down Expand Up @@ -94,7 +91,6 @@ function useGetData(
indicator1,
indicator2,
intl,
missing,
size,
],
);
Expand Down
18 changes: 8 additions & 10 deletions src/components/Charts/orcid/general/get-data-indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,32 @@ function useGetData(
) {
const intl = useIntl();
const [allData, setData] = useState({});
const [isLoading, setLoading] = useState(true);
const [isError, setError] = useState(false);
const [isLoading, setLoading] = useState(true);
const getDataForLastObservationSnap = useCallback(
async (lastObservationSnap) => {
const queries = [];
const queryCurrent = getFetchOptions({
const query = getFetchOptions({
key: 'orcidIndicator',
domain,
parameters: [filter1, indicator1, indicator2, size1, size2],
objectType: ['orcid'],
});
if (indicator2 === 'same_idref') {
queryCurrent.query.bool.filter.push({ term: { has_idref_abes: true } });
queryCurrent.query.bool.filter.push({
query.query.bool.filter.push({ term: { has_idref_abes: true } });
query.query.bool.filter.push({
term: { has_idref_aurehal: true },
});
}
if (indicator2 === 'same_id_hal') {
queryCurrent.query.bool.filter.push({
query.query.bool.filter.push({
term: { has_id_hal_abes: true },
});
queryCurrent.query.bool.filter.push({
query.query.bool.filter.push({
term: { has_id_hal_aurehal: true },
});
}
queries.push(Axios.post(ES_ORCID_API_URL, queryCurrent, HEADERS));
const res = await Axios.all(queries);
const data = res[0].data.aggregations.my_indicator1.buckets;
const res = await Axios.post(ES_ORCID_API_URL, query, HEADERS);
const data = res.data.aggregations.my_indicator1.buckets;
const categories = [];
const noOutline = {
style: {
Expand Down
1 change: 1 addition & 0 deletions src/pages/BaroNational/NationalOrcid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default function NationalOrcid() {
intlKey='app.national-orcid.general.publications'
>
<BSOChart id='orcid.general.chart-indicator-work' />
<BSOChart id='orcid.general.chart-indicator-active-work' />
<BSOChart id='orcid.general.chart-indicator-hal' />
<BSOChart id='orcid.general.chart-indicator-worksource' />
</QuestionSection>
Expand Down
3 changes: 3 additions & 0 deletions src/utils/chartComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ const ChartOrcidWorkSource = lazy(() => import('../components/Charts/orcid/gener
const ChartOrcidActive = lazy(() => import('../components/Charts/orcid/general/chart-indicator-active'));
const ChartOrcidHal = lazy(() => import('../components/Charts/orcid/general/chart-indicator-hal'));
const ChartOrcidWork = lazy(() => import('../components/Charts/orcid/general/chart-indicator-work'));
const ChartOrcidActiveWork = lazy(() => import('../components/Charts/orcid/general/chart-indicator-active-work'));
const ChartOrcidAffiliationId = lazy(() => import('../components/Charts/orcid/general/chart-indicator-affiliationid'));
const ChartOrcidTheseYear = lazy(() => import('../components/Charts/orcid/general/chart-indicator-these-year'));
const ChartOrcidTheseDiscipline = lazy(() => import('../components/Charts/orcid/general/chart-indicator-these-discipline'));
Expand Down Expand Up @@ -446,6 +447,7 @@ const chartComponents = {
ChartDataAvailibilityDiscipline,
'data.editeurs.voies-ouverture.chart-availibility':
ChartDataAvailibilityEditeur,
// Orcid
'orcid.general.chart-evolution': OrcidEvolution,
'orcid.general.creation-by-year': OrcidCreationByYear,
'orcid.general.chart-indicator-worksource': ChartOrcidWorkSource,
Expand All @@ -454,6 +456,7 @@ const chartComponents = {
'orcid.general.chart-indicator-active': ChartOrcidActive,
'orcid.general.chart-indicator-hal': ChartOrcidHal,
'orcid.general.chart-indicator-work': ChartOrcidWork,
'orcid.general.chart-indicator-active-work': ChartOrcidActiveWork,
'orcid.general.chart-indicator-affiliationid': ChartOrcidAffiliationId,
'orcid.general.chart-indicator-these-year': ChartOrcidTheseYear,
'orcid.general.chart-indicator-these-discipline': ChartOrcidTheseDiscipline,
Expand Down
33 changes: 28 additions & 5 deletions src/utils/chartFetchOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,15 @@ export default function getFetchOptions({
},
},
}),
orcidIndicatorSimple: ([myFilter1, myField, mySize, myMissing]) => ({
orcidComplexIndicator: ([
myFilter1,
myField1,
myField2,
myField3,
mySize1 = 10,
mySize2 = 10,
mySize3 = 10,
]) => ({
size: 0,
query: {
bool: {
Expand All @@ -2138,11 +2146,26 @@ export default function getFetchOptions({
},
},
aggs: {
my_indicator: {
my_indicator1: {
terms: {
field: myField,
size: mySize,
missing: myMissing,
field: myField1,
size: mySize1,
},
aggs: {
my_indicator2: {
terms: {
field: myField2,
size: mySize2,
},
aggs: {
my_indicator3: {
terms: {
field: myField3,
size: mySize3,
},
},
},
},
},
},
},
Expand Down
30 changes: 30 additions & 0 deletions src/utils/chartOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4082,6 +4082,36 @@ export const chartOptions = {
return options;
},
},
'orcid.general.chart-indicator-active-work': {
getOptions: (id, intl, categories, series) => {
const options = getGraphOptions({ id, intl });
options.chart.type = 'column';
options.xAxis = {
categories,
};
options.yAxis = getPercentageYAxis();
options.yAxis.title.text = intl.formatMessage({
id: 'app.orcid.proportion',
});
options.legend.reversed = true;
options.plotOptions = {
column: {
stacking: 'normal',
dataLabels: {
style: {
textOutline: 'none',
},
enabled: true,
formatter() {
return this.y.toFixed(0).concat(' %');
},
},
},
};
options.series = series;
return options;
},
},
'orcid.general.chart-indicator-affiliationid': {
getOptions: (id, intl, categories, data, dataTitle) => {
const options = getGraphOptions({ id, intl, dataTitle });
Expand Down

0 comments on commit 33de825

Please sign in to comment.