Skip to content

Commit f8686b0

Browse files
committed
use ember-charts for user-tag-graph
1 parent 6079e1a commit f8686b0

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

app/pods/components/user-tag-graph/component.js

+32-6
Original file line numberDiff line numberDiff 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
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 numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
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>

0 commit comments

Comments
 (0)