This repository has been archived by the owner on Jun 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completely restyled code based on Prettier code-formatter for consist…
…ency and improved readability
- Loading branch information
1 parent
5d2ba92
commit e05ef4d
Showing
1 changed file
with
43 additions
and
45 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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; | ||
|
e05ef4d
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.
Nice work Joseph. I’m a little puzzled by the relationship between MenuItem and renderMenuItem in ActionMenu.js.