Skip to content

Commit 7297103

Browse files
committed
charts coming in, nearly finished for now
1 parent c73391b commit 7297103

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

build/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ a:focus {
5858

5959
.reference-line-label {
6060
float: right;
61+
margin-right: 10%;
62+
}
63+
64+
.pie-container {
65+
margin-top: 20px;
66+
padding: 0px;
6167
}

src/components/Charts.js

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import s from '../styles/app.style.js'
33
const twitchMineVid = require('file-loader!./twitchminedemo.mp4');
4-
import { Area, AreaChart, LineChart, Line, ResponsiveContainer, XAxis, YAxis, ReferenceLine } from 'recharts';
4+
import { Area, AreaChart, LineChart, Line, ResponsiveContainer, XAxis, YAxis, PieChart, Pie, ReferenceLine, Cell, Label } from 'recharts';
55

66
const areaChartData = [
77
{age: 1, hours: 0},
@@ -30,9 +30,25 @@ const areaChartData = [
3030
{age: 24, hours: 5.8},
3131
{age: 25, hours: 3},
3232
{age: 26, hours: 0},
33-
{age: 27, hours: 0}
33+
{age: 27, hours: 0},
34+
{age: 28, hours: 0},
35+
{age: 29, hours: 0},
36+
{age: 30, hours: 0},
37+
{age: 31, hours: 0}
3438
]
3539

40+
const pieDataNormal = [
41+
{feel: 'concerned', value: .10},
42+
{day: 'not concerned', value: .9}
43+
]
44+
45+
const pieDataWindy = [
46+
{day: 'concerned', value: .99},
47+
{day: 'not concerned', value: .01}
48+
]
49+
50+
const Colors = ['rgba(165, 210, 95, 0.7)', 'rgb(225, 225, 225)']
51+
3652
export default class Charts extends React.Component {
3753

3854
render() {
@@ -45,23 +61,49 @@ export default class Charts extends React.Component {
4561
<ResponsiveContainer height={300} margin={{ top: 50, right: 10, left: 10, bottom: 5 }}>
4662
<AreaChart data={areaChartData} dot={false}>
4763
<Area dataKey="hours" style={{fill: 'rgba(165, 210, 95, 0.7)', stroke: 'none'}}/>
48-
<XAxis dataKey="age" type="number" tickLine={false} tick={false} />
49-
<ReferenceLine x={25} style={{stroke: 'green'}}/>
64+
<XAxis dataKey="age" type="number" tickLine={false} tick={false} style={{stroke: 'rgb(205, 205, 205)'}}/>
65+
<ReferenceLine x={25} style={{stroke: 'rgb(155, 155, 155)'}}/>
5066
</AreaChart>
5167
</ResponsiveContainer>
5268
</div>
5369
</div>
5470
<div className="row work-row">
5571
<div className="col-sm-10 col-sm-offset-1">
5672
<h4 className="text-muted"><strong>PERCENT OF DAY SPENT CONCERNED WITH RECEDING HAIRLINE</strong></h4>
57-
<h6 className="reference-line-label">Moved in with girlfriend</h6>
58-
<ResponsiveContainer height={300} margin={{ top: 50, right: 10, left: 10, bottom: 5 }}>
59-
<AreaChart data={areaChartData} dot={false}>
60-
<Area dataKey="hours" style={{fill: 'rgba(165, 210, 95, 0.7)', stroke: 'none'}}/>
61-
<XAxis dataKey="age" type="number" tickLine={false} tick={false} />
62-
<ReferenceLine x={25} style={{stroke: 'green'}}/>
63-
</AreaChart>
73+
<div className="col-xs-6 pie-container">
74+
<h4 style={{textAlign: 'center'}}>On a normal day</h4>
75+
<ResponsiveContainer height={200}>
76+
<PieChart>
77+
<Pie data={pieDataNormal}
78+
style={{stroke: 'none'}}
79+
nameKey="feel"
80+
dataKey="value"
81+
innerRadius={60}
82+
outerRadius={80}
83+
fill='rgba(165, 210, 95, 0.7)'>
84+
{pieDataNormal.map((entry, index) => <Cell key={index} fill={Colors[index % Colors.length]} />)}
85+
<Label position="center" style={{fontSize: '16px', color: 'white'}}>10%</Label>
86+
</Pie>
87+
</PieChart>
88+
</ResponsiveContainer>
89+
</div>
90+
<div className="col-xs-6 pie-container">
91+
<h4 style={{textAlign: 'center'}}>On a windy day</h4>
92+
<ResponsiveContainer height={200}>
93+
<PieChart>
94+
<Pie data={pieDataWindy}
95+
style={{stroke: 'none'}}
96+
nameKey="feel"
97+
dataKey="value"
98+
innerRadius={60}
99+
outerRadius={80}
100+
fill='rgba(165, 210, 95, 0.7)'>
101+
{pieDataWindy.map((entry, index) => <Cell key={index} fill={Colors[index % Colors.length]} />)}
102+
<Label position="center">99%</Label>
103+
</Pie>
104+
</PieChart>
64105
</ResponsiveContainer>
106+
</div>
65107
</div>
66108
</div>
67109
</div>

0 commit comments

Comments
 (0)