org.infolayer.templates.html
Class TE_chart

java.lang.Object
  extended byorg.kxml2.kdom.Element
      extended byorg.infolayer.templates.TemplateElement
          extended byorg.infolayer.templates.html.TE_chart

public class TE_chart
extends TemplateElement

Renders information in a chart. This template element takes one or more OCL expressions and renders them into a graphical chart. A number of different charts are supported.

The basic idea is as follows:

The element takes the following parameters:
type
The type of the chart. One of "area", "areaStacked", "bar", "barStacked", "barClustered", "line", or "point". Defaults to "bar".
width
The total width of the chart.
height
The total height of the chart.
format
The image type to render the chart into. May be one of "jpg", "png", or "svg". Defaults to "png".
fontFace
The font face used to render text in the chart. Defaults to "Helvetica".
fontSize
The font size used to render text in the chart. Defaults to "12".
title
The chart's title, to be printed above the chart. No title is printed, if none is speficied.
border
Determines whether a border is drawn around the chart. Values are "true" and "false", with "false" being the default.
bgcolor
Specifies the background color of the area outside the chart. Legal values are "black", "blue", "cyan", "gray", "green", "magenta", "orange", "pink", "red", "yellow", and "white". The default is "white". Each color can be combined with a prefix "light" or "dark". 24-bit hex values can also be used, if they start with the usual "#".
expr
Specifies an OCL expression that determines all the values for the x axis. Must result in an OCL collection, not in a single value. The type of this collection is not restricted, that is, it may contain objects, string, numbers or whatever. Further expressions define mappings from these values to x values and x axis labels.
xAxis
Controls rendering of the x axis. Legal values are "true" and "false", with "true" being the default.
xAxisTitle
Specifies a title for the x axis.
xAxisLabels
Specifies an OCL expression that maps x axis values to x axis labels. Since this expressions is applied to each element of the collection determined by the "expr" attribute, it is guaranteed the new collection has the same size. If the new collection doesn't hold string items, the values are converted to string by using toString().
yAxis
Controls rendering of the y axis. Legal values are "true" and "false", with "true" being the default.
yAxisTitle
Specifies a title for the y axis.
xAxisItems
Specifies the number of items (ticks) to draw on the y axis. Defaults to 5, of no value is specified.
Nested <chartdata> elements are used to specify the actual data sets to render. This element supports the following attributes:
expr
Specifies the mapping from x axis values to y axis values for this data set. Must result in an OCL collection of Integer or Float values.
color
Specifies the color for the graph, area, or bars used to render this data set. Legal values are "black", "blue", "cyan", "gray", "green", "magenta", "orange", "pink", "red", "yellow", and "white". The default is a random color. Each color can be combined with a prefix "light" or "dark". 24-bit hex values can also be used, if they start with the usual "#".
shape
Specifies the shape used for points in a line or point chart. Legal values are "triangle", "diamond", "quare", and "circle", with the latter being the default.
legend
Specifies the legend string for this data set.
The following example renders some basic mathematical functions into one chart:
 <t:chart type="line" format="jpg" title="Some simple math"
         
         expr="Sequence(Integer){-10..10}"
         xAxisLabels="'x=' + self"
         yAxisItems="10">

    <t:chartdata expr="self / 2" legend="x/2"/>
    <t:chartdata expr="self" legend="x"/>
    <t:chartdata expr="self * self / 2" legend="square(x)/2"/>

 
 
 Chart support is based on the jCharts
 library.

Author:
Joerg Pleumann (joerg@pleumann.de)
See Also:
Serialized Form

Constructor Summary
TE_chart()
           
 
Method Summary
 void apply(XmlSerializer xw, IlRequest context, Bindings bindings)
          Applies the template mechanism.
 
Methods inherited from class org.infolayer.templates.TemplateElement
applyChildren, assertNoChildren, assertNoChildren, getAttributeValue, getVarDefs, init, readTextContent, setVarDefs, writeAttributes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TE_chart

public TE_chart()
Method Detail

apply

public void apply(XmlSerializer xw,
                  IlRequest context,
                  Bindings bindings)
           throws java.io.IOException
Description copied from class: TemplateElement
Applies the template mechanism. Must be overwritten in the

Overrides:
apply in class TemplateElement
Throws:
java.io.IOException