grailsgroovychartsjfreechartopen-flash-chart

Charting amount of dated events in columns/bars


I want to create bar charts similar to web server logs. I have events in my database which all took place at a certain moment, I would like to grab all these events and then chart how many occurred each day, week, month, whatever on a bar (column) graph.

For example I want to chart how many visitors I had in a month in 31 columns, each representing one day.

Is there a charting application whereby I can grab all the visits for the month and give these dates to the library, and it will divide them into time periods of my choosing (e.g. view by day)?

If not then what is the simplest way of creating the data? 31 DB queries? One DB query and then checking the dates and divide the events up into 31 lists?

I'm using Groovy and Grails.


Solution

  • You may query your database to get Map which maps number of events to a certain date. Use criteria builder to make a query that returns grouped by date.