score:4
Accepted answer
You don't have to manually pass the context
to the datalabels' formatter
function since the plugin takes care of this itself.
Here's a working example of the pie graph with the options specified above.
But if you want to access the chart's context
in some other functions you want to pass to the options
, then you can get it through the chart instance by using this.chart.ctx
.
var options = {
animation: {
onComplete: function () {
var chartInstance = this.chart;
var ctx = chartInstance.ctx; // chart context
}
}
};
Source: stackoverflow.com
Related Query
- Pass context to options on React ChartJS 2
- Dynamically update the options of a chart in chartjs using Javascript
- TypeError: Cannot read property 'defaults' of undefined when using the react wrapper of chartjs
- React ChartJS prevent new data from being added into state after it's redrawn?
- how to get React chartjs to resize back down with window
- React ChartJS 2 : Get data on clicking the chart
- ChartJS set default options only to specific Canvas, not globally
- react testing library: can't acquire context from the given item
- Can't apply options of datalabels chartjs plugin in Vue
- How to add ChartJS code in Html2Pdf to view image
- Stacked bar chart starting from 0 - ChartJS React
- Chartjs Options are ignored
- ChartJS - radar chart options not working
- ChartJS options with Chartkick
- Graph streaming real-time data with react and chartjs
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- I am using chartjs node canvas to render a chart however the graph options are being ignored
- Chartjs not working with d3 from csv source
- React chartjs 2 - Type 'string' is not assignable to type '"timeseries"'
- React component wont re-render ChartJS chart with redux props
- How to hide some points inside my line graphic in React ChartJS 2?
- How to add a Date Selector to Chartjs in the context of Vue.js
- ChartJS - legends and tooltips options
- React + ChartJS V3: Annoations don't work
- Chartjs React Typescript moving x axis labels above chart
- How to select context or scale on chart in chartjs quickchart io to run getValueForPixel?
- Dynamically pass the JSON data in chartjs
- ChartJS pie chart with simple parsing options doesn't render, only works when set as bar/line chart
- How to always show a label in ChartJS in React
- Vuejs - Chartjs doesn't render my own options with api request
More Query from same tag
- How to draw multiple color bars in a bar chart along a Horizontal Line using chart.js
- laravel chartjs dates skipped
- Unexpected behavior with chart.js
- My chart won`t live update - done in Chart.js and Java Script
- Position Label under the Horizontal Bar
- How to display different datasets from different ajax calls in the same ChartJS?
- How to Create a Doughnut chart in Angular 12
- How to change HTML style in ChartOption with if condition?
- chartjs Line chart: scale respect value on x-axis
- Error in implementing chart.js in AngularJS
- ChartJS - Bottom labels displayed vertically
- Chart.js issue in plotting numeric X and Y in line chart
- Generate PDF from chart and table
- Chart.js, returning an "date" array to plot the line graph
- React js with react-chart js, does not render doughnut chart
- ng2-charts update labels and data
- Chart.js Show Label near Line in combined Chart
- problems with ChartJS refresh in angular component
- Chart.js . ASP . Legend Template
- How can i reformat dates
- rotated partial doughnut chart with a point marker in chart.js agularJS
- Cannot get react-chartjs to update
- base chart slice color on series value?
- what is wrong with my code ? java script chart position
- How to give break line in data label
- how to show chart using chart js
- How to update chart.js on websocket event?
- Cannot create Chart using Chart.JS @ 2.9.4
- How do I draw horizontal bars with a label using either ChartJS or D3?
- ng2 charts on Angular 9 not responsive