diff --git a/webapp/src/components/BarChartReport/custom-barChart.js b/webapp/src/components/BarChartReport/custom-barChart.js index 84e0ebc3..0bf2f7d2 100644 --- a/webapp/src/components/BarChartReport/custom-barChart.js +++ b/webapp/src/components/BarChartReport/custom-barChart.js @@ -4,16 +4,18 @@ import { makeStyles } from '@mui/styles' import PropTypes from 'prop-types' import { Box } from '@mui/system' import { - ComposedChart, - Bar, - XAxis, - YAxis, + ResponsiveContainer, CartesianGrid, + ComposedChart, Tooltip, Legend, - ResponsiveContainer + XAxis, + YAxis, + Bar } from 'recharts' +import Loader from '../Loader' + import CustomTooltipBarChart from './custom-tooltip-barChart' import styles from './styles' @@ -59,43 +61,49 @@ const CustomBarChart = ({ typeData, selectedUSD, data, barRef }) => { return ( - - - - - - } - /> - } /> - {legentsList.map(({ color, label }) => ( - + ) : ( + + + + + + } /> - ))} - + } /> + {legentsList.map(({ color, label }) => ( + + ))} + + )} ) } diff --git a/webapp/src/components/LineChartReport/custom-lineChart.js b/webapp/src/components/LineChartReport/custom-lineChart.js index d594ddf7..4d55e88d 100644 --- a/webapp/src/components/LineChartReport/custom-lineChart.js +++ b/webapp/src/components/LineChartReport/custom-lineChart.js @@ -11,6 +11,8 @@ import { Brush } from 'recharts' +import Loader from '../Loader' + import CustomTooltipLineChart from './custom-tooltip-lineChart' const renderTraveller = props => { @@ -73,77 +75,81 @@ const CustomLineChart = ({ coinType, data, lineRef }) => { height={300} marginTop="16px" > - - - - - } - /> - - - + ) : ( + - - - - - - + + + + } + /> + + + + + + + + + + )} ) } diff --git a/webapp/src/components/LineChartReport/index.js b/webapp/src/components/LineChartReport/index.js index 786fe203..938889e6 100644 --- a/webapp/src/components/LineChartReport/index.js +++ b/webapp/src/components/LineChartReport/index.js @@ -66,26 +66,29 @@ const LineChartReport = ({ }, [selectedUSD]) useEffect(() => { - if (viewSelected === 'last') { - const count = historicElections.length - 2 || 0 - const date = historicElections?.at(count)?.date_election.split('T')[0] - const subData = data?.filter(obj => obj.date >= date) - setDataChart(subData) - } + if (!viewSelected) return + + if (viewSelected === 'last') setDataChart([data.at(-2), data.at(-1)]) + if (viewSelected === 'all') setDataChart(data) + + setElectionRoundSelect('') }, [viewSelected]) useEffect(() => { if (!electionRoundSelect) return + const index = historicElections.findIndex( election => Number(election.election) === Number(electionRoundSelect) ) + const subData = data?.filter( objt => objt.date >= historicElections[index].date_election && - objt.date <= historicElections[index + 1]?.date_election + objt.date <= (historicElections[index + 1]?.date_election || objt.date) ) - setViewSelect(electionRoundSelect) + + setViewSelect('') setDataChart(subData) }, [electionRoundSelect]) @@ -130,7 +133,7 @@ const LineChartReport = ({ onClick={handleSelectElection} value="last" > - {t('estimated', { ns: 'incomeRoute' }).toUpperCase()} + {t('estimated', { ns: 'incomeRoute' })}