# `Nanodrop.Graph`

Generates SVG graphs for spectral data.

# `generate`

```elixir
@spec generate(
  [map()],
  struct()
) :: String.t()
```

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.

# `generate_png`

```elixir
@spec generate_png([map()], struct(), keyword()) :: {:ok, binary()} | {:error, term()}
```

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"}
    )

# `save`

```elixir
@spec save([map()], String.t(), struct()) :: :ok
```

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).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
