diff --git a/frontend/components/statistics/CategoryDistribution.vue b/frontend/components/statistics/CategoryDistribution.vue index 0b1f2847..781c622e 100644 --- a/frontend/components/statistics/CategoryDistribution.vue +++ b/frontend/components/statistics/CategoryDistribution.vue @@ -2,6 +2,7 @@ @@ -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])) } }) - \ No newline at end of file + diff --git a/frontend/components/statistics/LabelDistribution.vue b/frontend/components/statistics/LabelDistribution.vue index bd951e5d..13b8c28a 100644 --- a/frontend/components/statistics/LabelDistribution.vue +++ b/frontend/components/statistics/LabelDistribution.vue @@ -43,6 +43,10 @@ export default Vue.extend({ distribution: { type: Object as PropType, 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 }] } diff --git a/frontend/components/statistics/SpanDistribution.vue b/frontend/components/statistics/SpanDistribution.vue index d67e1ee7..07082cc8 100644 --- a/frontend/components/statistics/SpanDistribution.vue +++ b/frontend/components/statistics/SpanDistribution.vue @@ -2,6 +2,7 @@ @@ -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])) } }) - \ No newline at end of file +