java.lang.Object
org.rrd4j.graph.RrdGraphMeta

public final class RrdGraphMetaextends Object
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, matching ImageParameters.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 Details

    • RrdGraphMeta

      RrdGraphMeta()
      Package-private: instances are created by the renderer.
  • Method Details

    • populate

      void populate(ImageParameters im, List<PlotElement> plotElements)
      Populates this metadata from a finished render.
      Parameters:
      im - the render's image parameters, holding the plot rect and axis bounds
      plotElements - 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

      public String 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