@@ -8,7 +8,6 @@ import DatePicker from 'react-datepicker';
88
99import styles from './LessonsLearntChart.module.css' ;
1010import 'react-datepicker/dist/react-datepicker.css' ;
11- import './LessonsLearntChart.css' ;
1211
1312ChartJS . register ( BarElement , CategoryScale , LinearScale , Tooltip , Title ) ;
1413
@@ -65,8 +64,32 @@ const LessonsLearntChart = () => {
6564 endDate ,
6665 ) ;
6766
67+ const handleProjectChange = selected => {
68+ setSelectedProjects ( selected || [ ] ) ;
69+ } ;
70+
71+ const chartData = {
72+ labels : lessonsData . map ( d => d . projectName ) ,
73+ datasets : [
74+ {
75+ label : 'Lessons Learnt' ,
76+ data : lessonsData . map ( d => d . percentage ) ,
77+ backgroundColor : '#10b981' ,
78+ } ,
79+ ] ,
80+ } ;
81+
82+ const chartOptions = {
83+ responsive : true ,
84+ plugins : {
85+ title : {
86+ display : false ,
87+ } ,
88+ } ,
89+ } ;
90+
6891 return (
69- < div className = " styles.chartContainer" >
92+ < div className = { styles . chartContainer } >
7093 < ChartTitle title = "Lessons Learnt" />
7194
7295 < div className = { styles . filterRow } >
@@ -93,19 +116,34 @@ const LessonsLearntChart = () => {
93116 </ div >
94117
95118 < div className = { styles . chartWrapper } >
96- { isLoading ? < p > Loading...</ p > : < Bar data = { chartData } options = { chartOptions } /> }
97- < div className = { styles . percentageLabels } >
98- { lessonsData . map ( ( d , idx ) => (
99- < span
100- key = { idx }
101- className = { styles . percentageLabel }
102- style = { { left : `${ ( idx + 0.5 ) * ( 100 / lessonsData . length ) } %` } }
103- >
104- { d . percentage } %
105- </ span >
106- ) ) }
107- </ div >
119+ { isLoading ? (
120+ < p > Loading...</ p >
121+ ) : lessonsData . length === 0 ? (
122+ < p > No lessons data available for the selected criteria</ p >
123+ ) : (
124+ < >
125+ < Bar data = { chartData } options = { chartOptions } />
126+ < div className = { styles . percentageLabels } >
127+ { lessonsData . map ( ( d , idx ) => (
128+ < span
129+ key = { idx }
130+ className = { styles . percentageLabel }
131+ style = { {
132+ left :
133+ lessonsData . length > 0
134+ ? `${ ( idx + 0.5 ) * ( 100 / lessonsData . length ) } %`
135+ : '0%' ,
136+ } }
137+ >
138+ { d . percentage } %
139+ </ span >
140+ ) ) }
141+ </ div >
142+ </ >
143+ ) }
108144 </ div >
109145 </ div >
110146 ) ;
111147} ;
148+
149+ export default LessonsLearntChart ;
0 commit comments