Home forums Using CanvasJS [Loop] How to get data from DB inside chart

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27029

    Hi sorry for my english antecipated.

    I don’t know how send information from my database to the chart using loop to show data. Exemple: I create 1 teacher, it shows on the chart, then I create 1 studant for this teacher, it shows on the chart, I create the second studant, then, I create more 1 teacher, and so on, how to do the chart automatically based on my database? I I try to do a FOR loop inside the chart, the graphyc dont shows up.

    #27033
    data: [
    		
    		{
    		type: "column",
    		name: "Class 1",
    		showInLegend: true,      
    		yValueFormatString: "#,##0.# Units",
    		dataPoints: [
    			{ label: "Math",  y: 5.0 },
    		
    		]
    	},
    	{
    		type: "column",
    		name: "Class 2",
    		showInLegend: true,      
    		yValueFormatString: "#,##0.# Units",
    		dataPoints: [
    			{ label: "Math",  y: 10 },
    	
    		]
    	},
    	
    	
    	{
    		type: "column",
    		name: "Class 3",
    		
    		showInLegend: true,
    		yValueFormatString: "#,##0.# Units",
    		dataPoints: [
    			{ label: "Math",  y: 10 },
    		
    		]
    	},
    	
    	{
    		type: "column",
    		name: "Class 1",
    		
    		showInLegend: true,
    		yValueFormatString: "#,##0.# Units",
    		dataPoints: [
    			{ label: "Math",  y: 0 },
    			{ label: "Geography", y: 5 },
    		
    		]
    	}]

    I have 2 problems:

    How can I show dynamycally when A course was created, when a class (with the number of students) updated and so on…?
    How can I show the second course , thirty…, for the right way? Because the chart always need the first one to keep orderly

    #27065

    @thiagoand,

    Please take a look at this gallery example to render chart with data from database in PHP. In case this doesn’t help, can you please let me know the Server-side technology being used by you so that we can assist you with a suitable example.

    ___________
    Indranil Deo
    Team CanvasJS

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.