app.color

Color scale helpers for metadata-driven tip coloring.

Provides small built-in categorical palettes and gradient scales, along with utilities to infer field types and build color maps keyed by leaf name.

build-color-map

(build-color-map tips field-key palette-id type-override)

Builds a map of {leaf-name -> color} for the given field.

Tips are expected to include :metadata maps keyed by field keywords. Palette id is optional and will fall back to a default for the field type.

build-legend

(build-legend tips field-key palette-id type-override)

Builds legend entries for the given field.

Returns {:type :entries } with entries of {:id :label :color }. Numeric/date fields are binned into ranges; categorical fields list each unique value.

build-legend-sections

(build-legend-sections auto-legend field-label highlights legend-labels)

Assembles legend sections for display from auto-coloring and custom highlights.

Takes the legend built by build-legend, along with custom highlight data, and returns a vector of {:title string :entries [...]} section maps.

Arguments: - auto-legend - result of build-legend (may be nil) - field-label - display label for the auto-colored field (e.g. “Lineage”) - highlights - map of {leaf-name -> color} for custom highlights - legend-labels - map of {color -> user-label} for custom legend entries

Returns {:sections [...] :show? bool} where :show? is true when any legend sections exist.

categorical-options

(categorical-options)

Returns ordered categorical palette option maps.

gradient-options

(gradient-options)

Returns ordered gradient palette option maps.

infer-field-type

(infer-field-type metadata-rows field-key)

Infers the field type from metadata rows for a given key.

infer-value-type

(infer-value-type values)

Infers field type from a collection of values.

Returns {:type :values } where :values is numeric for numeric/date types (with non-parsing values ignored) or raw strings for categorical.

palette-options

(palette-options field-type)

Returns palette options appropriate for a field type.

Numeric and date fields use gradient palettes; everything else uses categorical palettes.

resolve-field-type

(resolve-field-type values type-override)

Resolves the effective field type, honoring an override when present.

resolve-palette

(resolve-palette field-type palette-id)

Resolves a palette id for the given field type, falling back to a default.

Returns {:id :palette }.