java.lang.Object
org.rrd4j.graph.RrdGraphMeta
The plot geometry and series behind a rendered graph, in a form a script can invert: given a cursor position in image pixels it yields the time and the value at that point.
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.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionbooleanWhether 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.toJson()Renders the metadata as compact JSON for a client-side overlay.
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
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