From 1d510951e5dce1d7cdfcf7c6cf973337f2a51ed0 Mon Sep 17 00:00:00 2001 From: Riku Rauhala Date: Thu, 29 Aug 2024 11:51:39 +0300 Subject: [PATCH] [Study programme] Update graduation time labels and tooltips #4580 --- .../StudyProgramme/MedianTimeBarChart.jsx | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/services/frontend/src/components/StudyProgramme/MedianTimeBarChart.jsx b/services/frontend/src/components/StudyProgramme/MedianTimeBarChart.jsx index ac4dac4a15..9fb4cc73c6 100644 --- a/services/frontend/src/components/StudyProgramme/MedianTimeBarChart.jsx +++ b/services/frontend/src/components/StudyProgramme/MedianTimeBarChart.jsx @@ -15,26 +15,14 @@ export const MedianTimeBarChart = ({ data, goal, title, byStartYear }) => { return y > max ? y : max }, goal * 2) - const getPercentage = (amount, classSize) => { - const percent = Math.round((amount / classSize) * 100 * 10) / 10 - return Number.isNaN(percent) ? 0 : percent - } - - const getDataLabel = (amount, classSize = undefined) => { - if (byStartYear) { - return `${amount} graduated (${getPercentage(amount, classSize)} % of class)` - } - return `${amount} graduated` - } - const getHeight = () => { const multiplier = data.length > 8 ? 35 : 55 return data.length * multiplier + 100 } - const getTooltipText = (amount, y, year, statistics, classSize) => { + const getTooltipText = (amount, y, year, statistics) => { const sortingText = byStartYear - ? `From class of ${year}, ${amount}/${classSize} students have graduated` + ? `From class of ${year}, ${amount} students have graduated` : `${amount} students graduated in year ${year}` const timeText = `
${sortingText}
median study time: ${y} months
` @@ -57,7 +45,7 @@ export const MedianTimeBarChart = ({ data, goal, title, byStartYear }) => { fontSize: '25px', // eslint-disable-next-line formatter: function () { - return getTooltipText(this.point.amount, this.y, this.point.name, this.point.statistics, this.point?.classSize) + return getTooltipText(this.point.amount, this.y, this.point.name, this.point.statistics) }, }, plotOptions: { @@ -82,7 +70,7 @@ export const MedianTimeBarChart = ({ data, goal, title, byStartYear }) => { }, // eslint-disable-next-line formatter: function () { - return getDataLabel(this.point.amount, this.point?.classSize) + return `${this.point.amount} graduated` }, }, ],