Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
completely restyled code based on Prettier code-formatter for consist…
Browse files Browse the repository at this point in the history
…ency and improved readability
  • Loading branch information
josephjdkim committed Oct 3, 2019
1 parent 5d2ba92 commit e05ef4d
Showing 1 changed file with 43 additions and 45 deletions.
88 changes: 43 additions & 45 deletions webapp/src/components/PopulationGraph.js
@@ -1,54 +1,52 @@
import React from "react";
import { LineChart } from "react-chartkick"
import "chart.js"
import { LineChart } from "react-chartkick";
import "chart.js";

const FMARKET = 5
const FMARKET = 5;

function PopulationGraph(props) {
if (props.loadingData){
var data=[]
console.log("props.id = " + props.id)
if (props.id !== FMARKET){
let env=props.env_file["pop_hist"]["pops"]
Object.keys(env).map((group, i_group) => {
console.log(props.env_file["members"][group]["attrs"]["color"])
/*
* Must determine what this code does and write it more clearly
* if possible.
*/
return(
data.push({name: group, color: props.env_file["members"][group]["attrs"]["color"],
data: {}}),
Object.keys(env[group]).map((member, i_member) => {
console.log(member)
return(
data[i_group]["data"][member] = env[group][i_member]
)
})
)
});
}
else {
let period = props.env_file["pop_hist"]["periods"]
let data_hist = props.env_file["members"]["market_maker"]["attrs"]["price_hist"]
var i
data.push({name: "price history", data:{}})
for (i = 0; i < period; i++){
data[0]["data"][i] = data_hist[i]
}
}
console.log("data passed to line graph",data)
if (props.loadingData) {
var data = [];
console.log("props.id = " + props.id);
if (props.id !== FMARKET) {
let env = props.env_file["pop_hist"]["pops"];
Object.keys(env).map((group, i_group) => {
console.log(props.env_file["members"][group]["attrs"]["color"]);
/*
* Must determine what this code does and write it more clearly
* if possible.
*/
return (
<div>
<LineChart
data={data} width="600px" height="600px"
/>
</div>
data.push({
name: group,
color: props.env_file["members"][group]["attrs"]["color"],
data: {}
}),
Object.keys(env[group]).map((member, i_member) => {
console.log(member);
return (data[i_group]["data"][member] = env[group][i_member]);
})
);
});
} else {
let period = props.env_file["pop_hist"]["periods"];
let data_hist =
props.env_file["members"]["market_maker"]["attrs"]["price_hist"];
var i;
data.push({ name: "price history", data: {} });
for (i = 0; i < period; i++) {
data[0]["data"][i] = data_hist[i];
}
}
else{
return(null)
}};
console.log("data passed to line graph", data);
return (
<div>
<LineChart data={data} width="600px" height="600px" />
</div>
);
} else {
return null;
}
}

export default PopulationGraph;

1 comment on commit e05ef4d

@gcallah
Copy link
Owner

@gcallah gcallah commented on e05ef4d Oct 4, 2019

Choose a reason for hiding this comment

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

Nice work Joseph. I’m a little puzzled by the relationship between MenuItem and renderMenuItem in ActionMenu.js.

Please sign in to comment.