| 14 | } |
| 15 | |
| 16 | async initChart () { |
| 17 | const { default: Chart } = await import(/* webpackChunkName: "chartjs" */ 'chart.js/auto') |
| 18 | |
| 19 | const canvas = this.querySelector('canvas') |
| 20 | |
| 21 | const ctx = canvas.getContext('2d') |
| 22 | |
| 23 | this.chartInstance = new Chart(ctx, { |
| 24 | type: 'bar', |
| 25 | data: { |
| 26 | labels: this.chartLabels, |
| 27 | datasets: this.chartDatasets |
| 28 | }, |
| 29 | options: { |
| 30 | responsive: true, |
| 31 | maintainAspectRatio: true, |
| 32 | animation: false, |
| 33 | scales: { |
| 34 | y: { |
| 35 | beginAtZero: true, |
| 36 | grace: '20%', |
| 37 | ticks: { |
| 38 | precision: 0 |
| 39 | } |
| 40 | } |
| 41 | }, |
| 42 | plugins: { |
| 43 | legend: { |
| 44 | display: false |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | }) |
| 49 | } |
| 50 | } |