phibr0 / obsidian-charts

Charts - Obsidian Plugin | Create editable, interactive and animated Charts in Obsidian via Chart.js
https://charts.phib.ro/
GNU Affero General Public License v3.0
574 stars 26 forks source link

[Bug]: Graphs don't generate in custom dataviewjs views #126

Open ThePolyBlank opened 1 month ago

ThePolyBlank commented 1 month ago

Describe the bug

When putting graph code in a js file and loading it with dv.view("scriptname"), the graph does not generate when it should.

Relevant errors (if available)

No response

Steps to reproduce

  1. Save a script with valid dataviewjs graph code
  2. load the script using dv.view(scriptname)

Expected Behavior

The graph shows up

Additional context

the same behavior accours when using eval()

Code

const chartData = {
    type: 'line',
    data: {
        labels: [1,2,3,4,5,6,7],
        datasets: [
            {
                label: 'Sample',
                data: [1,2,3,4,5,6,7],
                fill: true,
                backgroundColor: [
                    'rgba(255, 99, 132, 0.2)'
                ],
                borderColor: [
                    'rgba(255, 99, 132, 1)'
                ],
                borderWidth: 2,
            }
        ]
    }
}
window.renderChart(chartData, this.container)

Operating system

Windows