Hello, I have problem to fetch data from Codeigniter to Chart.
I have result json_encode() like this :
[{“jumlah_berita”:2,”nama_kategori”:”Music”},{“jumlah_berita”:1,”nama_kategori”:”Sport”},{“jumlah_berita”:1,”nama_kategori”:”Agama”},{“jumlah_berita”:0,”nama_kategori”:”Teknologi”},{“jumlah_berita”:1,”nama_kategori”:”Pendidikan”},{“jumlah_berita”:0,”nama_kategori”:”Cinta”},{“jumlah_berita”:0,”nama_kategori”:”coba test”}]
I’m already trying , but the result just blank white , not render the chart.
How can i implement this result json_encode() to chart?
Thank’s
`
<script>
window.onload = function() {
var tampil_kategori = ‘<?= $tampil_kategori ?>’;
var newdataPoints = JSON.parse(tampil_kategori);
var jumlahBerita = new CanvasJS.Chart(“chartContainer2”, {
animationEnabled: true,
theme: “light2”, // “light1”, “light2”, “dark1”, “dark2”
title: {
text: “Jumlah Berita(per Kategori)”
},
data: [{
type: “column”,
dataPoints: newdataPoints
}]
});
jumlahBerita.render();
}
</script>
`