Skip to content
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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
8 changes: 7 additions & 1 deletion src/components/ControlPanel/controlPanel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import Button from 'components/Button';
import Event from './event'

export default class ControlPanelComponent extends React.Component {
render() {
Expand Down Expand Up @@ -41,8 +42,13 @@ export default class ControlPanelComponent extends React.Component {
<option>Studio</option>
<option>W</option>
</select>

</div>

<Event />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't commit this

<Event />
<Event />
<Event />
<Event />
</div>
);
}
Expand Down
58 changes: 58 additions & 0 deletions src/components/ControlPanel/event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//Edited from components/Events/UserEvents/event.js
Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this function doesn't really depend on anything in the EventCard class or doesn't have anything to do with this file, put it in utils.js (in src/) and import it from there.


const majorMap = Config.majorMap;
Copy link
Contributor

Choose a reason for hiding this comment

The 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++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ES6 for syntax:

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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this


const className = "event-card user-card";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is unnecessary

return(
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
);
}
}
68 changes: 68 additions & 0 deletions src/components/ControlPanel/eventAnalytics.js
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
);
}
}
113 changes: 112 additions & 1 deletion src/components/ControlPanel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,115 @@
padding: 5px 0px;
}
}
}

.event-card {
display: inline-block;
vertical-align: top;
text-align: left;
width: calc((100vw - 550px)/2);
margin: 20px;
border-radius: 4px;
box-shadow: 0px 0px 3px #D2D2D2;
background-color: white;
transition: 0.125s ease-in-out;
// border: 3px solid $light-green;

@media (max-width: 1224px) {
width: calc((100vw - 500px));
}

@media (max-width: 690px) {
margin: 20px 0px;
}

@media (max-width: 340px) {
width: 300px;
}

&.selected {
transform: scale(1.02, 1.02);
}

&.selected:hover {
background: white;
}

&.admin-card {
margin-left: 10px;
}

.content {
padding: 20px;
position: relative;

h2 {
margin-right: 100px;
}

.points-container {
position: absolute;
height: 60px;
width: 85px;
border-radius: 50px;
line-height: 50px;
right: 12px;
top: 12px;
border: 1px solid #DADADA;
background-color: white;
text-align: center;

.label {
line-height: 0px;
margin-top: -10px;
font-size: 0.85em;
}

.points {
font-size: 1.1em;
}
}

.chartWrapper {
margin-top: 20px;

.chart-title {
text-align: center;
}
}
}

h2 {
color: #333333;
margin: 0;
}

h3 {
text-transform: uppercase;
font-size: 1.0em;
font-weight: 400;
color: #555555;
margin: 5px 0px;
}

p {
padding-top: 5px;
}

.subcontent {
border-top: 1px solid #F2F2F2;
margin-top: 10px;
padding-top: 10px;
color: #666666;
font-weight: 300;
font-size: 0.8em;

.time {
font-weight: 400;
}

.location {
padding-bottom: 0px;
}
}
}
}
2 changes: 1 addition & 1 deletion src/components/Leaderboard/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ export default class Leaderboard extends React.Component {
);
}
}
}
}
1 change: 1 addition & 0 deletions src/components/Topbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class Topbar extends React.Component {
<NavLink to="/events" activeClassName="selected"><NavigationItem icon="fa-calendar" text="Events" /></NavLink>
<NavLink to="/leaderboard" activeClassName="selected"><NavigationItem icon="fa-list" text="Members" /></NavLink>
<NavLink to="/resources" activeClassName="selected"> <NavigationItem icon="fa-building-o" text="Organization" /></NavLink>
<NavLink to="/controlpanel" activeClassName="selected"> <NavigationItem icon="fa-gamepad fa-2x" text="Admin" /></NavLink>
</div>
}
</div>
Expand Down
Loading