This page describes how to use or modify the Google Visualization Java library, and how to contribute to the open source code for the project.
Contents
Requirements
You must have the following components in order to use the Google Visualization Java library:
- A servlet container and the Servlet API version 2.4 or higher. One of the most commonly used servlet containers is Apache Tomcat, which includes the Servlet API. See http://tomcat.apache.org/download-55.cgi to download the binary for version 5.5. You need install only the Core module. You also need Tomcat to complete the tutorial sections: Getting Started, Using an External Data Store, and Defining Capabilities and the Flow of Events.
- The Java Development Kit version 6.0
or greater.
Note: It is also possible to use the JDK version 5.0. However, you must then remove
@Override
from every method in the library that overrides an interface method. This is due to the change in the@Override
annotation behavior in JDK version 6.0.
Dependencies
The data source Java library has the following dependencies. The library was tested with the versions listed; other versions might be acceptable, but have not been tested.
Included in the source or download:
- icu4j version 4.0.1.
- Jakarta commons lang version 2.4.
- Jakarta commons logging version 1.1.1.
- Google collections library version 1.0.
- javacc version 4.2. This is required only if you intend to compile the libraries, for example when modifying them as described below.
- opencsv version 1.8. This is required only if you intend to use a CSV data source.
Not included in the source or download:
- To use the
SqlDataSourceHelper
class with a mySQL database, you also needmysql.jar
in your runtime environment. See: http://www.mysql.com/products/connector/j/ for details and downloadable versions.
Using the Library as Provided
This section describes how to use the visualization Java library if you don't need to modify it. This process varies with your build system:
If using Maven, set up a dependency on the visualization library with the following settings:
- Group ID: com.google.visualization
- Artifact ID: visualization-datasource
- Version number: Use the latest version number listed on the project page.
If using any other build system:
- Download the library ZIP file from the project page, unzip the files, and include them in your project as your build system requires.
Running the Examples
The JAR example files are included along with the library JARs in the downloadable ZIP file. Instructions on running the examples are given on the Getting Started page.
Modifying the Library
If you want to modify the library code, you'll have to download the source from the open source hosting site and build it. Before doing this, read the licensing information linked to by the "Code license" section on the project page to see whether your use case is allowed.
Here are the steps for downloading and building the library:
- Download the source code using SVN, as described in on the Source > Checkout tab on the open source project page.
- Build your code. If building in Maven, use the pom.xml file provided with the source. If building with Apache Ant, follow the instructions given next (note that the code has been tested with Ant version 1.7.0; if you have an earlier version of Ant, you might need to upgrade)
Ant Build Instructions
1. Modify your build properties:
- Navigate to the
build-src
subdirectory of your chosen installation directory. - Using a text editor, open the
build.properties
file and make the following changes:- Edit the
servlet-api.jar
property to point to yourservlet-api.jar
file. For example, if you installed Tomcat to yourc:
drive in thetomcat_home
directory, then you would specify theservlet-api.jar
property as follows:
servlet-api.jar=C:/tomcat_home/common/lib/servlet-api.jar
Note: Use forward slashes rather than backslashes in the file path, even when using Windows
- To use your own copies of the dependencies described above, edit the paths in the same build.properties file.
- Edit the
2. Build the library:
Navigate the build-src
subdirectory in the file and type one of the
following:
ant datasource
- Builds the data source libraryant example
- Builds the examplesant
- Builds both data source and examplesant test
- Builds and runs the data source library tests. Very useful when you are modifying the library.
Contributing to the Open Source Project
If you want to contribute changes to the open source project, you'll have to get submission permissions to the project. Send an email to google-visualization-api@googlegroups.com asking for permission and instructions on how to submit changes.