Browse Source

Change bar color in statistics page

pull/1619/head
Hironsan 2 years ago
parent
commit
ed2341832b
3 changed files with 18 additions and 5 deletions
  1. 8
      frontend/components/statistics/CategoryDistribution.vue
  2. 7
      frontend/components/statistics/LabelDistribution.vue
  3. 8
      frontend/components/statistics/SpanDistribution.vue

8
frontend/components/statistics/CategoryDistribution.vue

@ -2,6 +2,7 @@
<label-distribution
title="Category Distribution"
:distribution="distribution"
:color-mapping="colorMapping"
/>
</template>
@ -16,12 +17,15 @@ export default Vue.extend({
data() {
return {
distribution: {}
distribution: {},
colorMapping: {},
}
},
async created() {
this.distribution = await this.$services.statistics.fetchCategoryDistribution(this.$route.params.id)
const labels = await this.$services.categoryType.list(this.$route.params.id)
this.colorMapping = Object.fromEntries(labels.map((label) => [label.text, label.backgroundColor]))
}
})
</script>
</script>

7
frontend/components/statistics/LabelDistribution.vue

@ -43,6 +43,10 @@ export default Vue.extend({
distribution: {
type: Object as PropType<Distribution>,
required: true
},
colorMapping: {
type: Object,
default: () => {},
}
},
@ -53,11 +57,12 @@ export default Vue.extend({
const labels = Object.keys(this.distribution[user])
labels.sort()
const counts = labels.map((label) => this.distribution[user][label])
const colors = labels.map((label) => label in this.colorMapping ? this.colorMapping[label] : '#00d1b2')
data[user] = {
labels,
datasets: [{
title: this.title,
backgroundColor: '#00d1b2',
backgroundColor: colors,
data: counts
}]
}

8
frontend/components/statistics/SpanDistribution.vue

@ -2,6 +2,7 @@
<label-distribution
title="Span Distribution"
:distribution="distribution"
:color-mapping="colorMapping"
/>
</template>
@ -16,12 +17,15 @@ export default Vue.extend({
data() {
return {
distribution: {}
distribution: {},
colorMapping: {},
}
},
async created() {
this.distribution = await this.$services.statistics.fetchSpanDistribution(this.$route.params.id)
const labels = await this.$services.spanType.list(this.$route.params.id)
this.colorMapping = Object.fromEntries(labels.map((label) => [label.text, label.backgroundColor]))
}
})
</script>
</script>
Loading…
Cancel
Save