Caution

This is the documentation for the current development branch of the CometVisu. It is possible that some of the described features are not yet available in the current release.

Also there might be lots of errors in this documentation as some parts of the content have been translated by an online translation service.

The diagram2 plugin

Description

Diagrams drawn with d3, the successor of the flot based diagram plugin.

The configuration is the one of the old plugin, only the widget names differ, so that both can be used side by side while this one is being completed.

The diagram2 plugin draws the history of measured values. It is the successor of the The diagram plugin plugin and uses D3 instead of flot. Its configuration is the same one: attributes, child elements, defaults and appearance match the old plugin, only the widget names are diagram2 and diagram2_info. Both plugins can therefore be used side by side in the same configuration and compared directly.

Like the old plugin the diagram is shown as a widget by default (inline diagram). With popup="true" a click additionally opens a fullscreen view in which the diagram can be panned and zoomed. Depending on the widget size, previewlabels and legend decide whether axis labels and the legend are shown in the inline diagram.

To show a current value as the widget that opens the diagram when clicked, use The diagram2_info plugin instead.

The plugin is included in the meta section of the main configuration like any other:

<plugins>
    <plugin name="diagram2" />
</plugins>

Hint

The plugin list is read from the main configuration only. If a <diagram2> lives in a file pulled in through <include>, the <plugin> entry still has to be in the main configuration.

Data sources

Every series is its own child element. Which sources are available depends on the backend in use:

<iobroker>

State from the ioBroker history. The content is the state id, instance selects the history instance (e.g. influxdb.0), backend a named backend entry.

<rrd>

RRD file on the server, as in the old plugin. The content is the name without the .rrd suffix, datasourceIndex selects the column inside the file.

<influx>

Measurement from an InfluxDB, filtered through <and>, <or> and <tag>.

<openhab>

Item from the openHAB persistence service. The content is the item name.

<demo>

Generated data, only useful in a demo configuration.

The series attributes are largely the same for all sources: yaxis assigns the series to an axis — its value is the name of that axis, i.e. the content of the corresponding <axis> element; without it the series goes onto the first axis. color and label set colour and legend text, scaling and offset convert the raw values, style selects between lines, bars and points, fill, steps, barWidth and align control the drawing, and resolution together with consolidationFunction (on <iobroker>, <rrd> and <influx>) decide how the values are aggregated for the shown time range. fillMissing closes gaps — <rrd> does not have that attribute.

The possible values of consolidationFunction and fillMissing, the filter elements and the authentication attribute inside <influx> are described with the old plugin and apply unchanged: The diagram plugin.

<diagram2 series="day" period="3" popup="true" previewlabels="true" legend="both" legendposition="nw">
    <layout colspan="12" rowspan="6" />
    <axis unit=" °C" label="Temperature" position="left" decimals="1">temperature</axis>
    <axis unit=" %" label="Humidity" position="right" min="0" max="100" decimals="0">humidity</axis>
    <iobroker instance="influxdb.0" color="#FF0000" label="Outside [°C]" yaxis="temperature">hm-rpc.0.LEQ123456.1.TEMPERATURE</iobroker>
    <iobroker instance="influxdb.0" color="#00A0FF" label="Humidity [%]" yaxis="humidity">hm-rpc.0.LEQ123456.1.HUMIDITY</iobroker>
</diagram2>

Interaction in the popup

The inline diagram does not move; panning and zooming only work in the popup view:

  • Pan: drag with the pressed mouse button, or swipe with one finger.

  • Zoom: a double click zooms in by a factor of 1.5, the mouse wheel zooms in both directions, two fingers zoom through a pinch gesture. The point under the pointer stays where it is.

  • Only the time axis is zoomed and panned. The value axes follow only if zoomYAxis="true" is set.

  • After each gesture the data for the new time range is loaded. The end stays at the current time, the start follows the visible range.

Stroke widths and grid colour

Four attributes decide how heavily the diagram is drawn — each on its own, each defaulting to the picture it had:

attribute

default

applies to

gridwidth

1

grid lines, axis lines and tick marks

gridopacity

0.4

how solid the grid lines are, 0 to 1

borderwidth

1

the frame around the plotting area

linewidth

see below

the graphs, their bar and point outlines included

gridopacity only affects the grid lines; frame, axes and tick marks are always solid.

Without linewidth diagram2 draws its lines with 1.5 and the outlines of bars and points with 1 — exactly as before; a configured value applies to all three.

The old plugin draws heavier: frame and graphs with 2, its grid lines with 1 as well, but in the full grid colour. So with borderwidth="2" linewidth="2" gridopacity="1" a diagram2 looks like a diagram. The Moving from diagram to diagram2 puts that into context.

Differences to diagram

Deliberate deviations from the old plugin:

  • popup is honoured. Without that attribute a click opens nothing, and the widget no longer looks like a control either. The old plugin always opens the popup.

  • The stroke is slimmer and the grid fainter, see above; three attributes restore the old picture.

  • The unit of an axis really is shown — on the tick labels and in the tooltip. diagram shows it in neither place, although it reads the unit attribute as well.

  • zoomYAxis governs both gestures. Without the attribute the value axis stays put, whether the diagram is dragged or zoomed; diagram ties only zooming to it and always takes the value axis along when dragging.

  • Points (style="points") have a radius of 2 px instead of 3 px.

  • The time axis thins out its labels when there is not enough room instead of letting them overlap.

  • Drawing is done with D3. jQuery and the eight flot scripts are no longer loaded.

Unchanged are the set of attributes and child elements, the axes with their margins and tick spacing, legend, tooltip, refresh, the colour order and the defaults.

Settings

Allowed attributes in the diagram2-element

Element

Attribute

Name

Content

Description

diagram2

width

string

Deprecated: please remove attribute and use layout with colspan instead for best results.

height

string

Deprecated: please remove attribute and use layout with rowspan instead for best results.

popup

true or false

Makes diagram clickable and opens fullscreen view of diagram when clicked

previewlabels

true or false

Show labels on inline-diagram in widget

series

hour, day, week, month, year, fullday or custom

Defines the base unit for the period attribute

refresh

integer

refresh-rate in seconds, no refresh if missing

period

string

Defines whether an interval of hours, weeks, month or years is displayed (as multiple of “series)”

gridcolor

string

Color of the grid shown behind the graphs

gridwidth

decimal

Stroke width of the grid lines, the axes and their ticks, in pixels. Default 1, the value the flot based diagram uses as well.

gridopacity

decimal

How solid the grid lines are drawn, between 0 and 1. Default 0.4, the flot based diagram draws them with the full grid color, so 1.

borderwidth

decimal

Stroke width of the frame around the plotting area, in pixels. Default 1, the flot based diagram draws it with 2.

linewidth

decimal

Stroke width of the graphs, their bar and point outlines included, in pixels. Without it lines are drawn with 1.5 and outlines with 1, the flot based diagram draws all of them with 2.

legend

both, inline, popup or none

Defines whether legend is shown in combination with popup attribute. “none” => no legend, “both” => legend is shown in small inline diagram and popup, “inline” => legend in inline diagram only, “popup” => legend is only displayed in popup diagram

legendposition

nw, ne, sw or se

Defines position of legend in diagram

title

string

Adds a title to the diagram

tooltip

true or false

Enables a tooltip which displays the current value where the graph is clicked

timeformat

string

The time format for formatting the x-axis of diagrams with following placeholders:<br/> %a: weekday name (customizable) %b: month name (customizable) %d: day of month, zero-padded (01-31) %e: day of month, space-padded ( 1-31) %H: hours, 24-hour time, zero-padded (00-23) %I: hours, 12-hour time, zero-padded (01-12) %m: month, zero-padded (01-12) %M: minutes, zero-padded (00-59) %q: quarter (1-4) %S: seconds, zero-padded (00-59) %y: year (two digits) %Y: year (four digits) %p: am/pm %P: AM/PM (uppercase version of %p) %w: weekday as number (0-6, 0 being Sunday)

timeformatTooltip

string

The time format for formatting the tooltip’s time value. See timeformat attribute for possible values

zoomYAxis

true or false

Defines whether zoom acts on y-axis in addition to x-axis

seriesStart

string

In case series attribute is of type “custom” the value of this attribute is used for the start of the series.

seriesEnd

string

In case series attribute is of type “custom” the value of this attribute is used for the end of the series.

seriesResolution

integer

In case series attribute is of type “custom” the value of this attribute is used for the resolution of the series.

Allowed child-elements and their attributes

Element

Attribute

Structure

Name

Content

Description

diagram2
  • layout

colspan

decimal

Amount of columns this widget should be wide.

colspan-m

decimal

Overrules the amount of columns on a medium screen.

colspan-s

decimal

Overrules the amount of columns on a small screen.

rowspan

decimal

Amount of rows this widget should be high.

x

string

Horizontal position of the widget for 2D pages.

x-s

string

Horizontal position of the widget for 2D pages on a small screen.

x-m

string

Horizontal position of the widget for 2D pages on a medium screen.

y

string

Vertical position of the widget for 2D pages.

y-s

string

Vertical position of the widget for 2D pages on a small screen.

y-m

string

Vertical position of the widget for 2D pages on a medium screen.

z

string

Reserved for future use.

width

string

Width for the widget for 2D pages.

width-s

string

Width for the widget for 2D pages on a small screen.

width-m

string

Width for the widget for 2D pages on a medium screen.

scale

true or false

Enable/Disable scaling layout values relative to backdrop on 2d pages (default: true).

scale-s

true or false

Enable/Disable scaling layout values relative to backdrop on 2d pages on a small screen (default: true).

scale-m

true or false

Enable/Disable scaling layout values relative to backdrop on 2d pages on a medium screen (default: true).

Element

Attribute

Structure

Name

Content

Description

diagram2
  • label

  • icon

name

string

Name of the icon registration.

type

string

flavour

string

Selection of a display variant. See also Flavour.

color

string

Color of the icon in CSS notation (e.g. #1188FF).

styling

string

Change the color of the displayed value depending on its value. See also Styling

class

string

Add this value to the CSS class so that it can be formatted by a user provided style sheet.

diagram2
  • label

    • #text

string

Text to display a label for the widget.

Element

Attribute

Structure

Name

Content

Description

diagram2
  • axis

label

string

Defines the label of the axis

min

decimal

Defines the minimum of y-axis.

max

decimal

Defines the maximum of y-axis.

position

left or right

unit

string

Defines the unit shown behind values in y-axis and tooltip

decimals

integer

Defines the number of digits in values of y-axis

diagram2
  • axis

    • #text

string

Element

Attribute

Structure

Name

Content

Description

diagram2
  • iobroker

backend

string

Name of the backend connection the history is read from. Defaults to the default backend connection.

instance

string

Instance of the ioBroker history adapter that holds the data, e.g. sql.0. Without it ioBroker uses the instance configured on the state itself.

yaxis

string

color

string

label

string

scaling

decimal

steps

true or false

fill

true or false

offset

integer

resolution

integer

Resolution in seconds. Sets the aggregation step of the ioBroker history request.

consolidationFunction

AVERAGE, MIN, MAX, TOTAL, COUNT, INTEGRAL, MINMAX or NONE

How the values are aggregated per step by the ioBroker history adapter. Not every adapter implements all of them, NONE returns the stored values unaggregated.

fillMissing

previous, linear or none

style

lines, bars or points

barWidth

integer

align

left, right or center

diagram2
  • iobroker

    • #text

string

Element

Attribute

Structure

Name

Content

Description

diagram2
  • rrd

yaxis

string

Assigns the rrd-data to a y-axis

color

string

Defines the color of the data-line in the graph

label

string

Defines the label of the data-series in the legend

scaling

decimal

steps

true or false

fill

true or false

Fill the space below the data-series or bar

style

lines, bars or points

barWidth

integer

Width of the bars in units of the x axis, contrary to most other measures that are specified in pixels. For instance, for time series the unit is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of a day.

align

left, right or center

datasourceIndex

integer

If there are multiple datasources in the RRD file this index defines which one to show. Use “rrdtool info” to find the correct index.

consolidationFunction

AVERAGE, LAST, MIN or MAX

Choose one of the consolidation functions of the RRDTool (see http://rrdtool.org).

resolution

integer

The standard resolution for retrieving data from the RRD file can be overriden with a custom value in seconds.

offset

integer

An offset in seconds to modify the timestamp of the retrieved data from the RRD file.

diagram2
  • rrd

    • #text

string

Element

Attribute

Structure

Name

Content

Description

diagram2
  • influx

measurement

string

Selection of the database and measurement (example: timeseries_db/KNX_LINE1)

yaxis

string

Assigns the InfluxDB-data to a y-axis

color

string

Defines the color of the data-line in the graph

label

string

Defines the label of the data-series in the legend

scaling

decimal

steps

true or false

fill

true or false

Fill the space below the data-series or bar

style

lines, bars or points

barWidth

integer

Width of the bars in units of the x axis, contrary to most other measures that are specified in pixels. For instance, for time series the unit is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of a day.

align

left, right or center

authentication

string

When the InfluxDB requires authentication the credentials in the hidden config with this key will be used.

field

string

If there are multiple fields in the InfluxDB series this field defines which one to show. When not set a default of “*” will be used. Warning: when more than one field is selected none will be displayed.

resolution

integer

The temporal resolution for the InfluxDB data can be set to a fixed interval (value in seconds). A value of “0” disables the grouping.

consolidationFunction

COUNT, DERIVATIVE, DERIVATIVE_COUNT, DERIVATIVE_MEAN, DERIVATIVE_MEDIAN, DERIVATIVE_MODE, DERIVATIVE_SUM, DERIVATIVE_FIRST, DERIVATIVE_LAST, DERIVATIVE_MIN, DERIVATIVE_MAX, DERIVATIVE_PERCENTILE_1, DERIVATIVE_PERCENTILE_5, DERIVATIVE_PERCENTILE_10, DERIVATIVE_PERCENTILE_20, DERIVATIVE_PERCENTILE_25, DERIVATIVE_PERCENTILE_75, DERIVATIVE_PERCENTILE_80, DERIVATIVE_PERCENTILE_90, DERIVATIVE_PERCENTILE_95, DERIVATIVE_PERCENTILE_99, DIFFERENCE, DIFFERENCE_COUNT, DIFFERENCE_MEAN, DIFFERENCE_MEDIAN, DIFFERENCE_MODE, DIFFERENCE_SUM, DIFFERENCE_FIRST, DIFFERENCE_LAST, DIFFERENCE_MIN, DIFFERENCE_MAX, DIFFERENCE_PERCENTILE_1, DIFFERENCE_PERCENTILE_5, DIFFERENCE_PERCENTILE_10, DIFFERENCE_PERCENTILE_20, DIFFERENCE_PERCENTILE_25, DIFFERENCE_PERCENTILE_75, DIFFERENCE_PERCENTILE_80, DIFFERENCE_PERCENTILE_90, DIFFERENCE_PERCENTILE_95, DIFFERENCE_PERCENTILE_99, ELAPSED, INTEGRAL, MAX, MEAN, MEDIAN, MIN, MODE, SPREAD, STDDEV or SUM

Choose one of the available data aggregation functions - required when the “resolution” attribute is set.

fillMissing

string

Optional when attribute “resolution” is set: fill the time steps where data is missing by this value or one of “linear”, “none”, “null” or “previous”.

offset

integer

An offset in seconds to modify the displayed timestamps of the retrieved data from the InfluxDB.

diagram2
  • influx

  • tag

key

string

operator

=, !=, <, <=, >, >=, =~ or !~

value

string

diagram2
  • influx

  • and

  • tag

key

string

operator

=, !=, <, <=, >, >=, =~ or !~

value

string

diagram2
  • influx

  • or

  • tag

key

string

operator

=, !=, <, <=, >, >=, =~ or !~

value

string

Element

Attribute

Structure

Name

Content

Description

diagram2
  • openhab

measurement

string

Name of the item, an alternative to writing it into the element.

yaxis

string

color

string

label

string

scaling

decimal

steps

true or false

fill

true or false

offset

integer

resolution

integer

fillMissing

previous, linear or none

style

lines, bars or points

barWidth

integer

align

left, right or center

diagram2
  • openhab

    • #text

string

Element

Attribute

Structure

Name

Content

Description

diagram2
  • demo

measurement

string

Name of the demo data, an alternative to writing it into the element.

yaxis

string

color

string

label

string

scaling

decimal

steps

true or false

fill

true or false

offset

integer

resolution

integer

fillMissing

previous, linear or none

style

lines, bars or points

barWidth

integer

align

left, right or center

diagram2
  • demo

    • #text

string