Add data from proposals to contribution chart

This commit is contained in:
2018-07-14 17:35:06 +02:00
parent 7a35f5177c
commit 2befc91d90
4 changed files with 71 additions and 16 deletions
@@ -1,17 +1,58 @@
import Component from '@ember/component'; import Component from '@ember/component';
import { computed } from '@ember/object';
let categoryColors = {
community: "#fb6868",
design: "#fbe468",
dev: "#e068fb",
docs: "#97fb68",
ops: "#8f68fb",
}
export default Component.extend({ export default Component.extend({
chartData: { contributions: null,
chartData: computed('contributions', function() {
let kredits = this.get('contributions')
.map(c => {
return { kind: c.kind, amount: c.amount }
}).reduce(function (kinds, c) {
if (c.kind in kinds) {
kinds[c.kind] = kinds[c.kind] + c.amount
} else {
kinds[c.kind] = c.amount;
}
return kinds;
}, {});
return {
datasets: [{ datasets: [{
data: [10, 20, 30] data: [
kredits['community'],
kredits['design'],
kredits['dev'],
kredits['ops'],
kredits['docs'],
],
borderColor: [
categoryColors.community,
categoryColors.design,
categoryColors.dev,
categoryColors.ops,
categoryColors.docs,
],
borderWidth: 1
}], }],
labels: [ labels: [
'Red', 'Community',
'Yellow', 'Design',
'Blue' 'Development',
] 'Operations & Infrastructure',
}, 'Documentation'
],
}
}),
chartOptions: { chartOptions: {
legend: { legend: {
@@ -1,5 +1,7 @@
{{ember-chart type='doughnut' <div class="chart">
{{ember-chart type='doughnut'
data=chartData data=chartData
options=chartOptions options=chartOptions
width=200 width=200
height=200}} height=200}}
</div>
+12
View File
@@ -62,6 +62,18 @@ section {
} }
} }
&#contributions-by-type {
.chart {
width: 50%;
margin-left: auto;
margin-right: auto;
}
@include media($mobile) {
width: 90%;
}
}
&#proposals-open, &#proposals-closed { &#proposals-open, &#proposals-closed {
.actions { .actions {
padding-top: 3rem; padding-top: 3rem;
+1 -1
View File
@@ -20,7 +20,7 @@
<h2>Contributions by type</h2> <h2>Contributions by type</h2>
</header> </header>
<div class="content"> <div class="content">
{{chart-contributions-by-type contributions=proposalsClosed}} {{chart-contributions-by-type contributions=proposals}}
</div> </div>
</section> </section>
</div> </div>