My source code is here below. The chart it creates made by using chartist.js .
<html>
<head>
<link rel="stylesheet" href="chartist.min.css">
</head>
<body>
<h3>Chartist Test</h3>
<br>
<div id="ct-chart5" class="ct-perfect-fourth"></div>
<script src="chartist.min.js"></script>
<script src="jquery-2.1.4.min.js"></script>
<script>
$(document).ready(function(){
var data = {
series: [5, 3, 4]
};
var sum = function(a, b) { return a + b };
new Chartist.Pie('#ct-chart5', data, {
labelInterpolationFnc: function(value) {
return Math.round(value / data.series.reduce(sum) * 100) + '%';
}
});
});
</script>
</body>
</html>
There is a var called data inside scripts tags below. But the thing is it has predefined values and chat is creating by those static values. How i can post some dynamic data into that variable? lets say we have some data retrieving from mysql db. i want to know how to feed those retrieving data into the predefined variable dynamically.