Skip to content

Commit

Permalink
Update loading state in MainChartCard
Browse files Browse the repository at this point in the history
The loading state in MainChartCard has been updated to reflect the latest data fetching status. The previous code used a hardcoded timeout to set loading to false which was removed. A loading spinner from Ant Design was added to provide a better visual feedback when fetching the data.
  • Loading branch information
manu committed Jul 15, 2024
1 parent 57a88e5 commit 19c68fd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions client/src/pages/Dashboard/Components/MainChartCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { LoadingOutlined } from '@ant-design/icons';
import {
Card,
Col,
DatePicker,
Flex,
Row,
Select,
Tabs,
Expand Down Expand Up @@ -83,9 +85,7 @@ const MainChartCard: React.FC<any> = ({}) => {
console.log('fetch data failed', error);
});
}
setTimeout(() => {
setLoading(false);
}, 5000);
setLoading(false);
};

useEffect(() => {
Expand All @@ -96,13 +96,21 @@ const MainChartCard: React.FC<any> = ({}) => {
const config = {
data: graphData,
// Waiting for https://github.com/ant-design/ant-design-charts/issues/2580
//loading: loading,
loading: loading,
animate: { enter: { type: 'waveIn' } },
theme: {
view: {
viewFill: '#151921',
},
},
loadingTemplate: (
<Flex
justify={'center'}
style={{ backgroundColor: '#151921', width: '100%', height: '100%' }}
>
<LoadingOutlined style={{ fontSize: '32px' }} />
</Flex>
),
xField: 'date',
yField: 'value',
colorField: 'name',
Expand Down

0 comments on commit 19c68fd

Please sign in to comment.