File tree Expand file tree Collapse file tree 2 files changed +37
-9
lines changed
app/pods/components/user-tag-graph Expand file tree Collapse file tree 2 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -9,21 +9,47 @@ export default class UserTagComponent extends Component {
9
9
10
10
@alias ( 'fetchUserTagsTask.lastSuccessful.value' ) userTags
11
11
12
+ options = {
13
+ legend : {
14
+ display : false
15
+ } ,
16
+ scales : {
17
+ xAxes : [ {
18
+ barThickness : 30 ,
19
+ gridLines : {
20
+ offsetGridLines : true
21
+ }
22
+ } ]
23
+ }
24
+ }
25
+
12
26
@computed ( 'userTags.@each.tag' , 'userTags.@each.rating' )
13
27
get chartData ( ) {
14
28
const userTags = this . get ( 'userTags' )
15
29
if ( userTags ) {
16
- return userTags . map ( ut => {
17
- return {
18
- x : ut . get ( 'tag.name' ) ,
19
- y : Math . round ( ut . get ( 'rating' ) )
20
- }
21
- } )
30
+ return {
31
+ labels : userTags . map ( _ => _ . get ( 'tag.name' ) ) ,
32
+ datasets : [
33
+ {
34
+ data : userTags . map ( _ => + _ . get ( 'rating' ) ) ,
35
+ fill :false ,
36
+ backgroundColor : this . gradient
37
+ }
38
+ ]
39
+ }
22
40
} else {
23
41
return [ ]
24
42
}
25
43
}
26
44
45
+ didInsertElement ( ) {
46
+ const ctx = document . getElementsByTagName ( 'canvas' ) [ 0 ] . getContext ( "2d" )
47
+ const gradient = ctx . createLinearGradient ( 0 , 0 , 0 , 200 )
48
+ gradient . addColorStop ( 0 , '#ec6333' )
49
+ gradient . addColorStop ( 1 , '#f19633' )
50
+ this . set ( 'gradient' , gradient )
51
+ }
52
+
27
53
didReceiveAttrs ( ) {
28
54
this . fetchUserTagsTask . perform ( )
29
55
}
Original file line number Diff line number Diff line change 1
1
<div class =" border-card" >
2
2
<h4 class =" t-align-c mb-4" >Topic-Vise Performance</h4 >
3
3
4
- {{ #if chartData }}
5
- <BarChart @data ={{ chartData }} />
6
- {{ /if }}
4
+ <EmberChart
5
+ @type =" bar"
6
+ @options ={{ options }}
7
+ @data ={{ chartData }} />
8
+
7
9
</div >
You can’t perform that action at this time.
0 commit comments