General developer forum

Problems with Chart API

 
Picture of Laurent Guillet
Problems with Chart API
 

I want to create a chart of the time a user is spending on Moodle using the Charts API. After a few failed attempts, I decided to try the simplest example I could think off and I copy-pasted the 'Mixed chart types' example of the documentation (php 'test' attached). It still didn't work (picture 'test' attached). I then decided to try if some examples of the Charts API in the core of Moodle worked. I tried with both the quiz/report/overview (picture quizreportoverview attached) and the blocks/ranking/graphs (picture blocksrankinggraphs attached). It still didn't work.

So I have 2 questions :


1) Are my use cases correct or am I making a mistake somewhere.

2) Am I missing something in the configuration of my Moodle ? The admin/environment.php tells me that everything is fine.


I am on Moodle 3.4 with php7.


Thanks in advance.




 
Average of ratings: -
Picture of Simey Lameze
Re: Problems with Chart API
Core developersDocumentation writersMoodle HQPlugin developersTesters

Hi Laurent, using your test.php I have managed to generate the chart:
chart

Please double check the require_once for the config.php and lib.php.

But otherwise the script is fine and generate the mixed chart you need.

Thanks.

 
Average of ratings: -
Picture of arsen adams
Re: Problems with Chart API
 

Google Charts is an interactive Web service that creates graphicalcharts from user-supplied information. The user supplies data and a formatting specification expressed in JavaScript embedded in a Web page; in response the service sends an image of the chart.



 
Average of ratings: -
Picture of Simey Lameze
Re: Problems with Chart API
Core developersDocumentation writersMoodle HQPlugin developersTesters

Google Charts is a very nice tool, however doesn't work offline. This is crucial, because some institutions might not have directly access to internet and in this specific case, the charts won't be generated.

 
Average of ratings: -
Picture of Marcus Green
Re: Problems with Chart API
Core developersParticularly helpful MoodlersPlugin developersTesters

I have been working on some concepts for sites that will not be connected to the internet so Google charts would not work for such sites.

 
Average of ratings: -