score:4
The reason why the event is fired 7 times was explained in this issue: How to get chart instance? #464
If options or other optional attributes are set after the data is set the chart will be destroyed and recreated. This logic is what allows the chart to be automatically updated everytime something changes in the chart settings.
When that happens you should just update the reference on your side.
To figure out which chart object is the one you want, just look for the chart directive id (or chart type) in the chart object.
Example:
Use an object as an associative array
$scope.myCharts = {};
Save object reference in the associative array
$scope.$on('chart-create', function (event, chart) {
console.log(chart.chart.canvas.id);
console.log(chart.chart.config.type);
//If id is the same, reference will be updated
$scope.myCharts[chart.chart.canvas.id] = chart;
});
Access chart object by its directive id
console.log($scope.myCharts[id]);
Source: stackoverflow.com
Related Query
- Getting access to already created Chart.js chart
- Getting the HTML code of a chart created by chart.js
- getting additional value fields from data source for dx.chartjs doughnut chart
- Created an onclick function to remove data from a line chart in ChartsJs, but getting "Cannot read property 'data' of undefined" error
- Chart JS data labels getting cut
- Chart js x-axis values getting repeated twice
- How to access labels array using chart plugin (Chart.pluginService.register) in Chartjs 2.x?
- Getting chart js bar chart to fill window
- Pie chart is not getting rendered in ChartJS
- Dynamically created Chart.js chart overpopulating time based x-axis?
- Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused. chat.JS
- How to access or get value of specific graph on chart plot by click event?
- High and low points on chart getting cut off
- chart is not getting updated from the values it received from Jquery
- Change Axis Line color in Chart created using chart.js
- ng2-charts access base chart object
- Chart JS : Getting issue with draw bar chart
- Having problems getting a line chart in Chartsjs to go *up* to 1, with bkg fill *under* the chart line
- Flask Socketio | Update and plot a chart using background tasks created by Flask Executor or ThreadPoolExecutor
- Update Chart js chart dynamically in angular 2 from data getting from nodejs service
- Create a chart on a dynamically created canvas in Angular-chart.js
- Access a chart in a different function
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- Legend isnt moving to the right on my doughnut chart created with chart.js
- Chart JS can't access data from array within an object
- How to get the data attribute of the canvas chart created using chartjs
- Chart content not getting displayed in ionic
- <Canvas is already in use. Chart with ID '18' must be destroyed before the canvas can be reused> in react
- Line Chart is not setting backgroundColor when created dynamically Chart.js
- Chart Is Not Created
More Query from same tag
- My choice of color is not used in my stacked bar chart
- how to Fill array with 0 if data is not present?
- How to add area with break on line chart with fill color
- how to format date string for x axis labels in chartjs?
- Problems trying to render some data on chartjs
- how to Highlight clicked Doughnut section or portion in chart.js?
- Trouble with setting background color for Line chart at Chartjs version 3.5.1
- "Does not provide an export named 'Tooltip'," even though I can output Tooltip
- Chart.js how to change width of color
- chartjs add dots to bars in grouped bar chart
- Chart.js: Get point index from chart.getPointsAtEvent(e)
- Create a arc like doughnut chart with Chart js plugins
- how to set start value as "0" in chartjs?
- chart.js 2.7.1 - polar area chart has too much padding
- Chart.js v2: How to make tooltips always appear on pie chart?
- How to change Chart.js horizontal bar chart Width?
- how to change display and styles of the labels in react-chartjs-2
- daily activity chart using PHP MySQL
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- Inserting data from arrays into a pie chart (chart.js)
- Legends for line charts in Chart.js
- Using Chart.js 2.0, display line chart values
- ng2-charts access chartjs object to apply chartjs functions
- Hide chart labels
- Chart.js line from annotations plugin is not appearing
- Chart.js How should I do to make vertical dotted line
- ChartJS Custom text on certain xAxis and yAxis linesS
- Responsive canvas extends beyond div
- Custom y axle using Chart.js
- Get Value for point clicked on Pie Chart in Chart.js 3