(arc-interpolate coord-px px1 py1 px2 py2 n-seg)Subdivide a line segment in pixel space through coord-px reprojection. Given two pixel-space endpoints (already in Cartesian panel coords), interpolates n intermediate points, projects each through coord-px, and returns a seq of [x y] pairs. Used for smooth wedge edges in polar.
Subdivide a line segment in pixel space through coord-px reprojection. Given two pixel-space endpoints (already in Cartesian panel coords), interpolates n intermediate points, projects each through coord-px, and returns a seq of [x y] pairs. Used for smooth wedge edges in polar.
(band-position band-s category group-idx n-groups frac)Where one dodged group sits inside a categorical band, in drawing
units. Returns {:lo :hi :mid :sub-bw} for that sub-band.
The first group is placed at the start of the band as a reader meets it: leftmost on a categorical x axis, topmost on a categorical y axis. Those are opposite directions in drawing units -- an x band scale runs left to right, and a y band scale places its first category at the foot of the panel, so its bandwidth is negative -- and the index is counted from the far end in that second case. Without it a horizontal dodge drew its groups bottom-up while the legend listed them top-down, so matching one against the other meant reading them in opposite directions.
Where one dodged group sits inside a categorical band, in drawing
units. Returns `{:lo :hi :mid :sub-bw}` for that sub-band.
The first group is placed at the start of the band as a reader meets
it: leftmost on a categorical x axis, topmost on a categorical y
axis. Those are opposite directions in drawing units -- an x band
scale runs left to right, and a y band scale places its first
category at the foot of the panel, so its bandwidth is negative --
and the index is counted from the far end in that second case.
Without it a horizontal dodge drew its groups bottom-up while the
legend listed them top-down, so matching one against the other meant
reading them in opposite directions.
- band-s: wadogo band scale
- category: category value to look up
- group-idx: index of this group within n-groups
- n-groups: total number of dodge groups
- frac: fraction of band width to use (e.g. 0.8)(bar-polygon coord-px flipped? cat-lo cat-hi val-lo val-hi)Compute polygon points for a rectangular bar, with arc interpolation when coord-px is provided (polar). In cartesian/flip, produces a simple 4-corner closed polygon.
Compute polygon points for a rectangular bar, with arc interpolation when coord-px is provided (polar). In cartesian/flip, produces a simple 4-corner closed polygon. - coord-px: pixel-space reprojection fn, or nil for cartesian - flipped?: true when axes are swapped - cat-lo, cat-hi: pixel range along the categorical (band) axis - val-lo, val-hi: pixel range along the numeric (value) axis
(draw-shape shape-kw r)Draw a shape symbol on a 2r-by-2r box whose top-left corner is the origin. Public so the legend renderer draws the same symbol the marks do. An unknown symbol draws a circle.
Draw a shape symbol on a 2r-by-2r box whose top-left corner is the origin. Public so the legend renderer draws the same symbol the marks do. An unknown symbol draws a circle.
Convert a plan layer into membrane drawable primitives.
layer is a plan layer map with data-space geometry and resolved colors.
ctx contains :coord-fn, :sx, :sy, :coord-type.
Dispatches on (:mark layer).
Convert a plan layer into membrane drawable primitives. `layer` is a plan layer map with data-space geometry and resolved colors. `ctx` contains :coord-fn, :sx, :sy, :coord-type. Dispatches on (:mark layer).
(layer->membrane-categorical-bars layer ctx)Render categorical count bars from a plan :rect layer. Stack: reads pre-computed :y0/:y1 from position adjustment. Dodge: reads :dodge-idx/:dodge-ctx from position adjustment.
Render categorical count bars from a plan :rect layer. Stack: reads pre-computed :y0/:y1 from position adjustment. Dodge: reads :dodge-idx/:dodge-ctx from position adjustment.
(layer->membrane-value-bars layer ctx)Render value bars from a plan :rect layer.
Render value bars from a plan :rect layer.
Names the panel region a mark's geometry is clipped to -- bounded so it cannot paint outside the region. The panel renderer resolves the name to a rectangle and clips the mark to it. Two regions exist:
This keeps the clip decision with each mark rather than hardcoded in the panel renderer. An extension whose mark draws in the margin registers (defmethod mark-clip-region :my-mark [_] :panel-box). Dispatches on the mark keyword.
Names the panel region a mark's geometry is clipped to -- bounded so it cannot paint outside the region. The panel renderer resolves the name to a rectangle and clips the mark to it. Two regions exist: - :drawing-area (the default) -- the grey panel background. The right choice for data marks: geometry past the domain is hidden at the plotting edge, and nothing spills into the axis margin (the band around the plot where ticks and labels sit). - :panel-box -- the wider panel rectangle, including that margin. For marks that draw in the margin on purpose (rug ticks), so they are not cut off at the drawing-area edge. This keeps the clip decision with each mark rather than hardcoded in the panel renderer. An extension whose mark draws in the margin registers (defmethod mark-clip-region :my-mark [_] :panel-box). Dispatches on the mark keyword.
(maybe-dash dash drawable)Wrap a stroked drawable in a stroke-dash pattern when dash is set
(a [dash gap ...] vector); otherwise return it unchanged. Placed
outside the stroke-width wrapper so both backends apply the dash.
Wrap a stroked drawable in a stroke-dash pattern when `dash` is set (a `[dash gap ...]` vector); otherwise return it unchanged. Placed outside the stroke-width wrapper so both backends apply the dash.
(numeric-baseline ctx flipped?)The value in data space that a mark drawn from a baseline measures from -- the foot of a bar, the closing edge of an area, the bottom of a lollipop stem.
Zero on a linear axis, where plan/compute-global-y-domain has
already pulled the domain out to cover it. A log axis has no reading
for zero, so the baseline is the panel's own smallest value and the
mark rests on the axis rather than being drawn from an infinity.
One function because five marks ask one question. :area and
:lollipop each answered it with a literal zero, so on a log value
axis sy of that zero was -Infinity: it reached the SVG as the
word Infinity inside a coordinate, Java2D clipped it without a
word, and Skia refused the drawing. An area drew a bowtie and a
lollipop lost every stem, on data with no zero in it at all.
flipped? says which axis carries the value: x on a horizontal
chart, y otherwise. Marks that read the band and value scales get it
from orient-scales. Marks that read coord-fn get it from the
coord, since :flip swaps the domains and passes the baseline
through sx -- passing false there closed a flipped area at the
column's minimum instead of at zero.
The value in data space that a mark drawn from a baseline measures from -- the foot of a bar, the closing edge of an area, the bottom of a lollipop stem. Zero on a linear axis, where `plan/compute-global-y-domain` has already pulled the domain out to cover it. A log axis has no reading for zero, so the baseline is the panel's own smallest value and the mark rests on the axis rather than being drawn from an infinity. One function because five marks ask one question. `:area` and `:lollipop` each answered it with a literal zero, so on a log value axis `sy` of that zero was `-Infinity`: it reached the SVG as the word `Infinity` inside a coordinate, Java2D clipped it without a word, and Skia refused the drawing. An area drew a bowtie and a lollipop lost every stem, on data with no zero in it at all. `flipped?` says which axis carries the value: x on a horizontal chart, y otherwise. Marks that read the band and value scales get it from `orient-scales`. Marks that read `coord-fn` get it from the coord, since `:flip` swaps the domains and passes the baseline through `sx` -- passing false there closed a flipped area at the column's minimum instead of at zero.
(orient-scales ctx)Extract oriented scales from rendering context.
For categorical marks that need band positioning, returns the
categorical (band) scale and numeric scale, swapped when flipped.
Flipped means either :coord :flip is in effect, or the panel's
y-axis is itself a band scale (numerical x + categorical y).
Returns {:flipped? :band-s :num-s}.
Extract oriented scales from rendering context.
For categorical marks that need band positioning, returns the
categorical (band) scale and numeric scale, swapped when flipped.
Flipped means either `:coord :flip` is in effect, or the panel's
y-axis is itself a band scale (numerical x + categorical y).
Returns {:flipped? :band-s :num-s}.(ridgeline-positions categories panel-height margin)Compute ridgeline band positions for a list of categories. Returns a vector of [category-name {:mid pixel-y :bw band-width}] pairs, preserving the input category order. Used by both the ridgeline renderer and panel tick label placement.
Returns a vector (not a map) so iteration order is deterministic
regardless of category count -- (into (array-map) ...) quietly
promotes to PersistentHashMap on the 9th key, scrambling the
order via Clojure hash. Callers do (get pos cat) style lookup
so they need to convert to a map locally if random access matters.
Compute ridgeline band positions for a list of categories.
Returns a vector of [category-name {:mid pixel-y :bw band-width}]
pairs, preserving the input category order. Used by both the
ridgeline renderer and panel tick label placement.
Returns a vector (not a map) so iteration order is deterministic
regardless of category count -- `(into (array-map) ...)` quietly
promotes to PersistentHashMap on the 9th key, scrambling the
order via Clojure hash. Callers do `(get pos cat)` style lookup
so they need to convert to a map locally if random access matters.(tooltip-value group layer i built-in)What one mark says on hover.
A :tooltip mapping is the writer's own answer and wins: a column
gives one string per row, a written value gives the same string for
every mark of the layer. Formatting a tooltip is formatting a
column, which the data language already does better than a plotting
option could -- a currency sign, a thousands separator, 1.7M, a
value from a column the layer does not draw.
Where nothing was mapped, built-in is called to describe the mark
from what its layer read.
The value is returned as the writer wrote it -- a string, or a hiccup vector for a tooltip with markup in it. Which of the two it is decides how the writer carries it to the page, so the decision is made once, there, rather than by every mark.
Returns nil when the layer draws no tooltip at all, which is what leaves the attribute off the element.
What one mark says on hover. A `:tooltip` mapping is the writer's own answer and wins: a column gives one string per row, a written value gives the same string for every mark of the layer. Formatting a tooltip is formatting a column, which the data language already does better than a plotting option could -- a currency sign, a thousands separator, `1.7M`, a value from a column the layer does not draw. Where nothing was mapped, `built-in` is called to describe the mark from what its layer read. The value is returned as the writer wrote it -- a string, or a hiccup vector for a tooltip with markup in it. Which of the two it is decides how the writer carries it to the page, so the decision is made once, there, rather than by every mark. Returns nil when the layer draws no tooltip at all, which is what leaves the attribute off the element.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |