First, to access the element, you SHOULD NOT be using document.
Please select element starting with $w(‘#XXX’) handler.
Then, I know you want to send data to the element. You can use HTML communication OR custom element.
Please read this chart example from Wix:
https://www.wix.com/velo/example/chart.js-custom-element
https://www.wix.com/velo/example/create-a-custom-chart