Can someone please share some sample bar/ pie charts created from database queries
In reply to Betty Grazia
Re: Configurable reports: Creating graphs from database queries
by AL Rachels -
Hi Betty,
I don't have any examples for Configurable reports, but the grade pages for MooTyper has code for bar charts made from various database queries. The two files that include charts are the gview.php and owngrades.php files, with the pertinent code at the end of each of the files.
I don't have any examples for Configurable reports, but the grade pages for MooTyper has code for bar charts made from various database queries. The two files that include charts are the gview.php and owngrades.php files, with the pertinent code at the end of each of the files.
In reply to Betty Grazia
Re: Configurable reports: Creating graphs from database queries
by Mark Sharp -
When you fetch data from the database the array is indexed by the first field returned (usually an id). When you're creating a series of data for the chart, you need to ensure the array is indexed sequentially (0,1,2 etc) - array_values($yourresults) - should do the trick.
ChartAPI documentation: https://docs.moodle.org/dev/Charts_API
This is a chart I've been working on: https://github.com/ltu-solent/moodle-report_participationlog/blob/main/classes/partchart.php
ChartAPI documentation: https://docs.moodle.org/dev/Charts_API
This is a chart I've been working on: https://github.com/ltu-solent/moodle-report_participationlog/blob/main/classes/partchart.php