-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
An XML configuration file is at the center of Carte. If you look into the Carte sources, many classes are initialised with a:
void init(DOMElement configRoot) throws ReportException;
where the configRoot
is the root configuration element (reportdef
), although it may not necessarily be the document root.
There are configuration example files in the examples
directory of carte-jmh, like sac-benchmark.xml.
The configuration root is a <reportdef>
element in the http://carte.sourceforge.io/report
namespace, with its id
attribute being the ID of the report. The <name>
child element gives the report name, and then there are other important elements.
The <reportset>
element tells which reports you are going to produce.
For example:
<reportset basedir="templates">
<report>
<renderer>io.sf.carte.chart.SVGBarChartRenderer</renderer>
<template>barchart.svg</template>
<store-id>fileStore</store-id>
<store-id>documentStore</store-id>
</report>
<report>
<renderer>io.sf.carte.chart.external.XChartRenderer</renderer>
</report>
</reportset>
tells Carte that there will be two report renderers. First, SVGBarChartRenderer
will be used together with the fileStore
and documentStore
stores. Then, XChartRenderer
will be used.
Now let's talk about the stores.
The <storage>
element has one or more <store>
child elements that define how the charts will be used.
You generally use DocumentStore
(which internally uses HTMLTableStore
if the document contains <table>
elements with the carteitem
class) and FileStore
.
The DocumentStore
is just an HTML file where certain elements have the carteitem
class.
In the XML configuration, the document specified by the <pathname>
element (in the next example, doc_store.html
) is the store, and the fallback images will be in the PNG format, stored at the my_fallback_dir
directory which will be visible over HTTP with the uri imagefallback
as given by the baseuri
attribute (typically, baseuri
will coincide with the last part of the <fallback>
element contents).
<storage>
<store id="documentStore" classname="io.sf.carte.report.DocumentStore">
<pathname>${user.home}/path/to/doc_store.html</pathname>
<fallback baseuri="imagefallback" format="png">
${user.home}/path/to/my_fallback_dir
</fallback>
</store>
</storage>
It also uses a HTMLTableStore
to look for HTML tables in the document.
Stores data into an HTML table.
In the XML configuration file, you can use an optional <css-classes>
element where you tell which class attribute the numbers and units will have (by default, number
for numbers and no class for units).
<css-classes>
<number>numberclass</number>
<unit>unitclass</unit>
</css-classes>
Then, it will retrieve all the HTML tables with a carteitem
class and fill in the report data accordingly.
Stores charts in a directory.
In the following example, the store will be the $TMP/chart_dir
directory:
<storage>
<store id="fileStore" classname="io.sf.carte.report.FileStore">
<directory>${java.io.tmpdir}/chart_dir</directory>
</store>
</storage>
Your Carte-based application must define other configuration elements so you can specify how to obtain your data and configure the ChartRenderer
instances. You are encouraged to read the JMH page as an example of a real application.