Eunoia

Eunoia.place_labels

Julia · julia · 1.0.1

place_labels(
    fit::AbstractEulerFit,
    sizes::AbstractDict;
    placement::Union{Nothing, AbstractString} = nothing,
    leader::Union{Nothing, AbstractString} = nothing,
    margin::Union{Nothing, Real} = nothing,
    iterations::Union{Nothing, Integer} = nothing,
    precision::Union{Nothing, Real} = nothing,
    tether::Union{Nothing, AbstractString} = nothing,
    leader_gap::Union{Nothing, Real} = nothing,
    min_gap::Union{Nothing, Real} = nothing
)

Methods

place_labels( fit::AbstractEulerFit, sizes::AbstractDict; placement::Union{Nothing, AbstractString} = nothing, leader::Union{Nothing, AbstractString} = nothing, margin::Union{Nothing, Real} = nothing, iterations::Union{Nothing, Integer} = nothing, precision::Union{Nothing, Real} = nothing, tether::Union{Nothing, AbstractString} = nothing, leader_gap::Union{Nothing, Real} = nothing, min_gap::Union{Nothing, Real} = nothing )

place_labels(fit, sizes; placement=nothing, leader=nothing, margin=nothing,
             iterations=nothing, precision=nothing, tether=nothing,
             leader_gap=nothing, min_gap=nothing)

Resolve collision-aware label positions for the regions of a fitted EulerFit/VennFit, given the rendered label box sizes.

The core can't place labels without their on-screen sizes (font metrics it never sees at fit time), so this is a separate call from euler: measure each label, then ask for placements. sizes is a mapping from region/combination strings ("A", "A&B", …) to a (width, height) tuple in the same coordinate units as the fitted shapes. Only regions present in both sizes and the fit's geometry get a placement; degenerate inputs are silently skipped.

Each placement tries to sit inside its region; one that can't fit is pushed outside with a leader line. Returns a Dict{String,LabelPlacement} (see LabelPlacement).

Strategy knobs (all optional; nothing keeps the core default). Invalid string tokens are rejected by the native core and surface as an error:

  • leader: leader edge type, "straight" (default) or "elbow" (d3-pie style orthogonal leaders with column-based placement).

  • placement: exterior solver for straight leaders, "raycast" (default), "force_directed" (spring/repulsion relaxation for crowded diagrams), or "matched" (noncrossing boundary labels); ignored for "elbow".

  • margin: gap between the diagram and exterior labels (both edge types); the per-region proportional default applies when omitted.

  • iterations: iteration cap for "force_directed" (default 200); ignored otherwise.

  • precision: pole-of-inaccessibility search precision (default 0.01).

  • tether: where an exterior leader attaches to its region, "poi" (default, the pole of inaccessibility) or "boundary" (the region's outer ring).

  • leader_gap: visible gap between the leader tip and the label box (default 0.0).

  • min_gap: minimum vertical spacing between stacked "elbow" labels; ignored otherwise.

fit = euler(Dict("A" => 5, "B" => 3, "A&B" => 1.5))
placements = place_labels(fit, Dict("A" => (0.6, 0.3), "B" => (0.6, 0.3));
                          placement="force_directed")