...
Several designs were considered for Pentaho ChartBeans.
ChartModel API
The first design was based on JavaBeans and is the source from which the term "beans" derives. The proposal was for two layers of beans--one at the chart component level and one at the chart type level. At the lower level, beans would represent parts of the classes for each of the structural components of a chart: the plot, axes, series, and titles. The higher level beans would put the pieces together to form chart types of interest to users, such as a BarChartBean
, LineChartBean
, and PieChartBean
.title. We'll refer to this design as the ChartModel
API.
ChartDocument API
The second design was based on a Document Object Model (DOM). A chart DOM is an object model that consists of elements which can have attributes and child elements. Elements have an associated namespace. Core chart elements, like title and plot would go into the Pentaho ChartBeans namespace. Other, chart engine-specific elements would go into their own namespaces. For example, Open Flash Chart-specific properties would go into a "openflashchart" namespace, while JFreeChart-specific properties would go into a "jfreechart" namespace.
In addition to the JavaBeans vs. DOM decision, it was important that the starting point for a chart be its data. The data are chart type-agnostic.
Finally, it was decided that even the chart type should be a styling issue--not a structural issue. This is because the same series could be used for multiple chart typesWe'll refer to this design as the ChartDocument
API.
Tale of Two APIs
Both designs have their advantages and disadvantages. The ChartModel
API provides JavaBeans familiarity to Java developers (and code completion in IDEs) and the ChartDocument
API is highly flexible and extensible. Currently, both approaches are available! You can build a chart by creating a tree of ChartElement
objects (with the ChartDocument
API) or you can call a series of setters for pieces of the chart's structure (with the ChartModel
API).
Prerequisites
Charting Terminology
...
Pentaho ChartBeans uses Cascading Style Sheets (CSS) to style charts. Pentaho ChartBeans is not limited to the W3C's style attributes (although it attempts to use them where appropriate, for familiarity). By using CSS, Pentaho ChartBeans allows you to completely separate chart structure and style. You can use external style sheets and inline selectors, as well as class and style attributes. Using an external style sheet would allow an organization to create a consistent look for all of its charts.
Examples
Example from a Java Developer Perspective
...