Display X and Y coordinates in Chart.js

I have a robot in my project that I get X and Y coordinates from when I start it. I want to show these coordinates that make the robot move in a diagram. Like a car to see where you’re going.

I get the data from the robot in the main.js file and call it in the index.html file using id = “posX” and id = “posY”

enter image description here

How can I pass the value shown above to the chart?

const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
    type: 'line',
    data: {
        datasets: [{
            label: 'GOKART MOVING',
            data: [document.getElementById(posX),document.getElementById(posY)],    
        }],
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true,
                    suggestedMax: 20,
                }
            }]
        }
    }
});