Zoom levels: named combinations of scales and column width.
Levels are ordered from the most detailed to the least detailed. The
default levels are :hour, :day, :week, :month, :quarter and :year.
Custom levels can be given to GanttEx.Live.Gantt through its zoom_levels
attribute:
[
%{name: :sprint, column_width: 60, scales: [[unit: :month, format: :month_year], [unit: :week, step: 2]]},
%{name: :month, column_width: 80, scales: [[unit: :year], [unit: :month]]}
]Examples
iex> levels = GanttEx.Zoom.default_levels()
iex> Enum.map(levels, & &1.name)
[:hour, :day, :week, :month, :quarter, :year]
iex> GanttEx.Zoom.zoom_in(levels, :week)
:day
iex> GanttEx.Zoom.zoom_out(levels, :year)
:year
Summary
Functions
Returns true if name can be zoomed further in the given direction.
Returns the default zoom levels.
Finds a level by name, falling back to the first level.
Validates and normalizes a list of levels, building GanttEx.Scale structs.
Returns the name of the next, more detailed level.
Returns the name of the next, less detailed level.
Types
@type level() :: %{ name: atom(), column_width: pos_integer(), scales: [GanttEx.Scale.t(), ...] }
A zoom level.
Functions
Returns true if name can be zoomed further in the given direction.
iex> GanttEx.Zoom.can_zoom?(GanttEx.Zoom.default_levels(), :hour, :in)
false
@spec default_levels() :: [level()]
Returns the default zoom levels.
Finds a level by name, falling back to the first level.
iex> GanttEx.Zoom.find(GanttEx.Zoom.default_levels(), :month).column_width
80
Validates and normalizes a list of levels, building GanttEx.Scale structs.
iex> [level] = GanttEx.Zoom.normalize!([%{name: :custom, scales: [[unit: :day]]}])
iex> {level.column_width, hd(level.scales).unit}
{60, :day}
Returns the name of the next, more detailed level.
Returns the name of the next, less detailed level.