I think you have the same id for canvas and for parent element. You want to select the parent element. Try console.log(getElementById({{ $pieGenderChart->id }}).parentNode); and see if it's working
Feb 27, 2020
2
Level 1
Laravel Charts - Trying to change ChartJS data dynamically fails
I'm using Laravel 6, Laravel Charts along with ChartJS. I have succesffully rendered a chart.
Laravel gives it a random unique ID each time the page is loaded.
I get it like so:
{{ $pieGenderChart->id }}
I wan't to change some of the dataset dynamically so I've looked into the DOM with
console.log(window);
Here's my chart (I believe)
I want to be able to change the data in the dom like so:
window.{{ $pieGenderChart->id }}.config.data.datasets[0].data[0] = x
It sits in the root of window... so I should be able to call it like so, right?
console.log(window.{{ $pieGenderChart->id }});
console.log(getElementById({{ $pieGenderChart->id }}));
Either way, same with JQuery, I only get the following
What am I missing here?
Please or to participate in this conversation.

