score:10
Accepted answer
plugins
should be placed in its own config section, and not nested under options
.
Instead of:
options: {
title: {
display: true,
text: graph.globals.title,
},
legend: {
display: true,
position: 'bottom',
fullWidth: false,
onClick: () => {},
labels: {
generateLabels: (chart) => {
return pieOptions.legendLeft(chart);
}
}
},
plugins: [{
beforeInit: function(chart, options) {
console.log('yolo');
}
}]
rotation: 3.9,
}
Your code should look like:
options: {
title: {
display: true,
text: graph.globals.title,
},
legend: {
display: true,
position: 'bottom',
fullWidth: false,
onClick: () => {},
labels: {
// generateLabels: (chart) => {
// return pieOptions.legendLeft(chart);
// }
}
},
rotation: 3.9,
},
plugins: [{
beforeInit: function(chart, options) {
console.log('yolo');
}
}]
Working JSFiddle: https://jsfiddle.net/r1x63b8v/
Source: stackoverflow.com
Related Query
- Inline plugin doesn't work
- How do I put this on Real-Time? I already put (async: True) but it doesnt work
- Charts.js scales yaxes ticks min max doesnt work
- Code doesn't work after updating chart.js versioning
- JavaScript implementation doesnt work (Chart.js)
- Chartjs Overlap click function doesnt work
- how can i use inline plugin inner title for chart js?
- How to run Chart.js samples using source code
- angular-charts.js doesnt work with ionic
- everything i put in the options of the Line charts doesnt work
- Automatic colors assignment in chart.js 2.x doesn't work anymore, used to work in v. 1.x
- angular 5 chart.js datalabels plugin
- How to display inline values in a stacked bar chart with Chart.js?
- How to properly use the chartjs datalabels plugin
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- Datalabels plugin chartjs showing '[object]' instead of value
- How to work out Chartjs using TypeScript with Chartjs.definitelyTyped from github
- How do I get tool tips to work on 2 data set half doughnut chart?
- Chart.js Radar chart legend label font size doesn't work
- math.max() doesn't work in IE
- Chart.js onAnimationComplete doesn't work
- Can't apply options of datalabels chartjs plugin in Vue
- How to add ChartJS code in Html2Pdf to view image
- Options beginAtZero doesn't work in angular-chart.js
- How to import and use a custom Chart.js plugin in Nuxt? (Chartjs-vuejs v2.9.4)
- Chart.js click event to open a custom tooltip does not work sometimes
- ChartsJS Annotations Plugin - Can you create a tooltip to accompany an annotation?
- Update Chart.js plugin
- How to use an Aurelia JSPM plugin with WebPack
- Chartjs with zoom plugin zooms too much with wheel just with single turn
More Query from same tag
- Avoiding Empty Curly Braces in MongoDB Aggregation
- How to customize tooltip on mouse hover of a polar area chart of Angular Charts
- How can I display different values on xAxes than on tooltip Chart.js V3
- Limit labels number on Chart.js line chart
- How to display final point value in charts.js
- Passing Array to Chart.js not working, chart not rendering
- charts js grid line not removing
- JSON data in Chart.js is splitting values
- How to add prefix to legend in ng charts using angular
- Chart.js Chart displays but no data
- Angular Chart color does not change
- How do you create rounded corners on the top and bottom of a bar chart and the between 2 part still draw like image?
- Chartjs: Need help on drawing a vertical line when hovering cursor
- How to insert arrays into objects that are inside an array? For ng2-charts / Charts.js
- Angular Overlapping bars using chart.js
- Chart JS Zoom Pan
- Chart.js Line Graph: Start a line in the middle of a graph
- Unable to Construct Stacked Vue-ChartJS Line Plot
- Chart.js "display:none" Issue
- Artefacts when showing compact vertical bar chart in chart.js
- Chart.js 3.6.2, Angular 10: Logarithmic Line chart Y-Axis problems. How to set and keep Y-Axis properties, even when data changes?
- Multiple y-axis in horizontalBar chart js
- chartjs datalabels not showing anything with django template
- GeoChart with nodeJS
- Vertical scrubber line using chartjs
- Adding label inside multiseries doughnut chart through chart.js
- Set an array to be displayed at Chart js
- ChartJS dynamically adding values with jQuery array
- Django and Chart.js Not Rendering Graph Correctly
- how to reset the graph/chart after zoomin, pan using chartjs