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
568 stars 26 forks source link

[Bug]: Incorrect Y value of bar chart after exporting to PDF #54

Closed 1-2-3 closed 1 year ago

1-2-3 commented 2 years ago

Describe the bug

A simple bar chart that works fine in the preview window, but the Y value is not correct after exporting the PDF.

Y is 7

type: bar
labels: [TESTA]
series:
  - title: AAA
    data: [7]
tension: 0.2
width: 80%
labelColors: false
fill: false
beginAtZero: false

preview window: image

PDF: Y is 6.6 image

Relevant errors (if available)

No response

Steps to reproduce

  1. Create a bar chart with a Y value of 7
  2. Renders without problems in preview mode
  3. Exported to PDF, the Y value became 6.6

Expected Behavior

Also has the correct Y value when exporting to PDF

Additional context

Obsidian:v0.14.2 Obsidian Charts: v3.5.1

Code

No response

Operating system

Windows

1-2-3 commented 2 years ago

It seems that the error of exporting PDF for the first time is not large, and there will be obvious errors when exporting PDF again.

ChristopherKlay commented 2 years ago

Any update on this?

It pretty much makes the addon unusable for lots of use cases, since it not only affects PDF exports, but also the convert to image functionality itself.

RafaelGB commented 1 year ago

same problem here, I just discovered the plugin and is awesome

Nedreow commented 1 year ago

I'm having a very similar problem when exporting a pie chart. Here is the chart from the documentation as an example:

incomplete pie

I think it is connected to the animation that plays when the chart is first displayed. My guess is that the animation is not finished when the note is converted to a pdf, resulting in a chart that is incomplete. If an option is added to disable the animation it should solve the problem.

Wemmy0 commented 1 year ago

Welp I spend ages on a graph for school work and it's useless because of this. EDIT: you can use the "Create image from graph" as a workaround. However it looks awful and the lines are so thin you can't see it

Wemmy0 commented 1 year ago

I've fixed the issue. (kinda) This isn't a perfect solution but if you need a quick fix:

  1. Download the new main.js file.
  2. Go into settings > community plugins > click on the folder icon next to "Installed Plugins"
  3. Go into the obsidian-charts folder
  4. Replace the old main.js file with the newly downloaded one
  5. Restart obsidian and it should work!

https://github.com/phibr0/obsidian-charts/compare/master...Wemmy0:obsidian-charts:master If you want to see the changes I made to the code, I made a fork of the plugin.