-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event stats #36
Open
isa-leroux448
wants to merge
41
commits into
dev
Choose a base branch
from
event-stats
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Event stats #36
Changes from 9 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
09795f2
init layout and styling
isa-leroux448 5e3ddf1
add tailwind styling and refactor
isa-leroux448 0d2055b
add responsiveness
isa-leroux448 bfbe843
add navbar profile link
isa-leroux448 16bbc2c
replace bizbot svg with png
isa-leroux448 e04139c
achieved front-end view for pop up. just need to plan how the data wi…
m20arcusk 8b3ce41
frontend visuals achieved, just need to refactor the method the data …
m20arcusk 0960883
updated and imported some types for the questions and respones as wel…
m20arcusk 7a29faa
small fix on a comment
m20arcusk a519108
didn't mean to delete BasicInformation in types.ts so I added it back
m20arcusk a3279ab
update mock registrant data
isa-leroux448 f22c4b2
create percentage bar component
isa-leroux448 811fdb6
create basic layout
isa-leroux448 a5d779f
make charts responsive on horizontal resize
isa-leroux448 bdf2754
removed console.log testing lines and updated tailwind with divider c…
m20arcusk d16fc21
updated the fetchQuestion function to use async and await
m20arcusk 37d9f2a
fetch backend
AllanT102 58753d5
add responsiveness
isa-leroux448 3e2f2dc
responsiveness fixes
isa-leroux448 347bd40
code clean up
isa-leroux448 b6eb611
Merge branch 'dev' of https://github.com/ubc-biztech/bt-web-v2 into e…
isa-leroux448 2cce179
fetch backend
AllanT102 be3925a
Delete .env
AllanT102 1aef301
ignore
AllanT102 f817709
changed to use async and await and now grabbing user responses from r…
m20arcusk 0f6fb2a
update types
isa-leroux448 ece81fb
comment out edit text
isa-leroux448 1fa423d
update date handling in profile event card
isa-leroux448 a712364
Merge branch 'dev' of https://github.com/ubc-biztech/bt-web-v2 into p…
isa-leroux448 34adaa5
move head
isa-leroux448 edbbf14
updated userResponse type and changed how it is accessed in userRespo…
m20arcusk 8185620
Merge pull request #37 from ubc-biztech/fetchbackend
AllanT102 5ab669a
resolved merge conflicts
m20arcusk 231e7ec
Merge pull request #34 from ubc-biztech/registration-user-popup
m20arcusk d5c4fea
Merge branch 'dev' of https://github.com/ubc-biztech/bt-web-v2 into p…
isa-leroux448 38064ee
Merge pull request #26 from ubc-biztech/profile-page
isa-leroux448 af530d7
add chart empty states
isa-leroux448 9edec04
replace Attendee type with Registration
isa-leroux448 d1bb883
Merge branch 'event-stats' of https://github.com/ubc-biztech/bt-web-v…
isa-leroux448 cf8ce98
fix attendee table popup nested object issues
isa-leroux448 2227669
fix package-lock file
isa-leroux448 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.dynamicWidth { | ||
width: 100%; | ||
} | ||
|
||
@media (min-width: 1024px) { | ||
.dynamicWidth { | ||
width: var(--dynamic-width); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { ReactNode } from "react"; | ||
import styles from './ChartBox.module.css' | ||
|
||
interface ChartBoxProps { | ||
height?: string; | ||
width?: string; | ||
title: string; | ||
children: ReactNode; | ||
} | ||
|
||
const ChartBox: React.FC<ChartBoxProps> = ({ | ||
children, | ||
title, | ||
height = "100%", | ||
width = "100%", | ||
}) => { | ||
return ( | ||
<div | ||
className={`bg-dark-slate my-2 p-4 flex flex-col rounded ${styles.dynamicWidth}`} | ||
style={{ | ||
height: height, | ||
'--dynamic-width': width | ||
} as React.CSSProperties} | ||
> | ||
<p className="text-white font-600 mb-2">{title}</p> | ||
<div className="flex-grow flex items-center"> | ||
<div className="flex-grow">{children}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChartBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { StatsChartData } from "@/types/types"; | ||
|
||
interface PercentageBarsProps { | ||
data: StatsChartData[]; | ||
} | ||
|
||
export const barColors = ['#A0C86E', '#75CFF5', '#E75A7C', '#FFC960', '#C082D6', '#7F94FF', '#EB8273'] | ||
|
||
const calculateBarPercentages = ( | ||
data: StatsChartData[], | ||
total: number | ||
) => { | ||
const percentages: { [key: string]: number } = {}; | ||
|
||
data.forEach((item) => { | ||
const { label, value } = item; | ||
percentages[label] = (value / total) * 100; | ||
}); | ||
return percentages; | ||
}; | ||
|
||
const getColorForIndex = (index: number): string => { | ||
return barColors[index % barColors.length]; | ||
}; | ||
|
||
const PercentageBars: React.FC<PercentageBarsProps> = ({ data }) => { | ||
const [total, setTotal] = useState(0); | ||
const [percentages, setPercentages] = useState<{ [key: string]: number }>({}); | ||
|
||
useEffect(() => { | ||
const totalValue = data.reduce((sum, item) => sum + item.value, 0); | ||
setTotal(totalValue); | ||
setPercentages(calculateBarPercentages(data, totalValue)); | ||
}, [data]); | ||
|
||
return ( | ||
<div> | ||
<div className="flex h-[50px] w-full mb-3 pt-6"> | ||
{Object.entries(percentages).map(([label, percentage], index) => ( | ||
<div | ||
key={label} | ||
className="flex items-center justify-center relative" | ||
style={{ | ||
flex: `0 0 ${percentage}%`, | ||
backgroundColor: getColorForIndex(index), | ||
borderTopLeftRadius: index === 0 ? "4px" : "0", | ||
borderBottomLeftRadius: index === 0 ? "4px" : "0", | ||
borderTopRightRadius: | ||
index === Object.entries(percentages).length - 1 ? "4px" : "0", | ||
borderBottomRightRadius: | ||
index === Object.entries(percentages).length - 1 ? "4px" : "0", | ||
}} | ||
> | ||
<div className="absolute top-[-25px] left-[50%] text-white text-sm font-medium translate-x-[-50%]"> | ||
{percentage.toFixed(1)}% | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
<div className="flex items-center w-full text-white"> | ||
<div className="flex flex-wrap"> | ||
{Object.keys(percentages).map((label, index) => ( | ||
<div key={label} className="flex items-center mr-5 text-xs"> | ||
<div | ||
className="w-4 h-4 mr-2 rounded-[2px]" | ||
style={{ | ||
backgroundColor: getColorForIndex(index), | ||
}} | ||
/> | ||
<span>{label}</span> | ||
</div> | ||
))} | ||
</div> | ||
<p className="ml-auto self-end font-600">Total registered: {total}</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PercentageBars; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is total always gonna be non zero?