Update/scales and tests#25
Update/scales and tests#25nkyllonen wants to merge 7 commits intorefactor/axis-labels-and-grid-linesfrom
Conversation
6200dee to
0212f27
Compare
0212f27 to
3e280cb
Compare
|
Now that I've thought about this again, I think: no, scales should NOT support a This is a possible way to keep the @doc """
Returns scale values for rendering labels and grid lines.
Supports a `:start` option to begin iteration from a specific value within the scale.
## Example
iex> scale_values(x_axis, step: 5)
[~D[2023-08-01], ~D[2023-08-06], ...]
iex> scale_values(x_axis, step: 5, start: ~D[2023-08-03])
[~D[2023-08-03], ~D[2023-08-08], ...]
"""
def scale_values(%{scale: scale}, opts \\ []) do
opts = Map.new(opts)
{start_value, scale_opts} = Map.pop(opts, :start)
values = Scale.values(scale, scale_opts)
case start_value do
nil ->
values
start ->
# Drop values until we reach the start point
Enum.drop_while(values, fn v -> v != start end)
end
endBenefits: ✅ Scale protocol stays pure (only step/ticks) |
After much back and forth, I don't see a way to remove the |
Currently branches off of
refactor/axis-labels-and-grid-lines. Waiting for #24 to merge first before trying to merge intophilosophical-rewrite.