Sooner or later, one of your clients will ask for graphical representation of something in your application. It may be time-based (revenue per day/month/year), or more arbitrary. Instead of checking available imaging libraries like JFreeChart, and wasting your own CPU cycles when creating images, you can rely on the Google Chart API that is available at http://code.google.com/apis/chart/.
This API supports many charts, some of which do not even resemble traditional graphs. We will come to this later in the recipe.
The source code of the example is available at examples/chapter4/mashup-chart-api
.
Some random data to draw from might be useful. A customer entity and an order entity are created in the following code snippets:
public class Customer { public String name; public List<Order> orders = new ArrayList<Order>(); public Customer() { name = RandomStringUtils.randomAlphabetic(10); for (int i = 0 ; i< 6 ; i++) {...