Repository navigation
Graphs
In a suite, an individual detail field may be in the form of a graph.
Graphs are defined in suite.xml, inside <detail> blocks, inside <template> blocks, similarly to text templates. To display a graph in case selection or details, add a new <field> to the appropriate <detail> block. The field's header text will be displayed as the graph's title.
Note that the template's "form" attribute must be set to "graph," and the graph must have a type. Supported types:
- "xy" may be configured to display as a line or scatter chart
- "time" for xy charts where the x axis uses date or datetime values
- "bubble" for bubble charts
- "bar" for bar charts. Bar charts expect the x function to return a string, which will be used to label the bar. While bar charts support multiple series, each series should use the same nodeset and x function.
<detail id="m0_case_long">
<title>
<text>
<locale id="case_lists.m0.title"/>
</text>
</title>
<field>
<header>
<text>
<locale id="case_lists.m0.header"/>
</text>
</header>
<template form="graph">
<graph type="xy">
<!-- see below -->
</graph>
</template>
</field>
</detail>A graph should contain a element for every series to be drawn.
It may contain a configuration element to define the graph's look and feel.
It may contain any number of annotations, which are strings to be drawn at specific points on the graph.
<graph>
<series type="line">
<!-- May contain 0..* series. See below. -->
</series>
<configuration>
<!-- May contain a single configuration. See below. -->
</configuration>
<annotation>
<!-- May contain 0..* annotations. See below. -->
</annotation>
</graph>A series is primarily defined by a nodeset, x function, and y function. The x and y functions will be applied against each node in the nodeset to generate points on the graph. Nodesets are likely either case data or fixture data.
Any series contained in a bubble graph must also have a radius function, which will determine the size of each bubble.
A series may contain a <configuration> block to customize its look and feel.
<series nodeset="instance('casedb')/casedb/case[index/parent=current()/@case_id]">
<configuration>
<!-- see below -->
</configuration>
<x function="hours" />
<y function="contraction_frequency" />
<radius function="contraction_length" />
</series>The configuration block consists of a set of properties. Each is a text element, as used elsewhere in the suite, so it can be localized text, an XPath expression, etc. An id identifies each property.
Supported properties:
- bar-sort: Bar graphs only. One of "ascending", "descending". If set, sort bars in this fashion. Note that this should only be used with single-series graphs.
- fill-above: If set, area above this line will be filled with the given color, which is expected to be a #aarrggbb or #rrggbb string.
- fill-below: As above, but below the line. (On the alert/action graph at the top of the page, this is how the red and yellow areas are created.)
- line-color: Color of line. Defaults to black. Note that setting this to #00xxxxxx will make the line disappear altogether.
- point-style: What shape to make the series' points. One of "none", "circle", "x", "diamond", "triangle". Defaults to "circle." (Compare the two lines on the alert/action graph at the top of the page.)
- max-radius: Bubble graphs only. Base the bubble size on this value, rather than on the data in the series. Useful when looking at multiple series or graphs and wanting them all to be on the same scale.
- secondary-y: XY graphs only. If true, plot this data on a secondary y axis, which may have its own min, max, and labels, and will be drawn on the right side of the graph.
- var-*: See graph configuration below. These variables will be available only to this series.
<configuration>
<text id="fill-below">
<value>#ffdddd00</value>
</text>
<text id="line-color">
<value>#00000000</value>
</text>
<text id="point-style">
<value>none</value>
</text>
</configuration>Graph configuration elements have the same format as series configuration elements, just with different available properties. The properties beginning with "secondary-y" refer to a second y axis, which may have its own min, max, and labels, and which will be drawn on the right side of the graph.
Supported properties:
- Axis min and max
- x-min (Note that for xy or bubble graphs, this should be a number, while for time graphs, it should be a string like "2014-12-31" or "2014-12-31 14:15:16")
- x-max (same formatting as x-max)
- y-min
- y-max
- secondary-y-min
- secondary-y-max
- Axis titles
- x-title
- y-title
- secondary-y-title
- Axis labels: default is to let the graphing code invent reasonable labels based on the min and max.
- x-labels
- y-labels
- secondary-y-labels
- Each of these accepts three types of values: a single number, a JSON array, or a JSON object:
-
3
- This will draw approximately 3 evenly-spaced labels on the axis.
-
[1, 3, 5]
- This will draw the labels "1", "3", and "5" at those points on the y axis.
-
{ "0": "freezing", "100": "boiling" }
- This will draw the text "freezing" and "boiling" at the 0 and 100 mark on the y axis, respectively.
-
3
- x-labels-time-format: Format for displaying time-based labels. This must be a string recognizable to SimpleDateFormat. Defaults to "yyyy-MM-dd." Relevant only for time graphs, and only if x-labels is a single number (or x-labels is unspecified).
- show-grid: defaults to true
- show-axes: defaults to true
- zoom: defaults to false. If true, this allows user to pinch zoom and drag to pan. It also enables buttons to zoom in and out. If false, there's no zooming or panning ability.
- var-foo: You can define suite variables, as described in the suite definition. A key like "var-foo" will define the variable $foo, which will then be available within the graph. Note that variables may not depend on each other, but standard configuration elements may depend on variables.
Annotations are text snippets that are drawn at user-specified points on the graph. An annotation requires an x coordinate, y coordinate, and value. These use the same <text> element as elsewhere in the suite, so they support localized text, XPath expressions, etc.
<annotation>
<x>
<text>
<value>5</value>
</text>
</x>
<y>
<text>
<value>7</value>
</text>
</y>
<text>
<value>Alert</value>
</text>
</annotation>