Data chart terlalu banyak

Cara buat chart pake database yang isinya banyak gimana ya gan ane buat jadinya chart nya kekecilan total jumlah di database ada 200an data

*Chart* *Database*

java script ane

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

<script type="text/javascript">
      var ctx = document.getElementById('myChart').getContext('2d');
      var chart = new Chart(ctx, {
        type: 'bar',
        data: {
        labels: [
          <?php
            if (count($graph)>0) {
              foreach ($graph as $data) {
                echo "'" .$data->APIID ."',";
              }
            }
          ?>
        ],
        datasets: [{
            label: 'Profit',
            backgroundColor: '#ADD8E6',
            borderColor: '##93C3D2',
            data: [
              <?php
                if (count($graph)>0) {
                  foreach ($graph as $data) {
                    echo str_replace(",","",$data->Jan19). ", ";
                  }
                }
              ?>
            ]
        }]
    },
});

  </script>

avatar MRifai
@MRifai

18 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

Kalo kekecilan, coba Right Click -&gt; Inspect di Canvas dan lihat CSS diatur Width'y berapa...

<pre> if (count($graph)&gt;0) { foreach ($graph as $data) { echo str_replace(",","",$data-&gt;Jan19). ", "; } } </pre> di akhir akan meninggalkan simbol "," kalo mau hilangin, bisa ganti seperti ini...

<pre> if (count($graph)&gt;0){$res_Graph=''; foreach($graph as $data){ $res_Graph.="'".str_replace(",","",$data-&gt;Jan19)."', "; }echo str_replace(", |","",$data-&gt;Jan19."|"); } </pre>

avatar Achmada
@Achmada

7 Kontribusi 1 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban