Chartjs-Get data from SQLite as an array and generate charts with the data using Chart.js in an HTML

0👍

Try to passing your data from tag body to tag script

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
    <title>Documment</title>
</head>

<body>
    <div class="container">
        <canvas>
        </canvas>
        <p id="data" style="display:none"><%= value %></p>
    </div>
</body>
<script>
    // your data change to string
    let data = document.getElementById("data").innerText 
  
    let array = data.split(',')
</script>
</html>

Leave a comment