Fix chart id
This commit is contained in:
parent
14c2e7c110
commit
4227c149ef
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="stats-container" :class="containerClass">
|
<div class="stats-container" :class="containerClass">
|
||||||
<h2>{{ title() }}</h2>
|
<h2>{{ title() }}</h2>
|
||||||
<div class="chart-container" :class="chartClass">
|
<div class="chart-container">
|
||||||
<canvas id="chart" widht="400" height="400"></canvas>
|
<canvas :id="chartID" widht="400" height="400"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -38,8 +38,8 @@ export default class StatsPie extends Vue {
|
|||||||
return `stats-container-${this.statType}`;
|
return `stats-container-${this.statType}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
chartClass(): string {
|
chartID(): string {
|
||||||
return `chart-container-${this.statType}`;
|
return `chart-${this.statType}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted(): void {
|
mounted(): void {
|
||||||
@ -51,9 +51,7 @@ export default class StatsPie extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderPie(): void {
|
renderPie(): void {
|
||||||
const elem = document.getElementById(
|
const elem = document.getElementById(this.chartID()) as HTMLCanvasElement;
|
||||||
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