Download a chart as an image (CSV, PNG, JPEG)
Merge request reports
Activity
assigned to @mohammad.torkashvand
1 import React, { useContext, ForwardRefExoticComponent, RefAttributes } from 'react'; 2 import { ChartContainerContext } from '../../helpers/ChartContainerProvider'; 3 import { Table, TableProps } from "react-bootstrap"; 4 5 const OriginalTable: ForwardRefExoticComponent<TableProps & RefAttributes<HTMLTableElement>> = Table; 6 7 const ChartTable: React.FC<TableProps> = (props) => { 8 const tableContainerRef = useContext(ChartContainerContext); 9 10 return ( 11 <div ref={tableContainerRef}> 12 <OriginalTable {...props} /> I think this should just render the children of the component (props destructured {children}), instead of requiring the table.. and reuse this across both chartjs graphs and tables
rename it to something like ChartContainer, as it's just a way to get a reference to the parent of whatever we're showing to be able to render it with domtoimage
Edited by Bjarke Madsenchanged this line in version 6 of the diff
46 47 data: BasicDataset 47 48 } 48 49 49 function LineGraph({ data }: inputProps): ReactElement { 50 return ( 51 <Line data={data} options={options} /> 52 ); 50 function LineGraph({data}: inputProps): ReactElement { 51 const chartContainerRef = useContext(ChartContainerContext); 52 53 return ( 54 <div ref={chartContainerRef}> reuse the (renamed) chartTable component instead
Edited by Bjarke Madsenchanged this line in version 7 of the diff
7 8 } 8 9 9 10 const WithLegend: React.FC<InputProps> = ({ children, location }) => { 11 const chartContainerRef = useContext(ChartContainerContext); 10 12 11 13 if (!location) location = "both"; 12 14 const top = location === "top" || location === "both"; 13 15 const bottom = location === "bottom" || location === "both"; 14 16 15 17 return ( 16 <> 18 <div ref={chartContainerRef}> changed this line in version 7 of the diff
57 59 <DownloadDataButton data={chargingStructureData} filename="charging_mechanism_of_nrens_per_year.csv" exportType={ExportType.CSV}/> 58 60 <DownloadDataButton data={chargingStructureData} filename="charging_mechanism_of_nrens_per_year.xlsx" exportType={ExportType.EXCEL} /> 59 61 </Row> 60 <Table className="charging-struct-table" striped bordered responsive> 62 <DownloadImageChartButton filename="charging_mechanism_of_nrens_per_year"/> 63 <ChartTable className="charging-struct-table" striped bordered responsive> changed this line in version 6 of the diff
62 64 <DownloadDataButton data={projectData} filename="nren_involvement_in_european_commission_projects.csv" exportType={ExportType.CSV}/> 63 65 <DownloadDataButton data={projectData} filename="nren_involvement_in_european_commission_projects.xlsx" exportType={ExportType.EXCEL}/> 64 66 </Row> 65 <Table borderless className='compendium-table'> 67 <DownloadImageChartButton filename="nren_involvement_in_european_commission_projects"/> 68 <ChartTable borderless className='compendium-table'> changed this line in version 6 of the diff
156 159 <DownloadDataButton data={fundingSourceData} filename="income_source_of_nren_per_year.csv" exportType={ExportType.CSV}/> 157 160 <DownloadDataButton data={fundingSourceData} filename="income_source_of_nren_per_year.xlsx" exportType={ExportType.EXCEL}/> 158 161 </Row> 159 <div> 162 <DownloadImageChartButton filename="income_source_of_nren_per_year"/> 163 <div ref={chartRef}> reuse (renamed) ChartTable in place of the div
Edited by Bjarke Madsenchanged this line in version 7 of the diff
56 58 <DownloadDataButton data={organisationData} filename="nren_parent_organisations.csv" exportType={ExportType.CSV}/> 57 59 <DownloadDataButton data={organisationData} filename="nren_parent_organisations.xlsx" exportType={ExportType.EXCEL}/> 58 60 </Row> 59 <Table borderless className='compendium-table'> 61 <DownloadImageChartButton filename='nren_parent_organisations'/> 62 <ChartTable borderless className='compendium-table'> changed this line in version 6 of the diff
73 75 <tbody> 74 76 {getJSXFromMap(organisationDataset)} 75 77 </tbody> 76 </Table> 78 </ChartTable> changed this line in version 6 of the diff
added 1 commit
- 25bcf066 - renamed TableWrapper to ChartContainer and maked it general
added 1 commit
- 65ce8e37 - renamed TableWrapper to ChartContainer and maked it general
added 1 commit
- 0a7b20d3 - renamed ChartTable to ChartContainer and made it general
mentioned in commit ffeaffcb