-
Notifications
You must be signed in to change notification settings - Fork 2
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
Added graphs for individual events #41
base: master
Are you sure you want to change the base?
Changes from 11 commits
3dee0ee
bf628f2
136051a
d61e059
4d44c64
6dbdf22
f47b3ed
5cda655
89ee34e
24fbb5b
cce94af
876adde
b876320
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//Edited from components/Events/UserEvents/event.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove these comments |
||
//To dynamically pull data, use components/Events/UserEvents/event.js as reference | ||
|
||
import React from 'react' | ||
import EventAnalytics from './eventAnalytics' | ||
import Config from 'config' | ||
|
||
export default class EventCard extends React.Component { | ||
//input: array of majors | ||
translate(majors) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this function doesn't really depend on anything in the |
||
|
||
const majorMap = Config.majorMap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix spacing |
||
|
||
const decideMajor = inputMajor => { | ||
for (let j = 0; j < majorMap.length; j++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use ES6 for (const { major, criteria } of majorMap) |
||
const { major, criteria } = majorMap[j]; | ||
const output = criteria.find(({ val }) => inputMajor.match(val)); | ||
if (output) { | ||
return major; | ||
} | ||
} | ||
return "Other" | ||
} | ||
|
||
let reducedMajors = majors.map(decideMajor); | ||
console.log(reducedMajors); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove debugging outputs |
||
} | ||
|
||
render() { | ||
|
||
this.translate(["computer science", "computer science and engineering", "electrical engineering", "mathematics of computation", "cognitive science", "linguistics and computer science", "math of computation", "applied mathematics", "undeclared engineering", "physics", "computer science & engineering", "computational and systems biology", "economics", "statistics", "mathematics", "bioengineering", "biochemistry", "mathematics/economics", "neuroscience", "chemistry", "mechanical engineering", "cs", "computer science engineering", "business economics", "cse", "civil engineering", "chemical engineering", "electrical and computer engineering", "math", "computational & systems biology", "computer engineering"]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this |
||
|
||
const className = "event-card user-card"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this variable is unnecessary |
||
return( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure your indentation is consistent |
||
<div className={className}> | ||
<div className="content"> | ||
<h2>THIS IS A VERY LONG EVENT TITLE THAT WILL OVERFLOW THE DIV</h2> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change this back to something normal. When we add the reducer for event analytics, we can templatize all of these. |
||
<h3>Event Committee</h3> | ||
|
||
|
||
|
||
<div className="points-container"> | ||
<div className="points Headline-2Secondary">100</div> | ||
<div className="label SubheaderSecondary">attendees</div> | ||
</div> | ||
|
||
|
||
|
||
<div className="subcontent"> | ||
<span className="time">7:00 am — 11:00 am</span> | ||
<p className="location">Event Location</p> | ||
</div> | ||
<EventAnalytics /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import Button from 'components/Button'; | ||
import Event from './event.js'; | ||
import { Chart } from 'chart.js' | ||
import { Bar } from 'react-chartjs-2' | ||
|
||
|
||
|
||
export default class EventAnalytics extends React.Component { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change this component to take in the data and labels through props instead of hard coding. For example, you might pass in: const yearData = { 1: 100, 2: 50, 3: 25, 4: 10 };
const majorData= { "CS/CSE": 300, "Ling CS": 100, "Math": 25 };
<EventAnalytics yearData={yearData} majorData={majorData} /> And then use the passed in objects to derive the labels, data, and display them. |
||
|
||
render() { | ||
const yearData = { | ||
labels: ["1", "2", "3", "4", "5+"], | ||
datasets: [{ | ||
label: 'Attendees', | ||
data: [400, 150, 30, 15, 5], | ||
backgroundColor: [ | ||
'rgba(255, 99, 132, 0.2)', | ||
'rgba(255, 159, 64, 0.2)', | ||
'rgba(255, 206, 86, 0.2)', | ||
'rgba(75, 192, 192, 0.2)', | ||
'rgba(54, 162, 235, 0.2)' | ||
], | ||
borderColor: [ | ||
'rgba(255,99,132,1)', | ||
'rgba(255, 159, 64, 1)', | ||
'rgba(255, 206, 86, 1)', | ||
'rgba(75, 192, 192, 1)', | ||
'rgba(54, 162, 235, 1)' | ||
], | ||
borderWidth: 1 | ||
}], | ||
options: { | ||
legend: { | ||
display: false | ||
} | ||
} | ||
}; | ||
|
||
const majorData = { | ||
labels: ["CS", "Ling CS", "Math CS"], | ||
datasets: [{ | ||
label: 'Attendees', | ||
data: [520, 150, 30], | ||
backgroundColor: [ | ||
'rgba(255, 99, 132, 0.2)', | ||
'rgba(75, 192, 192, 0.2)', | ||
'rgba(54, 162, 235, 0.2)' | ||
], | ||
borderColor: [ | ||
'rgba(255,99,132,1)', | ||
'rgba(75, 192, 192, 1)', | ||
'rgba(54, 162, 235, 1)' | ||
], | ||
borderWidth: 1 | ||
}] | ||
}; | ||
|
||
return ( | ||
<div className="chartWrapper"> | ||
<h3 className="chart-title">Attendees By Year</h3> | ||
<Bar data={yearData} options={{legend: { display: false }}} /> | ||
<h3 className="chart-title">Attendees By Major</h3> | ||
<Bar data={majorData} options={{legend: { display: false }}} /> | ||
</div> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,4 @@ export default class Leaderboard extends React.Component { | |
); | ||
} | ||
} | ||
} | ||
} |
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.
Don't commit this