Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: annotations don't work with chart-from-table #113

Open
SonjaBlack opened this issue Feb 9, 2024 · 0 comments
Open

[Bug]: annotations don't work with chart-from-table #113

SonjaBlack opened this issue Feb 9, 2024 · 0 comments

Comments

@SonjaBlack
Copy link

Describe the bug

First, thanks for this plugin. The chart-from-table capability is wonderful.

However, I would like to be able to add annotations to my charts. With charts generated from dataviewjs, this works. But with chart-from-table, I cannot get it to work at all.

Relevant errors (if available)

No response

Steps to reproduce

I found an working example online of adding annotations in the JSON object passed to window.renderChart():

options: {
plugins: {
annotation: {
annotations: {
myAnnotation: {
type: 'box',
yMin: 100,
yMax: 300,
backgroundColor: 'rgba(255,99,132,0.15)'
}
}
}
}
}

Based on how the other elements of that JSON map to the YAML in a chart code block, it looks like this should work:

type: line
id: myTable
file: "My Table"
layout: columns
beginAtZero: true
options:
  plugins:
    annotation:
      annotations:
        myAnnotation:
          type: box,
          yMin: 100,
          yMax: 300,
          backgroundColor: 'rgba(255,99,132,0.15)'

But it does not. The chart renders correctly, but there is no annotation. I have tried removing different levels of that options block (i.e. starting with plugins instead of options, and all the way down), but with the same results every time: a perfect chart, but with no annotations.

Expected Behavior

The charts plugin should pass any given options along to their indicated plugins. This doesn't seem to be happening.

As an enhancement to that, it would be nice if we didn't have to include the options/plugins/annotation levels in the YAML as well; they don't really add anything. The charts plugin should know which chartjs plugins it is using and should recognize a top-level YAML key for each one's options.

Additional context

I did try solving this on my own first. I have read ALL the documentation for the charts plugin, many blogs and other user-generated content about using charts, have asked in the obsidian forums and subreddit, but have not been able to find a way to make annotations work with chart-from-table.

Code

No response

Operating system

Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant