@@ -2,6 +2,144 @@ import React from 'react'
2
2
import './profile-page.scss'
3
3
import capitolSvg from "../../assets/capitol.svg" ;
4
4
import Img from "react-image" ;
5
+ import { Pie } from '@nivo/pie'
6
+
7
+
8
+ const TOTAL_COUNT_OF_VERIFIED_COMMENTS = 650
9
+
10
+ const averageRating = ( ) => {
11
+ const absoluteLie = ( 0 * 92 ) / TOTAL_COUNT_OF_VERIFIED_COMMENTS
12
+ const completelyFalse = ( 1 * 212 ) / TOTAL_COUNT_OF_VERIFIED_COMMENTS
13
+ const barelyTrue = ( 2.5 * 135 ) / TOTAL_COUNT_OF_VERIFIED_COMMENTS
14
+ const halfTrue = ( 5 * 93 ) / TOTAL_COUNT_OF_VERIFIED_COMMENTS
15
+ const mostlyTrue = ( 7.5 * 72 ) / TOTAL_COUNT_OF_VERIFIED_COMMENTS
16
+ const completelyTrue = ( 10 * 29 ) / TOTAL_COUNT_OF_VERIFIED_COMMENTS
17
+
18
+ return ( (
19
+ absoluteLie +
20
+ completelyFalse +
21
+ barelyTrue +
22
+ halfTrue +
23
+ mostlyTrue +
24
+ completelyTrue
25
+ ) * 10 ) . toFixed ( 2 )
26
+ }
27
+
28
+ const percentage = ( number ) => {
29
+ return ( ( number / TOTAL_COUNT_OF_VERIFIED_COMMENTS ) * 100 ) . toFixed ( 2 )
30
+ }
31
+
32
+ const pie = ( ) => (
33
+ < Pie
34
+ width = { 500 }
35
+ height = { 500 }
36
+ data = { [
37
+ {
38
+ "id" : "Absolute Lie" ,
39
+ "label" : "Absolute Lie" ,
40
+ "value" : percentage ( 92 ) ,
41
+ "color" : "hsl(17, 70%, 50%)"
42
+ } ,
43
+ {
44
+ "id" : "Completely False" ,
45
+ "label" : "Completely False" ,
46
+ "value" : percentage ( 212 ) ,
47
+ "color" : "hsl(195, 70%, 50%)"
48
+ } ,
49
+ {
50
+ "id" : "Barely True" ,
51
+ "label" : "Barely True" ,
52
+ "value" : percentage ( 135 ) ,
53
+ "color" : "hsl(229, 70%, 50%)"
54
+ } ,
55
+ {
56
+ "id" : "Half True" ,
57
+ "label" : "Half True" ,
58
+ "value" : percentage ( 93 ) ,
59
+ "color" : "hsl(72, 70%, 50%)"
60
+ } ,
61
+ {
62
+ "id" : "Mostly True" ,
63
+ "label" : "Mostly True" ,
64
+ "value" : percentage ( 72 ) ,
65
+ "color" : "hsl(73, 70%, 50%)"
66
+ } ,
67
+ {
68
+ "id" : "Completely True" ,
69
+ "label" : "Completely True" ,
70
+ "value" : percentage ( 29 ) ,
71
+ "color" : "hsl(229, 70%, 50%)"
72
+ }
73
+ ] }
74
+ margin = { {
75
+ "top" : 0 ,
76
+ "right" : 125 ,
77
+ "bottom" : 125 ,
78
+ "left" : 100
79
+ } }
80
+ innerRadius = { 0.5 }
81
+ padAngle = { 0.7 }
82
+ cornerRadius = { 3 }
83
+ colors = "set1"
84
+ colorBy = "id"
85
+ borderWidth = { 1 }
86
+ borderColor = "inherit:darker(0.2)"
87
+ radialLabel = { 'id' }
88
+ radialLabelsSkipAngle = { 10 }
89
+ radialLabelsTextXOffset = { 6 }
90
+ radialLabelsTextColor = "#333333"
91
+ radialLabelsLinkOffset = { 3 } //
92
+ radialLabelsLinkDiagonalLength = { 16 }
93
+ radialLabelsLinkHorizontalLength = { 0 } //
94
+ radialLabelsLinkStrokeWidth = { 1 }
95
+ radialLabelsLinkColor = "inherit"
96
+ slicesLabelsSkipAngle = { 10 }
97
+ slicesLabelsTextColor = "#333333"
98
+ animate = { true }
99
+ motionStiffness = { 90 }
100
+ motionDamping = { 15 }
101
+ defs = { [
102
+ {
103
+ "id" : "dots" ,
104
+ "type" : "patternDots" ,
105
+ "background" : "inherit" ,
106
+ "color" : "rgba(255, 255, 255, 0.3)" ,
107
+ "size" : 4 ,
108
+ "padding" : 1 ,
109
+ "stagger" : true
110
+ } ,
111
+ {
112
+ "id" : "lines" ,
113
+ "type" : "patternLines" ,
114
+ "background" : "inherit" ,
115
+ "color" : "rgba(255, 255, 255, 0.3)" ,
116
+ "rotation" : - 45 ,
117
+ "lineWidth" : 6 ,
118
+ "spacing" : 10
119
+ }
120
+ ] }
121
+ // legends={[
122
+ // {
123
+ // "anchor": "bottom",
124
+ // "direction": "row",
125
+ // "translateY": 56,
126
+ // "itemWidth": 100,
127
+ // "itemHeight": 18,
128
+ // "itemTextColor": "#999",
129
+ // "symbolSize": 18,
130
+ // "symbolShape": "circle",
131
+ // "effects": [
132
+ // {
133
+ // "on": "hover",
134
+ // "style": {
135
+ // "itemTextColor": "#000"
136
+ // }
137
+ // }
138
+ // ]
139
+ // }
140
+ // ]}
141
+ />
142
+ )
5
143
6
144
class ProfilePage extends React . Component {
7
145
@@ -15,36 +153,30 @@ class ProfilePage extends React.Component {
15
153
}
16
154
17
155
return < div className = { classes . join ( ' ' ) } >
18
- < div className = 'top-banner' >
19
- < div className = 'info' >
20
- < Img
21
- src = { [ this . props . representativeInfo . photoUrl , capitolSvg ] }
22
- loader = { < img src = { capitolSvg } alt = { this . props . representativeInfo . name } /> }
23
- />
24
- < div className = 'name' > { this . props . representativeInfo . name } </ div >
25
- < div className = 'office' >
26
- { this . props . representativeInfo . office } - { this . props . representativeInfo . party } Party
27
- </ div >
156
+ < div className = 'top-banner' >
157
+ < div className = 'info' >
158
+ < Img
159
+ src = { [ this . props . representativeInfo . photoUrl , capitolSvg ] }
160
+ loader = { < img src = { capitolSvg } alt = { this . props . representativeInfo . name } /> }
161
+ />
162
+ < div className = 'name' > { this . props . representativeInfo . name } </ div >
163
+ < div className = 'office' >
164
+ { this . props . representativeInfo . office } - { this . props . representativeInfo . party } Party
28
165
</ div >
29
166
</ div >
30
- < div className = 'carousel-container' >
31
- < div className = 'carousel-header' > Recent Tweets</ div >
32
- < Carousel >
33
- < div >
34
- < img src = { require ( "../../assets/twitter-placeholder.png" ) } alt = { '' } />
35
- </ div >
36
- < div >
37
- < img src = { require ( "../../assets/twitter-placeholder.png" ) } alt = { '' } />
38
- </ div >
39
- < div >
40
- < img src = { require ( "../../assets/twitter-placeholder.png" ) } alt = { '' } />
41
- </ div >
42
- < div >
43
- < img src = { require ( "../../assets/twitter-placeholder.png" ) } alt = { '' } />
44
- </ div >
45
- </ Carousel >
167
+ </ div >
168
+
169
+ < div className = 'truthiness' >
170
+ < div className = 'pie-title' >
171
+ { this . props . representativeInfo . name } 's Truthfulness Rating:
172
+ </ div >
173
+ < div className = { 'truth-rating' } >
174
+ { averageRating ( ) } %
175
+ </ div >
176
+ { pie ( ) }
46
177
</ div >
47
178
</ div >
179
+
48
180
}
49
181
}
50
182
0 commit comments