Home forums Using CanvasJS Issues retrievng data from MySql Reply To: Issues retrievng data from MySql

#7450

Anjali
Participant

Andres,

You just need to parse and modify your data as required. Below is an example.

var dataPoints = [];
	$.getJSON("tipus_recursos.php", function (result) {
		for(var i = 0; i <= result.length-1; i++) {
			dataPoints.push({label: result[i].Support, y: parseInt(result[i].y)});
		}
	var chart = new CanvasJS.Chart("chartContainer", {
		data: [
		{
			dataPoints: dataPoints
		}
		]
	});
	chart.render();
	});

__
Anjali