mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
adjust title
This commit is contained in:
1 parent
da9e7c6366
commit
e012b7f5ac
14 files changed
+38
-29
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user