Jump to content

kiwari

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About kiwari

  • Rank
    Newbie
  1. kiwari

    anyone help me with chartjs adn mysql, please

    thanks for replying, i'm new in this programming world. in browser page there is no error messages but chart not showing. and in developer tools, it shows error uncaught TypeError at chart.bundle.js and at line var chart = new Chart(ctx, {
  2. i want to build a bar chart with chartJS and database mysql with two different query, but bar chart not showing. can anyone help me to correct the code? this my query and javascript: <?php $a = mysqli_query("select count(a) as total1 from tbl"); $b = mysqli_query("select count(b) as total2 from tbl"); ?> <body> <div> <canvas id="chart"></canvas> </div> <script> var ctx = document.getElementById("chart"); var chartdata = { labels: 'CHART', datasets: [{ label: "A", data: [<?php while ($data1 = mysqli_fetch_array($a)) {echo '"''.$data1['total1'].'",';}?>], backgroundColor: "#000000" },{ data: [<?php while ($data2 = mysqli_fetch_array($b)) {echo '"''.$data2['total2'].'",';}?>], backgroundColor: "#ffffff" }] }; var chart = new Chart(ctx, { type: 'bar', data: chartdata }); </script> </body>
×