General developer forum

 
 
Picture of Joseph Rézeau
Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

Hi all,

Currently, Moodle uses a fairly old and limited graphlib (Graph Class. Version: 1.6.3 * Copyright (C) 2000  Herman Veluwenkamp).

In my current efforts at introducing the new "Personality Test" feature into the Questionnaire plugin, I wanted to output some results as a radar chart, and others as a "bi-polar" chart. I came across the pChart library, which does exactly what I want. See examples below.

pChart is already used in some Moodle (3rd-party) plugins. It is also used by the current version of LimeSurvey (v. 2). On the LimeSurvey site there is an interesing Comparison of different charting libraries, although it dates back to 2009.

I was wondering if there are any plans to update the graph/chart library included in Moodle to something more current and powerful.

Joseph

Here are 2 examples of output done with pChart and the Questionnaire module (WIP new features).

 


 
Average of ratings:Useful (4)
Picture of Tomasz Muras
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup Translators

What a timing - I was just reviewing PHP chart libriaries - and I've ended up with the same - pChart.

It looks like the best option out there but there are few things I didn't like about it:

1. The development is not open - or at least I didnt' find any public version control system with the code (the official one).
2. There is no community around the project - or if there is, it's buried deep down under all the spam - see the pchart forum.

Technically though, it looks like the best PHP charting library out there.

cheers,
Tomek

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@Tomasz,

I agree with all you have found out.

For as much as I've used it, it looks like an excellent library, with lots of features.

Unfortunately it does not seem to be actively maintained, and the forum is at the moment over-flooded with spam.

But I notice that after weighing pros and cons, LimeSurvey has decided to keep it in ther latest current version. If the Moodle community is interested, it might be worth trying to approach the developer and see how things look for the future of this library.

Joseph

 
Average of ratings: -
Picture of Bernard Boucher
Re: Time for a new graph/chart library in Moodle?
 

Bonjour Joseph,

                        personally I have started to integrate RGraph with my Moodle work.

It is based on html5 and javascript, meaning that the client machine instead of the server do the processing for creating the charts. Another great debate to have wink

As you suggest it is Time for a new graph/chart library in Moodle server or client side!

Bernard

 

 

 
Average of ratings: -
Picture of Danny Wahl
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful Moodlers

only "downside" I see to rgraph is it's jQuery powered.  Notice that "downside" is in quotes only because I don't consider jQuery bad...

 
Average of ratings:Useful (1)
Martin in black and white
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

Totally agree that we need to decide on this for 2.5.

I'd appreciate if you guys here could consider yourselves a task force and come up with a good recommendation for us to put in core.

Needs to be GPL-compatible obviously, and I would suggest focussing on HTML5 solutions just because of the flexibility and taking load off the server,

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

Further to Bernard's suggestion I have started experimenting with RGraph which uses HTML5 and JavaScript. It looks more "dynamic" than PHP-based PChart and is actively maintained.

I also found that, for my so-called "Personality test" Questionnaire needs, both the "rose" and "bi-polar" libraries provided excellent results, see attached.

However, as pointed by Danny Wahl, RGraph uses JQuery, which is not the library of choice in Moodle. I have no idea how far this is a problem.

Where should we go from here? Anyone interested try out various Graph libraries and post their findings in this thread or should a proper bug report be started or what?

Joseph


 
Average of ratings:Useful (3)
Picture of Danny Wahl
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful Moodlers

However, as pointed by Danny Wahl, RGraph uses JQuery, which is not the library of choice in Moodle. I have no idea how far this is a problem.

I really don't want to ruffle feathers - but I would hope that "picking the right tool" would prevail over "not using jQuery".  To that end, Moodle has already included jQuery in core (mymobile theme) and the new Moodle Mobile app is built on jQuery, so maybe there's a case and a methodology to include jQuery in core - but only call it when YUI can't do (reasonably) what's being attempted.

That would make it easier for contrib authors to use jQuery in a non-conflict mode too (maybe $PAGE->requires->js('/lib/jQuery.js');)

I'm really not trying to start the "why doesn't Moodle use jQuery" argument again...

 
Average of ratings: -
Picture of Ankit Agarwal
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Moodle Course Creator Certificate holdersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

Just linking the realted issue MDL-35686

 
Average of ratings: -
Picture of Ankit Agarwal
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Moodle Course Creator Certificate holdersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

And also just for comparision, I would also like to recomend yui3 charts, they seem pretty flexible, simple to use and with all the basic features that we can need.

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@Ankit,

The examples of yui3 charts I have found so far do not provide radar or "rose" or "bi-polar" charts similar to the 2 charts I posted here on Monday, 14 January 2013, 10:58 PM.

Can you please point to examples of those chart types for yui3 on the Internet?

Joseph

 
Average of ratings: -
Picture of Ankit Agarwal
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Moodle Course Creator Certificate holdersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

I haven't looked in detail all the possible charts that are supported by yui3.  I just wanted to get it out there for consideration as well basically because:-

# Chart generation will be done on client side

# Long upstream support assured

# Yui3 libraries are already in place in moodle.

There are some dual axis support as well, but havent played with it much http://yuilibrary.com/yui/docs/charts/charts-dualaxes.html

From memory there is some series support as well but afaik they might not support such complex radar chart types etc.

 
Average of ratings: -
Picture of Darko Miletić
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful Moodlers

YUI chart sucks because it does not output chart as image. YUI2 uses flash and YUI3 SVG. Hence it is virtually impossible to export those to image and generate static report in PDF or something else. Any new chart library must have that otherwise it is fairly useless.

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@Darko,

RGraph does output images (in *.png format). Also, from what I have seen, the types of charts that YUI produces are fairly limited.

The more I conduct my tests with RGraph, the more I like it. Anyone else?

Joseph

 
Average of ratings: -
Me!
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

Rgraph is not GPL,

It is Creative Commons Attribution Non-Commercial which is incompatible with the GPL (http://www.gnu.org/licenses/license-list.html#ccby). 

We would have to contact the copyright owner and get them to relicense. 

 

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@Damyon,

Thanks for this important piece of information. What is our next move, then? Are Moodle HQ ready to approach RGraph?

Joseph

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@Damyon (and others in this discussion),

Just noticed that RGraph is now released under the MIT license. Does this make it an "acceptable" chart library for inclusion in Moodle core?

I am planning to use RGraph in the Questionnaire module for its 2.6.3 version to be released any time soon.

I really wish Moodle HQ made up their minds to include a more current chart library (in moodle 2.7). Anyone interested please vote for MDL-35686.

Joseph

 
Average of ratings: -
Picture of Hubert Chathi
Re: Time for a new graph/chart library in Moodle?
 

FWIW, pChart 2 has an odd license.  According to the licensing page, if your application is non-commercial, then you can use the GPL 3 license.  If your application is commercial, then you need to pay for a license, even if your application can be distributed under the GPL.  AFAIK, this in unenforcable, because you could just get some non-commercial entity to redistribute the library to you under the terms of GPL 3, but it would go against the author's wishes.

pChart 1 is just straight GPL, but of course isn't developed any more.

As far as choosing a graphing library, one big decision is whether we want the rendering to be done in the browser via JavaScript, or on the server (or both).  Both have their advantages and disadvantages:

Rendering in the browser:

  • means that you can have more interactive graphs more easily (e.g. mouse-over data points to see their values, zoom in/out)
  • doesn't work if JavaScript is disabled, or in old browsers
  • doesn't work for PDF exports

Rendering on the server:

  • means you need to serve an image file separate from the HTML file, which means you either need to generate the image on-the-fly (which may mean executing the same query twice), or caching
  • is more compatible (doesn't need JavaScript, canvas, flash, SVG, etc; works for PDF exports)

As far as making a PDF export, is it sufficient to just use a bitmap image, or do you want it to be a vector image?  (AFAIK, since pChart is tied to GD, it can only create a bitmap, and the same is true for most of the graphing libraries I've seen.)

 
Average of ratings: -
Me!
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

Rendering in the browser != doesn't work for exports. It would just need to be factored in - you can render a canvas element to a png with javascript.

var canvas = document.getElementById("mycanvas");
var img = canvas.toDataURL("image/png");
 
Average of ratings: -
Picture of Hubert Chathi
Re: Time for a new graph/chart library in Moodle?
 

I'm not sure if I understand what you're trying to say here. Are you suggesting that you render the graph in the browser, export it to a PNG data URL, send that back to the server, and then have the server combine it into the PDF?  That seems like an odd way of doing things, and of course doesn't work if there is no browser involved (e.g. if you want to produce a PDF in a cron or web service call).

 
Average of ratings: -
Me!
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers

No - I'm suggesting we can produce printable HTML versions of the reports (not PDF).  

Agree - this doesn't work for reports generated by cron.

 

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

Hubert "As far as making a PDF export, is it sufficient to just use a bitmap image, or do you want it to be a vector image?"

Which Moodle activities currently need to output PDF exports?

Joseph

 
Average of ratings: -
Picture of Hubert Chathi
Re: Time for a new graph/chart library in Moodle?
 

I'm not aware of any activities in Moodle core that do PDF exports (nor am I aware of anything in Moodle core that generates PDFs in a cron, which I talk about in another post).  I'm just pointing out things to consider, should the functionality ever be needed later.  It is also done in some addons (e.g. Remote Learner's ELIS, which, I should note, uses pChart 1 (at least at the time that I was there), and, IIRC, just just embeds a bitmap image in the PDF).

 
Average of ratings: -
Davo
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful Moodlers

The book module (core from 2.4 onwards) does PDF export.

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@Davo,

Looking at the Book module on Moodle 2.4.1+ (Build: 20130118) I do not see any "PDF export" setting.

Joseph

 
Average of ratings: -
Davo
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful Moodlers

Sorry - I take it back. It must have been a custom version of the plugin we did for a client (where I'd forgotten it wasn't standard functionality when I was asked to tweak it a bit).

 
Average of ratings: -
Picture of Darko Miletić
Re: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Particularly helpful Moodlers

None of the core activities export PDF but few of contributed plugins do that and in the commercial module area it is rather frequent request from the clients. So having a chart library that can generate image in the server is really important. Relying on canvas and HTML5 is something too far in the future. Lots of institutions are still stuck on IE8.

 
Average of ratings: -
asd
Vastus: Time for a new graph/chart library in Moodle?
Group DevelopersGroup Translators

What about Google Charts integration? 

https://developers.google.com/chart/

 
Average of ratings: -