score:1
Accepted answer
could you try
initializegraph() {
const that = this;
this.graph = new chart('graph', {
type: 'pie',
data: {
datasets: [{
data: [1,2],
backgroundcolor: ['#rrggbb', '#ff0000'],
}],
labels: ['blue','red']
},
options: {
onclick : function(event,elements) {
that.hello();
}
}
});
}
score:0
did you try using arrow function? (e) => {}
the this
variable’s scope is different when using arrow function.
the arrow function inherit the ‘this’ from the parent scope, which in your case might refers to global scope.
Source: stackoverflow.com
Related Query
- can't call any function inside of onClick function chart.js
- chart js onclick function call
- $scope variable do not respond to the onClick function of angular chart
- Destroying chart.js is not working when chart created inside function - chart.destroy() is not a function
- Created an onclick function to remove data from a line chart in ChartsJs, but getting "Cannot read property 'data' of undefined" error
- How to add text inside the doughnut chart using Chart.js?
- chartjs datalabels change font and color of text displaying inside pie chart
- get yLabel value onclick chart js
- angular-chartjs line chart TypeError: t.merge is not a function
- Blank PNG image using Chart JS . toBase64Image() function
- Get X, Y onClick chart coordinates in ChartJS
- Bold text inside doughnut chart (chart.js)
- Chart.js update function (chart,labels,data) will not update the chart
- is there a way to call a Component's function from click function of Chartjs
- Chart JS Re-Animate chart with onclick
- Hovering over chart.js values in Meteor onRendered function causes chart axis shift
- Chartjs (Non Vue) Not Rendering Graph Chart inside V-if/V-show
- Chart.js tooltip at any point on the chart
- How to add title inside doughnut chart in Angular Chart?
- Chart.js chart does not display when inside an ngIf.
- How to access data outside the onclick function
- Chart.js chart onclick disables legend onclick
- How to determine chart type inside 'chart.js' pluginservice
- How to make aspecific API call from within a Line Chart class in ReactJS using react-chartjs-2?
- Is there any way to get Chiselled Effect in chart js?
- code works fine on jsfiddle but one function is not working on website
- Maximum call stack error when attempting to update Chart in Vue js
- chart.js pie chart background colors: is there any way to generate them randomly?
- How to show slice value inside of slice in pie chart using chart.js
- Text inside Doughnut chart using Chart.js and Angular2, Ionic2
More Query from same tag
- how to sort tooltip value in Chart.js
- React export component that is not diplayed to PNG
- Chart Js - Limit points on graph without limiting data
- Chart.js 2.1.6: Drawing horizontal Limit Lines?
- how to load mysql query to chartjs with php?
- How to format date parsed from ASPX JSON via AJAX?
- ChartJS scale ticks with scatter plot
- how can i show labels and value in both on bar chart
- Tooltips in Chart js are always black instead of the color of the corresponding dataset
- Show wrong information in chart js 2
- using ajax populate dynamic piechart from chartjs
- Using Chart.js onClick function, can you execute code from an undefined or null result?
- Charts.js How to add a link when you click a barchart?
- How to make one datefilter for multiple charts on one webpage?
- Link in ChartJS tooltip not clickable
- Rotate chart "pie" to need value or angle
- Adding image on chart js
- How to style specific gridlines differently in chartJs?
- How to display value of only one datapoint in line chart
- Is it possible in chartjs to hide certain dataset legends?
- How can I shade a portion of a ChartJS line grph=
- How to display a barchart in chart.js?
- Charts doesn't appear
- Define new position for tooltip in ng2-charts
- Hiding the ticks on the x-axes clips the chart (Chart.JS)
- chart.js Radar shows 0 when value is 12
- Add a second Y-axis for Linechart in Chart.js?
- Stacked bar charts in Chart.js with JSON data
- Angular canvas is undefined
- Example: Doughnut | Error: Uncaught ReferenceError: Utils is not defined