A graph is served as an <img>, which makes the SVG an isolated document - script does not run inside it and the parent page cannot read its DOM. The numbers a tooltip needs therefore have to travel separately from the picture, which is what this class is for.
Units
Time is epoch seconds, matchingImageParameters.start and ImageParameters.end. Values are in the axis' own display unit, the same one ValueAxis prints before appending a K/M/G suffix: both the axis bounds and every series value are divided by ImageParameters.magfact, so the pair stays consistent whichever branch set the bounds and a client can invert linearly without knowing the factor.Field Summary
FieldsModifier and TypeFieldDescriptionThe CSS colour per series, parallel toseries, or null where the plot element was painted with something that has no single colour.private longThe end time of the graph.private List<double[]> The data series of the graph.private longThe start time of the graph.private intThe x origin of the graph.private intThe width of the graph.private doubleThe highest value of the y axis.private doubleThe lowest value of the y axis.private intThe y origin of the graph.private intThe height of the graph.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate static StringThe CSS colour of a plot element, for a readout swatch to match the graph's own legend.booleanWhether there is enough here to invert a cursor position: a plot area, a non-degenerate time span, a non-degenerate value range and at least one series.(package private) voidpopulate(ImageParameters im, List<PlotElement> plotElements) Populates this metadata from a finished render.private static Stringround(double v) Rounds for transport: three decimals is finer than any axis label.toJson()Renders the metadata as compact JSON for a client-side overlay.
Field Details
xOrigin
private int xOriginThe x origin of the graph.yOrigin
private int yOriginThe y origin of the graph.xSize
private int xSizeThe width of the graph.ySize
private int ySizeThe height of the graph.start
private long startThe start time of the graph.end
private long endThe end time of the graph.yMin
private double yMinThe lowest value of the y axis.yMax
private double yMaxThe highest value of the y axis.series
The data series of the graph.colors
Constructor Details
RrdGraphMeta
RrdGraphMeta()Package-private: instances are created by the renderer.
Method Details
populate
Populates this metadata from a finished render.- Parameters:
im- the render's image parameters, holding the plot rect and axis boundsplotElements- the definition's plot elements, holding the series values
hexOf
The CSS colour of a plot element, for a readout swatch to match the graph's own legend.Taken from the element that drew the line, so the swatch cannot drift from the legend when a theme changes. A fill may be a gradient or a texture rather than a flat colour, and those have no single swatch equivalent, so they yield null and the caller falls back to the stylesheet's own colour.
- Parameters:
paint- the element's paint, may be null- Returns:
- a
#rrggbbstring, with alpha as#rrggbbaawhen translucent, or null
isInvertible
public boolean isInvertible()Whether there is enough here to invert a cursor position: a plot area, a non-degenerate time span, a non-degenerate value range and at least one series. A flat or empty graph produces a zero-height range, and dividing by it would yield infinities.- Returns:
- true when the metadata is usable
toJson
Renders the metadata as compact JSON for a client-side overlay.Values are rounded to a fixed number of decimals: the client only ever displays them, and full double precision would triple the payload for no visible gain. Non-finite samples become null so the payload stays valid JSON - a NaN in a series is a gap, not a value.
- Returns:
- the JSON document, never null
round
Rounds for transport: three decimals is finer than any axis label.- Parameters:
v- the value to round- Returns:
- v rounded to three decimals, as a string