i am using this chart example where i updated query in data.php with
working
"SELECT student_id,student_name,marks FROM tbl_marks WHERE student_id IN(1, 2, 3)"
not working
"SELECT student_id,student_name,marks FROM tbl_marks WHERE student_id IN(1, 2)"
basically single entry and multiple entry works fine but when i select two data row it shows blank one side of bar graph.
<script>
$(document).ready(function () {
showGraph();
});
function showGraph()
{
{
$.post("data.php",
function (data)
{
console.log(data);
var name = [];
var marks = [];
for (var i in data) {
name.push(data[i].student_name);
marks.push(data[i].marks);
}
var chartdata = {
labels: name,
datasets: [
{
label: 'Student Marks',
backgroundColor: '#49e2ff',
borderColor: '#46d5f1',
hoverBackgroundColor: '#CCCCCC',
hoverBorderColor: '#666666',
data: marks
}
]
};
var graphTarget = $("#graphCanvas");
var barGraph = new Chart(graphTarget, {
type: 'bar',
data: chartdata
});
});
}
}
</script>