Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,50 @@ land in a minor release.

## [Unreleased]

## [0.3.0] — 2026-09-29
### Fixed

- **A geom's own arrays now follow the panel's final scales.** Error bars, ribbons, tiles and
rectangles, segments, box plots, violins, an image's bounds, and the baselines of areas and bars
were projected onto the panel when the geom was built, against the series' scales as they were
then. A second layer with a wider domain, `Chart.withXDomain`/`withYDomain`, or a switch to a
log axis then moved the layer's points and left those arrays behind. `Chart.addErrorbar` of
±0.5 m on a 0–10 m line drew a bar spanning 0–10 m, and a tile beside a wider scatter filled the
panel. Present since 0.2.0. Single-layer figures, and layers that happened to share a domain,
were always right, which is why no baseline moved with the fix.
- **A shot over states with differently shaped grids keeps every panel.** `Chart.arrangeUnion`
took its outer grid from the one state with the most panels, so an animation between a 1×2
and a 2×1 figure arranged against one shape, and the other state's extra panel had no region
and was not drawn. The grid is now the union of every state's rows, columns and panel
positions.
- **`SvgPathData.parse` no longer hangs on a number after `Z`.** `Z` takes no arguments, and a
number following it was read as another `Z` that consumed nothing, so `M0 0 Z 1` looped forever,
appending `ClosePath` until memory ran out. It is now refused by name, like every other
malformed path.
- **`Scene.opacity nan` is refused.** NaN fails both comparisons the clamp is made of, so it
reached the IR unchanged and each backend handled it differently. It now raises
`ArgumentException`; every other value is still clamped into [0, 1].

### Security

- **A formula cannot run a shell command.** `Marey.Tools.Tex` starts `latex` with
`--disable-write18`. The formula is the public `TextRun.Tex` field and may come from data, and
on a TeX installation configured with `shell_escape = t`, `\immediate\write18{…}` in it ran
the command. TeX Live's and MiKTeX's restricted default already refused commands outside their
allow-list, so default installations were not affected.

### Changed

- **`Geom` carries data, and `GeomOf<nd>` is what gets drawn.** The union is now
`GeomOf<'p>`, generic over the space its numbers live in; `Geom` is `GeomOf<1>`, data values
with their measure spent by the typed constructor exactly as before. `Geom.project` puts one on
a panel through a pair of scales, and the figure compiler calls it with the panel's final scales
beside the points. `Geom.compile`, `compileFor` and `compileSubset` take a `GeomOf<nd>`; to draw
a geom outside a figure, `Geom.onSeries s` projects it through its own series' scales.
`BoxSpan` and `ViolinProfile` gained the same parameter. `Geom.text` and `Geom.textAt` carry no
numbers and are generic in it. A layer's area or bar baseline is now the data value zero, and
`Geom.project` clamps it into the panel.

## [0.3.0] — 2026-10-05

**M2.5 — *Raster*.** An eighth package, and the first output that is not text.

Expand Down
8 changes: 8 additions & 0 deletions src/Marey.Core/Scene.fs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,15 @@ module Scene =
/// and three backends left to their own devices would invent three different answers to it
/// — SVG clamps, Skia truncates a byte, TikZ passes it to a driver. One answer, at the
/// constructor, is the only way the IR stays the thing all three agree about.
///
/// **NaN is refused rather than clamped**, because it fails both comparisons a clamp is made
/// of and would otherwise reach the IR untouched. A translucent value has a nearest legal
/// opacity; NaN has none, which is `Anim`'s reason for validating a duration rather than
/// clamping one.
let opacity (alpha: float) (n: Node) =
if System.Double.IsNaN alpha then
invalidArg "alpha" "Marey: an opacity of NaN has no nearest value in [0,1] to clamp to."

Opacity((if alpha < 0.0 then 0.0
elif alpha > 1.0 then 1.0
else alpha),
Expand Down
33 changes: 25 additions & 8 deletions src/Marey.Plot/Figure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,14 @@ module Figure =
p.Layers
|> Array.mapi (fun ordinal l ->
let pts = Erase.projectXY l.Data

// D97 — the geom's own arrays through the same scales as `pts`, at
// the same moment. Projected at construction they went stale as soon
// as `unify` or a stated domain moved the panel out from under them.
let geom =
let sx, sy = Erase.seriesScales l.Data
Geom.project sx.Project sy.Project l.Geom

let layerKey = Keys.layer panelKey ordinal

// D69 — the rows this layer was asked to name. `None` is the
Expand All @@ -864,7 +872,7 @@ module Figure =
// No channels, no counts: an unchannelled layer's annotation is
// exactly what it was before phase 2, so every baseline that
// predates channels stays byte-identical.
Geom.compileFor address None p.Coord plotSize l.Style l.Geom pts, [||]
Geom.compileFor address None p.Coord plotSize l.Style geom pts, [||]
else
let (batches, unmapped) = Channel.split l.Channels pts.Length

Expand All @@ -877,7 +885,7 @@ module Figure =
p.Coord
plotSize
(b.Restyle l.Style)
l.Geom
geom
pts)

// `unmapped` is reported rather than swallowed: a point whose
Expand Down Expand Up @@ -1107,13 +1115,22 @@ module Figure =

let head = states |> Array.map headOf |> Array.max

// The frame the grid is taken from is the one with the most panels, so an animation that
// adds a panel mid-shot still has a region for it. Everything else about the grid — rows,
// columns, gaps, padding — is the theme's and does not vary with the data.
let widest =
states |> Array.maxBy (fun f -> (f.Panels.Length, max 1 f.Rows, max 1 f.Cols))
// The grid is the union of every state's: as many rows and columns as any state has,
// and a region for every panel position any state uses. It used to be taken from the
// one state with the most panels, which is the same thing until two states have the
// same count in different shapes — a 1×2 and a 2×1 — and then one of them lost a panel
// to a grid that had no region for it. Gaps, padding and the theme do not vary with the
// data, so the first state supplies them.
let template =
{ states.[0] with
Rows = states |> Array.map (fun f -> max 1 f.Rows) |> Array.max
Cols = states |> Array.map (fun f -> max 1 f.Cols) |> Array.max
Panels =
states
|> Array.collect (fun f -> f.Panels)
|> Array.distinctBy (fun p -> p.Row, p.Col) }

let outer = Layout.arrange m extent (outerGrid (Some head) widest)
let outer = Layout.arrange m extent (outerGrid (Some head) template)

// Then every panel of every state, unioned by key. `Array.choose` rather than an
// exception when a key is missing: a state that lacks a panel another state has
Expand Down
Loading
Loading