Cannot get annotation plugin to work.
See original GitHub issueI am trying to get the chartjs-plugin-annotation working in my test project here
Here is my Barchart.vue file, which is how I understand the plugin should be registered
<script>
import { Bar, mixins } from "vue-chartjs";
import chartJsPluginAnnotation from "chartjs-plugin-annotation";
const { reactiveProp } = mixins;
export default {
extends: Bar,
mixins: [reactiveProp],
props: ["chartData", "options"],
mounted() {
this.addPlugin(chartJsPluginAnnotation);
this.renderChart(this.chartData, this.options);
},
};
</script>
This is the template for the parent component:
<template>
<div class="small">
<button @click="fillData()">Randomize</button>
<bar-chart
v-if="loaded"
:chart-data="chartData"
:options="chartOptions"
/>
</div>
</template>
And this options from the data()
section of the same component
data () {
return {
chartOptions: {
responsive: true,
tooltips: {
mode: 'index',
intersect: true
},
scales: {
xAxes: [{
id: 'time-axis',
type: 'time',
stacked: true,
offset: true,
time: {
unit: 'week',
tooltipFormat: 'll',
unitStepSize: 1
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [{
stacked: true
}]
},
annotation: {
drawTime: 'afterDatasetsDraw',
annotations: [{
id: 'vline',
type: 'line',
mode: 'vertical',
scaleID: 'x-axis-0',
value: '2020-09-05',
borderColor: 'black',
borderWidth: 5,
label: {
backgroundColor: 'red',
content: 'Test Label',
enabled: true
}
}]
}
},
chartData: null
}
},
The data renders correctly and redraws on the “randomize” button as I need it to, however the annotation is not drawn.
Ideally I need the annotations to be re-rendered when the data is randomized, hence the “setAnnotation” commented out on line 115, but at the moment I’m not getting a static line at all.
Environment
- vue.js version: 2.6.11
- vue-chart.js version: 3.5.1
- chart.js version: 2.9.4
- npm version: 6.14.8
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Can't get event from chartjs-annotation-plugin on mouseenter
It seems to be a bug in the annotation plugin because if you build the current master and use that as a source...
Read more >Can't get annotated plugin discovery to fire - Drupal Answers
To debug a plugin manager use it as a service and get the discovered plugins: $type = \Drupal::service('plugin.manager.archiver'); ...
Read more >1. How to install the Annotation Plugin chartjs ... - YouTube
How to install the Annotation Plugin chartjs- plugin - annotation in Chart.jsIn this video we will explore how to install the annotation plugin...
Read more >Migrate to v10 | Maps SDK | Android
Inside the DSL block, use code completion in Android Studio to find all available ... In v9, view annotations were included in the...
Read more >chartjs-plugin-annotation
Annotations for Chart.js. Latest version: 2.1.0, last published: a month ago. Start using chartjs-plugin-annotation in your project by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dankell
https://stackoverflow.com/questions/64878459/annotation-dont-show-in-vue-chartjs/65769130#65769130 Hope it helps you.
Will do. Also trying to see whether I can identify what changed to cause the break.