Skip to content
Jenny Schweers edited this page Apr 14, 2015 · 33 revisions

Graphs

In a suite, an individual detail field may be in the form of a graph.

Overarching Placement

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
<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="line">
        <!-- see below -->
      </graph>
    </template>
  </field>
</detail>

Graph

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>

Series

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>

Configuration (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:

  • 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>

Configuration (graph)

TODO

Annotations

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>

Clone this wiki locally