Plotly.Normalize (plotly_ex v0.3.0)

Copy Markdown View Source

Utility for normalising keyword lists to atom-keyed maps before JSON encoding.

deep_normalize/1 recursively converts nonempty keyword lists into an atom-keyed map, allowing keyword lists to be used anywhere a nested map is accepted in trace attributes or layout values.

Summary

Functions

Coerces bare-string 3D scene axis titles to %{text: title}.

Recursively converts keyword lists to atom-keyed maps.

Functions

coerce_scene_axis_titles(layout)

Coerces bare-string 3D scene axis titles to %{text: title}.

Call this on an already-normalized layout map (post deep_normalize/1).

Unlike 2D cartesian xaxis/yaxis, plotly.js does not default a bare string scene.xaxis.title (or scene2, scene3, …) to %{text: ...} — it silently falls back to the default "x"/"y"/"z" axis label instead of raising or rendering the given title.

deep_normalize(kw)

Recursively converts keyword lists to atom-keyed maps.

  • Nonempty keyword lists → %{atom: value} maps (recursed into)
  • Empty lists → empty arrays; use %{} for an empty object
  • Plain maps (non-struct) → values recursed into
  • Non-keyword lists → elements recursed into
  • Plotly.RawJS structs → %{"__rawjs__" => value} string-keyed maps
  • Other structs and scalars → returned as-is