I'm not really after code but got myself into a loop (no pun). I'm hoping that by the time I write this down, I'll work it out.
I'm trying to think how to draw a number of charts to show a student's grade and the average grade. A student will have have a number of grades which will change over time. I'm trying to work out how to do this.
I've used google charts before and that's fine the issue is how to create and display a number of charts where the number required is unknown.
The data will be in the database and so I use Ajax requests to return JSON data for the grade (student grade, average, and labels). when I know how many charts to produce it's fine.
I think I need to do something like (all in javascript?)
- Query to return the number of grades -AJax so useable in Javascript
- Use above query to create a loop to process all grades
- Within loop -use Ajax to produce data for each chart - query=user and grade
- within loop - create chart using JS library like charts.js or google charts
- Within loop - create appropriate to attach chart to
step 3 is where I'm stuck: I'm struggling as in the case I don't know how many grades to query and what parameters to use e.g. Ajax query ..../userid/grade-title
In this case, it's unknown until I start looking for the data.
Has anyone done similar? Do you just use Javascript to render all the s required to display charts? Do I initially build an array of grades to query -not just the count of grades to display?
I'm writing this here as it usually helps and as I type I think I've worked it out but just now wondering if anyone has any other suggestions. Just a list of steps is fine.
Copyright Notice:Content Author:「jason」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46214296/how-to-draw-an-unknown-number-of-charts-using-charts-js-or-google-charts-with