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 {
99
1010 @alias ( 'fetchUserTagsTask.lastSuccessful.value' ) userTags
1111
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+
1226 @computed ( 'userTags.@each.tag' , 'userTags.@each.rating' )
1327 get chartData ( ) {
1428 const userTags = this . get ( 'userTags' )
1529 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+ }
2240 } else {
2341 return [ ]
2442 }
2543 }
2644
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+
2753 didReceiveAttrs ( ) {
2854 this . fetchUserTagsTask . perform ( )
2955 }
Original file line number Diff line number Diff line change 11<div class =" border-card" >
22 <h4 class =" t-align-c mb-4" >Topic-Vise Performance</h4 >
33
4- {{ #if chartData }}
5- <BarChart @data ={{ chartData }} />
6- {{ /if }}
4+ <EmberChart
5+ @type =" bar"
6+ @options ={{ options }}
7+ @data ={{ chartData }} />
8+
79</div >
You can’t perform that action at this time.
0 commit comments