The Pentaho BI platform currently employs JFreeChart as its charting engine.
Component Name: ChartComponent
The ChartComponent is a BI component that can create a variety of charts including:
...
To successfully use this component, you will want to be familiar with the Chart Reference.
Inputs
REQUIRED INPUTS
chart-data
...
Note | ||
---|---|---|
| ||
While you can access the chart component through Design Studio's graphical UI, Design Studio does not provide a nice interface for defining all of your properties yet, nor does it provide the appropriate UI for determining how and where you are going to specify your chart properties (as an input or resource - Design Studio puts the chart-attributes element in the component definition by default). These enhancements will come (or you can contribute them!), but for now, you will need to use the XML editing tab of the action sequence to add your chart properties. |
Chart Attributes as an Input
You can specify your chart properties as a String input parameter. The caveat to this input is that the chart properties need to be represented in the string in XML format, inside of a CDATA section.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<inputs> <attributes type="string"> <sources> <request>attributes</request> </sources> <default-value> <![CDATA[ <chart-attributes> <chart-type>BarChart</chart-type> <border-visible>false</border-visible> <is-clickable>false</is-clickable> <include-legend>true</include-legend> ... more chart attributes here ... </chart-attributes> ]]> </default-value> </attributes> </inputs> ... <action-definition> <component-name>ChartComponent</component-name> <action-type>Bar Chart</action-type> <action-inputs> <chart-data type="result-set" mapping="query_result"/> *<chart-attributes type="string" mapping="attributes"/>* </action-inputs> ... |
Chart Attributes as a Resource
You can place the chart-attribute XML in a file, then reference that file as a resource in your action sequence.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<resources> <chart_resource> <solution-file> <location>testchart.xml</location> <mime-type>text/xml</mime-type> </solution-file> </chart_resource> </resources> <actions> ... <action-definition> <component-name>ChartComponent</component-name> <action-type>Bar Chart</action-type> ... <action-resources> <chart-attributes type="resource" mapping="chart_resource"/> </action-resources> ... |
Chart Attributes in the Component Definition
By default, the Design Studio will put the chart-attributes XML node in the component definition. This in-line mode of describing the chart is fine, but can be problematic if you want to dynamically add or change a chart property in the process of your action sequence. Which is why we added the ability to define the chart properties in a resource or input definition.
...
series-name
A replaceable parameter for the URL template. Typically, the series name from the drill point in the chart; also referred to as ParamName2 in some docs.
Outputs
The ChartComponent can return both the chart and its image map (if drill URLs are defined via the URLTemplate) several different ways. Here are the legitimate outputs you can specify, and what the result of each is:
- CHART_OUTPUT (<chart-output type="content"/>)
- Stores the chart in the content repository for use in a subsequent action or process, or displays if the output destination is response and the name is content.
- CHART_FILE_NAME_OUTPUT (<chart-filename type="string"/>)
- Returns the name of the chart file, including the file extension (with no path information) as a String.
- HTML_MAPPING_OUTPUT (<chart-mapping type="string"/>)
- Returns the name of the file that the map has been saved to, including the file extension (with no path information) as a String.
- HTML_MAPPING_HTML (<chart-map-html type="string"/>)
- Returns the chart image map HTML as a String.
- BASE_URL_OUTPUT (<base-url type="string"/>)
- Returns the web app's base URL (ie., http://localhost:8080/pentaho) as a String.
- HTML_IMG_TAG (<image-tag type="string"/>)
- Returns an HTML snippet including the image map, image (<IMG />) tag for the chart image with src, width, height and usemap attributes defined.
- If "image-tag=" appears in the the chart output, include "wrapper=false" in the URL to remove it.
Example Action Sequence
The following action sequence uses the output from a SQL lookup rule ( a Relational data source) as the input for a ChartComponent. See the Chart Properties Reference for an explanation of the chart properties.
...