Postingan lainnya
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
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>
1 Jawaban:
Kalo kekecilan, coba Right Click -> Inspect di Canvas dan lihat CSS diatur Width'y berapa...
<pre> if (count($graph)>0) { foreach ($graph as $data) { echo str_replace(",","",$data->Jan19). ", "; } } </pre> di akhir akan meninggalkan simbol "," kalo mau hilangin, bisa ganti seperti ini...
<pre> if (count($graph)>0){$res_Graph=''; foreach($graph as $data){ $res_Graph.="'".str_replace(",","",$data->Jan19)."', "; }echo str_replace(", |","",$data->Jan19."|"); } </pre>