Repository navigation
MUGL Normalization Rules
In order to allow for more convenient authoring of MUGL files, the MUGL specification allows certain tags and attributes to be omitted, and Multigraph will assume that those tags/attributes have certain default values. In many cases, the default values are simply constants; for example, the default color for an axis is black. In some cases, though, default values need to be computed based on the context; for example, the default format for axis labels depends on the data type of the axis.
We say that a MUGL file is "normalized" if it contains values for everything that Multigraph needs, with no need to compute any additional defaults. This file lists the rules used to "normalize" a MUGL file.
Set default values for all unspecified attributes whose defaults are constants
If a <data> tag does not have a <variables> section but does have a <values> section, examine the first row of values in the <values> section to determine the number of variables (columns) present, and create a <variables> section with one <variable> tag for each variable. If a <data> section does not have a <variables> section and also does not have a <values> section, throw an error (we insist on <variables> sections for both <csv> and <service> data objects).
If a <variable> tag does not specify an id, assign it an id of 'x' for a variable in column 0, 'y' for a variable in column 1, 'y1' for a variable in column 2, 'y2' for a variable in column 3, and so on. These default ids should be chosen based strictly on the column number, regardless on which variables in the data section have explicitly specified ids. So, for example, if we have
<data>
<variables>
<variable column="0" type="datetime" id="time"/>
</variables>
<values>
20120602, 13.1
</values>
</data>
Then we would insert
<variable column="1" type="number" id="y"/>
after the first <variable> tag.
If a <variable> tag in a <data><variables> section is missing its column attribute, assign a default based on its order in the list of <variable> tags in that section, starting with 0, but skipping any column numbers that are explicitly specified. For example, the normalized form for
<variables>
<variable type="number" id="foo" column="1"/>
<variable type="number" id="bar"/>
<variable type="number" id="bat"/>
</variables>
would be
<variables>
<variable type="number" id="foo" column="1"/>
<variable type="number" id="bar" column="0"/>
<variable type="number" id="bat" column="2"/>
</variables>
If a MUGL file contains no <plot> section, create one that plots the first (column 0) variable from the first <data> section along the file's first <horizontalaxis>, against the second (column 1) variable from that same <data> section along the file's first <verticalaxis>.
If a MUGL file does not contain any <horizontalaxis> sections, insert one.
If a MUGL file does not contain any <verticalaxis> sections, insert one.
If any of the <horizontalaxis> tags in a MUGL file do not specify id attributes, assign default ids by using x for the first horizontal axis, x1 for the second, x2 for the third, and so on. Choose the default id based strictly on where the axis is in the sequence of horizontal axes in the MUGL file; e.g. if the first horizontal axis in the file has an id attribute, but the second one does not, assign the second one an id of 'x1', not 'x'.
Similarly for <verticalaxis>, with names y, y1, y2, etc.