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
546 stars 25 forks source link

[Bug]: bestFit doesn't consider data loaded from table #123

Open nhomble opened 1 month ago

nhomble commented 1 month ago

Describe the bug

There is a exception when I try to add a trend line in a chart block that sources the series from a table.

Seems like sourcing from the table isn't happening in time when the bestFit condition is hit.

Relevant errors (if available)

https://github.com/phibr0/obsidian-charts/blob/master/src/main.ts#L47
`series` is `undefined`

Steps to reproduce

x y
1 1
2 4
3 9
4 16

^repro

type: line
id: repro
layout: columns
tension: 0.2
width: 80%
labelColors: false
fill: false
beginAtZero: false
bestFit: true
bestFitNumber: 1

Expected Behavior

The best fit line should work for table sources just like inline series.

Additional context

No response

Code

No response

Operating system

Windows

JuanDArdilaG commented 1 week ago

I'm receiving this error when using best fit option with a chart from a table: plugin:obsidian-charts:80 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0') at Ol.postprocessor (plugin:obsidian-charts:80:1389)