Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/components/BMDashboard/LessonsLearnt/LessonsLearntChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ const useLessonsData = (selectedProjects, startDate, endDate) => {
projectName: item.project || 'Unknown Project',
projectId: item.projectId,
lessonsCount: item.lessonsCount || 0,
percentage:
Number.parseFloat((item.changePercentage || '0%').replace('%', '').replace('+', '')) ||
0,
changePercentage: item.changePercentage || '0%',
changePercentage: item.changePercentage ?? 'N/A',
}));

// When multiple projects selected, filter to only the chosen ones
Expand Down Expand Up @@ -201,7 +198,7 @@ function LessonsLearntChart({ darkMode: propDarkMode }) {
align: 'end',
offset: 2,
font: { weight: 'bold', size: 11 },
formatter: (_value, ctx) => lessonsData[ctx.dataIndex]?.changePercentage || '0%',
formatter: (_value, ctx) => lessonsData[ctx.dataIndex]?.changePercentage ?? 'N/A',
color: ctx => changeColor(lessonsData[ctx.dataIndex]?.changePercentage, darkMode),
},
},
Expand Down Expand Up @@ -362,6 +359,12 @@ function LessonsLearntChart({ darkMode: propDarkMode }) {
<div className={styles.barContainer}>
<Bar data={chartData} options={chartOptions} plugins={[ChartDataLabels]} />
</div>

<p className={styles.statusText}>
Bars show the number of lessons in the selected date range. MoM Change shows the
percentage change compared with the previous month. N/A means the previous month had
zero lessons, so a percentage increase cannot be calculated.
</p>
</>
)}
</div>
Expand Down
Loading