Moth

A 2D Graphing Application SourceForge.net Logo
News
Examples
Documentation
Download
SourceForge
Project

XML

Each XML file describes how to generate one or more images. This is done by specifying one or more sources of data, and one or more images. The drawing layers of the images then use the data in the columns to figure out where to draw.

Since the contents of a data source are interpretted as XML, special care must be taken when the contents contain certain characters. The following table lists alternatives for the characters that have special meaning in XML:
&&
<&lt;
Alternately, you can use the CDATA method of guarding against XML interpretation. A chunk of text that starts with <![CDATA[ and ends with ]]> will not be interpretted by the XML parser.

The fact that the contents of a data source is interpretted as XML allows you to use XML comments to hide part of the contents from the data source. <!-- is the start of a comment and --> is the end. They may not be nested.

The image tags which actually draw data (<area>, <grid>, <line>, <points>, and <segments>) are drawn in layers in order that they appear in the image, bottom to top.

Top-Level Tag

<moth>
Attributes:
nametypedefault
drawbooleantrue
dump-columnsbooleanfalse
draw-nanbooleanfalse
dump-xmlbooleanfalse
Contents: <mysql>
<rpn>
<rrd>
<textfile>
<image>

Data Source Tags

<mysql>
Attributes:
nametypedefault
columnscolumn list
hosttext"localhost"
databasetext
usernametext
passwordtext
Contents: SQL
<rpn>
Attributes:
nametypedefault
columnscolumn list
Contents: reverse polish notation
<rrd>
Attributes:
nametypedefault
columnscolumn list
filenamefilename
cf"AVERAGE" or "MIN" or "MAX" or "LAST"
starttextsee 'man rrdfetch'
endtextsee 'man rrdfetch'
resolutioninteger secondssee 'man rrdfetch'
Contents: A whitespace-separated list of ds-names, used to fill the columns. The columns are filled in the same order as the ds-names are given.
Note: The first column is filled with the timestamps pulled out of the rrd file.
<textfile>
Attributes:
nametypedefault
columnscolumn list
filenamefilename
skipinteger0
delimitertexttab

Image Tags

<image>
Attributes:
nametypedefault
filenamefilename
fileformattext
widthinteger pixels
heightinteger pixels
size-type"image" or "canvas""canvas"
titletext
backgroundcolor"white"
canvascolor"white"
border-colorcolor"#CCCCCC"
border-sizeinteger pixels1
Contents: <axis>
<area>
<grid>
<line>
<points>
<segments>
<axis>
Attributes:
nametypedefault
location"left" or "top" or "right" or "bottom"
scaling"linear" or "log2" or "loge" or "log10""linear"
clip-mindouble
clip-maxdouble
clip-forcebooleanfalse
snap-todouble
titletext
colorcolor"black"
Contents: <label>
<label>
Attributes:
nametypedefault
colorcolor"color" attribute of parent axis
modulusdouble"snap-to" attribute of parent axis if it exists
offsetdouble0.0
Contents: value template
default is "%1.0#"

Drawing Layer Tags

<area>
Attributes:
nametypedefault
titletext
colorcolor"black"
x0column"x0" or "x"
y0column"y0" or "y"
x1column"x1" or "x"
y1column"y1" or "y"
x-axis"left" or "right""left"
y-axis"top" or "bottom""bottom"
<grid>
Attributes:
nametypedefault
colorcolor"black"
x-modulusdouble
y-modulusdouble
x-offsetdouble0.0
y-offsetdouble0.0
x-axis"left" or "right""left"
y-axis"top" or "bottom""bottom"
<line>
Attributes:
nametypedefault
titletext
colorcolor"black"
xcolumn"x"
ycolumn"y"
x-axis"left" or "right""left"
y-axis"top" or "bottom""bottom"
widthpixels or column1.0
<points>
Attributes:
nametypedefault
titletext
colorcolor"black"
xcolumn"x"
ycolumn"y"
x-axis"left" or "right""left"
y-axis"top" or "bottom""bottom"
radiuspixels or column0.5
filledbooleanfalse
<segments>
Attributes:
nametypedefault
titletext
colorcolor"black"
x0column"x0" or "x"
y0column"y0" or "y"
x1column"x1" or "x"
y1column"y1" or "y"
x-axis"left" or "right""left"
y-axis"top" or "bottom""bottom"
widthpixels or column1.0

Attribute Types

boolean
A boolean value indicates a condition that is either true or false. "on", "yes", "true", or 1.0 are interpretted as true, everything else is interpretted as false.
color
See the colors documentation page.
column
The name of a column, which must have already been created by a datasource. (It must have been specified in a column list.)
column list
A column list is a comma-separated list of column names. The name of each column must start with a letter and must not be all UPPERCASE.
double
A double is a real number -- a number that has a whole and decimal part. (The name "double" comes from Computer Science and refers to how accurate a number can be represented.)
filename
A filename is the name of a file. If an relative path is used, it is usually interpretted in relation to where the moth program is run.
integer
An integer is a whole number -- a number without a decimal part.
text
A chunk of text. Some attributes may also have restrictions on what constitutes a valid value. For example, <mysql>'s attribute database must be a valid database on the specified host.