Want to get Lullabot article, videocast, and podcast announcements delivered right to your in-box?
Let us know your email address (we won't share it) and we'll let you know when anything exciting happens.
Drupal Charting
I needed to find a way to create nice charts from Views data so that end users could adapt them to selected date ranges or categories, but I found that this is not as easy as it ought to be. It took quite a bit of time just to figure out what the options were, let alone decide which were the most promising solutions for my situation. Since this turned into such a time-consuming project, I've documented the steps I took and what I found to make things easier for anyone else looking for solutions like this.
I investigated several Drupal 6x modules to see which ones might be ready for prime time. Many of the modules have alpha releases or less and/or have dependencies on other modules that are alpha or beta (i.e. Views Charts (alpha) depends on SWF Object API (beta), several of the modules depend on the Charts module (alpha)). Several are brand new modules with no activity beyond the initial check in. Because of that, I used the latest development version of each module in my testing to be sure I had the latest code with all fixes applied.
I checked a few statistics to evaluate how useful, popular, and well maintained each module is. I looked at the number of downloads in a recent week rather than total downloads because so many of the modules are new. I looked at the dates of the first and latest commit to see how new they are and how active the maintainers are. I noted the most recent version to make it clear which ones are development, alpha, beta, or full releases. I also noted whether or not there is Views integration, since that will be the easiest way for most people to use them. Many provide charts of system information in the administration 'Reports' area and I noted that below.
The names and dependencies are especially confusing. There are both a 'Chart' and a 'Charts' module, and both 'Open Flash Chart API' and 'Open Flash Chart 2 API'. Many require downloads from third party libraries and may not always make it clear what files are needed, where to get them, or where to put them. Many dependencies are not documented or not clear. Several require PHP 5.1 or PHP 5.2. Whatever I figured out I noted in the evaluations below.
I created some numeric and text data using CCK fields and auto-filled them using the Devel Generate module, then tried to chart my data in various modules. There are three main types of charting that are supported by the Drupal modules, Google Charts, Open Flash Charts, and Fusion Charts.
The end result in Google Charts looked like the following:


In Open Flash Charts, similar data looked like the following (with neat flash animation that you can't see here):


More information (and better examples of each) are available on their web sites:
http://teethgrinder.co.uk/open-flash-chart-2/
http://www.fusioncharts.com/
http://code.google.com/apis/chart/
General Notes about Views Charting
There are some special caveats to getting this working with Views. None of the flash charts can be viewed in the Views preview pane, you have to save the view and look at the page or block to see the effect. This was true for every module that provided a flash alternative.
You can chart the individual values in Views, but most of the time you will want to chart aggregated totals, the COUNT or SUM or AVG of your values, so finding a way to do aggregations is important. This is handled differently by different modules. Charts provides a way to do a COUNT of values, FusionCharts is trying to incorporate aggregation settings, and add on modules like Views Calc or Views GroupBy provide other ways to aggregate totals. There is work going on in Views to add more ways to get aggregated totals and that will change the way this works in the future.
When you use aggregations you have to be careful not to add any extra fields, filters, sorts, or arguments to the view or you will screw up the logic that creates the query when Views tries to aggregate that new field. You may have to look at the query created to be able to tell if it is doing the right thing, most useful for people who know how to interpret SQL code.
Watch the values for 'pager' and 'number of items'. The number of items defaults to 10, so unless you change it you will not be viewing a chart of all your data, only the first 10 items.
It's a good idea to first create a simple view like a table of your data to be sure your view is set up to produce logical results.
Following are more details about each of the modules I evaluated.
Charts
Url: http://drupal.org/project/charts
Drupal dependencies: Open Flash Charts depends on the Open Flash API.
Third party code: Open Flash Charts and Fusion Charts require add-ins.
Maintainer(s): brmassa
# Downloads week of Apr 4: 647
Date added: March 10, 2008
Date lasted updated: November 13, 2008
Latest version: 6.x-1.0-alpha5
Views integration: Yes
Demonstration/Tutorial: http://drupal.org/node/233753
This module provides a single integration for all three charting methods: Google Charts, Open Flash Charts, and Fusion Charts. Because of that it implements a basic set of functions and does not support special features of any of them. For instance there is no way to use the 'map' chart in Google charts or use features like Google's setting to automatically fit the bars in a bar graph to the space available.
There is no documentation about where to put the external files for Open Flash or Fusion Charts and there were numerous issues reporting that no one else was able to get them to work. I finally figured out that using Open Flash in Charts introduces an undocumented dependency on the Open Flash Chart API (not to be confused with Open Flash Chart 2 API) but it does not check if the module is installed before trying to use it, causing potentially fatal errors if not set up correctly. Open Flash Chart API in turn requires version 1, not version 2, of Open Flash, which is fairly well buried on the Open Flash site. Once I got the right files and modules enabled, the Open Flash charts worked as well as the Google charts. I was never able to find any way to get Fusion Charts working.
The Views integration only works on simple data sets or counts (the configuration says 'Display sum of different values', but the code is counting the values, not summing them). You add one field to the view and either display its values or the aggregated counts of its values. It would take custom code or another module to do more than that. The Views Calc module provides an additional Views chart style that will do SUM, COUNT, AVG, MIN, or MAX aggregations of the data. The Views GroupBy module adds a COUNT aggregation field that can be charted.
This package also includes an optional 'System Charting' module that will create a charts display of some system statistics in the administration 'Reports' section.
This appears to be the most widely-used module, it does have Views integration, and it is used by other modules that extend the core code.
Chart
Url: http://drupal.org/project/chart
Drupal dependencies:
Third party code: None, works with Google Charts
Maintainer(s): tjholowaychuk, chrislynch
# Downloads week of Apr 4: 114
Date added: January 3, 2008
Date lasted updated: September 11, 2008
Latest version: 6.x-1.2
Views integration: No
Demonstration/Tutorial: http://code.google.com/p/drupal-chart-api/wiki/Examples
This module predates the other Drupal charts modules and works only with Google charts. It overcomes the problem the Charts module has in that it can fully implement the Google API since it's not trying work with other charting platforms. You can do Maps and other special Google charts. However, there is no Views integration for this module, so for all practical purposes, the only way to use it is as an API for your custom code or for system charts. The provided system charts are nice:

FusionCharts
Url: http://drupal.org/project/fusioncharts
Drupal dependencies: Colorpicker
Third party code: Fusion Charts
Maintainer(s): aaron1234nz
# Downloads week of Apr 4: 107
Date added: July 26, 2008
Date lasted updated: March 14, 2009
Latest version: 6.x-1.x-dev
Views integration: In progress
Demonstration/Tutorial: http://sandbox.webtolife.org/fusioncharts/multi_series
The module has a dependency on the Colorpicker module, which is clearly noted on the project page with a link to that project. The project page also provides an outline of what it does, which includes integration with Views, Webform, and CCK, and availability as an API. Much of the installation documentation is in an included README.txt file, which makes it clear how to set things up. The state of the Drupal 6 version is correctly noted as very early stage and not ready for production.
The module includes charts in the administration 'Reports' section, like the following:

The views integration is not complete so I could not test it, but it looks very interesting, it looks like it could be far more flexible than the Charts module, letting you choose which fields to group by, how to aggregate them, and whether to include multiple values on a single chart or multiple charts. At the moment it appears progress on that is stuck, but this is exactly the kind of interface I hoped to find in all the modules.

This module is clearly not ready to use, but has interesting possibilities.
Open Flash Chart 2 API
Url: http://drupal.org/project/ofc_api
Drupal dependencies: PHP 5.2+
Third party code: Open Flash 2
Maintainer(s): kong
# Downloads week of Apr 4: 26
Date added: April 3, 2009
Date lasted updated: April 10, 2009
Latest version: 6.x-1.1
Views integration: No
Demonstration/Tutorial: http://suksit.com/node/230/open-flash-chart-2-api-module-for-drupal, http://drupal.org/node/423020
This is an API for Open Flash 2 and does not do anything on its own, but is needed by other modules or used as an API.
Open Flash Chart API
Url: http://drupal.org/project/open_flash_chart_api
Drupal dependencies: None
Third party code: Open Flash 1
Maintainer(s): redndahead
# Downloads week of Apr 4: 265
Date added: November 16, 2007
Date lasted updated: January 13, 2009
Latest version: 6.x-2.10
Views integration: No
This is an API for Open Flash 1 and does not do anything on its own, but is needed by other modules or used as an API.
Views Charts & Charts and Graphs
Url: http://drupal.org/project/charts_graphs
http://drupal.org/project/views_charts
Drupal dependencies: Views, SWFObject API
Third party code: Open Flash 2, SWF Object
Maintainer(s): irakli
# Downloads week of Apr 4: 90
Date added: March 4, 2009
Date lasted updated: March 4, 2009
Latest version: 6.x-1.0-alpha1
Views integration: Yes
Video: http://dc2009.drupalcon.org/session/business-analytics-drupal-views
Charts and Graphs is the API, and Views Charts is the Views integration module that uses the API. The project page notes that you will want to use something like Views GroupBy to do meaningful charts, and clearly identifies its dependencies, with links to the project pages for each. It depends on the SWF Object API (not to be confused with SWF Object), which in turn requires that you download and include some of the SWF Object code (which has both a version 1 and a version 2, so you have to pick up the correct one, version 2). Charts and Graphs requires that you find and download Open Flash 2 and the instructions for doing that are buried in charts_graphs/apis/charts_openflash/INSTALL.txt. The module creates no automatic system charts, just provides Views integration, but you could create your own system charts using Views.
Once I got all the right modules installed and all the right files set up I was able to create simple charts fairly well. The project page recommends using Views GroupBy to do aggregations but that only works for COUNT queries, plus I was not able to get it working correctly for anything other than basic node fields like title and type. CCK fields would not work at all, they added additional fields to the query that kept it from doing the right grouping.
This is a brand new project, so I assume they will iron the wrinkles out, but as it stands right now I wasn't able to get useful results for anything that required aggregation.
Update!
When irakli reported below that CCK fields ought to work, I went back to file an issue illustrating my problems and found there were significant updates to several of the modules between the time I tested them (April 15) and the time this report was published (April 23), so I re-ran all my tests using the latest code. This time I was able to aggregate and chart CCK fields with no problems. I also found that they have removed some of the dependencies and incorporated some of the external files, making it easier to set up. So I would say this alternative is much further along than it was when I first ran my tests. Since these fixes were made before the date of this report, I wanted to clarify this information.
Statistics Pro
Url: http://drupal.org/project/statspro
Drupal dependencies: Statistics (core), Charts
Third party code: Whatever Charts requires
Maintainer(s): mr3dblond
# Downloads week of Apr 4: 107
Date added: December 31, 2008
Date lasted updated: January 2, 2009
Latest version: 6.x-1.x-dev
Views integration: Yes
This module depends on the Charts module, so has all the same installation and set up issues. It will use whatever charting framework you set up for Charts, either Google Charts or Open Flash Charts. The project page says it has Drush support, but I didn't investigate what that meant. This package is primarily designed to provide charting for administrative information. Once set up it creates an impressive collection of system information tables and charts. All the tables are Views tables so they can be adjusted, although there are few changes you can make because they only use custom 'Statistics Pro' fields and filters, not all the fields and filters you might be expecting to see. However, as an administration tool, this is pretty impressive.

Which Way to Go?
So which is best? Many of these are not yet ready for production, so I would use them in the administrative area or other places where failures are not critical. If you only need system charts, Chart, Charts, FusionCharts and Statistics Pro are good candidates. If you want to create custom charts using Views, only Charts and Statistics Pro, and possibly Views Charts feel at all 'ready', and even then only using simple data sets.
Views charting is definitely still in its infancy. Even with the best of them getting meaningful charts out is very much trial and error. But there are some interesting possibilities coming along that are worth keeping an eye on.
Useful Links
- Open Flash 1 & 2 - a place to get source files for both version 1 and version 2
- SWFObject
- Views Calc
- Views GroupBy
- Issue to add grouping to Views
- Drupal Charting Group
Comments on this post will automatically be closed three months from the original post date.



RSS Feed



Comments
Go Karen
Karen's first Lullablog! Way to go, Karen! And yes, the Charts module is quite incredible.
This is incredibly thorough
This is incredibly thorough Karen. Well done!
GREAT summary!!!
Excellent! I'm glad you went through the trouble to write all this down: It's the sort of thing that everyone who wants to do charts has to go through. I'm sure your work will save a lot of people a lot of time.
I faced the same question myself in preparing for my next Lynda.com series ("Drupal 6: Online Presentation of Data"), which has a video that covers exactly this question. In the end I said, "Here it is, the modules are currently in terrible shape, but they're likely to get better by the time you see this". (I recorded in March for a summer release.) We'll see.
Open Flash Chart API
Even though I am listed as the maintainer of Open Flash Chart API. I'd still like to give credit where its due. jvandervort has really taken the reigns on it. Also due to a serious lack of understanding about cvs the development version shows last updated in january, but the last release was in late February for D6.
It was nice to see this list it does a great job. It also helped to see there was a duplication of efforts with Open Flash Chart API and Open Flash Chart 2 API. Hopefully we can collaborate and make it one module.
This sumary is just
This sumary is just absolutely brilliant
You just saved me at least 10h of preparation work
A 1000thanks to you
Great Evaluation
Thanks so much for taking the time to do this. This is such a huge value to the community.
I went through exactly the
I went through exactly the same process a few days ago; I ended up opting for Open Flash Chart 2 (http://drupal.org/project/ofc_api). As you said, many of these charting modules are under heavy development and, as excited as I am to be able to rely on views and the Views GroupBy module (http://drupal.org/project/views_groupby) to generate my charts, I don't see this happening before at least another 6 months.
I would mention the Flot module as well (http://drupal.org/project/flot) for people looking for an API to draw line charts only (I needed chart pies...). One direction that I'd be interested in pursuing as well, especially since views allows to easily generate tables, would be something more accessible like this: http://www.filamentgroup.com/lab/creating_accessible_charts_using_canvas...
Hot topic
Excellent overview! Wim Leers also covered this topic just two days ago at http://wimleers.com/blog/episodes-server-charting-in-drupal. It looks like charting modules are ripe for consolidation to create a "best of breed" solution that supports Views and multiple charting libraries through a central API.
Great!
I created a page for charting module comparisons at http://drupal.org/node/443814 and added a link to this article and Wim Leer's article.
Download stats
Very interesting read and thank-you very much.
One quick question, you mentioned you had checked download stats for modules, where or how did you find that information?
Resources
Look in the lower left corner on each module's project page and you'll see a heading called 'Resources'. Under that you'll see a link called 'View usage statistics' that takes you to a spreadsheet showing the downloads for that module.
Ah
Oh you mean Usage stats from the Update status module, sorry its just you said "download stats". I would love to know the download stats, as a comparison to the usage stats, was hoping these existed somewhere like buried in CVS:)
Thanks!
Excellent comparison!
Excellent comparison Karen! You should consider putting it in the comparisons of contributed modules section of the Getting Started handbook. Great article, thanks!
Done!
I didn't want to reproduce the whole article with all the images over there, but I added a page for Drupal Charting comparisons with a link back to this article.
Wow! thanks for all the
Wow! thanks for all the detail. This will save me alot of time on a project I'm currently bidding.
I wrote 'chart', which came
I wrote 'chart', which came before many of the others. Drupal folk need to get over the fact that views cannot do everything for you, and should not in most cases. Drupal developers also need to learn to work together instead of creating several projects like this, these are some reasons why I left Drupal, however its an issue that needs to be dealt with. PHP draws far to many 'newbs' to the community in terms of contribution.
Charts
Karan
You rock! Thanks for all your creative work. It won't take long until you a Lullabot Legend.
Ron
View GroupBy
Thank you for a wonderful review, Karen.
Views_Groupby should definitely work CCK fields and it has been tested on numerous use-cases (even ones including relationships i.e. n-degree joins).
It would be great if you can open an issue in views_groupby queue with your test-case so we can see what went wrong there.
Thank you!
Will Do
I will do that. I ran into so many different issues in the different modules that I just didn't have time to open issues for each of them. I'm glad to hear you did work on CCK integration so I will go post my non-working example there so you can work the kinks out. Thanks!
Update!!
When I went back to file an issue about this I found that there were significant changes in some of these modules between the date I tested them and the date this report got published, so I re-ran all my tests with the latest code and was able to chart CCK fields with no problem. Since this took place before the date of this report, I added an update above to clarify that.
Thanks!
Thank you
Thank you, Karen, for both re-testing and the wonderful blog post.
Charts
I am responsible for the patch which added views integration to the Charts module. I spent one or two days on that. It is based on the unfinished GSOC project.
Karen you are right, the count of the values is totally lame. It should be better handled with a module which modifies the SQL query. But I did not know about any other options at that time..
As I see the http://drupal.org/project/views_calc module has much more options to generate data for the graph, and it has very similar settings. I would encourage users who are using the views integration in the Charts module to try out (and switch to) "Views Calc" + "Charts" (Style: Views Calc Chart) as it is much more better.
Charts module back on rails
Karen,
thanks a lot about this article. I'm the Charts module author and i was really out of time to develop it properly. Now i get some time and i promise to address some of your issues.
The first one to get finally fixed is... your code! I got all the Charts+Views integration from Views Calc module and moved directly to Charts. It might release you the burden of maintaining such non-related code.
It will, however, depend on Views Calc in order to use Charts and Views. No need to replicate all functionalities.
You are more than welcome to join me on Charts dev team if you wish.
regards,
massa
Issue queue
Created an issue: http://drupal.org/node/464568
Karen you really know your
Karen you really know your stuff! Thanks for the great article.
Very useful
Thank you for this. It's a very useful post. I will bookmark it and return later, as I have a big charting project coming up. Fantastic to find the ground-work done for me! =)
Fantastic Summary
Great resource as we are currently investigating these modules. Thanks!
Karen is a true FOSS warrior
Its people like Karen, who make FOSS, a force to reckon with, the time she spent analysing the different modules, not only proved her high intellect, but also versatility. She presents the information in a simple to understand format. That's why we need more ladies in FOSS/IT/Computing
great job 'aluta continua'