-
Notifications
You must be signed in to change notification settings - Fork 1
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
14 changed files
with
641 additions
and
41 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
87 changes: 87 additions & 0 deletions
87
src/components/Charts/data/general/repositories/datasets-by-format.js
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,87 @@ | ||
import Highcharts from 'highcharts'; | ||
import HCExportingData from 'highcharts/modules/export-data'; | ||
import HCExporting from 'highcharts/modules/exporting'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
import PropTypes from 'prop-types'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import customComments from '../../../../../utils/chartComments'; | ||
import { chartOptions } from '../../../../../utils/chartOptions'; | ||
import { domains, graphIds } from '../../../../../utils/constants'; | ||
import { getObservationLabel, withDomain } from '../../../../../utils/helpers'; | ||
import useGlobals from '../../../../../utils/Hooks/useGetGlobals'; | ||
import WrapperChart from '../../../../WrapperChart'; | ||
import GraphComments from '../../../graph-comments'; | ||
import useGetData from './get-data'; | ||
|
||
HCExporting(Highcharts); | ||
HCExportingData(Highcharts); | ||
|
||
const Chart = ({ domain, hasComments, hasFooter, id }) => { | ||
const chartRef = useRef(); | ||
const intl = useIntl(); | ||
const [chartComments, setChartComments] = useState(''); | ||
const { lastObservationSnap } = useGlobals(); | ||
const { allData, isError, isLoading } = useGetData( | ||
lastObservationSnap, | ||
domain, | ||
'format', | ||
6, | ||
); | ||
const { categories, dataGraph } = allData; | ||
const dataTitle = { | ||
observationYear: getObservationLabel(lastObservationSnap, intl), | ||
}; | ||
const idWithDomain = withDomain(id, domain); | ||
const optionsGraph = chartOptions[id].getOptions( | ||
idWithDomain, | ||
intl, | ||
categories, | ||
dataGraph, | ||
dataTitle, | ||
); | ||
const hasBeta = true; | ||
useEffect(() => { | ||
setChartComments(customComments(allData, idWithDomain, intl)); | ||
}, [allData, idWithDomain, intl]); | ||
|
||
return ( | ||
<WrapperChart | ||
chartRef={chartRef} | ||
dataTitle={dataTitle} | ||
domain={domain} | ||
hasBeta={hasBeta} | ||
hasComments={false} | ||
hasFooter={hasFooter} | ||
id={id} | ||
isError={isError} | ||
isLoading={isLoading || !dataGraph || !categories} | ||
> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
id={idWithDomain} | ||
options={optionsGraph} | ||
ref={chartRef} | ||
/> | ||
{hasComments && chartComments && ( | ||
<GraphComments comments={chartComments} hasFooter={hasFooter} /> | ||
)} | ||
</WrapperChart> | ||
); | ||
}; | ||
|
||
Chart.defaultProps = { | ||
domain: '', | ||
hasComments: true, | ||
hasFooter: true, | ||
id: 'data.general.repositories.datasets-by-format', | ||
}; | ||
Chart.propTypes = { | ||
domain: PropTypes.oneOf(domains), | ||
hasComments: PropTypes.bool, | ||
hasFooter: PropTypes.bool, | ||
id: PropTypes.oneOf(graphIds), | ||
}; | ||
|
||
export default Chart; |
87 changes: 87 additions & 0 deletions
87
src/components/Charts/data/general/repositories/datasets-by-publisher.js
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,87 @@ | ||
import Highcharts from 'highcharts'; | ||
import HCExportingData from 'highcharts/modules/export-data'; | ||
import HCExporting from 'highcharts/modules/exporting'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
import PropTypes from 'prop-types'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import customComments from '../../../../../utils/chartComments'; | ||
import { chartOptions } from '../../../../../utils/chartOptions'; | ||
import { domains, graphIds } from '../../../../../utils/constants'; | ||
import { getObservationLabel, withDomain } from '../../../../../utils/helpers'; | ||
import useGlobals from '../../../../../utils/Hooks/useGetGlobals'; | ||
import WrapperChart from '../../../../WrapperChart'; | ||
import GraphComments from '../../../graph-comments'; | ||
import useGetData from './get-data'; | ||
|
||
HCExporting(Highcharts); | ||
HCExportingData(Highcharts); | ||
|
||
const Chart = ({ domain, hasComments, hasFooter, id }) => { | ||
const chartRef = useRef(); | ||
const intl = useIntl(); | ||
const [chartComments, setChartComments] = useState(''); | ||
const { lastObservationSnap } = useGlobals(); | ||
const { allData, isError, isLoading } = useGetData( | ||
lastObservationSnap, | ||
domain, | ||
'publisher', | ||
12, | ||
); | ||
const { categories, dataGraph } = allData; | ||
const dataTitle = { | ||
observationYear: getObservationLabel(lastObservationSnap, intl), | ||
}; | ||
const idWithDomain = withDomain(id, domain); | ||
const optionsGraph = chartOptions[id].getOptions( | ||
idWithDomain, | ||
intl, | ||
categories, | ||
dataGraph, | ||
dataTitle, | ||
); | ||
const hasBeta = true; | ||
useEffect(() => { | ||
setChartComments(customComments(allData, idWithDomain, intl)); | ||
}, [allData, idWithDomain, intl]); | ||
|
||
return ( | ||
<WrapperChart | ||
chartRef={chartRef} | ||
dataTitle={dataTitle} | ||
domain={domain} | ||
hasBeta={hasBeta} | ||
hasComments={false} | ||
hasFooter={hasFooter} | ||
id={id} | ||
isError={isError} | ||
isLoading={isLoading || !dataGraph || !categories} | ||
> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
id={idWithDomain} | ||
options={optionsGraph} | ||
ref={chartRef} | ||
/> | ||
{hasComments && chartComments && ( | ||
<GraphComments comments={chartComments} hasFooter={hasFooter} /> | ||
)} | ||
</WrapperChart> | ||
); | ||
}; | ||
|
||
Chart.defaultProps = { | ||
domain: '', | ||
hasComments: true, | ||
hasFooter: true, | ||
id: 'data.general.repositories.datasets-by-publisher', | ||
}; | ||
Chart.propTypes = { | ||
domain: PropTypes.oneOf(domains), | ||
hasComments: PropTypes.bool, | ||
hasFooter: PropTypes.bool, | ||
id: PropTypes.oneOf(graphIds), | ||
}; | ||
|
||
export default Chart; |
87 changes: 87 additions & 0 deletions
87
src/components/Charts/data/general/repositories/datasets-by-size.js
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,87 @@ | ||
import Highcharts from 'highcharts'; | ||
import HCExportingData from 'highcharts/modules/export-data'; | ||
import HCExporting from 'highcharts/modules/exporting'; | ||
import HighchartsReact from 'highcharts-react-official'; | ||
import PropTypes from 'prop-types'; | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import customComments from '../../../../../utils/chartComments'; | ||
import { chartOptions } from '../../../../../utils/chartOptions'; | ||
import { domains, graphIds } from '../../../../../utils/constants'; | ||
import { getObservationLabel, withDomain } from '../../../../../utils/helpers'; | ||
import useGlobals from '../../../../../utils/Hooks/useGetGlobals'; | ||
import WrapperChart from '../../../../WrapperChart'; | ||
import GraphComments from '../../../graph-comments'; | ||
import useGetData from './get-data'; | ||
|
||
HCExporting(Highcharts); | ||
HCExportingData(Highcharts); | ||
|
||
const Chart = ({ domain, hasComments, hasFooter, id }) => { | ||
const chartRef = useRef(); | ||
const intl = useIntl(); | ||
const [chartComments, setChartComments] = useState(''); | ||
const { lastObservationSnap } = useGlobals(); | ||
const { allData, isError, isLoading } = useGetData( | ||
lastObservationSnap, | ||
domain, | ||
'size_cat', | ||
10, | ||
); | ||
const { categories, dataGraph } = allData; | ||
const dataTitle = { | ||
observationYear: getObservationLabel(lastObservationSnap, intl), | ||
}; | ||
const idWithDomain = withDomain(id, domain); | ||
const optionsGraph = chartOptions[id].getOptions( | ||
idWithDomain, | ||
intl, | ||
categories, | ||
dataGraph, | ||
dataTitle, | ||
); | ||
const hasBeta = true; | ||
useEffect(() => { | ||
setChartComments(customComments(allData, idWithDomain, intl)); | ||
}, [allData, idWithDomain, intl]); | ||
|
||
return ( | ||
<WrapperChart | ||
chartRef={chartRef} | ||
dataTitle={dataTitle} | ||
domain={domain} | ||
hasBeta={hasBeta} | ||
hasComments={false} | ||
hasFooter={hasFooter} | ||
id={id} | ||
isError={isError} | ||
isLoading={isLoading || !dataGraph || !categories} | ||
> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
id={idWithDomain} | ||
options={optionsGraph} | ||
ref={chartRef} | ||
/> | ||
{hasComments && chartComments && ( | ||
<GraphComments comments={chartComments} hasFooter={hasFooter} /> | ||
)} | ||
</WrapperChart> | ||
); | ||
}; | ||
|
||
Chart.defaultProps = { | ||
domain: '', | ||
hasComments: true, | ||
hasFooter: true, | ||
id: 'data.general.repositories.datasets-by-size', | ||
}; | ||
Chart.propTypes = { | ||
domain: PropTypes.oneOf(domains), | ||
hasComments: PropTypes.bool, | ||
hasFooter: PropTypes.bool, | ||
id: PropTypes.oneOf(graphIds), | ||
}; | ||
|
||
export default Chart; |
Oops, something went wrong.