-
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.
feat(graphs): Add new graph about results for CT within 1 year fater …
…completion by year
- Loading branch information
Showing
6 changed files
with
245 additions
and
1 deletion.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
...nents/Charts/studies/general/dynamique-ouverture/chart-evolution-within-1-year-by-year.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,84 @@ | ||
import '../../../graph.scss'; | ||
|
||
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, | ||
studiesTypes, | ||
} from '../../../../../utils/constants'; | ||
import { withDomain, withtStudyType } from '../../../../../utils/helpers'; | ||
import WrapperChart from '../../../../WrapperChart'; | ||
import GraphComments from '../../../graph-comments'; | ||
import useGetData from './get-data'; | ||
|
||
HCExporting(Highcharts); | ||
HCExportingData(Highcharts); | ||
|
||
const Chart = ({ domain, hasComments, hasFooter, id, studyType }) => { | ||
const chartRef = useRef(); | ||
const intl = useIntl(); | ||
const [chartComments, setChartComments] = useState(''); | ||
const { allData, isError, isLoading } = useGetData(studyType); | ||
const { dataGraph6 } = allData; | ||
const idWithDomain = withDomain(id, domain); | ||
const idWithDomainAndStudyType = withtStudyType(idWithDomain, studyType); | ||
const optionsGraph = chartOptions[id].getOptions( | ||
idWithDomain, | ||
intl, | ||
dataGraph6, | ||
studyType, | ||
); | ||
|
||
useEffect(() => { | ||
setChartComments(customComments(allData, idWithDomainAndStudyType, intl)); | ||
}, [allData, idWithDomainAndStudyType, intl]); | ||
|
||
return ( | ||
<WrapperChart | ||
chartRef={chartRef} | ||
domain={domain} | ||
hasComments={false} | ||
hasFooter={hasFooter} | ||
id={id} | ||
isError={isError} | ||
isLoading={isLoading || !allData} | ||
studyType={studyType} | ||
> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
id={idWithDomainAndStudyType} | ||
options={optionsGraph} | ||
ref={chartRef} | ||
/> | ||
{hasComments && chartComments && ( | ||
<GraphComments comments={chartComments} hasFooter={hasFooter} /> | ||
)} | ||
</WrapperChart> | ||
); | ||
}; | ||
|
||
Chart.defaultProps = { | ||
domain: 'health', | ||
hasComments: true, | ||
hasFooter: true, | ||
id: 'general.dynamique.chart-evolution-within-1-year-by-year', | ||
studyType: 'Interventional', | ||
}; | ||
Chart.propTypes = { | ||
domain: PropTypes.oneOf(domains), | ||
hasComments: PropTypes.bool, | ||
hasFooter: PropTypes.bool, | ||
id: PropTypes.oneOf(graphIds), | ||
studyType: PropTypes.oneOf(studiesTypes), | ||
}; | ||
|
||
export default Chart; |
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
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
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