Connext Graphs Overview
The basic idea behind connext-graphs is to make integrating the Open Flash Chart (http://teethgrinder.co.uk/open-flash-chart/) as easy as possible.
The project was started because I wanted to use a chart library that looked similar to the Google charts in their Analyzer application. Struts 2.0 has a plug-in for the JFreeChart library but I wanted a chart that a user could interact with. When the user hovers over a chart point the properties of that point is shown and in this way the chart does not feel like an empty piece of information plonked on the site to take up space.
- Written as a Struts 2.0 plug-in so the initialization of the Flash object is taken care of
- The chart data generation uses Java objects to model the different aspects of the chart
- The styling is configurable by the data sent to the chart
- Some aspects of the chart is stylable via CSS
To Be Done
- Implement the Pie Charts
- Remove the link to the Open Flash Chart site because the chart does this
- Small fixes and improvements
- JFreeChart (http://www.jfree.org/jfreechart/)
- Fusion Charts (http://www.fusioncharts.com/)
- Open Flash Chart (http://teethgrinder.co.uk/open-flash-chart/)
Open Flash Chart is shown as an alternative because it includes a Java class to output the data file used by the chart library. This Java class was not used when developing connext-graphs.
The sketch chart is based upon the bar chart but has an extra `fun` option that indicates how interesting the chart should be rendered.
How to use
1. Create a chart controller that specifies the properties of the charting area
OFCGraphController controller = new OFCGraphController();
controller.getTitle().setText("Example Sketch Bar Chart");
controller.getYLegend().setText("No. of tasks");
2. Create the chart data series
It is possible to mix and match the different series types so you could a line chart and a sketch chart combined.
DefaultOFCGraphDataModel model = new DefaultOFCGraphDataModel();
model.setSeriesType(new OFCBarSketchSeriesType(55, 10, "#d070ac", "#000000", "Test", 10));
The offset parameter of OFCBarSketchSeriesType(alpha, offset, color, outlineColor, text, size) specifies the fun aspect of the chart.
The following values can be used:-
- 0 - 3 Boring
- 4 - 6 Fun
- 7 - Interesting
3. Add the series to the charting area
4. Render the chart data
value = controller.render();
Here the data string used by Open Flash Chart is assigned to the value property and this property is read by the graph.jsp view.
<%@ include file="include.jsp" %>
<s:property value="value" escape="false" />
5. Include the Flash component
Of course none of this would work if the Open Flash Chart object was not embedded into the Struts view.
The following :-
- declares the tag library of connext-graphs
- creates the Flash object
- links the data from the data view defined in steps 1 - 4
<%@ taglib prefix="m" uri="/connext" %>
Figure 1 : Hovering over a chart point