Creating a bar chart in pdf

Creating a bar chart in pdf

Hi,
      I have been trying to create a pdf that is able to send a pdf containing a bar chart of my devices over a span of 7 days with this html code i got from w3 school (W3Schools Tryit Editor):
const html =
`<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

<canvas id="myChart"></canvas>

<script>
new Chart("myChart", {
  type: "bar",
  data: {
    labels: [${device}],
    datasets: [{
      backgroundColor:[${color}],
      data:[${value}]
    }]
  },
  options: {
    legend: {display: false},
    title: {
      display: true,
      text: "World Wine Production 2018"
    }
  }
});
</script>

</body>
</html>`;
When I initially ran it with fixed labels, backgroundColor, data it works how ever when I
replace them with the the variables i gotten from the device, the pdf just shows all blanks.
I am not sure if it is the issue with the array and string I passed in or is it unable to
check the variables