Nanodrop.Graph
(nanodrop v0.3.1)
Copy Markdown
Generates SVG graphs for spectral data.
Summary
Functions
Generates an SVG graph from measurement results.
Generates a PNG binary with embedded metadata.
Generates an SVG graph and saves to file.
Functions
Generates an SVG graph from measurement results.
Parameters
results- List of measurement result maps containing::sample- Sample number:wavelengths- List of wavelengths:absorbance- List of absorbance values
mode- A Nanodrop.Mode implementation (e.g.,%Nanodrop.Mode.DNA{})
Returns
SVG string.
Generates a PNG binary with embedded metadata.
Returns {:ok, png_binary} or {:error, reason}.
The PNG includes spectrum data as JSON in the png-comment chunk.
Additional metadata can be passed in the metadata option.
Options
:metadata- Additional metadata map to merge into the embedded JSON
Example
result = %{
sample: 1,
wavelengths: [...],
absorbance: [...],
a260: 1.5,
a280: 0.8,
ratio: 1.87,
concentration: 75.0
}
{:ok, png} = Nanodrop.Graph.generate_png([result], %Nanodrop.Mode.DNA{},
metadata: %{timestamp: "2026-04-11T10:30:00Z", device_serial: "ABC123"}
)
Generates an SVG graph and saves to file.
If filename ends in .png, converts SVG to PNG using Vix/libvips.
Otherwise saves as SVG.
PNG files include spectrum data as metadata (JSON in png-comment chunk).