Using ChartJs-Plugin-Datalabels as a local plugin
See original GitHub issueI have a Vue application with several Chart types using Chart.js. Iam currently trying to use the Chartjs-Plugin-Datalabels with only one of these charts, the Bar chart.
However, as soon as I import the ChartJS-Plugin-Datalabels plugin, it becomes activated for all of the Chart types in my application, even if I only import it within the BarChart.vue file.
<script>
import { Bar, HorizontalBar, mixins } from "vue-chartjs";
import ChartJSPluginDatalabels from "chartjs-plugin-datalabels"; //Activates in every chart type
export default {
name: "BarChartWidget",
mixins: [ mixins.reactiveProp ],
props: [
"chartData",
"options",
],
extends: Bar,
mounted(){
this.renderChart(this.chartData, this.options);
}
}
</script>
I have tried adding this.addPlugin(ChartJSPluginDatalabels);
to the mounted function, but this makes no difference.
Is there a way to use this Plugin only in this specific Vue component?
Environment
- vue.js version: 2.5.16
- vue-chart.js version: 3.3.2
- npm version: 5.6.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Getting Started | chartjs-plugin-datalabels
chartjs -plugin-datalabels must be loaded after the Chart.js library! ... It must be manually registered either globally or locally (see #42 ...
Read more >Plugins
Plugins. Plugins are the most efficient way to customize or change the default behavior of a chart. They have been introduced at version ......
Read more >1. How to add chartjs-plugin-datalabels to Chart.JS - YouTube
1 How to add chartjs plugin datalabels in chart.jsIn this video we will explore how to add the chartjs plugin datalabels in Chart.JS....
Read more >chart.js - ChartDataLabels is globally active for some reason
As described here in the docs if you use Chart.register(ChartDatalabels) you register it as a global plugin which means it applies to all ......
Read more >How to use React with Chart js and plugins
How To Use label plugin in Chartjs-plugin-data labels. · npm install chartjs-plugin-datalabels --save · import {Chart} from 'chart.js'; import ...
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
Hi there @RBrNx,
I’m trying to apply what’s outlined in this thread, but I can’t get the data labels to show just on a single chart.
In my main.js file, this seems to be working fine:
If I disable the last line the labels show on all the charts.
Then in 1 particular chart, I try to do this, but no labels are showing:
Any ideas why this isn’t working ?
Working fine with, import Chart from ‘chart.js’; import ChartDataLabels from ‘chartjs-plugin-datalabels’; Chart.plugins.unregister(ChartDataLabels);