Giggly.Geom.Context (giggly v0.2.0)

Copy Markdown View Source

What a geom draws with beyond its own rows, handed to Giggly.Geom.draw_panel/3, draw_key/3 and key_size/3: where a panel's rows go and what the panel is like.

A geom asks it where its rows go (transform/2, munch/2), where the panel ends (extents/1), whether a straight line stays straight (linear?/1), whether the panel shows its marks mirrored (mirrored?/1) and where its marks are cut off (clip/1). A geom drawing by delegation hands the context on to the geom it delegates to, as it is. A legend key's context places nothing, since a key is drawn in no panel.

Summary

Functions

Where what is drawn in the panel is cut off: :on, at its edges; :off, nowhere; or {:outline, points}, at an outline in the panel's units.

Each axis's extent in the panel, {low, high}, in the data's positions.

Whether a straight line in the data stays straight in the panel, so a line's ends may be placed with transform/2 alone; where it does not, a line is drawn through munch/2.

Whether the panel shows its marks mirrored, exactly one of its axes running backwards.

frame's lines placed in the panel, each cut into steps short enough to follow the panel's curves: its rows are the lines' points in order, a change of group ending one line. Where straight lines stay straight it places them as transform/2 does.

frame with its positions placed in the panel, each from 0 at one edge to 1 at the other; its other columns are left as they are.

Types

t()

@opaque t()

Functions

clip(context)

@spec clip(t()) :: :on | :off | {:outline, [{float(), float()}]}

Where what is drawn in the panel is cut off: :on, at its edges; :off, nowhere; or {:outline, points}, at an outline in the panel's units.

extents(context)

@spec extents(t()) :: %{x: {number(), number()}, y: {number(), number()}}

Each axis's extent in the panel, {low, high}, in the data's positions.

linear?(context)

@spec linear?(t()) :: boolean()

Whether a straight line in the data stays straight in the panel, so a line's ends may be placed with transform/2 alone; where it does not, a line is drawn through munch/2.

mirrored?(context)

@spec mirrored?(t()) :: boolean()

Whether the panel shows its marks mirrored, exactly one of its axes running backwards.

munch(context, frame)

@spec munch(t(), Giggly.DataFrame.t()) :: Giggly.DataFrame.t()

frame's lines placed in the panel, each cut into steps short enough to follow the panel's curves: its rows are the lines' points in order, a change of group ending one line. Where straight lines stay straight it places them as transform/2 does.

transform(context, frame)

@spec transform(t(), Giggly.DataFrame.t()) :: Giggly.DataFrame.t()

frame with its positions placed in the panel, each from 0 at one edge to 1 at the other; its other columns are left as they are.