im trying to fetch data with ajax request to update chart.js. the ajax request is fine. but the response wont update the chart. this is how i fetch data :
<script type="text/javascript">
$(document).ready(function(){
$("#data-row").hide();
$("#btnCari").click(function(){
var periode = $("select[name='tahun']").val();
$.ajax({
url:"<?php echo site_url('laporan/get_keuntungan/')?>"+periode,
success:function(data){
var graph = data;
data: {
labels: ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli","Agustus",'September','Oktober','November','Desember'],
datasets: [
{
label: "Penjualan",
fill: true,
lineTension: 0.3,
backgroundColor: gradient1,
borderColor: gradient1,
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
borderWidth: 1,
pointBorderColor: gradient1,
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: gradient1,
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: [graph],
spanGaps: false
}
]
}
});
$("#data-row").fadeOut("slow");
$("#data-row").fadeIn("slow");
}
})
});
})
the ajax response is look like this :
'10,20,30,40,50,10,20,30,30'
but it wont update the chart.