Visualize.Chart.Builder.ThemeSheet (Visualize v0.8.1)

Copy Markdown View Source

The theme mode's preview sheet (spec/14 §20.3, D-139): fixed sample charts drawn through the theme being edited, and the designs a person adds from the store.

A theme is judged against everything it must serve, so the samples cover what a theme carries — the categorical series, the five roles, the thermal and diverging ramps, and axes, grid and text — and a card of the chrome's swatches. Each is drawn through the ordinary path, Visualize.Chart.apply/2 then render/2, with resolve: :literal, so the sheet shows the edited theme and no stylesheet of the host's page re-points a slot under it.

This module compiles only when Phoenix.Component is loaded (spec/10 §1.1, D-45, D-85).

Summary

Functions

The theme with every ramp it cannot draw — fewer than two anchors, an anchor that is not a color — and an empty series replaced by the default theme's, so a sheet always draws while the editor names the fault (spec/14 §20.3).

The fixed samples (spec/14 §20.3), each %{id, title, design, sources}: categorical series, a status chart in the five roles, a thermal and a diverging chart, and a titled chart of axes, grid and text.

Renders the preview sheet (spec/14 §20.3): <div class="vis-builder-theme-sheet"> of <figure class="vis-builder-theme-sample"> cards — the chrome's swatches, each fixed sample, then each design from the store with its × — and the form that adds a design.

Functions

drawable(theme)

@spec drawable(Visualize.Theme.t()) :: Visualize.Theme.t()

The theme with every ramp it cannot draw — fewer than two anchors, an anchor that is not a color — and an empty series replaced by the default theme's, so a sheet always draws while the editor names the fault (spec/14 §20.3).

iex> theme = %{Visualize.Theme.default() | ramps: %{status: ["#nope"]}, series: []}
iex> drawn = Visualize.Chart.Builder.ThemeSheet.drawable(theme)
iex> {drawn.ramps.status, drawn.series == Visualize.Theme.default().series}
{["#4ca34b", "#bd7407", "#c23238"], true}

samples()

@spec samples() :: [
  %{id: String.t(), title: String.t(), design: map(), sources: map()}
]

The fixed samples (spec/14 §20.3), each %{id, title, design, sources}: categorical series, a status chart in the five roles, a thermal and a diverging chart, and a titled chart of axes, grid and text.

sheet(assigns)

Renders the preview sheet (spec/14 §20.3): <div class="vis-builder-theme-sheet"> of <figure class="vis-builder-theme-sample"> cards — the chrome's swatches, each fixed sample, then each design from the store with its × — and the form that adds a design.

Attributes

  • id (:string) (required) - the sheet's id.
  • theme (:any) (required) - the %Visualize.Theme{} being edited.
  • designs (:list) - designs from the store, each %{id, name, design}, drawn after the samples. Defaults to [].
  • choices (:list) - the store's composites to add, {name, id} each. Defaults to [].
  • sources (:map) - the pool a stored design binds to. Defaults to %{}.
  • vars (:map) - the values a stored design's variables take. Defaults to %{}.
  • vision (:atom) - the deficiency the sheet is seen under (§20.5). Defaults to :none.
  • target (:any) - the phx-target of the sheet's events. Defaults to nil.