adjust title

This commit is contained in:
Pete Matsyburka committed 2026-09-23 11:00:17 +03:00
1 parent da9e7c6366
commit e012b7f5ac
14 files changed
+38 -29

No files matched your search

+13 -5
View File
@@ -1,8 +1,7 @@
export default class extends HTMLElement {
connectedCallback () {
this.chartLabels = JSON.parse(this.dataset.labels || '[]')
this.chartDatasets = JSON.parse(this.dataset.datasets || '[]')
static observedAttributes = ['data-labels', 'data-datasets']
connectedCallback () {
this.initChart()
}
@@ -13,6 +12,15 @@ export default class extends HTMLElement {
}
}
attributeChangedCallback (_, oldValue, newValue) {
if (!this.chartInstance || oldValue === newValue) return
this.chartInstance.data.labels = JSON.parse(this.dataset.labels || '[]')
this.chartInstance.data.datasets = JSON.parse(this.dataset.datasets || '[]')
this.chartInstance.update()
}
async initChart () {
const { default: Chart } = await import(/* webpackChunkName: "chartjs" */ 'chart.js/auto')
@@ -23,8 +31,8 @@ export default class extends HTMLElement {
this.chartInstance = new Chart(ctx, {
type: 'bar',
data: {
labels: this.chartLabels,
datasets: this.chartDatasets
labels: JSON.parse(this.dataset.labels || '[]'),
datasets: JSON.parse(this.dataset.datasets || '[]')
},
options: {
responsive: true,