-
Notifications
You must be signed in to change notification settings - Fork 6
Update/scales and tests #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: refactor/axis-labels-and-grid-lines
Are you sure you want to change the base?
Update/scales and tests #25
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.