Try to fix stat pies
This commit is contained in:
parent
735114edbd
commit
ecfbf43b24
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="stats-container" :class="containerClass">
|
<div class="stats-container" :class="containerClass">
|
||||||
<h2>{{ title() }}</h2>
|
<h2>{{ title() }}</h2>
|
||||||
<div class="chart-container">
|
<div class="chart-container" :class="chartClass">
|
||||||
<canvas id="chart" widht="400" height="400"></canvas>
|
<canvas id="chart" widht="400" height="400"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -37,6 +37,9 @@ export default class StatsPie extends Vue {
|
|||||||
containerClass(): string {
|
containerClass(): string {
|
||||||
return `stats-container-${this.statType}`;
|
return `stats-container-${this.statType}`;
|
||||||
}
|
}
|
||||||
|
chartClass(): string {
|
||||||
|
return `chart-container-${this.statType}`;
|
||||||
|
}
|
||||||
|
|
||||||
mounted(): void {
|
mounted(): void {
|
||||||
const url = `/api/stats?type=${this.statType}&limit=10`;
|
const url = `/api/stats?type=${this.statType}&limit=10`;
|
||||||
@ -47,7 +50,9 @@ export default class StatsPie extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderPie(): void {
|
renderPie(): void {
|
||||||
const elem = document.getElementById('chart') as HTMLCanvasElement;
|
const elem = document.getElementById(
|
||||||
|
this.chartClass(),
|
||||||
|
) as HTMLCanvasElement;
|
||||||
const ctx = elem.getContext('2d') as CanvasRenderingContext2D;
|
const ctx = elem.getContext('2d') as CanvasRenderingContext2D;
|
||||||
const sortedStats = this.stats.sort();
|
const sortedStats = this.stats.sort();
|
||||||
const values = sortedStats.map((s) => s.count);
|
const values = sortedStats.map((s) => s.count);
|
||||||
|
Loading…
Reference in New Issue
Block a user