What I’m trying to do
Add annotations to a chart, through the charts plugin’s codeblock route.
This seems like it should be possible, as the github repo for charts shows that it includes a dependency on chartjs-plugin-annotation
, which supports the kinds of annotations I want, such as drawing text and other shapes on top of your chart.
But I can’t find any information on how to denote my annotations in the codeblock, and everything I’ve tried hasn’t worked.
Things I have tried
Just adding an “annotations” block to the code block, with YAML modeled after how chartjs-plugin-annotation
says they’re supposed to look.
type: bar
id: mytable
layout: rows
annotations:
mybox:
type: 'box',
yMin: 1,
yMax: 10,
xMin: 1,
yMin: 10,
backgroundColor: 'rgba(255,99,132,0.15)'
Trying the same, but with the YAML modeled after what actually does work with a chart that’s hand-crafted with dataviewjs:
type: bar
id: mytable
layout: rows
options:
plugins:
annotation:
annotations:
mybox:
type: 'box',
yMin: 1,
yMax: 10,
xMin: 1,
yMin: 10,
backgroundColor: 'rgba(255,99,132,0.15)'
Summary
If you create a chart fully manually, with dataviewjs, then annotations seem to work fine with an options: { plugins: { annotation: { etc }}}
key in the JSON object passed to window.renderChart()
. But creating a chart with code is ridiculous when the data-driven ones you get from the charts
codeblocks are already basically perfect and way easier.
All I want is to add some annotations using the codeblock form. Has anyone gotten this to work?