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.
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): brmassaDownloads 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.
Url: http://drupal.org/project/chart Drupal dependencies: Third party code: None, works with Google Charts Maintainer(s): tjholowaychuk, chrislynchDownloads 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:
Url: http://drupal.org/project/fusioncharts Drupal dependencies: Colorpicker Third party code: Fusion Charts Maintainer(s): aaron1234nzDownloads 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): kongDownloads 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): redndaheadDownloads 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): irakliDownloads 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.
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.
Url: http://drupal.org/project/statspro Drupal dependencies: Statistics (core), Charts Third party code: Whatever Charts requires Maintainer(s): mr3dblondDownloads 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.